1 package eu
.etaxonomy
.cdm
.persistence
.dao
;
4 import static org
.junit
.Assert
.assertFalse
;
5 import static org
.junit
.Assert
.assertTrue
;
7 import java
.io
.FileNotFoundException
;
10 import org
.apache
.log4j
.Logger
;
11 import org
.junit
.Before
;
12 import org
.junit
.Test
;
13 import org
.springframework
.beans
.factory
.annotation
.Autowired
;
14 import org
.springframework
.test
.context
.ContextConfiguration
;
16 import eu
.etaxonomy
.cdm
.model
.common
.Enumeration
;
17 import eu
.etaxonomy
.cdm
.model
.common
.Keyword
;
18 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
19 import eu
.etaxonomy
.cdm
.test
.unit
.CdmUnitTestBase
;
22 public class EnumerationDaoHibernateImplTest
extends CdmUnitTestBase
{
23 static Logger logger
= Logger
.getLogger(EnumerationDaoHibernateImplTest
.class);
26 private IEnumerationDAO dao
;
27 private Enumeration enumeration
;
30 // generate enumeration for every test to play with
31 public void onSetUp() throws Exception
{
32 logger
.debug(EnumerationDaoHibernateImplTest
.class.getSimpleName() + " setup()");
33 this.enumeration
= new Enumeration("Biological subdomains","biodomain","http://myterms.org/biodomain");
34 String
[] repres
= {"genetics","physiology","systematics","taxonomy","nomenclature"};
35 for (String r
: repres
){
36 Keyword term
= new Keyword(r
,r
,null);
37 enumeration
.addTerm(term
);
42 public void testSave() {
43 dao
.saveOrUpdate(this.enumeration
);
44 this.enumeration
.addTerm(new Keyword("cladistics","cladistics",null));
45 dao
.saveOrUpdate(this.enumeration
);
49 public void testFindString() {
50 List
<Enumeration
> myEnum
= dao
.find("biodomain");
51 assertTrue(myEnum
.contains(this.enumeration
));
55 public void loadTerms() {
57 dao
.loadTerms(Rank
.class, "Rank.csv", true);
58 } catch (FileNotFoundException e
) {
59 // TODO Auto-generated catch block
61 } catch (NoDefinedTermClassException e
) {
62 // TODO Auto-generated catch block
68 public void testList100() {
69 assertFalse(dao
.list(100,1).isEmpty());