@Test
public void usesExceptionMapperToConvertWebApplicationExceptionToResponseWhenResponseFromWebApplicationExceptionDoesNotHaveEntity() throws Exception {

    WebApplicationException webApplicationException = new WebApplicationException(serverError().build());
    doThrow(webApplicationException).when(requestDispatcher).dispatch(request, response);
    ExceptionMapper<WebApplicationException> exceptionMapper = mock(ExceptionMapper.class);
    when(exceptionMapper.toResponse(webApplicationException)).thenReturn(serverError().entity("response from exception mapper").build());
    when(providers.getExceptionMapper(WebApplicationException.class)).thenReturn(exceptionMapper);
    requestHandler.handleRequest(request, response);
    ArgumentCaptor<Response> argumentCaptor = ArgumentCaptor.forClass(Response.class);
    verify(response).setResponse(argumentCaptor.capture());
    assertEquals(INTERNAL_SERVER_ERROR, argumentCaptor.getValue().getStatusInfo());
    assertEquals("response from exception mapper", argumentCaptor.getValue().getEntity());
}