X9InputStreamReturnReader implements Iterable<X937ReturnGraph>, Closeable { public Stream<X937ReturnGraph> stream() { return StreamSupport.stream(this.spliterator(), false); } X9InputStreamReturnReader(InputStream inputStream);  X9InputStreamReturnReader(X9InputStreamRecordReader reader);  X9InputStreamReturnReader(InputStream inputStream, boolean skipInvalidRecords); X937ReturnGraph readNextReturn(); @Override void close(); Stream<X937ReturnGraph> stream(); @Override Iterator<X937ReturnGraph> iterator();  }
@Test public void shouldStreamReturnWithReader() throws Exception { try (X9InputStreamRecordReader reader1 = X9InputStreamRecordReaderTest.buildReaderFromFile()) { RecordCountRecordFilter filter = new RecordCountRecordFilter(); reader1.addFilter(filter); X9InputStreamCheckDetailReader reader = new X9InputStreamCheckDetailReader(reader1); final int[] recordsFound = {0}; reader.stream().forEach(graph -> { X937CheckDetailRecord detailRecord = graph.checkDetailRecord(); recordsFound[0]++; }); assertEquals(recordsFound[0], filter.getRecordCounters()[25]); } }