private static void checkStream(List<byte[]> expectedContent, RetainingAsyncWritableChannel channel)
      throws Exception {
    assertEquals("Bytes written does not match expected content length",
        expectedContent.stream().mapToLong(buf -> buf.length).sum(), channel.getBytesWritten());
    try (InputStream inputStream = channel.consumeContentAsInputStream()) {
      for (byte[] buf : expectedContent) {
        byte[] readBuf = new byte[buf.length];
        int read = 0;
        while (read < buf.length) {
          read += inputStream.read(readBuf, read, buf.length - read);
        }
        assertArrayEquals("Read content should match expected", buf, readBuf);
      }
      assertEquals("Stream should be fully read", -1, inputStream.read());
    }
  }
Check that the content in the stream returned by {@link RetainingAsyncWritableChannel#consumeContentAsInputStream()}
matches expectations.
@param expectedContent the expected content.
@param channel the channel that contains the copied content.
ambry-commons/src/test/java/com/github/ambry/commons/RetainingAsyncWritableChannelTest.java