ApplicationProviderBinder extends ProviderBinder { @Override public <T extends Throwable> ExceptionMapper<T> getExceptionMapper(Class<T> type) { ExceptionMapper<T> exceptionMapper = doGetExceptionMapper(type); if (exceptionMapper == null) { exceptionMapper = getDefaults().getExceptionMapper(type); } return exceptionMapper; }  @Override List<MediaType> getAcceptableWriterMediaTypes(Class<?> type, Type genericType, Annotation[] annotations); @Override ContextResolver<T> getContextResolver(Class<T> contextType, MediaType mediaType); @Override ExceptionMapper<T> getExceptionMapper(Class<T> type); @Override MessageBodyReader<T> getMessageBodyReader(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override MessageBodyWriter<T> getMessageBodyWriter(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override List<MethodInvokerFilter> getMethodInvokerFilters(String path); @Override List<RequestFilter> getRequestFilters(String path); @Override List<ResponseFilter> getResponseFilters(String path);  }
@Test public void retrievesExceptionMapperByExceptionType() { ExceptionMapper<RuntimeException> exceptionMapper = new RuntimeExceptionMapper(); applicationProviders.addExceptionMapper(exceptionMapper); assertSame(exceptionMapper, applicationProviders.getExceptionMapper(RuntimeException.class)); }
@Test public void retrievesExceptionMapperFromEmbeddedProviderBinderByExceptionTypeWhenRequiredExceptionMapperIsNotAvailableInApplicationProviderBinder() { ExceptionMapper<RuntimeException> exceptionMapper = mock(ExceptionMapper.class); when(embeddedProviders.getExceptionMapper(RuntimeException.class)).thenReturn(exceptionMapper); assertSame(exceptionMapper, applicationProviders.getExceptionMapper(RuntimeException.class)); }