org.apache.tinkerpop.gremlin.process.traversal.Traversal Java Examples

The following examples show how to use org.apache.tinkerpop.gremlin.process.traversal.Traversal. 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: AddEdgeTest.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
@FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
public void g_V_asXaX_inXcreatedX_addEXcreatedByX_fromXaX_propertyXyear_2009X_propertyXacl_publicX() {
    final Traversal<Vertex, Edge> traversal = get_g_V_asXaX_inXcreatedX_addEXcreatedByX_fromXaX_propertyXyear_2009X_propertyXacl_publicX();
    printTraversalForm(traversal);
    int count = 0;
    while (traversal.hasNext()) {
        final Edge edge = traversal.next();
        assertEquals("createdBy", edge.label());
        assertEquals(2009, g.E(edge).values("year").next());
        assertEquals("public", g.E(edge).values("acl").next());
        assertEquals(2, g.E(edge).properties().count().next().intValue());
        assertEquals("person", g.E(edge).inV().label().next());
        assertEquals("software", g.E(edge).outV().label().next());
        if (g.E(edge).outV().values("name").next().equals("ripple"))
            assertEquals("josh", g.E(edge).inV().values("name").next());
        count++;

    }
    assertEquals(4, count);
    assertEquals(10, IteratorUtils.count(g.E()));
    assertEquals(6, IteratorUtils.count(g.V()));
}
 
Example #2
Source File: TestGroupCount.java    From sqlg with MIT License 6 votes vote down vote up
@Test
    public void g_V_both_groupCountXaX_out_capXaX_selectXkeysX_unfold_both_groupCountXaX_capXaX() {
        loadModern();

        final Traversal<Vertex, Map<Vertex, Long>> traversal = this.sqlgGraph.traversal().V().both().groupCount("a").out().cap("a").select(Column.keys).unfold().both().groupCount("a").cap("a");
        printTraversalForm(traversal);
        //  [{v[1]=6, v[2]=2, v[3]=6, v[4]=6, v[5]=2, v[6]=2}]
        final Map<Vertex, Long> map = traversal.next();
        assertFalse(traversal.hasNext());
        assertEquals(6, map.size());
        assertEquals(6l, map.get(convertToVertex(this.sqlgGraph, "marko")).longValue());
        assertEquals(2l, map.get(convertToVertex(this.sqlgGraph, "vadas")).longValue());
        assertEquals(6l, map.get(convertToVertex(this.sqlgGraph, "lop")).longValue());
        assertEquals(6l, map.get(convertToVertex(this.sqlgGraph, "josh")).longValue());
        assertEquals(2l, map.get(convertToVertex(this.sqlgGraph, "ripple")).longValue());
        assertEquals(6l, map.get(convertToVertex(this.sqlgGraph, "marko")).longValue());
//        checkSideEffects(traversal.asAdmin().getSideEffects(), "a", HashMap.class);
    }
 
Example #3
Source File: MatchStepTest.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Test
public void testPreCompilationOfWherePredicate() {
    final List<Traversal.Admin<?, ?>> traversals = Arrays.asList(
            __.match(as("a").out().as("b"), as("c").where(P.neq("d"))).asAdmin(),
            __.match(as("a").out().as("b"), where("c", P.neq("d"))).asAdmin());
    assertEquals(1, new HashSet<>(traversals).size()); // the two patterns should pre-compile to the same traversal
    traversals.forEach(traversal -> {
        final MatchStep<?, ?> matchStep = (MatchStep<?, ?>) traversal.getStartStep();
        //assertFalse(matchStep.getStartLabel().isPresent());
        assertEquals(2, matchStep.getGlobalChildren().size());
        Traversal.Admin<Object, Object> pattern = matchStep.getGlobalChildren().get(0);
        assertEquals("a", ((MatchStep.MatchStartStep) pattern.getStartStep()).getSelectKey().get());
        assertEquals(VertexStep.class, pattern.getStartStep().getNextStep().getClass());
        assertEquals("b", ((MatchStep.MatchEndStep) pattern.getEndStep()).getMatchKey().get());
        //
        pattern = matchStep.getGlobalChildren().get(1);
        assertEquals(MatchStep.MatchStartStep.class, pattern.getStartStep().getClass());
        assertEquals("c", ((MatchStep.MatchStartStep) pattern.getStartStep()).getSelectKey().get());
        assertEquals(WherePredicateStep.class, pattern.getStartStep().getNextStep().getClass());
        assertEquals(MatchStep.MatchEndStep.class, pattern.getStartStep().getNextStep().getNextStep().getClass());
        assertFalse(((WherePredicateStep<?>) pattern.getStartStep().getNextStep()).getStartKey().isPresent());
        assertEquals("d", ((WherePredicateStep<?>) pattern.getStartStep().getNextStep()).getPredicate().get().getOriginalValue());
    });
}
 
