use of org.talend.components.localio.fixedflowinput.FixedFlowInputProperties in project components by Talend.
the class FixedFlowInputRuntimeTest method test_MultipleInput_TenOutputRow.
@Test
public void test_MultipleInput_TenOutputRow() throws Exception {
String inputAsString = generateInputJSON(inputSchema, inputIndexedRecord1) + generateInputJSON(inputSchema, inputIndexedRecord2);
FixedFlowInputProperties properties = new FixedFlowInputProperties("test");
properties.init();
properties.schemaFlow.schema.setValue(inputSchema);
properties.values.setValue(inputAsString);
properties.nbRows.setValue(10);
FixedFlowInputRuntime runtime = new FixedFlowInputRuntime();
runtime.initialize(null, properties);
PCollection<IndexedRecord> indexRecords = pipeline.apply(runtime);
try (DirectCollector<IndexedRecord> collector = DirectCollector.of()) {
indexRecords.apply(collector);
// Run the pipeline to fill the collectors.
pipeline.run().waitUntilFinish();
// Validate the contents of the collected outputs.
List<IndexedRecord> outputs = collector.getRecords();
assertEquals(20, outputs.size());
for (int i = 0; i < 10; ++i) {
assertEquals(inputIndexedRecord1.toString(), outputs.get(i * 2).toString());
assertEquals(inputIndexedRecord2.toString(), outputs.get(i * 2 + 1).toString());
}
}
}
use of org.talend.components.localio.fixedflowinput.FixedFlowInputProperties in project components by Talend.
the class FixedFlowInputRuntimeTest method test_MultipleInput_OneOutputRow.
@Test
public void test_MultipleInput_OneOutputRow() throws Exception {
String inputAsString = generateInputJSON(inputSchema, inputIndexedRecord1) + generateInputJSON(inputSchema, inputIndexedRecord2);
FixedFlowInputProperties properties = new FixedFlowInputProperties("test");
properties.init();
properties.schemaFlow.schema.setValue(inputSchema);
properties.values.setValue(inputAsString);
properties.nbRows.setValue(1);
FixedFlowInputRuntime runtime = new FixedFlowInputRuntime();
runtime.initialize(null, properties);
PCollection<IndexedRecord> indexRecords = pipeline.apply(runtime);
try (DirectCollector<IndexedRecord> collector = DirectCollector.of()) {
indexRecords.apply(collector);
// Run the pipeline to fill the collectors.
pipeline.run().waitUntilFinish();
;
// Validate the contents of the collected outputs.
List<IndexedRecord> outputs = collector.getRecords();
assertEquals(2, outputs.size());
assertEquals(inputIndexedRecord1.toString(), outputs.get(0).toString());
assertEquals(inputIndexedRecord2.toString(), outputs.get(1).toString());
}
}
use of org.talend.components.localio.fixedflowinput.FixedFlowInputProperties in project components by Talend.
the class SandboxedFixedFlowInputRuntimeTest method createComponentProperties.
/**
* @return the properties for this component, fully initialized with the default values.
*/
public static FixedFlowInputProperties createComponentProperties() {
// Configure the component.
FixedFlowInputProperties componentProps = new FixedFlowInputProperties(null);
componentProps.init();
return componentProps;
}
Aggregations