@Test public void testSetTimer() { when(this.env.getCurrentDateTime()).thenReturn(ZonedDateTime.of(2018, 2, 1, 4, 21, 55, 987, ZoneId.of("Z"))); LocalDateTime timerTime = LocalDateTime.of(2018, 2, 1, 4, 21, 55); Timer t = new Timer(1, timerTime, null, true); this.tlogic.setTimer(timerTime); verify(this.scheduler).schedule(ArgumentMatchers.any(Runnable.class), ArgumentMatchers.any(Instant.class)); assertThat(this.tlogic.setTimer(timerTime).toString(), is(t.toString())); }
public Timer setTimer(LocalDateTime timerTime) { int id = searchTimerId(); Timer timer = new Timer(id, timerTime, null, true); this.timerStorage.save(timer); Runnable timerRunnable = createTimerRunnable(timer); ZonedDateTime with = this.environment.getCurrentDateTime().with(timer.getTimerTime()); if (with.isBefore(this.environment.getCurrentDateTime())) { with = with.plusDays(1); } this.taskScheduler.schedule(timerRunnable, with.toInstant()); return timer; }
TimerLogic implements RunnableService { public Timer setTimer(LocalDateTime timerTime) { int id = searchTimerId(); Timer timer = new Timer(id, timerTime, null, true); this.timerStorage.save(timer); Runnable timerRunnable = createTimerRunnable(timer); ZonedDateTime with = this.environment.getCurrentDateTime().with(timer.getTimerTime()); if (with.isBefore(this.environment.getCurrentDateTime())) { with = with.plusDays(1); } this.taskScheduler.schedule(timerRunnable, with.toInstant()); return timer; } }
TimerLogic implements RunnableService { public Timer setTimer(LocalDateTime timerTime) { int id = searchTimerId(); Timer timer = new Timer(id, timerTime, null, true); this.timerStorage.save(timer); Runnable timerRunnable = createTimerRunnable(timer); ZonedDateTime with = this.environment.getCurrentDateTime().with(timer.getTimerTime()); if (with.isBefore(this.environment.getCurrentDateTime())) { with = with.plusDays(1); } this.taskScheduler.schedule(timerRunnable, with.toInstant()); return timer; }  }
TimerLogic implements RunnableService { public Timer setTimer(LocalDateTime timerTime) { int id = searchTimerId(); Timer timer = new Timer(id, timerTime, null, true); this.timerStorage.save(timer); Runnable timerRunnable = createTimerRunnable(timer); ZonedDateTime with = this.environment.getCurrentDateTime().with(timer.getTimerTime()); if (with.isBefore(this.environment.getCurrentDateTime())) { with = with.plusDays(1); } this.taskScheduler.schedule(timerRunnable, with.toInstant()); return timer; }  Runnable createTimerRunnable(Timer timer); Timer setTimer(LocalDateTime timerTime); int searchTimerId(); String deleteAllTimers(); String deleteTimer(int timerNumber); String stopRinging(); Timer getTimer(int timerNumber); List<Timer> getAllTimers(); Timer pauseTimer(Timer timer); Timer reactivateTimer(Timer timer); @Override void start(); @Override void stop(); }
TimerLogic implements RunnableService { public Timer setTimer(LocalDateTime timerTime) { int id = searchTimerId(); Timer timer = new Timer(id, timerTime, null, true); this.timerStorage.save(timer); Runnable timerRunnable = createTimerRunnable(timer); ZonedDateTime with = this.environment.getCurrentDateTime().with(timer.getTimerTime()); if (with.isBefore(this.environment.getCurrentDateTime())) { with = with.plusDays(1); } this.taskScheduler.schedule(timerRunnable, with.toInstant()); return timer; }  Runnable createTimerRunnable(Timer timer); Timer setTimer(LocalDateTime timerTime); int searchTimerId(); String deleteAllTimers(); String deleteTimer(int timerNumber); String stopRinging(); Timer getTimer(int timerNumber); List<Timer> getAllTimers(); Timer pauseTimer(Timer timer); Timer reactivateTimer(Timer timer); @Override void start(); @Override void stop();  }