package ae3.dao;

import java.util.List;

import org.apache.solr.client.solrj.SolrServerException;
import org.junit.Test;

import ae3.AtlasAbstractTest;
import ae3.dao.AtlasDao;
import ae3.dao.AtlasObjectNotFoundException;
import ae3.model.AtlasExperiment;

public class AtlasDaoTest extends AtlasAbstractTest
{
	@Test
	public void test_getExperimentByIdAER() throws AtlasObjectNotFoundException
	{
		  AtlasExperiment exp=AtlasDao.getExperimentByIdAER("1324144279");
		  assertNotNull(exp);
		  assertNotNull(exp.getAerExpAccession());
		  assertNotNull(exp.getAerExpId());
		  assertNotNull(exp.getAerExpName());
		  assertNotNull(exp.getDwExpId());
		  if (exp.getDwExpId() != null)
		  {
			  AtlasExperiment exp1=AtlasDao.getExperimentByIdDw(exp.getDwExpId().toString());
			  assertNotNull(exp1);
			  assertNotNull(exp1.getDwExpAccession());
			  assertNotNull(exp1.getDwExpId());
			  assertNotNull(exp1.getDwExpDescription());			  
		  }

		  log.info("######################## Experiment name: " + exp.getAerExpAccession());
		  log.info("######################## Experiment id: " + exp.getAerExpId());
		  log.info("######################## Experiment id: " + exp.getDwExpId());
		  
	}
	
	@Test
	public void test_getExperimentByIdDw() throws AtlasObjectNotFoundException
	{
		  AtlasExperiment exp=AtlasDao.getExperimentByIdDw("334420710");
		  assertNotNull(exp);
		  assertNotNull(exp.getDwExpAccession());
		  assertNotNull(exp.getAerExpId());
		  assertNotNull(exp.getDwExpType());
		  log.info("######################## Experiment name: " + exp.getDwExpAccession());
		  log.info("######################## Experiment id: " + exp.getAerExpId());
		  log.info("######################## Experiment id: " + exp.getDwExpId());
		  
	}

	@Test	
	public void test_getExperimentByAccession() throws AtlasObjectNotFoundException
	{
		AtlasExperiment exp=AtlasDao.getExperimentByAccession("E-MEXP-980");
	}
	

	
}

@@ -88,24 +88,72 @@
 rException;%0A
+import org.apache.solr.common.SolrDocumentList;%0A
 import org.j
@@ -297,16 +297,44 @@
 eriment;
+%0Aimport ae3.model.AtlasGene;
 %0A%0Apublic
@@ -1984,14 +1984,1187 @@
 %22);%0A%09%7D%0A%09
+%0A%09@Test%0A%09public void test_getGeneByIdentifier()%7B%0A%09%09boolean notFound_thrown = false;%0A%09%09boolean multi_thrown = false;%0A%09%09%0A%09%09%09%0A%09%09//Test normal gene query%0A%09%09try%7B%0A%09%09%09AtlasGene gene = AtlasDao.getGeneByIdentifier(%22ENSG00000066279%22);%0A%09%09%09assertNotNull(gene);%0A%09%09%7Dcatch (AtlasObjectNotFoundException ex)%7B%0A%09%09%09notFound_thrown = true;%0A%09%09%7Dcatch (MultipleGeneException ex)%7B%0A%09%09%09multi_thrown = true;%0A%09%09%7D%0A%09%09assertFalse(notFound_thrown);%0A%09%09assertFalse(multi_thrown);%0A%09%09%0A%09%09//Test multiple gene hit exception%0A%09%09multi_thrown = false;%0A%09%09notFound_thrown = false;%0A%09%09try%7B%0A%09%09%09AtlasGene gene2 = AtlasDao.getGeneByIdentifier(%22P08898%22);%0A%09%09%7Dcatch (MultipleGeneException ex)%7B%0A%09%09%09multi_thrown = true;%0A%09%09%7Dcatch (AtlasObjectNotFoundException ex)%7B%0A%09%09%09notFound_thrown = true;%0A%09%09%7D%0A%09%09assertTrue(multi_thrown);%0A%09%09assertFalse(notFound_thrown);%0A%09%09%0A%09%09//Test gene not found exception%0A%09%09notFound_thrown = false;%0A%09%09multi_thrown = false;%0A%09%09try%7B%0A%09%09%09AtlasGene gene2 = AtlasDao.getGeneByIdentifier(%22mysteriousGene%22);%0A%09%09%7Dcatch (AtlasObjectNotFoundException ex)%7B%0A%09%09%09notFound_thrown = true;%0A%09%09%7Dcatch (MultipleGeneException ex)%7B%0A%09%09%09multi_thrown = true;%0A%09%09%7D%0A%09%09assertTrue(notFound_thrown);%0A%09%09assertFalse(multi_thrown);%0A%0A%09%09%0A%09%09%0A%09%7D%0A%09
 %0A%0A%09%0A%7D%0A

test for getGeneIdentifier method in AtlasDAO