Search in sources :

Example 1 with ExcelOutputStepNode

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

the class MetaverseValidationIT method testExcelOutputStepNode.

@Test
public void testExcelOutputStepNode() throws Exception {
    ExcelOutputStepNode excelOutputStepNode = root.getExcelOutputStepNode();
    assertNotNull(excelOutputStepNode);
    ExcelOutputMeta meta = (ExcelOutputMeta) getStepMeta(excelOutputStepNode);
    TransMeta tm = meta.getParentStepMeta().getParentTransMeta();
    String[] fileNames = meta.getFiles(tm);
    RowMetaInterface incomingFields = tm.getStepFields(meta.getParentStepMeta());
    ExcelField[] outputFields = meta.getOutputFields();
    // should write to one file
    Iterable<FramedMetaverseNode> outputFiles = excelOutputStepNode.getOutputFiles();
    assertEquals(fileNames.length, getIterableSize(outputFiles));
    int i = 0;
    for (FramedMetaverseNode node : outputFiles) {
        assertEquals(normalizeFilePath(fileNames[i++]), normalizeFilePath(node.getName()));
    }
    Iterable<StreamFieldNode> outFields = excelOutputStepNode.getOutputStreamFields();
    int outFieldCount = getIterableSize(outFields);
    // should have output stream nodes as well as file nodes
    assertEquals(outputFields.length * 2, 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 : ExcelField(org.pentaho.di.trans.steps.exceloutput.ExcelField) ExcelOutputMeta(org.pentaho.di.trans.steps.exceloutput.ExcelOutputMeta) TransMeta(org.pentaho.di.trans.TransMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ExcelOutputStepNode(org.pentaho.metaverse.frames.ExcelOutputStepNode) StreamFieldNode(org.pentaho.metaverse.frames.StreamFieldNode) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) FramedMetaverseNode(org.pentaho.metaverse.frames.FramedMetaverseNode) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)1 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)1 TransMeta (org.pentaho.di.trans.TransMeta)1 ExcelField (org.pentaho.di.trans.steps.exceloutput.ExcelField)1 ExcelOutputMeta (org.pentaho.di.trans.steps.exceloutput.ExcelOutputMeta)1 ExcelOutputStepNode (org.pentaho.metaverse.frames.ExcelOutputStepNode)1 FramedMetaverseNode (org.pentaho.metaverse.frames.FramedMetaverseNode)1 StreamFieldNode (org.pentaho.metaverse.frames.StreamFieldNode)1