Search in sources :

Example 26 with VALIDATE_COMPILATION

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

the class ValidatorContextTest method testCONTEXT_MISSING_EXPR_ReaderInput.

@Test
public void testCONTEXT_MISSING_EXPR_ReaderInput() throws IOException {
    try (final Reader reader = getReader("context/CONTEXT_MISSING_EXPR.dmn")) {
        final List<DMNMessage> validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION);
        assertThat(ValidatorUtil.formatMessages(validate), validate.size(), is(2));
        // this is schema validation
        assertTrue(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.FAILED_XML_VALIDATION)));
        assertTrue(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.MISSING_EXPRESSION)));
    }
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) DMNMessage(org.kie.dmn.api.core.DMNMessage) VALIDATE_COMPILATION(org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION) DMNMessageType(org.kie.dmn.api.core.DMNMessageType) ContextEntry(org.kie.dmn.model.v1_1.ContextEntry) IOException(java.io.IOException) Test(org.junit.Test) Reader(java.io.Reader) Context(org.kie.dmn.model.v1_1.Context) List(java.util.List) VALIDATE_SCHEMA(org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA) Assert(org.junit.Assert) 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 27 with VALIDATE_COMPILATION

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

the class ValidatorContextTest method testCONTEXT_ENTRY_MISSING_VARIABLE_ReaderInput.

@Test
public void testCONTEXT_ENTRY_MISSING_VARIABLE_ReaderInput() throws IOException {
    try (final Reader reader = getReader("context/CONTEXT_ENTRY_MISSING_VARIABLE.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.MISSING_VARIABLE)));
        // check that it reports and error for the second context entry, but not for the last one
        final ContextEntry ce = (ContextEntry) validate.get(0).getSourceReference();
        assertThat(((Context) ce.getParent()).getContextEntry().indexOf(ce), is(1));
    }
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) DMNMessage(org.kie.dmn.api.core.DMNMessage) VALIDATE_COMPILATION(org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION) DMNMessageType(org.kie.dmn.api.core.DMNMessageType) ContextEntry(org.kie.dmn.model.v1_1.ContextEntry) IOException(java.io.IOException) Test(org.junit.Test) Reader(java.io.Reader) Context(org.kie.dmn.model.v1_1.Context) List(java.util.List) VALIDATE_SCHEMA(org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA) Assert(org.junit.Assert) VALIDATE_MODEL(org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL) Context(org.kie.dmn.model.v1_1.Context) DMNMessage(org.kie.dmn.api.core.DMNMessage) Reader(java.io.Reader) ContextEntry(org.kie.dmn.model.v1_1.ContextEntry) Test(org.junit.Test)

Example 28 with VALIDATE_COMPILATION

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

the class ValidatorContextTest method testCONTEXT_MISSING_ENTRIES_ReaderInput.

@Test
public void testCONTEXT_MISSING_ENTRIES_ReaderInput() throws IOException {
    try (final Reader reader = getReader("context/CONTEXT_MISSING_ENTRIES.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.MISSING_EXPRESSION)));
    }
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) DMNMessage(org.kie.dmn.api.core.DMNMessage) VALIDATE_COMPILATION(org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION) DMNMessageType(org.kie.dmn.api.core.DMNMessageType) ContextEntry(org.kie.dmn.model.v1_1.ContextEntry) IOException(java.io.IOException) Test(org.junit.Test) Reader(java.io.Reader) Context(org.kie.dmn.model.v1_1.Context) List(java.util.List) VALIDATE_SCHEMA(org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA) Assert(org.junit.Assert) 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 29 with VALIDATE_COMPILATION

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

the class ValidatorDMNElementReferenceTest method testELEMREF_NOHASH_ReaderInput.

@Test
public void testELEMREF_NOHASH_ReaderInput() throws IOException {
    try (final Reader reader = getReader("dmnelementref/ELEMREF_NOHASH.dmn")) {
        final List<DMNMessage> validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION);
        assertThat(ValidatorUtil.formatMessages(validate), validate.size(), is(3));
        assertTrue(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.MISSING_EXPRESSION)));
        assertTrue(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.INVALID_HREF_SYNTAX)));
        assertTrue(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.REQ_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 30 with VALIDATE_COMPILATION

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

the class ValidatorDecisionTableTest method testDTABLE_PRIORITY_MISSING_OUTVALS_ReaderInput.

@Test
public void testDTABLE_PRIORITY_MISSING_OUTVALS_ReaderInput() throws IOException {
    try (final Reader reader = getReader("DTABLE_PRIORITY_MISSING_OUTVALS.dmn")) {
        List<DMNMessage> validate = validator.validate(reader, VALIDATE_SCHEMA, VALIDATE_MODEL, VALIDATE_COMPILATION);
        assertThat(ValidatorUtil.formatMessages(validate), validate.isEmpty(), is(false));
        assertTrue(validate.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.MISSING_OUTPUT_VALUES)));
    }
}
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

IOException (java.io.IOException)46 Reader (java.io.Reader)46 List (java.util.List)46 CoreMatchers.is (org.hamcrest.CoreMatchers.is)46 Test (org.junit.Test)46 DMNMessage (org.kie.dmn.api.core.DMNMessage)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