Java Code Examples for org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal#hasNext()

The following examples show how to use org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal#hasNext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestGremlinCompileGraphStep.java    From sqlg with MIT License 6 votes vote down vote up
@Test
public void g_V_localXinEXknowsX_limitX2XX_outV_name() {
    loadModern();
    assertModernGraph(this.sqlgGraph, true, false);
    DefaultGraphTraversal<Vertex, String> traversal = (DefaultGraphTraversal<Vertex, String>)this.sqlgGraph.traversal()
            .V()
            .local(
                    __.inE("knows").limit(2)
            )
            .outV()
            .<String>values("name");
    Assert.assertEquals(4, traversal.getSteps().size());
    printTraversalForm(traversal);
    Assert.assertEquals(4, traversal.getSteps().size());
    int counter = 0;
    while (traversal.hasNext()) {
        counter++;
        Assert.assertEquals(traversal.next(), "marko");
    }
    Assert.assertFalse(traversal.hasNext());
    Assert.assertEquals(2, counter);
}
 
Example 2
Source File: TestGremlinCompileWithHas.java    From sqlg with MIT License 6 votes vote down vote up
@Test
public void g_VX4X_out_asXhereX_hasXlang_javaX_selectXhereX_name() {
    Graph g = this.sqlgGraph;
    loadModern(this.sqlgGraph);
    assertModernGraph(g, true, false);
    Object vertexId = convertToVertexId("josh");
    DefaultGraphTraversal<Vertex, String> traversal = (DefaultGraphTraversal<Vertex, String>) g.traversal().V(vertexId)
            .out().as("here")
            .has("lang", "java")
            .select("here").<String>values("name");
    Assert.assertEquals(5, traversal.getSteps().size());
    printTraversalForm(traversal);
    if (traversal.getSteps().size() != 3 && traversal.getSteps().size() != 4) {
        Assert.fail("expected 3 or 4 found " + traversal.getSteps().size());
    }
    int counter = 0;
    final Set<String> names = new HashSet<>();
    while (traversal.hasNext()) {
        counter++;
        names.add(traversal.next());
    }
    Assert.assertEquals(2, counter);
    Assert.assertEquals(2, names.size());
    Assert.assertTrue(names.contains("ripple"));
    Assert.assertTrue(names.contains("lop"));
}
 
Example 3
Source File: TestGremlinCompileWithHas.java    From sqlg with MIT License 6 votes vote down vote up
@Test
public void g_V_asXaX_out_asXaX_out_asXaX_selectXaX_byXunfold_valuesXnameX_foldX_rangeXlocal_1_2X() {
    loadModern();
    Graph g = this.sqlgGraph;
    assertModernGraph(g, true, false);
    DefaultGraphTraversal<Vertex, String> traversal = (DefaultGraphTraversal<Vertex, String>) g.traversal()
            .V().as("a")
            .out().as("a")
            .out().as("a")
            .<List<String>>select(Pop.all, "a")
            .by(__.unfold().values("name").fold())
            .<String>range(Scope.local, 1, 2);
    Assert.assertEquals(5, traversal.getSteps().size());
    int counter = 0;
    while (traversal.hasNext()) {
        final String s = traversal.next();
        Assert.assertEquals("josh", s);
        counter++;
    }
    Assert.assertEquals(2, counter);
    Assert.assertEquals(3, traversal.getSteps().size());
}
 
Example 4
Source File: TestGremlinCompileWithHas.java    From sqlg with MIT License 6 votes vote down vote up
@Test
public void g_V_asXaX_out_asXaX_out_asXaX_selectXaX_byXunfold_valuesXnameX_foldX_rangeXlocal_1_2X_Simple() {
    loadModern();
    Graph g = this.sqlgGraph;
    assertModernGraph(g, true, false);
    DefaultGraphTraversal<Vertex, List<Vertex>> traversal = (DefaultGraphTraversal<Vertex, List<Vertex>>) g.traversal()
            .V().as("a")
            .out().as("a")
            .out().as("a")
            .<List<Vertex>>select(Pop.all, "a");
    Assert.assertEquals(4, traversal.getSteps().size());
    printTraversalForm(traversal);
    Assert.assertEquals(2, traversal.getSteps().size());
    int counter = 0;
    while (traversal.hasNext()) {
        final List<Vertex> s = traversal.next();
        Assert.assertEquals(3, s.size());
        System.out.println(s);
        counter++;
    }
    Assert.assertEquals(2, counter);
}
 
