use of org.pentaho.dictionary.MetaverseLink in project pentaho-metaverse by pentaho.
the class MetaverseBuilderTest method testAddLink_existingLink.
@Test
public void testAddLink_existingLink() throws Exception {
// Retain current number of edges
int originalEdgeCount = 0;
for (Edge e : graph.getEdges()) {
originalEdgeCount++;
}
MetaverseTransientNode node2 = new MetaverseTransientNode();
node2.setStringID("nodeToId");
node2.setName("to name");
MetaverseLink link = new MetaverseLink(node, "uses", node2);
builder.addLink(link);
Vertex fromResult = graph.getVertex(node.getStringID());
Vertex toResult = graph.getVertex(node2.getStringID());
// make sure the edge exits before we try to add it again
assertNotNull(graph.getEdge(builder.getEdgeId(fromResult, link.getLabel(), toResult)));
// make sure we only added 1
int count = 0;
for (Edge e : graph.getEdges()) {
count++;
}
assertEquals(originalEdgeCount + 1, count);
// now lets add it again
builder.addLink(link);
// make sure we still only have one edge
count = 0;
for (Edge e : graph.getEdges()) {
count++;
}
assertEquals(originalEdgeCount + 1, count);
}
Aggregations