DynamicCollection extends AbstractCollection<E> { public DynamicIterator iterator() { return iterator(0); } DynamicCollection(); DynamicIterator iterator(); DynamicIterator iterator(int index); int size(); boolean isEmpty(); boolean contains(Object o); Object[] toArray(); T[] toArray(T[] a); boolean containsAll(Collection<?> c); boolean add(E e); boolean remove(Object o); E get(int index); @Override void clear(); E remove(int index); E first(); E last();  }
@Test public void testIterator() throws Exception { collection.add(OBJ_0); Iterator iterator = collection.iterator(); assertThat(iterator.hasNext(), equalTo(true)); assertThat(iterator.next(), sameInstance(OBJ_0)); assertThat(iterator.hasNext(), equalTo(false)); }