aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-01-25 20:32:14 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2013-01-25 20:32:14 +0100
commit31680c993557c3cd862005dc073f03412d62cc05 (patch)
tree91664f917b93732a6dd421135964e63404081b35
parentf6bcd1b80a758e9dd5e52af1ec6dd24c5ae45a31 (diff)
downloadsonarqube-31680c993557c3cd862005dc073f03412d62cc05.tar.gz
sonarqube-31680c993557c3cd862005dc073f03412d62cc05.zip
SONAR-2501 first step to fix case of Graphson* classes
-rw-r--r--sonar-core/src/main/java/org/sonar/core/graph/GraphWriter.java6
-rw-r--r--sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphonException.java (renamed from sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphSonException.java)6
-rw-r--r--sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphonMode.java (renamed from sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphSONMode.java)2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphonReader.java (renamed from sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphSONReader.java)14
-rw-r--r--sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphonTokens.java (renamed from sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphSONTokens.java)2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphonWriter.java (renamed from sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphSONWriter.java)17
-rw-r--r--sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonUtil.java142
-rw-r--r--sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonReaderTest.java42
-rw-r--r--sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonUtilTest.java106
-rw-r--r--sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonWriterTest.java48
10 files changed, 192 insertions, 193 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/GraphWriter.java b/sonar-core/src/main/java/org/sonar/core/graph/GraphWriter.java
index ac8b01a8efc..72066aee2f4 100644
--- a/sonar-core/src/main/java/org/sonar/core/graph/GraphWriter.java
+++ b/sonar-core/src/main/java/org/sonar/core/graph/GraphWriter.java
@@ -21,8 +21,8 @@ package org.sonar.core.graph;
import com.tinkerpop.blueprints.Graph;
import org.apache.commons.io.IOUtils;
-import org.sonar.core.graph.graphson.GraphSONMode;
-import org.sonar.core.graph.graphson.GraphSONWriter;
+import org.sonar.core.graph.graphson.GraphonMode;
+import org.sonar.core.graph.graphson.GraphonWriter;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -32,7 +32,7 @@ public class GraphWriter {
public String write(Graph graph) {
ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
- new GraphSONWriter().write(graph, output, GraphSONMode.COMPACT);
+ new GraphonWriter().write(graph, output, GraphonMode.COMPACT);
output.flush();
output.close();
return new String(output.toByteArray());
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphSonException.java b/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphonException.java
index f037e76249f..9962fbda3cc 100644
--- a/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphSonException.java
+++ b/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphonException.java
@@ -19,12 +19,12 @@
*/
package org.sonar.core.graph.graphson;
-public class GraphSonException extends RuntimeException {
- public GraphSonException(String message) {
+public class GraphonException extends RuntimeException {
+ public GraphonException(String message) {
super(message);
}
- public GraphSonException(String message, Throwable cause) {
+ public GraphonException(String message, Throwable cause) {
super(message, cause);
}
}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphSONMode.java b/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphonMode.java
index 3fde6287c08..ecc326fc87a 100644
--- a/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphSONMode.java
+++ b/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphonMode.java
@@ -24,7 +24,7 @@ package org.sonar.core.graph.graphson;
*
* @author Stephen Mallette
*/
-public enum GraphSONMode {
+public enum GraphonMode {
/**
* COMPACT constructs GraphSON on the assumption that all property keys
* are fair game for exclusion including _type, _inV, _outV, _label and _id.
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphSONReader.java b/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphonReader.java
index 1b3aee4d009..525d70b237d 100644
--- a/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphSONReader.java
+++ b/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphonReader.java
@@ -33,7 +33,7 @@ import java.util.Set;
/**
* Greatly inspired by the Blueprints implementation based on Jettison/Jackson
*/
-public class GraphSONReader {
+public class GraphonReader {
public Graph read(InputStream jsonInput, Graph toGraph) {
return read(jsonInput, toGraph, 1000, null, null);
@@ -57,25 +57,25 @@ public class GraphSONReader {
ElementFactory elementFactory = new ElementFactory(batchGraph);
- final GraphSONMode mode = GraphSONMode.valueOf(json.get(GraphSONTokens.MODE).toString());
+ final GraphonMode mode = GraphonMode.valueOf(json.get(GraphonTokens.MODE).toString());
GraphsonUtil graphson = new GraphsonUtil(mode, elementFactory, vertexPropertyKeys, edgePropertyKeys);
- JSONArray vertices = (JSONArray) json.get(GraphSONTokens.VERTICES);
+ JSONArray vertices = (JSONArray) json.get(GraphonTokens.VERTICES);
for (Object vertice : vertices) {
graphson.vertexFromJson((JSONObject) vertice);
}
- JSONArray edges = (JSONArray) json.get(GraphSONTokens.EDGES);
+ JSONArray edges = (JSONArray) json.get(GraphonTokens.EDGES);
for (Object edgeObject : edges) {
JSONObject edge = (JSONObject) edgeObject;
- final Vertex inV = batchGraph.getVertex(edge.get(GraphSONTokens._IN_V));
- final Vertex outV = batchGraph.getVertex(edge.get(GraphSONTokens._OUT_V));
+ final Vertex inV = batchGraph.getVertex(edge.get(GraphonTokens._IN_V));
+ final Vertex outV = batchGraph.getVertex(edge.get(GraphonTokens._OUT_V));
graphson.edgeFromJson(edge, outV, inV);
}
batchGraph.shutdown();
return toGraph;
} catch (Exception e) {
- throw new GraphSonException("Unable to parse GraphSON", e);
+ throw new GraphonException("Unable to parse GraphSON", e);
}
}
}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphSONTokens.java b/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphonTokens.java
index b67e713ca64..affd04126dd 100644
--- a/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphSONTokens.java
+++ b/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphonTokens.java
@@ -23,7 +23,7 @@ package org.sonar.core.graph.graphson;
* @author Marko A. Rodriguez (http://markorodriguez.com)
* @author Stephen Mallette
*/
-class GraphSONTokens {
+class GraphonTokens {
public static final String VERTEX = "vertex";
public static final String EDGE = "edge";
public static final String _ID = "_id";
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphSONWriter.java b/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphonWriter.java
index a48a24db336..d1b2de8103d 100644
--- a/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphSONWriter.java
+++ b/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphonWriter.java
@@ -19,7 +19,6 @@
*/
package org.sonar.core.graph.graphson;
-import com.google.common.base.Charsets;
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Graph;
import com.tinkerpop.blueprints.Vertex;
@@ -32,13 +31,13 @@ import java.io.OutputStream;
import java.util.Set;
/**
- * GraphSONWriter writes a Graph to a TinkerPop JSON OutputStream.
+ * GraphonWriter writes a Graph to a TinkerPop JSON OutputStream.
*
* @author Stephen Mallette
*/
-public class GraphSONWriter {
+public class GraphonWriter {
- public void write(Graph graph, OutputStream jsonOutputStream, GraphSONMode mode) {
+ public void write(Graph graph, OutputStream jsonOutputStream, GraphonMode mode) {
write(graph, jsonOutputStream, mode, null, null);
}
@@ -51,28 +50,28 @@ public class GraphSONWriter {
* @param mode determines the format of the GraphSON
* @throws java.io.IOException thrown if there is an error generating the JSON data
*/
- public void write(Graph graph, OutputStream jsonOutputStream, GraphSONMode mode, @Nullable Set<String> vertexPropertyKeys, @Nullable Set<String> edgePropertyKeys) {
+ public void write(Graph graph, OutputStream jsonOutputStream, GraphonMode mode, @Nullable Set<String> vertexPropertyKeys, @Nullable Set<String> edgePropertyKeys) {
try {
JSONObject root = new JSONObject();
GraphsonUtil graphson = new GraphsonUtil(mode, null, vertexPropertyKeys, edgePropertyKeys);
- root.put(GraphSONTokens.MODE, mode.toString());
+ root.put(GraphonTokens.MODE, mode.toString());
JSONArray verticesArray = new JSONArray();
for (Vertex v : graph.getVertices()) {
verticesArray.add(graphson.objectNodeFromElement(v));
}
- root.put(GraphSONTokens.VERTICES, verticesArray);
+ root.put(GraphonTokens.VERTICES, verticesArray);
JSONArray edgesArray = new JSONArray();
for (Edge e : graph.getEdges()) {
edgesArray.add(graphson.objectNodeFromElement(e));
}
- root.put(GraphSONTokens.EDGES, edgesArray);
+ root.put(GraphonTokens.EDGES, edgesArray);
jsonOutputStream.write(root.toString().getBytes("UTF-8"));
} catch (Exception e) {
- throw new GraphSonException("Fail to generate GraphSON", e);
+ throw new GraphonException("Fail to generate GraphSON", e);
}
}
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonUtil.java b/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonUtil.java
index 60c213c33fb..069abc8856a 100644
--- a/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonUtil.java
+++ b/sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonUtil.java
@@ -50,7 +50,7 @@ import static org.sonar.core.graph.graphson.ElementPropertyConfig.ElementPropert
*/
class GraphsonUtil {
- private final GraphSONMode mode;
+ private final GraphonMode mode;
private final Set<String> vertexPropertyKeys;
private final Set<String> edgePropertyKeys;
private final ElementFactory factory;
@@ -69,19 +69,19 @@ class GraphsonUtil {
/**
* A GraphSONUtiltiy that includes all properties of vertices and edges.
*/
- GraphsonUtil(GraphSONMode mode, ElementFactory factory) {
+ GraphsonUtil(GraphonMode mode, ElementFactory factory) {
this(mode, factory, ElementPropertyConfig.AllProperties);
}
/**
* A GraphSONUtility that includes the specified properties.
*/
- GraphsonUtil(GraphSONMode mode, ElementFactory factory,
+ GraphsonUtil(GraphonMode mode, ElementFactory factory,
Set<String> vertexPropertyKeys, Set<String> edgePropertyKeys) {
this(mode, factory, ElementPropertyConfig.includeProperties(vertexPropertyKeys, edgePropertyKeys));
}
- GraphsonUtil(GraphSONMode mode, ElementFactory factory,
+ GraphsonUtil(GraphonMode mode, ElementFactory factory,
ElementPropertyConfig config) {
this.vertexPropertyKeys = config.getVertexPropertyKeys();
this.edgePropertyKeys = config.getEdgePropertyKeys();
@@ -90,15 +90,15 @@ class GraphsonUtil {
this.mode = mode;
this.factory = factory;
- this.hasEmbeddedTypes = mode == GraphSONMode.EXTENDED;
+ this.hasEmbeddedTypes = mode == GraphonMode.EXTENDED;
- this.includeReservedVertexId = includeReservedKey(mode, GraphSONTokens._ID, vertexPropertyKeys, this.vertexPropertiesRule);
- this.includeReservedEdgeId = includeReservedKey(mode, GraphSONTokens._ID, edgePropertyKeys, this.edgePropertiesRule);
- this.includeReservedVertexType = includeReservedKey(mode, GraphSONTokens._TYPE, vertexPropertyKeys, this.vertexPropertiesRule);
- this.includeReservedEdgeType = includeReservedKey(mode, GraphSONTokens._TYPE, edgePropertyKeys, this.edgePropertiesRule);
- this.includeReservedEdgeLabel = includeReservedKey(mode, GraphSONTokens._LABEL, edgePropertyKeys, this.edgePropertiesRule);
- this.includeReservedEdgeOutV = includeReservedKey(mode, GraphSONTokens._OUT_V, edgePropertyKeys, this.edgePropertiesRule);
- this.includeReservedEdgeInV = includeReservedKey(mode, GraphSONTokens._IN_V, edgePropertyKeys, this.edgePropertiesRule);
+ this.includeReservedVertexId = includeReservedKey(mode, GraphonTokens._ID, vertexPropertyKeys, this.vertexPropertiesRule);
+ this.includeReservedEdgeId = includeReservedKey(mode, GraphonTokens._ID, edgePropertyKeys, this.edgePropertiesRule);
+ this.includeReservedVertexType = includeReservedKey(mode, GraphonTokens._TYPE, vertexPropertyKeys, this.vertexPropertiesRule);
+ this.includeReservedEdgeType = includeReservedKey(mode, GraphonTokens._TYPE, edgePropertyKeys, this.edgePropertiesRule);
+ this.includeReservedEdgeLabel = includeReservedKey(mode, GraphonTokens._LABEL, edgePropertyKeys, this.edgePropertiesRule);
+ this.includeReservedEdgeOutV = includeReservedKey(mode, GraphonTokens._OUT_V, edgePropertyKeys, this.edgePropertiesRule);
+ this.includeReservedEdgeInV = includeReservedKey(mode, GraphonTokens._IN_V, edgePropertyKeys, this.edgePropertiesRule);
}
/**
@@ -108,7 +108,7 @@ class GraphsonUtil {
* @param propertyKeys The property keys at the root of the element to serialize. If null, then all keys are serialized.
* @param mode the type of GraphSON to be generated.
*/
- static JSONObject jsonFromElement(Element element, @Nullable Set<String> propertyKeys, GraphSONMode mode) {
+ static JSONObject jsonFromElement(Element element, @Nullable Set<String> propertyKeys, GraphonMode mode) {
GraphsonUtil graphson = element instanceof Edge ? new GraphsonUtil(mode, null, null, propertyKeys)
: new GraphsonUtil(mode, null, propertyKeys, null);
return graphson.jsonFromElement(element);
@@ -121,7 +121,7 @@ class GraphsonUtil {
* @param propertyKeys The property keys at the root of the element to serialize. If null, then all keys are serialized.
* @param mode The type of GraphSON to generate.
*/
- static JSONObject objectNodeFromElement(Element element, Set<String> propertyKeys, GraphSONMode mode) {
+ static JSONObject objectNodeFromElement(Element element, Set<String> propertyKeys, GraphonMode mode) {
GraphsonUtil graphson = element instanceof Edge ? new GraphsonUtil(mode, null, null, propertyKeys)
: new GraphsonUtil(mode, null, propertyKeys, null);
return graphson.objectNodeFromElement(element);
@@ -135,7 +135,7 @@ class GraphsonUtil {
* @param mode the mode of the GraphSON
* @param propertyKeys a list of keys to include on reading of element properties
*/
- static Vertex vertexFromJson(JSONObject json, ElementFactory factory, GraphSONMode mode,
+ static Vertex vertexFromJson(JSONObject json, ElementFactory factory, GraphonMode mode,
Set<String> propertyKeys) throws IOException {
GraphsonUtil graphson = new GraphsonUtil(mode, factory, propertyKeys, null);
return graphson.vertexFromJson(json);
@@ -149,7 +149,7 @@ class GraphsonUtil {
* @param mode the mode of the GraphSON
* @param propertyKeys a list of keys to include on reading of element properties
*/
- static Vertex vertexFromJson(String json, ElementFactory factory, GraphSONMode mode,
+ static Vertex vertexFromJson(String json, ElementFactory factory, GraphonMode mode,
Set<String> propertyKeys) throws ParseException {
GraphsonUtil graphson = new GraphsonUtil(mode, factory, propertyKeys, null);
return graphson.vertexFromJson(json);
@@ -163,18 +163,18 @@ class GraphsonUtil {
* @param mode the mode of the GraphSON
* @param propertyKeys a list of keys to include on reading of element properties
*/
- static Vertex vertexFromJson(InputStream json, ElementFactory factory, GraphSONMode mode,
+ static Vertex vertexFromJson(InputStream json, ElementFactory factory, GraphonMode mode,
Set<String> propertyKeys) throws IOException, ParseException {
GraphsonUtil graphson = new GraphsonUtil(mode, factory, propertyKeys, null);
return graphson.vertexFromJson(json);
}
- private static boolean includeReservedKey(GraphSONMode mode, String key,
+ private static boolean includeReservedKey(GraphonMode mode, String key,
Set<String> propertyKeys,
ElementPropertiesRule rule) {
// the key is always included in modes other than compact. if it is compact, then validate that the
// key is in the property key list
- return mode != GraphSONMode.COMPACT || includeKey(key, propertyKeys, rule);
+ return mode != GraphonMode.COMPACT || includeKey(key, propertyKeys, rule);
}
private static boolean includeKey(String key, Set<String> propertyKeys,
@@ -209,7 +209,7 @@ class GraphsonUtil {
* @param propertyKeys a list of keys to include when reading of element properties
*/
static Edge edgeFromJson(String json, Vertex out, Vertex in,
- ElementFactory factory, GraphSONMode mode,
+ ElementFactory factory, GraphonMode mode,
Set<String> propertyKeys) throws IOException, ParseException {
GraphsonUtil graphson = new GraphsonUtil(mode, factory, null, propertyKeys);
return graphson.edgeFromJson(json, out, in);
@@ -224,7 +224,7 @@ class GraphsonUtil {
* @param propertyKeys a list of keys to include when reading of element properties
*/
static Edge edgeFromJson(InputStream json, Vertex out, Vertex in,
- ElementFactory factory, GraphSONMode mode,
+ ElementFactory factory, GraphonMode mode,
Set<String> propertyKeys) throws IOException, ParseException {
GraphsonUtil graphson = new GraphsonUtil(mode, factory, null, propertyKeys);
return graphson.edgeFromJson(json, out, in);
@@ -239,7 +239,7 @@ class GraphsonUtil {
* @param propertyKeys a list of keys to include when reading of element properties
*/
static Edge edgeFromJson(JSONObject json, Vertex out, Vertex in,
- ElementFactory factory, GraphSONMode mode,
+ ElementFactory factory, GraphonMode mode,
Set<String> propertyKeys) throws IOException {
GraphsonUtil graphson = new GraphsonUtil(mode, factory, null, propertyKeys);
return graphson.edgeFromJson(json, out, in);
@@ -261,8 +261,8 @@ class GraphsonUtil {
}
private static boolean isReservedKey(String key) {
- return key.equals(GraphSONTokens._ID) || key.equals(GraphSONTokens._TYPE) || key.equals(GraphSONTokens._LABEL)
- || key.equals(GraphSONTokens._OUT_V) || key.equals(GraphSONTokens._IN_V);
+ return key.equals(GraphonTokens._ID) || key.equals(GraphonTokens._TYPE) || key.equals(GraphonTokens._LABEL)
+ || key.equals(GraphonTokens._OUT_V) || key.equals(GraphonTokens._IN_V);
}
private static JSONArray createJSONList(List list, Set<String> propertyKeys, boolean showTypes) {
@@ -270,7 +270,7 @@ class GraphsonUtil {
for (Object item : list) {
if (item instanceof Element) {
jsonList.add(objectNodeFromElement((Element) item, propertyKeys,
- showTypes ? GraphSONMode.EXTENDED : GraphSONMode.NORMAL));
+ showTypes ? GraphonMode.EXTENDED : GraphonMode.NORMAL));
} else if (item instanceof List) {
jsonList.add(createJSONList((List) item, propertyKeys, showTypes));
} else if (item instanceof Map) {
@@ -296,7 +296,7 @@ class GraphsonUtil {
value = createJSONMap((Map) value, propertyKeys, showTypes);
} else if (value instanceof Element) {
value = objectNodeFromElement((Element) value, propertyKeys,
- showTypes ? GraphSONMode.EXTENDED : GraphSONMode.NORMAL);
+ showTypes ? GraphonMode.EXTENDED : GraphonMode.NORMAL);
} else if (value.getClass().isArray()) {
value = createJSONList(convertArrayToList(value), propertyKeys, showTypes);
}
@@ -313,24 +313,24 @@ class GraphsonUtil {
if (hasEmbeddedTypes) {
JSONObject json = (JSONObject) node;
- if (json.get(GraphSONTokens.TYPE).equals(GraphSONTokens.TYPE_UNKNOWN)) {
+ if (json.get(GraphonTokens.TYPE).equals(GraphonTokens.TYPE_UNKNOWN)) {
propertyValue = null;
- } else if (json.get(GraphSONTokens.TYPE).equals(GraphSONTokens.TYPE_BOOLEAN)) {
- propertyValue = json.get(GraphSONTokens.VALUE);
- } else if (json.get(GraphSONTokens.TYPE).equals(GraphSONTokens.TYPE_FLOAT)) {
- propertyValue = ((Double) json.get(GraphSONTokens.VALUE)).floatValue();
- } else if (json.get(GraphSONTokens.TYPE).equals(GraphSONTokens.TYPE_DOUBLE)) {
- propertyValue = json.get(GraphSONTokens.VALUE);
- } else if (json.get(GraphSONTokens.TYPE).equals(GraphSONTokens.TYPE_INTEGER)) {
- propertyValue = ((Long) json.get(GraphSONTokens.VALUE)).intValue();
- } else if (json.get(GraphSONTokens.TYPE).equals(GraphSONTokens.TYPE_LONG)) {
- propertyValue = json.get(GraphSONTokens.VALUE);
- } else if (json.get(GraphSONTokens.TYPE).equals(GraphSONTokens.TYPE_STRING)) {
- propertyValue = json.get(GraphSONTokens.VALUE);
- } else if (json.get(GraphSONTokens.TYPE).equals(GraphSONTokens.TYPE_LIST)) {
- propertyValue = readProperties(((JSONArray) json.get(GraphSONTokens.VALUE)).iterator(), hasEmbeddedTypes);
- } else if (json.get(GraphSONTokens.TYPE).equals(GraphSONTokens.TYPE_MAP)) {
- propertyValue = readProperties((JSONObject) json.get(GraphSONTokens.VALUE), false, hasEmbeddedTypes);
+ } else if (json.get(GraphonTokens.TYPE).equals(GraphonTokens.TYPE_BOOLEAN)) {
+ propertyValue = json.get(GraphonTokens.VALUE);
+ } else if (json.get(GraphonTokens.TYPE).equals(GraphonTokens.TYPE_FLOAT)) {
+ propertyValue = ((Double) json.get(GraphonTokens.VALUE)).floatValue();
+ } else if (json.get(GraphonTokens.TYPE).equals(GraphonTokens.TYPE_DOUBLE)) {
+ propertyValue = json.get(GraphonTokens.VALUE);
+ } else if (json.get(GraphonTokens.TYPE).equals(GraphonTokens.TYPE_INTEGER)) {
+ propertyValue = ((Long) json.get(GraphonTokens.VALUE)).intValue();
+ } else if (json.get(GraphonTokens.TYPE).equals(GraphonTokens.TYPE_LONG)) {
+ propertyValue = json.get(GraphonTokens.VALUE);
+ } else if (json.get(GraphonTokens.TYPE).equals(GraphonTokens.TYPE_STRING)) {
+ propertyValue = json.get(GraphonTokens.VALUE);
+ } else if (json.get(GraphonTokens.TYPE).equals(GraphonTokens.TYPE_LIST)) {
+ propertyValue = readProperties(((JSONArray) json.get(GraphonTokens.VALUE)).iterator(), hasEmbeddedTypes);
+ } else if (json.get(GraphonTokens.TYPE).equals(GraphonTokens.TYPE_MAP)) {
+ propertyValue = readProperties((JSONObject) json.get(GraphonTokens.VALUE), false, hasEmbeddedTypes);
} else {
propertyValue = node.toString();
}
@@ -457,9 +457,9 @@ class GraphsonUtil {
String type = determineType(value);
JSONObject valueAndType = new JSONObject();
- valueAndType.put(GraphSONTokens.TYPE, type);
+ valueAndType.put(GraphonTokens.TYPE, type);
- if (type.equals(GraphSONTokens.TYPE_LIST)) {
+ if (type.equals(GraphonTokens.TYPE_LIST)) {
// values of lists must be accumulated as ObjectNode objects under the value key.
// will return as a ArrayNode. called recursively to traverse the entire
@@ -468,14 +468,14 @@ class GraphsonUtil {
// there is a set of values that must be accumulated as an array under a key
JSONArray valueArray = new JSONArray();
- valueAndType.put(GraphSONTokens.VALUE, valueArray);
+ valueAndType.put(GraphonTokens.VALUE, valueArray);
for (int ix = 0; ix < list.size(); ix++) {
// the value of each item in the array is a node object from an ArrayNode...must
// get the value of it.
addObject(valueArray, getValue(list.get(ix), includeType));
}
- } else if (type.equals(GraphSONTokens.TYPE_MAP)) {
+ } else if (type.equals(GraphonTokens.TYPE_MAP)) {
// maps are converted to a ObjectNode. called recursively to traverse
// the entire object graph within the map.
@@ -488,14 +488,14 @@ class GraphsonUtil {
convertedMap.put(key, jsonObject.get(key));
}
- valueAndType.put(GraphSONTokens.VALUE, convertedMap);
+ valueAndType.put(GraphonTokens.VALUE, convertedMap);
} else {
// this must be a primitive value or a complex object. if a complex
// object it will be handled by a call to toString and stored as a
// string value
- putObject(valueAndType, GraphSONTokens.VALUE, value);
+ putObject(valueAndType, GraphonTokens.VALUE, value);
}
// this goes back as a JSONObject with data type and value
@@ -542,23 +542,23 @@ class GraphsonUtil {
}
private static String determineType(Object value) {
- String type = GraphSONTokens.TYPE_STRING;
+ String type = GraphonTokens.TYPE_STRING;
if (value == null) {
type = "unknown";
} else if (value instanceof Double) {
- type = GraphSONTokens.TYPE_DOUBLE;
+ type = GraphonTokens.TYPE_DOUBLE;
} else if (value instanceof Float) {
- type = GraphSONTokens.TYPE_FLOAT;
+ type = GraphonTokens.TYPE_FLOAT;
} else if (value instanceof Integer) {
- type = GraphSONTokens.TYPE_INTEGER;
+ type = GraphonTokens.TYPE_INTEGER;
} else if (value instanceof Long) {
- type = GraphSONTokens.TYPE_LONG;
+ type = GraphonTokens.TYPE_LONG;
} else if (value instanceof Boolean) {
- type = GraphSONTokens.TYPE_BOOLEAN;
+ type = GraphonTokens.TYPE_BOOLEAN;
} else if (value instanceof JSONArray) {
- type = GraphSONTokens.TYPE_LIST;
+ type = GraphonTokens.TYPE_LIST;
} else if (value instanceof JSONObject) {
- type = GraphSONTokens.TYPE_MAP;
+ type = GraphonTokens.TYPE_MAP;
}
return type;
@@ -591,10 +591,10 @@ class GraphsonUtil {
Edge edgeFromJson(JSONObject json, Vertex out, Vertex in) throws IOException {
Map<String, Object> props = GraphsonUtil.readProperties(json, true, this.hasEmbeddedTypes);
-// Object edgeId = getTypedValueFromJsonNode(json.get(GraphSONTokens._ID));
- Object edgeId = json.get(GraphSONTokens._ID);
+// Object edgeId = getTypedValueFromJsonNode(json.get(GraphonTokens._ID));
+ Object edgeId = json.get(GraphonTokens._ID);
- Object nodeLabel = json.get(GraphSONTokens._LABEL);
+ Object nodeLabel = json.get(GraphonTokens._LABEL);
String label = nodeLabel == null ? null : nodeLabel.toString();
Edge e = factory.createEdge(edgeId, out, in, label);
@@ -622,8 +622,8 @@ class GraphsonUtil {
Vertex vertexFromJson(JSONObject json) {
Map<String, Object> props = readProperties(json, true, this.hasEmbeddedTypes);
- //Object vertexId = getTypedValueFromJsonNode((JSONObject)json.get(GraphSONTokens._ID));
- Object vertexId = json.get(GraphSONTokens._ID);
+ //Object vertexId = getTypedValueFromJsonNode((JSONObject)json.get(GraphonTokens._ID));
+ Object vertexId = json.get(GraphonTokens._ID);
Vertex v = factory.createVertex(vertexId);
for (Map.Entry<String, Object> entry : props.entrySet()) {
@@ -649,14 +649,14 @@ class GraphsonUtil {
*/
org.json.simple.JSONObject objectNodeFromElement(Element element) {
boolean isEdge = element instanceof Edge;
- boolean showTypes = mode == GraphSONMode.EXTENDED;
+ boolean showTypes = mode == GraphonMode.EXTENDED;
Set<String> propertyKeys = isEdge ? this.edgePropertyKeys : this.vertexPropertyKeys;
ElementPropertiesRule elementPropertyConfig = isEdge ? this.edgePropertiesRule : this.vertexPropertiesRule;
org.json.simple.JSONObject jsonElement = createJSONMap(createPropertyMap(element, propertyKeys, elementPropertyConfig), propertyKeys, showTypes);
if ((isEdge && this.includeReservedEdgeId) || (!isEdge && this.includeReservedVertexId)) {
- putObject(jsonElement, GraphSONTokens._ID, element.getId());
+ putObject(jsonElement, GraphonTokens._ID, element.getId());
}
// it's important to keep the order of these straight. check Edge first and then Vertex because there
@@ -665,31 +665,31 @@ class GraphsonUtil {
Edge edge = (Edge) element;
if (this.includeReservedEdgeId) {
- putObject(jsonElement, GraphSONTokens._ID, element.getId());
+ putObject(jsonElement, GraphonTokens._ID, element.getId());
}
if (this.includeReservedEdgeType) {
- jsonElement.put(GraphSONTokens._TYPE, GraphSONTokens.EDGE);
+ jsonElement.put(GraphonTokens._TYPE, GraphonTokens.EDGE);
}
if (this.includeReservedEdgeOutV) {
- putObject(jsonElement, GraphSONTokens._OUT_V, edge.getVertex(Direction.OUT).getId());
+ putObject(jsonElement, GraphonTokens._OUT_V, edge.getVertex(Direction.OUT).getId());
}
if (this.includeReservedEdgeInV) {
- putObject(jsonElement, GraphSONTokens._IN_V, edge.getVertex(Direction.IN).getId());
+ putObject(jsonElement, GraphonTokens._IN_V, edge.getVertex(Direction.IN).getId());
}
if (this.includeReservedEdgeLabel) {
- jsonElement.put(GraphSONTokens._LABEL, edge.getLabel());
+ jsonElement.put(GraphonTokens._LABEL, edge.getLabel());
}
} else if (element instanceof Vertex) {
if (this.includeReservedVertexId) {
- putObject(jsonElement, GraphSONTokens._ID, element.getId());
+ putObject(jsonElement, GraphonTokens._ID, element.getId());
}
if (this.includeReservedVertexType) {
- jsonElement.put(GraphSONTokens._TYPE, GraphSONTokens.VERTEX);
+ jsonElement.put(GraphonTokens._TYPE, GraphonTokens.VERTEX);
}
}
diff --git a/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonReaderTest.java b/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonReaderTest.java
index 9c0cb908c8a..74cbdaa08f8 100644
--- a/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonReaderTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonReaderTest.java
@@ -47,7 +47,7 @@ public class GraphsonReaderTest {
byte[] bytes = json.getBytes();
InputStream inputStream = new ByteArrayInputStream(bytes);
- new GraphSONReader().read(inputStream, graph);
+ new GraphonReader().read(inputStream, graph);
Assert.assertEquals(2, getIterableCount(graph.getVertices()));
Assert.assertEquals(1, getIterableCount(graph.getEdges()));
@@ -98,7 +98,7 @@ public class GraphsonReaderTest {
byte[] bytes = json.getBytes();
InputStream inputStream = new ByteArrayInputStream(bytes);
- new GraphSONReader().read(inputStream, graph);
+ new GraphonReader().read(inputStream, graph);
Assert.assertEquals(2, getIterableCount(graph.getVertices()));
Assert.assertEquals(1, getIterableCount(graph.getEdges()));
@@ -149,7 +149,7 @@ public class GraphsonReaderTest {
byte[] bytes = json.getBytes();
InputStream inputStream = new ByteArrayInputStream(bytes);
- new GraphSONReader().read(inputStream, graph);
+ new GraphonReader().read(inputStream, graph);
Assert.assertEquals(2, getIterableCount(graph.getVertices()));
Assert.assertEquals(1, getIterableCount(graph.getEdges()));
@@ -197,8 +197,8 @@ public class GraphsonReaderTest {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
- GraphSONWriter writer = new GraphSONWriter();
- writer.write(graph, stream, GraphSONMode.EXTENDED);
+ GraphonWriter writer = new GraphonWriter();
+ writer.write(graph, stream, GraphonMode.EXTENDED);
stream.flush();
stream.close();
@@ -209,7 +209,7 @@ public class GraphsonReaderTest {
InputStream inputStream = new ByteArrayInputStream(bytes);
TinkerGraph emptyGraph = new TinkerGraph();
- new GraphSONReader().read(inputStream, emptyGraph);
+ new GraphonReader().read(inputStream, emptyGraph);
Assert.assertEquals(6, getIterableCount(emptyGraph.getVertices()));
Assert.assertEquals(6, getIterableCount(emptyGraph.getEdges()));
@@ -243,16 +243,16 @@ public class GraphsonReaderTest {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
Set<String> edgeKeys = new HashSet<String>();
- edgeKeys.add(GraphSONTokens._ID);
- edgeKeys.add(GraphSONTokens._IN_V);
- edgeKeys.add(GraphSONTokens._OUT_V);
- edgeKeys.add(GraphSONTokens._LABEL);
+ edgeKeys.add(GraphonTokens._ID);
+ edgeKeys.add(GraphonTokens._IN_V);
+ edgeKeys.add(GraphonTokens._OUT_V);
+ edgeKeys.add(GraphonTokens._LABEL);
Set<String> vertexKeys = new HashSet<String>();
- vertexKeys.add(GraphSONTokens._ID);
+ vertexKeys.add(GraphonTokens._ID);
- GraphSONWriter writer = new GraphSONWriter();
- writer.write(graph, stream, GraphSONMode.EXTENDED, vertexKeys, edgeKeys);
+ GraphonWriter writer = new GraphonWriter();
+ writer.write(graph, stream, GraphonMode.EXTENDED, vertexKeys, edgeKeys);
stream.flush();
stream.close();
@@ -263,7 +263,7 @@ public class GraphsonReaderTest {
InputStream inputStream = new ByteArrayInputStream(bytes);
TinkerGraph emptyGraph = new TinkerGraph();
- new GraphSONReader().read(inputStream, emptyGraph);
+ new GraphonReader().read(inputStream, emptyGraph);
Assert.assertEquals(6, getIterableCount(emptyGraph.getVertices()));
Assert.assertEquals(6, getIterableCount(emptyGraph.getEdges()));
@@ -296,21 +296,21 @@ public class GraphsonReaderTest {
}
- @Test(expected = GraphSonException.class)
+ @Test(expected = GraphonException.class)
public void inputGraphCompactFullCycleBroken() throws Exception {
TinkerGraph graph = TinkerGraphFactory.createTinkerGraph();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
Set<String> edgeKeys = new HashSet<String>();
- edgeKeys.add(GraphSONTokens._IN_V);
- edgeKeys.add(GraphSONTokens._OUT_V);
- edgeKeys.add(GraphSONTokens._LABEL);
+ edgeKeys.add(GraphonTokens._IN_V);
+ edgeKeys.add(GraphonTokens._OUT_V);
+ edgeKeys.add(GraphonTokens._LABEL);
Set<String> vertexKeys = new HashSet<String>();
- GraphSONWriter writer = new GraphSONWriter();
- writer.write(graph, stream, GraphSONMode.COMPACT, vertexKeys, edgeKeys);
+ GraphonWriter writer = new GraphonWriter();
+ writer.write(graph, stream, GraphonMode.COMPACT, vertexKeys, edgeKeys);
stream.flush();
stream.close();
@@ -321,7 +321,7 @@ public class GraphsonReaderTest {
InputStream inputStream = new ByteArrayInputStream(bytes);
TinkerGraph emptyGraph = new TinkerGraph();
- new GraphSONReader().read(inputStream, emptyGraph);
+ new GraphonReader().read(inputStream, emptyGraph);
}
diff --git a/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonUtilTest.java b/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonUtilTest.java
index ad24c277774..e06ac02136e 100644
--- a/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonUtilTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonUtilTest.java
@@ -68,7 +68,7 @@ public class GraphsonUtilTest {
Edge e = this.graph.addEdge(3, v1, v2, "test");
e.setProperty("weight", 0.5f);
- JSONObject json = GraphsonUtil.jsonFromElement(e, null, GraphSONMode.NORMAL);
+ JSONObject json = GraphsonUtil.jsonFromElement(e, null, GraphonMode.NORMAL);
assertThat(json).isNotNull();
assertThat(json.containsKey(GraphSONTokens._ID)).isTrue();
@@ -97,7 +97,7 @@ public class GraphsonUtilTest {
add(GraphSONTokens._ID);
}};
- JSONObject json = GraphsonUtil.jsonFromElement(e, propertiesToInclude, GraphSONMode.COMPACT);
+ JSONObject json = GraphsonUtil.jsonFromElement(e, propertiesToInclude, GraphonMode.COMPACT);
assertThat(json).isNotNull();
assertThat(json.containsKey(GraphSONTokens._TYPE)).isFalse();
@@ -129,7 +129,7 @@ public class GraphsonUtilTest {
ElementPropertyConfig config = new ElementPropertyConfig(null, propertiesToExclude,
ElementPropertyConfig.ElementPropertiesRule.INCLUDE,
ElementPropertyConfig.ElementPropertiesRule.EXCLUDE);
- GraphsonUtil utility = new GraphsonUtil(GraphSONMode.COMPACT, factory, config);
+ GraphsonUtil utility = new GraphsonUtil(GraphonMode.COMPACT, factory, config);
JSONObject json = utility.jsonFromElement(e);
assertThat(json).isNotNull();
@@ -151,7 +151,7 @@ public class GraphsonUtilTest {
Edge e = this.graph.addEdge(3, v1, v2, "test");
e.setProperty("weight", 0.5f);
- JSONObject json = GraphsonUtil.jsonFromElement(e, null, GraphSONMode.COMPACT);
+ JSONObject json = GraphsonUtil.jsonFromElement(e, null, GraphonMode.COMPACT);
assertThat(json).isNotNull();
assertThat(json.containsKey(GraphSONTokens._ID)).isTrue();
@@ -167,7 +167,7 @@ public class GraphsonUtilTest {
Vertex v = this.graph.addVertex(1);
v.setProperty("name", "marko");
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.NORMAL);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.NORMAL);
assertThat(json).isNotNull();
assertThat(json.containsKey(GraphSONTokens._ID)).isTrue();
@@ -186,7 +186,7 @@ public class GraphsonUtilTest {
add(GraphSONTokens._ID);
}};
- JSONObject json = GraphsonUtil.jsonFromElement(v, propertiesToInclude, GraphSONMode.COMPACT);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, propertiesToInclude, GraphonMode.COMPACT);
assertThat(json).isNotNull();
assertThat(json.containsKey(GraphSONTokens._TYPE)).isFalse();
@@ -208,7 +208,7 @@ public class GraphsonUtilTest {
ElementPropertyConfig.ElementPropertiesRule.EXCLUDE,
ElementPropertyConfig.ElementPropertiesRule.EXCLUDE);
- GraphsonUtil utility = new GraphsonUtil(GraphSONMode.COMPACT, factory, config);
+ GraphsonUtil utility = new GraphsonUtil(GraphonMode.COMPACT, factory, config);
JSONObject json = utility.jsonFromElement(v);
assertThat(json).isNotNull();
@@ -222,7 +222,7 @@ public class GraphsonUtilTest {
Vertex v = this.graph.addVertex(1);
v.setProperty("name", "marko");
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.COMPACT);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.COMPACT);
assertThat(json).isNotNull();
assertThat(json.containsKey(GraphSONTokens._TYPE)).isTrue();
@@ -241,7 +241,7 @@ public class GraphsonUtilTest {
v.setProperty("keyDouble", 4.4);
v.setProperty("keyBoolean", true);
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.NORMAL);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.NORMAL);
assertThat(json).isNotNull();
assertThat(json.containsKey(GraphSONTokens._ID)).isTrue();
@@ -271,7 +271,7 @@ public class GraphsonUtilTest {
v.setProperty("keyMap", map);
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.NORMAL);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.NORMAL);
assertThat(json).isNotNull();
assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
@@ -296,7 +296,7 @@ public class GraphsonUtilTest {
v.setProperty("keyList", list);
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.NORMAL);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.NORMAL);
assertThat(json).isNotNull();
assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
@@ -314,7 +314,7 @@ public class GraphsonUtilTest {
v.setProperty("keyStringArray", stringArray);
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.NORMAL);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.NORMAL);
assertThat(json).isNotNull();
assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
@@ -332,7 +332,7 @@ public class GraphsonUtilTest {
v.setProperty("keyDoubleArray", doubleArray);
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.NORMAL);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.NORMAL);
assertThat(json).isNotNull();
assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
@@ -350,7 +350,7 @@ public class GraphsonUtilTest {
v.setProperty("keyIntArray", intArray);
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.NORMAL);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.NORMAL);
assertThat(json).isNotNull();
assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
@@ -368,7 +368,7 @@ public class GraphsonUtilTest {
v.setProperty("keyLongArray", longArray);
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.NORMAL);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.NORMAL);
assertThat(json).isNotNull();
assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
@@ -386,7 +386,7 @@ public class GraphsonUtilTest {
v.setProperty("keyFloatArray", floatArray);
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.NORMAL);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.NORMAL);
assertThat(json).isNotNull();
assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
@@ -404,7 +404,7 @@ public class GraphsonUtilTest {
v.setProperty("keyBooleanArray", booleanArray);
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.NORMAL);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.NORMAL);
assertThat(json).isNotNull();
assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
@@ -420,7 +420,7 @@ public class GraphsonUtilTest {
Vertex v = this.graph.addVertex(1);
v.setProperty("mycat", new Cat("smithers"));
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.NORMAL);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.NORMAL);
assertThat(json).isNotNull();
assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
@@ -433,7 +433,7 @@ public class GraphsonUtilTest {
Vertex v = this.graph.addVertex(1);
v.setProperty("mycat", new Cat("smithers"));
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.EXTENDED);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.EXTENDED);
assertThat(json).isNotNull();
assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
@@ -453,7 +453,7 @@ public class GraphsonUtilTest {
v.setProperty("cats", cats);
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.NORMAL);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.NORMAL);
assertThat(json).isNotNull();
assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
@@ -489,7 +489,7 @@ public class GraphsonUtilTest {
v.setProperty("crazy-map", map);
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.NORMAL);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.NORMAL);
assertThat(json).isNotNull();
assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
@@ -523,7 +523,7 @@ public class GraphsonUtilTest {
Set<String> propertiesToInclude = new HashSet<String>();
propertiesToInclude.add("y");
- JSONObject json = GraphsonUtil.jsonFromElement(v, propertiesToInclude, GraphSONMode.NORMAL);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, propertiesToInclude, GraphonMode.NORMAL);
assertThat(json).isNotNull();
assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
@@ -551,7 +551,7 @@ public class GraphsonUtilTest {
propertiesToInclude.add("y");
propertiesToInclude.add("v");
- JSONObject json = GraphsonUtil.jsonFromElement(v, propertiesToInclude, GraphSONMode.NORMAL);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, propertiesToInclude, GraphonMode.NORMAL);
assertThat(json).isNotNull();
assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
@@ -578,7 +578,7 @@ public class GraphsonUtilTest {
v.setProperty("keyDouble", 4.4);
v.setProperty("keyBoolean", true);
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.EXTENDED);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.EXTENDED);
assertThat(json).isNotNull();
assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
@@ -631,7 +631,7 @@ public class GraphsonUtilTest {
v.setProperty("keyList", list);
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.EXTENDED);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.EXTENDED);
assertThat(json).isNotNull();
assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
@@ -666,7 +666,7 @@ public class GraphsonUtilTest {
v.setProperty("keyList", list);
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.EXTENDED);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.EXTENDED);
assertThat(json).isNotNull();
assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
@@ -701,7 +701,7 @@ public class GraphsonUtilTest {
v.setProperty("keyList", list);
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.EXTENDED);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.EXTENDED);
assertThat(json).isNotNull();
assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
@@ -736,7 +736,7 @@ public class GraphsonUtilTest {
v.setProperty("keyList", list);
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.EXTENDED);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.EXTENDED);
assertThat(json).isNotNull();
assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
@@ -774,7 +774,7 @@ public class GraphsonUtilTest {
v.setProperty("keyList", listList);
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.EXTENDED);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.EXTENDED);
assertThat(json).isNotNull();
assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
@@ -811,7 +811,7 @@ public class GraphsonUtilTest {
v.setProperty("keyMap", map);
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.EXTENDED);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.EXTENDED);
assertThat(json).isNotNull();
assertThat(json.get(GraphSONTokens._ID)).isEqualTo("1");
@@ -861,7 +861,7 @@ public class GraphsonUtilTest {
list.add("string");
v.setProperty("keyList", list);
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.NORMAL);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.NORMAL);
assertThat(json).isNotNull();
assertThat(json.get("key")).isNull();
@@ -903,7 +903,7 @@ public class GraphsonUtilTest {
list.add("string");
v.setProperty("keyList", list);
- JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphSONMode.EXTENDED);
+ JSONObject json = GraphsonUtil.jsonFromElement(v, null, GraphonMode.EXTENDED);
assertThat(json).isNotNull();
@@ -938,7 +938,7 @@ public class GraphsonUtilTest {
Graph g = new TinkerGraph();
ElementFactory factory = new ElementFactory(g);
- Vertex v = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson1), factory, GraphSONMode.NORMAL, null);
+ Vertex v = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson1), factory, GraphonMode.NORMAL, null);
assertThat(v).isSameAs(g.getVertex(1));
@@ -953,7 +953,7 @@ public class GraphsonUtilTest {
Graph g = new TinkerGraph();
ElementFactory factory = new ElementFactory(g);
- Vertex v = GraphsonUtil.vertexFromJson(vertexJson1, factory, GraphSONMode.NORMAL, null);
+ Vertex v = GraphsonUtil.vertexFromJson(vertexJson1, factory, GraphonMode.NORMAL, null);
assertThat(v).isSameAs(g.getVertex(1));
@@ -969,7 +969,7 @@ public class GraphsonUtilTest {
ElementFactory factory = new ElementFactory(g);
String vertexJson = "{\"person\":{\"value\":\"marko\",\"type\":\"string\"},\"_id\":1,\"_type\":\"vertex\"}";
- Vertex v = GraphsonUtil.vertexFromJson(vertexJson, factory, GraphSONMode.EXTENDED, null);
+ Vertex v = GraphsonUtil.vertexFromJson(vertexJson, factory, GraphonMode.EXTENDED, null);
Assert.assertSame(v, g.getVertex(1));
@@ -983,7 +983,7 @@ public class GraphsonUtilTest {
Graph g = new TinkerGraph();
ElementFactory factory = new ElementFactory(g);
- Vertex v = GraphsonUtil.vertexFromJson(inputStreamVertexJson1, factory, GraphSONMode.NORMAL, null);
+ Vertex v = GraphsonUtil.vertexFromJson(inputStreamVertexJson1, factory, GraphonMode.NORMAL, null);
Assert.assertSame(v, g.getVertex(1));
@@ -1001,7 +1001,7 @@ public class GraphsonUtilTest {
Set<String> ignoreAge = new HashSet<String>();
ignoreAge.add("age");
ElementPropertyConfig config = ElementPropertyConfig.excludeProperties(ignoreAge, null);
- GraphsonUtil utility = new GraphsonUtil(GraphSONMode.NORMAL, factory, config);
+ GraphsonUtil utility = new GraphsonUtil(GraphonMode.NORMAL, factory, config);
Vertex v = utility.vertexFromJson((JSONObject) JSONValue.parse(vertexJson1));
Assert.assertSame(v, g.getVertex(1));
@@ -1017,9 +1017,9 @@ public class GraphsonUtilTest {
Graph g = new TinkerGraph();
ElementFactory factory = new ElementFactory(g);
- Vertex v1 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson1), factory, GraphSONMode.NORMAL, null);
- Vertex v2 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson2), factory, GraphSONMode.NORMAL, null);
- Edge e = GraphsonUtil.edgeFromJson((JSONObject) JSONValue.parse(edgeJson), v1, v2, factory, GraphSONMode.NORMAL, null);
+ Vertex v1 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson1), factory, GraphonMode.NORMAL, null);
+ Vertex v2 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson2), factory, GraphonMode.NORMAL, null);
+ Edge e = GraphsonUtil.edgeFromJson((JSONObject) JSONValue.parse(edgeJson), v1, v2, factory, GraphonMode.NORMAL, null);
Assert.assertSame(v1, g.getVertex(1));
Assert.assertSame(v2, g.getVertex(2));
@@ -1038,9 +1038,9 @@ public class GraphsonUtilTest {
Graph g = new TinkerGraph();
ElementFactory factory = new ElementFactory(g);
- Vertex v1 = GraphsonUtil.vertexFromJson(vertexJson1, factory, GraphSONMode.NORMAL, null);
- Vertex v2 = GraphsonUtil.vertexFromJson(vertexJson2, factory, GraphSONMode.NORMAL, null);
- Edge e = GraphsonUtil.edgeFromJson(edgeJson, v1, v2, factory, GraphSONMode.NORMAL, null);
+ Vertex v1 = GraphsonUtil.vertexFromJson(vertexJson1, factory, GraphonMode.NORMAL, null);
+ Vertex v2 = GraphsonUtil.vertexFromJson(vertexJson2, factory, GraphonMode.NORMAL, null);
+ Edge e = GraphsonUtil.edgeFromJson(edgeJson, v1, v2, factory, GraphonMode.NORMAL, null);
Assert.assertSame(v1, g.getVertex(1));
Assert.assertSame(v2, g.getVertex(2));
@@ -1059,13 +1059,13 @@ public class GraphsonUtilTest {
Graph g = new TinkerGraph();
ElementFactory factory = new ElementFactory(g);
- Vertex v1 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson1), factory, GraphSONMode.NORMAL, null);
- Vertex v2 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson2), factory, GraphSONMode.NORMAL, null);
+ Vertex v1 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson1), factory, GraphonMode.NORMAL, null);
+ Vertex v2 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson2), factory, GraphonMode.NORMAL, null);
Set<String> ignoreWeight = new HashSet<String>();
ignoreWeight.add("weight");
ElementPropertyConfig config = ElementPropertyConfig.excludeProperties(null, ignoreWeight);
- GraphsonUtil utility = new GraphsonUtil(GraphSONMode.NORMAL, factory, config);
+ GraphsonUtil utility = new GraphsonUtil(GraphonMode.NORMAL, factory, config);
Edge e = utility.edgeFromJson((JSONObject) JSONValue.parse(edgeJson), v1, v2);
Assert.assertSame(v1, g.getVertex(1));
@@ -1085,9 +1085,9 @@ public class GraphsonUtilTest {
Graph g = new TinkerGraph();
ElementFactory factory = new ElementFactory(g);
- Vertex v1 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson1), factory, GraphSONMode.NORMAL, null);
- Vertex v2 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson2), factory, GraphSONMode.NORMAL, null);
- Edge e = GraphsonUtil.edgeFromJson((JSONObject) JSONValue.parse(edgeJsonLight), v1, v2, factory, GraphSONMode.NORMAL, null);
+ Vertex v1 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson1), factory, GraphonMode.NORMAL, null);
+ Vertex v2 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson2), factory, GraphonMode.NORMAL, null);
+ Edge e = GraphsonUtil.edgeFromJson((JSONObject) JSONValue.parse(edgeJsonLight), v1, v2, factory, GraphonMode.NORMAL, null);
Assert.assertSame(v1, g.getVertex(1));
Assert.assertSame(v2, g.getVertex(2));
@@ -1099,9 +1099,9 @@ public class GraphsonUtilTest {
Graph g = new TinkerGraph();
ElementFactory factory = new ElementFactory(g);
- Vertex v1 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson1), factory, GraphSONMode.COMPACT, null);
- Vertex v2 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson2), factory, GraphSONMode.COMPACT, null);
- Edge e = GraphsonUtil.edgeFromJson(inputStreamEdgeJsonLight, v1, v2, factory, GraphSONMode.COMPACT, null);
+ Vertex v1 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson1), factory, GraphonMode.COMPACT, null);
+ Vertex v2 = GraphsonUtil.vertexFromJson((JSONObject) JSONValue.parse(vertexJson2), factory, GraphonMode.COMPACT, null);
+ Edge e = GraphsonUtil.edgeFromJson(inputStreamEdgeJsonLight, v1, v2, factory, GraphonMode.COMPACT, null);
Assert.assertSame(v1, g.getVertex(1));
Assert.assertSame(v2, g.getVertex(2));
@@ -1121,7 +1121,7 @@ public class GraphsonUtilTest {
add(GraphSONTokens._IN_V);
}};
- GraphsonUtil graphson = new GraphsonUtil(GraphSONMode.COMPACT, factory, vertexKeys, edgeKeys);
+ GraphsonUtil graphson = new GraphsonUtil(GraphonMode.COMPACT, factory, vertexKeys, edgeKeys);
Vertex v1 = graphson.vertexFromJson((JSONObject) JSONValue.parse(vertexJson1));
Vertex v2 = graphson.vertexFromJson((JSONObject) JSONValue.parse(vertexJson2));
diff --git a/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonWriterTest.java b/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonWriterTest.java
index 54551df7f1d..77a7c2b1e45 100644
--- a/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonWriterTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/graph/graphson/GraphsonWriterTest.java
@@ -38,8 +38,8 @@ public class GraphsonWriterTest {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
- GraphSONWriter writer = new GraphSONWriter();
- writer.write(g, stream, GraphSONMode.NORMAL);
+ GraphonWriter writer = new GraphonWriter();
+ writer.write(g, stream, GraphonMode.NORMAL);
stream.flush();
stream.close();
@@ -51,17 +51,17 @@ public class GraphsonWriterTest {
// ensure that the JSON conforms to basic structure and that the right
// number of graph elements are present. other tests already cover element formatting
assertThat(rootNode).isNotNull();
- assertThat(rootNode.containsKey(GraphSONTokens.MODE)).isTrue();
- assertThat(rootNode.get(GraphSONTokens.MODE)).isEqualTo("NORMAL");
+ assertThat(rootNode.containsKey(GraphonTokens.MODE)).isTrue();
+ assertThat(rootNode.get(GraphonTokens.MODE)).isEqualTo("NORMAL");
- assertThat(rootNode.containsKey(GraphSONTokens.VERTICES)).isTrue();
+ assertThat(rootNode.containsKey(GraphonTokens.VERTICES)).isTrue();
- JSONArray vertices = (JSONArray) rootNode.get(GraphSONTokens.VERTICES);
+ JSONArray vertices = (JSONArray) rootNode.get(GraphonTokens.VERTICES);
assertThat(vertices).hasSize(6);
- assertThat(rootNode.containsKey(GraphSONTokens.EDGES)).isTrue();
+ assertThat(rootNode.containsKey(GraphonTokens.EDGES)).isTrue();
- JSONArray edges = (JSONArray) rootNode.get(GraphSONTokens.EDGES);
+ JSONArray edges = (JSONArray) rootNode.get(GraphonTokens.EDGES);
assertThat(edges).hasSize(6);
}
@@ -71,8 +71,8 @@ public class GraphsonWriterTest {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
- GraphSONWriter writer = new GraphSONWriter();
- writer.write(g, stream, GraphSONMode.EXTENDED);
+ GraphonWriter writer = new GraphonWriter();
+ writer.write(g, stream, GraphonMode.EXTENDED);
stream.flush();
stream.close();
@@ -84,17 +84,17 @@ public class GraphsonWriterTest {
// ensure that the JSON conforms to basic structure and that the right
// number of graph elements are present. other tests already cover element formatting
assertThat(rootNode).isNotNull();
- assertThat(rootNode.containsKey(GraphSONTokens.MODE)).isTrue();
- assertThat(rootNode.get(GraphSONTokens.MODE)).isEqualTo("EXTENDED");
+ assertThat(rootNode.containsKey(GraphonTokens.MODE)).isTrue();
+ assertThat(rootNode.get(GraphonTokens.MODE)).isEqualTo("EXTENDED");
- assertThat(rootNode.containsKey(GraphSONTokens.VERTICES)).isTrue();
+ assertThat(rootNode.containsKey(GraphonTokens.VERTICES)).isTrue();
- JSONArray vertices = (JSONArray) rootNode.get(GraphSONTokens.VERTICES);
+ JSONArray vertices = (JSONArray) rootNode.get(GraphonTokens.VERTICES);
assertThat(vertices).hasSize(6);
- assertThat(rootNode.containsKey(GraphSONTokens.EDGES)).isTrue();
+ assertThat(rootNode.containsKey(GraphonTokens.EDGES)).isTrue();
- JSONArray edges = (JSONArray) rootNode.get(GraphSONTokens.EDGES);
+ JSONArray edges = (JSONArray) rootNode.get(GraphonTokens.EDGES);
assertThat(edges).hasSize(6);
}
@@ -104,8 +104,8 @@ public class GraphsonWriterTest {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
- GraphSONWriter writer = new GraphSONWriter();
- writer.write(g, stream, GraphSONMode.COMPACT);
+ GraphonWriter writer = new GraphonWriter();
+ writer.write(g, stream, GraphonMode.COMPACT);
stream.flush();
stream.close();
@@ -117,17 +117,17 @@ public class GraphsonWriterTest {
// ensure that the JSON conforms to basic structure and that the right
// number of graph elements are present. other tests already cover element formatting
assertThat(rootNode).isNotNull();
- assertThat(rootNode.containsKey(GraphSONTokens.MODE)).isTrue();
- assertThat(rootNode.get(GraphSONTokens.MODE)).isEqualTo("COMPACT");
+ assertThat(rootNode.containsKey(GraphonTokens.MODE)).isTrue();
+ assertThat(rootNode.get(GraphonTokens.MODE)).isEqualTo("COMPACT");
- assertThat(rootNode.containsKey(GraphSONTokens.VERTICES)).isTrue();
+ assertThat(rootNode.containsKey(GraphonTokens.VERTICES)).isTrue();
- JSONArray vertices = (JSONArray) rootNode.get(GraphSONTokens.VERTICES);
+ JSONArray vertices = (JSONArray) rootNode.get(GraphonTokens.VERTICES);
assertThat(vertices).hasSize(6);
- assertThat(rootNode.containsKey(GraphSONTokens.EDGES)).isTrue();
+ assertThat(rootNode.containsKey(GraphonTokens.EDGES)).isTrue();
- JSONArray edges = (JSONArray) rootNode.get(GraphSONTokens.EDGES);
+ JSONArray edges = (JSONArray) rootNode.get(GraphonTokens.EDGES);
assertThat(edges).hasSize(6);
}
}