1
|
/**
|
2
|
* Copyright (C) 2009 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
|
package eu.etaxonomy.cdm.strategy.cache.common;
|
10
|
|
11
|
import java.util.UUID;
|
12
|
|
13
|
import org.junit.Assert;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
import org.junit.Before;
|
17
|
import org.junit.BeforeClass;
|
18
|
import org.junit.Test;
|
19
|
|
20
|
import eu.etaxonomy.cdm.model.common.DefaultTermInitializer;
|
21
|
import eu.etaxonomy.cdm.model.location.NamedArea;
|
22
|
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
|
23
|
import eu.etaxonomy.cdm.model.name.Rank;
|
24
|
|
25
|
/**
|
26
|
* @author a.mueller
|
27
|
* @date 19.05.2010
|
28
|
*
|
29
|
*/
|
30
|
public class TermDefaultCacheStrategyTest {
|
31
|
@SuppressWarnings("unused")
|
32
|
private static final Logger logger = Logger.getLogger(TermDefaultCacheStrategyTest.class);
|
33
|
|
34
|
private TermDefaultCacheStrategy<?> strategy;
|
35
|
|
36
|
//************************* SET UP ****************************************
|
37
|
|
38
|
/**
|
39
|
* @throws java.lang.Exception
|
40
|
*/
|
41
|
@BeforeClass
|
42
|
public static void setUpBeforeClass() {
|
43
|
if (Rank.GENUS() == null){
|
44
|
DefaultTermInitializer vocabularyStore = new DefaultTermInitializer();
|
45
|
vocabularyStore.initialize();
|
46
|
}
|
47
|
}
|
48
|
|
49
|
/**
|
50
|
* @throws java.lang.Exception
|
51
|
*/
|
52
|
@Before
|
53
|
public void setUp() throws Exception {
|
54
|
strategy = new TermDefaultCacheStrategy();
|
55
|
}
|
56
|
|
57
|
|
58
|
//******************************* TEST **********************************************
|
59
|
|
60
|
/**
|
61
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.common.TermDefaultCacheStrategy#getUuid()}.
|
62
|
*/
|
63
|
@Test
|
64
|
public void testGetUuid() {
|
65
|
String uuid = "9cdf52c1-bac4-4b6c-a7f9-1a87401bd8f9";
|
66
|
Assert.assertEquals("UUID should be equal", uuid, strategy.getUuid().toString());
|
67
|
}
|
68
|
|
69
|
/**
|
70
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.common.TermDefaultCacheStrategy#getTitleCache(eu.etaxonomy.cdm.model.common.TermBase)}.
|
71
|
*/
|
72
|
@Test
|
73
|
public void testGetTitleCache() {
|
74
|
Assert.assertEquals("Genus title cache should be 'Genus'", "Genus", Rank.GENUS().getTitleCache());
|
75
|
Assert.assertEquals("Nom. Illeg. title cache should be 'Illegitimate'", "Illegitimate", NomenclaturalStatusType.ILLEGITIMATE().getTitleCache());
|
76
|
}
|
77
|
|
78
|
/**
|
79
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.common.TermDefaultCacheStrategy#getTitleCache(eu.etaxonomy.cdm.model.common.TermBase)}.
|
80
|
*/
|
81
|
@Test
|
82
|
public void testGetTitleCacheNoRepresentations() {
|
83
|
final String newTermUuid = "e3a6e29d-314a-4e06-be70-cbfe093842ec";
|
84
|
NamedArea newTerm = NamedArea.NewInstance();
|
85
|
newTerm.setUuid(UUID.fromString(newTermUuid));
|
86
|
|
87
|
Assert.assertEquals("Term with no representation must return a title that makes some sense", "NamedArea<e3a6e29d-314a-4e06-be70-cbfe093842ec>", newTerm.getTitleCache());
|
88
|
}
|
89
|
|
90
|
}
|