StreamIterator implements CloseableIterator<T> { @Override public void close() { CloseableUtil.close(iterator); CloseableUtil.close(stream); } StreamIterator();  StreamIterator(final Stream<T> stream); @Override void close(); @Override boolean hasNext(); @Override T next(); @Override void remove(); Stream<T> getStream();  }
@Test public void shouldDelegateCloseToWrappedIterator() { final Stream<Object> stream = mock(Stream.class); final StreamIterator<Object> streamIterator = new StreamIterator<>(stream); streamIterator.close(); verify(stream).close(); }