Search in sources :

Example 46 with FaultFamily

use of alma.acs.alarmsystem.generated.FaultFamily 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)

Example 47 with FaultFamily

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

the class AlarmManagerTest method testDeleteFaultCode.

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

Aggregations

FaultFamily (alma.acs.alarmsystem.generated.FaultFamily)47 FaultCode (alma.acs.alarmsystem.generated.FaultCode)19 FaultMember (alma.acs.alarmsystem.generated.FaultMember)19 Vector (java.util.Vector)14 ACSAlarmDAOImpl (cl.utfsm.acs.acg.dao.ACSAlarmDAOImpl)11 Contact (alma.acs.alarmsystem.generated.Contact)7 FaultMemberDefault (alma.acs.alarmsystem.generated.FaultMemberDefault)7 Point (org.eclipse.swt.graphics.Point)7 Alarm (cern.laser.business.data.Alarm)6 MalformedURLException (java.net.MalformedURLException)6 ArrayList (java.util.ArrayList)5 ValidationException (org.exolab.castor.xml.ValidationException)5 Category (alma.acs.alarmsystem.generated.Category)4 Location (alma.acs.alarmsystem.generated.Location)4 LaserObjectNotFoundException (cern.laser.business.LaserObjectNotFoundException)4 Source (cern.laser.business.data.Source)4 Alarms (alma.acs.alarmsystem.generated.Alarms)3 Triplet (cern.laser.business.data.Triplet)3 IllegalOperationException (cl.utfsm.acs.acg.core.IllegalOperationException)3 ReductionRule (cl.utfsm.acs.acg.core.ReductionRule)3