Class AwaitilityKt
-
- All Implemented Interfaces:
public final class AwaitilityKt
-
-
Field Summary
Fields Modifier and Type Field Description private final static ConditionFactoryawaitprivate final static ConditionFactoryforeverprivate final static ConditionFactorywithprivate final static ConditionFactorygivenprivate final static ConditionFactorythenprivate final static ConditionFactoryand
-
Method Summary
Modifier and Type Method Description final ConditionFactorygetAwait()final ConditionFactorygetForever()final ConditionFactorygetWith()final ConditionFactorygetGiven()final ConditionFactorygetThen()final ConditionFactorygetAnd()final static <T extends Any> Tmatches(AwaitilityKtUntilFunCondition<T> $self, Function1<T, Boolean> pred)Infix function which is what allows us to write the predicate on right-hand side of matches without using a dot. final static <T extends Any> Thas(AwaitilityKtUntilFunCondition<T> $self, Function1<T, Boolean> pred)Infix function that allows us to write the predicate on right-hand side of has without using a dot. final static <T extends Any> AwaitilityKtUntilFunCondition<T>untilCallTo(ConditionFactory $self, Function0<T> fn)An extension function to ConditionFactorythat allows you do write conditions such as:
Note that await is a getter that needs to imported fromawait untilCallTo { myRepository.count() } matches { count -> count == 1 }org.awaitility.kotlin.final static <T extends Any> TuntilNotNull(ConditionFactory $self, Function0<T> fn)An extension function to ConditionFactorythat allows you do write conditions such as:
Note that await is a getter that needs to imported fromval data = await untilNotNull { myDataRepository.findById("id") }org.awaitility.kotlin.final static <T extends Any> UnituntilNull(ConditionFactory $self, Function0<T> fn)An extension function to ConditionFactorythat allows you do write conditions such as:
Note that await is a getter that needs to imported fromawait untilNull { myDataRepository.findById("id") }org.awaitility.kotlin.final static Unituntil(ConditionFactory $self, Function0<Boolean> fn)An extension function to ConditionFactorythat allows you do write conditions such as:
Note that await is a getter that needs to imported fromawait until { myRepository.count() == 1 }org.awaitility.kotlin.final static UnituntilAsserted(ConditionFactory $self, Function0<Unit> fn)An extension function to ConditionFactorythat allows you do write conditions such as:
I.e.await withPollInterval ONE_HUNDRED_MILLISECONDS ignoreException IllegalArgumentException::class untilAsserted { assertThat(fakeRepository.value).isEqualTo(1) }final static ConditionFactoryatMost(ConditionFactory $self, Duration duration)Await at most timeoutbefore throwing a timeout exception.final static ConditionFactoryatLeast(ConditionFactory $self, Duration timeout)Condition has to be evaluated not earlier than timeoutbefore throwing a timeout exception.final static ConditionFactorywithAlias(ConditionFactory $self, String alias)Start building a named await statement. final static ConditionFactorywithPollDelay(ConditionFactory $self, Duration pollDelay)Specify the delay that will be used before Awaitility starts polling for the result the first time. final static ConditionFactorywithPollInterval(ConditionFactory $self, Duration pollInterval)Specify the polling interval Awaitility will use for this await statement. final static ConditionFactorywithPollInterval(ConditionFactory $self, PollInterval pollInterval)Specify the polling interval Awaitility will use for this await statement. final static ConditionFactoryignoreExceptionsInstanceOf(ConditionFactory $self, KClass<out Throwable> exceptionType)Instruct Awaitility to ignore exceptions instance of the supplied exceptionType type. final static ConditionFactoryignoreException(ConditionFactory $self, KClass<out Throwable> exceptionType)Instruct Awaitility to ignore a specific exception and <i>no</i> subclasses of this exception. final static ConditionFactoryignoreExceptionsMatching(ConditionFactory $self, Matcher<in Throwable> matcher)Instruct Awaitility to ignore exceptions that occur during evaluation and matches the supplied Hamcrest matcher. final static ConditionFactoryignoreExceptionsMatching(ConditionFactory $self, Function1<Throwable, Boolean> matcher)Instruct Awaitility to ignore exceptions that occur during evaluation and matches the supplied Hamcrest matcher. final static ConditionFactorypollExecutorService(ConditionFactory $self, ExecutorService executorService)Specify the executor service whose threads will be used to evaluate the poll condition in Awaitility. final static ConditionFactorypollThread(ConditionFactory $self, Function1<Runnable, Thread> threadSupplier)Specify a thread supplier whose thread will be used to evaluate the poll condition in Awaitility. final static UnituntilTrue(ConditionFactory $self, AtomicBoolean atomicBoolean)Await until a Atomic boolean becomes true. final static UnituntilFalse(ConditionFactory $self, AtomicBoolean atomicBoolean)Await until a Atomic boolean becomes false. final static <T extends Any> ConditionFactoryconditionEvaluationListener(ConditionFactory $self, ConditionEvaluationListener<T> conditionEvaluationListener)Handle condition evaluation results each time evaluation of a condition occurs. final static ConditionFactorylogging(ConditionFactory $self, Function1<String, Unit> logPrinter)Logging condition evaluation results each time evaluation of a condition occurs to chosen consumer. -
-
Method Detail
-
getAwait
final ConditionFactory getAwait()
- Returns:
A new ConditionFactory instance
-
getForever
final ConditionFactory getForever()
-
getWith
final ConditionFactory getWith()
-
getGiven
final ConditionFactory getGiven()
-
getThen
final ConditionFactory getThen()
-
getAnd
final ConditionFactory getAnd()
-
matches
final static <T extends Any> T matches(AwaitilityKtUntilFunCondition<T> $self, Function1<T, Boolean> pred)
Infix function which is what allows us to write the predicate on right-hand side of matches without using a dot.
- Parameters:
pred- The predicate that determines whether or not the condition is fulfilled.
-
has
final static <T extends Any> T has(AwaitilityKtUntilFunCondition<T> $self, Function1<T, Boolean> pred)
Infix function that allows us to write the predicate on right-hand side of has without using a dot. This allows expressions such as:
val data = await untilCallTo { fakeObjectRepository.data } has { state == "Hello" }where
datais defined as:data class Data(var state: String)I.e. inside the scope of
hastheDatainstance is used asthis(see here for more info).- Parameters:
pred- The predicate that determines whether or not the condition is fulfilled.- Since:
3.1.5
-
untilCallTo
final static <T extends Any> AwaitilityKtUntilFunCondition<T> untilCallTo(ConditionFactory $self, Function0<T> fn)
An extension function to
ConditionFactorythat allows you do write conditions such as:await untilCallTo { myRepository.count() } matches { count -> count == 1 }Note that await is a getter that needs to imported from
org.awaitility.kotlin.- Parameters:
fn- A function that returns the value that will be evaluated by the predicate in matches.- Since:
3.1.1
-
untilNotNull
final static <T extends Any> T untilNotNull(ConditionFactory $self, Function0<T> fn)
An extension function to
ConditionFactorythat allows you do write conditions such as:val data = await untilNotNull { myDataRepository.findById("id") }Note that await is a getter that needs to imported from
org.awaitility.kotlin.- Since:
3.1.4
-
untilNull
final static <T extends Any> Unit untilNull(ConditionFactory $self, Function0<T> fn)
An extension function to
ConditionFactorythat allows you do write conditions such as:await untilNull { myDataRepository.findById("id") }Note that await is a getter that needs to imported from
org.awaitility.kotlin.- Since:
3.1.5
-
until
final static Unit until(ConditionFactory $self, Function0<Boolean> fn)
An extension function to
ConditionFactorythat allows you do write conditions such as:await until { myRepository.count() == 1 }Note that await is a getter that needs to imported from
org.awaitility.kotlin.- Parameters:
fn- The function to evaluate- Since:
3.1.2
-
untilAsserted
final static Unit untilAsserted(ConditionFactory $self, Function0<Unit> fn)
An extension function to
ConditionFactorythat allows you do write conditions such as:await withPollInterval ONE_HUNDRED_MILLISECONDS ignoreException IllegalArgumentException::class untilAsserted { assertThat(fakeRepository.value).isEqualTo(1) }I.e. you can use untilAsserted to integrate Awaitility with an assertion library of choice. Note that await is a getter that needs to imported from
org.awaitility.kotlin- Parameters:
fn- A function that returns the value that will be evaluated by the predicate in matches.- Returns:
the condition factory
- Since:
3.1.2
-
atMost
final static ConditionFactory atMost(ConditionFactory $self, Duration duration)
Await at most
timeoutbefore throwing a timeout exception.- Parameters:
duration- the duration- Returns:
the condition factory
- Since:
3.1.2
-
atLeast
final static ConditionFactory atLeast(ConditionFactory $self, Duration timeout)
Condition has to be evaluated not earlier than
timeoutbefore throwing a timeout exception.- Parameters:
timeout- the timeout- Returns:
the condition factory
- Since:
3.1.2
-
withAlias
final static ConditionFactory withAlias(ConditionFactory $self, String alias)
Start building a named await statement. This is useful is cases when you have several awaits in your test and you need to tell them apart. If a named await timeout's the <code>alias</code> will be displayed indicating which await statement that failed.
- Parameters:
alias- the alias that will be shown if the await timeouts.- Returns:
the condition factory
- Since:
3.1.2
-
withPollDelay
final static ConditionFactory withPollDelay(ConditionFactory $self, Duration pollDelay)
Specify the delay that will be used before Awaitility starts polling for the result the first time. If you don't specify a poll delay explicitly it'll be the same as the poll interval.
- Parameters:
pollDelay- the poll delay- Returns:
the condition factory
- Since:
3.1.2
-
withPollInterval
final static ConditionFactory withPollInterval(ConditionFactory $self, Duration pollInterval)
Specify the polling interval Awaitility will use for this await statement. This means the frequency in which the condition is checked for completion.
- Parameters:
pollInterval- the poll interval- Returns:
the condition factory
- Since:
3.1.2
-
withPollInterval
final static ConditionFactory withPollInterval(ConditionFactory $self, PollInterval pollInterval)
Specify the polling interval Awaitility will use for this await statement. For example org.awaitility.pollinterval.FibonacciPollInterval.fibonacci.
- Parameters:
pollInterval- the poll interval- Returns:
the condition factory
- Since:
3.1.2
-
ignoreExceptionsInstanceOf
final static ConditionFactory ignoreExceptionsInstanceOf(ConditionFactory $self, KClass<out Throwable> exceptionType)
Instruct Awaitility to ignore exceptions instance of the supplied exceptionType type. Exceptions will be treated as evaluating to <code>false</code>. This is useful in situations where the evaluated conditions may temporarily throw exceptions.
- Parameters:
exceptionType- The exception type (hierarchy) to ignore- Returns:
the condition factory
- Since:
3.1.2
-
ignoreException
final static ConditionFactory ignoreException(ConditionFactory $self, KClass<out Throwable> exceptionType)
Instruct Awaitility to ignore a specific exception and <i>no</i> subclasses of this exception. Exceptions will be treated as evaluating to <code>false</code>. This is useful in situations where the evaluated conditions may temporarily throw exceptions.
- Parameters:
exceptionType- The exception type to ignore- Returns:
the condition factory
- Since:
3.1.2
-
ignoreExceptionsMatching
final static ConditionFactory ignoreExceptionsMatching(ConditionFactory $self, Matcher<in Throwable> matcher)
Instruct Awaitility to ignore exceptions that occur during evaluation and matches the supplied Hamcrest matcher. Exceptions will be treated as evaluating to
false. This is useful in situations where the evaluated conditions may temporarily throw exceptions.- Parameters:
matcher- The Hamcrest matcher- Returns:
the condition factory.
- Since:
3.1.2
-
ignoreExceptionsMatching
final static ConditionFactory ignoreExceptionsMatching(ConditionFactory $self, Function1<Throwable, Boolean> matcher)
Instruct Awaitility to ignore exceptions that occur during evaluation and matches the supplied Hamcrest matcher. Exceptions will be treated as evaluating to
false. This is useful in situations where the evaluated conditions may temporarily throw exceptions.- Parameters:
matcher- The predicate- Returns:
the condition factory.
- Since:
3.1.2
-
pollExecutorService
final static ConditionFactory pollExecutorService(ConditionFactory $self, ExecutorService executorService)
Specify the executor service whose threads will be used to evaluate the poll condition in Awaitility. Note that the executor service must be shutdown manually!
This is an advanced feature and it should only be used sparingly.
- Parameters:
executorService- The executor service that Awaitility will use when polling condition evaluations- Returns:
the condition factory
- Since:
3.1.2
-
pollThread
final static ConditionFactory pollThread(ConditionFactory $self, Function1<Runnable, Thread> threadSupplier)
Specify a thread supplier whose thread will be used to evaluate the poll condition in Awaitility. The supplier will be called only once and the thread it returns will be reused during all condition evaluations. This is an advanced feature and it should only be used sparingly.
- Parameters:
threadSupplier- A supplier of the thread that Awaitility will use when polling- Returns:
the condition factory
- Since:
3.1.2
-
untilTrue
final static Unit untilTrue(ConditionFactory $self, AtomicBoolean atomicBoolean)
Await until a Atomic boolean becomes true.
- Parameters:
atomicBoolean- the atomic variable- Returns:
the condition factory
- Since:
3.1.2
-
untilFalse
final static Unit untilFalse(ConditionFactory $self, AtomicBoolean atomicBoolean)
Await until a Atomic boolean becomes false.
- Parameters:
atomicBoolean- the atomic variable- Returns:
the condition factory
- Since:
3.1.2
-
conditionEvaluationListener
final static <T extends Any> ConditionFactory conditionEvaluationListener(ConditionFactory $self, ConditionEvaluationListener<T> conditionEvaluationListener)
Handle condition evaluation results each time evaluation of a condition occurs. Works only with a Hamcrest matcher-based condition.
- Parameters:
conditionEvaluationListener- the condition evaluation listener- Returns:
the condition factory
- Since:
4.1.1
-
-
-
-