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);
String actual = response.getEntity().toString();
assertEquals(actual, response2);
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);
}