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/08/13 22:03:30 UTC

[13/22] incubator-tinkerpop git commit: Added shouldWriteXYZGraphASTP2GraphSON tests which utilize GraphSONLegacyWriter and TP2GraphSONUtility. CrewGraph is the only one failing due to "multiple properties for same key" location

Added shouldWriteXYZGraphASTP2GraphSON tests which utilize GraphSONLegacyWriter and TP2GraphSONUtility. CrewGraph is the only one failing due to "multiple properties for same key" location


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

Branch: refs/heads/tp30-legson
Commit: 081e403c892c9e7b08d7d934fae7ffad3c7a04e6
Parents: 12cadd2
Author: ebice <eb...@behaviormatrix.com>
Authored: Thu Jul 2 15:09:52 2015 -0400
Committer: ebice <eb...@behaviormatrix.com>
Committed: Thu Jul 2 15:09:52 2015 -0400

----------------------------------------------------------------------
 .../io/graphson/GraphSONLegacyWriter.java       |  8 ++--
 .../io/graphson/TP2GraphSONUtility.java         | 11 +++---
 .../structure/IoDataGenerationTest.java         | 41 +++++++++++++++++---
 3 files changed, 46 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/081e403c/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONLegacyWriter.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONLegacyWriter.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONLegacyWriter.java
