You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by mi...@apache.org on 2022/03/18 15:58:27 UTC
[tinkerpop] 01/01: Enable a few tests in Properties.feature
This is an automated email from the ASF dual-hosted git repository.
mikepersonick pushed a commit to branch TINKERPOP-2724
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 34a70c2eec8c3ccd228f72257c0971acfb6fe6c0
Author: mikepersonick <mi...@supersonick.io>
AuthorDate: Fri Mar 18 09:58:10 2022 -0600
Enable a few tests in Properties.feature
---
.../Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs | 2 ++
.../test/cucumber/feature-steps.js | 6 ++--
.../gremlin-javascript/test/cucumber/gremlin.js | 2 ++
.../src/main/python/radish/feature_steps.py | 5 +--
gremlin-python/src/main/python/radish/gremlin.py | 2 ++
gremlin-test/features/map/Properties.feature | 38 +++++++++++++++++-----
.../tinkerpop/gremlin/features/StepDefinition.java | 35 +++++++++++++++-----
7 files changed, 68 insertions(+), 22 deletions(-)
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
index 377399a..9b5f08e 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
@@ -677,6 +677,8 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
{"g_V_hasXageX_propertiesXage_nameX_value", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Has("age").Properties<object>("age","name").Value<object>()}},
{"g_V_propertiesXname_age_nullX_value", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Properties<object>("name","age",null).Value<object>()}},
{"g_V_valuesXname_age_nullX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Values<object>("name","age",null)}},
+ {"g_V_hasXageX_properties_hasXid_nameIdX_value", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Has("age").Properties<object>().Has(T.Id,p["xx1"]).Value<object>()}},
+ {"g_V_hasXageX_properties_hasXid_nameIdAsStringX_value", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Has("age").Properties<object>().Has(T.Id,p["xx1"]).Value<object>()}},
{"g_VX1X_asXaX_outXknowsX_asXbX_selectXa_bX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).As("a").Out("knows").As("b").Select<object>("a","b")}},
{"g_VX1X_asXaX_outXknowsX_asXbX_selectXa_bX_byXnameX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).As("a").Out("knows").As("b").Select<object>("a","b").By("name")}},
{"g_VX1X_asXaX_outXknowsX_asXbX_selectXaX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).As("a").Out("knows").As("b").Select<object>("a")}},
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
index 5fd5335..ce37938 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/feature-steps.js
@@ -63,7 +63,7 @@ const ignoreReason = {
nullKeysInMapNotSupportedWell: "Javascript does not nicely support 'null' as a key in Map instances",
setNotSupported: "There is no Set support in gremlin-javascript",
needsFurtherInvestigation: '',
- vertexPropertyNotSupported: "Need a parser for vertex properties",
+ vertexPropertyNotSupported: "Need a Gherkin parser for vertex properties",
};
const ignoredScenarios = {
@@ -74,7 +74,9 @@ const ignoredScenarios = {
'g_V_shortestPath_edgesIncluded': new IgnoreError(ignoreReason.needsFurtherInvestigation),
'g_V_shortestPath_edgesIncluded_edgesXoutEX': new IgnoreError(ignoreReason.needsFurtherInvestigation),
'g_V_shortestpath': new IgnoreError(ignoreReason.needsFurtherInvestigation),
- 'g_V_properties_order': new IgnoreError(ignoreReason.vertexPropertyNotSupported)
+ 'g_V_properties_order': new IgnoreError(ignoreReason.vertexPropertyNotSupported),
+ 'g_V_hasXageX_properties_hasXid_nameIdX_value': new IgnoreError(ignoreReason.vertexPropertyNotSupported),
+ 'g_V_hasXageX_properties_hasXid_nameIdAsStringX_value': new IgnoreError(ignoreReason.vertexPropertyNotSupported)
};
Given(/^the (.+) graph$/, function (graphName) {
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js
index 31387de..f674415 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js
@@ -668,6 +668,8 @@ const gremlins = {
g_V_hasXageX_propertiesXage_nameX_value: [function({g}) { return g.V().has("age").properties("age","name").value() }],
g_V_propertiesXname_age_nullX_value: [function({g}) { return g.V().properties("name","age",null).value() }],
g_V_valuesXname_age_nullX: [function({g}) { return g.V().values("name","age",null) }],
+ g_V_hasXageX_properties_hasXid_nameIdX_value: [function({g, xx1}) { return g.V().has("age").properties().has(T.id,xx1).value() }],
+ g_V_hasXageX_properties_hasXid_nameIdAsStringX_value: [function({g, xx1}) { return g.V().has("age").properties().has(T.id,xx1).value() }],
g_VX1X_asXaX_outXknowsX_asXbX_selectXa_bX: [function({g, vid1}) { return g.V(vid1).as("a").out("knows").as("b").select("a","b") }],
g_VX1X_asXaX_outXknowsX_asXbX_selectXa_bX_byXnameX: [function({g, vid1}) { return g.V(vid1).as("a").out("knows").as("b").select("a","b").by("name") }],
g_VX1X_asXaX_outXknowsX_asXbX_selectXaX: [function({g, vid1}) { return g.V(vid1).as("a").out("knows").as("b").select("a") }],
diff --git a/gremlin-python/src/main/python/radish/feature_steps.py b/gremlin-python/src/main/python/radish/feature_steps.py
index 9e2e745..f3f0285 100644
--- a/gremlin-python/src/main/python/radish/feature_steps.py
+++ b/gremlin-python/src/main/python/radish/feature_steps.py
@@ -40,8 +40,9 @@ direction = {
"to": Direction.IN,
}
-ignores = ["g.V().properties().order()"] # need a vertex property parser for result set: https://issues.apache.org/jira/browse/TINKERPOP-2686
-
+ignores = ["g.V().properties().order()", # need a Gherkin parser for VertexProperty: https://issues.apache.org/jira/browse/TINKERPOP-2686
+ "g.V().has(\"age\").properties().has(T.id, xx1).value()", # need a Gherkin parser for VertexProperty: https://issues.apache.org/jira/browse/TINKERPOP-2686
+ ]
@given("the {graph_name:w} graph")
def choose_graph(step, graph_name):
diff --git a/gremlin-python/src/main/python/radish/gremlin.py b/gremlin-python/src/main/python/radish/gremlin.py
index a91dfad..6756c50 100644
--- a/gremlin-python/src/main/python/radish/gremlin.py
+++ b/gremlin-python/src/main/python/radish/gremlin.py
@@ -650,6 +650,8 @@ world.gremlins = {
'g_V_hasXageX_propertiesXage_nameX_value': [(lambda g:g.V().has('age').properties('age','name').value())],
'g_V_propertiesXname_age_nullX_value': [(lambda g:g.V().properties('name','age',None).value())],
'g_V_valuesXname_age_nullX': [(lambda g:g.V().values('name','age',None))],
+ 'g_V_hasXageX_properties_hasXid_nameIdX_value': [(lambda g, xx1=None:g.V().has('age').properties().has(T.id_,xx1).value())],
+ 'g_V_hasXageX_properties_hasXid_nameIdAsStringX_value': [(lambda g, xx1=None:g.V().has('age').properties().has(T.id_,xx1).value())],
'g_VX1X_asXaX_outXknowsX_asXbX_selectXa_bX': [(lambda g, vid1=None:g.V(vid1).as_('a').out('knows').as_('b').select('a','b'))],
'g_VX1X_asXaX_outXknowsX_asXbX_selectXa_bX_byXnameX': [(lambda g, vid1=None:g.V(vid1).as_('a').out('knows').as_('b').select('a','b').by('name'))],
'g_VX1X_asXaX_outXknowsX_asXbX_selectXaX': [(lambda g, vid1=None:g.V(vid1).as_('a').out('knows').as_('b').select('a'))],
diff --git a/gremlin-test/features/map/Properties.feature b/gremlin-test/features/map/Properties.feature
index cf67239..fb03c2f 100644
--- a/gremlin-test/features/map/Properties.feature
+++ b/gremlin-test/features/map/Properties.feature
@@ -108,23 +108,43 @@ Feature: Step - properties()
| lop |
| ripple |
- Scenario: g_injectXg_VX1X_propertiesXnameX_nextX_value
+ Scenario: g_injectXg_VX1X_propertiesXnameXX_value
Given an unsupported test
Then nothing should happen because
"""
- The test suite doesn't do well with vertex property values.
+ There is no way to inject a VertexProperty via the parser
"""
+# Given the modern graph
+# And using the parameter xx1 defined as "vp[josh-name->?]"
+# And the traversal of
+# """
+# g.inject(xx1).value()
+# """
+# When iterated to list
+# Then the result should be unordered
+# | result |
+# | josh |
Scenario: g_V_hasXageX_properties_hasXid_nameIdX_value
- Given an unsupported test
- Then nothing should happen because
+ Given the modern graph
+ And using the parameter xx1 defined as "vp[marko-name->?].id"
+ And the traversal of
"""
- GLV suite doesn't support property identifiers and related assertions
+ g.V().has("age").properties().has(T.id, xx1).value()
"""
+ When iterated to list
+ Then the result should be unordered
+ | result |
+ | marko |
Scenario: g_V_hasXageX_properties_hasXid_nameIdAsStringX_value
- Given an unsupported test
- Then nothing should happen because
+ Given the modern graph
+ And using the parameter xx1 defined as "vp[marko-name->?].sid"
+ And the traversal of
+ """
+ g.V().has("age").properties().has(T.id, xx1).value()
"""
- GLV suite doesn't support property identifiers and related assertions
- """
\ No newline at end of file
+ When iterated to list
+ Then the result should be unordered
+ | result |
+ | marko |
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/features/StepDefinition.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/features/StepDefinition.java
index bfec6f9..b636743 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/features/StepDefinition.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/features/StepDefinition.java
@@ -135,6 +135,9 @@ public final class StepDefinition {
}));
add(Pair.with(Pattern.compile("e\\[(.+)\\]\\.id"), s -> getEdgeIdString(g, s)));
add(Pair.with(Pattern.compile("e\\[(.+)\\]\\.sid"), s -> getEdgeIdString(g, s)));
+ add(Pair.with(Pattern.compile("vp\\[(.+)\\]\\.id"), s -> getVertexPropertyIdString(g, s)));
+ add(Pair.with(Pattern.compile("vp\\[(.+)\\]\\.sid"), s -> getVertexPropertyIdString(g, s)));
+
add(Pair.with(Pattern.compile("t\\[(.*)\\]"), s -> String.format("T.%s", s)));
add(Pair.with(Pattern.compile("D\\[(.*)\\]"), s -> String.format("Direction.%s", s)));
@@ -491,25 +494,39 @@ public final class StepDefinition {
filter(edge -> g.V(edge.inVertex().id()).has("name", t.getValue2()).hasNext()).findFirst().get();
}
+ private static Object getEdgeId(final GraphTraversalSource g, final String e) {
+ return getEdge(g, e).id();
+ }
+
+ private static String getEdgeIdString(final GraphTraversalSource g, final String e) {
+ return getEdgeId(g, e).toString();
+ }
+
/**
* Reuse edge triplet syntax for VertexProperty: vp[vertexName-key->value]
*/
private VertexProperty getVertexProperty(final GraphTraversalSource g, final String e) {
- final Triplet<String,String,String> t = getEdgeTriplet(e);
- return (VertexProperty) g.V().has("name", t.getValue0())
- .properties(t.getValue1())
- .hasValue(convertToObject(t.getValue2()))
- .tryNext().orElse(null);
+ final Triplet<String,String,String> triplet = getEdgeTriplet(e);
+
+ GraphTraversal traversal = g.V().has("name", triplet.getValue0())
+ .properties(triplet.getValue1());
+
+ // allow wildcard '?' for value
+ if (!"?".equals(triplet.getValue2()))
+ traversal = traversal.hasValue(convertToObject(triplet.getValue2()));
+
+ return (VertexProperty) traversal.tryNext().orElse(null);
}
- private static Object getEdgeId(final GraphTraversalSource g, final String e) {
- return getEdge(g, e).id();
+ private Object getVertexPropertyId(final GraphTraversalSource g, final String e) {
+ return getVertexProperty(g, e).id();
}
- private static String getEdgeIdString(final GraphTraversalSource g, final String e) {
- return getEdgeId(g, e).toString();
+ private String getVertexPropertyIdString(final GraphTraversalSource g, final String e) {
+ return getVertexPropertyId(g, e).toString();
}
+
private String applyParameters(final String docString) {
String replaced = docString;
// sort from longest to shortest so that xx1 does not replace xx10