Interface SelectorResolver.Context
-
- Enclosing interface:
- SelectorResolver
@API(status=EXPERIMENTAL, since="1.5") public static interface SelectorResolver.Context
The context for resolving aDiscoverySelectorand adding it to the test tree.The context is used to add resolved
TestDescriptorsto the test tree if and only if the parentTestDescriptorcould be found. Alternatively, a resolver may use the context to resolve a certainDiscoverySelectorinto aTestDescriptor(e.g. for adding a filter and returning a partial match).- Since:
- 1.5
- See Also:
SelectorResolver
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T extends TestDescriptor>
Optional<T>addToParent(Function<TestDescriptor,Optional<T>> creator)Add aTestDescriptorto an unspecified parent, usually the engine descriptor, by applying the suppliedFunctionto the new parent.<T extends TestDescriptor>
Optional<T>addToParent(Supplier<DiscoverySelector> parentSelectorSupplier, Function<TestDescriptor,Optional<T>> creator)Add aTestDescriptorto a parent, specified by theDiscoverySelectorreturned by the suppliedSupplier, by applying the suppliedFunctionto the new parent.Optional<TestDescriptor>resolve(DiscoverySelector selector)Resolve the suppliedTestDescriptor, if possible.
-
-
-
Method Detail
-
resolve
Optional<TestDescriptor> resolve(DiscoverySelector selector)
Resolve 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.- Parameters:
selector- the selector to resolve- Returns:
- the resolved
TestDescriptor; nevernullbut potentially empty
-
addToParent
<T extends TestDescriptor> Optional<T> addToParent(Function<TestDescriptor,Optional<T>> creator)
Add 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.- 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 - Throws:
ClassCastException- if the previously existingTestDescriptoris not an instance ofT
-
addToParent
<T extends TestDescriptor> Optional<T> addToParent(Supplier<DiscoverySelector> parentSelectorSupplier, Function<TestDescriptor,Optional<T>> creator)
Add 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.- 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 - Throws:
ClassCastException- if the previously existingTestDescriptoris not an instance ofT
-
-