index 5f5e137..8d517a2 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONLegacyWriter.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONLegacyWriter.java
@@ -115,7 +115,7 @@ public class GraphSONLegacyWriter {
         Iterable<Vertex> vertices;
         if (normalize) {
             vertices = new ArrayList<Vertex>();
-            Iterator<Vertex> viter = graph.vertices(null);
+            Iterator<Vertex> viter = graph.vertices();
             while (viter.hasNext()) {
                 ((Collection<Vertex>) vertices).add(viter.next());
             }
@@ -124,7 +124,7 @@ public class GraphSONLegacyWriter {
             vertices = new Iterable<Vertex>() {
                 @Override
                 public Iterator<Vertex> iterator() {
-                    return graph.vertices(null);
+                    return graph.vertices();
                 }
             };
         }
@@ -135,7 +135,7 @@ public class GraphSONLegacyWriter {
         Iterable<Edge> edges;
         if (normalize) {
             edges = new ArrayList<Edge>();
-            Iterator<Edge> eiter = graph.edges(null);
+            Iterator<Edge> eiter = graph.edges();
             while (eiter.hasNext()) {
                 ((Collection<Edge>) edges).add(eiter.next());
             }
@@ -144,7 +144,7 @@ public class GraphSONLegacyWriter {
             edges = new Iterable<Edge>() {
                 @Override
                 public Iterator<Edge> iterator() {
-                    return graph.edges(null);
+                    return graph.edges();
                 }
             };
         }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/081e403c/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TP2GraphSONUtility.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TP2GraphSONUtility.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TP2GraphSONUtility.java
index 73e895f..4806a0d 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TP2GraphSONUtility.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TP2GraphSONUtility.java
@@ -440,8 +440,9 @@ public class TP2GraphSONUtility {
     }
 
     private static ObjectNode objectNodeFromElement(final Element element, final List<String> propertyKeys, final GraphSONMode mode) {
-        final TP2GraphSONUtility graphson = element instanceof Edge ? new TP2GraphSONUtility(mode, null, null, new HashSet<String>(propertyKeys))
-                : new TP2GraphSONUtility(mode, null, new HashSet<String>(propertyKeys), null);
+        Set<String> propKeySet = (propertyKeys!=null)? new HashSet<String>(propertyKeys) : null;
+        final TP2GraphSONUtility graphson = element instanceof Edge ? new TP2GraphSONUtility(mode, null, null, propKeySet)
+                : new TP2GraphSONUtility(mode, null, propKeySet, null);
         return graphson.objectNodeFromElement(element);
     }
 
@@ -692,7 +693,7 @@ public class TP2GraphSONUtility {
 
         if (propertyKeys == null) {
             for (String key : propertyKeyList) {
-                final Object valToPutInMap = element.property(key);
+                final Object valToPutInMap = element.property(key).value();
                 if (valToPutInMap != null) {
                     map.put(key, valToPutInMap);
                 }
@@ -700,7 +701,7 @@ public class TP2GraphSONUtility {
         } else {
             if (rule == ElementPropertiesRule.INCLUDE) {
                 for (String key : propertyKeys) {
-                    final Object valToPutInMap = element.property(key);
+                    final Object valToPutInMap = element.property(key).value();
                     if (valToPutInMap != null) {
                         map.put(key, valToPutInMap);
                     }
@@ -708,7 +709,7 @@ public class TP2GraphSONUtility {
             } else {
                 for (String key : propertyKeyList) {
                     if (!propertyKeys.contains(key)) {
-                        final Object valToPutInMap = element.property(key);
+                        final Object valToPutInMap = element.property(key).value();
                         if (valToPutInMap != null) {
                             map.put(key, valToPutInMap);
                         }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/081e403c/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/IoDataGenerationTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/IoDataGenerationTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/IoDataGenerationTest.java
index 86fc733..7882778 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/IoDataGenerationTest.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/IoDataGenerationTest.java
@@ -29,6 +29,7 @@ import org.apache.tinkerpop.gremlin.structure.T;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.io.GraphReader;
 import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLWriter;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONLegacyWriter;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper;
 import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter;
 import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoReader;
@@ -36,11 +37,7 @@ import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoWriter;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
+import java.io.*;
 import java.util.stream.IntStream;
 
 /**
@@ -126,6 +123,16 @@ public class IoDataGenerationTest {
      * No assertions.  Just write out the graph for convenience.
      */
     @Test
+    public void shouldWriteClassicGraphAsTP2GraphSONNoTypes() throws IOException {
+        final OutputStream os = new FileOutputStream(tempPath + "tinkerpop2-classic.json");
+        GraphSONLegacyWriter.outputGraph(TinkerFactory.createClassic(), os);
+        os.close();
+    }
+
+    /**
+     * No assertions.  Just write out the graph for convenience.
+     */
+    @Test
     public void shouldWriteModernGraphAsGraphSONNoTypes() throws IOException {
         final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-modern.json");
         GraphSONWriter.build().create().writeGraph(os, TinkerFactory.createModern());
@@ -136,6 +143,16 @@ public class IoDataGenerationTest {
      * No assertions.  Just write out the graph for convenience.
      */
     @Test
+    public void shouldWriteModernGraphAsTP2GraphSONNoTypes() throws IOException {
+        final OutputStream os = new FileOutputStream(tempPath + "tinkerpop2-modern.json");
+        GraphSONLegacyWriter.outputGraph(TinkerFactory.createModern(), os);
+        os.close();
+    }
+
+    /**
+     * No assertions.  Just write out the graph for convenience.
+     */
+    @Test
     public void shouldWriteCrewGraphAsGraphSONNoTypes() throws IOException {
         final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-crew.json");
         GraphSONWriter.build().create().writeGraph(os, TinkerFactory.createTheCrew());
@@ -146,6 +163,16 @@ public class IoDataGenerationTest {
      * No assertions.  Just write out the graph for convenience.
      */
     @Test
+    public void shouldWriteCrewGraphAsTP2GraphSONNoTypes() throws IOException {
+        final OutputStream os = new FileOutputStream(tempPath + "tinkerpop2-crew.json");
+        GraphSONLegacyWriter.outputGraph(TinkerFactory.createTheCrew(), os);
+        os.close();
+    }
+
+    /**
+     * No assertions.  Just write out the graph for convenience.
+     */
+    @Test
     public void shouldWriteClassicGraphNormalizedAsGraphSON() throws IOException {
         final OutputStream os = new FileOutputStream(tempPath + "tinkerpop-classic-normalized.json");
         GraphSONWriter.build().mapper(GraphSONMapper.build().normalize(true).create()).create().writeGraph(os, TinkerFactory.createClassic());
@@ -274,5 +301,9 @@ public class IoDataGenerationTest {
         final OutputStream os4 = new FileOutputStream(tempPath + "grateful-dead-typed.json");
         GraphSONWriter.build().mapper(GraphSONMapper.build().embedTypes(true).create()).create().writeGraph(os4, g);
         os4.close();
+
+        final OutputStream os5 = new FileOutputStream(tempPath + "grateful-dead-tp2.json");
+        GraphSONLegacyWriter.outputGraph(g, os5);
+        os5.close();
     }
 }