use of org.kie.dmn.api.core.DMNResult in project drools by kiegroup.
the class DMNRuntimeTest method testDateAllowedValues.
@Test
public void testDateAllowedValues() {
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("date_allowed_values.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_fbf002a3-615b-4f02-98e4-c28d4676225a", "Error with constraints verification");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
DMNContext ctx = runtime.newContext();
Object duration = BuiltInType.DURATION.fromString("P20Y");
ctx.set("yearsMonth", duration);
Object dateTime = BuiltInType.DATE_TIME.fromString("2017-05-16T17:58:00.000");
ctx.set("dateTime", dateTime);
DMNResult dmnResult = runtime.evaluateAll(dmnModel, ctx);
DMNContext result = dmnResult.getContext();
assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.hasErrors(), is(false));
assertThat((Map<String, Object>) result.get("Decision Logic 1"), hasEntry("years and months", duration));
assertThat((Map<String, Object>) result.get("Decision Logic 1"), hasEntry("Date Time", dateTime));
}
use of org.kie.dmn.api.core.DMNResult in project drools by kiegroup.
the class DMNRuntimeTest method testVerifyExtendedKieFEELFunction_today.
@Test
public void testVerifyExtendedKieFEELFunction_today() {
// DROOLS-2322
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("just_today.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_56fd6445-ff6a-4c28-8206-71fce7f80436", "just today");
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(false));
assertThat(dmnResult.getDecisionResultByName("a decision just today").getResult(), notNullValue());
}
use of org.kie.dmn.api.core.DMNResult in project drools by kiegroup.
the class DMNAssemblerTest method testExtendedMode.
@Test
public void testExtendedMode() {
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("strictMode.dmn", this.getClass());
DMNModel model = runtime.getModel("http://www.trisotech.com/dmn/definitions/_ecf4ea54-2abc-4e2f-a101-4fe14e356a46", "strictMode");
DMNContext ctx = runtime.newContext();
ctx.set("timestring", "2016-12-20T14:30:22z");
DMNResult result = runtime.evaluateAll(model, ctx);
assertEquals(DateTimeFormatter.ISO_TIME.parse("14:30:22z", OffsetTime::from), result.getDecisionResultByName("time").getResult());
}
use of org.kie.dmn.api.core.DMNResult in project drools by kiegroup.
the class DMNDecisionTableHitPolicyTest method testSimpleDecisionTableHitPolicyUniqueSatisfies.
@Test
public void testSimpleDecisionTableHitPolicyUniqueSatisfies() {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-U.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-U");
assertThat(dmnModel, notNullValue());
final DMNContext context = getSimpleTableContext(BigDecimal.valueOf(18), "ASD", false);
final DMNResult dmnResult = runtime.evaluateAll(dmnModel, context);
final DMNContext result = dmnResult.getContext();
assertThat(result.get("Approval Status"), nullValue());
assertTrue(dmnResult.getMessages().size() > 0);
}
use of org.kie.dmn.api.core.DMNResult in project drools by kiegroup.
the class DMNDecisionTableHitPolicyTest method testDecisionTableHitPolicyCollect.
@Test
public void testDecisionTableHitPolicyCollect() {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("Collect_Hit_Policy.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_da1a4dcb-01bf-4dee-9be8-f498bc68178c", "Collect Hit Policy");
assertThat(dmnModel, notNullValue());
final DMNContext context = DMNFactory.newContext();
context.set("Input", 20);
final DMNResult dmnResult = runtime.evaluateAll(dmnModel, context);
assertThat(dmnResult.hasErrors(), is(false));
final DMNContext result = dmnResult.getContext();
assertThat(result.get("Collect"), is(BigDecimal.valueOf(50)));
}
Aggregations