use of org.pentaho.di.trans.steps.valuemapper.ValueMapperMeta 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));
}
}
}
use of org.pentaho.di.trans.steps.valuemapper.ValueMapperMeta 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);
}
Aggregations