use of org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord in project pentaho-metaverse by pentaho.
the class StepAnalyzerTest method testGetChanges_noPassthroughs.
@Test
public void testGetChanges_noPassthroughs() throws Exception {
ComponentDerivationRecord change1 = mock(ComponentDerivationRecord.class);
ComponentDerivationRecord change2 = mock(ComponentDerivationRecord.class);
ComponentDerivationRecord change3 = mock(ComponentDerivationRecord.class);
Set<ComponentDerivationRecord> changeRecords = new HashSet<>();
changeRecords.add(change1);
changeRecords.add(change2);
changeRecords.add(change3);
doReturn(changeRecords).when(analyzer).getChangeRecords(baseStepMeta);
doReturn(null).when(analyzer).getPassthroughChanges();
Set<ComponentDerivationRecord> changes = analyzer.getChanges();
assertTrue(CollectionUtils.isNotEmpty(changes));
assertEquals(3, changes.size());
}
use of org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord 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.analyzer.kettle.ComponentDerivationRecord in project pentaho-kettle by pentaho.
the class GetXMLDataStepAnalyzer method getChangeRecords.
@Override
public Set<ComponentDerivationRecord> getChangeRecords(GetXMLDataMeta meta) throws MetaverseAnalyzerException {
Set<ComponentDerivationRecord> changes = new HashSet<>();
boolean isInFields = meta.isInFields();
boolean isAFile = meta.getIsAFile();
boolean isAUrl = meta.isReadUrl();
// if we are getting xml from a field, we need to add the "derives" links from the xml to the output fields
if (isInFields && !isAFile && !isAUrl) {
GetXMLDataField[] fields = baseStepMeta.getInputFields();
if (getInputs() != null) {
Set<StepField> inputFields = getInputs().getFieldNames();
for (StepField inputField : inputFields) {
if (inputField.getFieldName().equals(meta.getXMLField())) {
// link this to all of the outputs that come from the xml
for (GetXMLDataField field : fields) {
ComponentDerivationRecord change = new ComponentDerivationRecord(meta.getXMLField(), field.getName());
changes.add(change);
}
break;
}
}
}
}
return changes;
}
Aggregations