You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2021/09/02 15:19:31 UTC
[tinkerpop] 06/10: TINKERPOP-2605 Added test for select() where
by() produces null
This is an automated email from the ASF dual-hosted git repository.
spmallette pushed a commit to branch TINKERPOP-2605
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 24c70cf03e8a000cffc408cbafbcdd37bbfa57df
Author: Stephen Mallette <st...@amazon.com>
AuthorDate: Tue Aug 24 13:12:11 2021 -0400
TINKERPOP-2605 Added test for select() where by() produces null
---
.../Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs | 1 +
.../gremlin-javascript/test/cucumber/gremlin.js | 1 +
gremlin-python/src/main/python/radish/gremlin.py | 1 +
gremlin-test/features/map/Select.feature | 18 +++++++++++++++++-
.../gremlin/process/traversal/step/map/SelectTest.java | 15 +++++++++++++++
5 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
index fe23a6f..f9567a0 100644
--- a/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
+++ b/gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs
@@ -560,6 +560,7 @@ namespace Gremlin.Net.IntegrationTest.Gherkin
{"g_V_hasXperson_name_markoX_path_asXaX_unionXidentity_identityX_selectXaX_unfold", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Has("person","name","marko").Path().As("a").Union<object>(__.Identity(),__.Identity()).Select<object>("a").Unfold<object>()}},
{"g_EX11X_propertiesXweightX_asXaX_selectXaX_byXkeyX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.E(p["eid11"]).Properties<object>("weight").As("a").Select<object>("a").By(T.Key)}},
{"g_EX11X_propertiesXweightX_asXaX_selectXaX_byXvalueX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.E(p["eid11"]).Properties<object>("weight").As("a").Select<object>("a").By(T.Value)}},
+ {"g_V_asXaX_selectXaX_byXageX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().As("a").Select<object>("a").By("age")}},
{"g_V_shortestPath", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.WithStrategies(new VertexProgramStrategy(graphComputer: "org.apache.tinkerpop.gremlin.process.computer.GraphComputer")).V().Identity().ShortestPath()}},
{"g_V_both_dedup_shortestPath", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.WithStrategies(new VertexProgramStrategy(graphComputer: "org.apache.tinkerpop.gremlin.process.computer.GraphComputer")).V().Both().Dedup().ShortestPath()}},
{"g_V_shortestPath_edgesIncluded", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.WithStrategies(new VertexProgramStrategy(graphComputer: "org.apache.tinkerpop.gremlin.process.computer.GraphComputer")).V().Identity().ShortestPath().With("~tinkerpop.shortestPath.includeEdges")}},
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 5bda6d9..13a5a24 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
@@ -549,6 +549,7 @@ const gremlins = {
g_V_hasXperson_name_markoX_path_asXaX_unionXidentity_identityX_selectXaX_unfold: [function({g}) { return g.V().has("person","name","marko").path().as("a").union(__.identity(),__.identity()).select("a").unfold() }],
g_EX11X_propertiesXweightX_asXaX_selectXaX_byXkeyX: [function({g, eid11}) { return g.E(eid11).properties("weight").as("a").select("a").by(T.key) }],
g_EX11X_propertiesXweightX_asXaX_selectXaX_byXvalueX: [function({g, eid11}) { return g.E(eid11).properties("weight").as("a").select("a").by(T.value) }],
+ g_V_asXaX_selectXaX_byXageX: [function({g}) { return g.V().as("a").select("a").by("age") }],
g_V_shortestPath: [function({g}) { return g.withStrategies(new VertexProgramStrategy(new Map([["graphComputer","org.apache.tinkerpop.gremlin.process.computer.GraphComputer"]]))).V().identity().shortestPath() }],
g_V_both_dedup_shortestPath: [function({g}) { return g.withStrategies(new VertexProgramStrategy(new Map([["graphComputer","org.apache.tinkerpop.gremlin.process.computer.GraphComputer"]]))).V().both().dedup().shortestPath() }],
g_V_shortestPath_edgesIncluded: [function({g}) { return g.withStrategies(new VertexProgramStrategy(new Map([["graphComputer","org.apache.tinkerpop.gremlin.process.computer.GraphComputer"]]))).V().identity().shortestPath().with_("~tinkerpop.shortestPath.includeEdges") }],
diff --git a/gremlin-python/src/main/python/radish/gremlin.py b/gremlin-python/src/main/python/radish/gremlin.py
index 69379ec..3974ce9 100644
--- a/gremlin-python/src/main/python/radish/gremlin.py
+++ b/gremlin-python/src/main/python/radish/gremlin.py
@@ -534,6 +534,7 @@ world.gremlins = {
'g_V_hasXperson_name_markoX_path_asXaX_unionXidentity_identityX_selectXaX_unfold': [(lambda g:g.V().has('person','name','marko').path().as_('a').union(__.identity(),__.identity()).select('a').unfold())],
'g_EX11X_propertiesXweightX_asXaX_selectXaX_byXkeyX': [(lambda g, eid11=None:g.E(eid11).properties('weight').as_('a').select('a').by(T.key))],
'g_EX11X_propertiesXweightX_asXaX_selectXaX_byXvalueX': [(lambda g, eid11=None:g.E(eid11).properties('weight').as_('a').select('a').by(T.value))],
+ 'g_V_asXaX_selectXaX_byXageX': [(lambda g:g.V().as_('a').select('a').by('age'))],
'g_V_shortestPath': [(lambda g:g.withStrategies(*[TraversalStrategy('VertexProgramStrategy',{'graphComputer':'org.apache.tinkerpop.gremlin.process.computer.GraphComputer'}, 'org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.VertexProgramStrategy')]).V().identity().shortestPath())],
'g_V_both_dedup_shortestPath': [(lambda g:g.withStrategies(*[TraversalStrategy('VertexProgramStrategy',{'graphComputer':'org.apache.tinkerpop.gremlin.process.computer.GraphComputer'}, 'org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.VertexProgramStrategy')]).V().both().dedup().shortestPath())],
'g_V_shortestPath_edgesIncluded': [(lambda g:g.withStrategies(*[TraversalStrategy('VertexProgramStrategy',{'graphComputer':'org.apache.tinkerpop.gremlin.process.computer.GraphComputer'}, 'org.apache.tinkerpop.gremlin.process.computer.traversal.strategy.decoration.VertexProgramStrategy')]).V().identity().shortestPath().with_('~tinkerpop.shortestPath.includeEdges'))],
diff --git a/gremlin-test/features/map/Select.feature b/gremlin-test/features/map/Select.feature
index c0002f2..3169e0e 100644
--- a/gremlin-test/features/map/Select.feature
+++ b/gremlin-test/features/map/Select.feature
@@ -814,4 +814,20 @@ Feature: Step - select()
When iterated to list
Then the result should be unordered
| result |
- | d[0.4].d |
\ No newline at end of file
+ | d[0.4].d |
+
+ Scenario: g_V_asXaX_selectXaX_byXageX
+ Given the modern graph
+ And the traversal of
+ """
+ g.V().as("a").select("a").by("age")
+ """
+ When iterated to list
+ Then the result should be unordered
+ | result |
+ | d[29].i |
+ | d[27].i |
+ | null |
+ | d[32].i |
+ | null |
+ | d[35].i |
\ No newline at end of file
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectTest.java
index cd274d0..f6c8d12 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/SelectTest.java
@@ -94,6 +94,8 @@ public abstract class SelectTest extends AbstractGremlinProcessTest {
public abstract Traversal<Vertex, Long> get_g_V_selectXaX_count();
+ public abstract Traversal<Vertex, Object> get_g_V_asXaX_selectXaX_byXageX();
+
// below are original back()-tests
public abstract Traversal<Vertex, Vertex> get_g_VX1X_asXhereX_out_selectXhereX(final Object v1Id);
@@ -886,6 +888,14 @@ public abstract class SelectTest extends AbstractGremlinProcessTest {
checkResults(Arrays.asList(convertToVertex(graph, "marko"), convertToVertex(graph, "marko")), traversal);
}
+ @Test
+ @LoadGraphWith(MODERN)
+ public void g_V_asXaX_selectXaX_byXageX() {
+ final Traversal<Vertex, Object> traversal = get_g_V_asXaX_selectXaX_byXageX();
+ printTraversalForm(traversal);
+ checkResults(Arrays.asList(29, 27, null, 32, null, 35), traversal);
+ }
+
public static class Traversals extends SelectTest {
@Override
public Traversal<Vertex, Map<String, Vertex>> get_g_VX1X_asXaX_outXknowsX_asXbX_selectXa_bX(final Object v1Id) {
@@ -1209,5 +1219,10 @@ public abstract class SelectTest extends AbstractGremlinProcessTest {
public Traversal<Vertex, Vertex> get_g_V_hasXperson_name_markoX_path_asXaX_unionXidentity_identityX_selectXaX_unfold() {
return g.V().has("person","name","marko").path().as("a").union(identity(),identity()).select("a").unfold();
}
+
+ @Override
+ public Traversal<Vertex, Object> get_g_V_asXaX_selectXaX_byXageX() {
+ return g.V().as("a").select("a").by("age");
+ }
}
}