ref #6158 Update documentation from svn to git (cdmlib-print)
[cdmlib.git] / cdmlib-model / src / test / java / eu / etaxonomy / cdm / strategy / parser / NonViralNameParserImplTest.java
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
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 }
690
691 @Test
692 public final void testHybridsRemoval(){
693 //if the parser input already has hybridrelationships they need to be removed
694 //Create input
695 String hybridCache = "Abies alba "+UTF8.HYBRID+" Pinus bus";
696 INonViralName name1 = parser.parseFullName(hybridCache, botanicCode, null);
697 assertFalse("Name must not have parsing problems", name1.hasProblem());
698 assertTrue("", name1.getHybridChildRelations().size() == 2);
699
700 hybridCache = "Abieta albana "+UTF8.HYBRID+" Pinuta custa";
701 boolean makeEmpty = true;
702 parser.parseFullName(name1, hybridCache, Rank.SPECIES(), makeEmpty);
703 assertEquals("After parsing another string there should still be 2 parents, but different ones", 2, name1.getHybridChildRelations().size());
704 assertFalse("Name must not have parsing problems", name1.hasProblem());
705
706
707 hybridCache = "Calendula arvensis Mill.";
708 makeEmpty = true;
709 parser.parseFullName(name1, hybridCache, Rank.SPECIES(), makeEmpty);
710 assertTrue("", name1.getHybridChildRelations().isEmpty());
711 assertFalse("Name must not have parsing problems", name1.hasProblem());
712
713
714 //AND the same for reference parsing
715 hybridCache = "Abies alba "+UTF8.HYBRID+" Pinus bus";
716 name1 = parser.parseReferencedName(hybridCache, botanicCode, null);
717 assertFalse("Name must not have parsing problems", name1.hasProblem());
718 assertTrue("", name1.getHybridChildRelations().size() == 2);
719
720 hybridCache = "Abieta albana "+UTF8.HYBRID+" Pinuta custa";
721 makeEmpty = true;
722 parser.parseReferencedName(name1, hybridCache, Rank.SPECIES(), makeEmpty);
723 assertEquals("After parsing another string there should still be 2 parents, but different ones", 2, name1.getHybridChildRelations().size());
724 assertFalse("Name must not have parsing problems", name1.hasProblem());
725
726
727 hybridCache = "Calendula arvensis Mill.";
728 makeEmpty = true;
729 parser.parseReferencedName(name1, hybridCache, Rank.SPECIES(), makeEmpty);
730 assertTrue("", name1.getHybridChildRelations().isEmpty());
731 assertFalse("Name must not have parsing problems", name1.hasProblem());
732 }
733
734 private void testName_StringNomcodeRank(Method parseMethod)
735 throws InvocationTargetException, IllegalAccessException {
736 INonViralName name1 = (INonViralName)parseMethod.invoke(parser, strNameAbies1, null, Rank.SPECIES());
737 //parser.parseFullName(strNameAbies1, null, Rank.SPECIES());
738 assertEquals("Abies", name1.getGenusOrUninomial());
739 assertEquals("alba", name1.getSpecificEpithet());
740
741 INonViralName nameAuthor = (INonViralName)parseMethod.invoke(parser, strNameAbiesAuthor1, null, Rank.SPECIES());
742 assertEquals("Abies", nameAuthor.getGenusOrUninomial());
743 assertEquals("alba", nameAuthor.getSpecificEpithet());
744 assertEquals("Mueller", nameAuthor.getCombinationAuthorship().getNomenclaturalTitle());
745
746 INonViralName nameBasionymAuthor = (INonViralName)parseMethod.invoke(parser, strNameAbiesBasionymAuthor1, null, Rank.SPECIES());
747 assertEquals("Abies", nameBasionymAuthor.getGenusOrUninomial());
748 assertEquals("alba", nameBasionymAuthor.getSpecificEpithet());
749 assertEquals("D'Mueller", nameBasionymAuthor.getCombinationAuthorship().getNomenclaturalTitle());
750 assertEquals("Ciardelli", nameBasionymAuthor.getBasionymAuthorship().getNomenclaturalTitle());
751
752 INonViralName nameBasionymExAuthor = (INonViralName)parseMethod.invoke(parser, strNameAbiesBasionymExAuthor1, null, Rank.SPECIES());
753 assertEquals("Abies", nameBasionymExAuthor.getGenusOrUninomial());
754 assertEquals("alba", nameBasionymExAuthor.getSpecificEpithet());
755 assertEquals("D'Mueller", nameBasionymExAuthor.getExCombinationAuthorship().getNomenclaturalTitle());
756 assertEquals("de Greuther", nameBasionymExAuthor.getCombinationAuthorship().getNomenclaturalTitle());
757 assertEquals("Ciardelli", nameBasionymExAuthor.getExBasionymAuthorship().getNomenclaturalTitle());
758 assertEquals("Doering", nameBasionymExAuthor.getBasionymAuthorship().getNomenclaturalTitle());
759
760 INonViralName name2 = (INonViralName)parseMethod.invoke(parser, strNameAbiesSub1, null, Rank.SPECIES());
761 assertEquals("Abies", name2.getGenusOrUninomial());
762 assertEquals("alba", name2.getSpecificEpithet());
763 assertEquals("beta", name2.getInfraSpecificEpithet());
764 assertEquals(Rank.SUBSPECIES(), name2.getRank());
765
766
767 // unparseable *********
768 String problemString = "sdfjlös wer eer wer";
769 INonViralName nameProblem = (INonViralName)parseMethod.invoke(parser, problemString, null, Rank.SPECIES());
770 List<ParserProblem> list = nameProblem.getParsingProblems();
771 assertTrue(nameProblem.getParsingProblem()!=0);
772 assertEquals(problemString, nameProblem.getTitleCache());
773 }
774
775
776 /**
777 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseReferencedName(NonViralName, java.lang.String, eu.etaxonomy.cdm.model.name.Rank, boolean)(, )}.
778 */
779 @Test
780 public final void testParseNomStatus() {
781 //nom. ambig.
782 String strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. ambig.";
783 INonViralName nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
784 assertFullRefStandard(nameTestStatus);
785 assertTrue(nameTestStatus.getStatus().size()== 1);
786 assertEquals( NomenclaturalStatusType.AMBIGUOUS(), nameTestStatus.getStatus().iterator().next().getType());
787
788 //nom. inval.
789 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. inval.";
790 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
791 assertFullRefStandard(nameTestStatus);
792 assertTrue(nameTestStatus.getStatus().size()== 1);
793 assertEquals( NomenclaturalStatusType.INVALID(), nameTestStatus.getStatus().iterator().next().getType());
794
795 //nom. dub.
796 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. dub.";
797 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
798 assertFullRefStandard(nameTestStatus);
799 assertTrue(nameTestStatus.getStatus().size()== 1);
800 assertEquals( NomenclaturalStatusType.DOUBTFUL(), nameTestStatus.getStatus().iterator().next().getType());
801
802 //nom. confus.
803 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. confus.";
804 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
805 assertFullRefStandard(nameTestStatus);
806 assertTrue(nameTestStatus.getStatus().size()== 1);
807 assertEquals( NomenclaturalStatusType.CONFUSUM(), nameTestStatus.getStatus().iterator().next().getType());
808
809 //nom. illeg.
810 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. illeg.";
811 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
812 assertFullRefStandard(nameTestStatus);
813 assertTrue(nameTestStatus.getStatus().size()== 1);
814 assertEquals( NomenclaturalStatusType.ILLEGITIMATE(), nameTestStatus.getStatus().iterator().next().getType());
815
816 //nom. superfl.
817 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. superfl.";
818 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
819 assertFullRefStandard(nameTestStatus);
820 assertTrue(nameTestStatus.getStatus().size()== 1);
821 assertEquals( NomenclaturalStatusType.SUPERFLUOUS(), nameTestStatus.getStatus().iterator().next().getType());
822
823 //nom. rej.
824 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. rej.";
825 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
826 assertFullRefStandard(nameTestStatus);
827 assertTrue(nameTestStatus.getStatus().size()== 1);
828 assertEquals( NomenclaturalStatusType.REJECTED(), nameTestStatus.getStatus().iterator().next().getType());
829
830 //nom. utique rej.
831 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. utique rej.";
832 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
833 assertFullRefStandard(nameTestStatus);
834 assertTrue(nameTestStatus.getStatus().size()== 1);
835 assertEquals( NomenclaturalStatusType.UTIQUE_REJECTED(), nameTestStatus.getStatus().iterator().next().getType());
836
837 //nom. cons. prop.
838 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. cons. prop.";
839 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
840 assertFullRefStandard(nameTestStatus);
841 assertTrue(nameTestStatus.getStatus().size()== 1);
842 assertEquals( NomenclaturalStatusType.CONSERVED_PROP(), nameTestStatus.getStatus().iterator().next().getType());
843
844 //nom. orth. cons. prop.
845 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. orth. cons. prop.";
846 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
847 assertFullRefStandard(nameTestStatus);
848 assertTrue(nameTestStatus.getStatus().size()== 1);
849 assertEquals( NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED_PROP(), nameTestStatus.getStatus().iterator().next().getType());
850
851 //nom. cons. prop.
852 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. cons. des.";
853 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
854 assertFullRefStandard(nameTestStatus);
855 assertTrue(nameTestStatus.getStatus().size()== 1);
856 assertEquals( NomenclaturalStatusType.CONSERVED_DESIG(), nameTestStatus.getStatus().iterator().next().getType());
857
858 //nom. legit.
859 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. legit.";
860 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
861 assertFullRefStandard(nameTestStatus);
862 assertTrue(nameTestStatus.getStatus().size()== 1);
863 assertEquals( NomenclaturalStatusType.LEGITIMATE(), nameTestStatus.getStatus().iterator().next().getType());
864
865 //nom. altern.
866 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. altern.";
867 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
868 assertFullRefStandard(nameTestStatus);
869 assertTrue(nameTestStatus.getStatus().size()== 1);
870 assertEquals( NomenclaturalStatusType.ALTERNATIVE(), nameTestStatus.getStatus().iterator().next().getType());
871
872 //nom. alternativ.
873 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. alternativ.";
874 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
875 assertFullRefStandard(nameTestStatus);
876 assertTrue(nameTestStatus.getStatus().size()== 1);
877 assertEquals( NomenclaturalStatusType.ALTERNATIVE(), nameTestStatus.getStatus().iterator().next().getType());
878
879 //nom. nov.
880 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. nov.";
881 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
882 assertFullRefStandard(nameTestStatus);
883 assertTrue(nameTestStatus.getStatus().size()== 1);
884 assertEquals( NomenclaturalStatusType.NOVUM(), nameTestStatus.getStatus().iterator().next().getType());
885
886 //nom. utique rej. prop.
887 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. utique rej. prop.";
888 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
889 assertFullRefStandard(nameTestStatus);
890 assertTrue(nameTestStatus.getStatus().size()== 1);
891 assertEquals( NomenclaturalStatusType.UTIQUE_REJECTED_PROP(), nameTestStatus.getStatus().iterator().next().getType());
892
893 //nom. orth. cons.
894 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. orth. cons.";
895 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
896 assertFullRefStandard(nameTestStatus);
897 assertTrue(nameTestStatus.getStatus().size()== 1);
898 assertEquals( NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED(), nameTestStatus.getStatus().iterator().next().getType());
899
900 //nom. rej. prop.
901 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. rej. prop.";
902 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
903 assertFullRefStandard(nameTestStatus);
904 assertTrue(nameTestStatus.getStatus().size()== 1);
905 assertEquals( NomenclaturalStatusType.REJECTED_PROP(), nameTestStatus.getStatus().iterator().next().getType());
906
907 //nom. cons.
908 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. cons.";
909 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
910 assertFullRefStandard(nameTestStatus);
911 assertTrue(nameTestStatus.getStatus().size()== 1);
912 assertEquals( NomenclaturalStatusType.CONSERVED(), nameTestStatus.getStatus().iterator().next().getType());
913
914 //nom. sanct.
915 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. sanct.";
916 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
917 assertFullRefStandard(nameTestStatus);
918 assertTrue(nameTestStatus.getStatus().size()== 1);
919 assertEquals( NomenclaturalStatusType.SANCTIONED(), nameTestStatus.getStatus().iterator().next().getType());
920
921 //nom. nud.
922 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. nud.";
923 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
924 assertFullRefStandard(nameTestStatus);
925 assertTrue(nameTestStatus.getStatus().size()== 1);
926 assertEquals( NomenclaturalStatusType.NUDUM(), nameTestStatus.getStatus().iterator().next().getType());
927
928 //comb. inval.
929 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, comb. inval.";
930 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
931 assertFullRefStandard(nameTestStatus);
932 assertTrue(nameTestStatus.getStatus().size()== 1);
933 assertEquals( NomenclaturalStatusType.COMBINATION_INVALID(), nameTestStatus.getStatus().iterator().next().getType());
934
935 //comb. illeg.
936 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, comb. illeg.";
937 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
938 assertFullRefStandard(nameTestStatus);
939 assertTrue(nameTestStatus.getStatus().size()== 1);
940 assertEquals( NomenclaturalStatusType.COMBINATION_ILLEGITIMATE(), nameTestStatus.getStatus().iterator().next().getType());
941
942 //nom. provis.
943 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. provis.";
944 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
945 assertFullRefStandard(nameTestStatus);
946 assertTrue(nameTestStatus.getStatus().size()== 1);
947 assertEquals( NomenclaturalStatusType.PROVISIONAL(), nameTestStatus.getStatus().iterator().next().getType());
948
949 //nom. valid
950 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. valid";
951 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
952 assertFullRefStandard(nameTestStatus);
953 assertTrue(nameTestStatus.getStatus().size()== 1);
954 assertEquals( NomenclaturalStatusType.VALID(), nameTestStatus.getStatus().iterator().next().getType());
955
956 //nom. subnud.
957 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. subnud.";
958 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
959 assertFullRefStandard(nameTestStatus);
960 assertTrue(nameTestStatus.getStatus().size()== 1);
961 assertEquals( NomenclaturalStatusType.SUBNUDUM(), nameTestStatus.getStatus().iterator().next().getType());
962
963 //opus. utique oppr.
964 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, opus. utique oppr.";
965 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
966 assertFullRefStandard(nameTestStatus);
967 assertTrue(nameTestStatus.getStatus().size()== 1);
968 assertEquals( NomenclaturalStatusType.OPUS_UTIQUE_OPPR(), nameTestStatus.getStatus().iterator().next().getType());
969
970 //comb. nov.
971 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, comb. nov.";
972 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
973 assertFullRefStandard(nameTestStatus);
974 assertTrue(nameTestStatus.getStatus().size()== 1);
975 assertEquals( NomenclaturalStatusType.COMB_NOV(), nameTestStatus.getStatus().iterator().next().getType());
976
977 //orth. rej.
978 strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, orth. rej.";
979 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
980 assertFullRefStandard(nameTestStatus);
981 assertTrue(nameTestStatus.getStatus().size()== 1);
982 assertEquals( NomenclaturalStatusType.ORTHOGRAPHY_REJECTED(), nameTestStatus.getStatus().iterator().next().getType());
983
984 //ined.
985 strTestStatus = "Houstonia macvaughii (Terrell), ined.";
986 nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
987 assertEquals("Houstonia", nameTestStatus.getGenusOrUninomial());
988 assertEquals("macvaughii", nameTestStatus.getSpecificEpithet());
989 assertEquals("(Terrell)", nameTestStatus.getAuthorshipCache());
990 assertEquals(1, nameTestStatus.getStatus().size());
991 assertEquals( NomenclaturalStatusType.INED(), nameTestStatus.getStatus().iterator().next().getType());
992
993 //not yet parsed "not avail."
994 }
995
996 /**
997 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseReferencedName(NonViralName, java.lang.String, eu.etaxonomy.cdm.model.name.Rank, boolean)(, )}.
998 */
999 @Test
1000 public final void testParseReferencedName() {
1001 try {
1002 Method parseMethod = parser.getClass().getDeclaredMethod("parseReferencedName", String.class, NomenclaturalCode.class, Rank.class);
1003 testName_StringNomcodeRank(parseMethod);
1004 } catch (Exception e) {
1005 e.printStackTrace();
1006 assertTrue(false);
1007 }
1008
1009
1010 //null
1011 String strNull = null;
1012 Rank rankSpecies = Rank.SPECIES();
1013 INonViralName nameNull = parser.parseReferencedName(strNull, null, rankSpecies);
1014 assertNull(nameNull);
1015
1016 //Empty
1017 String strEmpty = "";
1018 INonViralName nameEmpty = parser.parseReferencedName(strEmpty, null, rankSpecies);
1019 assertFalse(nameEmpty.hasProblem());
1020 assertEquals(strEmpty, nameEmpty.getFullTitleCache());
1021 assertNull(nameEmpty.getNomenclaturalMicroReference());
1022
1023
1024 //Whitespaces
1025 String strFullWhiteSpcaceAndDot = "Abies alba Mill., Sp. Pl. 4: 455 . 1987 .";
1026 INonViralName namefullWhiteSpcaceAndDot = parser.parseReferencedName(strFullWhiteSpcaceAndDot, null, rankSpecies);
1027 assertFullRefStandard(namefullWhiteSpcaceAndDot);
1028 assertTrue(((Reference)namefullWhiteSpcaceAndDot.getNomenclaturalReference()).getType().equals(eu.etaxonomy.cdm.model.reference.ReferenceType.Book));
1029 assertEquals( "Abies alba Mill., Sp. Pl. 4: 455. 1987", namefullWhiteSpcaceAndDot.getFullTitleCache());
1030
1031 //Book
1032 String fullReference = "Abies alba Mill., Sp. Pl. 4: 455. 1987";
1033 INonViralName name1 = parser.parseReferencedName(fullReference, null, rankSpecies);
1034 assertFullRefStandard(name1);
1035 assertTrue(((Reference)name1.getNomenclaturalReference()).getType().equals(eu.etaxonomy.cdm.model.reference.ReferenceType.Book));
1036 assertEquals(fullReference, name1.getFullTitleCache());
1037 assertTrue("Name author and reference author should be the same", name1.getCombinationAuthorship() == ((Reference)name1.getNomenclaturalReference()).getAuthorship());
1038
1039 //Book Section
1040 fullReference = "Abies alba Mill. in Otto, Sp. Pl. 4(6): 455. 1987";
1041 INonViralName name2 = parser.parseReferencedName(fullReference + ".", null, rankSpecies);
1042 assertFullRefNameStandard(name2);
1043 assertEquals(fullReference, name2.getFullTitleCache());
1044 assertFalse(name2.hasProblem());
1045 INomenclaturalReference ref = name2.getNomenclaturalReference();
1046 assertEquals(ReferenceType.BookSection, ((Reference)ref).getType());
1047 IBookSection bookSection = (IBookSection) ref;
1048 IBook inBook = bookSection.getInBook();
1049 assertNotNull(inBook);
1050 assertNotNull(inBook.getAuthorship());
1051 assertEquals("Otto", inBook.getAuthorship().getTitleCache());
1052 assertEquals("Otto, Sp. Pl. 4(6)", inBook.getTitleCache());
1053 assertEquals("Sp. Pl.", inBook.getAbbrevTitle());
1054 assertEquals("4(6)", inBook.getVolume());
1055 assertTrue("Name author and reference author should be the same", name2.getCombinationAuthorship() == ((Reference)name2.getNomenclaturalReference()).getAuthorship());
1056
1057 //Article
1058 fullReference = "Abies alba Mill. in Sp. Pl. 4(6): 455. 1987";
1059 INonViralName name3 = parser.parseReferencedName(fullReference, null, rankSpecies);
1060 assertFullRefNameStandard(name3);
1061 name3.setTitleCache(null);
1062 assertEquals(fullReference, name3.getFullTitleCache());
1063 assertFalse(name3.hasProblem());
1064 ref = name3.getNomenclaturalReference();
1065 assertEquals(eu.etaxonomy.cdm.model.reference.ReferenceType.Article, ref.getType());
1066 //Article article = (Article)ref;
1067 IJournal journal = ((IArticle)ref).getInJournal();
1068 assertNotNull(journal);
1069 //assertEquals("Sp. Pl. 4(6)", inBook.getTitleCache());
1070 assertEquals("Sp. Pl.",((Reference) journal).getTitleCache());
1071 assertEquals("Sp. Pl.", journal.getAbbrevTitle());
1072 assertEquals("4(6)",((IArticle)ref).getVolume());
1073 assertTrue("Name author and reference author should be the same", name3.getCombinationAuthorship() == name3.getNomenclaturalReference().getAuthorship());
1074
1075 //Article with volume range
1076 fullReference = "Abies alba Mill. in Sp. Pl. 4(1-2): 455. 1987";
1077 INonViralName name3a = parser.parseReferencedName(fullReference, null, rankSpecies);
1078 name3a.setTitleCache(null);
1079 assertEquals(fullReference, name3a.getFullTitleCache());
1080 assertFalse(name3a.hasProblem());
1081 ref = name3a.getNomenclaturalReference();
1082 assertEquals(eu.etaxonomy.cdm.model.reference.ReferenceType.Article, ref.getType());
1083 assertEquals("4(1-2)",((IArticle)ref).getVolume());
1084
1085 //SoftArticle - having "," on position > 4
1086 String journalTitle = "Bull. Soc. Bot.France. Louis., Roi";
1087 String yearPart = " 1987 - 1989";
1088 String parsedYear = "1987-1989";
1089 String fullReferenceWithoutYear = "Abies alba Mill. in " + journalTitle + " 4(6): 455.";
1090 fullReference = fullReferenceWithoutYear + yearPart;
1091 String fullReferenceWithEnd = fullReference + ".";
1092 INonViralName name4 = parser.parseReferencedName(fullReferenceWithEnd, null, rankSpecies);
1093 assertFalse(name4.hasProblem());
1094 assertFullRefNameStandard(name4);
1095 assertEquals(fullReferenceWithoutYear + " " + parsedYear, name4.getFullTitleCache());
1096 ref = name4.getNomenclaturalReference();
1097 assertEquals(ReferenceType.Article, ref.getType());
1098 //article = (Article)ref;
1099 assertEquals(parsedYear, ref.getYear());
1100 journal = ((IArticle)ref).getInJournal();
1101 assertNotNull(journal);
1102 assertEquals(journalTitle, ((Reference) journal).getTitleCache());
1103 assertEquals(journalTitle, journal.getAbbrevTitle());
1104 assertEquals("4(6)", ((IArticle)ref).getVolume());
1105
1106 //Zoo name
1107 String strNotParsableZoo = "Abies alba M., 1923, Sp. P. xxwer4352, nom. inval.";
1108 IZoologicalName nameZooRefNotParsabel = parser.parseReferencedName(strNotParsableZoo, null, null);
1109 assertTrue(nameZooRefNotParsabel.hasProblem());
1110 List<ParserProblem> list = nameZooRefNotParsabel.getParsingProblems();
1111 assertTrue("List must contain detail and year warning ", list.contains(ParserProblem.CheckDetailOrYear));
1112 assertEquals(21, nameZooRefNotParsabel.getProblemStarts());
1113 assertEquals(37, nameZooRefNotParsabel.getProblemEnds());
1114 assertTrue(nameZooRefNotParsabel.getNomenclaturalReference().hasProblem());
1115 list = nameZooRefNotParsabel.getNomenclaturalReference().getParsingProblems();
1116 assertTrue("List must contain detail and year warning ", list.contains(ParserProblem.CheckDetailOrYear));
1117
1118 assertEquals(NomenclaturalCode.ICZN, nameZooRefNotParsabel.getNomenclaturalCode());
1119 assertEquals(Integer.valueOf(1923), nameZooRefNotParsabel.getPublicationYear());
1120 assertEquals(1, nameZooRefNotParsabel.getStatus().size());
1121
1122 String strZooNameSineYear = "Homo sapiens L., 1758, Sp. An. 3: 345";
1123 IZoologicalName nameZooNameSineYear = parser.parseReferencedName(strZooNameSineYear);
1124 assertFalse(nameZooNameSineYear.hasProblem());
1125 assertEquals("Name without reference year must have year", (Integer)1758, nameZooNameSineYear.getPublicationYear());
1126 assertEquals("Name without reference year must have year", "1758", nameZooNameSineYear.getNomenclaturalReference().getYear());
1127
1128 String strZooNameNewCombination = "Homo sapiens (L., 1758) Mill., 1830, Sp. An. 3: 345";
1129 IZoologicalName nameZooNameNewCombination = parser.parseReferencedName(strZooNameNewCombination);
1130 assertTrue(nameZooNameNewCombination.hasProblem());
1131 list = nameZooNameNewCombination.getParsingProblems();
1132 assertTrue("List must contain new combination has publication warning ", list.contains(ParserProblem.NewCombinationHasPublication));
1133 assertEquals(35, nameZooNameNewCombination.getProblemStarts());
1134 assertEquals(51, nameZooNameNewCombination.getProblemEnds());
1135
1136
1137 //Special MicroRefs
1138 String strSpecDetail1 = "Abies alba Mill. in Sp. Pl. 4(6): [455]. 1987";
1139 INonViralName nameSpecDet1 = parser.parseReferencedName(strSpecDetail1 + ".", null, rankSpecies);
1140 assertFalse(nameSpecDet1.hasProblem());
1141 assertEquals(strSpecDetail1, nameSpecDet1.getFullTitleCache());
1142 assertEquals("[455]", nameSpecDet1.getNomenclaturalMicroReference());
1143
1144 //Special MicroRefs
1145 String strSpecDetail2 = "Abies alba Mill. in Sp. Pl. 4(6): couv. 2. 1987";
1146 INonViralName nameSpecDet2 = parser.parseReferencedName(strSpecDetail2 + ".", null, rankSpecies);
1147 assertFalse(nameSpecDet2.hasProblem());
1148 assertEquals(strSpecDetail2, nameSpecDet2.getFullTitleCache());
1149 assertEquals("couv. 2", nameSpecDet2.getNomenclaturalMicroReference());
1150
1151 //Special MicroRefs
1152 String strSpecDetail3 = "Abies alba Mill. in Sp. Pl. 4(6): fig. 455. 1987";
1153 INonViralName nameSpecDet3 = parser.parseReferencedName(strSpecDetail3 + ".", null, rankSpecies);
1154 assertFalse(nameSpecDet3.hasProblem());
1155 assertEquals(strSpecDetail3, nameSpecDet3.getFullTitleCache());
1156 assertEquals("fig. 455", nameSpecDet3.getNomenclaturalMicroReference());
1157
1158 //Special MicroRefs
1159 String strSpecDetail4 = "Abies alba Mill. in Sp. Pl. 4(6): fig. 455-567. 1987";
1160 fullReference = strSpecDetail4 + ".";
1161 INonViralName nameSpecDet4 = parser.parseReferencedName(fullReference, null, rankSpecies);
1162 assertFalse(nameSpecDet4.hasProblem());
1163 assertEquals(strSpecDetail4, nameSpecDet4.getFullTitleCache());
1164 assertEquals("fig. 455-567", nameSpecDet4.getNomenclaturalMicroReference());
1165
1166
1167 //Special MicroRefs
1168 String strSpecDetail5 = "Abies alba Mill. in Sp. Pl. 4(6): Gard n\u00B0 4. 1987";
1169 fullReference = strSpecDetail5 + ".";
1170 INonViralName nameSpecDet5 = parser.parseReferencedName(fullReference, null, rankSpecies);
1171 assertFalse(nameSpecDet5.hasProblem());
1172 assertEquals(strSpecDetail5, nameSpecDet5.getFullTitleCache());
1173 assertEquals("Gard n\u00B0 4", nameSpecDet5.getNomenclaturalMicroReference());
1174
1175 //Special MicroRefs
1176 String strSpecDetail6 = "Abies alba Mill. in Sp. Pl. 4(6): 455a. 1987";
1177 fullReference = strSpecDetail6 + ".";
1178 INonViralName nameSpecDet6 = parser.parseReferencedName(fullReference, null, rankSpecies);
1179 assertFalse(nameSpecDet6.hasProblem());
1180 assertEquals(strSpecDetail6, nameSpecDet6.getFullTitleCache());
1181 assertEquals("455a", nameSpecDet6.getNomenclaturalMicroReference());
1182
1183 //Special MicroRefs
1184 String strSpecDetail7 = "Abies alba Mill. in Sp. Pl. 4(6): pp.455-457. 1987";
1185 fullReference = strSpecDetail7 + ".";
1186 INonViralName nameSpecDet7 = parser.parseReferencedName(fullReference, null, rankSpecies);
1187 assertFalse(nameSpecDet7.hasProblem());
1188 assertEquals(strSpecDetail7, nameSpecDet7.getFullTitleCache());
1189 assertEquals("pp.455-457", nameSpecDet7.getNomenclaturalMicroReference());
1190
1191 //Special MicroRefs
1192 String strSpecDetail8 = "Abies alba Mill. in Sp. Pl. 4(6): ppp.455-457. 1987";
1193 INonViralName nameSpecDet8 = parser.parseReferencedName(strSpecDetail8, null, rankSpecies);
1194 assertTrue(nameSpecDet8.hasProblem());
1195 assertEquals(20, nameSpecDet8.getProblemStarts()); //TODO better start behind :
1196 assertEquals(51, nameSpecDet8.getProblemEnds()); //TODO better stop after -457
1197
1198
1199 //Special MicroRefs
1200 String strSpecDetail9 = "Abies alba Mill. in Sp. Pl. 4(6): pp. 455 - 457. 1987";
1201 INonViralName nameSpecDet9 = parser.parseReferencedName(strSpecDetail9, null, rankSpecies);
1202 assertFalse(nameSpecDet9.hasProblem());
1203 assertEquals(strSpecDetail9, nameSpecDet9.getFullTitleCache());
1204 assertEquals("pp. 455 - 457", nameSpecDet9.getNomenclaturalMicroReference());
1205
1206 //Special MicroRefs
1207 String strSpecDetail10 = "Abies alba Mill. in Sp. Pl. 4(6): p 455. 1987";
1208 INonViralName nameSpecDet10 = parser.parseReferencedName(strSpecDetail10, null, rankSpecies);
1209 assertFalse(nameSpecDet10.hasProblem());
1210 assertEquals(strSpecDetail10, nameSpecDet10.getFullTitleCache());
1211 assertEquals("p 455", nameSpecDet10.getNomenclaturalMicroReference());
1212
1213 //Special MicroRefs
1214 String strSpecDetail11 = "Abies alba Mill. in Sp. Pl. 4(6): p. 455 - 457. 1987";
1215 INonViralName nameSpecDet11 = parser.parseReferencedName(strSpecDetail11, null, rankSpecies);
1216 assertTrue(nameSpecDet11.hasProblem());
1217 list = nameSpecDet11.getParsingProblems();
1218 assertTrue("Problem is Detail. Must be pp.", list.contains(ParserProblem.CheckDetailOrYear));
1219 assertEquals(20, nameSpecDet8.getProblemStarts()); //TODO better start behind :
1220 assertEquals(51, nameSpecDet8.getProblemEnds()); //TODO better stop after - 457
1221
1222
1223 //no volume, no edition
1224 String strNoVolume = "Abies alba Mill., Sp. Pl.: 455. 1987";
1225 INonViralName nameNoVolume = parser.parseReferencedName(strNoVolume, null, rankSpecies);
1226 assertFalse(nameNoVolume.hasProblem());
1227 assertEquals(strNoVolume, nameNoVolume.getFullTitleCache());
1228 assertEquals(null, ((IVolumeReference)(nameNoVolume.getNomenclaturalReference())).getVolume());
1229 assertEquals(null, ((IBook)nameNoVolume.getNomenclaturalReference()).getEdition());
1230
1231 //volume, no edition
1232 strNoVolume = "Abies alba Mill., Sp. Pl. 2: 455. 1987";
1233 nameNoVolume = parser.parseReferencedName(strNoVolume, null, rankSpecies);
1234 assertFalse(nameNoVolume.hasProblem());
1235 assertEquals(strNoVolume, nameNoVolume.getFullTitleCache());
1236 assertEquals("2", ((IVolumeReference)(nameNoVolume.getNomenclaturalReference())).getVolume());
1237 assertEquals(null, ((IBook)(nameNoVolume.getNomenclaturalReference())).getEdition());
1238
1239 //no volume, edition
1240 strNoVolume = "Abies alba Mill., Sp. Pl., ed. 3: 455. 1987";
1241 nameNoVolume = parser.parseReferencedName(strNoVolume, null, rankSpecies);
1242 assertFalse(nameNoVolume.hasProblem());
1243 assertEquals(strNoVolume, nameNoVolume.getFullTitleCache());
1244 assertEquals(null, ((IVolumeReference)(nameNoVolume.getNomenclaturalReference())).getVolume());
1245 assertEquals("3", ((IBook)(nameNoVolume.getNomenclaturalReference())).getEdition());
1246
1247 //volume, edition
1248 strNoVolume = "Abies alba Mill., Sp. Pl. ed. 3, 4(5): 455. 1987";
1249 nameNoVolume = parser.parseReferencedName(strNoVolume, null, rankSpecies);
1250 assertFalse(nameNoVolume.hasProblem());
1251 assertEquals(strNoVolume.replace(" ed.", ", ed."), nameNoVolume.getFullTitleCache());
1252 assertEquals("4(5)", ((IVolumeReference)(nameNoVolume.getNomenclaturalReference())).getVolume());
1253 assertEquals("3", ((IBook)(nameNoVolume.getNomenclaturalReference())).getEdition());
1254
1255 String strUnparsableInRef = "Abies alba Mill. in -er46: 455. 1987";
1256 INonViralName nameUnparsableInRef = parser.parseReferencedName(strUnparsableInRef, null, rankSpecies);
1257 assertTrue(nameUnparsableInRef.hasProblem());
1258 list = nameUnparsableInRef.getParsingProblems();
1259 assertTrue("Unparsable title", list.contains(ParserProblem.UnparsableReferenceTitle));
1260 assertEquals(strUnparsableInRef, nameUnparsableInRef.getFullTitleCache());
1261 assertEquals(20, nameUnparsableInRef.getProblemStarts());
1262 assertEquals(25, nameUnparsableInRef.getProblemEnds());
1263
1264
1265 //volume, edition
1266 String strNoSeparator = "Abies alba Mill. Sp. Pl. ed. 3, 4(5): 455. 1987";
1267 INonViralName nameNoSeparator = parser.parseReferencedName(strNoSeparator, ICNAFP, rankSpecies);
1268 assertTrue(nameNoSeparator.hasProblem());
1269 list = nameNoSeparator.getParsingProblems();
1270 assertTrue("Problem is missing name-reference separator", list.contains(ParserProblem.NameReferenceSeparation));
1271 assertEquals(strNoSeparator, nameNoSeparator.getFullTitleCache());
1272 assertEquals(10, nameNoSeparator.getProblemStarts()); //TODO better start behind Mill. (?)
1273 assertEquals(47, nameNoSeparator.getProblemEnds()); //TODO better stop before :
1274
1275 String strUnparsableInRef2 = "Hieracium pepsicum L., My Bookkkk 1. 1903";
1276 INonViralName nameUnparsableInRef2 = parser.parseReferencedName(strUnparsableInRef2, null, rankSpecies);
1277 assertTrue(nameUnparsableInRef2.hasProblem());
1278 list = nameUnparsableInRef2.getParsingProblems();
1279 assertTrue("Problem detail", list.contains(ParserProblem.CheckDetailOrYear));
1280 assertEquals(strUnparsableInRef2, nameUnparsableInRef2.getFullTitleCache());
1281 assertEquals(23, nameUnparsableInRef2.getProblemStarts());
1282 assertEquals(41, nameUnparsableInRef2.getProblemEnds());
1283
1284
1285 String strUnparsableInRef3 = "Hieracium pespcim N., My Bookkkk 1. 1902";
1286 INonViralName nameUnparsableInRef3 = parser.parseReferencedName(strUnparsableInRef3, null, null);
1287 assertTrue(nameUnparsableInRef3.hasProblem());
1288 list = nameUnparsableInRef3.getParsingProblems();
1289 assertTrue("Problem detail", list.contains(ParserProblem.CheckDetailOrYear));
1290 assertEquals(strUnparsableInRef3, nameUnparsableInRef3.getFullTitleCache());
1291 assertEquals(22, nameUnparsableInRef3.getProblemStarts());
1292 assertEquals(40, nameUnparsableInRef3.getProblemEnds());
1293
1294 String strUnparsableInRef4 = "Hieracium pepsicum (Hsllreterto) L., My Bookkkk 1. 1903";
1295 INonViralName nameUnparsableInRef4 = parser.parseReferencedName(strUnparsableInRef4, null, null);
1296 assertTrue(nameUnparsableInRef4.hasProblem());
1297 list = nameUnparsableInRef4.getParsingProblems();
1298 assertTrue("Problem detail", list.contains(ParserProblem.CheckDetailOrYear));
1299 assertEquals(strUnparsableInRef4, nameUnparsableInRef4.getFullTitleCache());
1300 assertEquals(37, nameUnparsableInRef4.getProblemStarts());
1301 assertEquals(55, nameUnparsableInRef4.getProblemEnds());
1302
1303 String strSameName = "Hieracium pepcum (Hsllreterto) L., My Bokkk 1. 1903";
1304 INonViralName nameSameName = nameUnparsableInRef4;
1305 parser.parseReferencedName(nameSameName, strSameName, null, true);
1306 assertTrue(nameSameName.hasProblem());
1307 list = nameSameName.getParsingProblems();
1308 assertTrue("Problem detail", list.contains(ParserProblem.CheckDetailOrYear));
1309 assertEquals(strSameName, nameSameName.getFullTitleCache());
1310 assertEquals(35, nameSameName.getProblemStarts());
1311 assertEquals(51, nameSameName.getProblemEnds());
1312
1313 String strGenusUnparse = "Hieracium L., jlklk";
1314 INonViralName nameGenusUnparse =
1315 parser.parseReferencedName(strGenusUnparse, null, null);
1316 assertTrue(nameGenusUnparse.hasProblem());
1317 list = nameGenusUnparse.getParsingProblems();
1318 assertTrue("Problem detail", list.contains(ParserProblem.CheckDetailOrYear));
1319 assertTrue("Problem uninomial", list.contains(ParserProblem.CheckRank));
1320 assertEquals(strGenusUnparse, nameGenusUnparse.getFullTitleCache());
1321 assertEquals(0, nameGenusUnparse.getProblemStarts());
1322 assertEquals(19, nameGenusUnparse.getProblemEnds());
1323
1324 String strGenusUnparse2 = "Hieracium L., Per Luigi: 44. 1987";
1325 INonViralName nameGenusUnparse2 =
1326 parser.parseReferencedName(strGenusUnparse2, null, Rank.FAMILY());
1327 assertFalse(nameGenusUnparse2.hasProblem());
1328 assertEquals(strGenusUnparse2, nameGenusUnparse2.getFullTitleCache());
1329 assertEquals(-1, nameGenusUnparse2.getProblemStarts());
1330 assertEquals(-1, nameGenusUnparse2.getProblemEnds());
1331
1332 String strBookSection2 = "Hieracium vulgatum subsp. acuminatum (Jord.) Zahn in Schinz & Keller, Fl. Schweiz, ed. 2, 2: 288. 1905-1907";
1333 String strBookSection2NoComma = "Hieracium vulgatum subsp. acuminatum (Jord.) Zahn in Schinz & Keller, Fl. Schweiz ed. 2, 2: 288. 1905-1907";
1334 INonViralName nameBookSection2 =
1335 parser.parseReferencedName(strBookSection2, null, null);
1336 assertFalse(nameBookSection2.hasProblem());
1337 nameBookSection2.setFullTitleCache(null, false);
1338 assertEquals(strBookSection2NoComma.replace(" ed.", ", ed."), nameBookSection2.getFullTitleCache());
1339 assertEquals(-1, nameBookSection2.getProblemStarts());
1340 assertEquals(-1, nameBookSection2.getProblemEnds());
1341 assertNull((nameBookSection2.getNomenclaturalReference()).getDatePublished().getStart());
1342 assertEquals("1905-1907", ((IBookSection)nameBookSection2.getNomenclaturalReference()).getInBook().getDatePublished().getYear());
1343
1344
1345 String strBookSection = "Hieracium vulgatum subsp. acuminatum (Jord.) Zahn in Schinz & Keller, Fl. Schweiz ed. 2, 2: 288. 1905";
1346 INonViralName nameBookSection =
1347 parser.parseReferencedName(strBookSection, null, null);
1348 assertFalse(nameBookSection.hasProblem());
1349 assertEquals(strBookSection.replace(" ed.", ", ed."), nameBookSection.getFullTitleCache());
1350 assertEquals(-1, nameBookSection.getProblemStarts());
1351 assertEquals(-1, nameBookSection.getProblemEnds());
1352 assertNull(((IBookSection)nameBookSection.getNomenclaturalReference()).getInBook().getDatePublished().getStart());
1353 assertEquals("1905", ((IBookSection)nameBookSection.getNomenclaturalReference()).getDatePublished().getYear());
1354
1355 String strXXXs = "Abies alba, Soer der 1987";
1356 INonViralName problemName = parser.parseReferencedName(strXXXs, null, null);
1357 assertTrue(problemName.hasProblem());
1358 list = problemName.getParsingProblems();
1359 assertTrue("Problem must be name-reference separation", list.contains(ParserProblem.NameReferenceSeparation));
1360 parser.parseReferencedName(problemName, strBookSection, null, true);
1361 assertFalse(problemName.hasProblem());
1362
1363 problemName = parser.parseFullName(strXXXs, null, null);
1364 assertTrue(problemName.hasProblem());
1365 list = problemName.getParsingProblems();
1366 assertTrue("Name part must be unparsable", list.contains(ParserProblem.UnparsableNamePart));
1367
1368
1369 String testParsable = "Pithecellobium macrostachyum Benth.";
1370 assertTrue(isParsable(testParsable, ICNAFP));
1371
1372 testParsable = "Pithecellobium macrostachyum (Benth.)";
1373 assertTrue(isParsable(testParsable, ICNAFP));
1374
1375 testParsable = "Pithecellobium macrostachyum (Benth., 1845)";
1376 assertTrue(isParsable(testParsable, NomenclaturalCode.ICZN));
1377
1378 testParsable = "Pithecellobium macrostachyum L., Sp. Pl. 3: n\u00B0 123. 1753."; //00B0 is degree character
1379 assertTrue(isParsable(testParsable, ICNAFP));
1380
1381 testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. Mitt.-Eur. 6: 1285. 1929";
1382 assertTrue("Reference title should support special characters as separators like - and &", isParsable(testParsable, ICNAFP));
1383
1384 testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. Mitt.&Eur. 6: 1285. 1929";
1385 assertTrue("Reference title should support special characters as separators like - and &", isParsable(testParsable, ICNAFP));
1386
1387 testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. Mitt.-Eur.& 6: 1285. 1929";
1388 assertFalse("Reference title should not support special characters like - and & at the end of the title", isParsable(testParsable, ICNAFP));
1389 assertTrue("Problem must be reference title", getProblems(testParsable, ICNAFP).
1390 contains(ParserProblem.UnparsableReferenceTitle));
1391
1392 testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. Mitt.:Eur. 6: 1285. 1929";
1393 assertFalse("Reference title should not support detail separator", isParsable(testParsable, ICNAFP));
1394 assertTrue("Problem must be reference title", getProblems(testParsable, ICNAFP).
1395 contains(ParserProblem.UnparsableReferenceTitle));
1396
1397 testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. (Mitt.) 6: 1285. 1929";
1398 assertTrue("Reference title should support brackets", isParsable(testParsable, ICNAFP));
1399
1400 testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. (Mitt.) 6: 1285. 1929";
1401 assertTrue("Reference title should support brackets", isParsable(testParsable, ICNAFP));
1402
1403 testParsable = "Hieracium lachenalii Zahn, nom. illeg.";
1404 assertTrue("Reference should not be obligatory if a nom status exist", isParsable(testParsable, ICNAFP));
1405
1406 testParsable = "Hieracium lachenalii, nom. illeg.";
1407 assertTrue("Authorship should not be obligatory if followed by nom status", isParsable(testParsable, ICNAFP));
1408
1409 testParsable = "Hieracium lachenalii, Ill. Fl. (Mitt.) 6: 1285. 1929";
1410 assertFalse("Author is obligatory if followed by reference", isParsable(testParsable, ICNAFP));
1411 assertTrue("Problem must be name-reference separation", getProblems(testParsable, ICNAFP).
1412 contains(ParserProblem.NameReferenceSeparation));
1413
1414 testParsable = "Hieracium lachenalii in Hegi, Ill. Fl. (Mitt.) 6: 1285. 1929";
1415 assertFalse("Author is obligatory if followed by reference", isParsable(testParsable, ICNAFP));
1416 assertTrue("Problem must be name-reference separation", getProblems(testParsable, ICNAFP).
1417 contains(ParserProblem.NameReferenceSeparation));
1418
1419 testParsable = "Abies alba Mill. var. alba";
1420 assertTrue("Autonym problem", isParsable(testParsable, ICNAFP));
1421
1422 testParsable = "Scleroblitum abc Ulbr. in Engler & Prantl, Nat. Pflanzenfam., ed. 2, 16c: 495. 1934.";
1423 assertTrue("Volume with subdivision", isParsable(testParsable, ICNAFP));
1424
1425
1426 testParsable = "Hieracium antarcticum d'Urv. in M\u00E9m. Soc. Linn. Paris 4: 608. 1826";
1427 // testParsable = "Hieracium antarcticum Urv. in M\u00E9m. Soc. Linn. Paris 4: 608. 1826";
1428 assertTrue("Name with apostrophe is not parsable", isParsable(testParsable, ICNAFP));
1429
1430 testParsable = "Cichorium intybus subsp. glaucum (Hoffmanns. & Link) Tzvelev in Komarov, Fl. SSSR 29: 17. 1964";
1431 assertTrue("Reference containing a word in uppercase is not parsable", isParsable(testParsable, ICNAFP));
1432
1433
1434 }
1435
1436
1437 /**
1438 * Test author with name parts van, von, de, de la, d', da, del.
1439 * See also http://dev.e-taxonomy.eu/trac/ticket/3373
1440 */
1441 @Test
1442 public final void testComposedAuthorNames(){
1443
1444 //van author (see https://dev.e-taxonomy.eu/trac/ticket/3373)
1445 String testParsable = "Aphelocoma unicolor subsp. griscomi van Rossem, 1928";
1446 assertTrue("Author with 'van' should be parsable", isParsable(testParsable, ICZN));
1447
1448 //von author (see https://dev.e-taxonomy.eu/trac/ticket/3373)
1449 testParsable = "Aphelocoma unicolor subsp. griscomi von Rossem, 1928";
1450 assertTrue("Author with 'von' should be parsable", isParsable(testParsable, ICZN));
1451
1452 //de author (see https://dev.e-taxonomy.eu/trac/ticket/3373)
1453 testParsable = "Aphelocoma unicolor subsp. griscomi de Rossem, 1928";
1454 assertTrue("Author with 'de' should be parsable", isParsable(testParsable, ICZN));
1455
1456 //de la author (see https://dev.e-taxonomy.eu/trac/ticket/3373)
1457 testParsable = "Aphelocoma unicolor subsp. griscomi de la Rossem, 1928";
1458 assertTrue("Author with 'de la' should be parsable", isParsable(testParsable, ICZN));
1459
1460 //d' author (see https://dev.e-taxonomy.eu/trac/ticket/3373)
1461 testParsable = "Aphelocoma unicolor subsp. griscomi d'Rossem, 1928";
1462 assertTrue("Author with \"'d'\" should be parsable", isParsable(testParsable, ICZN));
1463
1464 //da author (see https://dev.e-taxonomy.eu/trac/ticket/3373)
1465 testParsable = "Aphelocoma unicolor subsp. griscomi da Rossem, 1928";
1466 assertTrue("Author with 'da' should be parsable", isParsable(testParsable, ICZN));
1467
1468 //del author (see https://dev.e-taxonomy.eu/trac/ticket/3373)
1469 testParsable = "Aphelocoma unicolor subsp. griscomi del Rossem, 1928";
1470 assertTrue("Author with 'del' should be parsable", isParsable(testParsable, ICZN));
1471
1472 //O' author (see https://dev.e-taxonomy.eu/trac/ticket/4759)
1473 testParsable = "Aphelocoma unicolor subsp. griscomi O'Connor, 1928";
1474 assertTrue("Author with 'O'' should be parsable", isParsable(testParsable, ICZN));
1475
1476 //del author (see https://dev.e-taxonomy.eu/trac/ticket/4759)
1477 testParsable = "Aphelocoma unicolor subsp. griscomi zur Strassen, 1928";
1478 assertTrue("Author with 'zur' should be parsable", isParsable(testParsable, ICZN));
1479
1480 }
1481
1482
1483
1484 /**
1485 * @param testParsable
1486 * @param icbn
1487 * @return
1488 */
1489 private List<ParserProblem> getProblems(String string, NomenclaturalCode code) {
1490 List<ParserProblem> result = parser.parseReferencedName(string, code, null).getParsingProblems();
1491 return result;
1492 }
1493
1494 private boolean isParsable(String string, NomenclaturalCode code){
1495 INonViralName name = parser.parseReferencedName(string, code, null);
1496 return ! name.hasProblem();
1497 }
1498
1499 private void assertFullRefNameStandard(INonViralName name){
1500 assertEquals("Abies", name.getGenusOrUninomial());
1501 assertEquals("alba", name.getSpecificEpithet());
1502 assertEquals("Mill.", name.getAuthorshipCache());
1503 assertEquals("455", name.getNomenclaturalMicroReference());
1504 assertNotNull(name.getNomenclaturalReference());
1505 }
1506
1507 private void assertFullRefStandard(INonViralName name){
1508 assertEquals("Abies", name.getGenusOrUninomial());
1509 assertEquals("alba", name.getSpecificEpithet());
1510 assertEquals("Mill.", name.getAuthorshipCache());
1511 assertEquals("455", name.getNomenclaturalMicroReference());
1512 assertNotNull(name.getNomenclaturalReference());
1513 INomenclaturalReference ref = name.getNomenclaturalReference();
1514 assertEquals("1987", ref.getYear());
1515 assertEquals("Sp. Pl.", ref.getAbbrevTitle());
1516 }
1517
1518
1519 @Test
1520 public void testNeverEndingParsing(){
1521 //some full titles result in never ending parsing process https://dev.e-taxonomy.eu/trac/ticket/1556
1522
1523 String irinaExample = "Milichiidae Sharp, 1899, Insects. Part II. Hymenopteracontinued (Tubulifera and Aculeata), Coleoptera, Strepsiptera, Lepidoptera, Diptera, Aphaniptera, Thysanoptera, Hemiptera, Anoplura 6: 504. 1899";
1524 // irinaExample = "Milichiidae Sharp, 1899, Insects. Part II. Uiuis Iuiui Hymenopteracontinued (Tubulifera and Aculeata), Coleoptera, Strepsiptera, Lepidoptera, Diptera, Aphaniptera, Thysanoptera, Hemiptera, Anoplura 6: 504. 1899";
1525 INonViralName nvn = this.parser.parseReferencedName(irinaExample, NomenclaturalCode.ICZN, null);
1526 int parsingProblem = nvn.getParsingProblem();
1527 Assert.assertEquals("Name should have only rank warning", 1, parsingProblem);
1528 Assert.assertEquals("Titlecache", "Milichiidae Sharp, 1899", nvn.getTitleCache());
1529 Assert.assertEquals("If this line reached everything should be ok", "Milichiidae", nvn.getGenusOrUninomial());
1530
1531 String anotherExample = "Scorzonera hispanica var. brevifolia Boiss. & Balansa in Boissier, Diagn. Pl. Orient., ser. 2 6: 119. 1859.";
1532 nvn = this.parser.parseReferencedName(anotherExample, ICNAFP, null);
1533 parsingProblem = nvn.getParsingProblem();
1534 Assert.assertEquals("Problem should be 0", 0, parsingProblem);
1535 Assert.assertEquals("Titlecache", "Scorzonera hispanica var. brevifolia Boiss. & Balansa", nvn.getTitleCache());
1536 Assert.assertEquals("If this line reached everything should be ok", "Scorzonera", nvn.getGenusOrUninomial());
1537
1538 String unparsable = "Taraxacum nevskii L., Trudy Bot. Inst. Nauk S.S.S.R., Ser. 1, Fl. Sist. Vyssh. Rast. 4: 293. 1937.";
1539 // String unparsableA = "Taraxacum nevskii L. in Trudy Bot. Inst. Nauk: 293. 1937.";
1540 nvn = this.parser.parseReferencedName(unparsable, ICNAFP, null);
1541 Assert.assertEquals("Titlecache", "Taraxacum nevskii L.", nvn.getTitleCache());
1542 Assert.assertEquals("If this line reached everything should be ok", "Taraxacum", nvn.getGenusOrUninomial());
1543 parsingProblem = nvn.getParsingProblem();
1544 Assert.assertEquals("Name should no warnings or errors", 0, parsingProblem);
1545
1546 String unparsable2 = "Hieracium pxxx Dahlst., Kongl. Svenska Vetensk. Acad. Handl. ser. 2, 26(3): 255. 1894";
1547 // String unparsable2A = "Hieracium pxxx Dahlst., Kongl Svenska Vetensk Acad Handl, 26: 255. 1894.";
1548 nvn = this.parser.parseReferencedName(unparsable2, ICNAFP, null);
1549 Assert.assertEquals("Titlecache", "Hieracium pxxx Dahlst.", nvn.getTitleCache());
1550 Assert.assertEquals("If this line reached everything should be ok", "Hieracium", nvn.getGenusOrUninomial());
1551 parsingProblem = nvn.getParsingProblem();
1552 Assert.assertEquals("Name should no warnings or errors", 0, parsingProblem);
1553
1554
1555 String again = "Adiantum emarginatum Bory ex. Willd., Species Plantarum, ed. 4,5,1: 449,450. 1810";
1556 nvn = this.parser.parseReferencedName(again, ICNAFP, null);
1557 Assert.assertEquals("Titlecache", "Adiantum emarginatum Bory ex Willd.", nvn.getTitleCache());
1558 Assert.assertEquals("If this line reached everything should be ok", "Adiantum", nvn.getGenusOrUninomial());
1559
1560 }
1561
1562 @Test
1563 public final void testSeriesPart(){
1564 Pattern seriesPattern = Pattern.compile(NonViralNameParserImplRegExBase.pSeriesPart);
1565 Matcher matcher = seriesPattern.matcher("ser. 2");
1566 Assert.assertTrue("", matcher.matches());
1567 }
1568
1569 /**
1570 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#fullTeams(java.lang.String)}.
1571 */
1572 @Test
1573 public final void testFullTeams() {
1574 logger.warn("Not yet implemented"); // TODO
1575 }
1576
1577 /**
1578 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#AuthorshipAndEx(java.lang.String)}.
1579 * @throws StringNotParsableException
1580 */
1581 @Test
1582 public final void testParseAuthorsTaxonNameString() throws StringNotParsableException {
1583 INonViralName nvn = TaxonNameFactory.NewZoologicalInstance(null);
1584 parser.parseAuthors(nvn, "Eckweiler & ten Hagen, 2003");
1585 Team team = (Team)nvn.getCombinationAuthorship();
1586 Assert.assertNotNull("Comb. author must not be null", team);
1587 Assert.assertEquals("Must be team with 2 members", 2, team.getTeamMembers().size());
1588 Assert.assertEquals("Second member must be 'ten Hagen'", "ten Hagen", team.getTeamMembers().get(1).getTitleCache());
1589
1590 //Crosson du Cormier, 1964
1591 IZoologicalName zooName = TaxonNameFactory.NewZoologicalInstance(null);
1592 parser.parseAuthors(zooName, "Crosson du Cormier, 1964");
1593 Person person = (Person)zooName.getCombinationAuthorship();
1594 Assert.assertNotNull("Comb. author must not be null", person);
1595 Assert.assertEquals("Persons title must be 'Crosson du Cormier'", "Crosson du Cormier", person.getTitleCache());
1596 Assert.assertEquals("Year must be 1964", Integer.valueOf(1964), zooName.getPublicationYear() );
1597
1598 //(van der Hoeven, 1839)
1599 zooName = TaxonNameFactory.NewZoologicalInstance(null);
1600 parser.parseAuthors(zooName, "(van der Hoeven, 1839)");
1601 Assert.assertNull("Combination author must be null", zooName.getCombinationAuthorship());
1602 person = (Person)zooName.getBasionymAuthorship();
1603 Assert.assertNotNull("Basionym author must not be null", person);
1604 Assert.assertEquals("Persons title must be 'van der Hoeven'", "van der Hoeven", person.getTitleCache());
1605 Assert.assertEquals("Year must be 1839", Integer.valueOf(1839), zooName.getOriginalPublicationYear() );
1606
1607 //le Doux, 1931
1608 zooName = TaxonNameFactory.NewZoologicalInstance(null);
1609 parser.parseAuthors(zooName, "le Doux, 1931");
1610 person = (Person)zooName.getCombinationAuthorship();
1611 Assert.assertNotNull("Comb. author must not be null", person);
1612 Assert.assertEquals("Persons title must be 'le Doux'", "le Doux", person.getTitleCache());
1613 Assert.assertEquals("Year must be 1931", Integer.valueOf(1931), zooName.getPublicationYear() );
1614
1615
1616 }
1617
1618 @Test //#4764
1619 public void testParseSection(){
1620 //this test does not really test problematic cases where sect.idInVoc = "sect." instead of "sect.(bot.)"
1621 //however, by changing the csv file entry to sect. just for testing it can be used as a functional test
1622 String sectionNameStr = "Taraxacum sect. Testtaxa M\u00fcller, Incredible Taxa: 12. 2016";
1623 INonViralName sectionName = parser.parseReferencedName(sectionNameStr, NomenclaturalCode.ICNAFP, null);
1624 int parsingProblem = sectionName.getParsingProblem();
1625 Assert.assertEquals("Problem should be 0", 0, parsingProblem);
1626 Rank rank = sectionName.getRank();
1627 Assert.assertEquals("", Rank.SECTION_BOTANY(), rank );
1628
1629 }
1630
1631 @Test //#5072
1632 public final void testLongRunningParsingCapitals(){
1633 DateTime start = DateTime.now();
1634 String nameStr = "Nazeris fujianensis JIAYAO HU, LIZHEN LI, MEIJUN ZHAO,2010"; //name from CoL that created problems
1635 INonViralName name = parser.parseReferencedName(nameStr, NomenclaturalCode.ICZN, null);
1636 DateTime end = DateTime.now();
1637 Duration duration = new Duration(start, end);
1638 long seconds = duration.getStandardSeconds();
1639 //this is the critical part of the test that must not be changed
1640 Assert.assertTrue("Parsing of name should take less then 3 seconds but took " + seconds, seconds < 3);
1641
1642 }
1643
1644 @Test //#5072
1645 //http://www.regular-expressions.info/catastrophic.html
1646 public final void testLongRunningParsing(){
1647
1648 //name only
1649 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";
1650 DateTime start = DateTime.now();
1651 INonViralName name = parser.parseReferencedName(nameStr, NomenclaturalCode.ICNAFP, null);
1652 DateTime end = DateTime.now();
1653 Duration duration = new Duration(start, end);
1654 long seconds = duration.getStandardSeconds();
1655 //this is the critical part of the test that must not be changed
1656 Assert.assertTrue("Parsing of name should take less then 3 seconds but took " + seconds, seconds < 3);
1657 //the following may be discussed
1658 Assert.assertFalse("Name should parse without problems",name.hasProblem());
1659
1660
1661 //with reference
1662 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.";
1663 start = DateTime.now();
1664 name = parser.parseReferencedName(nameStr, NomenclaturalCode.ICNAFP, null);
1665 end = DateTime.now();
1666 duration = new Duration(start, end);
1667 seconds = duration.getStandardSeconds();
1668 //this is the critical part of the test that must not be changed
1669 Assert.assertTrue("Parsing of name should take less then 3 seconds but took " + seconds, seconds < 3);
1670 //the following may be discussed
1671 Assert.assertFalse("Name should parse without problems",name.hasProblem());
1672 }
1673
1674 @Test //#5072
1675 public final void testLongRunningParsingAuthors(){
1676 //http://www.regular-expressions.info/catastrophic.html
1677 //
1678 //Länge des Nachnamens macht keinen Unterschied
1679 //Anzahl der "AuthorParts scheint entscheidend
1680 // & am Ende macht es langsamger (16s), als nur ","(6s))
1681
1682 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";
1683 TeamOrPersonBase[] authorArray = new TeamOrPersonBase[4];
1684 try {
1685 DateTime start = DateTime.now();
1686 parser.fullAuthors(authorStr, authorArray, new Integer[]{1800, null, null, null}, BotanicalName.class);
1687 DateTime end = DateTime.now();
1688 Duration duration = new Duration(start, end);
1689 long seconds = duration.getStandardSeconds();
1690 // System.out.println(seconds);
1691 //this is the critical part of the test that must not be changed
1692 Assert.assertTrue("Parsing of name should take less then 3 seconds but took " + seconds, seconds < 3);
1693 } catch (StringNotParsableException e) {
1694 e.printStackTrace();
1695 Assert.fail("Authors should be parsable");
1696 }
1697
1698 }
1699
1700
1701 /**
1702 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#AuthorshipAndEx(java.lang.String)}.
1703 */
1704 @Test
1705 public final void testAuthorshipAndEx() {
1706 logger.warn("Not yet implemented"); // TODO
1707 }
1708
1709 /**
1710 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#Authorship(java.lang.String)}.
1711 */
1712 @Test
1713 public final void testAuthorship() {
1714 logger.warn("Not yet implemented"); // TODO
1715 }
1716
1717 /**
1718 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseCultivar(java.lang.String)}.
1719 */
1720 @Test
1721 public final void testParseCultivar() {
1722 logger.warn("Not yet implemented"); // TODO
1723 }
1724
1725 @Test
1726 public final void testNomenclaturalStatus() {
1727 BotanicalName name = TaxonNameFactory.NewBotanicalInstance(Rank.FAMILY(), "Acanthopale", null, null, null, null, null, null, null);
1728 name.addStatus(NomenclaturalStatus.NewInstance(NomenclaturalStatusType.ALTERNATIVE()));
1729 BotanicalName name2 = TaxonNameFactory.NewBotanicalInstance(Rank.FAMILY());
1730 parser.parseReferencedName(name2, name.getFullTitleCache(), name2.getRank(), true);
1731 parser.parseReferencedName(name2, name.getFullTitleCache(), name2.getRank(), true);
1732 Assert.assertEquals("Title cache should be same. No duplication of nom. status should take place", name.getFullTitleCache(), name2.getFullTitleCache());
1733 }
1734
1735 @Test
1736 public final void testSpecificAuthors(){
1737 //McVaugh
1738 INonViralName name = parser.parseFullName("Psidium longipes var. orbiculare (O.Berg) McVaugh");
1739 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
1740 TeamOrPersonBase<?> combinationAuthor = name.getCombinationAuthorship();
1741 assertEquals( "McVaugh", combinationAuthor.getNomenclaturalTitle());
1742 TeamOrPersonBase<?> basionymAuthor = name.getBasionymAuthorship();
1743 assertEquals( "O.Berg", basionymAuthor.getNomenclaturalTitle());
1744
1745 // Campanula rhodensis A. DC.
1746
1747 }
1748
1749 @Test
1750 public final void testExistingProblems(){
1751 //Canabio, issue with space
1752 INonViralName name = parser.parseReferencedName("Machaonia erythrocarpa var. hondurensis (Standl.) Borhidi"
1753 + " in Acta Bot. Hung. 46 (1-2): 30. 2004");
1754 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
1755 TeamOrPersonBase<?> combinationAuthor = name.getCombinationAuthorship();
1756 assertEquals( "Borhidi", combinationAuthor.getNomenclaturalTitle());
1757 Reference nomRef = (Reference)name.getNomenclaturalReference();
1758 assertEquals(ReferenceType.Article, nomRef.getType());
1759 assertEquals("46 (1-2)", nomRef.getVolume());
1760
1761 //Canabio, detail with fig.
1762 name = parser.parseReferencedName("Didymaea floribunda Rzed."
1763 + " in Bol. Soc. Bot. Mex. 44: 72, fig. 1. 1983");
1764 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
1765 combinationAuthor = name.getCombinationAuthorship();
1766 assertEquals( "Rzed.", combinationAuthor.getNomenclaturalTitle());
1767 nomRef = (Reference)name.getNomenclaturalReference();
1768 assertEquals(ReferenceType.Article, nomRef.getType());
1769 assertEquals("44", nomRef.getVolume());
1770 assertEquals("72, fig. 1", name.getNomenclaturalMicroReference());
1771
1772 //fig with a-c and without dot
1773 name = parser.parseReferencedName("Deppea guerrerensis Dwyer & Lorence"
1774 + " in Allertonia 4: 428. fig 4a-c. 1988"); //
1775 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
1776 combinationAuthor = name.getCombinationAuthorship();
1777 assertEquals( "Dwyer & Lorence", combinationAuthor.getNomenclaturalTitle());
1778 nomRef = (Reference)name.getNomenclaturalReference();
1779 assertEquals(ReferenceType.Article, nomRef.getType());
1780 assertEquals("4", nomRef.getVolume());
1781 assertEquals("428. fig 4a-c", name.getNomenclaturalMicroReference());
1782
1783 //issue with EN_DASH (3–4)
1784 name = parser.parseReferencedName("Arachnothryx tacanensis (Lundell) Borhidi"
1785 + " in Acta Bot. Hung. 33 (3" + UTF8.EN_DASH + "4): 303. 1987");
1786 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
1787 combinationAuthor = name.getCombinationAuthorship();
1788 assertEquals( "Borhidi", combinationAuthor.getNomenclaturalTitle());
1789 nomRef = (Reference)name.getNomenclaturalReference();
1790 assertEquals(ReferenceType.Article, nomRef.getType());
1791 assertEquals("33 (3" + UTF8.EN_DASH + "4)", nomRef.getVolume());
1792 assertEquals("303", name.getNomenclaturalMicroReference());
1793
1794 //fig with f.
1795 name = parser.parseReferencedName("Stenotis Terrell"
1796 + " in Sida 19(4): 901" + UTF8.EN_DASH + "911, f. 1" + UTF8.EN_DASH + "2. 2001");
1797 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
1798 combinationAuthor = name.getCombinationAuthorship();
1799 assertEquals( "Terrell", combinationAuthor.getNomenclaturalTitle());
1800 nomRef = (Reference)name.getNomenclaturalReference();
1801 assertEquals(ReferenceType.Article, nomRef.getType());
1802 assertEquals("19(4)", nomRef.getVolume());
1803 assertEquals("901" + UTF8.EN_DASH + "911, f. 1" + UTF8.EN_DASH + "2", name.getNomenclaturalMicroReference());
1804
1805 //detail with figs
1806 name = parser.parseReferencedName("Randia sonorensis Wiggins"
1807 + " in Contr. Dudley Herb. 3: 75, figs 4-6. 1940");
1808 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
1809 combinationAuthor = name.getCombinationAuthorship();
1810 assertEquals( "Wiggins", combinationAuthor.getNomenclaturalTitle());
1811 nomRef = (Reference)name.getNomenclaturalReference();
1812 assertEquals(ReferenceType.Article, nomRef.getType());
1813 assertEquals("3", nomRef.getVolume());
1814 assertEquals("75, figs 4-6", name.getNomenclaturalMicroReference());
1815
1816 //detail with pl. and figs
1817 name = parser.parseReferencedName("Randia sonorensis Wiggins"
1818 + " in Contr. Dudley Herb. 3: 75, pl. 19, figs 4-6. 1940");
1819 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
1820 combinationAuthor = name.getCombinationAuthorship();
1821 assertEquals( "Wiggins", combinationAuthor.getNomenclaturalTitle());
1822 nomRef = (Reference)name.getNomenclaturalReference();
1823 assertEquals(ReferenceType.Article, nomRef.getType());
1824 assertEquals("3", nomRef.getVolume());
1825 assertEquals("75, pl. 19, figs 4-6", name.getNomenclaturalMicroReference());
1826
1827
1828 //pl
1829 name = parser.parseReferencedName("Carapichea Aubl."
1830 + " in Hist. Pl. Guiane 1: 167, pl. 64. 1775");
1831 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
1832 combinationAuthor = name.getCombinationAuthorship();
1833 assertEquals( "Aubl.", combinationAuthor.getNomenclaturalTitle());
1834 nomRef = (Reference)name.getNomenclaturalReference();
1835 assertEquals(ReferenceType.Article, nomRef.getType());
1836 assertEquals("1", nomRef.getVolume());
1837 assertEquals("167, pl. 64", name.getNomenclaturalMicroReference());
1838
1839 //fig with ,
1840 name = parser.parseReferencedName("Hoffmannia ixtlanensis Lorence"
1841 + " in Novon 4: 121. fig. 2a, b. 1994");
1842 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
1843 combinationAuthor = name.getCombinationAuthorship();
1844 assertEquals( "Lorence", combinationAuthor.getNomenclaturalTitle());
1845 nomRef = (Reference)name.getNomenclaturalReference();
1846 assertEquals(ReferenceType.Article, nomRef.getType());
1847 assertEquals("4", nomRef.getVolume());
1848 assertEquals("121. fig. 2a, b", name.getNomenclaturalMicroReference());
1849
1850 //detail with , to number
1851 name = parser.parseReferencedName("Deppea martinez-calderonii Lorence"
1852 + " in Allertonia 4: 399. figs 1e, 2. 1988");
1853 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
1854 combinationAuthor = name.getCombinationAuthorship();
1855 assertEquals( "Lorence", combinationAuthor.getNomenclaturalTitle());
1856 nomRef = (Reference)name.getNomenclaturalReference();
1857 assertEquals(ReferenceType.Article, nomRef.getType());
1858 assertEquals("4", nomRef.getVolume());
1859 assertEquals("399. figs 1e, 2", name.getNomenclaturalMicroReference());
1860
1861 //(Suppl.)
1862 name = parser.parseReferencedName("Manettia costaricensis Wernham"
1863 + " in J. Bot. 57(Suppl.): 38. 1919");
1864 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
1865 combinationAuthor = name.getCombinationAuthorship();
1866 assertEquals( "Wernham", combinationAuthor.getNomenclaturalTitle());
1867 nomRef = (Reference)name.getNomenclaturalReference();
1868 assertEquals(ReferenceType.Article, nomRef.getType());
1869 assertEquals("57(Suppl.)", nomRef.getVolume());
1870 assertEquals("38", name.getNomenclaturalMicroReference());
1871
1872 //NY.
1873 name = parser.parseReferencedName("Crusea psyllioides (Kunth) W.R. Anderson"
1874 + " in Mem. NY. Bot. Gard. 22: 75. 1972");
1875 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
1876 combinationAuthor = name.getCombinationAuthorship();
1877 assertEquals( "W.R. Anderson", combinationAuthor.getNomenclaturalTitle());
1878 nomRef = (Reference)name.getNomenclaturalReference();
1879 assertEquals(ReferenceType.Article, nomRef.getType());
1880 assertEquals("22", nomRef.getVolume());
1881 assertEquals("75", name.getNomenclaturalMicroReference());
1882
1883 //apostroph word in title
1884 name = parser.parseReferencedName("Sabicea glabrescens Benth."
1885 + " in Hooker's J. Bot. Kew Gard. Misc. 3: 219. 1841");
1886 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
1887 combinationAuthor = name.getCombinationAuthorship();
1888 assertEquals( "Benth.", combinationAuthor.getNomenclaturalTitle());
1889 nomRef = (Reference)name.getNomenclaturalReference();
1890 assertEquals(ReferenceType.Article, nomRef.getType());
1891 assertEquals("3", nomRef.getVolume());
1892 assertEquals("219", name.getNomenclaturalMicroReference());
1893
1894 // place published e.g. (Hannover)
1895 name = parser.parseReferencedName("Pittoniotis trichantha Griseb."
1896 + " in Bonplandia (Hannover) 6 (1): 8. 1858");
1897 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
1898 combinationAuthor = name.getCombinationAuthorship();
1899 assertEquals( "Griseb.", combinationAuthor.getNomenclaturalTitle());
1900 nomRef = (Reference)name.getNomenclaturalReference();
1901 assertEquals(ReferenceType.Article, nomRef.getType());
1902 assertEquals("6 (1)", nomRef.getVolume());
1903 assertEquals("8", name.getNomenclaturalMicroReference());
1904
1905 //komplex / incorrect year without quotation marks
1906 name = parser.parseReferencedName("Javorkaea Borhidi & Jarai-Koml."
1907 + " in Acta Bot. Hung. 29(1\u20134): 16, f. 1\u20132, t. 1-8. 1983 [1984]");
1908 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
1909 combinationAuthor = name.getCombinationAuthorship();
1910 assertEquals( "Borhidi & Jarai-Koml.", combinationAuthor.getNomenclaturalTitle());
1911 nomRef = (Reference)name.getNomenclaturalReference();
1912 assertEquals(ReferenceType.Article, nomRef.getType());
1913 assertEquals("29(1\u20134)", nomRef.getVolume());
1914 assertEquals("16, f. 1\u20132, t. 1-8", name.getNomenclaturalMicroReference());
1915 assertEquals("1983 [1984]", nomRef.getDatePublishedString());
1916 assertEquals("1984", nomRef.getYear());
1917
1918 //incorrect year with \u201e \u201f (s. eu.etaxonomy.cdm.common.UTF8.ENGLISH_QUOT_START
1919 name = parser.parseReferencedName("Javorkaea Borhidi & Jarai-Koml."
1920 + " in Acta Bot. Hung. 29(1-4): 16, f. 1-2. \u201e1983\u201f [1984]");
1921 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
1922 combinationAuthor = name.getCombinationAuthorship();
1923 assertEquals( "Borhidi & Jarai-Koml.", combinationAuthor.getNomenclaturalTitle());
1924 nomRef = (Reference)name.getNomenclaturalReference();
1925 assertEquals(ReferenceType.Article, nomRef.getType());
1926 assertEquals("29(1-4)", nomRef.getVolume());
1927 assertEquals("16, f. 1-2", name.getNomenclaturalMicroReference());
1928 assertEquals("\u201e1983\u201f [1984]", nomRef.getDatePublishedString());
1929 assertEquals("1984", nomRef.getYear());
1930
1931 //incorrect year with "
1932 name = parser.parseReferencedName("Javorkaea Borhidi & Jarai-Koml."
1933 + " in Acta Bot. Hung. 29(1-4): 16, f. 1-2. \"1983\" [1984]");
1934 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
1935 combinationAuthor = name.getCombinationAuthorship();
1936 assertEquals( "Borhidi & Jarai-Koml.", combinationAuthor.getNomenclaturalTitle());
1937 nomRef = (Reference)name.getNomenclaturalReference();
1938 assertEquals(ReferenceType.Article, nomRef.getType());
1939 assertEquals("29(1-4)", nomRef.getVolume());
1940 assertEquals("16, f. 1-2", name.getNomenclaturalMicroReference());
1941 assertEquals("\"1983\" [1984]", nomRef.getDatePublishedString());
1942 assertEquals("1984", nomRef.getYear());
1943
1944 //fig. a
1945 name = parser.parseReferencedName("Psychotria capitata Ruiz & Pav."
1946 + " in Fl. Peruv. 2: 59, pl. 206, fig. a. 1799");
1947 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
1948 combinationAuthor = name.getCombinationAuthorship();
1949 assertEquals( "Ruiz & Pav.", combinationAuthor.getNomenclaturalTitle());
1950 nomRef = (Reference)name.getNomenclaturalReference();
1951 assertEquals(ReferenceType.Article, nomRef.getType());
1952 assertEquals("2", nomRef.getVolume());
1953 assertEquals("59, pl. 206, fig. a", name.getNomenclaturalMicroReference());
1954
1955 //442A.
1956 name = parser.parseReferencedName("Rogiera elegans Planch."
1957 + " in Fl. Serres Jard. Eur. 5: 442A. 1849");
1958 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
1959 combinationAuthor = name.getCombinationAuthorship();
1960 assertEquals( "Planch.", combinationAuthor.getNomenclaturalTitle());
1961 nomRef = (Reference)name.getNomenclaturalReference();
1962 assertEquals(ReferenceType.Article, nomRef.getType());
1963 assertEquals("5", nomRef.getVolume());
1964 assertEquals("442A", name.getNomenclaturalMicroReference());
1965
1966 //f
1967 name = parser.parseReferencedName("Coussarea imitans L.O. Williams"
1968 + " in Phytologia 26 (6): 488-489, f. 1973");
1969 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
1970 combinationAuthor = name.getCombinationAuthorship();
1971 assertEquals( "L.O. Williams", combinationAuthor.getNomenclaturalTitle());
1972 nomRef = (Reference)name.getNomenclaturalReference();
1973 assertEquals(ReferenceType.Article, nomRef.getType());
1974 assertEquals("26 (6)", nomRef.getVolume());
1975 assertEquals("488-489, f", name.getNomenclaturalMicroReference());
1976
1977 //Phys.-Med.
1978 name = parser.parseReferencedName("Coccocypselum cordifolium Nees & Mart."
1979 + " in Nova Acta Phys.-Med. Acad. Caes.\u2013Leop. Nat. Cur. 12: 14. 1824");
1980 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
1981 combinationAuthor = name.getCombinationAuthorship();
1982 assertEquals( "Nees & Mart.", combinationAuthor.getNomenclaturalTitle());
1983 nomRef = (Reference)name.getNomenclaturalReference();
1984 assertEquals(ReferenceType.Article, nomRef.getType());
1985 assertEquals("Nova Acta Phys.-Med. Acad. Caes.\u2013Leop. Nat. Cur.", nomRef.getInReference().getAbbrevTitle());
1986 assertEquals("12", nomRef.getVolume());
1987 assertEquals("14", name.getNomenclaturalMicroReference());
1988 assertEquals("1824", nomRef.getYear());
1989
1990 //(ed. 10) wanted?
1991 // Syst. Nat. (ed. 10) 2: 930. 1759
1992 // name = parser.parseReferencedName("Erithalis fruticosa L."
1993 // + ", Syst. Nat. ed. 10, 2: 930. 1759");
1994 // Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
1995 // combinationAuthor = name.getCombinationAuthorship();
1996 // assertEquals( "L.", combinationAuthor.getNomenclaturalTitle());
1997 // nomRef = (Reference)name.getNomenclaturalReference();
1998 // assertEquals(ReferenceType.Book, nomRef.getType());
1999 // assertEquals("2", nomRef.getVolume());
2000 // assertEquals("10", nomRef.getEdition());
2001 // assertEquals("930", name.getNomenclaturalMicroReference());
2002 // assertEquals("1759", nomRef.getYear());
2003
2004 //issue with letter "(1a)"
2005 name = parser.parseReferencedName("Arthraerua (Kuntze) Schinz,"
2006 + " Nat. Pflanzenfam. 3(1a): 109. 1893");
2007 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
2008 combinationAuthor = name.getCombinationAuthorship();
2009 assertEquals( "Schinz", combinationAuthor.getNomenclaturalTitle());
2010 nomRef = (Reference)name.getNomenclaturalReference();
2011 Assert.assertFalse("Reference should be parsable", nomRef.isProtectedTitleCache());
2012 assertEquals(ReferenceType.Book, nomRef.getType());
2013 assertEquals("Nat. Pflanzenfam.", nomRef.getAbbrevTitle());
2014 assertEquals("3(1a)", nomRef.getVolume());
2015 assertEquals("109", name.getNomenclaturalMicroReference());
2016 assertEquals("1893", nomRef.getYear());
2017
2018 //Accent graph in author name #6057
2019 name = parser.parseReferencedName("Sedum plicatum O`Brian");
2020 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
2021 assertEquals( "O`Brian", name.getCombinationAuthorship().getNomenclaturalTitle());
2022
2023 //-e- #6060
2024 name = parser.parseReferencedName("Thamniopsis stenodictyon (Sehnem) Oliveira-e-Silva & O.Yano");
2025 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
2026 Team team = (Team)name.getCombinationAuthorship();
2027 assertEquals( "Oliveira-e-Silva", team.getTeamMembers().get(0).getNomenclaturalTitle());
2028
2029 //Vorabdr.
2030 name = parser.parseReferencedName("Ophrys hystera Kreutz & Ruedi Peter in J. Eur. Orchideen 30(Vorabdr.): 128. 1997");
2031 Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
2032 assertEquals( "30(Vorabdr.)", ((Reference)name.getNomenclaturalReference()).getVolume());
2033
2034 //test case disabled, would fail! Is due to '´t'
2035 // ´t
2036 // name = parser.parseReferencedName("Sempervivum globiferum subsp. allionii (Jord. & Fourr.) ´t Hart & Bleij");
2037 // Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());
2038
2039
2040 }
2041
2042 }