use of org.pentaho.dictionary.MetaverseTransientNode in project pentaho-metaverse by pentaho.
the class StepAnalyzerTest method testCreateOutputFieldNode.
@Test
public void testCreateOutputFieldNode() throws Exception {
doReturn("thisStepName").when(analyzer).getStepName();
MetaverseTransientNode node = new MetaverseTransientNode("node id");
doReturn(node).when(analyzer).createNodeFromDescriptor(any(IComponentDescriptor.class));
ValueMetaInterface vmi = new ValueMeta("name", 1);
IMetaverseNode outputFieldNode = analyzer.createOutputFieldNode(descriptor.getContext(), vmi, "thisStepName", DictionaryConst.NODE_TYPE_TRANS_FIELD);
assertNotNull(outputFieldNode);
assertNotNull(outputFieldNode.getProperty(DictionaryConst.PROPERTY_KETTLE_TYPE));
assertEquals("thisStepName", outputFieldNode.getProperty(DictionaryConst.PROPERTY_TARGET_STEP));
// the input node should be added by this step
verify(builder).addNode(outputFieldNode);
}
use of org.pentaho.dictionary.MetaverseTransientNode 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.dictionary.MetaverseTransientNode in project pentaho-metaverse by pentaho.
the class StepAnalyzerTest method testCreateFieldNode_NoTargetStep.
@Test
public void testCreateFieldNode_NoTargetStep() throws Exception {
IComponentDescriptor fieldDescriptor = mock(IComponentDescriptor.class);
ValueMetaInterface fieldMeta = new ValueMeta("address");
MetaverseTransientNode node = new MetaverseTransientNode("hello");
doReturn(node).when(analyzer).createNodeFromDescriptor(fieldDescriptor);
IMetaverseNode fieldNode = analyzer.createFieldNode(fieldDescriptor, fieldMeta, null, true);
assertNotNull(fieldNode);
assertNotNull(fieldNode.getProperty(DictionaryConst.PROPERTY_KETTLE_TYPE));
assertNull(fieldNode.getProperty(DictionaryConst.PROPERTY_TARGET_STEP));
// make sure it did not added to the graph
verify(builder, never()).addNode(node);
}
Aggregations