use of org.talend.sdk.component.runtime.beam.data.Sample in project component-runtime by Talend.
the class BeamIOWrappingTest method mapper.
@Test
public void mapper() {
final Object source = newComponent("beamio_input", ComponentManager.ComponentType.MAPPER);
assertThat(source, instanceOf(BeamSource.class));
final Mapper mapper = new BeamMapperImpl((PTransform<PBegin, ?>) source, getPlugin(), "test", "beamio_input");
mapper.start();
assertEquals(2, mapper.assess());
final Input input = mapper.create();
assertNotNull(input);
input.start();
assertEquals(new Sample("a"), input.next());
assertEquals(new Sample("b"), input.next());
assertNull(input.next());
input.stop();
mapper.stop();
}
use of org.talend.sdk.component.runtime.beam.data.Sample in project component-runtime by Talend.
the class BeamComponentExtensionTest method assertMapper.
private void assertMapper(final Mapper mapper) {
assertNotNull(mapper);
mapper.start();
final Input input = mapper.create();
input.start();
assertEquals(new Sample("a"), input.next());
assertEquals(new Sample("b"), input.next());
assertNull(input.next());
input.stop();
mapper.stop();
}
use of org.talend.sdk.component.runtime.beam.data.Sample in project component-runtime by Talend.
the class BeamIOWrappingTest method outputChain.
@Test
public void outputChain() {
MySink.DATA.clear();
final Object source = newComponent("beamio_output_chain", ComponentManager.ComponentType.PROCESSOR);
final Processor processor = new BeamProcessorChainImpl((PTransform<PCollection<?>, PDone>) source, null, getPlugin(), "test", "beamio_output");
processor.start();
processor.beforeGroup();
Stream.of("tsrif", "dnoces").forEach(data -> processor.onNext(name -> {
assertEquals(Branches.DEFAULT_BRANCH, name);
return new Sample(data);
}, name -> value -> MySink.DATA.add(value.toString())));
processor.afterGroup(name -> {
assertEquals(Branches.DEFAULT_BRANCH, name);
return value -> MySink.DATA.add(value.toString());
});
processor.stop();
assertEquals(asList("setup", "start-bundle", "first", "second", "finish-out", "finish-bundle", "teardown"), MySink.DATA);
MySink.DATA.clear();
}
Aggregations