LinkedSortedSet implements SortedSet<T> { public Iterator<T> iterator() { return orderedSet.iterator(); }  int size(); boolean isEmpty(); boolean contains(Object o); Iterator<T> iterator(); Object[] toArray(); E[] toArray(E[] a); boolean add(T e); boolean remove(Object o); boolean containsAll(Collection<?> c); boolean addAll(Collection<? extends T> c); boolean retainAll(Collection<?> c); boolean removeAll(Collection<?> c); void clear(); @Override int hashCode(); @Override boolean equals(Object obj); Comparator<? super T> comparator(); SortedSet<T> subSet(T fromElement, T toElement); SortedSet<T> headSet(T toElement); SortedSet<T> tailSet(T fromElement); T first(); T last();  }
@Test public void shouldNextGivenIteratorHasNoElements() { SortedSet<Long> set = new LinkedSortedSet<Long>(); Iterator<Long> iterator = set.iterator(); assert iterator.hasNext() == false; try { iterator.next(); fail(); } catch (NoSuchElementException e) { assertNull(e.getMessage()); } }