@Override
 public void visitMonitoredService(OnmsMonitoredService monSvc) {
   OnmsServiceType dbType = monSvc.getServiceType();
   if (dbType.getId() == null) {
     dbType = createServiceTypeIfNecessary(dbType.getName());
   }
   monSvc.setServiceType(dbType);
 }
  /** {@inheritDoc} */
  public void poll(OnmsMonitoredService monSvc, int pollResultId) {

    EventBuilder bldr =
        new EventBuilder(EventConstants.DEMAND_POLL_SERVICE_EVENT_UEI, "PollerService");

    bldr.setNodeid(monSvc.getNodeId());
    bldr.setInterface(monSvc.getIpAddress());
    bldr.setIfIndex(monSvc.getIfIndex());
    bldr.setService(monSvc.getServiceType().getName());

    bldr.addParam(EventConstants.PARM_DEMAND_POLL_ID, pollResultId);

    sendEvent(bldr.getEvent());
  }
  @Test
  @Transactional
  public void testNotificationSave() {
    OnmsEvent event = new OnmsEvent();
    event.setDistPoller(m_distPollerDao.load("localhost"));
    event.setEventCreateTime(new Date());
    event.setEventDescr("event dao test");
    event.setEventHost("localhost");
    event.setEventLog("Y");
    event.setEventDisplay("Y");
    event.setEventLogGroup("event dao test log group");
    event.setEventLogMsg("event dao test log msg");
    event.setEventSeverity(7);
    event.setEventSource("EventDaoTest");
    event.setEventTime(new Date());
    event.setEventUei("uei://org/opennms/test/NotificationDaoTest");
    //        OnmsAlarm alarm = new OnmsAlarm();
    //        event.setAlarm(alarm);

    OnmsNode node = m_nodeDao.findAll().iterator().next();
    OnmsIpInterface iface = node.getIpInterfaces().iterator().next();
    OnmsMonitoredService service = iface.getMonitoredServices().iterator().next();
    event.setNode(node);
    event.setServiceType(service.getServiceType());
    event.setIpAddr(iface.getIpAddress());
    m_eventDao.save(event);
    OnmsEvent newEvent = m_eventDao.load(event.getId());
    assertEquals("uei://org/opennms/test/NotificationDaoTest", newEvent.getEventUei());

    OnmsNotification notification = new OnmsNotification();
    notification.setEvent(newEvent);
    notification.setTextMsg("Tests are fun!");
    m_notificationDao.save(notification);

    OnmsNotification newNotification = m_notificationDao.load(notification.getNotifyId());
    assertEquals(
        "uei://org/opennms/test/NotificationDaoTest", newNotification.getEvent().getEventUei());
  }