Search in sources :

Example 21 with FaultMember

use of alma.acs.alarmsystem.generated.FaultMember in project ACS by ACS-Community.

the class AlarmManagerTest method testDeleteFaultMember.

public void testDeleteFaultMember() throws Exception {
    _am = AlarmManager.getInstance(_daoManager.getAlarmDAO());
    _am.loadFromCDB();
    List<FaultFamily> ff1 = _am.getAllAlarms();
    assertNotNull(ff1);
    int size1 = ff1.get(0).getFaultMember().length;
    assertTrue(_am.deleteFaultMember(ff1.get(0), ff1.get(0).getFaultMember(0)));
    int size2 = ff1.get(0).getFaultMember().length;
    assertEquals(size1, size2 + 1);
    boolean exception = false;
    try {
        _am.deleteFaultMember(null, ff1.get(0).getFaultMember(0));
    } catch (NullPointerException e) {
        exception = true;
    }
    assertTrue(exception);
    exception = false;
    try {
        _am.deleteFaultMember(ff1.get(0), null);
    } catch (NullPointerException e) {
        exception = true;
    }
    assertTrue(exception);
    exception = false;
    try {
        _am.deleteFaultMember(null, null);
    } catch (NullPointerException e) {
        exception = true;
    }
    assertTrue(exception);
    FaultFamily ff = new FaultFamily();
    ff.addFaultMember(new FaultMember());
    exception = false;
    try {
        _am.deleteFaultMember(ff, ff.getFaultMember(0));
    } catch (NullPointerException e) {
        exception = true;
    }
    assertTrue(exception);
    ff.setName("foobar");
    ff.getFaultMember(0).setName("foobar");
    assertFalse(_am.deleteFaultMember(ff, ff.getFaultMember(0)));
}
Also used : FaultMember(alma.acs.alarmsystem.generated.FaultMember) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily)

Example 22 with FaultMember

use of alma.acs.alarmsystem.generated.FaultMember in project ACS by ACS-Community.

the class AlarmManagerTest method testAddFaultMember.

public void testAddFaultMember() throws Exception {
    boolean exception = false;
    _am = AlarmManager.getInstance(_daoManager.getAlarmDAO());
    _am.loadFromCDB();
    List<FaultFamily> ff1 = _am.getAllAlarms();
    assertNotNull(ff1);
    int size1, size2;
    size1 = ff1.get(0).getFaultMemberCount();
    try {
        _am.addFaultMember(ff1.get(0), null);
    } catch (NullPointerException e) {
        exception = true;
    }
    assertTrue(exception);
    size2 = ff1.get(0).getFaultMemberCount();
    assertEquals(size1, size2);
    FaultMember fm = new FaultMember();
    exception = false;
    size1 = ff1.get(0).getFaultMemberCount();
    try {
        _am.addFaultMember(ff1.get(0), fm);
    } catch (NullPointerException e) {
        exception = true;
    }
    assertTrue(exception);
    size2 = ff1.get(0).getFaultMemberCount();
    assertEquals(size1, size2);
    exception = false;
    size1 = ff1.get(0).getFaultMemberCount();
    fm.setName("foobar");
    try {
        _am.addFaultMember(ff1.get(0), fm);
    } catch (Exception e) {
        exception = true;
    }
    assertFalse(exception);
    size2 = ff1.get(0).getFaultMemberCount();
    assertEquals(size1, size2 - 1);
    exception = false;
    size1 = ff1.get(0).getFaultMemberCount();
    fm = new FaultMember();
    fm.setName("foobar");
    try {
        _am.addFaultMember(ff1.get(0), fm);
    } catch (Exception e) {
        exception = true;
    }
    assertTrue(exception);
    size2 = ff1.get(0).getFaultMemberCount();
    assertEquals(size1, size2);
    exception = false;
    size1 = ff1.get(0).getFaultMemberCount();
    fm = new FaultMember();
    fm.setName("foobar2");
    try {
        _am.addFaultMember(ff1.get(0), fm);
    } catch (Exception e) {
        exception = true;
    }
    assertFalse(exception);
    size2 = ff1.get(0).getFaultMemberCount();
    assertEquals(size1, size2 - 1);
}
Also used : FaultMember(alma.acs.alarmsystem.generated.FaultMember) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily)

Aggregations

FaultMember (alma.acs.alarmsystem.generated.FaultMember)22 FaultFamily (alma.acs.alarmsystem.generated.FaultFamily)19 FaultCode (alma.acs.alarmsystem.generated.FaultCode)12 FaultMemberDefault (alma.acs.alarmsystem.generated.FaultMemberDefault)7 Contact (alma.acs.alarmsystem.generated.Contact)6 Alarm (cern.laser.business.data.Alarm)6 Location (alma.acs.alarmsystem.generated.Location)5 ArrayList (java.util.ArrayList)4 Point (org.eclipse.swt.graphics.Point)4 Triplet (cern.laser.business.data.Triplet)3 IllegalOperationException (cl.utfsm.acs.acg.core.IllegalOperationException)3 ReductionRule (cl.utfsm.acs.acg.core.ReductionRule)3 ACSAlarmDAOImpl (cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl)3 Vector (java.util.Vector)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 SelectionListener (org.eclipse.swt.events.SelectionListener)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Event (org.eclipse.swt.widgets.Event)3 TreeItem (org.eclipse.swt.widgets.TreeItem)3