StatsCollectingStreams { public static InputStream wrap(@NotNull final BlobStatsCollector collector, final String blobId, InputStream in) { return StatsCollectingStreams.wrap(collector, blobId, in, System.nanoTime()); }  static InputStream wrap(@NotNull final BlobStatsCollector collector, final String blobId, InputStream in); static InputStream wrap(@NotNull final BlobStatsCollector collector, final String blobId, InputStream in, long startTime);  }
@Test public void downloadCallback() throws Exception { NullInputStream in = new NullInputStream(1042); TestCollector stats = new TestCollector(); InputStream wrappedStream = StatsCollectingStreams.wrap(stats, "foo", in); assertEquals(0, stats.callbackCount); CountingOutputStream cos = new CountingOutputStream(new NullOutputStream()); IOUtils.copy(wrappedStream, cos); assertEquals(1042, cos.getCount()); assertEquals(0, stats.callbackCount); wrappedStream.close(); assertEquals(1042, stats.size); assertEquals(1, stats.downloadCompletedCount); }