DayTimer extends TimerTask { public void startTimer() { final Calendar cal = Calendar.getInstance(); cal.add(Calendar.HOUR_OF_DAY, 1); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); timer.scheduleAtFixedRate(this, new Date(cal.getTimeInMillis()), TIMER_INTERVAL); } DayTimer(final UserInterface ui); void startTimer(); void stopTimer(); @Override void run();  }
@Test public void startTimerShouldScheduleAtFixedRate() { dayTimer.startTimer(); verify(timer).scheduleAtFixedRate(eq(dayTimer), any(Date.class), eq(1000L * 60L * 60L)); }