AsyncCustomAutoConfiguration implements BeanPostProcessor { @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof AsyncConfigurer && !(bean instanceof LazyTraceAsyncCustomizer)) { AsyncConfigurer configurer = (AsyncConfigurer) bean; return new LazyTraceAsyncCustomizer(this.beanFactory, configurer); } return bean; }  @Override Object postProcessBeforeInitialization(Object bean, String beanName); @Override Object postProcessAfterInitialization(Object bean, String beanName);  }
@Test public void should_return_bean_when_its_not_a_async_configurer() throws Exception { AsyncCustomAutoConfiguration configuration = new AsyncCustomAutoConfiguration(); Object bean = configuration.postProcessAfterInitialization(new Object(), "someName"); then(bean).isNotInstanceOf(LazyTraceAsyncCustomizer.class); }
@Test public void should_return_lazy_async_configurer_when_bean_is_async_configurer() throws Exception { AsyncCustomAutoConfiguration configuration = new AsyncCustomAutoConfiguration(); Object bean = configuration.postProcessAfterInitialization(mock(AsyncConfigurer.class), "someName"); then(bean).isInstanceOf(LazyTraceAsyncCustomizer.class); }