### Question:
ListSelectorViewImpl implements ListSelectorView { @Override public void setItems(final List<ListSelectorItem> items) { DOMUtil.removeAllChildren(itemsContainer); items.forEach(item -> makeListSelectorItemView(item).ifPresent(child -> itemsContainer.appendChild(child.getElement()))); } ListSelectorViewImpl(); @Inject  ListSelectorViewImpl(final UnorderedList itemsContainer,
                                final ManagedInstance<ListSelectorTextItemView> listSelectorTextItemViews,
                                final ManagedInstance<ListSelectorDividerItemView> listSelectorDividerItemViews,
                                final ManagedInstance<ListSelectorHeaderItemView> listSelectorHeaderItemViews); @Override void init(final Presenter presenter); @Override void setItems(final List<ListSelectorItem> items); @Override void show(final Optional<String> title); @Override void hide(); @Override void setOnClosedByKeyboardCallback(final Consumer<CanBeClosedByKeyboard> callback);  }### Answer:
@Test public void testSetItems() { final boolean textItemEnabled = true; final String textItemText = "Insert rule above"; doReturn(textItemEnabled).when(textItem).isEnabled(); doReturn(textItemText).when(textItem).getText(); final String headerItemText = "Header"; doReturn(headerItemText).when(headerItem).getText(); view.setItems(Arrays.asList(textItem, dividerItem, headerItem)); verify(itemsContainer).appendChild(textElement); verify(itemsContainer).appendChild(dividerElement); verify(itemsContainer).appendChild(headerElement); verify(textItemView).setEnabled(eq(textItemEnabled)); verify(textItemView).setText(eq(textItemText)); verify(headerItemView).setText(eq(headerItemText)); final ArgumentCaptor<Command> commandCaptor = ArgumentCaptor.forClass(Command.class); verify(textItemView).addClickHandler(commandCaptor.capture()); commandCaptor.getValue().execute(); verify(presenter).onItemSelected(eq(textItem)); reset(presenter); doReturn(false).when(textItem).isEnabled(); commandCaptor.getValue().execute(); verify(presenter, never()).onItemSelected(any(HasListSelectorControl.ListSelectorTextItem.class)); }
@Test public void testSetItemsUnknownImplementation() { view.setItems(singletonList(mock(HasListSelectorControl.ListSelectorItem.class))); verify(itemsContainer, never()).appendChild(any()); }