You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by dk...@apache.org on 2015/06/03 02:12:39 UTC

[34/50] [abbrv] incubator-tinkerpop git commit: Loosen feature tests around identifiers TINKERPOP3-695

Loosen feature tests around identifiers TINKERPOP3-695

Check willAllowId() before asserting failure on id support tests.  This allows these tests to pass if the graph doesn't internally support the id type, but does allow the id to be used (e.g. a graph toString's all incoming ids).


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

Branch: refs/heads/preprocessor
Commit: bfe1e983ffc7eb9487f7172ba8b2ea77ae86d477
Parents: 96bc1ad
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Jun 1 08:00:44 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Jun 1 08:00:44 2015 -0400

----------------------------------------------------------------------
 .../gremlin/structure/FeatureSupportTest.java   | 133 +++++++++++++++----
 1 file changed, 104 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/bfe1e983/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 40b6694..693d8f6 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
@@ -200,8 +200,13 @@ public class FeatureSupportTest {
         @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_STRING_IDS, supported = false)
         public void shouldSupportUserSuppliedIdsOfTypeString() throws Exception {
             try {
-                graph.addVertex(T.id, "this-is-a-valid-id");
-                fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), FEATURE_STRING_IDS));
+                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));
             } catch (Exception e) {
                 validateException(Vertex.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), e);
             }
@@ -213,15 +218,25 @@ public class FeatureSupportTest {
         @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_NUMERIC_IDS, supported = false)
         public void shouldSupportUserSuppliedIdsOfTypeNumeric() throws Exception {
             try {
-                graph.addVertex(T.id, 123456);
-                fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), FEATURE_NUMERIC_IDS));
+                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));
             } catch (Exception e) {
                 validateException(Vertex.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), e);
             }
 
             try {
-                graph.addVertex(T.id, 123456l);
-                fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), FEATURE_NUMERIC_IDS));
+                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));
             } catch (Exception e) {
                 validateException(Vertex.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), e);
             }
@@ -233,8 +248,13 @@ public class FeatureSupportTest {
         @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_UUID_IDS, supported = false)
         public void shouldSupportUserSuppliedIdsOfTypeUuid() throws Exception {
             try {
-                graph.addVertex(T.id, UUID.randomUUID());
-                fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), FEATURE_UUID_IDS));
+                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));
             } catch (Exception e) {
                 validateException(Vertex.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), e);
             }
@@ -246,8 +266,13 @@ public class FeatureSupportTest {
         @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_ANY_IDS, supported = false)
         public void shouldSupportUserSuppliedIdsOfTypeAny() throws Exception {
             try {
-                graph.addVertex(T.id, new Date());
-                fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexFeatures.class.getSimpleName(), FEATURE_ANY_IDS));
+                final Date id = new Date();
+                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_ANY_IDS));
             } catch (Exception e) {
                 validateException(Vertex.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), e);
             }
@@ -417,9 +442,14 @@ public class FeatureSupportTest {
         @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_STRING_IDS, supported = false)
         public void shouldSupportUserSuppliedIdsOfTypeString() throws Exception {
             try {
+                final String id = "this-is-a-valid-id";
                 final Vertex v = graph.addVertex();
-                v.addEdge("test", v, T.id, "this-is-a-valid-id");
-                fail(String.format(INVALID_FEATURE_SPECIFICATION, EdgeFeatures.class.getSimpleName(), FEATURE_STRING_IDS));
+                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));
             } catch (Exception e) {
                 validateException(Edge.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), e);
             }
@@ -431,17 +461,27 @@ public class FeatureSupportTest {
         @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_NUMERIC_IDS, supported = false)
         public void shouldSupportUserSuppliedIdsOfTypeNumeric() throws Exception {
             try {
+                final int id = 123456;
                 final Vertex v = graph.addVertex();
-                v.addEdge("test", v, T.id, 123456);
-                fail(String.format(INVALID_FEATURE_SPECIFICATION, EdgeFeatures.class.getSimpleName(), FEATURE_NUMERIC_IDS));
+                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));
             } catch (Exception e) {
                 validateException(Edge.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), e);
             }
 
             try {
+                final long id = 123456l;
                 final Vertex v = graph.addVertex();
-                v.addEdge("test", v, T.id, 123456l);
-                fail(String.format(INVALID_FEATURE_SPECIFICATION, EdgeFeatures.class.getSimpleName(), FEATURE_NUMERIC_IDS));
+                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));
             } catch (Exception e) {
                 validateException(Edge.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), e);
             }
