Search in sources :

Example 1 with EventBuilder

use of org.opennms.netmgt.model.events.EventBuilder 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());
}
Also used : EventBuilder(org.opennms.netmgt.model.events.EventBuilder) Argument(org.opennms.netmgt.model.notifd.Argument)

Example 2 with EventBuilder

use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.

the class ReverseDnsProvisioningAdapter method buildEvent.

private EventBuilder buildEvent(String uei, int nodeId) {
    EventBuilder builder = new EventBuilder(uei, "Provisioner", new Date());
    builder.setNodeid(nodeId);
    return builder;
}
Also used : EventBuilder(org.opennms.netmgt.model.events.EventBuilder) Date(java.util.Date)

Example 3 with EventBuilder

use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.

the class NodeDiscovery method sendCompletedEvent.

protected void sendCompletedEvent(int nodeid) {
    EventBuilder builder = new EventBuilder("uei.opennms.org/internal/linkd/nodeLinkDiscoveryCompleted", "EnhancedLinkd");
    builder.setNodeid(getNodeId());
    builder.setInterface(getPrimaryIpAddress());
    builder.addParam("runnable", getName());
    m_linkd.getEventForwarder().sendNow(builder.getEvent());
}
Also used : EventBuilder(org.opennms.netmgt.model.events.EventBuilder)

Example 4 with EventBuilder

use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.

the class NodeDiscovery method sendStartEvent.

protected void sendStartEvent(int nodeid) {
    EventBuilder builder = new EventBuilder("uei.opennms.org/internal/linkd/nodeLinkDiscoveryStarted", "EnhancedLinkd");
    builder.setNodeid(getNodeId());
    builder.setInterface(getPrimaryIpAddress());
    builder.addParam("runnable", getName());
    m_linkd.getEventForwarder().sendNow(builder.getEvent());
}
Also used : EventBuilder(org.opennms.netmgt.model.events.EventBuilder)

Example 5 with EventBuilder

use of org.opennms.netmgt.model.events.EventBuilder in project opennms by OpenNMS.

the class NodeDiscovery method sendSuspendedEvent.

protected void sendSuspendedEvent(int nodeid) {
    EventBuilder builder = new EventBuilder("uei.opennms.org/internal/linkd/nodeLinkDiscoverySuspended", "EnhancedLinkd");
    builder.setNodeid(getNodeId());
    builder.setInterface(getPrimaryIpAddress());
    builder.addParam("runnable", getName());
    m_linkd.getEventForwarder().sendNow(builder.getEvent());
}
Also used : EventBuilder(org.opennms.netmgt.model.events.EventBuilder)

Aggregations

EventBuilder (org.opennms.netmgt.model.events.EventBuilder)305 Test (org.junit.Test)88 Event (org.opennms.netmgt.xml.event.Event)84 Date (java.util.Date)22 OnmsNode (org.opennms.netmgt.model.OnmsNode)17 InetAddress (java.net.InetAddress)16 EventProxyException (org.opennms.netmgt.events.api.EventProxyException)15 AlarmData (org.opennms.netmgt.xml.event.AlarmData)14 EventAnticipator (org.opennms.netmgt.dao.mock.EventAnticipator)12 ServletException (javax.servlet.ServletException)9 EventHandler (org.opennms.netmgt.events.api.annotations.EventHandler)9 Parm (org.opennms.netmgt.xml.event.Parm)9 Event (org.opennms.netmgt.xml.eventconf.Event)9 File (java.io.File)8 ArrayList (java.util.ArrayList)8 JUnitTemporaryDatabase (org.opennms.core.test.db.annotations.JUnitTemporaryDatabase)7 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)7 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)7 SyntaxToEvent (org.opennms.netmgt.model.events.snmp.SyntaxToEvent)7 Transactional (org.springframework.transaction.annotation.Transactional)6