You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2015/05/07 16:21:04 UTC

[2/4] incubator-tinkerpop git commit: TinkerGraph Computer and Standard tests now run against the process test suite without strategies -- well, a few key strategies are required. This is good to make sure that strategies are not changing the semantics o

TinkerGraph Computer and Standard tests now run against the process test suite without strategies -- well, a few key strategies are required. This is good to make sure that strategies are not changing the semantics of the traversal.


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

Branch: refs/heads/master
Commit: a8db176859ae476b4259a53a20db718ef19c0110
Parents: 90b75e2
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Thu May 7 08:20:08 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Thu May 7 08:20:08 2015 -0600

----------------------------------------------------------------------
 .../dsl/graph/GraphTraversalSource.java         |  2 +-
 .../traversal/step/map/AddVertexTest.java       |  3 +-
 .../step/sideEffect/TinkerGraphStep.java        |  2 +-
 .../TinkerGraphNoStrategyComputerProvider.java  | 67 ++++++++++++++++++++
 ...inkerGraphNoStrategyProcessComputerTest.java | 35 ++++++++++
 ...inkerGraphNoStrategyProcessStandardTest.java |  2 +-
 .../process/TinkerGraphNoStrategyProvider.java  | 63 ++++++++++++++++++
 .../process/TinkerNoStrategyGraphProvider.java  | 57 -----------------
 8 files changed, 170 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a8db1768/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
