Search in sources :

Example 1 with VoidDMNRuntimeKB

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());
}
Also used : DMNResult(org.kie.dmn.api.core.DMNResult) DMNRuntimeImpl(org.kie.dmn.core.impl.DMNRuntimeImpl) DMNContext(org.kie.dmn.api.core.DMNContext) RegistryContext(org.kie.internal.command.RegistryContext) DMNModelImpl(org.kie.dmn.core.impl.DMNModelImpl) ContextImpl(org.drools.core.command.impl.ContextImpl) VoidDMNRuntimeKB(org.kie.dmn.core.impl.VoidDMNRuntimeKB) Test(org.junit.Test)

Aggregations

ContextImpl (org.drools.core.command.impl.ContextImpl)1 Test (org.junit.Test)1 DMNContext (org.kie.dmn.api.core.DMNContext)1 DMNResult (org.kie.dmn.api.core.DMNResult)1 DMNModelImpl (org.kie.dmn.core.impl.DMNModelImpl)1 DMNRuntimeImpl (org.kie.dmn.core.impl.DMNRuntimeImpl)1 VoidDMNRuntimeKB (org.kie.dmn.core.impl.VoidDMNRuntimeKB)1 RegistryContext (org.kie.internal.command.RegistryContext)1