package ubic.gemma.model.association.phenotype;

import java.util.Collection;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import ubic.gemma.testing.BaseSpringContextTest;

public class PhenotypeAssociationTest extends BaseSpringContextTest {

    @Autowired
    private UrlEvidenceDao eviDao;

    @Autowired
    private LiteratureEvidenceDao litDao;

    @Test
    public void createUrlEvidence() {
        UrlEvidence entity = new UrlEvidenceImpl();
        entity.setDescription( "testDescription" );
        entity.setName( "testname" );
        entity.setUrl( "www.test.com" );
        eviDao.create( entity );
    }

    @Test
    public void createLiteratureEvidence() {
        LiteratureEvidence entity = new LiteratureEvidenceImpl();
        entity.setDescription( "testDescription2" );
        entity.setName( "testname2" );

        litDao.create( entity );

        entity.setName( "testDescription2Update" );

        litDao.update( entity );
    }

    @Test
    public void findAllLiteratureEvidence() {
        Collection<LiteratureEvidence> c = ( Collection<LiteratureEvidence> ) litDao.loadAll();

        // check all
        for ( LiteratureEvidence literatureEvidence : c ) {
            System.out.println( literatureEvidence.getDescription() );
        }
    }

}

@@ -53,28 +53,105 @@
 ort 
-java.util.Collection
+static org.junit.Assert.*;%0A%0Aimport java.util.Collection;%0A%0Aimport junit.tests.framework.AssertTest
 ;%0A%0Ai
@@ -417,108 +417,67 @@
    @
-Autowired%0A    private LiteratureEvidenceDao litDao;%0A%0A    @Test%0A    public void createUrlEvidence() %7B
+Test%0A    public void testUrlEvidence() %7B%0A%0A        // create
 %0A   
@@ -489,30 +489,35 @@
 UrlEvidence 
-entity
+urlEvidence
  = new UrlEv
@@ -530,38 +530,43 @@
 Impl();%0A        
-entity
+urlEvidence
 .setDescription(
@@ -587,38 +587,43 @@
 ion%22 );%0A        
-entity
+urlEvidence
 .setName( %22testn
@@ -634,30 +634,35 @@
  );%0A        
-entity
+urlEvidence
 .setUrl( %22ww
@@ -688,90 +688,61 @@
     
-eviDao.create( entity );%0A    %7D%0A%0A    @Test%0A    public void createLiterature
+UrlEvidence entityReturn = eviDao.create( url
 Evidence
 () %7B
@@ -729,36 +729,35 @@
 ate( urlEvidence
-() %7B
+ );
 %0A        Literat
@@ -753,167 +753,126 @@
     
-LiteratureEvidence entity = new LiteratureEvidenceImpl();%0A        entity.setDescription( %22testDescription2%22 );%0A        entity.setName( %22testname2
+assertNotNull( entityReturn.getId() );%0A%0A        // update%0A        urlEvidence.setUrl( %22www.testupdate.com
 %22 );%0A
-%0A
         
 litD
@@ -871,29 +871,34 @@
     
-lit
+evi
 Dao.
-cre
+upd
 ate( 
-entity
+urlEvidence
  );%0A
@@ -910,90 +910,95 @@
     
-entity.setName( %22testDescription2Update%22 );%0A%0A        litDao.update( entity
+// load%0A        UrlEvidence urlEvidenceLoad = eviDao.load( entityReturn.getId()
  );%0A    
 %7D%0A%0A 
@@ -997,62 +997,38 @@
     
-%7D%0A%0A
     
-@Test%0A    public void findAllLiterature
+assertNotNull( url
 Evidence
 () %7B
@@ -1023,20 +1023,23 @@
 Evidence
-() %7B
+Load );
 %0A       
@@ -1043,258 +1043,203 @@
     
-Collection%3CLiteratureEvidence%3E c = ( Collection%3CLiteratureEvidence%3E ) litDao.loadAll();%0A%0A        // check all%0A        for ( LiteratureEvidence literatureEvidence : c ) %7B%0A            System.out.println( literatureEvidence.getDescription() );%0A        %7D
+assertTrue( urlEvidenceLoad.getUrl().equals( %22www.testupdate.com%22 ) );%0A%0A        // remove%0A        eviDao.remove( entityReturn.getId() );%0A        assertNull( eviDao.load( entityReturn.getId() ) );
 %0A   

test CRUD operations on a evidence