Search in sources :

Example 1 with TextFileOutputStepNode

use of org.pentaho.metaverse.frames.TextFileOutputStepNode in project pentaho-metaverse by pentaho.

the class MetaverseValidationIT method testTextFileOutputStepNode.

@Test
public void testTextFileOutputStepNode() throws Exception {
    TextFileOutputStepNode textFileOutputStepNode = root.getTextFileOutputStepNode("textFileOutput", "Text file output");
    TextFileOutputMeta meta = (TextFileOutputMeta) getStepMeta(textFileOutputStepNode);
    TransMeta tm = meta.getParentStepMeta().getParentTransMeta();
    String[] fileNames = meta.getFiles(tm);
    RowMetaInterface incomingFields = tm.getPrevStepFields(meta.getParentStepMeta());
    int outputFields = getExpectedOutputFieldCount(meta);
    assertNotNull(textFileOutputStepNode);
    Iterable<StreamFieldNode> outFields = textFileOutputStepNode.getOutputStreamFields();
    int outFieldCount = getIterableSize(outFields);
    // should have output stream nodes as well as file nodes
    assertEquals(outputFields + meta.getOutputFields().length, outFieldCount);
    int fileFieldCount = 0;
    for (StreamFieldNode outField : outFields) {
        if (DictionaryConst.NODE_TYPE_FILE_FIELD.equals(outField.getType())) {
            ValueMetaInterface vmi = incomingFields.searchValueMeta(outField.getName());
            assertEquals(vmi.getName(), outField.getFieldPopulatesMe().getName());
            fileFieldCount++;
        }
    }
    assertEquals(fileFieldCount, outFieldCount / 2);
}
Also used : TextFileOutputMeta(org.pentaho.di.trans.steps.textfileoutput.TextFileOutputMeta) TransMeta(org.pentaho.di.trans.TransMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) StreamFieldNode(org.pentaho.metaverse.frames.StreamFieldNode) TextFileOutputStepNode(org.pentaho.metaverse.frames.TextFileOutputStepNode) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Example 2 with TextFileOutputStepNode

use of org.pentaho.metaverse.frames.TextFileOutputStepNode in project pentaho-metaverse by pentaho.

the class MetaverseValidationIT method testTextFileOutputStepNode_FileFromStreamField.

@Test
public void testTextFileOutputStepNode_FileFromStreamField() throws Exception {
    TextFileOutputStepNode textFileOutputStepNode = root.getTextFileOutputStepNode("textFileOutput", "Text file output - file from field");
    TextFileOutputMeta meta = (TextFileOutputMeta) getStepMeta(textFileOutputStepNode);
    TransMeta tm = meta.getParentStepMeta().getParentTransMeta();
    RowMetaInterface incomingFields = tm.getPrevStepFields(meta.getParentStepMeta());
    int outputFields = getExpectedOutputFieldCount(meta);
    assertNotNull(textFileOutputStepNode);
    // should write to one file
    Iterable<FramedMetaverseNode> outputFiles = textFileOutputStepNode.getOutputFiles();
    assertEquals(0, getIterableSize(outputFiles));
    Iterable<StreamFieldNode> usedFields = textFileOutputStepNode.getStreamFieldNodesUses();
    int usedFieldCount = getIterableSize(usedFields);
    assertEquals(1, usedFieldCount);
    Iterable<StreamFieldNode> outFields = textFileOutputStepNode.getOutputStreamFields();
    int outFieldCount = getIterableSize(outFields);
    // should have output stream nodes as well as file nodes
    assertEquals(outputFields + meta.getOutputFields().length, outFieldCount);
    int fileFieldCount = 0;
    for (StreamFieldNode outField : outFields) {
        if (DictionaryConst.NODE_TYPE_FILE_FIELD.equals(outField.getType())) {
            ValueMetaInterface vmi = incomingFields.searchValueMeta(outField.getName());
            assertEquals(vmi.getName(), outField.getFieldPopulatesMe().getName());
            fileFieldCount++;
        }
    }
    assertEquals(fileFieldCount, outFieldCount / 2);
}
Also used : TextFileOutputMeta(org.pentaho.di.trans.steps.textfileoutput.TextFileOutputMeta) TransMeta(org.pentaho.di.trans.TransMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) StreamFieldNode(org.pentaho.metaverse.frames.StreamFieldNode) FramedMetaverseNode(org.pentaho.metaverse.frames.FramedMetaverseNode) TextFileOutputStepNode(org.pentaho.metaverse.frames.TextFileOutputStepNode) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)2 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)2 TransMeta (org.pentaho.di.trans.TransMeta)2 TextFileOutputMeta (org.pentaho.di.trans.steps.textfileoutput.TextFileOutputMeta)2 StreamFieldNode (org.pentaho.metaverse.frames.StreamFieldNode)2 TextFileOutputStepNode (org.pentaho.metaverse.frames.TextFileOutputStepNode)2 FramedMetaverseNode (org.pentaho.metaverse.frames.FramedMetaverseNode)1