use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.
the class PollerBackEndTest method testStatusChangeFromUpToDown.
// reportResult test variations
// what if we cant' find the locationMonitor with that ID
// what if we can't find the service with that ID
// what if we can't find a current status
// do I send events for status changed
public void testStatusChangeFromUpToDown() {
expect(m_locMonDao.get(LOCATION_MONITOR_ID)).andReturn(m_locationMonitor);
expect(m_monSvcDao.get(1)).andReturn(m_httpService);
expect(m_locMonDao.getMostRecentStatusChange(m_locationMonitor, m_httpService)).andReturn(m_httpCurrentStatus);
// TODO: make anticipate method
EventBuilder eventBuilder = new EventBuilder(EventConstants.REMOTE_NODE_LOST_SERVICE_UEI, "PollerBackEnd").setMonitoredService(m_httpService).addParam(EventConstants.PARM_LOCATION_MONITOR_ID, LOCATION_MONITOR_ID);
m_eventIpcManager.getEventAnticipator().anticipateEvent(eventBuilder.getEvent());
final PollStatus newStatus = PollStatus.unavailable("Test Down");
OnmsLocationSpecificStatus expectedStatus = new OnmsLocationSpecificStatus(m_locationMonitor, m_httpService, newStatus);
m_locMonDao.saveStatusChange(isA(OnmsLocationSpecificStatus.class));
expectLastCall().andAnswer(new StatusChecker(expectedStatus));
m_mocks.replayAll();
m_backEnd.reportResult(LOCATION_MONITOR_ID, 1, newStatus);
}
use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.
the class PollerBackEndTest method testStatusDownWhenNoneKnown.
public void testStatusDownWhenNoneKnown() {
expect(m_locMonDao.get(LOCATION_MONITOR_ID)).andReturn(m_locationMonitor);
expect(m_monSvcDao.get(2)).andReturn(m_dnsService);
expect(m_locMonDao.getMostRecentStatusChange(m_locationMonitor, m_dnsService)).andReturn(null);
final PollStatus newStatus = PollStatus.unavailable("where'd he go?");
OnmsLocationSpecificStatus expectedStatus = new OnmsLocationSpecificStatus(m_locationMonitor, m_dnsService, newStatus);
m_locMonDao.saveStatusChange(isA(OnmsLocationSpecificStatus.class));
expectLastCall().andAnswer(new StatusChecker(expectedStatus));
// expect a status change if the node is now down and we didn't know before
EventBuilder eventBuilder = new EventBuilder(EventConstants.REMOTE_NODE_LOST_SERVICE_UEI, "PollerBackEnd").setMonitoredService(m_dnsService).addParam(EventConstants.PARM_LOCATION_MONITOR_ID, LOCATION_MONITOR_ID);
m_eventIpcManager.getEventAnticipator().anticipateEvent(eventBuilder.getEvent());
m_mocks.replayAll();
m_backEnd.reportResult(LOCATION_MONITOR_ID, 2, newStatus);
}
use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.
the class ConfigureSnmpTest method createConfigureSnmpEventBuilder.
private EventBuilder createConfigureSnmpEventBuilder(final String firstIp, final String lastIp) {
EventBuilder bldr = new EventBuilder(EventConstants.CONFIGURE_SNMP_EVENT_UEI, "ConfigureSnmpTest");
bldr.addParam(EventConstants.PARM_FIRST_IP_ADDRESS, firstIp);
bldr.addParam(EventConstants.PARM_LAST_IP_ADDRESS, lastIp);
return bldr;
}
use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.
the class MockPollContext method createEvent.
@Override
public Event createEvent(String uei, int nodeId, InetAddress address, String svcName, Date date, String reason) {
EventBuilder e = MockEventUtil.createEventBuilder("Test", uei, nodeId, (address == null ? null : InetAddressUtils.str(address)), svcName, reason);
e.setTime(date);
return e.getEvent();
}
use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.
the class LatencyStoringServiceMonitorAdaptorIT method testThresholds.
@Test
@JUnitTemporaryDatabase(tempDbClass = MockDatabase.class)
public void testThresholds() throws Exception {
EventBuilder bldr = new EventBuilder(EventConstants.HIGH_THRESHOLD_EVENT_UEI, "LatencyStoringServiceMonitorAdaptorTest");
bldr.setNodeid(1);
bldr.setInterface(addr("127.0.0.1"));
bldr.setService("ICMP");
m_eventIpcManager.getEventAnticipator().anticipateEvent(bldr.getEvent());
bldr = new EventBuilder(EventConstants.HIGH_THRESHOLD_REARM_EVENT_UEI, "LatencyStoringServiceMonitorAdaptorTest");
bldr.setNodeid(1);
bldr.setInterface(addr("127.0.0.1"));
bldr.setService("ICMP");
m_eventIpcManager.getEventAnticipator().anticipateEvent(bldr.getEvent());
// This should emulate a trigger and a rearm
executeThresholdTest(new Double[] { 100.0, 10.0 });
m_eventIpcManager.getEventAnticipator().verifyAnticipated();
}
Aggregations