Class TestTimeService

java.lang.Object
com.reallifedeveloper.common.domain.TestTimeService
All Implemented Interfaces:
TimeService

public class TestTimeService extends Object implements TimeService
An implementation of the TimeService interface useful for testing.

The now() method returns a predefined set of dates.

Author:
RealLifeDeveloper
  • Field Details

    • DATE_TIME_FORMAT

      public static final String DATE_TIME_FORMAT
      The format used when parsing date and time strings ("yyyy-MM-dd HH:mm:ssX").
      See Also:
  • Constructor Details

    • TestTimeService

      public TestTimeService()
  • Method Details

    • now

      public ZonedDateTime now()

      This method returns the DateTimes set using the setDateTimes(String...) method. If it is called more times than there are test dates defined, it starts over again from the first test date.

      Specified by:
      now in interface TimeService
    • dateTimes

      public List<ZonedDateTime> dateTimes()
      Gives the list of dates that are returned by this service.
      Returns:
      the list of dates returned by this service
    • setDateTimes

      public void setDateTimes(ZonedDateTime... dateTimes)
      Sets the DateTimes returned from the now() method.
      Parameters:
      dateTimes - the dates the now() method should return
    • setDateTimes

      public void setDateTimes(String... dateTimeStrings)
      Sets the DateTimes returned from the now() method.
      Parameters:
      dateTimeStrings - the dates the now() method should return, on the format "yyyy-MM-dd HH:mm:ssX"