### Question:
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();  }### Answer:
@Test protected void testEditAlarm() { List<Alarm> returnedAlarms = createAlarms(3, true); when(this.alarmStorage.getAll()).thenReturn(returnedAlarms); this.alarmNumber = 2; Alarm a = new Alarm(this.alarmNumber, LocalDateTime.of(LocalDateTime.now().getYear(), LocalDateTime.now().getMonthValue(), LocalDateTime.now().getDayOfMonth(), 12, 12), true); 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)); assertThat(this.acl.editAlarm(this.alarmNumber, -1, 12, 12), is(a)); }
@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)); }