### Question:
SortedList extends TransformedList<E,E> { @Override public boolean contains(Object object) { return indexOf(object) != -1; } 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 testContains() { BasicEventList<Comparable> source = new BasicEventList<>(); SortedList<Comparable> sorted = SortedList.create(source); Integer ten = new Integer(10); boolean emptyTest = sorted.contains(ten); assertEquals(false, emptyTest); Integer one = new Integer(1); for(int i = 0; i < 12; i++) { source.add(one); } Integer five = new Integer(5); for(int i = 0; i < 13; i++) { source.add(five); } Integer nine = new Integer(9); for(int i = 0; i < 10; i++) { source.add(nine); } boolean firstTest = sorted.contains(one); assertEquals(true, firstTest); boolean secondTest = sorted.contains(five); assertEquals(true, secondTest); boolean thirdTest = sorted.contains(nine); assertEquals(true, thirdTest); boolean fourthTest = sorted.contains(ten); assertEquals(false, fourthTest); }
@Test public void testContainsWithWeakComparator() { BasicEventList<Comparable> source = new BasicEventList<>(); SortedList<Comparable> sorted = new SortedList<>(source, GlazedLists.comparableComparator()); final Song enterSandman = new Song("Metallica", "Enter Sandman"); final Song masterOfPuppets = new Song("Metallica", "Master of Puppets"); final Song battery = new Song("Metallica", "Battery"); sorted.add(enterSandman); sorted.add(masterOfPuppets); sorted.add(battery); assertTrue(sorted.contains(enterSandman)); assertTrue(sorted.contains(masterOfPuppets)); assertTrue(sorted.contains(battery)); assertFalse(sorted.contains(new Song("Metallica", "One"))); assertFalse(sorted.contains(null)); sorted.add(null); assertTrue(sorted.contains(null)); }