### Question:
SortedList extends TransformedList<E,E> { public static <E extends Comparable<? super E>> SortedList<E> create(EventList<E> source) { return new SortedList<>(source); } SortedList(EventList<E> source);  SortedList(EventList<E> source, Comparator<? super E> comparator); static SortedList<E> create(EventList<E> source); void setMode(int mode); int getMode(); @Override void listChanged(ListEvent<E> listChanges); Comparator<? super E> getComparator(); void setComparator(Comparator<? super E> comparator); @Override int indexOf(Object object); @Override int lastIndexOf(Object object); int sortIndex(Object object); int lastSortIndex(Object object); @Deprecated int indexOfSimulated(Object object); @Override boolean contains(Object object); @Override Iterator<E> iterator(); static final int STRICT_SORT_ORDER; static final int AVOID_MOVING_ELEMENTS; }### Answer:
@Test public void testSimpleMoves() { unsortedList = new BasicEventList<>(); sortedList = SortedList.create(unsortedList); ListConsistencyListener.install(sortedList); unsortedList.addAll(GlazedListsTests.stringToList("ABCDEFG")); assertEquals(GlazedListsTests.stringToList("ABCDEFG"), unsortedList); assertEquals(GlazedListsTests.stringToList("ABCDEFG"), sortedList); unsortedList.set(3, "H"); assertEquals(GlazedListsTests.stringToList("ABCHEFG"), unsortedList); assertEquals(GlazedListsTests.stringToList("ABCEFGH"), sortedList); }
@Test public void testComplexEvents() { unsortedList = new BasicEventList<>(); TransactionList<Comparable> nestableList = new TransactionList<>(unsortedList); sortedList = SortedList.create(nestableList); ListConsistencyListener.install(sortedList); nestableList.beginEvent(); nestableList.addAll(GlazedListsTests.stringToList("ABCDEFG")); nestableList.commitEvent(); assertEquals(GlazedListsTests.stringToList("ABCDEFG"), nestableList); assertEquals(GlazedListsTests.stringToList("ABCDEFG"), sortedList); nestableList.beginEvent(false); nestableList.set(3, "H"); nestableList.add(0, "A"); nestableList.commitEvent(); assertEquals(GlazedListsTests.stringToList("AABCHEFG"), nestableList); assertEquals(GlazedListsTests.stringToList("AABCEFGH"), sortedList); nestableList.beginEvent(false); nestableList.add(0, "I"); nestableList.add(1, "A"); nestableList.set(5, "J"); nestableList.set(9, "K"); nestableList.commitEvent(); assertEquals(GlazedListsTests.stringToList("IAAABJHEFK"), nestableList); assertEquals(GlazedListsTests.stringToList("AAABEFHIJK"), sortedList); }
@Test public void testSortBeforeAndAfter() { for(int i = 0; i < 4000; i++) { unsortedList.add(new Integer(random.nextInt())); } final List<Comparable> controlList = new ArrayList<>(); controlList.addAll(unsortedList); Collections.sort(controlList); assertEquals(controlList, sortedList); sortedList = SortedList.create(unsortedList); assertEquals(controlList, sortedList); }