ScenarioSimulationEventHandler implements AppendColumnEventHandler,
                                                       AppendRowEventHandler,
                                                       DeleteColumnEventHandler,
                                                       DeleteRowEventHandler,
                                                       DisableTestToolsEventHandler,
                                                       DuplicateInstanceEventHandler,
                                                       DuplicateRowEventHandler,
                                                       EnableTestToolsEventHandler,
                                                       ImportEventHandler,
                                                       InsertColumnEventHandler,
                                                       InsertRowEventHandler,
                                                       PrependColumnEventHandler,
                                                       PrependRowEventHandler,
                                                       RedoEventHandler,
                                                       ReloadTestToolsEventHandler,
                                                       RunSingleScenarioEventHandler,
                                                       ScenarioGridReloadEventHandler,
                                                       ScenarioNotificationEventHandler,
                                                       SetGridCellValueEventHandler,
                                                       SetHeaderCellValueEventHandler,
                                                       SetInstanceHeaderEventHandler,
                                                       SetPropertyHeaderEventHandler,
                                                       UndoEventHandler,
                                                       UnsupportedDMNEventHandler,
                                                       ValidateSimulationEventHandler { protected void commonExecution(final AbstractScenarioSimulationCommand command, final boolean focusGridAfterExecution) { final Optional<AbstractScesimGridModel> selectedScenarioGridModel = context.getSelectedScenarioGridModel(); final Optional<GridWidget> gridWidget = selectedScenarioGridModel.isPresent() ? Optional.of(selectedScenarioGridModel.get().getGridWidget()) : Optional.empty(); gridWidget.ifPresent(grd -> context.getStatus().setCurrentGrid(grd)); final CommandResult<ScenarioSimulationViolation> status = scenarioCommandManager.execute(context, command); if (Objects.equals(CommandResult.Type.ERROR, status.getType())) { String operation = new StringBuilder() .append("Command ") .append(command.getClass().getSimpleName()) .append(" failure") .toString(); commonNotifyError(status, operation); } else if (Objects.equals(CommandResultBuilder.SUCCESS, status) && (command instanceof AbstractScenarioGridCommand)) { scenarioCommandRegistryManager.register(context, (AbstractScenarioGridCommand) command); if (focusGridAfterExecution && gridWidget.isPresent()) { context.getScenarioGridPanelByGridWidget(gridWidget.get()).setFocus(true); } } }  void setEventBus(EventBus eventBus); void setDeletePopupPresenter(DeletePopupPresenter deletePopupPresenter); void setPreserveDeletePopupPresenter(PreserveDeletePopupPresenter preserveDeletePopupPresenter); void setConfirmPopupPresenter(ConfirmPopupPresenter confirmPopupPresenter); void setFileUploadPopupPresenter(FileUploadPopupPresenter fileUploadPopupPresenter); void setNotificationEvent(Event<NotificationEvent> notificationEvent); void setScenarioSimulationPresenter(ScenarioSimulationEditorPresenter scenarioSimulationEditorPresenter); void setScenarioCommandRegistryManager(ScenarioCommandRegistryManager scenarioCommandRegistryManager); void setScenarioCommandManager(ScenarioCommandManager scenarioCommandManager); void setContext(ScenarioSimulationContext context); @PreDestroy void unregisterHandlers(); @Override void onEvent(AppendColumnEvent event); @Override void onEvent(AppendRowEvent event); @Override void onEvent(DeleteColumnEvent event); @Override void onEvent(DeleteRowEvent event); @Override void onEvent(DisableTestToolsEvent event); @Override void onEvent(DuplicateInstanceEvent event); @Override void onEvent(DuplicateRowEvent event); @Override void onEvent(EnableTestToolsEvent event); @Override void onEvent(ImportEvent event); @Override void onEvent(InsertColumnEvent event); @Override void onEvent(InsertRowEvent event); @Override void onEvent(PrependColumnEvent event); @Override void onEvent(PrependRowEvent event); @Override void onEvent(RedoEvent event); @Override void onEvent(ReloadTestToolsEvent event); @Override void onEvent(RunSingleScenarioEvent event); @Override void onEvent(ScenarioGridReloadEvent event); @Override void onEvent(ScenarioNotificationEvent event); @Override void onEvent(SetGridCellValueEvent event); @Override void onEvent(SetHeaderCellValueEvent event); @Override void onEvent(SetInstanceHeaderEvent event); @Override void onEvent(SetPropertyHeaderEvent event); @Override void onEvent(UndoEvent event); @Override void onEvent(UnsupportedDMNEvent event); @Override void onEvent(ValidateSimulationEvent event);  }
@Test public void commonExecution() { when(scenarioCommandManagerMock.execute(eq(scenarioSimulationContextLocal), eq(appendRowCommandMock))).thenReturn(CommandResultBuilder.SUCCESS); scenarioSimulationEventHandler.commonExecution(appendRowCommandMock, true); assertEquals(simulationMock, scenarioSimulationContextLocal.getStatus().getSimulation()); verify(scenarioCommandRegistryManagerMock, times(1)).register(eq(scenarioSimulationContextLocal), eq(appendRowCommandMock)); reset(scenarioCommandRegistryManagerMock); CommandResult<ScenarioSimulationViolation> status = new CommandResultImpl<>(CommandResult.Type.ERROR, Collections.singletonList(new ScenarioSimulationViolation("FAKE ERROR"))); when(scenarioCommandManagerMock.execute(eq(scenarioSimulationContextLocal), eq(appendRowCommandMock))).thenReturn(status); scenarioSimulationEventHandler.commonExecution(appendRowCommandMock, true); assertEquals(simulationMock, scenarioSimulationContextLocal.getStatus().getSimulation()); verify(scenarioCommandRegistryManagerMock, never()).register(eq(scenarioSimulationContextLocal), eq(appendRowCommandMock)); }