use of org.opennms.netmgt.xml.eventconf.Logmsg in project opennms by OpenNMS.
the class Mib2Events method getTrapEventLogmsg.
public Logmsg getTrapEventLogmsg(MibValueSymbol trapValueSymbol) {
Logmsg msg = new Logmsg();
msg.setDest("logndisplay");
final StringBuffer dbuf = new StringBuffer();
dbuf.append("<p>");
dbuf.append("\n");
dbuf.append("\t").append(trapValueSymbol.getName()).append(" trap received\n");
int vbNum = 1;
for (MibValue vb : getTrapVars(trapValueSymbol)) {
dbuf.append("\t").append(vb.getName()).append("=%parm[#").append(vbNum).append("]%\n");
vbNum++;
}
if (dbuf.charAt(dbuf.length() - 1) == '\n') {
// delete the \n at the end
dbuf.deleteCharAt(dbuf.length() - 1);
}
dbuf.append("</p>\n\t");
msg.setContent(dbuf.toString());
return msg;
}
use of org.opennms.netmgt.xml.eventconf.Logmsg in project opennms by OpenNMS.
the class EventConfDataTest method anticipateAndSend.
public void anticipateAndSend(String event, Event snmp) {
/*
if (event != null) {
createEvent(event);
}
*/
org.opennms.netmgt.xml.eventconf.Event econf = eventConfDao.findByEvent(snmp);
System.out.println("Eventconf: " + (econf == null ? null : new EventConfWrapper(econf)));
if (event != null) {
if (econf == null) {
fail("Was expecting to match an eventconf with a UEI of \"" + event + "\", but no matching eventconf was found.");
} else {
if (!event.equals(econf.getUei())) {
fail("Was expecting to match an eventconf with a UEI of \"" + event + "\", but received an eventconf with a UEI of \"" + econf.getUei() + "\"");
}
// everything's fine
}
} else {
if (econf != null) {
boolean complain = true;
Logmsg logmsg = econf.getLogmsg();
if (logmsg != null) {
LogDestType dest = logmsg.getDest();
if (LogDestType.DISCARDTRAPS.equals(dest)) {
complain = false;
}
}
if (complain) {
fail("Was not expecting an eventconf, but received an eventconf with " + "an UEI of \"" + econf.getUei() + "\"");
}
}
// everything's fine
}
finishUp();
}
Aggregations