TINKERPOP-1857 Added GLV match() tests
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/ade1daf8 Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/ade1daf8 Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/ade1daf8 Branch: refs/heads/TINKERPOP-1777 Commit: ade1daf8670de64c3f57d9c7f13c2645e58754ac Parents: 7a44584 Author: Stephen Mallette <sp...@genoprime.com> Authored: Thu Feb 1 13:06:44 2018 -0500 Committer: Stephen Mallette <sp...@genoprime.com> Committed: Wed Feb 14 15:34:09 2018 -0500 ---------------------------------------------------------------------- gremlin-test/features/map/Match.feature | 315 +++++++++++++++++++ .../process/traversal/step/map/MatchTest.java | 4 +- .../gremlin/process/FeatureCoverageTest.java | 17 +- 3 files changed, 330 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ade1daf8/gremlin-test/features/map/Match.feature ---------------------------------------------------------------------- diff --git a/gremlin-test/features/map/Match.feature b/gremlin-test/features/map/Match.feature index e3f04d5..006692a 100644 --- a/gremlin-test/features/map/Match.feature +++ b/gremlin-test/features/map/Match.feature @@ -78,3 +78,318 @@ Feature: Step - match() | m[{"a":"v[marko]","b":"v[josh]", "c":"v[ripple]"}] | | m[{"a":"v[marko]","b":"v[josh]", "c":"v[lop]"}] | + Scenario: g_V_matchXa_created_b__b_0created_cX_whereXa_neq_cX_selectXa_cX + Given the modern graph + And the traversal of + """ + g.V().match(__.as("a").out("created").as("b"), + __.as("b").in("created").as("c")).where("a", P.neq("c")).select("a", "c") + """ + When iterated to list + Then the result should be unordered + | result | + | m[{"a":"v[marko]","c":"v[josh]"}] | + | m[{"a":"v[marko]","c":"v[peter]"}] | + | m[{"a":"v[josh]","c":"v[marko]"}] | + | m[{"a":"v[josh]","c":"v[peter]"}] | + | m[{"a":"v[peter]","c":"v[marko]"}] | + | m[{"a":"v[peter]","c":"v[josh]"}] | + + Scenario: g_V_matchXd_0knows_a__d_hasXname_vadasX__a_knows_b__b_created_cX + Given the modern graph + And the traversal of + """ + g.V().match(__.as("d").in("knows").as("a"), + __.as("d").has("name", "vadas"), + __.as("a").out("knows").as("b"), + __.as("b").out("created").as("c")) + """ + When iterated to list + Then the result should be unordered + | result | + | m[{"a":"v[marko]","b":"v[josh]","c":"v[ripple]","d":"v[vadas]"}] | + | m[{"a":"v[marko]","b":"v[josh]","c":"v[lop]","d":"v[vadas]"}] | + + Scenario: g_V_matchXa_created_lop_b__b_0created_29_c__c_whereXrepeatXoutX_timesX2XXX + Given the modern graph + And the traversal of + """ + g.V().match(__.as("a").out("created").has("name", "lop").as("b"), + __.as("b").in("created").has("age", 29).as("c"), + __.as("c").where(__.repeat(__.out()).times(2))) + """ + When iterated to list + Then the result should be unordered + | result | + | m[{"a":"v[marko]","b":"v[lop]","c":"v[marko]"}] | + | m[{"a":"v[josh]","b":"v[lop]","c":"v[marko]"}] | + | m[{"a":"v[peter]","b":"v[lop]","c":"v[marko]"}] | + + Scenario: g_V_asXaX_out_asXbX_matchXa_out_count_c__b_in_count_cX + Given the modern graph + And the traversal of + """ + g.V().as("a").out().as("b").match(__.as("a").out().count().as("c"), __.as("b").in().count().as("c")) + """ + When iterated to list + Then the result should be unordered + | result | + | m[{"a":"v[marko]","b":"v[lop]","c":3}] | + + Scenario: g_V_matchXa__a_out_b__notXa_created_bXX + Given the modern graph + And the traversal of + """ + g.V().match(__.as("a").out().as("b"),__.not(__.as("a").out("created").as("b"))) + """ + When iterated to list + Then the result should be unordered + | result | + | m[{"a":"v[marko]","b":"v[vadas]"}] | + | m[{"a":"v[marko]","b":"v[josh]"}] | + + Scenario: g_V_matchXa_created_lop_b__b_0created_29_cX_whereXc_repeatXoutX_timesX2XX_selectXa_b_cX + Given the modern graph + And the traversal of + """ + g.V().match(__.as("a").out("created").has("name", "lop").as("b"), + __.as("b").in("created").has("age", 29).as("c")).where(__.as("c").repeat(__.out()).times(2)).select("a", "b", "c") + """ + When iterated to list + Then the result should be unordered + | result | + | m[{"a":"v[marko]","b":"v[lop]","c":"v[marko]"}] | + | m[{"a":"v[josh]","b":"v[lop]","c":"v[marko]"}] | + | m[{"a":"v[peter]","b":"v[lop]","c":"v[marko]"}] | + + Scenario: g_V_out_out_matchXa_0created_b__b_0knows_cX_selectXcX_outXcreatedX_name + Given the modern graph + And the traversal of + """ + g.V().out().out().match(__.as("a").in("created").as("b"), + __.as("b").in("knows").as("c")). + select("c").out("created").values("name") + """ + When iterated to list + Then the result should be unordered + | result | + | lop | + | lop | + + Scenario: g_V_matchXa_knows_b__b_created_c__a_created_cX_dedupXa_b_cX_selectXaX_byXnameX + Given the modern graph + And the traversal of + """ + g.V().match(__.as("a").out("knows").as("b"), + __.as("b").out("created").as("c"), + __.as("a").out("created").as("c")).dedup("a", "b", "c").select("a").by("name") + """ + When iterated to list + Then the result should be unordered + | result | + | marko | + + Scenario: g_V_matchXa_created_b__a_repeatXoutX_timesX2XX_selectXa_bX + Given the modern graph + And the traversal of + """ + g.V().match(__.as("a").out("created").as("b"), + __.as("a").repeat(__.out()).times(2).as("b")).select("a", "b") + """ + When iterated to list + Then the result should be unordered + | result | + | m[{"a":"v[marko]","b":"v[lop]"}] | + + Scenario: g_V_notXmatchXa_age_b__a_name_cX_whereXb_eqXcXX_selectXaXX_name + Given the modern graph + And the traversal of + """ + g.V().not(__.match(__.as("a").values("age").as("b"), __.as("a").values("name").as("c")).where("b", P.eq("c")).select("a")).values("name") + """ + When iterated to list + Then the result should be unordered + | result | + | marko | + | vadas | + | lop | + | josh | + | ripple | + | peter | + + Scenario: g_V_matchXa_knows_b__andXa_created_c__b_created_c__andXb_created_count_d__a_knows_count_dXXX + Given the modern graph + And the traversal of + """ + g.V().match(__.as("a").out("knows").as("b"), + __.and(__.as("a").out("created").as("c"), + __.as("b").out("created").as("c"), + __.and(__.as("b").out("created").count().as("d"), + __.as("a").out("knows").count().as("d")))) + """ + When iterated to list + Then the result should be unordered + | result | + | m[{"a":"v[marko]","b":"v[josh]","c":"v[lop]","d":2}] | + + Scenario: g_V_matchXa_whereXa_neqXcXX__a_created_b__orXa_knows_vadas__a_0knows_and_a_hasXlabel_personXX__b_0created_c__b_0created_count_isXgtX1XXX_selectXa_b_cX_byXidX + Given the modern graph + And the traversal of + """ + g.V().match(__.where("a", P.neq("c")), + __.as("a").out("created").as("b"), + __.or(__.as("a").out("knows").has("name", "vadas"), + __.as("a").in("knows").and().as("a").has(T.label, "person")), + __.as("b").in("created").as("c"), + __.as("b").in("created").count().is(P.gt(1))).select("a", "b", "c").by(T.id) + """ + When iterated to list + Then the result should be unordered + | result | + | m[{"a":1,"b":3,"c":4}] | + | m[{"a":1,"b":3,"c":6}] | + | m[{"a":4,"b":3,"c":1}] | + | m[{"a":4,"b":3,"c":6}] | + + Scenario: g_V_matchXa__a_both_b__b_both_cX_dedupXa_bX + Given the modern graph + And the traversal of + """ + g.V().match(__.as("a").both().as("b"), + __.as("b").both().as("c")).dedup("a", "b") + """ + When iterated to list + Then the result should be unordered + | result | + | m[{"a":"v[marko]","b":"v[lop]","c":"v[marko]"}] | + | m[{"a":"v[marko]","b":"v[vadas]","c":"v[marko]"}] | + | m[{"a":"v[marko]","b":"v[josh]","c":"v[ripple]"}] | + | m[{"a":"v[vadas]","b":"v[marko]","c":"v[lop]"}] | + | m[{"a":"v[lop]","b":"v[marko]","c":"v[lop]"}] | + | m[{"a":"v[lop]","b":"v[josh]","c":"v[ripple]"}] | + | m[{"a":"v[lop]","b":"v[peter]","c":"v[lop]"}] | + | m[{"a":"v[josh]","b":"v[ripple]","c":"v[josh]"}] | + | m[{"a":"v[josh]","b":"v[lop]","c":"v[marko]"}] | + | m[{"a":"v[josh]","b":"v[marko]","c":"v[lop]"}] | + | m[{"a":"v[ripple]","b":"v[josh]","c":"v[ripple]"}] | + | m[{"a":"v[peter]","b":"v[lop]","c":"v[marko]"}] | + + Scenario: g_V_matchXa_knows_b__b_created_lop__b_matchXb_created_d__d_0created_cX_selectXcX_cX_selectXa_b_cX + Given the modern graph + And the traversal of + """ + g.V().match(__.as("a").out("knows").as("b"), + __.as("b").out("created").has("name", "lop"), + __.as("b").match(__.as("b").out("created").as("d"), + __.as("d").in("created").as("c")).select("c").as("c")).select("a", "b", "c") + """ + When iterated to list + Then the result should be unordered + | result | + | m[{"a":"v[marko]","b":"v[josh]","c":"v[josh]"}] | + | m[{"a":"v[marko]","b":"v[josh]","c":"v[marko]"}] | + | m[{"a":"v[marko]","b":"v[josh]","c":"v[josh]"}] | + | m[{"a":"v[marko]","b":"v[josh]","c":"v[peter]"}] | + + Scenario: g_V_matchXa_knows_b__a_created_cX + Given the modern graph + And the traversal of + """ + g.V().match(__.as("a").out("knows").as("b"), + __.as("a").out("created").as("c")) + """ + When iterated to list + Then the result should be unordered + | result | + | m[{"a":"v[marko]","b":"v[vadas]","c":"v[lop]"}] | + | m[{"a":"v[marko]","b":"v[josh]","c":"v[lop]"}] | + + Scenario: g_V_matchXwhereXandXa_created_b__b_0created_count_isXeqX3XXXX__a_both_b__whereXb_inXX + Given the modern graph + And the traversal of + """ + g.V().match(__.where(__.and(__.as("a").out("created").as("b"), + __.as("b").in("created").count().is(P.eq(3)))), + __.as("a").both().as("b"), + __.where(__.as("b").in())) + """ + When iterated to list + Then the result should be unordered + | result | + | m[{"a":"v[marko]","b":"v[lop]"}] | + | m[{"a":"v[josh]","b":"v[lop]"}] | + | m[{"a":"v[peter]","b":"v[lop]"}] | + + Scenario: g_V_matchXa_outEXcreatedX_order_byXweight_decrX_limitX1X_inV_b__b_hasXlang_javaXX_selectXa_bX_byXnameX + Given the modern graph + And the traversal of + """ + g.V().match(__.as("a").outE("created").order().by("weight", Order.decr).limit(1).inV().as("b"), + __.as("b").has("lang", "java")).select("a", "b").by("name") + """ + When iterated to list + Then the result should be unordered + | result | + | m[{"a":"marko","b":"lop"}] | + | m[{"a":"josh","b":"ripple"}] | + | m[{"a":"peter","b":"lop"}] | + + Scenario: g_V_matchXa_both_b__b_both_cX_dedupXa_bX_byXlabelX + Given the modern graph + And the traversal of + """ + g.V().match(__.as("a").both().as("b"), + __.as("b").both().as("c")).dedup("a", "b").by(T.label) + """ + When iterated to list + Then the result should be unordered + | result | + | m[{"a":"v[marko]","b":"v[lop]","c":"v[marko]"}] | + | m[{"a":"v[marko]","b":"v[vadas]","c":"v[marko]"}] | + | m[{"a":"v[lop]","b":"v[marko]","c":"v[lop]"}] | + + Scenario: g_V_matchXa_created_b__b_0created_aX + Given the modern graph + And the traversal of + """ + g.V().match(__.as("a").out("created").as("b"), + __.as("b").in("created").as("a")) + """ + When iterated to list + Then the result should be unordered + | result | + | m[{"a":"v[marko]","b":"v[lop]"}] | + | m[{"a":"v[josh]","b":"v[ripple]"}] | + | m[{"a":"v[josh]","b":"v[lop]"}] | + | m[{"a":"v[peter]","b":"v[lop]"}] | + + Scenario: g_V_asXaX_out_asXbX_matchXa_out_count_c__orXa_knows_b__b_in_count_c__and__c_isXgtX2XXXX + Given the modern graph + And the traversal of + """ + g.V().as("a").out().as("b").match(__.as("a").out().count().as("c"), + __.or(__.as("a").out("knows").as("b"),__.as("b").in().count().as("c").and().as("c").is(P.gt(2)))) + """ + When iterated to list + Then the result should be unordered + | result | + | m[{"a":"v[marko]","b":"v[lop]","c":"d[3].l"}] | + | m[{"a":"v[marko]","b":"v[vadas]","c":"d[3].l"}] | + | m[{"a":"v[marko]","b":"v[josh]","c":"d[3].l"}] | + + Scenario: g_V_matchXa_knows_count_bX_selectXbX + Given the modern graph + And the traversal of + """ + g.V().match(__.as("a").out("knows").count().as("b")).select("b") + """ + When iterated to list + Then the result should be unordered + | result | + | d[2].l | + | d[0].l | + | d[0].l | + | d[0].l | + | d[0].l | + | d[0].l | + http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ade1daf8/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchTest.java ---------------------------------------------------------------------- diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchTest.java index cab3cbf..40ae6e9 100644 --- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchTest.java +++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchTest.java @@ -255,7 +255,7 @@ public abstract class MatchTest extends AbstractGremlinProcessTest { @Test @LoadGraphWith(MODERN) - public void g_V_matchXa_created_b__a_repeatXoutX_timesX2XX_selectXab_nameX() throws Exception { + public void g_V_matchXa_created_b__a_repeatXoutX_timesX2XX_selectXa_bX() throws Exception { final Traversal<Vertex, Map<String, Vertex>> traversal = get_g_V_matchXa_created_b__a_repeatXoutX_timesX2XX_selectXa_bX(); printTraversalForm(traversal); assertTrue(traversal.hasNext()); @@ -490,7 +490,7 @@ public abstract class MatchTest extends AbstractGremlinProcessTest { @Test @LoadGraphWith(MODERN) - public void g_V_matchXwhereXandXa_created_b__b_0created_count_isXeqX3XXXX__a_both_bX() { + public void g_V_matchXwhereXandXa_created_b__b_0created_count_isXeqX3XXXX__a_both_b__whereXb_inXX() { final Traversal<Vertex, Map<String, Object>> traversal = get_g_V_matchXwhereXandXa_created_b__b_0created_count_isXeqX3XXXX__a_both_b__whereXb_inXX(); printTraversalForm(traversal); checkResults(makeMapList(2, http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ade1daf8/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java ---------------------------------------------------------------------- diff --git a/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java b/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java index ff6156a..48c64b9 100644 --- a/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java +++ b/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java @@ -100,11 +100,20 @@ public class FeatureCoverageTest { private static Pattern scenarioName = Pattern.compile("^\\s*Scenario:\\s*(.*)$"); - // g_V_addVXlabel_animal_age_0X - deprecated - // g_addVXlabel_person_name_stephenX - deprecated private static final List<String> testToIgnore = Arrays.asList( + // deprecated tests "g_V_addVXlabel_animal_age_0X", - "g_addVXlabel_person_name_stephenX"); + "g_addVXlabel_person_name_stephenX", + // grateful dead graph not supported in GLV suite + "g_V_matchXa_0sungBy_b__a_0writtenBy_c__b_writtenBy_d__c_sungBy_d__d_hasXname_GarciaXX", + "g_V_matchXa_hasXsong_name_sunshineX__a_mapX0followedBy_weight_meanX_b__a_0followedBy_c__c_filterXweight_whereXgteXbXXX_outV_dX_selectXdX_byXnameX", + "g_V_matchXa_0sungBy_b__a_0sungBy_c__b_writtenBy_d__c_writtenBy_e__d_hasXname_George_HarisonX__e_hasXname_Bob_MarleyXX", + "g_V_matchXa_hasXname_GarciaX__a_0writtenBy_b__a_0sungBy_bX", + "g_V_hasLabelXsongsX_matchXa_name_b__a_performances_cX_selectXb_cX_count", + "g_V_matchXa_hasXname_GarciaX__a_0writtenBy_b__b_followedBy_c__c_writtenBy_d__whereXd_neqXaXXX", + "g_V_matchXa_0sungBy_b__a_0writtenBy_c__b_writtenBy_dX_whereXc_sungBy_dX_whereXd_hasXname_GarciaXX", + "get_g_V_matchXa_followedBy_count_isXgtX10XX_b__a_0followedBy_count_isXgtX10XX_bX_count", + "g_V_matchXa_followedBy_count_isXgtX10XX_b__a_0followedBy_count_isXgtX10XX_bX_count"); @Test // @Ignore("As it stands we won't have all of these tests migrated initially so there is no point to running this in full - it can be flipped on later") @@ -208,7 +217,7 @@ public class FeatureCoverageTest { testMethods.removeAll(testsInFeatureFile); - assertEquals("All test methods are not implemented in the " + featureFileName + ": " + testMethods, testMethods.size(), 0); + assertEquals("All test methods are not implemented in the " + featureFileName + ": " + testMethods, 0, testMethods.size()); } } }