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