Search in sources :

Example 6 with StreamFieldNode

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

the class MetaverseValidationIT method testTransExecutorStepNode.

@Test
public void testTransExecutorStepNode() throws Exception {
    TransExecutorStepNode transExecutorStepNode = root.getTransExecutorStepNode();
    assertNotNull(transExecutorStepNode);
    TransExecutorMeta meta = (TransExecutorMeta) getStepMeta(transExecutorStepNode);
    assertEquals(meta.getParentStepMeta().getName(), transExecutorStepNode.getName());
    assertEquals(meta.getOutputRowsSourceStep(), transExecutorStepNode.getOutputRowsTargetStepName());
    assertEquals(meta.getResultFilesTargetStep(), transExecutorStepNode.getResultFilesTargetStepName());
    assertEquals(meta.getExecutionResultTargetStep(), transExecutorStepNode.getExecutionResultsTargetStepName());
    assertNotNull(transExecutorStepNode.getOutputStepByName(meta.getOutputRowsSourceStep()));
    assertNotNull(transExecutorStepNode.getOutputStepByName(meta.getResultFilesTargetStep()));
    assertNotNull(transExecutorStepNode.getOutputStepByName(meta.getExecutionResultTargetStep()));
    RowMetaInterface incomingRow = meta.getParentStepMeta().getParentTransMeta().getPrevStepFields(meta.getParentStepMeta());
    int incomingFieldCount = incomingRow.size();
    Iterable<StreamFieldNode> streamFieldNodes = transExecutorStepNode.getOutputStreamFields();
    int countOutputStreamFieldNode = getIterableSize(streamFieldNodes);
    List<String> outputFields = Arrays.asList(meta.getOutputRowsField());
    for (StreamFieldNode streamFieldNode : streamFieldNodes) {
        assertNotNull(streamFieldNode.getKettleType());
        if (outputFields.contains(streamFieldNode.getName())) {
            // this field came back to us from the sub trans via a result, lets make sure they link up
            assertEquals(transExecutorStepNode.getTransToExecute(), streamFieldNode.getFieldNodesThatDeriveMe().iterator().next().getStepThatOutputsMe().getTransNode());
        }
    }
    streamFieldNodes = transExecutorStepNode.getStreamFieldNodesDeletes();
    int countDeletedStreamFieldNode = getIterableSize(streamFieldNodes);
    for (StreamFieldNode streamFieldNode : streamFieldNodes) {
        assertNotNull(streamFieldNode.getKettleType());
    }
    assertNotNull(transExecutorStepNode.getTransToExecute());
    streamFieldNodes = transExecutorStepNode.getStreamFieldNodesUses();
    int countUsedStreamFieldNode = getIterableSize(streamFieldNodes);
    for (StreamFieldNode streamFieldNode : streamFieldNodes) {
        assertNotNull(streamFieldNode.getKettleType());
        // these should link up to stream fields in the sub trans via the "get rows from result" step
        for (StreamFieldNode derived : streamFieldNode.getFieldNodesDerivedFromMe()) {
            // the trans that is to be executed should contain the step that creates a field derived from the incoming field
            assertEquals(transExecutorStepNode.getTransToExecute(), derived.getStepThatInputsMe().getTransNode());
        }
    }
    assertEquals(incomingFieldCount, countUsedStreamFieldNode);
}
Also used : TransExecutorMeta(org.pentaho.di.trans.steps.transexecutor.TransExecutorMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) StreamFieldNode(org.pentaho.metaverse.frames.StreamFieldNode) TransExecutorStepNode(org.pentaho.metaverse.frames.TransExecutorStepNode) Test(org.junit.Test)

Example 7 with StreamFieldNode

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

the class MetaverseValidationIT method testMongoDbInput.

@Test
public void testMongoDbInput() throws Exception {
    MongoDbInputStepNode node = root.getMongoDbInputStepNode();
    assertNotNull(node);
    MongoDbMeta meta = (MongoDbMeta) getStepMeta(node);
    assertEquals(meta.getCollection(), node.getCollection().getName());
    assertEquals(meta.getDbName(), node.getDatasource(meta.getDbName()).getName());
    Iterable<StreamFieldNode> inputs = node.getInputStreamFields();
    Iterable<StreamFieldNode> outputs = node.getOutputStreamFields();
    assertEquals(getIterableSize(inputs), getIterableSize(outputs));
    for (StreamFieldNode output : outputs) {
        assertEquals(output.getName(), output.getFieldPopulatesMe().getName());
    }
    MongoConnectionNode datasource = node.getDatasource(meta.getDbName());
    assertEquals(meta.getHostnames(), datasource.getHost());
    assertEquals(meta.getPort(), datasource.getPort());
    assertEquals(meta.getAuthenticationUser(), datasource.getUserName());
    assertEquals(meta.getDbName(), datasource.getDatabaseName());
    assertEquals(DictionaryConst.NODE_TYPE_MONGODB_CONNECTION, datasource.getType());
    FramedMetaverseNode collection = node.getCollection();
    assertEquals(meta.getCollection(), collection.getName());
    assertEquals(DictionaryConst.NODE_TYPE_MONGODB_COLLECTION, collection.getType());
}
Also used : MongoDbInputStepNode(org.pentaho.metaverse.frames.MongoDbInputStepNode) StreamFieldNode(org.pentaho.metaverse.frames.StreamFieldNode) FramedMetaverseNode(org.pentaho.metaverse.frames.FramedMetaverseNode) MongoDbMeta(org.pentaho.di.trans.steps.mongodb.MongoDbMeta) MongoConnectionNode(org.pentaho.metaverse.frames.MongoConnectionNode) Test(org.junit.Test)

