Search in sources :

Example 61 with List

use of org.kie.dmn.model.v1_1.List 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 62 with List

use of org.kie.dmn.model.v1_1.List in project drools by kiegroup.

the class ValidatorTest method testINVOCATION_MISSING_TARGETRbis.

@Ignore("known current limitation")
@Test
public void testINVOCATION_MISSING_TARGETRbis() {
    Definitions definitions = utilDefinitions("INVOCATION_MISSING_TARGETbis.dmn", "INVOCATION_MISSING_TARGETbis");
    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 63 with List

use of org.kie.dmn.model.v1_1.List in project drools by kiegroup.

the class ValidatorTest method utilDefinitions.

private Definitions utilDefinitions(String filename, String modelName) {
    // List<DMNMessage> validateXML;
    // try {
    // validateXML = validator.validate( new File(this.getClass().getResource(filename).toURI()), DMNValidator.Validation.VALIDATE_SCHEMA );
    // assertThat( "using unit test method utilDefinitions must received a XML valid DMN file", validateXML, IsEmptyCollection.empty() );
    // } catch (URISyntaxException e) {
    // e.printStackTrace();
    // fail("Unable for the test suite to locate the file for XML validation.");
    // }
    DMNMarshaller marshaller = DMNMarshallerFactory.newDefaultMarshaller();
    try (InputStreamReader isr = new InputStreamReader(getClass().getResourceAsStream(filename))) {
        Definitions definitions = marshaller.unmarshal(isr);
        assertThat(definitions, notNullValue());
        return definitions;
    } catch (IOException e) {
        e.printStackTrace();
        fail("Unable for the test suite to locate the file for validation.");
    }
    return null;
}
Also used : DMNMarshaller(org.kie.dmn.api.marshalling.v1_1.DMNMarshaller) InputStreamReader(java.io.InputStreamReader) Definitions(org.kie.dmn.model.v1_1.Definitions) IOException(java.io.IOException)

Example 64 with List

use of org.kie.dmn.model.v1_1.List in project drools by kiegroup.

the class ValidatorTest method testMACDInputDefinitions.

@Test
public void testMACDInputDefinitions() {
    DMNRuntime runtime = DMNRuntimeUtil.createRuntime("MACD-enhanced_iteration.dmn", DMNInputRuntimeTest.class);
    DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_6cfe7d88-6741-45d1-968c-b61a597d0964", "MACD-enhanced iteration");
    assertThat(dmnModel, notNullValue());
    Definitions definitions = dmnModel.getDefinitions();
    assertThat(definitions, notNullValue());
    List<DMNMessage> messages = DMNValidatorFactory.newValidator().validate(definitions, VALIDATE_MODEL, VALIDATE_COMPILATION);
    assertThat(messages.toString(), messages.size(), is(0));
}
Also used : DMNMessage(org.kie.dmn.api.core.DMNMessage) Definitions(org.kie.dmn.model.v1_1.Definitions) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) DMNModel(org.kie.dmn.api.core.DMNModel) Test(org.junit.Test) DMNInputRuntimeTest(org.kie.dmn.core.DMNInputRuntimeTest)

Example 65 with List

use of org.kie.dmn.model.v1_1.List in project drools by kiegroup.

the class DMNRuntimeTest method testList_of_Vowels.

