Revision 17d56bdf
Added by Andreas Müller almost 8 years ago
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/name/ZoologicalNameCacheStrategyTest.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
16 | 16 |
import java.lang.reflect.Method; |
17 | 17 |
|
18 | 18 |
import org.apache.log4j.Logger; |
19 |
import org.junit.Assert; |
|
19 | 20 |
import org.junit.Before; |
20 | 21 |
import org.junit.BeforeClass; |
21 | 22 |
import org.junit.Test; |
... | ... | |
34 | 35 |
public class ZoologicalNameCacheStrategyTest extends NameCacheStrategyTestBase { |
35 | 36 |
@SuppressWarnings("unused") |
36 | 37 |
private static final Logger logger = Logger.getLogger(ZoologicalNameCacheStrategyTest.class); |
37 |
|
|
38 |
|
|
38 | 39 |
private ZooNameDefaultCacheStrategy strategy; |
39 | 40 |
private ZoologicalName familyName; |
40 | 41 |
private ZoologicalName genusName; |
41 | 42 |
private ZoologicalName subGenusName; |
42 | 43 |
private ZoologicalName speciesName; |
43 | 44 |
private ZoologicalName subSpeciesName; |
45 |
private ZoologicalName speciesNameWithInfrGenEpi; |
|
44 | 46 |
private TeamOrPersonBase<?> author; |
45 | 47 |
private TeamOrPersonBase<?> exAuthor; |
46 | 48 |
private TeamOrPersonBase<?> basAuthor; |
47 | 49 |
private TeamOrPersonBase<?> exBasAuthor; |
48 |
|
|
50 |
|
|
49 | 51 |
private final String familyNameString = "Familia"; |
50 | 52 |
private final String genusNameString = "Genus"; |
51 | 53 |
private final String speciesNameString = "Abies alba"; |
52 | 54 |
private final String subSpeciesNameString = "Abies alba subsp. beta"; |
55 |
private final String speciesNameWithGenusEpiString = "Bacanius (Mullerister) rombophorus (Aube, 1843)"; |
|
53 | 56 |
|
54 | 57 |
private final String authorString = "L."; |
55 | 58 |
private final String exAuthorString = "Exaut."; |
56 | 59 |
private final String basAuthorString = "Basio, A."; |
57 | 60 |
private final String exBasAuthorString = "ExBas. N."; |
58 |
|
|
61 |
|
|
59 | 62 |
private final Integer publicationYear = 1928; |
60 | 63 |
private final Integer originalPublicationYear = 1860; |
61 |
|
|
62 |
|
|
64 |
|
|
65 |
|
|
63 | 66 |
|
64 | 67 |
/** |
65 | 68 |
* @throws java.lang.Exception |
... | ... | |
78 | 81 |
strategy = ZooNameDefaultCacheStrategy.NewInstance(); |
79 | 82 |
familyName = ZoologicalName.PARSED_NAME(familyNameString, Rank.FAMILY()); |
80 | 83 |
genusName = ZoologicalName.PARSED_NAME(genusNameString, Rank.GENUS()); |
81 |
|
|
84 |
|
|
82 | 85 |
subGenusName = ZoologicalName.NewInstance(Rank.SUBGENUS()); |
83 | 86 |
subGenusName.setGenusOrUninomial("Genus"); |
84 | 87 |
subGenusName.setInfraGenericEpithet("InfraGenericPart"); |
85 |
|
|
88 |
|
|
86 | 89 |
speciesName = ZoologicalName.PARSED_NAME(speciesNameString); |
87 | 90 |
subSpeciesName = ZoologicalName.PARSED_NAME(subSpeciesNameString); |
91 |
speciesNameWithInfrGenEpi = ZoologicalName.PARSED_NAME(speciesNameWithGenusEpiString); |
|
92 |
Assert.assertFalse(speciesName.hasProblem()); //guarantee names are well past |
|
93 |
Assert.assertFalse(speciesNameWithInfrGenEpi.hasProblem()); |
|
94 |
Assert.assertFalse(subSpeciesName.hasProblem()); |
|
95 |
|
|
88 | 96 |
|
89 | 97 |
author = Person.NewInstance(); |
90 | 98 |
author.setNomenclaturalTitle(authorString); |
... | ... | |
95 | 103 |
exBasAuthor = Person.NewInstance(); |
96 | 104 |
exBasAuthor.setNomenclaturalTitle(exBasAuthorString); |
97 | 105 |
} |
98 |
|
|
106 |
|
|
99 | 107 |
|
100 | 108 |
/********* TEST *******************************************/ |
101 | 109 |
|
... | ... | |
128 | 136 |
subSpeciesName.setExBasionymAuthorship(exBasAuthor); |
129 | 137 |
subSpeciesName.setPublicationYear(publicationYear); |
130 | 138 |
subSpeciesName.setOriginalPublicationYear(originalPublicationYear); |
131 |
|
|
139 |
|
|
132 | 140 |
assertEquals(subSpeciesNameString, strategy.getNameCache(subSpeciesName)); |
133 | 141 |
assertEquals(subSpeciesNameString + " (" + exBasAuthorString + " ex " + basAuthorString + ", " + originalPublicationYear +")" + " " + exAuthorString + " ex " + authorString + ", " + publicationYear, strategy.getTitleCache(subSpeciesName)); |
134 |
|
|
135 |
//Autonym,
|
|
142 |
|
|
143 |
//Autonym, |
|
136 | 144 |
subSpeciesName.setInfraSpecificEpithet("alba"); |
137 | 145 |
subSpeciesName.setCombinationAuthorship(author); |
138 | 146 |
subSpeciesName.setBasionymAuthorship(null); |
... | ... | |
144 | 152 |
//new we now assume that there are no autonyms in zoology (source: they do not exist in Fauna Europaea) |
145 | 153 |
assertEquals("Abies alba subsp. alba", strategy.getNameCache(subSpeciesName)); |
146 | 154 |
assertEquals("Abies alba subsp. alba (1860) L., 1928", strategy.getTitleCache(subSpeciesName)); |
147 |
|
|
155 |
|
|
156 |
//species with infraGeneric epi |
|
157 |
assertEquals(speciesNameWithGenusEpiString, strategy.getTitleCache(speciesNameWithInfrGenEpi)); |
|
148 | 158 |
} |
149 | 159 |
|
150 | 160 |
/** |
... | ... | |
159 | 169 |
|
160 | 170 |
subSpeciesName.setExCombinationAuthorship(exAuthor); |
161 | 171 |
assertEquals( exAuthorString + " ex " + authorString + ", " + publicationYear , strategy.getAuthorshipCache(subSpeciesName)); |
162 |
|
|
172 |
|
|
163 | 173 |
subSpeciesName.setBasionymAuthorship(basAuthor); |
164 | 174 |
assertEquals("(" + basAuthorString + ")" + " " + exAuthorString + " ex " + authorString + ", " + publicationYear , strategy.getAuthorshipCache(subSpeciesName)); |
165 | 175 |
subSpeciesName.setOriginalPublicationYear(originalPublicationYear); |
... | ... | |
167 | 177 |
|
168 | 178 |
subSpeciesName.setExBasionymAuthorship(exBasAuthor); |
169 | 179 |
assertEquals("(" + exBasAuthorString + " ex " + basAuthorString + ", " + originalPublicationYear + ")" + " " + exAuthorString + " ex " + authorString + ", " + publicationYear , strategy.getAuthorshipCache(subSpeciesName)); |
170 |
|
|
180 |
|
|
171 | 181 |
//cache |
172 | 182 |
subSpeciesName.setAuthorshipCache(authorString); |
173 | 183 |
assertEquals("AuthorshipCache must be updated", authorString, subSpeciesName.getAuthorshipCache()); |
... | ... | |
176 | 186 |
//TODO make this not needed |
177 | 187 |
subSpeciesName.setTitleCache(null, false); |
178 | 188 |
assertEquals("TitleCache must be updated", "Abies alba subsp. beta " + "(ExBas. N. ex Basio, A., 1860) Exaut. ex L., 1928", subSpeciesName.getTitleCache()); |
179 |
|
|
189 |
|
|
180 | 190 |
assertNull("Authorship cache for null must return null", strategy.getAuthorshipCache(null)); |
181 |
|
|
191 |
|
|
182 | 192 |
} |
183 |
|
|
193 |
|
|
184 | 194 |
/** |
185 | 195 |
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.BotanicNameDefaultCacheStrategy#getUninomialNameCache(eu.etaxonomy.cdm.model.name.BotanicalName)}. |
186 | 196 |
*/ |
... | ... | |
196 | 206 |
public final void testGetInfraGenusTaggedNameCache() { |
197 | 207 |
String methodName = "getInfraGenusTaggedNameCache"; |
198 | 208 |
Method method = getMethod(NonViralNameDefaultCacheStrategy.class, methodName, NonViralName.class); |
199 |
|
|
209 |
|
|
200 | 210 |
this.getStringValue(method, strategy, subGenusName); |
201 | 211 |
assertEquals("Genus subg. InfraGenericPart", strategy.getNameCache(subGenusName)); |
202 | 212 |
} |
... | ... | |
216 | 226 |
public final void testGetInfraSpeciesNameCache() { |
217 | 227 |
assertEquals(subSpeciesNameString, strategy.getNameCache(subSpeciesName)); |
218 | 228 |
} |
219 |
|
|
229 |
|
|
220 | 230 |
|
221 | 231 |
/** |
222 | 232 |
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.BotanicNameDefaultCacheStrategy#getInfraSpeciesNameCache(eu.etaxonomy.cdm.model.name.BotanicalName)}. |
... | ... | |
233 | 243 |
assertEquals("Abies alba subsp. alba", strategy.getNameCache(subSpeciesName)); |
234 | 244 |
assertEquals("Abies alba subsp. alba L.", strategy.getTitleCache(subSpeciesName)); |
235 | 245 |
} |
236 |
|
|
237 |
|
|
246 |
|
|
247 |
|
|
238 | 248 |
} |
Also available in: Unified diff
Adding test for formatting species with infrageneric epi #5881