PropertiesContainerPresenter implements PropertiesContainer,
                                                     PropertiesContainerView.ActionDelegate,
                                                     SelectionManager.SelectionChangeListener,
                                                     PropertiesPanelPresenter.RemovePanelListener { @Override public void show(@Nullable Runner runner) { if (runner == null) { view.clear(); return; } currentPanel = runnerPanels.get(runner); if (currentPanel == null) { currentPanel = widgetFactory.createPropertiesPanel(runner); currentPanel.hideButtonsPanel(); runnerPanels.put(runner, currentPanel); } currentPanel.update(runner); view.showWidget(currentPanel); } @Inject  PropertiesContainerPresenter(PropertiesContainerView view,
                                        WidgetFactory widgetFactory,
                                        SelectionManager selectionManager,
                                        AppContext appContext); @Override void show(@Nullable Runner runner); @Override void show(@Nullable Environment environment); @Override void reset(); @NotNull @Override IsWidget getView(); @Override void setVisible(boolean visible); @Override void go(AcceptsOneWidget container); @Override void onSelectionChanged(@NotNull Selection selection); @Override void onPanelRemoved(@NotNull Environment environment); @Override void setVisibleNoRunnerLabel(boolean visible);  }
@Test public void panelForRunnerShouldBeCreatedAndShownWhenCurrentPanelIsNull() { when(widgetFactory.createPropertiesPanel(runner)).thenReturn(currentPanel); presenter.show(runner); verify(widgetFactory).createPropertiesPanel(runner); verify(currentPanel).update(runner); verify(view).showWidget(currentPanel); verify(currentPanel).hideButtonsPanel(); }
@Test public void ifPanelForRunnerIsAlreadyCreatedWeShouldNotCreateNewPanel() { when(widgetFactory.createPropertiesPanel(runner)).thenReturn(currentPanel); presenter.show(runner); presenter.show(runner); verify(widgetFactory).createPropertiesPanel(runner); verify(currentPanel, times(2)).update(runner); verify(view, times(2)).showWidget(currentPanel); }
@Test public void panelForEnvironmentShouldBeCreatedAndShownWhenCurrentPanelIsNull() { when(widgetFactory.createPropertiesPanel(environment)).thenReturn(currentPanel); presenter.show(environment); verify(widgetFactory).createPropertiesPanel(environment); verify(currentPanel).addListener(presenter); verify(currentPanel).update(environment); verify(view).showWidget(currentPanel); }
@Test public void panelForEnvironmentShouldBeCreatedAndShownWhenCurrentProjectIsNull() { when(appContext.getCurrentProject()).thenReturn(null); presenter.show(environment); verify(appContext).getCurrentProject(); verify(view).showWidget(stabPanel); }
@Test public void widgetCreatedByEnvironmentShouldBeShownWhenCurrentPanelIsNotNull() { when(widgetFactory.createPropertiesPanel(environment)).thenReturn(currentPanel); presenter.show(environment); presenter.show(environment); verify(widgetFactory).createPropertiesPanel(environment); verify(currentPanel, times(2)).update(environment); verify(view, times(2)).showWidget(currentPanel); }