OrderedSet implements Set<E> { public Iterator<E> iterator() { return set.iterator(); } OrderedSet();  OrderedSet(Collection<E> set);  OrderedSet(int initialCapacity); Object[] toArray(); boolean removeAll(Collection<?> c); T[] toArray(T[] a); Iterator<E> iterator(); int size(); boolean isEmpty(); boolean contains(Object o); boolean add(E o); boolean remove(Object o); void clear(); @Override Object clone(); boolean containsAll(Collection<?> c); boolean addAll(Collection<? extends E> c); boolean retainAll(Collection<?> c); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test public void shouldNextGivenIteratorHasNoElements() { OrderedSet<Long> set = new OrderedSet<Long>(); Iterator<Long> iterator = set.iterator(); assert iterator.hasNext() == false; try { iterator.next(); fail(); } catch (NoSuchElementException e) { assertNull(e.getMessage()); } }