Search in sources :

Example 6 with FixedFlowInputProperties

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());
        }
    }
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) FixedFlowInputProperties(org.talend.components.localio.fixedflowinput.FixedFlowInputProperties) Test(org.junit.Test)

Example 7 with FixedFlowInputProperties

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());
    }
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) FixedFlowInputProperties(org.talend.components.localio.fixedflowinput.FixedFlowInputProperties) Test(org.junit.Test)

Example 8 with FixedFlowInputProperties

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;
}
Also used : FixedFlowInputProperties(org.talend.components.localio.fixedflowinput.FixedFlowInputProperties)

Aggregations

FixedFlowInputProperties (org.talend.components.localio.fixedflowinput.FixedFlowInputProperties)8 IndexedRecord (org.apache.avro.generic.IndexedRecord)7 Test (org.junit.Test)7 GenericRecord (org.apache.avro.generic.GenericRecord)1 RuntimableRuntime (org.talend.components.api.component.runtime.RuntimableRuntime)1 RuntimeInfo (org.talend.daikon.runtime.RuntimeInfo)1 SandboxedInstance (org.talend.daikon.sandbox.SandboxedInstance)1