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.strategy.cache.name;
|
11
|
|
12
|
import static org.junit.Assert.assertEquals;
|
13
|
import static org.junit.Assert.assertNull;
|
14
|
|
15
|
import java.util.List;
|
16
|
|
17
|
import junit.framework.Assert;
|
18
|
|
19
|
import org.apache.log4j.Logger;
|
20
|
import org.junit.Before;
|
21
|
import org.junit.BeforeClass;
|
22
|
import org.junit.Test;
|
23
|
|
24
|
import eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor;
|
25
|
import eu.etaxonomy.cdm.model.agent.Person;
|
26
|
import eu.etaxonomy.cdm.model.common.DefaultTermInitializer;
|
27
|
import eu.etaxonomy.cdm.model.name.BotanicalName;
|
28
|
import eu.etaxonomy.cdm.model.name.NonViralName;
|
29
|
import eu.etaxonomy.cdm.model.name.Rank;
|
30
|
import eu.etaxonomy.cdm.model.name.ZoologicalName;
|
31
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
32
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
33
|
|
34
|
/**
|
35
|
* @author a.mueller
|
36
|
* @created 26.11.2008
|
37
|
* @version 1.0
|
38
|
*/
|
39
|
public class NonViralNameDefaultCacheStrategyTest {
|
40
|
private static final Logger logger = Logger.getLogger(NonViralNameDefaultCacheStrategyTest.class);
|
41
|
|
42
|
private NonViralNameDefaultCacheStrategy strategy;
|
43
|
|
44
|
private static final String familyNameString = "Familia";
|
45
|
private static final String genusNameString = "Genus";
|
46
|
private static final String speciesNameString = "Abies alba";
|
47
|
private static final String subSpeciesNameString = "Abies alba subsp. beta";
|
48
|
private static final String appendedPhraseString = "app phrase";
|
49
|
|
50
|
private static final String authorString = "L.";
|
51
|
private static final String exAuthorString = "Exaut.";
|
52
|
private static final String basAuthorString = "Basio, A.";
|
53
|
private static final String exBasAuthorString = "ExBas. N.";
|
54
|
|
55
|
private BotanicalName familyName;
|
56
|
private BotanicalName genusName;
|
57
|
private BotanicalName subGenusName;
|
58
|
private BotanicalName speciesName;
|
59
|
private BotanicalName subSpeciesName;
|
60
|
private INomenclaturalAuthor author;
|
61
|
private INomenclaturalAuthor exAuthor;
|
62
|
private INomenclaturalAuthor basAuthor;
|
63
|
private INomenclaturalAuthor exBasAuthor;
|
64
|
private Reference citationRef;
|
65
|
|
66
|
@BeforeClass
|
67
|
public static void setUpBeforeClass() {
|
68
|
DefaultTermInitializer vocabularyStore = new DefaultTermInitializer();
|
69
|
vocabularyStore.initialize();
|
70
|
}
|
71
|
|
72
|
/**
|
73
|
* @throws java.lang.Exception
|
74
|
*/
|
75
|
@Before
|
76
|
public void setUp() throws Exception {
|
77
|
strategy = NonViralNameDefaultCacheStrategy.NewInstance();
|
78
|
familyName = BotanicalName.PARSED_NAME(familyNameString, Rank.FAMILY());
|
79
|
genusName = BotanicalName.PARSED_NAME(genusNameString, Rank.GENUS());
|
80
|
|
81
|
subGenusName = BotanicalName.NewInstance(Rank.SUBGENUS());
|
82
|
subGenusName.setGenusOrUninomial("Genus");
|
83
|
subGenusName.setInfraGenericEpithet("InfraGenericPart");
|
84
|
|
85
|
speciesName = BotanicalName.PARSED_NAME(speciesNameString);
|
86
|
subSpeciesName = BotanicalName.PARSED_NAME(subSpeciesNameString);
|
87
|
|
88
|
author = Person.NewInstance();
|
89
|
author.setNomenclaturalTitle(authorString);
|
90
|
exAuthor = Person.NewInstance();
|
91
|
exAuthor.setNomenclaturalTitle(exAuthorString);
|
92
|
basAuthor = Person.NewInstance();
|
93
|
basAuthor.setNomenclaturalTitle(basAuthorString);
|
94
|
exBasAuthor = Person.NewInstance();
|
95
|
exBasAuthor.setNomenclaturalTitle(exBasAuthorString);
|
96
|
|
97
|
}
|
98
|
|
99
|
//**************************** TESTS **************************************************
|
100
|
|
101
|
/**
|
102
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#getTitleCache(eu.etaxonomy.cdm.model.name.NonViralName)}.
|
103
|
*/
|
104
|
@Test
|
105
|
public void testGetTitleCache() {
|
106
|
logger.warn("Not yet implemented");
|
107
|
}
|
108
|
|
109
|
/**
|
110
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#getFullTitleCache(eu.etaxonomy.cdm.model.name.NonViralName)}.
|
111
|
*/
|
112
|
@Test
|
113
|
public void testGetFullTitleCache() {
|
114
|
logger.warn("Not yet implemented");
|
115
|
}
|
116
|
|
117
|
|
118
|
/**
|
119
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#getNameCache(eu.etaxonomy.cdm.model.name.NonViralName)}.
|
120
|
*/
|
121
|
@Test
|
122
|
public void testGetNameCache() {
|
123
|
assertEquals("Species Name should be Abies alba", speciesNameString, speciesName.getNameCache());
|
124
|
speciesName.setNameCache("Any species");
|
125
|
assertEquals("Species Name should be Any species", "Any species", speciesName.getNameCache());
|
126
|
assertEquals("Species Name should be Any species", "Any species", speciesName.getTitleCache());
|
127
|
assertEquals("subSpeciesNameString should be correct", subSpeciesNameString, subSpeciesName.getNameCache());
|
128
|
BotanicalName botName = BotanicalName.NewInstance(Rank.VARIETY());
|
129
|
botName.setGenusOrUninomial("Lepidocaryum");
|
130
|
botName.setSpecificEpithet("tenue");
|
131
|
botName.setInfraSpecificEpithet("tenue");
|
132
|
assertEquals("", "Lepidocaryum tenue var. tenue", botName.getNameCache());
|
133
|
BotanicalName specName = BotanicalName.NewInstance(Rank.SPECIES());
|
134
|
specName.setGenusOrUninomial("Genus");
|
135
|
specName.setSpecificEpithet("");
|
136
|
assertEquals("Empty species string must not result in trailing whitespace", "Genus", specName.getNameCache());
|
137
|
|
138
|
//unranked taxa
|
139
|
String unrankedCache;
|
140
|
BotanicalName unrankedName = BotanicalName.NewInstance(Rank.UNRANKED());
|
141
|
unrankedName.setGenusOrUninomial("Genus");
|
142
|
NonViralNameDefaultCacheStrategy<BotanicalName> strategy = NonViralNameDefaultCacheStrategy.NewInstance();
|
143
|
//infraspecific
|
144
|
unrankedName.setInfraSpecificEpithet("infraspecific");
|
145
|
unrankedName.setSpecificEpithet("species");
|
146
|
unrankedCache = strategy.getNameCache(unrankedName);
|
147
|
|
148
|
Assert.assertEquals("Correct unranked cache expected", "Genus species [unranked] infraspecific", unrankedCache);
|
149
|
|
150
|
//infrageneric
|
151
|
unrankedName.setInfraSpecificEpithet(null);
|
152
|
unrankedName.setSpecificEpithet(null);
|
153
|
unrankedName.setInfraGenericEpithet("Infrageneric");
|
154
|
unrankedCache = strategy.getNameCache(unrankedName);
|
155
|
Assert.assertEquals("Correct unranked cache expected", "Genus [unranked] Infrageneric", unrankedCache);
|
156
|
|
157
|
|
158
|
}
|
159
|
|
160
|
/**
|
161
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#getNameCache(eu.etaxonomy.cdm.model.name.NonViralName)}.
|
162
|
*/
|
163
|
@Test
|
164
|
public void testNameCacheWithInfraGenericEpithet() {
|
165
|
speciesName.setInfraGenericEpithet("Infraabies");
|
166
|
assertEquals("Species Name should be Abies (Infraabies) alba", "Abies (Infraabies) alba", speciesName.getNameCache());
|
167
|
|
168
|
BotanicalName botName = BotanicalName.NewInstance(Rank.VARIETY());
|
169
|
botName.setGenusOrUninomial("Lepidocaryum");
|
170
|
botName.setInfraGenericEpithet("Infralepi");
|
171
|
botName.setSpecificEpithet("tenue");
|
172
|
botName.setInfraSpecificEpithet("tenue");
|
173
|
assertEquals("Name cache should be Lepidocaryum (Infralepi) tenue var. tenue", "Lepidocaryum (Infralepi) tenue var. tenue", botName.getNameCache());
|
174
|
|
175
|
botName.setInfraGenericEpithet(" ");
|
176
|
assertEquals("Empty infrageneric epithet must be neglegted", "Lepidocaryum tenue var. tenue", botName.getNameCache());
|
177
|
}
|
178
|
|
179
|
/**
|
180
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#getAuthorshipCache(eu.etaxonomy.cdm.model.name.NonViralName)}.
|
181
|
*/
|
182
|
@Test
|
183
|
public void testGetAuthorshipCache() {
|
184
|
this.speciesName.setCombinationAuthorTeam(author);
|
185
|
assertEquals(author.getNomenclaturalTitle(), speciesName.getAuthorshipCache());
|
186
|
this.speciesName.setBasionymAuthorTeam(basAuthor);
|
187
|
String expected = strategy.getBasionymStart()+ basAuthor.getNomenclaturalTitle()+strategy.getBasionymEnd()+strategy.getBasionymAuthorCombinationAuthorSeperator()+author.getNomenclaturalTitle();
|
188
|
assertEquals(expected, speciesName.getAuthorshipCache());
|
189
|
String authorshipcache = "authorshipcache";
|
190
|
speciesName.setAuthorshipCache(authorshipcache);
|
191
|
assertEquals(authorshipcache, speciesName.getAuthorshipCache());
|
192
|
speciesName.setCombinationAuthorTeam(exAuthor);
|
193
|
assertEquals(authorshipcache, speciesName.getAuthorshipCache()); //cache is protected
|
194
|
assertEquals(speciesNameString + " " + authorshipcache, speciesName.getFullTitleCache());
|
195
|
//unprotected
|
196
|
speciesName.setProtectedAuthorshipCache(false);
|
197
|
String atomizedAuthorCache = strategy.getBasionymStart()+ basAuthor.getNomenclaturalTitle()+strategy.getBasionymEnd()+strategy.getBasionymAuthorCombinationAuthorSeperator()+exAuthor.getNomenclaturalTitle();
|
198
|
assertEquals(atomizedAuthorCache, speciesName.getAuthorshipCache());
|
199
|
String atomizedTitleCache = speciesNameString + " "+ strategy.getBasionymStart()+ basAuthor.getNomenclaturalTitle()+strategy.getBasionymEnd()+strategy.getBasionymAuthorCombinationAuthorSeperator()+exAuthor.getNomenclaturalTitle();
|
200
|
assertEquals(atomizedTitleCache, speciesName.getTitleCache());
|
201
|
assertEquals(atomizedTitleCache, speciesName.getFullTitleCache());
|
202
|
}
|
203
|
|
204
|
@Test
|
205
|
public void testCacheListener() {
|
206
|
Reference ref = ReferenceFactory.newGeneric();
|
207
|
ref.setTitleCache("GenericRef",true);
|
208
|
this.subSpeciesName.setNomenclaturalReference(ref);
|
209
|
Assert.assertEquals("Expected full title cache has error", "Abies alba subsp. beta, GenericRef", subSpeciesName.getFullTitleCache());
|
210
|
subSpeciesName.setCombinationAuthorTeam(author);
|
211
|
subSpeciesName.setBasionymAuthorTeam(basAuthor);
|
212
|
Assert.assertEquals("Expected full title cache has error", "Abies alba subsp. beta (Basio, A.) L., GenericRef", subSpeciesName.getFullTitleCache());
|
213
|
//cascade name change to fullTitleCache
|
214
|
subSpeciesName.setRank(Rank.SPECIES());
|
215
|
subSpeciesName.setProtectedNameCache(true);
|
216
|
Assert.assertNull("name cache should be null", subSpeciesName.getNameCache());
|
217
|
subSpeciesName.setProtectedNameCache(false);
|
218
|
Assert.assertNotNull("name cache should not be null", subSpeciesName.getNameCache());
|
219
|
Assert.assertEquals("Expected full title cache has error", "Abies alba (Basio, A.) L., GenericRef", subSpeciesName.getFullTitleCache());
|
220
|
Assert.assertEquals("Expected full title cache has error", "Abies alba (Basio, A.) L.", subSpeciesName.getTitleCache());
|
221
|
Assert.assertEquals("Expected full title cache has error", "Abies alba", subSpeciesName.getNameCache());
|
222
|
|
223
|
subSpeciesName.setProtectedNameCache(true);
|
224
|
subSpeciesName.setSpecificEpithet("gamma");
|
225
|
Assert.assertEquals("Expected full title cache has error", "Abies alba (Basio, A.) L., GenericRef", subSpeciesName.getFullTitleCache());
|
226
|
Assert.assertEquals("Expected full title cache has error", "Abies alba (Basio, A.) L.", subSpeciesName.getTitleCache());
|
227
|
Assert.assertEquals("Expected full title cache has error", "Abies alba", subSpeciesName.getNameCache());
|
228
|
//make original status
|
229
|
subSpeciesName.setRank(Rank.SUBSPECIES());
|
230
|
Assert.assertEquals("Expected full title cache has error", "Abies alba (Basio, A.) L., GenericRef", subSpeciesName.getFullTitleCache());
|
231
|
|
232
|
//author change
|
233
|
author.setNomenclaturalTitle("M.");
|
234
|
Assert.assertEquals("Expected full title cache has error", "(Basio, A.) M.", subSpeciesName.getAuthorshipCache());
|
235
|
Assert.assertEquals("Expected full title cache has error", "Abies alba (Basio, A.) M., GenericRef", subSpeciesName.getFullTitleCache());
|
236
|
Assert.assertEquals("Expected full title cache has error", "Abies alba (Basio, A.) M.", subSpeciesName.getTitleCache());
|
237
|
|
238
|
//protectedTitleCache
|
239
|
subSpeciesName.setProtectedTitleCache(true);
|
240
|
subSpeciesName.setProtectedNameCache(false);
|
241
|
subSpeciesName.setGenusOrUninomial("Pinus");
|
242
|
subSpeciesName.setSpecificEpithet("alba");
|
243
|
Assert.assertEquals("Expected full title cache has error", "Pinus alba subsp. beta", subSpeciesName.getNameCache());
|
244
|
Assert.assertEquals("Expected full title cache has error", "Abies alba (Basio, A.) M., GenericRef", subSpeciesName.getFullTitleCache());
|
245
|
Assert.assertEquals("Expected full title cache has error", "Abies alba (Basio, A.) M.", subSpeciesName.getTitleCache());
|
246
|
|
247
|
subSpeciesName.setTitleCache("Pinus beta C.", true);
|
248
|
Assert.assertEquals("Expected full title cache has error", "Pinus beta C., GenericRef", subSpeciesName.getFullTitleCache());
|
249
|
subSpeciesName.setProtectedTitleCache(false);
|
250
|
|
251
|
Assert.assertEquals("Expected full title cache has error", "Pinus alba subsp. beta (Basio, A.) M., GenericRef", subSpeciesName.getFullTitleCache());
|
252
|
|
253
|
//protected full title cache set
|
254
|
subSpeciesName.setFullTitleCache("ABC");
|
255
|
Assert.assertEquals("Expected full title cache has error", "ABC", subSpeciesName.getFullTitleCache());
|
256
|
subSpeciesName.setProtectedFullTitleCache(false);
|
257
|
Assert.assertEquals("Expected full title cache has error", "Pinus alba subsp. beta (Basio, A.) M., GenericRef", subSpeciesName.getFullTitleCache());
|
258
|
|
259
|
//protected title cache set
|
260
|
subSpeciesName.setProtectedTitleCache(false);
|
261
|
Assert.assertEquals("Expected full title cache has error", "Pinus alba subsp. beta (Basio, A.) M., GenericRef", subSpeciesName.getFullTitleCache());
|
262
|
|
263
|
//protectedNameCache set
|
264
|
subSpeciesName.setProtectedNameCache(true);
|
265
|
Assert.assertEquals("Expected full title cache has error", "Pinus alba subsp. beta (Basio, A.) M., GenericRef", subSpeciesName.getFullTitleCache());
|
266
|
subSpeciesName.setNameCache("P. alba subsp. beta");
|
267
|
Assert.assertEquals("Expected full title cache has error", "P. alba subsp. beta (Basio, A.) M., GenericRef", subSpeciesName.getFullTitleCache());
|
268
|
|
269
|
subSpeciesName.setGenusOrUninomial("A.");
|
270
|
subSpeciesName.setProtectedNameCache(false);
|
271
|
Assert.assertEquals("Expected full title cache has error", "A. alba subsp. beta (Basio, A.) M., GenericRef", subSpeciesName.getFullTitleCache());
|
272
|
subSpeciesName.setNameCache("P. alba subsp. beta");
|
273
|
Assert.assertEquals("Expected full title cache has error", "P. alba subsp. beta (Basio, A.) M., GenericRef", subSpeciesName.getFullTitleCache());
|
274
|
|
275
|
//protected authorship
|
276
|
subSpeciesName.setProtectedAuthorshipCache(true);
|
277
|
Assert.assertEquals("Expected full title cache has error", "P. alba subsp. beta (Basio, A.) M., GenericRef", subSpeciesName.getFullTitleCache());
|
278
|
subSpeciesName.setAuthorshipCache("Ciard.");
|
279
|
Assert.assertEquals("Expected full title cache has error", "P. alba subsp. beta Ciard., GenericRef", subSpeciesName.getFullTitleCache());
|
280
|
|
281
|
author.setNomenclaturalTitle("X.");
|
282
|
subSpeciesName.setProtectedAuthorshipCache(false);
|
283
|
Assert.assertEquals("Expected full title cache has error", "P. alba subsp. beta (Basio, A.) X., GenericRef", subSpeciesName.getFullTitleCache());
|
284
|
|
285
|
//clear
|
286
|
subSpeciesName.setProtectedNameCache(false);
|
287
|
Assert.assertEquals("Expected full title cache has error", "A. alba subsp. beta (Basio, A.) X., GenericRef", subSpeciesName.getFullTitleCache());
|
288
|
|
289
|
//appended phrase
|
290
|
subSpeciesName.setProtectedNameCache(true);
|
291
|
Assert.assertEquals("Expected full title cache has error", "A. alba subsp. beta (Basio, A.) X., GenericRef", subSpeciesName.getFullTitleCache());
|
292
|
subSpeciesName.setAppendedPhrase("app phrase");
|
293
|
Assert.assertEquals("Expected full title cache has error", "A. alba subsp. beta (Basio, A.) X., GenericRef", subSpeciesName.getFullTitleCache());
|
294
|
subSpeciesName.setProtectedNameCache(false);
|
295
|
Assert.assertEquals("Expected full title cache has error", "A. alba subsp. beta app phrase (Basio, A.) X., GenericRef", subSpeciesName.getFullTitleCache());
|
296
|
subSpeciesName.setAppendedPhrase("app2 phrase2");
|
297
|
subSpeciesName.setProtectedNameCache(true);
|
298
|
Assert.assertNull("NameCache should be null", subSpeciesName.getNameCache());
|
299
|
subSpeciesName.setProtectedNameCache(false);
|
300
|
subSpeciesName.setAppendedPhrase(null);
|
301
|
|
302
|
|
303
|
//ref + nomRef
|
304
|
Reference book = ReferenceFactory.newBook();
|
305
|
book.setTitle("Booktitle");
|
306
|
Assert.assertNotNull("TitleCache should not be null", subSpeciesName.getTitleCache());
|
307
|
subSpeciesName.setNomenclaturalReference(book);
|
308
|
subSpeciesName.setNomenclaturalMicroReference("22");
|
309
|
Assert.assertEquals("Expected full title cache has error", "A. alba subsp. beta (Basio, A.) X., Booktitle: 22", subSpeciesName.getFullTitleCache());
|
310
|
subSpeciesName.setProtectedTitleCache(true);
|
311
|
Assert.assertNotNull("TitleCache should not be null", subSpeciesName.getTitleCache());
|
312
|
|
313
|
//year
|
314
|
ZoologicalName zooName = ZoologicalName.NewInstance(Rank.SPECIES());
|
315
|
zooName.setGenusOrUninomial("Homo");
|
316
|
zooName.setSpecificEpithet("sapiens");
|
317
|
zooName.setBasionymAuthorTeam(basAuthor);
|
318
|
zooName.setCombinationAuthorTeam(author);
|
319
|
zooName.setNomenclaturalReference(book);
|
320
|
zooName.setNomenclaturalMicroReference("22");
|
321
|
Assert.assertEquals("Expected full title cache has error", "Homo sapiens (Basio, A.) X., Booktitle: 22", zooName.getFullTitleCache());
|
322
|
|
323
|
zooName.setOriginalPublicationYear(1922);
|
324
|
zooName.setPublicationYear(1948);
|
325
|
Assert.assertEquals("Expected full title cache has error", "Homo sapiens (Basio, A., 1922) X., 1948, Booktitle: 22", zooName.getFullTitleCache());
|
326
|
zooName.setOriginalPublicationYear(1923);
|
327
|
zooName.setProtectedAuthorshipCache(true);
|
328
|
Assert.assertNull("AuthorshipCache should be null", zooName.getAuthorshipCache());
|
329
|
zooName.setProtectedAuthorshipCache(false);
|
330
|
Assert.assertNotNull("AuthorshipCache should not be null", zooName.getAuthorshipCache());
|
331
|
zooName.setPublicationYear(1949);
|
332
|
zooName.setProtectedAuthorshipCache(true);
|
333
|
Assert.assertNull("AuthorshipCache should be null", zooName.getAuthorshipCache());
|
334
|
|
335
|
|
336
|
|
337
|
|
338
|
}
|
339
|
|
340
|
/**
|
341
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#setNameAuthorSeperator(java.lang.String)}.
|
342
|
*/
|
343
|
@Test
|
344
|
public void testGetSetNameAuthorSeperator() {
|
345
|
String authorSeparator = "authorSeparator";
|
346
|
strategy.setNameAuthorSeperator(authorSeparator);
|
347
|
assertEquals(authorSeparator, strategy.getNameAuthorSeperator());
|
348
|
strategy.setNameAuthorSeperator(null);
|
349
|
assertNull(strategy.getNameAuthorSeperator());
|
350
|
}
|
351
|
|
352
|
/**
|
353
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#setBasionymStart(java.lang.String)}.
|
354
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#getBasionymStart()}.
|
355
|
*/
|
356
|
@Test
|
357
|
public void testGetSetBasionymStart() {
|
358
|
String basStart = "start";
|
359
|
strategy.setBasionymStart(basStart);
|
360
|
assertEquals(basStart, strategy.getBasionymStart());
|
361
|
strategy.setBasionymStart(null);
|
362
|
assertNull(strategy.getBasionymStart());
|
363
|
}
|
364
|
|
365
|
/**
|
366
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#setBasionymEnd(java.lang.String)}.
|
367
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#getBasionymEnd()}.
|
368
|
*/
|
369
|
@Test
|
370
|
public void testGetSetBasionymEnd() {
|
371
|
String basEnd = "end";
|
372
|
strategy.setBasionymEnd(basEnd);
|
373
|
assertEquals(basEnd, strategy.getBasionymEnd());
|
374
|
strategy.setBasionymEnd(null);
|
375
|
assertNull(strategy.getBasionymEnd());
|
376
|
}
|
377
|
|
378
|
/**
|
379
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#setExAuthorSeperator(java.lang.String)}.
|
380
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#getExAuthorSeperator()}.
|
381
|
*/
|
382
|
@Test
|
383
|
public void testGetSetExAuthorSeperator() {
|
384
|
String exAuthorSeparator = "exAuthorSeparator";
|
385
|
strategy.setExAuthorSeperator(exAuthorSeparator);
|
386
|
assertEquals(exAuthorSeparator, strategy.getExAuthorSeperator());
|
387
|
strategy.setExAuthorSeperator(null);
|
388
|
assertNull(strategy.getExAuthorSeperator());
|
389
|
}
|
390
|
|
391
|
/**
|
392
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#setBasionymAuthorCombinationAuthorSeperator(java.lang.CharSequence)}.
|
393
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#getBasionymAuthorCombinationAuthorSeperator()}.
|
394
|
*/
|
395
|
@Test
|
396
|
public void testSetBasionymAuthorCombinationAuthorSeperator() {
|
397
|
String basComSeparator = "basComSeparator";
|
398
|
strategy.setBasionymAuthorCombinationAuthorSeperator(basComSeparator);
|
399
|
assertEquals(basComSeparator, strategy.getBasionymAuthorCombinationAuthorSeperator());
|
400
|
strategy.setBasionymAuthorCombinationAuthorSeperator(null);
|
401
|
assertNull(strategy.getBasionymAuthorCombinationAuthorSeperator());
|
402
|
}
|
403
|
|
404
|
@Test
|
405
|
public void testGetInfraGenericNames(){
|
406
|
String author = "Anyauthor";
|
407
|
NonViralName nonViralName = NonViralName.NewInstance(Rank.SUBGENUS());
|
408
|
nonViralName.setGenusOrUninomial("Genus");
|
409
|
nonViralName.setInfraGenericEpithet("subgenus");
|
410
|
nonViralName.setAuthorshipCache(author);
|
411
|
|
412
|
//test ordinary infrageneric
|
413
|
String subGenusNameCache = strategy.getInfraGenusNameCache(nonViralName);
|
414
|
assertEquals("Subgenus name should be 'Genus subg. subgenus'.", "Genus subg. subgenus", subGenusNameCache);
|
415
|
String subGenusTitle = strategy.getTitleCache(nonViralName);
|
416
|
assertEquals("Subgenus name should be 'Genus subg. subgenus Anyauthor'.", "Genus subg. subgenus Anyauthor", subGenusTitle);
|
417
|
|
418
|
//test species aggregates and species groups
|
419
|
nonViralName.setRank(Rank.SPECIESAGGREGATE());
|
420
|
nonViralName.setSpecificEpithet("myspecies");
|
421
|
nonViralName.setInfraGenericEpithet(null);
|
422
|
String aggrNameCache = strategy.getInfraGenusNameCache(nonViralName);
|
423
|
assertEquals("Species aggregate name should be 'Genus myspecies aggr.'.", "Genus myspecies aggr.", aggrNameCache);
|
424
|
String aggrNameTitle = strategy.getTitleCache(nonViralName);
|
425
|
Assert.assertTrue("Species aggregate should not include author information.", aggrNameTitle.indexOf(author) == -1);
|
426
|
assertEquals("Species aggregate name should be 'Genus myspecies aggr.'.", "Genus myspecies aggr.", aggrNameTitle);
|
427
|
nonViralName.setRank(Rank.SPECIESGROUP());
|
428
|
String groupNameTitle = strategy.getTitleCache(nonViralName);
|
429
|
assertEquals("Species group name should be 'Genus myspecies species group'.", "Genus myspecies species group", groupNameTitle);
|
430
|
|
431
|
//test species aggregates and species groups with infrageneric information
|
432
|
//TODO check if groups do ever have infrageneric epithets
|
433
|
nonViralName.setRank(Rank.SPECIESAGGREGATE());
|
434
|
nonViralName.setSpecificEpithet("myspecies");
|
435
|
nonViralName.setInfraGenericEpithet("Infragenus");
|
436
|
aggrNameCache = strategy.getInfraGenusNameCache(nonViralName);
|
437
|
assertEquals("Species aggregate name should be 'Genus (Infragenus) myspecies aggr.'.", "Genus (Infragenus) myspecies aggr.", aggrNameCache);
|
438
|
|
439
|
aggrNameTitle = strategy.getTitleCache(nonViralName);
|
440
|
Assert.assertTrue("Species aggregate should not include author information.", aggrNameTitle.indexOf(author) == -1);
|
441
|
assertEquals("Species aggregate name should be 'Genus (Infragenus) myspecies aggr.'.", "Genus (Infragenus) myspecies aggr.", aggrNameTitle);
|
442
|
|
443
|
nonViralName.setRank(Rank.SPECIESGROUP());
|
444
|
groupNameTitle = strategy.getTitleCache(nonViralName);
|
445
|
assertEquals("Species group name should be 'Genus (Infragenus) myspecies species group'.", "Genus (Infragenus) myspecies species group", groupNameTitle);
|
446
|
|
447
|
|
448
|
}
|
449
|
|
450
|
/**
|
451
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#getTaggedName(eu.etaxonomy.cdm.model.name.NonViralName)}.
|
452
|
*/
|
453
|
@Test
|
454
|
public void testGetTaggedNameSpeciesAggregate() {
|
455
|
BotanicalName speciesAggregate = BotanicalName.NewInstance(Rank.SPECIESAGGREGATE());
|
456
|
speciesAggregate.setGenusOrUninomial("Mygenus");
|
457
|
speciesAggregate.setSpecificEpithet("myspecies");
|
458
|
List<Object> taggedName = strategy.getTaggedName(speciesAggregate);
|
459
|
Assert.assertEquals("1rd tag must be genus epithet", "Mygenus", taggedName.get(0));
|
460
|
Assert.assertEquals("2rd tag must be species epithet", "myspecies", taggedName.get(1));
|
461
|
Assert.assertEquals("3rd tag must be aggregate marker", "aggr.",taggedName.get(2));
|
462
|
}
|
463
|
|
464
|
|
465
|
@Test
|
466
|
public void testGetTaggedNameSubspecies(){
|
467
|
List taggedName = strategy.getTaggedName(subSpeciesName);
|
468
|
Assert.assertEquals("First tag should be 'Abies'", "Abies", taggedName.get(0));
|
469
|
Assert.assertEquals("Second tag should be 'alba'", "alba", taggedName.get(1));
|
470
|
Assert.assertEquals("Third tag should be subspecies rank", Rank.SUBSPECIES(), taggedName.get(2));
|
471
|
Assert.assertEquals("Third tag should be subspecies rank, and rank abbreviatioin should be subsp.", "subsp.", ((Rank)taggedName.get(2)).getAbbreviation() );
|
472
|
Assert.assertEquals("Fourth tag should be 'beta'", "beta", taggedName.get(3));
|
473
|
//to be continued
|
474
|
|
475
|
}
|
476
|
|
477
|
|
478
|
}
|