public BoundedNettyByteBufReceive send(Send send) throws IOException {
    if (!shouldRespond) {
      return null;
    }
    // Error order:
    // 1. hardError
    // 2. if No_Error, use serverErrorsByType
    // 3. if No_Error, use serverErrors
    RequestOrResponseType type = ((RequestOrResponse) send).getRequestType();
    LinkedList<ServerErrorCode> errorsByType = serverErrorsByType.get(type);
    ServerErrorCode serverError =
        hardError != null ? hardError : errorsByType.size() > 0 ? errorsByType.poll() : ServerErrorCode.NoError;
    if (serverError == ServerErrorCode.NoError) {
      serverError = serverErrors.size() > 0 ? serverErrors.poll() : ServerErrorCode.NoError;
    }
    RequestOrResponse response;
    requestCounts.computeIfAbsent(type, k -> new LongAdder()).increment();
    switch (type) {
      case PutRequest:
        response = makePutResponse((PutRequest) send, serverError);
        break;
      case GetRequest:
        response = makeGetResponse((GetRequest) send, serverError);
        break;
      case DeleteRequest:
        response = makeDeleteResponse((DeleteRequest) send, serverError);
        break;
      case TtlUpdateRequest:
        response = makeTtlUpdateResponse((TtlUpdateRequest) send, serverError);
        break;
      case UndeleteRequest:
        response = makeUndeleteResponse((UndeleteRequest) send, serverError);
        break;
      case ReplicateBlobRequest:
        response = makeReplicateBlobResponse((ReplicateBlobRequest) send, serverError);
        break;
      default:
        throw new IOException("Unknown request type received");
    }
    ByteBufferChannel channel = new ByteBufferChannel(ByteBuffer.allocate((int) response.sizeInBytes()));
    response.writeTo(channel);
    response.release();
    ByteBuffer payload = channel.getBuffer();
    payload.flip();
    BoundedNettyByteBufReceive receive = new BoundedNettyByteBufReceive(100 * 1024 * 1024);
    receive.readFrom(Channels.newChannel(new ByteBufferInputStream(payload)));
    return receive;
  }
Take in a request in the form of {@link Send} and return a response in the form of a
{@link BoundedNettyByteBufReceive}.
@param send the request.
@return the response.
@throws IOException if there was an error in interpreting the request.
ambry-router/src/test/java/com/github/ambry/router/MockServer.java