Search in sources :

Example 21 with Alarm

use of cern.laser.client.data.Alarm in project ACS by ACS-Community.

the class AlarmContainerTest method testRemoveOldest.

/**
	 * Test <code>removeOldest()</code>
	 * 
	 * @throws Exception
	 */
public void testRemoveOldest() throws Exception {
    // Add some alarms
    final Vector<Alarm> alarms = new Vector<Alarm>();
    int notReduced = populateContainer(CONTAINER_SIZE / 2, "TEST", alarms, null);
    class EDTReader implements Runnable {

        // The value to check after reading from EDT
        private final int value;

        EDTReader(int val) {
            value = val;
        }

        public void run() {
            assertEquals("Wrong not reduced size", CONTAINER_SIZE / 2, container.size(false));
            assertEquals("Wrong reduced size", value, container.size(true));
        }
    }
    EDTExecutor.instance().executeSync(new EDTReader(notReduced));
    final AlarmTableEntry removedEntry = container.removeOldest();
    assertNotNull(removedEntry);
    // Check the sizes
    class EDTReader2 implements Runnable {

        // The value to check after reading from EDT
        private final int notReduced;

        EDTReader2(int notReduced) {
            this.notReduced = notReduced;
        }

        public void run() {
            assertEquals(alarms.size() - 1, container.size(false));
            if (removedEntry.isReduced()) {
                assertEquals(notReduced, container.size(true));
            } else {
                assertEquals(notReduced - 1, container.size(true));
            }
        }
    }
    EDTExecutor.instance().executeSync(new EDTReader2(notReduced));
    // Check if removed alarms was the oldest alarm
    assertEquals(alarms.get(0).getAlarmId(), removedEntry.getAlarmId());
}
Also used : Alarm(cern.laser.client.data.Alarm) AlarmTableEntry(alma.acsplugins.alarmsystem.gui.table.AlarmTableEntry) Vector(java.util.Vector)

Aggregations

Alarm (cern.laser.client.data.Alarm)21 AlarmTableEntry (alma.acsplugins.alarmsystem.gui.table.AlarmTableEntry)4 AlarmClientException (alma.alarmsystem.clients.alarm.AlarmClientException)4 Vector (java.util.Vector)4 SpecialAlarm (alma.acsplugins.alarmsystem.gui.specialalarm.SpecialAlarm)2 CategoryClient (alma.alarmsystem.clients.CategoryClient)2 LaserSelectionException (cern.laser.client.services.selection.LaserSelectionException)2 Properties (java.util.Properties)2 AlarmGUIType (alma.acsplugins.alarmsystem.gui.table.AlarmGUIType)1 AlarmContainerException (alma.acsplugins.alarmsystem.gui.table.AlarmsContainer.AlarmContainerException)1 AlarmSelectionListener (alma.acsplugins.alarmsystem.gui.viewcoordination.ViewCoordinator.AlarmSelectionListener)1 Category (alma.alarmsystem.Category)1 AlarmCategoryClient (alma.alarmsystem.clients.AlarmCategoryClient)1 SourceClient (alma.alarmsystem.clients.SourceClient)1 AlarmFilter (alma.alarmsystem.clients.alarm.AlarmFilter)1 AlarmListenerForTesting (alma.alarmsystem.clients.test.utils.AlarmListenerForTesting)1 AlrmStatListenerForTesting (alma.alarmsystem.clients.test.utils.AlrmStatListenerForTesting)1 CernAlarmServiceUtils (alma.alarmsystem.corbaservice.CernAlarmServiceUtils)1 AcsJCannotGetComponentEx (alma.maciErrType.wrappers.AcsJCannotGetComponentEx)1 AlarmImpl (cern.laser.business.data.AlarmImpl)1