@Test
    @LoadGraphWith(MODERN)
    public void g_V_connectedComponent_withXEDGES_bothEXknowsXX_withXPROPERTY_NAME_clusterX_project_byXnameX_byXclusterX() {
        final Traversal<Vertex, Map<String,Object>> traversal = get_g_V_connectedComponent_withXedges_bothEXknowsXX_withXpropertyName_clusterX_project_byXnameX_byXclusterX();
        printTraversalForm(traversal);
        int counter = 0;

        String softwareComponent = null;

        // sort to make sure that "peter" is always last
        final Iterator<Map<String,Object>> itty = traversal.toList().stream().sorted((o1, o2) -> o1.get("name").toString().equals("peter") ? 1 : -1).iterator();

        while (itty.hasNext()) {
            final Map<String,Object> m = itty.next();
            final String name = m.get("name").toString();

            // since the three of the returned values are in the same component just need to grab the first one and
            // use that as a comparison to the others and then for the fourth returned item "peter" just needs to not
            // be in the same component
            if (null == softwareComponent)
                softwareComponent = m.get("cluster").toString();

            assertNotNull(softwareComponent);

            switch (name) {
                case "marko":
                case "vadas":
                case "josh":
                    counter++;
                    assertEquals(softwareComponent, m.get("cluster"));
                    break;
                case "peter":
                    counter++;
                    assertNotEquals(softwareComponent, m.get("cluster"));
                    break;
            }
        }
        assertEquals(4, counter);
    }
@author Stephen Mallette (http://stephen.genoprime.com)
gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/ConnectedComponentTest.java