TabContainerViewImpl extends Composite implements TabContainerView { @Override public void setVisibleTitle(@NotNull Map<String, Boolean> tabVisibilities) { tabs.clear(); for (Map.Entry<String, Boolean> entry : tabVisibilities.entrySet()) { String title = entry.getKey(); TabWidget tabWidget = titles.get(title); if (tabWidget != null && entry.getValue()) { tabs.add(tabWidget); } } } @Inject  TabContainerViewImpl(RunnerResources resources, WidgetFactory widgetFactory); @Override void showTab(@NotNull Tab tab); @Override void selectTab(@NotNull Tab tab); @Override void setVisibleTitle(@NotNull Map<String, Boolean> tabVisibilities); @Override void addTab(@NotNull Tab tab); @Override void showTabTitle(@NotNull String tabName, boolean isShown); @Override void setDelegate(ActionDelegate actionDelegate);  }
@Test public void shouldVisibleOneTitle() { Map<String, Boolean> tabVisibilities = new HashMap<>(); tabVisibilities.put(TITLE1, true); tabVisibilities.put(TITLE2, false); addThreeTabs(); tabContainerView.setVisibleTitle(tabVisibilities); verify(tabContainerView.tabs).clear(); verify(tabContainerView.tabs).add(tabWidget1); }
@Test public void tabShouldNotBeShownWhenTabWidgetIsNull() { Map<String, Boolean> tabVisibilities = new HashMap<>(); tabVisibilities.put(TITLE1, true); tabVisibilities.put(TITLE2, false); tabContainerView.setVisibleTitle(tabVisibilities); verify(tabContainerView.tabs, never()).add(Matchers.<TabWidget>anyObject()); }
@Test public void shouldVisibleTwoTitle() { Map<String, Boolean> tabVisibilities = new HashMap<>(); tabVisibilities.put(TITLE1, true); tabVisibilities.put(TITLE2, true); addThreeTabs(); tabContainerView.setVisibleTitle(tabVisibilities); verify(tabContainerView.tabs).clear(); verify(tabContainerView.tabs).add(tabWidget1); verify(tabContainerView.tabs).add(tabWidget2); }
@Test public void shouldVisibleTitleWithWrongList() { Map<String, Boolean> tabVisibilities = new HashMap<>(); tabVisibilities.put(TITLE1, true); tabVisibilities.put("not existed title", true); tabVisibilities.put(TITLE2, true); addThreeTabs(); tabContainerView.setVisibleTitle(tabVisibilities); verify(tabContainerView.tabs).clear(); verify(tabContainerView.tabs).add(tabWidget1); }