use of org.mockito.internal.configuration.DefaultInjectionEngine in project gwt-test-utils by gwt-test-utils.
the class GwtInjectingAnnotationEngine method injectMocks.
/**
* Initializes mock/spies dependencies for objects annotated with @InjectMocks for given
* testClassInstance.
* <p>
* See examples in javadoc for {@link MockitoAnnotations} class.
*
* @param testClassInstance Test class, usually <code>this</code>
*/
public void injectMocks(final Object testClassInstance) {
Class<?> clazz = testClassInstance.getClass();
Set<Field> mockDependentFields = new HashSet<Field>();
Set<Object> mocks = newMockSafeHashSet();
while (clazz != Object.class) {
new InjectMocksScanner(clazz).addTo(mockDependentFields);
new GwtMockScanner(testClassInstance, clazz).addPreparedMocks(mocks);
clazz = clazz.getSuperclass();
}
new DefaultInjectionEngine().injectMocksOnFields(mockDependentFields, mocks, testClassInstance);
}
Aggregations