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
;
17 import java
.util
.List
;
18 import java
.util
.UUID
;
20 import org
.apache
.log4j
.Logger
;
21 import org
.junit
.Ignore
;
22 import org
.junit
.Test
;
23 import org
.unitils
.dbunit
.annotation
.DataSet
;
24 import org
.unitils
.spring
.annotation
.SpringBeanByType
;
26 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
27 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTermBase
;
28 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
29 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
30 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
31 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
32 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
33 import eu
.etaxonomy
.cdm
.model
.name
.SpecimenTypeDesignationStatus
;
34 import eu
.etaxonomy
.cdm
.test
.integration
.CdmIntegrationTest
;
41 public class TermServiceImplTest
extends CdmIntegrationTest
{
42 @SuppressWarnings("unused")
43 private static final Logger logger
= Logger
.getLogger(TermServiceImplTest
.class);
46 private ITermService service
;
49 private IVocabularyService vocabularyService
;
51 /* ************************* TESTS *************************************************/
54 * Test method for {@link eu.etaxonomy.cdm.api.service.TermServiceImpl#getTermByUri(java.lang.String)}.
56 @Ignore //second part of test throws unexpected exception & also first part fails since language(406)
57 //is also not found here
60 public void testGetTermByUri() {
61 String uriStr
= "http://any.uri.com";
62 URI uri
= URI
.create(uriStr
);
63 DefinedTermBase
<?
> term
= service
.getByUri(uri
);
66 // TermVocabulary<?> voc = term.getVocabulary();
67 // service.saveOrUpdate(term);
68 // List<MarkerType> list = service.listByTermClass(MarkerType.class, null, null, null, null);
71 //FIXME throws object not found exception. Wants to load term.voc(11).representation(496).language(124) which does not exist
72 //I do not understand where the vocabulary data comes from (checked persistence TermsDataSet-with_auditing_info.xml) but somehow this does not apply
73 String uriNotExistStr
= "http://www.notExisting.com";
74 URI uriNotExist
= URI
.create(uriNotExistStr
);
75 DefinedTermBase
<?
> termNotExist
= service
.getByUri(uriNotExist
);
76 assertNull(termNotExist
);
80 * Test method for {@link eu.etaxonomy.cdm.api.service.TermServiceImpl#getTermByUuid(java.util.UUID)}.
83 public void testGetTermByUuid() {
85 String strUUID
= "ffca6ec8-8b88-417b-a6a0-f7c992aac19b";
86 UUID uuid
= UUID
.fromString(strUUID
);
87 DefinedTermBase
<?
> term
= service
.find(uuid
);
89 assertEquals(Rank
.DOMAIN(), term
);
91 String strUUIDNotExist
= "00000000-8b88-417b-a6a0-f7c992aac19c";
92 UUID uuidNotExist
= UUID
.fromString(strUUIDNotExist
);
93 DefinedTermBase
<?
> termNotExist
= service
.find(uuidNotExist
);
94 assertNull(termNotExist
);
99 * Test method for {@link eu.etaxonomy.cdm.api.service.TermServiceImpl#listTerms(java.util.UUID)}.
103 public void testGetVocabularyUUID() {
105 String rankVocabularyUuid
= "ef0d1ce1-26e3-4e83-b47b-ca74eed40b1b";
106 UUID rankUuid
= UUID
.fromString(rankVocabularyUuid
);
107 TermVocabulary
<Rank
> voc
= vocabularyService
.find(rankUuid
);
109 assertEquals(66, voc
.getTerms().size());
111 String nullVocabularyUuid
= "00000000-26e3-4e83-b47b-ca74eed40b1b";
112 UUID nullUuid
= UUID
.fromString(nullVocabularyUuid
);
113 TermVocabulary
<Rank
> nullVoc
= vocabularyService
.find(nullUuid
);
119 public void testGetAreaByTdwgAbbreviation(){
120 String tdwgAbbreviation
= "GER-OO";
121 NamedArea germany
= service
.getAreaByTdwgAbbreviation(tdwgAbbreviation
);
122 assertEquals(tdwgAbbreviation
, germany
.getRepresentation(Language
.DEFAULT()).getAbbreviatedLabel());
126 public void testListTerms() {
127 Pager
<SpecimenTypeDesignationStatus
> results
= (Pager
)service
.page(SpecimenTypeDesignationStatus
.class, null,null,null,null);
128 assertNotNull("Results should not be null",results
);