DiskQueue extends AbstractQueue<Payload> { @Override public Iterator<Payload> iterator() { return new PayloadIterator(getFiles().iterator()); } private  DiskQueue(Builder builder); @Override Iterator<Payload> iterator(); @Override int size(); @Override boolean offer(Payload payload); @Override Payload poll(); @Override Payload peek();  }
@Test public void shouldReturnIteratorOfPayloads() { Payload payload1 = new Payload.Builder().build(); Payload payload2 = new Payload.Builder().build(); sut.add(payload1); sut.add(payload2); Iterator<Payload> it = sut.iterator(); assertThat(it.hasNext(), is(true)); assertThat(it.next(), anyOf(equalTo(payload1), equalTo(payload2))); assertThat(it.hasNext(), is(true)); assertThat(it.next(), anyOf(equalTo(payload1), equalTo(payload2))); }