Search in sources :

Example 41 with MockPipelineConfigurer

use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.

the class TableSinkTest method testTableSinkWithOutputSchemaWithOneNonRowKeyField.

@Test(expected = IllegalArgumentException.class)
public void testTableSinkWithOutputSchemaWithOneNonRowKeyField() {
    Schema outputSchema = Schema.recordOf("purchase", Schema.Field.of("user", 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);
}
Also used : MockPipelineConfigurer(io.cdap.cdap.etl.mock.common.MockPipelineConfigurer) Schema(io.cdap.cdap.api.data.schema.Schema) TableSinkConfig(io.cdap.plugin.common.TableSinkConfig) Test(org.junit.Test)

Example 42 with MockPipelineConfigurer

use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.

the class TableSinkTest method testTableSinkWithOutputSchemaExtraField.

@Test
public void testTableSinkWithOutputSchemaExtraField() {
    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("points", Schema.of(Schema.Type.DOUBLE)));
    Schema inputSchema = Schema.recordOf("purchase", Schema.Field.of("rowkey", Schema.of(Schema.Type.STRING)), Schema.Field.of("user", 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());
}
Also used : MockPipelineConfigurer(io.cdap.cdap.etl.mock.common.MockPipelineConfigurer) Schema(io.cdap.cdap.api.data.schema.Schema) TableSinkConfig(io.cdap.plugin.common.TableSinkConfig) FailureCollector(io.cdap.cdap.etl.api.FailureCollector) Test(org.junit.Test)

Example 43 with MockPipelineConfigurer

use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.

the class TableSinkTest method testTableSinkWithFieldTypeMismatch.

@Test
public void testTableSinkWithFieldTypeMismatch() {
    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("item", 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("item", 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());
}
Also used : MockPipelineConfigurer(io.cdap.cdap.etl.mock.common.MockPipelineConfigurer) Schema(io.cdap.cdap.api.data.schema.Schema) TableSinkConfig(io.cdap.plugin.common.TableSinkConfig) FailureCollector(io.cdap.cdap.etl.api.FailureCollector) Test(org.junit.Test)

Example 44 with MockPipelineConfigurer

use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.

the class TableSinkTest method testTableSinkWithMissingOutputSchema.

@Test
public void testTableSinkWithMissingOutputSchema() {
    TableSinkConfig tableSinkConfig = new TableSinkConfig("tableSink", "rowkey", null);
    TableSink tableSink = new TableSink(tableSinkConfig);
    MockPipelineConfigurer mockPipelineConfigurer = new MockPipelineConfigurer(null);
    tableSink.configurePipeline(mockPipelineConfigurer);
}
Also used : MockPipelineConfigurer(io.cdap.cdap.etl.mock.common.MockPipelineConfigurer) TableSinkConfig(io.cdap.plugin.common.TableSinkConfig) Test(org.junit.Test)

Example 45 with MockPipelineConfigurer

use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.

the class TableSinkTest method testTableSinkWithComplexTypeSkipped.

@Test
public void testTableSinkWithComplexTypeSkipped() {
    Schema outputSchema = Schema.recordOf("purchase", Schema.Field.of("rowkey", Schema.of(Schema.Type.STRING)), Schema.Field.of("user", 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);
}
Also used : MockPipelineConfigurer(io.cdap.cdap.etl.mock.common.MockPipelineConfigurer) Schema(io.cdap.cdap.api.data.schema.Schema) TableSinkConfig(io.cdap.plugin.common.TableSinkConfig) Test(org.junit.Test)

Aggregations

MockPipelineConfigurer (io.cdap.cdap.etl.mock.common.MockPipelineConfigurer)89 Test (org.junit.Test)89 Schema (io.cdap.cdap.api.data.schema.Schema)56 FailureCollector (io.cdap.cdap.etl.api.FailureCollector)26 StructuredRecord (io.cdap.cdap.api.data.format.StructuredRecord)22 ValidationException (io.cdap.cdap.etl.api.validation.ValidationException)17 Cause (io.cdap.cdap.etl.api.validation.ValidationFailure.Cause)12 ValidationFailure (io.cdap.cdap.etl.api.validation.ValidationFailure)10 TableSinkConfig (io.cdap.plugin.common.TableSinkConfig)10 HBaseSink (io.cdap.plugin.sink.HBaseSink)7 ETLBatchConfig (io.cdap.cdap.etl.proto.v2.ETLBatchConfig)5 MockEmitter (io.cdap.cdap.etl.mock.common.MockEmitter)4 TransformContext (io.cdap.cdap.etl.api.TransformContext)3 MockTransformContext (io.cdap.cdap.etl.mock.transform.MockTransformContext)3 SolrSearchSink (io.cdap.plugin.batch.SolrSearchSink)3 PipelineConfigurer (io.cdap.cdap.etl.api.PipelineConfigurer)2 LookupConfig (io.cdap.cdap.etl.api.LookupConfig)1 LookupTableConfig (io.cdap.cdap.etl.api.LookupTableConfig)1 MockFailureCollector (io.cdap.cdap.etl.mock.validation.MockFailureCollector)1