SortedUniqueList extends ArrayList<T> { @Override public void add( int index, T element ) { return; } SortedUniqueList(); @Override void add( int index, T element ); @Override boolean addAll( int index, Collection<? extends T> c ); @Override boolean add( T element ); @Override boolean addAll( Collection<? extends T> c );  }
@Test public void add() { list.add( p1 ); assertTrue( "List should contain 1 Element", list.size() == 1 ); list.add( p2 ); assertTrue( "List should contain 2 Elements", list.size() == 2 ); list.add( p3 ); assertTrue( "List should contain 3 Elements", list.size() == 3 ); }
@Test public void unique() { list.add( p1 ); assertTrue( "List should contain 1 Element", list.size() == 1 ); list.add( p3 ); assertTrue( "List should contain 2 Elements", list.size() == 2 ); list.add( p4 ); assertTrue( "List not should contain double Elements", list.size() == 2 ); }
@Test public void sorted() { list.add( p1 ); list.add( p2 ); list.add( p3 ); for ( int i = 0; i < ( list.size() - 1 ); ++i ) { assertTrue( "Elements should be sorted", list.get( i ).getName().compareTo( list.get( i + 1 ).getName() ) < 0 ); } }