Correct handling for multiple author teams (replace & by , )
[cdmlib.git] / cdmlib-model / src / test / java / eu / etaxonomy / cdm / strategy / parser / NameTypeParserTest.java
1 // $Id$
2 /**
3 * Copyright (C) 2009 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10 package eu.etaxonomy.cdm.strategy.parser;
11
12 import static org.junit.Assert.*;
13 import junit.framework.Assert;
14
15 import org.junit.Before;
16 import org.junit.BeforeClass;
17 import org.junit.Test;
18
19 import eu.etaxonomy.cdm.model.common.DefaultTermInitializer;
20 import eu.etaxonomy.cdm.model.name.NameTypeDesignationStatus;
21 import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;
22
23 /**
24 * @author a.mueller
25 * @date 02.08.2011
26 *
27 */
28 public class NameTypeParserTest {
29
30 /**
31 * @throws java.lang.Exception
32 */
33 @BeforeClass
34 public static void setUpBeforeClass() throws Exception {
35 DefaultTermInitializer initializer = new DefaultTermInitializer();
36 initializer.initialize();
37 }
38
39 /**
40 * @throws java.lang.Exception
41 */
42 @Before
43 public void setUp() throws Exception {
44 }
45
46 /**
47 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NameTypeParser#makeNameTypeStatus(java.lang.String)}.
48 */
49 @Test
50 public void testMakeNameTypeStatus() {
51 //orig dest
52 String typeString = "original designation";
53 NameTypeDesignationStatus type;
54 try {
55 type = NameTypeParser.parseNameTypeStatus(typeString);
56 Assert.assertEquals("Type should be original designation", NameTypeDesignationStatus.ORIGINAL_DESIGNATION(), type);
57 } catch (UnknownCdmTypeException e) {
58 Assert.fail(typeString + " not recognized");
59 }
60 typeString = "original desig.";
61 try {
62 type = NameTypeParser.parseNameTypeStatus(typeString);
63 Assert.assertEquals("Type should be original designation", NameTypeDesignationStatus.ORIGINAL_DESIGNATION(), type);
64 } catch (UnknownCdmTypeException e) {
65 Assert.fail(typeString + " not recognized");
66 }
67 typeString = "ORIginAL DESig.";
68 try {
69 type = NameTypeParser.parseNameTypeStatus(typeString);
70 Assert.assertEquals("Type should be original designation", NameTypeDesignationStatus.ORIGINAL_DESIGNATION(), type);
71 } catch (UnknownCdmTypeException e) {
72 Assert.fail(typeString + " not recognized");
73 }
74
75 //present desig
76 typeString = "present designation";
77 try {
78 type = NameTypeParser.parseNameTypeStatus(typeString);
79 Assert.assertEquals("Type should be present designation", NameTypeDesignationStatus.PRESENT_DESIGNATION(), type);
80 } catch (UnknownCdmTypeException e) {
81 Assert.fail(typeString + " not recognized");
82 }
83 //subsequent desig
84 typeString = "subsequent designation";
85 try {
86 type = NameTypeParser.parseNameTypeStatus(typeString);
87 Assert.assertEquals("Type should be subsequent designation", NameTypeDesignationStatus.SUBSEQUENT_DESIGNATION(), type);
88 } catch (UnknownCdmTypeException e) {
89 Assert.fail(typeString + " not recognized");
90 }
91 //monotypy
92 typeString = "monotypy";
93 try {
94 type = NameTypeParser.parseNameTypeStatus(typeString);
95 Assert.assertEquals("Type should be 'monotypy'", NameTypeDesignationStatus.MONOTYPY(), type);
96 } catch (UnknownCdmTypeException e) {
97 Assert.fail(typeString + " not recognized");
98 }
99 //subs. monotypy
100 typeString = "subsequent monotypy";
101 try {
102 type = NameTypeParser.parseNameTypeStatus(typeString);
103 Assert.assertEquals("Type should be 'subsequent monotypy'", NameTypeDesignationStatus.SUBSEQUENT_MONOTYPY(), type);
104 } catch (UnknownCdmTypeException e) {
105 Assert.fail(typeString + " not recognized");
106 }
107
108 //tautonomy
109 typeString = "tautonomy";
110 try {
111 type = NameTypeParser.parseNameTypeStatus(typeString);
112 Assert.assertEquals("Type should be tautonomy", NameTypeDesignationStatus.TAUTONYMY(), type);
113 } catch (UnknownCdmTypeException e) {
114 Assert.fail(typeString + " not recognized");
115 }
116 //lectotype
117 typeString = "lectotype";
118 try {
119 type = NameTypeParser.parseNameTypeStatus(typeString);
120 Assert.assertEquals("Type should be lectotype", NameTypeDesignationStatus.LECTOTYPE(), type);
121 } catch (UnknownCdmTypeException e) {
122 Assert.fail(typeString + " not recognized");
123 }
124 //automatic
125 typeString = "automatic";
126 try {
127 type = NameTypeParser.parseNameTypeStatus(typeString);
128 Assert.assertEquals("Type should be automatic", NameTypeDesignationStatus.AUTOMATIC(), type);
129 } catch (UnknownCdmTypeException e) {
130 Assert.fail(typeString + " not recognized");
131 }
132 //automatic
133 typeString = "not applicable";
134 try {
135 type = NameTypeParser.parseNameTypeStatus(typeString);
136 Assert.assertEquals("Type should be 'not applicable'", NameTypeDesignationStatus.NOT_APPLICABLE(), type);
137 } catch (UnknownCdmTypeException e) {
138 Assert.fail(typeString + " not recognized");
139 }
140
141
142
143 }
144 }