use of alma.acs.alarmsystem.generated.Contact in project ACS by ACS-Community.
the class ACSAlarmDAOImplTest method testRemoveFaultFamily.
public void testRemoveFaultFamily() {
Alarm al1;
boolean exception;
//Delete Entry if it exists due to an error in previous test
{
FaultFamily ff = new FaultFamily();
ff.setName("ffTest1");
try {
_alarmDAO.removeFaultFamily(ff);
} catch (Exception e) {
//This happens when FaultFamily "ffTest1" doesn't exist
}
}
//Check null argument
exception = false;
try {
_alarmDAO.removeFaultFamily(null);
} catch (Exception e) {
exception = true;
}
assertTrue(exception);
//Check Remove FF that doesn't exist
FaultFamily ff = new FaultFamily();
ff.setName("ffTest1");
exception = false;
try {
_alarmDAO.removeFaultFamily(ff);
} catch (Exception e) {
exception = true;
}
assertTrue(exception);
//Check Remove FF
ff.setAlarmSource("ALARM_SYSTEM_SOURCES");
ff.setHelpUrl("http://www.test.com");
Contact ct = new Contact();
ct.setEmail("em1");
ct.setGsm("gsm1");
ct.setName("cont1");
ff.setContact(ct);
FaultCode fc = new FaultCode();
fc.setValue(1);
fc.setPriority(0);
fc.setAction("action1");
fc.setCause("cause1");
fc.setConsequence("conseq1");
fc.setProblemDescription("problem1");
ff.addFaultCode(fc);
FaultMemberDefault fmd = new FaultMemberDefault();
Location lc = new Location();
lc.setBuilding("b1");
lc.setFloor("f1");
lc.setMnemonic("m1");
lc.setPosition("p1");
lc.setRoom("r1");
fmd.setLocation(lc);
ff.setFaultMemberDefault(fmd);
FaultMember fm = new FaultMember();
fm.setName("fmTest1");
lc = new Location();
lc.setBuilding("b2");
lc.setFloor("f2");
lc.setMnemonic("m2");
lc.setPosition("p2");
lc.setRoom("r2");
fm.setLocation(lc);
ff.addFaultMember(fm);
exception = false;
try {
_alarmDAO.addFaultFamily(ff);
} catch (Exception e) {
exception = true;
}
assertFalse(exception);
al1 = _alarmDAO.getAlarm("ffTest1:fmTest1:1");
assertNotNull(al1);
try {
_alarmDAO.removeFaultFamily(ff);
} catch (Exception e) {
exception = true;
}
assertFalse(exception);
al1 = _alarmDAO.getAlarm("ffTest1:fmTest1:1");
assertNull(al1);
}
use of alma.acs.alarmsystem.generated.Contact in project ACS by ACS-Community.
the class AlarmManagerTest method testSaveToCDB.
public void testSaveToCDB() {
boolean exception;
_am = AlarmManager.getInstance(_daoManager.getAlarmDAO());
_am.loadFromCDB();
List<FaultFamily> ff1 = _am.getAllAlarms();
assertNotNull(ff1);
int size1 = ff1.size();
int size2;
exception = false;
FaultFamily ff = new FaultFamily();
size1 = ff1.size();
ff.setName("foobar");
ff.setHelpUrl("http://www.foobar.cl/");
Contact ct = new Contact();
ct.setEmail("test@foobar.cl");
ct.setGsm("da");
ct.setName("Foobar");
ff.setContact(ct);
FaultCode fc = new FaultCode();
fc.setValue(1);
fc.setAction("a1");
fc.setCause("c1");
fc.setConsequence("co1");
fc.setPriority(1);
fc.setProblemDescription("pd1");
ff.addFaultCode(fc);
FaultMember fm = new FaultMember();
fm.setName("fmFoobar");
Location lc = new Location();
lc.setBuilding("b1");
lc.setFloor("f1");
lc.setMnemonic("m1");
lc.setPosition("p1");
lc.setRoom("r1");
fm.setLocation(lc);
try {
_am.addFaultFamily(ff);
} catch (Exception e) {
exception = true;
}
assertFalse(exception);
size2 = ff1.size();
assertEquals(size1, size2 - 1);
_am.saveToCDB();
_am.loadFromCDB();
FaultFamily fft = _am.getFaultFamily("foobar");
assertNotNull(fft);
assertEquals(fft.getName(), ff.getName());
assertEquals(fft.getHelpUrl(), ff.getHelpUrl());
exception = false;
try {
_am.deleteFaultFamily(fft);
} catch (Exception e) {
exception = true;
}
assertFalse(exception);
_am.saveToCDB();
_am.loadFromCDB();
fft = _am.getFaultFamily("foobar");
assertNull(fft);
}
Aggregations