ScenarioSimulationEditorPresenter { public void onUberfireDocksInteractionEvent(@Observes final UberfireDocksInteractionEvent uberfireDocksInteractionEvent) { if (isUberfireDocksInteractionEventToManage(uberfireDocksInteractionEvent) && !TestToolsPresenter.IDENTIFIER.equals(uberfireDocksInteractionEvent.getTargetDock().getIdentifier())) { populateRightDocks(uberfireDocksInteractionEvent.getTargetDock().getIdentifier()); } } ScenarioSimulationEditorPresenter(); @Inject  ScenarioSimulationEditorPresenter(final AbstractScenarioSimulationProducer abstractScenarioSimulationProducer,
                                             final ScenarioSimulationResourceType type,
                                             final PlaceManager placeManager,
                                             final AbstractScenarioSimulationDocksHandler abstractScenarioSimulationDocksHandler,
                                             final TextFileExport textFileExport,
                                             final ConfirmPopupPresenter confirmPopupPresenter); void setWrapper(ScenarioSimulationEditorWrapper scenarioSimulationEditorWrapper); void setPath(ObservablePath path); ObservablePath getPath(); void setPackageName(String packageName); void onClose(); void showDocks(PlaceStatus status); void hideDocks(); void onUberfireDocksInteractionEvent(@Observes final UberfireDocksInteractionEvent uberfireDocksInteractionEvent); void expandToolsDock(); ScenarioSimulationView getView(); ScenarioSimulationModel getModel(); Command getPopulateTestToolsCommand(); void reloadTestTools(boolean disable); void onRunScenario(); void onRunScenario(List<Integer> indexOfScenarioToRun); void onUndo(); void onRedo(); void setUndoButtonEnabledStatus(boolean enabled); void setRedoButtonEnabledStatus(boolean enabled); void setItemMenuEnabled(boolean enabled); void addDownloadMenuItem(FileMenuBuilder fileMenuBuilder, Supplier<Path> pathSupplier); DataManagementStrategy getDataManagementStrategy(); void onImport(String fileContents, GridWidget gridWidget); EventBus getEventBus(); ScenarioSimulationContext getContext(); void sendNotification(String text, NotificationEvent.NotificationType type); void sendNotification(String text, NotificationEvent.NotificationType type, boolean autoHide); void makeMenuBar(FileMenuBuilder fileMenuBuilder); void addCommonActions(final FileMenuBuilder fileMenuBuilder, MenuItem versionMenuItem, MenuItem alertsButtonMenuItem); void loadContent(); boolean isDirty(); void onEditTabSelected(); void onBackgroundTabSelected(); void onOverviewSelected(); void onImportsTabSelected(); void validateSimulation(); void selectSimulationTab(); void selectBackgroundTab(); RemoteCallback<String> getExportCallBack(); ErrorCallback<Boolean> getValidationFailedCallback(); void populateRightDocks(String identifier); void getModelSuccessCallbackMethod(DataManagementStrategy dataManagementStrategy, ScenarioSimulationModel model); ScenarioSimulationResourceType getType(); void setTestTools(TestToolsView.Presenter presenter); void setCheatSheet(CheatSheetView.Presenter presenter); void setSettings(SettingsView.Presenter presenter); String getJsonModel(ScenarioSimulationModel model); static final String IDENTIFIER; }
