Search in sources :

Example 36 with IMetaverseNode

use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.

the class TransExecutorStepAnalyzerTest method testConnectUsedFieldToSubTrans_noChildTransSteps.

@Test
public void testConnectUsedFieldToSubTrans_noChildTransSteps() throws Exception {
    IMetaverseNode childTransNode = mock(IMetaverseNode.class);
    IMetaverseNode rootNode = mock(IMetaverseNode.class);
    when(childTransMeta.getSteps()).thenReturn(null);
    spyAnalyzer.linkUsedFieldToSubTrans(rootNode, childTransMeta, childTransNode, descriptor);
    verify(spyAnalyzer, never()).createFieldNode(any(IComponentDescriptor.class), any(ValueMetaInterface.class), anyString(), eq(false));
    verify(builder, never()).addLink(any(IMetaverseNode.class), eq(DictionaryConst.LINK_DERIVES), any(IMetaverseNode.class));
}
Also used : IComponentDescriptor(org.pentaho.metaverse.api.IComponentDescriptor) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Example 37 with IMetaverseNode

use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.

the class TransExecutorStepAnalyzerTest method testConnectToSubTransOutputFields_MainOutput.

@Test
public void testConnectToSubTransOutputFields_MainOutput() throws Exception {
    when(meta.getOutputRowsSourceStep()).thenReturn(null);
    when(meta.getExecutorsOutputStep()).thenReturn("outputRowsStepName");
    String[] outputFields = new String[] { "first", "last" };
    when(meta.getOutputRowsField()).thenReturn(outputFields);
    IMetaverseNode outNode = mock(IMetaverseNode.class);
    StepNodes outputs = new StepNodes();
    outputs.addNode("outputRowsStepName", "first", outNode);
    outputs.addNode("outputRowsStepName", "last", outNode);
    doReturn(outputs).when(spyAnalyzer).getOutputs();
    // we'll test this in it's own test
    doNothing().when(spyAnalyzer).linkResultFieldToSubTrans(any(IMetaverseNode.class), any(TransMeta.class), any(IMetaverseNode.class), any(IComponentDescriptor.class));
    IMetaverseNode childTransNode = mock(IMetaverseNode.class);
    spyAnalyzer.connectToSubTransOutputFields(meta, childTransMeta, childTransNode, descriptor);
    verify(spyAnalyzer, times(outputFields.length)).linkResultFieldToSubTrans(any(IMetaverseNode.class), any(TransMeta.class), any(IMetaverseNode.class), any(IComponentDescriptor.class));
}
Also used : IComponentDescriptor(org.pentaho.metaverse.api.IComponentDescriptor) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) TransMeta(org.pentaho.di.trans.TransMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) Matchers.anyString(org.mockito.Matchers.anyString) StepNodes(org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes) Test(org.junit.Test)

Example 38 with IMetaverseNode

use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.

the class BlueprintsGraphMetaverseReaderTest method testFindNodes.

@Test
public void testFindNodes() throws Exception {
    IMetaverseReader metaverseReader = new BlueprintsGraphMetaverseReader(graph);
    List<IMetaverseNode> nodes = metaverseReader.findNodes(DictionaryConst.PROPERTY_TYPE, DictionaryConst.NODE_TYPE_DATA_COLUMN);
    assertNotNull("Node is null", nodes);
    assertEquals("Node count is wrong", 7, nodes.size());
    Set<String> ids = new HashSet<String>();
    for (IMetaverseNode node : nodes) {
        ids.add(node.getStringID());
    }
    assertTrue("Id is missing", ids.contains("datasource1.table1.field1"));
    assertTrue("Id is missing", ids.contains("datasource1.table1.field2"));
    assertTrue("Id is missing", ids.contains("datasource1.table1.field3"));
    assertTrue("Id is missing", ids.contains("datasource1.table2.field1"));
    assertTrue("Id is missing", ids.contains("datasource1.table2.field2"));
    assertTrue("Id is missing", ids.contains("datasource1.table2.field3"));
    assertTrue("Id is missing", ids.contains("datasource1.table2.field4"));
    nodes = metaverseReader.findNodes(DictionaryConst.PROPERTY_NAME, "Transformation: trans1.ktr");
    assertNotNull("Node is null", nodes);
    assertEquals("Node count is wrong", 1, nodes.size());
    assertEquals("Id is missing", "Transformation: trans1.ktr", nodes.get(0).getProperty(DictionaryConst.PROPERTY_NAME));
}
Also used : IMetaverseReader(org.pentaho.metaverse.api.IMetaverseReader) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 39 with IMetaverseNode

use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.

the class MetaverseBuilderTest method testIsVirtual.

@Test
public void testIsVirtual() {
    builder.addNode(node);
    Vertex v = graph.getVertex(node.getStringID());
    assertFalse(builder.isVirtual(v));
    IMetaverseNode virtual = builder.createNodeObject("virtual node");
    Vertex virtualVertex = graph.addVertex(virtual.getStringID());
    virtualVertex.setProperty(DictionaryConst.NODE_VIRTUAL, virtual.getProperty(DictionaryConst.NODE_VIRTUAL));
    assertTrue(builder.isVirtual(virtualVertex));
    assertFalse(builder.isVirtual(null));
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) Test(org.junit.Test)

Example 40 with IMetaverseNode

use of org.pentaho.metaverse.api.IMetaverseNode in project pentaho-metaverse by pentaho.

the class MetaverseBuilderTest method testUpdateNode.

@Test
public void testUpdateNode() {
    builder.addNode(node);
    Vertex v = graph.getVertex(node.getStringID());
    assertEquals(node.getName(), v.getProperty("name"));
    assertEquals(node.getStringID(), v.getId());
    IMetaverseNode updateNode = builder.createNodeObject(node.getStringID());
    updateNode.setName("UPDATED NAME");
    updateNode.setProperty("new prop", "test");
    updateNode.setType("new type");
    builder.updateNode(updateNode);
    v = graph.getVertex(node.getStringID());
    assertEquals(node.getStringID(), v.getId());
    assertEquals(updateNode.getStringID(), v.getId());
    assertEquals(updateNode.getName(), v.getProperty("name"));
    assertEquals("test", v.getProperty("new prop"));
    assertEquals(updateNode.getType(), v.getProperty("type"));
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) Test(org.junit.Test)

Aggregations

IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)131 Test (org.junit.Test)77 IComponentDescriptor (org.pentaho.metaverse.api.IComponentDescriptor)30 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)23 MetaverseComponentDescriptor (org.pentaho.metaverse.api.MetaverseComponentDescriptor)16 ValueMeta (org.pentaho.di.core.row.ValueMeta)13 IExternalResourceInfo (org.pentaho.metaverse.api.model.IExternalResourceInfo)12 IAnalysisContext (org.pentaho.metaverse.api.IAnalysisContext)11 MetaverseAnalyzerException (org.pentaho.metaverse.api.MetaverseAnalyzerException)11 Vertex (com.tinkerpop.blueprints.Vertex)10 ArrayList (java.util.ArrayList)10 INamespace (org.pentaho.metaverse.api.INamespace)10 TransMeta (org.pentaho.di.trans.TransMeta)9 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)9 MetaverseTransientNode (org.pentaho.dictionary.MetaverseTransientNode)9 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)8 Namespace (org.pentaho.metaverse.api.Namespace)8 StepField (org.pentaho.metaverse.api.StepField)8 HashMap (java.util.HashMap)7 Matchers.anyString (org.mockito.Matchers.anyString)7