use of org.kie.dmn.api.core.DMNModel in project drools by kiegroup.
the class DMNRuntimeTest method testDROOLS2147_message.
@Test
public void testDROOLS2147_message() {
// DROOLS-2147 truncate message length
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Ex_4_3simplified.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_5c5a9c72-627e-4666-ae85-31356fed3658", "Ex_4_3simplified");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
DMNContext context = DMNFactory.newContext();
StringBuilder sb = new StringBuilder("abcdefghijklmnopqrstuvwxyz");
for (int i = 0; i < 100; i++) {
sb.append("abcdefghijklmnopqrstuvwxyz");
}
context.set("number", sb.toString());
DMNResult dmnResult = runtime.evaluateAll(dmnModel, context);
System.out.println(dmnResult);
assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(true));
assertThat(dmnResult.getMessages().stream().filter(m -> m.getMessageType() == DMNMessageType.ERROR_EVAL_NODE).anyMatch(m -> m.getMessage().contains("... [string clipped after 50 chars, total length is")), is(true));
}
use of org.kie.dmn.api.core.DMNModel in project drools by kiegroup.
the class DMNRuntimeTest method testInvalidModel.
@Test
public void testInvalidModel() {
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Loan_Prequalification_Condensed_Invalid.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_ba68fb9d-7421-4f3a-a7ab-f785ea0bae6b", "Loan Prequalification Condensed");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(true));
assertThat(dmnModel.getMessages().size(), is(2));
assertThat(dmnModel.getMessages().get(0).getSourceId(), is("_8b5cac9e-c8ca-4817-b05a-c70fa79a8d48"));
assertThat(dmnModel.getMessages().get(1).getSourceId(), is("_ef09d90e-e1a4-4ec9-885b-482d1f4a1cee"));
}
use of org.kie.dmn.api.core.DMNModel 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.DMNModel 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.DMNModel 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"));
}
Aggregations