### Question:
AlarmServer extends AbstractService { public ActiveAlarm<T> shelve(ActiveAlarm<T> alarm, String username, String message, long shelveDuration) { if (!activeAlarms.containsValue(alarm)) { return null; } alarm.shelve(username, message, shelveDuration); alarmListeners.forEach(l -> l.notifyUpdate(AlarmNotificationType.SHELVED, alarm)); timer.schedule(() -> checkShelved(), shelveDuration, TimeUnit.MILLISECONDS); return alarm; } AlarmServer(String yamcsInstance, ScheduledThreadPoolExecutor timer); Map<S, ActiveAlarm<T>> addAlarmListener(AlarmListener<T> listener); void removeAlarmListener(AlarmListener<T> listener); Map<S, ActiveAlarm<T>> getActiveAlarms(); ActiveAlarm<T> getActiveAlarm(S subject, int id); ActiveAlarm<T> getActiveAlarm(S subject); ActiveAlarm<T> acknowledge(ActiveAlarm<T> alarm, String username, long ackTime, String message); ActiveAlarm<T> reset(ActiveAlarm<T> alarm, String username, long resetTime, String message); ActiveAlarm<T> clear(ActiveAlarm<T> alarm, String username, long clearTime, String message); ActiveAlarm<T> shelve(ActiveAlarm<T> alarm, String username, String message,
            long shelveDuration); ActiveAlarm<T> unshelve(ActiveAlarm<T> alarm, String username); @Override void doStart(); void update(T pv, int minViolations); void update(T value, int minViolations, boolean autoAck, boolean latching); @Override void doStop(); void clearAll();  }### Answer:
@Test public void testShelve() throws InterruptedException { MyListener l = new MyListener(); alarmServer.addAlarmListener(l); ParameterValue pv1_0 = getParameterValue(p1, MonitoringResult.WARNING); alarmServer.update(pv1_0, 1); ActiveAlarm<ParameterValue> aa = l.triggered.remove(); assertEquals(pv1_0, aa.currentValue); assertEquals(pv1_0, aa.mostSevereValue); assertEquals(pv1_0, aa.triggerValue); long shelvetime = TimeEncoding.getWallclockTime(); ActiveAlarm<ParameterValue> aa1 = alarmServer.shelve(aa, "busy operator", "looking at it later", 500); assertNotNull(aa1); assertEquals(1, l.shelved.size()); assertEquals(aa, l.shelved.remove()); ActiveAlarm<ParameterValue> aa2 = l.unshelved.poll(2000, TimeUnit.MILLISECONDS); if (aa2 == null) { System.out.println("shelvetime:" + shelvetime + " wallclocktime: " + TimeEncoding.getWallclockTime()); System.out.println("Active alarms: " + alarmServer.getActiveAlarms()); } assertEquals(aa, aa2); assertFalse(aa.isShelved()); }