Example 5
Source File: TestRangeLimit.java    From sqlg with MIT License 5 votes vote down vote up
@Test
public void testRangeOnVertexLabelsCriteria() {
    for (int i = 0; i < 100; i++) {
        this.sqlgGraph.addVertex(T.label, "A", "name", "a" + i, "prop0", "value");
    }
    this.sqlgGraph.tx().commit();
    DefaultGraphTraversal<Vertex, Object> g = (DefaultGraphTraversal<Vertex, Object>)this.sqlgGraph.traversal()
            .V().hasLabel("A").has("prop0", "value")
            .order().by("name")
            .range(1, 4)
            .values("name");
    Assert.assertEquals(5, g.getSteps().size());
    ensureRangeGlobal(g);
    int cnt = 0;
    Set<String> names = new HashSet<>();
    String previous = null;
    if (g.hasNext()) {
        Assert.assertEquals(2, g.getSteps().size());
        Assert.assertTrue(g.getSteps().get(0) instanceof SqlgGraphStep);
        SqlgGraphStep sqlgGraphStep = (SqlgGraphStep) g.getSteps().get(0);
        assertStep(sqlgGraphStep, true, false, false, false, true);
    }
    while (g.hasNext()) {
        String n = (String) g.next();
        names.add(n);
        if (previous != null) {
            Assert.assertTrue(previous.compareTo(n) < 0);
        }
        previous = n;
        cnt++;
    }
    ensureNoRangeGlobal(g);
    Assert.assertEquals(3, cnt);
    Assert.assertEquals(names.toString(), 3, names.size());
    Assert.assertTrue(names.toString(), names.contains("a1"));
    Assert.assertTrue(names.toString(), names.contains("a10"));
    Assert.assertTrue(names.toString(), names.contains("a11"));

}
 
Example 6
Source File: TestRangeLimit.java    From sqlg with MIT License 5 votes vote down vote up
@Test
    public void testRangeOnMultipleLabels() {
        for (int i = 0; i < 20; i++) {
            Vertex a = this.sqlgGraph.addVertex(T.label, "A", "name", "a" + i);
            Vertex b = this.sqlgGraph.addVertex(T.label, "B", "name", "b" + i);
            a.addEdge("E", b, "name", "e" + i);
        }
        this.sqlgGraph.tx().commit();
        DefaultGraphTraversal<Vertex, Object> g = (DefaultGraphTraversal<Vertex, Object>)this.sqlgGraph.traversal()
                .V().hasLabel("A", "B")
                .limit(4)
                .values("name");
        Assert.assertEquals(4, g.getSteps().size());
        ensureRangeGlobal(g);
        int cnt = 0;
        Set<String> names = new HashSet<>();
        if (g.hasNext()) {
            Assert.assertEquals(2, g.getSteps().size());
            Assert.assertTrue(g.getSteps().get(0) instanceof SqlgGraphStep);
            SqlgGraphStep sqlgGraphStep = (SqlgGraphStep) g.getSteps().get(0);
            //TODO this really should execute limit on the db and finally in the step.
            //That way less results are returned from the db
            assertStep(sqlgGraphStep, true, false, true, true, false);
        }
        while (g.hasNext()) {
            String n = (String) g.next();
            names.add(n);
            cnt++;
        }
        // we still have to cut the union result
//        ensureRangeGlobal(g);
        Assert.assertEquals(4, cnt);
        Assert.assertEquals(names.toString(), 4, names.size());

    }
 
Example 7
Source File: TestRangeLimit.java    From sqlg with MIT License 5 votes vote down vote up
@Test
    public void testRangeOnMultipleLabelsOffset() {
        for (int i = 0; i < 20; i++) {
            Vertex a = this.sqlgGraph.addVertex(T.label, "A", "name", "a" + i);
            Vertex b = this.sqlgGraph.addVertex(T.label, "B", "name", "b" + i);
            a.addEdge("E", b, "name", "e" + i);
        }
        this.sqlgGraph.tx().commit();
        DefaultGraphTraversal<Vertex, Object> g = (DefaultGraphTraversal<Vertex, Object>) this.sqlgGraph.traversal()
                .V().hasLabel("A", "B")
                .range(1, 4)
                .values("name");
        Assert.assertEquals(4, g.getSteps().size());
        ensureRangeGlobal(g);
        int cnt = 0;
        Set<String> names = new HashSet<>();
        if (g.hasNext()) {
            Assert.assertEquals(2, g.getSteps().size());
            Assert.assertTrue(g.getSteps().get(0) instanceof SqlgGraphStep);
            SqlgGraphStep sqlgGraphStep = (SqlgGraphStep) g.getSteps().get(0);
            assertStep(sqlgGraphStep, true, false, true, true, false);
        }
        while (g.hasNext()) {
            String n = (String) g.next();
            names.add(n);
            cnt++;
        }
        // cannot have offset on different labels
//        ensureRangeGlobal(g);
        Assert.assertEquals(3, cnt);
        Assert.assertEquals(names.toString(), 3, names.size());
    }
 
