use of alma.acs.alarmsystem.generated.FaultFamily in project ACS by ACS-Community.
the class AlarmManagerTest method testUpdateFaultFamily.
public void testUpdateFaultFamily() throws Exception {
boolean exception = false;
_am = AlarmManager.getInstance(_daoManager.getAlarmDAO());
_am.loadFromCDB();
List<FaultFamily> ff1 = _am.getAllAlarms();
assertNotNull(ff1);
FaultFamily ff, ffm;
int size1;
int size2;
size1 = ff1.size();
try {
_am.updateFaultFamily(null, null);
} catch (NullPointerException e) {
exception = true;
}
assertTrue(exception);
size2 = ff1.size();
assertEquals(size1, size2);
ff = new FaultFamily();
exception = false;
size1 = ff1.size();
try {
_am.updateFaultFamily(ff, null);
} catch (NullPointerException e) {
exception = true;
}
assertTrue(exception);
size2 = ff1.size();
assertEquals(size1, size2);
exception = false;
size1 = ff1.size();
try {
_am.updateFaultFamily(null, ff);
} catch (NullPointerException e) {
exception = true;
}
assertTrue(exception);
size2 = ff1.size();
assertEquals(size1, size2);
ff.setName("foobar");
exception = false;
size1 = ff1.size();
try {
_am.updateFaultFamily(ff, null);
} catch (Exception e) {
exception = true;
}
assertTrue(exception);
size2 = ff1.size();
assertEquals(size1, size2);
exception = false;
size1 = ff1.size();
try {
_am.updateFaultFamily(null, ff);
} catch (Exception e) {
exception = true;
}
assertTrue(exception);
size2 = ff1.size();
assertEquals(size1, size2);
exception = false;
size1 = ff1.size();
ff = new FaultFamily();
ffm = new FaultFamily();
ff.setName("foobar");
ffm.setName("foobar2");
try {
_am.updateFaultFamily(ff, ffm);
} catch (IllegalOperationException e) {
exception = true;
}
assertTrue(exception);
size2 = ff1.size();
assertEquals(size1, size2);
exception = false;
size1 = ff1.size();
try {
_am.addFaultFamily(ff);
} catch (IllegalOperationException e) {
exception = true;
}
assertFalse(exception);
size2 = ff1.size();
assertEquals(size1, size2 - 1);
exception = false;
size1 = ff1.size();
try {
_am.updateFaultFamily(ff, ffm);
} catch (IllegalOperationException e) {
exception = true;
}
assertFalse(exception);
size2 = ff1.size();
assertEquals(size1, size2);
assertNotNull(_am.getFaultFamily("foobar2"));
}
use of alma.acs.alarmsystem.generated.FaultFamily in project ACS by ACS-Community.
the class AlarmManagerTest method testGetFaultCode.
public void testGetFaultCode() {
_am = AlarmManager.getInstance(_daoManager.getAlarmDAO());
_am.loadFromCDB();
List<FaultFamily> ffList = _am.getAllAlarms();
assertNotNull(ffList);
for (FaultFamily faultFamily : ffList) {
FaultCode[] codes = faultFamily.getFaultCode();
assertNotNull(codes);
for (int i = 0; i < codes.length; i++) {
FaultCode code = _am.getFaultCode(faultFamily.getName(), codes[i].getValue());
assertNotNull(code);
assertEquals(code.getAction(), codes[i].getAction());
assertEquals(code.getCause(), codes[i].getCause());
assertEquals(code.getConsequence(), codes[i].getConsequence());
assertEquals(code.getInstant(), codes[i].getInstant());
assertEquals(code.getPriority(), codes[i].getPriority());
assertEquals(code.getProblemDescription(), codes[i].getProblemDescription());
assertEquals(code.getValue(), codes[i].getValue());
}
}
}
use of alma.acs.alarmsystem.generated.FaultFamily 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.FaultFamily in project ACS by ACS-Community.
the class AlarmManagerTest method testUpdateFaultMember.
public void testUpdateFaultMember() throws Exception {
boolean exception = false;
_am = AlarmManager.getInstance(_daoManager.getAlarmDAO());
_am.loadFromCDB();
List<FaultFamily> ff1 = _am.getAllAlarms();
assertNotNull(ff1);
FaultFamily ff;
FaultMember fm, fmm;
int size1;
int size2;
ff = new FaultFamily();
size1 = ff1.get(0).getFaultMemberCount();
try {
_am.updateFaultMember(null, null, null);
} catch (NullPointerException e) {
exception = true;
}
assertTrue(exception);
size2 = ff1.get(0).getFaultMemberCount();
assertEquals(size1, size2);
exception = false;
size1 = ff1.get(0).getFaultMemberCount();
try {
_am.updateFaultMember(ff, null, null);
} catch (NullPointerException e) {
exception = true;
}
assertTrue(exception);
size2 = ff1.get(0).getFaultMemberCount();
assertEquals(size1, size2);
ff.setName("foo");
fm = new FaultMember();
exception = false;
size1 = ff1.get(0).getFaultMemberCount();
try {
_am.updateFaultMember(ff, fm, null);
} catch (NullPointerException e) {
exception = true;
}
assertTrue(exception);
size2 = ff1.get(0).getFaultMemberCount();
assertEquals(size1, size2);
fmm = new FaultMember();
exception = false;
size1 = ff1.get(0).getFaultMemberCount();
try {
_am.updateFaultMember(ff, null, fmm);
} catch (NullPointerException e) {
exception = true;
}
assertTrue(exception);
size2 = ff1.get(0).getFaultMemberCount();
assertEquals(size1, size2);
exception = false;
size1 = ff1.get(0).getFaultMemberCount();
try {
_am.updateFaultMember(ff, fm, fmm);
} catch (NullPointerException e) {
exception = true;
}
assertTrue(exception);
size2 = ff1.get(0).getFaultMemberCount();
assertEquals(size1, size2);
exception = false;
ff.setName(ff1.get(0).getName());
fm.setName("foobar");
fmm.setName("foobar2");
size1 = ff1.get(0).getFaultMemberCount();
try {
_am.updateFaultMember(ff, fm, fmm);
} catch (IllegalOperationException e) {
exception = true;
}
assertTrue(exception);
size2 = ff1.get(0).getFaultMemberCount();
assertEquals(size1, size2);
exception = false;
size1 = ff1.get(0).getFaultMemberCount();
try {
_am.addFaultMember(ff, fm);
} catch (IllegalOperationException e) {
exception = true;
}
assertFalse(exception);
size2 = ff1.get(0).getFaultMemberCount();
assertEquals(size1, size2 - 1);
exception = false;
size1 = ff1.get(0).getFaultMemberCount();
try {
_am.updateFaultMember(ff, fm, fmm);
} catch (IllegalOperationException e) {
exception = true;
}
assertFalse(exception);
size2 = ff1.get(0).getFaultMemberCount();
assertEquals(size1, size2);
assertNotNull(_am.getFaultMember(ff1.get(0).getName(), "foobar2"));
}
use of alma.acs.alarmsystem.generated.FaultFamily 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)));
}
Aggregations