Revision bf3b1132
Added by Andreas Müller almost 4 years ago
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/parser/NonViralNameParserImplTest.java | ||
---|---|---|
35 | 35 |
import eu.etaxonomy.cdm.model.agent.Person; |
36 | 36 |
import eu.etaxonomy.cdm.model.agent.Team; |
37 | 37 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
38 |
import eu.etaxonomy.cdm.model.common.TimePeriod; |
|
38 | 39 |
import eu.etaxonomy.cdm.model.name.HybridRelationship; |
39 | 40 |
import eu.etaxonomy.cdm.model.name.IBotanicalName; |
40 | 41 |
import eu.etaxonomy.cdm.model.name.INonViralName; |
... | ... | |
66 | 67 |
private static final NomenclaturalCode ICNAFP = NomenclaturalCode.ICNAFP; |
67 | 68 |
private static final NomenclaturalCode ICZN = NomenclaturalCode.ICZN; |
68 | 69 |
|
70 |
private static final String SEP = TimePeriod.SEP; |
|
71 |
|
|
69 | 72 |
private static final Logger logger = Logger.getLogger(NonViralNameParserImplTest.class); |
70 | 73 |
|
71 | 74 |
final private String strNameAbies1 = "Abies alba"; |
... | ... | |
1305 | 1308 |
String journalTitle = "Bull. Soc. Bot.France. Louis., Roi"; |
1306 | 1309 |
String yearPart = " 1987 - 1989"; |
1307 | 1310 |
String parsedYear = "1987-1989"; |
1311 |
String parsedYearFormatted = "1987"+SEP+"1989"; |
|
1308 | 1312 |
String fullReferenceWithoutYear = "Abies alba Mill. in " + journalTitle + " 4(6): 455."; |
1309 | 1313 |
fullReference = fullReferenceWithoutYear + yearPart; |
1310 | 1314 |
String fullReferenceWithEnd = fullReference + "."; |
1311 | 1315 |
INonViralName name4 = parser.parseReferencedName(fullReferenceWithEnd, null, rankSpecies); |
1312 | 1316 |
assertFalse(name4.hasProblem()); |
1313 | 1317 |
assertFullRefNameStandard(name4); |
1314 |
assertEquals(fullReferenceWithoutYear + " " + parsedYear, name4.getFullTitleCache()); |
|
1318 |
assertEquals(fullReferenceWithoutYear + " " + parsedYearFormatted, name4.getFullTitleCache());
|
|
1315 | 1319 |
ref = name4.getNomenclaturalReference(); |
1316 | 1320 |
assertEquals(ReferenceType.Article, ref.getType()); |
1317 | 1321 |
//article = (Article)ref; |
1318 |
assertEquals(parsedYear, ref.getYear()); |
|
1322 |
assertEquals(parsedYearFormatted, ref.getYear());
|
|
1319 | 1323 |
journal = ((IArticle)ref).getInJournal(); |
1320 | 1324 |
assertNotNull(journal); |
1321 | 1325 |
assertEquals(journalTitle, ((Reference) journal).getTitleCache()); |
... | ... | |
1554 | 1558 |
parser.parseReferencedName(strBookSection2, null, null); |
1555 | 1559 |
assertFalse(nameBookSection2.hasProblem()); |
1556 | 1560 |
nameBookSection2.setFullTitleCache(null, false); |
1557 |
assertEquals(strBookSection2NoComma.replace(" ed.", ", ed."), nameBookSection2.getFullTitleCache()); |
|
1561 |
assertEquals(strBookSection2NoComma.replace(" ed.", ", ed.").replace("-",SEP), nameBookSection2.getFullTitleCache());
|
|
1558 | 1562 |
assertEquals(-1, nameBookSection2.getProblemStarts()); |
1559 | 1563 |
assertEquals(-1, nameBookSection2.getProblemEnds()); |
1560 | 1564 |
assertNull((nameBookSection2.getNomenclaturalReference()).getDatePublished().getStart()); |
1561 |
assertEquals("1905-1907", ((IBookSection)nameBookSection2.getNomenclaturalReference()).getInBook().getDatePublished().getYear()); |
|
1562 |
|
|
1565 |
assertEquals("1905"+SEP+"1907", ((IBookSection)nameBookSection2.getNomenclaturalReference()).getInBook().getDatePublished().getYear()); |
|
1563 | 1566 |
|
1564 | 1567 |
String strBookSection = "Hieracium vulgatum subsp. acuminatum (Jord.) Zahn in Schinz & Keller, Fl. Schweiz ed. 2, 2: 288. 1905"; |
1565 | 1568 |
INonViralName nameBookSection = |
... | ... | |
2493 | 2496 |
Reference nomRef = name.getNomenclaturalReference(); |
2494 | 2497 |
assertEquals(ReferenceType.Article, nomRef.getType()); |
2495 | 2498 |
assertEquals("1978 [\"1977\"]", nomRef.getDatePublished().toString()); |
2499 |
|
|
2500 |
name = parser.parseReferencedName("Calamintha transsilvanica (J\u00e1v.) So\u00f3 in Acta Bot. Acad. Sci. Hung. 23: 382. 1977 Apr 4"); |
|
2501 |
Assert.assertFalse("Name should be parsable", name.isProtectedTitleCache()); |
|
2502 |
nomRef = name.getNomenclaturalReference(); |
|
2503 |
assertEquals(ReferenceType.Article, nomRef.getType()); |
|
2504 |
assertEquals("1977 Apr 4", nomRef.getDatePublished().toString()); |
|
2505 |
assertEquals(Integer.valueOf(4), nomRef.getDatePublished().getStartMonth()); |
|
2496 | 2506 |
} |
2497 | 2507 |
|
2498 | 2508 |
|
Also available in: Unified diff
ref #9071, ref #6276 Change TimePeriodFormatting to YYYY-MMM-DD