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/15 19:47:29 UTC

[07/50] incubator-tinkerpop git commit: Add tests to enforce Element equality.

Add tests to enforce Element equality.

This makes it so that both the id() and id().toString() both can be used to evaluate equality.  The toString() of an id() is now a first-class representation of an identifier.  See TINKERPOP3-581 for more details


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

Branch: refs/heads/variables
Commit: bb86121ae7bd24bf2da030d300d5fcf5b65049db
Parents: 0c16dc8
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Apr 13 16:32:59 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Apr 13 16:32:59 2015 -0400

----------------------------------------------------------------------
 .../tinkerpop/gremlin/structure/EdgeTest.java   | 29 ++++++++++++++++++
 .../gremlin/structure/VertexPropertyTest.java   | 31 ++++++++++++++++++++
 .../tinkerpop/gremlin/structure/VertexTest.java | 25 ++++++++++++++++
 3 files changed, 85 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bb86121a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/EdgeTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/EdgeTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/EdgeTest.java
index 67eedf3..54368a6 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/EdgeTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/EdgeTest.java
@@ -54,6 +54,35 @@ public class EdgeTest {
     })
     public static class BasicEdgeTest extends AbstractGremlinTest {
         @Test
+        @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
+        @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
+        public void shouldValidateEquality() {
+            final Vertex v = graph.addVertex();
+            final Edge e1 = v.addEdge("self", v);
+            final Edge e2 = v.addEdge("self", v);
+
+            assertEquals(e1, e1);
+            assertEquals(e2, e2);
+            assertNotEquals(e1, e2);
+        }
+
+        @Test
+        @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
+        @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
+        public void shouldValidateIdEquality() {
+            final Vertex v = graph.addVertex();
+            final Edge e1 = v.addEdge("self", v);
+            final Edge e2 = v.addEdge("self", v);
+
+            assertEquals(e1.id(), e1.id());
+            assertEquals(e2.id(), e2.id());
+            assertEquals(e1.id().toString(), e1.id().toString());
+            assertEquals(e2.id().toString(), e2.id().toString());
+            assertNotEquals(e1.id(), e2.id());
+            assertNotEquals(e1.id().toString(), e2.id().toString());
+        }
+
+        @Test
         @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
         @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
         public void shouldHaveStandardStringRepresentation() {

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bb86121a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/VertexPropertyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/VertexPropertyTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/VertexPropertyTest.java
index 35fbf73..099108d 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/VertexPropertyTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/VertexPropertyTest.java
@@ -49,6 +49,37 @@ import static org.junit.Assert.*;
 @RunWith(Enclosed.class)
 public class VertexPropertyTest extends AbstractGremlinTest {
 
+    public static class BasicVertexProperty extends AbstractGremlinTest {
+        @Test
+        @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
+        @FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = Graph.Features.VertexPropertyFeatures.FEATURE_INTEGER_VALUES)
+        public void shouldValidateEquality() {
+            final Vertex v = graph.addVertex();
+            final VertexProperty vp1 = v.property("x", 0);
+            final VertexProperty vp2 = v.property("y", 1);
+
+            assertEquals(vp1, vp1);
+            assertEquals(vp2, vp2);
+            assertNotEquals(vp1, vp2);
+        }
+
+        @Test
+        @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
+        @FeatureRequirement(featureClass = Graph.Features.VertexPropertyFeatures.class, feature = Graph.Features.VertexPropertyFeatures.FEATURE_INTEGER_VALUES)
+        public void shouldValidateIdEquality() {
+            final Vertex v = graph.addVertex();
+            final VertexProperty vp1 = v.property("x", 0);
+            final VertexProperty vp2 = v.property("y", 1);
+
+            assertEquals(vp1.id(), vp1.id());
+            assertEquals(vp2.id(), vp2.id());
+            assertEquals(vp1.id().toString(), vp1.id().toString());
+            assertEquals(vp2.id().toString(), vp2.id().toString());
+            assertNotEquals(vp1.id(), vp2.id());
+            assertNotEquals(vp1.id().toString(), vp2.id().toString());
+        }
+    }
+
     public static class VertexPropertyAddition extends AbstractGremlinTest {
 
         @Test

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bb86121a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/VertexTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/VertexTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/VertexTest.java
index de2a20e..bbbf184 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/VertexTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/VertexTest.java
@@ -164,6 +164,31 @@ public class VertexTest {
     public static class BasicVertexTest extends AbstractGremlinTest {
         @Test
         @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
+        public void shouldValidateEquality() {
+            final Vertex v1 = graph.addVertex();
+            final Vertex v2 = graph.addVertex();
+
+            assertEquals(v1, v1);
+            assertEquals(v2, v2);
+            assertNotEquals(v1, v2);
+        }
+
+        @Test
+        @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
+        public void shouldValidateIdEquality() {
+            final Vertex v1 = graph.addVertex();
+            final Vertex v2 = graph.addVertex();
+
+            assertEquals(v1.id(), v1.id());
+            assertEquals(v2.id(), v2.id());
+            assertEquals(v1.id().toString(), v1.id().toString());
+            assertEquals(v2.id().toString(), v2.id().toString());
+            assertNotEquals(v1.id(), v2.id());
+            assertNotEquals(v1.id().toString(), v2.id().toString());
+        }
+
+        @Test
+        @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
         public void shouldHaveExceptionConsistencyWhenUsingNullVertexLabel() {
             try {
                 graph.addVertex(T.label, null);