use of org.kie.dmn.api.core.DMNRuntime in project drools by kiegroup.
the class DMNRuntimeTypeCheckTest method testAskTypeCheckInKModuleButOverrideRuntime.
@Test
public void testAskTypeCheckInKModuleButOverrideRuntime() {
DMNRuntime runtime = getRuntimeWithTypeCheckOption("true", ks.getResources().newClassPathResource("forTypeCheckTest.dmn", this.getClass()));
((DMNRuntimeImpl) runtime).setOption(new RuntimeTypeCheckOption(false));
assertPerformTypeCheck(runtime);
}
use of org.kie.dmn.api.core.DMNRuntime 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.DMNRuntime in project drools by kiegroup.
the class DMNRuntimeTypeCheckTest method testExplicitDisableTypeCheckInKModule.
@Test
public void testExplicitDisableTypeCheckInKModule() {
DMNRuntime runtime = getRuntimeWithTypeCheckOption("false", ks.getResources().newClassPathResource("forTypeCheckTest.dmn", this.getClass()));
assertNoTypeCheck(runtime);
}
use of org.kie.dmn.api.core.DMNRuntime in project drools by kiegroup.
the class DMNRuntimeTypeCheckTest method testDefaultNoTypeCheck.
@Test
public void testDefaultNoTypeCheck() {
// do NOT use the DMNRuntimeUtil as that enables typeSafe check override for runtime.
final KieContainer kieContainer = KieHelper.getKieContainer(ks.newReleaseId("org.kie", "dmn-test-" + UUID.randomUUID(), "1.0"), ks.getResources().newClassPathResource("forTypeCheckTest.dmn", this.getClass()));
DMNRuntime runtime = kieContainer.newKieSession().getKieRuntime(DMNRuntime.class);
assertNoTypeCheck(runtime);
}
use of org.kie.dmn.api.core.DMNRuntime in project drools by kiegroup.
the class DMNRuntimeTypeCheckTest method testExplicitDisableTypeCheckInKModuleButOverrideRuntime.
@Test
public void testExplicitDisableTypeCheckInKModuleButOverrideRuntime() {
DMNRuntime runtime = getRuntimeWithTypeCheckOption("false", ks.getResources().newClassPathResource("forTypeCheckTest.dmn", this.getClass()));
((DMNRuntimeImpl) runtime).setOption(new RuntimeTypeCheckOption(true));
assertPerformTypeCheck(runtime);
}
Aggregations