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/04/24 17:45:56 UTC

[10/31] incubator-tinkerpop git commit: fixed a bug in Attachable.GET around attaching properties to the edges of a vertex.

fixed a bug in Attachable.GET around attaching properties to the edges of a vertex.


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

Branch: refs/heads/master
Commit: ea5a489177ea095b9e2438723d6539bb9e8a55ca
Parents: 0868203
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Thu Apr 23 16:10:44 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Thu Apr 23 16:10:44 2015 -0600

----------------------------------------------------------------------
 .../tinkerpop/gremlin/structure/util/Attachable.java  | 14 ++++++++------
 .../gremlin/structure/util/star/StarGraphTest.java    |  6 +++---
 2 files changed, 11 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/ea5a4891/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
index bc1c386..5d50779 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java
@@ -30,7 +30,6 @@ import org.apache.tinkerpop.gremlin.structure.VertexProperty;
 
 import java.util.Iterator;
 import java.util.Optional;
-import java.util.function.BiFunction;
 import java.util.function.Function;
 
 /**
@@ -184,11 +183,11 @@ public interface Attachable<V> {
         }
 
         public static Optional<Edge> getEdge(final Attachable<Edge> attachableEdge, final Vertex hostVertex) {
-            final Object baseId = attachableEdge.get().id();
+            final Edge baseEdge = attachableEdge.get();
             final Iterator<Edge> edgeIterator = hostVertex.edges(Direction.OUT);
             while (edgeIterator.hasNext()) {
                 final Edge edge = edgeIterator.next();
-                if (edge.id().equals(baseId))
+                if (ElementHelper.areEqual(edge, baseEdge))
                     return Optional.of(edge);
             }
             return Optional.empty();
@@ -259,9 +258,12 @@ public interface Attachable<V> {
             } else if (propertyElement instanceof Edge) {
                 final Iterator<Edge> edgeIterator = hostVertex.edges(Direction.OUT);
                 while (edgeIterator.hasNext()) {
-                    final Property property = edgeIterator.next().property(baseProperty.key());
-                    if (property.isPresent() && property.value().equals(baseProperty.value()))
-                        return Optional.of(property);
+                    final Edge edge = edgeIterator.next();
+                    if (ElementHelper.areEqual(edge, propertyElement)) {
+                        final Property property = edge.property(baseProperty.key());
+                        if (ElementHelper.areEqual(baseProperty, property))
+                            return Optional.of(property);
+                    }
                 }
                 return Optional.empty();
             } else { // vertex property

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/ea5a4891/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java
index afa151e..abc388b 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphTest.java
@@ -91,18 +91,18 @@ public class StarGraphTest extends AbstractGremlinTest {
     }
 
     @Test
-    @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    @LoadGraphWith(LoadGraphWith.GraphData.CREW)
     public void testAttachableGetMethod() {
         // vertex host
         g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().properties().forEachRemaining(vertexProperty -> validateVertexProperty(vertexProperty, ((Attachable<VertexProperty>) vertexProperty).attach(vertex, Attachable.Method.GET))));
-        g.V().forEachRemaining(vertex -> vertex.properties().forEachRemaining(vertexProperty -> vertexProperty.properties().forEachRemaining(property -> ((Attachable<Property>) property).attach(vertex, Attachable.Method.GET))));
+        g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().properties().forEachRemaining(vertexProperty -> vertexProperty.properties().forEachRemaining(property -> validateProperty(property, ((Attachable<Property>) property).attach(vertex, Attachable.Method.GET)))));
         g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().edges(Direction.OUT).forEachRemaining(edge -> validateEdge(edge, ((Attachable<Edge>) edge).attach(vertex, Attachable.Method.GET))));
         g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().edges(Direction.OUT).forEachRemaining(edge -> edge.properties().forEachRemaining(property -> validateProperty(property, ((Attachable<Property>) property).attach(vertex, Attachable.Method.GET)))));
 
         // graph host
         g.V().forEachRemaining(vertex -> validateVertex(vertex, StarGraph.of(vertex).getStarVertex().attach(graph, Attachable.Method.GET)));
         g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().properties().forEachRemaining(vertexProperty -> validateVertexProperty(vertexProperty, ((Attachable<VertexProperty>) vertexProperty).attach(graph, Attachable.Method.GET))));
-        g.V().forEachRemaining(vertex -> vertex.properties().forEachRemaining(vertexProperty -> vertexProperty.properties().forEachRemaining(property -> ((Attachable<Property>) property).attach(graph, Attachable.Method.GET))));
+        g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().properties().forEachRemaining(vertexProperty -> vertexProperty.properties().forEachRemaining(property -> validateProperty(property, ((Attachable<Property>) property).attach(graph, Attachable.Method.GET)))));
         g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().edges(Direction.OUT).forEachRemaining(edge -> validateEdge(edge, ((Attachable<Edge>) edge).attach(graph, Attachable.Method.GET))));
         g.V().forEachRemaining(vertex -> StarGraph.of(vertex).getStarVertex().edges(Direction.OUT).forEachRemaining(edge -> edge.properties().forEachRemaining(property -> validateProperty(property, ((Attachable<Property>) property).attach(graph, Attachable.Method.GET)))));
     }