Search in sources :

Example 21 with FaultCode

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

the class AlarmManagerTest method testAddFaultCode.

public void testAddFaultCode() 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).getFaultCodeCount();
    try {
        _am.addFaultCode(ff1.get(0), null);
    } catch (NullPointerException e) {
        exception = true;
    }
    assertTrue(exception);
    size2 = ff1.get(0).getFaultCodeCount();
    assertEquals(size1, size2);
    FaultCode fc = new FaultCode();
    exception = false;
    size1 = ff1.get(0).getFaultCodeCount();
    fc.setValue(10233);
    try {
        _am.addFaultCode(ff1.get(0), fc);
    } catch (Exception e) {
        exception = true;
    }
    assertFalse(exception);
    size2 = ff1.get(0).getFaultCodeCount();
    assertEquals(size1, size2 - 1);
    exception = false;
    size1 = ff1.get(0).getFaultCodeCount();
    fc = new FaultCode();
    fc.setValue(10233);
    try {
        _am.addFaultCode(ff1.get(0), fc);
    } catch (Exception e) {
        exception = true;
    }
    assertTrue(exception);
    size2 = ff1.get(0).getFaultCodeCount();
    assertEquals(size1, size2);
    exception = false;
    size1 = ff1.get(0).getFaultCodeCount();
    fc = new FaultCode();
    fc.setValue(10234);
    try {
        _am.addFaultCode(ff1.get(0), fc);
    } catch (Exception e) {
        exception = true;
    }
    assertFalse(exception);
    size2 = ff1.get(0).getFaultCodeCount();
    assertEquals(size1, size2 - 1);
}
Also used : FaultCode(alma.acs.alarmsystem.generated.FaultCode) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily)

Example 22 with FaultCode

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

FaultCode (alma.acs.alarmsystem.generated.FaultCode)22 FaultFamily (alma.acs.alarmsystem.generated.FaultFamily)19 FaultMember (alma.acs.alarmsystem.generated.FaultMember)12 Contact (alma.acs.alarmsystem.generated.Contact)6 FaultMemberDefault (alma.acs.alarmsystem.generated.FaultMemberDefault)6 Alarm (cern.laser.business.data.Alarm)6 Point (org.eclipse.swt.graphics.Point)5 Location (alma.acs.alarmsystem.generated.Location)4 ArrayList (java.util.ArrayList)4 TreeItem (org.eclipse.swt.widgets.TreeItem)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