TabContainerPresenter implements TabContainer, TabContainerView.ActionDelegate, PanelState.StateChangeListener { @Override public void onStateChanged() { State state = panelState.getState(); Tab firsVisibleTab = null; boolean isRightPropertiesPanel = RIGHT_PROPERTIES.equals(panelLocation); boolean isSplitterOff = SPLITTER_OFF.equals(panelState.getSplitterState()); for (Tab tab : tabs.values()) { boolean visible = tab.isAvailableScope(state); if (visible && firsVisibleTab == null && (!isRightPropertiesPanel || isSplitterOff)) { firsVisibleTab = tab; } tabVisibilities.put(tab.getTitle(), visible); } view.setVisibleTitle(tabVisibilities); if (firsVisibleTab == null) { return; } view.showTab(firsVisibleTab); view.selectTab(firsVisibleTab); } @Inject  TabContainerPresenter(TabContainerView view, PanelState panelState, RunnerLocalizationConstant locale); @Override void go(AcceptsOneWidget container); @Override void showTab(@NotNull String title); @Override void addTab(@NotNull Tab tab); @Override void showTabTitle(@NotNull String tabName, boolean isShown); @Override void setLocation(@NotNull PanelLocation panelLocation); @Override void onTabClicked(@NotNull String title); @Override void onStateChanged();  }
@Test public void shouldOnStateChangedWhenNoneTabIsVisible() { when(tab1.isAvailableScope(RUNNERS)).thenReturn(false); when(tab2.isAvailableScope(RUNNERS)).thenReturn(false); addTwoTabs(); tabContainerPresenter.onStateChanged(); verify(panelState).getState(); verify(tab1).isAvailableScope(RUNNERS); verify(tab2).isAvailableScope(RUNNERS); verify(tab1, times(2)).getTitle(); verify(tab2, times(2)).getTitle(); verify(view).setVisibleTitle(Matchers.<Map<String, Boolean>>anyObject()); verifyNoMoreInteractions(view); }