use of org.opennms.netmgt.config.notifications.Notification in project opennms by OpenNMS.
the class BroadcastEventProcessorIT method testVarbindsdecodeNMS7598.
/**
* Test Varbindsdecode replacement on notifications.
*
* @author Alejandro Galue <agalue@opennms.org>
*/
@Test
public void testVarbindsdecodeNMS7598() throws Exception {
EventBuilder bldr = new EventBuilder("uei.opennms.org/vendor/Cisco/traps/cHsrpStateChange", "testVarbindsdecodeNMS7598");
bldr.setNodeid(0);
bldr.setInterface(addr("0.0.0.0"));
bldr.addParam("cHsrpGrpStandbyState", "3");
String templateText = "Notice #%noticeid%: new state is %parm[#1]%";
String expectedText = "Notice #1001: new state is listen(3)";
Notification n = new Notification();
n.setName("cHsrpGrpStandbyState");
n.setSubject(templateText);
n.setNumericMessage(templateText);
n.setTextMessage(templateText);
Map<String, String> params = m_eventProcessor.buildParameterMap(n, bldr.getEvent(), 1001);
Assert.assertEquals(expectedText, params.get(NotificationManager.PARAM_NUM_MSG));
Assert.assertEquals(expectedText, params.get(NotificationManager.PARAM_TEXT_MSG));
Assert.assertEquals(expectedText, params.get(NotificationManager.PARAM_SUBJECT));
}
use of org.opennms.netmgt.config.notifications.Notification in project opennms by OpenNMS.
the class NotifdIT method testRebuildParameterMap.
@Test
public void testRebuildParameterMap() throws Exception {
MockInterface iface = m_network.getInterface(1, "192.168.1.1");
Date downDate = new Date();
anticipateNotificationsForGroup("interface 192.168.1.1 down.", "All services are down on interface 192.168.1.1", "InitialGroup", downDate, 0);
// bring node down now
Event event = iface.createDownEvent(downDate);
m_eventMgr.sendEventToListeners(event);
sleep(1000);
Collection<Integer> notifIds = m_db.findNoticesForEvent(event);
Notification[] notification = m_notificationManager.getNotifForEvent(event);
int index = 0;
for (Integer notifId : notifIds) {
Map<String, String> originalMap = m_eventProcessor.buildParameterMap(notification[index], event, notifId.intValue());
Map<String, String> resolutionMap = new HashMap<String, String>(originalMap);
resolutionMap.put(NotificationManager.PARAM_SUBJECT, "RESOLVED: " + resolutionMap.get(NotificationManager.PARAM_SUBJECT));
resolutionMap.put(NotificationManager.PARAM_TEXT_MSG, "RESOLVED: " + resolutionMap.get(NotificationManager.PARAM_TEXT_MSG));
resolutionMap.put(NotificationManager.PARAM_NUM_MSG, "RESOLVED: " + resolutionMap.get(NotificationManager.PARAM_NUM_MSG));
Map<String, String> rebuiltMap = m_notifd.getBroadcastEventProcessor().rebuildParameterMap(notifId.intValue(), "RESOLVED: ", m_notifd.getConfigManager().getConfiguration().getNumericSkipResolutionPrefix());
assertEquals(resolutionMap, rebuiltMap);
index++;
}
}
Aggregations