Search in sources :

Example 91 with Definitions

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

the class DMNXMLLoaderTest method testLoadingDishDecision.

@Test
public void testLoadingDishDecision() {
    final DMNMarshaller DMNMarshaller = DMNMarshallerFactory.newDefaultMarshaller();
    final InputStream is = this.getClass().getResourceAsStream("dish-decision.xml");
    final InputStreamReader isr = new InputStreamReader(is);
    final Object o = DMNMarshaller.unmarshal(isr);
    final Definitions root = (Definitions) o;
    assertNotNull(root);
}
Also used : DMNMarshaller(org.kie.dmn.api.marshalling.DMNMarshaller) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) Definitions(org.kie.dmn.model.api.Definitions) Test(org.junit.Test)

Example 92 with Definitions

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

the class DMNXMLLoaderTest method testLoadingDecisionServices.

@Test
public void testLoadingDecisionServices() {
    final DMNMarshaller DMNMarshaller = DMNMarshallerFactory.newMarshallerWithExtensions(Arrays.asList(new DecisionServicesExtensionRegister()));
    final InputStream is = this.getClass().getResourceAsStream("0004-decision-services.dmn");
    final InputStreamReader isr = new InputStreamReader(is);
    final Definitions def = DMNMarshaller.unmarshal(isr);
    assertThat(def.getDecisionService().size(), is(2));
    DecisionService decisionService1 = def.getDecisionService().get(0);
    assertThat(decisionService1.getId(), is("_70386614-9838-420b-a2ae-ff901ada63fb"));
    assertThat(decisionService1.getName(), is("A Only Knowing B and C"));
    assertThat(decisionService1.getDescription(), is("Description of A (BC)"));
    assertThat(decisionService1.getOutputDecision().size(), is(1));
    assertThat(decisionService1.getEncapsulatedDecision().size(), is(0));
    assertThat(decisionService1.getInputDecision().size(), is(2));
    assertThat(decisionService1.getInputData().size(), is(0));
    assertThat(decisionService1.getOutputDecision().get(0).getHref(), is("#_c2b44706-d479-4ceb-bb74-73589d26dd04"));
    DecisionService decisionService2 = def.getDecisionService().get(1);
    assertThat(decisionService2.getId(), is("_4620ef13-248a-419e-bc68-6b601b725a03"));
    assertThat(decisionService2.getName(), is("A only as output knowing D and E"));
    assertThat(decisionService2.getOutputDecision().size(), is(1));
    assertThat(decisionService2.getEncapsulatedDecision().size(), is(2));
    assertThat(decisionService2.getInputDecision().size(), is(0));
    assertThat(decisionService2.getInputData().size(), is(2));
    assertThat(decisionService2.getInputData().get(0).getHref(), is("#_bcea16fb-6c19-4bde-b37d-73407002c064"));
    assertThat(decisionService2.getInputData().get(1).getHref(), is("#_207b9195-a441-47f2-9414-2fad64b463f9"));
}
Also used : DMNMarshaller(org.kie.dmn.api.marshalling.DMNMarshaller) InputStreamReader(java.io.InputStreamReader) DecisionServicesExtensionRegister(org.kie.dmn.backend.marshalling.v1_1.xstream.extensions.DecisionServicesExtensionRegister) InputStream(java.io.InputStream) Definitions(org.kie.dmn.model.api.Definitions) DecisionService(org.kie.dmn.model.api.DecisionService) Test(org.junit.Test)

Example 93 with Definitions

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

the class DMNXMLLoaderTest method testLoadingWithNoDecisionServices.

@Test
public void testLoadingWithNoDecisionServices() {
    final DMNMarshaller DMNMarshaller = DMNMarshallerFactory.newMarshallerWithExtensions(Arrays.asList(new DecisionServicesExtensionRegister()));
    final InputStream is = this.getClass().getResourceAsStream("0001-input-data-string.dmn");
    final InputStreamReader isr = new InputStreamReader(is);
    final Definitions def = DMNMarshaller.unmarshal(isr);
    // check if No DecisionServices in extended v1.1 does not NPE.
    assertThat(def.getDecisionService().size(), is(0));
}
Also used : DMNMarshaller(org.kie.dmn.api.marshalling.DMNMarshaller) InputStreamReader(java.io.InputStreamReader) DecisionServicesExtensionRegister(org.kie.dmn.backend.marshalling.v1_1.xstream.extensions.DecisionServicesExtensionRegister) InputStream(java.io.InputStream) Definitions(org.kie.dmn.model.api.Definitions) Test(org.junit.Test)

Example 94 with Definitions

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

the class DMNXMLLoaderTest method test0004_multiple_extensions.

@Test
public void test0004_multiple_extensions() throws Exception {
    DMNMarshaller marshaller = DMNMarshallerFactory.newMarshallerWithExtensions(Arrays.asList(new DecisionServicesExtensionRegister()));
    final InputStream is = this.getClass().getResourceAsStream("0004-decision-services_multiple_extensions.dmn");
    final InputStreamReader isr = new InputStreamReader(is);
    final Definitions def = marshaller.unmarshal(isr);
    assertThat(def.getExtensionElements().getAny().size(), is(1));
// if arrived here, means it did not fail with exception while trying to unmarshall unknown rss extension element, hence it just skipped it.
}
Also used : DMNMarshaller(org.kie.dmn.api.marshalling.DMNMarshaller) InputStreamReader(java.io.InputStreamReader) DecisionServicesExtensionRegister(org.kie.dmn.backend.marshalling.v1_1.xstream.extensions.DecisionServicesExtensionRegister) InputStream(java.io.InputStream) Definitions(org.kie.dmn.model.api.Definitions) Test(org.junit.Test)

Example 95 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) 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)

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