Search in sources :

Example 96 with IMetaverseNode

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

the class TransExecutorStepAnalyzerTest method testConnectToSubTransOutputFields.

@Test
public void testConnectToSubTransOutputFields() throws Exception {
    when(meta.getOutputRowsSourceStep()).thenReturn("outputRowsStepName");
    when(meta.getExecutorsOutputStep()).thenReturn(null);
    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 97 with IMetaverseNode

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

the class TransExecutorStepAnalyzerTest method testGetUsedFields.

@Test
public void testGetUsedFields() throws Exception {
    IMetaverseNode outNode = mock(IMetaverseNode.class);
    StepNodes inputs = new StepNodes();
    inputs.addNode("previousStep", "one", outNode);
    inputs.addNode("previousStep", "two", outNode);
    doReturn(inputs).when(spyAnalyzer).getInputs();
    Set<StepField> usedFields = spyAnalyzer.getUsedFields(meta);
    assertEquals(inputs.getFieldNames(), usedFields);
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) StepField(org.pentaho.metaverse.api.StepField) StepNodes(org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes) Test(org.junit.Test)

Example 98 with IMetaverseNode

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

the class TransExecutorStepAnalyzerTest method testLinkResultFieldToSubTrans.

@Test
public void testLinkResultFieldToSubTrans() throws Exception {
    IMetaverseNode childTransNode = mock(IMetaverseNode.class);
    IMetaverseNode fieldNode = mock(IMetaverseNode.class);
    when(fieldNode.getName()).thenReturn(resultsFieldNames[1]);
    List<StepMeta> childTransSteps = new ArrayList<StepMeta>();
    StepMeta dummy = mock(StepMeta.class);
    when(dummy.getStepMetaInterface()).thenReturn(mock(DummyTransMeta.class));
    childTransSteps.add(dummy);
    StepMeta parentStepMeta = mock(StepMeta.class);
    when(parentStepMeta.getParentTransMeta()).thenReturn(parentTransMeta);
    StepMeta rowsFromResult = mock(StepMeta.class);
    RowsToResultMeta mockRowsToResultMeta = mock(RowsToResultMeta.class);
    when(rowsFromResult.getStepMetaInterface()).thenReturn(mockRowsToResultMeta);
    when(mockRowsToResultMeta.getParentStepMeta()).thenReturn(parentStepMeta);
    when(mockRowsToResultMeta.getName()).thenReturn("stepName");
    childTransSteps.add(rowsFromResult);
    RowMetaInterface rowMetaInterface = mock(RowMetaInterface.class);
    when(parentTransMeta.getStepFields(any(StepMeta.class))).thenReturn(rowMetaInterface);
    when(rowMetaInterface.getFieldNames()).thenReturn(resultsFieldNames);
    when(childTransMeta.getSteps()).thenReturn(childTransSteps);
    IMetaverseNode subFieldNode = mock(IMetaverseNode.class);
    doReturn(subFieldNode).when(spyAnalyzer).createFieldNode(any(IComponentDescriptor.class), any(ValueMetaInterface.class), eq(StepAnalyzer.NONE), eq(false));
    spyAnalyzer.linkResultFieldToSubTrans(fieldNode, childTransMeta, childTransNode, descriptor);
    verify(spyAnalyzer).createFieldNode(any(IComponentDescriptor.class), any(ValueMetaInterface.class), eq(StepAnalyzer.NONE), eq(false));
    verify(builder).addLink(eq(subFieldNode), eq(DictionaryConst.LINK_DERIVES), eq(fieldNode));
}
Also used : IComponentDescriptor(org.pentaho.metaverse.api.IComponentDescriptor) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) ArrayList(java.util.ArrayList) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) RowsToResultMeta(org.pentaho.di.trans.steps.rowstoresult.RowsToResultMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Example 99 with IMetaverseNode

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

the class TransExecutorStepAnalyzerTest method testConnectUsedFieldToSubTrans_noChildRowsFromResultStep.

@Test
public void testConnectUsedFieldToSubTrans_noChildRowsFromResultStep() throws Exception {
    IMetaverseNode childTransNode = mock(IMetaverseNode.class);
    IMetaverseNode rootNode = mock(IMetaverseNode.class);
    List<StepMeta> childTransSteps = new ArrayList<StepMeta>();
    StepMeta dummy = mock(StepMeta.class);
    when(dummy.getStepMetaInterface()).thenReturn(mock(DummyTransMeta.class));
    childTransSteps.add(dummy);
    when(childTransMeta.getSteps()).thenReturn(childTransSteps);
    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) ArrayList(java.util.ArrayList) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Example 100 with IMetaverseNode

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

the class TransExecutorStepAnalyzerTest method testConnectToSubTransInputFields_noPrevFields.

@Test
public void testConnectToSubTransInputFields_noPrevFields() throws Exception {
    IMetaverseNode childTransNode = mock(IMetaverseNode.class);
    StepNodes inputs = new StepNodes();
    doReturn(inputs).when(spyAnalyzer).getInputs();
    doNothing().when(spyAnalyzer).linkUsedFieldToSubTrans(any(IMetaverseNode.class), any(TransMeta.class), any(IMetaverseNode.class), any(IComponentDescriptor.class));
    spyAnalyzer.connectToSubTransInputFields(meta, childTransMeta, childTransNode, descriptor);
    verify(spyAnalyzer, never()).linkUsedFieldToSubTrans(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) StepNodes(org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes) 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