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 2016/12/30 16:26:47 UTC

[1/3] tinkerpop git commit: TINKERPOP-1130 Tests for edge untyped graphson

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1130 7a9390568 -> 0f3d8feac


TINKERPOP-1130 Tests for edge untyped graphson


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

Branch: refs/heads/TINKERPOP-1130
Commit: 77f527c6a93194aa46c75eeb93ea2694a81da123
Parents: 7a93905
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Dec 30 10:26:02 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 30 10:26:02 2016 -0500

----------------------------------------------------------------------
 .../tinkerpop/gremlin/structure/io/Model.java   | 11 ++-
 .../io/AbstractUntypedCompatibilityTest.java    | 83 +++++++++++++++++---
 .../GraphSONUntypedCompatibilityTest.java       |  3 -
 3 files changed, 79 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/77f527c6/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 215db71..24af1d8 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
@@ -111,7 +111,12 @@ public class Model {
         }}, GryoCompatibility.V1D0_3_2_3);
         addCoreEntry(UUID.fromString("41d2e28a-20a4-4ab0-b379-d810dede3786"), "UUID");
 
-        addGraphStructureEntry(graph.edges().next(), "Edge");
+        // TODO: remove incompatibilities in Element on GraphSON 2.0
+        // temporary incompatibility in v2 graphson starting at 3.3.0 with Element properties - need to revert some
+        // changes on master (which is what helped start this mess) once this work is merged
+        final Compatibility[] graphsonV2NoType = Compatibilities.with(GraphSONCompatibility.class)
+                .configuredAs(".*no-types").matchToArray();
+        addGraphStructureEntry(graph.edges().next(), "Edge", "", graphsonV2NoType);
         addGraphStructureEntry(g.V().out().out().path().next(), "Path");
         addGraphStructureEntry(graph.edges().next().properties().next(), "Property");
         addEntry("Graph Structure", StarGraph.of(graph.vertices().next()), "StarGraph", "", Compatibilities.GRYO_ONLY.match());
@@ -297,8 +302,8 @@ public class Model {
         addGraphStructureEntry(obj, title, "");
     }
 