Example #4
Source File: GroupTest.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_V_group_byXoutE_countX_byXnameX() {
    final Traversal<Vertex, Map<Long, Collection<String>>> traversal = get_g_V_group_byXoutE_countX_byXnameX();
    printTraversalForm(traversal);
    assertTrue(traversal.hasNext());
    final Map<Long, Collection<String>> map = traversal.next();
    assertFalse(traversal.hasNext());
    assertEquals(4, map.size());
    assertTrue(map.containsKey(0l));
    assertTrue(map.containsKey(1l));
    assertTrue(map.containsKey(2l));
    assertTrue(map.containsKey(3l));
    assertEquals(3, map.get(0l).size());
    assertEquals(1, map.get(1l).size());
    assertEquals(1, map.get(2l).size());
    assertEquals(1, map.get(3l).size());
    assertTrue(map.get(0l).contains("lop"));
    assertTrue(map.get(0l).contains("ripple"));
    assertTrue(map.get(0l).contains("vadas"));
    assertTrue(map.get(1l).contains("peter"));
    assertTrue(map.get(2l).contains("josh"));
    assertTrue(map.get(3l).contains("marko"));
    checkSideEffects(traversal.asAdmin().getSideEffects());
}
 
Example #5
Source File: TestTraversalAddV.java    From sqlg with MIT License 6 votes vote down vote up
@Test
public void g_addV_asXfirstX_repeatXaddEXnextX_toXaddVX_inVX_timesX5X_addEXnextX_toXselectXfirstXX() {
    final Traversal<Vertex, Edge> traversal = this.sqlgGraph.traversal()
            .addV().as("first")
            .repeat(
                    __.addE("next").to(__.addV()).inV()).times(5)
            .addE("next")
            .to(__.select("first"));
    printTraversalForm(traversal);
    Assert.assertEquals("next", traversal.next().label());
    Assert.assertFalse(traversal.hasNext());
    Assert.assertEquals(6L, this.sqlgGraph.traversal().V().count().next().longValue());
    Assert.assertEquals(6L, this.sqlgGraph.traversal().E().count().next().longValue());
    Assert.assertEquals(Arrays.asList(2L, 2L, 2L, 2L, 2L, 2L), this.sqlgGraph.traversal().V().map(__.bothE().count()).toList());
    Assert.assertEquals(Arrays.asList(1L, 1L, 1L, 1L, 1L, 1L), this.sqlgGraph.traversal().V().map(__.inE().count()).toList());
    Assert.assertEquals(Arrays.asList(1L, 1L, 1L, 1L, 1L, 1L), this.sqlgGraph.traversal().V().map(__.outE().count()).toList());
}
 
