TabContainerPresenter implements TabContainer, TabContainerView.ActionDelegate, PanelState.StateChangeListener { @Override public void addTab(@NotNull Tab tab) { String title = tab.getTitle(); if (tabs.containsKey(title)) { throw new IllegalStateException("Tab with title " + title + " has already added. Please, check your title name."); } view.addTab(tab); if (isFirst || locale.runnerTabTerminal().equals(title)) { view.showTab(tab); view.selectTab(tab); isFirst = false; } tabs.put(title, tab); tabVisibilities.put(title, true); } @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 shouldAddTwoTabs() { shouldAddFirstTab(); tabContainerPresenter.addTab(tab2); verify(tab2).getTitle(); verify(view).addTab(tab2); }
@Test(expected = IllegalStateException.class) public void shouldAddTabWhichIsAlreadyExist() { tabContainerPresenter.addTab(tab1); tabContainerPresenter.addTab(tab1); verify(tab1).getTitle(); verifyNoMoreInteractions(view); }