use of io.quarkus.test.junit.mockito.InjectMock in project quarkus by quarkusio.
the class CreateMockitoMocksCallback method afterConstruct.
@Override
public void afterConstruct(Object testInstance) {
Class<?> current = testInstance.getClass();
while (current.getSuperclass() != null) {
for (Field field : current.getDeclaredFields()) {
InjectMock injectMockAnnotation = field.getAnnotation(InjectMock.class);
if (injectMockAnnotation != null) {
boolean returnsDeepMocks = injectMockAnnotation.returnsDeepMocks();
Object beanInstance = getBeanInstance(testInstance, field, InjectMock.class);
Optional<Object> result = createMockAndSetTestField(testInstance, field, beanInstance, new MockConfiguration(returnsDeepMocks));
if (result.isPresent()) {
MockitoMocksTracker.track(testInstance, result.get(), beanInstance);
}
}
}
current = current.getSuperclass();
}
}
Aggregations