Class FakeTimeProvider

java.lang.Object
com.exonum.binding.testkit.FakeTimeProvider
All Implemented Interfaces:
TimeProvider

public class FakeTimeProvider
extends java.lang.Object
implements TimeProvider
Fake time provider for service testing. Allows to manually manipulate time that is returned by TestKit time service. If you need to set results of different consecutive calls on getTime(), consider using a mock of TimeProvider instead.
  • Method Summary

    Modifier and Type Method Description
    void addTime​(java.time.temporal.TemporalAmount toAdd)
    Increases stored time by given amount.
    static FakeTimeProvider create​(java.time.ZonedDateTime initialTime)
    Creates a fake time provider with given time.
    java.time.ZonedDateTime getTime()
    Returns the current time of this time provider in UTC time zone.
    void setTime​(java.time.ZonedDateTime time)
    Sets new time for this time provider.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • create

      public static FakeTimeProvider create​(java.time.ZonedDateTime initialTime)
      Creates a fake time provider with given time. Note that time should be in UTC time zone.
      Throws:
      java.lang.IllegalArgumentException - if value has time zone other than UTC
    • setTime

      public void setTime​(java.time.ZonedDateTime time)
      Sets new time for this time provider. Note that time should be in UTC time zone.
      Throws:
      java.lang.IllegalArgumentException - if value has time zone other than UTC
    • addTime

      public void addTime​(java.time.temporal.TemporalAmount toAdd)
      Increases stored time by given amount.
    • getTime

      public java.time.ZonedDateTime getTime()
      Description copied from interface: TimeProvider
      Returns the current time of this time provider in UTC time zone.
      Specified by:
      getTime in interface TimeProvider