### Question:
SubSequenceIterator extends CachingIterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("start", start) .append("stop", stop) .append("step", step) .append("cursor", cursor) .toString(); } SubSequenceIterator(Iterator<? extends T> iterator, Integer start, Integer stop, Integer step);  SubSequenceIterator(Iterator<? extends T> iterator, Integer start, Integer stop); @Override String toString();  }### Answer:
@Test @SuppressWarnings("unchecked") public void shouldIncludeIteratorInToStringRepresentation() throws Exception { Iterator<Integer> input = (Iterator<Integer>) mock(Iterator.class); Integer start = 2, stop = 7, step = 2; when(input.toString()).thenReturn("the-iterator"); SubSequenceIterator<Integer> iterator = new SubSequenceIterator<Integer>(input, start, stop, step); String toString = iterator.toString(); assertThat(toString, containsString("the-iterator")); }
@Test public void shouldIncludeStartStopAndStepInToStringRepresentation() throws Exception { Iterator<Integer> input = iteratorWith(1, 2, 3); Integer start = 2, stop = 7, step = 2; SubSequenceIterator<Integer> iterator = new SubSequenceIterator<Integer>(input, start, stop, step); String toString = iterator.toString(); assertThat(toString, containsString("start=2")); assertThat(toString, containsString("stop=7")); assertThat(toString, containsString("step=2")); }
@Test public void shouldIncludeCursorInToStringRepresentation() throws Exception { Iterator<Integer> input = iteratorWith(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); Integer start = 2, stop = 7, step = 2; SubSequenceIterator<Integer> iterator = new SubSequenceIterator<Integer>(input, start, stop, step); Integer val = iterator.next(); String toString = iterator.toString(); assertThat(toString, containsString("cursor=3")); }