Search in sources :

Example 1 with InjectSpy

use of io.quarkus.test.junit.mockito.InjectSpy in project quarkus by quarkusio.

the class CreateMockitoSpiesCallback method afterConstruct.

@Override
public void afterConstruct(Object testInstance) {
    Class<?> current = testInstance.getClass();
    while (current.getSuperclass() != null) {
        for (Field field : current.getDeclaredFields()) {
            InjectSpy injectSpyAnnotation = field.getAnnotation(InjectSpy.class);
            if (injectSpyAnnotation != null) {
                Object beanInstance = CreateMockitoMocksCallback.getBeanInstance(testInstance, field, InjectSpy.class);
                Object spy = createSpyAndSetTestField(testInstance, field, beanInstance);
                MockitoMocksTracker.track(testInstance, spy, beanInstance);
            }
        }
        current = current.getSuperclass();
    }
}
Also used : Field(java.lang.reflect.Field) InjectSpy(io.quarkus.test.junit.mockito.InjectSpy)

Aggregations

InjectSpy (io.quarkus.test.junit.mockito.InjectSpy)1 Field (java.lang.reflect.Field)1