FilterPagedTable extends Composite { public void removeTab(String gridKey) { int index = getGridIndex(gridKey); if (index != -1) { dataGridFilterHashMap.remove(gridKey); removeTab(index); multiGridPreferencesStore.removeTab(gridKey); multiGridPreferencesStore.setSelectedGrid(""); if (navTabs.getWidgetCount() > 1) { selectTab(index == 0 ? 0 : index - 1); } preferencesService.call().saveUserPreferences(multiGridPreferencesStore); } } FilterPagedTable();  FilterPagedTable(MultiGridPreferencesStore gridsPreferences); void removeTab(String gridKey); String getValidKeyForAdditionalListGrid(String baseName); void createNewTab(PagedTable<T> pagedTable,
                             final String key,
                             Button button,
                             Command filterCommand); void addTab(final PagedTable<T> grid,
                       final String key,
                       final Command filterCommand); void addTab(final PagedTable<T> grid,
                       final String key,
                       final Command filterCommand,
                       final boolean selectTab); void addAddTableButton(Button addTableButton); Widget makeWidget(); MultiGridPreferencesStore getMultiGridPreferencesStore(); void setMultiGridPreferencesStore(MultiGridPreferencesStore multiGridPreferencesStore); void setPreferencesService(Caller<UserPreferencesService> preferencesService); void setSelectedTab(); void saveTabSettings(String key,
                                HashMap<String, Object> params); void saveNewTabSettings(String key,
                                   HashMap<String, Object> params); void saveNewRefreshInterval(int newValue); int getRefreshInterval(); void setRefreshGridCommand(Command refreshGridCommand); void removeTab(int index); public Command refreshGridCommand; }
@Test public void testRemoveTab() throws Exception { final Element element = mock(Element.class); when(element.getStyle()).thenReturn(mock(Style.class)); when(button.getElement()).thenReturn(element); when(button.addClickHandler(any(ClickHandler.class))).thenAnswer(new Answer() { public Object answer(InvocationOnMock aInvocation) throws Throwable { clickHandler = (ClickHandler) aInvocation.getArguments()[0]; return null; } }); final YesNoCancelPopup yesNoCancelPopup = mock(YesNoCancelPopup.class); doReturn(yesNoCancelPopup).when(filterPagedTable).getYesNoCancelPopup(anyString(), anyString()); filterPagedTable.addTab(mock(PagedTable.class), "", mock(Command.class)); clickHandler.onClick(new ClickEvent() { }); verify(yesNoCancelPopup).show(); verify(filterPagedTable, never()).removeTab(anyInt()); verify(filterPagedTable, never()).removeTab(anyString()); }