use of org.kie.internal.command.RegistryContext in project drools by kiegroup.
the class GetAllDMNContextCommand method execute.
@Override
public Map<String, Object> execute(Context context) {
RegistryContext registryContext = (RegistryContext) context;
DMNResult dmnResult = registryContext.lookup(DMNResult.class);
if (dmnResult == null) {
throw new IllegalStateException("There is not DMNResult available");
}
return dmnResult.getContext().getAll();
}
use of org.kie.internal.command.RegistryContext in project drools by kiegroup.
the class GetAllDMNContextCommandTest method execute.
@Test
public void execute() {
RegistryContext registryContext = new ContextImpl();
GetAllDMNContextCommand getAllDMNContextCommand = new GetAllDMNContextCommand();
assertThatThrownBy(() -> getAllDMNContextCommand.execute(registryContext)).isInstanceOf(IllegalStateException.class).hasMessage("There is not DMNResult available");
DMNResultImpl dmnResult = new DMNResultImpl(null);
dmnResult.setContext(new DMNContextImpl());
registryContext.register(DMNResult.class, dmnResult);
Map<String, Object> result = getAllDMNContextCommand.execute(registryContext);
assertEquals(0, result.size());
}
use of org.kie.internal.command.RegistryContext in project drools by kiegroup.
the class GetDMNMessagesCommandTest method execute.
@Test
public void execute() {
RegistryContext registryContext = new ContextImpl();
GetDMNMessagesCommand getDMNMessagesCommand = new GetDMNMessagesCommand();
assertThatThrownBy(() -> getDMNMessagesCommand.execute(registryContext)).isInstanceOf(IllegalStateException.class).hasMessage("There is no DMNResult available");
DMNResultImpl dmnResult = new DMNResultImpl(null);
dmnResult.setContext(new DMNContextImpl());
registryContext.register(DMNResult.class, dmnResult);
List<DMNMessage> result = getDMNMessagesCommand.execute(registryContext);
assertEquals(0, result.size());
}
use of org.kie.internal.command.RegistryContext in project drools by kiegroup.
the class SetDMNInputCommandTest method execute.
@Test
public void execute() {
RegistryContext registryContext = new ContextImpl();
String testVariable = "testVariable";
SetDMNInputCommand setDMNInputCommand = new SetDMNInputCommand(testVariable, 10);
setDMNInputCommand.execute(registryContext);
DMNContext lookup = registryContext.lookup(DMNContext.class);
assertTrue(lookup.isDefined(testVariable));
}
use of org.kie.internal.command.RegistryContext in project drools by kiegroup.
the class GetContextCommand method execute.
@Override
public Void execute(Context context) {
Context returned = ((RegistryContext) context).getContextManager().getContext(name);
((RequestContextImpl) context).setApplicationContext(returned);
return null;
}
Aggregations