@Test protected void testActivateAlarmNotFound() { when(this.alarmStorage.getAll()).thenReturn(createAlarms(3, true)); this.alarmNumber = 4; assertThrows(NoSuchElementException.class, () -> this.acl.activateAlarm(this.alarmNumber)); }
protected String activateAlarm(int alarmNumber) { Alarm a = getAlarm(alarmNumber); if (!a.isActive()) { a.setActive(true); this.alarmStorage.save(a); return this.alarmS + a.getId() + " activated"; } return this.alarmS + alarmNumber + " is already active"; }
AlarmClockLogic implements RunnableService { protected String activateAlarm(int alarmNumber) { Alarm a = getAlarm(alarmNumber); if (!a.isActive()) { a.setActive(true); this.alarmStorage.save(a); return this.alarmS + a.getId() + " activated"; } return this.alarmS + alarmNumber + " is already active"; } }
AlarmClockLogic implements RunnableService { protected String activateAlarm(int alarmNumber) { Alarm a = getAlarm(alarmNumber); if (!a.isActive()) { a.setActive(true); this.alarmStorage.save(a); return this.alarmS + a.getId() + " activated"; } return this.alarmS + alarmNumber + " is already active"; }  }
AlarmClockLogic implements RunnableService { protected String activateAlarm(int alarmNumber) { Alarm a = getAlarm(alarmNumber); if (!a.isActive()) { a.setActive(true); this.alarmStorage.save(a); return this.alarmS + a.getId() + " activated"; } return this.alarmS + alarmNumber + " is already active"; }  String stopRinging(); @Override void start(); @Override void stop(); }
AlarmClockLogic implements RunnableService { protected String activateAlarm(int alarmNumber) { Alarm a = getAlarm(alarmNumber); if (!a.isActive()) { a.setActive(true); this.alarmStorage.save(a); return this.alarmS + a.getId() + " activated"; } return this.alarmS + alarmNumber + " is already active"; }  String stopRinging(); @Override void start(); @Override void stop();  }