Example #6
Source File: TraversalHelperTest.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldIdentifyGlobalChildren() {
    final Traversal.Admin<?, ?> globalChild = __.select("a", "b").by("name").asAdmin();
    TraversalParent parent = new RepeatStep<>(new DefaultTraversal());
    ((RepeatStep) parent).setRepeatTraversal(globalChild);
    assertTrue(TraversalHelper.isGlobalChild(globalChild));
    ///
    new UnionStep<>(new DefaultTraversal(), globalChild);
    assertTrue(TraversalHelper.isGlobalChild(globalChild));
    ///
    new TraversalVertexProgramStep(new DefaultTraversal<>(), globalChild);
    assertTrue(TraversalHelper.isGlobalChild(globalChild));
    ///
    final Traversal.Admin<?, ?> remoteRemoteChild = __.repeat(globalChild).asAdmin();
    new UnionStep<>(new DefaultTraversal(), remoteRemoteChild);
    assertTrue(TraversalHelper.isGlobalChild(globalChild));
}
 
Example #7
Source File: IsTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_V_valuesXageX_isXlte_30X() {
    final Traversal<Vertex, Integer> traversal = get_g_V_valuesXageX_isXlte_30X();
    printTraversalForm(traversal);
    checkResults(Arrays.asList(27, 29), traversal);
}
 
Example #8
Source File: PeerPressureTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_V_peerPressure_hasXclusterX() {
    final Traversal<Vertex, Vertex> traversal = get_g_V_peerPressure_hasXclusterX();
    printTraversalForm(traversal);
    assertEquals(6, IteratorUtils.count(traversal));
}
 
Example #9
Source File: CountTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_V_count() {
    final Traversal<Vertex, Long> traversal = get_g_V_count();
    printTraversalForm(traversal);
    assertEquals(new Long(6), traversal.next());
    assertFalse(traversal.hasNext());
}
 
Example #10
Source File: WhereTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_VX1X_asXaX_outXcreatedX_inXcreatedX_asXbX_whereXa_neqXbXX_name() {
    final Traversal<Vertex, String> traversal = get_g_VX1X_asXaX_outXcreatedX_inXcreatedX_asXbX_whereXa_neqXbXX_name(convertToVertexId(graph, "marko"));
    printTraversalForm(traversal);
    checkResults(Arrays.asList("josh", "peter"), traversal);
}
 
Example #11
Source File: AddEdgeTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
@FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
public void g_addEXV_outE_label_groupCount_orderXlocalX_byXvalues_descX_selectXkeysX_unfold_limitX1XX_fromXV_hasXname_vadasXX_toXV_hasXname_lopXX() {
    final Traversal<Edge, Edge> traversal = get_g_addEXV_outE_label_groupCount_orderXlocalX_byXvalues_descX_selectXkeysX_unfold_limitX1XX_fromXV_hasXname_vadasXX_toXV_hasXname_lopXX();
    printTraversalForm(traversal);
    final Edge edge = traversal.next();
    assertFalse(traversal.hasNext());
    assertEquals("created", edge.label());
    assertEquals(convertToVertexId("vadas"), edge.outVertex().id());
    assertEquals(convertToVertexId("lop"), edge.inVertex().id());
    assertEquals(6L, g.V().count().next().longValue());
    assertEquals(7L, g.E().count().next().longValue());
}
 
Example #12
Source File: SqlgOrStepBarrier.java    From sqlg with MIT License 5 votes vote down vote up
@Override
protected boolean filter(final Traverser.Admin<S> traverser) {
    for (final Traversal.Admin<S, ?> traversal : this.traversals) {
        if (TraversalUtil.test(traverser, traversal))
            return true;
    }
    return false;
}
 
Example #13
Source File: VertexTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
private void assert_g_v1_outXknowsX(final Traversal<Vertex, Vertex> traversal) {
    printTraversalForm(traversal);
    int counter = 0;
    final Set<Vertex> vertices = new HashSet<>();
    while (traversal.hasNext()) {
        counter++;
        final Vertex vertex = traversal.next();
        vertices.add(vertex);
        assertTrue(vertex.value("name").equals("vadas") ||
                vertex.value("name").equals("josh"));
    }
    assertEquals(2, counter);
    assertEquals(2, vertices.size());
}
 
Example #14
Source File: PropertiesTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_V_hasXageX_properties_hasXid_nameIdX_value() {
    final Traversal<Vertex, Object> traversal = get_g_V_hasXageX_properties_hasXid_nameIdX_value(convertToVertexPropertyId("marko", "name").next());
    printTraversalForm(traversal);
    checkResults(Collections.singletonList("marko"), traversal);
}
 
