Class ExtensionRegistry
- java.lang.Object
-
- ru.vyarus.spock.jupiter.engine.ExtensionRegistry
-
public class ExtensionRegistry extends java.lang.ObjectHolds all found junit extensions for target context. Registry is hierarchical: first spec-level registry created and then feature-level registries. Extensions lookup performed by top-most registry and then by parent (if exists).Based on
org.junit.jupiter.engine.extension.MutableExtensionRegistryfrom junit-jupiter-engine (5.8). Does not support auto-detected, default and synthetic extensions (no need).- Since:
- 30.11.2021
-
-
Constructor Summary
Constructors Constructor Description ExtensionRegistry(ExtensionRegistry parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <E extends org.junit.jupiter.api.extension.Extension>
java.util.List<E>getExtensions(java.lang.Class<E> extensionType)Get allExtensionsof the specified type that are present in this registry or one of its ancestors.<E extends org.junit.jupiter.api.extension.Extension>
java.util.List<E>getReversedExtensions(java.lang.Class<E> extensionType)Get allExtensionsof the specified type that are present in this registry or one of its ancestors, in reverse order.voidregisterExtension(java.lang.Class<? extends org.junit.jupiter.api.extension.Extension> extensionType)Instantiate an extension of the given type using its default constructor and register it in the registry.voidregisterExtension(org.junit.jupiter.api.extension.Extension extension, java.lang.Object source)Register the suppliedExtension, without checking if an extension of that type has already been registered.<E extends org.junit.jupiter.api.extension.Extension>
java.util.stream.Stream<E>stream(java.lang.Class<E> extensionType)Stream allExtensionsof the specified type that are present in this registry.
-
-
-
Constructor Detail
-
ExtensionRegistry
public ExtensionRegistry(ExtensionRegistry parent)
-
-
Method Detail
-
stream
public <E extends org.junit.jupiter.api.extension.Extension> java.util.stream.Stream<E> stream(java.lang.Class<E> extensionType)
Stream allExtensionsof the specified type that are present in this registry.Extensions in ancestors are ignored.
- Type Parameters:
E- extension type- Parameters:
extensionType- the type ofExtensionto stream- Returns:
- stream of found extensions
- See Also:
getReversedExtensions(Class)
-
getExtensions
public <E extends org.junit.jupiter.api.extension.Extension> java.util.List<E> getExtensions(java.lang.Class<E> extensionType)
Get allExtensionsof the specified type that are present in this registry or one of its ancestors.- Type Parameters:
E- extension type- Parameters:
extensionType- the type ofExtensionto get- Returns:
- list of found extensions or empty list
- See Also:
getReversedExtensions(Class),stream(Class)
-
getReversedExtensions
public <E extends org.junit.jupiter.api.extension.Extension> java.util.List<E> getReversedExtensions(java.lang.Class<E> extensionType)
Get allExtensionsof the specified type that are present in this registry or one of its ancestors, in reverse order.- Type Parameters:
E- extension type- Parameters:
extensionType- the type ofExtensionto get- Returns:
- reversed list of found extensions
- See Also:
getExtensions(Class),stream(Class)
-
registerExtension
public void registerExtension(java.lang.Class<? extends org.junit.jupiter.api.extension.Extension> extensionType)
Instantiate an extension of the given type using its default constructor and register it in the registry.A new
Extensionshould not be registered if an extension of the given type already exists in the registry or a parent registry.- Parameters:
extensionType- the type of extension to register
-
registerExtension
public void registerExtension(org.junit.jupiter.api.extension.Extension extension, java.lang.Object source)Register the suppliedExtension, without checking if an extension of that type has already been registered.Semantics for Source
If an extension is registered declaratively via
@ExtendWith, thesourceand theextensionshould be the same object. However, if an extension is registered programmatically via@RegisterExtension, thesourceobject should be theFieldthat is annotated with@RegisterExtension. Similarly, if an extension is registered programmatically as a lambda expression or method reference, thesourceobject should be the underlyingMethodthat implements the extension API.- Parameters:
extension- the extension to register; nevernullsource- the source of the extension
-
-