tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkupp...@apache.org
Subject [05/23] tinkerpop git commit: TINKERPOP-1874 Added tests around P
Date Wed, 24 Jan 2018 21:14:27 GMT
TINKERPOP-1874 Added tests around P

Validates various forms of serialization with focus on GraphSON and GLVs (where there were
problems).


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/261b93b6
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/261b93b6
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/261b93b6

Branch: refs/heads/TINKERPOP-1447
Commit: 261b93b646c503068328d291224b430e4618410b
Parents: 231bbb6
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Thu Jan 18 17:07:21 2018 -0500
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Thu Jan 18 17:07:21 2018 -0500

----------------------------------------------------------------------
 ...aphSONMapperV2d0PartialEmbeddedTypeTest.java | 29 ++++++++++
 .../traversal/step/filter/GroovyHasTest.groovy  | 20 +++++++
 gremlin-test/features/filter/Has.feature        | 44 ++++++++++++++
 .../process/traversal/step/filter/HasTest.java  | 60 ++++++++++++++++++++
 4 files changed, 153 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/261b93b6/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperV2d0PartialEmbeddedTypeTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperV2d0PartialEmbeddedTypeTest.java
b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperV2d0PartialEmbeddedTypeTest.java
index 28107d0..5b009e1 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperV2d0PartialEmbeddedTypeTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperV2d0PartialEmbeddedTypeTest.java
@@ -19,6 +19,7 @@
 package org.apache.tinkerpop.gremlin.structure.io.graphson;
 
 import org.apache.tinkerpop.gremlin.process.remote.traversal.DefaultRemoteTraverser;
+import org.apache.tinkerpop.gremlin.process.traversal.P;
 import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
 import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper;
 import org.junit.Test;
@@ -31,6 +32,7 @@ import java.time.Instant;
 import java.time.ZoneOffset;
 import java.time.ZonedDateTime;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -254,6 +256,33 @@ public class GraphSONMapperV2d0PartialEmbeddedTypeTest extends AbstractGraphSONT
         assertEquals(o, serializeDeserialize(mapper, o, Traverser.class));
     }
 
+    @Test
+    public void shouldHandleVariantsOfP() throws Exception {
+        final List<P> variantsOfP = Arrays.asList(
+                P.between(1,2),
+                P.eq(1),
+                P.gt(1),
+                P.gte(1),
+                P.inside(1,2),
+                P.lt(1),
+                P.lte(1),
+                P.neq(1),
+                P.not(P.eq(1)),
+                P.outside(1,2),
+                P.within(1),
+                P.within(1,2,3,4),
+                P.within(Arrays.asList(1,2,3,4)),
+                P.without(1),
+                P.without(1,2,3,4),
+                P.without(Arrays.asList(1,2,3,4)),
+                P.eq(1).and(P.eq(2)),
+                P.eq(1).or(P.eq(2)));
+
+        for (P p : variantsOfP) {
+            assertEquals(p, serializeDeserialize(mapper, p, P.class));
+        }
+    }
+
     // Class needs to be defined as statics as it's a nested class.
     public static class FunObject {
         private String val;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/261b93b6/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyHasTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyHasTest.groovy
b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyHasTest.groovy
index c70a50d..19bdf42 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyHasTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyHasTest.groovy
@@ -191,5 +191,25 @@ public abstract class GroovyHasTest {
         public Traversal<Vertex, Long> get_g_V_notXhasIdXwithinXemptyXXX_count() {
             new ScriptTraversal<>(g, "gremlin-groovy", "g.V.not(hasId(within([]))).count")
         }
+
+        @Override
+        public Traversal<Vertex, Long> get_g_V_hasXage_withinX27X_count() {
+            new ScriptTraversal<>(g, "gremlin-groovy", "g.V().has('age', P.within(27)).count()")
+        }
+
+        @Override
+        public Traversal<Vertex, Long> get_g_V_hasXage_withinX27_29X_count() {
+            new ScriptTraversal<>(g, "gremlin-groovy", "g.V().has('age', P.within(27,
29)).count()")
+        }
+
+        @Override
+        public Traversal<Vertex, Long> get_g_V_hasXage_withoutX27X_count() {
+            new ScriptTraversal<>(g, "gremlin-groovy", "g.V().has('age', P.without(27)).count()")
+        }
+
+        @Override
+        public Traversal<Vertex, Long> get_g_V_hasXage_withoutX27_29X_count() {
+            new ScriptTraversal<>(g, "gremlin-groovy", "g.V().has('age', P.without(27,
29)).count()")
+        }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/261b93b6/gremlin-test/features/filter/Has.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/filter/Has.feature b/gremlin-test/features/filter/Has.feature
index 797a1ec..55b46a7 100644
--- a/gremlin-test/features/filter/Has.feature
+++ b/gremlin-test/features/filter/Has.feature
@@ -43,3 +43,47 @@ Feature: Step - has()
       | v[josh] |
       | v[peter] |
 
