ReportingFactory implements InputStreamFactory { @Override public InputStream openStream() throws IOException { InputStream wrappedStream = factory.openStream(); report.expectedSize(factory.getExpectedSize()); return new ReportingInputStream(wrappedStream, report); } ReportingFactory(InputStreamFactory factory, ProgressReport report); @Override InputStream openStream(); @Override long getExpectedSize();  }
@Test public void reportsTotalSizeWhenOpeningTheStream() throws Exception { reportingFactory.openStream(); verify(report).expectedSize(20); }