Package com.exonum.binding.testkit
Class FakeTimeProvider
- java.lang.Object
-
- com.exonum.binding.testkit.FakeTimeProvider
-
- All Implemented Interfaces:
TimeProvider
public class FakeTimeProvider extends 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 ongetTime()
, consider using a mock of TimeProvider instead.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTime(TemporalAmount toAdd)
Increases stored time by given amount.static FakeTimeProvider
create(ZonedDateTime initialTime)
Creates a fake time provider with given time.ZonedDateTime
getTime()
Returns the current time of this time provider in UTC time zone.void
setTime(ZonedDateTime time)
Sets new time for this time provider.
-
-
-
Method Detail
-
create
public static FakeTimeProvider create(ZonedDateTime initialTime)
Creates a fake time provider with given time. Note that time should be in UTC time zone.- Throws:
IllegalArgumentException
- if value has time zone other than UTC
-
setTime
public void setTime(ZonedDateTime time)
Sets new time for this time provider. Note that time should be in UTC time zone.- Throws:
IllegalArgumentException
- if value has time zone other than UTC
-
addTime
public void addTime(TemporalAmount toAdd)
Increases stored time by given amount.
-
getTime
public ZonedDateTime getTime()
Description copied from interface:TimeProvider
Returns the current time of this time provider in UTC time zone.- Specified by:
getTime
in interfaceTimeProvider
-
-