use of org.pentaho.di.core.row.ValueMeta in project pentaho-metaverse by pentaho.
the class StepAnalyzerTest method testCreateInputFieldNode.
@Test
public void testCreateInputFieldNode() 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 inputFieldNode = analyzer.createInputFieldNode(descriptor.getContext(), vmi, "thisStepName", DictionaryConst.NODE_TYPE_TRANS_FIELD);
assertNotNull(inputFieldNode);
assertNotNull(inputFieldNode.getProperty(DictionaryConst.PROPERTY_KETTLE_TYPE));
assertEquals("thisStepName", inputFieldNode.getProperty(DictionaryConst.PROPERTY_TARGET_STEP));
// the input node should not be added by this step
verify(builder, never()).addNode(inputFieldNode);
}
use of org.pentaho.di.core.row.ValueMeta in project pentaho-metaverse by pentaho.
the class StepAnalyzerTest method testCreateFieldNode_virtual.
@Test
public void testCreateFieldNode_virtual() 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, "nextStep", false);
assertNotNull(fieldNode);
assertNotNull(fieldNode.getProperty(DictionaryConst.PROPERTY_KETTLE_TYPE));
assertEquals("nextStep", fieldNode.getProperty(DictionaryConst.PROPERTY_TARGET_STEP));
// make sure it did not added to the graph
verify(builder, never()).addNode(node);
}
use of org.pentaho.di.core.row.ValueMeta 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.di.core.row.ValueMeta 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);
}
use of org.pentaho.di.core.row.ValueMeta in project pentaho-kettle by pentaho.
the class GetXMLDataStepAnalyzerTest method testCreateOutputFieldNode.
@Test
public void testCreateOutputFieldNode() throws Exception {
doReturn(builder).when(analyzer).getMetaverseBuilder();
analyzer.setBaseStepMeta(meta);
GetXMLDataField[] fields = new GetXMLDataField[2];
GetXMLDataField field1 = new GetXMLDataField("name");
GetXMLDataField field2 = new GetXMLDataField("age");
field1.setXPath("field1/xpath");
field2.setElementType(1);
field1.setResultType(1);
field2.setRepeated(true);
fields[0] = field1;
fields[1] = field2;
when(meta.getInputFields()).thenReturn(fields);
IAnalysisContext context = mock(IAnalysisContext.class);
doReturn("thisStepName").when(analyzer).getStepName();
when(node.getLogicalId()).thenReturn("logical id");
ValueMetaInterface vmi = new ValueMeta("name", 1);
IMetaverseNode outputFieldNode = analyzer.createOutputFieldNode(context, vmi, ExternalResourceStepAnalyzer.RESOURCE, DictionaryConst.NODE_TYPE_TRANS_FIELD);
assertNotNull(outputFieldNode);
assertNotNull(outputFieldNode.getProperty(DictionaryConst.PROPERTY_KETTLE_TYPE));
assertEquals(ExternalResourceStepAnalyzer.RESOURCE, outputFieldNode.getProperty(DictionaryConst.PROPERTY_TARGET_STEP));
assertEquals("field1/xpath", outputFieldNode.getProperty("xpath"));
assertNotNull(outputFieldNode.getProperty("resultType"));
assertNotNull(outputFieldNode.getProperty("element"));
assertEquals(false, outputFieldNode.getProperty("repeat"));
// the input node should be added by this step
verify(builder).addNode(outputFieldNode);
}
Aggregations