private void sendNodeDownEventWithUpdateFieldSeverity( String reductionKey, MockNode node, OnmsSeverity severity) throws SQLException { 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("Severity"); field.setUpdateOnReduction(Boolean.TRUE); fields.add(field); data.setUpdateField(fields); event.setAlarmData(data); } else { event.setAlarmData(null); } event.setLogDest("logndisplay"); event.setLogMessage("testing"); event.setSeverity(severity.getLabel()); m_eventdIpcMgr.sendNow(event.getEvent()); }
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()); }
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()); }
@Test public void testNoLogmsg() throws Exception { EventBuilder bldr = new EventBuilder("testNoLogmsg", "AlarmdTest"); 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(); }
@Test @JUnitTemporaryDatabase( tempDbClass = MockDatabase.class) // Relies on specific IDs so we need a fresh database 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); }