Class ExtensionUtils

java.lang.Object
org.junit.jupiter.engine.descriptor.ExtensionUtils

final class ExtensionUtils extends Object
Collection of utilities for working with extensions and the extension registry.
Since:
5.1
See Also:
  • Field Details

    • orderComparator

      private static final Comparator<Field> orderComparator
      Since:
      5.4
    • registersExtension

      private static final Predicate<Field> registersExtension
      Predicate which determines if a Field registers an extension via @RegisterExtension or @ExtendWith.
      Since:
      5.11.3
  • Constructor Details

    • ExtensionUtils

      private ExtensionUtils()
  • Method Details

    • populateNewExtensionRegistryFromExtendWithAnnotation

      static MutableExtensionRegistry populateNewExtensionRegistryFromExtendWithAnnotation(MutableExtensionRegistry parentRegistry, AnnotatedElement annotatedElement)
      Populate a new MutableExtensionRegistry from extension types declared via @ExtendWith on the supplied AnnotatedElement.
      Parameters:
      parentRegistry - the parent extension registry to set in the newly created registry; never null
      annotatedElement - the annotated element on which to search for declarations of @ExtendWith; never null
      Returns:
      the new extension registry; never null
      Since:
      5.0
    • registerExtensionsFromStaticFields

      static void registerExtensionsFromStaticFields(ExtensionRegistrar registrar, Class<?> clazz)
      Register extensions using the supplied registrar from static fields in the supplied class that are annotated with @ExtendWith or @RegisterExtension.

      The extensions will be sorted according to @Order semantics prior to registration.

      Parameters:
      registrar - the registrar with which to register the extensions; never null
      clazz - the class or interface in which to find the fields; never null
      Since:
      5.11
    • registerExtensionsFromInstanceFields

      static void registerExtensionsFromInstanceFields(ExtensionRegistrar registrar, Class<?> clazz)
      Register extensions using the supplied registrar from instance fields in the supplied class that are annotated with @ExtendWith or @RegisterExtension.

      The extensions will be sorted according to @Order semantics prior to registration.

      Parameters:
      registrar - the registrar with which to register the extensions; never null
      clazz - the class or interface in which to find the fields; never null
      Since:
      5.11
    • readAndValidateExtensionFromField

      private static org.junit.jupiter.api.extension.Extension readAndValidateExtensionFromField(Field field, Object instance, List<Class<? extends org.junit.jupiter.api.extension.Extension>> declarativeExtensionTypes)
      Since:
      5.11
    • registerExtensionsFromConstructorParameters

      static void registerExtensionsFromConstructorParameters(ExtensionRegistrar registrar, Class<?> clazz)
      Register extensions using the supplied registrar from parameters in the declared constructor of the supplied class that are annotated with @ExtendWith.
      Parameters:
      registrar - the registrar with which to register the extensions; never null
      clazz - the class in which to find the declared constructor; never null
      Since:
      5.8
    • registerExtensionsFromExecutableParameters

      static void registerExtensionsFromExecutableParameters(ExtensionRegistrar registrar, Executable executable)
      Register extensions using the supplied registrar from parameters in the supplied Executable (i.e., a Constructor or Method) that are annotated with @ExtendWith.
      Parameters:
      registrar - the registrar with which to register the extensions; never null
      executable - the constructor or method whose parameters should be searched; never null
      Since:
      5.8
    • streamExtensionRegisteringFields

      private static Stream<Field> streamExtensionRegisteringFields(Class<?> clazz, Predicate<Field> predicate)
      Since:
      5.11
    • streamDeclarativeExtensionTypes

      private static Stream<Class<? extends org.junit.jupiter.api.extension.Extension>> streamDeclarativeExtensionTypes(AnnotatedElement annotatedElement)
      Since:
      5.11
    • streamDeclarativeExtensionTypes

      private static Stream<Class<? extends org.junit.jupiter.api.extension.Extension>> streamDeclarativeExtensionTypes(List<org.junit.jupiter.api.extension.ExtendWith> extendWithAnnotations)
      Since:
      5.11
    • getOrder

      private static int getOrder(Field field)
      Since:
      5.4