Search in sources :

Example 11 with IMetaverseLink

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());
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) IMetaverseLink(org.pentaho.metaverse.api.IMetaverseLink) Test(org.junit.Test)

Example 12 with IMetaverseLink

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);
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) IMetaverseLink(org.pentaho.metaverse.api.IMetaverseLink) Test(org.junit.Test)

Aggregations

IMetaverseLink (org.pentaho.metaverse.api.IMetaverseLink)12 Vertex (com.tinkerpop.blueprints.Vertex)8 Test (org.junit.Test)8 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)5 Edge (com.tinkerpop.blueprints.Edge)3 MetaverseLink (org.pentaho.dictionary.MetaverseLink)2 Direction (com.tinkerpop.blueprints.Direction)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Date (java.util.Date)1 KettleException (org.pentaho.di.core.exception.KettleException)1 UnknownParamException (org.pentaho.di.core.parameters.UnknownParamException)1 Trans (org.pentaho.di.trans.Trans)1 TransHopMeta (org.pentaho.di.trans.TransHopMeta)1 TransMeta (org.pentaho.di.trans.TransMeta)1 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)1 StepMeta (org.pentaho.di.trans.step.StepMeta)1 GenericStepMetaAnalyzer (org.pentaho.metaverse.analyzer.kettle.step.GenericStepMetaAnalyzer)1 IComponentDescriptor (org.pentaho.metaverse.api.IComponentDescriptor)1 INamespace (org.pentaho.metaverse.api.INamespace)1 MetaverseAnalyzerException (org.pentaho.metaverse.api.MetaverseAnalyzerException)1