package gov.nih.nci.cabig.caaers.dao;

import gov.nih.nci.cabig.caaers.DaoTestCase;
import gov.nih.nci.cabig.caaers.domain.ResearchStaff;

/**
 * @author Kulasekaran
 */
public class ResearchStaffDaoTest extends DaoTestCase<ResearchStaffDao>{
   
    public void testGetById() throws Exception {
    	ResearchStaff researchStaff = getDao().getById(-100);    	
        assertNotNull("ResearchStaff not found", researchStaff);
        assertEquals("Wrong last name", "Scott", researchStaff.getLastName());
        assertEquals("Wrong first name", "Dilbert", researchStaff.getFirstName());        
    }
        
    public void testSaveNewResearchStaff() throws Exception {
        Integer savedId;
        {
        	ResearchStaff researchStaff = new ResearchStaff();
        	researchStaff.setFirstName("Jeff");
        	researchStaff.setLastName("Someone");
        	
            getDao().save(researchStaff);
            savedId = researchStaff.getId();
            assertNotNull("The saved researchStaff id", savedId);
        }

        interruptSession();

        {
        	ResearchStaff loaded = getDao().getById(savedId);
            assertNotNull("Could not reload researchStaff id " + savedId, loaded);
            assertEquals("Wrong firstname", "Jeff", loaded.getFirstName());
            assertEquals("Wrong lastname", "Someone", loaded.getLastName());
        }
    }
}

@@ -134,16 +134,62 @@
 hStaff;%0D
+%0Aimport gov.nih.nci.cabig.caaers.domain.Site;%0D
 %0A%0D%0A/**%0D%0A
@@ -402,16 +402,17 @@
 yId(-100
+0
 );    %09%0D
@@ -523,13 +523,13 @@
 %22, %22
-Scott
+Gates
 %22, r
@@ -604,15 +604,12 @@
 %22, %22
-Dilbert
+Bill
 %22, r
@@ -926,24 +926,119 @@
 %0A        %09%0D%0A
+        %09Site site = new Site();%0D%0A        %09%0D%0A        %09researchStaff.setSite(site);%0D%0A        %09%0D%0A
             

update test