@Test public void testSetAlarm() { when(this.env.getCurrentDateTime()).thenReturn(ZonedDateTime.of(2018, 2, 1, 4, 21, 55, 987, ZoneId.of("Z"))); this.acl.setAlarm(1, 4, 20); verify(this.scheduler).schedule(ArgumentMatchers.any(Runnable.class), ArgumentMatchers.any(Instant.class)); }
protected Alarm setAlarm(int tomorrow, int hour, int minute) { if (Alarm.timeValid(hour, minute)) { tomorrowCheck(tomorrow, hour, minute); int id = searchAlarmId(); Alarm alarm = new Alarm(id, this.alarmTime, true); this.alarmStorage.save(alarm); Runnable alarmRunnable = createAlarmRunnable(id); ZonedDateTime with = this.environment.getCurrentDateTime().with(alarm.getAlarmTime()); if (with.isBefore(this.environment.getCurrentDateTime())) { with = with.plusDays(1); } this.taskScheduler.schedule(alarmRunnable, with.toInstant()); return alarm; } throw new IllegalArgumentException(); }
AlarmClockLogic implements RunnableService { protected Alarm setAlarm(int tomorrow, int hour, int minute) { if (Alarm.timeValid(hour, minute)) { tomorrowCheck(tomorrow, hour, minute); int id = searchAlarmId(); Alarm alarm = new Alarm(id, this.alarmTime, true); this.alarmStorage.save(alarm); Runnable alarmRunnable = createAlarmRunnable(id); ZonedDateTime with = this.environment.getCurrentDateTime().with(alarm.getAlarmTime()); if (with.isBefore(this.environment.getCurrentDateTime())) { with = with.plusDays(1); } this.taskScheduler.schedule(alarmRunnable, with.toInstant()); return alarm; } throw new IllegalArgumentException(); } }
AlarmClockLogic implements RunnableService { protected Alarm setAlarm(int tomorrow, int hour, int minute) { if (Alarm.timeValid(hour, minute)) { tomorrowCheck(tomorrow, hour, minute); int id = searchAlarmId(); Alarm alarm = new Alarm(id, this.alarmTime, true); this.alarmStorage.save(alarm); Runnable alarmRunnable = createAlarmRunnable(id); ZonedDateTime with = this.environment.getCurrentDateTime().with(alarm.getAlarmTime()); if (with.isBefore(this.environment.getCurrentDateTime())) { with = with.plusDays(1); } this.taskScheduler.schedule(alarmRunnable, with.toInstant()); return alarm; } throw new IllegalArgumentException(); }  }
AlarmClockLogic implements RunnableService { protected Alarm setAlarm(int tomorrow, int hour, int minute) { if (Alarm.timeValid(hour, minute)) { tomorrowCheck(tomorrow, hour, minute); int id = searchAlarmId(); Alarm alarm = new Alarm(id, this.alarmTime, true); this.alarmStorage.save(alarm); Runnable alarmRunnable = createAlarmRunnable(id); ZonedDateTime with = this.environment.getCurrentDateTime().with(alarm.getAlarmTime()); if (with.isBefore(this.environment.getCurrentDateTime())) { with = with.plusDays(1); } this.taskScheduler.schedule(alarmRunnable, with.toInstant()); return alarm; } throw new IllegalArgumentException(); }  String stopRinging(); @Override void start(); @Override void stop(); }
AlarmClockLogic implements RunnableService { protected Alarm setAlarm(int tomorrow, int hour, int minute) { if (Alarm.timeValid(hour, minute)) { tomorrowCheck(tomorrow, hour, minute); int id = searchAlarmId(); Alarm alarm = new Alarm(id, this.alarmTime, true); this.alarmStorage.save(alarm); Runnable alarmRunnable = createAlarmRunnable(id); ZonedDateTime with = this.environment.getCurrentDateTime().with(alarm.getAlarmTime()); if (with.isBefore(this.environment.getCurrentDateTime())) { with = with.plusDays(1); } this.taskScheduler.schedule(alarmRunnable, with.toInstant()); return alarm; } throw new IllegalArgumentException(); }  String stopRinging(); @Override void start(); @Override void stop();  }