Class MockAsyncExec

java.lang.Object
org.apache.polaris.nosql.async.MockAsyncExec
All Implemented Interfaces:
org.apache.polaris.nosql.async.AsyncExec

public class MockAsyncExec extends Object implements org.apache.polaris.nosql.async.AsyncExec
An AsyncExec implementation used in tests that need to verify the interaction with AsyncExec. Execution of submitted tasks needs to be manually triggered by the tests that use this class.

This implementation is best used in combination with MutableMonotonicClock to allow assertions on scheduled/execution timestamps.

  • Constructor Details

    • MockAsyncExec

      public MockAsyncExec(org.apache.polaris.ids.api.MonotonicClock clock)
  • Method Details

    • tasks

      public List<MockAsyncExec.Task<?>> tasks()
    • nextReady

      public Optional<MockAsyncExec.Task<?>> nextReady()
    • nextReadyAt

      public Optional<MockAsyncExec.Task<?>> nextReadyAt(Instant at)
    • readyCount

      public long readyCount()
    • readyCount

      public long readyCount(Instant at)
    • readyCallables

      public List<MockAsyncExec.Task<?>> readyCallables()
    • schedulePeriodic

      public org.apache.polaris.nosql.async.Cancelable<Void> schedulePeriodic(Runnable runnable, Duration initialDelay, Duration delay)
      Specified by:
      schedulePeriodic in interface org.apache.polaris.nosql.async.AsyncExec
    • schedule

      public <R> org.apache.polaris.nosql.async.Cancelable<R> schedule(Callable<R> callable, Duration delay)
      Specified by:
      schedule in interface org.apache.polaris.nosql.async.AsyncExec