use of com.linkedin.restli.internal.client.ResponseFutureImpl in project rest.li by linkedin.
the class MockFailedResponseFutureBuilder method buildWithErrorResponse.
private ResponseFuture<V> buildWithErrorResponse(ProtocolVersion protocolVersion) {
int status = (_errorResponse.hasStatus()) ? _errorResponse.getStatus() : DEFAULT_HTTP_STATUS;
// create a RestLiResponseException and wrap it in an ExecutionException that will be thrown by the ResponseFuture
RestLiResponseException restLiResponseException = new MockRestliResponseExceptionBuilder().setErrorResponse(_errorResponse).setStatus(HttpStatus.fromCode(status)).setCookies(getCookies() == null ? Collections.emptyList() : getCookies()).setHeaders(getHeaders() == null ? new HashMap<>() : getHeaders()).build();
ExecutionException executionException = new ExecutionException(restLiResponseException);
Future<Response<V>> responseFuture = buildFuture(null, executionException);
return new ResponseFutureImpl<>(responseFuture, _errorHandlingBehavior);
}
use of com.linkedin.restli.internal.client.ResponseFutureImpl in project rest.li by linkedin.
the class MockFailedResponseFutureBuilder method buildWithEntity.
private ResponseFuture<V> buildWithEntity() {
int status = getStatus();
byte[] entity = mapToBytes(getEntity().data());
Response<V> decodedResponse = new MockResponseBuilder<K, V>().setEntity(getEntity()).setStatus(status).setHeaders(getHeaders()).setCookies(getCookies()).setProtocolVersion(getProtocolVersion()).build();
RestResponse restResponse = new RestResponseBuilder().setEntity(entity).setStatus(status).setHeaders(decodedResponse.getHeaders()).setCookies(CookieUtil.encodeCookies(decodedResponse.getCookies())).build();
RestLiResponseException restLiResponseException = new RestLiResponseException(restResponse, decodedResponse, new ErrorResponse());
ExecutionException executionException = new ExecutionException(restLiResponseException);
Future<Response<V>> responseFuture = buildFuture(null, executionException);
return new ResponseFutureImpl<>(responseFuture, _errorHandlingBehavior);
}
Aggregations