use of org.opennms.netmgt.model.OnmsMonitoringSystem 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");
}
Aggregations