ResourceBinderImpl implements ResourceBinder { @Override public void addResource(Class<?> resourceClass, MultivaluedMap<String, String> properties) { if (!resourceClass.isAnnotationPresent(Path.class)) { throw new ResourcePublicationException(String.format( "Resource class %s it is not root resource. Path annotation javax.ws.rs.Path is not specified for this class.", resourceClass.getName())); } try { addResource(new PerRequestObjectFactory<>(newResourceDescriptor(null, resourceClass, properties))); } catch (ResourcePublicationException e) { throw e; } catch (Exception e) { throw new ResourcePublicationException(e.getMessage(), e); } }  @Override void addResource(Class<?> resourceClass, MultivaluedMap<String, String> properties); @Override void addResource(String uriPattern, Class<?> resourceClass, MultivaluedMap<String, String> properties); @Override void addResource(Object resource, MultivaluedMap<String, String> properties); @Override void addResource(String uriPattern, Object resource, MultivaluedMap<String, String> properties); @Override void addResource(ObjectFactory<ResourceDescriptor> newResourceFactory); void clear(); @Override ObjectFactory<ResourceDescriptor> getMatchedResource(String requestPath, List<String> parameterValues); @Override List<ObjectFactory<ResourceDescriptor>> getResources(); @Override int getSize(); @Override ObjectFactory<ResourceDescriptor> removeResource(Class<?> clazz); @Override ObjectFactory<ResourceDescriptor> removeResource(String path);  }
@Test public void throwsResourcePublicationExceptionWhenResourceClassIsNotAnnotatedWithPathAnnotation() throws Exception { thrown.expect(ResourcePublicationException.class); resourceBinder.addResource(NoPathAnnotationResource.class, new MultivaluedHashMap<>()); }
@Test public void throwsResourcePublicationExceptionWhenResourceIsNotAnnotatedWithPathAnnotation() throws Exception { thrown.expect(ResourcePublicationException.class); resourceBinder.addResource(new NoPathAnnotationResource(), new MultivaluedHashMap<>()); }
@Test public void throwsPerRequestResourcePublicationExceptionWhenTryRegisterTwoResourcesWithTheSamePath() throws Exception { resourceBinder.addResource(EchoResource.class, new MultivaluedHashMap<>()); thrown.expect(ResourcePublicationException.class); resourceBinder.addResource(OtherEchoResource.class, new MultivaluedHashMap<>()); }