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));
}
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));
}
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());
}
}
}
}
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);
}
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);
}
}
}
Aggregations