2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.api
.service
;
12 import static org
.junit
.Assert
.assertEquals
;
13 import static org
.junit
.Assert
.assertNotNull
;
14 import static org
.junit
.Assert
.assertNull
;
16 import java
.util
.UUID
;
18 import org
.apache
.log4j
.Logger
;
19 import org
.junit
.Ignore
;
20 import org
.junit
.Test
;
21 import org
.unitils
.spring
.annotation
.SpringBeanByType
;
23 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
24 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTermBase
;
25 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
26 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
27 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
28 import eu
.etaxonomy
.cdm
.model
.location
.TdwgArea
;
29 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
30 import eu
.etaxonomy
.cdm
.model
.name
.SpecimenTypeDesignationStatus
;
31 import eu
.etaxonomy
.cdm
.test
.integration
.CdmIntegrationTest
;
38 public class TermServiceImplTest
extends CdmIntegrationTest
{
39 private static final Logger logger
= Logger
.getLogger(TermServiceImplTest
.class);
42 private ITermService service
;
45 private IVocabularyService vocabularyService
;
47 /* ************************* TESTS *************************************************/
50 * Test method for {@link eu.etaxonomy.cdm.api.service.TermServiceImpl#setDao(eu.etaxonomy.cdm.persistence.dao.common.IDefinedTermDao)}.
53 public void testSetDao() {
54 logger
.info("not yet implemented");
58 * Test method for {@link eu.etaxonomy.cdm.api.service.TermServiceImpl#getTermByUri(java.lang.String)}.
60 @Ignore //method not yet implemented
62 public void testGetTermByUri() {
64 DefinedTermBase term
= service
.getByUri(uri
);
66 //assertEquals(Rank.DOMAIN(), term);
68 String uriNotExist
= "";
69 DefinedTermBase termNotExist
= service
.getByUri(uriNotExist
);
70 assertNull(termNotExist
);
74 * Test method for {@link eu.etaxonomy.cdm.api.service.TermServiceImpl#getTermByUuid(java.util.UUID)}.
77 public void testGetTermByUuid() {
79 String strUUID
= "ffca6ec8-8b88-417b-a6a0-f7c992aac19b";
80 UUID uuid
= UUID
.fromString(strUUID
);
81 DefinedTermBase term
= service
.find(uuid
);
83 assertEquals(Rank
.DOMAIN(), term
);
85 String strUUIDNotExist
= "00000000-8b88-417b-a6a0-f7c992aac19c";
86 UUID uuidNotExist
= UUID
.fromString(strUUIDNotExist
);
87 DefinedTermBase termNotExist
= service
.find(uuidNotExist
);
88 assertNull(termNotExist
);
93 * Test method for {@link eu.etaxonomy.cdm.api.service.TermServiceImpl#listTerms(java.util.UUID)}.
97 public void testGetVocabularyUUID() {
99 String rankVocabularyUuid
= "ef0d1ce1-26e3-4e83-b47b-ca74eed40b1b";
100 UUID rankUuid
= UUID
.fromString(rankVocabularyUuid
);
101 TermVocabulary
<Rank
> voc
= vocabularyService
.find(rankUuid
);
103 assertEquals(61, voc
.getTerms().size());
105 String nullVocabularyUuid
= "00000000-26e3-4e83-b47b-ca74eed40b1b";
106 UUID nullUuid
= UUID
.fromString(nullVocabularyUuid
);
107 TermVocabulary
<Rank
> nullVoc
= vocabularyService
.find(nullUuid
);
112 * Test method for {@link eu.etaxonomy.cdm.api.service.TermServiceImpl#listVocabularies(java.lang.Class)}.
114 @Ignore //method not yet implemented
116 public void testSetVocabularies() {
117 logger
.warn("Not yet implemented");
121 public void testGetAreaByTdwgAbbreviation(){
122 String tdwgAbbreviation
= "GER-OO";
123 NamedArea germany
= service
.getAreaByTdwgAbbreviation(tdwgAbbreviation
);
124 assertEquals(tdwgAbbreviation
, germany
.getRepresentation(Language
.DEFAULT()).getAbbreviatedLabel());
128 public void testListTerms() {
129 Pager
<SpecimenTypeDesignationStatus
> results
= (Pager
)service
.page(SpecimenTypeDesignationStatus
.class, null,null,null,null);
130 assertNotNull("Results should not be null",results
);