AlarmService { public Alarm searchAlarm(final Alarm alarm) { Collection<Alarm> identicalAlarms = searchAlarmsBySourceTargetAndThresholds(alarm.getGraphiteBaseUrl(), alarm.getTarget(), alarm.getWarn(), alarm.getError()); if (!identicalAlarms.isEmpty()) { return identicalAlarms.iterator().next(); } return null; }  Alarm getAlarm(String id); Collection<Alarm> getAllAlarms(); Alarm subscribeToAAlarm(final Alarm alarm); Alarm searchAlarm(final Alarm alarm); Collection<Alarm> searchAlarmsBySubscriptionTarget(String subTarget); Alarm updateAlarm(final Alarm alarm);  }
@Test public void searchAlarm() throws Exception { Alarm searchAlarm = new Alarm(); searchAlarm.setTarget("keepLastValue(perf.MPD.mpdsimulation.allRequests.ok.count)"); searchAlarm.setWarn(BigDecimal.valueOf(100)); searchAlarm.setError(BigDecimal.valueOf(200)); Alarm foundAlarm = alarmService.searchAlarm(searchAlarm); assertNotNull(foundAlarm); assertEquals(TestUtils.DEFAULT_ALARM_ID, foundAlarm.getId()); }
@Test public void searchNonExistentAlarm() throws Exception { Alarm searchAlarm = new Alarm(); searchAlarm.setTarget("testing.is.good"); searchAlarm.setWarn(BigDecimal.valueOf(155)); searchAlarm.setError(BigDecimal.valueOf(551)); Alarm foundAlarm = alarmService.searchAlarm(searchAlarm); assertNull(foundAlarm); }