Project

General

Profile

Download (4.72 KB) Statistics
| Branch: | Tag: | Revision:
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 org.junit.Assert;
13

    
14
import org.junit.Before;
15
import org.junit.BeforeClass;
16
import org.junit.Test;
17

    
18
import eu.etaxonomy.cdm.model.common.DefaultTermInitializer;
19
import eu.etaxonomy.cdm.model.name.NameTypeDesignationStatus;
20
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;
21

    
22
/**
23
 * @author a.mueller
24
 * @date 02.08.2011
25
 *
26
 */
27
public class NameTypeParserTest {
28

    
29
	/**
30
	 * @throws java.lang.Exception
31
	 */
32
	@BeforeClass
33
	public static void setUpBeforeClass() throws Exception {
34
		DefaultTermInitializer initializer = new DefaultTermInitializer();
35
		initializer.initialize();
36
	}
37

    
38
	/**
39
	 * @throws java.lang.Exception
40
	 */
41
	@Before
42
	public void setUp() throws Exception {
43
	}
44

    
45
	/**
46
	 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NameTypeParser#makeNameTypeStatus(java.lang.String)}.
47
	 */
48
	@Test
49
	public void testMakeNameTypeStatus() {
50
		//orig dest
51
		String typeString = "original designation";
52
		NameTypeDesignationStatus type;
53
		try {
54
			type = NameTypeParser.parseNameTypeStatus(typeString);
55
			Assert.assertEquals("Type should be original designation", NameTypeDesignationStatus.ORIGINAL_DESIGNATION(), type);
56
		} catch (UnknownCdmTypeException e) {
57
			Assert.fail(typeString + " not recognized");
58
		}	
59
		typeString = "original desig.";
60
		try {
61
			type = NameTypeParser.parseNameTypeStatus(typeString);
62
			Assert.assertEquals("Type should be original designation", NameTypeDesignationStatus.ORIGINAL_DESIGNATION(), type);
63
		} catch (UnknownCdmTypeException e) {
64
			Assert.fail(typeString + " not recognized");
65
		}
66
		typeString = "ORIginAL DESig.";
67
		try {
68
			type = NameTypeParser.parseNameTypeStatus(typeString);
69
			Assert.assertEquals("Type should be original designation", NameTypeDesignationStatus.ORIGINAL_DESIGNATION(), type);
70
		} catch (UnknownCdmTypeException e) {
71
			Assert.fail(typeString + " not recognized");
72
		}
73

    
74
		//present desig
75
		typeString = "present designation";
76
		try {
77
			type = NameTypeParser.parseNameTypeStatus(typeString);
78
			Assert.assertEquals("Type should be present designation", NameTypeDesignationStatus.PRESENT_DESIGNATION(), type);
79
		} catch (UnknownCdmTypeException e) {
80
			Assert.fail(typeString + " not recognized");
81
		}
82
		//subsequent desig
83
		typeString = "subsequent designation";
84
		try {
85
			type = NameTypeParser.parseNameTypeStatus(typeString);
86
			Assert.assertEquals("Type should be subsequent designation", NameTypeDesignationStatus.SUBSEQUENT_DESIGNATION(), type);
87
		} catch (UnknownCdmTypeException e) {
88
			Assert.fail(typeString + " not recognized");
89
		}
90
		//monotypy
91
		typeString = "monotypy";
92
		try {
93
			type = NameTypeParser.parseNameTypeStatus(typeString);
94
			Assert.assertEquals("Type should be 'monotypy'", NameTypeDesignationStatus.MONOTYPY(), type);
95
		} catch (UnknownCdmTypeException e) {
96
			Assert.fail(typeString + " not recognized");
97
		}
98
		//subs. monotypy
99
		typeString = "subsequent monotypy";
100
		try {
101
			type = NameTypeParser.parseNameTypeStatus(typeString);
102
			Assert.assertEquals("Type should be 'subsequent monotypy'", NameTypeDesignationStatus.SUBSEQUENT_MONOTYPY(), type);
103
		} catch (UnknownCdmTypeException e) {
104
			Assert.fail(typeString + " not recognized");
105
		}
106

    
107
		//tautonomy
108
		typeString = "tautonomy";
109
		try {
110
			type = NameTypeParser.parseNameTypeStatus(typeString);
111
			Assert.assertEquals("Type should be tautonomy", NameTypeDesignationStatus.TAUTONYMY(), type);
112
		} catch (UnknownCdmTypeException e) {
113
			Assert.fail(typeString + " not recognized");
114
		}
115
		//lectotype
116
		typeString = "lectotype";
117
		try {
118
			type = NameTypeParser.parseNameTypeStatus(typeString);
119
			Assert.assertEquals("Type should be lectotype", NameTypeDesignationStatus.LECTOTYPE(), type);
120
		} catch (UnknownCdmTypeException e) {
121
			Assert.fail(typeString + " not recognized");
122
		}
123
		//automatic
124
		typeString = "automatic";
125
		try {
126
			type = NameTypeParser.parseNameTypeStatus(typeString);
127
			Assert.assertEquals("Type should be automatic", NameTypeDesignationStatus.AUTOMATIC(), type);
128
		} catch (UnknownCdmTypeException e) {
129
			Assert.fail(typeString + " not recognized");
130
		}
131
		//automatic
132
		typeString = "not applicable";
133
		try {
134
			type = NameTypeParser.parseNameTypeStatus(typeString);
135
			Assert.assertEquals("Type should be 'not applicable'", NameTypeDesignationStatus.NOT_APPLICABLE(), type);
136
		} catch (UnknownCdmTypeException e) {
137
			Assert.fail(typeString + " not recognized");
138
		}
139

    
140

    
141

    
142
	}
143
}
(1-1/4)