Search in sources :

Example 11 with StreamFieldNode

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

the class MetaverseValidationIT method testValueMapperStepNode_overwrite.

@Test
public void testValueMapperStepNode_overwrite() throws Exception {
    TransformationStepNode valueMapperStepNode = root.getStepNode("value_mapper", "Value Mapper - overwrite");
    assertEquals(1, getIterableSize(valueMapperStepNode.getStreamFieldNodesUses()));
    StreamFieldNode usesNode = valueMapperStepNode.getStreamFieldNodesUses().iterator().next();
    ValueMapperMeta meta = (ValueMapperMeta) getStepMeta(valueMapperStepNode);
    assertEquals(meta.getFieldToUse(), usesNode.getName());
    Iterable<StreamFieldNode> inFields = valueMapperStepNode.getInputStreamFields();
    int countInputs = getIterableSize(inFields);
    Iterable<StreamFieldNode> outFields = valueMapperStepNode.getOutputStreamFields();
    int countOutputs = getIterableSize(outFields);
    assertEquals(countInputs, countOutputs);
    for (StreamFieldNode outField : outFields) {
        assertNotNull(outField.getKettleType());
        if (outField.getName().equals(meta.getTargetField())) {
            Operations ops = MetaverseUtil.convertOperationsStringToMap(usesNode.getOperations());
            List<IOperation> dataOps = ops.get(ChangeType.DATA);
            assertNotNull(dataOps);
            assertEquals(meta.getSourceValue().length, dataOps.size());
            for (int i = 0; i < dataOps.size(); i++) {
                IOperation dataOp = dataOps.get(i);
                assertEquals(DictionaryConst.PROPERTY_TRANSFORMS, dataOp.getName());
                assertEquals(dataOp.toString(), meta.getSourceValue()[i] + " -> " + meta.getTargetValue()[i]);
            }
            // there should not be any metadata operations
            assertNull(ops.get(ChangeType.METADATA));
        }
    }
    int derivedCount = getIterableSize(usesNode.getFieldNodesDerivedFromMe());
    assertEquals(1, derivedCount);
}
Also used : IOperation(org.pentaho.metaverse.api.model.IOperation) TransformationStepNode(org.pentaho.metaverse.frames.TransformationStepNode) StreamFieldNode(org.pentaho.metaverse.frames.StreamFieldNode) Operations(org.pentaho.metaverse.api.model.Operations) ValueMapperMeta(org.pentaho.di.trans.steps.valuemapper.ValueMapperMeta) Test(org.junit.Test)

Example 12 with StreamFieldNode

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

the class MetaverseValidationIT method testExcelInputStep.

@Test
public void testExcelInputStep() throws Exception {
    // this is testing a specific TextFileInputStep instance
    ExcelInputStepNode excelInputStepNode = root.getExcelInputStepNode();
    assertNotNull(excelInputStepNode);
    Iterable<FramedMetaverseNode> inputFiles = excelInputStepNode.getInputFiles();
    int countInputFiles = getIterableSize(inputFiles);
    assertEquals(1, countInputFiles);
    for (FramedMetaverseNode inputFile : inputFiles) {
        assertTrue(inputFile.getName().endsWith("SacramentoCrime.xls"));
    }
    assertEquals("Microsoft Excel Input", excelInputStepNode.getStepType());
    int countUses = getIterableSize(excelInputStepNode.getFileFieldNodesUses());
    int countInputs = getIterableSize(excelInputStepNode.getInputStreamFields());
    assertEquals(0, countUses);
    int fileFieldCount = 0;
    Iterable<StreamFieldNode> outFields = excelInputStepNode.getOutputStreamFields();
    int countOutputs = getIterableSize(outFields);
    for (StreamFieldNode outField : outFields) {
        assertNotNull(outField.getKettleType());
        FieldNode fieldPopulatesMe = outField.getFieldPopulatesMe();
        assertNotNull(fieldPopulatesMe);
        assertEquals(DictionaryConst.NODE_TYPE_FILE_FIELD, fieldPopulatesMe.getType());
        assertEquals(excelInputStepNode, fieldPopulatesMe.getStepThatInputsMe());
        fileFieldCount++;
    }
    assertEquals(countInputs, fileFieldCount);
    assertEquals(countOutputs, fileFieldCount);
}
Also used : FieldNode(org.pentaho.metaverse.frames.FieldNode) StreamFieldNode(org.pentaho.metaverse.frames.StreamFieldNode) StreamFieldNode(org.pentaho.metaverse.frames.StreamFieldNode) ExcelInputStepNode(org.pentaho.metaverse.frames.ExcelInputStepNode) FramedMetaverseNode(org.pentaho.metaverse.frames.FramedMetaverseNode) Test(org.junit.Test)

Example 13 with StreamFieldNode

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

the class MetaverseValidationIT method testStringsCutStepNode.

