Class Wait

java.lang.Object
io.skodjob.testframe.wait.Wait

public class Wait extends Object
Wait utils
  • Method Details

    • until

      public static void until(String description, long pollIntervalMs, long timeoutMs, BooleanSupplier ready)
      For every poll (happening once each pollIntervalMs) checks if supplier ready is true. If yes, the wait is closed. Otherwise, waits another pollIntervalMs and tries again. Once the wait timeout (specified by timeoutMs is reached and supplier wasn't true until that time, throws WaitException.
      Parameters:
      description - information about on what we are waiting
      pollIntervalMs - poll interval in milliseconds
      timeoutMs - timeout specified in milliseconds
      ready - BooleanSupplier containing code, which should be executed each poll, verifying readiness of the particular thing
    • until

      public static void until(String description, long pollIntervalMs, long timeoutMs, BooleanSupplier ready, Runnable onTimeout)
      For every poll (happening once each pollIntervalMs) checks if supplier ready is true. If yes, the wait is closed. Otherwise, waits another pollIntervalMs and tries again. Once the wait timeout (specified by timeoutMs is reached and supplier wasn't true until that time, runs the onTimeout (f.e. print of logs, showing the actual value that was checked inside ready), and finally throws WaitException.
      Parameters:
      description - information about on what we are waiting
      pollIntervalMs - poll interval in milliseconds
      timeoutMs - timeout specified in milliseconds
      ready - BooleanSupplier containing code, which should be executed each poll, verifying readiness of the particular thing
      onTimeout - Runnable executed once timeout is reached and before the WaitException is thrown.
    • untilAsync

      public static CompletableFuture<Void> untilAsync(String description, long pollIntervalMs, long timeoutMs, BooleanSupplier ready)
      For every poll (happening once each pollIntervalMs) checks if supplier ready is true. If yes, the wait is closed. Otherwise, waits another pollIntervalMs and tries again. Once the wait timeout (specified by timeoutMs is reached and supplier wasn't true until that time, runs the onTimeout (f.e. print of logs, showing the actual value that was checked inside ready), and finally throws WaitException.
      Parameters:
      description - information about on what we are waiting
      pollIntervalMs - poll interval in milliseconds
      timeoutMs - timeout specified in milliseconds
      ready - BooleanSupplier containing code, which should be executed each poll, verifying readiness of the particular thing
      Returns:
      completable future for waiting