use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.
the class ProjectionTransformTest method testKeepDropBothNonNull.
@Test
public void testKeepDropBothNonNull() {
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());
try {
ProjectionTransform.ProjectionTransformConfig config = new ProjectionTransform.ProjectionTransformConfig("y, z", null, null, "x,y");
new ProjectionTransform(config).configurePipeline(mockConfigurer);
Assert.fail();
} catch (ValidationException e) {
Assert.assertEquals(1, e.getFailures().size());
Assert.assertEquals(2, e.getFailures().get(0).getCauses().size());
}
}
use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.
the class ProjectionTransformTest method testKeepFieldsValidations.
@Test
public void testKeepFieldsValidations() {
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(null, null, null, "n");
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.KEEP);
expectedCause.addAttribute(CauseAttributes.CONFIG_ELEMENT, "n");
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 KVTableSinkTest method testTableSinkWithNullTypeForKey.
@Test(expected = IllegalArgumentException.class)
public void testTableSinkWithNullTypeForKey() {
Schema inputSchema = Schema.recordOf("purchase", // only string and bytes are supported, this is invalid type
Schema.Field.of("rowKey", Schema.nullableOf(Schema.of(Schema.Type.STRING))), Schema.Field.of("user", Schema.of(Schema.Type.STRING)));
KVTableSink.KVTableConfig kvTableConfig = new KVTableSink.KVTableConfig("purchases", "rowKey", "user");
KVTableSink kvTableSink = new KVTableSink(kvTableConfig);
MockPipelineConfigurer mockPipelineConfigurer = new MockPipelineConfigurer(inputSchema);
kvTableSink.configurePipeline(mockPipelineConfigurer);
}
use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.
the class KVTableSinkTest method testTableSinkWithNullableTypeForValue.
@Test
public void testTableSinkWithNullableTypeForValue() {
Schema inputSchema = Schema.recordOf("purchase", // only string and bytes are supported, this is invalid type
Schema.Field.of("user", Schema.nullableOf(Schema.of(Schema.Type.STRING))), Schema.Field.of("rowKey", Schema.of(Schema.Type.STRING)));
KVTableSink.KVTableConfig kvTableConfig = new KVTableSink.KVTableConfig("purchases", "rowKey", "user");
KVTableSink kvTableSink = new KVTableSink(kvTableConfig);
MockPipelineConfigurer mockPipelineConfigurer = new MockPipelineConfigurer(inputSchema);
kvTableSink.configurePipeline(mockPipelineConfigurer);
}
use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.
the class KVTableSinkTest method testTableSinkWithMissingValueField.
@Test(expected = IllegalArgumentException.class)
public void testTableSinkWithMissingValueField() {
Schema inputSchema = Schema.recordOf("purchase", Schema.Field.of("rowKey", Schema.of(Schema.Type.STRING)), Schema.Field.of("userid", Schema.of(Schema.Type.STRING)));
KVTableSink.KVTableConfig kvTableConfig = new KVTableSink.KVTableConfig("purchases", "rowKey", "user");
KVTableSink kvTableSink = new KVTableSink(kvTableConfig);
MockPipelineConfigurer mockPipelineConfigurer = new MockPipelineConfigurer(inputSchema);
kvTableSink.configurePipeline(mockPipelineConfigurer);
}
Aggregations