Project

General

Profile

Download (4.24 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
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.
8
*/
9

    
10
package eu.etaxonomy.cdm.api.service;
11

    
12
import static org.junit.Assert.assertEquals;
13
import static org.junit.Assert.assertNotNull;
14
import static org.junit.Assert.assertNull;
15

    
16
import java.util.UUID;
17

    
18
import org.apache.log4j.Logger;
19
import org.junit.Ignore;
20
import org.junit.Test;
21
import org.unitils.spring.annotation.SpringBeanByType;
22

    
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.name.Rank;
29
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
30
import eu.etaxonomy.cdm.test.integration.CdmIntegrationTest;
31

    
32
/**
33
 * @author a.mueller
34
 * @created 27.05.2008
35
 * @version 1.0
36
 */
37
public class TermServiceImplTest extends CdmIntegrationTest {
38
	private static final Logger logger = Logger.getLogger(TermServiceImplTest.class);
39

    
40
	@SpringBeanByType
41
	private ITermService service;
42
	
43
	@SpringBeanByType
44
	private IVocabularyService vocabularyService;
45

    
46
/* ************************* TESTS *************************************************/
47
	
48
	/**
49
	 * Test method for {@link eu.etaxonomy.cdm.api.service.TermServiceImpl#setDao(eu.etaxonomy.cdm.persistence.dao.common.IDefinedTermDao)}.
50
	 */
51
	@Test
52
	public void testSetDao() {
53
		logger.info("not yet implemented");
54
	}
55

    
56
	/**
57
	 * Test method for {@link eu.etaxonomy.cdm.api.service.TermServiceImpl#getTermByUri(java.lang.String)}.
58
	 */
59
	@Ignore //method not yet implemented
60
	@Test
61
	public void testGetTermByUri() {
62
		String uri = ""; 
63
		DefinedTermBase term = service.getByUri(uri);
64
		assertNotNull(term);
65
		//assertEquals(Rank.DOMAIN(), term);
66
		//NULL
67
		String uriNotExist = "";
68
		DefinedTermBase termNotExist = service.getByUri(uriNotExist);
69
		assertNull(termNotExist);
70
	}
71

    
72
	/**
73
	 * Test method for {@link eu.etaxonomy.cdm.api.service.TermServiceImpl#getTermByUuid(java.util.UUID)}.
74
	 */
75
	@Test
76
	public void testGetTermByUuid() {
77
		// Rank.Domain
78
		String strUUID = "ffca6ec8-8b88-417b-a6a0-f7c992aac19b"; 
79
		UUID uuid = UUID.fromString(strUUID);
80
		DefinedTermBase term = service.find(uuid);
81
		assertNotNull(term);
82
		assertEquals(Rank.DOMAIN(), term);
83
		//NULL
84
		String strUUIDNotExist = "00000000-8b88-417b-a6a0-f7c992aac19c";
85
		UUID uuidNotExist = UUID.fromString(strUUIDNotExist);
86
		DefinedTermBase termNotExist = service.find(uuidNotExist);
87
		assertNull(termNotExist);
88
	}
89

    
90

    
91
	/**
92
	 * Test method for {@link eu.etaxonomy.cdm.api.service.TermServiceImpl#listTerms(java.util.UUID)}.
93
	 */
94
	@Ignore
95
	@Test
96
	public void testGetVocabularyUUID() {
97
		//Rank
98
		String rankVocabularyUuid = "ef0d1ce1-26e3-4e83-b47b-ca74eed40b1b"; 
99
		UUID rankUuid = UUID.fromString(rankVocabularyUuid);
100
		TermVocabulary<Rank> voc = vocabularyService.find(rankUuid);
101
		assertNotNull(voc);
102
		assertEquals(61, voc.getTerms().size());
103
		//Null
104
		String nullVocabularyUuid = "00000000-26e3-4e83-b47b-ca74eed40b1b"; 
105
		UUID nullUuid = UUID.fromString(nullVocabularyUuid);
106
		TermVocabulary<Rank> nullVoc = vocabularyService.find(nullUuid);
107
		assertNull(nullVoc);
108
	}
109

    
110
	/**
111
	 * Test method for {@link eu.etaxonomy.cdm.api.service.TermServiceImpl#listVocabularies(java.lang.Class)}.
112
	 */
113
	@Ignore //method not yet implemented
114
	@Test
115
	public void testSetVocabularies() {
116
		logger.warn("Not yet implemented");
117
	}
118
	
119
	@Test
120
	@Ignore //FIXME ignoring just for today 9.6.2010 a.kohlbecker !!!!!!!!!!!!!!!!!!!!!
121
	public void testGetAreaByTdwgAbbreviation(){
122
		String tdwgAbbreviation = "GER-OO";
123
		NamedArea germany = service.getAreaByTdwgAbbreviation(tdwgAbbreviation);
124
		assertEquals(tdwgAbbreviation, germany.getRepresentation(Language.DEFAULT()).getAbbreviatedLabel());
125
	}
126
	
127
	@Test
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);
131
	}
132
}
(13-13/14)