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/06/01 14:26:53 UTC

incubator-tinkerpop git commit: Used assumptions in supplied id feature tests TINKERPOP-695

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master bfe1e983f -> c520013de


Used assumptions in supplied id feature tests TINKERPOP-695

Assumptions allow the test to ignore rather than just pass which could be misleading in some sense.


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

Branch: refs/heads/master
Commit: c520013dea8900f65047d7ea7c3575625c3533a2
Parents: bfe1e98
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jun 1 08:25:46 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Jun 1 08:25:46 2015 -0400

----------------------------------------------------------------------
 .../gremlin/structure/FeatureSupportTest.java   | 205 +++++++++++--------
 1 file changed, 119 insertions(+), 86 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/c520013d/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/FeatureSupportTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/FeatureSupportTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/FeatureSupportTest.java
index 693d8f6..c2106cb 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/FeatureSupportTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/FeatureSupportTest.java
@@ -43,6 +43,7 @@ import static org.apache.tinkerpop.gremlin.structure.Graph.Features.VariableFeat
 import static org.apache.tinkerpop.gremlin.structure.Graph.Features.VertexFeatures.FEATURE_USER_SUPPLIED_IDS;
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.*;
+import static org.junit.Assume.assumeFalse;
 import static org.junit.Assume.assumeThat;
 
 /**
@@ -199,14 +200,15 @@ public class FeatureSupportTest {
         @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS)
         @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_STRING_IDS, supported = false)
         public void shouldSupportUserSuppliedIdsOfTypeString() throws Exception {
+            final String id = "this-is-a-valid-id";
+
+            // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
+            // to throw the exception
+            assumeFalse(graph.features().vertex().willAllowId(id));
+
             try {
-                final String id = "this-is-a-valid-id";
                 graph.addVertex(T.id, id);
-
-                // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
-                // to throw the exception
-                if (!graph.features().vertex().willAllowId(id))
-                    fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), FEATURE_STRING_IDS));
+                fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), FEATURE_STRING_IDS));
             } catch (Exception e) {
                 validateException(Vertex.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), e);
             }
@@ -216,27 +218,35 @@ public class FeatureSupportTest {
         @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
         @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS)
         @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_NUMERIC_IDS, supported = false)
-        public void shouldSupportUserSuppliedIdsOfTypeNumeric() throws Exception {
+        public void shouldSupportUserSuppliedIdsOfTypeNumericInt() throws Exception {
+            final int id = 123456;
+
+            // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
+            // to throw the exception
+            assumeFalse(graph.features().vertex().willAllowId(id));
+
             try {
-                final int id = 123456;
                 graph.addVertex(T.id, id);
-
-                // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
-                // to throw the exception
-                if (!graph.features().vertex().willAllowId(id))
-                    fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), FEATURE_NUMERIC_IDS));
+                fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), FEATURE_NUMERIC_IDS));
             } catch (Exception e) {
                 validateException(Vertex.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), e);
             }
+        }
+
+        @Test
+        @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
+        @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS)
+        @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_NUMERIC_IDS, supported = false)
+        public void shouldSupportUserSuppliedIdsOfTypeNumericLong() throws Exception {
+            final long id = 123456l;
+
+            // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
+            // to throw the exception
+            assumeFalse(graph.features().vertex().willAllowId(id));
 
             try {
-                final long id = 123456l;
                 graph.addVertex(T.id, id);
-
-                // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
-                // to throw the exception
-                if (!graph.features().vertex().willAllowId(id))
-                    fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), FEATURE_NUMERIC_IDS));
+                fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), FEATURE_NUMERIC_IDS));
             } catch (Exception e) {
                 validateException(Vertex.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), e);
             }
@@ -247,14 +257,15 @@ public class FeatureSupportTest {
         @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS)
         @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_UUID_IDS, supported = false)
         public void shouldSupportUserSuppliedIdsOfTypeUuid() throws Exception {
+            final UUID id = UUID.randomUUID();
+
+            // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
+            // to throw the exception
+            assumeFalse(graph.features().vertex().willAllowId(id));
+
             try {
-                final UUID id = UUID.randomUUID();
                 graph.addVertex(T.id, id);
-
-                // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
-                // to throw the exception
-                if (!graph.features().vertex().willAllowId(id))
-                    fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), FEATURE_UUID_IDS));
+                fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), FEATURE_UUID_IDS));
             } catch (Exception e) {
                 validateException(Vertex.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), e);
             }
@@ -441,15 +452,16 @@ public class FeatureSupportTest {
         @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS)
         @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_STRING_IDS, supported = false)
         public void shouldSupportUserSuppliedIdsOfTypeString() throws Exception {
+            final String id = "this-is-a-valid-id";
+
+            // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
+            // to throw the exception
+            assumeFalse(graph.features().edge().willAllowId(id));
+
             try {
-                final String id = "this-is-a-valid-id";
                 final Vertex v = graph.addVertex();
                 v.addEdge("test", v, T.id, id);
-
-                // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
-                // to throw the exception
-                if (!graph.features().edge().willAllowId(id))
-                    fail(String.format(INVALID_FEATURE_SPECIFICATION, EdgeFeatures.class.getSimpleName(), FEATURE_STRING_IDS));
+                fail(String.format(INVALID_FEATURE_SPECIFICATION, EdgeFeatures.class.getSimpleName(), FEATURE_STRING_IDS));
             } catch (Exception e) {
                 validateException(Edge.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), e);
             }
@@ -459,29 +471,37 @@ public class FeatureSupportTest {
         @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
         @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS)
         @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_NUMERIC_IDS, supported = false)
-        public void shouldSupportUserSuppliedIdsOfTypeNumeric() throws Exception {
+        public void shouldSupportUserSuppliedIdsOfTypeNumericInt() throws Exception {
+            final int id = 123456;
+
+            // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
+            // to throw the exception
+            assumeFalse(graph.features().edge().willAllowId(id));
+
             try {
-                final int id = 123456;
                 final Vertex v = graph.addVertex();
                 v.addEdge("test", v, T.id, id);
-
-                // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
-                // to throw the exception
-                if (!graph.features().edge().willAllowId(id))
-                    fail(String.format(INVALID_FEATURE_SPECIFICATION, EdgeFeatures.class.getSimpleName(), FEATURE_NUMERIC_IDS));
+                fail(String.format(INVALID_FEATURE_SPECIFICATION, EdgeFeatures.class.getSimpleName(), FEATURE_NUMERIC_IDS));
             } catch (Exception e) {
                 validateException(Edge.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), e);
             }
+        }
+
+        @Test
+        @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
+        @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS)
+        @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_NUMERIC_IDS, supported = false)
+        public void shouldSupportUserSuppliedIdsOfTypeNumericLong() throws Exception {
+            final long id = 123456l;
+
+            // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
+            // to throw the exception
+            assumeFalse(graph.features().edge().willAllowId(id));
 
             try {
-                final long id = 123456l;
                 final Vertex v = graph.addVertex();
                 v.addEdge("test", v, T.id, id);
-
-                // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
-                // to throw the exception
-                if (!graph.features().edge().willAllowId(id))
-                    fail(String.format(INVALID_FEATURE_SPECIFICATION, EdgeFeatures.class.getSimpleName(), FEATURE_NUMERIC_IDS));
+                fail(String.format(INVALID_FEATURE_SPECIFICATION, EdgeFeatures.class.getSimpleName(), FEATURE_NUMERIC_IDS));
             } catch (Exception e) {
                 validateException(Edge.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), e);
             }
@@ -492,15 +512,16 @@ public class FeatureSupportTest {
         @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS)
         @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_UUID_IDS, supported = false)
         public void shouldSupportUserSuppliedIdsOfTypeUuid() throws Exception {
+            final UUID id = UUID.randomUUID();
+
+            // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
+            // to throw the exception
+            assumeFalse(graph.features().edge().willAllowId(id));
+
             try {
-                final UUID id = UUID.randomUUID();
                 final Vertex v = graph.addVertex();
                 v.addEdge("test", v, T.id, id);
-
-                // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
-                // to throw the exception
-                if (!graph.features().edge().willAllowId(id))
-                    fail(String.format(INVALID_FEATURE_SPECIFICATION, EdgeFeatures.class.getSimpleName(), FEATURE_UUID_IDS));
+                fail(String.format(INVALID_FEATURE_SPECIFICATION, EdgeFeatures.class.getSimpleName(), FEATURE_UUID_IDS));
             } catch (Exception e) {
                 validateException(Edge.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), e);
             }
@@ -512,15 +533,16 @@ public class FeatureSupportTest {
         @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS)
         @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_ANY_IDS, supported = false)
         public void shouldSupportUserSuppliedIdsOfTypeAny() throws Exception {
+            final Date id = new Date();
+
+            // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
+            // to throw the exception
+            assumeFalse(graph.features().edge().willAllowId(id));
+
             try {
-                final Date id = new Date();
                 final Vertex v = graph.addVertex();
                 v.addEdge("test", v, T.id, id);
-
-                // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
-                // to throw the exception
-                if (!graph.features().edge().willAllowId(id))
-                    fail(String.format(INVALID_FEATURE_SPECIFICATION, EdgeFeatures.class.getSimpleName(), FEATURE_ANY_IDS));
+                fail(String.format(INVALID_FEATURE_SPECIFICATION, EdgeFeatures.class.getSimpleName(), FEATURE_ANY_IDS));
             } catch (Exception e) {
                 validateException(Edge.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), e);
             }
@@ -702,15 +724,16 @@ public class FeatureSupportTest {
         @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS)
         @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_STRING_IDS, supported = false)
         public void shouldSupportUserSuppliedIdsOfTypeString() throws Exception {
+            final String id = "this-is-a-valid-id";
+
+            // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
+            // to throw the exception
+            assumeFalse(graph.features().vertex().properties().willAllowId(id));
+
             try {
-                final String id = "this-is-a-valid-id";
                 final Vertex v = graph.addVertex();
                 v.property(VertexProperty.Cardinality.single, "test", v, T.id, id);
-
-                // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
-                // to throw the exception
-                if (!graph.features().vertex().properties().willAllowId(id))
-                    fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), FEATURE_STRING_IDS));
+                fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), FEATURE_STRING_IDS));
             } catch (Exception ex) {
                 validateException(VertexProperty.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), ex);
             }
@@ -720,29 +743,37 @@ public class FeatureSupportTest {
         @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
         @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS)
         @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_NUMERIC_IDS, supported = false)
-        public void shouldSupportUserSuppliedIdsOfTypeNumeric() throws Exception {
+        public void shouldSupportUserSuppliedIdsOfTypeNumericInt() throws Exception {
+            final int id = 123456;
+
+            // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
+            // to throw the exception
+            assumeFalse(graph.features().vertex().properties().willAllowId(id));
+
             try {
-                final int id = 123456;
                 final Vertex v = graph.addVertex();
                 v.property(VertexProperty.Cardinality.single, "test", v, T.id, id);
-
-                // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
-                // to throw the exception
-                if (!graph.features().vertex().properties().willAllowId(id))
-                    fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), FEATURE_NUMERIC_IDS));
+                fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), FEATURE_NUMERIC_IDS));
             } catch (Exception ex) {
                 validateException(VertexProperty.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), ex);
             }
+        }
+
+        @Test
+        @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
+        @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS)
+        @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_NUMERIC_IDS, supported = false)
+        public void shouldSupportUserSuppliedIdsOfTypeNumericLong() throws Exception {
+            final long id = 123456l;
+
+            // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
+            // to throw the exception
+            assumeFalse(graph.features().vertex().properties().willAllowId(id));
 
             try {
-                final long id = 123456l;
                 final Vertex v = graph.addVertex();
                 v.property(VertexProperty.Cardinality.single, "test", v, T.id, id);
-
-                // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
-                // to throw the exception
-                if (!graph.features().vertex().properties().willAllowId(id))
-                    fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), FEATURE_NUMERIC_IDS));
+                fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), FEATURE_NUMERIC_IDS));
             } catch (Exception ex) {
                 validateException(VertexProperty.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), ex);
             }
@@ -753,15 +784,16 @@ public class FeatureSupportTest {
         @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS)
         @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_UUID_IDS, supported = false)
         public void shouldSupportUserSuppliedIdsOfTypeUuid() throws Exception {
+            final UUID id = UUID.randomUUID();
+
+            // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
+            // to throw the exception
+            assumeFalse(graph.features().vertex().properties().willAllowId(id));
+
             try {
-                final UUID id = UUID.randomUUID();
                 final Vertex v = graph.addVertex();
                 v.property(VertexProperty.Cardinality.single, "test", v, T.id, id);
-
-                // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
-                // to throw the exception
-                if (!graph.features().vertex().properties().willAllowId(id))
-                    fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), FEATURE_UUID_IDS));
+                fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), FEATURE_UUID_IDS));
             } catch (Exception ex) {
                 validateException(VertexProperty.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), ex);
             }
@@ -773,14 +805,15 @@ public class FeatureSupportTest {
         @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_USER_SUPPLIED_IDS)
         @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_ANY_IDS, supported = false)
         public void shouldSupportUserSuppliedIdsOfTypeAny() throws Exception {
+            final Date id = new Date();
+
+            // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
+            // to throw the exception
+            assumeFalse(graph.features().vertex().properties().willAllowId(id));
+
             try {
-                final Date id = new Date();
                 final Vertex v = graph.addVertex();
                 v.property(VertexProperty.Cardinality.single, "test", v, T.id, id);
-
-                // a graph can "allow" an id without internally supporting it natively and therefore doesn't need
-                // to throw the exception
-                if (!graph.features().vertex().properties().willAllowId(id))
                 fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), FEATURE_ANY_IDS));
             } catch (Exception ex) {
                 validateException(VertexProperty.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), ex);