57 |
57 |
*
|
58 |
58 |
*/
|
59 |
59 |
public class NonViralNameParserImplTest {
|
60 |
|
private static final NomenclaturalCode ICBN = NomenclaturalCode.ICNAFP;
|
|
60 |
private static final NomenclaturalCode ICNAFP = NomenclaturalCode.ICNAFP;
|
61 |
61 |
private static final NomenclaturalCode ICZN = NomenclaturalCode.ICZN;
|
62 |
62 |
|
63 |
63 |
private static final Logger logger = Logger.getLogger(NonViralNameParserImplTest.class);
|
... | ... | |
102 |
102 |
@Before
|
103 |
103 |
public void setUp() throws Exception {
|
104 |
104 |
parser = NonViralNameParserImpl.NewInstance();
|
105 |
|
botanicCode = ICBN;
|
|
105 |
botanicCode = ICNAFP;
|
106 |
106 |
}
|
107 |
107 |
|
108 |
108 |
|
... | ... | |
161 |
161 |
//Uninomials
|
162 |
162 |
ZoologicalName milichiidae = (ZoologicalName)parser.parseSimpleName("Milichiidae", NomenclaturalCode.ICZN, null);
|
163 |
163 |
assertEquals("Family rank expected", Rank.FAMILY(), milichiidae.getRank());
|
164 |
|
BotanicalName crepidinae = (BotanicalName)parser.parseSimpleName("Crepidinae", ICBN, null);
|
|
164 |
BotanicalName crepidinae = (BotanicalName)parser.parseSimpleName("Crepidinae", ICNAFP, null);
|
165 |
165 |
assertEquals("Family rank expected", Rank.SUBTRIBE(), crepidinae.getRank());
|
166 |
|
BotanicalName abies = (BotanicalName)parser.parseSimpleName("Abies", ICBN, null);
|
|
166 |
BotanicalName abies = (BotanicalName)parser.parseSimpleName("Abies", ICNAFP, null);
|
167 |
167 |
assertEquals("Family rank expected", Rank.GENUS(), abies.getRank());
|
168 |
168 |
|
169 |
169 |
abies.addParsingProblem(ParserProblem.CheckRank);
|
170 |
170 |
parser.parseSimpleName(abies, "Abies", abies.getRank(), true);
|
171 |
171 |
assertTrue(abies.getParsingProblems().contains(ParserProblem.CheckRank));
|
172 |
172 |
|
173 |
|
BotanicalName rosa = (BotanicalName)parser.parseSimpleName("Rosaceae", ICBN, null);
|
|
173 |
BotanicalName rosa = (BotanicalName)parser.parseSimpleName("Rosaceae", ICNAFP, null);
|
174 |
174 |
assertTrue("Rosaceae have rank family", rosa.getRank().equals(Rank.FAMILY()));
|
175 |
175 |
assertTrue("Rosaceae must have a rank warning", rosa.hasProblem(ParserProblem.CheckRank));
|
176 |
176 |
parser.parseSimpleName(rosa, "Rosaceaex", abies.getRank(), true);
|
... | ... | |
178 |
178 |
assertTrue("Rosaceaex must have a rank warning", rosa.hasProblem(ParserProblem.CheckRank));
|
179 |
179 |
|
180 |
180 |
//repeat but remove warning after first parse
|
181 |
|
rosa = (BotanicalName)parser.parseSimpleName("Rosaceae", ICBN, null);
|
|
181 |
rosa = (BotanicalName)parser.parseSimpleName("Rosaceae", ICNAFP, null);
|
182 |
182 |
assertTrue("Rosaceae have rank family", rosa.getRank().equals(Rank.FAMILY()));
|
183 |
183 |
assertTrue("Rosaceae must have a rank warning", rosa.hasProblem(ParserProblem.CheckRank));
|
184 |
184 |
rosa.removeParsingProblem(ParserProblem.CheckRank);
|
... | ... | |
186 |
186 |
assertEquals("Rosaceaex have rank family", Rank.FAMILY(), rosa.getRank());
|
187 |
187 |
assertFalse("Rosaceaex must have no rank warning", rosa.hasProblem(ParserProblem.CheckRank));
|
188 |
188 |
|
189 |
|
|
190 |
189 |
}
|
191 |
190 |
|
192 |
191 |
/**
|
... | ... | |
307 |
306 |
|
308 |
307 |
|
309 |
308 |
//Autonym
|
310 |
|
BotanicalName autonymName = (BotanicalName)parser.parseFullName("Abies alba Mill. var. alba", ICBN, null);
|
|
309 |
BotanicalName autonymName = (BotanicalName)parser.parseFullName("Abies alba Mill. var. alba", ICNAFP, null);
|
311 |
310 |
assertFalse("Autonym should be parsable", autonymName.hasProblem());
|
312 |
311 |
|
313 |
312 |
|
... | ... | |
332 |
331 |
NonViralName<?> name = parser.parseFullName(fullNameString);
|
333 |
332 |
assertFalse(name.hasProblem());
|
334 |
333 |
|
|
334 |
//author with no space #5618
|
|
335 |
fullNameString = "Gordonia moaensis (Vict.)H. Keng";
|
|
336 |
name = parser.parseFullName(fullNameString);
|
|
337 |
assertFalse(name.hasProblem());
|
|
338 |
assertNotNull(name.getCombinationAuthorship());
|
|
339 |
assertEquals("H. Keng", name.getCombinationAuthorship().getNomenclaturalTitle());
|
|
340 |
|
|
341 |
//name without combination author , only to check if above fix for #5618 works correctly
|
|
342 |
fullNameString = "Gordonia moaensis (Vict.)";
|
|
343 |
name = parser.parseFullName(fullNameString);
|
|
344 |
assertFalse(name.hasProblem());
|
|
345 |
assertNull(name.getCombinationAuthorship());
|
|
346 |
assertNotNull(name.getBasionymAuthorship());
|
|
347 |
assertEquals("Vict.", name.getBasionymAuthorship().getNomenclaturalTitle());
|
|
348 |
|
335 |
349 |
}
|
336 |
350 |
|
337 |
351 |
@Test
|
... | ... | |
1132 |
1146 |
|
1133 |
1147 |
//volume, edition
|
1134 |
1148 |
String strNoSeparator = "Abies alba Mill. Sp. Pl. ed. 3, 4(5): 455. 1987";
|
1135 |
|
NonViralName<?> nameNoSeparator = parser.parseReferencedName(strNoSeparator, ICBN, rankSpecies);
|
|
1149 |
NonViralName<?> nameNoSeparator = parser.parseReferencedName(strNoSeparator, ICNAFP, rankSpecies);
|
1136 |
1150 |
assertTrue(nameNoSeparator.hasProblem());
|
1137 |
1151 |
list = nameNoSeparator.getParsingProblems();
|
1138 |
1152 |
assertTrue("Problem is missing name-reference separator", list.contains(ParserProblem.NameReferenceSeparation));
|
... | ... | |
1235 |
1249 |
|
1236 |
1250 |
|
1237 |
1251 |
String testParsable = "Pithecellobium macrostachyum Benth.";
|
1238 |
|
assertTrue(isParsable(testParsable, ICBN));
|
|
1252 |
assertTrue(isParsable(testParsable, ICNAFP));
|
1239 |
1253 |
|
1240 |
1254 |
testParsable = "Pithecellobium macrostachyum (Benth.)";
|
1241 |
|
assertTrue(isParsable(testParsable, ICBN));
|
|
1255 |
assertTrue(isParsable(testParsable, ICNAFP));
|
1242 |
1256 |
|
1243 |
1257 |
testParsable = "Pithecellobium macrostachyum (Benth., 1845)";
|
1244 |
1258 |
assertTrue(isParsable(testParsable, NomenclaturalCode.ICZN));
|
1245 |
1259 |
|
1246 |
1260 |
testParsable = "Pithecellobium macrostachyum L., Sp. Pl. 3: n\u00B0 123. 1753."; //00B0 is degree character
|
1247 |
|
assertTrue(isParsable(testParsable, ICBN));
|
|
1261 |
assertTrue(isParsable(testParsable, ICNAFP));
|
1248 |
1262 |
|
1249 |
1263 |
testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. Mitt.-Eur. 6: 1285. 1929";
|
1250 |
|
assertTrue("Reference title should support special characters as separators like - and &", isParsable(testParsable, ICBN));
|
|
1264 |
assertTrue("Reference title should support special characters as separators like - and &", isParsable(testParsable, ICNAFP));
|
1251 |
1265 |
|
1252 |
1266 |
testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. Mitt.&Eur. 6: 1285. 1929";
|
1253 |
|
assertTrue("Reference title should support special characters as separators like - and &", isParsable(testParsable, ICBN));
|
|
1267 |
assertTrue("Reference title should support special characters as separators like - and &", isParsable(testParsable, ICNAFP));
|
1254 |
1268 |
|
1255 |
1269 |
testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. Mitt.-Eur.& 6: 1285. 1929";
|
1256 |
|
assertFalse("Reference title should not support special characters like - and & at the end of the title", isParsable(testParsable, ICBN));
|
1257 |
|
assertTrue("Problem must be reference title", getProblems(testParsable, ICBN).
|
|
1270 |
assertFalse("Reference title should not support special characters like - and & at the end of the title", isParsable(testParsable, ICNAFP));
|
|
1271 |
assertTrue("Problem must be reference title", getProblems(testParsable, ICNAFP).
|
1258 |
1272 |
contains(ParserProblem.UnparsableReferenceTitle));
|
1259 |
1273 |
|
1260 |
1274 |
testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. Mitt.:Eur. 6: 1285. 1929";
|
1261 |
|
assertFalse("Reference title should not support detail separator", isParsable(testParsable, ICBN));
|
1262 |
|
assertTrue("Problem must be reference title", getProblems(testParsable, ICBN).
|
|
1275 |
assertFalse("Reference title should not support detail separator", isParsable(testParsable, ICNAFP));
|
|
1276 |
assertTrue("Problem must be reference title", getProblems(testParsable, ICNAFP).
|
1263 |
1277 |
contains(ParserProblem.UnparsableReferenceTitle));
|
1264 |
1278 |
|
1265 |
1279 |
testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. (Mitt.) 6: 1285. 1929";
|
1266 |
|
assertTrue("Reference title should support brackets", isParsable(testParsable, ICBN));
|
|
1280 |
assertTrue("Reference title should support brackets", isParsable(testParsable, ICNAFP));
|
1267 |
1281 |
|
1268 |
1282 |
testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. (Mitt.) 6: 1285. 1929";
|
1269 |
|
assertTrue("Reference title should support brackets", isParsable(testParsable, ICBN));
|
|
1283 |
assertTrue("Reference title should support brackets", isParsable(testParsable, ICNAFP));
|
1270 |
1284 |
|
1271 |
1285 |
testParsable = "Hieracium lachenalii Zahn, nom. illeg.";
|
1272 |
|
assertTrue("Reference should not be obligatory if a nom status exist", isParsable(testParsable, ICBN));
|
|
1286 |
assertTrue("Reference should not be obligatory if a nom status exist", isParsable(testParsable, ICNAFP));
|
1273 |
1287 |
|
1274 |
1288 |
testParsable = "Hieracium lachenalii, nom. illeg.";
|
1275 |
|
assertTrue("Authorship should not be obligatory if followed by nom status", isParsable(testParsable, ICBN));
|
|
1289 |
assertTrue("Authorship should not be obligatory if followed by nom status", isParsable(testParsable, ICNAFP));
|
1276 |
1290 |
|
1277 |
1291 |
testParsable = "Hieracium lachenalii, Ill. Fl. (Mitt.) 6: 1285. 1929";
|
1278 |
|
assertFalse("Author is obligatory if followed by reference", isParsable(testParsable, ICBN));
|
1279 |
|
assertTrue("Problem must be name-reference separation", getProblems(testParsable, ICBN).
|
|
1292 |
assertFalse("Author is obligatory if followed by reference", isParsable(testParsable, ICNAFP));
|
|
1293 |
assertTrue("Problem must be name-reference separation", getProblems(testParsable, ICNAFP).
|
1280 |
1294 |
contains(ParserProblem.NameReferenceSeparation));
|
1281 |
1295 |
|
1282 |
1296 |
testParsable = "Hieracium lachenalii in Hegi, Ill. Fl. (Mitt.) 6: 1285. 1929";
|
1283 |
|
assertFalse("Author is obligatory if followed by reference", isParsable(testParsable, ICBN));
|
1284 |
|
assertTrue("Problem must be name-reference separation", getProblems(testParsable, ICBN).
|
|
1297 |
assertFalse("Author is obligatory if followed by reference", isParsable(testParsable, ICNAFP));
|
|
1298 |
assertTrue("Problem must be name-reference separation", getProblems(testParsable, ICNAFP).
|
1285 |
1299 |
contains(ParserProblem.NameReferenceSeparation));
|
1286 |
1300 |
|
1287 |
1301 |
testParsable = "Abies alba Mill. var. alba";
|
1288 |
|
assertTrue("Autonym problem", isParsable(testParsable, ICBN));
|
|
1302 |
assertTrue("Autonym problem", isParsable(testParsable, ICNAFP));
|
1289 |
1303 |
|
1290 |
1304 |
testParsable = "Scleroblitum abc Ulbr. in Engler & Prantl, Nat. Pflanzenfam., ed. 2, 16c: 495. 1934.";
|
1291 |
|
assertTrue("Volume with subdivision", isParsable(testParsable, ICBN));
|
|
1305 |
assertTrue("Volume with subdivision", isParsable(testParsable, ICNAFP));
|
1292 |
1306 |
|
1293 |
1307 |
|
1294 |
1308 |
testParsable = "Hieracium antarcticum d'Urv. in M\u00E9m. Soc. Linn. Paris 4: 608. 1826";
|
1295 |
1309 |
// testParsable = "Hieracium antarcticum Urv. in M\u00E9m. Soc. Linn. Paris 4: 608. 1826";
|
1296 |
|
assertTrue("Name with apostrophe is not parsable", isParsable(testParsable, ICBN));
|
|
1310 |
assertTrue("Name with apostrophe is not parsable", isParsable(testParsable, ICNAFP));
|
1297 |
1311 |
|
1298 |
1312 |
testParsable = "Cichorium intybus subsp. glaucum (Hoffmanns. & Link) Tzvelev in Komarov, Fl. SSSR 29: 17. 1964";
|
1299 |
|
assertTrue("Reference containing a word in uppercase is not parsable", isParsable(testParsable, ICBN));
|
|
1313 |
assertTrue("Reference containing a word in uppercase is not parsable", isParsable(testParsable, ICNAFP));
|
1300 |
1314 |
|
1301 |
1315 |
|
1302 |
1316 |
}
|
... | ... | |
1398 |
1412 |
Assert.assertEquals("If this line reached everything should be ok", "Milichiidae", nvn.getGenusOrUninomial());
|
1399 |
1413 |
|
1400 |
1414 |
String anotherExample = "Scorzonera hispanica var. brevifolia Boiss. & Balansa in Boissier, Diagn. Pl. Orient., ser. 2 6: 119. 1859.";
|
1401 |
|
nvn = this.parser.parseReferencedName(anotherExample, ICBN, null);
|
|
1415 |
nvn = this.parser.parseReferencedName(anotherExample, ICNAFP, null);
|
1402 |
1416 |
parsingProblem = nvn.getParsingProblem();
|
1403 |
1417 |
Assert.assertEquals("Problem should be 0", 0, parsingProblem);
|
1404 |
1418 |
Assert.assertEquals("Titlecache", "Scorzonera hispanica var. brevifolia Boiss. & Balansa", nvn.getTitleCache());
|
... | ... | |
1406 |
1420 |
|
1407 |
1421 |
String unparsable = "Taraxacum nevskii L., Trudy Bot. Inst. Nauk S.S.S.R., Ser. 1, Fl. Sist. Vyssh. Rast. 4: 293. 1937.";
|
1408 |
1422 |
// String unparsableA = "Taraxacum nevskii L. in Trudy Bot. Inst. Nauk: 293. 1937.";
|
1409 |
|
nvn = this.parser.parseReferencedName(unparsable, ICBN, null);
|
|
1423 |
nvn = this.parser.parseReferencedName(unparsable, ICNAFP, null);
|
1410 |
1424 |
Assert.assertEquals("Titlecache", "Taraxacum nevskii L.", nvn.getTitleCache());
|
1411 |
1425 |
Assert.assertEquals("If this line reached everything should be ok", "Taraxacum", nvn.getGenusOrUninomial());
|
1412 |
1426 |
parsingProblem = nvn.getParsingProblem();
|
... | ... | |
1414 |
1428 |
|
1415 |
1429 |
String unparsable2 = "Hieracium pxxx Dahlst., Kongl. Svenska Vetensk. Acad. Handl. ser. 2, 26(3): 255. 1894";
|
1416 |
1430 |
// String unparsable2A = "Hieracium pxxx Dahlst., Kongl Svenska Vetensk Acad Handl, 26: 255. 1894.";
|
1417 |
|
nvn = this.parser.parseReferencedName(unparsable2, ICBN, null);
|
|
1431 |
nvn = this.parser.parseReferencedName(unparsable2, ICNAFP, null);
|
1418 |
1432 |
Assert.assertEquals("Titlecache", "Hieracium pxxx Dahlst.", nvn.getTitleCache());
|
1419 |
1433 |
Assert.assertEquals("If this line reached everything should be ok", "Hieracium", nvn.getGenusOrUninomial());
|
1420 |
1434 |
parsingProblem = nvn.getParsingProblem();
|
... | ... | |
1422 |
1436 |
|
1423 |
1437 |
|
1424 |
1438 |
String again = "Adiantum emarginatum Bory ex. Willd., Species Plantarum, ed. 4,5,1: 449,450. 1810";
|
1425 |
|
nvn = this.parser.parseReferencedName(again, ICBN, null);
|
|
1439 |
nvn = this.parser.parseReferencedName(again, ICNAFP, null);
|
1426 |
1440 |
Assert.assertEquals("Titlecache", "Adiantum emarginatum Bory ex Willd.", nvn.getTitleCache());
|
1427 |
1441 |
Assert.assertEquals("If this line reached everything should be ok", "Adiantum", nvn.getGenusOrUninomial());
|
1428 |
1442 |
|
... | ... | |
1430 |
1444 |
|
1431 |
1445 |
@Test
|
1432 |
1446 |
public final void testSeriesPart(){
|
1433 |
|
Pattern seriesPattern = Pattern.compile(NonViralNameParserImpl.pSeriesPart);
|
|
1447 |
Pattern seriesPattern = Pattern.compile(NonViralNameParserImplRegExBase.pSeriesPart);
|
1434 |
1448 |
Matcher matcher = seriesPattern.matcher("ser. 2");
|
1435 |
1449 |
Assert.assertTrue("", matcher.matches());
|
1436 |
1450 |
}
|
Fix combination author without space parsing #5618