-    private void addGraphStructureEntry(final Object obj, final String title, final String description) {
-        addEntry("Graph Structure", obj, title, description);
+    private void addGraphStructureEntry(final Object obj, final String title, final String description, final Compatibility... incompatibilities) {
+        addEntry("Graph Structure", obj, title, description, incompatibilities);
     }
 
     private void addGraphProcessEntry(final Object obj, final String title) {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/77f527c6/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractUntypedCompatibilityTest.java
----------------------------------------------------------------------
diff --git a/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractUntypedCompatibilityTest.java b/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractUntypedCompatibilityTest.java
index db57145..94a1c0c 100644
--- a/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractUntypedCompatibilityTest.java
+++ b/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractUntypedCompatibilityTest.java
@@ -18,7 +18,11 @@
  */
 package org.apache.tinkerpop.gremlin.structure.io;
 
+import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
+import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
 import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 import org.junit.Test;
 
 import java.util.HashMap;
@@ -38,26 +42,81 @@ public abstract class AbstractUntypedCompatibilityTest extends AbstractCompatibi
 
     @Test
     public void shouldReadWriteAuthenticationChallenge() throws Exception {
-        assumeCompatibility("authenticationchallenge");
+        final String resourceName = "authenticationchallenge";
+        assumeCompatibility(resourceName);
 
-        final HashMap fromStatic = read(getCompatibility().readFromResource("authenticationchallenge"), HashMap.class);
-        final HashMap recycled = read(write(fromStatic, HashMap.class), HashMap.class);
+        final ResponseMessage resource = findModelEntryObject(resourceName);
+        final HashMap fromStatic = read(getCompatibility().readFromResource(resourceName), HashMap.class);
+        final HashMap recycled = read(write(resource, ResponseMessage.class), HashMap.class);
         assertNotSame(fromStatic, recycled);
-        assertEquals("41d2e28a-20a4-4ab0-b379-d810dede3786", recycled.get("requestId"));
+        assertEquals(fromStatic, recycled);
+        assertEquals(resource.getRequestId().toString(), fromStatic.get("requestId"));
+        assertEquals(ResponseStatusCode.AUTHENTICATE.getValue(), ((Map) fromStatic.get("status")).get("code"));
+        assertEquals(resource.getRequestId().toString(), recycled.get("requestId"));
         assertEquals(ResponseStatusCode.AUTHENTICATE.getValue(), ((Map) recycled.get("status")).get("code"));
     }
 
     @Test
     public void shouldReadWriteAuthenticationResponse() throws Exception {
-        assumeCompatibility("authenticationresponse");
+        final String resourceName = "authenticationresponse";
+        assumeCompatibility(resourceName);
 
-        final HashMap fromStatic = read(getCompatibility().readFromResource("authenticationresponse"), HashMap.class);
-        final HashMap recycled = read(write(fromStatic, HashMap.class), HashMap.class);
+        final RequestMessage resource = findModelEntryObject(resourceName);
+        final HashMap fromStatic = read(getCompatibility().readFromResource(resourceName), HashMap.class);
+        final HashMap recycled = read(write(resource, RequestMessage.class), HashMap.class);
         assertNotSame(fromStatic, recycled);
-        assertEquals("cb682578-9d92-4499-9ebc-5c6aa73c5397", recycled.get("requestId"));
-        assertEquals("authentication", recycled.get("op"));
-        assertEquals("", recycled.get("processor"));
-        assertEquals("PLAIN", ((Map) recycled.get("args")).get("saslMechanism"));
-        assertEquals("AHN0ZXBocGhlbgBwYXNzd29yZA==", ((Map) recycled.get("args")).get("sasl"));
+        assertEquals(fromStatic, recycled);
+        assertEquals(resource.getRequestId().toString(), fromStatic.get("requestId"));
+        assertEquals(resource.getOp(), fromStatic.get("op"));
+        assertEquals(resource.getProcessor(), fromStatic.get("processor"));
+        assertEquals(resource.getArgs().get("saslMechanism"), ((Map) fromStatic.get("args")).get("saslMechanism"));
+        assertEquals(resource.getArgs().get("sasl"), ((Map) fromStatic.get("args")).get("sasl"));
+        assertEquals(resource.getRequestId().toString(), recycled.get("requestId"));
+        assertEquals(resource.getOp(), recycled.get("op"));
+        assertEquals(resource.getProcessor(), recycled.get("processor"));
+        assertEquals(resource.getArgs().get("saslMechanism"), ((Map) recycled.get("args")).get("saslMechanism"));
+        assertEquals(resource.getArgs().get("sasl"), ((Map) recycled.get("args")).get("sasl"));
+    }
+
+    @Test
+    public void shouldReadWriteEdge() throws Exception {
+        final String resourceName = "edge";
+        assumeCompatibility(resourceName);
+
+        final Edge resource = findModelEntryObject(resourceName);
+        final HashMap fromStatic = read(getCompatibility().readFromResource("edge"), HashMap.class);
+        final HashMap recycled = read(write(resource, Edge.class), HashMap.class);
+        assertNotSame(fromStatic, recycled);
+        assertEquals(resource.id(), fromStatic.get("id"));
+        assertEquals(resource.label(), fromStatic.get("label"));
+        assertEquals(resource.id(), fromStatic.get("id"));
+        assertEquals(resource.inVertex().label(), fromStatic.get("inVLabel"));
+        assertEquals(resource.outVertex().label(), fromStatic.get("outVLabel"));
+        assertEquals(resource.inVertex().id(), fromStatic.get("inV"));
+        assertEquals(resource.outVertex().id(), fromStatic.get("outV"));
+        assertEquals(resource.id(), recycled.get("id"));
+        assertEquals(resource.label(), recycled.get("label"));
+        assertEquals(resource.id(), recycled.get("id"));
+        assertEquals(resource.inVertex().label(), recycled.get("inVLabel"));
+        assertEquals(resource.outVertex().label(), recycled.get("outVLabel"));
+        assertEquals(resource.inVertex().id(), recycled.get("inV"));
+        assertEquals(resource.outVertex().id(), recycled.get("outV"));
+
+        // deal with incompatibilities
+        if (getCompatibility().getConfiguration().equals("v1d0")) {
+            assertEquals("edge", fromStatic.get("type"));
+            assertEquals(IteratorUtils.count(resource.properties()), ((Map) fromStatic.get("properties")).size());
+            assertEquals(resource.value("since"), ((Map) fromStatic.get("properties")).get("since"));
+            assertEquals("edge", recycled.get("type"));
+            assertEquals(IteratorUtils.count(resource.properties()), ((Map) recycled.get("properties")).size());
+            assertEquals(resource.value("since"), ((Map) recycled.get("properties")).get("since"));
+        } else if (getCompatibility().getConfiguration().contains("no-types")) {
+            assertEquals(IteratorUtils.count(resource.properties()), ((Map) fromStatic.get("properties")).size());
+            assertEquals(resource.keys().iterator().next(), ((Map) ((Map) fromStatic.get("properties")).get("since")).get("key"));
+            assertEquals(resource.value("since"), ((Map) ((Map) fromStatic.get("properties")).get("since")).get("value"));
+            assertEquals(IteratorUtils.count(resource.properties()), ((Map) recycled.get("properties")).size());
+            assertEquals(resource.keys().iterator().next(), ((Map) ((Map) recycled.get("properties")).get("since")).get("key"));
+            assertEquals(resource.value("since"), ((Map) ((Map) recycled.get("properties")).get("since")).get("value"));
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/77f527c6/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUntypedCompatibilityTest.java
----------------------------------------------------------------------
diff --git a/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUntypedCompatibilityTest.java b/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUntypedCompatibilityTest.java
index 34c5f84..08eb811 100644
--- a/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUntypedCompatibilityTest.java
+++ b/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUntypedCompatibilityTest.java
@@ -51,13 +51,10 @@ public class GraphSONUntypedCompatibilityTest extends AbstractUntypedCompatibili
     public static Iterable<Object[]> data() {
         return Arrays.asList(new Object[][]{
                 {GraphSONCompatibility.V1D0_3_2_3, mapperV1 },
-                {GraphSONCompatibility.V1D0_3_2_3, mapperV2 },
                 {GraphSONCompatibility.V2D0_NO_TYPE_3_2_3, mapperV2 },
                 {GraphSONCompatibility.V1D0_3_2_4, mapperV1 },
-                {GraphSONCompatibility.V1D0_3_2_4, mapperV2 },
                 {GraphSONCompatibility.V2D0_NO_TYPE_3_2_4, mapperV2 },
                 {GraphSONCompatibility.V1D0_3_3_0, mapperV1 },
-                {GraphSONCompatibility.V1D0_3_3_0, mapperV2 },
                 {GraphSONCompatibility.V2D0_NO_TYPE_3_3_0, mapperV2 }
         });
     }


[3/3] tinkerpop git commit: TINKERPOP-1130 Finished tests for untyped structure elements.

Posted by sp...@apache.org.
TINKERPOP-1130 Finished tests for untyped structure elements.


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

Branch: refs/heads/TINKERPOP-1130
Commit: 0f3d8feac2682c577ed2f182ebcf4a0adebe42ab
Parents: cf98809
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Dec 30 11:26:13 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 30 11:26:13 2016 -0500

----------------------------------------------------------------------
 .../tinkerpop/gremlin/structure/io/Model.java   | 12 +--
 .../io/AbstractUntypedCompatibilityTest.java    | 84 ++++++++++++++++++++
 2 files changed, 88 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0f3d8fea/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 de8cece..3e07cea 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
@@ -118,16 +118,12 @@ public class Model {
                 .configuredAs(".*no-types").matchToArray();
         addGraphStructureEntry(graph.edges().next(), "Edge", "", graphsonV2NoType);
         addGraphStructureEntry(g.V().out().out().path().next(), "Path", "", graphsonV2NoType);
-        addGraphStructureEntry(graph.edges().next().properties().next(), "Property");
+        addGraphStructureEntry(graph.edges().next().properties().next(), "Property", "", graphsonV2NoType);
         addEntry("Graph Structure", StarGraph.of(graph.vertices().next()), "StarGraph", "", Compatibilities.GRYO_ONLY.match());
-        addEntry("Graph Structure", graph, "TinkerGraph", "`TinkerGraph` has a custom serializer that is registered as part of the `TinkerIoRegistry`.",
-                new HashMap<Compatibility, String>() {{
-                    put(GryoCompatibility.V1D0_3_2_3, "Serialization of TinkerGraph had a bug that prevented proper operation in versions prior to 3.2.4.");
-                    put(GraphSONCompatibility.V2D0_PARTIAL_3_2_3, "Serialization of TinkerGraph had a bug that prevented proper operation in versions prior to 3.2.4.");
-                }}, GryoCompatibility.V1D0_3_2_3, GraphSONCompatibility.V2D0_PARTIAL_3_2_3);
+        addGraphStructureEntry(graph, "TinkerGraph", "`TinkerGraph` has a custom serializer that is registered as part of the `TinkerIoRegistry`.");
         addEntry("Graph Structure", g.V(1).out().out().tree().next(), "Tree", "", Compatibilities.GRYO_ONLY.match());
-        addGraphStructureEntry(graph.vertices().next(), "Vertex");
-        addGraphStructureEntry(graph.vertices().next().properties().next(), "VertexProperty");
+        addGraphStructureEntry(graph.vertices().next(), "Vertex", "", graphsonV2NoType);
+        addGraphStructureEntry(graph.vertices().next().properties().next(), "VertexProperty", "", graphsonV2NoType);
 
         addGraphProcessEntry(SackFunctions.Barrier.normSack, "Barrier", "");
         addGraphProcessEntry(new Bytecode.Binding("x", 1), "Binding", "A \"Binding\" refers to a `Bytecode.Binding`.");

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0f3d8fea/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractUntypedCompatibilityTest.java
----------------------------------------------------------------------
diff --git a/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractUntypedCompatibilityTest.java b/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractUntypedCompatibilityTest.java
index 94118ca..fb36cfc 100644
--- a/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractUntypedCompatibilityTest.java
+++ b/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractUntypedCompatibilityTest.java
@@ -23,7 +23,9 @@ import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
 import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
 import org.apache.tinkerpop.gremlin.process.traversal.Path;
 import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Property;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 import org.junit.Test;
 
@@ -155,4 +157,86 @@ public abstract class AbstractUntypedCompatibilityTest extends AbstractCompatibi
         assertEquals(((Vertex) resource.objects().get(2)).id(), ((Map) ((List) recycled.get("objects")).get(2)).get("id"));
         assertEquals(((Vertex) resource.objects().get(2)).label(), ((Map) ((List) recycled.get("objects")).get(2)).get("label"));
     }
+
+    @Test
+    public void shouldReadWriteProperty() throws Exception {
+        final String resourceName = "property";
+        assumeCompatibility(resourceName);
+
+        final Property resource = findModelEntryObject(resourceName);
+        final HashMap fromStatic = read(getCompatibility().readFromResource(resourceName), HashMap.class);
+        final HashMap recycled = read(write(resource, Path.class), HashMap.class);
+        assertNotSame(fromStatic, recycled);
+        assertEquals(2, fromStatic.size());
+        assertEquals(resource.key(), fromStatic.get("key"));
+        assertEquals(resource.value(), fromStatic.get("value"));
+        assertEquals(2, recycled.size());
+        assertEquals(resource.key(), recycled.get("key"));
+        assertEquals(resource.value(), recycled.get("value"));
+    }
+
+    @Test
+    public void shouldReadWriteVertex() throws Exception {
+        final String resourceName = "vertex";
+        assumeCompatibility(resourceName);
+
+        final Vertex resource = findModelEntryObject(resourceName);
+        final HashMap fromStatic = read(getCompatibility().readFromResource(resourceName), HashMap.class);
+        final HashMap recycled = read(write(resource, Edge.class), HashMap.class);
+        assertNotSame(fromStatic, recycled);
+        assertEquals(resource.id(), fromStatic.get("id"));
+        assertEquals(resource.label(), fromStatic.get("label"));
+        assertEquals(resource.id(), fromStatic.get("id"));
+        assertEquals(resource.id(), recycled.get("id"));
+        assertEquals(resource.label(), recycled.get("label"));
+        assertEquals(resource.id(), recycled.get("id"));
+        assertEquals(IteratorUtils.count(resource.keys()), ((Map) fromStatic.get("properties")).size());
+        assertEquals(resource.value("name"), ((Map) ((List) ((Map) fromStatic.get("properties")).get("name")).get(0)).get("value"));
+        assertEquals(IteratorUtils.list(resource.values("location")).get(0), ((Map) ((List) ((Map) fromStatic.get("properties")).get("location")).get(0)).get("value"));
+        assertEquals(IteratorUtils.list(resource.values("location")).get(1), ((Map) ((List) ((Map) fromStatic.get("properties")).get("location")).get(1)).get("value"));
+        assertEquals(IteratorUtils.list(resource.values("location")).get(2), ((Map) ((List) ((Map) fromStatic.get("properties")).get("location")).get(2)).get("value"));
+        assertEquals(((VertexProperty) IteratorUtils.list(resource.properties("location")).get(0)).value("startTime"), ((Map) ((Map) ((List) ((Map) fromStatic.get("properties")).get("location")).get(0)).get("properties")).get("startTime"));
+        assertEquals(((VertexProperty) IteratorUtils.list(resource.properties("location")).get(0)).value("endTime"), ((Map) ((Map) ((List) ((Map) fromStatic.get("properties")).get("location")).get(0)).get("properties")).get("endTime"));
+        assertEquals(((VertexProperty) IteratorUtils.list(resource.properties("location")).get(1)).value("startTime"), ((Map) ((Map) ((List) ((Map) fromStatic.get("properties")).get("location")).get(1)).get("properties")).get("startTime"));
+        assertEquals(((VertexProperty) IteratorUtils.list(resource.properties("location")).get(1)).value("endTime"), ((Map) ((Map) ((List) ((Map) fromStatic.get("properties")).get("location")).get(1)).get("properties")).get("endTime"));
+        assertEquals(((VertexProperty) IteratorUtils.list(resource.properties("location")).get(2)).value("startTime"), ((Map) ((Map) ((List) ((Map) fromStatic.get("properties")).get("location")).get(2)).get("properties")).get("startTime"));
+        assertEquals(((VertexProperty) IteratorUtils.list(resource.properties("location")).get(2)).value("endTime"), ((Map) ((Map) ((List) ((Map) fromStatic.get("properties")).get("location")).get(2)).get("properties")).get("endTime"));
+        assertEquals(((VertexProperty) IteratorUtils.list(resource.properties("location")).get(3)).value("startTime"), ((Map) ((Map) ((List) ((Map) fromStatic.get("properties")).get("location")).get(3)).get("properties")).get("startTime"));
+        assertEquals(IteratorUtils.count(resource.keys()), ((Map) recycled.get("properties")).size());
+        assertEquals(resource.value("name"), ((Map) ((List) ((Map) recycled.get("properties")).get("name")).get(0)).get("value"));
+        assertEquals(IteratorUtils.list(resource.values("location")).get(0), ((Map) ((List) ((Map) recycled.get("properties")).get("location")).get(0)).get("value"));
+        assertEquals(IteratorUtils.list(resource.values("location")).get(1), ((Map) ((List) ((Map) recycled.get("properties")).get("location")).get(1)).get("value"));
+        assertEquals(IteratorUtils.list(resource.values("location")).get(2), ((Map) ((List) ((Map) recycled.get("properties")).get("location")).get(2)).get("value"));
+        assertEquals(((VertexProperty) IteratorUtils.list(resource.properties("location")).get(0)).value("startTime"), ((Map) ((Map) ((List) ((Map) recycled.get("properties")).get("location")).get(0)).get("properties")).get("startTime"));
+        assertEquals(((VertexProperty) IteratorUtils.list(resource.properties("location")).get(0)).value("endTime"), ((Map) ((Map) ((List) ((Map) recycled.get("properties")).get("location")).get(0)).get("properties")).get("endTime"));
+        assertEquals(((VertexProperty) IteratorUtils.list(resource.properties("location")).get(1)).value("startTime"), ((Map) ((Map) ((List) ((Map) recycled.get("properties")).get("location")).get(1)).get("properties")).get("startTime"));
+        assertEquals(((VertexProperty) IteratorUtils.list(resource.properties("location")).get(1)).value("endTime"), ((Map) ((Map) ((List) ((Map) recycled.get("properties")).get("location")).get(1)).get("properties")).get("endTime"));
+        assertEquals(((VertexProperty) IteratorUtils.list(resource.properties("location")).get(2)).value("startTime"), ((Map) ((Map) ((List) ((Map) recycled.get("properties")).get("location")).get(2)).get("properties")).get("startTime"));
+        assertEquals(((VertexProperty) IteratorUtils.list(resource.properties("location")).get(2)).value("endTime"), ((Map) ((Map) ((List) ((Map) recycled.get("properties")).get("location")).get(2)).get("properties")).get("endTime"));
+        assertEquals(((VertexProperty) IteratorUtils.list(resource.properties("location")).get(3)).value("startTime"), ((Map) ((Map) ((List) ((Map) recycled.get("properties")).get("location")).get(3)).get("properties")).get("startTime"));
+
+        // deal with incompatibilities
+        if (getCompatibility().getConfiguration().equals("v1d0")) {
+            assertEquals("vertex", fromStatic.get("type"));
+        }
+    }
+
+    @Test
+    public void shouldReadWriteVertexProperty() throws Exception {
+        final String resourceName = "vertexproperty";
+        assumeCompatibility(resourceName);
+
+        final VertexProperty resource = findModelEntryObject(resourceName);
+        final HashMap fromStatic = read(getCompatibility().readFromResource(resourceName), HashMap.class);
+        final HashMap recycled = read(write(resource, Edge.class), HashMap.class);
+        assertNotSame(fromStatic, recycled);
+        assertEquals(3, fromStatic.size());
+        assertEquals(resource.id().toString(), fromStatic.get("id").toString());
+        assertEquals(resource.key(), fromStatic.get("label"));
+        assertEquals(resource.value(), fromStatic.get("value"));
+        assertEquals(3, recycled.size());
+        assertEquals(resource.id().toString(), fromStatic.get("id").toString());
+        assertEquals(resource.key(), recycled.get("label"));
+        assertEquals(resource.value(), recycled.get("value"));
+    }
 }


[2/3] tinkerpop git commit: TINKERPOP-1130 Testing for Path untyped GraphSON

Posted by sp...@apache.org.
TINKERPOP-1130 Testing for Path untyped GraphSON


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

Branch: refs/heads/TINKERPOP-1130
Commit: cf98809b76d24132c5a4a596f9fc5b00ed4ad45c
Parents: 77f527c
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Dec 30 10:35:28 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Dec 30 10:35:28 2016 -0500

----------------------------------------------------------------------
 .../tinkerpop/gremlin/structure/io/Model.java   |  2 +-
 .../io/AbstractUntypedCompatibilityTest.java    | 38 +++++++++++++++++++-
 2 files changed, 38 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cf98809b/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 24af1d8..de8cece 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
@@ -117,7 +117,7 @@ public class Model {
         final Compatibility[] graphsonV2NoType = Compatibilities.with(GraphSONCompatibility.class)
                 .configuredAs(".*no-types").matchToArray();
         addGraphStructureEntry(graph.edges().next(), "Edge", "", graphsonV2NoType);
-        addGraphStructureEntry(g.V().out().out().path().next(), "Path");
+        addGraphStructureEntry(g.V().out().out().path().next(), "Path", "", graphsonV2NoType);
         addGraphStructureEntry(graph.edges().next().properties().next(), "Property");
         addEntry("Graph Structure", StarGraph.of(graph.vertices().next()), "StarGraph", "", Compatibilities.GRYO_ONLY.match());
         addEntry("Graph Structure", graph, "TinkerGraph", "`TinkerGraph` has a custom serializer that is registered as part of the `TinkerIoRegistry`.",

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cf98809b/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractUntypedCompatibilityTest.java
----------------------------------------------------------------------
diff --git a/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractUntypedCompatibilityTest.java b/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractUntypedCompatibilityTest.java
index 94a1c0c..94118ca 100644
--- a/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractUntypedCompatibilityTest.java
+++ b/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractUntypedCompatibilityTest.java
@@ -21,11 +21,14 @@ package org.apache.tinkerpop.gremlin.structure.io;
 import org.apache.tinkerpop.gremlin.driver.message.RequestMessage;
 import org.apache.tinkerpop.gremlin.driver.message.ResponseMessage;
 import org.apache.tinkerpop.gremlin.driver.message.ResponseStatusCode;
+import org.apache.tinkerpop.gremlin.process.traversal.Path;
 import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 import org.junit.Test;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import static org.junit.Assert.assertEquals;
@@ -84,7 +87,7 @@ public abstract class AbstractUntypedCompatibilityTest extends AbstractCompatibi
         assumeCompatibility(resourceName);
 
         final Edge resource = findModelEntryObject(resourceName);
-        final HashMap fromStatic = read(getCompatibility().readFromResource("edge"), HashMap.class);
+        final HashMap fromStatic = read(getCompatibility().readFromResource(resourceName), HashMap.class);
         final HashMap recycled = read(write(resource, Edge.class), HashMap.class);
         assertNotSame(fromStatic, recycled);
         assertEquals(resource.id(), fromStatic.get("id"));
@@ -119,4 +122,37 @@ public abstract class AbstractUntypedCompatibilityTest extends AbstractCompatibi
             assertEquals(resource.value("since"), ((Map) ((Map) recycled.get("properties")).get("since")).get("value"));
         }
     }
+
+    @Test
+    public void shouldReadWritePath() throws Exception {
+        final String resourceName = "path";
+        assumeCompatibility(resourceName);
+
+        final Path resource = findModelEntryObject(resourceName);
+        final HashMap fromStatic = read(getCompatibility().readFromResource(resourceName), HashMap.class);
+        final HashMap recycled = read(write(resource, Path.class), HashMap.class);
+        assertNotSame(fromStatic, recycled);
+        assertEquals(resource.labels().size(), ((List) fromStatic.get("labels")).size());
+        assertEquals(resource.labels().get(0).size(), ((List) ((List) fromStatic.get("labels")).get(0)).size());
+        assertEquals(resource.labels().get(1).size(), ((List) ((List) fromStatic.get("labels")).get(1)).size());
+        assertEquals(resource.labels().get(2).size(), ((List) ((List) fromStatic.get("labels")).get(2)).size());
+        assertEquals(resource.objects().size(), ((List) fromStatic.get("objects")).size());
+        assertEquals(((Vertex) resource.objects().get(0)).id(), ((Map) ((List) fromStatic.get("objects")).get(0)).get("id"));
+        assertEquals(((Vertex) resource.objects().get(0)).label(), ((Map) ((List) fromStatic.get("objects")).get(0)).get("label"));
+        assertEquals(((Vertex) resource.objects().get(1)).id(), ((Map) ((List) fromStatic.get("objects")).get(1)).get("id"));
+        assertEquals(((Vertex) resource.objects().get(1)).label(), ((Map) ((List) fromStatic.get("objects")).get(1)).get("label"));
+        assertEquals(((Vertex) resource.objects().get(2)).id(), ((Map) ((List) fromStatic.get("objects")).get(2)).get("id"));
+        assertEquals(((Vertex) resource.objects().get(2)).label(), ((Map) ((List) fromStatic.get("objects")).get(2)).get("label"));
+        assertEquals(resource.labels().size(), ((List) recycled.get("labels")).size());
+        assertEquals(resource.labels().get(0).size(), ((List) ((List) recycled.get("labels")).get(0)).size());
+        assertEquals(resource.labels().get(1).size(), ((List) ((List) recycled.get("labels")).get(1)).size());
+        assertEquals(resource.labels().get(2).size(), ((List) ((List) recycled.get("labels")).get(2)).size());
+        assertEquals(resource.objects().size(), ((List) recycled.get("objects")).size());
+        assertEquals(((Vertex) resource.objects().get(0)).id(), ((Map) ((List) recycled.get("objects")).get(0)).get("id"));
+        assertEquals(((Vertex) resource.objects().get(0)).label(), ((Map) ((List) recycled.get("objects")).get(0)).get("label"));
+        assertEquals(((Vertex) resource.objects().get(1)).id(), ((Map) ((List) recycled.get("objects")).get(1)).get("id"));
+        assertEquals(((Vertex) resource.objects().get(1)).label(), ((Map) ((List) recycled.get("objects")).get(1)).get("label"));
+        assertEquals(((Vertex) resource.objects().get(2)).id(), ((Map) ((List) recycled.get("objects")).get(2)).get("id"));
+        assertEquals(((Vertex) resource.objects().get(2)).label(), ((Map) ((List) recycled.get("objects")).get(2)).get("label"));
+    }
 }