Example 8
Source File: TestRangeLimit.java    From sqlg with MIT License 5 votes vote down vote up
@Test
public void testRangeOnEdgeLabels() {
    for (int i = 0; i < 20; i++) {
        Vertex a = this.sqlgGraph.addVertex(T.label, "A", "name", "a" + i);
        Vertex b = this.sqlgGraph.addVertex(T.label, "B", "name", "b" + i);
        a.addEdge("E", b, "name", "e" + i);
    }
    this.sqlgGraph.tx().commit();
    DefaultGraphTraversal<Edge, Object> g = (DefaultGraphTraversal<Edge, Object>)this.sqlgGraph.traversal()
            .E().hasLabel("E")
            .order().by("name")
            .range(1, 4)
            .values("name");
    Assert.assertEquals(5, g.getSteps().size());
    ensureRangeGlobal(g);
    int cnt = 0;
    Set<String> names = new HashSet<>();
    String previous = null;
    if (g.hasNext()) {
        Assert.assertEquals(2, g.getSteps().size());
        Assert.assertTrue(g.getSteps().get(0) instanceof SqlgGraphStep);
        SqlgGraphStep sqlgGraphStep = (SqlgGraphStep) g.getSteps().get(0);
        assertStep(sqlgGraphStep, true, false, false, false, true);
    }
    while (g.hasNext()) {
        String n = (String) g.next();
        names.add(n);
        if (previous != null) {
            Assert.assertTrue(previous.compareTo(n) < 0);
        }
        previous = n;
        cnt++;
    }
    ensureNoRangeGlobal(g);
    Assert.assertEquals(3, cnt);
    Assert.assertEquals(names.toString(), 3, names.size());
    Assert.assertTrue(names.toString(), names.contains("e1"));
    Assert.assertTrue(names.toString(), names.contains("e10"));
    Assert.assertTrue(names.toString(), names.contains("e11"));
}
 
Example 9
Source File: TestRangeLimit.java    From sqlg with MIT License 5 votes vote down vote up
@Test
public void testLimitOnVertexLabels() {
    for (int i = 0; i < 20; i++) {
        this.sqlgGraph.addVertex(T.label, "A", "name", "a" + i);
    }
    this.sqlgGraph.tx().commit();
    DefaultGraphTraversal<Vertex, Object> g = (DefaultGraphTraversal<Vertex, Object>)this.sqlgGraph.traversal()
            .V().hasLabel("A")
            .order().by("name")
            .limit(3)
            .values("name");
    Assert.assertEquals(5, g.getSteps().size());
    ensureRangeGlobal(g);
    int cnt = 0;
    Set<String> names = new HashSet<>();
    String previous = null;
    if (g.hasNext()) {
        Assert.assertEquals(2, g.getSteps().size());
        Assert.assertTrue(g.getSteps().get(0) instanceof SqlgGraphStep);
        SqlgGraphStep sqlgGraphStep = (SqlgGraphStep) g.getSteps().get(0);
        assertStep(sqlgGraphStep, true, false, false, false, true);
    }
    while (g.hasNext()) {
        String n = (String) g.next();
        names.add(n);
        if (previous != null) {
            Assert.assertTrue(previous.compareTo(n) < 0);
        }
        previous = n;
        cnt++;
    }
    ensureNoRangeGlobal(g);
    Assert.assertEquals(3, cnt);
    Assert.assertEquals(names.toString(), 3, names.size());
    Assert.assertTrue(names.toString(), names.contains("a1"));
    Assert.assertTrue(names.toString(), names.contains("a10"));
    Assert.assertTrue(names.toString(), names.contains("a0"));
}
 