Example 8 with StreamFieldNode

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

the class MetaverseValidationIT method testStringOperationsStepNode.

@Test
public void testStringOperationsStepNode() throws Exception {
    TransformationStepNode node = root.getStepNode("string_operations", "String operations");
    // Make sure we have the right number of links used
    assertEquals(4, getIterableSize(node.getInputStreamFields()));
    assertEquals(4, getIterableSize(node.getStreamFieldNodesUses()));
    assertEquals(5, getIterableSize(node.getOutputStreamFields()));
    for (StreamFieldNode sfn : node.getOutputStreamFields()) {
        // "Last Name" is a special case for this test, it is passthrough
        if (sfn.getName().equals("Last 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 9 with StreamFieldNode

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

the class MetaverseValidationIT method testValueMapperStepNode_newField.

@Test
public void testValueMapperStepNode_newField() throws Exception {
    TransformationStepNode valueMapperStepNode = root.getStepNode("value_mapper", "Value Mapper - new field");
    assertEquals(1, getIterableSize(valueMapperStepNode.getStreamFieldNodesUses()));
    StreamFieldNode usesNode = valueMapperStepNode.getStreamFieldNodesUses().iterator().next();
    ValueMapperMeta meta = (ValueMapperMeta) getStepMeta(valueMapperStepNode);
    assertEquals(meta.getFieldToUse(), usesNode.getName());
    assertNull(usesNode.getOperations());
    Iterable<StreamFieldNode> inFields = valueMapperStepNode.getInputStreamFields();
    int countInputs = getIterableSize(inFields);
    Iterable<StreamFieldNode> outFields = valueMapperStepNode.getOutputStreamFields();
    int countOutputs = getIterableSize(outFields);
    assertEquals(countInputs + 1, countOutputs);
    for (StreamFieldNode outField : outFields) {
        assertNotNull(outField.getKettleType());
        if (outField.getName().equals(meta.getTargetField())) {
            Iterable<StreamFieldNode> fieldNodesThatDeriveMe = outField.getFieldNodesThatDeriveMe();
            assertNotNull(fieldNodesThatDeriveMe);
            int derivesCount = getIterableSize(outField.getFieldNodesThatDeriveMe());
            assertEquals(1, derivesCount);
            for (FieldNode derives : outField.getFieldNodesThatDeriveMe()) {
                assertEquals(usesNode.getName(), derives.getName());
                assertEquals(usesNode.getType(), derives.getType());
            }
            Operations ops = MetaverseUtil.convertOperationsStringToMap(outField.getOperations());
            List<IOperation> dataOps = ops.get(ChangeType.DATA);
            assertNotNull(dataOps);
            assertEquals(1, dataOps.size());
            for (IOperation dataOp : dataOps) {
                assertEquals(Operation.MAPPING_CATEGORY, dataOp.getCategory());
                assertEquals(DictionaryConst.PROPERTY_TRANSFORMS, dataOp.getName());
            }
            // there should not be any metadata operations
            assertNull(ops.get(ChangeType.METADATA));
        }
    }
}
Also used : IOperation(org.pentaho.metaverse.api.model.IOperation) FieldNode(org.pentaho.metaverse.frames.FieldNode) StreamFieldNode(org.pentaho.metaverse.frames.StreamFieldNode) 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 10 with StreamFieldNode

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

the class MetaverseValidationIT method testStringsReplaceStepNode.

@Test
public void testStringsReplaceStepNode() throws Exception {
    TransformationStepNode node = root.getStepNode("strings_replace", "Replace in string");
    // 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(5, getIterableSize(node.getInputStreamFields()));
    assertEquals(5, getIterableSize(node.getStreamFieldNodesUses()));
    assertEquals(10, getIterableSize(node.getOutputStreamFields()));
    for (StreamFieldNode sfn : node.getOutputStreamFields()) {
        // The following are special cases for this test, they are passthrough fields
        if (sfn.getName().equals("LastName") || sfn.getName().equals("FirstName") || sfn.getName().equals("NickName") || sfn.getName().equals("Template")) {
            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)

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