use of io.cdap.cdap.etl.proto.v2.spec.PluginSpec in project cdap by caskdata.
the class PipelineSpecGeneratorTest method testOutputPorts.
@Test
public void testOutputPorts() throws ValidationException {
/*
*
* |portA --> sinkA
* |
* source --> split --|portB --> sinkB
* |
* |portC --> sinkC
*
* portA has output schemaA, portB has output schemaB, portC has null output schema
*/
ETLBatchConfig config = ETLBatchConfig.builder().setTimeSchedule("* * * * *").addStage(new ETLStage("source", MOCK_SOURCE)).addStage(new ETLStage("split", MOCK_SPLITTER)).addStage(new ETLStage("sinkA", MOCK_SINK)).addStage(new ETLStage("sinkB", MOCK_SINK)).addStage(new ETLStage("sinkC", MOCK_SINK)).addConnection("source", "split").addConnection("source", "split").addConnection("split", "sinkA", "portA").addConnection("split", "sinkB", "portB").addConnection("split", "sinkC", "portC").setNumOfRecordsPreview(100).build();
Map<String, String> emptyMap = Collections.emptyMap();
PipelineSpec expected = BatchPipelineSpec.builder().addStage(StageSpec.builder("source", new PluginSpec(BatchSource.PLUGIN_TYPE, "mocksource", EMPTY_MAP, ARTIFACT_ID)).addOutput(SCHEMA_A, "split").build()).addStage(StageSpec.builder("split", new PluginSpec(SplitterTransform.PLUGIN_TYPE, "mocksplit", EMPTY_MAP, ARTIFACT_ID)).addInputSchema("source", SCHEMA_A).addOutput("sinkA", "portA", SCHEMA_A).addOutput("sinkB", "portB", SCHEMA_B).addOutput("sinkC", "portC", null).setErrorSchema(SCHEMA_A).build()).addStage(StageSpec.builder("sinkA", new PluginSpec(BatchSink.PLUGIN_TYPE, "mocksink", EMPTY_MAP, ARTIFACT_ID)).addInputSchema("split", SCHEMA_A).setErrorSchema(SCHEMA_A).build()).addStage(StageSpec.builder("sinkB", new PluginSpec(BatchSink.PLUGIN_TYPE, "mocksink", EMPTY_MAP, ARTIFACT_ID)).addInputSchema("split", SCHEMA_B).setErrorSchema(SCHEMA_B).build()).addStage(StageSpec.builder("sinkC", new PluginSpec(BatchSink.PLUGIN_TYPE, "mocksink", EMPTY_MAP, ARTIFACT_ID)).addInputSchema("split", null).build()).addConnections(config.getConnections()).setResources(config.getResources()).setDriverResources(config.getDriverResources()).setClientResources(config.getClientResources()).setStageLoggingEnabled(config.isStageLoggingEnabled()).setNumOfRecordsPreview(config.getNumOfRecordsPreview()).build();
PipelineSpec actual = specGenerator.generateSpec(config);
Assert.assertEquals(expected, actual);
}
Aggregations