Search in sources :

Example 16 with DMNMessage

use of org.kie.dmn.api.core.DMNMessage in project drools by kiegroup.

the class ValidatorTest method testInvalidXml.

@Test
public void testInvalidXml() throws URISyntaxException {
    List<DMNMessage> validateXML = validator.validate(new File(this.getClass().getResource("invalidXml.dmn").toURI()), DMNValidator.Validation.VALIDATE_SCHEMA);
    assertThat(ValidatorUtil.formatMessages(validateXML), validateXML.size(), is(1));
    assertThat(validateXML.get(0).toString(), validateXML.get(0).getMessageType(), is(DMNMessageType.FAILED_XML_VALIDATION));
}
Also used : DMNMessage(org.kie.dmn.api.core.DMNMessage) File(java.io.File) Test(org.junit.Test) DMNInputRuntimeTest(org.kie.dmn.core.DMNInputRuntimeTest)

Example 17 with DMNMessage

use of org.kie.dmn.api.core.DMNMessage in project drools by kiegroup.

the class ValidatorTest method testINVOCATION_MISSING_TARGET.

@Test
@Ignore("Needs to be improved as invocations can be used to invoke functions node defined in BKMs. E.g., FEEL built in functions, etc.")
public void testINVOCATION_MISSING_TARGET() {
    Definitions definitions = utilDefinitions("INVOCATION_MISSING_TARGET.dmn", "INVOCATION_MISSING_TARGET");
    List<DMNMessage> validate = validator.validate(definitions);
// assertTrue( validate.stream().anyMatch( p -> p.getMessageType().equals( DMNMessageType.INVOCATION_MISSING_TARGET ) ) );
}
Also used : DMNMessage(org.kie.dmn.api.core.DMNMessage) Definitions(org.kie.dmn.model.v1_1.Definitions) Ignore(org.junit.Ignore) Test(org.junit.Test) DMNInputRuntimeTest(org.kie.dmn.core.DMNInputRuntimeTest)

Example 18 with DMNMessage

use of org.kie.dmn.api.core.DMNMessage in project drools by kiegroup.

the class ValidatorTypeRefTest method testTYPEREF_NOT_FEEL_NOT_DEF_ReaderInput.

@Test
public void testTYPEREF_NOT_FEEL_NOT_DEF_ReaderInput() throws IOException {
    try (final Reader reader = getReader("typeref/TYPEREF_NOT_FEEL_NOT_DEF.dmn")) {
        final List<DMNMessage> validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION);
        assertThat(ValidatorUtil.formatMessages(validate), validate.size(), is(2));
        assertTrue(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.INVALID_NAME)));
        assertTrue(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.TYPE_DEF_NOT_FOUND)));
    }
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) Assert.assertThat(org.junit.Assert.assertThat) List(java.util.List) DMNMessage(org.kie.dmn.api.core.DMNMessage) VALIDATE_SCHEMA(org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA) DMNMessageType(org.kie.dmn.api.core.DMNMessageType) VALIDATE_COMPILATION(org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) Reader(java.io.Reader) VALIDATE_MODEL(org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL) DMNMessage(org.kie.dmn.api.core.DMNMessage) Reader(java.io.Reader) Test(org.junit.Test)

Example 19 with DMNMessage

use of org.kie.dmn.api.core.DMNMessage in project drools by kiegroup.

the class ValidatorTypeRefTest method testTYPEREF_NOT_FEEL_NOT_DEF_valid_ResourceInput.

@Test
public void testTYPEREF_NOT_FEEL_NOT_DEF_valid_ResourceInput() throws IOException {
    // the test also highlight typically in a DMN model many nodes would not define a typeRef, resulting in a large number of false negative
    try (final Reader reader = getReader("typeref/TYPEREF_NOT_FEEL_NOT_DEF_valid.dmn")) {
        final List<DMNMessage> validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION);
        assertThat(ValidatorUtil.formatMessages(validate), validate.size(), is(0));
    }
}
Also used : DMNMessage(org.kie.dmn.api.core.DMNMessage) Reader(java.io.Reader) Test(org.junit.Test)

Example 20 with DMNMessage

use of org.kie.dmn.api.core.DMNMessage in project drools by kiegroup.

the class ValidatorTypeRefTest method testTYPEREF_NO_FEEL_TYPE_ReaderInput.

@Test
public void testTYPEREF_NO_FEEL_TYPE_ReaderInput() throws IOException {
    try (final Reader reader = getReader("typeref/TYPEREF_NO_FEEL_TYPE.dmn")) {
        final List<DMNMessage> validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION);
        assertThat(ValidatorUtil.formatMessages(validate), validate.size(), is(1));
        assertTrue(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.TYPE_REF_NOT_FOUND)));
    }
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) Assert.assertThat(org.junit.Assert.assertThat) List(java.util.List) DMNMessage(org.kie.dmn.api.core.DMNMessage) VALIDATE_SCHEMA(org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA) DMNMessageType(org.kie.dmn.api.core.DMNMessageType) VALIDATE_COMPILATION(org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) Reader(java.io.Reader) VALIDATE_MODEL(org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL) DMNMessage(org.kie.dmn.api.core.DMNMessage) Reader(java.io.Reader) Test(org.junit.Test)

Aggregations

DMNMessage (org.kie.dmn.api.core.DMNMessage)59 Test (org.junit.Test)58 Reader (java.io.Reader)52 IOException (java.io.IOException)46 List (java.util.List)46 CoreMatchers.is (org.hamcrest.CoreMatchers.is)46 DMNMessageType (org.kie.dmn.api.core.DMNMessageType)46 VALIDATE_COMPILATION (org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION)46 VALIDATE_MODEL (org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL)46 VALIDATE_SCHEMA (org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA)46 Assert.assertThat (org.junit.Assert.assertThat)33 Assert.assertTrue (org.junit.Assert.assertTrue)33 Assert (org.junit.Assert)13 Context (org.kie.dmn.model.v1_1.Context)7 ContextEntry (org.kie.dmn.model.v1_1.ContextEntry)7 DMNInputRuntimeTest (org.kie.dmn.core.DMNInputRuntimeTest)5 Definitions (org.kie.dmn.model.v1_1.Definitions)4 DMNModel (org.kie.dmn.api.core.DMNModel)3 DMNRuntime (org.kie.dmn.api.core.DMNRuntime)3 Ignore (org.junit.Ignore)2