GetAllDMNContextCommand implements ExecutableCommand<Map<String, Object>> { @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(); }  @Override Map<String, Object> execute(Context context);  }
@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()); }