use of org.kie.dmn.api.core.DMNContext 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.DMNContext 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.DMNContext in project drools by kiegroup.
the class DMNDecisionTableHitPolicyTest method testSimpleDecisionTableHitPolicyRuleOrder.
@Test
public void testSimpleDecisionTableHitPolicyRuleOrder() {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-R.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-R");
assertThat(dmnModel, notNullValue());
final DMNContext context = getSimpleTableContext(BigDecimal.valueOf(70), "Medium", true);
final DMNContext result = evaluateSimpleTableWithContext(dmnModel, runtime, context);
final List<String> decisionResults = (List<String>) result.get("Approval Status");
assertThat(decisionResults, hasSize(3));
assertThat(decisionResults, contains("Approved", "Needs review", "Declined"));
}
use of org.kie.dmn.api.core.DMNContext in project drools by kiegroup.
the class DMNDecisionTableHitPolicyTest method executeTestDecisionTableHitPolicyCollect.
private List<BigDecimal> executeTestDecisionTableHitPolicyCollect(DMNContext context) {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-C.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-C");
assertThat(dmnModel, notNullValue());
final DMNContext result = evaluateSimpleTableWithContext(dmnModel, runtime, context);
final List<BigDecimal> decisionResults = (List<BigDecimal>) result.get("Status number");
return decisionResults;
}
use of org.kie.dmn.api.core.DMNContext in project drools by kiegroup.
the class DMNDecisionTableHitPolicyTest method testSimpleDecisionTableHitPolicyFirst.
@Test
public void testSimpleDecisionTableHitPolicyFirst() {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-F.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-F");
assertThat(dmnModel, notNullValue());
final DMNContext context = getSimpleTableContext(BigDecimal.valueOf(18), "Medium", true);
final DMNContext result = evaluateSimpleTableWithContext(dmnModel, runtime, context);
final Map<String, Object> decisionResult = (Map<String, Object>) result.get("Decision Result");
assertThat(decisionResult.values(), hasSize(2));
assertThat(decisionResult, hasEntry(is("Approval Status"), is("Approved")));
assertThat(decisionResult, hasEntry(is("Decision Review"), is("Decision final")));
}
Aggregations