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 2015/05/07 15:35:34 UTC

[4/4] incubator-tinkerpop git commit: Implemented a method to execute process tests without strategies. TINKERPOP3-668

Implemented a method to execute process tests without strategies. TINKERPOP3-668

There are currently some failing tests in implementing this approach.


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

Branch: refs/heads/no-strategy-test
Commit: 90b75e2cb6c73bcf15c80a7c2a62ced6f338c53b
Parents: 135563a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 7 09:33:57 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu May 7 09:33:57 2015 -0400

----------------------------------------------------------------------
 .../process/traversal/TraversalSource.java      |  3 ++
 .../dsl/graph/GraphTraversalSource.java         |  7 ++-
 ...inkerGraphNoStrategyProcessStandardTest.java | 33 ++++++++++++
 .../process/TinkerNoStrategyGraphProvider.java  | 57 ++++++++++++++++++++
 4 files changed, 99 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/90b75e2c/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalSource.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalSource.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalSource.java
index db32d00..138ed73 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalSource.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalSource.java
@@ -22,6 +22,7 @@ import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 
 import java.io.Serializable;
+import java.util.List;
 import java.util.Optional;
 
 /**
@@ -38,6 +39,8 @@ public interface TraversalSource {
 
     public Optional<Graph> getGraph();
 
+    public List<TraversalStrategy> getStrategies();
+
     ////////////////
 
     public interface Builder<C extends TraversalSource> extends Serializable {

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/90b75e2c/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 570c78c..8115f81 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
@@ -36,6 +36,7 @@ import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
 import org.apache.tinkerpop.gremlin.util.function.ConstantSupplier;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
 import java.util.function.Supplier;
@@ -148,6 +149,10 @@ public class GraphTraversalSource implements TraversalSource {
         return new Builder();
     }
 
+    @Override
+    public List<TraversalStrategy> getStrategies() {
+        return Collections.unmodifiableList(strategies.toList());
+    }
 
     @Override
     public Optional<GraphComputer> getGraphComputer() {
@@ -196,7 +201,7 @@ public class GraphTraversalSource implements TraversalSource {
         }
 
         @Override
-        public TraversalSource.Builder without(Class<? extends TraversalStrategy> strategyClass) {
+        public TraversalSource.Builder without(final Class<? extends TraversalStrategy> strategyClass) {
             this.withoutStrategies.add(strategyClass);
             return this;
         }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/90b75e2c/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
new file mode 100644
index 0000000..a9d4e35
--- /dev/null
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerGraphNoStrategyProcessStandardTest.java
@@ -0,0 +1,33 @@
+/*
+ * 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.ProcessStandardSuite;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.junit.runner.RunWith;
+
+/**
+ * Executes the Standard Gremlin Process Test Suite using TinkerGraph.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+@RunWith(ProcessStandardSuite.class)
+@ProcessStandardSuite.GraphProviderClass(provider = TinkerNoStrategyGraphProvider.class, graph = TinkerGraph.class)
+public class TinkerGraphNoStrategyProcessStandardTest {
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/90b75e2c/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
new file mode 100644
index 0000000..014d449
--- /dev/null
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/process/TinkerNoStrategyGraphProvider.java
@@ -0,0 +1,57 @@
+/*
+ * 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;
+    }
+}