Example #15
Source File: VertexTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_VX4X_bothE_hasXweight_lt_1X_otherV() {
    final Traversal<Vertex, Vertex> traversal = get_g_VX4X_bothE_hasXweight_lt_1X_otherV(convertToVertexId("josh"));
    printTraversalForm(traversal);
    final List<Vertex> vertices = traversal.toList();
    assertEquals(1, vertices.size());
    assertEquals(vertices.get(0).value("name"), "lop");
    assertFalse(traversal.hasNext());
}
 
Example #16
Source File: WriteTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
@FeatureRequirement(featureClass = Graph.Features.GraphFeatures.class, feature = Graph.Features.GraphFeatures.FEATURE_IO_WRITE)
public void g_io_writeXjsonX() throws IOException {
    final String fileToWrite = TestHelper.generateTempFile(WriteTest.class,"tinkerpop-modern-v3d0", ".json").getAbsolutePath().replace('\\', '/');

    final File f = new File(fileToWrite);
    assertThat(f.length() == 0, is(true));

    final Traversal<Object,Object> traversal = get_g_io_writeXjsonX(fileToWrite);
    printTraversalForm(traversal);
    traversal.iterate();

    assertThat(f.length() > 0, is(true));
}
 
Example #17
Source File: TestPropertyValues.java    From sqlg with MIT License 5 votes vote down vote up
@Test
public void testOptimizePastSelect() {
    Vertex a1 = this.sqlgGraph.addVertex(T.label, "A", "name", "a1");
    Vertex a2 = this.sqlgGraph.addVertex(T.label, "A", "name", "a2");
    Vertex b1 = this.sqlgGraph.addVertex(T.label, "B", "name", "b1");
    Vertex b2 = this.sqlgGraph.addVertex(T.label, "B", "name", "b2");
    Vertex c1 = this.sqlgGraph.addVertex(T.label, "C", "name", "c1");
    Vertex c2 = this.sqlgGraph.addVertex(T.label, "C", "name", "c2");
    Vertex d1 = this.sqlgGraph.addVertex(T.label, "D", "name", "d1", "surname", "s1");
    Vertex d2 = this.sqlgGraph.addVertex(T.label, "D", "name", "d2", "surname", "s2");
    a1.addEdge("ab", b1);
    a2.addEdge("ab", b2);
    b1.addEdge("bc", c1);
    b2.addEdge("bc", c2);
    c1.addEdge("cd", d1);
    c2.addEdge("cd", d2);
    this.sqlgGraph.tx().commit();

    Traversal<Vertex, String> traversal = this.sqlgGraph.traversal()
            .V().hasLabel("C")
            .has("name", "c2")
            .as("c")
            .in("bc")
            .in("ab")
            .has("name", "a2")
            .select("c")
            .out("cd")
            .has("name", "d2")
            .values("surname");

    printTraversalForm(traversal);
    List<String> surnames = traversal.toList();
    Assert.assertEquals(1, surnames.size());
    Assert.assertEquals("s2", surnames.get(0));
    checkRestrictedProperties(SqlgVertexStep.class, traversal, 0, "surname");
}
 
Example #18
Source File: JanusGraphTraversalUtil.java    From grakn with GNU Affero General Public License v3.0 5 votes vote down vote up
private static void getMultiQueryCompatibleStepsFromChildTraversal(Traversal.Admin<?, ?> childTraversal, Step parentStep, Set<Step> multiQueryCompatibleSteps) {
    Step firstStep = childTraversal.getStartStep();
    while (firstStep instanceof StartStep || firstStep instanceof SideEffectStep) {
        // Want the next step if this is a side effect
        firstStep = firstStep.getNextStep();
    }
    if (firstStep.getClass().isAssignableFrom(VertexStep.class)) {
        multiQueryCompatibleSteps.add(parentStep);
    }
}
 
