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 2016/08/27 00:54:31 UTC

[16/50] [abbrv] tinkerpop git commit: more GroovyTranslatorTest to jsr223.

more GroovyTranslatorTest to jsr223.


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

Branch: refs/heads/master
Commit: af4f9237fc59e7432b2a758fb56d2d3dc83b03cc
Parents: d5ff0ad
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Thu Aug 25 06:21:12 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Thu Aug 25 06:21:25 2016 -0600

----------------------------------------------------------------------
 .../gremlin/groovy/GroovyEnvironmentSuite.java  |  1 +
 .../gremlin/groovy/GroovyTranslatorTest.java    | 90 --------------------
 .../groovy/jsr223/GroovyTranslatorTest.java     | 90 ++++++++++++++++++++
 3 files changed, 91 insertions(+), 90 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/af4f9237/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentSuite.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentSuite.java b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentSuite.java
index 05699c1..be89f65 100644
--- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentSuite.java
+++ b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentSuite.java
@@ -27,6 +27,7 @@ import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngineOverG
 import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngineSandboxCustomTest;
 import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngineSandboxedStandardTest;
 import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngineTinkerPopSandboxTest;
+import org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyTranslatorTest;
 import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoader;
 import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoaderTest;
 import org.apache.tinkerpop.gremlin.groovy.plugin.dsl.credential.CredentialGraphTest;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/af4f9237/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyTranslatorTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyTranslatorTest.java b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyTranslatorTest.java
deleted file mode 100644
index 15d7667..0000000
--- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyTranslatorTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-
-package org.apache.tinkerpop.gremlin.groovy;
-
-import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
-import org.apache.tinkerpop.gremlin.LoadGraphWith;
-import org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyTranslator;
-import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.TranslationStrategy;
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.util.function.Lambda;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class GroovyTranslatorTest extends AbstractGremlinTest {
-
-    @Test
-    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
-    public void shouldSupportStringSupplierLambdas() throws Exception {
-        GraphTraversalSource g = graph.traversal();
-        g = g.withStrategies(new TranslationStrategy(g, GroovyTranslator.of("g")));
-        GraphTraversal.Admin<Vertex, Integer> t = g.withSideEffect("lengthSum", 0).withSack(1)
-                .V()
-                .filter(Lambda.predicate("it.get().label().equals('person')"))
-                .flatMap(Lambda.function("it.get().vertices(Direction.OUT)"))
-                .map(Lambda.<Traverser<Object>, Integer>function("it.get().value('name').length()"))
-                .sideEffect(Lambda.consumer("{ x -> x.sideEffects(\"lengthSum\", x.<Integer>sideEffects('lengthSum') + x.get()) }"))
-                .order().by(Lambda.comparator("a,b -> a <=> b"))
-                .sack(Lambda.biFunction("{ a,b -> a + b }"))
-                .asAdmin();
-        final List<Integer> sacks = new ArrayList<>();
-        final List<Integer> lengths = new ArrayList<>();
-        while (t.hasNext()) {
-            final Traverser.Admin<Integer> traverser = t.nextTraverser();
-            sacks.add(traverser.sack());
-            lengths.add(traverser.get());
-        }
-        assertFalse(t.hasNext());
-        //
-        assertEquals(6, lengths.size());
-        assertEquals(3, lengths.get(0).intValue());
-        assertEquals(3, lengths.get(1).intValue());
-        assertEquals(3, lengths.get(2).intValue());
-        assertEquals(4, lengths.get(3).intValue());
-        assertEquals(5, lengths.get(4).intValue());
-        assertEquals(6, lengths.get(5).intValue());
-        ///
-        assertEquals(6, sacks.size());
-        assertEquals(4, sacks.get(0).intValue());
-        assertEquals(4, sacks.get(1).intValue());
-        assertEquals(4, sacks.get(2).intValue());
-        assertEquals(5, sacks.get(3).intValue());
-        assertEquals(6, sacks.get(4).intValue());
-        assertEquals(7, sacks.get(5).intValue());
-        //
-        assertEquals(24, t.getSideEffects().<Number>get("lengthSum").intValue());
-    }
-
-    @Test
-    public void shouldHaveValidToString() {
-        assertEquals("translator[h:gremlin-groovy]", GroovyTranslator.of("h").toString());
-    }
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/af4f9237/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorTest.java b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorTest.java
new file mode 100644
index 0000000..8060d39
--- /dev/null
+++ b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorTest.java
@@ -0,0 +1,90 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.groovy.jsr223;
+
+import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
+import org.apache.tinkerpop.gremlin.LoadGraphWith;
+import org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyTranslator;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.TranslationStrategy;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.util.function.Lambda;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class GroovyTranslatorTest extends AbstractGremlinTest {
+
+    @Test
+    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    public void shouldSupportStringSupplierLambdas() throws Exception {
+        GraphTraversalSource g = graph.traversal();
+        g = g.withStrategies(new TranslationStrategy(g, GroovyTranslator.of("g")));
+        GraphTraversal.Admin<Vertex, Integer> t = g.withSideEffect("lengthSum", 0).withSack(1)
+                .V()
+                .filter(Lambda.predicate("it.get().label().equals('person')"))
+                .flatMap(Lambda.function("it.get().vertices(Direction.OUT)"))
+                .map(Lambda.<Traverser<Object>, Integer>function("it.get().value('name').length()"))
+                .sideEffect(Lambda.consumer("{ x -> x.sideEffects(\"lengthSum\", x.<Integer>sideEffects('lengthSum') + x.get()) }"))
+                .order().by(Lambda.comparator("a,b -> a <=> b"))
+                .sack(Lambda.biFunction("{ a,b -> a + b }"))
+                .asAdmin();
+        final List<Integer> sacks = new ArrayList<>();
+        final List<Integer> lengths = new ArrayList<>();
+        while (t.hasNext()) {
+            final Traverser.Admin<Integer> traverser = t.nextTraverser();
+            sacks.add(traverser.sack());
+            lengths.add(traverser.get());
+        }
+        assertFalse(t.hasNext());
+        //
+        assertEquals(6, lengths.size());
+        assertEquals(3, lengths.get(0).intValue());
+        assertEquals(3, lengths.get(1).intValue());
+        assertEquals(3, lengths.get(2).intValue());
+        assertEquals(4, lengths.get(3).intValue());
+        assertEquals(5, lengths.get(4).intValue());
+        assertEquals(6, lengths.get(5).intValue());
+        ///
+        assertEquals(6, sacks.size());
+        assertEquals(4, sacks.get(0).intValue());
+        assertEquals(4, sacks.get(1).intValue());
+        assertEquals(4, sacks.get(2).intValue());
+        assertEquals(5, sacks.get(3).intValue());
+        assertEquals(6, sacks.get(4).intValue());
+        assertEquals(7, sacks.get(5).intValue());
+        //
+        assertEquals(24, t.getSideEffects().<Number>get("lengthSum").intValue());
+    }
+
+    @Test
+    public void shouldHaveValidToString() {
+        assertEquals("translator[h:gremlin-groovy]", GroovyTranslator.of("h").toString());
+    }
+}