### Question:
RankedList { public RankedList( Comparator<T> comparator ) { this.comparator = comparator; this.set = new TreeSet<>(); this.list = null; } RankedList( Comparator<T> comparator ); void itemAdded( T item, Map config ); void itemRemoved( T item ); static final String SERVICE_RANKING; }### Answer:
@Test public void testRankedList() { String a = "a"; String b = "b"; String c = "c"; String d = "d"; String e = "e"; String f = "f"; rankedList.itemAdded( a, Collections.singletonMap( RankedList.SERVICE_RANKING, 10 ) ); rankedList.itemAdded( b, Collections.emptyMap() ); rankedList.itemAdded( c, Collections.singletonMap( RankedList.SERVICE_RANKING, "12" ) ); rankedList.itemAdded( d, Collections.singletonMap( RankedList.SERVICE_RANKING, new Object() { @Override public String toString() { return "11"; } } ) ); rankedList.itemAdded( null, Collections.emptyMap() ); rankedList.itemAdded( e, Collections.singletonMap( RankedList.SERVICE_RANKING, 10 ) ); rankedList.itemAdded( f, null ); assertEquals( new ArrayList<>( Arrays.asList( c, d, a, e, b, f ) ), rankedList.getList() ); rankedList.itemRemoved( null ); assertEquals( new ArrayList<>( Arrays.asList( c, d, a, e, b, f ) ), rankedList.getList() ); rankedList.itemRemoved( a ); assertEquals( new ArrayList<>( Arrays.asList( c, d, e, b, f ) ), rankedList.getList() ); }