Affects: 6.x

MockitoPostProcessor has been deprecated in Spring Boot. AOT processing of an application's tests generates code like this:

    /**
     * Get the bean definition for 'spyPostProcessor'.
     */
    public static BeanDefinition getSpyPostProcessorBeanDefinition() {
      RootBeanDefinition beanDefinition = new RootBeanDefinition(MockitoPostProcessor.SpyPostProcessor.class);
      beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
      beanDefinition.getConstructorArgumentValues().addIndexedArgumentValue(0, new RuntimeBeanReference("org.springframework.boot.test.mock.mockito.MockitoPostProcessor"));
      beanDefinition.setInstanceSupplier(getSpyPostProcessorInstanceSupplier());
      return beanDefinition;
    }

This results in a deprecation warning for MockitoPostProcessor.

Note that the generated code correctly suppresses warnings for using MockitoPostProcessor directly:

  /**
   * Get the bean definition for 'mockitoPostProcessor'.
   */
  @SuppressWarnings("deprecation")
  public static BeanDefinition getMockitoPostProcessorBeanDefinition() {
    RootBeanDefinition beanDefinition = new RootBeanDefinition(MockitoPostProcessor.class);
    beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
    beanDefinition.getConstructorArgumentValues().addIndexedArgumentValue(0, Collections.emptySet());
    beanDefinition.setInstanceSupplier(getMockitoPostProcessorInstanceSupplier());
    return beanDefinition;
  }

Referring to the SpyPostProcessor nested class appears to be enough to throw off the deprecated API detection.

Comment From: snicoll

This is a bug of what we intended to implement in #29597. As such, the issue as originally titled sounds better to me, and it should be fixed in 6.1.x.

Comment From: wilkinsona

Thanks, @snicoll. A fix in 6.1.x was what I hoped for as this looked like a bug to me based on the previous work in this area in that generation.