Interface BeanOverrideProcessor


public interface BeanOverrideProcessor
Strategy interface for Bean Override processing, which creates BeanOverrideHandler instances that drive how target beans are overridden.

At least one composed annotation that is meta-annotated with @BeanOverride must be a companion of this processor and may optionally provide annotation attributes that can be used to configure the BeanOverrideHandler.

Implementations are required to have a no-argument constructor and be stateless.

Since:
6.2
Author:
Simon Baslé, Stephane Nicoll, Sam Brannen
  • Method Details

    • createHandler

      BeanOverrideHandler createHandler(Annotation overrideAnnotation, Class<?> testClass, Field field)
      Create a BeanOverrideHandler for the given annotated field.

      This method will only be invoked when a @BeanOverride annotation is declared on a field — for example, if the supplied field is annotated with @MockitoBean.

      Parameters:
      overrideAnnotation - the composed annotation that declares the @BeanOverride annotation which registers this processor
      testClass - the test class to process
      field - the annotated field
      Returns:
      the BeanOverrideHandler that should handle the given field
      See Also:
    • createHandlers

      default List<BeanOverrideHandler> createHandlers(Annotation overrideAnnotation, Class<?> testClass)
      Create a list of BeanOverrideHandler instances for the given override annotation and test class.

      This method will only be invoked when a @BeanOverride annotation is declared at the type level — for example, if the supplied test class is annotated with @MockitoBean.

      Note that the test class may not be directly annotated with the override annotation. For example, the override annotation may have been declared on an interface, superclass, or enclosing class within the test class hierarchy.

      The default implementation returns an empty list, signaling that this BeanOverrideProcessor does not support type-level @BeanOverride declarations. Can be overridden by concrete implementations to support type-level use cases.

      Parameters:
      overrideAnnotation - the composed annotation that declares the @BeanOverride annotation which registers this processor
      testClass - the test class to process
      Returns:
      the list of BeanOverrideHandlers for the annotated class
      Since:
      6.2.2
      See Also: