Class TestFieldUtils
java.lang.Object
ru.vyarus.dropwizard.guice.test.jupiter.env.field.TestFieldUtils
Helper utility for search and processing annotated test fields (for test extensions implementation).
- Since:
- 07.02.2025
-
Method Summary
Modifier and TypeMethodDescriptionstatic <A extends Annotation,T>
List<AnnotatedField<A,T>> findAnnotatedFields(Class<?> testClass, Class<A> ann, Class<T> requiredType) Search for annotated fields in test clas (including base test hierarchy).static <A extends Annotation,T>
List<AnnotatedField<A,T>> getInheritedFields(List<AnnotatedField<A, T>> fields) Filter fields, declared in base test classes (not own fields).static <A extends Annotation,T>
List<AnnotatedField<A,T>> getTestOwnFields(List<AnnotatedField<A, T>> fields) Filter fields, declared directly in test classes (own fields).static <A extends Annotation,T>
List<T>getValues(List<AnnotatedField<A, T>> fields, Object instance) Get multiple fields value at once.static String
-
Method Details
-
findAnnotatedFields
public static <A extends Annotation,T> List<AnnotatedField<A,T>> findAnnotatedFields(Class<?> testClass, Class<A> ann, Class<T> requiredType) Search for annotated fields in test clas (including base test hierarchy). In the returned list static fields go first (sort applied).- Type Parameters:
A- annotation typeT- field (base) type- Parameters:
testClass- test classann- field annotationrequiredType- required field type (if field is not a supertype of declared - error thrown)- Returns:
- detected fields
-
getInheritedFields
public static <A extends Annotation,T> List<AnnotatedField<A,T>> getInheritedFields(List<AnnotatedField<A, T>> fields) Filter fields, declared in base test classes (not own fields).- Type Parameters:
A- annotation typeT- field type- Parameters:
fields- fields to filter- Returns:
- fields not directly declared in test class
-
getTestOwnFields
public static <A extends Annotation,T> List<AnnotatedField<A,T>> getTestOwnFields(List<AnnotatedField<A, T>> fields) Filter fields, declared directly in test classes (own fields).- Type Parameters:
A- annotation typeT- field type- Parameters:
fields- fields to filter- Returns:
- fields directly declared in test class
-
getValues
public static <A extends Annotation,T> List<T> getValues(List<AnnotatedField<A, T>> fields, Object instance) Get multiple fields value at once.- Type Parameters:
A- annotation typeT- field type- Parameters:
fields- fields to get values frominstance- test instance (could by null for static fields)- Returns:
- field values
-
toString
- Parameters:
field- field- Returns:
- string field representation with class and reduced package (for reports and logs).
-