Search in sources :

Example 6 with IAnalysisContext

use of org.pentaho.metaverse.api.IAnalysisContext in project pentaho-metaverse by pentaho.

the class ExternalResourceStepAnalyzerTest method testCreateOutputFieldNode.

@Test
public void testCreateOutputFieldNode() throws Exception {
    IAnalysisContext context = mock(IAnalysisContext.class);
    doReturn("thisStepName").when(analyzer).getStepName();
    analyzer.rootNode = node;
    when(node.getLogicalId()).thenReturn("logical id");
    ValueMetaInterface vmi = new ValueMeta("name", 1);
    IMetaverseNode outputFieldNode = analyzer.createOutputFieldNode(context, vmi, "targetStep", DictionaryConst.NODE_TYPE_TRANS_FIELD);
    assertNotNull(outputFieldNode);
    assertNotNull(outputFieldNode.getProperty(DictionaryConst.PROPERTY_KETTLE_TYPE));
    assertEquals("targetStep", outputFieldNode.getProperty(DictionaryConst.PROPERTY_TARGET_STEP));
    assertEquals(DictionaryConst.NODE_TYPE_TRANS_FIELD, outputFieldNode.getType());
    // 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)

Example 7 with IAnalysisContext

use of org.pentaho.metaverse.api.IAnalysisContext 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

IAnalysisContext (org.pentaho.metaverse.api.IAnalysisContext)7 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)7 Test (org.junit.Test)6 ValueMeta (org.pentaho.di.core.row.ValueMeta)6 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)6 MetaverseException (org.pentaho.metaverse.api.MetaverseException)1 IExternalResourceInfo (org.pentaho.metaverse.api.model.IExternalResourceInfo)1 MongoField (org.pentaho.mongo.wrapper.field.MongoField)1