Search in sources :

Example 1 with Validation

use of org.kie.dmn.validation.DMNValidator.Validation in project drools by kiegroup.

the class PMMLValidatorImportTest method testImportPMML2.

@Test
public void testImportPMML2() throws IOException {
    // DROOLS-4395 [DMN Designer] Validation fails for included PMML model
    try (Reader defsReader = getReader("KiePMMLScoreCard_wInputType.dmn", DMNRuntimePMMLTest.class)) {
        final Definitions defs = getDefinitions(defsReader, "http://www.trisotech.com/definitions/_ca466dbe-20b4-4e88-a43f-4ce3aff26e4f", "KiePMMLScoreCard");
        DMNValidator.ValidatorBuilder.ValidatorImportReaderResolver resolver = (ns, name, i) -> {
            if (ns.equals(defs.getNamespace()) && name.equals(defs.getName()) && i.equals(defs.getImport().get(0).getLocationURI())) {
                return getReader("test_scorecard.pmml", DMNRuntimePMMLTest.class);
            } else {
                return null;
            }
        };
        final List<DMNMessage> messages = validator.validateUsing(Validation.VALIDATE_MODEL, Validation.VALIDATE_COMPILATION).usingImports(resolver).theseModels(defs);
        assertThat(ValidatorUtil.formatMessages(messages), messages.size(), is(0));
    }
}
Also used : AbstractValidatorTest(org.kie.dmn.validation.AbstractValidatorTest) CoreMatchers.is(org.hamcrest.CoreMatchers.is) DMNValidator(org.kie.dmn.validation.DMNValidator) List(java.util.List) DMNMessage(org.kie.dmn.api.core.DMNMessage) Validation(org.kie.dmn.validation.DMNValidator.Validation) Test(org.junit.Test) IOException(java.io.IOException) Reader(java.io.Reader) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ValidatorUtil(org.kie.dmn.validation.ValidatorUtil) Definitions(org.kie.dmn.model.api.Definitions) DMNMessage(org.kie.dmn.api.core.DMNMessage) Definitions(org.kie.dmn.model.api.Definitions) Reader(java.io.Reader) AbstractValidatorTest(org.kie.dmn.validation.AbstractValidatorTest) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 Reader (java.io.Reader)1 List (java.util.List)1 CoreMatchers.is (org.hamcrest.CoreMatchers.is)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Test (org.junit.Test)1 DMNMessage (org.kie.dmn.api.core.DMNMessage)1 Definitions (org.kie.dmn.model.api.Definitions)1 AbstractValidatorTest (org.kie.dmn.validation.AbstractValidatorTest)1 DMNValidator (org.kie.dmn.validation.DMNValidator)1 Validation (org.kie.dmn.validation.DMNValidator.Validation)1 ValidatorUtil (org.kie.dmn.validation.ValidatorUtil)1