TaskAnnotationBeanPostProcessor implements BeanPostProcessor { public void processAnnotations(ApplicationContext applicationContext) { for (String beanName : applicationContext.getBeanDefinitionNames()) { postProcessAfterInitialization(applicationContext.getBean(beanName), beanName); } } TaskAnnotationBeanPostProcessor(BundleContext bundleContext,
                                           ChannelService channelService); void processAnnotations(ApplicationContext applicationContext); @Override Object postProcessBeforeInitialization(Object bean, String beanName); @Override Object postProcessAfterInitialization(final Object bean, final String beanName);  }
@Test public void shouldNotProcessWhenContextNotContainsBean() { when(context.getBeanDefinitionNames()).thenReturn(new String[]{}); processor.processAnnotations(context); verify(channelService, never()).addOrUpdate(any(Channel.class)); }
@Test public void shouldProcessForAllBeansInContext() { String beanName = "testActionWithoutParam"; TestActionWithoutParam bean = new TestActionWithoutParam(); when(context.getBeanDefinitionNames()).thenReturn(new String[]{beanName}); when(context.getBean(beanName)).thenReturn(bean); ArgumentCaptor<Channel> captor = ArgumentCaptor.forClass(Channel.class); processor.processAnnotations(context); verify(channelService).addOrUpdate(captor.capture()); assertChannel(captor.getValue()); }