use of org.kie.dmn.api.core.DMNResult 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());
}
use of org.kie.dmn.api.core.DMNResult in project drools by kiegroup.
the class DMNRuntimeTest method testSimpleItemDefinition.
@Test
public void testSimpleItemDefinition() {
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("simple-item-def.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn/itemdef", "simple-item-def");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
DMNContext context = DMNFactory.newContext();
context.set("Monthly Salary", 1000);
DMNResult dmnResult = runtime.evaluateAll(dmnModel, context);
assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(false));
DMNContext result = dmnResult.getContext();
assertThat(result.get("Yearly Salary"), is(new BigDecimal("12000")));
}
use of org.kie.dmn.api.core.DMNResult in project drools by kiegroup.
the class DMNRuntimeTest method testNotListInDT.
@Test
public void testNotListInDT() {
// DROOLS-2416
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("anot.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_292c1c7b-6b38-415d-938f-e9ca51d30b2b", "anot");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
DMNContext context = DMNFactory.newContext();
context.set("a letter", "a");
DMNResult dmnResult = runtime.evaluateAll(dmnModel, context);
assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(false));
DMNContext result = dmnResult.getContext();
assertThat(result.get("what letter decision"), is("vowel"));
}
use of org.kie.dmn.api.core.DMNResult in project drools by kiegroup.
the class DMNRuntimeTest method testPriority_table_context_recursion.
@Test
public void testPriority_table_context_recursion() {
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("priority_table_context_recursion.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_ff54a44d-b8f5-48fc-b2b7-43db767e8a1c", "not quite all or nothing P");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
DMNContext context = runtime.newContext();
context.set("isAffordable", false);
context.set("RiskCategory", "Medium");
DMNResult dmnResult = runtime.evaluateAll(dmnModel, context);
DMNContext result = dmnResult.getContext();
assertThat(result.get("Approval Status"), is("Declined"));
}
use of org.kie.dmn.api.core.DMNResult in project drools by kiegroup.
the class DMNRuntimeTest method testNPE.
@Test
public void testNPE() {
// DROOLS-1512
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("NPE.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_95b7ee22-1964-4be5-b7db-7db66692c707", "Dessin 1");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
DMNContext context = runtime.newContext();
DMNResult dmnResult = runtime.evaluateAll(dmnModel, context);
assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(true));
assertThat(dmnResult.getMessages().stream().anyMatch(m -> m.getMessageType().equals(DMNMessageType.REQ_NOT_FOUND)), is(true));
}
Aggregations