use of org.kie.dmn.api.core.DMNContext in project drools by kiegroup.
the class DMNDecisionTableHitPolicyTest method testSimpleDecisionTableHitPolicyOutputOrder.
@Test
public void testSimpleDecisionTableHitPolicyOutputOrder() {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-O.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-O");
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("Declined", "Declined", "Approved"));
}
use of org.kie.dmn.api.core.DMNContext in project drools by kiegroup.
the class DMNDecisionTableHitPolicyTest method testSimpleDecisionTableHitPolicyPriorityMultipleOutputs.
@Test
public void testSimpleDecisionTableHitPolicyPriorityMultipleOutputs() {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0004-simpletable-P-multiple-outputs.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0004-simpletable-P-multiple-outputs");
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("Declined")));
assertThat(decisionResult, hasEntry(is("Decision Review"), is("Needs verification")));
}
use of org.kie.dmn.api.core.DMNContext 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)));
}
use of org.kie.dmn.api.core.DMNContext in project drools by kiegroup.
the class DMNDecisionTableHitPolicyTest method getSimpleTableContext.
private DMNContext getSimpleTableContext(final BigDecimal age, final String riskCategory, final boolean isAffordable) {
final DMNContext context = DMNFactory.newContext();
context.set("Age", age);
context.set("RiskCategory", riskCategory);
context.set("isAffordable", isAffordable);
return context;
}
use of org.kie.dmn.api.core.DMNContext in project drools by kiegroup.
the class DMNDecisionTableHitPolicyTest method testSimpleDecisionTableHitPolicyCollectAggregateFunction.
private void testSimpleDecisionTableHitPolicyCollectAggregateFunction(final String resourceName, final String modelName, final BigDecimal expectedResult, final DMNContext context) {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime(resourceName, this.getClass());
final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", modelName);
assertThat(dmnModel, notNullValue());
final DMNContext result = evaluateSimpleTableWithContext(dmnModel, runtime, context);
assertThat(result.get("Status number"), is(expectedResult));
}
Aggregations