use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.
the class JoinerConfigTest method testJoinerOutputSchema.
@Test
public void testJoinerOutputSchema() {
String joinKeys = "film.film_id=filmActor.film_id=filmCategory.film_id";
String selectedFields = "film.film_id, film.film_name, filmActor.actor_name as renamed_actor, " + "filmCategory.category_name as renamed_category";
String requiredInputs = "film,filmActor,filmCategory";
JoinerConfig joinerConfig = new JoinerConfig(joinKeys, selectedFields, requiredInputs);
Joiner joiner = new Joiner(joinerConfig);
FailureCollector collector = new MockFailureCollector();
AutoJoinerContext autoJoinerContext = new MockAutoJoinerContext(INPUT_STAGES, collector);
JoinDefinition joinDefinition = joiner.define(autoJoinerContext);
Assert.assertEquals(OUTPUT_SCHEMA, joinDefinition.getOutputSchema());
Assert.assertEquals(0, collector.getValidationFailures().size());
}
use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.
the class JoinerConfigTest method testJoinerConfigWithoutRequiredInputs.
@Test
public void testJoinerConfigWithoutRequiredInputs() {
Schema outputSchema = Schema.recordOf("join.output", Schema.Field.of("film_id", Schema.of(Schema.Type.STRING)), Schema.Field.of("film_name", Schema.of(Schema.Type.STRING)), Schema.Field.of("renamed_actor", Schema.nullableOf(Schema.of(Schema.Type.STRING))), Schema.Field.of("renamed_category", Schema.nullableOf(Schema.of(Schema.Type.STRING))));
JoinerConfig config = new JoinerConfig("film.film_id=filmActor.film_id=filmCategory.film_id&" + "film.film_name=filmActor.film_name=filmCategory.film_name", SELECTED_FIELDS, "film");
Joiner joiner = new Joiner(config);
FailureCollector collector = new MockFailureCollector();
AutoJoinerContext autoJoinerContext = new MockAutoJoinerContext(INPUT_STAGES, collector);
JoinDefinition joinDefinition = joiner.define(autoJoinerContext);
Assert.assertEquals(outputSchema, joinDefinition.getOutputSchema());
Assert.assertEquals(0, collector.getValidationFailures().size());
}
use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.
the class JoinerConfigTest method testJoinerWithNullableSchema.
@Test
public void testJoinerWithNullableSchema() {
Schema filmCategorySchema = Schema.recordOf("filmCategory", Schema.Field.of("film_id", Schema.of(Schema.Type.STRING)), Schema.Field.of("film_name", Schema.of(Schema.Type.STRING)), Schema.Field.of("category_name", Schema.nullableOf(Schema.of(Schema.Type.STRING))));
String joinKeys = "film.film_id=filmActor.film_id=filmCategory.film_id";
String selectedFields = "film.film_id, film.film_name, filmActor.actor_name as renamed_actor, " + "filmCategory.category_name as renamed_category";
String requiredInputs = "film,filmActor";
JoinerConfig conf = new JoinerConfig(joinKeys, selectedFields, requiredInputs);
Schema outputSchema = Schema.recordOf("join.output", Schema.Field.of("film_id", Schema.of(Schema.Type.STRING)), Schema.Field.of("film_name", Schema.of(Schema.Type.STRING)), Schema.Field.of("renamed_actor", Schema.of(Schema.Type.STRING)), Schema.Field.of("renamed_category", filmCategorySchema.getField("category_name").getSchema()));
Joiner joiner = new Joiner(conf);
FailureCollector collector = new MockFailureCollector();
AutoJoinerContext autoJoinerContext = new MockAutoJoinerContext(INPUT_STAGES, collector);
JoinDefinition joinDefinition = joiner.define(autoJoinerContext);
Assert.assertEquals(outputSchema, joinDefinition.getOutputSchema());
Assert.assertEquals(0, collector.getValidationFailures().size());
}
use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.
the class XMLReaderConfigTest method testEmptyNodePath.
@Test
public void testEmptyNodePath() {
XMLReaderBatchSource.XMLReaderConfig config = new XMLReaderBatchSource.XMLReaderConfig("emptyNodePathReference", "/opt/hdfs/catalog.xml", null, "", null, null, "Yes", "XMLTrackingTable", 30, "/tmp");
FailureCollector collector = new MockFailureCollector();
config.validate(collector);
Assert.assertEquals(1, collector.getValidationFailures().size());
Assert.assertEquals(1, collector.getValidationFailures().get(0).getCauses().size());
Cause expectedCause = new Cause();
expectedCause.addAttribute(CauseAttributes.STAGE_CONFIG, XMLReaderBatchSource.XMLReaderConfig.NODE_PATH);
Assert.assertEquals(expectedCause, collector.getValidationFailures().get(0).getCauses().get(0));
}
use of io.cdap.cdap.etl.mock.validation.MockFailureCollector in project hydrator-plugins by cdapio.
the class XMLReaderConfigTest method testEmptyTemporaryFolder.
@Test
public void testEmptyTemporaryFolder() {
XMLReaderBatchSource.XMLReaderConfig config = new XMLReaderBatchSource.XMLReaderConfig("emptyNodePathReference", "/opt/hdfs/catalog.xml", null, "/catalog/book/", "Delete", null, "No", "XMLTrackingTable", 30, null);
FailureCollector collector = new MockFailureCollector();
config.validate(collector);
Assert.assertEquals(1, collector.getValidationFailures().size());
Assert.assertEquals(1, collector.getValidationFailures().get(0).getCauses().size());
Cause expectedCause = new Cause();
expectedCause.addAttribute(CauseAttributes.STAGE_CONFIG, XMLReaderBatchSource.XMLReaderConfig.TEMPORARY_FOLDER);
Assert.assertEquals(expectedCause, collector.getValidationFailures().get(0).getCauses().get(0));
}
Aggregations