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 2017/07/13 17:27:21 UTC
[04/34] tinkerpop git commit: TINKERPOP-1427 Added g:Map for GraphSON
3.0
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperEmbeddedTypeTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperEmbeddedTypeTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperEmbeddedTypeTest.java
index 66bab80..b65f5c7 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperEmbeddedTypeTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperEmbeddedTypeTest.java
@@ -43,7 +43,12 @@ import java.time.YearMonth;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import static org.hamcrest.CoreMatchers.any;
+import static org.hamcrest.Matchers.either;
import static org.hamcrest.core.StringStartsWith.startsWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assume.assumeThat;
@@ -61,6 +66,9 @@ public class GraphSONMapperEmbeddedTypeTest extends AbstractGraphSONTest {
{"v2", GraphSONMapper.build().version(GraphSONVersion.V2_0)
.addCustomModule(GraphSONXModuleV2d0.build().create(false))
.typeInfo(TypeInfo.PARTIAL_TYPES).create().createMapper()},
+ {"v3", GraphSONMapper.build().version(GraphSONVersion.V3_0)
+ .addCustomModule(GraphSONXModuleV3d0.build().create(false))
+ .typeInfo(TypeInfo.PARTIAL_TYPES).create().createMapper()}
});
}
@@ -72,8 +80,23 @@ public class GraphSONMapperEmbeddedTypeTest extends AbstractGraphSONTest {
public String version;
@Test
+ public void shouldHandleMap() throws Exception {
+ assumeThat(version, startsWith("v3"));
+
+ final Map<Object,Object> o = new HashMap<>();
+ o.put("string key", "string value");
+ o.put(1, 1);
+ o.put(1L, 1L);
+
+ final List<Object> l = Arrays.asList("test", 1, 5L);
+ o.put(l, "crazy");
+
+ assertEquals(o, serializeDeserialize(mapper, o, Map.class));
+ }
+
+ @Test
public void shouldHandleBiFunctionLambda() throws Exception {
- assumeThat(version, startsWith("v2"));
+ assumeThat(version, either(startsWith("v2")).or(startsWith("v3")));
final Lambda o = (Lambda) Lambda.biFunction("x,y -> 'test'");
assertEquals(o, serializeDeserialize(mapper, o, Lambda.class));
@@ -81,7 +104,7 @@ public class GraphSONMapperEmbeddedTypeTest extends AbstractGraphSONTest {
@Test
public void shouldHandleComparatorLambda() throws Exception {
- assumeThat(version, startsWith("v2"));
+ assumeThat(version, either(startsWith("v2")).or(startsWith("v3")));
final Lambda o = (Lambda) Lambda.comparator("x,y -> x <=> y");
assertEquals(o, serializeDeserialize(mapper, o, Lambda.class));
@@ -89,7 +112,7 @@ public class GraphSONMapperEmbeddedTypeTest extends AbstractGraphSONTest {
@Test
public void shouldHandleConsumerLambda() throws Exception {
- assumeThat(version, startsWith("v2"));
+ assumeThat(version, either(startsWith("v2")).or(startsWith("v3")));
final Lambda o = (Lambda) Lambda.consumer("x -> x");
assertEquals(o, serializeDeserialize(mapper, o, Lambda.class));
@@ -97,7 +120,7 @@ public class GraphSONMapperEmbeddedTypeTest extends AbstractGraphSONTest {
@Test
public void shouldHandleFunctionLambda() throws Exception {
- assumeThat(version, startsWith("v2"));
+ assumeThat(version, either(startsWith("v2")).or(startsWith("v3")));
final Lambda o = (Lambda) Lambda.function("x -> x");
assertEquals(o, serializeDeserialize(mapper, o, Lambda.class));
@@ -105,7 +128,7 @@ public class GraphSONMapperEmbeddedTypeTest extends AbstractGraphSONTest {
@Test
public void shouldHandlePredicateLambda() throws Exception {
- assumeThat(version, startsWith("v2"));
+ assumeThat(version, either(startsWith("v2")).or(startsWith("v3")));
final Lambda o = (Lambda) Lambda.predicate("x -> true");
assertEquals(o, serializeDeserialize(mapper, o, Lambda.class));
@@ -113,7 +136,7 @@ public class GraphSONMapperEmbeddedTypeTest extends AbstractGraphSONTest {
@Test
public void shouldHandleSupplierLambda() throws Exception {
- assumeThat(version, startsWith("v2"));
+ assumeThat(version, either(startsWith("v2")).or(startsWith("v3")));
final Lambda o = (Lambda) Lambda.supplier("'test'");
assertEquals(o, serializeDeserialize(mapper, o, Lambda.class));
@@ -121,7 +144,7 @@ public class GraphSONMapperEmbeddedTypeTest extends AbstractGraphSONTest {
@Test
public void shouldHandleBytecodeBinding() throws Exception {
- assumeThat(version, startsWith("v2"));
+ assumeThat(version, either(startsWith("v2")).or(startsWith("v3")));
final Bytecode.Binding<String> o = new Bytecode.Binding<>("test", "testing");
assertEquals(o, serializeDeserialize(mapper, o, Bytecode.Binding.class));
@@ -129,7 +152,7 @@ public class GraphSONMapperEmbeddedTypeTest extends AbstractGraphSONTest {
@Test
public void shouldHandleTraverser() throws Exception {
- assumeThat(version, startsWith("v2"));
+ assumeThat(version, either(startsWith("v2")).or(startsWith("v3")));
final Traverser<String> o = new DefaultRemoteTraverser<>("test", 100);
assertEquals(o, serializeDeserialize(mapper, o, Traverser.class));
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperPartialEmbeddedTypeTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperPartialEmbeddedTypeTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperPartialEmbeddedTypeTest.java
new file mode 100644
index 0000000..de4cc58
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperPartialEmbeddedTypeTest.java
@@ -0,0 +1,297 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.structure.io.graphson;
+
+import org.apache.tinkerpop.gremlin.process.remote.traversal.DefaultRemoteTraverser;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.time.Instant;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.StringContains.containsString;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * Tests automatic typed serialization/deserialization for GraphSON 2.0+.
+ *
+ * @author Kevin Gallardo (https://kgdo.me)
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+@RunWith(Parameterized.class)
+public class GraphSONMapperPartialEmbeddedTypeTest extends AbstractGraphSONTest {
+
+ @Parameterized.Parameters(name = "{0}")
+ public static Iterable<Object[]> data() {
+ return Arrays.asList(new Object[][]{
+ {"v2", GraphSONMapper.build().version(GraphSONVersion.V2_0)
+ .addCustomModule(GraphSONXModuleV2d0.build().create(false))
+ .typeInfo(TypeInfo.PARTIAL_TYPES).create().createMapper()},
+ {"v3", GraphSONMapper.build().version(GraphSONVersion.V3_0)
+ .addCustomModule(GraphSONXModuleV3d0.build().create(false))
+ .typeInfo(TypeInfo.PARTIAL_TYPES).create().createMapper()}
+ });
+ }
+
+ @Parameterized.Parameter(1)
+ public ObjectMapper mapper;
+
+
+ @Parameterized.Parameter(0)
+ public String version;
+
+ @Test
+ public void shouldSerializeDeserializeNestedCollectionsAndMapAndTypedValuesCorrectly() throws Exception {
+ // Trying to fail the TypeDeserializer type detection
+ final UUID uuid = UUID.randomUUID();
+ final List<Object> myList = new ArrayList<>();
+
+ final List<Object> myList2 = new ArrayList<>();
+ myList2.add(UUID.randomUUID());
+ myList2.add(33L);
+ myList2.add(84);
+ final Map<String,Object> map2 = new HashMap<>();
+ map2.put("eheh", UUID.randomUUID());
+ map2.put("normal", "normal");
+ myList2.add(map2);
+
+ final Map<String, Object> map1 = new HashMap<>();
+ map1.put("hello", "world");
+ map1.put("test", uuid);
+ map1.put("hehe", myList2);
+ myList.add(map1);
+
+ myList.add("kjkj");
+ myList.add(UUID.randomUUID());
+ assertEquals(myList, serializeDeserializeAuto(mapper, myList));
+
+ // no "@value" property
+ String s = "{\""+GraphSONTokens.VALUETYPE+"\":\"" + GraphSONTokens.GREMLIN_TYPE_NAMESPACE + ":UUID\", \"test\":2}";
+ Map<String,Object> map = new LinkedHashMap<>();
+ map.put(GraphSONTokens.VALUETYPE, GraphSONTokens.GREMLIN_TYPE_NAMESPACE + ":UUID");
+ map.put("test", 2);
+ Object res = mapper.readValue(s, Object.class);
+ assertEquals(map, res);
+
+ // "@value" and "@type" property reversed
+ s = "{\""+GraphSONTokens.VALUEPROP+"\":2, \"" + GraphSONTokens.VALUETYPE + "\":\"" + GraphSONTokens.GREMLIN_TYPE_NAMESPACE + ":Int64\"}";
+ res = mapper.readValue(s, Object.class);
+ assertEquals(res, 2L);
+ assertEquals(res.getClass(), Long.class);
+
+ // no "@type" property.
+ s = "{\""+GraphSONTokens.VALUEPROP + "\":2, \"id\":2}";
+ map = new LinkedHashMap<>();
+ map.put(GraphSONTokens.VALUEPROP, 2);
+ map.put("id", 2);
+ res = mapper.readValue(s, Object.class);
+ assertEquals(res, map);
+ }
+
+ @Test
+ public void shouldFailIfMoreThanTwoPropertiesInATypePattern() {
+ String s = "{\"" + GraphSONTokens.VALUEPROP + "\":2, \"" + GraphSONTokens.VALUETYPE + "\":\""+GraphSONTokens.GREMLIN_TYPE_NAMESPACE +":Int64\", \"hello\": \"world\"}";
+ try {
+ mapper.readValue(s, Object.class);
+ fail("Should have failed deserializing because there's more than properties in the type.");
+ } catch (IOException e) {
+ assertThat(e.getMessage(), containsString("Detected the type pattern in the JSON payload but the map containing the types and values contains other fields. This is not allowed by the deserializer."));
+ }
+ s = "{\"" + GraphSONTokens.VALUETYPE + "\":\""+GraphSONTokens.GREMLIN_TYPE_NAMESPACE +":Int64\",\"" + GraphSONTokens.VALUEPROP + "\":2, \"hello\": \"world\"}";
+ try {
+ mapper.readValue(s, Object.class);
+ fail("Should have failed deserializing because there's more than properties in the type.");
+ } catch (IOException e) {
+ assertThat(e.getMessage(), containsString("Detected the type pattern in the JSON payload but the map containing the types and values contains other fields. This is not allowed by the deserializer."));
+ }
+ }
+
+ @Test
+ public void shouldFailIfTypeSpecifiedIsNotSameTypeInPayload() {
+ final ZoneOffset o = ZonedDateTime.now().getOffset();
+ final ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ try {
+ mapper.writeValue(stream, o);
+ final InputStream inputStream = new ByteArrayInputStream(stream.toByteArray());
+ // What has been serialized is a ZoneOffset with the type, but the user explicitly requires another type.
+ mapper.readValue(inputStream, Instant.class);
+ fail("Should have failed decoding the value");
+ } catch (Exception e) {
+ assertThat(e.getMessage(), containsString("Could not deserialize the JSON value as required. Nested exception: java.lang.InstantiationException: Cannot deserialize the value with the detected type contained in the JSON ('" + GraphSONTokens.GREMLINX_TYPE_NAMESPACE + ":ZoneOffset') to the type specified in parameter to the object mapper (class java.time.Instant). Those types are incompatible."));
+ }
+ }
+
+ @Test
+ public void shouldHandleRawPOJOs() throws Exception {
+ final FunObject funObject = new FunObject();
+ funObject.setVal("test");
+ assertEquals(funObject.toString(), serializeDeserialize(mapper, funObject, FunObject.class).toString());
+ assertEquals(funObject.getClass(), serializeDeserialize(mapper, funObject, FunObject.class).getClass());
+ }
+
+ @Test
+ public void shouldHandleMapWithTypesUsingEmbedTypeSettingV2d0() throws Exception {
+ final ObjectMapper mapper = GraphSONMapper.build()
+ .version(GraphSONVersion.V2_0)
+ .typeInfo(TypeInfo.PARTIAL_TYPES)
+ .create()
+ .createMapper();
+
+ final Map<String,Object> m = new HashMap<>();
+ m.put("test", 100L);
+
+ final String json = mapper.writeValueAsString(m);
+ final Map read = mapper.readValue(json, HashMap.class);
+
+ assertEquals(100L, read.get("test"));
+ }
+
+ @Test
+ public void shouldNotHandleMapWithTypesUsingEmbedTypeSettingV2d0() throws Exception {
+ final ObjectMapper mapper = GraphSONMapper.build()
+ .version(GraphSONVersion.V2_0)
+ .typeInfo(TypeInfo.NO_TYPES)
+ .create()
+ .createMapper();
+
+ final Map<String,Object> m = new HashMap<>();
+ m.put("test", 100L);
+
+ final String json = mapper.writeValueAsString(m);
+ final Map read = mapper.readValue(json, HashMap.class);
+
+ assertEquals(100, read.get("test"));
+ }
+
+ @Test
+ public void shouldHandleMapWithTypesUsingEmbedTypeSettingV1d0() throws Exception {
+ final ObjectMapper mapper = GraphSONMapper.build()
+ .version(GraphSONVersion.V1_0)
+ .typeInfo(TypeInfo.PARTIAL_TYPES)
+ .create()
+ .createMapper();
+
+ final Map<String,Object> m = new HashMap<>();
+ m.put("test", 100L);
+
+ final String json = mapper.writeValueAsString(m);
+ final Map read = mapper.readValue(json, HashMap.class);
+
+ assertEquals(100L, read.get("test"));
+ }
+
+ @Test
+ public void shouldNotHandleMapWithTypesUsingEmbedTypeSettingV1d0() throws Exception {
+ final ObjectMapper mapper = GraphSONMapper.build()
+ .version(GraphSONVersion.V1_0)
+ .typeInfo(TypeInfo.NO_TYPES)
+ .create()
+ .createMapper();
+
+ final Map<String,Object> m = new HashMap<>();
+ m.put("test", 100L);
+
+ final String json = mapper.writeValueAsString(m);
+ final Map read = mapper.readValue(json, HashMap.class);
+
+ assertEquals(100, read.get("test"));
+ }
+
+ @Test
+ public void shouldLooseTypesInfoWithGraphSONNoType() throws Exception {
+ final ObjectMapper mapper = GraphSONMapper.build()
+ .version(GraphSONVersion.V2_0)
+ .typeInfo(TypeInfo.NO_TYPES)
+ .create()
+ .createMapper();
+
+ final UUID uuid = UUID.randomUUID();
+ final List<Object> myList = new ArrayList<>();
+
+ final List<Object> myList2 = new ArrayList<>();
+ myList2.add(UUID.randomUUID());
+ myList2.add(33L);
+ myList2.add(84);
+ final Map<String,Object> map2 = new HashMap<>();
+ map2.put("eheh", UUID.randomUUID());
+ map2.put("normal", "normal");
+ myList2.add(map2);
+
+ final Map<String, Object> map1 = new HashMap<>();
+ map1.put("hello", "world");
+ map1.put("test", uuid);
+ map1.put("hehe", myList2);
+ myList.add(map1);
+
+ myList.add("kjkj");
+ myList.add(UUID.randomUUID());
+
+ final String json = mapper.writeValueAsString(myList);
+ final Object read = mapper.readValue(json, Object.class);
+
+ // Not equals because of type loss
+ assertNotEquals(myList, read);
+ }
+
+ @Test
+ public void shouldHandleDefaultRemoteTraverser() throws Exception {
+ final DefaultRemoteTraverser<String> o = new DefaultRemoteTraverser<>("test", 100);
+ assertEquals(o, serializeDeserialize(mapper, o, Traverser.class));
+ }
+
+ // Class needs to be defined as statics as it's a nested class.
+ public static class FunObject {
+ private String val;
+
+ public FunObject() {
+ }
+
+ public String getVal() {
+ return this.val;
+ }
+
+ public void setVal(String s) {
+ this.val = s;
+ }
+
+ public String toString() {
+ return this.val;
+ }
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperTest.java
index 96bd9d6..e76b32e 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperTest.java
@@ -48,6 +48,9 @@ import static org.junit.Assert.assertEquals;
@RunWith(Parameterized.class)
public class GraphSONMapperTest {
+ /**
+ * No need to test V3 as it does not have an option to be constructed without types
+ */
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> data() {
return Arrays.asList(new Object[][]{
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperV2d0PartialEmbeddedTypeTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperV2d0PartialEmbeddedTypeTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperV2d0PartialEmbeddedTypeTest.java
deleted file mode 100644
index 45bb2b1..0000000
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperV2d0PartialEmbeddedTypeTest.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.structure.io.graphson;
-
-import org.apache.tinkerpop.gremlin.process.remote.traversal.DefaultRemoteTraverser;
-import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
-import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper;
-import org.junit.Test;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.time.Instant;
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.StringContains.containsString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.fail;
-
-/**
- * Tests automatic typed serialization/deserialization for GraphSON 2.0.
- */
-public class GraphSONMapperV2d0PartialEmbeddedTypeTest extends AbstractGraphSONTest {
-
- private final ObjectMapper mapper = GraphSONMapper.build()
- .version(GraphSONVersion.V2_0)
- .addCustomModule(GraphSONXModuleV2d0.build().create(false))
- .typeInfo(TypeInfo.PARTIAL_TYPES)
- .create()
- .createMapper();
-
- @Test
- public void shouldSerializeDeserializeNestedCollectionsAndMapAndTypedValuesCorrectly() throws Exception {
- // Trying to fail the TypeDeserializer type detection
- final UUID uuid = UUID.randomUUID();
- final List<Object> myList = new ArrayList<>();
-
- final List<Object> myList2 = new ArrayList<>();
- myList2.add(UUID.randomUUID());
- myList2.add(33L);
- myList2.add(84);
- final Map<String,Object> map2 = new HashMap<>();
- map2.put("eheh", UUID.randomUUID());
- map2.put("normal", "normal");
- myList2.add(map2);
-
- final Map<String, Object> map1 = new HashMap<>();
- map1.put("hello", "world");
- map1.put("test", uuid);
- map1.put("hehe", myList2);
- myList.add(map1);
-
- myList.add("kjkj");
- myList.add(UUID.randomUUID());
- assertEquals(myList, serializeDeserializeAuto(mapper, myList));
-
- // no "@value" property
- String s = "{\""+GraphSONTokens.VALUETYPE+"\":\"" + GraphSONTokens.GREMLIN_TYPE_NAMESPACE + ":UUID\", \"test\":2}";
- Map<String,Object> map = new LinkedHashMap<>();
- map.put(GraphSONTokens.VALUETYPE, GraphSONTokens.GREMLIN_TYPE_NAMESPACE + ":UUID");
- map.put("test", 2);
- Object res = mapper.readValue(s, Object.class);
- assertEquals(map, res);
-
- // "@value" and "@type" property reversed
- s = "{\""+GraphSONTokens.VALUEPROP+"\":2, \"" + GraphSONTokens.VALUETYPE + "\":\"" + GraphSONTokens.GREMLIN_TYPE_NAMESPACE + ":Int64\"}";
- res = mapper.readValue(s, Object.class);
- assertEquals(res, 2L);
- assertEquals(res.getClass(), Long.class);
-
- // no "@type" property.
- s = "{\""+GraphSONTokens.VALUEPROP + "\":2, \"id\":2}";
- map = new LinkedHashMap<>();
- map.put(GraphSONTokens.VALUEPROP, 2);
- map.put("id", 2);
- res = mapper.readValue(s, Object.class);
- assertEquals(res, map);
- }
-
- @Test
- public void shouldFailIfMoreThanTwoPropertiesInATypePattern() {
- String s = "{\"" + GraphSONTokens.VALUEPROP + "\":2, \"" + GraphSONTokens.VALUETYPE + "\":\""+GraphSONTokens.GREMLIN_TYPE_NAMESPACE +":Int64\", \"hello\": \"world\"}";
- try {
- mapper.readValue(s, Object.class);
- fail("Should have failed deserializing because there's more than properties in the type.");
- } catch (IOException e) {
- assertThat(e.getMessage(), containsString("Detected the type pattern in the JSON payload but the map containing the types and values contains other fields. This is not allowed by the deserializer."));
- }
- s = "{\"" + GraphSONTokens.VALUETYPE + "\":\""+GraphSONTokens.GREMLIN_TYPE_NAMESPACE +":Int64\",\"" + GraphSONTokens.VALUEPROP + "\":2, \"hello\": \"world\"}";
- try {
- mapper.readValue(s, Object.class);
- fail("Should have failed deserializing because there's more than properties in the type.");
- } catch (IOException e) {
- assertThat(e.getMessage(), containsString("Detected the type pattern in the JSON payload but the map containing the types and values contains other fields. This is not allowed by the deserializer."));
- }
- }
-
- @Test
- public void shouldFailIfTypeSpecifiedIsNotSameTypeInPayload() {
- final ZoneOffset o = ZonedDateTime.now().getOffset();
- final ByteArrayOutputStream stream = new ByteArrayOutputStream();
- try {
- mapper.writeValue(stream, o);
- final InputStream inputStream = new ByteArrayInputStream(stream.toByteArray());
- // What has been serialized is a ZoneOffset with the type, but the user explicitly requires another type.
- mapper.readValue(inputStream, Instant.class);
- fail("Should have failed decoding the value");
- } catch (Exception e) {
- assertThat(e.getMessage(), containsString("Could not deserialize the JSON value as required. Nested exception: java.lang.InstantiationException: Cannot deserialize the value with the detected type contained in the JSON ('" + GraphSONTokens.GREMLINX_TYPE_NAMESPACE + ":ZoneOffset') to the type specified in parameter to the object mapper (class java.time.Instant). Those types are incompatible."));
- }
- }
-
- @Test
- public void shouldHandleRawPOJOs() throws Exception {
- final FunObject funObject = new FunObject();
- funObject.setVal("test");
- assertEquals(funObject.toString(), serializeDeserialize(mapper, funObject, FunObject.class).toString());
- assertEquals(funObject.getClass(), serializeDeserialize(mapper, funObject, FunObject.class).getClass());
- }
-
- @Test
- public void shouldHandleMapWithTypesUsingEmbedTypeSettingV2d0() throws Exception {
- final ObjectMapper mapper = GraphSONMapper.build()
- .version(GraphSONVersion.V2_0)
- .typeInfo(TypeInfo.PARTIAL_TYPES)
- .create()
- .createMapper();
-
- final Map<String,Object> m = new HashMap<>();
- m.put("test", 100L);
-
- final String json = mapper.writeValueAsString(m);
- final Map read = mapper.readValue(json, HashMap.class);
-
- assertEquals(100L, read.get("test"));
- }
-
- @Test
- public void shouldNotHandleMapWithTypesUsingEmbedTypeSettingV2d0() throws Exception {
- final ObjectMapper mapper = GraphSONMapper.build()
- .version(GraphSONVersion.V2_0)
- .typeInfo(TypeInfo.NO_TYPES)
- .create()
- .createMapper();
-
- final Map<String,Object> m = new HashMap<>();
- m.put("test", 100L);
-
- final String json = mapper.writeValueAsString(m);
- final Map read = mapper.readValue(json, HashMap.class);
-
- assertEquals(100, read.get("test"));
- }
-
- @Test
- public void shouldHandleMapWithTypesUsingEmbedTypeSettingV1d0() throws Exception {
- final ObjectMapper mapper = GraphSONMapper.build()
- .version(GraphSONVersion.V1_0)
- .typeInfo(TypeInfo.PARTIAL_TYPES)
- .create()
- .createMapper();
-
- final Map<String,Object> m = new HashMap<>();
- m.put("test", 100L);
-
- final String json = mapper.writeValueAsString(m);
- final Map read = mapper.readValue(json, HashMap.class);
-
- assertEquals(100L, read.get("test"));
- }
-
- @Test
- public void shouldNotHandleMapWithTypesUsingEmbedTypeSettingV1d0() throws Exception {
- final ObjectMapper mapper = GraphSONMapper.build()
- .version(GraphSONVersion.V1_0)
- .typeInfo(TypeInfo.NO_TYPES)
- .create()
- .createMapper();
-
- final Map<String,Object> m = new HashMap<>();
- m.put("test", 100L);
-
- final String json = mapper.writeValueAsString(m);
- final Map read = mapper.readValue(json, HashMap.class);
-
- assertEquals(100, read.get("test"));
- }
-
- @Test
- public void shouldLooseTypesInfoWithGraphSONNoType() throws Exception {
- final ObjectMapper mapper = GraphSONMapper.build()
- .version(GraphSONVersion.V2_0)
- .typeInfo(TypeInfo.NO_TYPES)
- .create()
- .createMapper();
-
- final UUID uuid = UUID.randomUUID();
- final List<Object> myList = new ArrayList<>();
-
- final List<Object> myList2 = new ArrayList<>();
- myList2.add(UUID.randomUUID());
- myList2.add(33L);
- myList2.add(84);
- final Map<String,Object> map2 = new HashMap<>();
- map2.put("eheh", UUID.randomUUID());
- map2.put("normal", "normal");
- myList2.add(map2);
-
- final Map<String, Object> map1 = new HashMap<>();
- map1.put("hello", "world");
- map1.put("test", uuid);
- map1.put("hehe", myList2);
- myList.add(map1);
-
- myList.add("kjkj");
- myList.add(UUID.randomUUID());
-
- final String json = mapper.writeValueAsString(myList);
- final Object read = mapper.readValue(json, Object.class);
-
- // Not equals because of type loss
- assertNotEquals(myList, read);
- }
-
- @Test
- public void shouldHandleDefaultRemoteTraverser() throws Exception {
- final DefaultRemoteTraverser<String> o = new DefaultRemoteTraverser<>("test", 100);
- assertEquals(o, serializeDeserialize(mapper, o, Traverser.class));
- }
-
- // Class needs to be defined as statics as it's a nested class.
- public static class FunObject {
- private String val;
-
- public FunObject() {
- }
-
- public String getVal() {
- return this.val;
- }
-
- public void setVal(String s) {
- this.val = s;
- }
-
- public String toString() {
- return this.val;
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerV3d0Test.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerV3d0Test.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerV3d0Test.java
index c1e43b5..b4f49d7 100644
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerV3d0Test.java
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerV3d0Test.java
@@ -34,7 +34,6 @@ import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
-import org.apache.tinkerpop.shaded.jackson.databind.util.StdDateFormat;
import org.junit.Test;
import java.util.ArrayList;
@@ -132,15 +131,15 @@ public class GraphSONMessageSerializerV3d0Test {
final ResponseMessage response = convert(IteratorUtils.asList(map.entrySet()));
assertCommon(response);
- final List<Map<String, Object>> deserializedEntries = (List<Map<String, Object>>) response.getResult().getData();
+ final List<Map.Entry<Object, Object>> deserializedEntries = (List<Map.Entry<Object, Object>>) response.getResult().getData();
assertEquals(3, deserializedEntries.size());
deserializedEntries.forEach(e -> {
- if (e.containsKey("x"))
- assertEquals(1, e.get("x"));
- else if (e.containsKey(v1.id().toString()))
- assertEquals(100, e.get(v1.id().toString()));
- else if (e.containsKey(StdDateFormat.instance.format(d)))
- assertEquals("test", e.get(StdDateFormat.instance.format(d)));
+ if (e.getKey().equals("x"))
+ assertEquals(1, e.getValue());
+ else if (e.getKey() instanceof Vertex && e.getKey().equals(v1))
+ assertEquals(100, e.getValue());
+ else if (e.getKey() instanceof Date)
+ assertEquals("test", e.getValue());
else
fail("Map entries contains a key that is not part of what was serialized");
});
@@ -246,17 +245,15 @@ public class GraphSONMessageSerializerV3d0Test {
final TinkerGraph graph = TinkerFactory.createClassic();
final GraphTraversalSource g = graph.traversal();
final Map<Vertex, Integer> map = new HashMap<>();
- map.put(g.V().has("name", "marko").next(), 1000);
+ final Vertex v1 = g.V().has("name", "marko").next();
+ map.put(v1, 1000);
final ResponseMessage response = convert(map);
assertCommon(response);
- final Map<String, Integer> deserializedMap = (Map<String, Integer>) response.getResult().getData();
+ final Map<Vertex, Integer> deserializedMap = (Map<Vertex, Integer>) response.getResult().getData();
assertEquals(1, deserializedMap.size());
-
- // with no embedded types the key (which is a vertex) simply serializes out to an id
- // {"result":{"1":1000},"code":200,"requestId":"2d62161b-9544-4f39-af44-62ec49f9a595","type":0}
- assertEquals(new Integer(1000), deserializedMap.get("1"));
+ assertEquals(new Integer(1000), deserializedMap.get(v1));
}
@Test
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonGraphSONJavaTranslator.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonGraphSONJavaTranslator.java b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonGraphSONJavaTranslator.java
index df3bb9d..9f6dfbd 100644
--- a/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonGraphSONJavaTranslator.java
+++ b/gremlin-python/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/PythonGraphSONJavaTranslator.java
@@ -31,6 +31,7 @@ import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONVersion;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONXModuleV2d0;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONXModuleV3d0;
import org.apache.tinkerpop.shaded.jackson.core.JsonFactory;
import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper;
@@ -53,10 +54,10 @@ final class PythonGraphSONJavaTranslator<S extends TraversalSource, T extends Tr
private final JavaTranslator<S, T> javaTranslator;
private final GraphSONReader reader = GraphSONReader.build().mapper(
GraphSONMapper.build().addCustomModule(GraphSONXModuleV2d0.build().create(false))
- .version(GraphSONVersion.V3_0).create()).create();
+ .version(GraphSONVersion.V2_0).create()).create();
private final GraphSONWriter writer = GraphSONWriter.build().mapper(
GraphSONMapper.build().addCustomModule(GraphSONXModuleV2d0.build().create(false))
- .version(GraphSONVersion.V3_0).create()).create();
+ .version(GraphSONVersion.V2_0).create()).create();
public PythonGraphSONJavaTranslator(final PythonTranslator pythonTranslator, final JavaTranslator<S, T> javaTranslator) {
this.pythonTranslator = pythonTranslator;
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
index f220c17..70e939e 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
@@ -800,6 +800,40 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
}
@Test
+ public void shouldWorkWithGraphSONV3Serialization() throws Exception {
+ final Cluster cluster = TestClientFactory.build().serializer(Serializers.GRAPHSON_V3D0).create();
+ final Client client = cluster.connect();
+
+ final List<Result> r = client.submit("TinkerFactory.createModern().traversal().V(1)").all().join();
+ assertEquals(1, r.size());
+
+ final Vertex v = r.get(0).get(DetachedVertex.class);
+ assertEquals(1, v.id());
+ assertEquals("person", v.label());
+
+ assertEquals(2, IteratorUtils.count(v.properties()));
+ assertEquals("marko", v.value("name"));
+ assertEquals(29, Integer.parseInt(v.value("age").toString()));
+
+ cluster.close();
+ }
+
+ @Test
+ public void shouldWorkWithGraphSONExtendedV3Serialization() throws Exception {
+ final Cluster cluster = TestClientFactory.build().serializer(Serializers.GRAPHSON_V3D0).create();
+ final Client client = cluster.connect();
+
+ final Instant now = Instant.now();
+ final List<Result> r = client.submit("java.time.Instant.ofEpochMilli(" + now.toEpochMilli() + ")").all().join();
+ assertEquals(1, r.size());
+
+ final Instant then = r.get(0).get(Instant.class);
+ assertEquals(now, then);
+
+ cluster.close();
+ }
+
+ @Test
@org.junit.Ignore("Can't seem to make this test pass consistently")
public void shouldHandleRequestSentThatNeverReturns() throws Exception {
final Cluster cluster = TestClientFactory.open();
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuditLogIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuditLogIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuditLogIntegrateTest.java
index 0eec35b..d3e830a 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuditLogIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuditLogIntegrateTest.java
@@ -23,6 +23,8 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
+import org.apache.log4j.Appender;
+import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.log4j.spi.LoggingEvent;
import static org.apache.log4j.Level.INFO;
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
index 820247e..c478753 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
@@ -731,7 +731,7 @@ public class GremlinServerHttpIntegrateTest extends AbstractGremlinServerIntegra
final String json = EntityUtils.toString(response.getEntity());
final JsonNode node = mapper.readTree(json);
assertEquals(true, node.get("result").get("data").get(0).isObject());
- assertEquals(1, node.get("result").get("data").get(0).get("y").get("@value").asInt());
+ assertEquals(1, node.get("result").get("data").get(0).get("@value").get(1).get("@value").asInt());
}
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
index ef0d4f0..13b763a 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
@@ -772,7 +772,7 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
@Test
public void shouldReceiveFailureOnBadGraphSONSerialization() throws Exception {
- final Cluster cluster = TestClientFactory.build().serializer(Serializers.GRAPHSON_V2D0).create();
+ final Cluster cluster = TestClientFactory.build().serializer(Serializers.GRAPHSON_V3D0).create();
final Client client = cluster.connect();
try {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoCustomTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoCustomTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoCustomTest.java
index 90934af..705874d 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoCustomTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoCustomTest.java
@@ -59,7 +59,8 @@ public class IoCustomTest extends AbstractGremlinTest {
final SimpleModule moduleV1d0 = new SimpleModule();
moduleV1d0.addSerializer(CustomId.class, new CustomId.CustomIdJacksonSerializerV1d0());
- final SimpleModule moduleV2d0 = new CustomId.CustomIdTinkerPopJacksonModule();
+ final SimpleModule moduleV2d0 = new CustomId.CustomIdTinkerPopJacksonModuleV2d0();
+ final SimpleModule modulev3d0 = new CustomId.CustomIdTinkerPopJacksonModuleV3d0();
return Arrays.asList(new Object[][]{
{"graphson-v1-embedded", true,
@@ -69,8 +70,8 @@ public class IoCustomTest extends AbstractGremlinTest {
(Function<Graph, GraphReader>) g -> g.io(IoCore.graphson()).reader().mapper(g.io(GraphSONIo.build(GraphSONVersion.V2_0)).mapper().addCustomModule(moduleV2d0).typeInfo(TypeInfo.PARTIAL_TYPES).create()).create(),
(Function<Graph, GraphWriter>) g -> g.io(IoCore.graphson()).writer().mapper(g.io(GraphSONIo.build(GraphSONVersion.V2_0)).mapper().addCustomModule(moduleV2d0).typeInfo(TypeInfo.PARTIAL_TYPES).create()).create()},
{"graphson-v3", true,
- (Function<Graph, GraphReader>) g -> g.io(IoCore.graphson()).reader().mapper(g.io(GraphSONIo.build(GraphSONVersion.V3_0)).mapper().addCustomModule(moduleV2d0).create()).create(),
- (Function<Graph, GraphWriter>) g -> g.io(IoCore.graphson()).writer().mapper(g.io(GraphSONIo.build(GraphSONVersion.V3_0)).mapper().addCustomModule(moduleV2d0).create()).create()},
+ (Function<Graph, GraphReader>) g -> g.io(IoCore.graphson()).reader().mapper(g.io(GraphSONIo.build(GraphSONVersion.V3_0)).mapper().addCustomModule(moduleV3d0).create()).create(),
+ (Function<Graph, GraphWriter>) g -> g.io(IoCore.graphson()).writer().mapper(g.io(GraphSONIo.build(GraphSONVersion.V3_0)).mapper().addCustomModule(moduleV3d0).create()).create()},
{"gryo-v1", true,
(Function<Graph, GraphReader>) g -> g.io(IoCore.gryo()).reader().mapper(g.io(IoCore.gryo()).mapper().version(GryoVersion.V1_0).addCustom(CustomId.class).create()).create(),
(Function<Graph, GraphWriter>) g -> g.io(IoCore.gryo()).writer().mapper(g.io(IoCore.gryo()).mapper().version(GryoVersion.V1_0).addCustom(CustomId.class).create()).create()},
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/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 7434f1f..bc0bf0a 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
@@ -597,7 +597,7 @@ public class IoTest {
final UUID id = UUID.fromString("AF4B5965-B176-4552-B3C1-FBBE2F52C305");
graph.addVertex(T.id, new CustomId("vertex", id));
- final SimpleModule module = new CustomId.CustomIdTinkerPopJacksonModule();
+ final SimpleModule module = new CustomId.CustomIdTinkerPopJacksonModuleV2d0();
final GraphWriter writer = graph.io(graphson).writer().mapper(
graph.io(graphson).mapper().version(GraphSONVersion.V2_0).addCustomModule(module).create()).create();
@@ -720,7 +720,7 @@ public class IoTest {
final UUID id = UUID.fromString("AF4B5965-B176-4552-B3C1-FBBE2F52C305");
graph.addVertex(T.id, new CustomId("vertex", id));
- final SimpleModule module = new CustomId.CustomIdTinkerPopJacksonModule();
+ final SimpleModule module = new CustomId.CustomIdTinkerPopJacksonModuleV3d0();
final GraphWriter writer = graph.io(graphson).writer().mapper(
graph.io(graphson).mapper().version(GraphSONVersion.V3_0).addCustomModule(module).create()).create();
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/util/CustomId.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/util/CustomId.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/util/CustomId.java
index 2277247..d503ae8 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/util/CustomId.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/util/CustomId.java
@@ -23,9 +23,13 @@ import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONTokens;
import org.apache.tinkerpop.gremlin.structure.io.graphson.TinkerPopJacksonModule;
import org.apache.tinkerpop.shaded.jackson.core.JsonGenerationException;
import org.apache.tinkerpop.shaded.jackson.core.JsonGenerator;
+import org.apache.tinkerpop.shaded.jackson.core.JsonParser;
import org.apache.tinkerpop.shaded.jackson.core.JsonProcessingException;
+import org.apache.tinkerpop.shaded.jackson.databind.DeserializationContext;
import org.apache.tinkerpop.shaded.jackson.databind.SerializerProvider;
+import org.apache.tinkerpop.shaded.jackson.databind.deser.std.StdDeserializer;
import org.apache.tinkerpop.shaded.jackson.databind.jsontype.TypeSerializer;
+import org.apache.tinkerpop.shaded.jackson.databind.ser.std.StdScalarSerializer;
import org.apache.tinkerpop.shaded.jackson.databind.ser.std.StdSerializer;
import java.io.IOException;
@@ -136,14 +140,14 @@ public class CustomId {
}
}
- public static class CustomIdTinkerPopJacksonModule extends TinkerPopJacksonModule {
+ public static class CustomIdTinkerPopJacksonModuleV2d0 extends TinkerPopJacksonModule {
private static final Map<Class, String> TYPE_DEFINITIONS = Collections.unmodifiableMap(
new LinkedHashMap<Class, String>() {{
put(CustomId.class, "id");
}});
- public CustomIdTinkerPopJacksonModule() {
+ public CustomIdTinkerPopJacksonModuleV2d0() {
super("custom");
addSerializer(CustomId.class, new CustomIdJacksonSerializerV2d0());
addDeserializer(CustomId.class, new CustomIdJacksonDeserializerV2d0());
@@ -159,4 +163,60 @@ public class CustomId {
return "simple";
}
}
+
+ public static class CustomIdJacksonSerializerV3d0 extends StdScalarSerializer<CustomId> {
+ public CustomIdJacksonSerializerV3d0() {
+ super(CustomId.class);
+ }
+
+ @Override
+ public void serialize(final CustomId customId, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider)
+ throws IOException, JsonGenerationException {
+ final Map<String, Object> m = new HashMap<>();
+ m.put("cluster", customId.getCluster());
+ m.put("elementId", customId.getElementId());
+ jsonGenerator.writeObject(m);
+ }
+ }
+
+ public static class CustomIdJacksonDeserializerV3d0 extends StdDeserializer<CustomId> {
+ public CustomIdJacksonDeserializerV3d0() {
+ super(CustomId.class);
+ }
+
+ @Override
+ public CustomId deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
+ final Map<String, Object> data = deserializationContext.readValue(jsonParser, Map.class);
+ return new CustomId((String) data.get("cluster"), (UUID) data.get("elementId"));
+ }
+
+ @Override
+ public boolean isCachable() {
+ return true;
+ }
+ }
+
+ public static class CustomIdTinkerPopJacksonModuleV3d0 extends TinkerPopJacksonModule {
+
+ private static final Map<Class, String> TYPE_DEFINITIONS = Collections.unmodifiableMap(
+ new LinkedHashMap<Class, String>() {{
+ put(CustomId.class, "id");
+ }});
+
+ public CustomIdTinkerPopJacksonModuleV3d0() {
+ super("custom");
+ addSerializer(CustomId.class, new CustomIdJacksonSerializerV3d0());
+ addDeserializer(CustomId.class, new CustomIdJacksonDeserializerV3d0());
+ }
+
+ @Override
+ public Map<Class, String> getTypeDefinitions() {
+ return TYPE_DEFINITIONS;
+ }
+
+ @Override
+ public String getTypeNamespace() {
+ return "simple";
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypedCompatibilityTest.java
----------------------------------------------------------------------
diff --git a/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypedCompatibilityTest.java b/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypedCompatibilityTest.java
index bf87d89..b2c63da 100644
--- a/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypedCompatibilityTest.java
+++ b/gremlin-tools/gremlin-io-test/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypedCompatibilityTest.java
@@ -21,6 +21,7 @@ package org.apache.tinkerpop.gremlin.structure.io.graphson;
import org.apache.tinkerpop.gremlin.structure.io.AbstractTypedCompatibilityTest;
import org.apache.tinkerpop.gremlin.structure.io.Compatibility;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV2d0;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV3d0;
import org.apache.tinkerpop.shaded.jackson.databind.ObjectMapper;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -41,9 +42,9 @@ public class GraphSONTypedCompatibilityTest extends AbstractTypedCompatibilityTe
version(GraphSONVersion.V2_0).create().createMapper();
private static ObjectMapper mapperV3 = GraphSONMapper.build().
- addRegistry(TinkerIoRegistryV2d0.instance()).
- addCustomModule(GraphSONXModuleV2d0.build().create(false)).
- addCustomModule(new org.apache.tinkerpop.gremlin.driver.ser.AbstractGraphSONMessageSerializerV2d0.GremlinServerModule()).
+ addRegistry(TinkerIoRegistryV3d0.instance()).
+ addCustomModule(GraphSONXModuleV3d0.build().create(false)).
+ addCustomModule(new org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0.GremlinServerModule()).
version(GraphSONVersion.V3_0).create().createMapper();
@Parameterized.Parameters(name = "expect({0})")
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/authenticationchallenge-v3d0.json
----------------------------------------------------------------------
diff --git a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/authenticationchallenge-v3d0.json b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/authenticationchallenge-v3d0.json
index 8c5b82c..d1734c6 100644
--- a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/authenticationchallenge-v3d0.json
+++ b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/authenticationchallenge-v3d0.json
@@ -3,10 +3,16 @@
"status" : {
"message" : "",
"code" : 407,
- "attributes" : { }
+ "attributes" : {
+ "@type" : "g:Map",
+ "@value" : [ ]
+ }
},
"result" : {
"data" : null,
- "meta" : { }
+ "meta" : {
+ "@type" : "g:Map",
+ "@value" : [ ]
+ }
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/authenticationresponse-v3d0.json
----------------------------------------------------------------------
diff --git a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/authenticationresponse-v3d0.json b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/authenticationresponse-v3d0.json
index 838e1fd..daceca2 100644
--- a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/authenticationresponse-v3d0.json
+++ b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/authenticationresponse-v3d0.json
@@ -3,7 +3,7 @@
"op" : "authentication",
"processor" : "",
"args" : {
- "saslMechanism" : "PLAIN",
- "sasl" : "AHN0ZXBocGhlbgBwYXNzd29yZA=="
+ "@type" : "g:Map",
+ "@value" : [ "saslMechanism", "PLAIN", "sasl", "AHN0ZXBocGhlbgBwYXNzd29yZA==" ]
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/metrics-v3d0.json
----------------------------------------------------------------------
diff --git a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/metrics-v3d0.json b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/metrics-v3d0.json
index 7b1e964..b4f86cd 100644
--- a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/metrics-v3d0.json
+++ b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/metrics-v3d0.json
@@ -1,54 +1,49 @@
{
"@type" : "g:Metrics",
"@value" : {
- "dur" : {
+ "@type" : "g:Map",
+ "@value" : [ "dur", {
"@type" : "g:Double",
"@value" : 100.0
- },
- "counts" : {
- "traverserCount" : {
+ }, "counts", {
+ "@type" : "g:Map",
+ "@value" : [ "traverserCount", {
"@type" : "g:Int64",
"@value" : 4
- },
- "elementCount" : {
+ }, "elementCount", {
"@type" : "g:Int64",
"@value" : 4
- }
- },
- "name" : "TinkerGraphStep(vertex,[~label.eq(person)])",
- "annotations" : {
- "percentDur" : {
+ } ]
+ }, "name", "TinkerGraphStep(vertex,[~label.eq(person)])", "annotations", {
+ "@type" : "g:Map",
+ "@value" : [ "percentDur", {
"@type" : "g:Double",
"@value" : 25.0
- }
- },
- "id" : "7.0.0()",
- "metrics" : [ {
+ } ]
+ }, "id", "7.0.0()", "metrics", [ {
"@type" : "g:Metrics",
"@value" : {
- "dur" : {
+ "@type" : "g:Map",
+ "@value" : [ "dur", {
"@type" : "g:Double",
"@value" : 100.0
- },
- "counts" : {
- "traverserCount" : {
+ }, "counts", {
+ "@type" : "g:Map",
+ "@value" : [ "traverserCount", {
"@type" : "g:Int64",
"@value" : 7
- },
- "elementCount" : {
+ }, "elementCount", {
"@type" : "g:Int64",
"@value" : 7
- }
- },
- "name" : "VertexStep(OUT,vertex)",
- "annotations" : {
- "percentDur" : {
+ } ]
+ }, "name", "VertexStep(OUT,vertex)", "annotations", {
+ "@type" : "g:Map",
+ "@value" : [ "percentDur", {
"@type" : "g:Double",
"@value" : 25.0
- }
- },
- "id" : "3.0.0()"
+ } ]
+ }, "id", "3.0.0()" ]
}
- } ]
+ } ] ]
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/path-v3d0.json
----------------------------------------------------------------------
diff --git a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/path-v3d0.json b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/path-v3d0.json
index 54ff76d..9ccaa00 100644
--- a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/path-v3d0.json
+++ b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/path-v3d0.json
@@ -9,97 +9,7 @@
"@type" : "g:Int32",
"@value" : 1
},
- "label" : "person",
- "properties" : {
- "name" : [ {
- "@type" : "g:VertexProperty",
- "@value" : {
- "id" : {
- "@type" : "g:Int64",
- "@value" : 0
- },
- "value" : "marko",
- "label" : "name"
- }
- } ],
- "location" : [ {
- "@type" : "g:VertexProperty",
- "@value" : {
- "id" : {
- "@type" : "g:Int64",
- "@value" : 6
- },
- "value" : "san diego",
- "label" : "location",
- "properties" : {
- "startTime" : {
- "@type" : "g:Int32",
- "@value" : 1997
- },
- "endTime" : {
- "@type" : "g:Int32",
- "@value" : 2001
- }
- }
- }
- }, {
- "@type" : "g:VertexProperty",
- "@value" : {
- "id" : {
- "@type" : "g:Int64",
- "@value" : 7
- },
- "value" : "santa cruz",
- "label" : "location",
- "properties" : {
- "startTime" : {
- "@type" : "g:Int32",
- "@value" : 2001
- },
- "endTime" : {
- "@type" : "g:Int32",
- "@value" : 2004
- }
- }
- }
- }, {
- "@type" : "g:VertexProperty",
- "@value" : {
- "id" : {
- "@type" : "g:Int64",
- "@value" : 8
- },
- "value" : "brussels",
- "label" : "location",
- "properties" : {
- "startTime" : {
- "@type" : "g:Int32",
- "@value" : 2004
- },
- "endTime" : {
- "@type" : "g:Int32",
- "@value" : 2005
- }
- }
- }
- }, {
- "@type" : "g:VertexProperty",
- "@value" : {
- "id" : {
- "@type" : "g:Int64",
- "@value" : 9
- },
- "value" : "santa fe",
- "label" : "location",
- "properties" : {
- "startTime" : {
- "@type" : "g:Int32",
- "@value" : 2005
- }
- }
- }
- } ]
- }
+ "label" : "person"
}
}, {
"@type" : "g:Vertex",
@@ -108,20 +18,7 @@
"@type" : "g:Int32",
"@value" : 10
},
- "label" : "software",
- "properties" : {
- "name" : [ {
- "@type" : "g:VertexProperty",
- "@value" : {
- "id" : {
- "@type" : "g:Int64",
- "@value" : 4
- },
- "value" : "gremlin",
- "label" : "name"
- }
- } ]
- }
+ "label" : "software"
}
}, {
"@type" : "g:Vertex",
@@ -130,20 +27,7 @@
"@type" : "g:Int32",
"@value" : 11
},
- "label" : "software",
- "properties" : {
- "name" : [ {
- "@type" : "g:VertexProperty",
- "@value" : {
- "id" : {
- "@type" : "g:Int64",
- "@value" : 5
- },
- "value" : "tinkergraph",
- "label" : "name"
- }
- } ]
- }
+ "label" : "software"
}
} ]
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessionclose-v3d0.json
----------------------------------------------------------------------
diff --git a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessionclose-v3d0.json b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessionclose-v3d0.json
index cc4386b..870c586 100644
--- a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessionclose-v3d0.json
+++ b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessionclose-v3d0.json
@@ -3,9 +3,10 @@
"op" : "close",
"processor" : "session",
"args" : {
- "session" : {
+ "@type" : "g:Map",
+ "@value" : [ "session", {
"@type" : "g:UUID",
"@value" : "41d2e28a-20a4-4ab0-b379-d810dede3786"
- }
+ } ]
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessioneval-v3d0.json
----------------------------------------------------------------------
diff --git a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessioneval-v3d0.json b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessioneval-v3d0.json
index 900e1ab..a62f70c 100644
--- a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessioneval-v3d0.json
+++ b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessioneval-v3d0.json
@@ -3,17 +3,16 @@
"op" : "eval",
"processor" : "session",
"args" : {
- "gremlin" : "g.V(x)",
- "language" : "gremlin-groovy",
- "session" : {
+ "@type" : "g:Map",
+ "@value" : [ "gremlin", "g.V(x)", "language", "gremlin-groovy", "session", {
"@type" : "g:UUID",
"@value" : "41d2e28a-20a4-4ab0-b379-d810dede3786"
- },
- "bindings" : {
- "x" : {
+ }, "bindings", {
+ "@type" : "g:Map",
+ "@value" : [ "x", {
"@type" : "g:Int32",
"@value" : 1
- }
- }
+ } ]
+ } ]
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessionevalaliased-v3d0.json
----------------------------------------------------------------------
diff --git a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessionevalaliased-v3d0.json b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessionevalaliased-v3d0.json
index 924bf77..240a6ef 100644
--- a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessionevalaliased-v3d0.json
+++ b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessionevalaliased-v3d0.json
@@ -3,20 +3,19 @@
"op" : "eval",
"processor" : "session",
"args" : {
- "gremlin" : "social.V(x)",
- "language" : "gremlin-groovy",
- "aliases" : {
- "g" : "social"
- },
- "session" : {
+ "@type" : "g:Map",
+ "@value" : [ "gremlin", "social.V(x)", "language", "gremlin-groovy", "aliases", {
+ "@type" : "g:Map",
+ "@value" : [ "g", "social" ]
+ }, "session", {
"@type" : "g:UUID",
"@value" : "41d2e28a-20a4-4ab0-b379-d810dede3786"
- },
- "bindings" : {
- "x" : {
+ }, "bindings", {
+ "@type" : "g:Map",
+ "@value" : [ "x", {
"@type" : "g:Int32",
"@value" : 1
- }
- }
+ } ]
+ } ]
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessionlesseval-v3d0.json
----------------------------------------------------------------------
diff --git a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessionlesseval-v3d0.json b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessionlesseval-v3d0.json
index 81e2f6c..dc8c8e6 100644
--- a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessionlesseval-v3d0.json
+++ b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessionlesseval-v3d0.json
@@ -3,13 +3,13 @@
"op" : "eval",
"processor" : "",
"args" : {
- "gremlin" : "g.V(x)",
- "language" : "gremlin-groovy",
- "bindings" : {
- "x" : {
+ "@type" : "g:Map",
+ "@value" : [ "gremlin", "g.V(x)", "language", "gremlin-groovy", "bindings", {
+ "@type" : "g:Map",
+ "@value" : [ "x", {
"@type" : "g:Int32",
"@value" : 1
- }
- }
+ } ]
+ } ]
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessionlessevalaliased-v3d0.json
----------------------------------------------------------------------
diff --git a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessionlessevalaliased-v3d0.json b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessionlessevalaliased-v3d0.json
index 0f6a54e..fc03a37 100644
--- a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessionlessevalaliased-v3d0.json
+++ b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/sessionlessevalaliased-v3d0.json
@@ -3,16 +3,16 @@
"op" : "eval",
"processor" : "",
"args" : {
- "gremlin" : "social.V(x)",
- "language" : "gremlin-groovy",
- "aliases" : {
- "g" : "social"
- },
- "bindings" : {
- "x" : {
+ "@type" : "g:Map",
+ "@value" : [ "gremlin", "social.V(x)", "language", "gremlin-groovy", "aliases", {
+ "@type" : "g:Map",
+ "@value" : [ "g", "social" ]
+ }, "bindings", {
+ "@type" : "g:Map",
+ "@value" : [ "x", {
"@type" : "g:Int32",
"@value" : 1
- }
- }
+ } ]
+ } ]
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/standardresult-v3d0.json
----------------------------------------------------------------------
diff --git a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/standardresult-v3d0.json b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/standardresult-v3d0.json
index 857c6db..0be6d51 100644
--- a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/standardresult-v3d0.json
+++ b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/standardresult-v3d0.json
@@ -3,7 +3,10 @@
"status" : {
"message" : "",
"code" : 200,
- "attributes" : { }
+ "attributes" : {
+ "@type" : "g:Map",
+ "@value" : [ ]
+ }
},
"result" : {
"data" : [ {
@@ -106,6 +109,9 @@
}
}
} ],
- "meta" : { }
+ "meta" : {
+ "@type" : "g:Map",
+ "@value" : [ ]
+ }
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/traversalmetrics-v3d0.json
----------------------------------------------------------------------
diff --git a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/traversalmetrics-v3d0.json b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/traversalmetrics-v3d0.json
index fdd18a4..8e7effd 100644
--- a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/traversalmetrics-v3d0.json
+++ b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/traversalmetrics-v3d0.json
@@ -1,114 +1,106 @@
{
"@type" : "g:TraversalMetrics",
"@value" : {
- "dur" : {
+ "@type" : "g:Map",
+ "@value" : [ "dur", {
"@type" : "g:Double",
"@value" : 0.004
- },
- "metrics" : [ {
+ }, "metrics", [ {
"@type" : "g:Metrics",
"@value" : {
- "dur" : {
+ "@type" : "g:Map",
+ "@value" : [ "dur", {
"@type" : "g:Double",
"@value" : 100.0
- },
- "counts" : {
- "traverserCount" : {
+ }, "counts", {
+ "@type" : "g:Map",
+ "@value" : [ "traverserCount", {
"@type" : "g:Int64",
"@value" : 4
- },
- "elementCount" : {
+ }, "elementCount", {
"@type" : "g:Int64",
"@value" : 4
- }
- },
- "name" : "TinkerGraphStep(vertex,[~label.eq(person)])",
- "annotations" : {
- "percentDur" : {
+ } ]
+ }, "name", "TinkerGraphStep(vertex,[~label.eq(person)])", "annotations", {
+ "@type" : "g:Map",
+ "@value" : [ "percentDur", {
"@type" : "g:Double",
"@value" : 25.0
- }
- },
- "id" : "7.0.0()"
+ } ]
+ }, "id", "7.0.0()" ]
}
}, {
"@type" : "g:Metrics",
"@value" : {
- "dur" : {
+ "@type" : "g:Map",
+ "@value" : [ "dur", {
"@type" : "g:Double",
"@value" : 100.0
- },
- "counts" : {
- "traverserCount" : {
+ }, "counts", {
+ "@type" : "g:Map",
+ "@value" : [ "traverserCount", {
"@type" : "g:Int64",
"@value" : 13
- },
- "elementCount" : {
+ }, "elementCount", {
"@type" : "g:Int64",
"@value" : 13
- }
- },
- "name" : "VertexStep(OUT,vertex)",
- "annotations" : {
- "percentDur" : {
+ } ]
+ }, "name", "VertexStep(OUT,vertex)", "annotations", {
+ "@type" : "g:Map",
+ "@value" : [ "percentDur", {
"@type" : "g:Double",
"@value" : 25.0
- }
- },
- "id" : "2.0.0()"
+ } ]
+ }, "id", "2.0.0()" ]
}
}, {
"@type" : "g:Metrics",
"@value" : {
- "dur" : {
+ "@type" : "g:Map",
+ "@value" : [ "dur", {
"@type" : "g:Double",
"@value" : 100.0
- },
- "counts" : {
- "traverserCount" : {
+ }, "counts", {
+ "@type" : "g:Map",
+ "@value" : [ "traverserCount", {
"@type" : "g:Int64",
"@value" : 7
- },
- "elementCount" : {
+ }, "elementCount", {
"@type" : "g:Int64",
"@value" : 7
- }
- },
- "name" : "VertexStep(OUT,vertex)",
- "annotations" : {
- "percentDur" : {
+ } ]
+ }, "name", "VertexStep(OUT,vertex)", "annotations", {
+ "@type" : "g:Map",
+ "@value" : [ "percentDur", {
"@type" : "g:Double",
"@value" : 25.0
- }
- },
- "id" : "3.0.0()"
+ } ]
+ }, "id", "3.0.0()" ]
}
}, {
"@type" : "g:Metrics",
"@value" : {
- "dur" : {
+ "@type" : "g:Map",
+ "@value" : [ "dur", {
"@type" : "g:Double",
"@value" : 100.0
- },
- "counts" : {
- "traverserCount" : {
+ }, "counts", {
+ "@type" : "g:Map",
+ "@value" : [ "traverserCount", {
"@type" : "g:Int64",
"@value" : 1
- },
- "elementCount" : {
+ }, "elementCount", {
"@type" : "g:Int64",
"@value" : 1
- }
- },
- "name" : "TreeStep",
- "annotations" : {
- "percentDur" : {
+ } ]
+ }, "name", "TreeStep", "annotations", {
+ "@type" : "g:Map",
+ "@value" : [ "percentDur", {
"@type" : "g:Double",
"@value" : 25.0
- }
- },
- "id" : "4.0.0()"
+ } ]
+ }, "id", "4.0.0()" ]
}
- } ]
+ } ] ]
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/tree-v3d0.json
----------------------------------------------------------------------
diff --git a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/tree-v3d0.json b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/tree-v3d0.json
index 74dcffc..77ba971 100644
--- a/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/tree-v3d0.json
+++ b/gremlin-tools/gremlin-io-test/src/test/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/_3_3_0/tree-v3d0.json
@@ -1,5 +1,5 @@
{
- "@type" : "g:Tree",
+ "@type" : "g:Map",
"@value" : [ {
"key" : {
"@type" : "g:Vertex",
@@ -102,7 +102,7 @@
}
},
"value" : {
- "@type" : "g:Tree",
+ "@type" : "g:Map",
"@value" : [ {
"key" : {
"@type" : "g:Vertex",
@@ -128,7 +128,7 @@
}
},
"value" : {
- "@type" : "g:Tree",
+ "@type" : "g:Map",
"@value" : [ {
"key" : {
"@type" : "g:Vertex",
@@ -154,7 +154,7 @@
}
},
"value" : {
- "@type" : "g:Tree",
+ "@type" : "g:Map",
"@value" : [ ]
}
} ]
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/60874a59/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV3d0.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV3d0.java b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV3d0.java
index 685a8cc..c2eebf9 100644
--- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV3d0.java
+++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV3d0.java
@@ -50,6 +50,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -194,7 +195,7 @@ public final class TinkerIoRegistryV3d0 extends AbstractIoRegistry {
final List<? extends Vertex> vertices;
jsonParser.nextToken();
- final Map<String, Object> graphData = deserializationContext.readValue(jsonParser, Map.class);
+ final Map<String, Object> graphData = deserializationContext.readValue(jsonParser, LinkedHashMap.class);
vertices = (List<DetachedVertex>) graphData.get(GraphSONTokens.VERTICES);
edges = (List<DetachedEdge>) graphData.get(GraphSONTokens.EDGES);