@Override public void registerItem(LiveSearchSelectorItem<TYPE> item) { item.setSelectionCallback(() -> selectItem(item)); item.setMultipleSelection(true); LiveSearchSelectorItem<TYPE> selectedItem = selectedItems.stream() .filter(filterItem -> filterItem.getKey().equals(item.getKey())) .findFirst() .orElse(null); if(selectedItem != null && selectedItem.getKey().equals(item.getKey())) { selectedItems.remove(selectedItem); visibleItems.remove(selectedItem); item.select(); selectedItems.add(item); } visibleItems.add(item); }
@Override public void registerItem(LiveSearchSelectorItem<TYPE> item) { item.setSelectionCallback(() -> selectItem(item)); item.setMultipleSelection(true); LiveSearchSelectorItem<TYPE> selectedItem = selectedItems.stream() .filter(filterItem -> filterItem.getKey().equals(item.getKey())) .findFirst() .orElse(null); if(selectedItem != null && selectedItem.getKey().equals(item.getKey())) { selectedItems.remove(selectedItem); visibleItems.remove(selectedItem); item.select(); selectedItems.add(item); } visibleItems.add(item); }
protected LiveSearchSelectorItem doTestSelectItem() { LiveSearchSelectorItem item = createItem(SELECTED_ITEM_TEXT); handler.registerItem(item); handler.selectItem(item); verify(item).select(); checkHandlerSelectedValue(SELECTED_ITEM_TEXT); assertEquals(SELECTED_ITEM_TEXT, handler.getDropDownMenuHeader()); verify(callback).execute(); return item; }
verify(handler, times(1)).selectItem(firstItem); verify(firstItem).select(); verify(callback).execute(); verify(handler, times(1)).selectItem(secondItem); verify(secondItem).select(); verify(callback, times(2)).execute(); verify(handler, times(1)).selectItem(thirdItem); verify(thirdItem).select(); verify(callback, times(3)).execute(); verify(handler, times(1)).selectItem(fourthItem); verify(fourthItem).select(); verify(callback, times(4)).execute(); verify(handler, times(2)).selectItem(firstItem); verify(firstItem).reset(); verify(callback, times(5)).execute(); verify(handler, times(2)).selectItem(secondItem); verify(secondItem).reset(); verify(callback, times(6)).execute(); verify(handler, times(2)).selectItem(thirdItem); verify(thirdItem).reset(); verify(callback, times(7)).execute(); verify(handler, times(2)).selectItem(fourthItem);