2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.strategy
.parser
;
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
;
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
;
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
;
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
;
63 public class NonViralNameParserImplTest
{
64 private static final NomenclaturalCode ICNAFP
= NomenclaturalCode
.ICNAFP
;
65 private static final NomenclaturalCode ICZN
= NomenclaturalCode
.ICZN
;
67 private static final Logger logger
= Logger
.getLogger(NonViralNameParserImplTest
.class);
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";
87 final private String strNameEmpty
= "";
88 final private String strNameNull
= null;
90 private NonViralNameParserImpl parser
;
91 private NomenclaturalCode botanicCode
;
94 * @throws java.lang.Exception
97 public static void setUpBeforeClass() throws Exception
{
98 DefaultTermInitializer termInitializer
= new DefaultTermInitializer();
99 termInitializer
.initialize();
104 * @throws java.lang.Exception
107 public void setUp() throws Exception
{
108 parser
= NonViralNameParserImpl
.NewInstance();
109 botanicCode
= ICNAFP
;
113 /*************** TEST *********************************************/
116 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#NEW_INSTANCE()}.
119 public final void testNewInstance() {
120 assertNotNull(parser
);
124 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#TaxonNameParserBotanicalNameImpl()}.
127 public final void testTaxonNameParserBotanicalNameImpl() {
128 logger
.warn("Not yet implemented"); // TODO
132 public final void testTeamSeperation(){
133 Rank speciesRank
= Rank
.SPECIES();
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());
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());
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());
160 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseSimpleName(java.lang.String, eu.etaxonomy.cdm.model.name.Rank)}.
163 public final void testParseSimpleName() {
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());
173 abies
.addParsingProblem(ParserProblem
.CheckRank
);
174 parser
.parseSimpleName(abies
, "Abies", abies
.getRank(), true);
175 assertTrue(abies
.getParsingProblems().contains(ParserProblem
.CheckRank
));
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
));
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
));
196 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseSubGenericFullName(java.lang.String)}.
199 public final void testParseSubGenericFullName() {
200 String zooSpeciesWithSubgenus
= "Bacanius (Mullerister) rombophorus (Aube, 1843)";
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());
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());
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());
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());
237 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseSubGenericSimpleName(java.lang.String)}.
240 public final void testParseSubGenericSimpleName() {
241 logger
.warn("Not yet implemented"); // TODO
245 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseFullName(java.lang.String, eu.etaxonomy.cdm.model.name.Rank)}.
248 public final void testParseFullNameUnicode() {
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());
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());
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());
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
);
288 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseFullName(java.lang.String, eu.etaxonomy.cdm.model.name.Rank)}.
291 public final void testParseFullName() {
293 Method parseMethod
= parser
.getClass().getDeclaredMethod("parseFullName", String
.class, NomenclaturalCode
.class, Rank
.class);
294 testName_StringNomcodeRank(parseMethod
);
295 } catch (Exception e
) {
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());
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());
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());
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());
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());
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());
346 BotanicalName autonymName
= (BotanicalName
)parser
.parseFullName("Abies alba Mill. var. alba", ICNAFP
, null);
347 assertFalse("Autonym should be parsable", autonymName
.hasProblem());
351 INonViralName nameEmpty
= parser
.parseFullName(strNameEmpty
);
352 assertNotNull(nameEmpty
);
353 assertEquals("", nameEmpty
.getTitleCache());
356 INonViralName nameNull
= parser
.parseFullName(strNameNull
);
357 assertNull(nameNull
);
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());
366 //author with 2 capitals
367 fullNameString
= "Campanula rhodensis A. DC.";
368 INonViralName name
= parser
.parseFullName(fullNameString
);
369 assertFalse(name
.hasProblem());
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());
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());
389 public final void testEtAl() throws StringNotParsableException
{
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() );
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());
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());
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());
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());
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());
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());
480 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseFullName(java.lang.String, eu.etaxonomy.cdm.model.name.Rank)}.
483 public final void testHybrids() {
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());
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());
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());
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());
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());
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());
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());
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
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
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
567 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseFullName(java.lang.String, eu.etaxonomy.cdm.model.name.Rank)}.
570 public final void testUnrankedNames() {
572 Method parseMethod
= parser
.getClass().getDeclaredMethod("parseFullName", String
.class, NomenclaturalCode
.class, Rank
.class);
573 testName_StringNomcodeRank(parseMethod
);
574 } catch (Exception e
) {
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());
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());
599 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseFullName(java.lang.String, eu.etaxonomy.cdm.model.name.Rank)}.
602 public final void testHybridFormulars() {
604 Method parseMethod
= parser
.getClass().getDeclaredMethod("parseFullName", String
.class, NomenclaturalCode
.class, Rank
.class);
605 testName_StringNomcodeRank(parseMethod
);
606 } catch (Exception e
) {
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());
628 name1
= parser
.parseReferencedName(hybridCache
, botanicCode
, null);
629 assertFalse("Name must not have parsing problems", name1
.hasProblem());
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());
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());
653 name1
= parser
.parseReferencedName(hybridCache
, botanicCode
, null);
654 assertFalse("Name must not have parsing problems", name1
.hasProblem());
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());
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());
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());
692 public final void testHybridsRemoval(){
693 //if the parser input already has hybridrelationships they need to be removed
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);
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());
707 hybridCache
= "Calendula arvensis Mill.";
709 parser
.parseFullName(name1
, hybridCache
, Rank
.SPECIES(), makeEmpty
);
710 assertTrue("", name1
.getHybridChildRelations().isEmpty());
711 assertFalse("Name must not have parsing problems", name1
.hasProblem());
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);
720 hybridCache
= "Abieta albana "+UTF8
.HYBRID
+" Pinuta custa";
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());
727 hybridCache
= "Calendula arvensis Mill.";
729 parser
.parseReferencedName(name1
, hybridCache
, Rank
.SPECIES(), makeEmpty
);
730 assertTrue("", name1
.getHybridChildRelations().isEmpty());
731 assertFalse("Name must not have parsing problems", name1
.hasProblem());
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());
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());
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());
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());
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());
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());
777 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseReferencedName(NonViralName, java.lang.String, eu.etaxonomy.cdm.model.name.Rank, boolean)(, )}.
780 public final void testParseNomStatus() {
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
993 //not yet parsed "not avail."
997 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseReferencedName(NonViralName, java.lang.String, eu.etaxonomy.cdm.model.name.Rank, boolean)(, )}.
1000 public final void testParseReferencedName() {
1002 Method parseMethod
= parser
.getClass().getDeclaredMethod("parseReferencedName", String
.class, NomenclaturalCode
.class, Rank
.class);
1003 testName_StringNomcodeRank(parseMethod
);
1004 } catch (Exception e
) {
1005 e
.printStackTrace();
1011 String strNull
= null;
1012 Rank rankSpecies
= Rank
.SPECIES();
1013 INonViralName nameNull
= parser
.parseReferencedName(strNull
, null, rankSpecies
);
1014 assertNull(nameNull
);
1017 String strEmpty
= "";
1018 INonViralName nameEmpty
= parser
.parseReferencedName(strEmpty
, null, rankSpecies
);
1019 assertFalse(nameEmpty
.hasProblem());
1020 assertEquals(strEmpty
, nameEmpty
.getFullTitleCache());
1021 assertNull(nameEmpty
.getNomenclaturalMicroReference());
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());
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());
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());
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());
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());
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());
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
));
1118 assertEquals(NomenclaturalCode
.ICZN
, nameZooRefNotParsabel
.getNomenclaturalCode());
1119 assertEquals(Integer
.valueOf(1923), nameZooRefNotParsabel
.getPublicationYear());
1120 assertEquals(1, nameZooRefNotParsabel
.getStatus().size());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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
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());
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());
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
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());
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());
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());
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());
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());
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 :
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());
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());
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());
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());
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());
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());
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());
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());
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());
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
));
1369 String testParsable
= "Pithecellobium macrostachyum Benth.";
1370 assertTrue(isParsable(testParsable
, ICNAFP
));
1372 testParsable
= "Pithecellobium macrostachyum (Benth.)";
1373 assertTrue(isParsable(testParsable
, ICNAFP
));
1375 testParsable
= "Pithecellobium macrostachyum (Benth., 1845)";
1376 assertTrue(isParsable(testParsable
, NomenclaturalCode
.ICZN
));
1378 testParsable
= "Pithecellobium macrostachyum L., Sp. Pl. 3: n\u00B0 123. 1753."; //00B0 is degree character
1379 assertTrue(isParsable(testParsable
, ICNAFP
));
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
));
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
));
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
));
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
));
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
));
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
));
1403 testParsable
= "Hieracium lachenalii Zahn, nom. illeg.";
1404 assertTrue("Reference should not be obligatory if a nom status exist", isParsable(testParsable
, ICNAFP
));
1406 testParsable
= "Hieracium lachenalii, nom. illeg.";
1407 assertTrue("Authorship should not be obligatory if followed by nom status", isParsable(testParsable
, ICNAFP
));
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
));
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
));
1419 testParsable
= "Abies alba Mill. var. alba";
1420 assertTrue("Autonym problem", isParsable(testParsable
, ICNAFP
));
1422 testParsable
= "Scleroblitum abc Ulbr. in Engler & Prantl, Nat. Pflanzenfam., ed. 2, 16c: 495. 1934.";
1423 assertTrue("Volume with subdivision", isParsable(testParsable
, ICNAFP
));
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
));
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
));
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
1442 public final void testComposedAuthorNames(){
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
));
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
));
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
));
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
));
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
));
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
));
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
));
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
));
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
));
1485 * @param testParsable
1489 private List
<ParserProblem
> getProblems(String string
, NomenclaturalCode code
) {
1490 List
<ParserProblem
> result
= parser
.parseReferencedName(string
, code
, null).getParsingProblems();
1494 private boolean isParsable(String string
, NomenclaturalCode code
){
1495 INonViralName name
= parser
.parseReferencedName(string
, code
, null);
1496 return ! name
.hasProblem();
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());
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());
1520 public void testNeverEndingParsing(){
1521 //some full titles result in never ending parsing process https://dev.e-taxonomy.eu/trac/ticket/1556
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());
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());
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
);
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
);
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());
1563 public final void testSeriesPart(){
1564 Pattern seriesPattern
= Pattern
.compile(NonViralNameParserImplRegExBase
.pSeriesPart
);
1565 Matcher matcher
= seriesPattern
.matcher("ser. 2");
1566 Assert
.assertTrue("", matcher
.matches());
1570 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#fullTeams(java.lang.String)}.
1573 public final void testFullTeams() {
1574 logger
.warn("Not yet implemented"); // TODO
1578 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#AuthorshipAndEx(java.lang.String)}.
1579 * @throws StringNotParsableException
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());
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() );
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() );
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() );
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
);
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);
1645 //http://www.regular-expressions.info/catastrophic.html
1646 public final void testLongRunningParsing(){
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());
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());
1675 public final void testLongRunningParsingAuthors(){
1676 //http://www.regular-expressions.info/catastrophic.html
1678 //Länge des Nachnamens macht keinen Unterschied
1679 //Anzahl der "AuthorParts scheint entscheidend
1680 // & am Ende macht es langsamger (16s), als nur ","(6s))
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];
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");
1702 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#AuthorshipAndEx(java.lang.String)}.
1705 public final void testAuthorshipAndEx() {
1706 logger
.warn("Not yet implemented"); // TODO
1710 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#Authorship(java.lang.String)}.
1713 public final void testAuthorship() {
1714 logger
.warn("Not yet implemented"); // TODO
1718 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseCultivar(java.lang.String)}.
1721 public final void testParseCultivar() {
1722 logger
.warn("Not yet implemented"); // TODO
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());
1736 public final void testSpecificAuthors(){
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());
1745 // Campanula rhodensis A. DC.
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
2034 //test case disabled, would fail! Is due to '´t'
2036 // name = parser.parseReferencedName("Sempervivum globiferum subsp. allionii (Jord. & Fourr.) ´t Hart & Bleij");
2037 // Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache());