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