Search in sources :

Example 6 with AlarmCriteria

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

the class AlarmRepositoryIT method testGetMatchingAlarms.

@Test
@JUnitTemporaryDatabase
public void testGetMatchingAlarms() {
    OnmsAlarm[] alarms = m_alarmRepo.getMatchingAlarms(AlarmUtil.getOnmsCriteria(new AlarmCriteria(new SeverityFilter(OnmsSeverity.NORMAL), new AlarmIdFilter(1))));
    assertNotNull(alarms);
    assertEquals(1, alarms.length);
    alarms = m_alarmRepo.getMatchingAlarms(AlarmUtil.getOnmsCriteria(new AlarmCriteria(new SeverityFilter(OnmsSeverity.MAJOR))));
    assertNotNull(alarms);
    assertEquals(0, alarms.length);
}
Also used : SeverityFilter(org.opennms.web.alarm.filter.SeverityFilter) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) AlarmCriteria(org.opennms.web.alarm.filter.AlarmCriteria) AlarmIdFilter(org.opennms.web.alarm.filter.AlarmIdFilter) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)

Example 7 with AlarmCriteria

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

the class AlarmRepositoryIT method testCountMatchingAlarmsBySeverity.

@Test
@Transactional
@JUnitTemporaryDatabase
public void testCountMatchingAlarmsBySeverity() {
    AlarmCriteria criteria = new AlarmCriteria();
    int[] matchingAlarms = m_alarmRepo.countMatchingAlarmsBySeverity(AlarmUtil.getOnmsCriteria(criteria));
    assertEquals(8, matchingAlarms.length);
    // Make sure that the count is correct per severity
    assertEquals(0, matchingAlarms[OnmsSeverity.CLEARED.getId()]);
    assertEquals(0, matchingAlarms[OnmsSeverity.CRITICAL.getId()]);
    assertEquals(0, matchingAlarms[OnmsSeverity.INDETERMINATE.getId()]);
    assertEquals(0, matchingAlarms[OnmsSeverity.MINOR.getId()]);
    assertEquals(1, matchingAlarms[OnmsSeverity.NORMAL.getId()]);
    assertEquals(0, matchingAlarms[OnmsSeverity.WARNING.getId()]);
    assertEquals(0, matchingAlarms[OnmsSeverity.MAJOR.getId()]);
}
Also used : AlarmCriteria(org.opennms.web.alarm.filter.AlarmCriteria) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with AlarmCriteria

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

the class AlarmRepositoryIT method testCountMatchingAlarms.

@Test
@JUnitTemporaryDatabase
public void testCountMatchingAlarms() {
    int alarms = m_alarmRepo.countMatchingAlarms(AlarmUtil.getOnmsCriteria(new AlarmCriteria(new AlarmIdFilter(1))));
    assertEquals(1, alarms);
    alarms = m_alarmRepo.countMatchingAlarms(AlarmUtil.getOnmsCriteria(new AlarmCriteria(new AlarmIdFilter(2))));
    assertEquals(0, alarms);
}
Also used : AlarmCriteria(org.opennms.web.alarm.filter.AlarmCriteria) AlarmIdFilter(org.opennms.web.alarm.filter.AlarmIdFilter) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)

Example 9 with AlarmCriteria

use of org.opennms.web.alarm.filter.AlarmCriteria 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)

Example 10 with AlarmCriteria

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

the class AlarmRepositoryIT method testSort.

@Test
@Transactional
@JUnitTemporaryDatabase
public void testSort() {
    for (SortStyle style : SortStyle.values()) {
        AlarmCriteria sorted = new AlarmCriteria(new Filter[0], style, AcknowledgeType.UNACKNOWLEDGED, 100, 0);
        OnmsAlarm[] alarms = m_alarmRepo.getMatchingAlarms(AlarmUtil.getOnmsCriteria(sorted));
        assertTrue("Failed to sort with style " + style, alarms.length > 0);
    }
}
Also used : OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) AlarmCriteria(org.opennms.web.alarm.filter.AlarmCriteria) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

AlarmCriteria (org.opennms.web.alarm.filter.AlarmCriteria)14 Test (org.junit.Test)10 JUnitTemporaryDatabase (org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)10 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)8 AlarmIdFilter (org.opennms.web.alarm.filter.AlarmIdFilter)6 Date (java.util.Date)5 SeverityFilter (org.opennms.web.alarm.filter.SeverityFilter)5 Filter (org.opennms.web.filter.Filter)5 Transactional (org.springframework.transaction.annotation.Transactional)5 AcknowledgedByFilter (org.opennms.web.alarm.filter.AcknowledgedByFilter)4 ArrayList (java.util.ArrayList)3 OnmsCriteria (org.opennms.netmgt.model.OnmsCriteria)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 AlarmQueryParms (org.opennms.web.alarm.AlarmQueryParms)2 NodeNameLikeFilter (org.opennms.web.alarm.filter.NodeNameLikeFilter)2 SyndContent (com.rometools.rome.feed.synd.SyndContent)1 SyndContentImpl (com.rometools.rome.feed.synd.SyndContentImpl)1 SyndEntry (com.rometools.rome.feed.synd.SyndEntry)1 SyndEntryImpl (com.rometools.rome.feed.synd.SyndEntryImpl)1 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)1