private void doHandleResponseSuccessTest(AsyncRequestResponseHandler asyncRequestResponseHandler) throws Exception {
    // both response and exception null
    MockRestRequest restRequest = createRestRequest(RestMethod.GET, "/", null, null);
    restRequest.getMetricsTracker().scalingMetricsTracker.markRequestReceived();
    MockRestResponseChannel restResponseChannel = new MockRestResponseChannel();
    awaitResponse(asyncRequestResponseHandler, restRequest, restResponseChannel, null, null);
    if (restResponseChannel.getException() != null) {
      throw restResponseChannel.getException();
    }

    // both response and exception not null
    restRequest = createRestRequest(RestMethod.GET, "/", null, null);
    restRequest.getMetricsTracker().scalingMetricsTracker.markRequestReceived();
    restResponseChannel = new MockRestResponseChannel();
    ByteBuffer responseBuffer = ByteBuffer.wrap(TestUtils.getRandomBytes(1024));
    ByteBufferRSC response = new ByteBufferRSC(responseBuffer);
    EventMonitor<ByteBufferRSC.Event> responseCloseMonitor =
        new EventMonitor<ByteBufferRSC.Event>(ByteBufferRSC.Event.Close);
    response.addListener(responseCloseMonitor);
    Exception e = new Exception();
    awaitResponse(asyncRequestResponseHandler, restRequest, restResponseChannel, response, e);
    // make sure exception was correctly sent to the RestResponseChannel.
    assertEquals("Exception was not piped correctly", e, restResponseChannel.getException());
    assertTrue("Response is not closed", responseCloseMonitor.awaitEvent(1, TimeUnit.SECONDS));

    // response null but exception not null.
    restRequest = createRestRequest(RestMethod.GET, "/", null, null);
    restRequest.getMetricsTracker().scalingMetricsTracker.markRequestReceived();
    restResponseChannel = new MockRestResponseChannel();
    e = new Exception();
    awaitResponse(asyncRequestResponseHandler, restRequest, restResponseChannel, null, e);
    // make sure exception was correctly sent to the RestResponseChannel.
    assertEquals("Exception was not piped correctly", e, restResponseChannel.getException());

    // response not null.
    // steady response - full response available.
    restRequest = createRestRequest(RestMethod.GET, "/", null, null);
    restRequest.getMetricsTracker().scalingMetricsTracker.markRequestReceived();
    restResponseChannel = new MockRestResponseChannel();
    responseBuffer = ByteBuffer.wrap(TestUtils.getRandomBytes(1024));
    response = new ByteBufferRSC(responseBuffer);
    responseCloseMonitor = new EventMonitor<ByteBufferRSC.Event>(ByteBufferRSC.Event.Close);
    response.addListener(responseCloseMonitor);
    awaitResponse(asyncRequestResponseHandler, restRequest, restResponseChannel, response, null);
    if (restResponseChannel.getException() == null) {
      assertArrayEquals("Response does not match", responseBuffer.array(), restResponseChannel.getResponseBody());
      assertTrue("Response is not closed", responseCloseMonitor.awaitEvent(1, TimeUnit.SECONDS));
    } else {
      throw restResponseChannel.getException();
    }
  }
Tests {@link AsyncRequestResponseHandler#handleResponse(RestRequest, RestResponseChannel, ReadableStreamChannel, Exception)} with good input.
@throws Exception
ambry-rest/src/test/java/com/github/ambry/rest/AsyncRequestResponseHandlerTest.java