SPITimeService implements TimeService { @Override public Date getTime() { Date result = null; for (TimeService server : timeServices) { result = server.getTime(); if (!(server instanceof DefaultTimeService) && null != result) { return result; } } return result; }  @Override Date getTime();  }
@Test public void assertGetTime() { Optional<TimeServiceFixture> optional = getFixtureHook(); assertTrue(optional.isPresent()); Date date = new Date(); optional.get().setDate(date); Date time = timeService.getTime(); assertThat(date, is(time)); }
@Test public void assertGetTimeWithDefault() { Optional<TimeServiceFixture> optional = getFixtureHook(); assertTrue(optional.isPresent()); Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DATE, -1); Date date = calendar.getTime(); Date time = timeService.getTime(); assertTrue(time.after(date)); }