Class ExtensionUtils
java.lang.Object
org.junit.jupiter.engine.descriptor.ExtensionUtils
Collection of utilities for working with extensions and the extension registry.
- Since:
- 5.1
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static int
(package private) static MutableExtensionRegistry
populateNewExtensionRegistryFromExtendWithAnnotation
(MutableExtensionRegistry parentRegistry, AnnotatedElement annotatedElement) Populate a newMutableExtensionRegistry
from extension types declared via@ExtendWith
on the suppliedAnnotatedElement
.(package private) 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
.(package private) static void
registerExtensionsFromExecutableParameters
(ExtensionRegistrar registrar, Executable executable) Register extensions using the supplied registrar from parameters in the suppliedExecutable
(i.e., aConstructor
orMethod
) that are annotated with@ExtendWith
.(package private) static void
registerExtensionsFromFields
(ExtensionRegistrar registrar, Class<?> clazz, Object instance) Register extensions using the supplied registrar from fields in the supplied class that are annotated with@ExtendWith
or@RegisterExtension
.streamExtensionTypes
(AnnotatedElement annotatedElement) streamExtensionTypes
(List<org.junit.jupiter.api.extension.ExtendWith> extendWithAnnotations)
-
Field Details
-
orderComparator
- Since:
- 5.4
-
-
Constructor Details
-
ExtensionUtils
private ExtensionUtils()
-
-
Method Details
-
populateNewExtensionRegistryFromExtendWithAnnotation
static MutableExtensionRegistry populateNewExtensionRegistryFromExtendWithAnnotation(MutableExtensionRegistry parentRegistry, AnnotatedElement annotatedElement) Populate a newMutableExtensionRegistry
from extension types declared via@ExtendWith
on the suppliedAnnotatedElement
.- Parameters:
parentRegistry
- the parent extension registry to set in the newly created registry; nevernull
annotatedElement
- the annotated element on which to search for declarations of@ExtendWith
; nevernull
- Returns:
- the new extension registry; never
null
- Since:
- 5.0
-
registerExtensionsFromFields
static void registerExtensionsFromFields(ExtensionRegistrar registrar, Class<?> clazz, Object instance) Register extensions using the supplied registrar from 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; nevernull
clazz
- the class or interface in which to find the fields; nevernull
instance
- the instance of the supplied class; may benull
when searching forstatic
fields in the class
-
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; nevernull
clazz
- the class in which to find the declared constructor; nevernull
- Since:
- 5.8
-
registerExtensionsFromExecutableParameters
static void registerExtensionsFromExecutableParameters(ExtensionRegistrar registrar, Executable executable) Register extensions using the supplied registrar from parameters in the suppliedExecutable
(i.e., aConstructor
orMethod
) that are annotated with@ExtendWith
.- Parameters:
registrar
- the registrar with which to register the extensions; nevernull
executable
- the constructor or method whose parameters should be searched; nevernull
- Since:
- 5.8
-
streamExtensionTypes
private static Stream<Class<? extends org.junit.jupiter.api.extension.Extension>> streamExtensionTypes(AnnotatedElement annotatedElement) - Since:
- 5.8
-
streamExtensionTypes
private static Stream<Class<? extends org.junit.jupiter.api.extension.Extension>> streamExtensionTypes(List<org.junit.jupiter.api.extension.ExtendWith> extendWithAnnotations) - Since:
- 5.8
-
getOrder
- Since:
- 5.4
-