Search in sources :

Example 1 with PipelineConfigurer

use of io.cdap.cdap.etl.api.PipelineConfigurer in project hydrator-plugins by cdapio.

the class XMLToJSONConverterTest method testInvalidInputFieldType.

@Test
public void testInvalidInputFieldType() throws Exception {
    Schema schema = Schema.recordOf("input1", Schema.Field.of("body", Schema.of(Schema.Type.INT)));
    XMLToJSON.Config config = new XMLToJSON.Config("body", "jsonevent", OUTPUT.toString());
    PipelineConfigurer configurer = new MockPipelineConfigurer(schema);
    FailureCollector collector = configurer.getStageConfigurer().getFailureCollector();
    XMLToJSON converter = new XMLToJSON(config);
    converter.configurePipeline(configurer);
    Assert.assertEquals(1, collector.getValidationFailures().size());
    Assert.assertEquals(2, collector.getValidationFailures().get(0).getCauses().size());
}
Also used : MockPipelineConfigurer(io.cdap.cdap.etl.mock.common.MockPipelineConfigurer) Schema(io.cdap.cdap.api.data.schema.Schema) PipelineConfigurer(io.cdap.cdap.etl.api.PipelineConfigurer) MockPipelineConfigurer(io.cdap.cdap.etl.mock.common.MockPipelineConfigurer) FailureCollector(io.cdap.cdap.etl.api.FailureCollector) Test(org.junit.Test)

Example 2 with PipelineConfigurer

use of io.cdap.cdap.etl.api.PipelineConfigurer in project hydrator-plugins by cdapio.

the class XMLToJSONConverterTest method testInvalidInputField.

@Test
public void testInvalidInputField() throws Exception {
    XMLToJSON.Config config = new XMLToJSON.Config("does_not_exist", "jsonevent", OUTPUT.toString());
    PipelineConfigurer configurer = new MockPipelineConfigurer(INPUT);
    FailureCollector collector = configurer.getStageConfigurer().getFailureCollector();
    XMLToJSON converter = new XMLToJSON(config);
    converter.configurePipeline(configurer);
    Assert.assertEquals(1, collector.getValidationFailures().size());
    Assert.assertEquals(1, collector.getValidationFailures().get(0).getCauses().size());
    Cause expectedCause = new Cause();
    expectedCause.addAttribute(CauseAttributes.STAGE_CONFIG, "inputField");
    Assert.assertEquals(expectedCause, collector.getValidationFailures().get(0).getCauses().get(0));
}
Also used : MockPipelineConfigurer(io.cdap.cdap.etl.mock.common.MockPipelineConfigurer) Cause(io.cdap.cdap.etl.api.validation.ValidationFailure.Cause) PipelineConfigurer(io.cdap.cdap.etl.api.PipelineConfigurer) MockPipelineConfigurer(io.cdap.cdap.etl.mock.common.MockPipelineConfigurer) FailureCollector(io.cdap.cdap.etl.api.FailureCollector) Test(org.junit.Test)

Aggregations

FailureCollector (io.cdap.cdap.etl.api.FailureCollector)2 PipelineConfigurer (io.cdap.cdap.etl.api.PipelineConfigurer)2 MockPipelineConfigurer (io.cdap.cdap.etl.mock.common.MockPipelineConfigurer)2 Test (org.junit.Test)2 Schema (io.cdap.cdap.api.data.schema.Schema)1 Cause (io.cdap.cdap.etl.api.validation.ValidationFailure.Cause)1