index 8115f81..401ae92 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.java
@@ -151,7 +151,7 @@ public class GraphTraversalSource implements TraversalSource {
 
     @Override
     public List<TraversalStrategy> getStrategies() {
-        return Collections.unmodifiableList(strategies.toList());
+        return Collections.unmodifiableList(this.strategies.toList());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a8db1768/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/AddVertexTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/AddVertexTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/AddVertexTest.java
index 2840cd5..9e6e7e9 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/AddVertexTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/AddVertexTest.java
@@ -56,8 +56,9 @@ public abstract class AddVertexTest extends AbstractGremlinTest {
             assertEquals(0, vertex.<Integer>value("age").intValue());
             count++;
         }
-        assertEquals(12, IteratorUtils.count(graph.vertices()));
         assertEquals(6, count);
+        assertEquals(12, IteratorUtils.count(graph.vertices()));
+
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a8db1768/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/step/sideEffect/TinkerGraphStep.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/step/sideEffect/TinkerGraphStep.java b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/step/sideEffect/TinkerGraphStep.java
index 8ae4344..8827c37 100644
--- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/step/sideEffect/TinkerGraphStep.java
+++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/process/traversal/step/sideEffect/TinkerGraphStep.java
@@ -74,7 +74,7 @@ public class TinkerGraphStep<S extends Element> extends GraphStep<S> implements
             return this.iteratorList(graph.vertices(this.ids));
         else
             return null == indexedContainer ?
-                    this.iteratorList(graph.vertices()) :
+                    this.iteratorList(graph.vertices()) :   // TODO: IteratorUtils.filter() using iteratorList() semantics.
                     TinkerHelper.queryVertexIndex(graph, indexedContainer.key, indexedContainer.value).stream()
                             .filter(vertex -> HasContainer.testAll(vertex, this.hasContainers))
                             .collect(Collectors.<Vertex>toList()).iterator();

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a8db1768/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyComputerProvider.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyComputerProvider.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyComputerProvider.java
new file mode 100644
index 0000000..0611afd
--- /dev/null
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyComputerProvider.java
@@ -0,0 +1,67 @@
+/*
+ *
+ *  * 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.tinkergraph.process;
+
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.engine.ComputerTraversalEngine;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ConjunctionStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.EngineDependentStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.ProfileStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ComputerVerificationStrategy;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+
+import java.util.Arrays;
+import java.util.HashSet;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class TinkerGraphNoStrategyComputerProvider extends TinkerGraphComputerProvider {
+
+    private static final HashSet<Class<? extends TraversalStrategy>> REQUIRED_STRATEGIES = new HashSet<>(Arrays.asList(
+            ComputerVerificationStrategy.class,
+            EngineDependentStrategy.class,
+            ProfileStrategy.class,
+            ConjunctionStrategy.class,
+            ComputerTraversalEngine.ComputerResultStrategy.class));
+
+    @Override
+    public GraphTraversalSource traversal(final Graph graph) {
+        final GraphTraversalSource.Builder builder = createBuilder(graph);
+        return builder.create(graph);
+    }
+
+    @Override
+    public GraphTraversalSource traversal(final Graph graph, final TraversalStrategy... strategies) {
+        final GraphTraversalSource.Builder builder = createBuilder(graph);
+        Arrays.asList(strategies).forEach(builder::with);
+        return builder.create(graph);
+    }
+
+    private GraphTraversalSource.Builder createBuilder(Graph graph) {
+        final GraphTraversalSource g = super.traversal(graph);
+        final GraphTraversalSource.Builder builder = g.asBuilder();
+        g.getStrategies().stream().map(strategy -> strategy.getClass()).filter(clazz -> !REQUIRED_STRATEGIES.contains(clazz)).forEach(builder::without);
+        return builder;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a8db1768/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyProcessComputerTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyProcessComputerTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyProcessComputerTest.java
new file mode 100644
index 0000000..99068c9
--- /dev/null
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyProcessComputerTest.java
@@ -0,0 +1,35 @@
+/*
+ *
+ *  * 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.tinkergraph.process;
+
+import org.apache.tinkerpop.gremlin.process.ProcessComputerSuite;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+@RunWith(ProcessComputerSuite.class)
+@ProcessComputerSuite.GraphProviderClass(provider = TinkerGraphNoStrategyComputerProvider.class, graph = TinkerGraph.class)
+public class TinkerGraphNoStrategyProcessComputerTest {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a8db1768/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyProcessStandardTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyProcessStandardTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyProcessStandardTest.java
index a9d4e35..8051365 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyProcessStandardTest.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyProcessStandardTest.java
@@ -28,6 +28,6 @@ import org.junit.runner.RunWith;
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 @RunWith(ProcessStandardSuite.class)
-@ProcessStandardSuite.GraphProviderClass(provider = TinkerNoStrategyGraphProvider.class, graph = TinkerGraph.class)
+@ProcessStandardSuite.GraphProviderClass(provider = TinkerGraphNoStrategyProvider.class, graph = TinkerGraph.class)
 public class TinkerGraphNoStrategyProcessStandardTest {
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a8db1768/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyProvider.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyProvider.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyProvider.java
new file mode 100644
index 0000000..578faec
--- /dev/null
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyProvider.java
@@ -0,0 +1,63 @@
+/*
+ * 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.tinkergraph.process;
+
+import org.apache.tinkerpop.gremlin.GraphProvider;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.ConjunctionStrategy;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.ProfileStrategy;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.tinkergraph.TinkerGraphProvider;
+import org.apache.tinkerpop.gremlin.tinkergraph.process.traversal.strategy.optimization.TinkerGraphStepStrategy;
+
+import java.util.Arrays;
+import java.util.HashSet;
+
+/**
+ * A {@link GraphProvider} that constructs a {@link TraversalSource} with no default strategies applied.  This allows
+ * the process tests to be executed without strategies applied.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class TinkerGraphNoStrategyProvider extends TinkerGraphProvider {
+
+    private static final HashSet<Class<? extends TraversalStrategy>> REQUIRED_STRATEGIES = new HashSet<>(Arrays.asList(TinkerGraphStepStrategy.class, ProfileStrategy.class, ConjunctionStrategy.class));
+
+    @Override
+    public GraphTraversalSource traversal(final Graph graph) {
+        final GraphTraversalSource.Builder builder = createBuilder(graph);
+        return builder.create(graph);
+    }
+
+    @Override
+    public GraphTraversalSource traversal(final Graph graph, final TraversalStrategy... strategies) {
+        final GraphTraversalSource.Builder builder = createBuilder(graph);
+        Arrays.asList(strategies).forEach(builder::with);
+        return builder.create(graph);
+    }
+
+    private GraphTraversalSource.Builder createBuilder(Graph graph) {
+        final GraphTraversalSource g = super.traversal(graph);
+        final GraphTraversalSource.Builder builder = g.asBuilder();
+        g.getStrategies().stream().map(strategy -> strategy.getClass()).filter(clazz -> !REQUIRED_STRATEGIES.contains(clazz)).forEach(builder::without);
+        return builder;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a8db1768/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerNoStrategyGraphProvider.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerNoStrategyGraphProvider.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerNoStrategyGraphProvider.java
deleted file mode 100644
index 014d449..0000000
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerNoStrategyGraphProvider.java
+++ /dev/null
@@ -1,57 +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.tinkergraph.process;
-
-import org.apache.tinkerpop.gremlin.GraphProvider;
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalSource;
-import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.tinkergraph.TinkerGraphProvider;
-
-import java.util.Arrays;
-
-/**
- * A {@link GraphProvider} that constructs a {@link TraversalSource} with no default strategies applied.  This allows
- * the process tests to be executed without strategies applied.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public class TinkerNoStrategyGraphProvider extends TinkerGraphProvider {
-
-    @Override
-    public GraphTraversalSource traversal(final Graph graph) {
-        final GraphTraversalSource.Builder builder = createBuilder(graph);
-        return builder.create(graph);
-    }
-
-    @Override
-    public GraphTraversalSource traversal(final Graph graph, final TraversalStrategy... strategies) {
-        final GraphTraversalSource.Builder builder = createBuilder(graph);
-        Arrays.asList(strategies).forEach(builder::with);
-        return builder.create(graph);
-    }
-
-    private GraphTraversalSource.Builder createBuilder(Graph graph) {
-        final GraphTraversalSource g = super.traversal(graph);
-        final GraphTraversalSource.Builder builder = GraphTraversalSource.build();
-        g.getStrategies().stream().map(strategy -> strategy.getClass()).forEach(builder::without);
-        return builder;
-    }
-}