FeatureAnnotations { public static Set<Annotation> getAnnotations(Feature feature) { Set<Annotation> annotations = new HashSet<Annotation>(); try { Class<? extends Feature> featureClass = feature.getClass(); Annotation[] fieldAnnotations = featureClass.getField(feature.name()).getAnnotations(); Annotation[] classAnnotations = featureClass.getAnnotations(); annotations.addAll(Arrays.asList(fieldAnnotations)); annotations.addAll(Arrays.asList(classAnnotations)); return annotations; } catch (SecurityException | NoSuchFieldException e) { } return annotations; }  static String getLabel(Feature feature); static boolean isEnabledByDefault(Feature feature); static boolean isAnnotationPresent(Feature feature, Class<? extends Annotation> annotationType); static Set<Annotation> getAnnotations(Feature feature); static A getAnnotation(Feature feature, Class<A> annotationType); static String[] getFeatureAttribute(Annotation annotation);  }
@Test void getAnnotationsWillReturnBothFieldAndClassLevelAnnotations() { Set<Annotation> result = FeatureAnnotations.getAnnotations(MyFeature.FEATURE_ENABLED_BY_DEFAULT); assertNotNull(result); assertEquals(2, result.size()); List<Annotation> enabledByDefault = result.stream().filter(createAnnotationTypePredicate(EnabledByDefault.class)).collect(toList()); assertFalse(enabledByDefault.isEmpty()); List<Annotation> classLevelGroup = result.stream().filter(createAnnotationTypePredicate(ClassLevelGroup.class)).collect(toList()); assertFalse(classLevelGroup.isEmpty()); }
@Test void getAnnotationsWillReturnEmptySetWhenThereAreNoAnnotations() { Set<Annotation> result = FeatureAnnotations.getAnnotations(MyFeature2.FEATURE_WITH_NO_ANNOTATIONS); assertNotNull(result); assertEquals(0, result.size()); }