use of com.linkedin.restli.internal.server.response.PartialRestResponse in project rest.li by linkedin.
the class FilterChainCallbackImpl method onResponseSuccess.
@Override
public void onResponseSuccess(final RestLiResponseData responseData, final RestLiResponseAttachments responseAttachments) {
final PartialRestResponse response = _responseHandler.buildPartialResponse(_method, responseData);
_wrappedCallback.onSuccess(_responseHandler.buildResponse(_method, response), getRequestExecutionReport(), responseAttachments);
}
use of com.linkedin.restli.internal.server.response.PartialRestResponse in project rest.li by linkedin.
the class FilterChainCallbackImpl method onError.
@Override
public void onError(Throwable th, final RestLiResponseData responseData, final RestLiResponseAttachments responseAttachments) {
RestLiServiceException e = responseData.getServiceException();
final PartialRestResponse response = _responseHandler.buildPartialResponse(_method, responseData);
_wrappedCallback.onError(_responseHandler.buildRestException(e, response), getRequestExecutionReport(), _requestAttachmentReader, responseAttachments);
}
use of com.linkedin.restli.internal.server.response.PartialRestResponse in project rest.li by linkedin.
the class TestRestLiResponseHandler method testPartialRestResponse.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "statusActionDataPartial")
public void testPartialRestResponse(AcceptTypeData acceptTypeData, String response1, String response2, ProtocolVersion protocolVersion, String errorResponseHeaderName) throws Exception {
final RestRequest request = buildRequest(acceptTypeData.acceptHeaders, protocolVersion);
PartialRestResponse response;
RoutingResult routingResult1 = buildRoutingResultAction(Status.class, request, acceptTypeData.acceptHeaders);
// #1 simple record template
response = _responseHandler.buildPartialResponse(routingResult1, _responseHandler.buildRestLiResponseData(request, routingResult1, buildStatusRecord()));
checkResponse(response, HttpStatus.S_200_OK, 1, false, true, errorResponseHeaderName);
assertEquals(response.getEntity().toString(), response1);
// #2 DataTemplate response
StringMap map = new StringMap();
map.put("key1", "value1");
map.put("key2", "value2");
RoutingResult routingResult2 = buildRoutingResultAction(StringMap.class, request, acceptTypeData.acceptHeaders);
response = _responseHandler.buildPartialResponse(routingResult2, _responseHandler.buildRestLiResponseData(request, routingResult2, map));
checkResponse(response, HttpStatus.S_200_OK, 1, false, true, errorResponseHeaderName);
//Obtain the maps necessary for comparison
final DataMap actualMap;
final DataMap expectedMap;
actualMap = response.getDataMap();
expectedMap = JACKSON_DATA_CODEC.stringToMap(response2);
assertEquals(actualMap, expectedMap);
RoutingResult routingResult3 = buildRoutingResultAction(Void.TYPE, request, acceptTypeData.acceptHeaders);
// #3 empty response
response = _responseHandler.buildPartialResponse(routingResult3, _responseHandler.buildRestLiResponseData(request, routingResult3, null));
checkResponse(response, HttpStatus.S_200_OK, 1, false, false, errorResponseHeaderName);
assertEquals(response.getEntity(), null);
}
Aggregations