use of org.kie.dmn.api.core.DMNContext in project drools by kiegroup.
the class DMNInputRuntimeTest method testInputStringAllowedValuesEvaluateAll.
@Test
public void testInputStringAllowedValuesEvaluateAll() {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0003-input-data-string-allowed-values.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0003-input-data-string-allowed-values");
assertThat(dmnModel, notNullValue());
final DMNContext context = DMNFactory.newContext();
context.set("Employment Status", "SELF-EMPLOYED");
final DMNResult dmnResult = runtime.evaluateAll(dmnModel, context);
final DMNContext result = dmnResult.getContext();
assertThat(result.get("Employment Status Statement"), is("You are SELF-EMPLOYED"));
}
use of org.kie.dmn.api.core.DMNContext in project drools by kiegroup.
the class DMNInputRuntimeTest method testInputStringEvaluateDecisionById.
@Test
public void testInputStringEvaluateDecisionById() {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0001-input-data-string.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/drools/kie-dmn", "_0001-input-data-string");
assertThat(dmnModel, notNullValue());
final DMNContext context = DMNFactory.newContext();
context.set("Full Name", "John Doe");
DMNResult dmnResult = runtime.evaluateById(dmnModel, context, "d_GreetingMessage");
assertThat(dmnResult.getDecisionResults().size(), is(1));
assertThat(dmnResult.getDecisionResultById("d_GreetingMessage").getResult(), is("Hello John Doe"));
final DMNContext result = dmnResult.getContext();
assertThat(result.get("Greeting Message"), is("Hello John Doe"));
dmnResult = runtime.evaluateById(dmnModel, context, "nonExistantId");
assertThat(dmnResult.getDecisionResults().size(), is(1));
assertThat(dmnResult.getDecisionResultByName("Greeting Message").getEvaluationStatus(), is(DMNDecisionResult.DecisionEvaluationStatus.NOT_EVALUATED));
dmnResult = runtime.evaluateById(dmnModel, context, "");
assertThat(dmnResult.getDecisionResults().size(), is(1));
assertThat(dmnResult.getDecisionResultByName("Greeting Message").getEvaluationStatus(), is(DMNDecisionResult.DecisionEvaluationStatus.NOT_EVALUATED));
dmnResult = runtime.evaluateById(dmnModel, context, (String) null);
assertThat(dmnResult.getDecisionResults().size(), is(1));
assertThat(dmnResult.getDecisionResultByName("Greeting Message").getEvaluationStatus(), is(DMNDecisionResult.DecisionEvaluationStatus.NOT_EVALUATED));
}
use of org.kie.dmn.api.core.DMNContext in project drools by kiegroup.
the class DMNInputRuntimeTest method testInputNumberEvaluateAll.
@Test
public void testInputNumberEvaluateAll() {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0002-input-data-number.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0002-input-data-number");
assertThat(dmnModel, notNullValue());
final DMNContext context = DMNFactory.newContext();
context.set("Monthly Salary", new BigDecimal(1000));
final DMNResult dmnResult = runtime.evaluateAll(dmnModel, context);
final DMNContext result = dmnResult.getContext();
assertThat(result.get("Yearly Salary"), is(new BigDecimal(12000)));
}
use of org.kie.dmn.api.core.DMNContext in project drools by kiegroup.
the class DMNInputRuntimeTest method testNonexistantInputNodeName.
@Test
public void testNonexistantInputNodeName() {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0001-input-data-string.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/drools/kie-dmn", "_0001-input-data-string");
assertThat(dmnModel, notNullValue());
final DMNContext context = DMNFactory.newContext();
context.set("Nonexistant Input", "John Doe");
final DMNResult dmnResult = runtime.evaluateAll(dmnModel, context);
assertThat(dmnResult.getDecisionResults().size(), is(1));
assertThat(dmnResult.getDecisionResultByName("Greeting Message").getResult(), is((String) null));
assertThat(dmnResult.getMessages().size(), is(1));
assertThat(dmnResult.getMessages().get(0).getSeverity(), is(DMNMessage.Severity.ERROR));
assertThat(dmnResult.getDecisionResults().get(0).getMessages().size(), is(1));
assertThat(dmnResult.getDecisionResults().get(0).getMessages().get(0).getSeverity(), is(DMNMessage.Severity.ERROR));
}
use of org.kie.dmn.api.core.DMNContext in project drools by kiegroup.
the class DMNInputRuntimeTest method testInputStringEvaluateDecisionByName.
@Test
public void testInputStringEvaluateDecisionByName() {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0001-input-data-string.dmn", this.getClass());
final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/drools/kie-dmn", "_0001-input-data-string");
assertThat(dmnModel, notNullValue());
final DMNContext context = DMNFactory.newContext();
context.set("Full Name", "John Doe");
DMNResult dmnResult = runtime.evaluateByName(dmnModel, context, "Greeting Message");
assertThat(dmnResult.getDecisionResults().size(), is(1));
assertThat(dmnResult.getDecisionResultByName("Greeting Message").getResult(), is("Hello John Doe"));
final DMNContext result = dmnResult.getContext();
assertThat(result.get("Greeting Message"), is("Hello John Doe"));
dmnResult = runtime.evaluateByName(dmnModel, context, "nonExistantName");
assertThat(dmnResult.getDecisionResults().size(), is(1));
assertThat(dmnResult.getDecisionResultByName("Greeting Message").getEvaluationStatus(), is(DMNDecisionResult.DecisionEvaluationStatus.NOT_EVALUATED));
dmnResult = runtime.evaluateByName(dmnModel, context, "");
assertThat(dmnResult.getDecisionResults().size(), is(1));
assertThat(dmnResult.getDecisionResultByName("Greeting Message").getEvaluationStatus(), is(DMNDecisionResult.DecisionEvaluationStatus.NOT_EVALUATED));
dmnResult = runtime.evaluateByName(dmnModel, context, (String) null);
assertThat(dmnResult.getDecisionResults().size(), is(1));
assertThat(dmnResult.getDecisionResultByName("Greeting Message").getEvaluationStatus(), is(DMNDecisionResult.DecisionEvaluationStatus.NOT_EVALUATED));
}
Aggregations