### Question:
GroupingList extends TransformedList<E, List<E>> { @Override public List<E> set(int index, List<E> value) { if(index < 0 || index >= size()) throw new IndexOutOfBoundsException("Cannot set at " + index + " on list of size " + size()); updates.beginEvent(true); final List<E> result = remove(index); add(index, value); updates.commitEvent(); return result; } GroupingList(EventList<E> source);  GroupingList(EventList<E> source, Comparator<? super E> comparator); private  GroupingList(SortedList<E> source, Comparator<? super E> comparator, Void dummyParameter); static GroupingList<E> create(EventList<E> source); int indexOfGroup(E groupElement); void setComparator(Comparator<? super E> comparator); @Override void listChanged(ListEvent<E> listChanges); @Override List<E> get(int index); @Override List<E> remove(int index); @Override List<E> set(int index, List<E> value); @Override void add(int index, List<E> value); @Override int size(); @Override void dispose();  }### Answer:
@Test public void testSet() { EventList<String> sourceList = new BasicEventList<>(); GroupingList<String> groupList = GroupingList.create(sourceList); ListConsistencyListener<List<String>> groupListConsistencyListener = ListConsistencyListener.install(groupList); groupListConsistencyListener.setPreviousElementTracked(false); ListConsistencyListener.install(sourceList); assertEquals(0, groupList.size()); sourceList.addAll(GlazedListsTests.stringToList("ABCDD")); groupList.set(3, GlazedListsTests.stringToList("BB")); assertEquals(GlazedListsTests.stringToLists("A,BBB,C"), groupList); groupList.set(2, GlazedListsTests.stringToList("AD")); assertEquals(GlazedListsTests.stringToLists("AA,BBB,D"), groupList); groupList.set(0, GlazedListsTests.stringToList("CC")); assertEquals(GlazedListsTests.stringToLists("BBB,CC,D"), groupList); groupList.set(2, GlazedListsTests.stringToList("")); assertEquals(GlazedListsTests.stringToLists("BBB,CC"), groupList); }