use of org.talend.dataprep.transformation.pipeline.TestLink in project data-prep by Talend.
the class FilterNodeTest method receive_should_filter_with_simple_predicate.
@Test
public void receive_should_filter_with_simple_predicate() throws Exception {
// given
final RowMetadata metadata0 = new RowMetadata();
final DataSetRow row0 = new DataSetRow(new HashMap<>());
// does not pass the predicate
row0.setTdpId(0L);
final RowMetadata metadata1 = new RowMetadata();
final DataSetRow row1 = new DataSetRow(new HashMap<>());
// pass the predicate
row1.setTdpId(1L);
final TestLink link = new TestLink(new BasicNode());
final FilterNode node = new FilterNode((row, metadata) -> row.getTdpId() == 1);
node.setLink(link);
// when
node.receive(row0, metadata0);
node.receive(row1, metadata1);
// then
assertThat(link.getEmittedRows(), hasSize(1));
assertThat(link.getEmittedRows(), contains(row1));
assertThat(link.getEmittedMetadata(), hasSize(1));
assertThat(link.getEmittedMetadata(), contains(metadata1));
}
use of org.talend.dataprep.transformation.pipeline.TestLink 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));
}
use of org.talend.dataprep.transformation.pipeline.TestLink in project data-prep by Talend.
the class BasicNodeTest method should_emit_multi_input_row_to_its_link.
@Test
public void should_emit_multi_input_row_to_its_link() {
// given
final TestLink link = new TestLink(new BasicNode());
final BasicNode node = new BasicNode();
node.setLink(link);
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
node.receive(rows, metadatas);
// then
assertThat(link.getEmittedRows(), hasSize(2));
assertThat(link.getEmittedRows(), contains(rows));
assertThat(link.getEmittedMetadata(), hasSize(2));
assertThat(link.getEmittedMetadata(), contains(metadatas));
}
use of org.talend.dataprep.transformation.pipeline.TestLink in project data-prep by Talend.
the class BasicNodeTest method should_emit_signal_to_all_targets.
@Test
public void should_emit_signal_to_all_targets() {
// given
final TestLink link = new TestLink(null);
final BasicNode node = new BasicNode();
node.setLink(link);
// when
node.signal(CANCEL);
// then
assertThat(link.getEmittedSignals(), hasSize(1));
assertThat(link.getEmittedSignals(), contains(CANCEL));
}
use of org.talend.dataprep.transformation.pipeline.TestLink in project data-prep by Talend.
the class BasicNodeTest method should_emit_single_input_row_to_its_link.
@Test
public void should_emit_single_input_row_to_its_link() {
// given
final TestLink link = new TestLink(new BasicNode());
final BasicNode node = new BasicNode();
node.setLink(link);
final DataSetRow row = new DataSetRow(new HashMap<>());
final RowMetadata metadata = new RowMetadata(new ArrayList<>());
// when
node.receive(row, metadata);
// then
assertThat(link.getEmittedRows(), hasSize(1));
assertThat(link.getEmittedRows(), contains(row));
assertThat(link.getEmittedMetadata(), hasSize(1));
assertThat(link.getEmittedMetadata(), contains(metadata));
}
Aggregations