use of org.opennms.netmgt.xml.event.AlarmData in project opennms by OpenNMS.
the class AlarmdIT method testNoDbid.
@Test
public void testNoDbid() throws Exception {
EventBuilder bldr = new EventBuilder("testNoDbid", "AlarmdTest");
bldr.setLogMessage(null);
bldr.setAlarmData(new AlarmData());
ThrowableAnticipator ta = new ThrowableAnticipator();
ta.anticipate(new IllegalArgumentException("Incoming event has an illegal dbid (0), aborting"));
try {
m_alarmd.getPersister().persist(bldr.getEvent());
} catch (Throwable t) {
ta.throwableReceived(t);
}
ta.verifyAnticipated();
}
use of org.opennms.netmgt.xml.event.AlarmData in project opennms by OpenNMS.
the class AlarmLifecycleEventsIT method sendNodeUpEvent.
private void sendNodeUpEvent(long nodeId) {
EventBuilder builder = new EventBuilder(EventConstants.NODE_UP_EVENT_UEI, "test");
Date currentTime = new Date();
builder.setTime(currentTime);
builder.setNodeid(nodeId);
builder.setSeverity("Normal");
AlarmData data = new AlarmData();
data.setAlarmType(2);
data.setReductionKey(String.format("%s:%d", EventConstants.NODE_UP_EVENT_UEI, nodeId));
data.setClearKey(String.format("%s:%d", EventConstants.NODE_DOWN_EVENT_UEI, nodeId));
builder.setAlarmData(data);
builder.setLogDest("logndisplay");
builder.setLogMessage("testing");
m_eventMgr.sendNow(builder.getEvent());
}
use of org.opennms.netmgt.xml.event.AlarmData in project opennms by OpenNMS.
the class AlarmdIT method testNorthbounder.
@Test
public void testNorthbounder() throws Exception {
assertTrue(m_northbounder.isInitialized());
assertTrue(m_northbounder.getAlarms().isEmpty());
final EventBuilder bldr = new EventBuilder("testNoLogmsg", "AlarmdTest");
bldr.setAlarmData(new AlarmData());
bldr.setLogMessage("This is a test.");
final Event event = bldr.getEvent();
event.setDbid(17);
MockNode node = m_mockNetwork.getNode(1);
sendNodeDownEvent("%nodeid%", node);
final List<NorthboundAlarm> alarms = m_northbounder.getAlarms();
assertTrue(alarms.size() > 0);
}
use of org.opennms.netmgt.xml.event.AlarmData in project opennms by OpenNMS.
the class AlarmdIT method sendNodeDownEventChangeLogMsg.
private void sendNodeDownEventChangeLogMsg(String reductionKey, MockNode node, String logMsg) {
EventBuilder event = MockEventUtil.createNodeDownEventBuilder("Test", node);
if (reductionKey != null) {
AlarmData data = new AlarmData();
data.setAlarmType(1);
data.setReductionKey(reductionKey);
List<UpdateField> fields = new ArrayList<UpdateField>();
UpdateField field = new UpdateField();
field.setFieldName("logMsg");
field.setUpdateOnReduction(Boolean.TRUE);
fields.add(field);
data.setUpdateField(fields);
event.setAlarmData(data);
} else {
event.setAlarmData(null);
}
event.setLogDest("logndisplay");
event.setLogMessage(logMsg);
m_eventdIpcMgr.sendNow(event.getEvent());
}
use of org.opennms.netmgt.xml.event.AlarmData in project opennms by OpenNMS.
the class AlarmdIT method sendNodeDownEvent.
private void sendNodeDownEvent(String reductionKey, MockNode node) throws SQLException {
EventBuilder event = MockEventUtil.createNodeDownEventBuilder("Test", node);
if (reductionKey != null) {
AlarmData data = new AlarmData();
data.setAlarmType(1);
data.setReductionKey(reductionKey);
event.setAlarmData(data);
} else {
event.setAlarmData(null);
}
event.setLogDest("logndisplay");
event.setLogMessage("testing");
m_eventdIpcMgr.sendNow(event.getEvent());
}
Aggregations