Search in sources :

Example 36 with DMNRuntime

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;
}
Also used : KieServices(org.kie.api.KieServices) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) KieContainer(org.kie.api.runtime.KieContainer)

Example 37 with DMNRuntime

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;
}
Also used : KieServices(org.kie.api.KieServices) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) KieContainer(org.kie.api.runtime.KieContainer)

Example 38 with DMNRuntime

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;
}
Also used : DMNRuntimeImpl(org.kie.dmn.core.impl.DMNRuntimeImpl) RuntimeTypeCheckOption(org.kie.dmn.core.compiler.RuntimeTypeCheckOption) DMNRuntime(org.kie.dmn.api.core.DMNRuntime)

Example 39 with 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;
}
Also used : Resource(org.kie.api.io.Resource) ArrayList(java.util.ArrayList) KieServices(org.kie.api.KieServices) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) KieContainer(org.kie.api.runtime.KieContainer)

Example 40 with DMNRuntime

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());
}
Also used : DMNResult(org.kie.dmn.api.core.DMNResult) DMNContext(org.kie.dmn.api.core.DMNContext) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) DMNModel(org.kie.dmn.api.core.DMNModel) Test(org.junit.Test)

Aggregations

DMNRuntime (org.kie.dmn.api.core.DMNRuntime)178 Test (org.junit.Test)164 DMNModel (org.kie.dmn.api.core.DMNModel)152 DMNContext (org.kie.dmn.api.core.DMNContext)132 DMNResult (org.kie.dmn.api.core.DMNResult)128 KieContainer (org.kie.api.runtime.KieContainer)34 KieServices (org.kie.api.KieServices)30 BigDecimal (java.math.BigDecimal)26 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)26 HashMap (java.util.HashMap)25 List (java.util.List)22 ArrayList (java.util.ArrayList)21 Map (java.util.Map)21 DMNMessage (org.kie.dmn.api.core.DMNMessage)16 CoreMatchers.is (org.hamcrest.CoreMatchers.is)13 CoreMatchers.notNullValue (org.hamcrest.CoreMatchers.notNullValue)13 Results (org.kie.api.builder.Results)13 AfterEvaluateDecisionTableEvent (org.kie.dmn.api.core.event.AfterEvaluateDecisionTableEvent)13 DMNRuntimeEventListener (org.kie.dmn.api.core.event.DMNRuntimeEventListener)13 DecisionNodeImpl (org.kie.dmn.core.ast.DecisionNodeImpl)13