use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.
the class UnionSplitterTest method testInvalidSchemas.
@Test
public void testInvalidSchemas() {
Schema inputSchema = Schema.recordOf("union", Schema.Field.of("a", Schema.unionOf(Schema.of(Schema.Type.NULL), Schema.arrayOf(Schema.of(Schema.Type.STRING)))), Schema.Field.of("b", Schema.unionOf(Schema.of(Schema.Type.NULL), Schema.enumWith("something"))), Schema.Field.of("c", Schema.unionOf(Schema.of(Schema.Type.NULL), Schema.mapOf(Schema.of(Schema.Type.STRING), Schema.of(Schema.Type.STRING)))), Schema.Field.of("d", Schema.nullableOf(Schema.of(Schema.Type.STRING))));
FailureCollector collector = new MockFailureCollector();
UnionSplitter.getOutputSchemas(inputSchema, "a", true, collector);
Assert.assertEquals(1, collector.getValidationFailures().size());
Assert.assertEquals(2, collector.getValidationFailures().get(0).getCauses().size());
collector = new MockFailureCollector();
UnionSplitter.getOutputSchemas(inputSchema, "b", true, collector);
Assert.assertEquals(1, collector.getValidationFailures().size());
Assert.assertEquals(2, collector.getValidationFailures().get(0).getCauses().size());
collector = new MockFailureCollector();
UnionSplitter.getOutputSchemas(inputSchema, "c", true, collector);
Assert.assertEquals(1, collector.getValidationFailures().size());
Assert.assertEquals(2, collector.getValidationFailures().get(0).getCauses().size());
collector = new MockFailureCollector();
UnionSplitter.getOutputSchemas(inputSchema, "d", true, collector);
Assert.assertEquals(0, collector.getValidationFailures().size());
}
use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.
the class CSVParserTest method testSchemaValidation.
@Test
public void testSchemaValidation() {
CSVParser.Config config = new CSVParser.Config("DEFAULT", null, "body", OUTPUT1.toString());
CSVParser csvParser = new CSVParser(config);
MockFailureCollector collector = new MockFailureCollector();
csvParser.validateInputSchema(INPUT1, collector);
Assert.assertEquals(0, collector.getValidationFailures().size());
Schema schema = csvParser.parseAndValidateOutputSchema(INPUT1, collector);
Assert.assertEquals(0, collector.getValidationFailures().size());
Assert.assertEquals(OUTPUT1, schema);
}
use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.
the class CSVParserTest method testNullableFieldSchemaValidation.
@Test
public void testNullableFieldSchemaValidation() {
CSVParser.Config config = new CSVParser.Config("DEFAULT", null, "body", OUTPUT1.toString());
CSVParser csvParser = new CSVParser(config);
MockFailureCollector collector = new MockFailureCollector();
csvParser.validateInputSchema(NULLABLE_INPUT, collector);
Assert.assertEquals(0, collector.getValidationFailures().size());
Schema schema = csvParser.parseAndValidateOutputSchema(NULLABLE_INPUT, collector);
Assert.assertEquals(0, collector.getValidationFailures().size());
Assert.assertEquals(OUTPUT1, schema);
}
use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.
the class CloneRecordTest method testInvalidNumberOfCopies.
@Test
public void testInvalidNumberOfCopies() {
CloneRecord.Config config = new CloneRecord.Config(0);
Transform<StructuredRecord, StructuredRecord> transform = new CloneRecord(config);
MockPipelineConfigurer mockPipelineConfigurer = new MockPipelineConfigurer(INPUT);
transform.configurePipeline(mockPipelineConfigurer);
MockFailureCollector failureCollector = (MockFailureCollector) mockPipelineConfigurer.getStageConfigurer().getFailureCollector();
Assert.assertEquals(1, failureCollector.getValidationFailures().size());
}
use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.
the class FileBatchSourceTest method testDelimitedFormatsValidSchema.
@Test
public void testDelimitedFormatsValidSchema() throws Exception {
FileSourceConfig config = new FileSourceConfig();
FailureCollector collector = new MockFailureCollector();
FieldSetter.setField(config, AbstractFileSourceConfig.class.getDeclaredField("referenceName"), "ref");
FieldSetter.setField(config, AbstractFileSourceConfig.class.getDeclaredField("format"), "delimited");
FieldSetter.setField(config, AbstractFileSourceConfig.class.getDeclaredField("schema"), RECORD_SCHEMA_VALID_DATE.toString());
FieldSetter.setField(config, FileSourceConfig.class.getDeclaredField("path"), "path");
config.validate(collector);
Assert.assertEquals(0, collector.getValidationFailures().size());
}
Aggregations