Example 10
Source File: TestRangeLimit.java    From sqlg with MIT License 5 votes vote down vote up
@Test
public void testRangeOnVertexLabelsNoOrder() {
    for (int i = 0; i < 20; i++) {
        this.sqlgGraph.addVertex(T.label, "A", "name", "a" + i);
    }
    this.sqlgGraph.tx().commit();
    DefaultGraphTraversal<Vertex, Object> g = (DefaultGraphTraversal<Vertex, Object>)this.sqlgGraph.traversal()
            .V().hasLabel("A")
            .range(1, 4)
            .values("name");
    Assert.assertEquals(4, g.getSteps().size());
    ensureRangeGlobal(g);
    int cnt = 0;
    Set<String> names = new HashSet<>();
    if (g.hasNext()) {
        Assert.assertEquals(2, g.getSteps().size());
        Assert.assertTrue(g.getSteps().get(0) instanceof SqlgGraphStep);
        SqlgGraphStep sqlgGraphStep = (SqlgGraphStep) g.getSteps().get(0);
        assertStep(sqlgGraphStep, true, false, false, true, true);
    }
    while (g.hasNext()) {
        String n = (String) g.next();
        names.add(n);
        cnt++;
    }
    ensureNoRangeGlobal(g);
    Assert.assertEquals(3, cnt);
    Assert.assertEquals(names.toString(), 3, names.size());
}
 
Example 11
Source File: TestGremlinCompileGraphStep.java    From sqlg with MIT License 5 votes vote down vote up
@Test
public void g_V_asXaX_outXcreatedX_inXcreatedX_whereXneqXaXX_asXbX_selectXa_bX_addInEXa_codeveloper_b_year_2009X() throws InterruptedException {
    Graph g = this.sqlgGraph;
    loadModern(this.sqlgGraph);
    assertModernGraph(g, true, false);
    DefaultGraphTraversal<Vertex, Edge> traversal = (DefaultGraphTraversal<Vertex, Edge>) this.sqlgGraph.traversal()
            .V().as("a")
            .out("created")
            .in("created")
            .where(P.neq("a")).as("b")
            .select("a", "b")
            .addE("co-developer").property("year", 2009).from("a").to("b");
    Assert.assertEquals(6, traversal.getSteps().size());
    printTraversalForm(traversal);
    int count = 0;
    while (traversal.hasNext()) {
        final Edge edge = traversal.next();
        Assert.assertEquals("co-developer", edge.label());
        Assert.assertEquals(2009, (int) edge.value("year"));
        Assert.assertEquals(1, IteratorUtils.count(edge.properties()));
        Assert.assertEquals("person", edge.inVertex().label());
        Assert.assertEquals("person", edge.outVertex().label());
        Assert.assertFalse(edge.inVertex().value("name").equals("vadas"));
        Assert.assertFalse(edge.outVertex().value("name").equals("vadas"));
        Assert.assertFalse(edge.inVertex().equals(edge.outVertex()));
        count++;
    }
    Assert.assertEquals(4, traversal.getSteps().size());
    Assert.assertEquals(6, count);
    Assert.assertEquals(12, IteratorUtils.count(this.sqlgGraph.edges()));
    Assert.assertEquals(6, IteratorUtils.count(this.sqlgGraph.vertices()));
    this.sqlgGraph.tx().commit();
    if (this.sqlgGraph1 != null) {
        Thread.sleep(SLEEP_TIME);
        Assert.assertEquals(12, IteratorUtils.count(this.sqlgGraph1.edges()));
        Assert.assertEquals(6, IteratorUtils.count(this.sqlgGraph1.vertices()));
    }
}
 
Example 12
Source File: TestRangeLimit.java    From sqlg with MIT License 5 votes vote down vote up
@Test
public void testRangeOnVertexLabels() {
    for (int i = 0; i < 100; i++) {
        this.sqlgGraph.addVertex(T.label, "A", "name", "a" + i);
    }
    this.sqlgGraph.tx().commit();
    DefaultGraphTraversal<Vertex, Object> g = (DefaultGraphTraversal<Vertex, Object>)this.sqlgGraph.traversal()
            .V().hasLabel("A")
            .order().by("name")
            .range(1, 4).values("name");
    Assert.assertEquals(5, g.getSteps().size());
    ensureRangeGlobal(g);
    int cnt = 0;
    Set<String> names = new HashSet<>();
    String previous = null;
    if (g.hasNext()) {
        Assert.assertEquals(2, g.getSteps().size());
        Assert.assertTrue(g.getSteps().get(0) instanceof SqlgGraphStep);
        SqlgGraphStep sqlgGraphStep = (SqlgGraphStep) g.getSteps().get(0);
        assertStep(sqlgGraphStep, true, false, false, false, true);
    }
    while (g.hasNext()) {
        String n = (String) g.next();
        names.add(n);
        if (previous != null) {
            Assert.assertTrue(previous.compareTo(n) < 0);
        }
        previous = n;
        cnt++;
    }
    ensureNoRangeGlobal(g);
    Assert.assertEquals(3, cnt);
    Assert.assertEquals(names.toString(), 3, names.size());
    Assert.assertTrue(names.toString(), names.contains("a1"));
    Assert.assertTrue(names.toString(), names.contains("a10"));
    Assert.assertTrue(names.toString(), names.contains("a11"));

}
 
