ScenarioSimulationMainGridPanelMouseMoveHandler extends AbstractScenarioSimulationGridPanelHandler implements ScenarioSimulationGridPanelMouseMoveHandler { protected void setupPopupPresenter(final FactMappingValue toManage, final int uiRowIndex, final int uiColumnIndex, final int xPosition,final int yPosition,final PopoverView.Position position) { final Object expectedValue = toManage.getRawValue(); final Object errorValue = toManage.getErrorValue(); if (FactMappingValueStatus.FAILED_WITH_ERROR == toManage.getStatus()) { errorReportPopupPresenter.setup(ScenarioSimulationEditorConstants.INSTANCE.errorReason(), ScenarioSimulationEditorConstants.INSTANCE.errorPopoverMessageFailedWithError( expectedValue != null ? expectedValue.toString() : NULL, errorValue != null ? errorValue.toString() : NULL), ScenarioSimulationEditorConstants.INSTANCE.keep(), ScenarioSimulationEditorConstants.INSTANCE.apply(), () -> scenarioGrid.getEventBus().fireEvent( new SetGridCellValueEvent(scenarioGrid.getGridWidget(), uiRowIndex, uiColumnIndex, errorValue != null ? errorValue.toString() : NULL)), xPosition, yPosition, position); } else { errorReportPopupPresenter.setup(ScenarioSimulationEditorConstants.INSTANCE.errorReason(), ScenarioSimulationEditorConstants.INSTANCE.errorPopoverMessageFailedWithException( toManage.getExceptionMessage()), ScenarioSimulationEditorConstants.INSTANCE.close(), xPosition, yPosition, position); } }  @Override void onNodeMouseMove(NodeMouseMoveEvent event); @Override void hidePopover(); @Override void setErrorReportPopupPresenter(ErrorReportPopoverPresenter errorReportPopupPresenter);  }
@Test public void setupPopupPresenterFailedWithoutValues() { when(factMappingValueMock.getRawValue()).thenReturn(null); when(factMappingValueMock.getErrorValue()).thenReturn(null); mouseMoveHandler.setupPopupPresenter(factMappingValueMock, ROW_INDEX, COLUMN_INDEX, DX, DY, PopoverView.Position.RIGHT); verify(errorReportPopupPresenterMock, times(1)).setup( eq(ScenarioSimulationEditorConstants.INSTANCE.errorReason()), eq(ScenarioSimulationEditorConstants.INSTANCE.errorPopoverMessageFailedWithError(NULL, NULL)), eq(ScenarioSimulationEditorConstants.INSTANCE.keep()), eq(ScenarioSimulationEditorConstants.INSTANCE.apply()), isA(Command.class), eq(DX), eq(DY), eq(PopoverView.Position.RIGHT)); }
@Test public void setupPopupPresenterWithScrollFailedWithError() { when(elementMock.getScrollTop()).thenReturn(SCROLL_TOP); when(elementMock.getScrollLeft()).thenReturn(SCROLL_LEFT); when(factMappingValueMock.getStatus()).thenReturn(FactMappingValueStatus.FAILED_WITH_ERROR); mouseMoveHandler.setupPopupPresenter(factMappingValueMock, ROW_INDEX, COLUMN_INDEX, DX, DY, PopoverView.Position.RIGHT); verify(errorReportPopupPresenterMock, times(1)).setup( eq(ScenarioSimulationEditorConstants.INSTANCE.errorReason()), eq(ScenarioSimulationEditorConstants.INSTANCE.errorPopoverMessageFailedWithError(RAW_VALUE, ERROR_VALUE)), eq(ScenarioSimulationEditorConstants.INSTANCE.keep()), eq(ScenarioSimulationEditorConstants.INSTANCE.apply()), isA(Command.class), eq(DX), eq(DY), eq(PopoverView.Position.RIGHT)); }
@Test public void setupPopupPresenterWithScrollFailedWithException() { when(elementMock.getScrollTop()).thenReturn(SCROLL_TOP); when(elementMock.getScrollLeft()).thenReturn(SCROLL_LEFT); when(factMappingValueMock.getStatus()).thenReturn(FactMappingValueStatus.FAILED_WITH_EXCEPTION); when(factMappingValueMock.getExceptionMessage()).thenReturn(EXCEPTION); mouseMoveHandler.setupPopupPresenter(factMappingValueMock, ROW_INDEX, COLUMN_INDEX, DX, DY, PopoverView.Position.RIGHT); verify(errorReportPopupPresenterMock, times(1)).setup( eq(ScenarioSimulationEditorConstants.INSTANCE.errorReason()), eq(ScenarioSimulationEditorConstants.INSTANCE.errorPopoverMessageFailedWithException(EXCEPTION)), eq(ScenarioSimulationEditorConstants.INSTANCE.close()), eq(DX), eq(DY), eq(PopoverView.Position.RIGHT)); }