@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")); }
@Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("procedure", procedure) .toString(); }
EachIterator implements Iterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("procedure", procedure) .toString(); } }
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); }
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(); }
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();  }