2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.model
.name
;
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
;
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
;
25 import eu
.etaxonomy
.cdm
.model
.agent
.Team
;
26 import eu
.etaxonomy
.cdm
.model
.agent
.TeamOrPersonBase
;
27 import eu
.etaxonomy
.cdm
.model
.common
.DefaultTermInitializer
;
28 import eu
.etaxonomy
.cdm
.model
.reference
.INomenclaturalReference
;
29 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
30 import eu
.etaxonomy
.cdm
.test
.unit
.EntityTestBase
;
33 public class BotanicalNameTest
extends EntityTestBase
{
34 private static final Logger logger
= Logger
.getLogger(BotanicalNameTest
.class);
36 private BotanicalName botanicalName1
;
37 private BotanicalName botanicalName2
;
40 public static void setUpBeforeClass() {
41 DefaultTermInitializer vocabularyStore
= new DefaultTermInitializer();
42 vocabularyStore
.initialize();
46 public void setUp() throws Exception
{
47 botanicalName1
= new BotanicalName();
48 botanicalName2
= new BotanicalName();
51 /****** TESTS *******************************/
54 public final void testPARSED_NAME() {
55 String fullName
= "Abies alba subsp. beta (L.) Mill.";
56 BotanicalName name
= BotanicalName
.PARSED_NAME(fullName
);
57 assertFalse(name
.hasProblem());
58 assertEquals("beta", name
.getInfraSpecificEpithet());
62 public final void testBotanicalName() {
63 assertNotNull(botanicalName1
);
64 assertNull(botanicalName1
.getRank());
68 public final void testBotanicalNameRank() {
69 Rank genus
= Rank
.GENUS();
70 BotanicalName rankName
= BotanicalName
.NewInstance(genus
);
71 assertNotNull(rankName
);
72 assertSame(genus
, rankName
.getRank());
73 assertTrue(rankName
.getRank().isGenus());
74 BotanicalName nullRankName
= BotanicalName
.NewInstance(null);
75 assertNotNull(nullRankName
);
76 assertNull(nullRankName
.getRank());
80 public final void testBotanicalNameRankStringStringStringAgentINomenclaturalReferenceString() {
81 ReferenceFactory refFactory
= ReferenceFactory
.newInstance();
82 Rank rank
= Rank
.SPECIALFORM();
83 String genusOrUninomial
= "Genus";
84 String infraGenericEpithet
= "infraGenericEpi";
85 String specificEpithet
= "specEpi";
86 String infraSpecificEpithet
= "infraSpecificEpi";
87 TeamOrPersonBase combinationAuthorTeam
= Team
.NewInstance();
88 INomenclaturalReference nomenclaturalReference
= refFactory
.newArticle();
89 String nomenclMicroRef
= "microRef";
90 HomotypicalGroup homotypicalGroup
= new HomotypicalGroup();
91 BotanicalName fullName
= new BotanicalName(rank
, genusOrUninomial
, infraGenericEpithet
, specificEpithet
, infraSpecificEpithet
, combinationAuthorTeam
, 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(combinationAuthorTeam
, fullName
.getCombinationAuthorTeam());
98 assertEquals(nomenclaturalReference
, fullName
.getNomenclaturalReference());
99 assertEquals("microRef", fullName
.getNomenclaturalMicroReference());
100 assertSame(homotypicalGroup
, fullName
.getHomotypicalGroup());
104 public final void testGetParentRelationships() {
105 assertEquals(0, botanicalName1
.getParentRelationships().size());
106 logger
.warn("Not yet implemented"); // TODO
110 public final void testGetChildRelationships() {
111 logger
.warn("Not yet implemented"); // TODO
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());
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());
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());
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());
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());
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());