use of org.talend.sdk.component.junit.beam.Data in project component-runtime by Talend.
the class TInProcessorBeamTest method processor.
@Test
@Ignore("You need to complete this test with your own data and assertions")
public void processor() {
// Processor configuration
// Setup your component configuration for the test here
final TInProcessorConfiguration configuration = new TInProcessorConfiguration();
// We create the component processor instance using the configuration filled above
final Processor processor = COMPONENT_FACTORY.createProcessor(TInProcessor.class, configuration);
// The join input factory construct inputs test data for every input branch you have defined for this component
// Make sure to fil in some test data for the branches you want to test
// You can also remove the branches that you don't need from the factory below
final JoinInputFactory joinInputFactory = new JoinInputFactory().withInput("__default__", asList());
// Convert it to a beam "source"
final PCollection<JsonObject> inputs = pipeline.apply(Data.of(processor.plugin(), joinInputFactory.asInputRecords()));
// add our processor right after to see each data as configured previously
final PCollection<Map<String, JsonObject>> outputs = inputs.apply(TalendFn.asFn(processor)).apply(Data.map(processor.plugin(), JsonObject.class));
PAssert.that(outputs).satisfies((SerializableFunction<Iterable<Map<String, JsonObject>>, Void>) input -> {
final List<Map<String, JsonObject>> result = StreamSupport.stream(input.spliterator(), false).collect(toList());
return null;
});
// run the pipeline and ensure the execution was successful
assertEquals(PipelineResult.State.DONE, pipeline.run().waitUntilFinish());
}
Aggregations