@Test
public void testStringsCutStepNode() throws Exception {
    TransformationStepNode node = root.getStepNode("strings_cut", "Strings cut");
    // Make sure we have the right number of links used, created and derived. Also,
    // Ensure there is an entry in the operations for those fields that are derived.
    assertEquals(3, getIterableSize(node.getInputStreamFields()));
    assertEquals(3, getIterableSize(node.getStreamFieldNodesUses()));
    assertEquals(4, getIterableSize(node.getOutputStreamFields()));
    for (StreamFieldNode sfn : node.getOutputStreamFields()) {
        // "Last Name" is a special case for this test, it is passthrough
        if (sfn.getName().equals("Middle Name")) {
            assertTrue(Const.isEmpty(sfn.getOperations()));
        } else {
            assertFalse(Const.isEmpty(sfn.getOperations()));
        }
    }
}
Also used : TransformationStepNode(org.pentaho.metaverse.frames.TransformationStepNode) StreamFieldNode(org.pentaho.metaverse.frames.StreamFieldNode) Test(org.junit.Test)

Example 14 with StreamFieldNode

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

the class MetaverseValidationIT method testTableInput.

@Test
public void testTableInput() throws Exception {
    TableInputStepNode tableNode = root.getTableInputStepNode();
    TableInputMeta meta = (TableInputMeta) getStepMeta(tableNode);
    assertNotNull(tableNode);
    assertNotNull(tableNode.getDatasource(meta.getDatabaseMeta().getName()));
    assertNotNull(tableNode.getDatabaseQueryNode());
    assertEquals(meta.getSQL(), tableNode.getDatabaseQueryNode().getQuery());
    Iterable<StreamFieldNode> outputStreamFields = tableNode.getOutputStreamFields();
    Iterable<DatabaseColumnNode> databaseColumns = tableNode.getDatabaseQueryNode().getDatabaseColumns();
    assertEquals(getIterableSize(outputStreamFields), getIterableSize(databaseColumns));
}
Also used : StreamFieldNode(org.pentaho.metaverse.frames.StreamFieldNode) TableInputStepNode(org.pentaho.metaverse.frames.TableInputStepNode) TableInputMeta(org.pentaho.di.trans.steps.tableinput.TableInputMeta) DatabaseColumnNode(org.pentaho.metaverse.frames.DatabaseColumnNode) Test(org.junit.Test)

Example 15 with StreamFieldNode

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

the class MetaverseValidationIT method testHttpClientStep.

@Test
public void testHttpClientStep() throws Exception {
    HttpClientStepNode node = root.getHttpClientStepNode();
    assertNotNull(node);
    Iterable<FramedMetaverseNode> inputUrls = node.getInputUrls();
    int countInputUrls = getIterableSize(inputUrls);
    assertEquals(1, countInputUrls);
    assertEquals("HTTP Client", node.getStepType());
    HTTPMeta stepMeta = (HTTPMeta) getStepMeta(node);
    for (FramedMetaverseNode inputUrl : inputUrls) {
        assertEquals(stepMeta.getUrl(), inputUrl.getName());
    }
    // check the param  field is "used"
    Iterable<StreamFieldNode> streamFieldNodesUses = node.getStreamFieldNodesUses();
    assertEquals(2, getIterableSize(streamFieldNodesUses));
    Iterable<StreamFieldNode> outputs = node.getOutputStreamFields();
    assertEquals(5, getIterableSize(outputs));
    Iterable<StreamFieldNode> inputs = node.getInputStreamFields();
    assertEquals(3, getIterableSize(inputs));
    for (StreamFieldNode in : inputs) {
        assertNotNull(in.getFieldNodesDerivedFromMe());
        assertEquals(in.getName(), in.getFieldNodesDerivedFromMe().iterator().next().getName());
    }
}
Also used : StreamFieldNode(org.pentaho.metaverse.frames.StreamFieldNode) FramedMetaverseNode(org.pentaho.metaverse.frames.FramedMetaverseNode) HttpClientStepNode(org.pentaho.metaverse.frames.HttpClientStepNode) HTTPMeta(org.pentaho.di.trans.steps.http.HTTPMeta) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)34 StreamFieldNode (org.pentaho.metaverse.frames.StreamFieldNode)34 FramedMetaverseNode (org.pentaho.metaverse.frames.FramedMetaverseNode)14 FieldNode (org.pentaho.metaverse.frames.FieldNode)9 TransMeta (org.pentaho.di.trans.TransMeta)6 Operations (org.pentaho.metaverse.api.model.Operations)6 TransformationStepNode (org.pentaho.metaverse.frames.TransformationStepNode)6 HashSet (java.util.HashSet)4 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)4 IOperation (org.pentaho.metaverse.api.model.IOperation)4 CsvFileInputStepNode (org.pentaho.metaverse.frames.CsvFileInputStepNode)4 FixedFileInputStepNode (org.pentaho.metaverse.frames.FixedFileInputStepNode)4 FileInputStream (java.io.FileInputStream)3 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)3 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)3 StepMeta (org.pentaho.di.trans.step.StepMeta)3 FileInputStepNode (org.pentaho.metaverse.frames.FileInputStepNode)3 ArrayList (java.util.ArrayList)2 FieldSplitterMeta (org.pentaho.di.trans.steps.fieldsplitter.FieldSplitterMeta)2 HTTPMeta (org.pentaho.di.trans.steps.http.HTTPMeta)2