use of org.opennms.netmgt.model.OnmsDistPoller in project opennms by OpenNMS.
the class AlarmRepositoryFilterIT method testParmsNotLikeFilter.
@Test
@Transactional
@JUnitTemporaryDatabase
public void testParmsNotLikeFilter() {
List<OnmsEvent> events = m_dbPopulator.getEventDao().findAll();
assertNotNull(events);
OnmsEvent event = events.get(0);
OnmsDistPoller poller = m_dbPopulator.getDistPollerDao().whoami();
assertNotNull(poller);
OnmsAlarm alarm = new OnmsAlarm();
alarm.setUei("uei.opennms.org/vendor/Juniper/traps/jnxVpnIfUp");
alarm.setLastEvent(event);
alarm.setSeverityId(3);
alarm.setDistPoller(poller);
alarm.setCounter(100);
alarm.setEventParms("componentType=service(string,text);url=http://localhost:8980/opennms/rtc/post/Network+Interfaces(string,text);user=rtc(string,text);passwd=rtc(string,text);catlabel=Network Interfaces(string,text)");
AlarmDao alarmDao = m_dbPopulator.getAlarmDao();
alarmDao.save(alarm);
alarmDao.flush();
OnmsAlarm alarm2 = new OnmsAlarm();
alarm2.setUei("uei.opennms.org/vendor/Juniper/traps/jnxVpnIfUp");
alarm2.setLastEvent(event);
alarm2.setSeverityId(3);
alarm2.setDistPoller(poller);
alarm2.setCounter(100);
alarm2.setEventParms("componentType=serviceElement(string,text);url=http://localhost:8980/opennms/rtc/post/Network+Interfaces(string,text);user=admin(string,text);passwd=rtc(string,text);catlabel=Network Interfaces(string,text)");
alarmDao.save(alarm2);
alarmDao.flush();
NegativeEventParmLikeFilter parmFilter = new NegativeEventParmLikeFilter("user=rtc");
assertEquals("user is not \"rtc\"", parmFilter.getTextDescription());
AlarmCriteria criteria = new AlarmCriteria(parmFilter);
OnmsAlarm[] alarms = m_daoAlarmRepo.getMatchingAlarms(AlarmUtil.getOnmsCriteria(criteria));
// alarm2 and the alarm from DatabasePopulator match this criteria
assertEquals(2, alarms.length);
}
Aggregations