### Question:
BatchedIterator implements Iterator<Iterable<T>> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("batchSize", batchSize) .append("iterator", iterator.toString()) .toString(); } BatchedIterator(Iterator<? extends T> iterator, int batchSize); @Override boolean hasNext(); @Override Iterable<T> next(); @Override void remove(); @Override String toString();  }### Answer:
@Test @SuppressWarnings("unchecked") public void shouldIncludeIteratorToStringInToString() throws Exception { Iterator<Integer> input = (Iterator<Integer>) mock(Iterator.class); when(input.toString()).thenReturn("iterator toString"); Iterator<Iterable<Integer>> batchIterator = new BatchedIterator<Integer>(input, 3); String toString = batchIterator.toString(); assertThat(toString, containsString("iterator toString")); }
@Test public void shouldIncludeBatchSizeInToString() throws Exception { Iterator<Integer> input = iteratorWith(1, 2, 3, 4); Integer batchSize = 10; BatchedIterator<Integer> batchedIterator = new BatchedIterator<Integer>(input, batchSize); String toString = batchedIterator.toString(); assertThat(toString, containsString("10")); }