The framework exposes DSL to do repeated test of condition (possibly in
another thread), for example to wait of an asynchronously result. The
builder mainly returns CompletableFuture
and let the caller handle it, but also provides some shortcut
methods to directly retrieve the result.
Optional<MyResultClass> result = WaitResult.
of(MyCallable).
expecting(MyPredicate).
repeat(2).
every(2,TimeUnit.MILLISECONDS).
get();
This sample defines an execution of maximal 2 retry, waiting 2 ms
between the retry and return the result of the execution. The
Optional
will be present if a result is accepted by
the predicate. In case of error during the execution of the
Callable
an AssertionError
will be thrown. Everything will be executed in this thread.
The sequence of actions will be :
The general form to use this DSL is :
... result =
WaitResult.
of(MyCallable). <-- Specify the action to be repeated
[ignoreException().] <-- May specify how to handle the exception
expecting(MyPredicate). <-- Specify the way to control the result
repeat(2). <-- Specify how much time the retry should be done
every(2,TimeUnit.MILLISECONDS). <--Specify how much time to wait between the retry
usingDefaultExecutor(). <-- Specify the executor to be used for the asynchronous actions
asyncExec(); <-- Finally return the way to wait for the result
WaitResult which is the
main entry point of this library.
,
CompletableFuture
Interface | Description |
---|---|
RetryPolicy |
This interface can be used to specify retry configuration.
|
WaitResultBuilder1<T> |
First Step of the builder of
CompletableFuture to skip, if necessary,
the error. |
WaitResultBuilder2<T> |
Second Step of the builder of
CompletableFuture to specify the
condition to accept a result. |
WaitResultBuilder3<T> |
Third Step of the builder of
CompletableFuture to specify the maximal
number of retry. |
WaitResultBuilder4<T> |
Fourth Step of the builder of
CompletableFuture to specify the amount
of time between the retry. |
WaitResultBuilder5<T> |
Almost final Step of the builder of
CompletableFuture to define the
executor it self. |
WaitResultBuilder6<T> |
Last Step of the builder of
CompletableFuture to create the
completable operation it self. |
Class | Description |
---|---|
RetryPolicies |
Helpers methods to build
RetryPolicy . |
WaitFile |
This class provides methods to wait for fileSystem events.
|
WaitResult |
This class is the entry point for this library to support async operation
inside test.
|
Copyright © 2021. All rights reserved.