Search in sources :

Example 11 with OnmsDistPoller

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);
}
Also used : OnmsEvent(org.opennms.netmgt.model.OnmsEvent) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) OnmsDistPoller(org.opennms.netmgt.model.OnmsDistPoller) AlarmDao(org.opennms.netmgt.dao.api.AlarmDao) Test(org.junit.Test) JUnitTemporaryDatabase(org.opennms.core.test.db.annotations.JUnitTemporaryDatabase) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

OnmsDistPoller (org.opennms.netmgt.model.OnmsDistPoller)11 Test (org.junit.Test)6 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)4 Transactional (org.springframework.transaction.annotation.Transactional)4 Before (org.junit.Before)3 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)3 Date (java.util.Date)2 JUnitTemporaryDatabase (org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)2 AlarmDao (org.opennms.netmgt.dao.api.AlarmDao)2 MockForeignSourceRepository (org.opennms.netmgt.provision.persist.MockForeignSourceRepository)2 ForeignSource (org.opennms.netmgt.provision.persist.foreignsource.ForeignSource)2 PluginConfig (org.opennms.netmgt.provision.persist.foreignsource.PluginConfig)2 ArrayList (java.util.ArrayList)1 Message (org.opennms.core.ipc.sink.api.Message)1 CamelBlueprintTest (org.opennms.core.test.camel.CamelBlueprintTest)1 ProxySnmpAgentConfigFactory (org.opennms.core.test.snmp.ProxySnmpAgentConfigFactory)1 Criteria (org.opennms.features.topology.api.topo.Criteria)1 SearchCriteria (org.opennms.features.topology.api.topo.SearchCriteria)1 SearchResult (org.opennms.features.topology.api.topo.SearchResult)1 AlarmProvider (org.opennms.features.topology.app.internal.AlarmProvider)1