use of org.talend.components.adapter.beam.example.AssertResultProperties in project components by Talend.
the class TCompBoundedSourceSinkAdapterTest method testSink.
@Test
public void testSink() {
Pipeline pipeline = TestPipeline.create();
AssertResultProperties assertResultProperties = new AssertResultProperties("assertResultProperties");
assertResultProperties.init();
assertResultProperties.data.setValue("b;c;a");
assertResultProperties.rowDelimited.setValue(";");
AssertResultSink assertResultSink = new AssertResultSink();
assertResultSink.initialize(null, assertResultProperties);
TCompSinkAdapter sink = new TCompSinkAdapter(assertResultSink);
final String schemaStr = assertResultProperties.schema.getValue().toString();
pipeline.apply(Create.of("a", "b", "c")).apply(ParDo.of(new DoFn<String, IndexedRecord>() {
@DoFn.ProcessElement
public void processElement(ProcessContext c) throws Exception {
IndexedRecord row = new GenericData.Record(new Schema.Parser().parse(schemaStr));
row.put(0, c.element());
c.output(row);
}
})).setCoder(LazyAvroCoder.of()).apply(Write.to(sink));
pipeline.run();
}
use of org.talend.components.adapter.beam.example.AssertResultProperties in project components by Talend.
the class TCompBoundedSourceSinkAdapterTest method testPipeline.
@Test
public void testPipeline() {
Pipeline pipeline = TestPipeline.create();
FixedFlowProperties fixedFlowProperties = new FixedFlowProperties("fixedFlowProperties");
fixedFlowProperties.init();
fixedFlowProperties.data.setValue("a;b;c");
fixedFlowProperties.rowDelimited.setValue(";");
AssertResultProperties assertResultProperties = new AssertResultProperties("assertResultProperties");
assertResultProperties.init();
assertResultProperties.data.setValue("b;c;a");
assertResultProperties.rowDelimited.setValue(";");
FixedFlowSource fixedFlowSource = new FixedFlowSource();
fixedFlowSource.initialize(null, fixedFlowProperties);
AssertResultSink assertResultSink = new AssertResultSink();
assertResultSink.initialize(null, assertResultProperties);
TCompBoundedSourceAdapter source = new TCompBoundedSourceAdapter(fixedFlowSource);
TCompSinkAdapter sink = new TCompSinkAdapter(assertResultSink);
pipeline.apply(Read.from(source)).apply(Write.to(sink));
pipeline.run();
}
Aggregations