LiveSearchDropDown implements IsWidget { public void init(LiveSearchService<TYPE> searchService, LiveSearchSelectionHandler<TYPE> selectionHandler) { this.searchService = searchService; this.selectionHandler = selectionHandler; selectionHandler.setLiveSearchSelectionCallback(this::onItemSelected); view.setClearSelectionMessage(selectionHandler.isMultipleSelection()); if (searchService instanceof EntryCreationLiveSearchService) { view.setNewInstanceEnabled(true); EntryCreationLiveSearchService<TYPE, ?> creationService = (EntryCreationLiveSearchService<TYPE, ?>) searchService; EntryCreationEditor<TYPE> editor = creationService.getEditor(); if (creationService.getEditor() instanceof InlineCreationEditor) { InlineCreationEditor<TYPE> inlineEditor = (InlineCreationEditor<TYPE>) editor; inlineEditor.init(this::addNewItem, view::restoreFooter); onAddItemPressed = () -> view.showNewItemEditor(inlineEditor); } else if (creationService.getEditor() instanceof ModalCreationEditor) { ModalCreationEditor<TYPE> modalEditor = (ModalCreationEditor<TYPE>) editor; modalEditor.init(this::addNewItem, () -> {}); onAddItemPressed = () -> modalEditor.show(); } } else { view.setNewInstanceEnabled(false); } } @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 testInit() { presenter.setWidth(200); presenter.setMaxItems(10); presenter.setSearchHint("a"); presenter.setSelectorHint("b"); assertEquals(presenter.getMaxItems(), 10); verify(view).setWidth(200); verify(view).setSearchHint("a"); verify(view).setDropDownText("b"); }