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