Class AwaitilityKt

  • All Implemented Interfaces:

    
    public final class AwaitilityKt
    
                        
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private final static ConditionFactory await
      private final static ConditionFactory forever
      private final static ConditionFactory with
      private final static ConditionFactory given
      private final static ConditionFactory then
      private final static ConditionFactory and
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final ConditionFactory getAwait()
      final ConditionFactory getForever()
      final ConditionFactory getWith()
      final ConditionFactory getGiven()
      final ConditionFactory getThen()
      final ConditionFactory getAnd()
      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:
      await untilCallTo { myRepository.count() } matches { count -> count == 1 }
      Note that await is a getter that needs to imported from 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:
      val data = await untilNotNull { myDataRepository.findById("id") }
      Note that await is a getter that needs to imported from 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:
      await untilNull { myDataRepository.findById("id") }
      Note that await is a getter that needs to imported from 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:
      await until { myRepository.count() == 1 }
      Note that await is a getter that needs to imported from 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:
       await withPollInterval ONE_HUNDRED_MILLISECONDS ignoreException IllegalArgumentException::class untilAsserted  {
           assertThat(fakeRepository.value).isEqualTo(1)
      }
      I.e.
      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.
      final static ConditionFactory logging(ConditionFactory $self, Function1<String, Unit> logPrinter) Logging condition evaluation results each time evaluation of a condition occurs to chosen consumer.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • getAwait

         final ConditionFactory getAwait()
        Returns:

        A new ConditionFactory instance

      • 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 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).

        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 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.
        Since:

        3.1.1

      • 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.

        Since:

        3.1.4

      • 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.

        Since:

        3.1.5

      • 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
        Since:

        3.1.2

      • 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.
        Returns:

        the condition factory

        Since:

        3.1.2

      • atMost

         final static ConditionFactory atMost(ConditionFactory $self, Duration duration)

        Await at most timeout before 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 timeout before 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

      • logging

         final static ConditionFactory logging(ConditionFactory $self, Function1<String, Unit> logPrinter)

        Logging condition evaluation results each time evaluation of a condition occurs to chosen consumer.

        Returns:

        the condition factory

        Since:

        4.2.1