use of alma.acs.alarmsystem.generated.FaultMember in project ACS by ACS-Community.
the class AlarmManagerTest method testDeleteFaultMember.
public void testDeleteFaultMember() throws Exception {
_am = AlarmManager.getInstance(_daoManager.getAlarmDAO());
_am.loadFromCDB();
List<FaultFamily> ff1 = _am.getAllAlarms();
assertNotNull(ff1);
int size1 = ff1.get(0).getFaultMember().length;
assertTrue(_am.deleteFaultMember(ff1.get(0), ff1.get(0).getFaultMember(0)));
int size2 = ff1.get(0).getFaultMember().length;
assertEquals(size1, size2 + 1);
boolean exception = false;
try {
_am.deleteFaultMember(null, ff1.get(0).getFaultMember(0));
} catch (NullPointerException e) {
exception = true;
}
assertTrue(exception);
exception = false;
try {
_am.deleteFaultMember(ff1.get(0), null);
} catch (NullPointerException e) {
exception = true;
}
assertTrue(exception);
exception = false;
try {
_am.deleteFaultMember(null, null);
} catch (NullPointerException e) {
exception = true;
}
assertTrue(exception);
FaultFamily ff = new FaultFamily();
ff.addFaultMember(new FaultMember());
exception = false;
try {
_am.deleteFaultMember(ff, ff.getFaultMember(0));
} catch (NullPointerException e) {
exception = true;
}
assertTrue(exception);
ff.setName("foobar");
ff.getFaultMember(0).setName("foobar");
assertFalse(_am.deleteFaultMember(ff, ff.getFaultMember(0)));
}
use of alma.acs.alarmsystem.generated.FaultMember 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);
}
Aggregations