Search in sources :

Example 1 with MockNotification

use of org.opennms.netmgt.mock.MockNotification in project opennms by OpenNMS.

the class MockNotificationStrategy method send.

/* (non-Javadoc)
     * @see org.opennms.netmgt.notifd.NotificationStrategy#send(java.util.List)
     */
@Override
public int send(List<Argument> arguments) {
    MockUtil.println("Message sent with arguments:" + arguments);
    MockNotification notification = new MockNotification();
    Iterator<Argument> it = arguments.iterator();
    while (it.hasNext()) {
        Argument arg = it.next();
        if (arg.getSwitch().equals(NotificationManager.PARAM_SUBJECT)) {
            notification.setSubject(arg.getValue());
        } else if (arg.getSwitch().equals(NotificationManager.PARAM_EMAIL)) {
            notification.setEmail(arg.getValue());
        } else if (arg.getSwitch().equals(NotificationManager.PARAM_TEXT_MSG)) {
            notification.setTextMsg(arg.getValue());
        }
    }
    notification.setExpectedTime(System.currentTimeMillis());
    NotificationAnticipator anticipator = getAnticipator();
    if (anticipator != null) {
        anticipator.notificationReceived(notification);
    } else {
        throw new NullPointerException("anticipator is null");
    }
    return 0;
}
Also used : MockNotification(org.opennms.netmgt.mock.MockNotification) Argument(org.opennms.netmgt.model.notifd.Argument) NotificationAnticipator(org.opennms.netmgt.mock.NotificationAnticipator)

Example 2 with MockNotification

use of org.opennms.netmgt.mock.MockNotification in project opennms by OpenNMS.

the class NotificationsITCase method createMockNotification.

protected MockNotification createMockNotification(long expectedTime, String subject, String textMsg, String email) {
    MockNotification notification;
    notification = new MockNotification();
    notification.setExpectedTime(expectedTime);
    notification.setSubject(subject);
    notification.setTextMsg(textMsg);
    notification.setEmail(email);
    return notification;
}
Also used : MockNotification(org.opennms.netmgt.mock.MockNotification)

Aggregations

MockNotification (org.opennms.netmgt.mock.MockNotification)2 NotificationAnticipator (org.opennms.netmgt.mock.NotificationAnticipator)1 Argument (org.opennms.netmgt.model.notifd.Argument)1