private void ensureCallbackOrder(ChannelWriter channelWriter, int expectedCallbackId) {
    WriteCallback writeCallback = channelWriter.writes.get(expectedCallbackId).writeCallback;
    assertTrue("Callback for the expected oldest chunk not invoked", writeCallback.callbackInvoked.get());
    for (int i = expectedCallbackId + 1; i < channelWriter.writes.size(); i++) {
      writeCallback = channelWriter.writes.get(i).writeCallback;
      assertFalse("Callback for a chunk younger than the expected is invoked", writeCallback.callbackInvoked.get());
    }
  }
Ensures that the callback with {@code expectedCallbackId} is invoked but callbacks for chunks younger than the
expected one (i.e. id > {@code expectedCallbackId}) have not been invoked.
@param channelWriter the {@link ChannelWriter} that wrote to the channel.
@param expectedCallbackId the id of the callback expected to be invoked.
ambry-commons/src/test/java/com/github/ambry/commons/ByteBufferAsyncWritableChannelTest.java