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/15 17:42:27 UTC

incubator-tinkerpop git commit: SugarLoader now makes sure that the Mixin for GraphTraversalSource has a proper toString(). Added test cases for all mixins in SugarLoader.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master e48162f8f -> 143b9a6c5


SugarLoader now makes sure that the Mixin for GraphTraversalSource has a proper toString(). Added test cases for all mixins in SugarLoader.


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

Branch: refs/heads/master
Commit: 143b9a6c592ba0c97fb9728b80d138297fd13ed7
Parents: e48162f
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Fri May 15 09:42:08 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Fri May 15 09:42:21 2015 -0600

----------------------------------------------------------------------
 .../traversal/step/filter/WhereStep.java        |  9 +++++--
 .../groovy/loaders/SugarLoaderTest.groovy       | 26 ++++++++++++++++++--
 .../gremlin/groovy/loaders/SugarLoader.groovy   |  8 +++---
 3 files changed, 35 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/143b9a6c/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/WhereStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/WhereStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/WhereStep.java
index a09aaeb..55fe85b 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/WhereStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/WhereStep.java
@@ -83,7 +83,7 @@ public final class WhereStep<S> extends FilterStep<S> implements TraversalParent
     }
 
     @Override
-    public List<Traversal.Admin> getLocalChildren() {
+    public List<Traversal.Admin<?,?>> getLocalChildren() {
         return this.predicate.getBiPredicate() instanceof BiPredicateTraversal ? Collections.singletonList(((BiPredicateTraversal) this.predicate.getBiPredicate()).getTraversal()) : Collections.emptyList();
     }
 
@@ -102,7 +102,8 @@ public final class WhereStep<S> extends FilterStep<S> implements TraversalParent
 
     @Override
     public Set<TraverserRequirement> getRequirements() {
-        return this.getSelfAndChildRequirements(Scope.local == this.scope ? TraverserRequirement.OBJECT : TraverserRequirement.OBJECT, TraverserRequirement.PATH, TraverserRequirement.SIDE_EFFECTS);
+        return this.getSelfAndChildRequirements(Scope.local == this.scope || !this.usesPathOrSideEffects() ?
+                TraverserRequirement.OBJECT : TraverserRequirement.OBJECT, TraverserRequirement.PATH, TraverserRequirement.SIDE_EFFECTS);
     }
 
     public void setScope(final Scope scope) {
@@ -113,4 +114,8 @@ public final class WhereStep<S> extends FilterStep<S> implements TraversalParent
     public Scope recommendNextScope() {
         return this.scope;
     }
+
+    private boolean usesPathOrSideEffects() {
+        return null != this.endKey && null != this.startKey;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/143b9a6c/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderTest.groovy
index 15e4c6d..1ade3a0 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderTest.groovy
@@ -21,8 +21,9 @@ package org.apache.tinkerpop.gremlin.groovy.loaders
 import org.apache.tinkerpop.gremlin.AbstractGremlinTest
 import org.apache.tinkerpop.gremlin.LoadGraphWith
 import org.apache.tinkerpop.gremlin.groovy.util.SugarTestHelper
-import org.apache.tinkerpop.gremlin.structure.Graph
-import org.apache.tinkerpop.gremlin.structure.Vertex
+import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper
+import org.apache.tinkerpop.gremlin.structure.*
+import org.apache.tinkerpop.gremlin.structure.util.StringFactory
 import org.junit.Test
 
 import static org.junit.Assert.*
@@ -95,4 +96,25 @@ class SugarLoaderTest extends AbstractGremlinTest {
             assertTrue(it[2] instanceof Integer)
         };
     }
+
+    @Test
+    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    public void shouldHaveProperToStringOfMixins() {
+        SugarLoader.load();
+        final Vertex vertex = graph.vertices().next();
+        final Edge edge = graph.edges().next();
+        final VertexProperty vertexProperty = vertex.property('name');
+        final Property property = edge.property('weight');
+
+        assertEquals(StringFactory.vertexString(vertex), vertex.toString());
+        assertEquals(StringFactory.edgeString(edge), edge.toString());
+        assertEquals(StringFactory.propertyString(vertexProperty), vertexProperty.toString());
+        assertEquals(StringFactory.propertyString(property), property.toString());
+        assertEquals(StringFactory.traversalSourceString(g), g.toString());
+        //assertEquals(StringFactory.traversalSourceString(g.withPath()), g.withPath().toString());
+        assertEquals(TraversalHelper.makeTraversalString(g.V().out().asAdmin()), g.V().out().toString());
+        assertEquals(TraversalHelper.makeTraversalString(g.V.out), g.V.out.toString());
+        assertEquals(convertToVertex(graph, "marko").toString(), g.V(convertToVertexId("marko")).next().toString())
+
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/143b9a6c/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoader.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoader.groovy b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoader.groovy
index 213b335..244ea54 100644
--- a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoader.groovy
+++ b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoader.groovy
@@ -163,9 +163,9 @@ class SugarLoader {
                 throw new UnsupportedOperationException("The provided key does not reference a known method: " + key);
         }
 
-        /*public String toString() {
-            return StringFactory.graphString(this.metaClass.owner, "");
-        }*/
+        public String toString() {
+            return StringFactory.traversalSourceString(this.metaClass.owner);
+        }
     }
 
     public static class GraphTraversalSourceStubCategory {
@@ -183,7 +183,7 @@ class SugarLoader {
         }
 
         /*public String toString() {
-            return StringFactory.graphString(this.metaClass.owner, "");
+            return StringFactory.traversalSourceString(this.metaClass.owner);
         }*/
     }