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/05/28 18:59:37 UTC
incubator-tinkerpop git commit: Changed assertion for id in tests.
TINKERPOP3-695
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/master d68fa629a -> 32924d86a
Changed assertion for id in tests. TINKERPOP3-695
Fixed a bug that was only doing a check on Edge features for whether or not user ids were supported. Second, validated that the graph supports numeric ids in order to do the assertion.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/32924d86
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/32924d86
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/32924d86
Branch: refs/heads/master
Commit: 32924d86ae98b112af9a0324e66d12930c2beeea
Parents: d68fa62
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu May 28 12:58:20 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu May 28 12:58:20 2015 -0400
----------------------------------------------------------------------
.../apache/tinkerpop/gremlin/GraphProvider.java | 19 -------------------
.../tinkerpop/gremlin/structure/io/IoTest.java | 17 ++++++++++-------
2 files changed, 10 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/32924d86/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/GraphProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/GraphProvider.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/GraphProvider.java
index 4c9b27d..7961d36 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/GraphProvider.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/GraphProvider.java
@@ -157,25 +157,6 @@ public interface GraphProvider {
* utilize an Element identifier will pass it to this method before usage. This method should be sure to
* be consistent in the return value such that calling it with "x" should always return the same transformed
* value.
- * <p/>
- * For {@link Graph} implementations that return {@code true} for
- * {@link Graph.Features.ElementFeatures#supportsUserSuppliedIds()} this method requires some additional thought.
- * That feature has some interesting ramifications when it comes to certain parts of the test suite. If that
- * feature is supported and {@link Graph.Features.ElementFeatures#supportsNumericIds()} is not supported (in
- * favor of some other data type), then test cases supported in the suite will be reduced. In such a case,
- * there are two options to consider.
- * <ol>
- * <li>Make it so that your graph can work with
- * {@link Graph.Features.ElementFeatures#supportsUserSuppliedIds()} returning {@link false}. Have it be a
- * configuration. Then, create one set of tests to run the suite with that configuration and a different
- * set of tests that run the suite in the other configuration.</li>
- * <li>Make it so that {@link Graph.Features.ElementFeatures#supportsNumericIds()} is possible. Convert
- * the {@link Number} to {@link String} inside {@link Graph#addVertex(Object...)}.</li>
- * </ol>
- * If considering the second option, then this method should be implemented such that it not only returns
- * consistent values as described above, but that it also apply "meaning" during conversion. In other words,
- * if {@code convertId(1, Vertex.class)} is called then this method should ensure that {@code 1} be converted to
- * the exact same value that it would be converted to if one had called {@code graph.addVertex(T.id, 1)}.
*/
default public Object convertId(final Object id, final Class<? extends Element> c) {
return id;
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/32924d86/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoTest.java
index b641127..ae4b32d 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoTest.java
@@ -2355,15 +2355,18 @@ public class IoTest extends AbstractGremlinTest {
}
private static void assertId(final Graph g, final boolean lossyForId, final Element e, final Object expected) {
- if (g.features().edge().supportsUserSuppliedIds()) {
+ // it is possible that a Graph (e.g. elastic-gremlin) can supportUserSuppliedIds but internally
+ // represent them as a value other than Numeric (which is what's in all of the test/toy data).
+ // as we feature check for userSuppliedIds when asserting the identifier, we also ensure that
+ // the id can be properly asserted for that Element before attempting to do so. By asserting
+ // at this level in this way, graphs can enjoy greater test coverage in IO.
+ if ((e instanceof Vertex && g.features().vertex().supportsUserSuppliedIds() && g.features().vertex().supportsNumericIds())
+ || (e instanceof Edge && g.features().edge().supportsUserSuppliedIds() && g.features().edge().supportsNumericIds())
+ || (e instanceof VertexProperty && g.features().vertex().properties().supportsUserSuppliedIds()) && g.features().vertex().properties().supportsNumericIds()) {
if (lossyForId)
assertEquals(expected.toString(), e.id().toString());
- else {
- // we convert the "expected" id via GraphProvider because it is possible that a Graph
- // (e.g. elastic-gremlin) can supportUserSuppliedIds but internally represent them as a
- // value other than Numeric (which is what's in all of the test/toy data).
- assertEquals(GraphManager.getGraphProvider().convertId(expected, Edge.class), e.id());
- }
+ else
+ assertEquals(expected, e.id());
}
}