use of org.kie.dmn.api.core.DMNResult in project drools by kiegroup.
the class DMNRuntimeTest method testDROOLS2200.
@Test
public void testDROOLS2200() {
// DROOLS-2200
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("will_be_null_if_negative.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_c5889555-7ae5-4a67-a872-3a9492caf6e7", "will be null if negative");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
DMNContext context = DMNFactory.newContext();
context.set("a number", -1);
DMNResult dmnResult = runtime.evaluateAll(dmnModel, context);
assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(false));
DMNContext resultContext = dmnResult.getContext();
assertThat(((Map) resultContext.get("will be null if negative")).get("s1"), nullValue());
assertThat(((Map) resultContext.get("will be null if negative")).get("s2"), is("negative"));
}
use of org.kie.dmn.api.core.DMNResult in project drools by kiegroup.
the class DMNRuntimeTest method testListContainmentDT.
@Test
public void testListContainmentDT() {
// DROOLS-2416
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("list_containment_DT.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_6ab2bd6d-adaa-45c4-a141-a84382a201eb", "list containment DT");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
DMNContext context = DMNFactory.newContext();
context.set("Passenger", prototype(entry("name", "Osama bin Laden")));
DMNResult dmnResult = runtime.evaluateAll(dmnModel, context);
System.out.println(dmnResult);
assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(false));
DMNContext result = dmnResult.getContext();
assertThat(result.get("Boarding Status"), is("Denied"));
}
use of org.kie.dmn.api.core.DMNResult in project drools by kiegroup.
the class DMNRuntimeTest method testNotificationsApproved2.
@Test
public void testNotificationsApproved2() {
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("NotificationsTest2.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "building-structure-rules");
assertThat(dmnModel, notNullValue());
DMNContext context = DMNFactory.newContext();
context.set("existingActivityApplicability", true);
context.set("Distance", new BigDecimal(9999));
context.set("willIncreaseTraffic", true);
DMNResult dmnResult = runtime.evaluateAll(dmnModel, context);
DMNContext result = dmnResult.getContext();
assertThat(result.get("Notification Status"), is("Notification to Province Approved"));
assertThat(result.get("Permit Status"), is("Building Activity Province Permit Required"));
}
use of org.kie.dmn.api.core.DMNResult in project drools by kiegroup.
the class DMNRuntimeTest method testBoxedContext.
@Test
public void testBoxedContext() {
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("BoxedContext.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/dmn/definitions/_0de36357-fec0-4b4e-b7f1-382d381e06e9", "Dessin 1");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
DMNContext context = DMNFactory.newContext();
context.set("a", 10);
context.set("b", 5);
DMNResult dmnResult = runtime.evaluateAll(dmnModel, context);
assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(false));
assertThat((Map<String, Object>) dmnResult.getContext().get("Math"), hasEntry("Sum", BigDecimal.valueOf(15)));
assertThat((Map<String, Object>) dmnResult.getContext().get("Math"), hasEntry("Product", BigDecimal.valueOf(50)));
}
use of org.kie.dmn.api.core.DMNResult in project drools by kiegroup.
the class DMNRuntimeTest method testDrools2125.
@Test
public void testDrools2125() {
// DROOLS-2125
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("drools2125.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_9f976b29-4cdd-42e9-8737-0ccbc2ad9498", "drools2125");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
DMNContext context = DMNFactory.newContext();
context.set("person", "Bob");
context.set("list of persons", Arrays.asList("Bob", "John"));
DMNResult dmnResult = runtime.evaluateAll(dmnModel, context);
assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(false));
DMNContext result = dmnResult.getContext();
assertThat(result.get("person is Bob"), is("yes"));
assertThat(result.get("persons complies with UT list"), is("yes"));
assertThat(result.get("person on the list of persons"), is("yes"));
assertThat(result.get("persons complies with hardcoded list"), is("yes"));
assertThat(result.get("person is person"), is("yes"));
}
Aggregations