Search in sources :

Example 1 with BasicNode

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

the class NodeBuilderTest method should_append_node_with_provided_link.

@Test
public void should_append_node_with_provided_link() {
    // given
    final Node nextNode = new BasicNode();
    // when
    final Node node = NodeBuilder.source().to((n) -> new TestLink(n[0]), nextNode).build();
    // then
    assertThat(node.getLink(), instanceOf(TestLink.class));
    assertThat(node.getLink().getTarget(), is(nextNode));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) Matchers.arrayContaining(org.hamcrest.Matchers.arrayContaining) IsInstanceOf.instanceOf(org.hamcrest.core.IsInstanceOf.instanceOf) Predicate(java.util.function.Predicate) FilteredSourceNode(org.talend.dataprep.transformation.pipeline.node.FilteredSourceNode) BasicLink(org.talend.dataprep.transformation.pipeline.link.BasicLink) Test(org.junit.Test) SourceNode(org.talend.dataprep.transformation.pipeline.node.SourceNode) TestLink(org.talend.dataprep.transformation.pipeline.TestLink) Node(org.talend.dataprep.transformation.pipeline.Node) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) CloneLink(org.talend.dataprep.transformation.pipeline.link.CloneLink) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) BasicNode(org.talend.dataprep.transformation.pipeline.node.BasicNode) ZipLink(org.talend.dataprep.transformation.pipeline.node.ZipLink) TestLink(org.talend.dataprep.transformation.pipeline.TestLink) FilteredSourceNode(org.talend.dataprep.transformation.pipeline.node.FilteredSourceNode) SourceNode(org.talend.dataprep.transformation.pipeline.node.SourceNode) Node(org.talend.dataprep.transformation.pipeline.Node) BasicNode(org.talend.dataprep.transformation.pipeline.node.BasicNode) BasicNode(org.talend.dataprep.transformation.pipeline.node.BasicNode) Test(org.junit.Test)

Example 2 with BasicNode

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

the class UpdatedStepVisitorTest method testUpdatedStepsWithKO.

@Test
public void testUpdatedStepsWithKO() throws Exception {
    // Given
    final Step step = new Step(ROOT_STEP.id(), new PreparationActions().id(), "0.0");
    final RowMetadata stepRowMetadata = new RowMetadata();
    final Node stepNode = NodeBuilder.from(new StepNode(step, stepRowMetadata, entryNode, new BasicNode())).to(new BasicNode()).build();
    final UpdatedStepVisitor visitor = new UpdatedStepVisitor(stepMetadataRepository);
    // Canceled action!
    actionContext.setActionStatus(ActionContext.ActionStatus.CANCELED);
    // When
    stepNode.exec().receive(new DataSetRow(metadata), metadata);
    // Then
    stepNode.accept(visitor);
    verify(stepMetadataRepository).update(step.id(), stepRowMetadata);
}
Also used : StepNode(org.talend.dataprep.transformation.pipeline.node.StepNode) StepNode(org.talend.dataprep.transformation.pipeline.node.StepNode) ActionNode(org.talend.dataprep.transformation.pipeline.node.ActionNode) Node(org.talend.dataprep.transformation.pipeline.Node) BasicNode(org.talend.dataprep.transformation.pipeline.node.BasicNode) BasicNode(org.talend.dataprep.transformation.pipeline.node.BasicNode) PreparationActions(org.talend.dataprep.api.preparation.PreparationActions) RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) Step(org.talend.dataprep.api.preparation.Step) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) Test(org.junit.Test)

Example 3 with BasicNode

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

the class UpdatedStepVisitorTest method testUpdatedStepsWithOk.

@Test
public void testUpdatedStepsWithOk() throws Exception {
    // Given
    final Step step = new Step(ROOT_STEP.id(), new PreparationActions().id(), "0.0");
    final RowMetadata stepRowMetadata = new RowMetadata();
    final Node stepNode = NodeBuilder.from(new StepNode(step, stepRowMetadata, entryNode, new BasicNode())).to(new BasicNode()).build();
    final UpdatedStepVisitor visitor = new UpdatedStepVisitor(stepMetadataRepository);
    // OK action!
    actionContext.setActionStatus(ActionContext.ActionStatus.OK);
    // When
    stepNode.exec().receive(new DataSetRow(metadata), metadata);
    // Then
    stepNode.accept(visitor);
    verify(stepMetadataRepository).update(step.id(), stepRowMetadata);
}
Also used : StepNode(org.talend.dataprep.transformation.pipeline.node.StepNode) StepNode(org.talend.dataprep.transformation.pipeline.node.StepNode) ActionNode(org.talend.dataprep.transformation.pipeline.node.ActionNode) Node(org.talend.dataprep.transformation.pipeline.Node) BasicNode(org.talend.dataprep.transformation.pipeline.node.BasicNode) BasicNode(org.talend.dataprep.transformation.pipeline.node.BasicNode) PreparationActions(org.talend.dataprep.api.preparation.PreparationActions) RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) Step(org.talend.dataprep.api.preparation.Step) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) Test(org.junit.Test)

Example 4 with BasicNode

use of org.talend.dataprep.transformation.pipeline.node.BasicNode 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 5 with BasicNode

use of org.talend.dataprep.transformation.pipeline.node.BasicNode 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

Test (org.junit.Test)9 BasicNode (org.talend.dataprep.transformation.pipeline.node.BasicNode)9 Node (org.talend.dataprep.transformation.pipeline.Node)7 SourceNode (org.talend.dataprep.transformation.pipeline.node.SourceNode)7 FilteredSourceNode (org.talend.dataprep.transformation.pipeline.node.FilteredSourceNode)5 ActionNode (org.talend.dataprep.transformation.pipeline.node.ActionNode)4 StepNode (org.talend.dataprep.transformation.pipeline.node.StepNode)4 DataSetRow (org.talend.dataprep.api.dataset.row.DataSetRow)3 RowMetadata (org.talend.dataprep.api.dataset.RowMetadata)2 PreparationActions (org.talend.dataprep.api.preparation.PreparationActions)2 Step (org.talend.dataprep.api.preparation.Step)2 BasicLink (org.talend.dataprep.transformation.pipeline.link.BasicLink)2 CloneLink (org.talend.dataprep.transformation.pipeline.link.CloneLink)2 CompileNode (org.talend.dataprep.transformation.pipeline.node.CompileNode)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Predicate (java.util.function.Predicate)1 CoreMatchers.is (org.hamcrest.CoreMatchers.is)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Matchers.arrayContaining (org.hamcrest.Matchers.arrayContaining)1 IsInstanceOf.instanceOf (org.hamcrest.core.IsInstanceOf.instanceOf)1