use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.
the class NormalizeTest method testInvalidNormalizeTypeAndValue.
@Test
public void testInvalidNormalizeTypeAndValue() throws Exception {
Normalize.NormalizeConfig config = new Normalize.NormalizeConfig(validFieldMapping, "ItemId:AttributeType:AttributeValue," + "ItemCost:ExpenseType:ExpenseValue", OUTPUT_SCHEMA.toString());
MockPipelineConfigurer configurer = new MockPipelineConfigurer(INPUT_SCHEMA);
new Normalize(config).configurePipeline(configurer);
FailureCollector collector = configurer.getStageConfigurer().getFailureCollector();
Assert.assertEquals(4, collector.getValidationFailures().size());
}
use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.
the class NormalizeTest method testInvalidNormalizingFromInputSchema.
@Test
public void testInvalidNormalizingFromInputSchema() throws Exception {
Normalize.NormalizeConfig config = new Normalize.NormalizeConfig(validFieldMapping, "ObjectId:AttributeType:AttributeValue," + "ItemCost:AttributeType:AttributeValue", OUTPUT_SCHEMA.toString());
MockPipelineConfigurer configurer = new MockPipelineConfigurer(INPUT_SCHEMA);
new Normalize(config).configurePipeline(configurer);
FailureCollector collector = configurer.getStageConfigurer().getFailureCollector();
Assert.assertEquals(1, collector.getValidationFailures().size());
Assert.assertEquals(1, collector.getValidationFailures().get(0).getCauses().size());
ValidationFailure.Cause expectedCause = new ValidationFailure.Cause();
expectedCause.addAttribute(CauseAttributes.STAGE_CONFIG, Normalize.NormalizeConfig.FIELD_NORMALIZING);
expectedCause.addAttribute(CauseAttributes.CONFIG_ELEMENT, "ObjectId:AttributeType:AttributeValue");
Assert.assertEquals(expectedCause, collector.getValidationFailures().get(0).getCauses().get(0));
}
use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.
the class NormalizeTest method testInvalidMappingsFromInputSchema.
@Test
public void testInvalidMappingsFromInputSchema() throws Exception {
Normalize.NormalizeConfig config = new Normalize.NormalizeConfig("Purchaser:Id,PurchaseDate:Date", validFieldNormalizing, OUTPUT_SCHEMA.toString());
MockPipelineConfigurer configurer = new MockPipelineConfigurer(INPUT_SCHEMA);
new Normalize(config).configurePipeline(configurer);
FailureCollector collector = configurer.getStageConfigurer().getFailureCollector();
Assert.assertEquals(1, collector.getValidationFailures().size());
Assert.assertEquals(1, collector.getValidationFailures().get(0).getCauses().size());
ValidationFailure.Cause expectedCause = new ValidationFailure.Cause();
expectedCause.addAttribute(CauseAttributes.STAGE_CONFIG, Normalize.NormalizeConfig.FIELD_MAPPING);
expectedCause.addAttribute(CauseAttributes.CONFIG_ELEMENT, "Purchaser:Id");
Assert.assertEquals(expectedCause, collector.getValidationFailures().get(0).getCauses().get(0));
}
use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.
the class NormalizeTest method testOutputSchema.
@Test
public void testOutputSchema() throws Exception {
Normalize.NormalizeConfig config = new Normalize.NormalizeConfig(validFieldMapping, validFieldNormalizing, OUTPUT_SCHEMA.toString());
MockPipelineConfigurer configurer = new MockPipelineConfigurer(INPUT_SCHEMA);
new Normalize(config).configurePipeline(configurer);
Assert.assertEquals(OUTPUT_SCHEMA, configurer.getOutputSchema());
}
use of io.cdap.cdap.etl.mock.common.MockPipelineConfigurer in project hydrator-plugins by cdapio.
the class NormalizeTest method testEmptyOutputSchema.
@Test
public void testEmptyOutputSchema() throws Exception {
Normalize.NormalizeConfig config = new Normalize.NormalizeConfig(validFieldMapping, validFieldNormalizing, null);
MockPipelineConfigurer configurer = new MockPipelineConfigurer(INPUT_SCHEMA);
try {
new Normalize(config).configurePipeline(configurer);
Assert.fail();
} catch (ValidationException e) {
Assert.assertEquals(1, e.getFailures().size());
Assert.assertEquals(1, e.getFailures().get(0).getCauses().size());
ValidationFailure.Cause expectedCause = new ValidationFailure.Cause();
expectedCause.addAttribute(STAGE, MOCK_STAGE);
expectedCause.addAttribute(CauseAttributes.STAGE_CONFIG, Normalize.NormalizeConfig.OUTPUT_SCHEMA);
Assert.assertEquals(expectedCause, e.getFailures().get(0).getCauses().get(0));
}
}
Aggregations