SetPropertyMethod extends AbstractPropertyMethod { @Override public <T extends Annotation> T getAnnotation(Class<T> type) { if (super.getAnnotation(type) != null) { reportInvalidAnnotationLocation(); } return getter.getAnnotation(type); } SetPropertyMethod(Method setter, GetPropertyMethod getter, String name, Class<?> type, Type genericType); @Override T getAnnotation(Class<T> type); @Override T getByMetaAnnotation(Class<M> type); @Override Annotation[] getAnnotations();  }
@Test public void getAnnotation() { TestAnnotation annotation = setPropertyMethod.getAnnotation(TestAnnotation.class); assertThat(annotation, notNullValue()); }
@Test public void getAnnotationOnSetter() { try { TestAnnotation annotation = setInvalidPropertyMethod.getAnnotation(TestAnnotation.class); fail("Expecting " + XOException.class); } catch (XOException e) { assertThat(e.getMessage(), containsString("setInvalidProperty")); } }