private void setRequestTest() throws RestServiceException {
    ResponseStatus status = ResponseStatus.Accepted;
    restResponseChannel =
        new NettyResponseChannel(ctx, new NettyMetrics(new MetricRegistry()), PERFORMANCE_CONFIG, this.nettyConfig);
    try {
      try {
        restResponseChannel.setRequest(null);
        status = ResponseStatus.InternalServerError;
        fail("Tried to set null request yet no exception was thrown");
      } catch (IllegalArgumentException e) {
        // expected. Nothing to do.
      }

      restResponseChannel.setRequest(request);
      try {
        restResponseChannel.setRequest(request);
        status = ResponseStatus.InternalServerError;
        fail("Tried to reset request and no exception was thrown");
      } catch (IllegalStateException e) {
        // expected. Nothing to do.
      }
    } finally {
      restResponseChannel.setStatus(status);
      restResponseChannel.onResponseComplete(null);
      assertFalse("Request channel is not closed", request.isOpen());
    }
  }
Tries different exception scenarios for {@link NettyResponseChannel#setRequest(NettyRequest)}.
@throws RestServiceException
ambry-rest/src/test/java/com/github/ambry/rest/NettyResponseChannelTest.java