use of io.cdap.cdap.etl.proto.v2.validation.StageValidationResponse in project cdap by caskdata.
the class DataPipelineServiceTest method testValidateStageOtherExceptionsCaptured.
// tests that exceptions thrown by configurePipeline that are not InvalidStageExceptions are
// captured as a ValidationFailure.
@Test
public void testValidateStageOtherExceptionsCaptured() throws Exception {
// SleepTransform throws an IllegalArgumentException if the sleep time is less than 1
String stageName = "tx";
ETLStage stage = new ETLStage(stageName, new ETLPlugin(SleepTransform.NAME, Transform.PLUGIN_TYPE, Collections.singletonMap("millis", "-1")));
StageValidationResponse actual = sendRequest(new StageValidationRequest(stage, Collections.emptyList(), false));
Assert.assertNull(actual.getSpec());
Assert.assertEquals(1, actual.getFailures().size());
ValidationFailure failure = actual.getFailures().iterator().next();
Assert.assertEquals(stageName, failure.getCauses().get(0).getAttribute(STAGE));
}
use of io.cdap.cdap.etl.proto.v2.validation.StageValidationResponse in project cdap by caskdata.
the class ValidationUtilsTest method testValidateNoException.
@Test
public void testValidateNoException() {
Schema testSchema = Schema.recordOf("a", Schema.Field.of("a", Schema.of(Schema.Type.STRING)));
StageSchema testStageSchema = new StageSchema("source", testSchema);
ETLStage etlStage = new ETLStage("source", MockSource.getPlugin("testtable"));
StageValidationRequest validationRequest = new StageValidationRequest(etlStage, Collections.singletonList(testStageSchema), false);
StageValidationResponse stageValidationResponse = ValidationUtils.validate(NamespaceId.DEFAULT.getNamespace(), validationRequest, getPluginConfigurer(MockSource.PLUGIN_CLASS), properties -> properties, MOCK_FEATURE_FLAGS_PROVIDER);
Assert.assertTrue(stageValidationResponse.getFailures().isEmpty());
}
Aggregations