4 package eu
.etaxonomy
.cdm
.persistence
.dao
.hibernate
.common
;
6 import static org
.junit
.Assert
.assertEquals
;
7 import static org
.junit
.Assert
.assertFalse
;
8 import static org
.junit
.Assert
.assertNotNull
;
10 import java
.io
.FileNotFoundException
;
11 import java
.io
.FileOutputStream
;
12 import java
.util
.List
;
13 import java
.util
.UUID
;
15 import org
.junit
.Assert
;
16 import org
.junit
.Before
;
17 import org
.junit
.Test
;
18 import org
.unitils
.dbunit
.annotation
.DataSet
;
19 import org
.unitils
.spring
.annotation
.SpringBeanByType
;
21 import eu
.etaxonomy
.cdm
.model
.common
.OriginalSource
;
22 import eu
.etaxonomy
.cdm
.model
.media
.Rights
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
24 import eu
.etaxonomy
.cdm
.persistence
.dao
.hibernate
.taxon
.TaxonDaoHibernateImpl
;
25 import eu
.etaxonomy
.cdm
.test
.integration
.CdmIntegrationTest
;
32 public class IdentifiableDaoBaseTest
extends CdmIntegrationTest
{
35 private TaxonDaoHibernateImpl identifiableDao
;
41 uuid
= UUID
.fromString("496b1325-be50-4b0a-9aa2-3ecd610215f2");
44 /************ TESTS *******************************
45 * @throws FileNotFoundException */
48 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.common.IdentifiableDaoBase#IdentifiableDaoBase(java.lang.Class)}.
51 public void testIdentifiableDaoBase() {
52 assertNotNull(identifiableDao
);
56 * Test method for {@link eu.etaxonomy.cdm.persistence.dao.hibernate.common.IdentifiableDaoBase#findByTitle(java.lang.String)}.
59 public void testFindByTitle() {
60 List
<TaxonBase
> results
= identifiableDao
.findByTitle("Lorem");
61 assertNotNull("findByTitle should return a list",results
);
62 assertEquals("findByTitle should return one entity", 1, results
.size());
63 assertEquals("findByTitle should return an entity with uuid " + uuid
,uuid
, results
.get(0).getUuid());
67 public void testGetRights() {
68 TaxonBase taxon
= identifiableDao
.findByUuid(uuid
);
69 assert taxon
!= null : "IdentifiableEntity must exist";
71 List
<Rights
> rights
= identifiableDao
.getRights(taxon
, null, null);
73 assertNotNull("getRights should return a List",rights
);
74 assertFalse("the list should not be empty",rights
.isEmpty());
75 assertEquals("getRights should return 2 Rights instances",2,rights
.size());
79 public void testSources() {
80 TaxonBase taxon
= identifiableDao
.findByUuid(uuid
);
81 assert taxon
!= null : "IdentifiableEntity must exist";
83 List
<OriginalSource
> sources
= identifiableDao
.getSources(taxon
, null, null);
85 assertNotNull("getSources should return a List", sources
);
86 assertFalse("the list should not be empty", sources
.isEmpty());
87 assertEquals("getSources should return 2 OriginalSource instances",2, sources
.size());
91 // TODO - implement this later
92 // public void testGetByLSID() throws Exception {
93 // LSID lsid = new LSID("urn:lsid:cate-project.org:taxonconcepts:1");
94 // TaxonBase result = taxonDAO.find(lsid);
96 // Assert.assertNotNull(result);