Search in sources :

Example 1 with EventCriteria

use of org.opennms.web.event.filter.EventCriteria in project opennms by OpenNMS.

the class DaoWebEventRepositoryIT method testFilterBySeverity.

@Test
@Transactional
public void testFilterBySeverity() {
    NegativeSeverityFilter filter = new NegativeSeverityFilter(OnmsSeverity.NORMAL.getId());
    EventCriteria criteria = new EventCriteria(filter);
    Event[] events = m_daoEventRepo.getMatchingEvents(criteria);
    assertTrue(events.length > 0);
    EventCriteria sortedCriteria = new EventCriteria(new Filter[] { filter }, SortStyle.ID, AcknowledgeType.UNACKNOWLEDGED, 100, 0);
    Event[] sortedEvents = m_daoEventRepo.getMatchingEvents(sortedCriteria);
    assertTrue(sortedEvents.length > 0);
}
Also used : NegativeSeverityFilter(org.opennms.web.event.filter.NegativeSeverityFilter) OnmsEvent(org.opennms.netmgt.model.OnmsEvent) EventCriteria(org.opennms.web.event.filter.EventCriteria) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with EventCriteria

use of org.opennms.web.event.filter.EventCriteria in project opennms by OpenNMS.

the class DaoWebEventRepositoryIT method testCountMatchingBySeverity.

@Test
@Transactional
public void testCountMatchingBySeverity() {
    int[] matchingEventCount = m_daoEventRepo.countMatchingEventsBySeverity(new EventCriteria(new SeverityFilter(3)));
    assertNotNull(matchingEventCount);
    assertEquals(8, matchingEventCount.length);
}
Also used : NegativeSeverityFilter(org.opennms.web.event.filter.NegativeSeverityFilter) SeverityFilter(org.opennms.web.event.filter.SeverityFilter) EventCriteria(org.opennms.web.event.filter.EventCriteria) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with EventCriteria

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

Example 4 with EventCriteria

use of org.opennms.web.event.filter.EventCriteria in project opennms by OpenNMS.

the class DaoWebEventRepositoryIT method testAcknowledgeUnacknowledgeAllAlarms.

@Test
@Transactional
public void testAcknowledgeUnacknowledgeAllAlarms() {
    m_daoEventRepo.acknowledgeAll("TestUser", new Date());
    int matchingEventCount = m_daoEventRepo.countMatchingEvents(new EventCriteria(new AcknowledgedByFilter("TestUser")));
    assertEquals(2, matchingEventCount);
    m_daoEventRepo.unacknowledgeAll();
    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) Date(java.util.Date) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with EventCriteria

use of org.opennms.web.event.filter.EventCriteria in project opennms by OpenNMS.

the class DaoWebEventRepositoryIT method testCountMatchingEvents.

@Test
@Transactional
public void testCountMatchingEvents() {
    EventCriteria criteria = new EventCriteria();
    int event = m_daoEventRepo.countMatchingEvents(criteria);
    assertEquals(2, event);
}
Also used : EventCriteria(org.opennms.web.event.filter.EventCriteria) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

EventCriteria (org.opennms.web.event.filter.EventCriteria)10 Test (org.junit.Test)6 Transactional (org.springframework.transaction.annotation.Transactional)5 Date (java.util.Date)4 ArrayList (java.util.ArrayList)3 EventIdFilter (org.opennms.web.event.filter.EventIdFilter)3 EventIdListFilter (org.opennms.web.event.filter.EventIdListFilter)3 Filter (org.opennms.web.filter.Filter)3 ServletException (javax.servlet.ServletException)2 AcknowledgedByFilter (org.opennms.web.event.filter.AcknowledgedByFilter)2 NegativeSeverityFilter (org.opennms.web.event.filter.NegativeSeverityFilter)2 MissingParameterException (org.opennms.web.servlet.MissingParameterException)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 HashMap (java.util.HashMap)1 TreeSet (java.util.TreeSet)1 JUnitTemporaryDatabase (org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)1 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)1 OnmsNode (org.opennms.netmgt.model.OnmsNode)1 Event (org.opennms.web.event.Event)1 SeverityFilter (org.opennms.web.event.filter.SeverityFilter)1