use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.
the class TableSinkTest method testTableSinkWithComplexTypeInOutputSchema.
@Test
public void testTableSinkWithComplexTypeInOutputSchema() {
Schema outputSchema = Schema.recordOf("purchase", Schema.Field.of("rowkey", Schema.of(Schema.Type.STRING)), Schema.Field.of("user", Schema.of(Schema.Type.STRING)), Schema.Field.of("complex", Schema.mapOf(Schema.of(Schema.Type.STRING), Schema.of(Schema.Type.STRING))));
Schema inputSchema = Schema.recordOf("purchase", Schema.Field.of("rowkey", Schema.of(Schema.Type.STRING)), Schema.Field.of("user", Schema.of(Schema.Type.STRING)), Schema.Field.of("complex", Schema.mapOf(Schema.of(Schema.Type.STRING), Schema.of(Schema.Type.STRING))));
TableSinkConfig tableSinkConfig = new TableSinkConfig("tableSink", "rowkey", outputSchema.toString());
TableSink tableSink = new TableSink(tableSinkConfig);
MockPipelineConfigurer mockPipelineConfigurer = new MockPipelineConfigurer(inputSchema);
tableSink.configurePipeline(mockPipelineConfigurer);
FailureCollector collector = mockPipelineConfigurer.getStageConfigurer().getFailureCollector();
Assert.assertEquals(1, collector.getValidationFailures().size());
}
use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.
the class TableSinkTest method testTableSinkWithOutputSchemaWithOnlyRowKeyField.
@Test(expected = IllegalArgumentException.class)
public void testTableSinkWithOutputSchemaWithOnlyRowKeyField() {
Schema outputSchema = Schema.recordOf("purchase", Schema.Field.of("rowkey", Schema.of(Schema.Type.STRING)));
Schema inputSchema = Schema.recordOf("purchase", Schema.Field.of("rowkey", Schema.of(Schema.Type.STRING)), Schema.Field.of("user", Schema.of(Schema.Type.STRING)), Schema.Field.of("count", Schema.of(Schema.Type.INT)));
TableSinkConfig tableSinkConfig = new TableSinkConfig("tableSink", "rowkey", outputSchema.toString());
TableSink tableSink = new TableSink(tableSinkConfig);
MockPipelineConfigurer mockPipelineConfigurer = new MockPipelineConfigurer(inputSchema);
tableSink.configurePipeline(mockPipelineConfigurer);
}
use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.
the class TableSinkTest method testTableSinkWithOutputSchemaMissingRowKeyField.
@Test(expected = IllegalArgumentException.class)
public void testTableSinkWithOutputSchemaMissingRowKeyField() {
Schema outputSchema = Schema.recordOf("purchase", Schema.Field.of("user", Schema.of(Schema.Type.STRING)), Schema.Field.of("count", Schema.of(Schema.Type.INT)));
Schema inputSchema = Schema.recordOf("purchase", Schema.Field.of("rowkey", Schema.of(Schema.Type.STRING)), Schema.Field.of("user", Schema.of(Schema.Type.STRING)), Schema.Field.of("count", Schema.of(Schema.Type.INT)));
TableSinkConfig tableSinkConfig = new TableSinkConfig("tableSink", "rowkey", outputSchema.toString());
TableSink tableSink = new TableSink(tableSinkConfig);
MockPipelineConfigurer mockPipelineConfigurer = new MockPipelineConfigurer(inputSchema);
tableSink.configurePipeline(mockPipelineConfigurer);
}
use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.
the class ProjectionTransformTest method testDropFieldsValidations.
@Test
public void testDropFieldsValidations() {
Schema schema = Schema.recordOf("three", Schema.Field.of("x", Schema.of(Schema.Type.INT)), Schema.Field.of("y", Schema.of(Schema.Type.DOUBLE)), Schema.Field.of("z", Schema.arrayOf(Schema.of(Schema.Type.INT))));
MockPipelineConfigurer mockConfigurer = new MockPipelineConfigurer(schema, Collections.emptyMap());
ProjectionTransform.ProjectionTransformConfig config = new ProjectionTransform.ProjectionTransformConfig("x,y,z", null, null, null);
try {
new ProjectionTransform(config).configurePipeline(mockConfigurer);
Assert.fail();
} catch (ValidationException e) {
Assert.assertEquals(1, e.getFailures().size());
Assert.assertEquals(1, e.getFailures().get(0).getCauses().size());
Cause expectedCause = new Cause();
expectedCause.addAttribute(CauseAttributes.STAGE_CONFIG, ProjectionTransform.ProjectionTransformConfig.DROP);
expectedCause.addAttribute(STAGE, MOCK_STAGE);
Assert.assertEquals(expectedCause, e.getFailures().get(0).getCauses().get(0));
}
}
use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.
the class LogParserTransformTest method testConfigurePipelineSchemaValidationError.
@Test
public void testConfigurePipelineSchemaValidationError() {
MockPipelineConfigurer mockConfigurer = new MockPipelineConfigurer(Schema.of(Schema.Type.BYTES), Collections.emptyMap());
S3_TRANSFORM.configurePipeline(mockConfigurer);
Assert.assertEquals(LOG_SCHEMA, mockConfigurer.getOutputSchema());
FailureCollector collector = mockConfigurer.getStageConfigurer().getFailureCollector();
Assert.assertEquals(1, mockConfigurer.getStageConfigurer().getFailureCollector().getValidationFailures().size());
Assert.assertEquals(0, collector.getValidationFailures().get(0).getCauses().size());
}
Aggregations