use of eu.etaxonomy.cdm.model.reference.IBookSection in project cdmlib by cybertaxonomy.
the class TaxonXExtractor method getReferenceWithType.
protected Reference getReferenceWithType(int reftype) {
Reference ref = null;
switch(reftype) {
case 1:
ref = ReferenceFactory.newGeneric();
break;
case 2:
IBook tmp = ReferenceFactory.newBook();
ref = (Reference) tmp;
break;
case 3:
ref = ReferenceFactory.newArticle();
break;
case 4:
IBookSection tmp2 = ReferenceFactory.newBookSection();
ref = (Reference) tmp2;
break;
case 5:
ref = ReferenceFactory.newJournal();
break;
case 6:
ref = ReferenceFactory.newPrintSeries();
break;
case 7:
ref = ReferenceFactory.newThesis();
break;
default:
break;
}
return ref;
}
use of eu.etaxonomy.cdm.model.reference.IBookSection in project cdmlib by cybertaxonomy.
the class NonViralNameParserImplTest method testParseReferencedName.
/**
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseReferencedName(NonViralName, java.lang.String, eu.etaxonomy.cdm.model.name.Rank, boolean)(, )}.
*/
@Test
public final void testParseReferencedName() {
try {
Method parseMethod = parser.getClass().getDeclaredMethod("parseReferencedName", String.class, NomenclaturalCode.class, Rank.class);
testName_StringNomcodeRank(parseMethod);
} catch (Exception e) {
e.printStackTrace();
assertTrue(false);
}
// null
String strNull = null;
Rank rankSpecies = Rank.SPECIES();
INonViralName nameNull = parser.parseReferencedName(strNull, null, rankSpecies);
assertNull(nameNull);
// Empty
String strEmpty = "";
INonViralName nameEmpty = parser.parseReferencedName(strEmpty, null, rankSpecies);
assertFalse(nameEmpty.hasProblem());
assertEquals(strEmpty, nameEmpty.getFullTitleCache());
assertNull(nameEmpty.getNomenclaturalMicroReference());
// Whitespaces
String strFullWhiteSpcaceAndDot = "Abies alba Mill., Sp. Pl. 4: 455 . 1987 .";
INonViralName namefullWhiteSpcaceAndDot = parser.parseReferencedName(strFullWhiteSpcaceAndDot, null, rankSpecies);
assertFullRefStandard(namefullWhiteSpcaceAndDot);
assertTrue(namefullWhiteSpcaceAndDot.getNomenclaturalReference().getType().equals(eu.etaxonomy.cdm.model.reference.ReferenceType.Book));
assertEquals("Abies alba Mill., Sp. Pl. 4: 455. 1987", namefullWhiteSpcaceAndDot.getFullTitleCache());
// Book
String fullReference = "Abies alba Mill., Sp. Pl. 4: 455. 1987";
INonViralName name1 = parser.parseReferencedName(fullReference, null, rankSpecies);
assertFullRefStandard(name1);
assertTrue(name1.getNomenclaturalReference().getType().equals(eu.etaxonomy.cdm.model.reference.ReferenceType.Book));
assertEquals(fullReference, name1.getFullTitleCache());
assertTrue("Name author and reference author should be the same", name1.getCombinationAuthorship() == name1.getNomenclaturalReference().getAuthorship());
// Book Section
fullReference = "Abies alba Mill. in Otto, Sp. Pl. 4(6): 455. 1987";
INonViralName name2 = parser.parseReferencedName(fullReference + ".", null, rankSpecies);
assertFullRefNameStandard(name2);
assertEquals(fullReference, name2.getFullTitleCache());
assertFalse(name2.hasProblem());
INomenclaturalReference ref = name2.getNomenclaturalReference();
assertEquals(ReferenceType.BookSection, ((Reference) ref).getType());
IBookSection bookSection = (IBookSection) ref;
IBook inBook = bookSection.getInBook();
assertNotNull(inBook);
assertNotNull(inBook.getAuthorship());
assertEquals("Otto", inBook.getAuthorship().getTitleCache());
assertEquals("Otto: Sp. Pl. 4(6)", inBook.getTitleCache());
assertEquals("Sp. Pl.", inBook.getAbbrevTitle());
assertEquals("4(6)", inBook.getVolume());
assertTrue("Name author and reference author should be the same", name2.getCombinationAuthorship() == name2.getNomenclaturalReference().getAuthorship());
// Article
fullReference = "Abies alba Mill. in Sp. Pl. 4(6): 455. 1987";
INonViralName name3 = parser.parseReferencedName(fullReference, null, rankSpecies);
assertFullRefNameStandard(name3);
name3.setTitleCache(null);
assertEquals(fullReference, name3.getFullTitleCache());
assertFalse(name3.hasProblem());
ref = name3.getNomenclaturalReference();
assertEquals(eu.etaxonomy.cdm.model.reference.ReferenceType.Article, ref.getType());
// Article article = (Article)ref;
IJournal journal = ((IArticle) ref).getInJournal();
assertNotNull(journal);
// assertEquals("Sp. Pl. 4(6)", inBook.getTitleCache());
assertEquals("Sp. Pl.", ((Reference) journal).getTitleCache());
assertEquals("Sp. Pl.", journal.getAbbrevTitle());
assertEquals("4(6)", ((IArticle) ref).getVolume());
assertTrue("Name author and reference author should be the same", name3.getCombinationAuthorship() == name3.getNomenclaturalReference().getAuthorship());
// Article with volume range
fullReference = "Abies alba Mill. in Sp. Pl. 4(1-2): 455. 1987";
INonViralName name3a = parser.parseReferencedName(fullReference, null, rankSpecies);
name3a.setTitleCache(null);
assertEquals(fullReference, name3a.getFullTitleCache());
assertFalse(name3a.hasProblem());
ref = name3a.getNomenclaturalReference();
assertEquals(eu.etaxonomy.cdm.model.reference.ReferenceType.Article, ref.getType());
assertEquals("4(1-2)", ((IArticle) ref).getVolume());
// SoftArticle - having "," on position > 4
String journalTitle = "Bull. Soc. Bot.France. Louis., Roi";
String yearPart = " 1987 - 1989";
String parsedYearFormatted = "1987" + SEP + "1989";
String fullReferenceWithoutYear = "Abies alba Mill. in " + journalTitle + " 4(6): 455.";
fullReference = fullReferenceWithoutYear + yearPart;
String fullReferenceWithEnd = fullReference + ".";
INonViralName name4 = parser.parseReferencedName(fullReferenceWithEnd, null, rankSpecies);
assertFalse(name4.hasProblem());
assertFullRefNameStandard(name4);
assertEquals(fullReferenceWithoutYear + " " + parsedYearFormatted, name4.getFullTitleCache());
ref = name4.getNomenclaturalReference();
assertEquals(ReferenceType.Article, ref.getType());
// article = (Article)ref;
assertEquals(parsedYearFormatted, ref.getYear());
journal = ((IArticle) ref).getInJournal();
assertNotNull(journal);
assertEquals(journalTitle, ((Reference) journal).getTitleCache());
assertEquals(journalTitle, journal.getAbbrevTitle());
assertEquals("4(6)", ((IArticle) ref).getVolume());
// Zoo name
String strNotParsableZoo = "Abies alba M., 1923, Sp. P. xxwer4352, nom. inval.";
IZoologicalName nameZooRefNotParsabel = parser.parseReferencedName(strNotParsableZoo, null, null);
assertTrue(nameZooRefNotParsabel.hasProblem());
List<ParserProblem> list = nameZooRefNotParsabel.getParsingProblems();
assertTrue("List must contain detail and year warning ", list.contains(ParserProblem.CheckDetailOrYear));
assertEquals(21, nameZooRefNotParsabel.getProblemStarts());
assertEquals(37, nameZooRefNotParsabel.getProblemEnds());
assertTrue(nameZooRefNotParsabel.getNomenclaturalReference().hasProblem());
list = nameZooRefNotParsabel.getNomenclaturalReference().getParsingProblems();
assertTrue("List must contain detail and year warning ", list.contains(ParserProblem.CheckDetailOrYear));
assertEquals(NomenclaturalCode.ICZN, nameZooRefNotParsabel.getNameType());
assertEquals(Integer.valueOf(1923), nameZooRefNotParsabel.getPublicationYear());
assertEquals(1, nameZooRefNotParsabel.getStatus().size());
String strZooNameSineYear = "Homo sapiens L., 1758, Sp. An. 3: 345";
IZoologicalName nameZooNameSineYear = parser.parseReferencedName(strZooNameSineYear);
assertFalse(nameZooNameSineYear.hasProblem());
assertEquals("Name without reference year must have year", (Integer) 1758, nameZooNameSineYear.getPublicationYear());
assertEquals("Name without reference year must have year", "1758", nameZooNameSineYear.getNomenclaturalReference().getYear());
String strZooNameNewCombination = "Homo sapiens (L., 1758) Mill., 1830, Sp. An. 3: 345";
IZoologicalName nameZooNameNewCombination = parser.parseReferencedName(strZooNameNewCombination);
assertTrue(nameZooNameNewCombination.hasProblem());
list = nameZooNameNewCombination.getParsingProblems();
assertTrue("List must contain new combination has publication warning ", list.contains(ParserProblem.NewCombinationHasPublication));
assertEquals(35, nameZooNameNewCombination.getProblemStarts());
assertEquals(51, nameZooNameNewCombination.getProblemEnds());
// Special MicroRefs
String strSpecDetail1 = "Abies alba Mill. in Sp. Pl. 4(6): [455]. 1987";
INonViralName nameSpecDet1 = parser.parseReferencedName(strSpecDetail1 + ".", null, rankSpecies);
assertFalse(nameSpecDet1.hasProblem());
assertEquals(strSpecDetail1, nameSpecDet1.getFullTitleCache());
assertEquals("[455]", nameSpecDet1.getNomenclaturalMicroReference());
// Special MicroRefs
String strSpecDetail2 = "Abies alba Mill. in Sp. Pl. 4(6): couv. 2. 1987";
INonViralName nameSpecDet2 = parser.parseReferencedName(strSpecDetail2 + ".", null, rankSpecies);
assertFalse(nameSpecDet2.hasProblem());
assertEquals(strSpecDetail2, nameSpecDet2.getFullTitleCache());
assertEquals("couv. 2", nameSpecDet2.getNomenclaturalMicroReference());
// Special MicroRefs
String strSpecDetail3 = "Abies alba Mill. in Sp. Pl. 4(6): fig. 455. 1987";
INonViralName nameSpecDet3 = parser.parseReferencedName(strSpecDetail3 + ".", null, rankSpecies);
assertFalse(nameSpecDet3.hasProblem());
assertEquals(strSpecDetail3, nameSpecDet3.getFullTitleCache());
assertEquals("fig. 455", nameSpecDet3.getNomenclaturalMicroReference());
// Special MicroRefs
String strSpecDetail4 = "Abies alba Mill. in Sp. Pl. 4(6): fig. 455-567. 1987";
fullReference = strSpecDetail4 + ".";
INonViralName nameSpecDet4 = parser.parseReferencedName(fullReference, null, rankSpecies);
assertFalse(nameSpecDet4.hasProblem());
assertEquals(strSpecDetail4, nameSpecDet4.getFullTitleCache());
assertEquals("fig. 455-567", nameSpecDet4.getNomenclaturalMicroReference());
// Special MicroRefs
String strSpecDetail5 = "Abies alba Mill. in Sp. Pl. 4(6): Gard n\u00B0 4. 1987";
fullReference = strSpecDetail5 + ".";
INonViralName nameSpecDet5 = parser.parseReferencedName(fullReference, null, rankSpecies);
assertFalse(nameSpecDet5.hasProblem());
assertEquals(strSpecDetail5, nameSpecDet5.getFullTitleCache());
assertEquals("Gard n\u00B0 4", nameSpecDet5.getNomenclaturalMicroReference());
// Special MicroRefs
String strSpecDetail6 = "Abies alba Mill. in Sp. Pl. 4(6): 455a. 1987";
fullReference = strSpecDetail6 + ".";
INonViralName nameSpecDet6 = parser.parseReferencedName(fullReference, null, rankSpecies);
assertFalse(nameSpecDet6.hasProblem());
assertEquals(strSpecDetail6, nameSpecDet6.getFullTitleCache());
assertEquals("455a", nameSpecDet6.getNomenclaturalMicroReference());
// Special MicroRefs
String strSpecDetail7 = "Abies alba Mill. in Sp. Pl. 4(6): pp.455-457. 1987";
fullReference = strSpecDetail7 + ".";
INonViralName nameSpecDet7 = parser.parseReferencedName(fullReference, null, rankSpecies);
assertFalse(nameSpecDet7.hasProblem());
assertEquals(strSpecDetail7, nameSpecDet7.getFullTitleCache());
assertEquals("pp.455-457", nameSpecDet7.getNomenclaturalMicroReference());
// Special MicroRefs
String strSpecDetail8 = "Abies alba Mill. in Sp. Pl. 4(6): ppp.455-457. 1987";
INonViralName nameSpecDet8 = parser.parseReferencedName(strSpecDetail8, null, rankSpecies);
assertTrue(nameSpecDet8.hasProblem());
// TODO better start behind :
assertEquals(20, nameSpecDet8.getProblemStarts());
// TODO better stop after -457
assertEquals(51, nameSpecDet8.getProblemEnds());
// Special MicroRefs
String strSpecDetail9 = "Abies alba Mill. in Sp. Pl. 4(6): pp. 455 - 457. 1987";
INonViralName nameSpecDet9 = parser.parseReferencedName(strSpecDetail9, null, rankSpecies);
assertFalse(nameSpecDet9.hasProblem());
assertEquals(strSpecDetail9, nameSpecDet9.getFullTitleCache());
assertEquals("pp. 455 - 457", nameSpecDet9.getNomenclaturalMicroReference());
// Special MicroRefs
String strSpecDetail10 = "Abies alba Mill. in Sp. Pl. 4(6): p 455. 1987";
INonViralName nameSpecDet10 = parser.parseReferencedName(strSpecDetail10, null, rankSpecies);
assertFalse(nameSpecDet10.hasProblem());
assertEquals(strSpecDetail10, nameSpecDet10.getFullTitleCache());
assertEquals("p 455", nameSpecDet10.getNomenclaturalMicroReference());
// Special MicroRefs
String strSpecDetail11 = "Abies alba Mill. in Sp. Pl. 4(6): p. 455 - 457. 1987";
INonViralName nameSpecDet11 = parser.parseReferencedName(strSpecDetail11, null, rankSpecies);
assertTrue(nameSpecDet11.hasProblem());
list = nameSpecDet11.getParsingProblems();
assertTrue("Problem is Detail. Must be pp.", list.contains(ParserProblem.CheckDetailOrYear));
// TODO better start behind :
assertEquals(20, nameSpecDet8.getProblemStarts());
// TODO better stop after - 457
assertEquals(51, nameSpecDet8.getProblemEnds());
// no volume, no edition
String strNoVolume = "Abies alba Mill., Sp. Pl.: 455. 1987";
INonViralName nameNoVolume = parser.parseReferencedName(strNoVolume, null, rankSpecies);
assertFalse(nameNoVolume.hasProblem());
assertEquals(strNoVolume, nameNoVolume.getFullTitleCache());
assertEquals(null, ((IVolumeReference) (nameNoVolume.getNomenclaturalReference())).getVolume());
assertEquals(null, ((IBook) nameNoVolume.getNomenclaturalReference()).getEdition());
// volume, no edition
strNoVolume = "Abies alba Mill., Sp. Pl. 2: 455. 1987";
nameNoVolume = parser.parseReferencedName(strNoVolume, null, rankSpecies);
assertFalse(nameNoVolume.hasProblem());
assertEquals(strNoVolume, nameNoVolume.getFullTitleCache());
assertEquals("2", ((IVolumeReference) (nameNoVolume.getNomenclaturalReference())).getVolume());
assertEquals(null, ((IBook) (nameNoVolume.getNomenclaturalReference())).getEdition());
// no volume, edition
strNoVolume = "Abies alba Mill., Sp. Pl., ed. 3: 455. 1987";
nameNoVolume = parser.parseReferencedName(strNoVolume, null, rankSpecies);
assertFalse(nameNoVolume.hasProblem());
assertEquals(strNoVolume, nameNoVolume.getFullTitleCache());
assertEquals(null, ((IVolumeReference) (nameNoVolume.getNomenclaturalReference())).getVolume());
assertEquals("3", ((IBook) (nameNoVolume.getNomenclaturalReference())).getEdition());
// volume, edition
strNoVolume = "Abies alba Mill., Sp. Pl. ed. 3, 4(5): 455. 1987";
nameNoVolume = parser.parseReferencedName(strNoVolume, null, rankSpecies);
assertFalse(nameNoVolume.hasProblem());
assertEquals(strNoVolume.replace(" ed.", ", ed."), nameNoVolume.getFullTitleCache());
assertEquals("4(5)", ((IVolumeReference) (nameNoVolume.getNomenclaturalReference())).getVolume());
assertEquals("3", ((IBook) (nameNoVolume.getNomenclaturalReference())).getEdition());
String strUnparsableInRef = "Abies alba Mill. in -er46: 455. 1987";
INonViralName nameUnparsableInRef = parser.parseReferencedName(strUnparsableInRef, null, rankSpecies);
assertTrue(nameUnparsableInRef.hasProblem());
list = nameUnparsableInRef.getParsingProblems();
assertTrue("Unparsable title", list.contains(ParserProblem.UnparsableReferenceTitle));
assertEquals(strUnparsableInRef, nameUnparsableInRef.getFullTitleCache());
assertEquals(20, nameUnparsableInRef.getProblemStarts());
assertEquals(25, nameUnparsableInRef.getProblemEnds());
// volume, edition
String strNoSeparator = "Abies alba Mill. Sp. Pl. ed. 3, 4(5): 455. 1987";
INonViralName nameNoSeparator = parser.parseReferencedName(strNoSeparator, ICNAFP, rankSpecies);
assertTrue(nameNoSeparator.hasProblem());
list = nameNoSeparator.getParsingProblems();
assertTrue("Problem is missing name-reference separator", list.contains(ParserProblem.NameReferenceSeparation));
assertEquals(strNoSeparator, nameNoSeparator.getFullTitleCache());
// TODO better start behind Mill. (?)
assertEquals(10, nameNoSeparator.getProblemStarts());
// TODO better stop before :
assertEquals(47, nameNoSeparator.getProblemEnds());
String strUnparsableInRef2 = "Hieracium pepsicum L., My Bookkkk 1. 1903";
INonViralName nameUnparsableInRef2 = parser.parseReferencedName(strUnparsableInRef2, null, rankSpecies);
assertTrue(nameUnparsableInRef2.hasProblem());
list = nameUnparsableInRef2.getParsingProblems();
assertTrue("Problem detail", list.contains(ParserProblem.CheckDetailOrYear));
assertEquals(strUnparsableInRef2, nameUnparsableInRef2.getFullTitleCache());
assertEquals(23, nameUnparsableInRef2.getProblemStarts());
assertEquals(41, nameUnparsableInRef2.getProblemEnds());
String strUnparsableInRef3 = "Hieracium pespcim N., My Bookkkk 1. 1902";
INonViralName nameUnparsableInRef3 = parser.parseReferencedName(strUnparsableInRef3, null, null);
assertTrue(nameUnparsableInRef3.hasProblem());
list = nameUnparsableInRef3.getParsingProblems();
assertTrue("Problem detail", list.contains(ParserProblem.CheckDetailOrYear));
assertEquals(strUnparsableInRef3, nameUnparsableInRef3.getFullTitleCache());
assertEquals(22, nameUnparsableInRef3.getProblemStarts());
assertEquals(40, nameUnparsableInRef3.getProblemEnds());
String strUnparsableInRef4 = "Hieracium pepsicum (Hsllreterto) L., My Bookkkk 1. 1903";
INonViralName nameUnparsableInRef4 = parser.parseReferencedName(strUnparsableInRef4, null, null);
assertTrue(nameUnparsableInRef4.hasProblem());
list = nameUnparsableInRef4.getParsingProblems();
assertTrue("Problem detail", list.contains(ParserProblem.CheckDetailOrYear));
assertEquals(strUnparsableInRef4, nameUnparsableInRef4.getFullTitleCache());
assertEquals(37, nameUnparsableInRef4.getProblemStarts());
assertEquals(55, nameUnparsableInRef4.getProblemEnds());
String strSameName = "Hieracium pepcum (Hsllreterto) L., My Bokkk 1. 1903";
INonViralName nameSameName = nameUnparsableInRef4;
parser.parseReferencedName(nameSameName, strSameName, null, true);
assertTrue(nameSameName.hasProblem());
list = nameSameName.getParsingProblems();
assertTrue("Problem detail", list.contains(ParserProblem.CheckDetailOrYear));
assertEquals(strSameName, nameSameName.getFullTitleCache());
assertEquals(35, nameSameName.getProblemStarts());
assertEquals(51, nameSameName.getProblemEnds());
String strGenusUnparse = "Hieracium L., jlklk";
INonViralName nameGenusUnparse = parser.parseReferencedName(strGenusUnparse, null, null);
assertTrue(nameGenusUnparse.hasProblem());
list = nameGenusUnparse.getParsingProblems();
assertTrue("Problem detail", list.contains(ParserProblem.CheckDetailOrYear));
assertTrue("Problem uninomial", list.contains(ParserProblem.CheckRank));
assertEquals(strGenusUnparse, nameGenusUnparse.getFullTitleCache());
assertEquals(0, nameGenusUnparse.getProblemStarts());
assertEquals(19, nameGenusUnparse.getProblemEnds());
String strGenusUnparse2 = "Hieracium L., Per Luigi: 44. 1987";
INonViralName nameGenusUnparse2 = parser.parseReferencedName(strGenusUnparse2, null, Rank.FAMILY());
assertFalse(nameGenusUnparse2.hasProblem());
assertEquals(strGenusUnparse2, nameGenusUnparse2.getFullTitleCache());
assertEquals(-1, nameGenusUnparse2.getProblemStarts());
assertEquals(-1, nameGenusUnparse2.getProblemEnds());
String strBookSection2 = "Hieracium vulgatum subsp. acuminatum (Jord.) Zahn in Schinz & Keller, Fl. Schweiz, ed. 2, 2: 288. 1905-1907";
String strBookSection2NoComma = "Hieracium vulgatum subsp. acuminatum (Jord.) Zahn in Schinz & Keller, Fl. Schweiz ed. 2, 2: 288. 1905-1907";
INonViralName nameBookSection2 = parser.parseReferencedName(strBookSection2, null, null);
assertFalse(nameBookSection2.hasProblem());
nameBookSection2.setFullTitleCache(null, false);
assertEquals(strBookSection2NoComma.replace(" ed.", ", ed.").replace("-", SEP), nameBookSection2.getFullTitleCache());
assertEquals(-1, nameBookSection2.getProblemStarts());
assertEquals(-1, nameBookSection2.getProblemEnds());
assertNull((nameBookSection2.getNomenclaturalReference()).getDatePublished().getStart());
assertEquals("1905" + SEP + "1907", ((IBookSection) nameBookSection2.getNomenclaturalReference()).getInBook().getDatePublished().getYear());
String strBookSection = "Hieracium vulgatum subsp. acuminatum (Jord.) Zahn in Schinz & Keller, Fl. Schweiz ed. 2, 2: 288. 1905";
INonViralName nameBookSection = parser.parseReferencedName(strBookSection, null, null);
assertFalse(nameBookSection.hasProblem());
assertEquals(strBookSection.replace(" ed.", ", ed."), nameBookSection.getFullTitleCache());
assertEquals(-1, nameBookSection.getProblemStarts());
assertEquals(-1, nameBookSection.getProblemEnds());
assertNull(((IBookSection) nameBookSection.getNomenclaturalReference()).getInBook().getDatePublished().getStart());
assertEquals("1905", ((IBookSection) nameBookSection.getNomenclaturalReference()).getDatePublished().getYear());
String strXXXs = "Abies alba, Soer der 1987";
INonViralName problemName = parser.parseReferencedName(strXXXs, null, null);
assertTrue(problemName.hasProblem());
list = problemName.getParsingProblems();
assertTrue("Problem must be name-reference separation", list.contains(ParserProblem.NameReferenceSeparation));
parser.parseReferencedName(problemName, strBookSection, null, true);
assertFalse(problemName.hasProblem());
problemName = parser.parseFullName(strXXXs, null, null);
assertTrue(problemName.hasProblem());
list = problemName.getParsingProblems();
assertTrue("Name part must be unparsable", list.contains(ParserProblem.UnparsableNamePart));
String testParsable = "Pithecellobium macrostachyum Benth.";
assertTrue(isParsable(testParsable, ICNAFP));
testParsable = "Pithecellobium macrostachyum (Benth.)";
assertTrue(isParsable(testParsable, ICNAFP));
testParsable = "Pithecellobium macrostachyum (Benth., 1845)";
assertTrue(isParsable(testParsable, NomenclaturalCode.ICZN));
// 00B0 is degree character
testParsable = "Pithecellobium macrostachyum L., Sp. Pl. 3: n\u00B0 123. 1753.";
assertTrue(isParsable(testParsable, ICNAFP));
testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. Mitt.-Eur. 6: 1285. 1929";
assertTrue("Reference title should support special characters as separators like - and &", isParsable(testParsable, ICNAFP));
testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. Mitt.&Eur. 6: 1285. 1929";
assertTrue("Reference title should support special characters as separators like - and &", isParsable(testParsable, ICNAFP));
testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. Mitt.-Eur.& 6: 1285. 1929";
assertFalse("Reference title should not support special characters like - and & at the end of the title", isParsable(testParsable, ICNAFP));
assertTrue("Problem must be reference title", getProblems(testParsable, ICNAFP).contains(ParserProblem.UnparsableReferenceTitle));
testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. Mitt.:Eur. 6: 1285. 1929";
assertFalse("Reference title should not support detail separator", isParsable(testParsable, ICNAFP));
assertTrue("Problem must be reference title", getProblems(testParsable, ICNAFP).contains(ParserProblem.UnparsableReferenceTitle));
testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. (Mitt.) 6: 1285. 1929";
assertTrue("Reference title should support brackets", isParsable(testParsable, ICNAFP));
testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. (Mitt.) 6: 1285. 1929";
assertTrue("Reference title should support brackets", isParsable(testParsable, ICNAFP));
testParsable = "Hieracium lachenalii Zahn, nom. illeg.";
assertTrue("Reference should not be obligatory if a nom status exist", isParsable(testParsable, ICNAFP));
testParsable = "Hieracium lachenalii, nom. illeg.";
assertTrue("Authorship should not be obligatory if followed by nom status", isParsable(testParsable, ICNAFP));
testParsable = "Hieracium lachenalii, Ill. Fl. (Mitt.) 6: 1285. 1929";
assertFalse("Author is obligatory if followed by reference", isParsable(testParsable, ICNAFP));
assertTrue("Problem must be name-reference separation", getProblems(testParsable, ICNAFP).contains(ParserProblem.NameReferenceSeparation));
testParsable = "Hieracium lachenalii in Hegi, Ill. Fl. (Mitt.) 6: 1285. 1929";
assertFalse("Author is obligatory if followed by reference", isParsable(testParsable, ICNAFP));
assertTrue("Problem must be name-reference separation", getProblems(testParsable, ICNAFP).contains(ParserProblem.NameReferenceSeparation));
testParsable = "Abies alba Mill. var. alba";
assertTrue("Autonym problem", isParsable(testParsable, ICNAFP));
testParsable = "Scleroblitum abc Ulbr. in Engler & Prantl, Nat. Pflanzenfam., ed. 2, 16c: 495. 1934.";
assertTrue("Volume with subdivision", isParsable(testParsable, ICNAFP));
testParsable = "Hieracium antarcticum d'Urv. in M\u00E9m. Soc. Linn. Paris 4: 608. 1826";
// testParsable = "Hieracium antarcticum Urv. in M\u00E9m. Soc. Linn. Paris 4: 608. 1826";
assertTrue("Name with apostrophe is not parsable", isParsable(testParsable, ICNAFP));
testParsable = "Cichorium intybus subsp. glaucum (Hoffmanns. & Link) Tzvelev in Komarov, Fl. SSSR 29: 17. 1964";
assertTrue("Reference containing a word in uppercase is not parsable", isParsable(testParsable, ICNAFP));
testParsable = "Silene broussonetiana Schott ex Webb & Berthel., Hist. Nat. Iles Canaries 3(2,1): 141. 1840";
assertTrue("Reference with volume with 2 number in brackets is not parsable", isParsable(testParsable, ICNAFP));
testParsable = "Silene broussonetiana Schott ex Webb & Berthel., Hist. Nat. Iles Canaries 3(2, 1): 141. 1840";
assertTrue("Reference with volume with 2 number in brackets is not parsable", isParsable(testParsable, ICNAFP));
}
use of eu.etaxonomy.cdm.model.reference.IBookSection in project cdmlib by cybertaxonomy.
the class ReferenceValidationTest method testLevel3ValidationWithInValidInReference.
@Test
public final void testLevel3ValidationWithInValidInReference() {
IBookSection bookSection = ReferenceFactory.newBookSection();
bookSection.setTitleCache("test", true);
bookSection.setTitle("");
bookSection.setInReference((Reference) book);
Set<ConstraintViolation<IBookSection>> constraintViolations = validator.validate(bookSection, Level3.class);
assertTrue("There should be one constraint violation as this book has a valid Ref", constraintViolations.size() == 0);
Reference article = ReferenceFactory.newArticle();
article.setTitleCache("article", true);
bookSection.setInReference(article);
constraintViolations = validator.validate(bookSection, Level3.class);
// assertTrue("There should be a constraint violation as this book has an invalid inReference",constraintViolations.size() == 1);
assertHasConstraintOnValidator((Set) constraintViolations, InReferenceValidator.class);
}
use of eu.etaxonomy.cdm.model.reference.IBookSection in project cdmlib by cybertaxonomy.
the class ReferenceDefaultCacheStrategyTest method testBookSectionRealExample.
@Test
public void testBookSectionRealExample() {
Team bookTeam = Team.NewTitledInstance("Chaudhary S. A.(ed.)", "Chaudhary S. A.(ed.)");
IBook book = ReferenceFactory.newBook();
book.setTitle("Flora of the Kingdom of Saudi Arabia");
book.setAuthorship(bookTeam);
book.setVolume("2(3)");
book.setPlacePublished("Riyadh");
book.setPublisher("National Herbarium");
book.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(2000));
Team sectionTeam = Team.NewTitledInstance("Chaudhary S. A.", "Chaudhary S. A.");
IBookSection bookSection = ReferenceFactory.newBookSection();
bookSection.setTitle("73. Hedypnois - 87. Crepis");
bookSection.setInBook(book);
bookSection.setAuthorship(sectionTeam);
bookSection.setPages("222-251");
Assert.assertEquals("Chaudhary S. A. 2000: 73. Hedypnois - 87. Crepis, pp. 222-251. " + UTF8.EN_DASH + " In: Chaudhary S. A.(ed.), Flora of the Kingdom of Saudi Arabia 2(3)", bookSection.getTitleCache());
}
use of eu.etaxonomy.cdm.model.reference.IBookSection in project cdmlib by cybertaxonomy.
the class MatchStrategyFactoryTest method getMatchingFullBookSection.
private IBookSection getMatchingFullBookSection() {
IBookSection bookSection = ReferenceFactory.newBookSection();
bookSection.setAuthorship(getDefaultFullPerson());
bookSection.setInBook(getDefaultFullBook());
bookSection.setDatePublished(TimePeriodParser.parseStringVerbatim("1892"));
((Reference) bookSection).updateCaches();
return bookSection;
}
Aggregations