TINKERPOP-2041 Added IO tests for TextP
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/8b69b34b Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/8b69b34b Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/8b69b34b Branch: refs/heads/TINKERPOP-2053 Commit: 8b69b34b6393a3071c0cd491ea9ec0ca09a1e5ae Parents: 9b96586 Author: Stephen Mallette <sp...@genoprime.com> Authored: Wed Oct 3 15:01:40 2018 -0400 Committer: Daniel Kuppitz <daniel_kupp...@hotmail.com> Committed: Thu Oct 4 07:45:08 2018 -0700 ---------------------------------------------------------------------- docs/src/dev/io/graphson.asciidoc | 26 ++++++++++++++++++++ .../scripts/generate-graphson-resources.groovy | 12 ++++----- .../tinkerpop/gremlin/structure/io/Model.java | 9 +++++++ .../io/AbstractTypedCompatibilityTest.java | 14 +++++++++++ .../io/graphson/_3_4_0/textp-v2d0-partial.json | 7 ++++++ .../io/graphson/_3_4_0/textp-v3d0.json | 7 ++++++ .../structure/io/gryo/_3_4_0/textp-v1d0.kryo | 1 + .../structure/io/gryo/_3_4_0/textp-v3d0.kryo | 1 + 8 files changed, 71 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8b69b34b/docs/src/dev/io/graphson.asciidoc ---------------------------------------------------------------------- diff --git a/docs/src/dev/io/graphson.asciidoc b/docs/src/dev/io/graphson.asciidoc index d140a2f..1c9081c 100644 --- a/docs/src/dev/io/graphson.asciidoc +++ b/docs/src/dev/io/graphson.asciidoc @@ -3014,6 +3014,19 @@ The following `Bytecode` example represents the traversal of `g.V().hasLabel('pe } ---- +==== TextP + +[source,json] +---- +{ + "@type" : "g:TextP", + "@value" : { + "predicate" : "containing", + "value" : "ark" + } +} +---- + ==== TraversalMetrics [source,json] @@ -5392,6 +5405,19 @@ Please see <<_p,P>> for additional information on `within`. } ---- +==== TextP + +[source,json] +---- +{ + "@type" : "g:TextP", + "@value" : { + "predicate" : "containing", + "value" : "ark" + } +} +---- + ==== TraversalMetrics [source,json] http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8b69b34b/gremlin-tools/gremlin-io-test/scripts/generate-graphson-resources.groovy ---------------------------------------------------------------------- diff --git a/gremlin-tools/gremlin-io-test/scripts/generate-graphson-resources.groovy b/gremlin-tools/gremlin-io-test/scripts/generate-graphson-resources.groovy index 55b4fa6..03112ed 100644 --- a/gremlin-tools/gremlin-io-test/scripts/generate-graphson-resources.groovy +++ b/gremlin-tools/gremlin-io-test/scripts/generate-graphson-resources.groovy @@ -59,19 +59,19 @@ toJson = { o, type, mapper, comment = "", suffix = "" -> writeSupportedV1Objects = { writer, mapper -> writer.write("=== Graph Structure\n\n") - model.entries("Graph Structure").findAll{it.isCompatibleWith(GraphSONCompatibility.V1D0_3_3_0)}.each { + model.entries("Graph Structure").findAll{it.isCompatibleWith(GraphSONCompatibility.V1D0_3_4_0)}.each { writer.write(toJsonV1d0NoTypes(it.getObject(), it.getTitle(), mapper, it.getDescription())) } writer.write("\n") writer.write("=== RequestMessage\n\n") - model.entries("RequestMessage").findAll{it.isCompatibleWith(GraphSONCompatibility.V1D0_3_3_0)}.each { + model.entries("RequestMessage").findAll{it.isCompatibleWith(GraphSONCompatibility.V1D0_3_4_0)}.each { writer.write(toJsonV1d0NoTypes(it.getObject(), it.getTitle(), mapper, it.getDescription())) } writer.write("\n") writer.write("=== ResponseMessage\n\n") - model.entries("ResponseMessage").findAll{it.isCompatibleWith(GraphSONCompatibility.V1D0_3_3_0)}.each { + model.entries("ResponseMessage").findAll{it.isCompatibleWith(GraphSONCompatibility.V1D0_3_4_0)}.each { writer.write(toJsonV1d0NoTypes(it.getObject(), it.getTitle(), mapper, it.getDescription())) } } @@ -156,7 +156,7 @@ mapper = GraphSONMapper.build(). file = new File("${projectBuildDir}/dev-docs/out-graphson-2d0-partial.txt") if (file.exists()) file.delete() -file.withWriter { writeSupportedV2V3Objects(it, mapper, toJsonV2d0PartialTypes, {it.isCompatibleWith(GraphSONCompatibility.V2D0_PARTIAL_3_3_1)}, v2ExtendedDescription) } +file.withWriter { writeSupportedV2V3Objects(it, mapper, toJsonV2d0PartialTypes, {it.isCompatibleWith(GraphSONCompatibility.V2D0_PARTIAL_3_4_0)}, v2ExtendedDescription) } mapper = GraphSONMapper.build(). addRegistry(TinkerIoRegistryV2d0.instance()). @@ -167,7 +167,7 @@ mapper = GraphSONMapper.build(). file = new File("${projectBuildDir}/dev-docs/out-graphson-2d0-no-type.txt") if (file.exists()) file.delete() -file.withWriter { writeSupportedV2V3Objects(it, mapper, toJsonV2d0NoTypes, {it.isCompatibleWith(GraphSONCompatibility.V2D0_NO_TYPE_3_3_1)}, v2ExtendedDescription) } +file.withWriter { writeSupportedV2V3Objects(it, mapper, toJsonV2d0NoTypes, {it.isCompatibleWith(GraphSONCompatibility.V2D0_NO_TYPE_3_4_0)}, v2ExtendedDescription) } mapper = GraphSONMapper.build(). addRegistry(TinkerIoRegistryV2d0.instance()). @@ -189,7 +189,7 @@ mapper = GraphSONMapper.build(). file = new File("${projectBuildDir}/dev-docs/out-graphson-3d0.txt") if (file.exists()) file.delete() -file.withWriter { writeSupportedV2V3Objects(it, mapper, toJsonV3d0, {it.isCompatibleWith(GraphSONCompatibility.V3D0_PARTIAL_3_3_1)}, v3ExtendedDescription) } +file.withWriter { writeSupportedV2V3Objects(it, mapper, toJsonV3d0, {it.isCompatibleWith(GraphSONCompatibility.V3D0_PARTIAL_3_4_0)}, v3ExtendedDescription) } def ver = "_" + "${projectVersion}".replace(".","_").replace("-SNAPSHOT","") def target = "${projectBaseDir}/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/" + ver http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8b69b34b/gremlin-tools/gremlin-io-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/Model.java ---------------------------------------------------------------------- diff --git a/gremlin-tools/gremlin-io-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/Model.java b/gremlin-tools/gremlin-io-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/Model.java index 3ad676f..f01b0fc 100644 --- a/gremlin-tools/gremlin-io-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/Model.java +++ b/gremlin-tools/gremlin-io-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/Model.java @@ -29,6 +29,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.P; import org.apache.tinkerpop.gremlin.process.traversal.Pop; import org.apache.tinkerpop.gremlin.process.traversal.SackFunctions; import org.apache.tinkerpop.gremlin.process.traversal.Scope; +import org.apache.tinkerpop.gremlin.process.traversal.TextP; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalOptionParent; import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversalMetrics; @@ -106,6 +107,12 @@ public class Model { final Compatibility[] noTypeGraphSONPlusGryo3_2_3 = Compatibilities.with(GryoCompatibility.class).beforeRelease("3.2.4").join(Compatibilities.UNTYPED_GRAPHSON).matchToArray(); final Compatibility[] noTypeGraphSONPlusGryo3_3_0 = Compatibilities.with(GryoCompatibility.class).beforeRelease("3.3.0").join(Compatibilities.UNTYPED_GRAPHSON).matchToArray(); + // the inverse of this definition is basically 3.4.0 or better for both GraphSON and Gryo with no support for + // untyped GraphSON anywhere along the way + final Compatibility[] before3_4_0 = Compatibilities.with(GryoCompatibility.class).beforeRelease("3.4.0") + .join(Compatibilities.with(GraphSONCompatibility.class).configuredAs(".*no-types|v1d0") + .join(Compatibilities.with(GraphSONCompatibility.class).beforeRelease("3.4.0"))).matchToArray(); + // there is no point to testing gryo for list/map/set as they are kryo primitives essentially final Compatibility[] noGraphSONBeforeV3AndNoGryo = Compatibilities.with(GraphSONCompatibility.class).configuredAs(".*v2d0-partial|v1d0|v2d0-no-types").join(Compatibilities.GRYO_ONLY).matchToArray(); @@ -164,6 +171,8 @@ public class Model { addGraphProcessEntry(P.gt(0).or(P.within(-1, -10, -100)), "P or", "", noTypeGraphSONPlusGryo3_2_3); addGraphProcessEntry(Scope.local, "Scope", "", Compatibilities.UNTYPED_GRAPHSON.matchToArray()); addGraphProcessEntry(T.label, "T", "", Compatibilities.UNTYPED_GRAPHSON.matchToArray()); + // TextP was only added at 3.4.0 and is not supported with untyped GraphSON of any sort + addGraphProcessEntry(TextP.containing("ark"), "TextP", "", before3_4_0); addGraphProcessEntry(createStaticTraversalMetrics(), "TraversalMetrics", "", noTypeGraphSONPlusGryo3_3_0); addGraphProcessEntry(g.V().hasLabel("person").asAdmin().nextTraverser(), "Traverser", "", Compatibilities.UNTYPED_GRAPHSON.matchToArray()); http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8b69b34b/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractTypedCompatibilityTest.java ---------------------------------------------------------------------- diff --git a/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractTypedCompatibilityTest.java b/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractTypedCompatibilityTest.java index 67e5901..f34a6c4 100644 --- a/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractTypedCompatibilityTest.java +++ b/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractTypedCompatibilityTest.java @@ -28,6 +28,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.Path; import org.apache.tinkerpop.gremlin.process.traversal.Pop; import org.apache.tinkerpop.gremlin.process.traversal.SackFunctions; import org.apache.tinkerpop.gremlin.process.traversal.Scope; +import org.apache.tinkerpop.gremlin.process.traversal.TextP; import org.apache.tinkerpop.gremlin.process.traversal.Traverser; import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree; import org.apache.tinkerpop.gremlin.process.traversal.util.Metrics; @@ -840,6 +841,19 @@ public abstract class AbstractTypedCompatibilityTest extends AbstractCompatibili } @Test + public void shouldReadWriteTextP() throws Exception { + final String resourceName = "textp"; + assumeCompatibility(resourceName); + + final TextP resource = findModelEntryObject(resourceName); + final TextP fromStatic = read(getCompatibility().readFromResource(resourceName), TextP.class); + final TextP recycled = read(write(fromStatic, TextP.class), TextP.class); + assertEquals(fromStatic, recycled); + assertEquals(resource, fromStatic); + assertEquals(resource, recycled); + } + + @Test public void shouldReadWriteTimestamp() throws Exception { final String resourceName = "timestamp"; assumeCompatibility(resourceName); http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8b69b34b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_4_0/textp-v2d0-partial.json ---------------------------------------------------------------------- diff --git a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_4_0/textp-v2d0-partial.json b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_4_0/textp-v2d0-partial.json new file mode 100644 index 0000000..2820989 --- /dev/null +++ b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_4_0/textp-v2d0-partial.json @@ -0,0 +1,7 @@ +{ + "@type" : "g:TextP", + "@value" : { + "predicate" : "containing", + "value" : "ark" + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8b69b34b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_4_0/textp-v3d0.json ---------------------------------------------------------------------- diff --git a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_4_0/textp-v3d0.json b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_4_0/textp-v3d0.json new file mode 100644 index 0000000..2820989 --- /dev/null +++ b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_4_0/textp-v3d0.json @@ -0,0 +1,7 @@ +{ + "@type" : "g:TextP", + "@value" : { + "predicate" : "containing", + "value" : "ark" + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8b69b34b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/_3_4_0/textp-v1d0.kryo ---------------------------------------------------------------------- diff --git a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/_3_4_0/textp-v1d0.kryo b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/_3_4_0/textp-v1d0.kryo new file mode 100644 index 0000000..d71eb0f --- /dev/null +++ b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/_3_4_0/textp-v1d0.kryo @@ -0,0 +1 @@ +containin�ar� \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8b69b34b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/_3_4_0/textp-v3d0.kryo ---------------------------------------------------------------------- diff --git a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/_3_4_0/textp-v3d0.kryo b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/_3_4_0/textp-v3d0.kryo new file mode 100644 index 0000000..d71eb0f --- /dev/null +++ b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/gryo/_3_4_0/textp-v3d0.kryo @@ -0,0 +1 @@ +containin�ar� \ No newline at end of file