Search in sources :

Example 1 with AlarmIdFilter

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

the class AlarmRepositoryIT method testEscalateAlarms.

@Test
@JUnitTemporaryDatabase
public void testEscalateAlarms() {
    int[] alarmIds = { 1 };
    m_alarmRepo.escalateAlarms(alarmIds, "TestUser", new Date());
    OnmsAlarm[] alarms = m_alarmRepo.getMatchingAlarms(AlarmUtil.getOnmsCriteria(new AlarmCriteria(new AlarmIdFilter(1))));
    assertNotNull(alarms);
    assertEquals(OnmsSeverity.WARNING.getId(), alarms[0].getSeverity().getId());
}
Also used : OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) 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 2 with AlarmIdFilter

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

the class AlarmRepositoryIT method testAcknowledgeUnacknowledge.

@Test
@JUnitTemporaryDatabase
public void testAcknowledgeUnacknowledge() {
    String user = "TestUser";
    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);
}
Also used : AlarmCriteria(org.opennms.web.alarm.filter.AlarmCriteria) AcknowledgedByFilter(org.opennms.web.alarm.filter.AcknowledgedByFilter) AlarmIdFilter(org.opennms.web.alarm.filter.AlarmIdFilter) Date(java.util.Date) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)

Example 3 with AlarmIdFilter

use of org.opennms.web.alarm.filter.AlarmIdFilter 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 4 with AlarmIdFilter

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

the class WebEventRepositoryFilterIT method testAlarmIdFilter.

@Test
// Relies on specific IDs so we need a fresh database
@JUnitTemporaryDatabase
public void testAlarmIdFilter() {
    AlarmIdFilter filter = new AlarmIdFilter(1);
    Event[] events = getMatchingDaoEvents(filter);
    assertEquals(1, events.length);
}
Also used : OnmsEvent(org.opennms.netmgt.model.OnmsEvent) Event(org.opennms.web.event.Event) AlarmIdFilter(org.opennms.web.alarm.filter.AlarmIdFilter) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)

Example 5 with AlarmIdFilter

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

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