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.ReferenceBase;
|
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 ReferenceBase citationRef;
|
65
|
private ReferenceFactory refFactory;
|
66
|
|
67
|
@BeforeClass
|
68
|
public static void setUpBeforeClass() {
|
69
|
DefaultTermInitializer vocabularyStore = new DefaultTermInitializer();
|
70
|
vocabularyStore.initialize();
|
71
|
}
|
72
|
|
73
|
/**
|
74
|
* @throws java.lang.Exception
|
75
|
*/
|
76
|
@Before
|
77
|
public void setUp() throws Exception {
|
78
|
refFactory = ReferenceFactory.newInstance();
|
79
|
strategy = NonViralNameDefaultCacheStrategy.NewInstance();
|
80
|
familyName = BotanicalName.PARSED_NAME(familyNameString, Rank.FAMILY());
|
81
|
genusName = BotanicalName.PARSED_NAME(genusNameString, Rank.GENUS());
|
82
|
|
83
|
subGenusName = BotanicalName.NewInstance(Rank.SUBGENUS());
|
84
|
subGenusName.setGenusOrUninomial("Genus");
|
85
|
subGenusName.setInfraGenericEpithet("InfraGenericPart");
|
86
|
|
87
|
speciesName = BotanicalName.PARSED_NAME(speciesNameString);
|
88
|
subSpeciesName = BotanicalName.PARSED_NAME(subSpeciesNameString);
|
89
|
|
90
|
author = Person.NewInstance();
|
91
|
author.setNomenclaturalTitle(authorString);
|
92
|
exAuthor = Person.NewInstance();
|
93
|
exAuthor.setNomenclaturalTitle(exAuthorString);
|
94
|
basAuthor = Person.NewInstance();
|
95
|
basAuthor.setNomenclaturalTitle(basAuthorString);
|
96
|
exBasAuthor = Person.NewInstance();
|
97
|
exBasAuthor.setNomenclaturalTitle(exBasAuthorString);
|
98
|
|
99
|
}
|
100
|
|
101
|
//**************************** TESTS **************************************************
|
102
|
|
103
|
/**
|
104
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#getTitleCache(eu.etaxonomy.cdm.model.name.NonViralName)}.
|
105
|
*/
|
106
|
@Test
|
107
|
public void testGetTitleCache() {
|
108
|
logger.warn("Not yet implemented");
|
109
|
}
|
110
|
|
111
|
/**
|
112
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#getFullTitleCache(eu.etaxonomy.cdm.model.name.NonViralName)}.
|
113
|
*/
|
114
|
@Test
|
115
|
public void testGetFullTitleCache() {
|
116
|
logger.warn("Not yet implemented");
|
117
|
}
|
118
|
|
119
|
|
120
|
/**
|
121
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#getNameCache(eu.etaxonomy.cdm.model.name.NonViralName)}.
|
122
|
*/
|
123
|
@Test
|
124
|
public void testGetNameCache() {
|
125
|
assertEquals("Species Name should be Abies alba", speciesNameString, speciesName.getNameCache());
|
126
|
speciesName.setNameCache("Any species");
|
127
|
assertEquals("Species Name should be Any species", "Any species", speciesName.getNameCache());
|
128
|
assertEquals("Species Name should be Any species", "Any species", speciesName.getTitleCache());
|
129
|
assertEquals("subSpeciesNameString should be correct", subSpeciesNameString, subSpeciesName.getNameCache());
|
130
|
BotanicalName botName = BotanicalName.NewInstance(Rank.VARIETY());
|
131
|
botName.setGenusOrUninomial("Lepidocaryum");
|
132
|
botName.setSpecificEpithet("tenue");
|
133
|
botName.setInfraSpecificEpithet("tenue");
|
134
|
assertEquals("", "Lepidocaryum tenue var. tenue", botName.getNameCache());
|
135
|
BotanicalName specName = BotanicalName.NewInstance(Rank.SPECIES());
|
136
|
specName.setGenusOrUninomial("Genus");
|
137
|
specName.setSpecificEpithet("");
|
138
|
assertEquals("Empty species string must not result in trailing whitespace", "Genus", specName.getNameCache());
|
139
|
|
140
|
}
|
141
|
|
142
|
/**
|
143
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#getAuthorshipCache(eu.etaxonomy.cdm.model.name.NonViralName)}.
|
144
|
*/
|
145
|
@Test
|
146
|
public void testGetAuthorshipCache() {
|
147
|
this.speciesName.setCombinationAuthorTeam(author);
|
148
|
assertEquals(author.getNomenclaturalTitle(), speciesName.getAuthorshipCache());
|
149
|
this.speciesName.setBasionymAuthorTeam(basAuthor);
|
150
|
String expected = strategy.getBasionymStart()+ basAuthor.getNomenclaturalTitle()+strategy.getBasionymEnd()+strategy.getBasionymAuthorCombinationAuthorSeperator()+author.getNomenclaturalTitle();
|
151
|
assertEquals(expected, speciesName.getAuthorshipCache());
|
152
|
String authorshipcache = "authorshipcache";
|
153
|
speciesName.setAuthorshipCache(authorshipcache);
|
154
|
assertEquals(authorshipcache, speciesName.getAuthorshipCache());
|
155
|
speciesName.setCombinationAuthorTeam(exAuthor);
|
156
|
assertEquals(authorshipcache, speciesName.getAuthorshipCache()); //cache is protected
|
157
|
assertEquals(speciesNameString + " " + authorshipcache, speciesName.getFullTitleCache());
|
158
|
//unprotected
|
159
|
speciesName.setProtectedAuthorshipCache(false);
|
160
|
String atomizedAuthorCache = strategy.getBasionymStart()+ basAuthor.getNomenclaturalTitle()+strategy.getBasionymEnd()+strategy.getBasionymAuthorCombinationAuthorSeperator()+exAuthor.getNomenclaturalTitle();
|
161
|
assertEquals(atomizedAuthorCache, speciesName.getAuthorshipCache());
|
162
|
String atomizedTitleCache = speciesNameString + " "+ strategy.getBasionymStart()+ basAuthor.getNomenclaturalTitle()+strategy.getBasionymEnd()+strategy.getBasionymAuthorCombinationAuthorSeperator()+exAuthor.getNomenclaturalTitle();
|
163
|
assertEquals(atomizedTitleCache, speciesName.getTitleCache());
|
164
|
assertEquals(atomizedTitleCache, speciesName.getFullTitleCache());
|
165
|
}
|
166
|
|
167
|
@Test
|
168
|
public void testCacheListener() {
|
169
|
ReferenceBase ref = refFactory.newGeneric();
|
170
|
ref.setTitleCache("GenericRef",true);
|
171
|
this.subSpeciesName.setNomenclaturalReference(ref);
|
172
|
Assert.assertEquals("Expected full title cache has error", "Abies alba subsp. beta, GenericRef", subSpeciesName.getFullTitleCache());
|
173
|
subSpeciesName.setCombinationAuthorTeam(author);
|
174
|
subSpeciesName.setBasionymAuthorTeam(basAuthor);
|
175
|
Assert.assertEquals("Expected full title cache has error", "Abies alba subsp. beta (Basio, A.) L., GenericRef", subSpeciesName.getFullTitleCache());
|
176
|
//cascade name change to fullTitleCache
|
177
|
subSpeciesName.setRank(Rank.SPECIES());
|
178
|
subSpeciesName.setProtectedNameCache(true);
|
179
|
Assert.assertNull("name cache should be null", subSpeciesName.getNameCache());
|
180
|
subSpeciesName.setProtectedNameCache(false);
|
181
|
Assert.assertNotNull("name cache should not be null", subSpeciesName.getNameCache());
|
182
|
Assert.assertEquals("Expected full title cache has error", "Abies alba (Basio, A.) L., GenericRef", subSpeciesName.getFullTitleCache());
|
183
|
Assert.assertEquals("Expected full title cache has error", "Abies alba (Basio, A.) L.", subSpeciesName.getTitleCache());
|
184
|
Assert.assertEquals("Expected full title cache has error", "Abies alba", subSpeciesName.getNameCache());
|
185
|
|
186
|
subSpeciesName.setProtectedNameCache(true);
|
187
|
subSpeciesName.setSpecificEpithet("gamma");
|
188
|
Assert.assertEquals("Expected full title cache has error", "Abies alba (Basio, A.) L., GenericRef", subSpeciesName.getFullTitleCache());
|
189
|
Assert.assertEquals("Expected full title cache has error", "Abies alba (Basio, A.) L.", subSpeciesName.getTitleCache());
|
190
|
Assert.assertEquals("Expected full title cache has error", "Abies alba", subSpeciesName.getNameCache());
|
191
|
//make original status
|
192
|
subSpeciesName.setRank(Rank.SUBSPECIES());
|
193
|
Assert.assertEquals("Expected full title cache has error", "Abies alba (Basio, A.) L., GenericRef", subSpeciesName.getFullTitleCache());
|
194
|
|
195
|
//author change
|
196
|
author.setNomenclaturalTitle("M.");
|
197
|
Assert.assertEquals("Expected full title cache has error", "(Basio, A.) M.", subSpeciesName.getAuthorshipCache());
|
198
|
Assert.assertEquals("Expected full title cache has error", "Abies alba (Basio, A.) M., GenericRef", subSpeciesName.getFullTitleCache());
|
199
|
Assert.assertEquals("Expected full title cache has error", "Abies alba (Basio, A.) M.", subSpeciesName.getTitleCache());
|
200
|
|
201
|
//protectedTitleCache
|
202
|
subSpeciesName.setProtectedTitleCache(true);
|
203
|
subSpeciesName.setProtectedNameCache(false);
|
204
|
subSpeciesName.setGenusOrUninomial("Pinus");
|
205
|
subSpeciesName.setSpecificEpithet("alba");
|
206
|
Assert.assertEquals("Expected full title cache has error", "Pinus alba subsp. beta", subSpeciesName.getNameCache());
|
207
|
Assert.assertEquals("Expected full title cache has error", "Abies alba (Basio, A.) M., GenericRef", subSpeciesName.getFullTitleCache());
|
208
|
Assert.assertEquals("Expected full title cache has error", "Abies alba (Basio, A.) M.", subSpeciesName.getTitleCache());
|
209
|
|
210
|
subSpeciesName.setTitleCache("Pinus beta C.", true);
|
211
|
Assert.assertEquals("Expected full title cache has error", "Pinus beta C., GenericRef", subSpeciesName.getFullTitleCache());
|
212
|
subSpeciesName.setProtectedTitleCache(false);
|
213
|
|
214
|
Assert.assertEquals("Expected full title cache has error", "Pinus alba subsp. beta (Basio, A.) M., GenericRef", subSpeciesName.getFullTitleCache());
|
215
|
|
216
|
//protected full title cache set
|
217
|
subSpeciesName.setFullTitleCache("ABC");
|
218
|
Assert.assertEquals("Expected full title cache has error", "ABC", subSpeciesName.getFullTitleCache());
|
219
|
subSpeciesName.setProtectedFullTitleCache(false);
|
220
|
Assert.assertEquals("Expected full title cache has error", "Pinus alba subsp. beta (Basio, A.) M., GenericRef", subSpeciesName.getFullTitleCache());
|
221
|
|
222
|
//protected title cache set
|
223
|
subSpeciesName.setProtectedTitleCache(false);
|
224
|
Assert.assertEquals("Expected full title cache has error", "Pinus alba subsp. beta (Basio, A.) M., GenericRef", subSpeciesName.getFullTitleCache());
|
225
|
|
226
|
//protectedNameCache set
|
227
|
subSpeciesName.setProtectedNameCache(true);
|
228
|
Assert.assertEquals("Expected full title cache has error", "Pinus alba subsp. beta (Basio, A.) M., GenericRef", subSpeciesName.getFullTitleCache());
|
229
|
subSpeciesName.setNameCache("P. alba subsp. beta");
|
230
|
Assert.assertEquals("Expected full title cache has error", "P. alba subsp. beta (Basio, A.) M., GenericRef", subSpeciesName.getFullTitleCache());
|
231
|
|
232
|
subSpeciesName.setGenusOrUninomial("A.");
|
233
|
subSpeciesName.setProtectedNameCache(false);
|
234
|
Assert.assertEquals("Expected full title cache has error", "A. alba subsp. beta (Basio, A.) M., GenericRef", subSpeciesName.getFullTitleCache());
|
235
|
subSpeciesName.setNameCache("P. alba subsp. beta");
|
236
|
Assert.assertEquals("Expected full title cache has error", "P. alba subsp. beta (Basio, A.) M., GenericRef", subSpeciesName.getFullTitleCache());
|
237
|
|
238
|
//protected authorship
|
239
|
subSpeciesName.setProtectedAuthorshipCache(true);
|
240
|
Assert.assertEquals("Expected full title cache has error", "P. alba subsp. beta (Basio, A.) M., GenericRef", subSpeciesName.getFullTitleCache());
|
241
|
subSpeciesName.setAuthorshipCache("Ciard.");
|
242
|
Assert.assertEquals("Expected full title cache has error", "P. alba subsp. beta Ciard., GenericRef", subSpeciesName.getFullTitleCache());
|
243
|
|
244
|
author.setNomenclaturalTitle("X.");
|
245
|
subSpeciesName.setProtectedAuthorshipCache(false);
|
246
|
Assert.assertEquals("Expected full title cache has error", "P. alba subsp. beta (Basio, A.) X., GenericRef", subSpeciesName.getFullTitleCache());
|
247
|
|
248
|
//clear
|
249
|
subSpeciesName.setProtectedNameCache(false);
|
250
|
Assert.assertEquals("Expected full title cache has error", "A. alba subsp. beta (Basio, A.) X., GenericRef", subSpeciesName.getFullTitleCache());
|
251
|
|
252
|
//appended phrase
|
253
|
subSpeciesName.setProtectedNameCache(true);
|
254
|
Assert.assertEquals("Expected full title cache has error", "A. alba subsp. beta (Basio, A.) X., GenericRef", subSpeciesName.getFullTitleCache());
|
255
|
subSpeciesName.setAppendedPhrase("app phrase");
|
256
|
Assert.assertEquals("Expected full title cache has error", "A. alba subsp. beta (Basio, A.) X., GenericRef", subSpeciesName.getFullTitleCache());
|
257
|
subSpeciesName.setProtectedNameCache(false);
|
258
|
Assert.assertEquals("Expected full title cache has error", "A. alba subsp. beta app phrase (Basio, A.) X., GenericRef", subSpeciesName.getFullTitleCache());
|
259
|
subSpeciesName.setAppendedPhrase("app2 phrase2");
|
260
|
subSpeciesName.setProtectedNameCache(true);
|
261
|
Assert.assertNull("NameCache should be null", subSpeciesName.getNameCache());
|
262
|
subSpeciesName.setProtectedNameCache(false);
|
263
|
subSpeciesName.setAppendedPhrase(null);
|
264
|
|
265
|
|
266
|
//ref + nomRef
|
267
|
ReferenceBase book = refFactory.newBook();
|
268
|
book.setTitle("Booktitle");
|
269
|
Assert.assertNotNull("TitleCache should not be null", subSpeciesName.getTitleCache());
|
270
|
subSpeciesName.setNomenclaturalReference(book);
|
271
|
subSpeciesName.setNomenclaturalMicroReference("22");
|
272
|
Assert.assertEquals("Expected full title cache has error", "A. alba subsp. beta (Basio, A.) X., Booktitle: 22", subSpeciesName.getFullTitleCache());
|
273
|
subSpeciesName.setProtectedTitleCache(true);
|
274
|
Assert.assertNotNull("TitleCache should not be null", subSpeciesName.getTitleCache());
|
275
|
|
276
|
//year
|
277
|
ZoologicalName zooName = ZoologicalName.NewInstance(Rank.SPECIES());
|
278
|
zooName.setGenusOrUninomial("Homo");
|
279
|
zooName.setSpecificEpithet("sapiens");
|
280
|
zooName.setBasionymAuthorTeam(basAuthor);
|
281
|
zooName.setCombinationAuthorTeam(author);
|
282
|
zooName.setNomenclaturalReference(book);
|
283
|
zooName.setNomenclaturalMicroReference("22");
|
284
|
Assert.assertEquals("Expected full title cache has error", "Homo sapiens (Basio, A.) X., Booktitle: 22", zooName.getFullTitleCache());
|
285
|
|
286
|
zooName.setOriginalPublicationYear(1922);
|
287
|
zooName.setPublicationYear(1948);
|
288
|
Assert.assertEquals("Expected full title cache has error", "Homo sapiens (Basio, A., 1922) X., 1948, Booktitle: 22", zooName.getFullTitleCache());
|
289
|
zooName.setOriginalPublicationYear(1923);
|
290
|
zooName.setProtectedAuthorshipCache(true);
|
291
|
Assert.assertNull("AuthorshipCache should be null", zooName.getAuthorshipCache());
|
292
|
zooName.setProtectedAuthorshipCache(false);
|
293
|
Assert.assertNotNull("AuthorshipCache should not be null", zooName.getAuthorshipCache());
|
294
|
zooName.setPublicationYear(1949);
|
295
|
zooName.setProtectedAuthorshipCache(true);
|
296
|
Assert.assertNull("AuthorshipCache should be null", zooName.getAuthorshipCache());
|
297
|
|
298
|
|
299
|
|
300
|
|
301
|
}
|
302
|
|
303
|
/**
|
304
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#getTaggedName(eu.etaxonomy.cdm.model.name.NonViralName)}.
|
305
|
*/
|
306
|
@Test
|
307
|
public void testGetTaggedName() {
|
308
|
logger.warn("testGetTaggedName yet implemented");
|
309
|
}
|
310
|
|
311
|
/**
|
312
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#setNameAuthorSeperator(java.lang.String)}.
|
313
|
*/
|
314
|
@Test
|
315
|
public void testGetSetNameAuthorSeperator() {
|
316
|
String authorSeparator = "authorSeparator";
|
317
|
strategy.setNameAuthorSeperator(authorSeparator);
|
318
|
assertEquals(authorSeparator, strategy.getNameAuthorSeperator());
|
319
|
strategy.setNameAuthorSeperator(null);
|
320
|
assertNull(strategy.getNameAuthorSeperator());
|
321
|
}
|
322
|
|
323
|
/**
|
324
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#setBasionymStart(java.lang.String)}.
|
325
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#getBasionymStart()}.
|
326
|
*/
|
327
|
@Test
|
328
|
public void testGetSetBasionymStart() {
|
329
|
String basStart = "start";
|
330
|
strategy.setBasionymStart(basStart);
|
331
|
assertEquals(basStart, strategy.getBasionymStart());
|
332
|
strategy.setBasionymStart(null);
|
333
|
assertNull(strategy.getBasionymStart());
|
334
|
}
|
335
|
|
336
|
/**
|
337
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#setBasionymEnd(java.lang.String)}.
|
338
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#getBasionymEnd()}.
|
339
|
*/
|
340
|
@Test
|
341
|
public void testGetSetBasionymEnd() {
|
342
|
String basEnd = "end";
|
343
|
strategy.setBasionymEnd(basEnd);
|
344
|
assertEquals(basEnd, strategy.getBasionymEnd());
|
345
|
strategy.setBasionymEnd(null);
|
346
|
assertNull(strategy.getBasionymEnd());
|
347
|
}
|
348
|
|
349
|
/**
|
350
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#setExAuthorSeperator(java.lang.String)}.
|
351
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#getExAuthorSeperator()}.
|
352
|
*/
|
353
|
@Test
|
354
|
public void testGetSetExAuthorSeperator() {
|
355
|
String exAuthorSeparator = "exAuthorSeparator";
|
356
|
strategy.setExAuthorSeperator(exAuthorSeparator);
|
357
|
assertEquals(exAuthorSeparator, strategy.getExAuthorSeperator());
|
358
|
strategy.setExAuthorSeperator(null);
|
359
|
assertNull(strategy.getExAuthorSeperator());
|
360
|
}
|
361
|
|
362
|
/**
|
363
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#setBasionymAuthorCombinationAuthorSeperator(java.lang.CharSequence)}.
|
364
|
* Test method for {@link eu.etaxonomy.cdm.strategy.cache.name.NonViralNameDefaultCacheStrategy#getBasionymAuthorCombinationAuthorSeperator()}.
|
365
|
*/
|
366
|
@Test
|
367
|
public void testSetBasionymAuthorCombinationAuthorSeperator() {
|
368
|
String basComSeparator = "basComSeparator";
|
369
|
strategy.setBasionymAuthorCombinationAuthorSeperator(basComSeparator);
|
370
|
assertEquals(basComSeparator, strategy.getBasionymAuthorCombinationAuthorSeperator());
|
371
|
strategy.setBasionymAuthorCombinationAuthorSeperator(null);
|
372
|
assertNull(strategy.getBasionymAuthorCombinationAuthorSeperator());
|
373
|
}
|
374
|
|
375
|
@Test
|
376
|
public void testGetInfraGericNames(){
|
377
|
String author = "Anyauthor";
|
378
|
NonViralName nonViralName = NonViralName.NewInstance(Rank.SUBGENUS());
|
379
|
nonViralName.setGenusOrUninomial("Genus");
|
380
|
nonViralName.setInfraGenericEpithet("subgenus");
|
381
|
nonViralName.setAuthorshipCache(author);
|
382
|
//test ordinary infrageneric
|
383
|
String subGenusNameCache = strategy.getInfraGenusNameCache(nonViralName);
|
384
|
assertEquals("Subgenus name should be 'Genus subg. subgenus'.", "Genus subg. subgenus", subGenusNameCache);
|
385
|
String subGenusTitle = strategy.getTitleCache(nonViralName);
|
386
|
assertEquals("Subgenus name should be 'Genus subg. subgenus Anyauthor'.", "Genus subg. subgenus Anyauthor", subGenusTitle);
|
387
|
//test species aggregates and species groups
|
388
|
nonViralName.setRank(Rank.SPECIESAGGREGATE());
|
389
|
nonViralName.setSpecificEpithet("species");
|
390
|
String aggrNameCache = strategy.getInfraGenusNameCache(nonViralName);
|
391
|
assertEquals("Species aggregate name should be 'Genus species aggr.'.", "Genus species aggr.", aggrNameCache);
|
392
|
String aggrNameTitle = strategy.getTitleCache(nonViralName);
|
393
|
Assert.assertTrue("Species aggregate should not include author information.", aggrNameTitle.indexOf(author) == -1);
|
394
|
assertEquals("Species aggregate name should be 'Genus species aggr.'.", "Genus species aggr.", aggrNameTitle);
|
395
|
nonViralName.setRank(Rank.SPECIESGROUP());
|
396
|
String groupNameTitle = strategy.getTitleCache(nonViralName);
|
397
|
assertEquals("Species group name should be 'Genus species group'.", "Genus species group", groupNameTitle);
|
398
|
|
399
|
}
|
400
|
|
401
|
@Test
|
402
|
public void getTaggedName(){
|
403
|
// BotanicalName botName = BotanicalName.NewInstance(Rank.SUBSPECIES());
|
404
|
// botName.setGenusOrUninomial("Genus");
|
405
|
// botName.setSpecificEpithet("species");
|
406
|
// botName.setInfraSpecificEpithet("subspecies");
|
407
|
List taggedName = strategy.getTaggedName(subSpeciesName);
|
408
|
Assert.assertEquals("First tag should be 'Abies'", "Abies", taggedName.get(0));
|
409
|
Assert.assertEquals("Second tag should be 'alba'", "alba", taggedName.get(1));
|
410
|
Assert.assertEquals("Third tag should be subspecies rank", Rank.SUBSPECIES(), taggedName.get(2));
|
411
|
Assert.assertEquals("Third tag should be subspecies rank, and rank abbreviatioin should be subsp.", "subsp.", ((Rank)taggedName.get(2)).getAbbreviation() );
|
412
|
Assert.assertEquals("Fourth tag should be 'beta'", "beta", taggedName.get(3));
|
413
|
//to be continued
|
414
|
|
415
|
}
|
416
|
|
417
|
}
|