use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.
the class LogParserTransformTest method testConfigurePipelineSchemaValidation.
@Test
public void testConfigurePipelineSchemaValidation() {
Schema inputSchemaString = Schema.recordOf("event", Schema.Field.of("CLF", Schema.of(Schema.Type.STRING)), Schema.Field.of("body", Schema.of(Schema.Type.STRING)));
MockPipelineConfigurer mockConfigurer = new MockPipelineConfigurer(inputSchemaString, Collections.emptyMap());
S3_TRANSFORM.configurePipeline(mockConfigurer);
Assert.assertEquals(LOG_SCHEMA, mockConfigurer.getOutputSchema());
Schema inputSchemaBytes = Schema.recordOf("event", Schema.Field.of("CLF", Schema.of(Schema.Type.STRING)), Schema.Field.of("body", Schema.of(Schema.Type.BYTES)));
mockConfigurer = new MockPipelineConfigurer(inputSchemaBytes, Collections.emptyMap());
CLF_TRANSFORM.configurePipeline(mockConfigurer);
Assert.assertEquals(LOG_SCHEMA, mockConfigurer.getOutputSchema());
}
use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.
the class CSVFormatterTest method testSchemaValidation.
@Test
public void testSchemaValidation() {
CSVFormatter.Config config = new CSVFormatter.Config("DELIMITED", "VBAR", OUTPUT.toString());
Transform<StructuredRecord, StructuredRecord> transform = new CSVFormatter(config);
MockPipelineConfigurer mockPipelineConfigurer = new MockPipelineConfigurer(INPUT1);
transform.configurePipeline(mockPipelineConfigurer);
Assert.assertEquals(OUTPUT, mockPipelineConfigurer.getOutputSchema());
}
use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.
the class CSVParserTest method testEmptyCustomDelimiter.
@Test
public void testEmptyCustomDelimiter() {
CSVParser config = new CSVParser(new CSVParser.Config("Custom", null, "body", OUTPUT4.toString()));
MockPipelineConfigurer configurer = new MockPipelineConfigurer(INPUT2);
try {
config.configurePipeline(configurer);
Assert.fail();
} catch (ValidationException e) {
Assert.assertEquals(2, configurer.getStageConfigurer().getFailureCollector().getValidationFailures().size());
}
}
use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.
the class CSVParserTest method testPassThrough.
@Test
public void testPassThrough() throws Exception {
MockEmitter<StructuredRecord> emitter = new MockEmitter<>();
CSVParser.Config config = new CSVParser.Config("DEFAULT", null, "body", OUTPUT3.toString());
Transform<StructuredRecord, StructuredRecord> transform = new CSVParser(config);
MockPipelineConfigurer mockPipelineConfigurer = new MockPipelineConfigurer(INPUT2);
transform.configurePipeline(mockPipelineConfigurer);
transform.initialize(null);
transform.transform(StructuredRecord.builder(INPUT2).set("body", "10,stringA,3,4.32,true").set("offset", 10).build(), emitter);
Assert.assertEquals(10L, emitter.getEmitted().get(0).<Long>get("a").longValue());
Assert.assertEquals("stringA", emitter.getEmitted().get(0).get("b"));
Assert.assertEquals(3, emitter.getEmitted().get(0).<Integer>get("c").intValue());
Assert.assertEquals(4.32d, emitter.getEmitted().get(0).get("d"), 0.0001d);
Assert.assertEquals(true, emitter.getEmitted().get(0).get("e"));
// Pass through from input.
Assert.assertEquals(10, emitter.getEmitted().get(0).<Integer>get("offset").intValue());
}
use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.
the class CSVParserTest method testPassThroughTypeMisMatch.
@Test
public void testPassThroughTypeMisMatch() {
CSVParser.Config config = new CSVParser.Config("DEFAULT", null, "body", OUTPUT4.toString());
Transform<StructuredRecord, StructuredRecord> transform = new CSVParser(config);
MockPipelineConfigurer configurer = new MockPipelineConfigurer(INPUT2);
try {
transform.configurePipeline(configurer);
} catch (ValidationException e) {
Assert.assertEquals(1, configurer.getStageConfigurer().getFailureCollector().getValidationFailures().size());
}
}
Aggregations