ScenarioContextMenuRegistry { private boolean manageHeaderRightClick(final ScenarioGrid scenarioGrid, final int left, final int top, final Integer uiHeaderRowIndex, final Integer uiColumnIndex) { final ScenarioGridColumn column = (ScenarioGridColumn) scenarioGrid.getModel().getColumns().get(uiColumnIndex); if (column == null) { return false; } ScenarioHeaderMetaData columnMetadata = ScenarioSimulationGridHeaderUtilities.getColumnScenarioHeaderMetaData(column, uiHeaderRowIndex); if (columnMetadata == null) { return false; } if (uiHeaderRowIndex == null) { return false; } boolean showDuplicateInstance = scenarioGrid.getType().equals(ScenarioSimulationModel.Type.RULE); String group = ScenarioSimulationUtils.getOriginalColumnGroup(columnMetadata.getColumnGroup()); switch (group) { case "": switch (columnMetadata.getTitle()) { case "GIVEN": headerGivenContextMenu.show(scenarioGrid.getGridWidget(), left, top); break; case "EXPECT": headerExpectedContextMenu.show(scenarioGrid.getGridWidget(), left, top); break; default: otherContextMenu.show(left, top); } break; case "GIVEN": givenContextMenu.show(scenarioGrid.getGridWidget(), left, top, uiColumnIndex, group, Objects.equals(columnMetadata.getMetadataType(), ScenarioHeaderMetaData.MetadataType.PROPERTY), showDuplicateInstance); break; case "EXPECT": expectedContextMenu.show(scenarioGrid.getGridWidget(),left, top, uiColumnIndex, group, Objects.equals(columnMetadata.getMetadataType(), ScenarioHeaderMetaData.MetadataType.PROPERTY), showDuplicateInstance); break; default: otherContextMenu.show(left, top); } scenarioGrid.setSelectedColumnAndHeader(uiHeaderRowIndex, uiColumnIndex); return true; } @Inject  ScenarioContextMenuRegistry(final OtherContextMenu otherContextMenu,
                                       final HeaderGivenContextMenu headerGivenContextMenu,
                                       final HeaderExpectedContextMenu headerExpectedContextMenu,
                                       final GivenContextMenu givenContextMenu,
                                       final ExpectedContextMenu expectedContextMenu,
                                       final GridContextMenu gridContextMenu); void setEventBus(final EventBus eventBus); void hideMenus(); boolean manageRightClick(final ScenarioGrid scenarioGrid,
                                    final ContextMenuEvent event); boolean manageRightClick(final ScenarioGrid scenarioGrid,
                                    final int clientXPosition,
                                    final int clientYPosition,
                                    final Integer uiRowIndex,
                                    final Integer uiColumnIndex,
                                    final boolean isHeader); void setErrorReportPopoverPresenter(ErrorReportPopoverPresenter errorReportPopoverPresenter); void hideErrorReportPopover();  }
@Test public void testManageHeaderRightClick() { final int clickPointX = 5; final int clickPointy = 6; doReturn(clickPointX).when(contextNativeEventMock).getClientX(); doReturn(clickPointy).when(contextNativeEventMock).getClientY(); assertThat(scenarioContextMenuRegistry.manageRightClick(scenarioGridMock, contextMenuEventMock)) .as("Click to [0,0] header cell") .isTrue(); verify(scenarioGridMock, times(1)).clearSelections(); verify(expectedContextMenuMock).show(GridWidget.SIMULATION, clickPointX, clickPointy, 0, COLUMN_GROUP, false, settingsLocal.getType().equals(ScenarioSimulationModel.Type.RULE)); verify(scenarioGridMock, times(1)).setSelectedColumnAndHeader(eq(0), eq(0)); verifyZeroInteractions(headerExpectedContextMenuMock); }