SortedUserList implements UserList { @Nullable @Override public User get(final int pos) { if (pos < userList.size()) { return userList.get(pos); } else { return null; } } SortedUserList(); @Override boolean add(final User user); @Nullable @Override User get(final int pos); @Override int indexOf(final User user); @Override boolean remove(final User user); @Override User set(final int pos, final User user); @Override int size(); @Override void addUserListListener(final UserListListener listener); @Override void removeUserListListener(final UserListListener listener); List<UserListListener> getListeners();  }
@Test public void addShouldSortUsersByName() { addAllUsers(); assertEquals("Annie", userList.get(0).getNick()); assertEquals("John", userList.get(1).getNick()); assertEquals("Lenny", userList.get(2).getNick()); assertEquals("Niles", userList.get(3).getNick()); }
@Test public void getShouldReturnNullIfNoElementFound() { assertNull(userList.get(0)); assertNull(userList.get(1)); }