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