@Test public void onUberfireDocksInteractionEvent() { UberfireDocksInteractionEvent uberfireDocksInteractionEventMock = mock(UberfireDocksInteractionEvent.class); doReturn(false).when(presenterSpy).isUberfireDocksInteractionEventToManage(uberfireDocksInteractionEventMock); presenterSpy.onUberfireDocksInteractionEvent(uberfireDocksInteractionEventMock); verify(presenterSpy, times(1)).isUberfireDocksInteractionEventToManage(eq(uberfireDocksInteractionEventMock)); verify(uberfireDocksInteractionEventMock, never()).getTargetDock(); verify(presenterSpy, never()).populateRightDocks(anyString()); verify(scenarioSimulationEditorWrapperMock, never()).populateDocks(anyString()); reset(presenterSpy); presenterSpy.dataManagementStrategy = null; presenterSpy.onUberfireDocksInteractionEvent(uberfireDocksInteractionEventMock); verify(presenterSpy, times(1)).isUberfireDocksInteractionEventToManage(eq(uberfireDocksInteractionEventMock)); verify(presenterSpy, never()).populateRightDocks(anyString()); verify(scenarioSimulationEditorWrapperMock, never()).populateDocks(anyString()); reset(presenterSpy); reset(uberfireDocksInteractionEventMock); presenterSpy.dataManagementStrategy = dataManagementStrategyMock; UberfireDock targetDockMock = mock(UberfireDock.class); when(uberfireDocksInteractionEventMock.getTargetDock()).thenReturn(targetDockMock); doReturn(true).when(presenterSpy).isUberfireDocksInteractionEventToManage(uberfireDocksInteractionEventMock); when(targetDockMock.getIdentifier()).thenReturn(SettingsPresenter.IDENTIFIER); when(targetDockMock.getPlaceRequest()).thenReturn(placeRequestMock); presenterSpy.onUberfireDocksInteractionEvent(uberfireDocksInteractionEventMock); verify(presenterSpy, times(1)).isUberfireDocksInteractionEventToManage(eq(uberfireDocksInteractionEventMock)); verify(uberfireDocksInteractionEventMock, times(2)).getTargetDock(); verify(presenterSpy, times(1)).populateRightDocks(eq(SettingsPresenter.IDENTIFIER)); verify(scenarioSimulationEditorWrapperMock, times(1)).populateDocks(eq(SettingsPresenter.IDENTIFIER)); reset(presenterSpy); reset(uberfireDocksInteractionEventMock); presenterSpy.dataManagementStrategy = dataManagementStrategyMock; when(uberfireDocksInteractionEventMock.getTargetDock()).thenReturn(targetDockMock); doReturn(true).when(presenterSpy).isUberfireDocksInteractionEventToManage(uberfireDocksInteractionEventMock); when(targetDockMock.getIdentifier()).thenReturn(CheatSheetPresenter.IDENTIFIER); when(targetDockMock.getPlaceRequest()).thenReturn(placeRequestMock); presenterSpy.onUberfireDocksInteractionEvent(uberfireDocksInteractionEventMock); verify(presenterSpy, times(1)).isUberfireDocksInteractionEventToManage(eq(uberfireDocksInteractionEventMock)); verify(uberfireDocksInteractionEventMock, times(2)).getTargetDock(); verify(presenterSpy, times(1)).populateRightDocks(eq(CheatSheetPresenter.IDENTIFIER)); verify(scenarioSimulationEditorWrapperMock, times(1)).populateDocks(eq(CheatSheetPresenter.IDENTIFIER)); reset(presenterSpy, scenarioSimulationEditorWrapperMock, uberfireDocksInteractionEventMock); presenterSpy.dataManagementStrategy = dataManagementStrategyMock; when(uberfireDocksInteractionEventMock.getTargetDock()).thenReturn(targetDockMock); doReturn(true).when(presenterSpy).isUberfireDocksInteractionEventToManage(uberfireDocksInteractionEventMock); when(targetDockMock.getIdentifier()).thenReturn(TestToolsPresenter.IDENTIFIER); when(targetDockMock.getPlaceRequest()).thenReturn(placeRequestMock); presenterSpy.onUberfireDocksInteractionEvent(uberfireDocksInteractionEventMock); verify(presenterSpy, times(1)).isUberfireDocksInteractionEventToManage(eq(uberfireDocksInteractionEventMock)); verify(uberfireDocksInteractionEventMock, times(1)).getTargetDock(); verify(presenterSpy, never()).populateRightDocks(anyString()); verify(scenarioSimulationEditorWrapperMock, never()).populateDocks(anyString()); }