CollectionSizedIterator implements SizedIterator<OBJECTT> { @Override public OBJECTT next() { final OBJECTT n = this.iterator.next(); ++this.index; return n; } CollectionSizedIterator(Collection<OBJECTT> collection); @Pure @Override boolean hasNext(); @Override OBJECTT next(); @Override void remove(); @Pure @Override int index(); @Pure @Override int totalSize(); @Pure @Override int rest();  }
@Test public void next() { assertSame(this.s1, this.iterator.next()); assertSame(this.s2, this.iterator.next()); assertSame(this.s3, this.iterator.next()); assertSame(this.s4, this.iterator.next()); assertSame(this.s5, this.iterator.next()); try { this.iterator.next(); fail("expecting NoSuchElementException"); } catch(NoSuchElementException exception) { } }