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

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

/**
 * 
 * @author Sujith Vellat Thayyilthodi
 * */
public class StudyDaoTest extends DaoTestCase<StudyDao>{

	
    public void testGet() throws Exception {
        Study loaded = (Study)getDao().getById(-2);
        assertNotNull("Study not found", loaded);
        assertEquals("title", loaded.getShortTitle());
    }
    
    public void testGetAllStudies() throws Exception {
    	
    }
    	
	
    public void testSave() throws Exception {
        Integer savedId;
        {
            Study newStudy = new Study();
            newStudy.setPrincipalInvestigatorCode("investigatorCode");
            newStudy.setPrincipalInvestigatorName("investigatorName");
            newStudy.setMultiInstitutionIndicator(Boolean.FALSE);
            newStudy.setPrimarySponsorCode("sponsorCode");
            newStudy.setPrimarySponsorName("sponsorName");
            getDao().save(newStudy);
            assertNotNull("No ID for newly saved study", newStudy.getId());
            savedId = newStudy.getId();
        }

        interruptSession();

        {
            Study reloaded = (Study)getDao().getById(savedId);
            assertNotNull("Saved Study not found", reloaded);
            assertEquals("investigatorCode", reloaded.getPrincipalInvestigatorCode());
            assertEquals("investigatorName", reloaded.getPrincipalInvestigatorName());
            assertEquals("sponsorCode", reloaded.getPrimarySponsorCode());
            assertEquals("sponsorName", reloaded.getPrimarySponsorName());
        }
    }
}

@@ -420,17 +420,23 @@
 Equals(%22
-t
+Short T
 itle%22, l
@@ -708,36 +708,150 @@
 .set
-PrincipalInvestigatorCode(%22i
+ShortTitle(%22Short Title Inserted%22);%0D%0A            newStudy.setLongTitle(%22Long Title Inserted%22);            %0D%0A            newStudy.setPrincipalI
 nves
@@ -857,24 +857,35 @@
 stigatorCode
+(%22ICODE_101
 %22);%0D%0A       
@@ -928,17 +928,17 @@
 orName(%22
-i
+I
 nvestiga
@@ -940,20 +940,30 @@
 stigator
+ 
 Name
+ Inserted
 %22);%0D%0A   
@@ -1070,27 +1070,25 @@
 orCode(%22
-sponsorCode
+SCODE_101
 %22);%0D%0A   
@@ -1128,27 +1128,37 @@
 orName(%22
-s
+S
 ponsor
+ 
 Name
+ Inserted
 %22);%0D%0A   
@@ -1522,24 +1522,17 @@
 ls(%22
-investigatorCode
+ICODE_101
 %22, r
@@ -1599,17 +1599,17 @@
 Equals(%22
-i
+I
 nvestiga
@@ -1611,20 +1611,30 @@
 stigator
+ 
 Name
+ Inserted
 %22, reloa
@@ -1701,19 +1701,17 @@
 ls(%22
-sponsorCode
+SCODE_101
 %22, r
@@ -1775,19 +1775,29 @@
 ls(%22
-s
+S
 ponsor
+ 
 Name
+ Inserted
 %22, r

Test Case updated.