public class SpyAnnotationEngine extends java.lang.Object implements AnnotationEngine, AnnotationEngine
Will try transform the field in a spy as with Mockito.spy().
If the field is not initialized, will try to initialize it, with a no-arg constructor.
If the field is also annotated with the compatible @InjectMocks then the field will be ignored, The injection engine will handle this specific case.
This engine will fail, if the field is also annotated with incompatible Mockito annotations.
| Constructor and Description |
|---|
SpyAnnotationEngine() |
| Modifier and Type | Method and Description |
|---|---|
private static void |
assertNoIncompatibleAnnotations(java.lang.Class<? extends java.lang.annotation.Annotation> annotation,
java.lang.reflect.Field field,
java.lang.Class<? extends java.lang.annotation.Annotation>... undesiredAnnotations) |
private static java.lang.reflect.Constructor<?> |
noArgConstructorOf(java.lang.Class<?> type) |
void |
process(java.lang.Class<?> context,
java.lang.Object testInstance)
Processes the test instance to configure annotated members.
|
private static java.lang.Object |
spyInstance(java.lang.reflect.Field field,
java.lang.Object instance) |
private static java.lang.Object |
spyNewInstance(java.lang.Object testInstance,
java.lang.reflect.Field field) |
private static boolean |
typeIsNonStaticInnerClass(java.lang.Class<?> type,
int modifiers) |
private static boolean |
typeIsPrivateAbstractInnerClass(java.lang.Class<?> type,
int modifiers) |
public void process(java.lang.Class<?> context,
java.lang.Object testInstance)
AnnotationEngineprocess in interface AnnotationEnginecontext - Class where to extract field information, check implementation for detailstestInstance - Test instanceprivate static java.lang.Object spyInstance(java.lang.reflect.Field field,
java.lang.Object instance)
private static java.lang.Object spyNewInstance(java.lang.Object testInstance,
java.lang.reflect.Field field)
throws java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException
java.lang.InstantiationExceptionjava.lang.IllegalAccessExceptionjava.lang.reflect.InvocationTargetExceptionprivate static java.lang.reflect.Constructor<?> noArgConstructorOf(java.lang.Class<?> type)
private static boolean typeIsNonStaticInnerClass(java.lang.Class<?> type,
int modifiers)
private static boolean typeIsPrivateAbstractInnerClass(java.lang.Class<?> type,
int modifiers)
private static void assertNoIncompatibleAnnotations(java.lang.Class<? extends java.lang.annotation.Annotation> annotation,
java.lang.reflect.Field field,
java.lang.Class<? extends java.lang.annotation.Annotation>... undesiredAnnotations)