Class InjectingAnnotationEngine
- java.lang.Object
-
- org.mockito.internal.configuration.InjectingAnnotationEngine
-
- All Implemented Interfaces:
AnnotationEngine
,AnnotationEngine
public class InjectingAnnotationEngine extends java.lang.Object implements AnnotationEngine, AnnotationEngine
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.mockito.plugins.AnnotationEngine
AnnotationEngine.NoAction
-
-
Field Summary
Fields Modifier and Type Field Description private AnnotationEngine
delegate
private AnnotationEngine
spyAnnotationEngine
-
Constructor Summary
Constructors Constructor Description InjectingAnnotationEngine()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private java.lang.AutoCloseable
injectCloseableMocks(java.lang.Object testClassInstance)
Initializes mock/spies dependencies for objects annotated with @InjectMocks for given testClassInstance.void
injectMocks(java.lang.Object testClassInstance)
Deprecated.protected void
onInjection(java.lang.Object testClassInstance, java.lang.Class<?> clazz, java.util.Set<java.lang.reflect.Field> mockDependentFields, java.util.Set<java.lang.Object> mocks)
java.lang.AutoCloseable
process(java.lang.Class<?> clazz, java.lang.Object testInstance)
Process the fields of the test instance and create Mocks, Spies, Captors and inject them on fields annotated @InjectMocks.private java.util.List<java.lang.AutoCloseable>
processIndependentAnnotations(java.lang.Class<?> clazz, java.lang.Object testInstance)
private java.util.List<java.lang.AutoCloseable>
processInjectMocks(java.lang.Class<?> clazz, java.lang.Object testInstance)
-
-
-
Field Detail
-
delegate
private final AnnotationEngine delegate
-
spyAnnotationEngine
private final AnnotationEngine spyAnnotationEngine
-
-
Method Detail
-
process
public java.lang.AutoCloseable process(java.lang.Class<?> clazz, java.lang.Object testInstance)
Process the fields of the test instance and create Mocks, Spies, Captors and inject them on fields annotated @InjectMocks.This code process the test class and the super classes.
- First create Mocks, Spies, Captors.
- Then try to inject them.
- Specified by:
process
in interfaceAnnotationEngine
- Parameters:
clazz
- Not usedtestInstance
- The instance of the test, should not be null.- See Also:
AnnotationEngine.process(Class, Object)
-
processInjectMocks
private java.util.List<java.lang.AutoCloseable> processInjectMocks(java.lang.Class<?> clazz, java.lang.Object testInstance)
-
processIndependentAnnotations
private java.util.List<java.lang.AutoCloseable> processIndependentAnnotations(java.lang.Class<?> clazz, java.lang.Object testInstance)
-
injectMocks
@Deprecated public void injectMocks(java.lang.Object testClassInstance)
Deprecated.Required by PowerMockito and retained to avoid API breakage despite being internal API.
-
injectCloseableMocks
private java.lang.AutoCloseable injectCloseableMocks(java.lang.Object testClassInstance)
Initializes mock/spies dependencies for objects annotated with @InjectMocks for given testClassInstance.See examples in javadoc for
MockitoAnnotations
class.- Parameters:
testClassInstance
- Test class, usuallythis
-
onInjection
protected void onInjection(java.lang.Object testClassInstance, java.lang.Class<?> clazz, java.util.Set<java.lang.reflect.Field> mockDependentFields, java.util.Set<java.lang.Object> mocks)
-
-