@Test
@UseDataProvider("exceptionMapperByExceptionType")
public <T extends Throwable> void retrievesExceptionMapperByExceptionType(boolean singletonOrPerRequest,
                                                                          Class<T> errorClass,
                                                                          Object expectedExceptionMapperClassOrInstance) throws Exception {

    if (singletonOrPerRequest == SINGLETON) {
        registerSingletonExceptionMappers();
    } else {
        registerPerRequestExceptionMappers();
    }
    ExceptionMapper<T> exceptionMapper = providers.getExceptionMapper(errorClass);
    if (singletonOrPerRequest == SINGLETON) {
        assertSame(expectedExceptionMapperClassOrInstance, exceptionMapper);
    } else {
        assertNotNull(exceptionMapper);
        assertEquals(expectedExceptionMapperClassOrInstance, exceptionMapper.getClass());
    }
}