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));
}
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));
}
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));
}
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));
}
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));
}
Aggregations