当前位置: 首页>>代码示例>>Java>>正文


Java OnmsEvent.setEventHost方法代码示例

本文整理汇总了Java中org.opennms.netmgt.model.OnmsEvent.setEventHost方法的典型用法代码示例。如果您正苦于以下问题:Java OnmsEvent.setEventHost方法的具体用法?Java OnmsEvent.setEventHost怎么用?Java OnmsEvent.setEventHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.opennms.netmgt.model.OnmsEvent的用法示例。


在下文中一共展示了OnmsEvent.setEventHost方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSave

import org.opennms.netmgt.model.OnmsEvent; //导入方法依赖的package包/类
@Test
@Transactional
   public void testSave() {
       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/EventDaoTest");
       OnmsNode node = (OnmsNode) m_nodeDao.findAll().iterator().next();
       OnmsIpInterface iface = (OnmsIpInterface)node.getIpInterfaces().iterator().next();
       OnmsMonitoredService service = (OnmsMonitoredService)iface.getMonitoredServices().iterator().next();
       event.setNode(node);
    event.setServiceType(service.getServiceType());
       OnmsAlarm alarm = new OnmsAlarm();
    event.setAlarm(alarm);
       event.setIpAddr(iface.getIpAddress());
       m_eventDao.save(event);
      
       OnmsEvent newEvent = m_eventDao.load(event.getId());
       assertEquals("uei://org/opennms/test/EventDaoTest", newEvent.getEventUei());
       assertNotNull(newEvent.getServiceType());
       assertEquals(service.getNodeId(), newEvent.getNode().getId());
       assertEquals(event.getIpAddr(), newEvent.getIpAddr());
   }
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:33,代码来源:EventDaoTest.java

示例2: testNotificationSave

import org.opennms.netmgt.model.OnmsEvent; //导入方法依赖的package包/类
@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());
    }
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:38,代码来源:NotificationDaoTest.java

示例3: createEvent

import org.opennms.netmgt.model.OnmsEvent; //导入方法依赖的package包/类
protected OnmsEvent createEvent() {
    final Calendar c = new GregorianCalendar();
    c.set(2010, Calendar.JANUARY, 1, 0, 0, 0);

    long time = c.getTimeInMillis();
    time = (time - (time % 1000));
    final Date date = new Date(time + (count * 60 * 60 * 1000));

    final OnmsEvent event = new OnmsEvent();
    event.setDistPoller(getDistPollerDao().load("localhost"));
    event.setEventUei("uei.opennms.org/test/" + count);
    event.setEventCreateTime(date);
    event.setEventTime(date);
    event.setEventDescr("Test event " + count);
    event.setEventDisplay("Y");
    event.setEventLog("Y");
    event.setEventHost("es-with-the-most-es");
    event.setEventLogMsg("Test event " + count + " (log)");
    event.setEventSeverity(OnmsSeverity.MAJOR.getId());
    event.setEventSource("AlarmStatsRestServiceTest");
    event.setNode(m_databasePopulator.getNode1());

    getEventDao().save(event);
    getEventDao().flush();

    count++;

    return event;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:30,代码来源:AlarmStatsRestServiceTest.java

示例4: testSaveUserNotification

import org.opennms.netmgt.model.OnmsEvent; //导入方法依赖的package包/类
@Test
@Transactional
   public void testSaveUserNotification() {
       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/UserNotificationDaoTest");
       OnmsAlarm alarm = new OnmsAlarm();
       event.setAlarm(alarm);

       OnmsNode node = (OnmsNode) m_nodeDao.findAll().iterator().next();
       OnmsIpInterface iface = (OnmsIpInterface)node.getIpInterfaces().iterator().next();
       OnmsMonitoredService service = (OnmsMonitoredService)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/UserNotificationDaoTest", 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/UserNotificationDaoTest", newNotification.getEvent().getEventUei());
       
       OnmsUserNotification userNotif = new OnmsUserNotification();
       userNotif.setNotification(notification);
       userNotif.setNotifyTime(new Date());
       userNotif.setUserId("OpenNMS User");
       userNotif.setMedia("E-mail");
       userNotif.setContactInfo("[email protected]");
       m_userNotificationDao.save(userNotif);
       
       assertNotNull(userNotif.getNotification());
       assertEquals(userNotif.getUserId(), "OpenNMS User");
   }
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:50,代码来源:UserNotificationDaoTest.java


注:本文中的org.opennms.netmgt.model.OnmsEvent.setEventHost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。