use of org.kie.dmn.api.core.DMNRuntime in project drools by kiegroup.
the class DMNRuntimeUtil method createRuntime.
public static DMNRuntime createRuntime(final Class testClass) {
final KieServices ks = KieServices.Factory.get();
final KieContainer kieContainer = KieHelper.getKieContainer(ks.newReleaseId("org.kie", "dmn-test-" + UUID.randomUUID(), "1.0"));
final DMNRuntime runtime = typeSafeGetKieRuntime(kieContainer);
Assert.assertNotNull(runtime);
return runtime;
}
use of org.kie.dmn.api.core.DMNRuntime in project drools by kiegroup.
the class DMNRuntimeUtil method createRuntime.
public static DMNRuntime createRuntime(final String resourceName, final Class testClass) {
final KieServices ks = KieServices.Factory.get();
final KieContainer kieContainer = KieHelper.getKieContainer(ks.newReleaseId("org.kie", "dmn-test-" + UUID.randomUUID(), "1.0"), ks.getResources().newClassPathResource(resourceName, testClass));
final DMNRuntime runtime = typeSafeGetKieRuntime(kieContainer);
Assert.assertNotNull(runtime);
return runtime;
}
use of org.kie.dmn.api.core.DMNRuntime in project drools by kiegroup.
the class DMNRuntimeUtil method typeSafeGetKieRuntime.
private static DMNRuntime typeSafeGetKieRuntime(final KieContainer kieContainer) {
DMNRuntime dmnRuntime = kieContainer.newKieSession().getKieRuntime(DMNRuntime.class);
((DMNRuntimeImpl) dmnRuntime).setOption(new RuntimeTypeCheckOption(true));
return dmnRuntime;
}
use of org.kie.dmn.api.core.DMNRuntime in project drools by kiegroup.
the class DMNRuntimeUtil method createRuntimeWithAdditionalResources.
public static DMNRuntime createRuntimeWithAdditionalResources(final String resourceName, final Class testClass, final String... additionalResources) {
final KieServices ks = KieServices.Factory.get();
Resource mainResource = ks.getResources().newClassPathResource(resourceName, testClass);
List<Resource> totalResources = new ArrayList<>();
totalResources.add(mainResource);
for (String add : additionalResources) {
totalResources.add(ks.getResources().newClassPathResource(add, testClass));
}
final KieContainer kieContainer = KieHelper.getKieContainer(ks.newReleaseId("org.kie", "dmn-test-" + UUID.randomUUID(), "1.0"), totalResources.toArray(new Resource[] {}));
final DMNRuntime runtime = typeSafeGetKieRuntime(kieContainer);
Assert.assertNotNull(runtime);
return runtime;
}
use of org.kie.dmn.api.core.DMNRuntime in project drools by kiegroup.
the class DMNAssemblerTest method testStrictMode.
@Test
public void testStrictMode() {
System.setProperty("org.kie.dmn.strictConformance", "true");
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);
assertNull(result.getDecisionResultByName("time").getResult());
}
Aggregations