ScenarioSimulationMainGridPanelClickHandler extends AbstractScenarioSimulationGridPanelHandler implements ScenarioSimulationGridPanelClickHandler { @Override public void setEventBus(EventBus eventBus) { this.eventBus = eventBus; }  void setScenarioContextMenuRegistry(ScenarioContextMenuRegistry scenarioContextMenuRegistry); @Override void setEventBus(EventBus eventBus); @Override void onClick(ClickEvent event); @Override @SuppressWarnings("unchecked") void onContextMenu(final ContextMenuEvent event); @Override void hideMenus();  }
@Test public void setEventBus() { scenarioSimulationMainGridPanelClickHandler.setEventBus(eventBusMock); assertSame(scenarioSimulationMainGridPanelClickHandler.eventBus, eventBusMock); }
@Test public void testManageLeftClick_ReadOnly() { when(informationHeaderMetaDataMock.isReadOnly()).thenReturn(true); scenarioSimulationMainGridPanelClickHandler.setEventBus(eventBusMock); assertTrue("Click to readonly header cell.", scenarioSimulationMainGridPanelClickHandler.manageCoordinates((int) CLICK_POINT_X, (int) CLICK_POINT_Y)); verify(scenarioGridMock, times(1)).setSelectedColumn(anyInt()); verify(eventBusMock, times(1)).fireEvent(any(EnableTestToolsEvent.class)); }
@Test public void testManageGridLeftClickReadOnlyTrue() { when(informationHeaderMetaDataMock.isReadOnly()).thenReturn(true); scenarioSimulationMainGridPanelClickHandler.setEventBus(eventBusMock); when(scenarioGridCellMock.isEditingMode()).thenReturn(false); doReturn(null).when(scenarioSimulationMainGridPanelClickHandler).getUiHeaderRowIndexLocal(isA(Point2D.class)); doReturn(UI_ROW_INDEX).when(scenarioSimulationMainGridPanelClickHandler).getUiRowIndexLocal(anyDouble()); doReturn(UI_COLUMN_INDEX).when(scenarioSimulationMainGridPanelClickHandler).getUiColumnIndexLocal(anyDouble()); assertTrue(scenarioSimulationMainGridPanelClickHandler.manageCoordinates((int) CLICK_POINT_X, (int) CLICK_POINT_Y)); verify(scenarioGridModelMock, times(1)).selectCell(eq(1), eq(0)); }
@Test public void testManageGridLeftClickReadOnlyFalse() { when(scenarioGridMock.startEditingCell(UI_ROW_INDEX, UI_COLUMN_INDEX)).thenReturn(true); when(informationHeaderMetaDataMock.isReadOnly()).thenReturn(false); scenarioSimulationMainGridPanelClickHandler.setEventBus(eventBusMock); when(scenarioGridCellMock.isEditingMode()).thenReturn(false); doReturn(null).when(scenarioSimulationMainGridPanelClickHandler).getUiHeaderRowIndexLocal(isA(Point2D.class)); doReturn(UI_ROW_INDEX).when(scenarioSimulationMainGridPanelClickHandler).getUiRowIndexLocal(anyDouble()); doReturn(UI_COLUMN_INDEX).when(scenarioSimulationMainGridPanelClickHandler).getUiColumnIndexLocal(anyDouble()); doReturn(scenarioGridCellMock).when(scenarioGridModelMock).getCell(UI_ROW_INDEX, UI_COLUMN_INDEX); assertTrue(scenarioSimulationMainGridPanelClickHandler.manageCoordinates((int) CLICK_POINT_X, (int) CLICK_POINT_Y)); verify(scenarioGridModelMock, times(1)).selectCell(eq(1), eq(0)); }