public class AwaitilityKt
Modifier and Type | Method and Description |
---|---|
static org.awaitility.core.ConditionFactory |
atLeast(org.awaitility.core.ConditionFactory $receiver,
java.time.Duration timeout)
Condition has to be evaluated not earlier than
timeout before throwing a timeout exception. |
static org.awaitility.core.ConditionFactory |
atMost(org.awaitility.core.ConditionFactory $receiver,
java.time.Duration duration)
Await at most
timeout before throwing a timeout exception. |
static org.awaitility.core.ConditionFactory |
getAwait()
This is typically the starting point of the Kotlin "DSL". Allows you to write
await instead of await() . For example: |
static <T> T |
has(AwaitilityKtUntilFunCondition<? extends T> $receiver,
kotlin.jvm.functions.Function1<? super T,java.lang.Boolean> pred)
Infix function that allows us to write the predicate on right-hand side of
AwaitilityKt.has without using a dot.
This allows expressions such as: |
static org.awaitility.core.ConditionFactory |
ignoreException(org.awaitility.core.ConditionFactory $receiver,
kotlin.reflect.KClass<? extends java.lang.Throwable> exceptionType)
Instruct Awaitility to ignore a specific exception and no subclasses of this exception.
Exceptions will be treated as evaluating to false.
This is useful in situations where the evaluated conditions may temporarily throw exceptions.
|
static org.awaitility.core.ConditionFactory |
ignoreExceptionsInstanceOf(org.awaitility.core.ConditionFactory $receiver,
kotlin.reflect.KClass<? extends java.lang.Throwable> exceptionType)
Instruct Awaitility to ignore exceptions instance of the supplied exceptionType type.
Exceptions will be treated as evaluating to false.
This is useful in situations where the evaluated conditions may temporarily throw exceptions.
|
static org.awaitility.core.ConditionFactory |
ignoreExceptionsMatching(org.awaitility.core.ConditionFactory $receiver,
org.hamcrest.Matcher<? super java.lang.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. |
static org.awaitility.core.ConditionFactory |
ignoreExceptionsMatching(org.awaitility.core.ConditionFactory $receiver,
kotlin.jvm.functions.Function1<? super java.lang.Throwable,java.lang.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. |
static <T> T |
matches(AwaitilityKtUntilFunCondition<? extends T> $receiver,
kotlin.jvm.functions.Function1<? super T,java.lang.Boolean> pred)
Infix function which is what allows us to write the predicate on right-hand side of
AwaitilityKt.matches without using a dot. |
static org.awaitility.core.ConditionFactory |
pollExecutorService(org.awaitility.core.ConditionFactory $receiver,
java.util.concurrent.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!
|
static org.awaitility.core.ConditionFactory |
pollThread(org.awaitility.core.ConditionFactory $receiver,
kotlin.jvm.functions.Function1<? super java.lang.Runnable,? extends java.lang.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.
|
static void |
until(org.awaitility.core.ConditionFactory $receiver,
kotlin.jvm.functions.Function0<java.lang.Boolean> fn)
An extension function to
ConditionFactory that allows you do write conditions such as: |
static void |
untilAsserted(org.awaitility.core.ConditionFactory $receiver,
kotlin.jvm.functions.Function0<kotlin.Unit> fn)
An extension function to
ConditionFactory that allows you do write conditions such as: |
static <T> AwaitilityKtUntilFunCondition<T> |
untilCallTo(org.awaitility.core.ConditionFactory $receiver,
kotlin.jvm.functions.Function0<? extends T> fn)
An extension function to
ConditionFactory that allows you do write conditions such as: |
static void |
untilFalse(org.awaitility.core.ConditionFactory $receiver,
java.util.concurrent.atomic.AtomicBoolean atomicBoolean)
Await until a Atomic boolean becomes false.
|
static <T> T |
untilNotNull(org.awaitility.core.ConditionFactory $receiver,
kotlin.jvm.functions.Function0<? extends T> fn)
An extension function to
ConditionFactory that allows you do write conditions such as: |
static <T> void |
untilNull(org.awaitility.core.ConditionFactory $receiver,
kotlin.jvm.functions.Function0<? extends T> fn)
An extension function to
ConditionFactory that allows you do write conditions such as: |
static void |
untilTrue(org.awaitility.core.ConditionFactory $receiver,
java.util.concurrent.atomic.AtomicBoolean atomicBoolean)
Await until a Atomic boolean becomes true.
|
static org.awaitility.core.ConditionFactory |
withAlias(org.awaitility.core.ConditionFactory $receiver,
java.lang.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 alias will be displayed indicating
which await statement that failed.
|
static org.awaitility.core.ConditionFactory |
withPollDelay(org.awaitility.core.ConditionFactory $receiver,
java.time.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.
|
static org.awaitility.core.ConditionFactory |
withPollInterval(org.awaitility.core.ConditionFactory $receiver,
java.time.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.
|
static org.awaitility.core.ConditionFactory |
withPollInterval(org.awaitility.core.ConditionFactory $receiver,
org.awaitility.pollinterval.PollInterval pollInterval)
Specify the polling interval Awaitility will use for this await
statement. For example org.awaitility.pollinterval.FibonacciPollInterval.fibonacci.
|
public static org.awaitility.core.ConditionFactory getAwait()
This is typically the starting point of the Kotlin "DSL". Allows you to write await
instead of await()
. For example:
await until { myRepository.count() == 2 }
public static <T> T matches(AwaitilityKtUntilFunCondition<? extends T> $receiver, kotlin.jvm.functions.Function1<? super T,java.lang.Boolean> pred)
Infix function which is what allows us to write the predicate on right-hand side of AwaitilityKt.matches
without using a dot.
pred
- The predicate that determines whether or not the condition is fulfilled.AwaitilityKt.matches
public static <T> T has(AwaitilityKtUntilFunCondition<? extends T> $receiver, kotlin.jvm.functions.Function1<? super T,java.lang.Boolean> pred)
Infix function that allows us to write the predicate on right-hand side of AwaitilityKt.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
the Data
instance is used as this
(see here for more info).
pred
- The predicate that determines whether or not the condition is fulfilled.AwaitilityKt.has
,
herepublic static <T> AwaitilityKtUntilFunCondition<T> untilCallTo(org.awaitility.core.ConditionFactory $receiver, kotlin.jvm.functions.Function0<? extends 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 AwaitilityKt.getAwait
is a getter that needs to imported from org.awaitility.kotlin
.
fn
- A function that returns the value that will be evaluated by the predicate in AwaitilityKt.matches
.AwaitilityKt.getAwait
public static <T> T untilNotNull(org.awaitility.core.ConditionFactory $receiver, kotlin.jvm.functions.Function0<? extends T> fn)
An extension function to ConditionFactory
that allows you do write conditions such as:
val data = await untilNotNull { myDataRepository.findById("id") }
Note that AwaitilityKt.getAwait
is a getter that needs to imported from org.awaitility.kotlin
.
AwaitilityKt.getAwait
public static <T> void untilNull(org.awaitility.core.ConditionFactory $receiver, kotlin.jvm.functions.Function0<? extends T> fn)
An extension function to ConditionFactory
that allows you do write conditions such as:
await untilNull { myDataRepository.findById("id") }
Note that AwaitilityKt.getAwait
is a getter that needs to imported from org.awaitility.kotlin
.
AwaitilityKt.getAwait
public static void until(org.awaitility.core.ConditionFactory $receiver, kotlin.jvm.functions.Function0<java.lang.Boolean> fn)
An extension function to ConditionFactory
that allows you do write conditions such as:
await until { myRepository.count() == 1 }
Note that AwaitilityKt.getAwait
is a getter that needs to imported from org.awaitility.kotlin
.
fn
- The function to evaluateAwaitilityKt.getAwait
public static void untilAsserted(org.awaitility.core.ConditionFactory $receiver, kotlin.jvm.functions.Function0<kotlin.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 AwaitilityKt.untilAsserted
to integrate Awaitility with an assertion library of choice.
Note that AwaitilityKt.getAwait
is a getter that needs to imported from org.awaitility.kotlin
fn
- A function that returns the value that will be evaluated by the predicate in AwaitilityKt.matches
.AwaitilityKt.untilAsserted
,
AwaitilityKt.getAwait
public static org.awaitility.core.ConditionFactory atMost(org.awaitility.core.ConditionFactory $receiver, java.time.Duration duration)
Await at most timeout
before throwing a timeout exception.
duration
- the durationpublic static org.awaitility.core.ConditionFactory atLeast(org.awaitility.core.ConditionFactory $receiver, java.time.Duration timeout)
Condition has to be evaluated not earlier than timeout
before throwing a timeout exception.
timeout
- the timeoutpublic static org.awaitility.core.ConditionFactory withAlias(org.awaitility.core.ConditionFactory $receiver, java.lang.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 alias will be displayed indicating which await statement that failed.
alias
- the alias that will be shown if the await timeouts.public static org.awaitility.core.ConditionFactory withPollDelay(org.awaitility.core.ConditionFactory $receiver, java.time.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.
pollDelay
- the poll delaypublic static org.awaitility.core.ConditionFactory withPollInterval(org.awaitility.core.ConditionFactory $receiver, java.time.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.
pollInterval
- the poll intervalpublic static org.awaitility.core.ConditionFactory withPollInterval(org.awaitility.core.ConditionFactory $receiver, org.awaitility.pollinterval.PollInterval pollInterval)
Specify the polling interval Awaitility will use for this await statement. For example org.awaitility.pollinterval.FibonacciPollInterval.fibonacci.
pollInterval
- the poll intervalpublic static org.awaitility.core.ConditionFactory ignoreExceptionsInstanceOf(org.awaitility.core.ConditionFactory $receiver, kotlin.reflect.KClass<? extends java.lang.Throwable> exceptionType)
Instruct Awaitility to ignore exceptions instance of the supplied exceptionType type. Exceptions will be treated as evaluating to false. This is useful in situations where the evaluated conditions may temporarily throw exceptions.
exceptionType
- The exception type (hierarchy) to ignorepublic static org.awaitility.core.ConditionFactory ignoreException(org.awaitility.core.ConditionFactory $receiver, kotlin.reflect.KClass<? extends java.lang.Throwable> exceptionType)
Instruct Awaitility to ignore a specific exception and no subclasses of this exception. Exceptions will be treated as evaluating to false. This is useful in situations where the evaluated conditions may temporarily throw exceptions.
exceptionType
- The exception type to ignorepublic static org.awaitility.core.ConditionFactory ignoreExceptionsMatching(org.awaitility.core.ConditionFactory $receiver, org.hamcrest.Matcher<? super java.lang.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.
matcher
- The Hamcrest matcherpublic static org.awaitility.core.ConditionFactory ignoreExceptionsMatching(org.awaitility.core.ConditionFactory $receiver, kotlin.jvm.functions.Function1<? super java.lang.Throwable,java.lang.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.
matcher
- The predicatepublic static org.awaitility.core.ConditionFactory pollExecutorService(org.awaitility.core.ConditionFactory $receiver, java.util.concurrent.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.
executorService
- The executor service that Awaitility will use when polling condition evaluationspublic static org.awaitility.core.ConditionFactory pollThread(org.awaitility.core.ConditionFactory $receiver, kotlin.jvm.functions.Function1<? super java.lang.Runnable,? extends java.lang.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.
threadSupplier
- A supplier of the thread that Awaitility will use when pollingpublic static void untilTrue(org.awaitility.core.ConditionFactory $receiver, java.util.concurrent.atomic.AtomicBoolean atomicBoolean)
Await until a Atomic boolean becomes true.
atomicBoolean
- the atomic variablepublic static void untilFalse(org.awaitility.core.ConditionFactory $receiver, java.util.concurrent.atomic.AtomicBoolean atomicBoolean)
Await until a Atomic boolean becomes false.
atomicBoolean
- the atomic variable