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));
}
}
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());
}
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()));
}
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);
}
}
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;
}
Aggregations