Search in sources :

Example 1 with AlarmForTesting

use of alma.alarmsystem.clients.test.utils.AlarmForTesting in project ACS by ACS-Community.

the class AlarmStatisticsTest method testUpdateAlarm.

/**
	 * Now that the updating of a filed works as expected, we check
	 * if updating for an alarm is updating the right fields
	 * 
	 * @throws Exception
	 */
public void testUpdateAlarm() throws Exception {
    AlarmForTesting alarm = new AlarmForTesting("faultFamily", "faultMember", 0, 1, true, false, false);
    stats.update(alarm);
    assertEquals(1, stats.getStatValue(AlarmStatField.ACTIVE).intValue());
    assertEquals(1, stats.getStatValue(AlarmStatField.PRI1).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.PRI2).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.PRI3).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.PRI4).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.MASKED).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.REDUCED).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.MULTIPLICITY_CHILD).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.MULTIPLICITY_PARENT).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.NODE_CHILD).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.NODE_PARENT).intValue());
    alarm.priority = 2;
    stats.update(alarm);
    assertEquals(2, stats.getStatValue(AlarmStatField.ACTIVE).intValue());
    assertEquals(1, stats.getStatValue(AlarmStatField.PRI1).intValue());
    assertEquals(1, stats.getStatValue(AlarmStatField.PRI2).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.PRI3).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.PRI4).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.MASKED).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.REDUCED).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.MULTIPLICITY_CHILD).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.MULTIPLICITY_PARENT).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.NODE_CHILD).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.NODE_PARENT).intValue());
    alarm.priority = 3;
    stats.update(alarm);
    assertEquals(3, stats.getStatValue(AlarmStatField.ACTIVE).intValue());
    assertEquals(1, stats.getStatValue(AlarmStatField.PRI1).intValue());
    assertEquals(1, stats.getStatValue(AlarmStatField.PRI2).intValue());
    assertEquals(1, stats.getStatValue(AlarmStatField.PRI3).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.PRI4).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.MASKED).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.REDUCED).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.MULTIPLICITY_CHILD).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.MULTIPLICITY_PARENT).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.NODE_CHILD).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.NODE_PARENT).intValue());
    alarm.priority = 4;
    stats.update(alarm);
    assertEquals(4, stats.getStatValue(AlarmStatField.ACTIVE).intValue());
    assertEquals(1, stats.getStatValue(AlarmStatField.PRI1).intValue());
    assertEquals(1, stats.getStatValue(AlarmStatField.PRI2).intValue());
    assertEquals(1, stats.getStatValue(AlarmStatField.PRI3).intValue());
    assertEquals(1, stats.getStatValue(AlarmStatField.PRI4).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.MASKED).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.REDUCED).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.MULTIPLICITY_CHILD).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.MULTIPLICITY_PARENT).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.NODE_CHILD).intValue());
    assertEquals(0, stats.getStatValue(AlarmStatField.NODE_PARENT).intValue());
}
Also used : AlarmForTesting(alma.alarmsystem.clients.test.utils.AlarmForTesting)

Example 2 with AlarmForTesting

use of alma.alarmsystem.clients.test.utils.AlarmForTesting in project ACS by ACS-Community.

the class AlarmListenerContainerTest method testDispatchAlarms.

/**
	 * Test the dispatching of alarms
	 * 
	 * {@link AlarmListenerForTesting} prints received alarms on the stdout.
	 * 
	 * This test checks the number of alarms received by 2 listeners:
	 * <OL>
	 * 	<LI>The un-filtered listener must receive all the notifications
	 *  <LI>The filtered listener must be notified only for alarms that pass the filter
	 * </OL>
	 * 
	 * This test checks if the filter is applied. 
	 * The correctness of the filtering is tested by {@link AlarmFilterTest}
	 */
public void testDispatchAlarms() throws Exception {
    // Instantiates 2 listeners one un-filtered and one filtered
    assertEquals(0, container.getAlarmListenersSize());
    AlarmListenerForTesting alarmL1 = new AlarmListenerForTesting("Unfiltered-listener");
    // Unfiltered
    AlarmListener listener1 = container.addAlarmListener(alarmL1);
    assertNotNull(listener1);
    AlarmFilter filter = new AlarmFilter(null, null, 10, 25);
    AlarmListenerForTesting alarmL2 = new AlarmListenerForTesting("Filtered-listener");
    // Filtered
    AlarmListener listener2 = container.addAlarmListener(alarmL2, filter);
    assertNotNull(listener2);
    assertEquals(2, container.getAlarmListenersSize());
    assertEquals(0, container.getStatListenersSize());
    int numOfAlarmsToDispatch = 50;
    for (int t = 1; t < numOfAlarmsToDispatch + 1; t++) {
        AlarmForTesting alarm = new AlarmForTesting("faultFamily", "faultMember", t, 2, true, false, true);
        container.dispatchAlarm(alarm);
        assertEquals(t, alarmL1.numAlarms);
    }
    // Filtered listeners is supposed to receive less alarms
    // i.e. all the alarms whose FC is in [10,15]
    assertEquals(16, alarmL2.numAlarms);
}
Also used : AlarmForTesting(alma.alarmsystem.clients.test.utils.AlarmForTesting) AlarmListenerForTesting(alma.alarmsystem.clients.test.utils.AlarmListenerForTesting) AlarmListener(alma.alarmsystem.clients.alarm.AlarmListenersContainer.AlarmListener) AlarmFilter(alma.alarmsystem.clients.alarm.AlarmFilter)

Aggregations

AlarmForTesting (alma.alarmsystem.clients.test.utils.AlarmForTesting)2 AlarmFilter (alma.alarmsystem.clients.alarm.AlarmFilter)1 AlarmListener (alma.alarmsystem.clients.alarm.AlarmListenersContainer.AlarmListener)1 AlarmListenerForTesting (alma.alarmsystem.clients.test.utils.AlarmListenerForTesting)1