Search in sources :

Example 6 with AlarmIdFilter

use of org.opennms.web.alarm.filter.AlarmIdFilter in project opennms by OpenNMS.

the class AlarmRepositoryIT method testGetUnacknowledgedAlarms.

@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));
}
Also used : SeverityFilter(org.opennms.web.alarm.filter.SeverityFilter) Filter(org.opennms.web.filter.Filter) AlarmIdFilter(org.opennms.web.alarm.filter.AlarmIdFilter) NodeNameLikeFilter(org.opennms.web.alarm.filter.NodeNameLikeFilter) AcknowledgedByFilter(org.opennms.web.alarm.filter.AcknowledgedByFilter) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) OnmsCriteria(org.opennms.netmgt.model.OnmsCriteria) AlarmCriteria(org.opennms.web.alarm.filter.AlarmCriteria) AlarmIdFilter(org.opennms.web.alarm.filter.AlarmIdFilter) Date(java.util.Date) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)

Aggregations

Test (org.junit.Test)6 JUnitTemporaryDatabase (org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)6 AlarmIdFilter (org.opennms.web.alarm.filter.AlarmIdFilter)6 AlarmCriteria (org.opennms.web.alarm.filter.AlarmCriteria)5 Date (java.util.Date)3 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)3 AcknowledgedByFilter (org.opennms.web.alarm.filter.AcknowledgedByFilter)2 SeverityFilter (org.opennms.web.alarm.filter.SeverityFilter)2 OnmsCriteria (org.opennms.netmgt.model.OnmsCriteria)1 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)1 NodeNameLikeFilter (org.opennms.web.alarm.filter.NodeNameLikeFilter)1 Event (org.opennms.web.event.Event)1 Filter (org.opennms.web.filter.Filter)1