List<FEELProfile> profiles = (List)((DMNRuntimeImpl) runtime).getProfiles(); FEEL feel = FEEL.newInstance(runtime.getRootClassLoader(), profiles);
public static DMNRuntime typeSafeGetKieRuntime(final KieContainer kieContainer) { DMNRuntime dmnRuntime = kieContainer.newKieSession().getKieRuntime(DMNRuntime.class); ((DMNRuntimeImpl) dmnRuntime).setOption(new RuntimeTypeCheckOption(true)); return dmnRuntime; }
@Test public void execute() { RegistryContext registryContext = new ContextImpl(); ExecuteDMNCommand executeDMNCommand = new ExecuteDMNCommand(); assertThatThrownBy(() -> executeDMNCommand.execute(registryContext)) .isInstanceOf(IllegalStateException.class) .hasMessage("No DMN active model defined"); registryContext.register(DMNModel.class, new DMNModelImpl(null)); assertThatThrownBy(() -> executeDMNCommand.execute(registryContext)) .isInstanceOf(IllegalStateException.class) .hasMessage("No DMNRuntime available"); DMNContext dmnContext = DMNFactory.newContext(); dmnContext.set("example", 10); registryContext.register(DMNRuntime.class, new DMNRuntimeImpl(null)); registryContext.register(DMNContext.class, dmnContext); DMNResult result = executeDMNCommand.execute(registryContext); assertNotNull(result); DMNContext newDmnContext = registryContext.lookup(DMNContext.class); assertEquals(1, dmnContext.getAll().size()); assertEquals(0, newDmnContext.getAll().size()); } }
@Test public void testExplicitDisableTypeCheckInKModuleButOverrideRuntime() { final DMNRuntime runtime = getRuntimeWithTypeCheckOption("false", ks.getResources().newClassPathResource("forTypeCheckTest.dmn", this.getClass())); ((DMNRuntimeImpl) runtime).setOption(new RuntimeTypeCheckOption(true)); assertPerformTypeCheck(runtime); }
@Test public void testAskTypeCheckInKModuleButOverrideRuntime() { final DMNRuntime runtime = getRuntimeWithTypeCheckOption("true", ks.getResources().newClassPathResource("forTypeCheckTest.dmn", this.getClass())); ((DMNRuntimeImpl) runtime).setOption(new RuntimeTypeCheckOption(false)); assertPerformTypeCheck(runtime); }
List<FEELProfile> profiles = (List)((DMNRuntimeImpl) runtime).getProfiles(); FEEL feel = FEEL.newInstance(runtime.getRootClassLoader(), profiles);
@Test public void testDefaultNoTypeCheckButOverrideRuntime() { // 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())); final DMNRuntime runtime = kieContainer.newKieSession().getKieRuntime(DMNRuntime.class); ((DMNRuntimeImpl) runtime).setOption(new RuntimeTypeCheckOption(true)); assertPerformTypeCheck(runtime); }