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));
}
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);
}
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));
}
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));
}
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));
}
Aggregations