Search in sources :

Example 1 with SplitFieldsStepNode

use of org.pentaho.metaverse.frames.SplitFieldsStepNode 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());
}
Also used : SplitFieldsStepNode(org.pentaho.metaverse.frames.SplitFieldsStepNode) StreamFieldNode(org.pentaho.metaverse.frames.StreamFieldNode) FieldSplitterMeta(org.pentaho.di.trans.steps.fieldsplitter.FieldSplitterMeta) Test(org.junit.Test)

Example 2 with SplitFieldsStepNode

use of org.pentaho.metaverse.frames.SplitFieldsStepNode 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());
        }
    }
}
Also used : SplitFieldsStepNode(org.pentaho.metaverse.frames.SplitFieldsStepNode) StreamFieldNode(org.pentaho.metaverse.frames.StreamFieldNode) FieldSplitterMeta(org.pentaho.di.trans.steps.fieldsplitter.FieldSplitterMeta) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 FieldSplitterMeta (org.pentaho.di.trans.steps.fieldsplitter.FieldSplitterMeta)2 SplitFieldsStepNode (org.pentaho.metaverse.frames.SplitFieldsStepNode)2 StreamFieldNode (org.pentaho.metaverse.frames.StreamFieldNode)2