java.lang.Object
java.time.Clock
io.axoniq.framework.workflow.runtime.test.utils.TestClock
All Implemented Interfaces:
InstantSource

@Internal public class TestClock extends Clock
Mutable clock for fixture-controlled workflow time.
Since:
5.4.0
Author:
Simon Zambrovski
  • Constructor Details

    • TestClock

      public TestClock()
      Creates a mutable clock.
    • TestClock

      public TestClock(Instant instant, ZoneId zone)
      Creates a mutable clock.
      Parameters:
      instant - initial instant
      zone - time zone
  • Method Details

    • getZone

      public ZoneId getZone()
      Returns the time zone used by this clock.
      Specified by:
      getZone in class Clock
      Returns:
      clock time zone
    • withZone

      public Clock withZone(ZoneId zone)
      Creates a mutable clock with the same instant and a different time zone.
      Specified by:
      withZone in interface InstantSource
      Specified by:
      withZone in class Clock
      Parameters:
      zone - time zone for the returned clock
      Returns:
      mutable clock using the requested zone
    • instant

      public Instant instant()
      Returns the current fixture-controlled instant.
      Specified by:
      instant in interface InstantSource
      Specified by:
      instant in class Clock
      Returns:
      current instant
    • advanceBy

      public Instant advanceBy(Duration duration)
      Advance the clock.
      Parameters:
      duration - duration to advance
      Returns:
      new instant