}
@Test
public void inputGraphModeCompact() throws IOException {
TinkerGraph graph = new TinkerGraph();
String json = "{ \"mode\":\"COMPACT\",\"vertices\": [ {\"_id\":1, \"test\": \"please work\", \"testlist\":[1, 2, 3, null], \"testmap\":{\"big\":10000000000, \"small\":0.4954959595959}}, {\"_id\":2, \"testagain\":\"please work again\"}], \"edges\":[{\"_id\":100, \"_outV\":1, \"_inV\":2, \"_label\":\"works\", \"teste\": \"please worke\"}]}";
byte[] bytes = json.getBytes();
InputStream inputStream = new ByteArrayInputStream(bytes);
GraphSONReader.inputGraph(graph, inputStream);
Assert.assertEquals(2, getIterableCount(graph.getVertices()));
Assert.assertEquals(1, getIterableCount(graph.getEdges()));
Vertex v1 = graph.getVertex(1);
Assert.assertNotNull(v1);
Assert.assertEquals("please work", v1.getProperty("test"));
Map map = (Map) v1.getProperty("testmap");
Assert.assertNotNull(map);
Assert.assertEquals(10000000000l, Long.parseLong(map.get("big").toString()));
Assert.assertEquals(0.4954959595959, Double.parseDouble(map.get("small").toString()), 0);
// Assert.assertNull(map.get("nullKey"));
List list = (List) v1.getProperty("testlist");
Assert.assertEquals(4, list.size());
boolean foundNull = false;
for (int ix = 0; ix < list.size(); ix++) {
if (list.get(ix) == null) {
foundNull = true;
break;
}
}
Assert.assertTrue(foundNull);
Vertex v2 = graph.getVertex(2);
Assert.assertNotNull(v2);
Assert.assertEquals("please work again", v2.getProperty("testagain"));
Edge e = graph.getEdge(100);
Assert.assertNotNull(e);
Assert.assertEquals("works", e.getLabel());
Assert.assertEquals(v1, e.getVertex(Direction.OUT));
Assert.assertEquals(v2, e.getVertex(Direction.IN));
Assert.assertEquals("please worke", e.getProperty("teste"));