Skip to content

com.hypercubetools.timeslip / TimeSlip

TimeSlip

class TimeSlip :Clock

A concrete Clock implementation that is configurable and alterable for the purposes of reproducible tests.

Types

Name Summary
SequenceBuilder class SequenceBuilder
Builder for a TimeSlip instance backed by a sequence of Instants.

Functions

Name Summary
done fun done():Unit
Invalidate the clock.
getZone fun getZone():ZoneId
Gets the time-zone being used to create dates and times.
instant fun instant():Instant
Gets the current instant of the clock.
moveTo fun moveTo(newInstant:Instant):Unit
Changes the clock to the given instant.
tick fun tick(delta:Duration= ONE_SECOND):Unit
Move the clock forward in time.
withZone fun withZone(newZone:ZoneId):Clock
Returns a copy of this clock with a different time-zone.

Companion Object Functions

Name Summary
at fun at(initialInstant:Instant, zone:ZoneId= DEFAULT_ZONE):TimeSlip
Create an instance that starts at a given time and won't move unless moveTo or tick are called.
noCall fun noCall():TimeSlip
Create an instance that will throw IllegalStateException whenever Clock methods are called.
sequence fun sequence(body:TimeSlip.SequenceBuilder.() ->Unit):TimeSlip
Create a TimeSlip instance backed by a sequence of Instants.
sequenceBuilder fun sequenceBuilder():TimeSlip.SequenceBuilder
Create a builder for a TimeSlip instance backed by a sequence of Instants.
startAt fun startAt(initialInstant:Instant, zone:ZoneId= DEFAULT_ZONE, tickAmount:Duration= ONE_SECOND):TimeSlip
Create an instance that starts at a given time, but moves forward by a constant amount each time the current time is requested.fun startAt(initialInstant:Instant, zone:ZoneId= DEFAULT_ZONE, tickForward:TickForward):TimeSlip
Create an instance that starts at a given time, but changes based on a given function each time the current time is requested.