1
|
/**
|
2
|
* Copyright (C) 2007 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
|
|
10
|
package eu.etaxonomy.cdm.model.name;
|
11
|
|
12
|
import static org.junit.Assert.assertEquals;
|
13
|
import static org.junit.Assert.assertFalse;
|
14
|
import static org.junit.Assert.assertNotNull;
|
15
|
import static org.junit.Assert.assertNull;
|
16
|
import static org.junit.Assert.assertSame;
|
17
|
import static org.junit.Assert.assertTrue;
|
18
|
|
19
|
import org.apache.log4j.Logger;
|
20
|
import org.junit.Assert;
|
21
|
import org.junit.Before;
|
22
|
import org.junit.BeforeClass;
|
23
|
import org.junit.Test;
|
24
|
import org.springframework.beans.BeanUtils;
|
25
|
|
26
|
import eu.etaxonomy.cdm.model.agent.Team;
|
27
|
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
|
28
|
import eu.etaxonomy.cdm.model.common.DefaultTermInitializer;
|
29
|
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
|
30
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
31
|
import eu.etaxonomy.cdm.test.unit.EntityTestBase;
|
32
|
|
33
|
|
34
|
public class BotanicalNameTest extends EntityTestBase{
|
35
|
private static final Logger logger = Logger.getLogger(BotanicalNameTest.class);
|
36
|
|
37
|
private BotanicalName botanicalName1;
|
38
|
private BotanicalName botanicalName2;
|
39
|
|
40
|
@BeforeClass
|
41
|
public static void setUpBeforeClass() {
|
42
|
DefaultTermInitializer vocabularyStore = new DefaultTermInitializer();
|
43
|
vocabularyStore.initialize();
|
44
|
}
|
45
|
|
46
|
@Before
|
47
|
public void setUp() throws Exception {
|
48
|
botanicalName1 = new BotanicalName();
|
49
|
botanicalName2 = new BotanicalName();
|
50
|
}
|
51
|
|
52
|
/****** TESTS *******************************/
|
53
|
|
54
|
@Test
|
55
|
public final void testPARSED_NAME() {
|
56
|
String fullName = "Abies alba subsp. beta (L.) Mill.";
|
57
|
BotanicalName name = BotanicalName.PARSED_NAME(fullName);
|
58
|
assertFalse(name.hasProblem());
|
59
|
assertEquals("beta", name.getInfraSpecificEpithet());
|
60
|
}
|
61
|
|
62
|
@Test
|
63
|
public final void testBotanicalName() {
|
64
|
assertNotNull(botanicalName1);
|
65
|
assertNull(botanicalName1.getRank());
|
66
|
}
|
67
|
|
68
|
@Test
|
69
|
public final void testBotanicalNameRank() {
|
70
|
Rank genus = Rank.GENUS();
|
71
|
BotanicalName rankName = BotanicalName.NewInstance(genus);
|
72
|
assertNotNull(rankName);
|
73
|
assertSame(genus, rankName.getRank());
|
74
|
assertTrue(rankName.getRank().isGenus());
|
75
|
BotanicalName nullRankName = BotanicalName.NewInstance(null);
|
76
|
assertNotNull(nullRankName);
|
77
|
assertNull(nullRankName.getRank());
|
78
|
}
|
79
|
|
80
|
@Test
|
81
|
public final void testBotanicalNameRankStringStringStringAgentINomenclaturalReferenceString() {
|
82
|
Rank rank = Rank.SPECIALFORM();
|
83
|
String genusOrUninomial = "Genus";
|
84
|
String infraGenericEpithet = "infraGenericEpi";
|
85
|
String specificEpithet = "specEpi";
|
86
|
String infraSpecificEpithet = "infraSpecificEpi";
|
87
|
TeamOrPersonBase<?> combinationAuthorship = Team.NewInstance();
|
88
|
INomenclaturalReference nomenclaturalReference = ReferenceFactory.newArticle();
|
89
|
String nomenclMicroRef = "microRef";
|
90
|
HomotypicalGroup homotypicalGroup = new HomotypicalGroup();
|
91
|
BotanicalName fullName = new BotanicalName(rank, genusOrUninomial, infraGenericEpithet, specificEpithet, infraSpecificEpithet, combinationAuthorship, nomenclaturalReference, nomenclMicroRef, homotypicalGroup);
|
92
|
assertEquals(Rank.SPECIALFORM(), fullName.getRank());
|
93
|
assertEquals("Genus", fullName.getGenusOrUninomial());
|
94
|
assertEquals("infraGenericEpi", fullName.getInfraGenericEpithet());
|
95
|
assertEquals("specEpi", fullName.getSpecificEpithet());
|
96
|
assertEquals("infraSpecificEpi", fullName.getInfraSpecificEpithet());
|
97
|
assertEquals(combinationAuthorship, fullName.getCombinationAuthorship());
|
98
|
assertEquals(nomenclaturalReference, fullName.getNomenclaturalReference());
|
99
|
assertEquals("microRef", fullName.getNomenclaturalMicroReference());
|
100
|
assertSame(homotypicalGroup, fullName.getHomotypicalGroup());
|
101
|
}
|
102
|
|
103
|
@Test
|
104
|
public final void testGetParentRelationships() {
|
105
|
assertEquals(0, botanicalName1.getHybridParentRelations().size());
|
106
|
logger.warn("Not yet implemented"); // TODO
|
107
|
}
|
108
|
|
109
|
@Test
|
110
|
public final void testGetChildRelationships() {
|
111
|
logger.warn("Not yet implemented"); // TODO
|
112
|
}
|
113
|
|
114
|
@Test
|
115
|
public final void testIsSetHybridFormula() {
|
116
|
assertFalse(botanicalName1.isHybridFormula());
|
117
|
botanicalName1.setHybridFormula(true);
|
118
|
assertTrue(botanicalName1.isHybridFormula());
|
119
|
botanicalName1.setHybridFormula(false);
|
120
|
assertFalse(botanicalName1.isHybridFormula());
|
121
|
}
|
122
|
|
123
|
@Test
|
124
|
public final void testIsSetMonomHybrid() {
|
125
|
assertFalse(botanicalName1.isMonomHybrid());
|
126
|
botanicalName1.setMonomHybrid(true);
|
127
|
assertTrue(botanicalName1.isMonomHybrid());
|
128
|
botanicalName1.setMonomHybrid(false);
|
129
|
assertFalse(botanicalName1.isMonomHybrid());
|
130
|
}
|
131
|
|
132
|
@Test
|
133
|
public final void testIsSetBinomHybrid() {
|
134
|
assertFalse(botanicalName1.isBinomHybrid());
|
135
|
botanicalName1.setBinomHybrid(true);
|
136
|
assertTrue(botanicalName1.isBinomHybrid());
|
137
|
botanicalName1.setBinomHybrid(false);
|
138
|
assertFalse(botanicalName1.isBinomHybrid());
|
139
|
}
|
140
|
|
141
|
@Test
|
142
|
public final void testIsTrinomHybrid() {
|
143
|
assertFalse(botanicalName1.isTrinomHybrid());
|
144
|
botanicalName1.setTrinomHybrid(true);
|
145
|
assertTrue(botanicalName1.isTrinomHybrid());
|
146
|
botanicalName1.setTrinomHybrid(false);
|
147
|
assertFalse(botanicalName1.isTrinomHybrid());
|
148
|
}
|
149
|
|
150
|
@Test
|
151
|
public final void testIsAnamorphic() {
|
152
|
assertFalse(botanicalName1.isAnamorphic());
|
153
|
botanicalName1.setAnamorphic(true);
|
154
|
assertTrue(botanicalName1.isAnamorphic());
|
155
|
botanicalName1.setAnamorphic(false);
|
156
|
assertFalse(botanicalName1.isAnamorphic());
|
157
|
}
|
158
|
|
159
|
@Test
|
160
|
public void testClone(){
|
161
|
botanicalName1.setGenusOrUninomial("Aus");
|
162
|
botanicalName1.setRank(Rank.GENUS());
|
163
|
botanicalName1.setAnamorphic(true);
|
164
|
BotanicalName clone = (BotanicalName)botanicalName1.clone();
|
165
|
Assert.assertEquals("Anamorphic should be equal", true, clone.isAnamorphic());
|
166
|
botanicalName1.setAnamorphic(false);
|
167
|
clone = (BotanicalName)botanicalName1.clone();
|
168
|
Assert.assertEquals("Anamorphic should be equal", false, clone.isAnamorphic());
|
169
|
}
|
170
|
|
171
|
@Test
|
172
|
public void beanTests(){
|
173
|
// #5307 Test that BeanUtils does not fail
|
174
|
BeanUtils.getPropertyDescriptors(BotanicalName.class);
|
175
|
BeanUtils.getPropertyDescriptors(TaxonNameBase.class);
|
176
|
BeanUtils.getPropertyDescriptors(NonViralName.class);
|
177
|
BeanUtils.getPropertyDescriptors(ZoologicalName.class);
|
178
|
BeanUtils.getPropertyDescriptors(ViralName.class);
|
179
|
BeanUtils.getPropertyDescriptors(CultivarPlantName.class);
|
180
|
}
|
181
|
}
|