Search in sources :

Example 1 with Tticket

use of org.opennms.netmgt.xml.event.Tticket in project opennms by OpenNMS.

the class EventUtilIT method testExpandTticketId.

@Test
public void testExpandTticketId() {
    String testString = "%tticketid%";
    String newString = eventUtil.expandParms(testString, m_nodeDownEvent);
    assertEquals("", newString);
    Tticket ticket = new Tticket();
    ticket.setContent("777");
    ticket.setState("1");
    m_nodeDownEvent.setTticket(ticket);
    newString = eventUtil.expandParms(testString, m_nodeDownEvent);
    assertEquals("777", newString);
}
Also used : Tticket(org.opennms.netmgt.xml.event.Tticket) Test(org.junit.Test)

Example 2 with Tticket

use of org.opennms.netmgt.xml.event.Tticket in project opennms by OpenNMS.

the class NotificationManager method getEvent.

/**
     * In the absence of DAOs and ORMs this creates an Event object from the persisted
     * record.
     *
     * @param eventid a int.
     * @return a populated Event object
     */
public Event getEvent(final int eventid) {
    // don't switch using event builder since this event is read from the database
    final Event event = new Event();
    Querier querier = new Querier(m_dataSource, "select * from events where eventid = ?", new RowProcessor() {

        @Override
        public void processRow(ResultSet rs) throws SQLException {
            event.setDbid(rs.getInt("eventid"));
            event.setUei(rs.getString("eventuei"));
            event.setNodeid(rs.getLong("nodeid"));
            event.setTime(rs.getDate("eventtime"));
            event.setHost(rs.getString("eventhost"));
            event.setInterface(rs.getString("ipaddr"));
            event.setSnmphost(rs.getString("eventsnmphost"));
            event.setService(getServiceName(rs.getInt("serviceid")));
            event.setCreationTime(rs.getDate("eventcreatetime"));
            event.setSeverity(rs.getString("eventseverity"));
            event.setPathoutage(rs.getString("eventpathoutage"));
            Tticket tticket = new Tticket();
            tticket.setContent(rs.getString("eventtticket"));
            tticket.setState(rs.getString("eventtticketstate"));
            event.setTticket(tticket);
            event.setSource(rs.getString("eventsource"));
        }

        private String getServiceName(int serviceid) {
            SingleResultQuerier querier = new SingleResultQuerier(m_dataSource, "select servicename from service where serviceid = ?");
            return (String) querier.getResult();
        }
    });
    querier.execute(eventid);
    return event;
}
Also used : Querier(org.opennms.core.utils.Querier) SingleResultQuerier(org.opennms.core.utils.SingleResultQuerier) Tticket(org.opennms.netmgt.xml.event.Tticket) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) Event(org.opennms.netmgt.xml.event.Event) SingleResultQuerier(org.opennms.core.utils.SingleResultQuerier) RowProcessor(org.opennms.core.utils.RowProcessor)

Example 3 with Tticket

use of org.opennms.netmgt.xml.event.Tticket in project opennms by OpenNMS.

the class NotifdIT method testAutoAcknowledge1.

@Test
public void testAutoAcknowledge1() throws Exception {
    m_destinationPathManager.getPath("NoEscalate").setInitialDelay("2000ms");
    MockNode node = m_network.getNode(1);
    Event downEvent = node.createDownEvent();
    Tticket tticket = new Tticket();
    tticket.setContent("777");
    tticket.setState("1");
    downEvent.setTticket(tticket);
    m_eventMgr.sendEventToListeners(downEvent);
    sleep(1000);
    Date date = new Date();
    Event upEvent = node.createUpEvent(date);
    long endTime = anticipateNotificationsForGroup("node 1 up.", "The node which was previously down is now up.", "UpGroup", date, 0);
    m_eventMgr.sendEventToListeners(upEvent);
    verifyAnticipated(endTime, 1000, 5000);
}
Also used : Tticket(org.opennms.netmgt.xml.event.Tticket) Event(org.opennms.netmgt.xml.event.Event) MockNode(org.opennms.netmgt.mock.MockNode) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Tticket (org.opennms.netmgt.xml.event.Tticket)3 Test (org.junit.Test)2 Event (org.opennms.netmgt.xml.event.Event)2 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Date (java.util.Date)1 Querier (org.opennms.core.utils.Querier)1 RowProcessor (org.opennms.core.utils.RowProcessor)1 SingleResultQuerier (org.opennms.core.utils.SingleResultQuerier)1 MockNode (org.opennms.netmgt.mock.MockNode)1