tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ok...@apache.org
Subject incubator-tinkerpop git commit: added test to make sure declared SideEffect is ultimate returned class.
Date Thu, 03 Mar 2016 20:08:05 GMT
Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1192 5ec7dd063 -> ff390381b


added test to make sure declared SideEffect is ultimate returned class.


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

Branch: refs/heads/TINKERPOP-1192
Commit: ff390381b9896a16c73a056f167e84f2beb8f1d6
Parents: 5ec7dd0
Author: Marko A. Rodriguez <okrammarko@gmail.com>
Authored: Thu Mar 3 13:07:52 2016 -0700
Committer: Marko A. Rodriguez <okrammarko@gmail.com>
Committed: Thu Mar 3 13:07:52 2016 -0700

----------------------------------------------------------------------
 .../step/sideEffect/GroovySideEffectTest.groovy |  7 +++
 .../step/sideEffect/SideEffectTest.java         | 47 +++++++++++++++++++-
 2 files changed, 53 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/ff390381/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySideEffectTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySideEffectTest.groovy
b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySideEffectTest.groovy
index 68135f9..5870457 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySideEffectTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySideEffectTest.groovy
@@ -50,5 +50,12 @@ public abstract class GroovySideEffectTest {
         public Traversal<Vertex, String> get_g_VX1X_out_sideEffectXX_name(final Object
v1Id) {
             new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).out().sideEffect
{}.name", "v1Id", v1Id)
         }
+
+        @Override
+        public Traversal<Vertex, Map<String, Long>> get_g_withSideEffectXa__linkedhashmapX_V_out_groupCountXaX_byXlabelX_out_out_capXaX()
{
+            new ScriptTraversal<>(g, "gremlin-groovy", "g.withSideEffect('a'){[:] as
LinkedHashMap}.V.out.groupCount('a').by(label).out.out.cap('a')");
+        }
+
+
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/ff390381/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SideEffectTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SideEffectTest.java
b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SideEffectTest.java
index e1990b6..d0b4e19 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SideEffectTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SideEffectTest.java
@@ -24,16 +24,23 @@ import org.apache.tinkerpop.gremlin.process.GremlinProcessRunner;
 import org.apache.tinkerpop.gremlin.process.IgnoreEngine;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalSideEffects;
+import org.apache.tinkerpop.gremlin.structure.T;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.function.Supplier;
 
 import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.MODERN;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
@@ -48,6 +55,8 @@ public abstract class SideEffectTest extends AbstractGremlinProcessTest
{
 
     public abstract Traversal<Vertex, String> get_g_VX1X_out_sideEffectXX_name(final
Object v1Id);
 
+    public abstract Traversal<Vertex, Map<String, Long>> get_g_withSideEffectXa__linkedhashmapX_V_out_groupCountXaX_byXlabelX_out_out_capXaX();
+
     @Test
     @LoadGraphWith(MODERN)
     @IgnoreEngine(TraversalEngine.Type.COMPUTER)
@@ -88,6 +97,28 @@ public abstract class SideEffectTest extends AbstractGremlinProcessTest
{
         assert_g_v1_out_sideEffectXincr_cX_valueXnameX(traversal);
     }
 
+    @Test
+    @LoadGraphWith(MODERN)
+    public void g_withSideEffectXa__linkedhashmapX_V_out_groupCountXaX_byXlabelX_out_out_capXaX()
{
+        final Traversal<Vertex, Map<String, Long>> traversal = get_g_withSideEffectXa__linkedhashmapX_V_out_groupCountXaX_byXlabelX_out_out_capXaX();
+        printTraversalForm(traversal);
+        Map<String, Long> map = traversal.next();
+        assertFalse(traversal.hasNext());
+        assertEquals(2, map.size());
+        assertEquals(4l, map.get("software").longValue());
+        assertEquals(2l, map.get("person").longValue());
+        final TraversalSideEffects sideEffects = traversal.asAdmin().getSideEffects();
+        map = sideEffects.get("a");
+        assertEquals(2, map.size());
+        assertEquals(4l, map.get("software").longValue());
+        assertEquals(2l, map.get("person").longValue());
+        ///
+        assertEquals(1, sideEffects.keys().size());
+        assertTrue(sideEffects.keys().contains("a"));
+        assertTrue(sideEffects.exists("a"));
+        assertTrue(sideEffects.get("a") instanceof LinkedHashMap);
+    }
+
     public static class Traversals extends SideEffectTest {
 
         @Override
@@ -116,5 +147,19 @@ public abstract class SideEffectTest extends AbstractGremlinProcessTest
{
             return g.V(v1Id).out().sideEffect(traverser -> {
             }).values("name");
         }
+
+        @Override
+        public Traversal<Vertex, Map<String, Long>> get_g_withSideEffectXa__linkedhashmapX_V_out_groupCountXaX_byXlabelX_out_out_capXaX()
{
+            return g.withSideEffect("a", new LinkedHashMapSupplier()).V().out().groupCount("a").by(T.label).out().out().cap("a");
+        }
+    }
+
+    private static class LinkedHashMapSupplier implements Supplier<LinkedHashMap> {
+
+        @Override
+        public LinkedHashMap get() {
+            return new LinkedHashMap();
+        }
+
     }
 }


Mime
View raw message