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.parser;
|
11
|
|
12
|
import static org.junit.Assert.assertEquals;
|
13
|
import static org.junit.Assert.assertFalse;
|
14
|
import static org.junit.Assert.assertNotNull;
|
15
|
import static org.junit.Assert.assertNull;
|
16
|
import static org.junit.Assert.assertTrue;
|
17
|
|
18
|
import java.lang.reflect.InvocationTargetException;
|
19
|
import java.lang.reflect.Method;
|
20
|
import java.util.List;
|
21
|
import java.util.regex.Matcher;
|
22
|
import java.util.regex.Pattern;
|
23
|
|
24
|
import org.apache.log4j.Logger;
|
25
|
import org.joda.time.DateTime;
|
26
|
import org.joda.time.Duration;
|
27
|
import org.junit.Assert;
|
28
|
import org.junit.Before;
|
29
|
import org.junit.BeforeClass;
|
30
|
import org.junit.Test;
|
31
|
|
32
|
import eu.etaxonomy.cdm.common.UTF8;
|
33
|
import eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor;
|
34
|
import eu.etaxonomy.cdm.model.agent.Person;
|
35
|
import eu.etaxonomy.cdm.model.agent.Team;
|
36
|
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
|
37
|
import eu.etaxonomy.cdm.model.common.DefaultTermInitializer;
|
38
|
import eu.etaxonomy.cdm.model.name.BotanicalName;
|
39
|
import eu.etaxonomy.cdm.model.name.HybridRelationship;
|
40
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
41
|
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
|
42
|
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
|
43
|
import eu.etaxonomy.cdm.model.name.NonViralName;
|
44
|
import eu.etaxonomy.cdm.model.name.Rank;
|
45
|
import eu.etaxonomy.cdm.model.name.ZoologicalName;
|
46
|
import eu.etaxonomy.cdm.model.reference.IArticle;
|
47
|
import eu.etaxonomy.cdm.model.reference.IBook;
|
48
|
import eu.etaxonomy.cdm.model.reference.IBookSection;
|
49
|
import eu.etaxonomy.cdm.model.reference.IJournal;
|
50
|
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
|
51
|
import eu.etaxonomy.cdm.model.reference.IReference;
|
52
|
import eu.etaxonomy.cdm.model.reference.IVolumeReference;
|
53
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
54
|
import eu.etaxonomy.cdm.model.reference.ReferenceType;
|
55
|
import eu.etaxonomy.cdm.strategy.exceptions.StringNotParsableException;
|
56
|
/**
|
57
|
* @author a.mueller
|
58
|
*
|
59
|
*/
|
60
|
public class NonViralNameParserImplTest {
|
61
|
private static final NomenclaturalCode ICNAFP = NomenclaturalCode.ICNAFP;
|
62
|
private static final NomenclaturalCode ICZN = NomenclaturalCode.ICZN;
|
63
|
|
64
|
private static final Logger logger = Logger.getLogger(NonViralNameParserImplTest.class);
|
65
|
|
66
|
final private String strNameFamily = "Asteraceae";
|
67
|
final private String strNameGenus = "Abies Mueller";
|
68
|
final private String strNameGenusUnicode = "Abies M\u00FCller";
|
69
|
final private String strNameAbies1 = "Abies alba";
|
70
|
final private String strNameAbiesSub1 = "Abies alba subsp. beta";
|
71
|
final private String strNameAbiesAuthor1 = "Abies alba Mueller";
|
72
|
final private String strNameAbiesAuthor1Unicode = "Abies alba M\u00FCller";
|
73
|
final private String strNameAbiesBasionymAuthor1 = "Abies alba (Ciardelli) D'Mueller";
|
74
|
final private String strNameAbiesBasionymAuthor1Unicode = "Abies alba (Ciardelli) D'M\u00FCller";
|
75
|
final private String strNameAbiesBasionymExAuthor1 ="Abies alba (Ciardelli ex Doering) D'Mueller ex. de Greuther";
|
76
|
final private String strNameAbiesBasionymExAuthor1Unicode ="Abies alba (Ciardelli ex D\u00F6ring) D'M\u00FCller ex. de Greuther";
|
77
|
final private String strNameTeam1 = "Abies alba Mueller & L.";
|
78
|
final private String strNameZoo1 = "Abies alba Mueller & L., 1822";
|
79
|
final private String strNameZoo2 = "Abies alba (Mueller, 1822) Ciardelli, 2002";
|
80
|
final private String strNameZoo3 = "Marmota marmota normalis Ciardelli, 2002";
|
81
|
final private String strNameZoo4 = "Marmota marmota subsp. normalis Ciardelli, 2002";
|
82
|
final private String strNameZoo5 = "Marmota marmota var. normalis Ciardelli, 2002";
|
83
|
|
84
|
final private String strNameEmpty = "";
|
85
|
final private String strNameNull = null;
|
86
|
|
87
|
private NonViralNameParserImpl parser ;
|
88
|
private NomenclaturalCode botanicCode;
|
89
|
|
90
|
/**
|
91
|
* @throws java.lang.Exception
|
92
|
*/
|
93
|
@BeforeClass
|
94
|
public static void setUpBeforeClass() throws Exception {
|
95
|
DefaultTermInitializer termInitializer = new DefaultTermInitializer();
|
96
|
termInitializer.initialize();
|
97
|
}
|
98
|
|
99
|
|
100
|
/**
|
101
|
* @throws java.lang.Exception
|
102
|
*/
|
103
|
@Before
|
104
|
public void setUp() throws Exception {
|
105
|
parser = NonViralNameParserImpl.NewInstance();
|
106
|
botanicCode = ICNAFP;
|
107
|
}
|
108
|
|
109
|
|
110
|
/*************** TEST *********************************************/
|
111
|
|
112
|
/**
|
113
|
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#NEW_INSTANCE()}.
|
114
|
*/
|
115
|
@Test
|
116
|
public final void testNewInstance() {
|
117
|
assertNotNull(parser);
|
118
|
}
|
119
|
|
120
|
/**
|
121
|
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#TaxonNameParserBotanicalNameImpl()}.
|
122
|
*/
|
123
|
@Test
|
124
|
public final void testTaxonNameParserBotanicalNameImpl() {
|
125
|
logger.warn("Not yet implemented"); // TODO
|
126
|
}
|
127
|
|
128
|
@Test
|
129
|
public final void testTeamSeperation(){
|
130
|
Rank speciesRank = Rank.SPECIES();
|
131
|
NonViralName<?> name;
|
132
|
|
133
|
// String strNameWith1AUthorAndCommaSepEditon = "Abies alba Mill., Sp. Pl., ed. 3: 455. 1987";
|
134
|
// name = parser.parseReferencedName(strNameWith1AUthorAndCommaSepEditon, botanicCode, speciesRank);
|
135
|
// Assert.assertFalse("No problems should exist", name.hasProblem());
|
136
|
// Assert.assertEquals("Name should not include reference part", "Abies alba Mill.", name.getTitleCache());
|
137
|
// Assert.assertEquals("Mill., Sp. Pl., ed. 3. 1987", name.getNomenclaturalReference().getTitleCache());
|
138
|
//
|
139
|
//
|
140
|
// String strNameWith2Authors = "Abies alba L. & Mill., Sp. Pl., ed. 3: 455. 1987";
|
141
|
// name = parser.parseReferencedName(strNameWith2Authors, botanicCode, speciesRank);
|
142
|
// Assert.assertFalse("No problems should exist", name.hasProblem());
|
143
|
// Assert.assertEquals("Name should not include reference part", "Abies alba L. & Mill.", name.getTitleCache());
|
144
|
// Assert.assertEquals("Name should have authorteam with 2 authors", 2, ((Team)name.getCombinationAuthorship()).getTeamMembers().size());
|
145
|
// Assert.assertEquals("L. & Mill., Sp. Pl., ed. 3. 1987", name.getNomenclaturalReference().getTitleCache());
|
146
|
|
147
|
String strNameWith3Authors = "Abies alba Mess., L. & Mill., Sp. Pl., ed. 3: 455. 1987";
|
148
|
name = parser.parseReferencedName(strNameWith3Authors, botanicCode, speciesRank);
|
149
|
Assert.assertFalse("No problems should exist", name.hasProblem());
|
150
|
Assert.assertEquals("Name should not include reference part", "Abies alba Mess., L. & Mill.", name.getTitleCache());
|
151
|
Assert.assertEquals("Name should have authorship with 2 authors", 3, ((Team)name.getCombinationAuthorship()).getTeamMembers().size());
|
152
|
Assert.assertEquals("Mess., L. & Mill., Sp. Pl., ed. 3. 1987", name.getNomenclaturalReference().getTitleCache());
|
153
|
|
154
|
}
|
155
|
|
156
|
/**
|
157
|
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseSimpleName(java.lang.String, eu.etaxonomy.cdm.model.name.Rank)}.
|
158
|
*/
|
159
|
@Test
|
160
|
public final void testParseSimpleName() {
|
161
|
|
162
|
//Uninomials
|
163
|
ZoologicalName milichiidae = (ZoologicalName)parser.parseSimpleName("Milichiidae", NomenclaturalCode.ICZN, null);
|
164
|
assertEquals("Family rank expected", Rank.FAMILY(), milichiidae.getRank());
|
165
|
BotanicalName crepidinae = (BotanicalName)parser.parseSimpleName("Crepidinae", ICNAFP, null);
|
166
|
assertEquals("Family rank expected", Rank.SUBTRIBE(), crepidinae.getRank());
|
167
|
BotanicalName abies = (BotanicalName)parser.parseSimpleName("Abies", ICNAFP, null);
|
168
|
assertEquals("Family rank expected", Rank.GENUS(), abies.getRank());
|
169
|
|
170
|
abies.addParsingProblem(ParserProblem.CheckRank);
|
171
|
parser.parseSimpleName(abies, "Abies", abies.getRank(), true);
|
172
|
assertTrue(abies.getParsingProblems().contains(ParserProblem.CheckRank));
|
173
|
|
174
|
BotanicalName rosa = (BotanicalName)parser.parseSimpleName("Rosaceae", ICNAFP, null);
|
175
|
assertTrue("Rosaceae have rank family", rosa.getRank().equals(Rank.FAMILY()));
|
176
|
assertTrue("Rosaceae must have a rank warning", rosa.hasProblem(ParserProblem.CheckRank));
|
177
|
parser.parseSimpleName(rosa, "Rosaceaex", abies.getRank(), true);
|
178
|
assertEquals("Rosaceaex have rank genus", Rank.GENUS(), rosa.getRank());
|
179
|
assertTrue("Rosaceaex must have a rank warning", rosa.hasProblem(ParserProblem.CheckRank));
|
180
|
|
181
|
//repeat but remove warning after first parse
|
182
|
rosa = (BotanicalName)parser.parseSimpleName("Rosaceae", ICNAFP, null);
|
183
|
assertTrue("Rosaceae have rank family", rosa.getRank().equals(Rank.FAMILY()));
|
184
|
assertTrue("Rosaceae must have a rank warning", rosa.hasProblem(ParserProblem.CheckRank));
|
185
|
rosa.removeParsingProblem(ParserProblem.CheckRank);
|
186
|
parser.parseSimpleName(rosa, "Rosaceaex", rosa.getRank(), true);
|
187
|
assertEquals("Rosaceaex have rank family", Rank.FAMILY(), rosa.getRank());
|
188
|
assertFalse("Rosaceaex must have no rank warning", rosa.hasProblem(ParserProblem.CheckRank));
|
189
|
|
190
|
}
|
191
|
|
192
|
/**
|
193
|
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseSubGenericFullName(java.lang.String)}.
|
194
|
*/
|
195
|
@Test
|
196
|
public final void testParseSubGenericFullName() {
|
197
|
String zooSpeciesWithSubgenus = "Bacanius (Mullerister) rombophorus (Aube, 1843)";
|
198
|
//zoo as fullName
|
199
|
ZoologicalName zooName = (ZoologicalName)parser.parseReferencedName(zooSpeciesWithSubgenus, NomenclaturalCode.ICZN, Rank.SPECIES());
|
200
|
Assert.assertTrue(zooName.getParsingProblems().isEmpty());
|
201
|
Assert.assertEquals("Mullerister", zooName.getInfraGenericEpithet());
|
202
|
Assert.assertEquals(Integer.valueOf(1843), zooName.getOriginalPublicationYear());
|
203
|
//zoo as referenced name
|
204
|
zooName = (ZoologicalName)parser.parseFullName(zooSpeciesWithSubgenus, NomenclaturalCode.ICZN, Rank.SPECIES());
|
205
|
Assert.assertTrue(zooName.getParsingProblems().isEmpty());
|
206
|
Assert.assertEquals("Mullerister", zooName.getInfraGenericEpithet());
|
207
|
Assert.assertEquals(Integer.valueOf(1843), zooName.getOriginalPublicationYear());
|
208
|
|
209
|
//bot as full Name
|
210
|
String botSpeciesWithSubgenus = "Bacanius (Mullerister) rombophorus (Aube) Mill.";
|
211
|
BotanicalName botName = (BotanicalName)parser.parseFullName(botSpeciesWithSubgenus, NomenclaturalCode.ICNAFP, Rank.GENUS());
|
212
|
Assert.assertTrue(botName.getParsingProblems().isEmpty());
|
213
|
Assert.assertEquals("Mullerister", botName.getInfraGenericEpithet());
|
214
|
Assert.assertEquals("rombophorus", botName.getSpecificEpithet());
|
215
|
Assert.assertEquals("Aube", botName.getBasionymAuthorship().getTitleCache());
|
216
|
|
217
|
//bot as referenced Name
|
218
|
botName = (BotanicalName)parser.parseReferencedName(botSpeciesWithSubgenus, NomenclaturalCode.ICNAFP, Rank.GENUS());
|
219
|
Assert.assertTrue(botName.getParsingProblems().isEmpty());
|
220
|
Assert.assertEquals("Mullerister", botName.getInfraGenericEpithet());
|
221
|
Assert.assertEquals("rombophorus", botName.getSpecificEpithet());
|
222
|
Assert.assertEquals("Aube", botName.getBasionymAuthorship().getTitleCache());
|
223
|
|
224
|
//bot without author
|
225
|
String botSpeciesWithSubgenusWithoutAuthor = "Bacanius (Mullerister) rombophorus";
|
226
|
botName = (BotanicalName)parser.parseReferencedName(botSpeciesWithSubgenusWithoutAuthor, NomenclaturalCode.ICNAFP, Rank.GENUS());
|
227
|
Assert.assertTrue(botName.getParsingProblems().isEmpty());
|
228
|
Assert.assertEquals("Mullerister", botName.getInfraGenericEpithet());
|
229
|
Assert.assertEquals("rombophorus", botName.getSpecificEpithet());
|
230
|
Assert.assertEquals("", botName.getAuthorshipCache());
|
231
|
}
|
232
|
|
233
|
/**
|
234
|
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseSubGenericSimpleName(java.lang.String)}.
|
235
|
*/
|
236
|
@Test
|
237
|
public final void testParseSubGenericSimpleName() {
|
238
|
logger.warn("Not yet implemented"); // TODO
|
239
|
}
|
240
|
|
241
|
/**
|
242
|
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseFullName(java.lang.String, eu.etaxonomy.cdm.model.name.Rank)}.
|
243
|
*/
|
244
|
@Test
|
245
|
public final void testParseFullNameUnicode() {
|
246
|
|
247
|
NonViralName<?> nameAuthor = parser.parseFullName(strNameAbiesAuthor1Unicode, null, Rank.SPECIES());
|
248
|
assertEquals("Abies", nameAuthor.getGenusOrUninomial());
|
249
|
assertEquals("alba", nameAuthor.getSpecificEpithet());
|
250
|
assertEquals("M\u00FCller", nameAuthor.getCombinationAuthorship().getNomenclaturalTitle());
|
251
|
|
252
|
NonViralName<?> nameBasionymAuthor = parser.parseFullName(strNameAbiesBasionymAuthor1Unicode, null, Rank.SPECIES());
|
253
|
assertEquals("Abies", nameBasionymAuthor.getGenusOrUninomial());
|
254
|
assertEquals("alba", nameBasionymAuthor.getSpecificEpithet());
|
255
|
assertEquals("D'M\u00FCller", nameBasionymAuthor.getCombinationAuthorship().getNomenclaturalTitle());
|
256
|
INomenclaturalAuthor basionymTeam = nameBasionymAuthor.getBasionymAuthorship();
|
257
|
assertEquals("Ciardelli", basionymTeam.getNomenclaturalTitle());
|
258
|
|
259
|
NonViralName<?> nameBasionymExAuthor = parser.parseFullName(strNameAbiesBasionymExAuthor1Unicode, null, Rank.SPECIES());
|
260
|
assertEquals("Abies", nameBasionymExAuthor.getGenusOrUninomial());
|
261
|
assertEquals("alba", nameBasionymExAuthor.getSpecificEpithet());
|
262
|
assertEquals("D'M\u00FCller", nameBasionymExAuthor.getExCombinationAuthorship().getNomenclaturalTitle());
|
263
|
assertEquals("de Greuther", nameBasionymExAuthor.getCombinationAuthorship().getNomenclaturalTitle());
|
264
|
INomenclaturalAuthor basionymTeam2 = nameBasionymExAuthor.getExBasionymAuthorship();
|
265
|
assertEquals("Ciardelli", basionymTeam2.getNomenclaturalTitle());
|
266
|
INomenclaturalAuthor exBasionymTeam2 = nameBasionymExAuthor.getBasionymAuthorship();
|
267
|
assertEquals("D\u00F6ring", exBasionymTeam2.getNomenclaturalTitle());
|
268
|
|
269
|
BotanicalName nameBasionymExAuthor2 = (BotanicalName)parser.parseFullName("Washingtonia filifera (Linden ex Andre) H.Wendl. ex de Bary", null, Rank.SPECIES());
|
270
|
assertEquals("Washingtonia", nameBasionymExAuthor2.getGenusOrUninomial());
|
271
|
assertEquals("filifera", nameBasionymExAuthor2.getSpecificEpithet());
|
272
|
assertEquals("H.Wendl.", nameBasionymExAuthor2.getExCombinationAuthorship().getNomenclaturalTitle());
|
273
|
assertEquals("de Bary", nameBasionymExAuthor2.getCombinationAuthorship().getNomenclaturalTitle());
|
274
|
INomenclaturalAuthor basionymTeam3 = nameBasionymExAuthor2.getBasionymAuthorship();
|
275
|
assertEquals("Andre", basionymTeam3.getNomenclaturalTitle());
|
276
|
INomenclaturalAuthor exBasionymTeam3 = nameBasionymExAuthor2.getExBasionymAuthorship();
|
277
|
assertEquals("Linden", exBasionymTeam3.getNomenclaturalTitle());
|
278
|
String title = nameBasionymExAuthor2.getTitleCache();
|
279
|
assertEquals("Washingtonia filifera (Linden ex Andre) H.Wendl. ex de Bary", title);
|
280
|
|
281
|
}
|
282
|
|
283
|
|
284
|
/**
|
285
|
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseFullName(java.lang.String, eu.etaxonomy.cdm.model.name.Rank)}.
|
286
|
*/
|
287
|
@Test
|
288
|
public final void testParseFullName() {
|
289
|
try {
|
290
|
Method parseMethod = parser.getClass().getDeclaredMethod("parseFullName", String.class, NomenclaturalCode.class, Rank.class);
|
291
|
testName_StringNomcodeRank(parseMethod);
|
292
|
} catch (Exception e) {
|
293
|
e.printStackTrace();
|
294
|
assertTrue(false);
|
295
|
}
|
296
|
|
297
|
//Team
|
298
|
NonViralName<?> nameTeam1 = parser.parseFullName(strNameTeam1);
|
299
|
assertEquals( "Abies", nameTeam1.getGenusOrUninomial());
|
300
|
assertEquals( "alba", nameTeam1.getSpecificEpithet());
|
301
|
assertEquals("Mueller & L.", nameTeam1.getCombinationAuthorship().getNomenclaturalTitle());
|
302
|
assertTrue(nameTeam1.getCombinationAuthorship() instanceof Team);
|
303
|
Team team = (Team)nameTeam1.getCombinationAuthorship();
|
304
|
assertEquals("Mueller", team.getTeamMembers().get(0).getNomenclaturalTitle());
|
305
|
assertEquals("L.", team.getTeamMembers().get(1).getNomenclaturalTitle());
|
306
|
|
307
|
//ZooName
|
308
|
ZoologicalName nameZoo1 = (ZoologicalName)parser.parseFullName(strNameZoo1);
|
309
|
assertEquals( "Abies", nameZoo1.getGenusOrUninomial());
|
310
|
assertEquals( "alba", nameZoo1.getSpecificEpithet());
|
311
|
assertEquals("Mueller & L.", nameZoo1.getCombinationAuthorship().getNomenclaturalTitle());
|
312
|
assertEquals(NomenclaturalCode.ICZN, nameZoo1.getNomenclaturalCode() );
|
313
|
assertEquals(Integer.valueOf(1822), nameZoo1.getPublicationYear());
|
314
|
assertTrue(nameZoo1.getCombinationAuthorship() instanceof Team);
|
315
|
Team teamZoo = (Team)nameZoo1.getCombinationAuthorship();
|
316
|
assertEquals("Mueller", teamZoo.getTeamMembers().get(0).getNomenclaturalTitle());
|
317
|
assertEquals("L.", teamZoo.getTeamMembers().get(1).getNomenclaturalTitle());
|
318
|
|
319
|
ZoologicalName nameZoo2 = (ZoologicalName)parser.parseFullName(strNameZoo2);
|
320
|
assertEquals(Integer.valueOf(2002), nameZoo2.getPublicationYear());
|
321
|
assertEquals(Integer.valueOf(1822), nameZoo2.getOriginalPublicationYear());
|
322
|
assertEquals("Mueller", nameZoo2.getBasionymAuthorship().getNomenclaturalTitle());
|
323
|
assertEquals("Ciardelli", nameZoo2.getCombinationAuthorship().getNomenclaturalTitle());
|
324
|
|
325
|
//subsp
|
326
|
ZoologicalName nameZoo3 = (ZoologicalName)parser.parseFullName(strNameZoo3);
|
327
|
assertEquals("Ciardelli", nameZoo3.getCombinationAuthorship().getNomenclaturalTitle());
|
328
|
assertFalse("Subsp. without marker should be parsable", nameZoo3.hasProblem());
|
329
|
assertEquals("Variety should be recognized", Rank.SUBSPECIES(), nameZoo3.getRank());
|
330
|
|
331
|
ZoologicalName nameZoo4 = (ZoologicalName)parser.parseFullName(strNameZoo4);
|
332
|
assertEquals("Ciardelli", nameZoo4.getCombinationAuthorship().getNomenclaturalTitle());
|
333
|
assertFalse("Subsp. without marker should be parsable", nameZoo4.hasProblem());
|
334
|
assertEquals("Variety should be recognized", Rank.SUBSPECIES(), nameZoo4.getRank());
|
335
|
|
336
|
ZoologicalName nameZoo5 = (ZoologicalName)parser.parseFullName(strNameZoo5);
|
337
|
assertEquals("Ciardelli", nameZoo5.getCombinationAuthorship().getNomenclaturalTitle());
|
338
|
assertFalse("Subsp. without marker should be parsable", nameZoo5.hasProblem());
|
339
|
assertEquals("Variety should be recognized", Rank.VARIETY(), nameZoo5.getRank());
|
340
|
|
341
|
|
342
|
//Autonym
|
343
|
BotanicalName autonymName = (BotanicalName)parser.parseFullName("Abies alba Mill. var. alba", ICNAFP, null);
|
344
|
assertFalse("Autonym should be parsable", autonymName.hasProblem());
|
345
|
|
346
|
|
347
|
//empty
|
348
|
NonViralName<?> nameEmpty = parser.parseFullName(strNameEmpty);
|
349
|
assertNotNull(nameEmpty);
|
350
|
assertEquals("", nameEmpty.getTitleCache());
|
351
|
|
352
|
//null
|
353
|
NonViralName<?> nameNull = parser.parseFullName(strNameNull);
|
354
|
assertNull(nameNull);
|
355
|
|
356
|
//some authors
|
357
|
String fullNameString = "Abies alba (Greuther & L'Hiver & al. ex M\u00FCller & Schmidt)Clark ex Ciardelli";
|
358
|
NonViralName<?> authorname = parser.parseFullName(fullNameString);
|
359
|
assertFalse(authorname.hasProblem());
|
360
|
assertEquals("Basionym author should have 3 authors", 2, ((Team)authorname.getExBasionymAuthorship()).getTeamMembers().size());
|
361
|
Assert.assertTrue("ExbasionymAuthorship must have more members'", ((Team)authorname.getExBasionymAuthorship()).isHasMoreMembers());
|
362
|
|
363
|
//author with 2 capitals
|
364
|
fullNameString = "Campanula rhodensis A. DC.";
|
365
|
NonViralName<?> name = parser.parseFullName(fullNameString);
|
366
|
assertFalse(name.hasProblem());
|
367
|
|
368
|
//author with no space #5618
|
369
|
fullNameString = "Gordonia moaensis (Vict.)H. Keng";
|
370
|
name = parser.parseFullName(fullNameString);
|
371
|
assertFalse(name.hasProblem());
|
372
|
assertNotNull(name.getCombinationAuthorship());
|
373
|
assertEquals("H. Keng", name.getCombinationAuthorship().getNomenclaturalTitle());
|
374
|
|
375
|
//name without combination author , only to check if above fix for #5618 works correctly
|
376
|
fullNameString = "Gordonia moaensis (Vict.)";
|
377
|
name = parser.parseFullName(fullNameString);
|
378
|
assertFalse(name.hasProblem());
|
379
|
assertNull(name.getCombinationAuthorship());
|
380
|
assertNotNull(name.getBasionymAuthorship());
|
381
|
assertEquals("Vict.", name.getBasionymAuthorship().getNomenclaturalTitle());
|
382
|
|
383
|
}
|
384
|
|
385
|
@Test
|
386
|
public final void testEtAl() throws StringNotParsableException {
|
387
|
//some authors
|
388
|
String fullNameString = "Abies alba Greuther, Hiver & al.";
|
389
|
NonViralName<?> authorname = parser.parseFullName(fullNameString);
|
390
|
assertFalse(authorname.hasProblem());
|
391
|
assertEquals("Basionym author should have 2 authors", 2, ((Team)authorname.getCombinationAuthorship()).getTeamMembers().size());
|
392
|
assertTrue("Basionym author team should have more authors", ((Team)authorname.getCombinationAuthorship()).isHasMoreMembers() );
|
393
|
|
394
|
//et al.
|
395
|
NonViralName<?> nvn = ZoologicalName.NewInstance(null);
|
396
|
parser.parseAuthors(nvn, "Eckweiler, Hand et al., 2003");
|
397
|
Team team = (Team)nvn.getCombinationAuthorship();
|
398
|
Assert.assertNotNull("Comb. author must not be null", team);
|
399
|
Assert.assertEquals("Must be team with 2 members", 2, team.getTeamMembers().size());
|
400
|
Assert.assertEquals("Second member must be 'Hand'", "Hand", team.getTeamMembers().get(1).getTitleCache());
|
401
|
Assert.assertTrue("Team must have more members'", team.isHasMoreMembers());
|
402
|
}
|
403
|
|
404
|
@Test
|
405
|
public final void testMultipleAuthors() {
|
406
|
//multiple authors for inReference
|
407
|
String fullTitleString = "Abies alba L. in Mill., Gregor & Behr., Sp. Pl. 173: 384. 1982.";
|
408
|
NonViralName<?> multipleAuthorRefName = parser.parseReferencedName(fullTitleString, NomenclaturalCode.ICNAFP, Rank.SPECIES());
|
409
|
assertFalse(multipleAuthorRefName.hasProblem());
|
410
|
assertTrue("Combination author should be a person", multipleAuthorRefName.getCombinationAuthorship() instanceof Person);
|
411
|
assertEquals("Combination author should be L.", "L.", ((Person)multipleAuthorRefName.getCombinationAuthorship()).getNomenclaturalTitle());
|
412
|
IReference nomRef = multipleAuthorRefName.getNomenclaturalReference();
|
413
|
Assert.assertNotNull("nomRef must have inRef", ((Reference)nomRef).getInReference());
|
414
|
Reference inRef = ((Reference)nomRef).getInReference();
|
415
|
String title = inRef.getTitle();
|
416
|
assertEquals("InRef title should be Sp. Pl.", "Sp. Pl.", title);
|
417
|
assertTrue(inRef.getAuthorship() instanceof Team);
|
418
|
Team team = (Team)inRef.getAuthorship();
|
419
|
assertEquals(3, team.getTeamMembers().size());
|
420
|
|
421
|
// multiple authors in Name
|
422
|
fullTitleString = "Abies alba Mill., Aber & Schwedt";
|
423
|
NonViralName<?> multipleAuthorName = parser.parseReferencedName(fullTitleString, NomenclaturalCode.ICNAFP, Rank.SPECIES());
|
424
|
assertFalse(multipleAuthorName.hasProblem());
|
425
|
assertTrue("Combination author should be a team", multipleAuthorName.getCombinationAuthorship() instanceof Team);
|
426
|
team = (Team)multipleAuthorName.getCombinationAuthorship();
|
427
|
assertEquals(3, team.getTeamMembers().size());
|
428
|
assertEquals("Second team member should be Aber", "Aber", team.getTeamMembers().get(1).getTitleCache());
|
429
|
|
430
|
// multiple authors in Name with reference
|
431
|
fullTitleString = "Abies alba Mill., Aber & Schwedt in L., Sp. Pl. 173: 384. 1982.";
|
432
|
multipleAuthorName = parser.parseReferencedName(fullTitleString, NomenclaturalCode.ICNAFP, Rank.SPECIES());
|
433
|
assertFalse(multipleAuthorName.hasProblem());
|
434
|
assertTrue("Combination author should be a team", multipleAuthorName.getCombinationAuthorship() instanceof Team);
|
435
|
team = (Team)multipleAuthorName.getCombinationAuthorship();
|
436
|
assertEquals(3, team.getTeamMembers().size());
|
437
|
assertEquals("Second team member should be Aber", "Aber", team.getTeamMembers().get(1).getTitleCache());
|
438
|
nomRef = multipleAuthorName.getNomenclaturalReference();
|
439
|
Assert.assertNotNull("nomRef must have inRef", ((Reference)nomRef).getInReference());
|
440
|
inRef = ((Reference)nomRef).getInReference();
|
441
|
title = inRef.getTitle();
|
442
|
assertEquals("InRef title should be Sp. Pl.", "Sp. Pl.", title);
|
443
|
assertTrue(inRef.getAuthorship() instanceof Person);
|
444
|
Person person = (Person)inRef.getAuthorship();
|
445
|
assertEquals("Book author should be L.", "L.", person.getNomenclaturalTitle());
|
446
|
|
447
|
|
448
|
fullTitleString = "Abies alba Mill., Aber & Schwedt, Sp. Pl. 173: 384. 1982.";
|
449
|
multipleAuthorName = parser.parseReferencedName(fullTitleString, NomenclaturalCode.ICNAFP, Rank.SPECIES());
|
450
|
assertFalse(multipleAuthorName.hasProblem());
|
451
|
assertTrue("Combination author should be a team", multipleAuthorName.getCombinationAuthorship() instanceof Team);
|
452
|
team = (Team)multipleAuthorName.getCombinationAuthorship();
|
453
|
assertEquals(3, team.getTeamMembers().size());
|
454
|
assertEquals("Second team member should be Aber", "Aber", team.getTeamMembers().get(1).getTitleCache());
|
455
|
nomRef = multipleAuthorName.getNomenclaturalReference();
|
456
|
Assert.assertNull("nomRef must not have inRef as it is a book itself", ((Reference)nomRef).getInReference());
|
457
|
title = nomRef.getTitle();
|
458
|
assertEquals("InRef title should be Sp. Pl.", "Sp. Pl.", title);
|
459
|
assertTrue(nomRef.getAuthorship() instanceof Team);
|
460
|
team = (Team)nomRef.getAuthorship();
|
461
|
assertEquals(3, team.getTeamMembers().size());
|
462
|
assertEquals("Second team member should be Schwedt", "Schwedt", team.getTeamMembers().get(2).getTitleCache());
|
463
|
|
464
|
//et al.
|
465
|
NonViralName<?> nvn = ZoologicalName.NewInstance(null);
|
466
|
parser.parseReferencedName (nvn, "Marmota marmota Eckweiler, Hand et al., 2003", Rank.SPECIES(),true);
|
467
|
assertTrue("Combination author should be a team", nvn.getCombinationAuthorship() instanceof Team);
|
468
|
team = (Team)nvn.getCombinationAuthorship();
|
469
|
Assert.assertNotNull("Comb. author must not be null", team);
|
470
|
Assert.assertEquals("Must be team with 2 members", 2, team.getTeamMembers().size());
|
471
|
Assert.assertEquals("Second member must be 'Hand'", "Hand", team.getTeamMembers().get(1).getTitleCache());
|
472
|
Assert.assertTrue("Team must have more members'", team.isHasMoreMembers());
|
473
|
|
474
|
}
|
475
|
|
476
|
/**
|
477
|
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseFullName(java.lang.String, eu.etaxonomy.cdm.model.name.Rank)}.
|
478
|
*/
|
479
|
@Test
|
480
|
public final void testHybrids() {
|
481
|
NonViralName<?> name1;
|
482
|
|
483
|
|
484
|
//Infrageneric hybrid
|
485
|
name1 = parser.parseFullName("Aegilops nothosubg. Insulae Scholz", botanicCode, null);
|
486
|
assertTrue("Name must have binom hybrid bit set", name1.isBinomHybrid());
|
487
|
assertFalse("Name must not have monom hybrid bit set", name1.isMonomHybrid());
|
488
|
assertFalse("Name must not have trinom hybrid bit set", name1.isTrinomHybrid());
|
489
|
assertEquals("Infrageneric epithet must be 'Insulae'", "Insulae", name1.getInfraGenericEpithet());
|
490
|
|
491
|
//Species hybrid
|
492
|
// NonViralName nameTeam1 = parser.parseFullName("Aegilops \u00D7insulae-cypri H. Scholz");
|
493
|
name1 = parser.parseFullName("Aegilops \u00D7insulae Scholz", botanicCode, null);
|
494
|
assertTrue("Name must have binom hybrid bit set", name1.isBinomHybrid());
|
495
|
assertFalse("Name must not have monom hybrid bit set", name1.isMonomHybrid());
|
496
|
assertFalse("Name must not have trinom hybrid bit set", name1.isTrinomHybrid());
|
497
|
assertEquals("Species epithet must be 'insulae'", "insulae", name1.getSpecificEpithet());
|
498
|
|
499
|
//Uninomial hybrid
|
500
|
name1 = parser.parseFullName("x Aegilops Scholz", botanicCode, null);
|
501
|
assertTrue("Name must have monom hybrid bit set", name1.isMonomHybrid());
|
502
|
assertFalse("Name must not have binom hybrid bit set", name1.isBinomHybrid());
|
503
|
assertFalse("Name must not have trinom hybrid bit set", name1.isTrinomHybrid());
|
504
|
assertEquals("Uninomial must be 'Aegilops'", "Aegilops", name1.getGenusOrUninomial());
|
505
|
|
506
|
//Subspecies hybrid with hybrid sign
|
507
|
//maybe false: see http://dev.e-taxonomy.eu/trac/ticket/3868
|
508
|
name1 = parser.parseFullName("Aegilops insulae subsp. X abies Scholz", botanicCode, null);
|
509
|
assertFalse("Name must not have monom hybrid bit set", name1.isMonomHybrid());
|
510
|
assertFalse("Name must not have binom hybrid bit set", name1.isBinomHybrid());
|
511
|
assertTrue("Name must have trinom hybrid bit set", name1.isTrinomHybrid());
|
512
|
assertEquals("Infraspecific epithet must be 'abies'", "abies", name1.getInfraSpecificEpithet());
|
513
|
|
514
|
//Subspecies hybrid with notho / n
|
515
|
name1 = parser.parseFullName("Aegilops insulae nothosubsp. abies Scholz", botanicCode, null);
|
516
|
assertFalse("Name must not have monom hybrid bit set", name1.isMonomHybrid());
|
517
|
assertFalse("Name must not have binom hybrid bit set", name1.isBinomHybrid());
|
518
|
assertFalse("Name must not be protected", name1.isProtectedTitleCache());
|
519
|
assertTrue("Name must have trinom hybrid bit set", name1.isTrinomHybrid());
|
520
|
assertEquals("Infraspecific epithet must be 'abies'", "abies", name1.getInfraSpecificEpithet());
|
521
|
name1 = parser.parseFullName("Aegilops insulae nsubsp. abies Scholz", botanicCode, null);
|
522
|
assertFalse("Name must not have monom hybrid bit set", name1.isMonomHybrid());
|
523
|
assertFalse("Name must not have binom hybrid bit set", name1.isBinomHybrid());
|
524
|
assertFalse("Name must not be protected", name1.isProtectedTitleCache());
|
525
|
assertTrue("Name must have trinom hybrid bit set", name1.isTrinomHybrid());
|
526
|
assertEquals("Infraspecific epithet must be 'abies'", "abies", name1.getInfraSpecificEpithet());
|
527
|
|
528
|
}
|
529
|
|
530
|
/**
|
531
|
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseFullName(java.lang.String, eu.etaxonomy.cdm.model.name.Rank)}.
|
532
|
*/
|
533
|
@Test
|
534
|
public final void testUnrankedNames() {
|
535
|
try {
|
536
|
Method parseMethod = parser.getClass().getDeclaredMethod("parseFullName", String.class, NomenclaturalCode.class, Rank.class);
|
537
|
testName_StringNomcodeRank(parseMethod);
|
538
|
} catch (Exception e) {
|
539
|
e.printStackTrace();
|
540
|
assertTrue(false);
|
541
|
}
|
542
|
|
543
|
//unranked infraspecific
|
544
|
String infraspecificUnranked = "Genus species [unranked] infraspecific";
|
545
|
NonViralName<?> name = parser.parseFullName(infraspecificUnranked);
|
546
|
assertEquals( "Genus", name.getGenusOrUninomial());
|
547
|
assertEquals( "species", name.getSpecificEpithet());
|
548
|
assertEquals( "infraspecific", name.getInfraSpecificEpithet());
|
549
|
assertEquals( "Unranked rank should be parsed", Rank.INFRASPECIFICTAXON(), name.getRank());
|
550
|
|
551
|
//unranked infrageneric
|
552
|
String infraGenericUnranked = "Genus [unranked] Infragen";
|
553
|
NonViralName<?> name2 = parser.parseFullName(infraGenericUnranked);
|
554
|
assertEquals( "Genus", name2.getGenusOrUninomial());
|
555
|
assertEquals( null, name2.getSpecificEpithet());
|
556
|
assertEquals( "Infragen", name2.getInfraGenericEpithet());
|
557
|
assertEquals( "Unranked rank should be parsed", Rank.INFRAGENERICTAXON(), name2.getRank());
|
558
|
|
559
|
}
|
560
|
|
561
|
|
562
|
/**
|
563
|
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseFullName(java.lang.String, eu.etaxonomy.cdm.model.name.Rank)}.
|
564
|
*/
|
565
|
@Test
|
566
|
public final void testHybridFormulars() {
|
567
|
try {
|
568
|
Method parseMethod = parser.getClass().getDeclaredMethod("parseFullName", String.class, NomenclaturalCode.class, Rank.class);
|
569
|
testName_StringNomcodeRank(parseMethod);
|
570
|
} catch (Exception e) {
|
571
|
e.printStackTrace();
|
572
|
assertTrue(false);
|
573
|
}
|
574
|
|
575
|
//Species hybrid
|
576
|
String hybridCache = "Abies alba "+UTF8.HYBRID+" Pinus bus";
|
577
|
NonViralName<?> name1 = parser.parseFullName(hybridCache, botanicCode, null);
|
578
|
assertTrue("Name must have hybrid formula bit set", name1.isHybridFormula());
|
579
|
assertEquals("Name must have 2 hybrid parents", 2, name1.getHybridChildRelations().size());
|
580
|
assertEquals("Title cache must be correct", hybridCache, name1.getTitleCache());
|
581
|
List<HybridRelationship> orderedRels = name1.getOrderedChildRelationships();
|
582
|
assertEquals("Name must have 2 hybrid parents in ordered list", 2, orderedRels.size());
|
583
|
NonViralName<?> firstParent = orderedRels.get(0).getParentName();
|
584
|
assertEquals("Name must have Abies alba as first hybrid parent", "Abies alba", firstParent.getTitleCache());
|
585
|
NonViralName<?> secondParent = orderedRels.get(1).getParentName();
|
586
|
assertEquals("Name must have Pinus bus as second hybrid parent", "Pinus bus", secondParent.getTitleCache());
|
587
|
assertEquals("Hybrid name must have the lowest rank ('species') as rank", Rank.SPECIES(), name1.getRank());
|
588
|
assertNull("Name must not have a genus eptithet", name1.getGenusOrUninomial());
|
589
|
assertNull("Name must not have a specific eptithet", name1.getSpecificEpithet());
|
590
|
assertFalse("Name must not have parsing problems", name1.hasProblem());
|
591
|
|
592
|
name1 = parser.parseReferencedName(hybridCache, botanicCode, null);
|
593
|
assertFalse("Name must not have parsing problems", name1.hasProblem());
|
594
|
|
595
|
//x-sign
|
596
|
hybridCache = "Abies alba x Pinus bus";
|
597
|
name1 = parser.parseFullName(hybridCache, botanicCode, null);
|
598
|
assertFalse("Name must be parsable", name1.hasProblem());
|
599
|
assertTrue("Name must have hybrid formula bit set", name1.isHybridFormula());
|
600
|
assertFalse("Name must not have parsing problems", name1.hasProblem());
|
601
|
|
602
|
|
603
|
//Subspecies first hybrid
|
604
|
name1 = parser.parseFullName("Abies alba subsp. beta "+UTF8.HYBRID+" Pinus bus", botanicCode, null);
|
605
|
assertTrue("Name must have hybrid formula bit set", name1.isHybridFormula());
|
606
|
assertEquals("Name must have 2 hybrid parents", 2, name1.getHybridChildRelations().size());
|
607
|
assertEquals("Title cache must be correct", "Abies alba subsp. beta "+UTF8.HYBRID+" Pinus bus", name1.getTitleCache());
|
608
|
orderedRels = name1.getOrderedChildRelationships();
|
609
|
assertEquals("Name must have 2 hybrid parents in ordered list", 2, orderedRels.size());
|
610
|
firstParent = orderedRels.get(0).getParentName();
|
611
|
assertEquals("Name must have Abies alba subsp. beta as first hybrid parent", "Abies alba subsp. beta", firstParent.getTitleCache());
|
612
|
secondParent = orderedRels.get(1).getParentName();
|
613
|
assertEquals("Name must have Pinus bus as second hybrid parent", "Pinus bus", secondParent.getTitleCache());
|
614
|
assertEquals("Hybrid name must have the lower rank ('subspecies') as rank", Rank.SUBSPECIES(), name1.getRank());
|
615
|
|
616
|
//variety second hybrid
|
617
|
name1 = parser.parseFullName("Abies alba \u00D7 Pinus bus var. beta", botanicCode, null);
|
618
|
assertTrue("Name must have hybrid formula bit set", name1.isHybridFormula());
|
619
|
assertEquals("Name must have 2 hybrid parents", 2, name1.getHybridChildRelations().size());
|
620
|
assertEquals("Title cache must be correct", "Abies alba \u00D7 Pinus bus var. beta", name1.getTitleCache());
|
621
|
assertEquals("Hybrid name must have the lower rank ('variety') as rank", Rank.VARIETY(), name1.getRank());
|
622
|
|
623
|
//hybrids with authors
|
624
|
name1 = parser.parseFullName("Abies alba L. \u00D7 Pinus bus Mill.", botanicCode, null);
|
625
|
assertTrue("Name must have hybrid formula bit set", name1.isHybridFormula());
|
626
|
assertEquals("Name must have 2 hybrid parents", 2, name1.getHybridChildRelations().size());
|
627
|
assertEquals("Title cache must be correct", "Abies alba L. \u00D7 Pinus bus Mill.", name1.getTitleCache());
|
628
|
orderedRels = name1.getOrderedChildRelationships();
|
629
|
assertEquals("Name must have 2 hybrid parents in ordered list", 2, orderedRels.size());
|
630
|
firstParent = orderedRels.get(0).getParentName();
|
631
|
assertEquals("Name must have Abies alba L. as first hybrid parent", "Abies alba L.", firstParent.getTitleCache());
|
632
|
secondParent = orderedRels.get(1).getParentName();
|
633
|
assertEquals("Name must have Pinus bus Mill. as second hybrid parent", "Pinus bus Mill.", secondParent.getTitleCache());
|
634
|
assertEquals("Hybrid name must have the lower rank ('species') as rank", Rank.SPECIES(), name1.getRank());
|
635
|
|
636
|
}
|
637
|
|
638
|
@Test
|
639
|
public final void testHybridsRemoval(){
|
640
|
//if the parser input already has hybridrelationships they need to be removed
|
641
|
//Create input
|
642
|
String hybridCache = "Abies alba "+UTF8.HYBRID+" Pinus bus";
|
643
|
NonViralName<?> name1 = parser.parseFullName(hybridCache, botanicCode, null);
|
644
|
assertFalse("Name must not have parsing problems", name1.hasProblem());
|
645
|
assertTrue("", name1.getHybridChildRelations().size() == 2);
|
646
|
|
647
|
hybridCache = "Abieta albana "+UTF8.HYBRID+" Pinuta custa";
|
648
|
boolean makeEmpty = true;
|
649
|
parser.parseFullName(name1, hybridCache, Rank.SPECIES(), makeEmpty);
|
650
|
assertEquals("After parsing another string there should still be 2 parents, but different ones", 2, name1.getHybridChildRelations().size());
|
651
|
assertFalse("Name must not have parsing problems", name1.hasProblem());
|
652
|
|
653
|
|
654
|
hybridCache = "Calendula arvensis Mill.";
|
655
|
makeEmpty = true;
|
656
|
parser.parseFullName(name1, hybridCache, Rank.SPECIES(), makeEmpty);
|
657
|
assertTrue("", name1.getHybridChildRelations().isEmpty());
|
658
|
assertFalse("Name must not have parsing problems", name1.hasProblem());
|
659
|
|
660
|
|
661
|
//AND the same for reference parsing
|
662
|
hybridCache = "Abies alba "+UTF8.HYBRID+" Pinus bus";
|
663
|
name1 = parser.parseReferencedName(hybridCache, botanicCode, null);
|
664
|
assertFalse("Name must not have parsing problems", name1.hasProblem());
|
665
|
assertTrue("", name1.getHybridChildRelations().size() == 2);
|
666
|
|
667
|
hybridCache = "Abieta albana "+UTF8.HYBRID+" Pinuta custa";
|
668
|
makeEmpty = true;
|
669
|
parser.parseReferencedName(name1, hybridCache, Rank.SPECIES(), makeEmpty);
|
670
|
assertEquals("After parsing another string there should still be 2 parents, but different ones", 2, name1.getHybridChildRelations().size());
|
671
|
assertFalse("Name must not have parsing problems", name1.hasProblem());
|
672
|
|
673
|
|
674
|
hybridCache = "Calendula arvensis Mill.";
|
675
|
makeEmpty = true;
|
676
|
parser.parseReferencedName(name1, hybridCache, Rank.SPECIES(), makeEmpty);
|
677
|
assertTrue("", name1.getHybridChildRelations().isEmpty());
|
678
|
assertFalse("Name must not have parsing problems", name1.hasProblem());
|
679
|
}
|
680
|
|
681
|
private void testName_StringNomcodeRank(Method parseMethod)
|
682
|
throws InvocationTargetException, IllegalAccessException {
|
683
|
NonViralName<?> name1 = (NonViralName<?>)parseMethod.invoke(parser, strNameAbies1, null, Rank.SPECIES());
|
684
|
//parser.parseFullName(strNameAbies1, null, Rank.SPECIES());
|
685
|
assertEquals("Abies", name1.getGenusOrUninomial());
|
686
|
assertEquals("alba", name1.getSpecificEpithet());
|
687
|
|
688
|
NonViralName<?> nameAuthor = (NonViralName<?>)parseMethod.invoke(parser, strNameAbiesAuthor1, null, Rank.SPECIES());
|
689
|
assertEquals("Abies", nameAuthor.getGenusOrUninomial());
|
690
|
assertEquals("alba", nameAuthor.getSpecificEpithet());
|
691
|
assertEquals("Mueller", nameAuthor.getCombinationAuthorship().getNomenclaturalTitle());
|
692
|
|
693
|
NonViralName<?> nameBasionymAuthor = (NonViralName<?>)parseMethod.invoke(parser, strNameAbiesBasionymAuthor1, null, Rank.SPECIES());
|
694
|
assertEquals("Abies", nameBasionymAuthor.getGenusOrUninomial());
|
695
|
assertEquals("alba", nameBasionymAuthor.getSpecificEpithet());
|
696
|
assertEquals("D'Mueller", nameBasionymAuthor.getCombinationAuthorship().getNomenclaturalTitle());
|
697
|
assertEquals("Ciardelli", nameBasionymAuthor.getBasionymAuthorship().getNomenclaturalTitle());
|
698
|
|
699
|
NonViralName<?> nameBasionymExAuthor = (NonViralName<?>)parseMethod.invoke(parser, strNameAbiesBasionymExAuthor1, null, Rank.SPECIES());
|
700
|
assertEquals("Abies", nameBasionymExAuthor.getGenusOrUninomial());
|
701
|
assertEquals("alba", nameBasionymExAuthor.getSpecificEpithet());
|
702
|
assertEquals("D'Mueller", nameBasionymExAuthor.getExCombinationAuthorship().getNomenclaturalTitle());
|
703
|
assertEquals("de Greuther", nameBasionymExAuthor.getCombinationAuthorship().getNomenclaturalTitle());
|
704
|
assertEquals("Ciardelli", nameBasionymExAuthor.getExBasionymAuthorship().getNomenclaturalTitle());
|
705
|
assertEquals("Doering", nameBasionymExAuthor.getBasionymAuthorship().getNomenclaturalTitle());
|
706
|
|
707
|
NonViralName<?> name2 = (NonViralName<?>)parseMethod.invoke(parser, strNameAbiesSub1, null, Rank.SPECIES());
|
708
|
assertEquals("Abies", name2.getGenusOrUninomial());
|
709
|
assertEquals("alba", name2.getSpecificEpithet());
|
710
|
assertEquals("beta", name2.getInfraSpecificEpithet());
|
711
|
assertEquals(Rank.SUBSPECIES(), name2.getRank());
|
712
|
|
713
|
|
714
|
// unparseable *********
|
715
|
String problemString = "sdfjlös wer eer wer";
|
716
|
NonViralName<?> nameProblem = (NonViralName<?>)parseMethod.invoke(parser, problemString, null, Rank.SPECIES());
|
717
|
List<ParserProblem> list = nameProblem.getParsingProblems();
|
718
|
assertTrue(nameProblem.getParsingProblem()!=0);
|
719
|
assertEquals(problemString, nameProblem.getTitleCache());
|
720
|
}
|
721
|
|
722
|
|
723
|
/**
|
724
|
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseReferencedName(NonViralName, java.lang.String, eu.etaxonomy.cdm.model.name.Rank, boolean)(, )}.
|
725
|
*/
|
726
|
@Test
|
727
|
public final void testParseNomStatus() {
|
728
|
//nom. ambig.
|
729
|
String strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. ambig.";
|
730
|
NonViralName<?> nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
731
|
assertFullRefStandard(nameTestStatus);
|
732
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
733
|
assertEquals( NomenclaturalStatusType.AMBIGUOUS(), nameTestStatus.getStatus().iterator().next().getType());
|
734
|
|
735
|
//nom. inval.
|
736
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. inval.";
|
737
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
738
|
assertFullRefStandard(nameTestStatus);
|
739
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
740
|
assertEquals( NomenclaturalStatusType.INVALID(), nameTestStatus.getStatus().iterator().next().getType());
|
741
|
|
742
|
//nom. dub.
|
743
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. dub.";
|
744
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
745
|
assertFullRefStandard(nameTestStatus);
|
746
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
747
|
assertEquals( NomenclaturalStatusType.DOUBTFUL(), nameTestStatus.getStatus().iterator().next().getType());
|
748
|
|
749
|
//nom. confus.
|
750
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. confus.";
|
751
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
752
|
assertFullRefStandard(nameTestStatus);
|
753
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
754
|
assertEquals( NomenclaturalStatusType.CONFUSUM(), nameTestStatus.getStatus().iterator().next().getType());
|
755
|
|
756
|
//nom. illeg.
|
757
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. illeg.";
|
758
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
759
|
assertFullRefStandard(nameTestStatus);
|
760
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
761
|
assertEquals( NomenclaturalStatusType.ILLEGITIMATE(), nameTestStatus.getStatus().iterator().next().getType());
|
762
|
|
763
|
//nom. superfl.
|
764
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. superfl.";
|
765
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
766
|
assertFullRefStandard(nameTestStatus);
|
767
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
768
|
assertEquals( NomenclaturalStatusType.SUPERFLUOUS(), nameTestStatus.getStatus().iterator().next().getType());
|
769
|
|
770
|
//nom. rej.
|
771
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. rej.";
|
772
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
773
|
assertFullRefStandard(nameTestStatus);
|
774
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
775
|
assertEquals( NomenclaturalStatusType.REJECTED(), nameTestStatus.getStatus().iterator().next().getType());
|
776
|
|
777
|
//nom. utique rej.
|
778
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. utique rej.";
|
779
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
780
|
assertFullRefStandard(nameTestStatus);
|
781
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
782
|
assertEquals( NomenclaturalStatusType.UTIQUE_REJECTED(), nameTestStatus.getStatus().iterator().next().getType());
|
783
|
|
784
|
//nom. cons. prop.
|
785
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. cons. prop.";
|
786
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
787
|
assertFullRefStandard(nameTestStatus);
|
788
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
789
|
assertEquals( NomenclaturalStatusType.CONSERVED_PROP(), nameTestStatus.getStatus().iterator().next().getType());
|
790
|
|
791
|
//nom. orth. cons. prop.
|
792
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. orth. cons. prop.";
|
793
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
794
|
assertFullRefStandard(nameTestStatus);
|
795
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
796
|
assertEquals( NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED_PROP(), nameTestStatus.getStatus().iterator().next().getType());
|
797
|
|
798
|
//nom. cons. prop.
|
799
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. cons. des.";
|
800
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
801
|
assertFullRefStandard(nameTestStatus);
|
802
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
803
|
assertEquals( NomenclaturalStatusType.CONSERVED_DESIG(), nameTestStatus.getStatus().iterator().next().getType());
|
804
|
|
805
|
//nom. legit.
|
806
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. legit.";
|
807
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
808
|
assertFullRefStandard(nameTestStatus);
|
809
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
810
|
assertEquals( NomenclaturalStatusType.LEGITIMATE(), nameTestStatus.getStatus().iterator().next().getType());
|
811
|
|
812
|
//nom. altern.
|
813
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. altern.";
|
814
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
815
|
assertFullRefStandard(nameTestStatus);
|
816
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
817
|
assertEquals( NomenclaturalStatusType.ALTERNATIVE(), nameTestStatus.getStatus().iterator().next().getType());
|
818
|
|
819
|
//nom. alternativ.
|
820
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. alternativ.";
|
821
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
822
|
assertFullRefStandard(nameTestStatus);
|
823
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
824
|
assertEquals( NomenclaturalStatusType.ALTERNATIVE(), nameTestStatus.getStatus().iterator().next().getType());
|
825
|
|
826
|
//nom. nov.
|
827
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. nov.";
|
828
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
829
|
assertFullRefStandard(nameTestStatus);
|
830
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
831
|
assertEquals( NomenclaturalStatusType.NOVUM(), nameTestStatus.getStatus().iterator().next().getType());
|
832
|
|
833
|
//nom. utique rej. prop.
|
834
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. utique rej. prop.";
|
835
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
836
|
assertFullRefStandard(nameTestStatus);
|
837
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
838
|
assertEquals( NomenclaturalStatusType.UTIQUE_REJECTED_PROP(), nameTestStatus.getStatus().iterator().next().getType());
|
839
|
|
840
|
//nom. orth. cons.
|
841
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. orth. cons.";
|
842
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
843
|
assertFullRefStandard(nameTestStatus);
|
844
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
845
|
assertEquals( NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED(), nameTestStatus.getStatus().iterator().next().getType());
|
846
|
|
847
|
//nom. rej. prop.
|
848
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. rej. prop.";
|
849
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
850
|
assertFullRefStandard(nameTestStatus);
|
851
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
852
|
assertEquals( NomenclaturalStatusType.REJECTED_PROP(), nameTestStatus.getStatus().iterator().next().getType());
|
853
|
|
854
|
//nom. cons.
|
855
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. cons.";
|
856
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
857
|
assertFullRefStandard(nameTestStatus);
|
858
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
859
|
assertEquals( NomenclaturalStatusType.CONSERVED(), nameTestStatus.getStatus().iterator().next().getType());
|
860
|
|
861
|
//nom. sanct.
|
862
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. sanct.";
|
863
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
864
|
assertFullRefStandard(nameTestStatus);
|
865
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
866
|
assertEquals( NomenclaturalStatusType.SANCTIONED(), nameTestStatus.getStatus().iterator().next().getType());
|
867
|
|
868
|
//nom. nud.
|
869
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. nud.";
|
870
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
871
|
assertFullRefStandard(nameTestStatus);
|
872
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
873
|
assertEquals( NomenclaturalStatusType.NUDUM(), nameTestStatus.getStatus().iterator().next().getType());
|
874
|
|
875
|
//comb. inval.
|
876
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, comb. inval.";
|
877
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
878
|
assertFullRefStandard(nameTestStatus);
|
879
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
880
|
assertEquals( NomenclaturalStatusType.COMBINATION_INVALID(), nameTestStatus.getStatus().iterator().next().getType());
|
881
|
|
882
|
//comb. illeg.
|
883
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, comb. illeg.";
|
884
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
885
|
assertFullRefStandard(nameTestStatus);
|
886
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
887
|
assertEquals( NomenclaturalStatusType.COMBINATION_ILLEGITIMATE(), nameTestStatus.getStatus().iterator().next().getType());
|
888
|
|
889
|
//nom. provis.
|
890
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. provis.";
|
891
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
892
|
assertFullRefStandard(nameTestStatus);
|
893
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
894
|
assertEquals( NomenclaturalStatusType.PROVISIONAL(), nameTestStatus.getStatus().iterator().next().getType());
|
895
|
|
896
|
//nom. valid
|
897
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. valid";
|
898
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
899
|
assertFullRefStandard(nameTestStatus);
|
900
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
901
|
assertEquals( NomenclaturalStatusType.VALID(), nameTestStatus.getStatus().iterator().next().getType());
|
902
|
|
903
|
//nom. subnud.
|
904
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. subnud.";
|
905
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
906
|
assertFullRefStandard(nameTestStatus);
|
907
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
908
|
assertEquals( NomenclaturalStatusType.SUBNUDUM(), nameTestStatus.getStatus().iterator().next().getType());
|
909
|
|
910
|
//opus. utique oppr.
|
911
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, opus. utique oppr.";
|
912
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
913
|
assertFullRefStandard(nameTestStatus);
|
914
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
915
|
assertEquals( NomenclaturalStatusType.OPUS_UTIQUE_OPPR(), nameTestStatus.getStatus().iterator().next().getType());
|
916
|
|
917
|
//comb. nov.
|
918
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, comb. nov.";
|
919
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
920
|
assertFullRefStandard(nameTestStatus);
|
921
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
922
|
assertEquals( NomenclaturalStatusType.COMB_NOV(), nameTestStatus.getStatus().iterator().next().getType());
|
923
|
|
924
|
//orth. rej.
|
925
|
strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, orth. rej.";
|
926
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
927
|
assertFullRefStandard(nameTestStatus);
|
928
|
assertTrue(nameTestStatus.getStatus().size()== 1);
|
929
|
assertEquals( NomenclaturalStatusType.ORTHOGRAPHY_REJECTED(), nameTestStatus.getStatus().iterator().next().getType());
|
930
|
|
931
|
//ined.
|
932
|
strTestStatus = "Houstonia macvaughii (Terrell) Aber, ined.";
|
933
|
nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
|
934
|
assertEquals("Houstonia", nameTestStatus.getGenusOrUninomial());
|
935
|
assertEquals("macvaughii", nameTestStatus.getSpecificEpithet());
|
936
|
assertEquals("(Terrell) Aber", nameTestStatus.getAuthorshipCache());
|
937
|
assertEquals(1, nameTestStatus.getStatus().size());
|
938
|
assertEquals( NomenclaturalStatusType.INED(), nameTestStatus.getStatus().iterator().next().getType());
|
939
|
|
940
|
//not yet parsed "not avail."
|
941
|
}
|
942
|
|
943
|
/**
|
944
|
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseReferencedName(NonViralName, java.lang.String, eu.etaxonomy.cdm.model.name.Rank, boolean)(, )}.
|
945
|
*/
|
946
|
@Test
|
947
|
public final void testParseReferencedName() {
|
948
|
try {
|
949
|
Method parseMethod = parser.getClass().getDeclaredMethod("parseReferencedName", String.class, NomenclaturalCode.class, Rank.class);
|
950
|
testName_StringNomcodeRank(parseMethod);
|
951
|
} catch (Exception e) {
|
952
|
e.printStackTrace();
|
953
|
assertTrue(false);
|
954
|
}
|
955
|
|
956
|
|
957
|
//null
|
958
|
String strNull = null;
|
959
|
Rank rankSpecies = Rank.SPECIES();
|
960
|
NonViralName<?> nameNull = parser.parseReferencedName(strNull, null, rankSpecies);
|
961
|
assertNull(nameNull);
|
962
|
|
963
|
//Empty
|
964
|
String strEmpty = "";
|
965
|
NonViralName<?> nameEmpty = parser.parseReferencedName(strEmpty, null, rankSpecies);
|
966
|
assertFalse(nameEmpty.hasProblem());
|
967
|
assertEquals(strEmpty, nameEmpty.getFullTitleCache());
|
968
|
assertNull(nameEmpty.getNomenclaturalMicroReference());
|
969
|
|
970
|
|
971
|
//Whitespaces
|
972
|
String strFullWhiteSpcaceAndDot = "Abies alba Mill., Sp. Pl. 4: 455 . 1987 .";
|
973
|
NonViralName<?> namefullWhiteSpcaceAndDot = parser.parseReferencedName(strFullWhiteSpcaceAndDot, null, rankSpecies);
|
974
|
assertFullRefStandard(namefullWhiteSpcaceAndDot);
|
975
|
assertTrue(((Reference)namefullWhiteSpcaceAndDot.getNomenclaturalReference()).getType().equals(eu.etaxonomy.cdm.model.reference.ReferenceType.Book));
|
976
|
assertEquals( "Abies alba Mill., Sp. Pl. 4: 455. 1987", namefullWhiteSpcaceAndDot.getFullTitleCache());
|
977
|
|
978
|
//Book
|
979
|
String fullReference = "Abies alba Mill., Sp. Pl. 4: 455. 1987";
|
980
|
NonViralName<?> name1 = parser.parseReferencedName(fullReference, null, rankSpecies);
|
981
|
assertFullRefStandard(name1);
|
982
|
assertTrue(((Reference)name1.getNomenclaturalReference()).getType().equals(eu.etaxonomy.cdm.model.reference.ReferenceType.Book));
|
983
|
assertEquals(fullReference, name1.getFullTitleCache());
|
984
|
assertTrue("Name author and reference author should be the same", name1.getCombinationAuthorship() == ((Reference)name1.getNomenclaturalReference()).getAuthorship());
|
985
|
|
986
|
//Book Section
|
987
|
fullReference = "Abies alba Mill. in Otto, Sp. Pl. 4(6): 455. 1987";
|
988
|
NonViralName<?> name2 = parser.parseReferencedName(fullReference + ".", null, rankSpecies);
|
989
|
assertFullRefNameStandard(name2);
|
990
|
assertEquals(fullReference, name2.getFullTitleCache());
|
991
|
assertFalse(name2.hasProblem());
|
992
|
INomenclaturalReference ref = name2.getNomenclaturalReference();
|
993
|
assertEquals(eu.etaxonomy.cdm.model.reference.ReferenceType.BookSection, ((Reference)ref).getType());
|
994
|
IBookSection bookSection = (IBookSection) ref;
|
995
|
IBook inBook = bookSection.getInBook();
|
996
|
assertNotNull(inBook);
|
997
|
assertNotNull(inBook.getAuthorship());
|
998
|
assertEquals("Otto", inBook.getAuthorship().getTitleCache());
|
999
|
assertEquals("Otto, Sp. Pl. 4(6)", inBook.getTitleCache());
|
1000
|
assertEquals("Sp. Pl.", inBook.getTitle());
|
1001
|
assertEquals("4(6)", inBook.getVolume());
|
1002
|
assertTrue("Name author and reference author should be the same", name2.getCombinationAuthorship() == ((Reference)name2.getNomenclaturalReference()).getAuthorship());
|
1003
|
|
1004
|
//Article
|
1005
|
fullReference = "Abies alba Mill. in Sp. Pl. 4(6): 455. 1987";
|
1006
|
NonViralName<?> name3 = parser.parseReferencedName(fullReference, null, rankSpecies);
|
1007
|
assertFullRefNameStandard(name3);
|
1008
|
name3.setTitleCache(null);
|
1009
|
assertEquals(fullReference, name3.getFullTitleCache());
|
1010
|
assertFalse(name3.hasProblem());
|
1011
|
ref = name3.getNomenclaturalReference();
|
1012
|
assertEquals(eu.etaxonomy.cdm.model.reference.ReferenceType.Article, ref.getType());
|
1013
|
//Article article = (Article)ref;
|
1014
|
IJournal journal = ((IArticle)ref).getInJournal();
|
1015
|
assertNotNull(journal);
|
1016
|
//assertEquals("Sp. Pl. 4(6)", inBook.getTitleCache());
|
1017
|
assertEquals("Sp. Pl.",((Reference) journal).getTitleCache());
|
1018
|
assertEquals("Sp. Pl.", journal.getTitle());
|
1019
|
assertEquals("4(6)",((IArticle)ref).getVolume());
|
1020
|
assertTrue("Name author and reference author should be the same", name3.getCombinationAuthorship() == name3.getNomenclaturalReference().getAuthorship());
|
1021
|
|
1022
|
//Article with volume range
|
1023
|
fullReference = "Abies alba Mill. in Sp. Pl. 4(1-2): 455. 1987";
|
1024
|
NonViralName<?> name3a = parser.parseReferencedName(fullReference, null, rankSpecies);
|
1025
|
name3a.setTitleCache(null);
|
1026
|
assertEquals(fullReference, name3a.getFullTitleCache());
|
1027
|
assertFalse(name3a.hasProblem());
|
1028
|
ref = name3a.getNomenclaturalReference();
|
1029
|
assertEquals(eu.etaxonomy.cdm.model.reference.ReferenceType.Article, ref.getType());
|
1030
|
assertEquals("4(1-2)",((IArticle)ref).getVolume());
|
1031
|
|
1032
|
//SoftArticle - having "," on position > 4
|
1033
|
String journalTitle = "Bull. Soc. Bot.France. Louis., Roi";
|
1034
|
String yearPart = " 1987 - 1989";
|
1035
|
String parsedYear = "1987-1989";
|
1036
|
String fullReferenceWithoutYear = "Abies alba Mill. in " + journalTitle + " 4(6): 455.";
|
1037
|
fullReference = fullReferenceWithoutYear + yearPart;
|
1038
|
String fullReferenceWithEnd = fullReference + ".";
|
1039
|
NonViralName<?> name4 = parser.parseReferencedName(fullReferenceWithEnd, null, rankSpecies);
|
1040
|
assertFalse(name4.hasProblem());
|
1041
|
assertFullRefNameStandard(name4);
|
1042
|
assertEquals(fullReferenceWithoutYear + " " + parsedYear, name4.getFullTitleCache());
|
1043
|
ref = name4.getNomenclaturalReference();
|
1044
|
assertEquals(ReferenceType.Article, ref.getType());
|
1045
|
//article = (Article)ref;
|
1046
|
assertEquals(parsedYear, ref.getYear());
|
1047
|
journal = ((IArticle)ref).getInJournal();
|
1048
|
assertNotNull(journal);
|
1049
|
assertEquals(journalTitle, ((Reference) journal).getTitleCache());
|
1050
|
assertEquals(journalTitle, journal.getTitle());
|
1051
|
assertEquals("4(6)", ((IArticle)ref).getVolume());
|
1052
|
|
1053
|
//Zoo name
|
1054
|
String strNotParsableZoo = "Abies alba M., 1923, Sp. P. xxwer4352, nom. inval.";
|
1055
|
ZoologicalName nameZooRefNotParsabel = (ZoologicalName)parser.parseReferencedName(strNotParsableZoo, null, null);
|
1056
|
assertTrue(nameZooRefNotParsabel.hasProblem());
|
1057
|
List<ParserProblem> list = nameZooRefNotParsabel.getParsingProblems();
|
1058
|
assertTrue("List must contain detail and year warning ", list.contains(ParserProblem.CheckDetailOrYear));
|
1059
|
assertEquals(21, nameZooRefNotParsabel.getProblemStarts());
|
1060
|
assertEquals(37, nameZooRefNotParsabel.getProblemEnds());
|
1061
|
assertTrue(nameZooRefNotParsabel.getNomenclaturalReference().hasProblem());
|
1062
|
list = nameZooRefNotParsabel.getNomenclaturalReference().getParsingProblems();
|
1063
|
assertTrue("List must contain detail and year warning ", list.contains(ParserProblem.CheckDetailOrYear));
|
1064
|
|
1065
|
assertEquals(NomenclaturalCode.ICZN, nameZooRefNotParsabel.getNomenclaturalCode());
|
1066
|
assertEquals(Integer.valueOf(1923), nameZooRefNotParsabel.getPublicationYear());
|
1067
|
assertEquals(1, nameZooRefNotParsabel.getStatus().size());
|
1068
|
|
1069
|
String strZooNameSineYear = "Homo sapiens L., 1758, Sp. An. 3: 345";
|
1070
|
ZoologicalName nameZooNameSineYear = (ZoologicalName)parser.parseReferencedName(strZooNameSineYear);
|
1071
|
assertFalse(nameZooNameSineYear.hasProblem());
|
1072
|
assertEquals("Name without reference year must have year", (Integer)1758, nameZooNameSineYear.getPublicationYear());
|
1073
|
assertEquals("Name without reference year must have year", "1758", nameZooNameSineYear.getNomenclaturalReference().getYear());
|
1074
|
|
1075
|
String strZooNameNewCombination = "Homo sapiens (L., 1758) Mill., 1830, Sp. An. 3: 345";
|
1076
|
ZoologicalName nameZooNameNewCombination = (ZoologicalName)parser.parseReferencedName(strZooNameNewCombination);
|
1077
|
assertTrue(nameZooNameNewCombination.hasProblem());
|
1078
|
list = nameZooNameNewCombination.getParsingProblems();
|
1079
|
assertTrue("List must contain new combination has publication warning ", list.contains(ParserProblem.NewCombinationHasPublication));
|
1080
|
assertEquals(35, nameZooNameNewCombination.getProblemStarts());
|
1081
|
assertEquals(51, nameZooNameNewCombination.getProblemEnds());
|
1082
|
|
1083
|
|
1084
|
//Special MicroRefs
|
1085
|
String strSpecDetail1 = "Abies alba Mill. in Sp. Pl. 4(6): [455]. 1987";
|
1086
|
NonViralName<?> nameSpecDet1 = parser.parseReferencedName(strSpecDetail1 + ".", null, rankSpecies);
|
1087
|
assertFalse(nameSpecDet1.hasProblem());
|
1088
|
assertEquals(strSpecDetail1, nameSpecDet1.getFullTitleCache());
|
1089
|
assertEquals("[455]", nameSpecDet1.getNomenclaturalMicroReference());
|
1090
|
|
1091
|
//Special MicroRefs
|
1092
|
String strSpecDetail2 = "Abies alba Mill. in Sp. Pl. 4(6): couv. 2. 1987";
|
1093
|
NonViralName<?> nameSpecDet2 = parser.parseReferencedName(strSpecDetail2 + ".", null, rankSpecies);
|
1094
|
assertFalse(nameSpecDet2.hasProblem());
|
1095
|
assertEquals(strSpecDetail2, nameSpecDet2.getFullTitleCache());
|
1096
|
assertEquals("couv. 2", nameSpecDet2.getNomenclaturalMicroReference());
|
1097
|
|
1098
|
//Special MicroRefs
|
1099
|
String strSpecDetail3 = "Abies alba Mill. in Sp. Pl. 4(6): fig. 455. 1987";
|
1100
|
NonViralName<?> nameSpecDet3 = parser.parseReferencedName(strSpecDetail3 + ".", null, rankSpecies);
|
1101
|
assertFalse(nameSpecDet3.hasProblem());
|
1102
|
assertEquals(strSpecDetail3, nameSpecDet3.getFullTitleCache());
|
1103
|
assertEquals("fig. 455", nameSpecDet3.getNomenclaturalMicroReference());
|
1104
|
|
1105
|
//Special MicroRefs
|
1106
|
String strSpecDetail4 = "Abies alba Mill. in Sp. Pl. 4(6): fig. 455-567. 1987";
|
1107
|
fullReference = strSpecDetail4 + ".";
|
1108
|
NonViralName<?> nameSpecDet4 = parser.parseReferencedName(fullReference, null, rankSpecies);
|
1109
|
assertFalse(nameSpecDet4.hasProblem());
|
1110
|
assertEquals(strSpecDetail4, nameSpecDet4.getFullTitleCache());
|
1111
|
assertEquals("fig. 455-567", nameSpecDet4.getNomenclaturalMicroReference());
|
1112
|
|
1113
|
|
1114
|
//Special MicroRefs
|
1115
|
String strSpecDetail5 = "Abies alba Mill. in Sp. Pl. 4(6): Gard n\u00B0 4. 1987";
|
1116
|
fullReference = strSpecDetail5 + ".";
|
1117
|
NonViralName<?> nameSpecDet5 = parser.parseReferencedName(fullReference, null, rankSpecies);
|
1118
|
assertFalse(nameSpecDet5.hasProblem());
|
1119
|
assertEquals(strSpecDetail5, nameSpecDet5.getFullTitleCache());
|
1120
|
assertEquals("Gard n\u00B0 4", nameSpecDet5.getNomenclaturalMicroReference());
|
1121
|
|
1122
|
//Special MicroRefs
|
1123
|
String strSpecDetail6 = "Abies alba Mill. in Sp. Pl. 4(6): 455a. 1987";
|
1124
|
fullReference = strSpecDetail6 + ".";
|
1125
|
NonViralName<?> nameSpecDet6 = parser.parseReferencedName(fullReference, null, rankSpecies);
|
1126
|
assertFalse(nameSpecDet6.hasProblem());
|
1127
|
assertEquals(strSpecDetail6, nameSpecDet6.getFullTitleCache());
|
1128
|
assertEquals("455a", nameSpecDet6.getNomenclaturalMicroReference());
|
1129
|
|
1130
|
//Special MicroRefs
|
1131
|
String strSpecDetail7 = "Abies alba Mill. in Sp. Pl. 4(6): pp.455-457. 1987";
|
1132
|
fullReference = strSpecDetail7 + ".";
|
1133
|
NonViralName<?> nameSpecDet7 = parser.parseReferencedName(fullReference, null, rankSpecies);
|
1134
|
assertFalse(nameSpecDet7.hasProblem());
|
1135
|
assertEquals(strSpecDetail7, nameSpecDet7.getFullTitleCache());
|
1136
|
assertEquals("pp.455-457", nameSpecDet7.getNomenclaturalMicroReference());
|
1137
|
|
1138
|
//Special MicroRefs
|
1139
|
String strSpecDetail8 = "Abies alba Mill. in Sp. Pl. 4(6): ppp.455-457. 1987";
|
1140
|
NonViralName<?> nameSpecDet8 = parser.parseReferencedName(strSpecDetail8, null, rankSpecies);
|
1141
|
assertTrue(nameSpecDet8.hasProblem());
|
1142
|
assertEquals(20, nameSpecDet8.getProblemStarts()); //TODO better start behind :
|
1143
|
assertEquals(51, nameSpecDet8.getProblemEnds()); //TODO better stop after -457
|
1144
|
|
1145
|
|
1146
|
//Special MicroRefs
|
1147
|
String strSpecDetail9 = "Abies alba Mill. in Sp. Pl. 4(6): pp. 455 - 457. 1987";
|
1148
|
NonViralName<?> nameSpecDet9 = parser.parseReferencedName(strSpecDetail9, null, rankSpecies);
|
1149
|
assertFalse(nameSpecDet9.hasProblem());
|
1150
|
assertEquals(strSpecDetail9, nameSpecDet9.getFullTitleCache());
|
1151
|
assertEquals("pp. 455 - 457", nameSpecDet9.getNomenclaturalMicroReference());
|
1152
|
|
1153
|
//Special MicroRefs
|
1154
|
String strSpecDetail10 = "Abies alba Mill. in Sp. Pl. 4(6): p 455. 1987";
|
1155
|
NonViralName<?> nameSpecDet10 = parser.parseReferencedName(strSpecDetail10, null, rankSpecies);
|
1156
|
assertFalse(nameSpecDet10.hasProblem());
|
1157
|
assertEquals(strSpecDetail10, nameSpecDet10.getFullTitleCache());
|
1158
|
assertEquals("p 455", nameSpecDet10.getNomenclaturalMicroReference());
|
1159
|
|
1160
|
//Special MicroRefs
|
1161
|
String strSpecDetail11 = "Abies alba Mill. in Sp. Pl. 4(6): p. 455 - 457. 1987";
|
1162
|
NonViralName<?> nameSpecDet11 = parser.parseReferencedName(strSpecDetail11, null, rankSpecies);
|
1163
|
assertTrue(nameSpecDet11.hasProblem());
|
1164
|
list = nameSpecDet11.getParsingProblems();
|
1165
|
assertTrue("Problem is Detail. Must be pp.", list.contains(ParserProblem.CheckDetailOrYear));
|
1166
|
assertEquals(20, nameSpecDet8.getProblemStarts()); //TODO better start behind :
|
1167
|
assertEquals(51, nameSpecDet8.getProblemEnds()); //TODO better stop after - 457
|
1168
|
|
1169
|
|
1170
|
//no volume, no edition
|
1171
|
String strNoVolume = "Abies alba Mill., Sp. Pl.: 455. 1987";
|
1172
|
NonViralName<?> nameNoVolume = parser.parseReferencedName(strNoVolume, null, rankSpecies);
|
1173
|
assertFalse(nameNoVolume.hasProblem());
|
1174
|
assertEquals(strNoVolume, nameNoVolume.getFullTitleCache());
|
1175
|
assertEquals(null, ((IVolumeReference)(nameNoVolume.getNomenclaturalReference())).getVolume());
|
1176
|
assertEquals(null, ((IBook)nameNoVolume.getNomenclaturalReference()).getEdition());
|
1177
|
|
1178
|
//volume, no edition
|
1179
|
strNoVolume = "Abies alba Mill., Sp. Pl. 2: 455. 1987";
|
1180
|
nameNoVolume = parser.parseReferencedName(strNoVolume, null, rankSpecies);
|
1181
|
assertFalse(nameNoVolume.hasProblem());
|
1182
|
assertEquals(strNoVolume, nameNoVolume.getFullTitleCache());
|
1183
|
assertEquals("2", ((IVolumeReference)(nameNoVolume.getNomenclaturalReference())).getVolume());
|
1184
|
assertEquals(null, ((IBook)(nameNoVolume.getNomenclaturalReference())).getEdition());
|
1185
|
|
1186
|
//no volume, edition
|
1187
|
strNoVolume = "Abies alba Mill., Sp. Pl., ed. 3: 455. 1987";
|
1188
|
nameNoVolume = parser.parseReferencedName(strNoVolume, null, rankSpecies);
|
1189
|
assertFalse(nameNoVolume.hasProblem());
|
1190
|
assertEquals(strNoVolume, nameNoVolume.getFullTitleCache());
|
1191
|
assertEquals(null, ((IVolumeReference)(nameNoVolume.getNomenclaturalReference())).getVolume());
|
1192
|
assertEquals("3", ((IBook)(nameNoVolume.getNomenclaturalReference())).getEdition());
|
1193
|
|
1194
|
//volume, edition
|
1195
|
strNoVolume = "Abies alba Mill., Sp. Pl. ed. 3, 4(5): 455. 1987";
|
1196
|
nameNoVolume = parser.parseReferencedName(strNoVolume, null, rankSpecies);
|
1197
|
assertFalse(nameNoVolume.hasProblem());
|
1198
|
assertEquals(strNoVolume.replace(" ed.", ", ed."), nameNoVolume.getFullTitleCache());
|
1199
|
assertEquals("4(5)", ((IVolumeReference)(nameNoVolume.getNomenclaturalReference())).getVolume());
|
1200
|
assertEquals("3", ((IBook)(nameNoVolume.getNomenclaturalReference())).getEdition());
|
1201
|
|
1202
|
String strUnparsableInRef = "Abies alba Mill. in -er46: 455. 1987";
|
1203
|
NonViralName<?> nameUnparsableInRef = parser.parseReferencedName(strUnparsableInRef, null, rankSpecies);
|
1204
|
assertTrue(nameUnparsableInRef.hasProblem());
|
1205
|
list = nameUnparsableInRef.getParsingProblems();
|
1206
|
assertTrue("Unparsable title", list.contains(ParserProblem.UnparsableReferenceTitle));
|
1207
|
assertEquals(strUnparsableInRef, nameUnparsableInRef.getFullTitleCache());
|
1208
|
assertEquals(20, nameUnparsableInRef.getProblemStarts());
|
1209
|
assertEquals(25, nameUnparsableInRef.getProblemEnds());
|
1210
|
|
1211
|
|
1212
|
//volume, edition
|
1213
|
String strNoSeparator = "Abies alba Mill. Sp. Pl. ed. 3, 4(5): 455. 1987";
|
1214
|
NonViralName<?> nameNoSeparator = parser.parseReferencedName(strNoSeparator, ICNAFP, rankSpecies);
|
1215
|
assertTrue(nameNoSeparator.hasProblem());
|
1216
|
list = nameNoSeparator.getParsingProblems();
|
1217
|
assertTrue("Problem is missing name-reference separator", list.contains(ParserProblem.NameReferenceSeparation));
|
1218
|
assertEquals(strNoSeparator, nameNoSeparator.getFullTitleCache());
|
1219
|
assertEquals(10, nameNoSeparator.getProblemStarts()); //TODO better start behind Mill. (?)
|
1220
|
assertEquals(47, nameNoSeparator.getProblemEnds()); //TODO better stop before :
|
1221
|
|
1222
|
String strUnparsableInRef2 = "Hieracium pepsicum L., My Bookkkk 1. 1903";
|
1223
|
NonViralName<?> nameUnparsableInRef2 = parser.parseReferencedName(strUnparsableInRef2, null, rankSpecies);
|
1224
|
assertTrue(nameUnparsableInRef2.hasProblem());
|
1225
|
list = nameUnparsableInRef2.getParsingProblems();
|
1226
|
assertTrue("Problem detail", list.contains(ParserProblem.CheckDetailOrYear));
|
1227
|
assertEquals(strUnparsableInRef2, nameUnparsableInRef2.getFullTitleCache());
|
1228
|
assertEquals(23, nameUnparsableInRef2.getProblemStarts());
|
1229
|
assertEquals(41, nameUnparsableInRef2.getProblemEnds());
|
1230
|
|
1231
|
|
1232
|
String strUnparsableInRef3 = "Hieracium pespcim N., My Bookkkk 1. 1902";
|
1233
|
NonViralName<?> nameUnparsableInRef3 = parser.parseReferencedName(strUnparsableInRef3, null, null);
|
1234
|
assertTrue(nameUnparsableInRef3.hasProblem());
|
1235
|
list = nameUnparsableInRef3.getParsingProblems();
|
1236
|
assertTrue("Problem detail", list.contains(ParserProblem.CheckDetailOrYear));
|
1237
|
assertEquals(strUnparsableInRef3, nameUnparsableInRef3.getFullTitleCache());
|
1238
|
assertEquals(22, nameUnparsableInRef3.getProblemStarts());
|
1239
|
assertEquals(40, nameUnparsableInRef3.getProblemEnds());
|
1240
|
|
1241
|
String strUnparsableInRef4 = "Hieracium pepsicum (Hsllreterto) L., My Bookkkk 1. 1903";
|
1242
|
NonViralName<?> nameUnparsableInRef4 = parser.parseReferencedName(strUnparsableInRef4, null, null);
|
1243
|
assertTrue(nameUnparsableInRef4.hasProblem());
|
1244
|
list = nameUnparsableInRef4.getParsingProblems();
|
1245
|
assertTrue("Problem detail", list.contains(ParserProblem.CheckDetailOrYear));
|
1246
|
assertEquals(strUnparsableInRef4, nameUnparsableInRef4.getFullTitleCache());
|
1247
|
assertEquals(37, nameUnparsableInRef4.getProblemStarts());
|
1248
|
assertEquals(55, nameUnparsableInRef4.getProblemEnds());
|
1249
|
|
1250
|
String strSameName = "Hieracium pepcum (Hsllreterto) L., My Bokkk 1. 1903";
|
1251
|
NonViralName<?> nameSameName = nameUnparsableInRef4;
|
1252
|
parser.parseReferencedName(nameSameName, strSameName, null, true);
|
1253
|
assertTrue(nameSameName.hasProblem());
|
1254
|
list = nameSameName.getParsingProblems();
|
1255
|
assertTrue("Problem detail", list.contains(ParserProblem.CheckDetailOrYear));
|
1256
|
assertEquals(strSameName, nameSameName.getFullTitleCache());
|
1257
|
assertEquals(35, nameSameName.getProblemStarts());
|
1258
|
assertEquals(51, nameSameName.getProblemEnds());
|
1259
|
|
1260
|
String strGenusUnparse = "Hieracium L., jlklk";
|
1261
|
NonViralName<?> nameGenusUnparse =
|
1262
|
parser.parseReferencedName(strGenusUnparse, null, null);
|
1263
|
assertTrue(nameGenusUnparse.hasProblem());
|
1264
|
list = nameGenusUnparse.getParsingProblems();
|
1265
|
assertTrue("Problem detail", list.contains(ParserProblem.CheckDetailOrYear));
|
1266
|
assertTrue("Problem uninomial", list.contains(ParserProblem.CheckRank));
|
1267
|
assertEquals(strGenusUnparse, nameGenusUnparse.getFullTitleCache());
|
1268
|
assertEquals(0, nameGenusUnparse.getProblemStarts());
|
1269
|
assertEquals(19, nameGenusUnparse.getProblemEnds());
|
1270
|
|
1271
|
String strGenusUnparse2 = "Hieracium L., Per Luigi: 44. 1987";
|
1272
|
NonViralName<?> nameGenusUnparse2 =
|
1273
|
parser.parseReferencedName(strGenusUnparse2, null, Rank.FAMILY());
|
1274
|
assertFalse(nameGenusUnparse2.hasProblem());
|
1275
|
assertEquals(strGenusUnparse2, nameGenusUnparse2.getFullTitleCache());
|
1276
|
assertEquals(-1, nameGenusUnparse2.getProblemStarts());
|
1277
|
assertEquals(-1, nameGenusUnparse2.getProblemEnds());
|
1278
|
|
1279
|
String strBookSection2 = "Hieracium vulgatum subsp. acuminatum (Jord.) Zahn in Schinz & Keller, Fl. Schweiz, ed. 2, 2: 288. 1905-1907";
|
1280
|
String strBookSection2NoComma = "Hieracium vulgatum subsp. acuminatum (Jord.) Zahn in Schinz & Keller, Fl. Schweiz ed. 2, 2: 288. 1905-1907";
|
1281
|
NonViralName<?> nameBookSection2 =
|
1282
|
parser.parseReferencedName(strBookSection2, null, null);
|
1283
|
assertFalse(nameBookSection2.hasProblem());
|
1284
|
nameBookSection2.setFullTitleCache(null, false);
|
1285
|
assertEquals(strBookSection2NoComma.replace(" ed.", ", ed."), nameBookSection2.getFullTitleCache());
|
1286
|
assertEquals(-1, nameBookSection2.getProblemStarts());
|
1287
|
assertEquals(-1, nameBookSection2.getProblemEnds());
|
1288
|
assertNull((nameBookSection2.getNomenclaturalReference()).getDatePublished().getStart());
|
1289
|
assertEquals("1905-1907", ((IBookSection)nameBookSection2.getNomenclaturalReference()).getInBook().getDatePublished().getYear());
|
1290
|
|
1291
|
|
1292
|
String strBookSection = "Hieracium vulgatum subsp. acuminatum (Jord.) Zahn in Schinz & Keller, Fl. Schweiz ed. 2, 2: 288. 1905";
|
1293
|
NonViralName<?> nameBookSection =
|
1294
|
parser.parseReferencedName(strBookSection, null, null);
|
1295
|
assertFalse(nameBookSection.hasProblem());
|
1296
|
assertEquals(strBookSection.replace(" ed.", ", ed."), nameBookSection.getFullTitleCache());
|
1297
|
assertEquals(-1, nameBookSection.getProblemStarts());
|
1298
|
assertEquals(-1, nameBookSection.getProblemEnds());
|
1299
|
assertNull(((IBookSection)nameBookSection.getNomenclaturalReference()).getInBook().getDatePublished().getStart());
|
1300
|
assertEquals("1905", ((IBookSection)nameBookSection.getNomenclaturalReference()).getDatePublished().getYear());
|
1301
|
|
1302
|
String strXXXs = "Abies alba, Soer der 1987";
|
1303
|
NonViralName<?> problemName = parser.parseReferencedName(strXXXs, null, null);
|
1304
|
assertTrue(problemName.hasProblem());
|
1305
|
list = problemName.getParsingProblems();
|
1306
|
assertTrue("Problem must be name-reference separation", list.contains(ParserProblem.NameReferenceSeparation));
|
1307
|
parser.parseReferencedName(problemName, strBookSection, null, true);
|
1308
|
assertFalse(problemName.hasProblem());
|
1309
|
|
1310
|
problemName = parser.parseFullName(strXXXs, null, null);
|
1311
|
assertTrue(problemName.hasProblem());
|
1312
|
list = problemName.getParsingProblems();
|
1313
|
assertTrue("Name part must be unparsable", list.contains(ParserProblem.UnparsableNamePart));
|
1314
|
|
1315
|
|
1316
|
String testParsable = "Pithecellobium macrostachyum Benth.";
|
1317
|
assertTrue(isParsable(testParsable, ICNAFP));
|
1318
|
|
1319
|
testParsable = "Pithecellobium macrostachyum (Benth.)";
|
1320
|
assertTrue(isParsable(testParsable, ICNAFP));
|
1321
|
|
1322
|
testParsable = "Pithecellobium macrostachyum (Benth., 1845)";
|
1323
|
assertTrue(isParsable(testParsable, NomenclaturalCode.ICZN));
|
1324
|
|
1325
|
testParsable = "Pithecellobium macrostachyum L., Sp. Pl. 3: n\u00B0 123. 1753."; //00B0 is degree character
|
1326
|
assertTrue(isParsable(testParsable, ICNAFP));
|
1327
|
|
1328
|
testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. Mitt.-Eur. 6: 1285. 1929";
|
1329
|
assertTrue("Reference title should support special characters as separators like - and &", isParsable(testParsable, ICNAFP));
|
1330
|
|
1331
|
testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. Mitt.&Eur. 6: 1285. 1929";
|
1332
|
assertTrue("Reference title should support special characters as separators like - and &", isParsable(testParsable, ICNAFP));
|
1333
|
|
1334
|
testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. Mitt.-Eur.& 6: 1285. 1929";
|
1335
|
assertFalse("Reference title should not support special characters like - and & at the end of the title", isParsable(testParsable, ICNAFP));
|
1336
|
assertTrue("Problem must be reference title", getProblems(testParsable, ICNAFP).
|
1337
|
contains(ParserProblem.UnparsableReferenceTitle));
|
1338
|
|
1339
|
testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. Mitt.:Eur. 6: 1285. 1929";
|
1340
|
assertFalse("Reference title should not support detail separator", isParsable(testParsable, ICNAFP));
|
1341
|
assertTrue("Problem must be reference title", getProblems(testParsable, ICNAFP).
|
1342
|
contains(ParserProblem.UnparsableReferenceTitle));
|
1343
|
|
1344
|
testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. (Mitt.) 6: 1285. 1929";
|
1345
|
assertTrue("Reference title should support brackets", isParsable(testParsable, ICNAFP));
|
1346
|
|
1347
|
testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. (Mitt.) 6: 1285. 1929";
|
1348
|
assertTrue("Reference title should support brackets", isParsable(testParsable, ICNAFP));
|
1349
|
|
1350
|
testParsable = "Hieracium lachenalii Zahn, nom. illeg.";
|
1351
|
assertTrue("Reference should not be obligatory if a nom status exist", isParsable(testParsable, ICNAFP));
|
1352
|
|
1353
|
testParsable = "Hieracium lachenalii, nom. illeg.";
|
1354
|
assertTrue("Authorship should not be obligatory if followed by nom status", isParsable(testParsable, ICNAFP));
|
1355
|
|
1356
|
testParsable = "Hieracium lachenalii, Ill. Fl. (Mitt.) 6: 1285. 1929";
|
1357
|
assertFalse("Author is obligatory if followed by reference", isParsable(testParsable, ICNAFP));
|
1358
|
assertTrue("Problem must be name-reference separation", getProblems(testParsable, ICNAFP).
|
1359
|
contains(ParserProblem.NameReferenceSeparation));
|
1360
|
|
1361
|
testParsable = "Hieracium lachenalii in Hegi, Ill. Fl. (Mitt.) 6: 1285. 1929";
|
1362
|
assertFalse("Author is obligatory if followed by reference", isParsable(testParsable, ICNAFP));
|
1363
|
assertTrue("Problem must be name-reference separation", getProblems(testParsable, ICNAFP).
|
1364
|
contains(ParserProblem.NameReferenceSeparation));
|
1365
|
|
1366
|
testParsable = "Abies alba Mill. var. alba";
|
1367
|
assertTrue("Autonym problem", isParsable(testParsable, ICNAFP));
|
1368
|
|
1369
|
testParsable = "Scleroblitum abc Ulbr. in Engler & Prantl, Nat. Pflanzenfam., ed. 2, 16c: 495. 1934.";
|
1370
|
assertTrue("Volume with subdivision", isParsable(testParsable, ICNAFP));
|
1371
|
|
1372
|
|
1373
|
testParsable = "Hieracium antarcticum d'Urv. in M\u00E9m. Soc. Linn. Paris 4: 608. 1826";
|
1374
|
// testParsable = "Hieracium antarcticum Urv. in M\u00E9m. Soc. Linn. Paris 4: 608. 1826";
|
1375
|
assertTrue("Name with apostrophe is not parsable", isParsable(testParsable, ICNAFP));
|
1376
|
|
1377
|
testParsable = "Cichorium intybus subsp. glaucum (Hoffmanns. & Link) Tzvelev in Komarov, Fl. SSSR 29: 17. 1964";
|
1378
|
assertTrue("Reference containing a word in uppercase is not parsable", isParsable(testParsable, ICNAFP));
|
1379
|
|
1380
|
|
1381
|
}
|
1382
|
|
1383
|
|
1384
|
/**
|
1385
|
* Test author with name parts van, von, de, de la, d', da, del.
|
1386
|
* See also http://dev.e-taxonomy.eu/trac/ticket/3373
|
1387
|
*/
|
1388
|
@Test
|
1389
|
public final void testComposedAuthorNames(){
|
1390
|
|
1391
|
//van author (see https://dev.e-taxonomy.eu/trac/ticket/3373)
|
1392
|
String testParsable = "Aphelocoma unicolor subsp. griscomi van Rossem, 1928";
|
1393
|
assertTrue("Author with 'van' should be parsable", isParsable(testParsable, ICZN));
|
1394
|
|
1395
|
//von author (see https://dev.e-taxonomy.eu/trac/ticket/3373)
|
1396
|
testParsable = "Aphelocoma unicolor subsp. griscomi von Rossem, 1928";
|
1397
|
assertTrue("Author with 'von' should be parsable", isParsable(testParsable, ICZN));
|
1398
|
|
1399
|
//de author (see https://dev.e-taxonomy.eu/trac/ticket/3373)
|
1400
|
testParsable = "Aphelocoma unicolor subsp. griscomi de Rossem, 1928";
|
1401
|
assertTrue("Author with 'de' should be parsable", isParsable(testParsable, ICZN));
|
1402
|
|
1403
|
//de la author (see https://dev.e-taxonomy.eu/trac/ticket/3373)
|
1404
|
testParsable = "Aphelocoma unicolor subsp. griscomi de la Rossem, 1928";
|
1405
|
assertTrue("Author with 'de la' should be parsable", isParsable(testParsable, ICZN));
|
1406
|
|
1407
|
//d' author (see https://dev.e-taxonomy.eu/trac/ticket/3373)
|
1408
|
testParsable = "Aphelocoma unicolor subsp. griscomi d'Rossem, 1928";
|
1409
|
assertTrue("Author with \"'d'\" should be parsable", isParsable(testParsable, ICZN));
|
1410
|
|
1411
|
//da author (see https://dev.e-taxonomy.eu/trac/ticket/3373)
|
1412
|
testParsable = "Aphelocoma unicolor subsp. griscomi da Rossem, 1928";
|
1413
|
assertTrue("Author with 'da' should be parsable", isParsable(testParsable, ICZN));
|
1414
|
|
1415
|
//del author (see https://dev.e-taxonomy.eu/trac/ticket/3373)
|
1416
|
testParsable = "Aphelocoma unicolor subsp. griscomi del Rossem, 1928";
|
1417
|
assertTrue("Author with 'del' should be parsable", isParsable(testParsable, ICZN));
|
1418
|
|
1419
|
//O' author (see https://dev.e-taxonomy.eu/trac/ticket/4759)
|
1420
|
testParsable = "Aphelocoma unicolor subsp. griscomi O'Connor, 1928";
|
1421
|
assertTrue("Author with 'O'' should be parsable", isParsable(testParsable, ICZN));
|
1422
|
|
1423
|
//del author (see https://dev.e-taxonomy.eu/trac/ticket/4759)
|
1424
|
testParsable = "Aphelocoma unicolor subsp. griscomi zur Strassen, 1928";
|
1425
|
assertTrue("Author with 'zur' should be parsable", isParsable(testParsable, ICZN));
|
1426
|
|
1427
|
}
|
1428
|
|
1429
|
|
1430
|
|
1431
|
/**
|
1432
|
* @param testParsable
|
1433
|
* @param icbn
|
1434
|
* @return
|
1435
|
*/
|
1436
|
private List<ParserProblem> getProblems(String string, NomenclaturalCode code) {
|
1437
|
List<ParserProblem> result;
|
1438
|
result = parser.parseReferencedName(string, code, null).getParsingProblems();
|
1439
|
return result;
|
1440
|
}
|
1441
|
|
1442
|
private boolean isParsable(String string, NomenclaturalCode code){
|
1443
|
NonViralName<?> name = parser.parseReferencedName(string, code, null);
|
1444
|
return ! name.hasProblem();
|
1445
|
}
|
1446
|
|
1447
|
private void assertFullRefNameStandard(NonViralName<?> name){
|
1448
|
assertEquals("Abies", name.getGenusOrUninomial());
|
1449
|
assertEquals("alba", name.getSpecificEpithet());
|
1450
|
assertEquals("Mill.", name.getAuthorshipCache());
|
1451
|
assertEquals("455", name.getNomenclaturalMicroReference());
|
1452
|
assertNotNull(name.getNomenclaturalReference());
|
1453
|
}
|
1454
|
|
1455
|
private void assertFullRefStandard(NonViralName<?> name){
|
1456
|
assertEquals("Abies", name.getGenusOrUninomial());
|
1457
|
assertEquals("alba", name.getSpecificEpithet());
|
1458
|
assertEquals("Mill.", name.getAuthorshipCache());
|
1459
|
assertEquals("455", name.getNomenclaturalMicroReference());
|
1460
|
assertNotNull(name.getNomenclaturalReference());
|
1461
|
INomenclaturalReference ref = name.getNomenclaturalReference();
|
1462
|
assertEquals("1987", ref.getYear());
|
1463
|
assertEquals("Sp. Pl.", ref.getTitle());
|
1464
|
}
|
1465
|
|
1466
|
|
1467
|
@Test
|
1468
|
public void testNeverEndingParsing(){
|
1469
|
//some full titles result in never ending parsing process https://dev.e-taxonomy.eu/trac/ticket/1556
|
1470
|
|
1471
|
String irinaExample = "Milichiidae Sharp, 1899, Insects. Part II. Hymenopteracontinued (Tubulifera and Aculeata), Coleoptera, Strepsiptera, Lepidoptera, Diptera, Aphaniptera, Thysanoptera, Hemiptera, Anoplura 6: 504. 1899";
|
1472
|
// irinaExample = "Milichiidae Sharp, 1899, Insects. Part II. Uiuis Iuiui Hymenopteracontinued (Tubulifera and Aculeata), Coleoptera, Strepsiptera, Lepidoptera, Diptera, Aphaniptera, Thysanoptera, Hemiptera, Anoplura 6: 504. 1899";
|
1473
|
NonViralName<?> nvn = this.parser.parseReferencedName(irinaExample, NomenclaturalCode.ICZN, null);
|
1474
|
int parsingProblem = nvn.getParsingProblem();
|
1475
|
Assert.assertEquals("Name should have only rank warning", 1, parsingProblem);
|
1476
|
Assert.assertEquals("Titlecache", "Milichiidae Sharp, 1899", nvn.getTitleCache());
|
1477
|
Assert.assertEquals("If this line reached everything should be ok", "Milichiidae", nvn.getGenusOrUninomial());
|
1478
|
|
1479
|
String anotherExample = "Scorzonera hispanica var. brevifolia Boiss. & Balansa in Boissier, Diagn. Pl. Orient., ser. 2 6: 119. 1859.";
|
1480
|
nvn = this.parser.parseReferencedName(anotherExample, ICNAFP, null);
|
1481
|
parsingProblem = nvn.getParsingProblem();
|
1482
|
Assert.assertEquals("Problem should be 0", 0, parsingProblem);
|
1483
|
Assert.assertEquals("Titlecache", "Scorzonera hispanica var. brevifolia Boiss. & Balansa", nvn.getTitleCache());
|
1484
|
Assert.assertEquals("If this line reached everything should be ok", "Scorzonera", nvn.getGenusOrUninomial());
|
1485
|
|
1486
|
String unparsable = "Taraxacum nevskii L., Trudy Bot. Inst. Nauk S.S.S.R., Ser. 1, Fl. Sist. Vyssh. Rast. 4: 293. 1937.";
|
1487
|
// String unparsableA = "Taraxacum nevskii L. in Trudy Bot. Inst. Nauk: 293. 1937.";
|
1488
|
nvn = this.parser.parseReferencedName(unparsable, ICNAFP, null);
|
1489
|
Assert.assertEquals("Titlecache", "Taraxacum nevskii L.", nvn.getTitleCache());
|
1490
|
Assert.assertEquals("If this line reached everything should be ok", "Taraxacum", nvn.getGenusOrUninomial());
|
1491
|
parsingProblem = nvn.getParsingProblem();
|
1492
|
Assert.assertEquals("Name should no warnings or errors", 0, parsingProblem);
|
1493
|
|
1494
|
String unparsable2 = "Hieracium pxxx Dahlst., Kongl. Svenska Vetensk. Acad. Handl. ser. 2, 26(3): 255. 1894";
|
1495
|
// String unparsable2A = "Hieracium pxxx Dahlst., Kongl Svenska Vetensk Acad Handl, 26: 255. 1894.";
|
1496
|
nvn = this.parser.parseReferencedName(unparsable2, ICNAFP, null);
|
1497
|
Assert.assertEquals("Titlecache", "Hieracium pxxx Dahlst.", nvn.getTitleCache());
|
1498
|
Assert.assertEquals("If this line reached everything should be ok", "Hieracium", nvn.getGenusOrUninomial());
|
1499
|
parsingProblem = nvn.getParsingProblem();
|
1500
|
Assert.assertEquals("Name should no warnings or errors", 0, parsingProblem);
|
1501
|
|
1502
|
|
1503
|
String again = "Adiantum emarginatum Bory ex. Willd., Species Plantarum, ed. 4,5,1: 449,450. 1810";
|
1504
|
nvn = this.parser.parseReferencedName(again, ICNAFP, null);
|
1505
|
Assert.assertEquals("Titlecache", "Adiantum emarginatum Bory ex Willd.", nvn.getTitleCache());
|
1506
|
Assert.assertEquals("If this line reached everything should be ok", "Adiantum", nvn.getGenusOrUninomial());
|
1507
|
|
1508
|
}
|
1509
|
|
1510
|
@Test
|
1511
|
public final void testSeriesPart(){
|
1512
|
Pattern seriesPattern = Pattern.compile(NonViralNameParserImplRegExBase.pSeriesPart);
|
1513
|
Matcher matcher = seriesPattern.matcher("ser. 2");
|
1514
|
Assert.assertTrue("", matcher.matches());
|
1515
|
}
|
1516
|
|
1517
|
/**
|
1518
|
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#fullTeams(java.lang.String)}.
|
1519
|
*/
|
1520
|
@Test
|
1521
|
public final void testFullTeams() {
|
1522
|
logger.warn("Not yet implemented"); // TODO
|
1523
|
}
|
1524
|
|
1525
|
/**
|
1526
|
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#AuthorshipAndEx(java.lang.String)}.
|
1527
|
* @throws StringNotParsableException
|
1528
|
*/
|
1529
|
@Test
|
1530
|
public final void testParseAuthorsTaxonNameString() throws StringNotParsableException {
|
1531
|
NonViralName<?> nvn = ZoologicalName.NewInstance(null);
|
1532
|
parser.parseAuthors(nvn, "Eckweiler & ten Hagen, 2003");
|
1533
|
Team team = (Team)nvn.getCombinationAuthorship();
|
1534
|
Assert.assertNotNull("Comb. author must not be null", team);
|
1535
|
Assert.assertEquals("Must be team with 2 members", 2, team.getTeamMembers().size());
|
1536
|
Assert.assertEquals("Second member must be 'ten Hagen'", "ten Hagen", team.getTeamMembers().get(1).getTitleCache());
|
1537
|
|
1538
|
//Crosson du Cormier, 1964
|
1539
|
ZoologicalName zooName = ZoologicalName.NewInstance(null);
|
1540
|
parser.parseAuthors(zooName, "Crosson du Cormier, 1964");
|
1541
|
Person person = (Person)zooName.getCombinationAuthorship();
|
1542
|
Assert.assertNotNull("Comb. author must not be null", person);
|
1543
|
Assert.assertEquals("Persons title must be 'Crosson du Cormier'", "Crosson du Cormier", person.getTitleCache());
|
1544
|
Assert.assertEquals("Year must be 1964", Integer.valueOf(1964), zooName.getPublicationYear() );
|
1545
|
|
1546
|
//(van der Hoeven, 1839)
|
1547
|
zooName = ZoologicalName.NewInstance(null);
|
1548
|
parser.parseAuthors(zooName, "(van der Hoeven, 1839)");
|
1549
|
Assert.assertNull("Combination author must be null", zooName.getCombinationAuthorship());
|
1550
|
person = (Person)zooName.getBasionymAuthorship();
|
1551
|
Assert.assertNotNull("Basionym author must not be null", person);
|
1552
|
Assert.assertEquals("Persons title must be 'van der Hoeven'", "van der Hoeven", person.getTitleCache());
|
1553
|
Assert.assertEquals("Year must be 1839", Integer.valueOf(1839), zooName.getOriginalPublicationYear() );
|
1554
|
|
1555
|
//le Doux, 1931
|
1556
|
zooName = ZoologicalName.NewInstance(null);
|
1557
|
parser.parseAuthors(zooName, "le Doux, 1931");
|
1558
|
person = (Person)zooName.getCombinationAuthorship();
|
1559
|
Assert.assertNotNull("Comb. author must not be null", person);
|
1560
|
Assert.assertEquals("Persons title must be 'le Doux'", "le Doux", person.getTitleCache());
|
1561
|
Assert.assertEquals("Year must be 1931", Integer.valueOf(1931), zooName.getPublicationYear() );
|
1562
|
|
1563
|
|
1564
|
}
|
1565
|
|
1566
|
@Test //#4764
|
1567
|
public void testParseSection(){
|
1568
|
//this test does not really test problematic cases where sect.idInVoc = "sect." instead of "sect.(bot.)"
|
1569
|
//however, by changing the csv file entry to sect. just for testing it can be used as a functional test
|
1570
|
String sectionNameStr = "Taraxacum sect. Testtaxa M\u00fcller, Incredible Taxa: 12. 2016";
|
1571
|
NonViralName<?> sectionName = parser.parseReferencedName(sectionNameStr, NomenclaturalCode.ICNAFP, null);
|
1572
|
int parsingProblem = sectionName.getParsingProblem();
|
1573
|
Assert.assertEquals("Problem should be 0", 0, parsingProblem);
|
1574
|
Rank rank = sectionName.getRank();
|
1575
|
Assert.assertEquals("", Rank.SECTION_BOTANY(), rank );
|
1576
|
|
1577
|
}
|
1578
|
|
1579
|
@Test //#5072
|
1580
|
public final void testLongRunningParsingCapitals(){
|
1581
|
DateTime start = DateTime.now();
|
1582
|
String nameStr = "Nazeris fujianensis JIAYAO HU, LIZHEN LI, MEIJUN ZHAO,2010"; //name from CoL that created problems
|
1583
|
NonViralName<?> name = parser.parseReferencedName(nameStr, NomenclaturalCode.ICZN, null);
|
1584
|
DateTime end = DateTime.now();
|
1585
|
Duration duration = new Duration(start, end);
|
1586
|
long seconds = duration.getStandardSeconds();
|
1587
|
//this is the critical part of the test that must not be changed
|
1588
|
Assert.assertTrue("Parsing of name should take less then 3 seconds but took " + seconds, seconds < 3);
|
1589
|
|
1590
|
}
|
1591
|
|
1592
|
@Test //#5072
|
1593
|
//http://www.regular-expressions.info/catastrophic.html
|
1594
|
public final void testLongRunningParsing(){
|
1595
|
|
1596
|
//name only
|
1597
|
String nameStr = "Dictyocoela berillonum R.S. Terry, J.E. Sm., R.G. Sharpe, T. Rigaud, D.T.J. Littlewood, J.E. Ironside, D. Rollinson & D. Bou";
|
1598
|
DateTime start = DateTime.now();
|
1599
|
NonViralName<?> name = parser.parseReferencedName(nameStr, NomenclaturalCode.ICNAFP, null);
|
1600
|
DateTime end = DateTime.now();
|
1601
|
Duration duration = new Duration(start, end);
|
1602
|
long seconds = duration.getStandardSeconds();
|
1603
|
//this is the critical part of the test that must not be changed
|
1604
|
Assert.assertTrue("Parsing of name should take less then 3 seconds but took " + seconds, seconds < 3);
|
1605
|
//the following may be discussed
|
1606
|
Assert.assertFalse("Name should parse without problems",name.hasProblem());
|
1607
|
|
1608
|
|
1609
|
//with reference
|
1610
|
nameStr = "Dictyocoela berillonum R.S. Terry, J.E. Sm., R.G. Sharpe, T. Rigaud, D.T.J. Littlewood, J.E. Ironside, D. Rollinson & D. Bou in Species Fauna Atlantica Of Blues Animals 3: p.345. 1758.";
|
1611
|
start = DateTime.now();
|
1612
|
name = parser.parseReferencedName(nameStr, NomenclaturalCode.ICNAFP, null);
|
1613
|
end = DateTime.now();
|
1614
|
duration = new Duration(start, end);
|
1615
|
seconds = duration.getStandardSeconds();
|
1616
|
//this is the critical part of the test that must not be changed
|
1617
|
Assert.assertTrue("Parsing of name should take less then 3 seconds but took " + seconds, seconds < 3);
|
1618
|
//the following may be discussed
|
1619
|
Assert.assertFalse("Name should parse without problems",name.hasProblem());
|
1620
|
}
|
1621
|
|
1622
|
@Test //#5072
|
1623
|
public final void testLongRunningParsingAuthors(){
|
1624
|
//http://www.regular-expressions.info/catastrophic.html
|
1625
|
//
|
1626
|
//Länge des Nachnamens macht keinen Unterschied
|
1627
|
//Anzahl der "AuthorParts scheint entscheidend
|
1628
|
// & am Ende macht es langsamger (16s), als nur ","(6s))
|
1629
|
|
1630
|
String authorStr = "R.S. Terry J.E. Sm. R.G. Sharpe T. Rigaud T.H. Rigseaud D.T. Li, R.G. Sharpe, T. Rigaud, D.T.J. Littlewood & D. Bou";
|
1631
|
TeamOrPersonBase[] authorArray = new TeamOrPersonBase[4];
|
1632
|
try {
|
1633
|
DateTime start = DateTime.now();
|
1634
|
parser.fullAuthors(authorStr, authorArray, new Integer[]{1800, null, null, null}, BotanicalName.class);
|
1635
|
DateTime end = DateTime.now();
|
1636
|
Duration duration = new Duration(start, end);
|
1637
|
long seconds = duration.getStandardSeconds();
|
1638
|
// System.out.println(seconds);
|
1639
|
//this is the critical part of the test that must not be changed
|
1640
|
Assert.assertTrue("Parsing of name should take less then 3 seconds but took " + seconds, seconds < 3);
|
1641
|
} catch (StringNotParsableException e) {
|
1642
|
e.printStackTrace();
|
1643
|
Assert.fail("Authors should be parsable");
|
1644
|
}
|
1645
|
|
1646
|
}
|
1647
|
|
1648
|
|
1649
|
/**
|
1650
|
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#AuthorshipAndEx(java.lang.String)}.
|
1651
|
*/
|
1652
|
@Test
|
1653
|
public final void testAuthorshipAndEx() {
|
1654
|
logger.warn("Not yet implemented"); // TODO
|
1655
|
}
|
1656
|
|
1657
|
/**
|
1658
|
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#Authorship(java.lang.String)}.
|
1659
|
*/
|
1660
|
@Test
|
1661
|
public final void testAuthorship() {
|
1662
|
logger.warn("Not yet implemented"); // TODO
|
1663
|
}
|
1664
|
|
1665
|
/**
|
1666
|
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseCultivar(java.lang.String)}.
|
1667
|
*/
|
1668
|
@Test
|
1669
|
public final void testParseCultivar() {
|
1670
|
logger.warn("Not yet implemented"); // TODO
|
1671
|
}
|
1672
|
|
1673
|
@Test
|
1674
|
public final void testNomenclaturalStatus() {
|
1675
|
BotanicalName name = BotanicalName.NewInstance(Rank.FAMILY(), "Acanthopale", null, null, null, null, null, null, null);
|
1676
|
name.addStatus(NomenclaturalStatus.NewInstance(NomenclaturalStatusType.ALTERNATIVE()));
|
1677
|
BotanicalName name2 = BotanicalName.NewInstance(Rank.FAMILY());
|
1678
|
parser.parseReferencedName(name2, name.getFullTitleCache(), name2.getRank(), true);
|
1679
|
parser.parseReferencedName(name2, name.getFullTitleCache(), name2.getRank(), true);
|
1680
|
Assert.assertEquals("Title cache should be same. No duplication of nom. status should take place", name.getFullTitleCache(), name2.getFullTitleCache());
|
1681
|
}
|
1682
|
|
1683
|
@Test
|
1684
|
public final void testSpecificAuthors(){
|
1685
|
//McVaugh
|
1686
|
NonViralName<?> name = parser.parseFullName("Psidium longipes var. orbiculare (O.Berg) McVaugh");
|
1687
|
Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
|
1688
|
TeamOrPersonBase<?> combinationAuthor = name.getCombinationAuthorship();
|
1689
|
assertEquals( "McVaugh", combinationAuthor.getNomenclaturalTitle());
|
1690
|
TeamOrPersonBase<?> basionymAuthor = name.getBasionymAuthorship();
|
1691
|
assertEquals( "O.Berg", basionymAuthor.getNomenclaturalTitle());
|
1692
|
|
1693
|
// Campanula rhodensis A. DC.
|
1694
|
|
1695
|
}
|
1696
|
|
1697
|
}
|