StreamIterable implements CloseableIterable<T> { @Override public void close() { CloseableUtil.close(streamSupplier); } StreamIterable(final StreamSupplier<T> streamSupplier); @Override void close(); @Override CloseableIterator<T> iterator(); @JsonIgnore Stream<T> getStream();  }
@Test public void shouldDelegateCloseToStreamIterable() throws IOException { final StreamSupplier<Object> streamSupplier = mock(StreamSupplier.class); final Stream<Object> stream = mock(Stream.class); given(streamSupplier.get()).willReturn(stream); final StreamIterable<Object> streamIterable = new StreamIterable<>(streamSupplier); streamIterable.close(); verify(streamSupplier).close(); }