@Override
  public Future<Long> write(ByteBuffer src, Callback<Long> callback) {
    if (src == null) {
      throw new IllegalArgumentException("Source buffer cannot be null");
    }
    FutureResult<Long> futureResult = new FutureResult<Long>();
    long bytesWritten = 0;
    Exception exception = null;
    if (!isOpen()) {
      exception = new ClosedChannelException();
    } else {
      responseMetadataFinalized.set(true);
      bytesWritten = src.remaining();
      for (int i = 0; i < bytesWritten; i++) {
        bodyBytes.write(src.get());
      }
    }
    futureResult.done(bytesWritten, exception);
    if (callback != null) {
      callback.onCompletion(bytesWritten, exception);
    }
    onEventComplete(Event.Write);
    return futureResult;
  }
Called when an event (function call) finishes successfully in MockRestResponseChannel. Does *not* trigger if the
event (function) fails.
@param mockRestResponseChannel the {@link MockRestResponseChannel} where the event occurred.
@param event the {@link Event} that occurred.
ambry-test-utils/src/main/java/com/github/ambry/rest/MockRestResponseChannel.java