Search in sources :

Example 1 with AlarmDTO

use of org.opennms.web.rest.model.v2.AlarmDTO in project opennms by OpenNMS.

the class AlarmMapperTest method canMapAlarm.

@Test
public void canMapAlarm() throws IOException {
    Event eventConf = new Event();
    eventConf.setUei("uei.opennms.org/nodes/interfaceDown");
    eventConf.setEventLabel("OpenNMS-defined node event: interfaceDown");
    eventConfDao.addEvent(eventConf);
    OnmsAlarm alarm = new OnmsAlarm();
    alarm.setId(34);
    alarm.setUei("uei.opennms.org/nodes/interfaceDown");
    OnmsMonitoringSystem monitoringSystem = new OnmsMonitoringSystem();
    monitoringSystem.setLocation("Default");
    alarm.setDistPoller(monitoringSystem);
    OnmsNode node = new OnmsNode();
    node.setId(1);
    node.setLabel("n1");
    alarm.setNode(node);
    alarm.setIpAddr(InetAddress.getByName("10.8.0.30"));
    alarm.setReductionKey("uei.opennms.org/nodes/interfaceDown::1:10.8.0.30");
    alarm.setAlarmType(1);
    alarm.setCounter(1);
    alarm.setSeverity(OnmsSeverity.MINOR);
    alarm.setFirstEventTime(new Date(1503412443118L));
    alarm.setDescription("All services are down on interface 10.8.0.30.");
    alarm.setLogMsg("Interface 10.8.0.30 is down.");
    alarm.setSuppressedUntil(new Date(1503412443118L));
    alarm.setSuppressedTime(new Date(1503412443118L));
    alarm.setLastEventTime(new Date(1503412443118L));
    alarm.setX733ProbableCause(0);
    OnmsServiceType serviceType = new OnmsServiceType();
    serviceType.setName("ICMP");
    serviceType.setId(3);
    alarm.setServiceType(serviceType);
    OnmsEvent event = new OnmsEvent();
    event.setId(2035);
    event.setEventUei("uei.opennms.org/nodes/interfaceDown");
    event.setEventTime(new Date(1503412443118L));
    event.setEventHost("noise");
    event.setEventSource("OpenNMS.Poller.DefaultPollContext");
    event.setIpAddr(InetAddress.getByName("10.8.0.30"));
    event.setEventCreateTime(new Date(1503412443118L));
    event.setEventDescr("All services are down on interface 10.8.0.30.");
    event.setEventLogMsg("Interface 10.8.0.30 is down.");
    event.setEventSeverity(OnmsSeverity.MINOR.getId());
    event.setEventLog("Y");
    event.setEventDisplay("Y");
    event.setNode(node);
    event.setDistPoller(monitoringSystem);
    event.setEventParameters(Lists.newArrayList(new OnmsEventParameter(event, "test", "testVal", "string")));
    event.setServiceType(serviceType);
    alarm.setLastEvent(event);
    alarm.setTTicketId("NMS-9587");
    alarm.setTTicketState(TroubleTicketState.OPEN);
    AlarmDTO alarmDTO = alarmMapper.alarmToAlarmDTO(alarm);
    mapAndMarshalToFromXmlAndJson(alarmDTO, "alarm.34.dto.xml", "alarm.34.dto.json");
}
Also used : OnmsEvent(org.opennms.netmgt.model.OnmsEvent) AlarmDTO(org.opennms.web.rest.model.v2.AlarmDTO) OnmsNode(org.opennms.netmgt.model.OnmsNode) OnmsAlarm(org.opennms.netmgt.model.OnmsAlarm) OnmsServiceType(org.opennms.netmgt.model.OnmsServiceType) OnmsEvent(org.opennms.netmgt.model.OnmsEvent) Event(org.opennms.netmgt.xml.eventconf.Event) OnmsEventParameter(org.opennms.netmgt.model.OnmsEventParameter) Date(java.util.Date) OnmsMonitoringSystem(org.opennms.netmgt.model.OnmsMonitoringSystem) JsonTest(org.opennms.core.test.xml.JsonTest) Test(org.junit.Test) XmlTest(org.opennms.core.test.xml.XmlTest)

Aggregations

Date (java.util.Date)1 Test (org.junit.Test)1 JsonTest (org.opennms.core.test.xml.JsonTest)1 XmlTest (org.opennms.core.test.xml.XmlTest)1 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)1 OnmsEvent (org.opennms.netmgt.model.OnmsEvent)1 OnmsEventParameter (org.opennms.netmgt.model.OnmsEventParameter)1 OnmsMonitoringSystem (org.opennms.netmgt.model.OnmsMonitoringSystem)1 OnmsNode (org.opennms.netmgt.model.OnmsNode)1 OnmsServiceType (org.opennms.netmgt.model.OnmsServiceType)1 Event (org.opennms.netmgt.xml.eventconf.Event)1 AlarmDTO (org.opennms.web.rest.model.v2.AlarmDTO)1