@Override
  public <T> ResponseFuture<T> sendRequest(Request<T> request, RequestContext requestContext)
  {
    FutureCallback<Response<T>> callback = new FutureCallback<>();
    sendRequest(request, requestContext, callback);
    return new ResponseFutureImpl<>(callback);
  }
@SuppressWarnings("deprecation")
  @Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "sendRequestOptions")
  public void testRestLiResponseExceptionCallback(SendRequestOption option,
                                                  TimeoutOption timeoutOption,
                                                  ProtocolVersionOption versionOption,
                                                  ProtocolVersion protocolVersion,
                                                  String errorResponseHeaderName,
                                                  ContentType contentType)
          throws ExecutionException, TimeoutException, InterruptedException, RestLiDecodingException
  {
    final String ERR_KEY = "someErr";
    final String ERR_VALUE = "WHOOPS!";
    final String ERR_MSG = "whoops2";
    final int HTTP_CODE = 400;
    final int APP_CODE = 666;
    final String CODE = "INVALID_INPUT";
    final String DOC_URL = "https://example.com/errors/invalid-input";
    final String REQUEST_ID = "abc123";

    RestClient client = mockClient(ERR_KEY, ERR_VALUE, ERR_MSG, HTTP_CODE, APP_CODE, CODE, DOC_URL, REQUEST_ID,
        protocolVersion, errorResponseHeaderName);
    Request<EmptyRecord> request = mockRequest(EmptyRecord.class, versionOption, contentType);
    RequestBuilder<Request<EmptyRecord>> requestBuilder = mockRequestBuilder(request);

    FutureCallback<Response<EmptyRecord>> callback = new FutureCallback<>();
    try
    {
      sendRequest(option, client, request, requestBuilder, callback);
      Long l = timeoutOption._l;
      TimeUnit timeUnit = timeoutOption._timeUnit;
      Response<EmptyRecord> response = l == null ? callback.get() : callback.get(l, timeUnit);
      Assert.fail("Should have thrown");
    }
    catch (ExecutionException e)
    {
      // New

      Throwable cause = e.getCause();
      Assert.assertTrue(cause instanceof RestLiResponseException, "Expected RestLiResponseException not " + cause.getClass().getName());
      RestLiResponseException rlre = (RestLiResponseException)cause;
      Assert.assertEquals(HTTP_CODE, rlre.getStatus());
      Assert.assertEquals(ERR_VALUE, rlre.getErrorDetails().get(ERR_KEY));
      Assert.assertEquals(APP_CODE, rlre.getServiceErrorCode());
      Assert.assertEquals(ERR_MSG, rlre.getServiceErrorMessage());
      Assert.assertEquals(CODE, rlre.getCode());
      Assert.assertEquals(DOC_URL, rlre.getDocUrl());
      Assert.assertEquals(REQUEST_ID, rlre.getRequestId());
      Assert.assertEquals(EmptyRecord.class.getCanonicalName(), rlre.getErrorDetailType());
      Assert.assertNotNull(rlre.getErrorDetailsRecord());
      Assert.assertTrue(rlre.getErrorDetailsRecord() instanceof EmptyRecord);

      // Old

      Assert.assertTrue(cause instanceof RestException, "Expected RestException not " + cause.getClass().getName());
      RestException re = (RestException)cause;
      RestResponse r = re.getResponse();

      ErrorResponse er = new EntityResponseDecoder<>(ErrorResponse.class).decodeResponse(r).getEntity();

      Assert.assertEquals(HTTP_CODE, r.getStatus());
      Assert.assertEquals(ERR_VALUE, er.getErrorDetails().data().getString(ERR_KEY));
      Assert.assertEquals(APP_CODE, er.getServiceErrorCode().intValue());
      Assert.assertEquals(ERR_MSG, er.getMessage());
    }
  }