@Test @JUnitTemporaryDatabase public void testGetUnacknowledgedAlarms() { OnmsCriteria acked = AlarmUtil.getOnmsCriteria(new AlarmCriteria(new Filter[0], AcknowledgeType.ACKNOWLEDGED)); OnmsCriteria unacked = AlarmUtil.getOnmsCriteria(new AlarmCriteria(new Filter[0], AcknowledgeType.UNACKNOWLEDGED)); OnmsCriteria all = AlarmUtil.getOnmsCriteria(new AlarmCriteria(new Filter[0], AcknowledgeType.BOTH)); int countAll = m_alarmRepo.countMatchingAlarms(all); int countAcked = m_alarmRepo.countMatchingAlarms(acked); int countUnacked = m_alarmRepo.countMatchingAlarms(unacked); assertEquals(countAll, countAcked + countUnacked); assertTrue(countAll > 0); assertTrue(countAcked == 0); assertTrue(countUnacked > 0); OnmsAlarm[] unackedAlarms = m_alarmRepo.getMatchingAlarms(unacked); assertEquals(countUnacked, unackedAlarms.length); OnmsAlarm[] ackedAlarms = m_alarmRepo.getMatchingAlarms(acked); assertEquals(countAcked, ackedAlarms.length); OnmsAlarm[] allAlarms = m_alarmRepo.getMatchingAlarms(all); assertEquals(countAll, allAlarms.length); m_alarmRepo.acknowledgeMatchingAlarms( "TestUser", new Date(), AlarmUtil.getOnmsCriteria(new AlarmCriteria(new AlarmIdFilter(1)))); assertEquals(countAcked + 1, m_alarmRepo.countMatchingAlarms(acked)); assertEquals(countUnacked - 1, m_alarmRepo.countMatchingAlarms(unacked)); }
@Test @JUnitTemporaryDatabase public void testAcknowledgeUnacknowledge() { String user = "******"; m_alarmRepo.acknowledgeMatchingAlarms( user, new Date(), AlarmUtil.getOnmsCriteria(new AlarmCriteria(new AlarmIdFilter(1)))); int matchingAlarmCount = m_alarmRepo.countMatchingAlarms( AlarmUtil.getOnmsCriteria(new AlarmCriteria(new AcknowledgedByFilter(user)))); assertEquals(1, matchingAlarmCount); m_alarmRepo.unacknowledgeMatchingAlarms( AlarmUtil.getOnmsCriteria(new AlarmCriteria(new AlarmIdFilter(1))), user); matchingAlarmCount = m_alarmRepo.countMatchingAlarms( AlarmUtil.getOnmsCriteria(new AlarmCriteria(new AcknowledgedByFilter(user)))); assertEquals(0, matchingAlarmCount); }