Example 13
Source File: TestGremlinCompileWithHas.java    From sqlg with MIT License 5 votes vote down vote up
@Test
public void g_VX1X_outE_hasXweight_inside_0_06X_inV() {
    Graph g = this.sqlgGraph;
    loadModern(this.sqlgGraph);
    assertModernGraph(g, true, false);
    DefaultGraphTraversal<Vertex, Vertex> traversal = (DefaultGraphTraversal<Vertex, Vertex>) get_g_VX1X_outE_hasXweight_inside_0_06X_inV(g.traversal(), convertToVertexId("marko"));
    Assert.assertEquals(4, traversal.getSteps().size());
    printTraversalForm(traversal);
    Assert.assertEquals(1, traversal.getSteps().size());
    while (traversal.hasNext()) {
        Vertex vertex = traversal.next();
        Assert.assertTrue(vertex.value("name").equals("vadas") || vertex.value("name").equals("lop"));
    }
    Assert.assertFalse(traversal.hasNext());
}
 
Example 14
Source File: TestGremlinCompileWithHas.java    From sqlg with MIT License 5 votes vote down vote up
@Test
public void g_V_out_outE_inV_inE_inV_both_name() {
    Graph g = this.sqlgGraph;
    loadModern(this.sqlgGraph);
    assertModernGraph(g, true, false);

    Object id = convertToVertexId(g, "marko");
    DefaultGraphTraversal<Vertex, String> traversal = (DefaultGraphTraversal<Vertex, String>) g.traversal().V(id).out().outE().inV().inE().inV().both().<String>values("name");
    Assert.assertEquals(8, traversal.getSteps().size());
    printTraversalForm(traversal);
    Assert.assertEquals(2, traversal.getSteps().size());
    int counter = 0;
    final Map<String, Integer> counts = new HashMap<>();
    while (traversal.hasNext()) {
        final String key = traversal.next();
        final int previousCount = counts.getOrDefault(key, 0);
        counts.put(key, previousCount + 1);
        counter++;
    }
    Assert.assertEquals(3, counts.size());
    Assert.assertEquals(4, counts.get("josh").intValue());
    Assert.assertEquals(3, counts.get("marko").intValue());
    Assert.assertEquals(3, counts.get("peter").intValue());

    Assert.assertEquals(10, counter);
    Assert.assertFalse(traversal.hasNext());
}
 
Example 15
Source File: TestRangeLimit.java    From sqlg with MIT License 4 votes vote down vote up
@Test
    public void testRangeOnMultipleLabelsOrdered() {
        Vertex c = this.sqlgGraph.addVertex(T.label, "C", "name", "c" + 12);
        for (int i = 0; i < 20; i++) {
            Vertex a = this.sqlgGraph.addVertex(T.label, "A", "name", "a" + i);
            Vertex b = this.sqlgGraph.addVertex(T.label, "B", "name", "b" + i);
            a.addEdge("E", b, "name", "e" + i);
        }
        this.sqlgGraph.tx().commit();
        DefaultGraphTraversal<Vertex, Object> g = (DefaultGraphTraversal<Vertex, Object>)this.sqlgGraph.traversal()
                .V().hasLabel("A", "B")
                .order().by("name")
                .range(1, 4)
                .values("name");
        Assert.assertEquals(5, g.getSteps().size());
        ensureRangeGlobal(g);
        int cnt = 0;
        Set<String> names = new HashSet<>();
        String previous = null;
        if (g.hasNext()) {
            Assert.assertEquals(2, g.getSteps().size());
            Assert.assertTrue(g.getSteps().get(0) instanceof SqlgGraphStep);
            SqlgGraphStep sqlgGraphStep = (SqlgGraphStep) g.getSteps().get(0);
            assertStep(sqlgGraphStep, true, true, true, true, false);
        }
        while (g.hasNext()) {
            String n = (String) g.next();
            names.add(n);
            if (previous != null) {
                Assert.assertTrue(previous.compareTo(n) < 0);
            }
            previous = n;
            cnt++;
        }
        // order by on multiple labels is not done in SQL, so the range isn't
//        ensureRangeGlobal(g);
        Assert.assertEquals(3, cnt);
        Assert.assertEquals(names.toString(), 3, names.size());
        Assert.assertTrue(names.toString(), names.contains("a1"));
        Assert.assertTrue(names.toString(), names.contains("a10"));
        Assert.assertTrue(names.toString(), names.contains("a11"));

    }
 
