Search in sources :

Example 6 with TransformationStepNode

use of org.pentaho.metaverse.frames.TransformationStepNode 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 7 with TransformationStepNode

use of org.pentaho.metaverse.frames.TransformationStepNode 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)

Aggregations

Test (org.junit.Test)7 TransformationStepNode (org.pentaho.metaverse.frames.TransformationStepNode)7 StreamFieldNode (org.pentaho.metaverse.frames.StreamFieldNode)6 IOperation (org.pentaho.metaverse.api.model.IOperation)3 Operations (org.pentaho.metaverse.api.model.Operations)3 ValueMapperMeta (org.pentaho.di.trans.steps.valuemapper.ValueMapperMeta)2 FieldNode (org.pentaho.metaverse.frames.FieldNode)2 FileInputStream (java.io.FileInputStream)1 TransMeta (org.pentaho.di.trans.TransMeta)1 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)1 StepMeta (org.pentaho.di.trans.step.StepMeta)1 NumberRangeMeta (org.pentaho.di.trans.steps.numberrange.NumberRangeMeta)1 TransformationNode (org.pentaho.metaverse.frames.TransformationNode)1