Search in sources :

Example 16 with Alarm

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

the class AlarmCategoryClientTest method setUp.

/**
	 * @see extends ComponentClientTestCase
	 */
public void setUp() throws Exception {
    super.setUp();
    categoryClient = new AlarmCategoryClient(getContainerServices());
    assertNotNull(categoryClient);
    AlarmFilter filter = new AlarmFilter(null, null, 2, 2);
    filteredLister = new AlarmListenerForTesting("Filtered_listener");
    assertNotNull(filteredLister);
    categoryClient.addAlarmListener(this);
    categoryClient.addAlarmListener(filteredLister, filter);
    statListener = new AlrmStatListenerForTesting();
    assertNotNull(statListener);
    categoryClient.addStatsListener(statListener);
    alarmsReceived = new Vector<Alarm>();
}
Also used : AlarmCategoryClient(alma.alarmsystem.clients.AlarmCategoryClient) Alarm(cern.laser.client.data.Alarm) AlarmListenerForTesting(alma.alarmsystem.clients.test.utils.AlarmListenerForTesting) AlrmStatListenerForTesting(alma.alarmsystem.clients.test.utils.AlrmStatListenerForTesting) AlarmFilter(alma.alarmsystem.clients.alarm.AlarmFilter)

Example 17 with Alarm

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

the class CategoryClientTest method setUp.

/**
	 * @see extends ComponentClientTestCase
	 */
public void setUp() throws Exception {
    super.setUp();
    categoryClient = new CategoryClient(getContainerServices());
    assertNotNull(categoryClient);
    alarmsReceived = new Vector<Alarm>();
}
Also used : Alarm(cern.laser.client.data.Alarm) CategoryClient(alma.alarmsystem.clients.CategoryClient)

Example 18 with Alarm

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

the class SpecialAlarmTest method testCreateSpecialAlarmWronglURL.

/**
	 * Test the creation of the alarm when the URL is <code>null</code>.
	 */
public void testCreateSpecialAlarmWronglURL() throws Exception {
    Alarm alarmNull = new SpecialAlarm(family, member, code, true, action, description, cause, consequences, priority, null, email, props);
    assertNull(alarmNull.getHelpURL());
    Alarm alarmEmpty = new SpecialAlarm(family, member, code, true, action, description, cause, consequences, priority, "", email, props);
    assertNull(alarmEmpty.getHelpURL());
}
Also used : Alarm(cern.laser.client.data.Alarm) SpecialAlarm(alma.acsplugins.alarmsystem.gui.specialalarm.SpecialAlarm) SpecialAlarm(alma.acsplugins.alarmsystem.gui.specialalarm.SpecialAlarm)

Example 19 with Alarm

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

the class AlarmContainerTest method populateContainer.

/**
	 * Populate the container with the passed number of randomly generated alarms.
	 * 
	 * @param size The number of alarms to add to the container 
	 * @param fm The fault family of the added alarms
	 * @param generatedAlarms A <code>Collection</code> containing the generated alarms;
	 * 						it can be <code>null</code>; if it is not null, the newly generated
	 * 						alarms are added to the collection.
	 * @param entries The <code>AlarmtableEntry</code> generated while adding alarms to the container
	 * 				it can be <code>null</code>; if it is not <code>null</code>, the newly generated
	 * 						entries are added to the collection.
	 * 					
	 * @return The number of not reduced alarms in the collection
	 */
private int populateContainer(int size, String fm, Collection<Alarm> generatedAlarms, Collection<AlarmTableEntry> entries) throws Exception {
    int notReduced = 0;
    int originalCollectionAlarmsSize = 0;
    if (generatedAlarms != null) {
        originalCollectionAlarmsSize = generatedAlarms.size();
    }
    int originalCollectionEntriesSize = 0;
    if (entries != null) {
        originalCollectionEntriesSize = entries.size();
    }
    for (int t = 0; t < size; t++) {
        Alarm alarm = TestAlarm.generateRndAlarm(fm);
        if (generatedAlarms != null) {
            generatedAlarms.add(alarm);
        }
        if (!alarm.getStatus().isReduced()) {
            notReduced++;
        }
        container.add(new AlarmTableEntry(alarm));
    }
    if (generatedAlarms != null) {
        assertEquals(size, generatedAlarms.size() - originalCollectionAlarmsSize);
    }
    if (entries != null) {
        assertEquals(size, entries.size() - originalCollectionEntriesSize);
    }
    return notReduced;
}
Also used : Alarm(cern.laser.client.data.Alarm) AlarmTableEntry(alma.acsplugins.alarmsystem.gui.table.AlarmTableEntry)

Example 20 with Alarm

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

the class AlarmContainerTest method testAlarmsRemove.

/**
	 * Test the removal of alarms
	 * 
	 * @throws Exception
	 */
public void testAlarmsRemove() throws Exception {
    // Add some alarms
    int notReduced = 0;
    Vector<Alarm> alarms = new Vector<Alarm>();
    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));
    // Trying to remove an alarm not in the container throws an exception
    Alarm al = TestAlarm.generateRndAlarm("EXCEPTION");
    boolean exceptionOccurred = false;
    try {
        container.remove(new AlarmTableEntry(al));
    } catch (AlarmContainerException e) {
        exceptionOccurred = true;
    }
    assertTrue(exceptionOccurred);
    // Remove all the alarms checking the number of alarms in the container
    int sz = CONTAINER_SIZE / 2;
    int reducedToRemove = notReduced;
    for (Alarm removedAlarm : alarms) {
        container.remove(new AlarmTableEntry(removedAlarm));
        sz--;
        if (!removedAlarm.getStatus().isReduced()) {
            reducedToRemove--;
        }
        class EDTReader2 implements Runnable {

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

            private final int reducedToRemove;

            EDTReader2(int sz, int reducedToRemove) {
                this.sz = sz;
                this.reducedToRemove = reducedToRemove;
            }

            public void run() {
                assertEquals(sz, container.size(false));
                assertEquals(reducedToRemove, container.size(true));
            }
        }
        EDTExecutor.instance().executeSync(new EDTReader2(sz, reducedToRemove));
    }
    // The container is empty
    EDTExecutor.instance().executeSync(new Runnable() {

        @Override
        public void run() {
            assertEquals(0, container.size(false));
            assertEquals(0, container.size(true));
        }
    });
}
Also used : Alarm(cern.laser.client.data.Alarm) AlarmTableEntry(alma.acsplugins.alarmsystem.gui.table.AlarmTableEntry) Vector(java.util.Vector) AlarmContainerException(alma.acsplugins.alarmsystem.gui.table.AlarmsContainer.AlarmContainerException)

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