Search in sources :

Example 6 with Event

use of org.opennms.netmgt.xml.eventconf.Event in project opennms by OpenNMS.

the class EventconfFactoryIT method testGetEventsByLabel.

@Test
public void testGetEventsByLabel() {
    List<Event> events = getEventsByLabel();
    ArrayList<String> beforeSort = new ArrayList<String>(events.size());
    for (Event e : events) {
        String label = e.getEventLabel();
        beforeSort.add(label);
    }
    ArrayList<String> afterSort = new ArrayList<String>(beforeSort);
    Collections.sort(afterSort, String.CASE_INSENSITIVE_ORDER);
    assertEquals(beforeSort.size(), afterSort.size());
    for (int i = 0; i < beforeSort.size(); i++) {
        assertEquals("Lists unequals at index " + i, beforeSort.get(i), afterSort.get(i));
    }
}
Also used : ArrayList(java.util.ArrayList) SyntaxToEvent(org.opennms.netmgt.model.events.snmp.SyntaxToEvent) Event(org.opennms.netmgt.xml.eventconf.Event) Test(org.junit.Test)

Example 7 with Event

use of org.opennms.netmgt.xml.eventconf.Event in project opennms by OpenNMS.

the class EventconfFactoryIT method testFindByEventUeiKnown.

@Test
public void testFindByEventUeiKnown() {
    EventBuilder bldr = new EventBuilder(knownUEI1, "testFindByEventUeiKnown");
    Event eventConf = m_eventConfDao.findByEvent(bldr.getEvent());
    assertNotNull("returned event configuration for event with known UEI '" + knownUEI1 + "' should not be null", eventConf);
    assertEquals("UEI", bldr.getEvent().getUei(), eventConf.getUei());
}
Also used : EventBuilder(org.opennms.netmgt.model.events.EventBuilder) SyntaxToEvent(org.opennms.netmgt.model.events.snmp.SyntaxToEvent) Event(org.opennms.netmgt.xml.eventconf.Event) Test(org.junit.Test)

Example 8 with Event

use of org.opennms.netmgt.xml.eventconf.Event in project opennms by OpenNMS.

the class EventconfFactoryIT method testGetAlarmType.

@Test
public void testGetAlarmType() {
    Event event = new Event();
    AlarmData data = new AlarmData();
    data.setAlarmType(2);
    data.setClearKey("uei.opennms.org.testUei:localhost:1");
    data.setReductionKey("reduceme");
    event.setAlarmData(data);
    final AlarmData alarmData = event.getAlarmData();
    int i = alarmData.getAlarmType();
    assertEquals(2, i);
    assertTrue("uei.opennms.org.testUei:localhost:1".equals(alarmData.getClearKey()));
    assertTrue("reduceme".equals(alarmData.getReductionKey()));
}
Also used : SyntaxToEvent(org.opennms.netmgt.model.events.snmp.SyntaxToEvent) Event(org.opennms.netmgt.xml.eventconf.Event) AlarmData(org.opennms.netmgt.xml.eventconf.AlarmData) Test(org.junit.Test)

Example 9 with Event

use of org.opennms.netmgt.xml.eventconf.Event in project opennms by OpenNMS.

the class EventconfFactorySaveTest method testAddEventToProgrammaticStore.

/**
     * Test adding and event to a specific file
     *
     */
public void testAddEventToProgrammaticStore() {
    Event event = getAddableEvent();
    m_eventConfDao.addEventToProgrammaticStore(event);
    //Check that the new Event is still there
    {
        List<Event> events = m_eventConfDao.getEvents(newUEI);
        assertNotNull("Should be at least one event", events);
        assertEquals("Should be only one event", 1, events.size());
        Event fetchedEvent = events.get(0);
        checkAddableEvent(fetchedEvent);
    }
    m_eventConfDao.saveCurrent();
    m_eventConfDao.reload();
    //We are expecting this new file to be there - if it's not, that's an issue
    m_fa.expecting(new File(m_fa.getTempDir().getAbsolutePath() + File.separator + "etc" + File.separator + "events"), "programmatic.events.xml");
    //Check again after the reload
    {
        List<Event> events = m_eventConfDao.getEvents(newUEI);
        assertNotNull("Should be at least one event", events);
        assertEquals("Should be only one event", 1, events.size());
        Event fetchedEvent = events.get(0);
        checkAddableEvent(fetchedEvent);
    }
}
Also used : Event(org.opennms.netmgt.xml.eventconf.Event) List(java.util.List) File(java.io.File)

Example 10 with Event

use of org.opennms.netmgt.xml.eventconf.Event in project opennms by OpenNMS.

the class EventconfFactorySaveTest method getAddableEvent.

private static Event getAddableEvent() {
    Event event = new Event();
    event.setUei(newUEI);
    event.setEventLabel(newEventLabel);
    event.setDescr(newDescr);
    Logmsg logmsg = new Logmsg();
    logmsg.setDest(newDest);
    logmsg.setContent(newContent);
    event.setLogmsg(logmsg);
    event.setSeverity(newSeverity);
    return event;
}
Also used : Logmsg(org.opennms.netmgt.xml.eventconf.Logmsg) Event(org.opennms.netmgt.xml.eventconf.Event)

Aggregations

Event (org.opennms.netmgt.xml.eventconf.Event)27 Test (org.junit.Test)15 SyntaxToEvent (org.opennms.netmgt.model.events.snmp.SyntaxToEvent)12 EventBuilder (org.opennms.netmgt.model.events.EventBuilder)6 Events (org.opennms.netmgt.xml.eventconf.Events)4 Varbindsdecode (org.opennms.netmgt.xml.eventconf.Varbindsdecode)4 File (java.io.File)3 List (java.util.List)3 Mask (org.opennms.netmgt.xml.eventconf.Mask)3 Maskelement (org.opennms.netmgt.xml.eventconf.Maskelement)3 ArrayList (java.util.ArrayList)2 TreeMap (java.util.TreeMap)2 FieldGroup (com.vaadin.data.fieldgroup.FieldGroup)1 ComboBox (com.vaadin.ui.ComboBox)1 TextField (com.vaadin.ui.TextField)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 StringWriter (java.io.StringWriter)1 Map (java.util.Map)1 Mib (net.percederberg.mibble.Mib)1 AlarmData (org.opennms.netmgt.xml.eventconf.AlarmData)1