Example 16
Source File: TestRangeLimit.java    From sqlg with MIT License 4 votes vote down vote up
@Test
    public void testRangeOnMultipleLabelsOrderedWithSkip() {
        Vertex c = this.sqlgGraph.addVertex(T.label, "C", "name", "c" + 12);
        for (int i = 0; i < 20; i++) {
            Vertex a = this.sqlgGraph.addVertex(T.label, "A", "name", "a" + i);
            Vertex b = this.sqlgGraph.addVertex(T.label, "B", "name", "b" + i);
            a.addEdge("E", b, "name", "e" + i);
        }
        this.sqlgGraph.tx().commit();
        DefaultGraphTraversal<Vertex, Object> g = (DefaultGraphTraversal<Vertex, Object>)this.sqlgGraph.traversal()
                .V().hasLabel("A", "B")
                .order().by("name")
                .skip(2)
                .values("name");
        Assert.assertEquals(5, g.getSteps().size());
        ensureRangeGlobal(g);
        int cnt = 0;
        Set<String> names = new HashSet<>();
        String previous = null;
        if (g.hasNext()) {
            Assert.assertEquals(2, g.getSteps().size());
            Assert.assertTrue(g.getSteps().get(0) instanceof SqlgGraphStep);
            SqlgGraphStep sqlgGraphStep = (SqlgGraphStep) g.getSteps().get(0);
            assertStep(sqlgGraphStep, true, true, true, true, false);
        }
        while (g.hasNext()) {
            String n = (String) g.next();
            names.add(n);
            if (previous != null) {
                Assert.assertTrue(previous.compareTo(n) < 0);
            }
            previous = n;
            cnt++;
        }
        // order by on multiple labels is not done in SQL, so the range isn't
//        ensureRangeGlobal(g);
        Assert.assertEquals(38, cnt);
        Assert.assertEquals(names.toString(), 38, names.size());
        Assert.assertTrue(names.toString(), !names.contains("a0"));
        Assert.assertTrue(names.toString(), !names.contains("a1"));

    }
 
Example 17
Source File: TestRangeLimit.java    From sqlg with MIT License 4 votes vote down vote up
@Test
public void testRangeOnEdgesOutput() {
    Vertex a = this.sqlgGraph.addVertex(T.label, "A", "name", "a0");

    for (int i = 0; i < 20; i++) {
        Vertex b = this.sqlgGraph.addVertex(T.label, "B", "name", "b" + i);
        a.addEdge("E", b, "name", "e" + i);
    }
    this.sqlgGraph.tx().commit();
    DefaultGraphTraversal<Vertex, Object> g = (DefaultGraphTraversal<Vertex, Object>)this.sqlgGraph.traversal()
            .V(a)
            .out("E")
            .order().by("name")
            .range(1, 4)
            .values("name");
    Assert.assertEquals(5, g.getSteps().size());
    ensureRangeGlobal(g);
    int cnt = 0;
    Set<String> names = new HashSet<>();
    String previous = null;
    if (g.hasNext()) {
        Assert.assertEquals(2, g.getSteps().size());
        Assert.assertTrue(g.getSteps().get(0) instanceof SqlgGraphStep);
        SqlgGraphStep sqlgGraphStep = (SqlgGraphStep) g.getSteps().get(0);
        assertStep(sqlgGraphStep, true, false, false, false, true);
    }
    while (g.hasNext()) {
        String n = (String) g.next();
        names.add(n);
        if (previous != null) {
            Assert.assertTrue(previous.compareTo(n) < 0);
        }
        previous = n;
        cnt++;
    }
    ensureNoRangeGlobal(g);
    Assert.assertEquals(3, cnt);
    Assert.assertEquals(names.toString(), 3, names.size());
    Assert.assertTrue(names.toString(), names.contains("b1"));
    Assert.assertTrue(names.toString(), names.contains("b10"));
    Assert.assertTrue(names.toString(), names.contains("b11"));

}