@Test public void testGraphToJson4() { Graph g = getGraph(); /* /-- V2 * V0(Integer)-- V1(Double)-- FanOut * \-- V3 */ Vertex<TestOp<String, Integer>, String, Integer> v0 = g.insert(new TestOp<>(), 1, 1); Connector<Integer> out0 = v0.getConnectors().get(0); Connector<Double> out1 = g.pipe(out0, new TestOp<Integer, Double>()); Vertex<TestOp<Double, String>, Double, String> v2 = g.insert(new TestOp<Double, String>(), 1, 1); Vertex<TestOp<Double, String>, Double, String> v3 = g.insert(new TestOp<Double, String>(), 1, 1); out1.connect(v2, 0); out1.connect(v3, 0); Gson gson = new GsonBuilder().setPrettyPrinting().create(); String json = gson.toJson(new GraphType(g)); GraphType gt2 = new Gson().fromJson(json, GraphType.class); assertEquals(5, gt2.getVertices().size()); assertEquals(4, gt2.getEdges().size()); }
@Test public void testGraphToJson2() { Graph g = getGraph(); TestOp<String, Integer> op1 = new TestOp<>(); Vertex<TestOp<String, Integer>, String, Integer> v = g.insert(op1, 1, 1); TestOp<Integer, Integer> op2 = new TestOp<>(); /*Connector<Integer> out2 = */ g.pipe(v.getConnectors().get(0), op2); Gson gson = new GsonBuilder().setPrettyPrinting().create(); String json = gson.toJson(new GraphType(g)); GraphType gt2 = new Gson().fromJson(json, GraphType.class); assertEquals(2, gt2.getVertices().size()); assertEquals(1, gt2.getEdges().size()); }