Example #19
Source File: TailTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
/**
 * Scenario: Global scope, using repeat (BULK)
 */
@Test
@LoadGraphWith(MODERN)
public void g_V_repeatXbothX_timesX3X_tailX7X() {
    final Traversal<Vertex, Vertex> traversal = get_g_V_repeatXbothX_timesX3X_tailX7X();
    printTraversalForm(traversal);
    int counter = 0;
    while (traversal.hasNext()) {
        traversal.next();
        counter++;
    }
    assertEquals(7, counter);
}
 
Example #20
Source File: WhereTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_V_asXaX_outXcreatedX_inXcreatedX_asXbX_whereXa_gtXbXX_byXageX_selectXa_bX_byXnameX() {
    final Traversal<Vertex, Map<String, String>> traversal = get_g_V_asXaX_outXcreatedX_inXcreatedX_asXbX_whereXa_gtXbXX_byXageX_selectXa_bX_byXnameX();
    printTraversalForm(traversal);
    checkResults(makeMapList(2,
            "a", "peter", "b", "josh",
            "a", "peter", "b", "marko",
            "a", "josh", "b", "marko"), traversal);
}
 
Example #21
Source File: GroupCountTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
private static void assertCommonB(final Traversal<Vertex, Map<String, Long>> traversal) {
    final Map<String, Long> map = traversal.next();
    assertEquals(map.size(), 2);
    assertEquals(3l, map.get("lop").longValue());
    assertEquals(1l, map.get("ripple").longValue());
    assertFalse(traversal.hasNext());
}
 
Example #22
Source File: ProfileTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_V_repeat_both_profileXmetricsX() {
    final Traversal<Vertex, Vertex> traversal = get_g_V_repeatXbothX_timesX3X_profileXmetricsX();
    printTraversalForm(traversal);
    traversal.iterate();
    final TraversalMetrics traversalMetrics = traversal.asAdmin().getSideEffects().get(METRICS_KEY);
    validate_g_V_repeat_both_modern_profile(traversalMetrics,
            traversal.asAdmin().getStrategies().getStrategy(RepeatUnrollStrategy.class).isPresent() &&
                    !traversal.asAdmin().getStrategies().getStrategy(ComputerVerificationStrategy.class).isPresent());
}
 
Example #23
Source File: SelectTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_V_valueMap_selectXlast_a_bX() {
    final Traversal<Vertex, Map<String, Object>> traversal = get_g_V_valueMap_selectXlast_a_bX();
    printTraversalForm(traversal);
    assertEquals(Collections.emptyList(), traversal.toList());
}
 
Example #24
Source File: StoreTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
public void g_VX1X_storeXaX_byXnameX_out_storeXaX_byXnameX_name_capXaX() {
    final Traversal<Vertex, Collection> traversal = get_g_VX1X_storeXaX_byXnameX_out_storeXaX_byXnameX_name_capXaX(convertToVertexId("marko"));
    printTraversalForm(traversal);
    final Collection names = traversal.next();
    assertEquals(4, names.size());
    assertTrue(names.contains("marko"));
    assertTrue(names.contains("josh"));
    assertTrue(names.contains("vadas"));
    assertTrue(names.contains("lop"));
    assertFalse(traversal.hasNext());
}
 
Example #25
Source File: OrderTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(GRATEFUL)
public void g_V_hasLabelXsongX_order_byXperformances_descX_byXnameX_rangeX110_120X_name() {
    final Traversal<Vertex, String> traversal = get_g_V_hasLabelXsongX_order_byXperformances_descX_byXnameX_rangeX110_120X_name();
    printTraversalForm(traversal);
    checkOrderedResults(Arrays.asList(
            "WANG DANG DOODLE", "THE ELEVEN", "WAY TO GO HOME", "FOOLISH HEART",
            "GIMME SOME LOVING", "DUPREES DIAMOND BLUES", "CORRINA", "PICASSO MOON",
            "KNOCKING ON HEAVENS DOOR", "MEMPHIS BLUES"), traversal);
}
 
