Java8RandomShortApi { public static LocalDateTime localDateTime() { return new RandomDate().localDateTime(); }  static Instant instant(); static List<Instant> instants(int n); static LocalDateTime localDateTime(); static List<LocalDateTime> localDateTimes(int nOfTimes); static ZonedDateTime zonedDateTime(); static List<ZonedDateTime> zonedDateTimes(int nOfTimes); static OffsetDateTime offsetDateTime(); static List<OffsetDateTime> offsetDateTimes(int nOfTimes); static LocalDate localDate(); static List<LocalDate> localDates(int nOfTimes);  }
@Test void beforeNowIsActuallyBefore() { assertThat(beforeNow().localDateTime(), lessThanOrEqualTo(LocalDateTime.now())); }
@Test void afterNowIsActuallyAfter() { assertThat(afterNow().localDateTime(), greaterThanOrEqualTo(LocalDateTime.now())); }
@Test void sinceIsReturningDatesTillNow() { LocalDateTime secondAgo = secondAgo(); assertThat(since(secondAgo).localDateTime(), lessThanOrEqualTo(LocalDateTime.now())); assertThat(since(secondAgo).localDateTime(), greaterThanOrEqualTo(secondAgo)); }
@Test void betweenForLocalDate() { assertThat(between(yearsAgo(2), startOfMonth()).localDateTime(), greaterThanOrEqualTo(yearsAgo(2).minusMinutes(1))); assertThat(between(yearsAgo(2), startOfMonth()).localDateTime(), lessThan(now())); }