@Test protected void testEditAlarmNotFound() { when(this.alarmStorage.getAll()).thenReturn(createAlarms(3, true)); this.alarmNumber = 4; assertThrows(NoSuchElementException.class, () -> this.acl.editAlarm(this.alarmNumber, 1, 12, 12)); }
protected Alarm editAlarm(int alarmNumber, int tomorrow, int hour, int minute) { if (Alarm.timeValid(hour, minute)) { tomorrowCheck(tomorrow, hour, minute); Alarm a = getAlarm(alarmNumber); a.setAlarmTime(this.alarmTime); this.alarmStorage.save(a); Runnable alarmRunnable = createAlarmRunnable(alarmNumber); ZonedDateTime with = this.environment.getCurrentDateTime().with(a.getAlarmTime()); if (with.isBefore(this.environment.getCurrentDateTime())) { with = with.plusDays(1); } this.taskScheduler.schedule(alarmRunnable, with.toInstant()); return a; } throw new NoSuchElementException(); }
AlarmClockLogic implements RunnableService { protected Alarm editAlarm(int alarmNumber, int tomorrow, int hour, int minute) { if (Alarm.timeValid(hour, minute)) { tomorrowCheck(tomorrow, hour, minute); Alarm a = getAlarm(alarmNumber); a.setAlarmTime(this.alarmTime); this.alarmStorage.save(a); Runnable alarmRunnable = createAlarmRunnable(alarmNumber); ZonedDateTime with = this.environment.getCurrentDateTime().with(a.getAlarmTime()); if (with.isBefore(this.environment.getCurrentDateTime())) { with = with.plusDays(1); } this.taskScheduler.schedule(alarmRunnable, with.toInstant()); return a; } throw new NoSuchElementException(); } }
AlarmClockLogic implements RunnableService { protected Alarm editAlarm(int alarmNumber, int tomorrow, int hour, int minute) { if (Alarm.timeValid(hour, minute)) { tomorrowCheck(tomorrow, hour, minute); Alarm a = getAlarm(alarmNumber); a.setAlarmTime(this.alarmTime); this.alarmStorage.save(a); Runnable alarmRunnable = createAlarmRunnable(alarmNumber); ZonedDateTime with = this.environment.getCurrentDateTime().with(a.getAlarmTime()); if (with.isBefore(this.environment.getCurrentDateTime())) { with = with.plusDays(1); } this.taskScheduler.schedule(alarmRunnable, with.toInstant()); return a; } throw new NoSuchElementException(); }  }
AlarmClockLogic implements RunnableService { protected Alarm editAlarm(int alarmNumber, int tomorrow, int hour, int minute) { if (Alarm.timeValid(hour, minute)) { tomorrowCheck(tomorrow, hour, minute); Alarm a = getAlarm(alarmNumber); a.setAlarmTime(this.alarmTime); this.alarmStorage.save(a); Runnable alarmRunnable = createAlarmRunnable(alarmNumber); ZonedDateTime with = this.environment.getCurrentDateTime().with(a.getAlarmTime()); if (with.isBefore(this.environment.getCurrentDateTime())) { with = with.plusDays(1); } this.taskScheduler.schedule(alarmRunnable, with.toInstant()); return a; } throw new NoSuchElementException(); }  String stopRinging(); @Override void start(); @Override void stop(); }
AlarmClockLogic implements RunnableService { protected Alarm editAlarm(int alarmNumber, int tomorrow, int hour, int minute) { if (Alarm.timeValid(hour, minute)) { tomorrowCheck(tomorrow, hour, minute); Alarm a = getAlarm(alarmNumber); a.setAlarmTime(this.alarmTime); this.alarmStorage.save(a); Runnable alarmRunnable = createAlarmRunnable(alarmNumber); ZonedDateTime with = this.environment.getCurrentDateTime().with(a.getAlarmTime()); if (with.isBefore(this.environment.getCurrentDateTime())) { with = with.plusDays(1); } this.taskScheduler.schedule(alarmRunnable, with.toInstant()); return a; } throw new NoSuchElementException(); }  String stopRinging(); @Override void start(); @Override void stop();  }