Revision 4dbcb616
Added by Andreas Müller over 3 years ago
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/parser/NonViralNameParserImplTest.java | ||
---|---|---|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
9 |
|
|
10 | 9 |
package eu.etaxonomy.cdm.strategy.parser; |
11 | 10 |
|
12 | 11 |
import static org.junit.Assert.assertEquals; |
... | ... | |
26 | 25 |
import org.joda.time.Duration; |
27 | 26 |
import org.junit.Assert; |
28 | 27 |
import org.junit.Before; |
29 |
import org.junit.BeforeClass; |
|
30 | 28 |
import org.junit.Ignore; |
31 | 29 |
import org.junit.Test; |
32 | 30 |
|
... | ... | |
54 | 52 |
import eu.etaxonomy.cdm.model.reference.IVolumeReference; |
55 | 53 |
import eu.etaxonomy.cdm.model.reference.Reference; |
56 | 54 |
import eu.etaxonomy.cdm.model.reference.ReferenceType; |
57 |
import eu.etaxonomy.cdm.model.term.DefaultTermInitializer; |
|
58 | 55 |
import eu.etaxonomy.cdm.strategy.exceptions.StringNotParsableException; |
56 |
import eu.etaxonomy.cdm.test.TermTestBase; |
|
59 | 57 |
|
60 | 58 |
/** |
61 | 59 |
* Tests for {@link NonViralNameParserImpl}. |
62 | 60 |
* |
63 | 61 |
* @author a.mueller |
64 | 62 |
*/ |
65 |
public class NonViralNameParserImplTest { |
|
63 |
public class NonViralNameParserImplTest extends TermTestBase {
|
|
66 | 64 |
|
67 | 65 |
private static final NomenclaturalCode ICNAFP = NomenclaturalCode.ICNAFP; |
68 | 66 |
private static final NomenclaturalCode ICZN = NomenclaturalCode.ICZN; |
... | ... | |
92 | 90 |
private NonViralNameParserImpl parser ; |
93 | 91 |
private NomenclaturalCode botanicCode; |
94 | 92 |
|
95 |
@BeforeClass |
|
96 |
public static void setUpBeforeClass() throws Exception { |
|
97 |
DefaultTermInitializer termInitializer = new DefaultTermInitializer(); |
|
98 |
termInitializer.initialize(); |
|
99 |
} |
|
100 |
|
|
101 | 93 |
@Before |
102 | 94 |
public void setUp() throws Exception { |
103 | 95 |
parser = NonViralNameParserImpl.NewInstance(); |
... | ... | |
106 | 98 |
|
107 | 99 |
/*************** TEST *********************************************/ |
108 | 100 |
|
109 |
/** |
|
110 |
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#NEW_INSTANCE()}. |
|
111 |
*/ |
|
112 | 101 |
@Test |
113 | 102 |
public final void testNewInstance() { |
114 | 103 |
assertNotNull(parser); |
115 | 104 |
} |
116 | 105 |
|
117 |
/** |
|
118 |
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#TaxonNameParserBotanicalNameImpl()}. |
|
119 |
*/ |
|
120 | 106 |
@Test |
121 | 107 |
public final void testTaxonNameParserBotanicalNameImpl() { |
122 | 108 |
logger.warn("Not yet implemented"); // TODO |
... | ... | |
147 | 133 |
Assert.assertEquals("Name should not include reference part", "Abies alba Mess., L. & Mill.", name.getTitleCache()); |
148 | 134 |
Assert.assertEquals("Name should have authorship with 2 authors", 3, ((Team)name.getCombinationAuthorship()).getTeamMembers().size()); |
149 | 135 |
Assert.assertEquals("Mess., L. & Mill., Sp. Pl., ed. 3. 1987", name.getNomenclaturalReference().getTitleCache()); |
150 |
|
|
151 | 136 |
} |
152 | 137 |
|
153 |
/** |
|
154 |
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseSimpleName(java.lang.String, eu.etaxonomy.cdm.model.name.Rank)}. |
|
155 |
*/ |
|
156 | 138 |
@Test |
157 | 139 |
public final void testParseSimpleName() { |
158 | 140 |
|
... | ... | |
183 | 165 |
parser.parseSimpleName(rosa, "Rosaceaex", rosa.getRank(), true); |
184 | 166 |
assertEquals("Rosaceaex have rank family", Rank.FAMILY(), rosa.getRank()); |
185 | 167 |
assertFalse("Rosaceaex must have no rank warning", rosa.hasProblem(ParserProblem.CheckRank)); |
186 |
|
|
187 | 168 |
} |
188 | 169 |
|
189 |
/** |
|
190 |
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseSubGenericFullName(java.lang.String)}. |
|
191 |
*/ |
|
192 | 170 |
@Test |
193 | 171 |
public final void testParseSubGenericFullName() { |
194 | 172 |
String zooSpeciesWithSubgenus = "Bacanius (Mullerister) rombophorus (Aube, 1843)"; |
... | ... | |
227 | 205 |
Assert.assertEquals("", botName.getAuthorshipCache()); |
228 | 206 |
} |
229 | 207 |
|
230 |
/** |
|
231 |
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseSubGenericSimpleName(java.lang.String)}. |
|
232 |
*/ |
|
233 | 208 |
@Test |
234 | 209 |
public final void testParseSubGenericSimpleName() { |
235 | 210 |
logger.warn("Not yet implemented"); // TODO |
236 | 211 |
} |
237 | 212 |
|
238 |
/** |
|
239 |
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseFullName(java.lang.String, eu.etaxonomy.cdm.model.name.Rank)}. |
|
240 |
*/ |
|
241 | 213 |
@Test |
242 | 214 |
public final void testParseFullNameUnicode() { |
243 | 215 |
|
... | ... | |
274 | 246 |
assertEquals("Linden", exBasionymTeam3.getNomenclaturalTitle()); |
275 | 247 |
String title = nameBasionymExAuthor2.getTitleCache(); |
276 | 248 |
assertEquals("Washingtonia filifera (Linden ex Andre) H.Wendl. ex de Bary", title); |
277 |
|
|
278 | 249 |
} |
279 | 250 |
|
280 |
|
|
281 |
/** |
|
282 |
* Test method for {@link eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl#parseFullName(java.lang.String, eu.etaxonomy.cdm.model.name.Rank)}. |
|
283 |
*/ |
|
284 | 251 |
@Test |
285 | 252 |
public final void testParseFullName() { |
286 | 253 |
try { |
... | ... | |
583 | 550 |
name1 = parser.parseReferencedName(nameStr); |
584 | 551 |
assertEquals(nameStr.replace("E. Kl", "E.Kl"), name1.getTitleCache()); //we expect the cache strategy to create the same result |
585 | 552 |
parser.setRemoveSpaceAfterDot(false); |
586 |
|
|
587 |
|
|
588 |
|
|
589 | 553 |
} |
590 | 554 |
|
591 | 555 |
@Test |
... | ... | |
799 | 763 |
assertEquals("Hybrid name must have the lower rank ('variety') as rank", Rank.VARIETY(), name1.getRank()); |
800 | 764 |
} |
801 | 765 |
|
802 |
|
|
803 | 766 |
@Test |
804 | 767 |
public final void testUnrankedNames() { |
805 | 768 |
try { |
... | ... | |
892 | 855 |
// } |
893 | 856 |
} |
894 | 857 |
|
895 |
|
|
896 | 858 |
@Test |
897 | 859 |
public final void testHybridsRemoval(){ |
898 | 860 |
//if the parser input already has hybridrelationships they need to be removed |
... | ... | |
928 | 890 |
assertEquals("After parsing another string there should still be 2 parents, but different ones", 2, name1.getHybridChildRelations().size()); |
929 | 891 |
assertFalse("Name must not have parsing problems", name1.hasProblem()); |
930 | 892 |
|
931 |
|
|
932 | 893 |
hybridCache = "Calendula arvensis Mill."; |
933 | 894 |
makeEmpty = true; |
934 | 895 |
parser.parseReferencedName(name1, hybridCache, Rank.SPECIES(), makeEmpty); |
Also available in: Unified diff
cleanup and use TermTestBase for model tests