@Test
public void usesExceptionMapperToConvertCauseOfInternalExceptionToResponse() throws Exception {

    Exception exception = new Exception();
    InternalException internalException = new InternalException(exception);
    doThrow(internalException).when(requestDispatcher).dispatch(request, response);
    ExceptionMapper<Exception> exceptionMapper = mock(ExceptionMapper.class);
    when(exceptionMapper.toResponse(exception)).thenReturn(serverError().entity("response from exception mapper").build());
    when(providers.getExceptionMapper(Exception.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());
}