-
public final class AwaitilityKt
-
-
Field Summary
Fields Modifier and Type Field Description private final static ConditionFactory
await
-
Method Summary
Modifier and Type Method Description final ConditionFactory
getAwait()
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. 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. final static <T extends Any> AwaitilityKtUntilFunCondition<T>
untilCallTo(ConditionFactory $self, Function0<T> fn)
An extension function to ConditionFactory
that 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> T
untilNotNull(ConditionFactory $self, Function0<T> fn)
An extension function to ConditionFactory
that 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> Unit
untilNull(ConditionFactory $self, Function0<T> fn)
An extension function to ConditionFactory
that 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 Unit
until(ConditionFactory $self, Function0<Boolean> fn)
An extension function to ConditionFactory
that 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 Unit
untilAsserted(ConditionFactory $self, Function0<Unit> fn)
An extension function to ConditionFactory
that 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 ConditionFactory
atMost(ConditionFactory $self, Duration duration)
Await at most timeout
before throwing a timeout exception.final static ConditionFactory
atLeast(ConditionFactory $self, Duration timeout)
Condition has to be evaluated not earlier than timeout
before throwing a timeout exception.final static ConditionFactory
withAlias(ConditionFactory $self, String alias)
Start building a named await statement. 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. final static ConditionFactory
withPollInterval(ConditionFactory $self, Duration pollInterval)
Specify the polling interval Awaitility will use for this await statement. final static ConditionFactory
withPollInterval(ConditionFactory $self, PollInterval pollInterval)
Specify the polling interval Awaitility will use for this await statement. final static ConditionFactory
ignoreExceptionsInstanceOf(ConditionFactory $self, KClass<out Throwable> exceptionType)
Instruct Awaitility to ignore exceptions instance of the supplied exceptionType type. 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. 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. 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. final static ConditionFactory
pollExecutorService(ConditionFactory $self, ExecutorService executorService)
Specify the executor service whose threads will be used to evaluate the poll condition in Awaitility. 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. final static Unit
untilTrue(ConditionFactory $self, AtomicBoolean atomicBoolean)
Await until a Atomic boolean becomes true. final static Unit
untilFalse(ConditionFactory $self, AtomicBoolean atomicBoolean)
Await until a Atomic boolean becomes false. final static <T extends Any> ConditionFactory
conditionEvaluationListener(ConditionFactory $self, ConditionEvaluationListener<T> conditionEvaluationListener)
Handle condition evaluation results each time evaluation of a condition occurs. -
-
Method Detail
-
getAwait
final ConditionFactory getAwait()
-
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
data
is defined as:data class Data(var state: String)
I.e. inside the scope of
has
theData
instance is used asthis
(see here for more info).- Parameters:
pred
- The predicate that determines whether or not the condition is fulfilled.
-
untilCallTo
final static <T extends Any> AwaitilityKtUntilFunCondition<T> untilCallTo(ConditionFactory $self, Function0<T> fn)
An extension function to
ConditionFactory
that 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.
-
untilNotNull
final static <T extends Any> T untilNotNull(ConditionFactory $self, Function0<T> fn)
An extension function to
ConditionFactory
that 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
.
-
untilNull
final static <T extends Any> Unit untilNull(ConditionFactory $self, Function0<T> fn)
An extension function to
ConditionFactory
that 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
.
-
until
final static Unit until(ConditionFactory $self, Function0<Boolean> fn)
An extension function to
ConditionFactory
that 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
-
untilAsserted
final static Unit untilAsserted(ConditionFactory $self, Function0<Unit> fn)
An extension function to
ConditionFactory
that 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.
-
atMost
final static ConditionFactory atMost(ConditionFactory $self, Duration duration)
Await at most
timeout
before throwing a timeout exception.- Parameters:
duration
- the duration
-
atLeast
final static ConditionFactory atLeast(ConditionFactory $self, Duration timeout)
Condition has to be evaluated not earlier than
timeout
before throwing a timeout exception.- Parameters:
timeout
- the timeout
-
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.
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
untilTrue
final static Unit untilTrue(ConditionFactory $self, AtomicBoolean atomicBoolean)
Await until a Atomic boolean becomes true.
- Parameters:
atomicBoolean
- the atomic variable
-
untilFalse
final static Unit untilFalse(ConditionFactory $self, AtomicBoolean atomicBoolean)
Await until a Atomic boolean becomes false.
- Parameters:
atomicBoolean
- the atomic variable
-
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
-
-
-
-