@Test
public void testList_of_Vowels() {
    // DROOLS-2357
    DMNRuntime runtime = DMNRuntimeUtil.createRuntime("List_of_Vowels.dmn", this.getClass());
    DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_c5f007ce-4d45-4aac-8729-991d4abc7826", "List of Vowels");
    assertThat(dmnModel, notNullValue());
    assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
    DMNContext emptyContext = DMNFactory.newContext();
    DMNResult dmnResult = runtime.evaluateAll(dmnModel, emptyContext);
    assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(true));
    assertThat(dmnResult.getMessages().stream().filter(m -> m.getMessageType() == DMNMessageType.ERROR_EVAL_NODE).anyMatch(m -> m.getSourceId().equals("_b2205027-d06c-41b5-8419-e14b501e14a6")), is(true));
    DMNContext result = dmnResult.getContext();
    assertThat(result.get("Decide Vowel a"), is("a"));
    assertThat(result.get("Decide BAD"), nullValue());
}
Also used : BeforeEvaluateDecisionTableEvent(org.kie.dmn.api.core.event.BeforeEvaluateDecisionTableEvent) CoreMatchers.is(org.hamcrest.CoreMatchers.is) Arrays(java.util.Arrays) DMNMessage(org.kie.dmn.api.core.DMNMessage) DMNResult(org.kie.dmn.api.core.DMNResult) ZonedDateTime(java.time.ZonedDateTime) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) Assert.assertThat(org.junit.Assert.assertThat) BigDecimal(java.math.BigDecimal) DMNModel(org.kie.dmn.api.core.DMNModel) Duration(java.time.Duration) Map(java.util.Map) LocalTime(java.time.LocalTime) ZoneOffset(java.time.ZoneOffset) OffsetTime(java.time.OffsetTime) BeforeEvaluateDecisionEvent(org.kie.dmn.api.core.event.BeforeEvaluateDecisionEvent) DMNRuntimeEventListener(org.kie.dmn.api.core.event.DMNRuntimeEventListener) DMNFactory(org.kie.dmn.core.api.DMNFactory) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Collection(java.util.Collection) BuiltInType(org.kie.dmn.feel.lang.types.BuiltInType) DMNModelImpl(org.kie.dmn.core.impl.DMNModelImpl) UUID(java.util.UUID) ItemDefinition(org.kie.dmn.model.v1_1.ItemDefinition) Collectors(java.util.stream.Collectors) DMNRuntimeUtil(org.kie.dmn.core.util.DMNRuntimeUtil) Matchers.any(org.mockito.Matchers.any) List(java.util.List) Matchers.contains(org.hamcrest.Matchers.contains) VerificationModeFactory.times(org.mockito.internal.verification.VerificationModeFactory.times) Assert.assertFalse(org.junit.Assert.assertFalse) LocalDate(java.time.LocalDate) DMNContext(org.kie.dmn.api.core.DMNContext) FEELStringMarshaller(org.kie.dmn.feel.marshaller.FEELStringMarshaller) KieHelper(org.kie.dmn.core.util.KieHelper) DMNDecisionResult(org.kie.dmn.api.core.DMNDecisionResult) AfterEvaluateDecisionEvent(org.kie.dmn.api.core.event.AfterEvaluateDecisionEvent) EvalHelper(org.kie.dmn.feel.util.EvalHelper) Mockito.mock(org.mockito.Mockito.mock) AfterEvaluateDecisionTableEvent(org.kie.dmn.api.core.event.AfterEvaluateDecisionTableEvent) DynamicTypeUtils.prototype(org.kie.dmn.core.util.DynamicTypeUtils.prototype) DMNMessageType(org.kie.dmn.api.core.DMNMessageType) CoreMatchers.not(org.hamcrest.CoreMatchers.not) DynamicTypeUtils.entry(org.kie.dmn.core.util.DynamicTypeUtils.entry) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArgumentCaptor(org.mockito.ArgumentCaptor) KieServices(org.kie.api.KieServices) Matchers.hasSize(org.hamcrest.Matchers.hasSize) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) Period(java.time.Period) Matchers.hasEntry(org.hamcrest.Matchers.hasEntry) KieContainer(org.kie.api.runtime.KieContainer) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.verify(org.mockito.Mockito.verify) Ignore(org.junit.Ignore) Assert.assertEquals(org.junit.Assert.assertEquals) DecisionNodeImpl(org.kie.dmn.core.ast.DecisionNodeImpl) DMNResult(org.kie.dmn.api.core.DMNResult) DMNContext(org.kie.dmn.api.core.DMNContext) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) DMNModel(org.kie.dmn.api.core.DMNModel) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)54 List (org.kie.workbench.common.dmn.api.definition.v1_1.List)26 ItemDefinition (org.kie.dmn.model.v1_1.ItemDefinition)21 QName (javax.xml.namespace.QName)17 ArrayList (java.util.ArrayList)15 List (java.util.List)14 DMNMessage (org.kie.dmn.api.core.DMNMessage)14 Import (org.kie.dmn.model.v1_1.Import)13 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)13 CoreMatchers.is (org.hamcrest.CoreMatchers.is)11 DMNMessageType (org.kie.dmn.api.core.DMNMessageType)11 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)11 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)10 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)10 Definitions (org.kie.dmn.model.v1_1.Definitions)9 IOException (java.io.IOException)8 Collectors (java.util.stream.Collectors)8 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)8 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)8 Reader (java.io.Reader)7