use of org.opennms.netmgt.model.notifd.Argument in project opennms by OpenNMS.
the class TicketNotificationStrategyTest method testCreateTicket.
public void testCreateTicket() {
// Setup the event anticipator
EventBuilder newSuspectBuilder = new EventBuilder(EventConstants.TROUBLETICKET_CREATE_UEI, m_ticketNotificationStrategy.getName());
newSuspectBuilder.setParam(EventConstants.PARM_ALARM_ID, "1");
newSuspectBuilder.setParam(EventConstants.PARM_ALARM_UEI, EventConstants.NODE_DOWN_EVENT_UEI);
newSuspectBuilder.setParam(EventConstants.PARM_USER, "admin");
m_eventIpcManager.getEventAnticipator().anticipateEvent(newSuspectBuilder.getEvent());
m_ticketNotificationStrategy.setAlarmState(new TicketNotificationStrategy.AlarmState(1));
m_ticketNotificationStrategy.setAlarmType(AlarmType.PROBLEM);
List<Argument> arguments = buildArguments("1", EventConstants.NODE_DOWN_EVENT_UEI);
assertEquals(0, m_ticketNotificationStrategy.send(arguments));
assertTrue("Expected events not forthcoming", m_eventIpcManager.getEventAnticipator().waitForAnticipated(0).isEmpty());
assertEquals("Received unexpected events", 0, m_eventIpcManager.getEventAnticipator().getUnanticipatedEvents().size());
}
use of org.opennms.netmgt.model.notifd.Argument in project opennms by OpenNMS.
the class MicroblogReplyNotificationStrategyTest method configureArgs.
@Override
public List<Argument> configureArgs() {
List<Argument> arguments = super.configureArgs();
Argument arg = new Argument("-ublog", null, "jeffg", false);
arguments.add(arg);
return arguments;
}
use of org.opennms.netmgt.model.notifd.Argument in project opennms by OpenNMS.
the class MicroblogReplyNotificationStrategyTest method postNotice.
@Ignore
@Test
@Override
public void postNotice() {
NotificationStrategy ns = new MicroblogReplyNotificationStrategy(m_daoConfigResource);
List<Argument> arguments = configureArgs();
Assert.assertEquals("NotificationStrategy should return 0 on success", 0, ns.send(arguments));
}
use of org.opennms.netmgt.model.notifd.Argument in project opennms by OpenNMS.
the class MicroblogDMNotificationStrategyTest method postNotice.
@Ignore
@Test
@Override
public void postNotice() {
NotificationStrategy ns = new MicroblogDMNotificationStrategy(m_daoConfigResource);
List<Argument> arguments = configureArgs();
Assert.assertEquals("NotificationStrategy should return 0 on success", 0, ns.send(arguments));
}
use of org.opennms.netmgt.model.notifd.Argument in project opennms by OpenNMS.
the class IrcCatNotificationStrategy method buildMessage.
private String buildMessage(List<Argument> arguments) {
String recipient = null;
String message = null;
for (Argument arg : arguments) {
if (NotificationManager.PARAM_EMAIL.equals(arg.getSwitch())) {
recipient = arg.getValue();
} else if (NotificationManager.PARAM_TEXT_MSG.equals(arg.getSwitch())) {
message = arg.getValue();
} else if (NotificationManager.PARAM_NUM_MSG.equals(arg.getSwitch())) {
message = arg.getValue();
} else {
throw new IllegalArgumentException("Unsupported notification argument switch '" + arg.getSwitch() + "'");
}
}
if (recipient == null) {
// FIXME We should have a better Exception to use here for configuration problems
throw new IllegalArgumentException("no recipient specified, but is required");
}
if (message == null) {
// FIXME We should have a better Exception to use here for configuration problems
throw new IllegalArgumentException("no message specified, but is required");
}
return recipient + " " + message;
}
Aggregations