Project

General

Profile

Download (78.8 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

    
10
package eu.etaxonomy.cdm.strategy.parser;
11

    
12
import static org.junit.Assert.assertEquals;
13
import static org.junit.Assert.assertFalse;
14
import static org.junit.Assert.assertNotNull;
15
import static org.junit.Assert.assertNull;
16
import static org.junit.Assert.assertTrue;
17

    
18
import java.lang.reflect.InvocationTargetException;
19
import java.lang.reflect.Method;
20
import java.util.List;
21
import java.util.regex.Matcher;
22
import java.util.regex.Pattern;
23

    
24
import org.apache.log4j.Logger;
25
import org.junit.Assert;
26
import org.junit.Before;
27
import org.junit.BeforeClass;
28
import org.junit.Test;
29

    
30
import eu.etaxonomy.cdm.common.UTF8;
31
import eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor;
32
import eu.etaxonomy.cdm.model.agent.Person;
33
import eu.etaxonomy.cdm.model.agent.Team;
34
import eu.etaxonomy.cdm.model.common.DefaultTermInitializer;
35
import eu.etaxonomy.cdm.model.name.BotanicalName;
36
import eu.etaxonomy.cdm.model.name.HybridRelationship;
37
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
38
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
39
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
40
import eu.etaxonomy.cdm.model.name.NonViralName;
41
import eu.etaxonomy.cdm.model.name.Rank;
42
import eu.etaxonomy.cdm.model.name.ZoologicalName;
43
import eu.etaxonomy.cdm.model.reference.IArticle;
44
import eu.etaxonomy.cdm.model.reference.IBook;
45
import eu.etaxonomy.cdm.model.reference.IBookSection;
46
import eu.etaxonomy.cdm.model.reference.IJournal;
47
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
48
import eu.etaxonomy.cdm.model.reference.IVolumeReference;
49
import eu.etaxonomy.cdm.model.reference.Reference;
50
import eu.etaxonomy.cdm.model.reference.ReferenceType;
51
import eu.etaxonomy.cdm.strategy.exceptions.StringNotParsableException;
52
/**
53
 * @author a.mueller
54
 *
55
 */
56
public class NonViralNameParserImplTest {
57
	private static final NomenclaturalCode ICBN = NomenclaturalCode.ICNAFP;
58
	private static final NomenclaturalCode ICZN = NomenclaturalCode.ICZN;
59

    
60
	private static final Logger logger = Logger.getLogger(NonViralNameParserImplTest.class);
61

    
62
	final private String strNameFamily = "Asteraceae";
63
	final private String strNameGenus = "Abies Mueller";
64
	final private String strNameGenusUnicode = "Abies M\u00FCller";
65
	final private String strNameAbies1 = "Abies alba";
66
	final private String strNameAbiesSub1 = "Abies alba subsp. beta";
67
	final private String strNameAbiesAuthor1 = "Abies alba Mueller";
68
	final private String strNameAbiesAuthor1Unicode = "Abies alba M\u00FCller";
69
	final private String strNameAbiesBasionymAuthor1 = "Abies alba (Ciardelli) D'Mueller";
70
	final private String strNameAbiesBasionymAuthor1Unicode = "Abies alba (Ciardelli) D'M\u00FCller";
71
	final private String strNameAbiesBasionymExAuthor1 ="Abies alba (Ciardelli ex Doering) D'Mueller ex. de Greuther";
72
	final private String strNameAbiesBasionymExAuthor1Unicode ="Abies alba (Ciardelli ex D\u00F6ring) D'M\u00FCller ex. de Greuther";
73
	final private String strNameTeam1 = "Abies alba Mueller & L.";
74
	final private String strNameZoo1 = "Abies alba Mueller & L., 1822";
75
	final private String strNameZoo2 = "Abies alba (Mueller, 1822) Ciardelli, 2002";
76
	final private String strNameZoo3 = "Marmota marmota normalis Ciardelli, 2002";
77
	final private String strNameZoo4 = "Marmota marmota subsp. normalis Ciardelli, 2002";
78
	final private String strNameZoo5 = "Marmota marmota var. normalis Ciardelli, 2002";
79

    
80
	final private String strNameEmpty = "";
81
	final private String strNameNull = null;
82

    
83
	private NonViralNameParserImpl parser ;
84
	private NomenclaturalCode botanicCode;
85

    
86
	/**
87
	 * @throws java.lang.Exception
88
	 */
89
	@BeforeClass
90
	public static void setUpBeforeClass() throws Exception {
91
		DefaultTermInitializer termInitializer = new DefaultTermInitializer();
92
		termInitializer.initialize();
93
	}
94

    
95

    
96
	/**
97
	 * @throws java.lang.Exception
98
	 */
99
	@Before
100
	public void setUp() throws Exception {
101
		parser = NonViralNameParserImpl.NewInstance();
102
		botanicCode = ICBN;
103
	}
104

    
105

    
106
/*************** TEST *********************************************/
107

    
108
	/**
109
	 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#NEW_INSTANCE()}.
110
	 */
111
	@Test
112
	public final void testNewInstance() {
113
		assertNotNull(parser);
114
	}
115

    
116
	/**
117
	 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#TaxonNameParserBotanicalNameImpl()}.
118
	 */
119
	@Test
120
	public final void testTaxonNameParserBotanicalNameImpl() {
121
		logger.warn("Not yet implemented"); // TODO
122
	}
123

    
124
	@Test
125
	public final void testTeamSeperation(){
126
		Rank speciesRank = Rank.SPECIES();
127
		NonViralName<?> name;
128

    
129
//		String strNameWith1AUthorAndCommaSepEditon = "Abies alba Mill., Sp. Pl., ed. 3: 455. 1987";
130
//		name = parser.parseReferencedName(strNameWith1AUthorAndCommaSepEditon, botanicCode, speciesRank);
131
//		Assert.assertFalse("No problems should exist", name.hasProblem());
132
//		Assert.assertEquals("Name should not include reference part", "Abies alba Mill.", name.getTitleCache());
133
//		Assert.assertEquals("Mill., Sp. Pl., ed. 3. 1987", name.getNomenclaturalReference().getTitleCache());
134
//
135
//
136
//		String strNameWith2Authors = "Abies alba L. & Mill., Sp. Pl., ed. 3: 455. 1987";
137
//		name = parser.parseReferencedName(strNameWith2Authors, botanicCode, speciesRank);
138
//		Assert.assertFalse("No problems should exist", name.hasProblem());
139
//		Assert.assertEquals("Name should not include reference part", "Abies alba L. & Mill.", name.getTitleCache());
140
//		Assert.assertEquals("Name should have authorteam with 2 authors", 2, ((Team)name.getCombinationAuthorship()).getTeamMembers().size());
141
//		Assert.assertEquals("L. & Mill., Sp. Pl., ed. 3. 1987", name.getNomenclaturalReference().getTitleCache());
142

    
143
		String strNameWith3Authors = "Abies alba Mess., L. & Mill., Sp. Pl., ed. 3: 455. 1987";
144
		name = parser.parseReferencedName(strNameWith3Authors, botanicCode, speciesRank);
145
		Assert.assertFalse("No problems should exist", name.hasProblem());
146
		Assert.assertEquals("Name should not include reference part", "Abies alba Mess., L. & Mill.", name.getTitleCache());
147
		Assert.assertEquals("Name should have authorship with 2 authors", 3, ((Team)name.getCombinationAuthorship()).getTeamMembers().size());
148
		Assert.assertEquals("Mess., L. & Mill., Sp. Pl., ed. 3. 1987", name.getNomenclaturalReference().getTitleCache());
149

    
150
	}
151

    
152
	/**
153
	 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseSimpleName(java.lang.String, eu.etaxonomy.cdm.model.name.Rank)}.
154
	 */
155
	@Test
156
	public final void testParseSimpleName() {
157

    
158
		//Uninomials
159
		ZoologicalName milichiidae = (ZoologicalName)parser.parseSimpleName("Milichiidae", NomenclaturalCode.ICZN, null);
160
		assertEquals("Family rank expected", Rank.FAMILY(), milichiidae.getRank());
161
		BotanicalName crepidinae = (BotanicalName)parser.parseSimpleName("Crepidinae", ICBN, null);
162
		assertEquals("Family rank expected", Rank.SUBTRIBE(), crepidinae.getRank());
163
		BotanicalName abies = (BotanicalName)parser.parseSimpleName("Abies", ICBN, null);
164
		assertEquals("Family rank expected", Rank.GENUS(), abies.getRank());
165

    
166
		abies.addParsingProblem(ParserProblem.CheckRank);
167
		parser.parseSimpleName(abies, "Abies", abies.getRank(), true);
168
		assertTrue(abies.getParsingProblems().contains(ParserProblem.CheckRank));
169

    
170
		BotanicalName rosa = (BotanicalName)parser.parseSimpleName("Rosaceae", ICBN, null);
171
		assertTrue("Rosaceae have rank family", rosa.getRank().equals(Rank.FAMILY()));
172
		assertTrue("Rosaceae must have a rank warning", rosa.hasProblem(ParserProblem.CheckRank));
173
		parser.parseSimpleName(rosa, "Rosaceaex", abies.getRank(), true);
174
		assertEquals("Rosaceaex have rank genus", Rank.GENUS(), rosa.getRank());
175
		assertTrue("Rosaceaex must have a rank warning", rosa.hasProblem(ParserProblem.CheckRank));
176

    
177
		//repeat but remove warning after first parse
178
		rosa = (BotanicalName)parser.parseSimpleName("Rosaceae", ICBN, null);
179
		assertTrue("Rosaceae have rank family", rosa.getRank().equals(Rank.FAMILY()));
180
		assertTrue("Rosaceae must have a rank warning", rosa.hasProblem(ParserProblem.CheckRank));
181
		rosa.removeParsingProblem(ParserProblem.CheckRank);
182
		parser.parseSimpleName(rosa, "Rosaceaex", rosa.getRank(), true);
183
		assertEquals("Rosaceaex have rank family", Rank.FAMILY(), rosa.getRank());
184
		assertFalse("Rosaceaex must have no rank warning", rosa.hasProblem(ParserProblem.CheckRank));
185

    
186

    
187
	}
188

    
189
	/**
190
	 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseSubGenericFullName(java.lang.String)}.
191
	 */
192
	@Test
193
	public final void testParseSubGenericFullName() {
194
		logger.warn("Not yet implemented"); // TODO
195
	}
196

    
197
	/**
198
	 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseSubGenericSimpleName(java.lang.String)}.
199
	 */
200
	@Test
201
	public final void testParseSubGenericSimpleName() {
202
		logger.warn("Not yet implemented"); // TODO
203
	}
204

    
205
	/**
206
	 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseFullName(java.lang.String, eu.etaxonomy.cdm.model.name.Rank)}.
207
	 */
208
	@Test
209
	public final void testParseFullNameUnicode() {
210

    
211
		NonViralName<?> nameAuthor = parser.parseFullName(strNameAbiesAuthor1Unicode, null, Rank.SPECIES());
212
		assertEquals("Abies", nameAuthor.getGenusOrUninomial());
213
		assertEquals("alba", nameAuthor.getSpecificEpithet());
214
		assertEquals("M\u00FCller", nameAuthor.getCombinationAuthorship().getNomenclaturalTitle());
215

    
216
		NonViralName<?> nameBasionymAuthor = parser.parseFullName(strNameAbiesBasionymAuthor1Unicode, null, Rank.SPECIES());
217
		assertEquals("Abies", nameBasionymAuthor.getGenusOrUninomial());
218
		assertEquals("alba", nameBasionymAuthor.getSpecificEpithet());
219
		assertEquals("D'M\u00FCller", nameBasionymAuthor.getCombinationAuthorship().getNomenclaturalTitle());
220
		INomenclaturalAuthor basionymTeam = nameBasionymAuthor.getBasionymAuthorship();
221
		assertEquals("Ciardelli", basionymTeam.getNomenclaturalTitle());
222

    
223
		NonViralName<?> nameBasionymExAuthor = parser.parseFullName(strNameAbiesBasionymExAuthor1Unicode, null, Rank.SPECIES());
224
		assertEquals("Abies", nameBasionymExAuthor.getGenusOrUninomial());
225
		assertEquals("alba", nameBasionymExAuthor.getSpecificEpithet());
226
		assertEquals("D'M\u00FCller", nameBasionymExAuthor.getExCombinationAuthorship().getNomenclaturalTitle());
227
		assertEquals("de Greuther", nameBasionymExAuthor.getCombinationAuthorship().getNomenclaturalTitle());
228
		INomenclaturalAuthor basionymTeam2 = nameBasionymExAuthor.getExBasionymAuthorship();
229
		assertEquals("Ciardelli", basionymTeam2.getNomenclaturalTitle());
230
		INomenclaturalAuthor exBasionymTeam2 = nameBasionymExAuthor.getBasionymAuthorship();
231
		assertEquals("D\u00F6ring", exBasionymTeam2.getNomenclaturalTitle());
232

    
233
		BotanicalName nameBasionymExAuthor2 = (BotanicalName)parser.parseFullName("Washingtonia filifera (Linden ex Andre) H.Wendl. ex de Bary", null, Rank.SPECIES());
234
		assertEquals("Washingtonia", nameBasionymExAuthor2.getGenusOrUninomial());
235
		assertEquals("filifera", nameBasionymExAuthor2.getSpecificEpithet());
236
		assertEquals("H.Wendl.", nameBasionymExAuthor2.getExCombinationAuthorship().getNomenclaturalTitle());
237
		assertEquals("de Bary", nameBasionymExAuthor2.getCombinationAuthorship().getNomenclaturalTitle());
238
		INomenclaturalAuthor basionymTeam3 = nameBasionymExAuthor2.getBasionymAuthorship();
239
		assertEquals("Andre", basionymTeam3.getNomenclaturalTitle());
240
		INomenclaturalAuthor exBasionymTeam3 = nameBasionymExAuthor2.getExBasionymAuthorship();
241
		assertEquals("Linden", exBasionymTeam3.getNomenclaturalTitle());
242
		String title = nameBasionymExAuthor2.getTitleCache();
243
		assertEquals("Washingtonia filifera (Linden ex Andre) H.Wendl. ex de Bary", title);
244

    
245
	}
246

    
247

    
248
	/**
249
	 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseFullName(java.lang.String, eu.etaxonomy.cdm.model.name.Rank)}.
250
	 */
251
	@Test
252
	public final void testParseFullName() {
253
		try {
254
			Method parseMethod = parser.getClass().getDeclaredMethod("parseFullName", String.class, NomenclaturalCode.class, Rank.class);
255
			testName_StringNomcodeRank(parseMethod);
256
		} catch (Exception e) {
257
			e.printStackTrace();
258
			assertTrue(false);
259
		}
260

    
261
		//Team
262
		NonViralName<?> nameTeam1 = parser.parseFullName(strNameTeam1);
263
		assertEquals( "Abies", nameTeam1.getGenusOrUninomial());
264
		assertEquals( "alba", nameTeam1.getSpecificEpithet());
265
		assertEquals("Mueller & L.",  nameTeam1.getCombinationAuthorship().getNomenclaturalTitle());
266
		assertTrue(nameTeam1.getCombinationAuthorship() instanceof Team);
267
		Team team = (Team)nameTeam1.getCombinationAuthorship();
268
		assertEquals("Mueller", team.getTeamMembers().get(0).getNomenclaturalTitle());
269
		assertEquals("L.", team.getTeamMembers().get(1).getNomenclaturalTitle());
270

    
271
		//ZooName
272
		ZoologicalName nameZoo1 = (ZoologicalName)parser.parseFullName(strNameZoo1);
273
		assertEquals( "Abies", nameZoo1.getGenusOrUninomial());
274
		assertEquals( "alba", nameZoo1.getSpecificEpithet());
275
		assertEquals("Mueller & L.",  nameZoo1.getCombinationAuthorship().getNomenclaturalTitle());
276
		assertEquals(NomenclaturalCode.ICZN, nameZoo1.getNomenclaturalCode() );
277
		assertEquals(Integer.valueOf(1822), nameZoo1.getPublicationYear());
278
		assertTrue(nameZoo1.getCombinationAuthorship() instanceof Team);
279
		Team teamZoo = (Team)nameZoo1.getCombinationAuthorship();
280
		assertEquals("Mueller", teamZoo.getTeamMembers().get(0).getNomenclaturalTitle());
281
		assertEquals("L.", teamZoo.getTeamMembers().get(1).getNomenclaturalTitle());
282

    
283
		ZoologicalName nameZoo2 = (ZoologicalName)parser.parseFullName(strNameZoo2);
284
		assertEquals(Integer.valueOf(2002), nameZoo2.getPublicationYear());
285
		assertEquals(Integer.valueOf(1822), nameZoo2.getOriginalPublicationYear());
286
		assertEquals("Mueller",  nameZoo2.getBasionymAuthorship().getNomenclaturalTitle());
287
		assertEquals("Ciardelli",  nameZoo2.getCombinationAuthorship().getNomenclaturalTitle());
288

    
289
		//subsp
290
		ZoologicalName nameZoo3 = (ZoologicalName)parser.parseFullName(strNameZoo3);
291
		assertEquals("Ciardelli",  nameZoo3.getCombinationAuthorship().getNomenclaturalTitle());
292
		assertFalse("Subsp. without marker should be parsable", nameZoo3.hasProblem());
293
		assertEquals("Variety should be recognized", Rank.SUBSPECIES(), nameZoo3.getRank());
294

    
295
		ZoologicalName nameZoo4 = (ZoologicalName)parser.parseFullName(strNameZoo4);
296
		assertEquals("Ciardelli",  nameZoo4.getCombinationAuthorship().getNomenclaturalTitle());
297
		assertFalse("Subsp. without marker should be parsable", nameZoo4.hasProblem());
298
		assertEquals("Variety should be recognized", Rank.SUBSPECIES(), nameZoo4.getRank());
299

    
300
		ZoologicalName nameZoo5 = (ZoologicalName)parser.parseFullName(strNameZoo5);
301
		assertEquals("Ciardelli",  nameZoo5.getCombinationAuthorship().getNomenclaturalTitle());
302
		assertFalse("Subsp. without marker should be parsable", nameZoo5.hasProblem());
303
		assertEquals("Variety should be recognized", Rank.VARIETY(), nameZoo5.getRank());
304

    
305

    
306
		//Autonym
307
		BotanicalName autonymName = (BotanicalName)parser.parseFullName("Abies alba Mill. var. alba", ICBN, null);
308
		assertFalse("Autonym should be parsable", autonymName.hasProblem());
309

    
310

    
311
		//empty
312
		NonViralName<?> nameEmpty = parser.parseFullName(strNameEmpty);
313
		assertNotNull(nameEmpty);
314
		assertEquals("", nameEmpty.getTitleCache());
315

    
316
		//null
317
		NonViralName<?> nameNull = parser.parseFullName(strNameNull);
318
		assertNull(nameNull);
319

    
320
		//some authors
321
		String fullNameString = "Abies alba (Greuther & L'Hiver & al. ex M\u00FCller & Schmidt)Clark ex Ciardelli";
322
		NonViralName<?> authorname = parser.parseFullName(fullNameString);
323
		assertFalse(authorname.hasProblem());
324
		assertEquals("Basionym author should have 3 authors", 2, ((Team)authorname.getExBasionymAuthorship()).getTeamMembers().size());
325
        Assert.assertTrue("ExbasionymAuthorship must have more members'", ((Team)authorname.getExBasionymAuthorship()).isHasMoreMembers());
326
	}
327

    
328
	@Test
329
    public final void testEtAl() throws StringNotParsableException {
330
        //some authors
331
        String fullNameString = "Abies alba Greuther, Hiver & al.";
332
        NonViralName<?> authorname = parser.parseFullName(fullNameString);
333
        assertFalse(authorname.hasProblem());
334
        assertEquals("Basionym author should have 2 authors", 2, ((Team)authorname.getCombinationAuthorship()).getTeamMembers().size());
335
        assertTrue("Basionym author team should have more authors", ((Team)authorname.getCombinationAuthorship()).isHasMoreMembers()  );
336

    
337
		//et al.
338
		NonViralName<?> nvn = ZoologicalName.NewInstance(null);
339
		parser.parseAuthors(nvn, "Eckweiler, Hand et al., 2003");
340
	    Team team = (Team)nvn.getCombinationAuthorship();
341
	    Assert.assertNotNull("Comb. author must not be null", team);
342
	    Assert.assertEquals("Must be team with 2 members", 2, team.getTeamMembers().size());
343
	    Assert.assertEquals("Second member must be 'Hand'", "Hand", team.getTeamMembers().get(1).getTitleCache());
344
	    Assert.assertTrue("Team must have more members'", team.isHasMoreMembers());
345
	}
346

    
347
	@Test
348
    public final void testMultipleAuthors() throws StringNotParsableException {
349
        //multiple authors for inReference
350
        String fullTitleString = "Abies alba L. in Mill., Gregor & Behr., Sp. Pl. 173: 384. 1982.";
351
        NonViralName<?> multipleAuthorRefName = parser.parseReferencedName(fullTitleString, NomenclaturalCode.ICNAFP, Rank.SPECIES());
352
        assertFalse(multipleAuthorRefName.hasProblem());
353
        assertTrue("Combination author should be a person", multipleAuthorRefName.getCombinationAuthorship() instanceof Person);
354
        assertEquals("Combination author should be L.", "L.", ((Person)multipleAuthorRefName.getCombinationAuthorship()).getNomenclaturalTitle());
355
        INomenclaturalReference nomRef = multipleAuthorRefName.getNomenclaturalReference();
356
        Assert.assertNotNull("nomRef must have inRef", ((Reference<?>)nomRef).getInReference());
357
        Reference<?> inRef = ((Reference<?>)nomRef).getInReference();
358
        String title = inRef.getTitle();
359
        assertEquals("InRef title should be Sp. Pl.", "Sp. Pl.", title);
360
        assertTrue(inRef.getAuthorship() instanceof Team);
361
        Team team = (Team)inRef.getAuthorship();
362
        assertEquals(3, team.getTeamMembers().size());
363

    
364
//        multiple authors in Name
365
        fullTitleString = "Abies alba Mill., Aber & Schwedt";
366
        NonViralName<?> multipleAuthorName = parser.parseReferencedName(fullTitleString, NomenclaturalCode.ICNAFP, Rank.SPECIES());
367
        assertFalse(multipleAuthorName.hasProblem());
368
        assertTrue("Combination author should be a team", multipleAuthorName.getCombinationAuthorship() instanceof Team);
369
        team = (Team)multipleAuthorName.getCombinationAuthorship();
370
        assertEquals(3, team.getTeamMembers().size());
371
        assertEquals("Second team member should be Aber", "Aber", team.getTeamMembers().get(1).getTitleCache());
372

    
373
//      multiple authors in Name with reference
374
	    fullTitleString = "Abies alba Mill., Aber & Schwedt in L., Sp. Pl. 173: 384. 1982.";
375
	    multipleAuthorName = parser.parseReferencedName(fullTitleString, NomenclaturalCode.ICNAFP, Rank.SPECIES());
376
	    assertFalse(multipleAuthorName.hasProblem());
377
	    assertTrue("Combination author should be a team", multipleAuthorName.getCombinationAuthorship() instanceof Team);
378
	    team = (Team)multipleAuthorName.getCombinationAuthorship();
379
	    assertEquals(3, team.getTeamMembers().size());
380
	    assertEquals("Second team member should be Aber", "Aber", team.getTeamMembers().get(1).getTitleCache());
381
	    nomRef = multipleAuthorName.getNomenclaturalReference();
382
        Assert.assertNotNull("nomRef must have inRef", ((Reference<?>)nomRef).getInReference());
383
        inRef = ((Reference<?>)nomRef).getInReference();
384
        title = inRef.getTitle();
385
        assertEquals("InRef title should be Sp. Pl.", "Sp. Pl.", title);
386
        assertTrue(inRef.getAuthorship() instanceof Person);
387
        Person person = (Person)inRef.getAuthorship();
388
        assertEquals("Book author should be L.", "L.", person.getNomenclaturalTitle());
389

    
390

    
391
	    fullTitleString = "Abies alba Mill., Aber & Schwedt, Sp. Pl. 173: 384. 1982.";
392
	    multipleAuthorName = parser.parseReferencedName(fullTitleString, NomenclaturalCode.ICNAFP, Rank.SPECIES());
393
	    assertFalse(multipleAuthorName.hasProblem());
394
	    assertTrue("Combination author should be a team", multipleAuthorName.getCombinationAuthorship() instanceof Team);
395
	    team = (Team)multipleAuthorName.getCombinationAuthorship();
396
	    assertEquals(3, team.getTeamMembers().size());
397
	    assertEquals("Second team member should be Aber", "Aber", team.getTeamMembers().get(1).getTitleCache());
398
	    nomRef = multipleAuthorName.getNomenclaturalReference();
399
        Assert.assertNull("nomRef must not have inRef as it is a book itself", ((Reference<?>)nomRef).getInReference());
400
        title = nomRef.getTitle();
401
        assertEquals("InRef title should be Sp. Pl.", "Sp. Pl.", title);
402
        assertTrue(nomRef.getAuthorship() instanceof Team);
403
        team = (Team)nomRef.getAuthorship();
404
        assertEquals(3, team.getTeamMembers().size());
405
        assertEquals("Second team member should be Schwedt", "Schwedt", team.getTeamMembers().get(2).getTitleCache());
406

    
407
		//et al.
408
		NonViralName<?> nvn = ZoologicalName.NewInstance(null);
409
		parser.parseReferencedName (nvn, "Marmota marmota Eckweiler, Hand et al., 2003", Rank.SPECIES(),true);
410
		assertTrue("Combination author should be a team", nvn.getCombinationAuthorship() instanceof Team);
411
        team = (Team)nvn.getCombinationAuthorship();
412
	    Assert.assertNotNull("Comb. author must not be null", team);
413
	    Assert.assertEquals("Must be team with 2 members", 2, team.getTeamMembers().size());
414
	    Assert.assertEquals("Second member must be 'Hand'", "Hand", team.getTeamMembers().get(1).getTitleCache());
415
	    Assert.assertTrue("Team must have more members'", team.isHasMoreMembers());
416

    
417
	}
418

    
419
	/**
420
	 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseFullName(java.lang.String, eu.etaxonomy.cdm.model.name.Rank)}.
421
	 */
422
	@Test
423
	public final void testHybrids() {
424
		try {
425
			Method parseMethod = parser.getClass().getDeclaredMethod("parseFullName", String.class, NomenclaturalCode.class, Rank.class);
426
			testName_StringNomcodeRank(parseMethod);
427
		} catch (Exception e) {
428
			e.printStackTrace();
429
			assertTrue(false);
430
		}
431

    
432
		//Species hybrid
433
//		NonViralName nameTeam1 = parser.parseFullName("Aegilops \u00D7insulae-cypri H. Scholz");
434
		NonViralName<?> name1 = parser.parseFullName("Aegilops \u00D7insulae Scholz", botanicCode, null);
435
		assertTrue("Name must have binom hybrid bit set", name1.isBinomHybrid());
436
		assertFalse("Name must not have monom hybrid bit set", name1.isMonomHybrid());
437
		assertFalse("Name must not have trinom hybrid bit set", name1.isTrinomHybrid());
438
		assertEquals("Species epithet must be 'insulae'", "insulae", name1.getSpecificEpithet());
439

    
440
		//Uninomial hybrid
441
		name1 = parser.parseFullName("x Aegilops Scholz", botanicCode, null);
442
		assertTrue("Name must have monom hybrid bit set", name1.isMonomHybrid());
443
		assertFalse("Name must not have binom hybrid bit set", name1.isBinomHybrid());
444
		assertFalse("Name must not have trinom hybrid bit set", name1.isTrinomHybrid());
445
		assertEquals("Uninomial must be 'Aegilops'", "Aegilops", name1.getGenusOrUninomial());
446

    
447
		//Species hybrid
448
		name1 = parser.parseFullName("Aegilops insulae subsp. X abies Scholz", botanicCode, null);
449
		assertFalse("Name must not have monom hybrid bit set", name1.isMonomHybrid());
450
		assertFalse("Name must not have binom hybrid bit set", name1.isBinomHybrid());
451
		assertTrue("Name must have trinom hybrid bit set", name1.isTrinomHybrid());
452
		assertEquals("Infraspecific epithet must be 'abies'", "abies", name1.getInfraSpecificEpithet());
453

    
454

    
455
	}
456

    
457
	/**
458
	 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseFullName(java.lang.String, eu.etaxonomy.cdm.model.name.Rank)}.
459
	 */
460
	@Test
461
	public final void testUnrankedNames() {
462
		try {
463
			Method parseMethod = parser.getClass().getDeclaredMethod("parseFullName", String.class, NomenclaturalCode.class, Rank.class);
464
			testName_StringNomcodeRank(parseMethod);
465
		} catch (Exception e) {
466
			e.printStackTrace();
467
			assertTrue(false);
468
		}
469

    
470
		//unranked infraspecific
471
		String infraspecificUnranked = "Genus species [unranked] infraspecific";
472
		NonViralName<?> name = parser.parseFullName(infraspecificUnranked);
473
		assertEquals( "Genus", name.getGenusOrUninomial());
474
		assertEquals( "species", name.getSpecificEpithet());
475
		assertEquals( "infraspecific", name.getInfraSpecificEpithet());
476
		assertEquals( "Unranked rank should be parsed", Rank.INFRASPECIFICTAXON(), name.getRank());
477

    
478
		//unranked infrageneric
479
		String infraGenericUnranked = "Genus [unranked] Infragen";
480
		NonViralName<?> name2 = parser.parseFullName(infraGenericUnranked);
481
		assertEquals( "Genus", name2.getGenusOrUninomial());
482
		assertEquals( null, name2.getSpecificEpithet());
483
		assertEquals( "Infragen", name2.getInfraGenericEpithet());
484
		assertEquals( "Unranked rank should be parsed", Rank.INFRAGENERICTAXON(), name2.getRank());
485

    
486
	}
487

    
488

    
489
	/**
490
	 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseFullName(java.lang.String, eu.etaxonomy.cdm.model.name.Rank)}.
491
	 */
492
	@Test
493
	public final void testHybridFormulars() {
494
		try {
495
			Method parseMethod = parser.getClass().getDeclaredMethod("parseFullName", String.class, NomenclaturalCode.class, Rank.class);
496
			testName_StringNomcodeRank(parseMethod);
497
		} catch (Exception e) {
498
			e.printStackTrace();
499
			assertTrue(false);
500
		}
501

    
502
		//Species hybrid
503
		String hybridCache = "Abies alba "+UTF8.HYBRID+" Pinus bus";
504
		NonViralName<?> name1 = parser.parseFullName(hybridCache, botanicCode, null);
505
		assertTrue("Name must have hybrid formula bit set", name1.isHybridFormula());
506
		assertEquals("Name must have 2 hybrid parents", 2, name1.getHybridChildRelations().size());
507
		assertEquals("Title cache must be correct", hybridCache, name1.getTitleCache());
508
		List<HybridRelationship> orderedRels = name1.getOrderedChildRelationships();
509
		assertEquals("Name must have 2 hybrid parents in ordered list", 2, orderedRels.size());
510
		NonViralName<?> firstParent = orderedRels.get(0).getParentName();
511
		assertEquals("Name must have Abies alba as first hybrid parent", "Abies alba", firstParent.getTitleCache());
512
		NonViralName<?> secondParent = orderedRels.get(1).getParentName();
513
		assertEquals("Name must have Pinus bus as second hybrid parent", "Pinus bus", secondParent.getTitleCache());
514
		assertEquals("Hybrid name must have the lowest rank ('species') as rank", Rank.SPECIES(), name1.getRank());
515
		assertNull("Name must not have a genus eptithet", name1.getGenusOrUninomial());
516
		assertNull("Name must not have a specific eptithet", name1.getSpecificEpithet());
517
		assertFalse("Name must not have parsing problems", name1.hasProblem());
518

    
519
		name1 = parser.parseReferencedName(hybridCache, botanicCode, null);
520
		assertFalse("Name must not have parsing problems", name1.hasProblem());
521

    
522
		//x-sign
523
		hybridCache = "Abies alba x Pinus bus";
524
		name1 = parser.parseFullName(hybridCache, botanicCode, null);
525
		assertFalse("Name must be parsable", name1.hasProblem());
526
		assertTrue("Name must have hybrid formula bit set", name1.isHybridFormula());
527
		assertFalse("Name must not have parsing problems", name1.hasProblem());
528

    
529

    
530
		//Subspecies first hybrid
531
		name1 = parser.parseFullName("Abies alba subsp. beta "+UTF8.HYBRID+" Pinus bus", botanicCode, null);
532
		assertTrue("Name must have hybrid formula bit set", name1.isHybridFormula());
533
		assertEquals("Name must have 2 hybrid parents", 2, name1.getHybridChildRelations().size());
534
		assertEquals("Title cache must be correct", "Abies alba subsp. beta "+UTF8.HYBRID+" Pinus bus", name1.getTitleCache());
535
		orderedRels = name1.getOrderedChildRelationships();
536
		assertEquals("Name must have 2 hybrid parents in ordered list", 2, orderedRels.size());
537
		firstParent = orderedRels.get(0).getParentName();
538
		assertEquals("Name must have Abies alba subsp. beta as first hybrid parent", "Abies alba subsp. beta", firstParent.getTitleCache());
539
		secondParent = orderedRels.get(1).getParentName();
540
		assertEquals("Name must have Pinus bus as second hybrid parent", "Pinus bus", secondParent.getTitleCache());
541
		assertEquals("Hybrid name must have the lower rank ('subspecies') as rank", Rank.SUBSPECIES(), name1.getRank());
542

    
543
		//variety second hybrid
544
		name1 = parser.parseFullName("Abies alba \u00D7 Pinus bus  var. beta", botanicCode, null);
545
		assertTrue("Name must have hybrid formula bit set", name1.isHybridFormula());
546
		assertEquals("Name must have 2 hybrid parents", 2, name1.getHybridChildRelations().size());
547
		assertEquals("Title cache must be correct", "Abies alba \u00D7 Pinus bus var. beta", name1.getTitleCache());
548
		assertEquals("Hybrid name must have the lower rank ('variety') as rank", Rank.VARIETY(), name1.getRank());
549

    
550
		//hybrids with authors
551
		name1 = parser.parseFullName("Abies alba L. \u00D7 Pinus bus Mill.", botanicCode, null);
552
		assertTrue("Name must have hybrid formula bit set", name1.isHybridFormula());
553
		assertEquals("Name must have 2 hybrid parents", 2, name1.getHybridChildRelations().size());
554
		assertEquals("Title cache must be correct", "Abies alba L. \u00D7 Pinus bus Mill.", name1.getTitleCache());
555
		orderedRels = name1.getOrderedChildRelationships();
556
		assertEquals("Name must have 2 hybrid parents in ordered list", 2, orderedRels.size());
557
		firstParent = orderedRels.get(0).getParentName();
558
		assertEquals("Name must have Abies alba L. as first hybrid parent", "Abies alba L.", firstParent.getTitleCache());
559
		secondParent = orderedRels.get(1).getParentName();
560
		assertEquals("Name must have Pinus bus Mill. as second hybrid parent", "Pinus bus Mill.", secondParent.getTitleCache());
561
		assertEquals("Hybrid name must have the lower rank ('species') as rank", Rank.SPECIES(), name1.getRank());
562

    
563
	}
564

    
565
	@Test
566
    public final void testHybridsRemoval(){
567
	    //if the parser input already has hybridrelationships they need to be removed
568
	    //Create input
569
        String hybridCache = "Abies alba "+UTF8.HYBRID+" Pinus bus";
570
        NonViralName<?> name1 = parser.parseFullName(hybridCache, botanicCode, null);
571
        assertFalse("Name must not have parsing problems", name1.hasProblem());
572
        assertTrue("", name1.getHybridChildRelations().size() == 2);
573

    
574
        hybridCache = "Abieta albana "+UTF8.HYBRID+" Pinuta custa";
575
        boolean makeEmpty = true;
576
        parser.parseFullName(name1, hybridCache, Rank.SPECIES(), makeEmpty);
577
        assertEquals("After parsing another string there should still be 2 parents, but different ones", 2, name1.getHybridChildRelations().size());
578
        assertFalse("Name must not have parsing problems", name1.hasProblem());
579

    
580

    
581
        hybridCache = "Calendula arvensis Mill.";
582
        makeEmpty = true;
583
        parser.parseFullName(name1, hybridCache, Rank.SPECIES(), makeEmpty);
584
        assertTrue("", name1.getHybridChildRelations().isEmpty());
585
        assertFalse("Name must not have parsing problems", name1.hasProblem());
586

    
587

    
588
        //AND the same for reference parsing
589
        hybridCache = "Abies alba "+UTF8.HYBRID+" Pinus bus";
590
        name1 = parser.parseReferencedName(hybridCache, botanicCode, null);
591
        assertFalse("Name must not have parsing problems", name1.hasProblem());
592
        assertTrue("", name1.getHybridChildRelations().size() == 2);
593

    
594
        hybridCache = "Abieta albana "+UTF8.HYBRID+" Pinuta custa";
595
        makeEmpty = true;
596
        parser.parseReferencedName(name1, hybridCache, Rank.SPECIES(), makeEmpty);
597
        assertEquals("After parsing another string there should still be 2 parents, but different ones", 2, name1.getHybridChildRelations().size());
598
        assertFalse("Name must not have parsing problems", name1.hasProblem());
599

    
600

    
601
        hybridCache = "Calendula arvensis Mill.";
602
        makeEmpty = true;
603
        parser.parseReferencedName(name1, hybridCache, Rank.SPECIES(), makeEmpty);
604
        assertTrue("", name1.getHybridChildRelations().isEmpty());
605
        assertFalse("Name must not have parsing problems", name1.hasProblem());
606
	}
607

    
608
	private void testName_StringNomcodeRank(Method parseMethod)
609
			throws InvocationTargetException, IllegalAccessException  {
610
		NonViralName<?> name1 = (NonViralName<?>)parseMethod.invoke(parser, strNameAbies1, null, Rank.SPECIES());
611
		//parser.parseFullName(strNameAbies1, null, Rank.SPECIES());
612
		assertEquals("Abies", name1.getGenusOrUninomial());
613
		assertEquals("alba", name1.getSpecificEpithet());
614

    
615
		NonViralName<?> nameAuthor = (NonViralName<?>)parseMethod.invoke(parser, strNameAbiesAuthor1, null, Rank.SPECIES());
616
		assertEquals("Abies", nameAuthor.getGenusOrUninomial());
617
		assertEquals("alba", nameAuthor.getSpecificEpithet());
618
		assertEquals("Mueller", nameAuthor.getCombinationAuthorship().getNomenclaturalTitle());
619

    
620
		NonViralName<?> nameBasionymAuthor = (NonViralName<?>)parseMethod.invoke(parser, strNameAbiesBasionymAuthor1, null, Rank.SPECIES());
621
		assertEquals("Abies", nameBasionymAuthor.getGenusOrUninomial());
622
		assertEquals("alba", nameBasionymAuthor.getSpecificEpithet());
623
		assertEquals("D'Mueller", nameBasionymAuthor.getCombinationAuthorship().getNomenclaturalTitle());
624
		assertEquals("Ciardelli", nameBasionymAuthor.getBasionymAuthorship().getNomenclaturalTitle());
625

    
626
		NonViralName<?> nameBasionymExAuthor = (NonViralName<?>)parseMethod.invoke(parser, strNameAbiesBasionymExAuthor1, null, Rank.SPECIES());
627
		assertEquals("Abies", nameBasionymExAuthor.getGenusOrUninomial());
628
		assertEquals("alba", nameBasionymExAuthor.getSpecificEpithet());
629
		assertEquals("D'Mueller", nameBasionymExAuthor.getExCombinationAuthorship().getNomenclaturalTitle());
630
		assertEquals("de Greuther", nameBasionymExAuthor.getCombinationAuthorship().getNomenclaturalTitle());
631
		assertEquals("Ciardelli", nameBasionymExAuthor.getExBasionymAuthorship().getNomenclaturalTitle());
632
		assertEquals("Doering", nameBasionymExAuthor.getBasionymAuthorship().getNomenclaturalTitle());
633

    
634
		NonViralName<?> name2 = (NonViralName<?>)parseMethod.invoke(parser, strNameAbiesSub1, null, Rank.SPECIES());
635
		assertEquals("Abies", name2.getGenusOrUninomial());
636
		assertEquals("alba", name2.getSpecificEpithet());
637
		assertEquals("beta", name2.getInfraSpecificEpithet());
638
		assertEquals(Rank.SUBSPECIES(), name2.getRank());
639

    
640

    
641
		// unparseable *********
642
		String problemString = "sdfjlös wer eer wer";
643
		NonViralName<?> nameProblem = (NonViralName<?>)parseMethod.invoke(parser, problemString, null, Rank.SPECIES());
644
		List<ParserProblem> list = nameProblem.getParsingProblems();
645
		assertTrue(nameProblem.getParsingProblem()!=0);
646
		assertEquals(problemString, nameProblem.getTitleCache());
647
	}
648

    
649

    
650
	/**
651
	 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseReferencedName(NonViralName, java.lang.String, eu.etaxonomy.cdm.model.name.Rank, boolean)(, )}.
652
	 */
653
	@Test
654
	public final void testParseNomStatus() {
655
		//nom. ambig.
656
		String strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. ambig.";
657
		NonViralName<?> nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
658
		assertFullRefStandard(nameTestStatus);
659
		assertTrue(nameTestStatus.getStatus().size()== 1);
660
		assertEquals( NomenclaturalStatusType.AMBIGUOUS(), nameTestStatus.getStatus().iterator().next().getType());
661

    
662
		//nom. dub.
663
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. dub.";
664
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
665
		assertFullRefStandard(nameTestStatus);
666
		assertTrue(nameTestStatus.getStatus().size()== 1);
667
		assertEquals( NomenclaturalStatusType.DOUBTFUL(), nameTestStatus.getStatus().iterator().next().getType());
668

    
669
		//nom. confus.
670
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. confus.";
671
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
672
		assertFullRefStandard(nameTestStatus);
673
		assertTrue(nameTestStatus.getStatus().size()== 1);
674
		assertEquals( NomenclaturalStatusType.CONFUSUM(), nameTestStatus.getStatus().iterator().next().getType());
675

    
676
		//nom. illeg.
677
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. illeg.";
678
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
679
		assertFullRefStandard(nameTestStatus);
680
		assertTrue(nameTestStatus.getStatus().size()== 1);
681
		assertEquals( NomenclaturalStatusType.ILLEGITIMATE(), nameTestStatus.getStatus().iterator().next().getType());
682

    
683
		//nom. superfl.
684
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. superfl.";
685
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
686
		assertFullRefStandard(nameTestStatus);
687
		assertTrue(nameTestStatus.getStatus().size()== 1);
688
		assertEquals( NomenclaturalStatusType.SUPERFLUOUS(), nameTestStatus.getStatus().iterator().next().getType());
689

    
690
		//nom. rej.
691
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. rej.";
692
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
693
		assertFullRefStandard(nameTestStatus);
694
		assertTrue(nameTestStatus.getStatus().size()== 1);
695
		assertEquals( NomenclaturalStatusType.REJECTED(), nameTestStatus.getStatus().iterator().next().getType());
696

    
697
		//nom. utique rej.
698
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. utique rej.";
699
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
700
		assertFullRefStandard(nameTestStatus);
701
		assertTrue(nameTestStatus.getStatus().size()== 1);
702
		assertEquals( NomenclaturalStatusType.UTIQUE_REJECTED(), nameTestStatus.getStatus().iterator().next().getType());
703

    
704
		//nom. cons. prop.
705
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. cons. prop.";
706
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
707
		assertFullRefStandard(nameTestStatus);
708
		assertTrue(nameTestStatus.getStatus().size()== 1);
709
		assertEquals( NomenclaturalStatusType.CONSERVED_PROP(), nameTestStatus.getStatus().iterator().next().getType());
710

    
711
		//nom. orth. cons. prop.
712
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. orth. cons. prop.";
713
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
714
		assertFullRefStandard(nameTestStatus);
715
		assertTrue(nameTestStatus.getStatus().size()== 1);
716
		assertEquals( NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED_PROP(), nameTestStatus.getStatus().iterator().next().getType());
717

    
718
		//nom. legit.
719
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. legit.";
720
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
721
		assertFullRefStandard(nameTestStatus);
722
		assertTrue(nameTestStatus.getStatus().size()== 1);
723
		assertEquals( NomenclaturalStatusType.LEGITIMATE(), nameTestStatus.getStatus().iterator().next().getType());
724

    
725
		//nom. altern.
726
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. altern.";
727
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
728
		assertFullRefStandard(nameTestStatus);
729
		assertTrue(nameTestStatus.getStatus().size()== 1);
730
		assertEquals( NomenclaturalStatusType.ALTERNATIVE(), nameTestStatus.getStatus().iterator().next().getType());
731

    
732
		//nom. alternativ.
733
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. alternativ.";
734
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
735
		assertFullRefStandard(nameTestStatus);
736
		assertTrue(nameTestStatus.getStatus().size()== 1);
737
		assertEquals( NomenclaturalStatusType.ALTERNATIVE(), nameTestStatus.getStatus().iterator().next().getType());
738

    
739
		//nom. nov.
740
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. nov.";
741
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
742
		assertFullRefStandard(nameTestStatus);
743
		assertTrue(nameTestStatus.getStatus().size()== 1);
744
		assertEquals( NomenclaturalStatusType.NOVUM(), nameTestStatus.getStatus().iterator().next().getType());
745

    
746
		//nom. utique rej. prop.
747
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. utique rej. prop.";
748
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
749
		assertFullRefStandard(nameTestStatus);
750
		assertTrue(nameTestStatus.getStatus().size()== 1);
751
		assertEquals( NomenclaturalStatusType.UTIQUE_REJECTED_PROP(), nameTestStatus.getStatus().iterator().next().getType());
752

    
753
		//nom. orth. cons.
754
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. orth. cons.";
755
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
756
		assertFullRefStandard(nameTestStatus);
757
		assertTrue(nameTestStatus.getStatus().size()== 1);
758
		assertEquals( NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED(), nameTestStatus.getStatus().iterator().next().getType());
759

    
760
		//nom. rej. prop.
761
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. rej. prop.";
762
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
763
		assertFullRefStandard(nameTestStatus);
764
		assertTrue(nameTestStatus.getStatus().size()== 1);
765
		assertEquals( NomenclaturalStatusType.REJECTED_PROP(), nameTestStatus.getStatus().iterator().next().getType());
766

    
767
		//nom. cons.
768
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. cons.";
769
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
770
		assertFullRefStandard(nameTestStatus);
771
		assertTrue(nameTestStatus.getStatus().size()== 1);
772
		assertEquals( NomenclaturalStatusType.CONSERVED(), nameTestStatus.getStatus().iterator().next().getType());
773

    
774
		//nom. sanct.
775
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. sanct.";
776
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
777
		assertFullRefStandard(nameTestStatus);
778
		assertTrue(nameTestStatus.getStatus().size()== 1);
779
		assertEquals( NomenclaturalStatusType.SANCTIONED(), nameTestStatus.getStatus().iterator().next().getType());
780

    
781
		//nom. inval.
782
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. inval.";
783
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
784
		assertFullRefStandard(nameTestStatus);
785
		assertTrue(nameTestStatus.getStatus().size()== 1);
786
		assertEquals( NomenclaturalStatusType.INVALID(), nameTestStatus.getStatus().iterator().next().getType());
787

    
788
		//nom. nud.
789
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. nud.";
790
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
791
		assertFullRefStandard(nameTestStatus);
792
		assertTrue(nameTestStatus.getStatus().size()== 1);
793
		assertEquals( NomenclaturalStatusType.NUDUM(), nameTestStatus.getStatus().iterator().next().getType());
794

    
795
		//comb. inval.
796
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, comb. inval.";
797
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
798
		assertFullRefStandard(nameTestStatus);
799
		assertTrue(nameTestStatus.getStatus().size()== 1);
800
		assertEquals( NomenclaturalStatusType.COMBINATION_INVALID(), nameTestStatus.getStatus().iterator().next().getType());
801

    
802
		//comb. illeg.
803
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, comb. illeg.";
804
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
805
		assertFullRefStandard(nameTestStatus);
806
		assertTrue(nameTestStatus.getStatus().size()== 1);
807
		assertEquals( NomenclaturalStatusType.COMBINATION_ILLEGITIMATE(), nameTestStatus.getStatus().iterator().next().getType());
808

    
809
		//nom. provis.
810
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. provis.";
811
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
812
		assertFullRefStandard(nameTestStatus);
813
		assertTrue(nameTestStatus.getStatus().size()== 1);
814
		assertEquals( NomenclaturalStatusType.PROVISIONAL(), nameTestStatus.getStatus().iterator().next().getType());
815

    
816
		//nom. valid
817
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. valid";
818
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
819
		assertFullRefStandard(nameTestStatus);
820
		assertTrue(nameTestStatus.getStatus().size()== 1);
821
		assertEquals( NomenclaturalStatusType.VALID(), nameTestStatus.getStatus().iterator().next().getType());
822

    
823
		//nom. subnud.
824
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, nom. subnud.";
825
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
826
		assertFullRefStandard(nameTestStatus);
827
		assertTrue(nameTestStatus.getStatus().size()== 1);
828
		assertEquals( NomenclaturalStatusType.SUBNUDUM(), nameTestStatus.getStatus().iterator().next().getType());
829

    
830
		//opus. utique oppr.
831
		strTestStatus = "Abies alba Mill., Sp. Pl. 4: 455. 1987, opus. utique oppr.";
832
		nameTestStatus = parser.parseReferencedName(strTestStatus, null, Rank.SPECIES());
833
		assertFullRefStandard(nameTestStatus);
834
		assertTrue(nameTestStatus.getStatus().size()== 1);
835
		assertEquals( NomenclaturalStatusType.OPUS_UTIQUE_OPPR(), nameTestStatus.getStatus().iterator().next().getType());
836

    
837
	}
838

    
839
	/**
840
	 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseReferencedName(NonViralName, java.lang.String, eu.etaxonomy.cdm.model.name.Rank, boolean)(, )}.
841
	 */
842
	@Test
843
	public final void testParseReferencedName() {
844
		try {
845
			Method parseMethod = parser.getClass().getDeclaredMethod("parseReferencedName", String.class, NomenclaturalCode.class, Rank.class);
846
			testName_StringNomcodeRank(parseMethod);
847
		} catch (Exception e) {
848
			e.printStackTrace();
849
			assertTrue(false);
850
		}
851

    
852

    
853
		//null
854
		String strNull = null;
855
		Rank rankSpecies = Rank.SPECIES();
856
		NonViralName<?> nameNull = parser.parseReferencedName(strNull, null, rankSpecies);
857
		assertNull(nameNull);
858

    
859
		//Empty
860
		String strEmpty = "";
861
		NonViralName<?> nameEmpty = parser.parseReferencedName(strEmpty, null, rankSpecies);
862
		assertFalse(nameEmpty.hasProblem());
863
		assertEquals(strEmpty, nameEmpty.getFullTitleCache());
864
		assertNull(nameEmpty.getNomenclaturalMicroReference());
865

    
866

    
867
		//Whitespaces
868
		String strFullWhiteSpcaceAndDot = "Abies alba Mill.,  Sp.   Pl.  4:  455 .  1987 .";
869
		NonViralName<?> namefullWhiteSpcaceAndDot = parser.parseReferencedName(strFullWhiteSpcaceAndDot, null, rankSpecies);
870
		assertFullRefStandard(namefullWhiteSpcaceAndDot);
871
		assertTrue(((Reference<?>)namefullWhiteSpcaceAndDot.getNomenclaturalReference()).getType().equals(eu.etaxonomy.cdm.model.reference.ReferenceType.Book));
872
		assertEquals( "Abies alba Mill., Sp. Pl. 4: 455. 1987", namefullWhiteSpcaceAndDot.getFullTitleCache());
873

    
874
		//Book
875
		String fullReference = "Abies alba Mill., Sp. Pl. 4: 455. 1987";
876
		NonViralName<?> name1 = parser.parseReferencedName(fullReference, null, rankSpecies);
877
		assertFullRefStandard(name1);
878
		assertTrue(((Reference<?>)name1.getNomenclaturalReference()).getType().equals(eu.etaxonomy.cdm.model.reference.ReferenceType.Book));
879
		assertEquals(fullReference, name1.getFullTitleCache());
880
		assertTrue("Name author and reference author should be the same", name1.getCombinationAuthorship() == ((Reference<?>)name1.getNomenclaturalReference()).getAuthorship());
881

    
882
		//Book Section
883
		fullReference = "Abies alba Mill. in Otto, Sp. Pl. 4(6): 455. 1987";
884
		NonViralName<?> name2 = parser.parseReferencedName(fullReference + ".", null, rankSpecies);
885
		assertFullRefNameStandard(name2);
886
		assertEquals(fullReference, name2.getFullTitleCache());
887
		assertFalse(name2.hasProblem());
888
		INomenclaturalReference ref = name2.getNomenclaturalReference();
889
		assertEquals(eu.etaxonomy.cdm.model.reference.ReferenceType.BookSection, ((Reference<?>)ref).getType());
890
		IBookSection bookSection = (IBookSection) ref;
891
		IBook inBook = bookSection.getInBook();
892
		assertNotNull(inBook);
893
		assertNotNull(inBook.getAuthorship());
894
		assertEquals("Otto", inBook.getAuthorship().getTitleCache());
895
		assertEquals("Otto, Sp. Pl. 4(6)", inBook.getTitleCache());
896
		assertEquals("Sp. Pl.", inBook.getTitle());
897
		assertEquals("4(6)", inBook.getVolume());
898
		assertTrue("Name author and reference author should be the same", name2.getCombinationAuthorship() == ((Reference<?>)name2.getNomenclaturalReference()).getAuthorship());
899

    
900
		//Article
901
		fullReference = "Abies alba Mill. in Sp. Pl. 4(6): 455. 1987";
902
		NonViralName<?> name3 = parser.parseReferencedName(fullReference, null, rankSpecies);
903
		assertFullRefNameStandard(name3);
904
		name3.setTitleCache(null);
905
		assertEquals(fullReference, name3.getFullTitleCache());
906
		assertFalse(name3.hasProblem());
907
		ref = name3.getNomenclaturalReference();
908
		assertEquals(eu.etaxonomy.cdm.model.reference.ReferenceType.Article, ref.getType());
909
		//Article article = (Article)ref;
910
		IJournal journal = ((IArticle)ref).getInJournal();
911
		assertNotNull(journal);
912
		//assertEquals("Sp. Pl. 4(6)", inBook.getTitleCache());
913
		assertEquals("Sp. Pl.",((Reference<?>) journal).getTitleCache());
914
		assertEquals("Sp. Pl.", journal.getTitle());
915
		assertEquals("4(6)",((IArticle)ref).getVolume());
916
		assertTrue("Name author and reference author should be the same", name3.getCombinationAuthorship() == name3.getNomenclaturalReference().getAuthorship());
917

    
918
		//SoftArticle - having "," on position > 4
919
		String journalTitle = "Bull. Soc. Bot.France. Louis., Roi";
920
		String yearPart = " 1987 - 1989";
921
		String parsedYear = "1987-1989";
922
		String fullReferenceWithoutYear = "Abies alba Mill. in " + journalTitle + " 4(6): 455.";
923
		fullReference = fullReferenceWithoutYear + yearPart;
924
		String fullReferenceWithEnd = fullReference + ".";
925
		NonViralName<?> name4 = parser.parseReferencedName(fullReferenceWithEnd, null, rankSpecies);
926
		assertFalse(name4.hasProblem());
927
		assertFullRefNameStandard(name4);
928
		assertEquals(fullReferenceWithoutYear + " " + parsedYear, name4.getFullTitleCache());
929
		ref = name4.getNomenclaturalReference();
930
		assertEquals(ReferenceType.Article, ref.getType());
931
		//article = (Article)ref;
932
		assertEquals(parsedYear, ref.getYear());
933
		journal = ((IArticle)ref).getInJournal();
934
		assertNotNull(journal);
935
		assertEquals(journalTitle, ((Reference<?>) journal).getTitleCache());
936
		assertEquals(journalTitle, journal.getTitle());
937
		assertEquals("4(6)", ((IArticle)ref).getVolume());
938

    
939
		//Zoo name
940
		String strNotParsableZoo = "Abies alba M., 1923, Sp. P. xxwer4352, nom. inval.";
941
		ZoologicalName nameZooRefNotParsabel = (ZoologicalName)parser.parseReferencedName(strNotParsableZoo, null, null);
942
		assertTrue(nameZooRefNotParsabel.hasProblem());
943
		List<ParserProblem> list = nameZooRefNotParsabel.getParsingProblems();
944
		assertTrue("List must contain detail and year warning ", list.contains(ParserProblem.CheckDetailOrYear));
945
		assertEquals(21, nameZooRefNotParsabel.getProblemStarts());
946
		assertEquals(37, nameZooRefNotParsabel.getProblemEnds());
947
		assertTrue(nameZooRefNotParsabel.getNomenclaturalReference().hasProblem());
948
		list = nameZooRefNotParsabel.getNomenclaturalReference().getParsingProblems();
949
		assertTrue("List must contain detail and year warning ", list.contains(ParserProblem.CheckDetailOrYear));
950

    
951
		assertEquals(NomenclaturalCode.ICZN, nameZooRefNotParsabel.getNomenclaturalCode());
952
		assertEquals(Integer.valueOf(1923), nameZooRefNotParsabel.getPublicationYear());
953
		assertEquals(1, nameZooRefNotParsabel.getStatus().size());
954

    
955
		String strZooNameSineYear = "Homo sapiens L., 1758, Sp. An. 3: 345";
956
		ZoologicalName nameZooNameSineYear = (ZoologicalName)parser.parseReferencedName(strZooNameSineYear);
957
		assertFalse(nameZooNameSineYear.hasProblem());
958
		assertEquals("Name without reference year must have year", (Integer)1758, nameZooNameSineYear.getPublicationYear());
959
		assertEquals("Name without reference year must have year", "1758", nameZooNameSineYear.getNomenclaturalReference().getYear());
960

    
961
		String strZooNameNewCombination = "Homo sapiens (L., 1758) Mill., 1830, Sp. An. 3: 345";
962
		ZoologicalName nameZooNameNewCombination = (ZoologicalName)parser.parseReferencedName(strZooNameNewCombination);
963
		assertTrue(nameZooNameNewCombination.hasProblem());
964
		list = nameZooNameNewCombination.getParsingProblems();
965
		assertTrue("List must contain new combination has publication warning ", list.contains(ParserProblem.NewCombinationHasPublication));
966
		assertEquals(35, nameZooNameNewCombination.getProblemStarts());
967
		assertEquals(51, nameZooNameNewCombination.getProblemEnds());
968

    
969

    
970
		//Special MicroRefs
971
		String strSpecDetail1 = "Abies alba Mill. in Sp. Pl. 4(6): [455]. 1987";
972
		NonViralName<?> nameSpecDet1 = parser.parseReferencedName(strSpecDetail1 + ".", null, rankSpecies);
973
		assertFalse(nameSpecDet1.hasProblem());
974
		assertEquals(strSpecDetail1, nameSpecDet1.getFullTitleCache());
975
		assertEquals("[455]", nameSpecDet1.getNomenclaturalMicroReference());
976

    
977
		//Special MicroRefs
978
		String strSpecDetail2 = "Abies alba Mill. in Sp. Pl. 4(6): couv. 2. 1987";
979
		NonViralName<?> nameSpecDet2 = parser.parseReferencedName(strSpecDetail2 + ".", null, rankSpecies);
980
		assertFalse(nameSpecDet2.hasProblem());
981
		assertEquals(strSpecDetail2, nameSpecDet2.getFullTitleCache());
982
		assertEquals("couv. 2", nameSpecDet2.getNomenclaturalMicroReference());
983

    
984
		//Special MicroRefs
985
		String strSpecDetail3 = "Abies alba Mill. in Sp. Pl. 4(6): fig. 455. 1987";
986
		NonViralName<?> nameSpecDet3 = parser.parseReferencedName(strSpecDetail3 + ".", null, rankSpecies);
987
		assertFalse(nameSpecDet3.hasProblem());
988
		assertEquals(strSpecDetail3, nameSpecDet3.getFullTitleCache());
989
		assertEquals("fig. 455", nameSpecDet3.getNomenclaturalMicroReference());
990

    
991
		//Special MicroRefs
992
		String strSpecDetail4 = "Abies alba Mill. in Sp. Pl. 4(6): fig. 455-567. 1987";
993
		fullReference = strSpecDetail4 + ".";
994
		NonViralName<?> nameSpecDet4 = parser.parseReferencedName(fullReference, null, rankSpecies);
995
		assertFalse(nameSpecDet4.hasProblem());
996
		assertEquals(strSpecDetail4, nameSpecDet4.getFullTitleCache());
997
		assertEquals("fig. 455-567", nameSpecDet4.getNomenclaturalMicroReference());
998

    
999

    
1000
		//Special MicroRefs
1001
		String strSpecDetail5 = "Abies alba Mill. in Sp. Pl. 4(6): Gard n\u00B0 4. 1987";
1002
		fullReference = strSpecDetail5 + ".";
1003
		NonViralName<?> nameSpecDet5 = parser.parseReferencedName(fullReference, null, rankSpecies);
1004
		assertFalse(nameSpecDet5.hasProblem());
1005
		assertEquals(strSpecDetail5, nameSpecDet5.getFullTitleCache());
1006
		assertEquals("Gard n\u00B0 4", nameSpecDet5.getNomenclaturalMicroReference());
1007

    
1008
		//Special MicroRefs
1009
		String strSpecDetail6 = "Abies alba Mill. in Sp. Pl. 4(6): 455a. 1987";
1010
		fullReference = strSpecDetail6 + ".";
1011
		NonViralName<?> nameSpecDet6 = parser.parseReferencedName(fullReference, null, rankSpecies);
1012
		assertFalse(nameSpecDet6.hasProblem());
1013
		assertEquals(strSpecDetail6, nameSpecDet6.getFullTitleCache());
1014
		assertEquals("455a", nameSpecDet6.getNomenclaturalMicroReference());
1015

    
1016
		//Special MicroRefs
1017
		String strSpecDetail7 = "Abies alba Mill. in Sp. Pl. 4(6): pp.455-457. 1987";
1018
		fullReference = strSpecDetail7 + ".";
1019
		NonViralName<?> nameSpecDet7 = parser.parseReferencedName(fullReference, null, rankSpecies);
1020
		assertFalse(nameSpecDet7.hasProblem());
1021
		assertEquals(strSpecDetail7, nameSpecDet7.getFullTitleCache());
1022
		assertEquals("pp.455-457", nameSpecDet7.getNomenclaturalMicroReference());
1023

    
1024
		//Special MicroRefs
1025
		String strSpecDetail8 = "Abies alba Mill. in Sp. Pl. 4(6): ppp.455-457. 1987";
1026
		NonViralName<?> nameSpecDet8 = parser.parseReferencedName(strSpecDetail8, null, rankSpecies);
1027
		assertTrue(nameSpecDet8.hasProblem());
1028
		assertEquals(20, nameSpecDet8.getProblemStarts()); //TODO better start behind :
1029
		assertEquals(51, nameSpecDet8.getProblemEnds());   //TODO better stop after -457
1030

    
1031

    
1032
		//Special MicroRefs
1033
		String strSpecDetail9 = "Abies alba Mill. in Sp. Pl. 4(6): pp. 455 - 457. 1987";
1034
		NonViralName<?> nameSpecDet9 = parser.parseReferencedName(strSpecDetail9, null, rankSpecies);
1035
		assertFalse(nameSpecDet9.hasProblem());
1036
		assertEquals(strSpecDetail9, nameSpecDet9.getFullTitleCache());
1037
		assertEquals("pp. 455 - 457", nameSpecDet9.getNomenclaturalMicroReference());
1038

    
1039
		//Special MicroRefs
1040
		String strSpecDetail10 = "Abies alba Mill. in Sp. Pl. 4(6): p 455. 1987";
1041
		NonViralName<?> nameSpecDet10 = parser.parseReferencedName(strSpecDetail10, null, rankSpecies);
1042
		assertFalse(nameSpecDet10.hasProblem());
1043
		assertEquals(strSpecDetail10, nameSpecDet10.getFullTitleCache());
1044
		assertEquals("p 455", nameSpecDet10.getNomenclaturalMicroReference());
1045

    
1046
		//Special MicroRefs
1047
		String strSpecDetail11 = "Abies alba Mill. in Sp. Pl. 4(6): p. 455 - 457. 1987";
1048
		NonViralName<?> nameSpecDet11 = parser.parseReferencedName(strSpecDetail11, null, rankSpecies);
1049
		assertTrue(nameSpecDet11.hasProblem());
1050
		list = nameSpecDet11.getParsingProblems();
1051
		assertTrue("Problem is Detail. Must be pp.", list.contains(ParserProblem.CheckDetailOrYear));
1052
		assertEquals(20, nameSpecDet8.getProblemStarts()); //TODO better start behind :
1053
		assertEquals(51, nameSpecDet8.getProblemEnds());   //TODO better stop after - 457
1054

    
1055

    
1056
		//no volume, no edition
1057
		String strNoVolume = "Abies alba Mill., Sp. Pl.: 455. 1987";
1058
		NonViralName<?> nameNoVolume = parser.parseReferencedName(strNoVolume, null, rankSpecies);
1059
		assertFalse(nameNoVolume.hasProblem());
1060
		assertEquals(strNoVolume, nameNoVolume.getFullTitleCache());
1061
		assertEquals(null, ((IVolumeReference)(nameNoVolume.getNomenclaturalReference())).getVolume());
1062
		assertEquals(null, ((IBook)nameNoVolume.getNomenclaturalReference()).getEdition());
1063

    
1064
		//volume, no edition
1065
		strNoVolume = "Abies alba Mill., Sp. Pl. 2: 455. 1987";
1066
		nameNoVolume = parser.parseReferencedName(strNoVolume, null, rankSpecies);
1067
		assertFalse(nameNoVolume.hasProblem());
1068
		assertEquals(strNoVolume, nameNoVolume.getFullTitleCache());
1069
		assertEquals("2", ((IVolumeReference)(nameNoVolume.getNomenclaturalReference())).getVolume());
1070
		assertEquals(null, ((IBook)(nameNoVolume.getNomenclaturalReference())).getEdition());
1071

    
1072
		//no volume, edition
1073
		strNoVolume = "Abies alba Mill., Sp. Pl., ed. 3: 455. 1987";
1074
		nameNoVolume = parser.parseReferencedName(strNoVolume, null, rankSpecies);
1075
		assertFalse(nameNoVolume.hasProblem());
1076
		assertEquals(strNoVolume, nameNoVolume.getFullTitleCache());
1077
		assertEquals(null, ((IVolumeReference)(nameNoVolume.getNomenclaturalReference())).getVolume());
1078
		assertEquals("3", ((IBook)(nameNoVolume.getNomenclaturalReference())).getEdition());
1079

    
1080
		//volume, edition
1081
		strNoVolume = "Abies alba Mill., Sp. Pl. ed. 3, 4(5): 455. 1987";
1082
		nameNoVolume = parser.parseReferencedName(strNoVolume, null, rankSpecies);
1083
		assertFalse(nameNoVolume.hasProblem());
1084
		assertEquals(strNoVolume.replace(" ed.", ", ed."), nameNoVolume.getFullTitleCache());
1085
		assertEquals("4(5)", ((IVolumeReference)(nameNoVolume.getNomenclaturalReference())).getVolume());
1086
		assertEquals("3", ((IBook)(nameNoVolume.getNomenclaturalReference())).getEdition());
1087

    
1088
		String strUnparsableInRef = "Abies alba Mill. in -er46: 455. 1987";
1089
		NonViralName<?> nameUnparsableInRef = parser.parseReferencedName(strUnparsableInRef, null, rankSpecies);
1090
		assertTrue(nameUnparsableInRef.hasProblem());
1091
		list = nameUnparsableInRef.getParsingProblems();
1092
		assertTrue("Unparsable title", list.contains(ParserProblem.UnparsableReferenceTitle));
1093
		assertEquals(strUnparsableInRef, nameUnparsableInRef.getFullTitleCache());
1094
		assertEquals(20, nameUnparsableInRef.getProblemStarts());
1095
		assertEquals(25, nameUnparsableInRef.getProblemEnds());
1096

    
1097

    
1098
		//volume, edition
1099
		String strNoSeparator = "Abies alba Mill. Sp. Pl. ed. 3, 4(5): 455. 1987";
1100
		NonViralName<?> nameNoSeparator = parser.parseReferencedName(strNoSeparator, ICBN, rankSpecies);
1101
		assertTrue(nameNoSeparator.hasProblem());
1102
		list = nameNoSeparator.getParsingProblems();
1103
		assertTrue("Problem is missing name-reference separator", list.contains(ParserProblem.NameReferenceSeparation));
1104
		assertEquals(strNoSeparator, nameNoSeparator.getFullTitleCache());
1105
		assertEquals(10, nameNoSeparator.getProblemStarts()); //TODO better start behind Mill. (?)
1106
		assertEquals(47, nameNoSeparator.getProblemEnds());   //TODO better stop before :
1107

    
1108
		String strUnparsableInRef2 = "Hieracium pepsicum L., My Bookkkk 1. 1903";
1109
		NonViralName<?> nameUnparsableInRef2 = parser.parseReferencedName(strUnparsableInRef2, null, rankSpecies);
1110
		assertTrue(nameUnparsableInRef2.hasProblem());
1111
		list = nameUnparsableInRef2.getParsingProblems();
1112
		assertTrue("Problem detail", list.contains(ParserProblem.CheckDetailOrYear));
1113
		assertEquals(strUnparsableInRef2, nameUnparsableInRef2.getFullTitleCache());
1114
		assertEquals(23, nameUnparsableInRef2.getProblemStarts());
1115
		assertEquals(41, nameUnparsableInRef2.getProblemEnds());
1116

    
1117

    
1118
		String strUnparsableInRef3 = "Hieracium pespcim N., My Bookkkk 1. 1902";
1119
		NonViralName<?> nameUnparsableInRef3 = parser.parseReferencedName(strUnparsableInRef3, null, null);
1120
		assertTrue(nameUnparsableInRef3.hasProblem());
1121
		list = nameUnparsableInRef3.getParsingProblems();
1122
		assertTrue("Problem detail", list.contains(ParserProblem.CheckDetailOrYear));
1123
		assertEquals(strUnparsableInRef3, nameUnparsableInRef3.getFullTitleCache());
1124
		assertEquals(22, nameUnparsableInRef3.getProblemStarts());
1125
		assertEquals(40, nameUnparsableInRef3.getProblemEnds());
1126

    
1127
		String strUnparsableInRef4 = "Hieracium pepsicum (Hsllreterto) L., My Bookkkk 1. 1903";
1128
		NonViralName<?> nameUnparsableInRef4 = parser.parseReferencedName(strUnparsableInRef4, null, null);
1129
		assertTrue(nameUnparsableInRef4.hasProblem());
1130
		list = nameUnparsableInRef4.getParsingProblems();
1131
		assertTrue("Problem detail", list.contains(ParserProblem.CheckDetailOrYear));
1132
		assertEquals(strUnparsableInRef4, nameUnparsableInRef4.getFullTitleCache());
1133
		assertEquals(37, nameUnparsableInRef4.getProblemStarts());
1134
		assertEquals(55, nameUnparsableInRef4.getProblemEnds());
1135

    
1136
		String strSameName = "Hieracium pepcum (Hsllreterto) L., My Bokkk 1. 1903";
1137
		NonViralName<?> nameSameName = nameUnparsableInRef4;
1138
		parser.parseReferencedName(nameSameName, strSameName, null, true);
1139
		assertTrue(nameSameName.hasProblem());
1140
		list = nameSameName.getParsingProblems();
1141
		assertTrue("Problem detail", list.contains(ParserProblem.CheckDetailOrYear));
1142
		assertEquals(strSameName, nameSameName.getFullTitleCache());
1143
		assertEquals(35, nameSameName.getProblemStarts());
1144
		assertEquals(51, nameSameName.getProblemEnds());
1145

    
1146
		String strGenusUnparse = "Hieracium L., jlklk";
1147
		NonViralName<?> nameGenusUnparse =
1148
			parser.parseReferencedName(strGenusUnparse, null, null);
1149
		assertTrue(nameGenusUnparse.hasProblem());
1150
		list = nameGenusUnparse.getParsingProblems();
1151
		assertTrue("Problem detail", list.contains(ParserProblem.CheckDetailOrYear));
1152
		assertTrue("Problem uninomial", list.contains(ParserProblem.CheckRank));
1153
		assertEquals(strGenusUnparse, nameGenusUnparse.getFullTitleCache());
1154
		assertEquals(0, nameGenusUnparse.getProblemStarts());
1155
		assertEquals(19, nameGenusUnparse.getProblemEnds());
1156

    
1157
		String strGenusUnparse2 = "Hieracium L., Per Luigi: 44. 1987";
1158
		NonViralName<?> nameGenusUnparse2 =
1159
			parser.parseReferencedName(strGenusUnparse2, null, Rank.FAMILY());
1160
		assertFalse(nameGenusUnparse2.hasProblem());
1161
		assertEquals(strGenusUnparse2, nameGenusUnparse2.getFullTitleCache());
1162
		assertEquals(-1, nameGenusUnparse2.getProblemStarts());
1163
		assertEquals(-1, nameGenusUnparse2.getProblemEnds());
1164

    
1165
		String strBookSection2 = "Hieracium vulgatum subsp. acuminatum (Jord.) Zahn in Schinz & Keller, Fl. Schweiz, ed. 2, 2: 288. 1905-1907";
1166
		String strBookSection2NoComma = "Hieracium vulgatum subsp. acuminatum (Jord.) Zahn in Schinz & Keller, Fl. Schweiz ed. 2, 2: 288. 1905-1907";
1167
		NonViralName<?> nameBookSection2 =
1168
			parser.parseReferencedName(strBookSection2, null, null);
1169
		assertFalse(nameBookSection2.hasProblem());
1170
		nameBookSection2.setFullTitleCache(null, false);
1171
		assertEquals(strBookSection2NoComma.replace(" ed.", ", ed."), nameBookSection2.getFullTitleCache());
1172
		assertEquals(-1, nameBookSection2.getProblemStarts());
1173
		assertEquals(-1, nameBookSection2.getProblemEnds());
1174
		assertNull((nameBookSection2.getNomenclaturalReference()).getDatePublished().getStart());
1175
		assertEquals("1905-1907", ((IBookSection)nameBookSection2.getNomenclaturalReference()).getInBook().getDatePublished().getYear());
1176

    
1177

    
1178
		String strBookSection = "Hieracium vulgatum subsp. acuminatum (Jord.) Zahn in Schinz & Keller, Fl. Schweiz ed. 2, 2: 288. 1905";
1179
		NonViralName<?> nameBookSection =
1180
			parser.parseReferencedName(strBookSection, null, null);
1181
		assertFalse(nameBookSection.hasProblem());
1182
		assertEquals(strBookSection.replace(" ed.", ", ed."), nameBookSection.getFullTitleCache());
1183
		assertEquals(-1, nameBookSection.getProblemStarts());
1184
		assertEquals(-1, nameBookSection.getProblemEnds());
1185
		assertNull(((IBookSection)nameBookSection.getNomenclaturalReference()).getInBook().getDatePublished().getStart());
1186
		assertEquals("1905", ((IBookSection)nameBookSection.getNomenclaturalReference()).getDatePublished().getYear());
1187

    
1188
		String strXXXs = "Abies alba, Soer der 1987";
1189
		NonViralName<?> problemName = parser.parseReferencedName(strXXXs, null, null);
1190
		assertTrue(problemName.hasProblem());
1191
		list = problemName.getParsingProblems();
1192
		assertTrue("Problem must be name-reference separation", list.contains(ParserProblem.NameReferenceSeparation));
1193
		parser.parseReferencedName(problemName, strBookSection, null, true);
1194
		assertFalse(problemName.hasProblem());
1195

    
1196
		problemName = parser.parseFullName(strXXXs, null, null);
1197
		assertTrue(problemName.hasProblem());
1198
		list = problemName.getParsingProblems();
1199
		assertTrue("Name part must be unparsable", list.contains(ParserProblem.UnparsableNamePart));
1200

    
1201

    
1202
		String testParsable = "Pithecellobium macrostachyum Benth.";
1203
		assertTrue(isParsable(testParsable, ICBN));
1204

    
1205
		testParsable = "Pithecellobium macrostachyum (Benth.)";
1206
		assertTrue(isParsable(testParsable, ICBN));
1207

    
1208
		testParsable = "Pithecellobium macrostachyum (Benth., 1845)";
1209
		assertTrue(isParsable(testParsable, NomenclaturalCode.ICZN));
1210

    
1211
		testParsable = "Pithecellobium macrostachyum L., Sp. Pl. 3: n\u00B0 123. 1753."; //00B0 is degree character
1212
		assertTrue(isParsable(testParsable, ICBN));
1213

    
1214
		testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. Mitt.-Eur. 6: 1285. 1929";
1215
		assertTrue("Reference title should support special characters as separators like - and &", isParsable(testParsable, ICBN));
1216

    
1217
		testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. Mitt.&Eur. 6: 1285. 1929";
1218
		assertTrue("Reference title should support special characters as separators like - and &", isParsable(testParsable, ICBN));
1219

    
1220
		testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. Mitt.-Eur.& 6: 1285. 1929";
1221
		assertFalse("Reference title should not support special characters like - and & at the end of the title", isParsable(testParsable, ICBN));
1222
		assertTrue("Problem must be reference title", getProblems(testParsable, ICBN).
1223
				contains(ParserProblem.UnparsableReferenceTitle));
1224

    
1225
		testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. Mitt.:Eur. 6: 1285. 1929";
1226
		assertFalse("Reference title should not support detail separator", isParsable(testParsable, ICBN));
1227
		assertTrue("Problem must be reference title", getProblems(testParsable, ICBN).
1228
				contains(ParserProblem.UnparsableReferenceTitle));
1229

    
1230
		testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. (Mitt.) 6: 1285. 1929";
1231
		assertTrue("Reference title should support brackets", isParsable(testParsable, ICBN));
1232

    
1233
		testParsable = "Hieracium lachenalii subsp. acuminatum (Jord.) Zahn in Hegi, Ill. Fl. (Mitt.) 6: 1285. 1929";
1234
		assertTrue("Reference title should support brackets", isParsable(testParsable, ICBN));
1235

    
1236
		testParsable = "Hieracium lachenalii Zahn, nom. illeg.";
1237
		assertTrue("Reference should not be obligatory if a nom status exist", isParsable(testParsable, ICBN));
1238

    
1239
		testParsable = "Hieracium lachenalii, nom. illeg.";
1240
		assertTrue("Authorship should not be obligatory if followed by nom status", isParsable(testParsable, ICBN));
1241

    
1242
		testParsable = "Hieracium lachenalii, Ill. Fl. (Mitt.) 6: 1285. 1929";
1243
		assertFalse("Author is obligatory if followed by reference", isParsable(testParsable, ICBN));
1244
		assertTrue("Problem must be name-reference separation", getProblems(testParsable, ICBN).
1245
				contains(ParserProblem.NameReferenceSeparation));
1246

    
1247
		testParsable = "Hieracium lachenalii in Hegi, Ill. Fl. (Mitt.) 6: 1285. 1929";
1248
		assertFalse("Author is obligatory if followed by reference", isParsable(testParsable, ICBN));
1249
		assertTrue("Problem must be name-reference separation", getProblems(testParsable, ICBN).
1250
				contains(ParserProblem.NameReferenceSeparation));
1251

    
1252
		testParsable = "Abies alba Mill. var. alba";
1253
		assertTrue("Autonym problem", isParsable(testParsable, ICBN));
1254

    
1255
		testParsable = "Scleroblitum abc Ulbr. in Engler & Prantl, Nat. Pflanzenfam., ed. 2, 16c: 495. 1934.";
1256
		assertTrue("Volume with subdivision", isParsable(testParsable, ICBN));
1257

    
1258

    
1259
		testParsable = "Hieracium antarcticum d'Urv. in M\u00E9m. Soc. Linn. Paris 4: 608. 1826";
1260
//		testParsable = "Hieracium antarcticum Urv. in M\u00E9m. Soc. Linn. Paris 4: 608. 1826";
1261
		assertTrue("Name with apostrophe is not parsable", isParsable(testParsable, ICBN));
1262

    
1263
		testParsable = "Cichorium intybus subsp. glaucum (Hoffmanns. & Link) Tzvelev in Komarov, Fl. SSSR 29: 17. 1964";
1264
		assertTrue("Reference containing a word in uppercase is not parsable", isParsable(testParsable, ICBN));
1265

    
1266

    
1267
	}
1268

    
1269

    
1270
	/**
1271
	 * Test author with name parts van, von, de, de la, d', da, del.
1272
	 * See also http://dev.e-taxonomy.eu/trac/ticket/3373
1273
	 */
1274
	@Test
1275
	public final void  testComposedAuthorNames(){
1276

    
1277
		//van author (see https://dev.e-taxonomy.eu/trac/ticket/3373)
1278
		String testParsable = "Aphelocoma unicolor subsp. griscomi van Rossem, 1928";
1279
		assertTrue("Author with 'van' should be parsable", isParsable(testParsable, ICZN));
1280

    
1281
		//von author (see https://dev.e-taxonomy.eu/trac/ticket/3373)
1282
		testParsable = "Aphelocoma unicolor subsp. griscomi von Rossem, 1928";
1283
		assertTrue("Author with 'von' should be parsable", isParsable(testParsable, ICZN));
1284

    
1285
		//de author (see https://dev.e-taxonomy.eu/trac/ticket/3373)
1286
		testParsable = "Aphelocoma unicolor subsp. griscomi de Rossem, 1928";
1287
		assertTrue("Author with 'de' should be parsable", isParsable(testParsable, ICZN));
1288

    
1289
		//de la author (see https://dev.e-taxonomy.eu/trac/ticket/3373)
1290
		testParsable = "Aphelocoma unicolor subsp. griscomi de la Rossem, 1928";
1291
		assertTrue("Author with 'de la' should be parsable", isParsable(testParsable, ICZN));
1292

    
1293
		//d' author (see https://dev.e-taxonomy.eu/trac/ticket/3373)
1294
		testParsable = "Aphelocoma unicolor subsp. griscomi d'Rossem, 1928";
1295
		assertTrue("Author with \"'d'\" should be parsable", isParsable(testParsable, ICZN));
1296

    
1297
		//da author (see https://dev.e-taxonomy.eu/trac/ticket/3373)
1298
		testParsable = "Aphelocoma unicolor subsp. griscomi da Rossem, 1928";
1299
		assertTrue("Author with 'da' should be parsable", isParsable(testParsable, ICZN));
1300

    
1301
		//del author (see https://dev.e-taxonomy.eu/trac/ticket/3373)
1302
		testParsable = "Aphelocoma unicolor subsp. griscomi del Rossem, 1928";
1303
		assertTrue("Author with 'del' should be parsable", isParsable(testParsable, ICZN));
1304

    
1305
		//O' author (see https://dev.e-taxonomy.eu/trac/ticket/4759)
1306
		testParsable = "Aphelocoma unicolor subsp. griscomi O'Connor, 1928";
1307
		assertTrue("Author with 'O'' should be parsable", isParsable(testParsable, ICZN));
1308

    
1309
		//del author (see https://dev.e-taxonomy.eu/trac/ticket/4759)
1310
		testParsable = "Aphelocoma unicolor subsp. griscomi zur Strassen, 1928";
1311
		assertTrue("Author with 'zur' should be parsable", isParsable(testParsable, ICZN));
1312

    
1313
	}
1314

    
1315

    
1316

    
1317
	/**
1318
	 * @param testParsable
1319
	 * @param icbn
1320
	 * @return
1321
	 */
1322
	private List<ParserProblem> getProblems(String string, NomenclaturalCode code) {
1323
		List<ParserProblem> result;
1324
		result = parser.parseReferencedName(string, code, null).getParsingProblems();
1325
		return result;
1326
	}
1327

    
1328
	private boolean isParsable(String string, NomenclaturalCode code){
1329
		NonViralName<?> name = parser.parseReferencedName(string, code, null);
1330
		return ! name.hasProblem();
1331
	}
1332

    
1333
	private void assertFullRefNameStandard(NonViralName<?> name){
1334
		assertEquals("Abies", name.getGenusOrUninomial());
1335
		assertEquals("alba", name.getSpecificEpithet());
1336
		assertEquals("Mill.", name.getAuthorshipCache());
1337
		assertEquals("455", name.getNomenclaturalMicroReference());
1338
		assertNotNull(name.getNomenclaturalReference());
1339
	}
1340

    
1341
	private void assertFullRefStandard(NonViralName<?> name){
1342
		assertEquals("Abies", name.getGenusOrUninomial());
1343
		assertEquals("alba", name.getSpecificEpithet());
1344
		assertEquals("Mill.", name.getAuthorshipCache());
1345
		assertEquals("455", name.getNomenclaturalMicroReference());
1346
		assertNotNull(name.getNomenclaturalReference());
1347
		INomenclaturalReference ref = name.getNomenclaturalReference();
1348
		assertEquals("1987", ref.getYear());
1349
		assertEquals("Sp. Pl.", ref.getTitle());
1350
	}
1351

    
1352

    
1353
	@Test
1354
	public void testNeverEndingParsing(){
1355
		//some full titles result in never ending parsing process https://dev.e-taxonomy.eu/trac/ticket/1556
1356

    
1357
		String irinaExample = "Milichiidae Sharp, 1899, Insects. Part II. Hymenopteracontinued (Tubulifera and Aculeata), Coleoptera, Strepsiptera, Lepidoptera, Diptera, Aphaniptera, Thysanoptera, Hemiptera, Anoplura 6: 504. 1899";
1358
//		irinaExample = "Milichiidae Sharp, 1899, Insects. Part II. Uiuis Iuiui Hymenopteracontinued (Tubulifera and Aculeata), Coleoptera, Strepsiptera, Lepidoptera, Diptera, Aphaniptera, Thysanoptera, Hemiptera, Anoplura 6: 504. 1899";
1359
		NonViralName<?> nvn = this.parser.parseReferencedName(irinaExample, NomenclaturalCode.ICZN, null);
1360
		int parsingProblem = nvn.getParsingProblem();
1361
		Assert.assertEquals("Name should have only rank warning", 1, parsingProblem);
1362
		Assert.assertEquals("Titlecache", "Milichiidae Sharp, 1899", nvn.getTitleCache());
1363
		Assert.assertEquals("If this line reached everything should be ok", "Milichiidae", nvn.getGenusOrUninomial());
1364

    
1365
		String anotherExample = "Scorzonera hispanica var. brevifolia Boiss. & Balansa in Boissier, Diagn. Pl. Orient., ser. 2 6: 119. 1859.";
1366
		nvn = this.parser.parseReferencedName(anotherExample, ICBN, null);
1367
		parsingProblem = nvn.getParsingProblem();
1368
		Assert.assertEquals("Problem should be 0", 0, parsingProblem);
1369
		Assert.assertEquals("Titlecache", "Scorzonera hispanica var. brevifolia Boiss. & Balansa", nvn.getTitleCache());
1370
		Assert.assertEquals("If this line reached everything should be ok", "Scorzonera", nvn.getGenusOrUninomial());
1371

    
1372
		String unparsable = "Taraxacum nevskii L., Trudy Bot. Inst. Nauk S.S.S.R., Ser. 1, Fl. Sist. Vyssh. Rast. 4: 293. 1937.";
1373
//		String unparsableA = "Taraxacum nevskii L. in Trudy Bot. Inst. Nauk: 293. 1937.";
1374
		nvn = this.parser.parseReferencedName(unparsable, ICBN, null);
1375
		Assert.assertEquals("Titlecache", "Taraxacum nevskii L.", nvn.getTitleCache());
1376
		Assert.assertEquals("If this line reached everything should be ok", "Taraxacum", nvn.getGenusOrUninomial());
1377
		parsingProblem = nvn.getParsingProblem();
1378
		Assert.assertEquals("Name should no warnings or errors", 0, parsingProblem);
1379

    
1380
		String unparsable2 = "Hieracium pxxx Dahlst., Kongl. Svenska Vetensk. Acad. Handl. ser. 2, 26(3): 255. 1894";
1381
//		String unparsable2A = "Hieracium pxxx Dahlst., Kongl Svenska Vetensk Acad Handl, 26: 255. 1894.";
1382
		nvn = this.parser.parseReferencedName(unparsable2, ICBN, null);
1383
		Assert.assertEquals("Titlecache", "Hieracium pxxx Dahlst.", nvn.getTitleCache());
1384
		Assert.assertEquals("If this line reached everything should be ok", "Hieracium", nvn.getGenusOrUninomial());
1385
		parsingProblem = nvn.getParsingProblem();
1386
		Assert.assertEquals("Name should no warnings or errors", 0, parsingProblem);
1387

    
1388

    
1389
		String again = "Adiantum emarginatum Bory ex. Willd., Species Plantarum, ed. 4,5,1: 449,450. 1810";
1390
		nvn = this.parser.parseReferencedName(again, ICBN, null);
1391
		Assert.assertEquals("Titlecache", "Adiantum emarginatum Bory ex Willd.", nvn.getTitleCache());
1392
		Assert.assertEquals("If this line reached everything should be ok", "Adiantum", nvn.getGenusOrUninomial());
1393

    
1394
	}
1395

    
1396
	@Test
1397
	public final void testSeriesPart(){
1398
		Pattern seriesPattern = Pattern.compile(NonViralNameParserImpl.pSeriesPart);
1399
		Matcher matcher = seriesPattern.matcher("ser. 2");
1400
		Assert.assertTrue("", matcher.matches());
1401
	}
1402

    
1403
	/**
1404
	 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#fullTeams(java.lang.String)}.
1405
	 */
1406
	@Test
1407
	public final void testFullTeams() {
1408
		logger.warn("Not yet implemented"); // TODO
1409
	}
1410

    
1411
	/**
1412
	 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#AuthorshipAndEx(java.lang.String)}.
1413
	 * @throws StringNotParsableException
1414
	 */
1415
	@Test
1416
	public final void testParseAuthorsTaxonNameString() throws StringNotParsableException {
1417
		NonViralName<?> nvn = ZoologicalName.NewInstance(null);
1418
		parser.parseAuthors(nvn, "Eckweiler & ten Hagen, 2003");
1419
		Team team = (Team)nvn.getCombinationAuthorship();
1420
		Assert.assertNotNull("Comb. author must not be null", team);
1421
		Assert.assertEquals("Must be team with 2 members", 2, team.getTeamMembers().size());
1422
		Assert.assertEquals("Second member must be 'ten Hagen'", "ten Hagen", team.getTeamMembers().get(1).getTitleCache());
1423

    
1424
		//Crosson du Cormier, 1964
1425
		ZoologicalName zooName = ZoologicalName.NewInstance(null);
1426
		parser.parseAuthors(zooName, "Crosson du Cormier, 1964");
1427
		Person person = (Person)zooName.getCombinationAuthorship();
1428
		Assert.assertNotNull("Comb. author must not be null", person);
1429
		Assert.assertEquals("Persons title must be 'Crosson du Cormier'", "Crosson du Cormier", person.getTitleCache());
1430
		Assert.assertEquals("Year must be 1964", Integer.valueOf(1964), zooName.getPublicationYear() );
1431

    
1432
		//(van der Hoeven, 1839)
1433
		zooName = ZoologicalName.NewInstance(null);
1434
		parser.parseAuthors(zooName, "(van der Hoeven, 1839)");
1435
		Assert.assertNull("Combination author must be null", zooName.getCombinationAuthorship());
1436
		person = (Person)zooName.getBasionymAuthorship();
1437
		Assert.assertNotNull("Basionym author must not be null", person);
1438
		Assert.assertEquals("Persons title must be 'van der Hoeven'", "van der Hoeven", person.getTitleCache());
1439
		Assert.assertEquals("Year must be 1839", Integer.valueOf(1839), zooName.getOriginalPublicationYear() );
1440

    
1441
		//le Doux, 1931
1442
		zooName = ZoologicalName.NewInstance(null);
1443
		parser.parseAuthors(zooName, "le Doux, 1931");
1444
		person = (Person)zooName.getCombinationAuthorship();
1445
		Assert.assertNotNull("Comb. author must not be null", person);
1446
		Assert.assertEquals("Persons title must be 'le Doux'", "le Doux", person.getTitleCache());
1447
		Assert.assertEquals("Year must be 1931", Integer.valueOf(1931), zooName.getPublicationYear() );
1448

    
1449

    
1450
	}
1451

    
1452
	@Test  //#4764
1453
	public void testParseSection(){
1454
	    //this test does not really test problematic cases where sect.idInVoc = "sect." instead of "sect.(bot.)"
1455
	    //however, by changing the csv file entry to sect. just for testing it can be used as a functional test
1456
	    String sectionNameStr = "Taraxacum sect. Testtaxa Müller, Incredible Taxa: 12. 2016";
1457
	    NonViralName<?> sectionName = parser.parseReferencedName(sectionNameStr, NomenclaturalCode.ICNAFP, null);
1458
	    int parsingProblem = sectionName.getParsingProblem();
1459
	    Assert.assertEquals("Problem should be 0", 0, parsingProblem);
1460
	    Rank rank = sectionName.getRank();
1461
	    Assert.assertEquals("", Rank.SECTION_BOTANY(), rank  );
1462

    
1463
	}
1464

    
1465

    
1466

    
1467
	/**
1468
	 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#AuthorshipAndEx(java.lang.String)}.
1469
	 */
1470
	@Test
1471
	public final void testAuthorshipAndEx() {
1472
		logger.warn("Not yet implemented"); // TODO
1473
	}
1474

    
1475
	/**
1476
	 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#Authorship(java.lang.String)}.
1477
	 */
1478
	@Test
1479
	public final void testAuthorship() {
1480
		logger.warn("Not yet implemented"); // TODO
1481
	}
1482

    
1483
	/**
1484
	 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseCultivar(java.lang.String)}.
1485
	 */
1486
	@Test
1487
	public final void testParseCultivar() {
1488
		logger.warn("Not yet implemented"); // TODO
1489
	}
1490

    
1491
//	@Ignore // please add this test once #2750 is fixed
1492
	@Test
1493
	public final void testNomenclaturalStatus() {
1494
		BotanicalName name = BotanicalName.NewInstance(Rank.FAMILY(), "Acanthopale", null, null, null, null, null, null, null);
1495
		name.addStatus(NomenclaturalStatus.NewInstance(NomenclaturalStatusType.ALTERNATIVE()));
1496

    
1497
		BotanicalName name2 = BotanicalName.NewInstance(Rank.FAMILY());
1498

    
1499
		parser.parseReferencedName(name2, name.getFullTitleCache(),	name2.getRank(), true);
1500

    
1501
		parser.parseReferencedName(name2, name.getFullTitleCache(),	name2.getRank(), true);
1502

    
1503
		Assert.assertEquals("Title cache should be same. No duplication of nom. status should take place", name.getFullTitleCache(), name2.getFullTitleCache());
1504

    
1505

    
1506
	}
1507

    
1508
}
(2-2/4)