test/src/main/java/de/taimos/dvalin/test/inject/InjectionUtils.java
/**
     * inject mocks into all autowired fields and return them to the caller
     *
     * @param bean the bean to autowire
     * @return object containing all the created and injected mocks
     */
inject mocks into all autowired fields and return them to the caller
@param bean the bean to autowire
@return object containing all the created and injected mocks
inject mocks into all autowired fields and return them to the caller @param bean the bean to autowire @return object containing all the created and injected mocks
public static InjectionMock injectMocks(Object bean) {
        InjectionMock mock = new InjectionMock();
        List<Field> fields = getFields(bean.getClass());
        for (Field field : fields) {
            if (field.isAnnotationPresent(Autowired.class)) {
                Qualifier qualifierAnnotation = field.getAnnotation(Qualifier.class);
                String qualifier = qualifierAnnotation == null ? null : qualifierAnnotation.value();
                Object mockObject = Mockito.mock(field.getType());
                doInjection(bean, mockObject, field);
                mock.addMock(field.getName(), mockObject, field.getType(), qualifier);
            }
        }
        return mock;
    }
public static InjectionMock injectMocks ( Object bean ) { InjectionMock mock = new InjectionMock ( ) ; List < Field > fields = getFields ( bean . getClass ( ) ) ; for ( Field field : fields ) { if ( field . isAnnotationPresent ( Autowired . class ) ) { Qualifier qualifierAnnotation = field . getAnnotation ( Qualifier . class ) ; String qualifier = qualifierAnnotation == null ? null : qualifierAnnotation . value ( ) ; Object mockObject = Mockito . mock ( field . getType ( ) ) ; doInjection ( bean , mockObject , field ) ; mock . addMock ( field . getName ( ) , mockObject , field . getType ( ) , qualifier ) ; } } return mock ; }
inject mocks into all autowired fields and return them to the caller
 @param bean the bean to autowire
 @return object containing all the created and injected mocks
inject mocks into all autowired fields and return them to the caller @param bean the bean to autowire @return object containing all the created and injected mocks