RestComponentResolver { @SuppressWarnings({"unchecked"}) public void addPerRequest(Class clazz) { if (clazz.getAnnotation(Provider.class) != null) { if (ContextResolver.class.isAssignableFrom(clazz)) { providers.addContextResolver(clazz); } if (ExceptionMapper.class.isAssignableFrom(clazz)) { providers.addExceptionMapper(clazz); } if (MessageBodyReader.class.isAssignableFrom(clazz)) { providers.addMessageBodyReader(clazz); } if (MessageBodyWriter.class.isAssignableFrom(clazz)) { providers.addMessageBodyWriter(clazz); } } else if (clazz.getAnnotation(Filter.class) != null) { if (MethodInvokerFilter.class.isAssignableFrom(clazz)) { providers.addMethodInvokerFilter(clazz); } if (RequestFilter.class.isAssignableFrom(clazz)) { providers.addRequestFilter(clazz); } if (ResponseFilter.class.isAssignableFrom(clazz)) { providers.addResponseFilter(clazz); } } else if (clazz.getAnnotation(Path.class) != null) { resources.addResource(clazz, null); } } RestComponentResolver(ResourceBinder resources, ProviderBinder providers); @SuppressWarnings({"unchecked"}) void addSingleton(Object instance); @SuppressWarnings({"unchecked"}) void addPerRequest(Class clazz); @SuppressWarnings({"unchecked"}) void addFactory(ObjectFactory factory);  }
@Test public void resolvesPerRequestResource() { componentResolver.addPerRequest(Resource.class); verify(resources).addResource(Resource.class, null); }
@Test public void resolvesPerRequestExceptionMapper() { componentResolver.addPerRequest(RuntimeExceptionMapper.class); verify(providers).addExceptionMapper(RuntimeExceptionMapper.class); }
@Test public void resolvesPerRequestContextResolver() { componentResolver.addPerRequest(ContextResolverText.class); verify(providers).addContextResolver(ContextResolverText.class); }
@Test public void resolvesPerRequestMessageBodyReader() { componentResolver.addPerRequest(StringEntityProvider.class); verify(providers).addMessageBodyReader(StringEntityProvider.class); }
@Test public void resolvesPerRequestMessageBodyWriter() { componentResolver.addPerRequest(StringEntityProvider.class); verify(providers).addMessageBodyWriter(StringEntityProvider.class); }
@Test public void resolvesPerRequestMethodInvokerFilter() { componentResolver.addPerRequest(AllMatchesMethodInvokerFilter.class); verify(providers).addMethodInvokerFilter(AllMatchesMethodInvokerFilter.class); }
@Test public void resolvesPerRequestRequestFilter() { componentResolver.addPerRequest(AllMatchesRequestFilter.class); verify(providers).addRequestFilter(AllMatchesRequestFilter.class); }
@Test public void resolvesPerResponseResponseFilter() { componentResolver.addPerRequest(AllMatchesResponseFilter.class); verify(providers).addResponseFilter(AllMatchesResponseFilter.class); }