TerminalContainerPresenter implements TerminalContainer,
                                                   TerminalContainerView.ActionDelegate,
                                                   SelectionManager.SelectionChangeListener { public void onSelectionChanged(@NotNull Selection selection) { if (ENVIRONMENT.equals(selection)) { return; } Runner runner = selectionManager.getRunner(); if (runner == null) { return; } showTerminal(runner); } @Inject  TerminalContainerPresenter(TerminalContainerView view,
                                      WidgetFactory widgetFactory,
                                      EventBus eventBus,
                                      final SelectionManager selectionManager); void onSelectionChanged(@NotNull Selection selection); @NotNull @Override IsWidget getView(); @Override void setVisible(boolean visible); @Override void go(AcceptsOneWidget container); @Override void update(@NotNull Runner runner); @Override void reset(); @Override void removeTerminalUrl(@NotNull Runner runner); @Override void setVisibleNoRunnerLabel(boolean isVisible);  }
@Test public void terminalShouldBeVisibleIfStatusOfRunnerIsNotRunning() throws Exception { presenter.onSelectionChanged(Selection.RUNNER); when(selectionManager.getRunner()).thenReturn(runner); when(runner.getStatus()).thenReturn(STOPPED); verify(eventBus).addHandler(Matchers.<Event.Type<RunnerApplicationStatusEventHandler>>anyObject(), appEventHandlerCaptor.capture()); RunnerApplicationStatusEventHandler handlerValue = appEventHandlerCaptor.getValue(); handlerValue.onRunnerStatusChanged(runner); verify(terminal, never()).setUrl(runner); }
@Test public void shouldOnSelectionChangedToRunner() { presenter.onSelectionChanged(Selection.RUNNER); verify(selectionManager).getRunner(); verify(widgetFactory).createTerminal(); verify(view).addWidget(terminal); }