use of org.pentaho.di.trans.steps.fieldsplitter.FieldSplitterMeta in project pentaho-metaverse by pentaho.
the class MetaverseValidationIT method testSplitFieldsStepNode_normal.
@Test
public void testSplitFieldsStepNode_normal() throws Exception {
SplitFieldsStepNode node = root.getSplitFieldsStepNodeByName("Split Fields - name");
assertNotNull(node);
FieldSplitterMeta meta = (FieldSplitterMeta) getStepMeta(node);
assertEquals(meta.getDelimiter(), node.getDelimiter());
assertEquals(meta.getEnclosure(), node.getEnclosure());
String[] outputFields = meta.getFieldName();
Iterable<StreamFieldNode> usedFields = node.getStreamFieldNodesUses();
int usedFieldCount = getIterableSize(usedFields);
assertEquals(1, usedFieldCount);
assertEquals(meta.getSplitField(), usedFields.iterator().next().getName());
// make sure the split field derives all of the output fields
Iterable<StreamFieldNode> outFields = node.getOutputStreamFields();
for (StreamFieldNode outField : outFields) {
Iterable<StreamFieldNode> derivingNodes = outField.getFieldNodesThatDeriveMe();
int derivesFieldCount = getIterableSize(derivingNodes);
assertEquals(1, derivesFieldCount);
StreamFieldNode derivingField = derivingNodes.iterator().next();
if (!derivingField.getName().equals("position")) {
assertEquals(derivingField.getName(), meta.getSplitField());
}
}
// make sure the node that was used is the split field
assertEquals(meta.getSplitField(), usedFields.iterator().next().getName());
}
use of org.pentaho.di.trans.steps.fieldsplitter.FieldSplitterMeta in project pentaho-metaverse by pentaho.
the class MetaverseValidationIT method testSplitFieldsStepNode_reuseTheSplitFieldNameInOutputField.
@Test
public void testSplitFieldsStepNode_reuseTheSplitFieldNameInOutputField() throws Exception {
SplitFieldsStepNode node = root.getSplitFieldsStepNodeByName("Split Fields - team");
assertNotNull(node);
FieldSplitterMeta meta = (FieldSplitterMeta) getStepMeta(node);
assertEquals(meta.getDelimiter(), node.getDelimiter());
assertEquals(meta.getEnclosure(), node.getEnclosure());
Iterable<StreamFieldNode> usedFields = node.getStreamFieldNodesUses();
int usedFieldCount = getIterableSize(usedFields);
// make sure the node that was used is the split field
assertEquals(meta.getSplitField(), usedFields.iterator().next().getName());
assertEquals(1, usedFieldCount);
// make sure the split field derives all of the output fields
// make sure the split field derives all of the output fields
Iterable<StreamFieldNode> outFields = node.getOutputStreamFields();
for (StreamFieldNode outField : outFields) {
Iterable<StreamFieldNode> derivingNodes = outField.getFieldNodesThatDeriveMe();
int derivesFieldCount = getIterableSize(derivingNodes);
assertEquals(1, derivesFieldCount);
StreamFieldNode derivingField = derivingNodes.iterator().next();
if (!derivingField.getName().equals("position")) {
assertEquals(derivingField.getName(), meta.getSplitField());
}
}
}
Aggregations