BusinessCentralGridContextMenu extends GridContextMenu { @Override public void show(GridWidget gridWidget, int mx, int my, int rowIndex) { super.show(gridWidget, mx, my, rowIndex); if (Objects.equals(GridWidget.BACKGROUND, gridWidget) && runSingleScenarioElement != null) { removeMenuItem(runSingleScenarioElement); runSingleScenarioElement = null; } else if (Objects.equals(GridWidget.SIMULATION, gridWidget)) { if (runSingleScenarioElement == null) { runSingleScenarioElement = addExecutableMenuItem(GRIDCONTEXTMENU_RUN_SINGLE_SCENARIO, constants.runSingleScenario(), "runSingleScenario"); } mapEvent(runSingleScenarioElement, new RunSingleScenarioEvent(rowIndex)); } }  @PostConstruct @Override void initMenu(); @Override void show(GridWidget gridWidget, int mx, int my, int rowIndex);  }
@Test public void show_Simulation_NullRunScenarioElement() { businessCentralGridContextMenuSpy.runSingleScenarioElement = null; super.show(businessCentralGridContextMenuSpy, GridWidget.SIMULATION, ScenarioSimulationEditorConstants.INSTANCE.scenario(), "scenario",0, 0, 1); verify(businessCentralGridContextMenuSpy, times(1)).addExecutableMenuItem(eq(GRIDCONTEXTMENU_RUN_SINGLE_SCENARIO), eq(ScenarioSimulationEditorConstants.INSTANCE.runSingleScenario()), eq("runSingleScenario")); verify(businessCentralGridContextMenuSpy, times(1)).mapEvent(eq(createdElementMock), isA(RunSingleScenarioEvent.class)); }
@Test public void show_Simulation_NotNullRunScenarioElement() { super.show(businessCentralGridContextMenuSpy, GridWidget.SIMULATION, ScenarioSimulationEditorConstants.INSTANCE.scenario(), "scenario", 0, 0, 1); verify(businessCentralGridContextMenuSpy, never()).addExecutableMenuItem(eq(GRIDCONTEXTMENU_RUN_SINGLE_SCENARIO), eq(ScenarioSimulationEditorConstants.INSTANCE.runSingleScenario()), eq("runSingleScenario")); verify(businessCentralGridContextMenuSpy, times(1)).mapEvent(eq(runSingleScenarioElementMock), isA(RunSingleScenarioEvent.class)); }
@Test public void show_Background_NullRunScenarioElement() { businessCentralGridContextMenuSpy.runSingleScenarioElement = null; super.show(businessCentralGridContextMenuSpy, GridWidget.BACKGROUND, ScenarioSimulationEditorConstants.INSTANCE.background(), "background", 0, 0, 1); verify(businessCentralGridContextMenuSpy, never()).addExecutableMenuItem(eq(GRIDCONTEXTMENU_RUN_SINGLE_SCENARIO), eq(ScenarioSimulationEditorConstants.INSTANCE.runSingleScenario()), eq("runSingleScenario")); verify(businessCentralGridContextMenuSpy, never()).mapEvent(eq(createdElementMock), isA(RunSingleScenarioEvent.class)); }
@Test public void show_Background_NotNullRunScenarioElement() { super.show(businessCentralGridContextMenuSpy, GridWidget.BACKGROUND, ScenarioSimulationEditorConstants.INSTANCE.background(), "background", 0, 0, 1); verify(businessCentralGridContextMenuSpy, never()).addExecutableMenuItem(eq(GRIDCONTEXTMENU_RUN_SINGLE_SCENARIO), eq(ScenarioSimulationEditorConstants.INSTANCE.runSingleScenario()), eq("runSingleScenario")); verify(businessCentralGridContextMenuSpy, never()).mapEvent(eq(createdElementMock), isA(RunSingleScenarioEvent.class)); }