Search in sources :

Example 6 with Contact

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);
}
Also used : FaultCode(alma.acs.alarmsystem.generated.FaultCode) FaultMember(alma.acs.alarmsystem.generated.FaultMember) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) Alarm(cern.laser.business.data.Alarm) Contact(alma.acs.alarmsystem.generated.Contact) FaultMemberDefault(alma.acs.alarmsystem.generated.FaultMemberDefault) Location(alma.acs.alarmsystem.generated.Location)

Example 7 with Contact

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);
}
Also used : FaultCode(alma.acs.alarmsystem.generated.FaultCode) FaultMember(alma.acs.alarmsystem.generated.FaultMember) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) Contact(alma.acs.alarmsystem.generated.Contact) Location(alma.acs.alarmsystem.generated.Location)

Aggregations

Contact (alma.acs.alarmsystem.generated.Contact)7 FaultFamily (alma.acs.alarmsystem.generated.FaultFamily)7 FaultCode (alma.acs.alarmsystem.generated.FaultCode)6 FaultMember (alma.acs.alarmsystem.generated.FaultMember)6 FaultMemberDefault (alma.acs.alarmsystem.generated.FaultMemberDefault)5 Location (alma.acs.alarmsystem.generated.Location)4 Alarm (cern.laser.business.data.Alarm)3 AlarmImpl (cern.laser.business.data.AlarmImpl)2 Category (cern.laser.business.data.Category)2 Location (cern.laser.business.data.Location)2 ResponsiblePerson (cern.laser.business.data.ResponsiblePerson)2 Source (cern.laser.business.data.Source)2 Triplet (cern.laser.business.data.Triplet)2 SourceDefinition (cern.laser.business.definition.data.SourceDefinition)2 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 HashSet (java.util.HashSet)2 InputSource (org.xml.sax.InputSource)2 Alarms (alma.acs.alarmsystem.generated.Alarms)1 Category (alma.acs.alarmsystem.generated.Category)1