}
}
public void testCopyGraph() {
Graph g = TinkerGraphFactory.createTinkerGraph();
Graph h = new TinkerGraph();
GraphHelper.copyGraph(g, h);
assertEquals(count(h.getVertices()), 6);
assertEquals(count(h.getEdges()), 6);
assertEquals(count(h.getVertex("1").getEdges(Direction.OUT)), 3);
assertEquals(count(h.getVertex("1").getEdges(Direction.IN)), 0);
Vertex marko = h.getVertex("1");
assertEquals(marko.getProperty("name"), "marko");
assertEquals(marko.getProperty("age"), 29);
int counter = 0;
for (Edge e : h.getVertex("1").getEdges(Direction.OUT)) {
if (e.getVertex(Direction.IN).getId().equals("2")) {
assertEquals(e.getProperty("weight"), 0.5f);
assertEquals(e.getLabel(), "knows");
assertEquals(e.getId(), "7");
counter++;
} else if (e.getVertex(Direction.IN).getId().equals("3")) {
assertEquals(Math.round((Float) e.getProperty("weight")), 0);
assertEquals(e.getLabel(), "created");
assertEquals(e.getId(), "9");
counter++;
} else if (e.getVertex(Direction.IN).getId().equals("4")) {
assertEquals(Math.round((Float) e.getProperty("weight")), 1);
assertEquals(e.getLabel(), "knows");
assertEquals(e.getId(), "8");
counter++;
}
}
assertEquals(count(h.getVertex("4").getEdges(Direction.OUT)), 2);
assertEquals(count(h.getVertex("4").getEdges(Direction.IN)), 1);
Vertex josh = h.getVertex("4");
assertEquals(josh.getProperty("name"), "josh");
assertEquals(josh.getProperty("age"), 32);
for (Edge e : h.getVertex("4").getEdges(Direction.OUT)) {
if (e.getVertex(Direction.IN).getId().equals("3")) {
assertEquals(Math.round((Float) e.getProperty("weight")), 0);
assertEquals(e.getLabel(), "created");
assertEquals(e.getId(), "11");
counter++;