### Question:
ListSelection implements ListEventListener<E> { public EventList<E> getSelected() { synchronized (selectionListeners) { if(selectedList == null){ selectedList = new SelectedList<>(source); source.getPublisher().setRelatedListener(selectedList, this); } } return selectedList; } ListSelection(EventList<E> source);  ListSelection(EventList<E> source, int[] initialSelection); @Override void listChanged(ListEvent<E> listChanges); void addValidSelectionMatcher(Matcher<E> validSelectionMatcher); void removeValidSelectionMatcher(Matcher<E> validSelectionMatcher); EventList<E> getSelected(); EventList<E> getTogglingSelected(); EventList<E> getDeselected(); EventList<E> getTogglingDeselected(); EventList<E> getSource(); void invertSelection(); boolean isSelected(int sourceIndex); void deselect(int index); void deselect(int start, int end); void deselect(int[] indices); void deselectAll(); void select(int index); void select(int start, int end); void select(int[] indices); int select(E value); boolean select(Collection<E> values); void selectAll(); void setSelection(int index); void setSelection(int start, int end); void setSelection(int[] indices); int getAnchorSelectionIndex(); void setAnchorSelectionIndex(int anchorSelectionIndex); int getLeadSelectionIndex(); void setLeadSelectionIndex(int leadSelectionIndex); void setSelectionMode(int selectionMode); int getSelectionMode(); int getMinSelectionIndex(); int getMaxSelectionIndex(); void addSelectionListener(Listener selectionListener); void removeSelectionListener(Listener selectionListener); void dispose(); static final int SINGLE_SELECTION; static final int SINGLE_INTERVAL_SELECTION; static final int MULTIPLE_INTERVAL_SELECTION; static final int MULTIPLE_INTERVAL_SELECTION_DEFENSIVE; }### Answer:
@Test public void testContradictingUpdates() { TransactionList<String> source = new TransactionList<>(new BasicEventList<String>()); ListSelection<String> listSelection = new ListSelection<>(source); ListConsistencyListener.install(listSelection.getSelected()); source.beginEvent(false); source.add("C"); source.add("E"); source.commitEvent(); source.beginEvent(); source.add(0, "A"); source.add(1, "B"); source.set(2, "C"); source.set(3, "E"); source.add(3, "D"); source.set(4, "E"); source.add(5, "F"); source.commitEvent(); source.beginEvent(false); while(!source.isEmpty()) { source.remove(0); } source.add("A"); source.add("B"); source.commitEvent(); source.beginEvent(); source.set(0, "a"); source.set(1, "b"); source.add(2, "c"); source.set(0, "a"); source.set(1, "b"); source.set(2, "c"); source.add(3, "d"); source.add(1, "e"); source.set(2, "c"); source.set(3, "d"); source.commitEvent(); }