### Question:
DaoWebAlarmRepository implements WebAlarmRepository, InitializingBean { @Transactional public Alarm[] getMatchingAlarms(AlarmCriteria criteria) { List<Alarm> alarms = new ArrayList<Alarm>(); List<OnmsAlarm> onmsAlarms = m_alarmDao.findMatching(getOnmsCriteria(criteria)); for (OnmsAlarm onmsAlarm : onmsAlarms) { alarms.add(mapOnmsAlarmToAlarm(onmsAlarm)); } return alarms.toArray(new Alarm[0]); }  @Override void afterPropertiesSet(); @Transactional void acknowledgeAll(String user, Date timestamp); @Transactional void acknowledgeAlarms(String user, Date timestamp, int[] alarmIds); @Transactional void acknowledgeMatchingAlarms(String user, Date timestamp, AlarmCriteria criteria); @Transactional void clearAlarms(int[] alarmIds, String user, Date timestamp); @Transactional int countMatchingAlarms(AlarmCriteria criteria); @Transactional int[] countMatchingAlarmsBySeverity(final AlarmCriteria criteria); @Transactional void escalateAlarms(int[] alarmIds, String user, Date timestamp); @Transactional Alarm getAlarm(int alarmId); @Transactional Alarm[] getMatchingAlarms(AlarmCriteria criteria); @Transactional void unacknowledgeAll(String user); @Transactional void unacknowledgeMatchingAlarms(AlarmCriteria criteria, String user); @Transactional void acknowledgeAlarms(int[] alarmIds, String user, Date timestamp); @Transactional void unacknowledgeAlarms(int[] alarmIds, String user); @Override @Transactional void updateStickyMemo(Integer alarmId, String body, String user); @Override @Transactional void updateReductionKeyMemo(Integer alarmId, String body, String user); @Override @Transactional void removeStickyMemo(Integer alarmId); @Override @Transactional void removeReductionKeyMemo(int alarmId); @Override @Transactional List<OnmsAcknowledgment> getAcknowledgments(int alarmId); @Override @Transactional List<AlarmSummary> getCurrentNodeAlarmSummaries();  }### Answer:
@Test @JUnitTemporaryDatabase public void testGetMatchingAlarms(){ Alarm[] alarms = m_alarmRepo.getMatchingAlarms(new AlarmCriteria(new SeverityFilter(OnmsSeverity.NORMAL), new AlarmIdFilter(1))); assertNotNull(alarms); assertEquals(1, alarms.length); alarms = m_alarmRepo.getMatchingAlarms(new AlarmCriteria(new SeverityFilter(OnmsSeverity.MAJOR))); assertNotNull(alarms); assertEquals(0, alarms.length); }
@Test @Transactional @JUnitTemporaryDatabase public void testSort() { for(SortStyle style : SortStyle.values()) { AlarmCriteria sorted = new AlarmCriteria(new Filter[0], style, AcknowledgeType.UNACKNOWLEDGED, 100, 0); Alarm[] alarms = m_alarmRepo.getMatchingAlarms(sorted); assertTrue("Failed to sort with style "+style, alarms.length > 0); } }
@Test @Transactional @JUnitTemporaryDatabase public void testSortAndSearchBySameProperty() { Filter[] filters = new Filter[] { new NodeNameLikeFilter("node") }; AlarmCriteria sorted = new AlarmCriteria(filters, SortStyle.NODE, AcknowledgeType.UNACKNOWLEDGED, 100, 0); Alarm[] alarms = m_alarmRepo.getMatchingAlarms(sorted); assertTrue("Failed to sort with style "+SortStyle.NODE, alarms.length > 0); }