use of org.kie.dmn.core.impl.VoidDMNRuntimeKB in project drools by kiegroup.
the class ExecuteDMNCommandTest method execute.
@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(new VoidDMNRuntimeKB()));
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());
}
Aggregations