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);
}
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()));
}
}
}
Aggregations