use of org.kie.dmn.api.core.DMNDecisionResult in project drools by kiegroup.
the class DMNRuntimeTest method testInvalidFunction.
@Test
public void testInvalidFunction() {
final DMNRuntime runtime = DMNRuntimeUtil.createRuntimeWithAdditionalResources("InvalidFunction.dmn", this.getClass());
final DMNModel model = runtime.getModel("http://www.trisotech.com/definitions/_84453b71-5d23-479f-9481-5196d92bacae", "0003-iteration-augmented");
assertThat(model, notNullValue());
final DMNContext context = DMNFactory.newContext();
context.set("Loans", new HashMap<>());
final DMNResult result = runtime.evaluateAll(model, context);
final List<DMNDecisionResult> decisionResults = result.getDecisionResults();
FEELStringMarshaller.INSTANCE.marshall(Arrays.asList(decisionResults.get(0).getResult(), decisionResults.get(1).getResult()));
}
use of org.kie.dmn.api.core.DMNDecisionResult in project drools by kiegroup.
the class DMNRuntimeTypeCheckTest method assertPerformTypeCheck.
private void assertPerformTypeCheck(DMNRuntime runtime) {
DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_6d8af9a2-dcf4-4b9e-8d90-6ccddc8c1bbd", "forTypeCheckTest");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
DMNContext context = DMNFactory.newContext();
context.set("a number", "ciao");
DMNResult dmnResult = runtime.evaluateAll(dmnModel, context);
assertThat("Should throw several errors, not only for 1 specific Decision: " + DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.getMessages(DMNMessage.Severity.ERROR).stream().allMatch(m -> m.getSourceId().equals(dmnModel.getDecisionByName("hundred minus number").getId())), is(false));
DMNDecisionResult textPlusNumberDR = dmnResult.getDecisionResultByName("text plus number");
// dependency failed type check
assertThat(textPlusNumberDR.getEvaluationStatus(), is(DecisionEvaluationStatus.SKIPPED));
DMNDecisionResult hundredMinusNumber = dmnResult.getDecisionResultByName("hundred minus number");
// dependency failed type check
assertThat(textPlusNumberDR.getEvaluationStatus(), is(DecisionEvaluationStatus.SKIPPED));
}
use of org.kie.dmn.api.core.DMNDecisionResult in project drools by kiegroup.
the class DMNRuntimeTypeCheckTest method assertNoTypeCheck.
private void assertNoTypeCheck(DMNRuntime runtime) {
DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_6d8af9a2-dcf4-4b9e-8d90-6ccddc8c1bbd", "forTypeCheckTest");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
DMNContext context = DMNFactory.newContext();
context.set("a number", "ciao");
DMNResult dmnResult = runtime.evaluateAll(dmnModel, context);
assertThat(DMNRuntimeUtil.formatMessages(dmnResult.getMessages()), dmnResult.getMessages(DMNMessage.Severity.ERROR).stream().allMatch(m -> m.getSourceId().equals(dmnModel.getDecisionByName("hundred minus number").getId())), is(true));
DMNDecisionResult textPlusNumberDR = dmnResult.getDecisionResultByName("text plus number");
assertThat(textPlusNumberDR.getEvaluationStatus(), is(DecisionEvaluationStatus.SUCCEEDED));
assertThat(textPlusNumberDR.getResult(), is("The input number is: ciao"));
DMNDecisionResult hundredMinusNumber = dmnResult.getDecisionResultByName("hundred minus number");
assertThat(hundredMinusNumber.getEvaluationStatus(), is(DecisionEvaluationStatus.FAILED));
}
Aggregations