### Question:
CircularList extends AbstractList<T> { @Override public java.util.Iterator<T> iterator() { if (isEmpty()) { return new EmptyIterator(); } else { return new MainIterator(); } } CircularList(int capacity); int getCapacity(); T get(int index); int size(); @Override boolean isEmpty(); @Override boolean add(T newElement); @Override boolean addAll(Collection<? extends T> newElements); T removeFirst(); T first(); T last(); @Override void clear(); @Override java.util.Iterator<T> iterator(); @Override Object[] toArray(); @Override T[] toArray(T[] elementsCopy);  }### Answer:
@Test public void testIterator() { CircularList<String> list = new CircularList<>(5); assertEquals("", toString(list)); list.addAll(Arrays.asList("A")); assertEquals("A", toString(list)); list.addAll(Arrays.asList("B", "C")); assertEquals("A,B,C", toString(list)); list.addAll(Arrays.asList("D", "E")); assertEquals("A,B,C,D,E", toString(list)); list.addAll(Arrays.asList("F", "G", "H")); assertEquals("D,E,F,G,H", toString(list)); list.addAll(Arrays.asList("I", "J")); assertEquals("F,G,H,I,J", toString(list)); }