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);
}
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);
}
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());
}
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());
}
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));
}
Aggregations