Search in sources :

Example 1 with FilterRowsStepNode

use of org.pentaho.metaverse.frames.FilterRowsStepNode in project pentaho-metaverse by pentaho.

the class MetaverseValidationIT method testFilterRowsStepNode.

@Test
public void testFilterRowsStepNode() throws Exception {
    FilterRowsStepNode node = root.getFilterRowsStepNode("Filter rows");
    assertNotNull(node);
    assertEquals("Filter rows", node.getStepType());
    FilterRowsMeta meta = (FilterRowsMeta) getStepMeta(node);
    Operations ops = MetaverseUtil.convertOperationsStringToMap(node.getOperations());
    assertEquals(1, ops.get(ChangeType.DATA_FLOW).size());
    assertEquals(meta.getCondition().toString(), ops.get(ChangeType.DATA_FLOW).get(0).getDescription());
    // should not be any created nodes
    Iterable<StreamFieldNode> streamFieldNodes = node.getStreamFieldNodesCreates();
    int countCreatedStreamFieldNode = getIterableSize(streamFieldNodes);
    assertEquals(0, countCreatedStreamFieldNode);
    // should not be any deleted nodes
    streamFieldNodes = node.getStreamFieldNodesCreates();
    int countDeletedStreamFieldNode = getIterableSize(streamFieldNodes);
    assertEquals(0, countDeletedStreamFieldNode);
    // should use all of the fields that are used in the condition of the step
    List<String> expectedUses = Arrays.asList(meta.getCondition().getUsedFields());
    streamFieldNodes = node.getStreamFieldNodesUses();
    int countUsedStreamFieldNode = getIterableSize(streamFieldNodes);
    assertEquals(expectedUses.size(), countUsedStreamFieldNode);
    for (StreamFieldNode streamFieldNode : streamFieldNodes) {
        assertTrue(expectedUses.contains(streamFieldNode.getName()));
    }
}
Also used : FilterRowsMeta(org.pentaho.di.trans.steps.filterrows.FilterRowsMeta) FilterRowsStepNode(org.pentaho.metaverse.frames.FilterRowsStepNode) StreamFieldNode(org.pentaho.metaverse.frames.StreamFieldNode) Operations(org.pentaho.metaverse.api.model.Operations) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 FilterRowsMeta (org.pentaho.di.trans.steps.filterrows.FilterRowsMeta)1 Operations (org.pentaho.metaverse.api.model.Operations)1 FilterRowsStepNode (org.pentaho.metaverse.frames.FilterRowsStepNode)1 StreamFieldNode (org.pentaho.metaverse.frames.StreamFieldNode)1