Example #26
Source File: EdgeVertexStepTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
protected List<Traversal> getTraversals() {
    return Arrays.asList(
            __.inV(),
            __.outV(),
            __.bothV()
    );
}
 
Example #27
Source File: SqlgTraversalFilterStepStrategy.java    From sqlg with MIT License 5 votes vote down vote up
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
    //Only optimize SqlgGraph. StarGraph also passes through here.
    if (!(traversal.getGraph().orElseThrow(IllegalStateException::new) instanceof SqlgGraph)) {
        return;
    }
    if (!SqlgTraversalUtil.mayOptimize(traversal)) {
        return;
    }
    List<TraversalFilterStep> traversalFilterSteps = TraversalHelper.getStepsOfAssignableClass(TraversalFilterStep.class, traversal);
    for (@SuppressWarnings("unchecked") TraversalFilterStep<S> traversalFilterStep : traversalFilterSteps) {

        List<Traversal.Admin<S, ?>> filterTraversals = traversalFilterStep.getLocalChildren();
        Preconditions.checkState(filterTraversals.size() == 1);
        Traversal.Admin<S, ?> filterTraversal = filterTraversals.get(0);

        //reducing barrier steps like count does not work with Sqlg's barrier optimizations
        List<ReducingBarrierStep> reducingBarrierSteps = TraversalHelper.getStepsOfAssignableClassRecursively(ReducingBarrierStep.class, filterTraversal);
        if (!reducingBarrierSteps.isEmpty()) {
            continue;
        }

        SqlgTraversalFilterStepBarrier sqlgTraversalFilterStepBarrier = new SqlgTraversalFilterStepBarrier<>(
                traversal,
                filterTraversal
        );
        for (String label : traversalFilterStep.getLabels()) {
            sqlgTraversalFilterStepBarrier.addLabel(label);
        }
        //noinspection unchecked
        TraversalHelper.replaceStep(
                traversalFilterStep,
                sqlgTraversalFilterStepBarrier,
                traversalFilterStep.getTraversal()
        );
    }
}
 
Example #28
Source File: ByModulatorOptimizationStrategy.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
private void optimizeByModulatingTraversal(final TraversalParent step, final Traversal.Admin<?, ?> traversal) {
    if (traversal == null) return;
    final List<Step> steps = traversal.asAdmin().getSteps();
    if (steps.size() == 1) {
        final Step singleStep = steps.get(0);
        optimizeForStep(step, traversal, singleStep);
    }
}
 
Example #29
Source File: TailTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
/**
 * Scenario: Local scope, List input, N=1
 */
@Test
@LoadGraphWith(MODERN)
public void g_V_asXaX_out_asXaX_out_asXaX_selectXmixed_aX_byXunfold_valuesXnameX_foldX_tailXlocal_1X() {
    final Traversal<Vertex, String> traversal = get_g_V_asXaX_out_asXaX_out_asXaX_selectXmixed_aX_byXunfold_valuesXnameX_foldX_tailXlocal_1X();
    printTraversalForm(traversal);
    final Set<String> expected = new HashSet(Arrays.asList("ripple", "lop"));
    final Set<String> actual = new HashSet(traversal.toList());
    assertEquals(expected, actual);
}
 
Example #30
Source File: TraversalHelperTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldAddStepsCorrectly() {
    Traversal.Admin traversal = new DefaultTraversal<>(EmptyGraph.instance());
    traversal.asAdmin().addStep(0, new LambdaFilterStep(traversal, traverser -> true));
    traversal.asAdmin().addStep(0, new HasStep(traversal));
    traversal.asAdmin().addStep(0, new IdentityStep(traversal));
    validateToyTraversal(traversal);

    traversal = new DefaultTraversal<>(EmptyGraph.instance());
    traversal.asAdmin().addStep(0, new IdentityStep(traversal));
    traversal.asAdmin().addStep(1, new HasStep(traversal));
    traversal.asAdmin().addStep(2, new LambdaFilterStep(traversal, traverser -> true));
    validateToyTraversal(traversal);
}