tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [31/44] tinkerpop git commit: TINKERPOP-1130 Testing for Path untyped GraphSON
Date Fri, 06 Jan 2017 19:42:36 GMT
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/fff3e98a
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/fff3e98a
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/fff3e98a

Branch: refs/heads/master
Commit: fff3e98ad7d5b89cde3e4f43197bad4e1f1de487
Parents: 20727db
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Fri Dec 30 10:35:28 2016 -0500
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Tue Jan 3 10:34:56 2017 -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/fff3e98a/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/fff3e98a/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"));
+    }
 }


Mime
View raw message