Search in sources :

Example 1 with TestNode

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

the class CloneLinkTest method should_emit_single_input_row_to_all_targets.

@Test
public void should_emit_single_input_row_to_all_targets() {
    // given
    final TestNode target1 = new TestNode();
    final TestNode target2 = new TestNode();
    final CloneLink link = new CloneLink(target1, target2);
    final DataSetRow row = new DataSetRow(new HashMap<>());
    final RowMetadata metadata = new RowMetadata(new ArrayList<>());
    // when
    link.emit(row, metadata);
    // then
    assertThat(target1.getReceivedRows(), hasSize(1));
    assertThat(target1.getReceivedRows(), contains(row));
    assertThat(target2.getReceivedRows(), hasSize(1));
    assertThat(target2.getReceivedRows(), contains(row));
    assertThat(target1.getReceivedMetadata(), hasSize(1));
    assertThat(target1.getReceivedMetadata(), contains(metadata));
    assertThat(target2.getReceivedMetadata(), hasSize(1));
    assertThat(target2.getReceivedMetadata(), contains(metadata));
}
Also used : TestNode(org.talend.dataprep.transformation.pipeline.TestNode) RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) Test(org.junit.Test)

Example 2 with TestNode

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

the class ZipLinkTest method should_emit_single_input_row_when_all_source_has_emitted_one.

@Test
public void should_emit_single_input_row_when_all_source_has_emitted_one() {
    // given
    final TestNode source1 = new TestNode();
    final TestNode source2 = new TestNode();
    final TestNode target = new TestNode();
    ZipLink.zip(new Node[] { source1, source2 }, target);
    final DataSetRow row = new DataSetRow(new HashMap<>());
    final RowMetadata metadata = new RowMetadata(new ArrayList<>());
    // when
    source1.receive(row, metadata);
    // then
    assertThat(target.getReceivedRows(), hasSize(0));
    assertThat(target.getReceivedMetadata(), hasSize(0));
    // when
    source2.receive(row, metadata);
    // then
    assertThat(target.getReceivedRows(), hasSize(2));
    assertThat(target.getReceivedMetadata(), hasSize(2));
}
Also used : TestNode(org.talend.dataprep.transformation.pipeline.TestNode) RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) Test(org.junit.Test)

Example 3 with TestNode

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

the class ZipLinkTest method should_emit_signal_when_all_source_has_emitted_one.

@Test
public void should_emit_signal_when_all_source_has_emitted_one() {
    // given
    final TestNode source1 = new TestNode();
    final TestNode source2 = new TestNode();
    final TestNode target = new TestNode();
    ZipLink.zip(new Node[] { source1, source2 }, target);
    // when
    source1.signal(END_OF_STREAM);
    // then
    assertThat(target.getReceivedSignals(), hasSize(0));
    // when
    source2.signal(END_OF_STREAM);
    // then
    assertThat(target.getReceivedSignals(), hasSize(1));
    assertThat(target.getReceivedSignals(), contains(END_OF_STREAM));
}
Also used : TestNode(org.talend.dataprep.transformation.pipeline.TestNode) Test(org.junit.Test)

Example 4 with TestNode

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

the class BasicLinkTest method should_emit_single_input_row.

@Test
public void should_emit_single_input_row() {
    // given
    final TestNode target = new TestNode();
    final BasicLink link = new BasicLink(target);
    final DataSetRow row = new DataSetRow(new HashMap<>());
    final RowMetadata metadata = new RowMetadata(new ArrayList<>());
    // when
    link.emit(row, metadata);
    // then
    assertThat(target.getReceivedRows(), hasSize(1));
    assertThat(target.getReceivedRows(), contains(row));
    assertThat(target.getReceivedMetadata(), hasSize(1));
    assertThat(target.getReceivedMetadata(), contains(metadata));
}
Also used : TestNode(org.talend.dataprep.transformation.pipeline.TestNode) RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) Test(org.junit.Test)

Example 5 with TestNode

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

the class BasicLinkTest method should_emit_multi_input_row.

@Test
public void should_emit_multi_input_row() {
    // given
    final TestNode target = new TestNode();
    final BasicLink link = new BasicLink(target);
    final DataSetRow row1 = new DataSetRow(new HashMap<>());
    final DataSetRow row2 = new DataSetRow(new HashMap<>());
    final RowMetadata metadata1 = new RowMetadata(new ArrayList<>());
    final RowMetadata metadata2 = new RowMetadata(new ArrayList<>());
    final DataSetRow[] rows = new DataSetRow[] { row1, row2 };
    final RowMetadata[] metadatas = new RowMetadata[] { metadata1, metadata2 };
    // when
    link.emit(rows, metadatas);
    // then
    assertThat(target.getReceivedRows(), hasSize(2));
    assertThat(target.getReceivedRows(), contains(rows));
    assertThat(target.getReceivedMetadata(), hasSize(2));
    assertThat(target.getReceivedMetadata(), contains(metadatas));
}
Also used : TestNode(org.talend.dataprep.transformation.pipeline.TestNode) RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)9 TestNode (org.talend.dataprep.transformation.pipeline.TestNode)9 RowMetadata (org.talend.dataprep.api.dataset.RowMetadata)7 DataSetRow (org.talend.dataprep.api.dataset.row.DataSetRow)7