Project

General

Profile

Download (4.72 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 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
package eu.etaxonomy.cdm.strategy.parser;
10

    
11
import org.junit.Assert;
12

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

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

    
21
/**
22
 * @author a.mueller
23
 \* @since 02.08.2011
24
 *
25
 */
26
public class NameTypeParserTest {
27

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

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

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

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

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

    
139

    
140

    
141
	}
142
}
(1-1/4)