### Question:
ReflectionHelper { public static Set<Field> getDeclaredFieldsWithAnnotationRecursively(final Class<?> clazz, final Class<? extends Annotation> annotationClass) { final HashSet<Field> fields = new HashSet<>(); addDeclaredFieldsWithAnnotationRecursively(fields, clazz, annotationClass); return fields; } private  ReflectionHelper(); static Class<?> getClassForName(final String className); static Class<?> getArrayType(final Class<?> type); static Field getDeclaredField(final Object bean, final String fieldName); static Object getFieldValue(final Object bean, final String fieldName); static Class<?> getGenericType(final Field field); static T newCollectionInstance(final Class<T> clazz); static T newInstance(final Class<T> clazz); static T newInstance(final String fullyQualifiedClassName, final Class<T> superType); static List<T> createInstances(final List<String> fullyQualifiedClassNames, final Class<T> superType); static void setFieldValue(final Object bean, final String fieldName, final Object value); static Set<Field> getDeclaredFieldsWithAnnotationRecursively(final Class<?> clazz,
                                                                        final Class<? extends Annotation> annotationClass); static T[] newArrayFromCollection(final Collection<?> collection, final Class<T> elementType);  }### Answer:
@Test public void getsDeclaredFieldsRecursivelyWithInheritance() { final Set<Field> fields = getDeclaredFieldsWithAnnotationRecursively(TestSubClass.class, Export.class); assertThat(fields).hasSize(2); assertThat(fields).extracting(Field::getName).contains("set", "paramSubClass"); }
@Test public void getsDeclaredFieldsRecursivelyWithoutInheritance() { final Set<Field> fields = getDeclaredFieldsWithAnnotationRecursively(TestBean.class, Export.class); assertThat(fields).hasSize(1); assertThat(fields).extracting(Field::getName).contains("set"); }