### Question:
MappedIterator implements Iterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("mappingFunction", function) .toString(); } MappedIterator(Iterator<? extends S> iterator, UnaryFunction<? super S, ? extends T> mapper); boolean hasNext(); T next(); void remove(); @Override String toString();  }### Answer:
@Test @SuppressWarnings("unchecked") public void shouldIncludeIteratorInToStringRepresentation() throws Exception { Iterator<Integer> input = (Iterator<Integer>) mock(Iterator.class); UnaryFunction<Integer, Integer> mapper = UnaryFunctions.identity(); when(input.toString()).thenReturn("the-iterator"); MappedIterator<Integer, Integer> iterator = new MappedIterator<Integer, Integer>(input, mapper); String toString = iterator.toString(); assertThat(toString, containsString("the-iterator")); }
@Test @SuppressWarnings("unchecked") public void shouldIncludeMappingFunctionInToStringRepresentation() throws Exception { Iterator<Integer> input = iteratorWith(1, 2 ,3); UnaryFunction<Integer, Integer> mapper = (UnaryFunction<Integer, Integer>) mock(UnaryFunction.class); when(mapper.toString()).thenReturn("the-mapping-function"); MappedIterator<Integer, Integer> iterator = new MappedIterator<Integer, Integer>(input, mapper); String toString = iterator.toString(); assertThat(toString, containsString("the-mapping-function")); }