@Test @SuppressWarnings("unchecked") public void shouldIncludeTheCurrentIteratorInTheToString() throws Exception { Iterator<Integer> firstIterator = (Iterator<Integer>) mock(Iterator.class); Iterator<Integer> secondIterator = iteratorWith(2); when(firstIterator.toString()).thenReturn("first iterator toString"); Iterator<Integer> chainedIterator = new ChainedIterator<Integer>(firstIterator, secondIterator); String toString = chainedIterator.toString(); assertThat(toString, containsString("first iterator toString")); }
@Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("currentIterator", currentIterator) .append("remainingIterators", iteratorsIterator) .toString(); }
ChainedIterator implements Iterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("currentIterator", currentIterator) .append("remainingIterators", iteratorsIterator) .toString(); } }
ChainedIterator implements Iterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("currentIterator", currentIterator) .append("remainingIterators", iteratorsIterator) .toString(); } ChainedIterator(Iterator<? extends Iterator<? extends T>> iteratorsIterator);  ChainedIterator(
            Iterator<? extends T> i1, Iterator<? extends T> i2);  ChainedIterator(
            Iterator<? extends T> i1, Iterator<? extends T> i2, Iterator<? extends T> i3);  ChainedIterator(
            Iterator<? extends T> i1, Iterator<? extends T> i2, Iterator<? extends T> i3, Iterator<? extends T> i4);  ChainedIterator(
            Iterator<? extends T> i1, Iterator<? extends T> i2, Iterator<? extends T> i3, Iterator<? extends T> i4,
            Iterator<? extends T> i5);  ChainedIterator(
            Iterator<? extends T> i1, Iterator<? extends T> i2, Iterator<? extends T> i3, Iterator<? extends T> i4,
            Iterator<? extends T> i5, Iterator<? extends T> i6);  ChainedIterator(
            Iterator<? extends T> i1, Iterator<? extends T> i2, Iterator<? extends T> i3, Iterator<? extends T> i4,
            Iterator<? extends T> i5, Iterator<? extends T> i6, Iterator<? extends T>... i7on); }
ChainedIterator implements Iterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("currentIterator", currentIterator) .append("remainingIterators", iteratorsIterator) .toString(); } ChainedIterator(Iterator<? extends Iterator<? extends T>> iteratorsIterator);  ChainedIterator(
            Iterator<? extends T> i1, Iterator<? extends T> i2);  ChainedIterator(
            Iterator<? extends T> i1, Iterator<? extends T> i2, Iterator<? extends T> i3);  ChainedIterator(
            Iterator<? extends T> i1, Iterator<? extends T> i2, Iterator<? extends T> i3, Iterator<? extends T> i4);  ChainedIterator(
            Iterator<? extends T> i1, Iterator<? extends T> i2, Iterator<? extends T> i3, Iterator<? extends T> i4,
            Iterator<? extends T> i5);  ChainedIterator(
            Iterator<? extends T> i1, Iterator<? extends T> i2, Iterator<? extends T> i3, Iterator<? extends T> i4,
            Iterator<? extends T> i5, Iterator<? extends T> i6);  ChainedIterator(
            Iterator<? extends T> i1, Iterator<? extends T> i2, Iterator<? extends T> i3, Iterator<? extends T> i4,
            Iterator<? extends T> i5, Iterator<? extends T> i6, Iterator<? extends T>... i7on); @Override boolean hasNext(); @Override T next(); @Override void remove(); @Override String toString(); }
ChainedIterator implements Iterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("currentIterator", currentIterator) .append("remainingIterators", iteratorsIterator) .toString(); } ChainedIterator(Iterator<? extends Iterator<? extends T>> iteratorsIterator);  ChainedIterator(
            Iterator<? extends T> i1, Iterator<? extends T> i2);  ChainedIterator(
            Iterator<? extends T> i1, Iterator<? extends T> i2, Iterator<? extends T> i3);  ChainedIterator(
            Iterator<? extends T> i1, Iterator<? extends T> i2, Iterator<? extends T> i3, Iterator<? extends T> i4);  ChainedIterator(
            Iterator<? extends T> i1, Iterator<? extends T> i2, Iterator<? extends T> i3, Iterator<? extends T> i4,
            Iterator<? extends T> i5);  ChainedIterator(
            Iterator<? extends T> i1, Iterator<? extends T> i2, Iterator<? extends T> i3, Iterator<? extends T> i4,
            Iterator<? extends T> i5, Iterator<? extends T> i6);  ChainedIterator(
            Iterator<? extends T> i1, Iterator<? extends T> i2, Iterator<? extends T> i3, Iterator<? extends T> i4,
            Iterator<? extends T> i5, Iterator<? extends T> i6, Iterator<? extends T>... i7on); @Override boolean hasNext(); @Override T next(); @Override void remove(); @Override String toString();  }