### Question:
RabbitMqBeanPostProcessor implements BeanPostProcessor { @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof SimpleRabbitListenerContainerFactory) { SimpleRabbitListenerContainerFactory factory = (SimpleRabbitListenerContainerFactory) bean; registerIdempotentInterceptor(factory); } else if (bean instanceof AbstractMessageListenerContainer) { AbstractMessageListenerContainer container = (AbstractMessageListenerContainer) bean; registerIdempotentInterceptor(container); } return bean; }  @Override Object postProcessBeforeInitialization(Object bean, String beanName); @Override Object postProcessAfterInitialization(Object bean, String beanName);  }### Answer:
@Test void testPostProcessBeforeInitialization() { Object object = new Object(); Object result = rabbitMqBeanPostProcessor.postProcessBeforeInitialization(object, "object"); assertThat(result).isNotNull(); assertThat(result).isSameAs(object); }
@Test void testSimpleRabbitListenerContainerFactoryInstrumentation() { SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory(); Object result = rabbitMqBeanPostProcessor.postProcessBeforeInitialization(factory, "factory"); assertThat(result).isNotNull(); assertThat(result).isInstanceOf(SimpleRabbitListenerContainerFactory.class); Advice[] adviceChain = factory.getAdviceChain(); assertThat(adviceChain).isNotNull(); assertThat(adviceChain).isNotEmpty(); assertThat(adviceChain).hasSize(1); assertThat(adviceChain[0]).isEqualTo(messageInterceptor); }
@Test void testSimpleMessageListenerContainerInstrumentation() { SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); Object result = rabbitMqBeanPostProcessor.postProcessBeforeInitialization(container, "container"); assertThat(result).isNotNull(); assertThat(result).isInstanceOf(SimpleMessageListenerContainer.class); Advice[] adviceChain = (Advice[]) ReflectionTestUtils.getField(result, "adviceChain"); assertThat(adviceChain).isNotNull(); assertThat(adviceChain).isNotEmpty(); assertThat(adviceChain).hasSize(1); assertThat(adviceChain[0]).isEqualTo(messageInterceptor); }