SingleLiveSearchSelectionHandler implements LiveSearchSelectionHandler<TYPE> { @Override public void registerItem(final LiveSearchSelectorItem<TYPE> item) { if(selectedItem != null && selectedItem.getKey().equals(item.getKey())) { visibleItems.remove(selectedItem); item.select(); selectedItem = item; } item.setSelectionCallback(() -> selectItem(item)); visibleItems.add(item); } SingleLiveSearchSelectionHandler(); @Override String getDropDownMenuHeader(); @Override void registerItem(final LiveSearchSelectorItem<TYPE> item); @Override void selectItem(LiveSearchSelectorItem<TYPE> item); @Override void selectKey(TYPE key); TYPE getSelectedKey(); String getSelectedValue(); @Override void setLiveSearchSelectionCallback(Command command); @Override void clearSelection(); @Override boolean isMultipleSelection();  }
@Test public void testRegisterItemWithoutSelectedValue() { LiveSearchSelectorItem item = createItem("any"); handler.registerItem(item); verify(item, never()).select(); verify(item, times(1)).setSelectionCallback(any()); checkHandlerSelectedValue(null); }
@Test public void testRegisterIItemWithSelectedValue() { LiveSearchSelectorItem selectedItem = doTestSelectItem(); LiveSearchSelectorItem secondItem = createItem(SELECTED_ITEM_TEXT); handler.registerItem(secondItem); verify(selectedItem, atLeast(1)).getKey(); verify(secondItem).getKey(); verify(secondItem).select(); }