use of org.talend.components.localio.fixedflowinput.FixedFlowInputProperties in project components by Talend.
the class FixedFlowInputRuntimeTest method test_TenOutputRow.
@Test
public void test_TenOutputRow() throws Exception {
String inputAsString = generateInputJSON(inputSchema, inputIndexedRecord1);
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(10, outputs.size());
for (IndexedRecord output : outputs) {
assertEquals(inputIndexedRecord1.toString(), output.toString());
}
}
}
use of org.talend.components.localio.fixedflowinput.FixedFlowInputProperties in project components by Talend.
the class FixedFlowInputRuntimeTest method test_NoOutputRow.
@Test
public void test_NoOutputRow() throws Exception {
String inputAsString = generateInputJSON(inputSchema, inputIndexedRecord1);
FixedFlowInputProperties properties = new FixedFlowInputProperties("test");
properties.init();
properties.schemaFlow.schema.setValue(inputSchema);
properties.values.setValue(inputAsString);
properties.nbRows.setValue(0);
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(0, outputs.size());
}
}
use of org.talend.components.localio.fixedflowinput.FixedFlowInputProperties in project components by Talend.
the class FixedFlowInputRuntimeTest method test_MultipleInput_NoOutputRow.
@Test
public void test_MultipleInput_NoOutputRow() 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(0);
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(0, outputs.size());
}
}
use of org.talend.components.localio.fixedflowinput.FixedFlowInputProperties in project components by Talend.
the class SandboxedFixedFlowInputRuntimeTest method testBasic.
@Test
public void testBasic() throws Exception {
// The two records to use as values.
GenericRecord r1 = new GenericData.Record(SampleSchemas.recordSimple());
r1.put("id", 1);
r1.put("name", "one");
GenericRecord r2 = new GenericData.Record(SampleSchemas.recordSimple());
r2.put("id", 2);
r2.put("name", "two");
final FixedFlowInputProperties props = createComponentProperties();
props.schemaFlow.schema.setValue(SampleSchemas.recordSimple());
props.values.setValue(r1.toString());
props.nbRows.setValue(2);
RuntimeInfo ri = def.getRuntimeInfo(ExecutionEngine.BEAM, props, ConnectorTopology.OUTGOING);
try (SandboxedInstance si = RuntimeUtil.createRuntimeClass(ri, getClass().getClassLoader())) {
RuntimableRuntime<FixedFlowInputProperties> runtime = (RuntimableRuntime<FixedFlowInputProperties>) si.getInstance();
runtime.initialize(null, props);
// The functionality of the runtime is tested in its own module.
}
}
use of org.talend.components.localio.fixedflowinput.FixedFlowInputProperties in project components by Talend.
the class FixedFlowInputRuntimeTest method test_OneOutputRow.
@Test
public void test_OneOutputRow() throws Exception {
String inputAsString = generateInputJSON(inputSchema, inputIndexedRecord1);
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(1, outputs.size());
assertEquals(inputIndexedRecord1.toString(), outputs.get(0).toString());
}
}
Aggregations