This is an automated email from the ASF dual-hosted git repository.

dkuppitz pushed a commit to branch TINKERPOP-1084
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 9ca40a6b17bd8f5e0deab15cf114ff3fac2fdb36
Author: Daniel Kuppitz <daniel_kupp...@hotmail.com>
AuthorDate: Mon Jun 17 14:24:46 2019 -0700

    added more tests
---
 gremlin-test/features/branch/Branch.feature        | 36 ++++++++++++++++-
 .../process/traversal/step/branch/BranchTest.java  | 47 ++++++++++++++++++++++
 2 files changed, 82 insertions(+), 1 deletion(-)

diff --git a/gremlin-test/features/branch/Branch.feature 
b/gremlin-test/features/branch/Branch.feature
index 6ee261f..7bb3e04 100644
--- a/gremlin-test/features/branch/Branch.feature
+++ b/gremlin-test/features/branch/Branch.feature
@@ -89,4 +89,38 @@ Feature: Step - branch()
       | person |
       | person |
       | software |
-      | software |
\ No newline at end of file
+      | software |
+
+  Scenario: 
g_V_branchXageX_optionXltX30X__youngX_optionXgtX30X__oldX_optionXnone__on_the_edgeX
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().hasLabel("person").
+        branch(values("age")).
+          option(P.lt(30), __.constant("young")).
+          option(P.gt(30), __.constant("old")).
+          option(Pick.none, __.constant("on the edge"))
+      """
+    When iterated to list
+    Then the result should be unordered
+      | result |
+      | young |
+      | young |
+      | old |
+      | old |
+
+  Scenario: 
g_V_branchXidentityX_optionXhasLabelXsoftwareX__inXcreatedX_name_order_foldX_optionXhasXname_vadasX__ageX_optionXneqX123X__bothE_countX
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().
+        branch(__.identity()).
+          option(__.hasLabel("software"), 
__.in("created").values("name").order().fold()).
+          option(__.has("name","vadas"), __.values("age")).
+          option(P.neq(123), __.bothE().count())
+      """
+    When iterated to list
+    Then the result should be unordered
+      | l[josh,josh,marko,peter] |
+      | d[27].i |
+      | d[12].l |
diff --git 
a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/BranchTest.java
 
b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/BranchTest.java
index 44a63bd..ed4b2e7 100644
--- 
a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/BranchTest.java
+++ 
b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/BranchTest.java
@@ -29,9 +29,19 @@ import org.junit.runner.RunWith;
 import java.util.Arrays;
 
 import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.MODERN;
+import static org.apache.tinkerpop.gremlin.process.traversal.P.gt;
+import static org.apache.tinkerpop.gremlin.process.traversal.P.lt;
+import static org.apache.tinkerpop.gremlin.process.traversal.P.neq;
+import static 
org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.bothE;
+import static 
org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.constant;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.has;
+import static 
org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.hasLabel;
+import static 
org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.identity;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.in;
 import static 
org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.label;
 import static 
org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.values;
 import static 
org.apache.tinkerpop.gremlin.process.traversal.step.TraversalOptionParent.Pick.any;
+import static 
org.apache.tinkerpop.gremlin.process.traversal.step.TraversalOptionParent.Pick.none;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
@@ -45,6 +55,10 @@ public abstract class BranchTest extends 
AbstractGremlinProcessTest {
 
     public abstract Traversal<Vertex, Object> 
get_g_V_branchXlabel_isXpersonX_countX_optionX1__ageX_optionX0__langX_optionX0__nameX_optionXany__labelX();
 
+    public abstract Traversal<Vertex, Object> 
get_g_V_branchXageX_optionXltX30X__youngX_optionXgtX30X__oldX_optionXnone__on_the_edgeX();
+
+    public abstract Traversal<Vertex, Object> 
get_g_V_branchXidentityX_optionXhasLabelXsoftwareX__inXcreatedX_name_order_foldX_optionXhasXname_vadasX__ageX_optionXneqX123X__bothE_countX();
+
     @Test
     @LoadGraphWith(MODERN)
     public void 
g_V_branchXlabel_eq_person__a_bX_optionXa__ageX_optionXb__langX_optionXb__nameX()
 {
@@ -69,6 +83,22 @@ public abstract class BranchTest extends 
AbstractGremlinProcessTest {
         checkResults(Arrays.asList("java", "java", "lop", "ripple", 29, 27, 
32, 35, "person", "person", "person", "person", "software", "software"), 
traversal);
     }
 
+    @Test
+    @LoadGraphWith(MODERN)
+    public void 
g_V_branchXageX_optionXltX30X__youngX_optionXgtX30X__oldX_optionXnone__on_the_edgeX()
 {
+        final Traversal<Vertex, Object> traversal = 
get_g_V_branchXageX_optionXltX30X__youngX_optionXgtX30X__oldX_optionXnone__on_the_edgeX();
+        printTraversalForm(traversal);
+        checkResults(Arrays.asList("young", "young", "old", "old"), traversal);
+    }
+
+    @Test
+    @LoadGraphWith(MODERN)
+    public void 
g_V_branchXidentityX_optionXhasLabelXsoftwareX__inXcreatedX_name_order_foldX_optionXhasXname_vadasX__ageX_optionXneqX123X__bothE_countX()
 {
+        final Traversal<Vertex, Object> traversal = 
get_g_V_branchXidentityX_optionXhasLabelXsoftwareX__inXcreatedX_name_order_foldX_optionXhasXname_vadasX__ageX_optionXneqX123X__bothE_countX();
+        printTraversalForm(traversal);
+        checkResults(Arrays.asList(Arrays.asList("josh", "josh", "marko", 
"peter"), 27, 12L), traversal);
+    }
+
     public static class Traversals extends BranchTest {
 
         @Override
@@ -95,5 +125,22 @@ public abstract class BranchTest extends 
AbstractGremlinProcessTest {
                     .option(0L, values("name"))
                     .option(any, label());
         }
+
+        @Override
+        public Traversal<Vertex, Object> 
get_g_V_branchXageX_optionXltX30X__youngX_optionXgtX30X__oldX_optionXnone__on_the_edgeX()
 {
+            return g.V().hasLabel("person")
+                    .branch(values("age"))
+                    .option(lt(30), constant("young"))
+                    .option(gt(30), constant("old"))
+                    .option(none, constant("on the edge"));
+        }
+
+        @Override
+        public Traversal<Vertex, Object> 
get_g_V_branchXidentityX_optionXhasLabelXsoftwareX__inXcreatedX_name_order_foldX_optionXhasXname_vadasX__ageX_optionXneqX123X__bothE_countX()
 {
+            return g.V().branch(identity())
+                    .option(hasLabel("software"), 
in("created").values("name").order().fold())
+                    .option(has("name","vadas"), values("age"))
+                    .option(neq(123), bothE().count());
+        }
     }
 }
\ No newline at end of file

Reply via email to