Search in sources :

Example 31 with ValueMeta

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);
}
Also used : IComponentDescriptor(org.pentaho.metaverse.api.IComponentDescriptor) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) MetaverseTransientNode(org.pentaho.dictionary.MetaverseTransientNode) ValueMeta(org.pentaho.di.core.row.ValueMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Example 32 with ValueMeta

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);
}
Also used : IComponentDescriptor(org.pentaho.metaverse.api.IComponentDescriptor) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) MetaverseTransientNode(org.pentaho.dictionary.MetaverseTransientNode) ValueMeta(org.pentaho.di.core.row.ValueMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Example 33 with ValueMeta

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);
}
Also used : IComponentDescriptor(org.pentaho.metaverse.api.IComponentDescriptor) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) MetaverseTransientNode(org.pentaho.dictionary.MetaverseTransientNode) ValueMeta(org.pentaho.di.core.row.ValueMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Example 34 with ValueMeta

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);
}
Also used : IComponentDescriptor(org.pentaho.metaverse.api.IComponentDescriptor) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) MetaverseTransientNode(org.pentaho.dictionary.MetaverseTransientNode) ValueMeta(org.pentaho.di.core.row.ValueMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Example 35 with ValueMeta

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);
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) IAnalysisContext(org.pentaho.metaverse.api.IAnalysisContext) ValueMeta(org.pentaho.di.core.row.ValueMeta) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Aggregations

ValueMeta (org.pentaho.di.core.row.ValueMeta)47 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)39 Test (org.junit.Test)18 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)14 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)13 RowMeta (org.pentaho.di.core.row.RowMeta)12 IAnalysisContext (org.pentaho.metaverse.api.IAnalysisContext)8 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)6 KettleValueException (org.pentaho.di.core.exception.KettleValueException)5 MetaverseTransientNode (org.pentaho.dictionary.MetaverseTransientNode)5 IComponentDescriptor (org.pentaho.metaverse.api.IComponentDescriptor)5 KettleException (org.pentaho.di.core.exception.KettleException)4 KettleStepException (org.pentaho.di.core.exception.KettleStepException)4 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)3 Matchers.anyString (org.mockito.Matchers.anyString)2 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)2 BatchUpdateException (java.sql.BatchUpdateException)1 Blob (java.sql.Blob)1 ResultSet (java.sql.ResultSet)1