Hello everyone,

I’m working on the issue NMS-8011 [1]. The code change so far is not 
complicated [2]. I’ve spent some time to figure out how to create a Unit test 
for this behavior and dived into AlarmdIT [3].

The testPersistAlarm() [4] seems like has everything I need to create a test. 
Try to understand the code in the integration test. Instead of dealing with 
native SQL statements, I thought using the existing Alarm Data Access Object 
(AlarmDaoHibernate) [5] has just get() and find() methods.

Investigating some more, I’ve found a AlarmPersisterImpl() [6] which has a 
persist() method but takes Events. It seems the method does not just persist an 
Alarm it just forwards the Event to addOrReduceEventsAsAlarm() and struggled to 
get the following test scenario implemented:

- No alarm exist: Send event with reduction key and result should be *one* alarm
- One alarm with reduction key exist: Send event with matching reduction key 
and result should be *one* alarm
- One alarm cleared exist: Send event with matching reduction key and result 
should be *one* alarm
- One alarm acknowledged exist: Send event with matching reduction key and 
result should be *one* alarm
- One alarm acknowledged *and* cleared exist: Send event with matching 
reduction key and result should be *two* alarms

Any hints welcome and thank you in advance.

[1] http://issues.opennms.org/browse/NMS-8011 
<http://issues.opennms.org/browse/NMS-8011>
[2] https://github.com/OpenNMS/opennms/pull/519 
<https://github.com/OpenNMS/opennms/pull/519>
[3] 
https://github.com/OpenNMS/opennms/blob/develop/opennms-alarms/daemon/src/test/java/org/opennms/netmgt/alarmd/AlarmdIT.java
 
<https://github.com/OpenNMS/opennms/blob/develop/opennms-alarms/daemon/src/test/java/org/opennms/netmgt/alarmd/AlarmdIT.java>
[4] 
https://github.com/OpenNMS/opennms/blob/develop/opennms-alarms/daemon/src/test/java/org/opennms/netmgt/alarmd/AlarmdIT.java#L181
 
<https://github.com/OpenNMS/opennms/blob/develop/opennms-alarms/daemon/src/test/java/org/opennms/netmgt/alarmd/AlarmdIT.java#L181>
[5] 
https://github.com/OpenNMS/opennms/blob/develop/opennms-dao/src/main/java/org/opennms/netmgt/dao/hibernate/AlarmDaoHibernate.java
 
<https://github.com/OpenNMS/opennms/blob/develop/opennms-dao/src/main/java/org/opennms/netmgt/dao/hibernate/AlarmDaoHibernate.java>
[6] 
https://github.com/OpenNMS/opennms/blob/develop/opennms-alarms/daemon/src/main/java/org/opennms/netmgt/alarmd/AlarmPersisterImpl.java
 
<https://github.com/OpenNMS/opennms/blob/develop/opennms-alarms/daemon/src/main/java/org/opennms/netmgt/alarmd/AlarmPersisterImpl.java>

--
Ronny Trommer, OGP
Germany :: Fulda :: Stuttgart
Web: http://www.opennms.org <http://www.opennms.org/>

PGP Key Fingerprint: 4A1B 4D06 FEEC 244D 38EF  8074 9075 B2E5 08A2 451E
PGP Key Server1: https://keyserver.pgp.com <https://keyserver.pgp.com/>
PGP Key Server2: http://pgp.mit.edu/ <http://pgp.mit.edu/>





Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

------------------------------------------------------------------------------
_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/index.php/Mailing_List_FAQ

opennms-devel mailing list

To *unsubscribe* or change your subscription options, see the bottom of this 
page:
https://lists.sourceforge.net/lists/listinfo/opennms-devel

Reply via email to