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