use of org.pentaho.metaverse.api.IMetaverseLink in project pentaho-metaverse by pentaho.
the class MetaverseBuilderTest method testUpdateLinkLabel.
@Test
public void testUpdateLinkLabel() {
IMetaverseLink link = createAndTestLink();
Vertex v = graph.getVertex(link.getFromNode().getStringID());
assertNotNull(v.getEdges(Direction.OUT, "uses"));
builder.updateLinkLabel(link, "owns");
assertEquals("owns", link.getLabel());
v = graph.getVertex(link.getFromNode().getStringID());
assertFalse(v.getEdges(Direction.OUT, "uses").iterator().hasNext());
assertTrue(v.getEdges(Direction.OUT, "owns").iterator().hasNext());
}
use of org.pentaho.metaverse.api.IMetaverseLink in project pentaho-metaverse by pentaho.
the class MetaverseBuilderTest method testDeleteLink_nonExistentFromNode.
@Test
public void testDeleteLink_nonExistentFromNode() {
IMetaverseLink link = createAndTestLink();
IMetaverseNode origFrom = link.getFromNode();
IMetaverseNode mockFrom = mock(IMetaverseNode.class);
link.setFromNode(mockFrom);
when(mockFrom.getStringID()).thenReturn("not in graph");
when(mockFrom.getLogicalId()).thenReturn("not in graph");
// now lets try to delete the link
builder.deleteLink(link);
Vertex fromResult = graph.getVertex(origFrom.getStringID());
Vertex toResult = graph.getVertex(link.getToNode().getStringID());
// the from node was explicitly added, it should still be there
assertNotNull(fromResult);
// the link should still be there
assertTrue(fromResult.getEdges(Direction.OUT, "uses").iterator().hasNext());
// should still be there
assertNotNull(toResult);
}
Aggregations