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