### Question:
EachIterator implements Iterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("procedure", procedure) .toString(); } EachIterator(Iterator<T> iterator, UnaryProcedure<? super T> procedure); @Override boolean hasNext(); @Override T next(); @Override void remove(); @Override String toString();  }### Answer:
@Test @SuppressWarnings("unchecked") public void shouldIncludeIteratorInToStringRepresentation() throws Exception { Iterator<String> input = (Iterator<String>) mock(Iterator.class); UnaryProcedure<String> action = new UnaryProcedure<String>() { @Override public void execute(String value) { System.out.println(value); } }; when(input.toString()).thenReturn("the-iterator"); EachIterator<String> iterator = new EachIterator<String>(input, action); String toString = iterator.toString(); assertThat(toString, containsString("the-iterator")); }
@Test public void shouldIncludeProcedureInToStringRepresentation() throws Exception { Iterator<String> input = iteratorWith("1", "2", "3"); UnaryProcedure<String> action = new UnaryProcedure<String>() { @Override public void execute(String value) { System.out.println(value); } @Override public String toString() { return "the-procedure"; } }; EachIterator<String> iterator = new EachIterator<String>(input, action); String toString = iterator.toString(); assertThat(toString, containsString("the-procedure")); }