Search in sources :

Example 16 with StageValidationResponse

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));
}
Also used : StageValidationRequest(io.cdap.cdap.etl.proto.v2.validation.StageValidationRequest) ETLStage(io.cdap.cdap.etl.proto.v2.ETLStage) ETLPlugin(io.cdap.cdap.etl.proto.v2.ETLPlugin) StageValidationResponse(io.cdap.cdap.etl.proto.v2.validation.StageValidationResponse) ValidationFailure(io.cdap.cdap.etl.api.validation.ValidationFailure) Test(org.junit.Test)

Example 17 with StageValidationResponse

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());
}
Also used : StageSchema(io.cdap.cdap.etl.proto.v2.validation.StageSchema) StageValidationRequest(io.cdap.cdap.etl.proto.v2.validation.StageValidationRequest) ETLStage(io.cdap.cdap.etl.proto.v2.ETLStage) StageSchema(io.cdap.cdap.etl.proto.v2.validation.StageSchema) Schema(io.cdap.cdap.api.data.schema.Schema) StageValidationResponse(io.cdap.cdap.etl.proto.v2.validation.StageValidationResponse) Test(org.junit.Test)

Aggregations

StageValidationResponse (io.cdap.cdap.etl.proto.v2.validation.StageValidationResponse)17 ETLStage (io.cdap.cdap.etl.proto.v2.ETLStage)16 StageValidationRequest (io.cdap.cdap.etl.proto.v2.validation.StageValidationRequest)16 Test (org.junit.Test)15 ETLPlugin (io.cdap.cdap.etl.proto.v2.ETLPlugin)10 StageSchema (io.cdap.cdap.etl.proto.v2.validation.StageSchema)10 Schema (io.cdap.cdap.api.data.schema.Schema)9 ValidationFailure (io.cdap.cdap.etl.api.validation.ValidationFailure)9 HashMap (java.util.HashMap)6 ArtifactSelectorConfig (io.cdap.cdap.etl.proto.ArtifactSelectorConfig)2 StageSpec (io.cdap.cdap.etl.proto.v2.spec.StageSpec)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 ArtifactScope (io.cdap.cdap.api.artifact.ArtifactScope)1 MacroEvaluator (io.cdap.cdap.api.macro.MacroEvaluator)1 MacroParserOptions (io.cdap.cdap.api.macro.MacroParserOptions)1 PluginConfigurer (io.cdap.cdap.api.plugin.PluginConfigurer)1 RunnableTask (io.cdap.cdap.api.service.worker.RunnableTask)1