+  Scenario: g_V_hasXage_withinX27X_count
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().has("age", P.within(27)).count()
+      """
+    When iterated to list
+    Then the result should be ordered
+      | result |
+      | d[1].l |
+
+  Scenario: g_V_hasXage_withinX27_29X_count
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().has("age", P.within(27,29)).count()
+      """
+    When iterated to list
+    Then the result should be ordered
+      | result |
+      | d[2].l |
+
+  Scenario: g_V_hasXage_withoutX27X_count
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().has("age", P.without(27)).count()
+      """
+    When iterated to list
+    Then the result should be ordered
+      | result |
+      | d[3].l |
+
+  Scenario: g_V_hasXage_withoutX27_29X_count
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().has("age", P.without(27,29)).count()
+      """
+    When iterated to list
+    Then the result should be ordered
+      | result |
+      | d[2].l |
+

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/261b93b6/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/HasTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/HasTest.java
b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/HasTest.java
index d8457f1..a5f4a62 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/HasTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/HasTest.java
@@ -117,6 +117,14 @@ public abstract class HasTest extends AbstractGremlinProcessTest {
 
     public abstract Traversal<Vertex, Long> get_g_V_notXhasIdXwithinXemptyXXX_count();
 
+    public abstract Traversal<Vertex, Long> get_g_V_hasXage_withinX27X_count();
+
+    public abstract Traversal<Vertex, Long> get_g_V_hasXage_withinX27_29X_count();
+
+    public abstract Traversal<Vertex, Long> get_g_V_hasXage_withoutX27X_count();
+
+    public abstract Traversal<Vertex, Long> get_g_V_hasXage_withoutX27_29X_count();
+
     @Test
     @LoadGraphWith(MODERN)
     public void g_V_outXcreatedX_hasXname__mapXlengthX_isXgtX3XXX_name() {
@@ -490,6 +498,38 @@ public abstract class HasTest extends AbstractGremlinProcessTest {
         assertEquals(6L, traversal.next().longValue());
     }
 
+    @Test
+    @LoadGraphWith(MODERN)
+    public void g_V_hasXage_withinX27X_count() {
+        final Traversal<Vertex, Long> traversal = get_g_V_hasXage_withinX27X_count();
+        printTraversalForm(traversal);
+        assertEquals(1L, traversal.next().longValue());
+    }
+
+    @Test
+    @LoadGraphWith(MODERN)
+    public void g_V_hasXage_withinX27_29X_count() {
+        final Traversal<Vertex, Long> traversal = get_g_V_hasXage_withinX27_29X_count();
+        printTraversalForm(traversal);
+        assertEquals(2L, traversal.next().longValue());
+    }
+
+    @Test
+    @LoadGraphWith(MODERN)
+    public void g_V_hasXage_withoutX27X_count() {
+        final Traversal<Vertex, Long> traversal = get_g_V_hasXage_withoutX27X_count();
+        printTraversalForm(traversal);
+        assertEquals(3L, traversal.next().longValue());
+    }
+
+    @Test
+    @LoadGraphWith(MODERN)
+    public void g_V_hasXage_withoutX27_29X_count() {
+        final Traversal<Vertex, Long> traversal = get_g_V_hasXage_withoutX27_29X_count();
+        printTraversalForm(traversal);
+        assertEquals(2L, traversal.next().longValue());
+    }
+
     public static class Traversals extends HasTest {
         @Override
         public Traversal<Edge, Edge> get_g_EX11X_outV_outE_hasXid_10X(final Object
e11Id, final Object e8Id) {
@@ -650,5 +690,25 @@ public abstract class HasTest extends AbstractGremlinProcessTest {
         public Traversal<Vertex, Long> get_g_V_notXhasIdXwithinXemptyXXX_count() {
             return g.V().not(__.hasId(P.within(Collections.emptyList()))).count();
         }
+
+        @Override
+        public Traversal<Vertex, Long> get_g_V_hasXage_withinX27X_count() {
+            return g.V().has("age", P.within(27)).count();
+        }
+
+        @Override
+        public Traversal<Vertex, Long> get_g_V_hasXage_withinX27_29X_count() {
+            return g.V().has("age", P.within(27, 29)).count();
+        }
+
+        @Override
+        public Traversal<Vertex, Long> get_g_V_hasXage_withoutX27X_count() {
+            return g.V().has("age", P.without(27)).count();
+        }
+
+        @Override
+        public Traversal<Vertex, Long> get_g_V_hasXage_withoutX27_29X_count() {
+            return g.V().has("age", P.without(27, 29)).count();
+        }
     }
 }
\ No newline at end of file


Mime
View raw message