use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.
the class StepAnalyzerTest method testMapChange_changedFieldIsTransient.
@Test
public void testMapChange_changedFieldIsTransient() throws Exception {
doReturn(outputs).when(analyzer).getOutputs();
doReturn(inputs).when(analyzer).getInputs();
IMetaverseNode transientNode = mock(IMetaverseNode.class);
String shouldBeNull = null;
doReturn(transientNode).when(analyzer).createOutputFieldNode(any(IAnalysisContext.class), any(ValueMetaInterface.class), eq(shouldBeNull), eq(DictionaryConst.NODE_TYPE_TRANS_FIELD));
// zip is not in the inputs or outputs, it must have been a temporary fields used internally by step.
StepField original = new StepField("nextStep", "address");
StepField changed = new StepField(null, "zip");
ComponentDerivationRecord cdr = new ComponentDerivationRecord(original, changed);
analyzer.mapChange(cdr);
verify(builder).addLink(rootNode, "transient", transientNode);
verify(analyzer).linkChangeNodes(any(IMetaverseNode.class), eq(transientNode));
}
use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.
the class StepAnalyzerTest method testCreateStepFields.
@Test
public void testCreateStepFields() throws Exception {
StepNodes stepNodes = new StepNodes();
IMetaverseNode node = mock(IMetaverseNode.class);
stepNodes.addNode("step1", "fieldname1", node);
stepNodes.addNode("step2", "fieldname2", node);
Set<StepField> test = analyzer.createStepFields("test", stepNodes);
assertEquals(2, test.size());
for (StepField stepField : test) {
assertEquals("test", stepField.getFieldName());
}
}
use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.
the class StepAnalyzerTest method testIsPassthrough.
@Test
public void testIsPassthrough() throws Exception {
doReturn(outputs).when(analyzer).getOutputs();
StepField testField = new StepField("previousStep2", "occupation");
assertTrue(analyzer.isPassthrough(testField));
}
use of org.pentaho.metaverse.api.StepField in project pentaho-metaverse by pentaho.
the class StepAnalyzerTest method testAnalyze.
@Test
public void testAnalyze() throws Exception {
when(baseStepMeta.getParentStepMeta()).thenReturn(parentStepMeta);
when(parentStepMeta.getCopies()).thenReturn(2);
analyzer.setMetaverseBuilder(builder);
doNothing().when(analyzer).validateState(descriptor, baseStepMeta);
doReturn(null).when(analyzer).processInputs(baseStepMeta);
doReturn(null).when(analyzer).processOutputs(baseStepMeta);
Set<StepField> usedFields = new HashSet<>();
usedFields.add(new StepField("inputStep", "name"));
doReturn(usedFields).when(analyzer).getUsedFields(baseStepMeta);
doNothing().when(analyzer).processUsedFields(usedFields);
Set<ComponentDerivationRecord> changeRecords = new HashSet<>();
changeRecords.add(mock(ComponentDerivationRecord.class));
changeRecords.add(mock(ComponentDerivationRecord.class));
doReturn(changeRecords).when(analyzer).getChanges();
doNothing().when(analyzer).mapChange(any(ComponentDerivationRecord.class));
MetaverseTransientNode node = new MetaverseTransientNode("hello");
doNothing().when(analyzer).customAnalyze(baseStepMeta, node);
when(parentStepMeta.getStepID()).thenReturn("step id");
doReturn(node).when(analyzer).createNodeFromDescriptor(descriptor);
IMetaverseNode analyzedNode = analyzer.analyze(descriptor, baseStepMeta);
assertNotNull(analyzedNode.getProperty("stepType"));
assertEquals(2, analyzedNode.getProperty("copies"));
assertEquals(analyzer.getClass().getSimpleName(), analyzedNode.getProperty("_analyzer"));
verify(builder).addNode(analyzedNode);
verify(analyzer).processInputs(baseStepMeta);
verify(analyzer).processOutputs(baseStepMeta);
verify(analyzer).getUsedFields(baseStepMeta);
verify(analyzer).processUsedFields(usedFields);
verify(analyzer).getChanges();
verify(analyzer, times(changeRecords.size())).mapChange(any(ComponentDerivationRecord.class));
verify(analyzer).customAnalyze(baseStepMeta, analyzedNode);
}
use of org.pentaho.metaverse.api.StepField in project pentaho-kettle by pentaho.
the class GetXMLDataStepAnalyzerTest method testGetUsedFields.
@Test
public void testGetUsedFields() throws Exception {
when(meta.isInFields()).thenReturn(true);
when(meta.getXMLField()).thenReturn("xml");
StepNodes inputs = new StepNodes();
inputs.addNode("previousStep", "xml", node);
inputs.addNode("previousStep", "otherField", node);
doReturn(inputs).when(analyzer).getInputs();
Set<StepField> usedFields = analyzer.getUsedFields(meta);
assertEquals(1, usedFields.size());
assertEquals("xml", usedFields.iterator().next().getFieldName());
}
Aggregations