/** * <p>createNodeEventBuilder</p> * * @param source a {@link java.lang.String} object. * @param uei a {@link java.lang.String} object. * @param node a {@link org.opennms.netmgt.mock.MockNode} object. * @return a {@link org.opennms.netmgt.model.events.EventBuilder} object. */ public static EventBuilder createNodeEventBuilder(String source, String uei, OnmsNode node) { return createEventBuilder(source, uei, node.getId(), null, null, null); }
/** * <p>createDownEvent</p> * * @return a {@link org.opennms.netmgt.xml.event.Event} object. */ @Override public Event createDownEvent() { return MockEventUtil.createInterfaceDownEvent("Test", this); }
/** * <p>createInterfaceEvent</p> * * @param source a {@link java.lang.String} object. * @param uei a {@link java.lang.String} object. * @param iface a {@link org.opennms.netmgt.mock.MockInterface} object. * @return a {@link org.opennms.netmgt.xml.event.Event} object. */ public static Event createInterfaceEvent(String source, String uei, MockInterface iface) { return createInterfaceEventBuilder(source, uei, iface).getEvent(); }
/** * <p>createNodeRegainedServiceEvent</p> * * @param source a {@link java.lang.String} object. * @param svc a {@link org.opennms.netmgt.mock.MockService} object. * @return a {@link org.opennms.netmgt.xml.event.Event} object. */ public static Event createNodeRegainedServiceEvent(String source, MockService svc) { return createServiceEvent(source, EventConstants.NODE_REGAINED_SERVICE_EVENT_UEI, svc, null); }
@Test public void testUnmangedWithOpenOutageAtStartup() throws InterruptedException { // before we start we need to initialize the database // create an outage for the service MockService svc = m_network.getService(1, "192.168.1.1", "SMTP"); MockInterface iface = m_network.getInterface(1, "192.168.1.2"); Event svcLostEvent = MockEventUtil.createNodeLostServiceEvent("Test", svc); m_db.writeEvent(svcLostEvent); createOutages(svc, svcLostEvent); Event ifaceDownEvent = MockEventUtil.createInterfaceDownEvent("Test", iface); m_db.writeEvent(ifaceDownEvent); createOutages(iface, ifaceDownEvent); // mark the service as unmanaged m_db.setServiceStatus(svc, 'U'); m_db.setInterfaceStatus(iface, 'U'); // assert that we have an open outage assertEquals(1, m_db.countOpenOutagesForService(svc)); assertEquals(1, m_db.countOutagesForService(svc)); assertEquals(iface.getServices().size(), m_db.countOutagesForInterface(iface)); assertEquals(iface.getServices().size(), m_db.countOpenOutagesForInterface(iface)); startDaemons(); // assert that we have no open outages assertEquals(0, m_db.countOpenOutagesForService(svc)); assertEquals(1, m_db.countOutagesForService(svc)); assertEquals(0, m_db.countOpenOutagesForInterface(iface)); assertEquals(iface.getServices().size(), m_db .countOutagesForInterface(iface)); }
/** * <p>createNewEvent</p> * * @return a {@link org.opennms.netmgt.xml.event.Event} object. */ @Override public Event createNewEvent() { return MockEventUtil.createNodeGainedServiceEvent("Test", this); }
/** * Trip a notification and see if the %noticeid% token gets expanded to a numeric * value in the subject and text message * * @author Jeff Gehlbach <jeffg@jeffg.org> */ @Test public void testExpandNoticeId_Bug1745() throws Exception { MockService svc = m_network.getService(1, "192.168.1.1", "ICMP"); Event event = MockEventUtil.createServiceEvent("Test", "uei.opennms.org/test/noticeIdExpansion", svc, null); // We need to know what noticeID to expect -- whatever the NotificationManager // gives us, the next notice to come out will have noticeID n+1. This isn't // foolproof, but it should work within the confines of JUnit as long as all // previous cases have torn down the mock Notifd. String antNID = Integer.toString(m_notificationManager.getNoticeId() + 1); Date testDate = new Date(); long finishedNotifs = anticipateNotificationsForGroup("notification '" + antNID + "'", "Notification '" + antNID + "'", "InitialGroup", testDate, 0); MockEventUtil.setEventTime(event, testDate); m_eventMgr.sendEventToListeners(event); verifyAnticipated(finishedNotifs, 1000); }
/** * <p>createDownEvent</p> * * @return a {@link org.opennms.netmgt.xml.event.Event} object. */ @Override public Event createDownEvent() { return MockEventUtil.createNodeDownEvent("Test", this); }
/** * <p>createDownEvent</p> * * @param date a {@link java.util.Date} object. * @return a {@link org.opennms.netmgt.xml.event.Event} object. */ public Event createDownEvent(Date date) { Event e = createDownEvent(); MockEventUtil.setEventTime(e, date); return e; }
/** * <p>createDownEvent</p> * * @return a {@link org.opennms.netmgt.xml.event.Event} object. */ @Override public Event createDownEvent() { return MockEventUtil.createNodeLostServiceEvent("Test", this, "Service Not Responding."); }
@Override public void visitService(MockService svc) { Event event = MockEventUtil.createEvent("Test", EventConstants.NODE_LOST_SERVICE_EVENT_UEI, svc.getNodeId(), svc.getIpAddr(), svc.getSvcName(), String.valueOf(PollStatus.SERVICE_UNAVAILABLE)); m_eventMgr.sendNow(event); } };
Map<String, String> m1 = convertParmsToMap(p1); Map<String, String> m2 = convertParmsToMap(p2);
/** * <p>createSuspendPollingServiceEvent</p> * * @param source a {@link java.lang.String} object. * @param svc a {@link org.opennms.netmgt.mock.MockService} object. * @return a {@link org.opennms.netmgt.xml.event.Event} object. */ public static Event createSuspendPollingServiceEvent(String source, MockService svc) { return createServiceEvent(source, EventConstants.SUSPEND_POLLING_SERVICE_EVENT_UEI, svc, null); }
@Test public void testUnmangedWithOpenOutageAtStartup() { // before we start we need to initialize the database // create an outage for the service MockService svc = m_network.getService(1, "192.168.1.1", "SMTP"); MockInterface iface = m_network.getInterface(1, "192.168.1.2"); Event svcLostEvent = MockEventUtil.createNodeLostServiceEvent("Test", svc); m_db.writeEvent(svcLostEvent); createOutages(svc, svcLostEvent); Event ifaceDownEvent = MockEventUtil.createInterfaceDownEvent("Test", iface); m_db.writeEvent(ifaceDownEvent); createOutages(iface, ifaceDownEvent); // mark the service as unmanaged m_db.setServiceStatus(svc, 'U'); m_db.setInterfaceStatus(iface, 'U'); // assert that we have an open outage assertEquals(1, m_db.countOpenOutagesForService(svc)); assertEquals(1, m_db.countOutagesForService(svc)); assertEquals(iface.getServices().size(), m_db.countOutagesForInterface(iface)); assertEquals(iface.getServices().size(), m_db.countOpenOutagesForInterface(iface)); startDaemons(); // assert that we have no open outages assertEquals(0, m_db.countOpenOutagesForService(svc)); assertEquals(1, m_db.countOutagesForService(svc)); assertEquals(0, m_db.countOpenOutagesForInterface(iface)); assertEquals(iface.getServices().size(), m_db.countOutagesForInterface(iface)); }
@Override public void visitService(MockService svc) { Event event = MockEventUtil.createNodeGainedServiceEvent("Test", svc); m_eventMgr.sendEventToListeners(event); } };
public void testWaitForEvent() throws Throwable { MockNode node = m_network.getNode(1); final Event event1 = MockEventUtil.createNodeDownEvent("Test", node); final Event event2 = MockEventUtil.createNodeDownEvent("Test", node); final Event event3 = MockEventUtil.createNodeDownEvent("Test", m_network.getNode(2));
/** * <p>createUpEvent</p> * * @param date a {@link java.util.Date} object. * @return a {@link org.opennms.netmgt.xml.event.Event} object. */ public Event createUpEvent(Date date) { Event e = createUpEvent(); MockEventUtil.setEventTime(e, date); return e; }
@Override public void visitService(MockService svc) { Event event = MockEventUtil.createEvent("Test", EventConstants.NODE_REGAINED_SERVICE_EVENT_UEI, svc.getNodeId(), svc.getIpAddr(), svc.getSvcName(), null); m_eventMgr.sendNow(event); } };
/** * <p>createNodeEventBuilder</p> * * @param source a {@link java.lang.String} object. * @param uei a {@link java.lang.String} object. * @param node a {@link org.opennms.netmgt.mock.MockNode} object. * @return a {@link org.opennms.netmgt.model.events.EventBuilder} object. */ public static EventBuilder createNodeEventBuilder(String source, String uei, MockNode node) { return createEventBuilder(source, uei, node.getNodeId(), null, null, null); }
/** * <p>createResumePollingServiceEvent</p> * * @param source a {@link java.lang.String} object. * @param svc a {@link org.opennms.netmgt.mock.MockService} object. * @return a {@link org.opennms.netmgt.xml.event.Event} object. */ public static Event createResumePollingServiceEvent(String source, MockService svc) { return createServiceEvent(source, EventConstants.RESUME_POLLING_SERVICE_EVENT_UEI, svc, null); }