3 * Copyright (C) 2009 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.strategy
.parser
;
12 import static org
.junit
.Assert
.*;
13 import junit
.framework
.Assert
;
15 import org
.junit
.Before
;
16 import org
.junit
.BeforeClass
;
17 import org
.junit
.Test
;
19 import eu
.etaxonomy
.cdm
.model
.common
.DefaultTermInitializer
;
20 import eu
.etaxonomy
.cdm
.model
.name
.NameTypeDesignationStatus
;
21 import eu
.etaxonomy
.cdm
.strategy
.exceptions
.UnknownCdmTypeException
;
28 public class NameTypeParserTest
{
31 * @throws java.lang.Exception
34 public static void setUpBeforeClass() throws Exception
{
35 DefaultTermInitializer initializer
= new DefaultTermInitializer();
36 initializer
.initialize();
40 * @throws java.lang.Exception
43 public void setUp() throws Exception
{
47 * Test method for {@link eu.etaxonomy.cdm.strategy.parser.NameTypeParser#makeNameTypeStatus(java.lang.String)}.
50 public void testMakeNameTypeStatus() {
52 String typeString
= "original designation";
53 NameTypeDesignationStatus type
;
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");
60 typeString
= "original desig.";
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");
67 typeString
= "ORIginAL DESig.";
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");
76 typeString
= "present designation";
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");
84 typeString
= "subsequent designation";
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");
92 typeString
= "monotypy";
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");
100 typeString
= "subsequent monotypy";
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");
109 typeString
= "tautonomy";
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");
117 typeString
= "lectotype";
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");
125 typeString
= "automatic";
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");
133 typeString
= "not applicable";
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");