Search in sources :

Example 11 with FaultFamily

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

the class AlarmManagerTest method testDeleteFaultFamily.

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

Example 12 with FaultFamily

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

the class AlarmManagerTest method testUpdateFaultCode.

public void testUpdateFaultCode() throws Exception {
    boolean exception = false;
    _am = AlarmManager.getInstance(_daoManager.getAlarmDAO());
    _am.loadFromCDB();
    List<FaultFamily> ff1 = _am.getAllAlarms();
    assertNotNull(ff1);
    FaultFamily ff;
    FaultCode fc, fcm;
    int size1;
    int size2;
    ff = new FaultFamily();
    size1 = ff1.get(0).getFaultCodeCount();
    try {
        _am.updateFaultCode(null, null, null);
    } catch (NullPointerException e) {
        exception = true;
    }
    assertTrue(exception);
    size2 = ff1.get(0).getFaultCodeCount();
    assertEquals(size1, size2);
    exception = false;
    size1 = ff1.get(0).getFaultCodeCount();
    try {
        _am.updateFaultCode(ff, null, null);
    } catch (NullPointerException e) {
        exception = true;
    }
    assertTrue(exception);
    size2 = ff1.get(0).getFaultCodeCount();
    assertEquals(size1, size2);
    ff.setName("foo");
    fc = new FaultCode();
    exception = false;
    size1 = ff1.get(0).getFaultCodeCount();
    try {
        _am.updateFaultCode(ff, fc, null);
    } catch (NullPointerException e) {
        exception = true;
    }
    assertTrue(exception);
    size2 = ff1.get(0).getFaultCodeCount();
    assertEquals(size1, size2);
    fcm = new FaultCode();
    exception = false;
    size1 = ff1.get(0).getFaultCodeCount();
    try {
        _am.updateFaultCode(ff, null, fcm);
    } catch (NullPointerException e) {
        exception = true;
    }
    assertTrue(exception);
    size2 = ff1.get(0).getFaultCodeCount();
    assertEquals(size1, size2);
    exception = false;
    ff.setName(ff1.get(0).getName());
    fc.setValue(10342);
    fcm.setValue(10343);
    size1 = ff1.get(0).getFaultCodeCount();
    try {
        _am.updateFaultCode(ff, fc, fcm);
    } catch (IllegalOperationException e) {
        exception = true;
    }
    assertTrue(exception);
    size2 = ff1.get(0).getFaultCodeCount();
    assertEquals(size1, size2);
    exception = false;
    size1 = ff1.get(0).getFaultCodeCount();
    try {
        _am.addFaultCode(ff, fc);
    } catch (IllegalOperationException e) {
        exception = true;
    }
    assertFalse(exception);
    size2 = ff1.get(0).getFaultCodeCount();
    assertEquals(size1, size2 - 1);
    exception = false;
    size1 = ff1.get(0).getFaultCodeCount();
    try {
        _am.updateFaultCode(ff, fc, fcm);
    } catch (IllegalOperationException e) {
        exception = true;
    }
    assertFalse(exception);
    size2 = ff1.get(0).getFaultCodeCount();
    assertEquals(size1, size2);
    assertNotNull(_am.getFaultCode(ff1.get(0).getName(), 10343));
}
Also used : FaultCode(alma.acs.alarmsystem.generated.FaultCode) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily)

Example 13 with FaultFamily

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

the class AlarmManagerTest method testGetFaultMember.

public void testGetFaultMember() {
    _am = AlarmManager.getInstance(_daoManager.getAlarmDAO());
    _am.loadFromCDB();
    List<FaultFamily> ffList = _am.getAllAlarms();
    assertNotNull(ffList);
    for (FaultFamily faultFamily : ffList) {
        FaultMember[] members = faultFamily.getFaultMember();
        assertNotNull(members);
        for (int i = 0; i < members.length; i++) {
            FaultMember member = _am.getFaultMember(faultFamily.getName(), members[i].getName());
            assertNotNull(member);
            assertEquals(member.getName(), members[i].getName());
            if (member.getLocation() != null) {
                assertEquals(member.getLocation().getBuilding(), members[i].getLocation().getBuilding());
                assertEquals(member.getLocation().getFloor(), members[i].getLocation().getFloor());
                assertEquals(member.getLocation().getRoom(), members[i].getLocation().getRoom());
                assertEquals(member.getLocation().getMnemonic(), members[i].getLocation().getMnemonic());
                assertEquals(member.getLocation().getPosition(), members[i].getLocation().getPosition());
            }
        }
    }
}
Also used : FaultMember(alma.acs.alarmsystem.generated.FaultMember) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily)

Example 14 with FaultFamily

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

the class AlarmManagerTest method testAddFaultFamily.

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

Example 15 with FaultFamily

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

the class AlarmsView method sortFaultFamilyList.

public void sortFaultFamilyList() {
    List<FaultFamily> ffList = _alarmManager.getAllAlarms();
    List<FaultFamily> sortedFFList = new ArrayList<FaultFamily>();
    /* We get a separate tmp list with the names,
		 * sort it, and then sort the original ffList */
    List<String> tmp = new ArrayList<String>();
    for (FaultFamily ff : ffList) tmp.add(ff.getName().toLowerCase());
    Collections.sort(tmp);
    for (String sff : tmp) for (FaultFamily ff : ffList) if (ff.getName().toLowerCase().compareTo(sff) == 0)
        sortedFFList.add(ff);
    ffList = sortedFFList;
    _tree.removeAll();
    for (FaultFamily family : ffList) {
        TreeItem iTree = new TreeItem(_tree, SWT.NONE);
        iTree.setData(NodeType.FAULT_FAMILY);
        iTree.setText(family.getName());
        iTree.setImage(Activator.getDefault().getImageRegistry().get(Activator.IMG_ALARM));
        for (int j = 0; j != 2; j++) {
            TreeItem jTree = new TreeItem(iTree, SWT.NONE);
            jTree.setText((j == 0 ? "Fault Codes" : "Fault Members"));
            jTree.setData((j == 0 ? NodeType.FAULT_CODE_LIST : NodeType.FAULT_MEMBER_LIST));
            jTree.setImage((j == 0 ? Activator.getDefault().getImageRegistry().get(Activator.IMG_FAULTCODES) : Activator.getDefault().getImageRegistry().get(Activator.IMG_FAULTMEMBERS)));
            if (j == 0)
                sortFaultCodeList(family, jTree);
            else
                sortFaultMemberList(family, jTree);
        }
    }
}
Also used : FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) TreeItem(org.eclipse.swt.widgets.TreeItem) ArrayList(java.util.ArrayList) Point(org.eclipse.swt.graphics.Point)

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