Search in sources :

Example 41 with Definitions

use of org.kie.dmn.model.api.Definitions in project drools by kiegroup.

the class ValidatorTest method testRelationwithemptycell.

@Test
public void testRelationwithemptycell() {
    // DROOLS-2439
    DMNRuntime runtime = DMNRuntimeUtil.createRuntime("relation_with_empty_cell.dmn", DMNRuntimeTest.class);
    DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_99a00903-2943-47df-bab1-a32f276617ea", "Relation with empty cell");
    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.api.Definitions) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) DMNModel(org.kie.dmn.api.core.DMNModel) DMNRuntimeTest(org.kie.dmn.core.DMNRuntimeTest) DMN13specificTest(org.kie.dmn.core.v1_3.DMN13specificTest) Test(org.junit.Test) DMNInputRuntimeTest(org.kie.dmn.core.DMNInputRuntimeTest) DMNDecisionServicesTest(org.kie.dmn.core.decisionservices.DMNDecisionServicesTest) ImportsTest(org.kie.dmn.core.imports.ImportsTest)

Example 42 with Definitions

use of org.kie.dmn.model.api.Definitions in project drools by kiegroup.

the class ValidatorTest method testDryRun.

@Test
public void testDryRun() {
    DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0001-input-data-string.dmn", DMNInputRuntimeTest.class);
    DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/drools/kie-dmn", "_0001-input-data-string");
    assertThat(dmnModel, notNullValue());
    Definitions definitions = dmnModel.getDefinitions();
    assertThat(definitions, notNullValue());
    DMNValidatorFactory.newValidator().validate(definitions);
}
Also used : Definitions(org.kie.dmn.model.api.Definitions) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) DMNModel(org.kie.dmn.api.core.DMNModel) DMNRuntimeTest(org.kie.dmn.core.DMNRuntimeTest) DMN13specificTest(org.kie.dmn.core.v1_3.DMN13specificTest) Test(org.junit.Test) DMNInputRuntimeTest(org.kie.dmn.core.DMNInputRuntimeTest) DMNDecisionServicesTest(org.kie.dmn.core.decisionservices.DMNDecisionServicesTest) ImportsTest(org.kie.dmn.core.imports.ImportsTest)

Example 43 with Definitions

use of org.kie.dmn.model.api.Definitions 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.api.Definitions) Ignore(org.junit.Ignore) DMNRuntimeTest(org.kie.dmn.core.DMNRuntimeTest) DMN13specificTest(org.kie.dmn.core.v1_3.DMN13specificTest) Test(org.junit.Test) DMNInputRuntimeTest(org.kie.dmn.core.DMNInputRuntimeTest) DMNDecisionServicesTest(org.kie.dmn.core.decisionservices.DMNDecisionServicesTest) ImportsTest(org.kie.dmn.core.imports.ImportsTest)

Example 44 with Definitions

use of org.kie.dmn.model.api.Definitions in project drools by kiegroup.

the class ValidatorDecisionServiceTest method testDS1ofEach.

@Test
public void testDS1ofEach() {
    DMNRuntime runtime = DMNRuntimeUtil.createRuntime("decisionservice/DS1ofEach_OK.dmn", this.getClass());
    DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_40B3D02F-868C-4925-A1F2-5710DFEEF51E", "DS1ofEach");
    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));
    DMNContext dmnContext = runtime.newContext();
    dmnContext.set("InputData-1", "id1");
    dmnContext.set("Decision-1", "od1");
    DMNResult evaluateDS1 = runtime.evaluateDecisionService(dmnModel, dmnContext, "DecisionService-1");
    LOG.debug("{}", evaluateDS1);
    assertThat(evaluateDS1.getDecisionResultByName("Decision-2"), nullValue());
    assertThat(evaluateDS1.getDecisionResultByName("Decision-3").getResult(), is("d3:d2:id1od1"));
}
Also used : DMNResult(org.kie.dmn.api.core.DMNResult) DMNMessage(org.kie.dmn.api.core.DMNMessage) Definitions(org.kie.dmn.model.api.Definitions) 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)

Example 45 with Definitions

use of org.kie.dmn.model.api.Definitions in project drools by kiegroup.

the class ValidatorDecisionServiceTest method testOKDS.

@Test
public void testOKDS() {
    DMNRuntime runtime = DMNRuntimeUtil.createRuntime("decisionservice/HelloDS_OK.dmn", this.getClass());
    DMNModel dmnModel = runtime.getModel("https://kiegroup.org/dmn/_7C3C7416-2F33-4718-AE35-F3843C5250DB", "HelloDS");
    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));
    DMNResult evaluateAll = runtime.evaluateAll(dmnModel, runtime.newContext());
    LOG.debug("{}", evaluateAll);
    assertThat(evaluateAll.getDecisionResultByName("Decision-1").getResult(), is("Hello World"));
}
Also used : DMNResult(org.kie.dmn.api.core.DMNResult) DMNMessage(org.kie.dmn.api.core.DMNMessage) Definitions(org.kie.dmn.model.api.Definitions) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) DMNModel(org.kie.dmn.api.core.DMNModel) Test(org.junit.Test)

Aggregations

Definitions (org.kie.dmn.model.api.Definitions)114 Test (org.junit.Test)71 DMNRuntime (org.kie.dmn.api.core.DMNRuntime)39 DMNMessage (org.kie.dmn.api.core.DMNMessage)37 DMNModel (org.kie.dmn.api.core.DMNModel)34 DMNResult (org.kie.dmn.api.core.DMNResult)32 TDefinitions (org.kie.dmn.model.v1_1.TDefinitions)31 Arrays (java.util.Arrays)28 Assert.assertTrue (org.junit.Assert.assertTrue)28 List (java.util.List)26 ItemDefinition (org.kie.dmn.model.api.ItemDefinition)26 Logger (org.slf4j.Logger)26 LoggerFactory (org.slf4j.LoggerFactory)26 HashMap (java.util.HashMap)25 Decision (org.kie.dmn.model.api.Decision)25 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)24 Assert.assertFalse (org.junit.Assert.assertFalse)24 DecisionNodeImpl (org.kie.dmn.core.ast.DecisionNodeImpl)24 DMNModelImpl (org.kie.dmn.core.impl.DMNModelImpl)24 ArrayList (java.util.ArrayList)23