WrapperProcessor implements BeanPostProcessor, ApplicationContextAware { static boolean isValidWrapper(Wrapper wrapper) { if (wrapper == null) { return true; } AtomicBoolean isValid = new AtomicBoolean(true); ReflectionUtils.doWithFields(wrapper.getClass(), field -> { final Autowired annotation = AnnotationUtils.findAnnotation(field, Autowired.class); if (annotation != null) { isValid.set(false); } }); return isValid.get(); }  @Override Object postProcessBeforeInitialization(Object bean, String beanName); @Override Object postProcessAfterInitialization(Object bean, String beanName); @Override void setApplicationContext(ApplicationContext applicationContext);  }
@Test public void shouldReportInvalidWrapper() throws Exception { assertFalse(WrapperProcessor.isValidWrapper(new InvalidWrapper())); }
@Test public void shouldReportValidWrapperForNull() throws Exception { assertTrue(WrapperProcessor.isValidWrapper(null)); }