use of org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes in project pentaho-metaverse by pentaho.
the class MergeJoinStepAnalyzerTest method setUp.
@Before
public void setUp() throws Exception {
when(mergeJoinMeta.getParentStepMeta()).thenReturn(parentStepMeta);
when(parentStepMeta.getParentTransMeta()).thenReturn(parentTransMeta);
analyzer = spy(new MergeJoinStepAnalyzer());
analyzer.setParentStepMeta(parentStepMeta);
analyzer.setParentTransMeta(parentTransMeta);
analyzer.setMetaverseBuilder(builder);
inputs = new StepNodes();
inputs.addNode("leftStep", "Country", mockFieldNode);
inputs.addNode("leftStep", "State", mockFieldNode);
inputs.addNode("rightStep", "CTR", mockFieldNode);
inputs.addNode("rightStep", "ST", mockFieldNode);
when(analyzer.getInputs()).thenReturn(inputs);
fields1 = inputs.getFieldNames("leftStep").toArray(new String[] {});
fields2 = inputs.getFieldNames("rightStep").toArray(new String[] {});
// add some more fields that won't be part of the join keys
inputs.addNode("leftStep", "value", mockFieldNode);
inputs.addNode("rightStep", "value", mockFieldNode);
when(parentTransMeta.getPrevStepNames(analyzer.getStepName())).thenReturn(inputs.getStepNames().toArray(new String[] {}));
when(mergeJoinMeta.getKeyFields1()).thenReturn(fields1);
when(mergeJoinMeta.getKeyFields2()).thenReturn(fields2);
outputs = new StepNodes();
outputs.addNode("out", "Country", mockFieldNode);
outputs.addNode("out", "State", mockFieldNode);
outputs.addNode("out", "CTR", mockFieldNode);
outputs.addNode("out", "ST", mockFieldNode);
outputs.addNode("out", "value", mockFieldNode);
outputs.addNode("out", "value_1", mockFieldNode);
when(analyzer.getOutputs()).thenReturn(outputs);
}
use of org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes in project pentaho-metaverse by pentaho.
the class SelectValuesStepAnalyzerTest method setUp.
@Before
public void setUp() throws Exception {
analyzer = spy(new SelectValuesStepAnalyzer());
analyzer.setParentTransMeta(parentTransMeta);
analyzer.setBaseStepMeta(selectValuesMeta);
doNothing().when(analyzer).validateState(null, selectValuesMeta);
prevFields = new HashMap<>();
prevFields.put("previousStep", rmi);
doReturn(prevFields).when(analyzer).getInputFields(selectValuesMeta);
doReturn("select values").when(analyzer).getStepName();
when(parentTransMeta.getPrevStepNames(analyzer.getStepName())).thenReturn(new String[] { "previousStep" });
inputs = new StepNodes();
inputs.addNode("previousStep", "first", node);
inputs.addNode("previousStep", "last", node);
inputs.addNode("previousStep", "age", node);
inputs.addNode("previousStep", "birthday", node);
doReturn(inputs).when(analyzer).getInputs();
testChange1 = new SelectMetadataChange(selectValuesMeta);
testChange1.setName("first");
testChange1.setCurrencySymbol("~");
testChange1.setStorageType(ValueMetaInterface.STORAGE_TYPE_BINARY_STRING);
testChange1.setDateFormatLocale("en_UK");
testChange1.setGroupingSymbol("...");
testChange2 = new SelectMetadataChange(selectValuesMeta);
testChange2.setName("last");
testChange2.setRename("last name");
testChange2.setDateFormatLenient(true);
testChange2.setConversionMask("##.#");
testChange2.setDateFormatTimeZone("YYYY-MM-DD");
testChange2.setDecimalSymbol(",");
}
use of org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes in project pentaho-metaverse by pentaho.
the class StringsReplaceStepAnalyzerTest method setUp.
@Before
public void setUp() throws Exception {
when(stringsReplaceMeta.getFieldInStream()).thenReturn(new String[] { "firstName", "middleName", "lastName" });
when(stringsReplaceMeta.getFieldOutStream()).thenReturn(new String[] { "", "MN", "lastName" });
when(stringsReplaceMeta.getFieldReplaceByString()).thenReturn(new String[] { "Tom", "Dick", "Harry" });
when(stringsReplaceMeta.getReplaceString()).thenReturn(new String[] { "Bill", "Steve", "Jeff" });
analyzer = spy(new StringsReplaceStepAnalyzer());
stepFields = new HashSet<>();
stepFields.add(new StepField("prev", "firstName"));
stepFields.add(new StepField("prev", "middleName"));
stepFields.add(new StepField("prev", "lastName"));
StepNodes stepNodes = mock(StepNodes.class);
when(stepNodes.findNodes(anyString())).thenAnswer(new Answer<List<IMetaverseNode>>() {
@Override
public List<IMetaverseNode> answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
List<IMetaverseNode> foundNodes = new ArrayList<>();
String fieldName = (String) args[0];
if (fieldName.equals("firstName") || fieldName.equals("middleName") || fieldName.equals("lastName")) {
foundNodes.add(mock(IMetaverseNode.class));
}
return foundNodes;
}
});
when(analyzer.getInputs()).thenReturn(stepNodes);
doReturn(stepFields).when(analyzer).createStepFields(anyString(), any(StepNodes.class));
// Call customAnalyze() for coverage, it does nothing
analyzer.customAnalyze(stringsReplaceMeta, mock(IMetaverseNode.class));
}
use of org.pentaho.metaverse.api.analyzer.kettle.step.StepNodes 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.analyzer.kettle.step.StepNodes 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);
}
Aggregations