@Test
public void sendsResponseFromThrownWebApplicationExceptionWhenResponseHasEntity() throws Exception {

    WebApplicationException exception = new WebApplicationException(serverError().entity("Some Error").build());
    doThrow(exception).when(requestDispatcher).dispatch(request, response);
    requestHandler.handleRequest(request, response);
    ArgumentCaptor<Response> argumentCaptor = ArgumentCaptor.forClass(Response.class);
    verify(response).setResponse(argumentCaptor.capture());
    assertEquals(INTERNAL_SERVER_ERROR, argumentCaptor.getValue().getStatusInfo());
    assertEquals("Some Error", argumentCaptor.getValue().getEntity());
}