Search in sources :

Example 6 with ActionNode

use of org.talend.dataprep.transformation.pipeline.node.ActionNode in project data-prep by Talend.

the class StepNodeTransformerTest method shouldCreateStepNodeWhenSurrounded.

@Test
public void shouldCreateStepNodeWhenSurrounded() throws Exception {
    // given
    Node node = // 
    NodeBuilder.from(// 
    new TestNode()).to(// 
    new CompileNode(null, null)).to(// 
    new ActionNode(null, null)).to(// 
    new BasicNode()).build();
    // when
    final Node processed = StepNodeTransformer.transform(node, asList(ROOT, STEP), s -> null);
    // then
    final Class[] expectedClasses = { SourceNode.class, TestNode.class, StepNode.class, BasicNode.class };
    final NodeClassVisitor visitor = new NodeClassVisitor();
    processed.accept(visitor);
    assertThat(visitor.traversedClasses, hasItems(expectedClasses));
}
Also used : CompileNode(org.talend.dataprep.transformation.pipeline.node.CompileNode) StepNode(org.talend.dataprep.transformation.pipeline.node.StepNode) SourceNode(org.talend.dataprep.transformation.pipeline.node.SourceNode) ActionNode(org.talend.dataprep.transformation.pipeline.node.ActionNode) CompileNode(org.talend.dataprep.transformation.pipeline.node.CompileNode) BasicNode(org.talend.dataprep.transformation.pipeline.node.BasicNode) ActionNode(org.talend.dataprep.transformation.pipeline.node.ActionNode) BasicNode(org.talend.dataprep.transformation.pipeline.node.BasicNode) Test(org.junit.Test)

Example 7 with ActionNode

use of org.talend.dataprep.transformation.pipeline.node.ActionNode in project data-prep by Talend.

the class StepNodeTransformerTest method shouldCreateStepNodeWithTooManySteps.

@Test
public void shouldCreateStepNodeWithTooManySteps() throws Exception {
    // given
    Node node = // 
    NodeBuilder.from(// 
    new CompileNode(null, null)).to(// 
    new ActionNode(null, null)).build();
    // when
    final Node processed = StepNodeTransformer.transform(node, asList(ROOT, STEP, STEP), s -> null);
    // then
    final Class[] expectedClasses = { SourceNode.class, StepNode.class };
    final NodeClassVisitor visitor = new NodeClassVisitor();
    processed.accept(visitor);
    assertThat(visitor.traversedClasses, hasItems(expectedClasses));
}
Also used : CompileNode(org.talend.dataprep.transformation.pipeline.node.CompileNode) StepNode(org.talend.dataprep.transformation.pipeline.node.StepNode) SourceNode(org.talend.dataprep.transformation.pipeline.node.SourceNode) ActionNode(org.talend.dataprep.transformation.pipeline.node.ActionNode) CompileNode(org.talend.dataprep.transformation.pipeline.node.CompileNode) BasicNode(org.talend.dataprep.transformation.pipeline.node.BasicNode) ActionNode(org.talend.dataprep.transformation.pipeline.node.ActionNode) Test(org.junit.Test)

Example 8 with ActionNode

use of org.talend.dataprep.transformation.pipeline.node.ActionNode in project data-prep by Talend.

the class StepNodeTransformerTest method shouldCreateStepNodesWhenSurrounded.

@Test
public void shouldCreateStepNodesWhenSurrounded() throws Exception {
    // given
    Node node = // 
    NodeBuilder.from(// 
    new TestNode()).to(// 
    new CompileNode(null, null)).to(// 
    new ActionNode(null, null)).to(// 
    new BasicNode()).to(// 
    new CompileNode(null, null)).to(// 
    new ActionNode(null, null)).build();
    // when
    final Node processed = StepNodeTransformer.transform(node, asList(ROOT, STEP, STEP), s -> null);
    // then
    final AtomicInteger stepNodeCount = new AtomicInteger();
    processed.accept(new Visitor() {

        @Override
        public void visitStepNode(StepNode stepNode) {
            stepNodeCount.incrementAndGet();
            super.visitStepNode(stepNode);
        }
    });
    assertEquals(2, stepNodeCount.get());
}
Also used : CompileNode(org.talend.dataprep.transformation.pipeline.node.CompileNode) StepNode(org.talend.dataprep.transformation.pipeline.node.StepNode) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) StepNode(org.talend.dataprep.transformation.pipeline.node.StepNode) SourceNode(org.talend.dataprep.transformation.pipeline.node.SourceNode) ActionNode(org.talend.dataprep.transformation.pipeline.node.ActionNode) CompileNode(org.talend.dataprep.transformation.pipeline.node.CompileNode) BasicNode(org.talend.dataprep.transformation.pipeline.node.BasicNode) ActionNode(org.talend.dataprep.transformation.pipeline.node.ActionNode) BasicNode(org.talend.dataprep.transformation.pipeline.node.BasicNode) Test(org.junit.Test)

Aggregations

ActionNode (org.talend.dataprep.transformation.pipeline.node.ActionNode)8 CompileNode (org.talend.dataprep.transformation.pipeline.node.CompileNode)6 Test (org.junit.Test)5 BasicNode (org.talend.dataprep.transformation.pipeline.node.BasicNode)5 SourceNode (org.talend.dataprep.transformation.pipeline.node.SourceNode)5 StepNode (org.talend.dataprep.transformation.pipeline.node.StepNode)5 RunnableAction (org.talend.dataprep.transformation.actions.common.RunnableAction)2 TransformationContext (org.talend.dataprep.transformation.api.action.context.TransformationContext)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Before (org.junit.Before)1 Step (org.talend.dataprep.api.preparation.Step)1 DataSetRowAction (org.talend.dataprep.transformation.api.action.DataSetRowAction)1 ActionContext (org.talend.dataprep.transformation.api.action.context.ActionContext)1 Node (org.talend.dataprep.transformation.pipeline.Node)1 Visitor (org.talend.dataprep.transformation.pipeline.Visitor)1 CleanUpNode (org.talend.dataprep.transformation.pipeline.node.CleanUpNode)1