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/08/22 18:30:56 UTC
[19/19] tinkerpop git commit: Minor code cleanup.
Minor code cleanup.
Mostly finalizing variables where required. CTR
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/f929db03
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/f929db03
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/f929db03
Branch: refs/heads/master
Commit: f929db03a9294c59f792e9c1b89a244203294d5a
Parents: 4710690
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Aug 22 14:29:55 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Aug 22 14:29:55 2016 -0400
----------------------------------------------------------------------
.../traversal/util/DefaultTraversalMetrics.java | 11 +-
.../process/traversal/util/MutableMetrics.java | 10 +-
.../structure/io/graphson/GraphSONMapper.java | 31 +-
.../io/graphson/GraphSONSerializersV2d0.java | 47 +--
.../io/graphson/GraphSONTypeDeserializer.java | 42 ++-
.../io/graphson/GraphSONTypeIdResolver.java | 12 +-
.../graphson/GraphSONTypeResolverBuilder.java | 14 +-
.../io/graphson/GraphSONTypeSerializer.java | 37 +--
.../structure/io/graphson/GraphSONUtil.java | 10 +-
.../structure/io/graphson/JsonParserConcat.java | 6 +-
.../io/graphson/TinkerPopJacksonModule.java | 2 +-
.../io/graphson/ToStringGraphSONSerializer.java | 3 +-
...aphSONMapperV2d0PartialEmbeddedTypeTest.java | 26 +-
.../AbstractGraphSONMessageSerializerV2d0.java | 7 +-
...raphSONMessageSerializerGremlinTestV1d0.java | 14 +-
...raphSONMessageSerializerGremlinTestV2d0.java | 12 +-
.../structure/TinkerIoRegistryV2d0.java | 2 +-
.../TinkerGraphGraphSONSerializerV2d0Test.java | 286 ++++++++++---------
18 files changed, 290 insertions(+), 282 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f929db03/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversalMetrics.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversalMetrics.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversalMetrics.java
index 058386b..ce52ffc 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversalMetrics.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/DefaultTraversalMetrics.java
@@ -39,7 +39,9 @@ import java.util.concurrent.TimeUnit;
* @author Bob Briody (http://bobbriody.com)
*/
public final class DefaultTraversalMetrics implements TraversalMetrics, Serializable {
- // toString() specific headers
+ /**
+ * toString() specific headers
+ */
private static final String[] HEADERS = {"Step", "Count", "Traversers", "Time (ms)", "% Dur"};
private final Map<String, MutableMetrics> metrics = new HashMap<>();
@@ -54,9 +56,10 @@ public final class DefaultTraversalMetrics implements TraversalMetrics, Serializ
public DefaultTraversalMetrics() {
}
- // This is only a convenient constructor needed for GraphSON deserialization.
- // TODO: see if that's ok to add that.
- public DefaultTraversalMetrics(long totalStepDurationNs, List<MutableMetrics> metricsMap) {
+ /**
+ * This is only a convenient constructor needed for GraphSON deserialization.
+ */
+ public DefaultTraversalMetrics(final long totalStepDurationNs, final List<MutableMetrics> metricsMap) {
this.totalStepDuration = totalStepDurationNs;
this.computedMetrics = new LinkedHashMap<>(metrics.size());
metricsMap.forEach(m -> computedMetrics.put(m.getId(), m.getImmutableClone()));
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f929db03/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/MutableMetrics.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/MutableMetrics.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/MutableMetrics.java
index 3b0c886..19e2069 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/MutableMetrics.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/MutableMetrics.java
@@ -31,7 +31,7 @@ public class MutableMetrics extends ImmutableMetrics implements Cloneable {
// Note: if you add new members then you probably need to add them to the copy constructor;
- private long tempTime = -1l;
+ private long tempTime = -1L;
protected MutableMetrics() {
// necessary for gryo serialization
@@ -42,10 +42,10 @@ public class MutableMetrics extends ImmutableMetrics implements Cloneable {
this.name = name;
}
- // create a MutableMetrics from an Immutable one.
- // needed that for tests, don't know if it is worth keeping it public.
- // TODO: see if it's ok to add this
- public MutableMetrics(Metrics other) {
+ /**
+ * Create a {@code MutableMetrics} from an immutable one.
+ */
+ public MutableMetrics(final Metrics other) {
this.id = other.getId();
this.name = other.getName();
this.annotations.putAll(other.getAnnotations());
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f929db03/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapper.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapper.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapper.java
index 2a000a3..06fe51c 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapper.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapper.java
@@ -90,7 +90,7 @@ public class GraphSONMapper implements Mapper<ObjectMapper> {
final ObjectMapper om = new ObjectMapper();
om.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
- GraphSONModule graphSONModule = version.getBuilder().create(normalize);
+ final GraphSONModule graphSONModule = version.getBuilder().create(normalize);
om.registerModule(graphSONModule);
customModules.forEach(om::registerModule);
@@ -110,37 +110,33 @@ public class GraphSONMapper implements Mapper<ObjectMapper> {
}
} else if (version == GraphSONVersion.V2_0) {
if (typeInfo != TypeInfo.NO_TYPES) {
- GraphSONTypeIdResolver graphSONTypeIdResolver = new GraphSONTypeIdResolver();
+ final GraphSONTypeIdResolver graphSONTypeIdResolver = new GraphSONTypeIdResolver();
final TypeResolverBuilder typer = new GraphSONTypeResolverBuilder()
.typesEmbedding(getTypeInfo())
.valuePropertyName(GraphSONTokens.VALUEPROP)
.init(JsonTypeInfo.Id.CUSTOM, graphSONTypeIdResolver)
- .typeProperty(GraphSONTokens.VALUETYPE)
- ;
+ .typeProperty(GraphSONTokens.VALUETYPE);
// Registers native Java types that are supported by Jackson
registerJavaBaseTypes(graphSONTypeIdResolver);
// Registers the GraphSON Module's types
- graphSONModule.getTypeDefinitions()
- .forEach(
- (targetClass, typeId) -> graphSONTypeIdResolver.addCustomType(String.format("%s:%s", graphSONModule.getTypeNamespace(), typeId), targetClass)
- );
-
+ graphSONModule.getTypeDefinitions().forEach(
+ (targetClass, typeId) -> graphSONTypeIdResolver.addCustomType(
+ String.format("%s:%s", graphSONModule.getTypeNamespace(), typeId), targetClass));
// Register types to typeResolver for the Custom modules
customModules.forEach(e -> {
if (e instanceof TinkerPopJacksonModule) {
- TinkerPopJacksonModule mod = (TinkerPopJacksonModule) e;
- Map<Class, String> moduleTypeDefinitions = mod.getTypeDefinitions();
+ final TinkerPopJacksonModule mod = (TinkerPopJacksonModule) e;
+ final Map<Class, String> moduleTypeDefinitions = mod.getTypeDefinitions();
if (moduleTypeDefinitions != null) {
- if (mod.getTypeNamespace() == null || mod.getTypeNamespace().isEmpty()) {
+ if (mod.getTypeNamespace() == null || mod.getTypeNamespace().isEmpty())
throw new IllegalStateException("Cannot specify a module for GraphSON 2.0 with type definitions but without a type Domain. " +
"If no specific type domain is required, use Gremlin's default domain, \"gremlin\" but there may be collisions.");
- }
- moduleTypeDefinitions.forEach(
- (targetClass, typeId) -> graphSONTypeIdResolver.addCustomType(String.format("%s:%s", mod.getTypeNamespace(), typeId), targetClass)
- );
+
+ moduleTypeDefinitions.forEach((targetClass, typeId) -> graphSONTypeIdResolver.addCustomType(
+ String.format("%s:%s", mod.getTypeNamespace(), typeId), targetClass));
}
}
});
@@ -277,7 +273,8 @@ public class GraphSONMapper implements Mapper<ObjectMapper> {
* the value of {@link #embedTypes(boolean)} where {@link TypeInfo#PARTIAL_TYPES} will set it to true and
* {@link TypeInfo#NO_TYPES} will set it to false.
*
- * The level can be NO_TYPES or PARTIAL_TYPES, and could be extended in the future.
+ * The level can be {@link TypeInfo#NO_TYPES} or {@link TypeInfo#PARTIAL_TYPES}, and could be extended in the
+ * future.
*/
public Builder typeInfo(final TypeInfo typeInfo) {
this.typeInfo = typeInfo;
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f929db03/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONSerializersV2d0.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONSerializersV2d0.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONSerializersV2d0.java
index a689a11..f6a2f89 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONSerializersV2d0.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONSerializersV2d0.java
@@ -159,9 +159,7 @@ public class GraphSONSerializersV2d0 {
jsonGenerator.writeFieldName(GraphSONTokens.PROPERTIES);
jsonGenerator.writeStartObject();
- elementProperties.forEachRemaining(
- prop -> safeWriteObjectField(jsonGenerator, prop.key(), prop)
- );
+ elementProperties.forEachRemaining(prop -> safeWriteObjectField(jsonGenerator, prop.key(), prop));
jsonGenerator.writeEndObject();
}
}
@@ -271,7 +269,7 @@ public class GraphSONSerializersV2d0 {
@Override
public void serialize(final Tree tree, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider) throws IOException, JsonGenerationException {
jsonGenerator.writeStartArray();
- Set<Map.Entry<Element, Tree>> set = tree.entrySet();
+ final Set<Map.Entry<Element, Tree>> set = tree.entrySet();
for (Map.Entry<Element, Tree> entry : set) {
jsonGenerator.writeStartObject();
jsonGenerator.writeObjectField(GraphSONTokens.KEY, entry.getKey());
@@ -326,7 +324,8 @@ public class GraphSONSerializersV2d0 {
}
@Override
- public void serialize(Integer integer, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
+ public void serialize(final Integer integer, final JsonGenerator jsonGenerator,
+ final SerializerProvider serializerProvider) throws IOException {
jsonGenerator.writeNumber(((Integer) integer).intValue());
}
}
@@ -337,7 +336,8 @@ public class GraphSONSerializersV2d0 {
}
@Override
- public void serialize(Double doubleValue, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
+ public void serialize(final Double doubleValue, final JsonGenerator jsonGenerator,
+ final SerializerProvider serializerProvider) throws IOException {
jsonGenerator.writeNumber(doubleValue);
}
}
@@ -367,7 +367,8 @@ public class GraphSONSerializersV2d0 {
}
@Override
- public void serialize(Metrics metrics, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
+ public void serialize(final Metrics metrics, final JsonGenerator jsonGenerator,
+ final SerializerProvider serializerProvider) throws IOException {
final Map<String, Object> m = new HashMap<>();
m.put(GraphSONTokens.ID, metrics.getId());
m.put(GraphSONTokens.NAME, metrics.getName());
@@ -422,11 +423,11 @@ public class GraphSONSerializersV2d0 {
}
@Override
- public T deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
+ public T deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
jsonParser.nextToken();
// This will automatically parse all typed stuff.
- Map<String, Object> mapData = deserializationContext.readValue(jsonParser, Map.class);
+ final Map<String, Object> mapData = deserializationContext.readValue(jsonParser, Map.class);
return createObject(mapData);
}
@@ -442,7 +443,7 @@ public class GraphSONSerializersV2d0 {
}
@Override
- Vertex createObject(Map<String, Object> vertexData) {
+ Vertex createObject(final Map<String, Object> vertexData) {
return new DetachedVertex(
vertexData.get(GraphSONTokens.ID),
vertexData.get(GraphSONTokens.LABEL).toString(),
@@ -458,7 +459,7 @@ public class GraphSONSerializersV2d0 {
}
@Override
- Edge createObject(Map<String, Object> edgeData) {
+ Edge createObject(final Map<String, Object> edgeData) {
return new DetachedEdge(
edgeData.get(GraphSONTokens.ID),
edgeData.get(GraphSONTokens.LABEL).toString(),
@@ -476,7 +477,7 @@ public class GraphSONSerializersV2d0 {
}
@Override
- Property createObject(Map<String, Object> propData) {
+ Property createObject(final Map<String, Object> propData) {
return new DetachedProperty(
(String) propData.get(GraphSONTokens.KEY),
propData.get(GraphSONTokens.VALUE));
@@ -490,11 +491,11 @@ public class GraphSONSerializersV2d0 {
}
@Override
- Path createObject(Map<String, Object> pathData) {
- Path p = MutablePath.make();
+ Path createObject(final Map<String, Object> pathData) {
+ final Path p = MutablePath.make();
- List labels = (List) pathData.get(GraphSONTokens.LABELS);
- List objects = (List) pathData.get(GraphSONTokens.OBJECTS);
+ final List labels = (List) pathData.get(GraphSONTokens.LABELS);
+ final List objects = (List) pathData.get(GraphSONTokens.OBJECTS);
for (int i = 0; i < objects.size(); i++) {
p.extend(objects.get(i), new HashSet((List) labels.get(i)));
@@ -510,7 +511,7 @@ public class GraphSONSerializersV2d0 {
}
@Override
- VertexProperty createObject(Map<String, Object> propData) {
+ VertexProperty createObject(final Map<String, Object> propData) {
return new DetachedVertexProperty(
propData.get(GraphSONTokens.ID),
(String) propData.get(GraphSONTokens.LABEL),
@@ -526,8 +527,8 @@ public class GraphSONSerializersV2d0 {
}
@Override
- Metrics createObject(Map<String, Object> metricsData) {
- MutableMetrics m = new MutableMetrics((String)metricsData.get(GraphSONTokens.ID), (String)metricsData.get(GraphSONTokens.NAME));
+ Metrics createObject(final Map<String, Object> metricsData) {
+ final MutableMetrics m = new MutableMetrics((String)metricsData.get(GraphSONTokens.ID), (String)metricsData.get(GraphSONTokens.NAME));
m.setDuration(Math.round((Double) metricsData.get(GraphSONTokens.DURATION) * 1000000), TimeUnit.NANOSECONDS);
for (Map.Entry<String, Long> count : ((Map<String, Long>)metricsData.getOrDefault(GraphSONTokens.COUNTS, new HashMap<>(0))).entrySet()) {
@@ -550,7 +551,7 @@ public class GraphSONSerializersV2d0 {
}
@Override
- TraversalMetrics createObject(Map<String, Object> traversalMetricsData) {
+ TraversalMetrics createObject(final Map<String, Object> traversalMetricsData) {
return new DefaultTraversalMetrics(
Math.round((Double) traversalMetricsData.get(GraphSONTokens.DURATION) * 1000000),
(List<MutableMetrics>) traversalMetricsData.get(GraphSONTokens.METRICS)
@@ -565,9 +566,9 @@ public class GraphSONSerializersV2d0 {
}
@Override
- public Tree deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
- List<Map> data = deserializationContext.readValue(jsonParser, List.class);
- Tree t = new Tree();
+ public Tree deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
+ final List<Map> data = deserializationContext.readValue(jsonParser, List.class);
+ final Tree t = new Tree();
for (Map<String, Object> entry : data) {
t.put(entry.get(GraphSONTokens.KEY), entry.get(GraphSONTokens.VALUE));
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f929db03/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypeDeserializer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypeDeserializer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypeDeserializer.java
index e614a7a..1950834 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypeDeserializer.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypeDeserializer.java
@@ -51,8 +51,8 @@ public class GraphSONTypeDeserializer extends TypeDeserializerBase {
private static final JavaType arrayJavaType = TypeFactory.defaultInstance().constructType(List.class);
- GraphSONTypeDeserializer(JavaType baseType, TypeIdResolver idRes, String typePropertyName,
- TypeInfo typeInfo, String valuePropertyName){
+ GraphSONTypeDeserializer(final JavaType baseType, final TypeIdResolver idRes, final String typePropertyName,
+ final TypeInfo typeInfo, final String valuePropertyName){
super(baseType, idRes, typePropertyName, false, null);
this.baseType = baseType;
this.idRes = idRes;
@@ -83,31 +83,31 @@ public class GraphSONTypeDeserializer extends TypeDeserializerBase {
}
@Override
- public Object deserializeTypedFromObject(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
+ public Object deserializeTypedFromObject(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException {
return deserialize(jsonParser, deserializationContext);
}
@Override
- public Object deserializeTypedFromArray(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
+ public Object deserializeTypedFromArray(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException {
return deserialize(jsonParser, deserializationContext);
}
@Override
- public Object deserializeTypedFromScalar(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
+ public Object deserializeTypedFromScalar(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException {
return deserialize(jsonParser, deserializationContext);
}
@Override
- public Object deserializeTypedFromAny(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
+ public Object deserializeTypedFromAny(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException {
return deserialize(jsonParser, deserializationContext);
}
/**
* Main logic for the deserialization.
*/
- private Object deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
- TokenBuffer buf = new TokenBuffer(jsonParser.getCodec(), false);
- TokenBuffer localCopy = new TokenBuffer(jsonParser.getCodec(), false);
+ private Object deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException {
+ final TokenBuffer buf = new TokenBuffer(jsonParser.getCodec(), false);
+ final TokenBuffer localCopy = new TokenBuffer(jsonParser.getCodec(), false);
// Detect type
try {
@@ -148,7 +148,7 @@ public class GraphSONTypeDeserializer extends TypeDeserializerBase {
if (typeName != null && valueCalled) {
// Type pattern detected.
- JavaType typeFromId = idRes.typeFromId(typeName);
+ final JavaType typeFromId = idRes.typeFromId(typeName);
if (!baseType.isJavaLangObject() && baseType != typeFromId) {
throw new InstantiationException(
@@ -158,13 +158,13 @@ public class GraphSONTypeDeserializer extends TypeDeserializerBase {
);
}
- JsonDeserializer jsonDeserializer = deserializationContext.findContextualValueDeserializer(typeFromId, null);
+ final JsonDeserializer jsonDeserializer = deserializationContext.findContextualValueDeserializer(typeFromId, null);
- JsonParser tokenParser = localCopy.asParser();
+ final JsonParser tokenParser = localCopy.asParser();
tokenParser.nextToken();
- Object value = jsonDeserializer.deserialize(tokenParser, deserializationContext);
+ final Object value = jsonDeserializer.deserialize(tokenParser, deserializationContext);
- JsonToken t = jsonParser.nextToken();
+ final JsonToken t = jsonParser.nextToken();
if (t == JsonToken.END_OBJECT) {
// we're good to go
return value;
@@ -191,19 +191,17 @@ public class GraphSONTypeDeserializer extends TypeDeserializerBase {
// Concatenate buf + localCopy + end of original content
- JsonParser toUseParser;
- JsonParser bufferParser = buf.asParser();
- JsonParser localCopyParser = localCopy.asParser();
+ final JsonParser bufferParser = buf.asParser();
+ final JsonParser localCopyParser = localCopy.asParser();
+ final JsonParser[] array = {bufferParser, localCopyParser, jsonParser};
- JsonParser[] array = {bufferParser, localCopyParser, jsonParser};
-
- toUseParser = new JsonParserConcat(array);
+ final JsonParser toUseParser = new JsonParserConcat(array);
toUseParser.nextToken();
// If a type has been specified in parameter :
if (!baseType.isJavaLangObject()) {
- JsonDeserializer jsonDeserializer = deserializationContext.findContextualValueDeserializer(baseType, null);
+ final JsonDeserializer jsonDeserializer = deserializationContext.findContextualValueDeserializer(baseType, null);
return jsonDeserializer.deserialize(toUseParser, deserializationContext);
}
// Otherwise, detect the current structure :
@@ -217,7 +215,7 @@ public class GraphSONTypeDeserializer extends TypeDeserializerBase {
// then consider it a simple type, even though we shouldn't be here if it was a simple type.
// TODO : maybe throw an error instead?
// throw deserializationContext.mappingException("Roger, we have a problem deserializing");
- JsonDeserializer jsonDeserializer = deserializationContext.findContextualValueDeserializer(baseType, null);
+ final JsonDeserializer jsonDeserializer = deserializationContext.findContextualValueDeserializer(baseType, null);
return jsonDeserializer.deserialize(toUseParser, deserializationContext);
}
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f929db03/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypeIdResolver.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypeIdResolver.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypeIdResolver.java
index 3edff73..5ad7265 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypeIdResolver.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypeIdResolver.java
@@ -48,7 +48,7 @@ public class GraphSONTypeIdResolver implements TypeIdResolver {
}
// Override manually a type definition.
- public GraphSONTypeIdResolver addCustomType(String name, Class clasz) {
+ public GraphSONTypeIdResolver addCustomType(final String name, final Class clasz) {
// May override types already registered, that's wanted.
getIdToType().put(name, TypeFactory.defaultInstance().constructType(clasz));
getTypeToId().put(clasz, name);
@@ -56,16 +56,16 @@ public class GraphSONTypeIdResolver implements TypeIdResolver {
}
@Override
- public void init(JavaType javaType) {
+ public void init(final JavaType javaType) {
}
@Override
- public String idFromValue(Object o) {
+ public String idFromValue(final Object o) {
return idFromValueAndType(o, o.getClass());
}
@Override
- public String idFromValueAndType(Object o, Class<?> aClass) {
+ public String idFromValueAndType(final Object o, final Class<?> aClass) {
if (!getTypeToId().containsKey(aClass)) {
// If one wants to serialize an object with a type, but hasn't registered
// a typeID for that class, fail.
@@ -82,12 +82,12 @@ public class GraphSONTypeIdResolver implements TypeIdResolver {
}
@Override
- public JavaType typeFromId(String s) {
+ public JavaType typeFromId(final String s) {
return typeFromId(null, s);
}
@Override
- public JavaType typeFromId(DatabindContext databindContext, String s) {
+ public JavaType typeFromId(final DatabindContext databindContext, final String s) {
// Get the type from the string from the stored Map. If not found, default to deserialize as a String.
return getIdToType().containsKey(s)
? getIdToType().get(s)
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f929db03/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypeResolverBuilder.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypeResolverBuilder.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypeResolverBuilder.java
index 001dd02..7d3d03c 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypeResolverBuilder.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypeResolverBuilder.java
@@ -41,24 +41,26 @@ public class GraphSONTypeResolverBuilder extends StdTypeResolverBuilder {
private String valuePropertyName;
@Override
- public TypeDeserializer buildTypeDeserializer(DeserializationConfig config, JavaType baseType, Collection<NamedType> subtypes) {
- TypeIdResolver idRes = this.idResolver(config, baseType, subtypes, false, true);
+ public TypeDeserializer buildTypeDeserializer(final DeserializationConfig config, final JavaType baseType,
+ final Collection<NamedType> subtypes) {
+ final TypeIdResolver idRes = this.idResolver(config, baseType, subtypes, false, true);
return new GraphSONTypeDeserializer(baseType, idRes, this.getTypeProperty(), typeInfo, valuePropertyName);
}
@Override
- public TypeSerializer buildTypeSerializer(SerializationConfig config, JavaType baseType, Collection<NamedType> subtypes) {
- TypeIdResolver idRes = this.idResolver(config, baseType, subtypes, true, false);
+ public TypeSerializer buildTypeSerializer(final SerializationConfig config, final JavaType baseType,
+ final Collection<NamedType> subtypes) {
+ final TypeIdResolver idRes = this.idResolver(config, baseType, subtypes, true, false);
return new GraphSONTypeSerializer(idRes, this.getTypeProperty(), typeInfo, valuePropertyName);
}
- public GraphSONTypeResolverBuilder valuePropertyName(String valuePropertyName) {
+ public GraphSONTypeResolverBuilder valuePropertyName(final String valuePropertyName) {
this.valuePropertyName = valuePropertyName;
return this;
}
- public GraphSONTypeResolverBuilder typesEmbedding(TypeInfo typeInfo) {
+ public GraphSONTypeResolverBuilder typesEmbedding(final TypeInfo typeInfo) {
this.typeInfo = typeInfo;
return this;
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f929db03/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypeSerializer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypeSerializer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypeSerializer.java
index 98cf16a..01e5a79 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypeSerializer.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONTypeSerializer.java
@@ -48,7 +48,8 @@ public class GraphSONTypeSerializer extends TypeSerializer {
private final TypeInfo typeInfo;
private final String valuePropertyName;
- GraphSONTypeSerializer(TypeIdResolver idRes, String propertyName, TypeInfo typeInfo, String valuePropertyName) {
+ GraphSONTypeSerializer(final TypeIdResolver idRes, final String propertyName, final TypeInfo typeInfo,
+ final String valuePropertyName) {
this.idRes = idRes;
this.propertyName = propertyName;
this.typeInfo = typeInfo;
@@ -56,7 +57,7 @@ public class GraphSONTypeSerializer extends TypeSerializer {
}
@Override
- public TypeSerializer forProperty(BeanProperty beanProperty) {
+ public TypeSerializer forProperty(final BeanProperty beanProperty) {
return this;
}
@@ -76,77 +77,77 @@ public class GraphSONTypeSerializer extends TypeSerializer {
}
@Override
- public void writeTypePrefixForScalar(Object o, JsonGenerator jsonGenerator) throws IOException {
+ public void writeTypePrefixForScalar(final Object o, final JsonGenerator jsonGenerator) throws IOException {
if (canWriteTypeId()) {
writeTypePrefix(jsonGenerator, getTypeIdResolver().idFromValueAndType(o, getClassFromObject(o)));
}
}
@Override
- public void writeTypePrefixForObject(Object o, JsonGenerator jsonGenerator) throws IOException {
+ public void writeTypePrefixForObject(final Object o, final JsonGenerator jsonGenerator) throws IOException {
jsonGenerator.writeStartObject();
// TODO: FULL_TYPES should be implemented here as : if (fullTypesModeEnabled()) writeTypePrefix(Map);
}
@Override
- public void writeTypePrefixForArray(Object o, JsonGenerator jsonGenerator) throws IOException {
+ public void writeTypePrefixForArray(final Object o, final JsonGenerator jsonGenerator) throws IOException {
jsonGenerator.writeStartArray();
// TODO: FULL_TYPES should be implemented here as : if (fullTypesModeEnabled()) writeTypePrefix(List);
}
@Override
- public void writeTypeSuffixForScalar(Object o, JsonGenerator jsonGenerator) throws IOException {
+ public void writeTypeSuffixForScalar(final Object o, final JsonGenerator jsonGenerator) throws IOException {
if (canWriteTypeId()) {
writeTypeSuffix(jsonGenerator);
}
}
@Override
- public void writeTypeSuffixForObject(Object o, JsonGenerator jsonGenerator) throws IOException {
+ public void writeTypeSuffixForObject(final Object o, final JsonGenerator jsonGenerator) throws IOException {
jsonGenerator.writeEndObject();
// TODO: FULL_TYPES should be implemented here as : if (fullTypesModeEnabled()) writeTypeSuffix(Map);
}
@Override
- public void writeTypeSuffixForArray(Object o, JsonGenerator jsonGenerator) throws IOException {
+ public void writeTypeSuffixForArray(final Object o, final JsonGenerator jsonGenerator) throws IOException {
jsonGenerator.writeEndArray();
// TODO: FULL_TYPES should be implemented here as : if (fullTypesModeEnabled()) writeTypeSuffix(List);
}
@Override
- public void writeCustomTypePrefixForScalar(Object o, JsonGenerator jsonGenerator, String s) throws IOException {
+ public void writeCustomTypePrefixForScalar(final Object o, final JsonGenerator jsonGenerator, final String s) throws IOException {
if (canWriteTypeId()) {
writeTypePrefix(jsonGenerator, s);
}
}
@Override
- public void writeCustomTypePrefixForObject(Object o, JsonGenerator jsonGenerator, String s) throws IOException {
+ public void writeCustomTypePrefixForObject(final Object o, final JsonGenerator jsonGenerator, final String s) throws IOException {
jsonGenerator.writeStartObject();
// TODO: FULL_TYPES should be implemented here as : if (fullTypesModeEnabled()) writeTypePrefix(s);
}
@Override
- public void writeCustomTypePrefixForArray(Object o, JsonGenerator jsonGenerator, String s) throws IOException {
+ public void writeCustomTypePrefixForArray(final Object o, final JsonGenerator jsonGenerator, final String s) throws IOException {
jsonGenerator.writeStartArray();
// TODO: FULL_TYPES should be implemented here as : if (fullTypesModeEnabled()) writeTypePrefix(s);
}
@Override
- public void writeCustomTypeSuffixForScalar(Object o, JsonGenerator jsonGenerator, String s) throws IOException {
+ public void writeCustomTypeSuffixForScalar(final Object o, final JsonGenerator jsonGenerator, final String s) throws IOException {
if (canWriteTypeId()) {
writeTypeSuffix(jsonGenerator);
}
}
@Override
- public void writeCustomTypeSuffixForObject(Object o, JsonGenerator jsonGenerator, String s) throws IOException {
+ public void writeCustomTypeSuffixForObject(final Object o, final JsonGenerator jsonGenerator, final String s) throws IOException {
jsonGenerator.writeEndObject();
// TODO: FULL_TYPES should be implemented here as : if (fullTypesModeEnabled()) writeTypeSuffix(s);
}
@Override
- public void writeCustomTypeSuffixForArray(Object o, JsonGenerator jsonGenerator, String s) throws IOException {
+ public void writeCustomTypeSuffixForArray(final Object o, final JsonGenerator jsonGenerator,final String s) throws IOException {
jsonGenerator.writeEndArray();
// TODO: FULL_TYPES should be implemented here as : if (fullTypesModeEnabled()) writeTypeSuffix(s);
}
@@ -156,13 +157,13 @@ public class GraphSONTypeSerializer extends TypeSerializer {
&& typeInfo == TypeInfo.PARTIAL_TYPES;
}
- private void writeTypePrefix(JsonGenerator jsonGenerator, String s) throws IOException {
+ private void writeTypePrefix(final JsonGenerator jsonGenerator, final String s) throws IOException {
jsonGenerator.writeStartObject();
jsonGenerator.writeStringField(this.getPropertyName(), s);
jsonGenerator.writeFieldName(this.valuePropertyName);
}
- private void writeTypeSuffix(JsonGenerator jsonGenerator) throws IOException {
+ private void writeTypeSuffix(final JsonGenerator jsonGenerator) throws IOException {
jsonGenerator.writeEndObject();
}
@@ -172,9 +173,9 @@ public class GraphSONTypeSerializer extends TypeSerializer {
**not** their implementations (TinkerGraph, DetachedVertex, TinkerEdge,
etc..)
*/
- private Class getClassFromObject(Object o) {
+ private Class getClassFromObject(final Object o) {
// not the most efficient
- Class c = o.getClass();
+ final Class c = o.getClass();
if (Vertex.class.isAssignableFrom(c)) {
return Vertex.class;
} else if (Edge.class.isAssignableFrom(c)) {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f929db03/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUtil.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUtil.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUtil.java
index 548bca1..9b90c78 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUtil.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONUtil.java
@@ -56,21 +56,21 @@ public final class GraphSONUtil {
}
}
- public static void writeStartObject(Object o, JsonGenerator jsonGenerator, TypeSerializer typeSerializer) throws IOException {
+ public static void writeStartObject(final Object o, final JsonGenerator jsonGenerator, final TypeSerializer typeSerializer) throws IOException {
if (typeSerializer != null)
typeSerializer.writeTypePrefixForObject(o, jsonGenerator);
else
jsonGenerator.writeStartObject();
}
- public static void writeEndObject(Object o, JsonGenerator jsonGenerator, TypeSerializer typeSerializer) throws IOException {
+ public static void writeEndObject(final Object o, final JsonGenerator jsonGenerator, final TypeSerializer typeSerializer) throws IOException {
if (typeSerializer != null)
typeSerializer.writeTypeSuffixForObject(o, jsonGenerator);
else
jsonGenerator.writeEndObject();
}
- public static void writeStartArray(Object o, JsonGenerator jsonGenerator, TypeSerializer typeSerializer) throws IOException {
+ public static void writeStartArray(final Object o, final JsonGenerator jsonGenerator, final TypeSerializer typeSerializer) throws IOException {
if (typeSerializer != null)
typeSerializer.writeTypePrefixForArray(o, jsonGenerator);
else
@@ -78,14 +78,14 @@ public final class GraphSONUtil {
}
- public static void writeEndArray(Object o, JsonGenerator jsonGenerator, TypeSerializer typeSerializer) throws IOException {
+ public static void writeEndArray(final Object o, final JsonGenerator jsonGenerator, final TypeSerializer typeSerializer) throws IOException {
if (typeSerializer != null)
typeSerializer.writeTypeSuffixForArray(o, jsonGenerator);
else
jsonGenerator.writeEndArray();
}
- static void safeWriteObjectField(JsonGenerator jsonGenerator, String key, Object value) {
+ static void safeWriteObjectField(final JsonGenerator jsonGenerator, final String key, final Object value) {
try {
jsonGenerator.writeObjectField(key, value);
} catch (IOException e) {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f929db03/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/JsonParserConcat.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/JsonParserConcat.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/JsonParserConcat.java
index 6b19e48..d285f73 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/JsonParserConcat.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/JsonParserConcat.java
@@ -37,15 +37,15 @@ import java.util.ArrayList;
* @author Kevin Gallardo (https://kgdo.me)
*/
public class JsonParserConcat extends JsonParserSequence {
- protected JsonParserConcat(JsonParser[] parsers) {
+ protected JsonParserConcat(final JsonParser[] parsers) {
super(parsers);
}
- public static JsonParserConcat createFlattened(JsonParser first, JsonParser second) {
+ public static JsonParserConcat createFlattened(final JsonParser first, final JsonParser second) {
if (!(first instanceof JsonParserConcat) && !(second instanceof JsonParserConcat)) {
return new JsonParserConcat(new JsonParser[]{first, second});
} else {
- ArrayList p = new ArrayList();
+ final ArrayList p = new ArrayList();
if (first instanceof JsonParserConcat) {
((JsonParserConcat) first).addFlattenedActiveParsers(p);
} else {
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f929db03/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TinkerPopJacksonModule.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TinkerPopJacksonModule.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TinkerPopJacksonModule.java
index 847027c..d15afcd 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TinkerPopJacksonModule.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TinkerPopJacksonModule.java
@@ -38,7 +38,7 @@ import java.util.Map;
*/
public abstract class TinkerPopJacksonModule extends SimpleModule {
- public TinkerPopJacksonModule(String name) {
+ public TinkerPopJacksonModule(final String name) {
super(name);
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f929db03/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/ToStringGraphSONSerializer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/ToStringGraphSONSerializer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/ToStringGraphSONSerializer.java
index fbd9e00..3f155fe 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/ToStringGraphSONSerializer.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/ToStringGraphSONSerializer.java
@@ -34,7 +34,8 @@ import java.io.IOException;
*/
public class ToStringGraphSONSerializer extends ToStringSerializer {
@Override
- public void serializeWithType(Object value, JsonGenerator gen, SerializerProvider provider, TypeSerializer typeSer) throws IOException {
+ public void serializeWithType(final Object value, final JsonGenerator gen, final SerializerProvider provider,
+ final TypeSerializer typeSer) throws IOException {
this.serialize(value, gen, provider);
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f929db03/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
index c2ad05e..e02588f 100644
--- 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
@@ -143,19 +143,19 @@ public class GraphSONMapperV2d0PartialEmbeddedTypeTest {
@Test
// Trying to fail the TypeDeserializer type detection
public void shouldSerializeDeserializeNestedCollectionsAndMapAndTypedValuesCorrectly() throws Exception {
- UUID uuid = UUID.randomUUID();
- List myList = new ArrayList<>();
+ final UUID uuid = UUID.randomUUID();
+ final List myList = new ArrayList<>();
- List myList2 = new ArrayList<>();
+ final List myList2 = new ArrayList<>();
myList2.add(UUID.randomUUID());
myList2.add(33L);
myList2.add(84);
- Map map2 = new HashMap<>();
+ final Map map2 = new HashMap<>();
map2.put("eheh", UUID.randomUUID());
map2.put("normal", "normal");
myList2.add(map2);
- Map<String, Object> map1 = new HashMap<>();
+ final Map<String, Object> map1 = new HashMap<>();
map1.put("hello", "world");
map1.put("test", uuid);
map1.put("hehe", myList2);
@@ -265,25 +265,25 @@ public class GraphSONMapperV2d0PartialEmbeddedTypeTest {
@Test
public void shouldLooseTypesInfoWithGraphSONNoType() throws Exception {
- ObjectMapper mapper = GraphSONMapper.build()
+ final ObjectMapper mapper = GraphSONMapper.build()
.version(GraphSONVersion.V2_0)
.typeInfo(TypeInfo.NO_TYPES)
.create()
.createMapper();
- UUID uuid = UUID.randomUUID();
- List myList = new ArrayList<>();
+ final UUID uuid = UUID.randomUUID();
+ final List myList = new ArrayList<>();
- List myList2 = new ArrayList<>();
+ final List myList2 = new ArrayList<>();
myList2.add(UUID.randomUUID());
myList2.add(33L);
myList2.add(84);
- Map map2 = new HashMap<>();
+ final Map map2 = new HashMap<>();
map2.put("eheh", UUID.randomUUID());
map2.put("normal", "normal");
myList2.add(map2);
- Map<String, Object> map1 = new HashMap<>();
+ final Map<String, Object> map1 = new HashMap<>();
map1.put("hello", "world");
map1.put("test", uuid);
map1.put("hehe", myList2);
@@ -292,8 +292,8 @@ public class GraphSONMapperV2d0PartialEmbeddedTypeTest {
myList.add("kjkj");
myList.add(UUID.randomUUID());
- String json = mapper.writeValueAsString(myList);
- Object read = mapper.readValue(json, Object.class);
+ final String json = mapper.writeValueAsString(myList);
+ final Object read = mapper.readValue(json, Object.class);
// Not equals because of type loss
assertNotEquals(myList, read);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f929db03/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGraphSONMessageSerializerV2d0.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGraphSONMessageSerializerV2d0.java b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGraphSONMessageSerializerV2d0.java
index d0303eb..d846a69 100644
--- a/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGraphSONMessageSerializerV2d0.java
+++ b/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/AbstractGraphSONMessageSerializerV2d0.java
@@ -228,12 +228,9 @@ public abstract class AbstractGraphSONMessageSerializerV2d0 extends AbstractMess
GraphSONUtil.writeStartObject(responseMessage, jsonGenerator, typeSerializer);
- if (null == responseMessage.getResult().getData())
- {
+ if (null == responseMessage.getResult().getData()){
jsonGenerator.writeNullField(SerTokens.TOKEN_DATA);
- }
- else
- {
+ } else {
jsonGenerator.writeFieldName(SerTokens.TOKEN_DATA);
Object result = responseMessage.getResult().getData();
serializerProvider.findTypedValueSerializer(result.getClass(), true, null).serialize(result, jsonGenerator, serializerProvider);
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f929db03/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerGremlinTestV1d0.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerGremlinTestV1d0.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerGremlinTestV1d0.java
index 95907f9..c18aca7 100644
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerGremlinTestV1d0.java
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerGremlinTestV1d0.java
@@ -269,22 +269,22 @@ public class GraphSONMessageSerializerGremlinTestV1d0 {
assertEquals(1, deserializedMap.size());
//check the first object and it's properties
- Map<String,Object> vertex = deserializedMap.get("1").get("key");
- Map<String,List<Map>> vertexProperties = (Map<String, List<Map>>)vertex.get("properties");
+ final Map<String,Object> vertex = deserializedMap.get("1").get("key");
+ final Map<String,List<Map>> vertexProperties = (Map<String, List<Map>>)vertex.get("properties");
assertEquals(1, (int)vertex.get("id"));
assertEquals("marko", vertexProperties.get("name").get(0).get("value"));
//check objects tree structure
//check Vertex property
- Map<String, Map<String, Map>> subTreeMap = deserializedMap.get("1").get("value");
- Map<String, Map<String, Map>> subTreeMap2 = subTreeMap.get("2").get("value");
- Map<String, String> vertexPropertiesDeep = subTreeMap2.get("3").get("key");
+ final Map<String, Map<String, Map>> subTreeMap = deserializedMap.get("1").get("value");
+ final Map<String, Map<String, Map>> subTreeMap2 = subTreeMap.get("2").get("value");
+ final Map<String, String> vertexPropertiesDeep = subTreeMap2.get("3").get("key");
assertEquals("vadas", vertexPropertiesDeep.get("value"));
assertEquals("name", vertexPropertiesDeep.get("label"));
// check subitem
- Map<String,Object> vertex2 = subTreeMap.get("3").get("key");
- Map<String,List<Map>> vertexProperties2 = (Map<String, List<Map>>)vertex2.get("properties");
+ final Map<String,Object> vertex2 = subTreeMap.get("3").get("key");
+ final Map<String,List<Map>> vertexProperties2 = (Map<String, List<Map>>)vertex2.get("properties");
assertEquals("lop", vertexProperties2.get("name").get(0).get("value"));
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f929db03/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerGremlinTestV2d0.java
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerGremlinTestV2d0.java b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerGremlinTestV2d0.java
index a7f8389..b85a45f 100644
--- a/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerGremlinTestV2d0.java
+++ b/gremlin-driver/src/test/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerGremlinTestV2d0.java
@@ -57,11 +57,11 @@ import static org.junit.Assert.fail;
*/
public class GraphSONMessageSerializerGremlinTestV2d0 {
- private UUID requestId = UUID.fromString("6457272A-4018-4538-B9AE-08DD5DDC0AA1");
- private ResponseMessage.Builder responseMessageBuilder = ResponseMessage.build(requestId);
- private static ByteBufAllocator allocator = UnpooledByteBufAllocator.DEFAULT;
+ private final UUID requestId = UUID.fromString("6457272A-4018-4538-B9AE-08DD5DDC0AA1");
+ private final ResponseMessage.Builder responseMessageBuilder = ResponseMessage.build(requestId);
+ private final static ByteBufAllocator allocator = UnpooledByteBufAllocator.DEFAULT;
- public MessageSerializer serializer = new GraphSONMessageSerializerGremlinV2d0();
+ public final MessageSerializer serializer = new GraphSONMessageSerializerGremlinV2d0();
@Test
public void shouldSerializeIterable() throws Exception {
@@ -272,11 +272,11 @@ public class GraphSONMessageSerializerGremlinTestV2d0 {
//check the first object and its key's properties
assertEquals(1, deserializedTree.size());
- Vertex v = ((Vertex) deserializedTree.keySet().iterator().next());
+ final Vertex v = ((Vertex) deserializedTree.keySet().iterator().next());
assertEquals(1, v.id());
assertEquals("marko", v.property("name").value());
- Tree firstTree = (Tree)deserializedTree.get(v);
+ final Tree firstTree = (Tree)deserializedTree.get(v);
assertEquals(3, firstTree.size());
Iterator<Vertex> vertexKeys = firstTree.keySet().iterator();
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f929db03/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV2d0.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV2d0.java b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV2d0.java
index 97c1cba..da9edb5 100644
--- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV2d0.java
+++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerIoRegistryV2d0.java
@@ -183,7 +183,7 @@ public final class TinkerIoRegistryV2d0 extends AbstractIoRegistry {
}
@Override
- public TinkerGraph deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
+ public TinkerGraph deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
final TinkerGraph graph = TinkerGraph.open();
final List<? extends Edge> edges;
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f929db03/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphGraphSONSerializerV2d0Test.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphGraphSONSerializerV2d0Test.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphGraphSONSerializerV2d0Test.java
index 907aaed..9005233 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphGraphSONSerializerV2d0Test.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphGraphSONSerializerV2d0Test.java
@@ -54,17 +54,18 @@ import java.util.UUID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
public class TinkerGraphGraphSONSerializerV2d0Test {
// As of TinkerPop 3.2.1 default for GraphSON 2.0 means types enabled.
- Mapper defaultMapperV2d0 = GraphSONMapper.build()
+ private final Mapper defaultMapperV2d0 = GraphSONMapper.build()
.version(GraphSONVersion.V2_0)
.addRegistry(TinkerIoRegistryV2d0.getInstance())
.create();
- Mapper noTypesMapperV2d0 = GraphSONMapper.build()
+ private final Mapper noTypesMapperV2d0 = GraphSONMapper.build()
.version(GraphSONVersion.V2_0)
.typeInfo(TypeInfo.NO_TYPES)
.addRegistry(TinkerIoRegistryV2d0.getInstance())
@@ -75,14 +76,14 @@ public class TinkerGraphGraphSONSerializerV2d0Test {
*/
@Test
public void shouldDeserializeGraphSONIntoTinkerGraphWithPartialTypes() throws IOException {
- GraphWriter writer = getWriter(defaultMapperV2d0);
- GraphReader reader = getReader(defaultMapperV2d0);
- TinkerGraph baseModern = TinkerFactory.createModern();
+ final GraphWriter writer = getWriter(defaultMapperV2d0);
+ final GraphReader reader = getReader(defaultMapperV2d0);
+ final TinkerGraph baseModern = TinkerFactory.createModern();
try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
writer.writeGraph(out, baseModern);
- String json = out.toString();
- TinkerGraph read = TinkerGraph.open();
+ final String json = out.toString();
+ final TinkerGraph read = TinkerGraph.open();
reader.readGraph(new ByteArrayInputStream(json.getBytes()), read);
IoTest.assertModernGraph(read, true, false);
}
@@ -93,14 +94,14 @@ public class TinkerGraphGraphSONSerializerV2d0Test {
*/
@Test
public void shouldDeserializeGraphSONIntoTinkerGraphWithoutTypes() throws IOException {
- GraphWriter writer = getWriter(noTypesMapperV2d0);
- GraphReader reader = getReader(noTypesMapperV2d0);
- TinkerGraph baseModern = TinkerFactory.createModern();
+ final GraphWriter writer = getWriter(noTypesMapperV2d0);
+ final GraphReader reader = getReader(noTypesMapperV2d0);
+ final TinkerGraph baseModern = TinkerFactory.createModern();
try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
writer.writeGraph(out, baseModern);
- String json = out.toString();
- TinkerGraph read = TinkerGraph.open();
+ final String json = out.toString();
+ final TinkerGraph read = TinkerGraph.open();
reader.readGraph(new ByteArrayInputStream(json.getBytes()), read);
IoTest.assertModernGraph(read, true, false);
}
@@ -111,20 +112,20 @@ public class TinkerGraphGraphSONSerializerV2d0Test {
*/
@Test
public void shouldDeserializeGraphSONIntoTinkerGraphKeepingTypes() throws IOException {
- GraphWriter writer = getWriter(defaultMapperV2d0);
- GraphReader reader = getReader(defaultMapperV2d0);
+ final GraphWriter writer = getWriter(defaultMapperV2d0);
+ final GraphReader reader = getReader(defaultMapperV2d0);
- Graph sampleGraph1 = TinkerFactory.createModern();
- Vertex v1 = sampleGraph1.addVertex(T.id, 100, "name", "kevin", "theUUID", UUID.randomUUID());
- Vertex v2 = sampleGraph1.addVertex(T.id, 101L, "name", "henri", "theUUID", UUID.randomUUID());
+ final Graph sampleGraph1 = TinkerFactory.createModern();
+ final Vertex v1 = sampleGraph1.addVertex(T.id, 100, "name", "kevin", "theUUID", UUID.randomUUID());
+ final Vertex v2 = sampleGraph1.addVertex(T.id, 101L, "name", "henri", "theUUID", UUID.randomUUID());
v1.addEdge("hello", v2, T.id, 101L,
"uuid", UUID.randomUUID());
try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
writer.writeObject(out, sampleGraph1);
- String json = out.toString();
+ final String json = out.toString();
- TinkerGraph read = reader.readObject(new ByteArrayInputStream(json.getBytes()), TinkerGraph.class);
+ final TinkerGraph read = reader.readObject(new ByteArrayInputStream(json.getBytes()), TinkerGraph.class);
assertTrue(approximateGraphsCheck(sampleGraph1, read));
}
}
@@ -134,14 +135,14 @@ public class TinkerGraphGraphSONSerializerV2d0Test {
*/
@Test
public void shouldLooseTypesWithGraphSONNoTypesForVertexIds() throws IOException {
- GraphWriter writer = getWriter(noTypesMapperV2d0);
- GraphReader reader = getReader(noTypesMapperV2d0);
- Graph sampleGraph1 = TinkerFactory.createModern();
+ final GraphWriter writer = getWriter(noTypesMapperV2d0);
+ final GraphReader reader = getReader(noTypesMapperV2d0);
+ final Graph sampleGraph1 = TinkerFactory.createModern();
sampleGraph1.addVertex(T.id, 100L, "name", "kevin");
try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
writer.writeGraph(out, sampleGraph1);
- String json = out.toString();
- TinkerGraph read = TinkerGraph.open();
+ final String json = out.toString();
+ final TinkerGraph read = TinkerGraph.open();
reader.readGraph(new ByteArrayInputStream(json.getBytes()), read);
// Should fail on deserialized vertex Id.
assertFalse(approximateGraphsCheck(sampleGraph1, read));
@@ -153,15 +154,15 @@ public class TinkerGraphGraphSONSerializerV2d0Test {
*/
@Test
public void shouldLooseTypesWithGraphSONNoTypesForVertexProps() throws IOException {
- GraphWriter writer = getWriter(noTypesMapperV2d0);
- GraphReader reader = getReader(noTypesMapperV2d0);
- Graph sampleGraph1 = TinkerFactory.createModern();
+ final GraphWriter writer = getWriter(noTypesMapperV2d0);
+ final GraphReader reader = getReader(noTypesMapperV2d0);
+ final Graph sampleGraph1 = TinkerFactory.createModern();
sampleGraph1.addVertex(T.id, 100, "name", "kevin", "uuid", UUID.randomUUID());
try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
writer.writeGraph(out, sampleGraph1);
- String json = out.toString();
- TinkerGraph read = TinkerGraph.open();
+ final String json = out.toString();
+ final TinkerGraph read = TinkerGraph.open();
reader.readGraph(new ByteArrayInputStream(json.getBytes()), read);
// Should fail on deserialized vertex prop.
assertFalse(approximateGraphsCheck(sampleGraph1, read));
@@ -173,15 +174,15 @@ public class TinkerGraphGraphSONSerializerV2d0Test {
*/
@Test
public void shouldLooseTypesWithGraphSONNoTypesForEdgeIds() throws IOException {
- GraphWriter writer = getWriter(noTypesMapperV2d0);
- GraphReader reader = getReader(noTypesMapperV2d0);
- Graph sampleGraph1 = TinkerFactory.createModern();
- Vertex v1 = sampleGraph1.addVertex(T.id, 100, "name", "kevin");
+ final GraphWriter writer = getWriter(noTypesMapperV2d0);
+ final GraphReader reader = getReader(noTypesMapperV2d0);
+ final Graph sampleGraph1 = TinkerFactory.createModern();
+ final Vertex v1 = sampleGraph1.addVertex(T.id, 100, "name", "kevin");
v1.addEdge("hello", sampleGraph1.traversal().V().has("name", "marko").next(), T.id, 101L);
try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
writer.writeGraph(out, sampleGraph1);
- String json = out.toString();
- TinkerGraph read = TinkerGraph.open();
+ final String json = out.toString();
+ final TinkerGraph read = TinkerGraph.open();
reader.readGraph(new ByteArrayInputStream(json.getBytes()), read);
// Should fail on deserialized edge Id.
assertFalse(approximateGraphsCheck(sampleGraph1, read));
@@ -193,17 +194,17 @@ public class TinkerGraphGraphSONSerializerV2d0Test {
*/
@Test
public void shouldLooseTypesWithGraphSONNoTypesForEdgeProps() throws IOException {
- GraphWriter writer = getWriter(noTypesMapperV2d0);
- GraphReader reader = getReader(noTypesMapperV2d0);
- Graph sampleGraph1 = TinkerFactory.createModern();
+ final GraphWriter writer = getWriter(noTypesMapperV2d0);
+ final GraphReader reader = getReader(noTypesMapperV2d0);
+ final Graph sampleGraph1 = TinkerFactory.createModern();
- Vertex v1 = sampleGraph1.addVertex(T.id, 100, "name", "kevin");
+ final Vertex v1 = sampleGraph1.addVertex(T.id, 100, "name", "kevin");
v1.addEdge("hello", sampleGraph1.traversal().V().has("name", "marko").next(), T.id, 101,
"uuid", UUID.randomUUID());
try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
writer.writeGraph(out, sampleGraph1);
- String json = out.toString();
- TinkerGraph read = TinkerGraph.open();
+ final String json = out.toString();
+ final TinkerGraph read = TinkerGraph.open();
reader.readGraph(new ByteArrayInputStream(json.getBytes()), read);
// Should fail on deserialized edge prop.
assertFalse(approximateGraphsCheck(sampleGraph1, read));
@@ -216,13 +217,13 @@ public class TinkerGraphGraphSONSerializerV2d0Test {
*/
@Test
public void shouldKeepTypesWhenDeserializingSerializedTinkerGraph() throws IOException {
- TinkerGraph tg = TinkerGraph.open();
+ final TinkerGraph tg = TinkerGraph.open();
- Vertex v = tg.addVertex("vertexTest");
- UUID uuidProp = UUID.randomUUID();
- Duration durationProp = Duration.ofHours(3);
- Long longProp = 2L;
- ByteBuffer byteBufferProp = ByteBuffer.wrap("testbb".getBytes());
+ final Vertex v = tg.addVertex("vertexTest");
+ final UUID uuidProp = UUID.randomUUID();
+ final Duration durationProp = Duration.ofHours(3);
+ final Long longProp = 2L;
+ final ByteBuffer byteBufferProp = ByteBuffer.wrap("testbb".getBytes());
// One Java util type natively supported by Jackson
v.property("uuid", uuidProp);
@@ -233,14 +234,14 @@ public class TinkerGraphGraphSONSerializerV2d0Test {
// One Java util type added by GraphSON
v.property("bytebuffer", byteBufferProp);
- GraphWriter writer = getWriter(defaultMapperV2d0);
- GraphReader reader = getReader(defaultMapperV2d0);
+ final GraphWriter writer = getWriter(defaultMapperV2d0);
+ final GraphReader reader = getReader(defaultMapperV2d0);
try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
writer.writeGraph(out, tg);
- String json = out.toString();
- TinkerGraph read = TinkerGraph.open();
+ final String json = out.toString();
+ final TinkerGraph read = TinkerGraph.open();
reader.readGraph(new ByteArrayInputStream(json.getBytes()), read);
- Vertex vRead = read.traversal().V().hasLabel("vertexTest").next();
+ final Vertex vRead = read.traversal().V().hasLabel("vertexTest").next();
assertEquals(vRead.property("uuid").value(), uuidProp);
assertEquals(vRead.property("duration").value(), durationProp);
assertEquals(vRead.property("long").value(), longProp);
@@ -251,233 +252,241 @@ public class TinkerGraphGraphSONSerializerV2d0Test {
@Test
public void deserializersTestsVertex() {
- TinkerGraph tg = TinkerGraph.open();
+ final TinkerGraph tg = TinkerGraph.open();
- Vertex v = tg.addVertex("vertexTest");
+ final Vertex v = tg.addVertex("vertexTest");
v.property("born", LocalDateTime.of(1971, 1, 2, 20, 50));
v.property("dead", LocalDateTime.of(1971, 1, 7, 20, 50));
- GraphWriter writer = getWriter(defaultMapperV2d0);
- GraphReader reader = getReader(defaultMapperV2d0);
+ final GraphWriter writer = getWriter(defaultMapperV2d0);
+ final GraphReader reader = getReader(defaultMapperV2d0);
try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
writer.writeObject(out, v);
- String json = out.toString();
+ final String json = out.toString();
// Object works, because there's a type in the payload now
// Vertex.class would work as well
// Anything else would not because we check the type in param here with what's in the JSON, for safety.
- Vertex vRead = (Vertex)reader.readObject(new ByteArrayInputStream(json.getBytes()), Object.class);
+ final Vertex vRead = (Vertex)reader.readObject(new ByteArrayInputStream(json.getBytes()), Object.class);
assertEquals(v, vRead);
} catch (IOException e) {
e.printStackTrace();
+ fail("Should not have thrown exception: " + e.getMessage());
}
}
@Test
public void deserializersTestsEdge() {
- TinkerGraph tg = TinkerGraph.open();
+ final TinkerGraph tg = TinkerGraph.open();
- Vertex v = tg.addVertex("vertexTest");
- Vertex v2 = tg.addVertex("vertexTest");
+ final Vertex v = tg.addVertex("vertexTest");
+ final Vertex v2 = tg.addVertex("vertexTest");
- Edge ed = v.addEdge("knows", v2, "time", LocalDateTime.now());
+ final Edge ed = v.addEdge("knows", v2, "time", LocalDateTime.now());
- GraphWriter writer = getWriter(defaultMapperV2d0);
- GraphReader reader = getReader(defaultMapperV2d0);
+ final GraphWriter writer = getWriter(defaultMapperV2d0);
+ final GraphReader reader = getReader(defaultMapperV2d0);
try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
writer.writeObject(out, ed);
- String json = out.toString();
+ final String json = out.toString();
// Object works, because there's a type in the payload now
// Edge.class would work as well
// Anything else would not because we check the type in param here with what's in the JSON, for safety.
- Edge eRead = (Edge)reader.readObject(new ByteArrayInputStream(json.getBytes()), Object.class);
+ final Edge eRead = (Edge)reader.readObject(new ByteArrayInputStream(json.getBytes()), Object.class);
assertEquals(ed, eRead);
} catch (IOException e) {
e.printStackTrace();
+ fail("Should not have thrown exception: " + e.getMessage());
}
}
@Test
public void deserializersTestsTinkerGraph() {
- TinkerGraph tg = TinkerGraph.open();
+ final TinkerGraph tg = TinkerGraph.open();
- Vertex v = tg.addVertex("vertexTest");
- Vertex v2 = tg.addVertex("vertexTest");
+ final Vertex v = tg.addVertex("vertexTest");
+ final Vertex v2 = tg.addVertex("vertexTest");
- Edge ed = v.addEdge("knows", v2);
+ v.addEdge("knows", v2);
- GraphWriter writer = getWriter(defaultMapperV2d0);
- GraphReader reader = getReader(defaultMapperV2d0);
+ final GraphWriter writer = getWriter(defaultMapperV2d0);
+ final GraphReader reader = getReader(defaultMapperV2d0);
try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
writer.writeObject(out, tg);
- String json = out.toString();
+ final String json = out.toString();
- Graph gRead = (Graph)reader.readObject(new ByteArrayInputStream(json.getBytes()), Object.class);
+ final Graph gRead = (Graph)reader.readObject(new ByteArrayInputStream(json.getBytes()), Object.class);
assertTrue(approximateGraphsCheck(tg, gRead));
} catch (IOException e) {
e.printStackTrace();
+ fail("Should not have thrown exception: " + e.getMessage());
}
}
@Test
public void deserializersTestsProperty() {
- TinkerGraph tg = TinkerGraph.open();
+ final TinkerGraph tg = TinkerGraph.open();
- Vertex v = tg.addVertex("vertexTest");
- Vertex v2 = tg.addVertex("vertexTest");
+ final Vertex v = tg.addVertex("vertexTest");
+ final Vertex v2 = tg.addVertex("vertexTest");
- Edge ed = v.addEdge("knows", v2);
+ final Edge ed = v.addEdge("knows", v2);
- GraphWriter writer = getWriter(defaultMapperV2d0);
- GraphReader reader = getReader(defaultMapperV2d0);
+ final GraphWriter writer = getWriter(defaultMapperV2d0);
+ final GraphReader reader = getReader(defaultMapperV2d0);
- Property prop = ed.property("since", Year.parse("1993"));
+ final Property prop = ed.property("since", Year.parse("1993"));
try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
writer.writeObject(out, prop);
- String json = out.toString();
+ final String json = out.toString();
- Property pRead = (Property)reader.readObject(new ByteArrayInputStream(json.getBytes()), Object.class);
+ final Property pRead = (Property)reader.readObject(new ByteArrayInputStream(json.getBytes()), Object.class);
//can't use equals here, because pRead is detached, its parent element has not been intentionally
//serialized and "equals()" checks that.
assertTrue(prop.key().equals(pRead.key()) && prop.value().equals(pRead.value()));
} catch (IOException e) {
e.printStackTrace();
+ fail("Should not have thrown exception: " + e.getMessage());
}
}
@Test
public void deserializersTestsVertexProperty() {
- TinkerGraph tg = TinkerGraph.open();
+ final TinkerGraph tg = TinkerGraph.open();
- Vertex v = tg.addVertex("vertexTest");
+ final Vertex v = tg.addVertex("vertexTest");
- GraphWriter writer = getWriter(defaultMapperV2d0);
- GraphReader reader = getReader(defaultMapperV2d0);
+ final GraphWriter writer = getWriter(defaultMapperV2d0);
+ final GraphReader reader = getReader(defaultMapperV2d0);
- VertexProperty prop = v.property("born", LocalDateTime.of(1971, 1, 2, 20, 50));
+ final VertexProperty prop = v.property("born", LocalDateTime.of(1971, 1, 2, 20, 50));
try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
writer.writeObject(out, prop);
- String json = out.toString();
+ final String json = out.toString();
- VertexProperty vPropRead = (VertexProperty)reader.readObject(new ByteArrayInputStream(json.getBytes()), Object.class);
+ final VertexProperty vPropRead = (VertexProperty)reader.readObject(new ByteArrayInputStream(json.getBytes()), Object.class);
//only classes and ids are checked, that's ok, full vertex property ser/de
//is checked elsewhere.
assertEquals(prop, vPropRead);
} catch (IOException e) {
e.printStackTrace();
+ fail("Should not have thrown exception: " + e.getMessage());
}
}
@Test
public void deserializersTestsPath() {
- TinkerGraph tg = TinkerFactory.createModern();
+ final TinkerGraph tg = TinkerFactory.createModern();
- GraphWriter writer = getWriter(defaultMapperV2d0);
- GraphReader reader = getReader(defaultMapperV2d0);
+ final GraphWriter writer = getWriter(defaultMapperV2d0);
+ final GraphReader reader = getReader(defaultMapperV2d0);
- Path p = tg.traversal().V(1).as("a").has("name").as("b").
+ final Path p = tg.traversal().V(1).as("a").has("name").as("b").
out("knows").out("created").as("c").
has("name", "ripple").values("name").as("d").
identity().as("e").path().next();
try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
writer.writeObject(out, p);
- String json = out.toString();
+ final String json = out.toString();
- Path pathRead = (Path)reader.readObject(new ByteArrayInputStream(json.getBytes()), Object.class);
+ final Path pathRead = (Path)reader.readObject(new ByteArrayInputStream(json.getBytes()), Object.class);
for (int i = 0; i < p.objects().size(); i++) {
- Object o = p.objects().get(i);
- Object oRead = pathRead.objects().get(i);
+ final Object o = p.objects().get(i);
+ final Object oRead = pathRead.objects().get(i);
assertEquals(o, oRead);
}
for (int i = 0; i < p.labels().size(); i++) {
- Set<String> o = p.labels().get(i);
- Set<String> oRead = pathRead.labels().get(i);
+ final Set<String> o = p.labels().get(i);
+ final Set<String> oRead = pathRead.labels().get(i);
assertEquals(o, oRead);
}
} catch (IOException e) {
e.printStackTrace();
+ fail("Should not have thrown exception: " + e.getMessage());
}
}
@Test
public void deserializersTestsMetrics() {
- TinkerGraph tg = TinkerFactory.createModern();
+ final TinkerGraph tg = TinkerFactory.createModern();
- GraphWriter writer = getWriter(defaultMapperV2d0);
- GraphReader reader = getReader(defaultMapperV2d0);
+ final GraphWriter writer = getWriter(defaultMapperV2d0);
+ final GraphReader reader = getReader(defaultMapperV2d0);
- TraversalMetrics tm = tg.traversal().V(1).as("a").has("name").as("b").
+ final TraversalMetrics tm = tg.traversal().V(1).as("a").has("name").as("b").
out("knows").out("created").as("c").
has("name", "ripple").values("name").as("d").
identity().as("e").profile().next();
- MutableMetrics m = new MutableMetrics(tm.getMetrics(0));
+ final MutableMetrics m = new MutableMetrics(tm.getMetrics(0));
// making sure nested metrics are included in serde
m.addNested(new MutableMetrics(tm.getMetrics(1)));
try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
writer.writeObject(out, m);
- String json = out.toString();
+ final String json = out.toString();
- Metrics metricsRead = (Metrics)reader.readObject(new ByteArrayInputStream(json.getBytes()), Object.class);
+ final Metrics metricsRead = (Metrics)reader.readObject(new ByteArrayInputStream(json.getBytes()), Object.class);
// toString should be enough to compare Metrics
assertTrue(m.toString().equals(metricsRead.toString()));
} catch (IOException e) {
e.printStackTrace();
+ fail("Should not have thrown exception: " + e.getMessage());
}
}
@Test
public void deserializersTestsTraversalMetrics() {
- TinkerGraph tg = TinkerFactory.createModern();
+ final TinkerGraph tg = TinkerFactory.createModern();
- GraphWriter writer = getWriter(defaultMapperV2d0);
- GraphReader reader = getReader(defaultMapperV2d0);
+ final GraphWriter writer = getWriter(defaultMapperV2d0);
+ final GraphReader reader = getReader(defaultMapperV2d0);
- TraversalMetrics tm = tg.traversal().V(1).as("a").has("name").as("b").
+ final TraversalMetrics tm = tg.traversal().V(1).as("a").has("name").as("b").
out("knows").out("created").as("c").
has("name", "ripple").values("name").as("d").
identity().as("e").profile().next();
try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
writer.writeObject(out, tm);
- String json = out.toString();
+ final String json = out.toString();
- TraversalMetrics traversalMetricsRead = (TraversalMetrics)reader.readObject(new ByteArrayInputStream(json.getBytes()), Object.class);
+ final TraversalMetrics traversalMetricsRead = (TraversalMetrics)reader.readObject(new ByteArrayInputStream(json.getBytes()), Object.class);
// toString should be enough to compare TraversalMetrics
assertTrue(tm.toString().equals(traversalMetricsRead.toString()));
} catch (IOException e) {
e.printStackTrace();
+ fail("Should not have thrown exception: " + e.getMessage());
}
}
@Test
public void deserializersTree() {
- TinkerGraph tg = TinkerFactory.createModern();
+ final TinkerGraph tg = TinkerFactory.createModern();
- GraphWriter writer = getWriter(noTypesMapperV2d0);
- GraphReader reader = getReader(noTypesMapperV2d0);
+ final GraphWriter writer = getWriter(noTypesMapperV2d0);
+ final GraphReader reader = getReader(noTypesMapperV2d0);
- Tree t = tg.traversal().V().out().out().tree().next();
+ final Tree t = tg.traversal().V().out().out().tree().next();
try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
- Vertex v = tg.traversal().V(1).next();
+ final Vertex v = tg.traversal().V(1).next();
v.property("myUUIDprop", UUID.randomUUID());
writer.writeObject(out, v);
// writer.writeObject(out, t);
- String json = out.toString();
+ final String json = out.toString();
- System.out.println("json = " + json);
+ //System.out.println("json = " + json);
// Tree treeRead = (Tree)reader.readObject(new ByteArrayInputStream(json.getBytes()), Object.class);
//Map's equals should check each component of the tree recursively
@@ -485,10 +494,9 @@ public class TinkerGraphGraphSONSerializerV2d0Test {
//is ok. Complete vertex deser is checked elsewhere.
// assertEquals(t, treeRead);
-
-
} catch (IOException e) {
e.printStackTrace();
+ fail("Should not have thrown exception: " + e.getMessage());
}
}
@@ -501,28 +509,28 @@ public class TinkerGraphGraphSONSerializerV2d0Test {
}
/**
- * Checks sequentially vertices and egdes of both graphs. Will check sequentially Vertex IDs, Vertex Properties IDs
+ * Checks sequentially vertices and edges of both graphs. Will check sequentially Vertex IDs, Vertex Properties IDs
* and values and classes. Then same for edges. To use when serializing a Graph and deserializing the supposedly
* same Graph.
*/
private boolean approximateGraphsCheck(Graph g1, Graph g2) {
- Iterator<Vertex> itV = g1.vertices();
- Iterator<Vertex> itVRead = g2.vertices();
+ final Iterator<Vertex> itV = g1.vertices();
+ final Iterator<Vertex> itVRead = g2.vertices();
while (itV.hasNext()) {
- Vertex v = itV.next();
- Vertex vRead = itVRead.next();
+ final Vertex v = itV.next();
+ final Vertex vRead = itVRead.next();
// Will only check IDs but that's 'good' enough.
if (!v.equals(vRead)) {
return false;
}
- Iterator itVP = v.properties();
- Iterator itVPRead = vRead.properties();
+ final Iterator itVP = v.properties();
+ final Iterator itVPRead = vRead.properties();
while (itVP.hasNext()) {
- VertexProperty vp = (VertexProperty) itVP.next();
- VertexProperty vpRead = (VertexProperty) itVPRead.next();
+ final VertexProperty vp = (VertexProperty) itVP.next();
+ final VertexProperty vpRead = (VertexProperty) itVPRead.next();
if (!vp.value().equals(vpRead.value())
|| !vp.equals(vpRead)) {
return false;
@@ -530,22 +538,22 @@ public class TinkerGraphGraphSONSerializerV2d0Test {
}
}
- Iterator<Edge> itE = g1.edges();
- Iterator<Edge> itERead = g2.edges();
+ final Iterator<Edge> itE = g1.edges();
+ final Iterator<Edge> itERead = g2.edges();
while (itE.hasNext()) {
- Edge e = itE.next();
- Edge eRead = itERead.next();
+ final Edge e = itE.next();
+ final Edge eRead = itERead.next();
// Will only check IDs but that's good enough.
if (!e.equals(eRead)) {
return false;
}
- Iterator itEP = e.properties();
- Iterator itEPRead = eRead.properties();
+ final Iterator itEP = e.properties();
+ final Iterator itEPRead = eRead.properties();
while (itEP.hasNext()) {
- Property ep = (Property) itEP.next();
- Property epRead = (Property) itEPRead.next();
+ final Property ep = (Property) itEP.next();
+ final Property epRead = (Property) itEPRead.next();
if (!ep.value().equals(epRead.value())
|| !ep.equals(epRead)) {
return false;