Search in sources :

Example 61 with Definitions

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

the class SignavioTest method testUnmarshall.

@Test
public void testUnmarshall() {
    DMNRuntime runtime = createRuntime("Test_Signavio_multiple.dmn");
    DMNModel model0 = runtime.getModels().get(0);
    Definitions definitions = model0.getDefinitions();
    DRGElement decision = definitions.getDrgElement().stream().filter(e -> e.getName().equals("greetingForEachPersonInPersons")).findFirst().orElseThrow(IllegalStateException::new);
    Object extElement = decision.getExtensionElements().getAny().get(0);
    assertThat(extElement, is(instanceOf(MultiInstanceDecisionLogic.class)));
    MultiInstanceDecisionLogic mid = (MultiInstanceDecisionLogic) extElement;
    LOG.info("{}", mid);
    assertThat(mid.getIterationExpression(), is("persons"));
    assertThat(mid.getIteratorShapeId(), is("id-707bbdf74438414623ac5d7067805b38"));
    assertThat(mid.getAggregationFunction(), is("COLLECT"));
    assertThat(mid.getTopLevelDecisionId(), is("id-7a23e2f201e3e0db3c991313cff5cd2b"));
}
Also used : Definitions(org.kie.dmn.model.api.Definitions) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) DMNModel(org.kie.dmn.api.core.DMNModel) DRGElement(org.kie.dmn.model.api.DRGElement) Test(org.junit.Test)

Example 62 with Definitions

use of org.kie.dmn.model.api.Definitions 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.api.Definitions) Ignore(org.junit.Ignore) AbstractValidatorTest(org.kie.dmn.validation.AbstractValidatorTest) Test(org.junit.Test) DMNInputRuntimeTest(org.kie.dmn.core.DMNInputRuntimeTest)

Example 63 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) AbstractValidatorTest(org.kie.dmn.validation.AbstractValidatorTest) Test(org.junit.Test) DMNInputRuntimeTest(org.kie.dmn.core.DMNInputRuntimeTest)

Example 64 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) AbstractValidatorTest(org.kie.dmn.validation.AbstractValidatorTest) Test(org.junit.Test) DMNInputRuntimeTest(org.kie.dmn.core.DMNInputRuntimeTest)

Example 65 with Definitions

use of org.kie.dmn.model.api.Definitions 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.api.Definitions) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) DMNModel(org.kie.dmn.api.core.DMNModel) AbstractValidatorTest(org.kie.dmn.validation.AbstractValidatorTest) Test(org.junit.Test) DMNInputRuntimeTest(org.kie.dmn.core.DMNInputRuntimeTest)

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