LiveSearchDropDown implements IsWidget { public void search(String pattern) { if (lastSearch == null || !lastSearch.equals(pattern)) { lastSearch = pattern != null ? pattern : ""; if (searchCacheEnabled && searchCache.containsKey(lastSearch)) { showResults(getFromSearchCache(lastSearch)); } else { doSearch(pattern); } } } @Inject  LiveSearchDropDown(View view,
                              ManagedInstance<LiveSearchSelectorItem<TYPE>> liveSearchSelectorItems); @Override Widget asWidget(); boolean isSearchEnabled(); void setSearchEnabled(boolean searchEnabled); void setClearSelectionEnabled(boolean clearSelectionEnabled); void setSelectorHint(String text); void setSearchHint(String text); void setNotFoundMessage(String noItemsMessage); void init(LiveSearchService<TYPE> searchService,
                     LiveSearchSelectionHandler<TYPE> selectionHandler); boolean isSearchCacheEnabled(); void setSearchCacheEnabled(boolean searchCacheEnabled); int getMaxItems(); void setMaxItems(int maxItems); void setWidth(int minWidth); void clear(); String getLastSearch(); void search(String pattern); void setSelectedItem(final TYPE key); void showResults(LiveSearchResults<TYPE> results); LiveSearchSelectorItem<TYPE> getSelectorItemForEntry(LiveSearchEntry<TYPE> entry); void setOnChange(Command onChange); void setEnabled(boolean enabled); void clearSelection(); void showNewItem(); @PreDestroy void destroy();  }
@Test public void testSearch() { presenter.search("a"); assertEquals(presenter.getLastSearch(), "a"); verify(view).clearItems(); verify(view).addItem(any()); verify(view).searchFinished(); verify(searchService).search(eq("a"), anyInt(), any()); }
@Test public void testRepeatedSearch() { presenter.search("a"); presenter.search("a"); verify(view).clearItems(); verify(view).addItem(any()); verify(view).searchFinished(); verify(searchService).search(eq("a"), anyInt(), any()); }