### Question:
JerseyJaxRsEntity implements JaxRsEntity { @Override public <T extends Annotation> Optional<T> getAnnotation(Class<T> annotationType) { Class castClass = Cast.toClass(input); return (Optional<T>) Optional.fromNullable(castClass.getAnnotation(annotationType)); } JerseyJaxRsEntity(Type input, SourceParser sourceParser); @Override Type getType(); @Override Optional<String> getDescription(); @Override JaxRsEntity createJaxRsEntity(Type type); @Override Optional<T> getAnnotation(Class<T> annotationType);  }### Answer:
@Test public void annotationOnSimpleType() throws Exception { JerseyJaxRsEntity entity = new JerseyJaxRsEntity(Foo.class, null); Optional<Ignore> annotations = entity.getAnnotation(Ignore.class); assertTrue(annotations.isPresent()); }
@Test public void annotationOnParametrizedType() throws Exception { Method m = Foo.class.getMethod("foo"); JerseyJaxRsEntity entity = new JerseyJaxRsEntity(m.getGenericReturnType(), null); Optional<Ignore> annotations = entity.getAnnotation(Ignore.class); assertTrue(annotations.isPresent()); }
@Test(expected = IllegalArgumentException.class) public void annotationOnParametrizedVariableType() throws Exception { Method m = Foo.class.getMethod("foot"); JerseyJaxRsEntity entity = new JerseyJaxRsEntity(m.getGenericReturnType(), null); Optional<Ignore> annotations = entity.getAnnotation(Ignore.class); assertTrue(annotations.isPresent()); }
@Test public void noAnnotation() throws Exception { JerseyJaxRsEntity entity = new JerseyJaxRsEntity(NoAnnotation.class, null); Optional<Ignore> annotations = entity.getAnnotation(Ignore.class); assertFalse(annotations.isPresent()); }