@API(status=EXPERIMENTAL,
since="1.5")
public static interface SelectorResolver.Context
DiscoverySelector and adding it to
the test tree.
The context is used to add resolved TestDescriptors to the test tree if and only if the parent
TestDescriptor could be found. Alternatively, a resolver may
use the context to resolve a
certain DiscoverySelector into a TestDescriptor (e.g. for
adding a filter and returning a partial match).
SelectorResolver| Modifier and Type | Method and Description |
|---|---|
<T extends TestDescriptor> |
addToParent(java.util.function.Function<TestDescriptor,java.util.Optional<T>> creator)
Add a
TestDescriptor to an unspecified parent, usually the
engine descriptor, by applying the supplied Function to the
new parent. |
<T extends TestDescriptor> |
addToParent(java.util.function.Supplier<DiscoverySelector> parentSelectorSupplier,
java.util.function.Function<TestDescriptor,java.util.Optional<T>> creator)
Add a
TestDescriptor to a parent, specified by the DiscoverySelector returned by the supplied Supplier, by
applying the supplied Function to the new parent. |
java.util.Optional<TestDescriptor> |
resolve(DiscoverySelector selector)
Resolve the supplied
TestDescriptor, if possible. |
java.util.Optional<TestDescriptor> resolve(DiscoverySelector selector)
TestDescriptor, if possible.
Calling this method has the same effect as returning a partial match from a SelectorResolver: the children of the resulting TestDescriptor will only be resolved if a subsequent resolution
finds an exact match that contains a TestDescriptor with the
same unique ID.
selector - the selector to resolveTestDescriptor; never null but
potentially empty<T extends TestDescriptor> java.util.Optional<T> addToParent(java.util.function.Function<TestDescriptor,java.util.Optional<T>> creator)
TestDescriptor to an unspecified parent, usually the
engine descriptor, by applying the supplied Function to 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 Function is present, it will be added as a child of the
parent TestDescriptor unless a descriptor with the same
unique ID was added
earlier.
T - the type of the new TestDescriptorcreator - Function that will be called with the new
parent to determine the new TestDescriptor to be added; must
not return nullTestDescriptor or the previously existing one
with the same unique ID; never null but potentially emptyjava.lang.ClassCastException - if the previously existing TestDescriptor is not an instance of T<T extends TestDescriptor> java.util.Optional<T> addToParent(java.util.function.Supplier<DiscoverySelector> parentSelectorSupplier, java.util.function.Function<TestDescriptor,java.util.Optional<T>> creator)
TestDescriptor to a parent, specified by the DiscoverySelector returned by the supplied Supplier, by
applying the supplied Function to 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, the DiscoverySelector returned by the supplied Supplier will
be used to determine the parent. If no parent is found, the supplied
Function will not be called. If there are multiple potential
parents, an exception will be thrown. Otherwise, the resolved
TestDescriptor will be used as the parent and passed to the
supplied Function.
If the result of applying the Function is present, it will be added as a child of the
parent TestDescriptor unless a descriptor with the same
unique ID was added
earlier.
T - the type of the new TestDescriptorcreator - Function that will be called with the new
parent to determine the new TestDescriptor to be added; must
not return nullTestDescriptor or the previously existing one
with the same unique ID; never null but potentially emptyjava.lang.ClassCastException - if the previously existing TestDescriptor is not an instance of T