Search in sources :

Example 16 with JUnitTemporaryDatabase

use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.

the class AlarmRepositoryFilterIT method testBeforeFirstEventTimeFilter.

@Test
@Transactional
@JUnitTemporaryDatabase
public void testBeforeFirstEventTimeFilter() {
    OnmsAlarm[] alarms = m_daoAlarmRepo.getMatchingAlarms(AlarmUtil.getOnmsCriteria(new AlarmCriteria(new BeforeFirstEventTimeFilter(new Date()))));
    assertEquals(1, alarms.length);
    alarms = m_daoAlarmRepo.getMatchingAlarms(AlarmUtil.getOnmsCriteria(new AlarmCriteria(new BeforeLastEventTimeFilter(new Date()))));
    assertEquals(1, alarms.length);
}
Also used : OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) Date(java.util.Date) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase) Transactional(org.springframework.transaction.annotation.Transactional)

Example 17 with JUnitTemporaryDatabase

use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.

the class AlarmRepositoryIT method testSortAndSearchBySameProperty.

@Test
@Transactional
@JUnitTemporaryDatabase
public void testSortAndSearchBySameProperty() {
    Filter[] filters = new Filter[] { new NodeNameLikeFilter("node") };
    AlarmCriteria sorted = new AlarmCriteria(filters, SortStyle.NODE, AcknowledgeType.UNACKNOWLEDGED, 100, 0);
    OnmsAlarm[] alarms = m_alarmRepo.getMatchingAlarms(AlarmUtil.getOnmsCriteria(sorted));
    assertTrue("Failed to sort with style " + SortStyle.NODE, alarms.length > 0);
}
Also used : NodeNameLikeFilter(org.opennms.web.alarm.filter.NodeNameLikeFilter) 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) 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 18 with JUnitTemporaryDatabase

use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase 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 19 with JUnitTemporaryDatabase

use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.

the class AlarmRepositoryIT method testAcknowledgements.

@Test
@JUnitTemporaryDatabase
public void testAcknowledgements() {
    m_alarmRepo.acknowledgeAlarms(new int[] { 1 }, "agalue", new Date());
    List<OnmsAcknowledgment> acks = m_alarmRepo.getAcknowledgments(1);
    Assert.assertNotNull(acks);
    Assert.assertEquals(1, acks.size());
    Assert.assertEquals("agalue", acks.get(0).getAckUser());
}
Also used : OnmsAcknowledgment(org.opennms.netmgt.model.OnmsAcknowledgment) Date(java.util.Date) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)

Example 20 with JUnitTemporaryDatabase

use of org.opennms.core.test.db.annotations.JUnitTemporaryDatabase in project opennms by OpenNMS.

the class DaoWebEventRepositoryIT method testAcknowledgeUnacknowledgeMatchingAlarms.

@Test
// Relies on specific IDs so we need a fresh database
@JUnitTemporaryDatabase
public void testAcknowledgeUnacknowledgeMatchingAlarms() {
    m_daoEventRepo.acknowledgeMatchingEvents("TestUser", new Date(), new EventCriteria(new EventIdFilter(1)));
    int matchingEventCount = m_daoEventRepo.countMatchingEvents(new EventCriteria(new AcknowledgedByFilter("TestUser")));
    assertEquals(1, matchingEventCount);
    m_daoEventRepo.unacknowledgeMatchingEvents(new EventCriteria(new AcknowledgedByFilter("TestUser")));
    matchingEventCount = m_daoEventRepo.countMatchingEvents(new EventCriteria(new AcknowledgedByFilter("TestUser")));
    assertEquals(0, matchingEventCount);
}
Also used : AcknowledgedByFilter(org.opennms.web.event.filter.AcknowledgedByFilter) EventCriteria(org.opennms.web.event.filter.EventCriteria) EventIdFilter(org.opennms.web.event.filter.EventIdFilter) Date(java.util.Date) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)

Aggregations

JUnitTemporaryDatabase (org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)109 Test (org.junit.Test)105 OnmsNode (org.opennms.netmgt.model.OnmsNode)21 Date (java.util.Date)20 JSONObject (org.json.JSONObject)18 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)18 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)17 Transactional (org.springframework.transaction.annotation.Transactional)14 FileInputStream (java.io.FileInputStream)10 AlarmCriteria (org.opennms.web.alarm.filter.AlarmCriteria)10 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)9 OnmsOutage (org.opennms.netmgt.model.OnmsOutage)8 EventBuilder (org.opennms.netmgt.model.events.EventBuilder)7 AlarmIdFilter (org.opennms.web.alarm.filter.AlarmIdFilter)7 HashMap (java.util.HashMap)6 OutageCriteria (org.opennms.web.outage.filter.OutageCriteria)6 Matcher (java.util.regex.Matcher)4 Pattern (java.util.regex.Pattern)4 JSONArray (org.json.JSONArray)4 AcknowledgedByFilter (org.opennms.web.alarm.filter.AcknowledgedByFilter)4