ParameterResolverFactory { public ParameterResolver createParameterResolver(Annotation annotation) { final Class annotationType = annotation.annotationType(); if (annotationType == CookieParam.class) { return new CookieParameterResolver((CookieParam)annotation, new TypeProducerFactory()); } if (annotationType == Context.class) { return new ContextParameterResolver(); } if (annotationType == FormParam.class) { return new FormParameterResolver((FormParam)annotation, new TypeProducerFactory()); } if (annotationType == HeaderParam.class) { return new HeaderParameterResolver((HeaderParam)annotation, new TypeProducerFactory()); } if (annotationType == MatrixParam.class) { return new MatrixParameterResolver((MatrixParam)annotation, new TypeProducerFactory()); } if (annotationType == PathParam.class) { return new PathParameterResolver((PathParam)annotation, new TypeProducerFactory()); } if (annotationType == QueryParam.class) { return new QueryParameterResolver((QueryParam)annotation, new TypeProducerFactory()); } if (annotationType == Property.class) { return new PropertyResolver((Property)annotation); } throw new IllegalArgumentException(String.format("Unsupported annotation %s", annotationType)); }  ParameterResolver createParameterResolver(Annotation annotation);  }
@UseDataProvider("supportedAnnotations") @Test public void returnsCorrectImplementationOfParameterResolverForInputAnnotation(Annotation annotation, Class<? extends ParameterResolver> expectedClassOfParameterResolver) { ParameterResolver parameterResolver = parameterResolverFactory.createParameterResolver(annotation); assertNotNull(parameterResolver); assertEquals(expectedClassOfParameterResolver, parameterResolver.getClass()); }
@Test(expected = IllegalArgumentException.class) public void throwsExceptionWhenInputAnnotationIsNotSupported() { parameterResolverFactory.createParameterResolver(annotationOfType(Path.class)); }