Class EngineDiscoveryRequestResolution.DefaultContext
- java.lang.Object
-
- org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.DefaultContext
-
- All Implemented Interfaces:
SelectorResolver.Context
- Enclosing class:
- EngineDiscoveryRequestResolution
private class EngineDiscoveryRequestResolution.DefaultContext extends java.lang.Object implements SelectorResolver.Context
-
-
Field Summary
Fields Modifier and Type Field Description private TestDescriptorparent
-
Constructor Summary
Constructors Constructor Description DefaultContext(TestDescriptor parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends TestDescriptor>
java.util.Optional<T>addToParent(java.util.function.Function<TestDescriptor,java.util.Optional<T>> creator)Add aTestDescriptorto an unspecified parent, usually the engine descriptor, by applying the suppliedFunctionto the new parent.<T extends TestDescriptor>
java.util.Optional<T>addToParent(java.util.function.Supplier<DiscoverySelector> parentSelectorSupplier, java.util.function.Function<TestDescriptor,java.util.Optional<T>> creator)Add aTestDescriptorto a parent, specified by theDiscoverySelectorreturned by the suppliedSupplier, by applying the suppliedFunctionto the new parent.private <T extends TestDescriptor>
java.util.Optional<T>createAndAdd(TestDescriptor parent, java.util.function.Function<TestDescriptor,java.util.Optional<T>> creator)java.util.Optional<TestDescriptor>resolve(DiscoverySelector selector)Resolve the suppliedTestDescriptor, if possible.
-
-
-
Field Detail
-
parent
private final TestDescriptor parent
-
-
Constructor Detail
-
DefaultContext
DefaultContext(TestDescriptor parent)
-
-
Method Detail
-
addToParent
public <T extends TestDescriptor> java.util.Optional<T> addToParent(java.util.function.Function<TestDescriptor,java.util.Optional<T>> creator)
Description copied from interface:SelectorResolver.ContextAdd aTestDescriptorto an unspecified parent, usually the engine descriptor, by applying the suppliedFunctionto the new parent.The parent will be the engine descriptor unless another parent has already been determined, i.e. if the selector that is being resolved is the result of expanding a
SelectorResolver.Match.If the result of applying the
Functionis present, it will be added as a child of the parentTestDescriptorunless a descriptor with the same unique ID was added earlier.- Specified by:
addToParentin interfaceSelectorResolver.Context- Type Parameters:
T- the type of the newTestDescriptor- Parameters:
creator-Functionthat will be called with the new parent to determine the newTestDescriptorto be added; must not returnnull- Returns:
- the new
TestDescriptoror the previously existing one with the same unique ID; nevernullbut potentially empty
-
addToParent
public <T extends TestDescriptor> java.util.Optional<T> addToParent(java.util.function.Supplier<DiscoverySelector> parentSelectorSupplier, java.util.function.Function<TestDescriptor,java.util.Optional<T>> creator)
Description copied from interface:SelectorResolver.ContextAdd aTestDescriptorto a parent, specified by theDiscoverySelectorreturned by the suppliedSupplier, by applying the suppliedFunctionto the new parent.Unless another parent has already been determined, i.e. if the selector that is being resolved is the result of expanding a
SelectorResolver.Match, theDiscoverySelectorreturned by the suppliedSupplierwill be used to determine the parent. If no parent is found, the suppliedFunctionwill not be called. If there are multiple potential parents, an exception will be thrown. Otherwise, the resolvedTestDescriptorwill be used as the parent and passed to the suppliedFunction.If the result of applying the
Functionis present, it will be added as a child of the parentTestDescriptorunless a descriptor with the same unique ID was added earlier.- Specified by:
addToParentin interfaceSelectorResolver.Context- Type Parameters:
T- the type of the newTestDescriptorcreator-Functionthat will be called with the new parent to determine the newTestDescriptorto be added; must not returnnull- Returns:
- the new
TestDescriptoror the previously existing one with the same unique ID; nevernullbut potentially empty
-
resolve
public java.util.Optional<TestDescriptor> resolve(DiscoverySelector selector)
Description copied from interface:SelectorResolver.ContextResolve the suppliedTestDescriptor, if possible.Calling this method has the same effect as returning a partial match from a
SelectorResolver: the children of the resultingTestDescriptorwill only be resolved if a subsequent resolution finds an exact match that contains aTestDescriptorwith the same unique ID.- Specified by:
resolvein interfaceSelectorResolver.Context- Parameters:
selector- the selector to resolve- Returns:
- the resolved
TestDescriptor; nevernullbut potentially empty
-
createAndAdd
private <T extends TestDescriptor> java.util.Optional<T> createAndAdd(TestDescriptor parent, java.util.function.Function<TestDescriptor,java.util.Optional<T>> creator)
-
-