@@ -453,9 +493,14 @@ public class FeatureSupportTest {
         @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_UUID_IDS, supported = false)
         public void shouldSupportUserSuppliedIdsOfTypeUuid() throws Exception {
             try {
+                final UUID id = UUID.randomUUID();
                 final Vertex v = graph.addVertex();
-                v.addEdge("test", v, T.id, UUID.randomUUID());
-                fail(String.format(INVALID_FEATURE_SPECIFICATION, EdgeFeatures.class.getSimpleName(), FEATURE_ANY_IDS));
+                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));
             } catch (Exception e) {
                 validateException(Edge.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), e);
             }
@@ -468,9 +513,14 @@ public class FeatureSupportTest {
         @FeatureRequirement(featureClass = VertexFeatures.class, feature = FEATURE_ANY_IDS, supported = false)
         public void shouldSupportUserSuppliedIdsOfTypeAny() throws Exception {
             try {
+                final Date id = new Date();
                 final Vertex v = graph.addVertex();
-                v.addEdge("test", v, T.id, new Date());
-                fail(String.format(INVALID_FEATURE_SPECIFICATION, EdgeFeatures.class.getSimpleName(), FEATURE_ANY_IDS));
+                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));
             } catch (Exception e) {
                 validateException(Edge.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), e);
             }
@@ -653,9 +703,14 @@ public class FeatureSupportTest {
         @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_STRING_IDS, supported = false)
         public void shouldSupportUserSuppliedIdsOfTypeString() throws Exception {
             try {
+                final String id = "this-is-a-valid-id";
                 final Vertex v = graph.addVertex();
-                v.property(VertexProperty.Cardinality.single, "test", v, T.id, "this-is-a-valid-id");
-                fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), FEATURE_STRING_IDS));
+                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));
             } catch (Exception ex) {
                 validateException(VertexProperty.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), ex);
             }
@@ -667,17 +722,27 @@ public class FeatureSupportTest {
         @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_NUMERIC_IDS, supported = false)
         public void shouldSupportUserSuppliedIdsOfTypeNumeric() throws Exception {
             try {
+                final int id = 123456;
                 final Vertex v = graph.addVertex();
-                v.property(VertexProperty.Cardinality.single, "test", v, T.id, 123456);
-                fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), FEATURE_NUMERIC_IDS));
+                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));
             } catch (Exception ex) {
                 validateException(VertexProperty.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), ex);
             }
 
             try {
+                final long id = 123456l;
                 final Vertex v = graph.addVertex();
-                v.property(VertexProperty.Cardinality.single, "test", v, T.id, 123456l);
-                fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), FEATURE_NUMERIC_IDS));
+                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));
             } catch (Exception ex) {
                 validateException(VertexProperty.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), ex);
             }
@@ -689,9 +754,14 @@ public class FeatureSupportTest {
         @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_UUID_IDS, supported = false)
         public void shouldSupportUserSuppliedIdsOfTypeUuid() throws Exception {
             try {
+                final UUID id = UUID.randomUUID();
                 final Vertex v = graph.addVertex();
-                v.property(VertexProperty.Cardinality.single, "test", v, T.id, UUID.randomUUID());
-                fail(String.format(INVALID_FEATURE_SPECIFICATION, VertexPropertyFeatures.class.getSimpleName(), FEATURE_ANY_IDS));
+                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));
             } catch (Exception ex) {
                 validateException(VertexProperty.Exceptions.userSuppliedIdsOfThisTypeNotSupported(), ex);
             }
@@ -704,8 +774,13 @@ public class FeatureSupportTest {
         @FeatureRequirement(featureClass = VertexPropertyFeatures.class, feature = FEATURE_ANY_IDS, supported = false)
         public void shouldSupportUserSuppliedIdsOfTypeAny() throws Exception {
             try {
+                final Date id = new Date();
                 final Vertex v = graph.addVertex();
-                v.property(VertexProperty.Cardinality.single, "test", v, T.id, new Date());
+                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);