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 on
getTime(), consider using a mock of TimeProvider instead.-
Method Summary
Modifier and Type Method Description voidaddTime(TemporalAmount toAdd)Increases stored time by given amount.static FakeTimeProvidercreate(ZonedDateTime initialTime)Creates a fake time provider with given time.ZonedDateTimegetTime()Returns the current time of this time provider in UTC time zone.voidsetTime(ZonedDateTime time)Sets new time for this time provider.
-
Method Details
-
create
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
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
Increases stored time by given amount. -
getTime
Description copied from interface:TimeProviderReturns the current time of this time provider in UTC time zone.- Specified by:
getTimein interfaceTimeProvider
-