Search in sources :

Example 81 with OnmsAlarm

use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.

the class LinkdEdgeStatusProviderTest method createBridgeDownAlarm.

private List<OnmsAlarm> createBridgeDownAlarm() {
    OnmsAlarm alarm = new OnmsAlarm();
    alarm.setNode(m_node2);
    alarm.setIfIndex(24);
    alarm.setUei(EventConstants.TOPOLOGY_LINK_DOWN_EVENT_UEI);
    return Arrays.asList(alarm);
}
Also used : OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm)

Example 82 with OnmsAlarm

use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.

the class NodeTableCellStyleGenerator method getAlarm.

public OnmsAlarm getAlarm(int nodeId) {
    CriteriaBuilder builder = new CriteriaBuilder(OnmsAlarm.class);
    builder.alias("node", "node");
    builder.ne("severity", OnmsSeverity.CLEARED);
    builder.orderBy("severity").desc();
    builder.eq("node.id", nodeId);
    builder.limit(Integer.valueOf(1));
    List<OnmsAlarm> alarms = alarmDao.findMatching(builder.toCriteria());
    return alarms == null || alarms.isEmpty() ? null : alarms.get(0);
}
Also used : CriteriaBuilder(org.opennms.core.criteria.CriteriaBuilder) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm)

Example 83 with OnmsAlarm

use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.

the class AlarmRepositoryIT method testClearAlarms.

@Test
@JUnitTemporaryDatabase
public void testClearAlarms() {
    OnmsAlarm alarm = m_alarmRepo.getAlarm(1);
    assertNotNull(alarm);
    assertEquals(OnmsSeverity.NORMAL.getId(), alarm.getSeverity().getId());
    int[] alarmIds = { 1 };
    m_alarmRepo.clearAlarms(alarmIds, "TestUser", new Date());
    alarm = m_alarmRepo.getAlarm(1);
    assertNotNull(alarm);
    assertEquals(OnmsSeverity.CLEARED.getId(), alarm.getSeverity().getId());
}
Also used : OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) Date(java.util.Date) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)

Example 84 with OnmsAlarm

use of org.opennms.netmgt.model.OnmsAlarm in project opennms by OpenNMS.

the class AlarmRepositoryIT method testGetAlarmById.

@Test
@Transactional
@JUnitTemporaryDatabase
public void testGetAlarmById() {
    OnmsAlarm alarm = m_alarmRepo.getAlarm(1);
    assertNotNull(alarm);
    assertEquals(1, alarm.getId().intValue());
    assertEquals("uei.opennms.org/test", alarm.getUei());
    assertEquals("00000000-0000-0000-0000-000000000000", alarm.getDistPoller().getId());
    assertEquals(1, alarm.getCounter().intValue());
    assertEquals(3, alarm.getSeverity().getId());
}
Also used : OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase) Transactional(org.springframework.transaction.annotation.Transactional)

Example 85 with OnmsAlarm

use of org.opennms.netmgt.model.OnmsAlarm 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

OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)143 Test (org.junit.Test)58 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)41 Date (java.util.Date)36 OnmsNode (org.opennms.netmgt.model.OnmsNode)36 Transactional (org.springframework.transaction.annotation.Transactional)35 OnmsEventParameter (org.opennms.netmgt.model.OnmsEventParameter)19 JUnitTemporaryDatabase (org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)18 NorthboundAlarm (org.opennms.netmgt.alarmd.api.NorthboundAlarm)18 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)17 ArrayList (java.util.ArrayList)14 OnmsAcknowledgment (org.opennms.netmgt.model.OnmsAcknowledgment)14 InetAddress (java.net.InetAddress)13 CriteriaBuilder (org.opennms.core.criteria.CriteriaBuilder)11 OnmsSnmpInterface (org.opennms.netmgt.model.OnmsSnmpInterface)10 OnmsNotification (org.opennms.netmgt.model.OnmsNotification)9 OnmsSeverity (org.opennms.netmgt.model.OnmsSeverity)9 AlarmDao (org.opennms.netmgt.dao.api.AlarmDao)8 AlarmCriteria (org.opennms.web.alarm.filter.AlarmCriteria)8 LinkedList (java.util.LinkedList)7