Search in sources :

Example 16 with RequestExecutionReportBuilder

use of com.linkedin.restli.server.RequestExecutionReportBuilder in project rest.li by linkedin.

the class TestRestLiCallback method testOnSuccessNoFilters.

@Test
public void testOnSuccessNoFilters() throws Exception {
    String result = "foo";
    RequestExecutionReport executionReport = new RequestExecutionReportBuilder().build();
    RestLiResponseAttachments restLiResponseAttachments = new RestLiResponseAttachments.Builder().build();
    RestLiResponseData responseData = new RestLiResponseDataImpl(HttpStatus.S_200_OK, Collections.<String, String>emptyMap(), Collections.<HttpCookie>emptyList());
    PartialRestResponse partialResponse = new PartialRestResponse.Builder().build();
    RestResponse restResponse = new RestResponseBuilder().build();
    // Set up.
    when(_requestExecutionReportBuilder.build()).thenReturn(executionReport);
    when(_responseHandler.buildRestLiResponseData(_restRequest, _routingResult, result)).thenReturn(responseData);
    when(_responseHandler.buildPartialResponse(_routingResult, responseData)).thenReturn(partialResponse);
    when(_responseHandler.buildResponse(_routingResult, partialResponse)).thenReturn(restResponse);
    // Invoke.
    _noFilterRestLiCallback.onSuccess(result, executionReport, restLiResponseAttachments);
    // Verify.
    verify(_responseHandler).buildPartialResponse(_routingResult, responseData);
    verify(_responseHandler).buildRestLiResponseData(_restRequest, _routingResult, result);
    verify(_responseHandler).buildResponse(_routingResult, partialResponse);
    verify(_callback).onSuccess(restResponse, executionReport, restLiResponseAttachments);
    verifyZeroInteractions(_restRequest, _routingResult);
    verifyNoMoreInteractions(_responseHandler, _callback);
}
Also used : RequestExecutionReportBuilder(com.linkedin.restli.server.RequestExecutionReportBuilder) RestResponse(com.linkedin.r2.message.rest.RestResponse) RestLiResponseData(com.linkedin.restli.server.RestLiResponseData) RestResponseBuilder(com.linkedin.r2.message.rest.RestResponseBuilder) RequestExecutionReport(com.linkedin.restli.server.RequestExecutionReport) RestLiResponseAttachments(com.linkedin.restli.server.RestLiResponseAttachments) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

RequestExecutionReport (com.linkedin.restli.server.RequestExecutionReport)16 RequestExecutionReportBuilder (com.linkedin.restli.server.RequestExecutionReportBuilder)16 RestLiResponseAttachments (com.linkedin.restli.server.RestLiResponseAttachments)16 RestResponseBuilder (com.linkedin.r2.message.rest.RestResponseBuilder)14 BeforeTest (org.testng.annotations.BeforeTest)14 Test (org.testng.annotations.Test)14 FilterRequestContext (com.linkedin.restli.server.filter.FilterRequestContext)13 RestException (com.linkedin.r2.message.rest.RestException)12 RestLiServiceException (com.linkedin.restli.server.RestLiServiceException)12 RoutingException (com.linkedin.restli.server.RoutingException)11 FilterResponseContext (com.linkedin.restli.server.filter.FilterResponseContext)10 EmptyRecord (com.linkedin.restli.common.EmptyRecord)9 InvocationOnMock (org.mockito.invocation.InvocationOnMock)9 RecordTemplate (com.linkedin.data.template.RecordTemplate)6 RestResponse (com.linkedin.r2.message.rest.RestResponse)6 Mockito.doAnswer (org.mockito.Mockito.doAnswer)5 Answer (org.mockito.stubbing.Answer)5 DataMap (com.linkedin.data.DataMap)2 RequestContext (com.linkedin.r2.message.RequestContext)2 RestRequest (com.linkedin.r2.message.rest.RestRequest)2