RunnerManagerPresenter extends BasePresenter implements RunnerManager,
                                                                     RunnerManagerView.ActionDelegate,
                                                                     ProjectActionHandler,
                                                                     SelectionManager.SelectionChangeListener { @Override public void onSelectionChanged(@NotNull Selection selection) { if (RUNNER.equals(selection)) { runnerSelected(); } else { environmentSelected(); } } @Inject  RunnerManagerPresenter(final RunnerManagerView view,
                                  RunnerActionFactory actionFactory,
                                  ModelsFactory modelsFactory,
                                  AppContext appContext,
                                  DtoFactory dtoFactory,
                                  ChooseRunnerAction chooseRunnerAction,
                                  EventBus eventBus,
                                  final RunnerLocalizationConstant locale,
                                  @LeftPanel TabContainer leftTabContainer,
                                  @LeftPropertiesPanel TabContainer leftPropertiesContainer,
                                  @RightPropertiesPanel TabContainer rightPropertiesContainer,
                                  PanelState panelState,
                                  Provider<TabBuilder> tabBuilderProvider,
                                  final ConsoleContainer consoleContainer,
                                  TerminalContainer terminalContainer,
                                  PropertiesContainer propertiesContainer,
                                  HistoryPanel history,
                                  TemplatesContainer templateContainer,
                                  RunnerCounter runnerCounter,
                                  SelectionManager selectionManager,
                                  TimerFactory timerFactory,
                                  GetSystemEnvironmentsAction getSystemEnvironmentsAction,
                                  RunnerUtil runnerUtil,
                                  @Run ResourcesLockedActionPermit runActionPermit,
                                  @Run ActionDenyAccessDialog runActionDenyAccessDialog); @NotNull RunnerManagerView getView(); void update(@NotNull Runner runner); @Override void onRunButtonClicked(); @Override void onRerunButtonClicked(); @Override void onStopButtonClicked(); @Override void onLogsButtonClicked(); @Override void stopRunner(@NotNull Runner runner); @Override void onMoreInfoBtnMouseOver(); @Override void onToggleSplitterClicked(boolean isShowSplitter); @Override Runner launchRunner(); @NotNull @Override Runner launchRunner(@NotNull RunOptions runOptions); @Override @NotNull Runner launchRunner(@NotNull RunOptions runOptions, @NotNull Scope scope, @NotNull String environmentName); @Override void go(@NotNull AcceptsOneWidget container); void setActive(); @NotNull @Override String getTitle(); @Nullable @Override ImageResource getTitleImage(); @Nullable @Override String getTitleToolTip(); @Override void onProjectReady(@NotNull ProjectActionEvent projectActionEvent); @Override void onProjectClosing(ProjectActionEvent event); @Override void onProjectClosed(@NotNull ProjectActionEvent projectActionEvent); @Override void onProjectOpened(ProjectActionEvent event); @NotNull Runner addRunner(@NotNull ApplicationProcessDescriptor processDescriptor); void addRunnerId(@NotNull Long runnerId); boolean isRunnerExist(@NotNull Long runnerId); @Override void onSelectionChanged(@NotNull Selection selection); static final String TIMER_STUB; }
@Test public void verifyInQueueTimer() { when(locale.messageRunnerInQueue()).thenReturn(TEXT); when(runner.getStatus()).thenReturn(IN_QUEUE); presenter.onSelectionChanged(RUNNER); verify(timerFactory, times(2)).newInstance(timerCaptor.capture()); timerCaptor.getAllValues().get(1).onRun(); verify(runner, times(2)).getStatus(); verify(locale).messageRunnerInQueue(); verify(consoleContainer).printInfo(runner, TEXT); }
@Test public void messageShouldNotBeShownIfRunnerIsNotInQueue() { when(runner.getStatus()).thenReturn(IN_PROGRESS); presenter.onSelectionChanged(RUNNER); verify(timerFactory, times(2)).newInstance(timerCaptor.capture()); timerCaptor.getAllValues().get(1).onRun(); verify(runner, times(2)).getStatus(); verify(locale, never()).messageRunnerInQueue(); verify(consoleContainer, never()).printInfo(runner, TEXT); }
@Test public void selectionShouldNotBeChangedWhenSelectionIsRunnerAndRunnerIsNull() { when(selectionManager.getRunner()).thenReturn(null); reset(history, rightPropertiesContainer, view); presenter.onSelectionChanged(RUNNER); verify(selectionManager).getRunner(); verify(terminalContainer).setVisibleNoRunnerLabel(true); verify(consoleContainer).setVisibleNoRunnerLabel(true); verify(propertiesContainer).setVisibleNoRunnerLabel(true); verifyNoMoreInteractions(history, rightPropertiesContainer, view); }
@Test public void selectionShouldBeChangedWhenSelectionIsRunner() { presenter.onSelectionChanged(RUNNER); verify(selectionManager).getRunner(); verifyRunnerSelected(); }
@Test public void selectionShouldBeChangedWhenSelectionIsEnvironmentAndRunnerEnvironmentIsNull() { presenter.onSelectionChanged(ENVIRONMENT); verify(selectionManager).getEnvironment(); verifyNoMoreInteractions(templates); }
@Test public void selectionShouldBeChangedWhenSelectionIsEnvironment() { when(selectionManager.getEnvironment()).thenReturn(runnerEnvironment); presenter.onSelectionChanged(ENVIRONMENT); verify(selectionManager).getEnvironment(); verify(templates).select(runnerEnvironment); }
@Test public void timerShouldNotUpdateIfRunnerIsNull() { when(selectionManager.getRunner()).thenReturn(null); presenter.onSelectionChanged(RUNNER); reset(view, runnerTimer); verify(timerFactory, times(2)).newInstance(timerCaptor.capture()); timerCaptor.getAllValues().get(0).onRun(); verifyNoMoreInteractions(view); verify(runnerTimer).schedule(TimeInterval.ONE_SEC.getValue()); }