1 |
b5eda83f
|
Andreas Müller
|
/**
|
2 |
|
|
*
|
3 |
|
|
*/
|
4 |
|
|
package eu.etaxonomy.cdm.model.taxon;
|
5 |
|
|
|
6 |
|
|
import static org.junit.Assert.*;
|
7 |
|
|
|
8 |
|
|
import org.apache.log4j.Logger;
|
9 |
|
|
import org.junit.After;
|
10 |
|
|
import org.junit.AfterClass;
|
11 |
|
|
import org.junit.Before;
|
12 |
|
|
import org.junit.BeforeClass;
|
13 |
|
|
import org.junit.Test;
|
14 |
|
|
|
15 |
|
|
import eu.etaxonomy.cdm.model.agent.Person;
|
16 |
|
|
import eu.etaxonomy.cdm.model.name.BotanicalName;
|
17 |
|
|
import eu.etaxonomy.cdm.model.name.Rank;
|
18 |
|
|
import eu.etaxonomy.cdm.model.name.ZoologicalName;
|
19 |
|
|
import eu.etaxonomy.cdm.model.reference.Book;
|
20 |
|
|
import eu.etaxonomy.cdm.model.reference.ReferenceBase;
|
21 |
|
|
|
22 |
|
|
/**
|
23 |
|
|
* @author a.mueller
|
24 |
|
|
*
|
25 |
|
|
*/
|
26 |
|
|
public class TaxonBaseTest {
|
27 |
|
|
private static final Logger logger = Logger.getLogger(TaxonBaseTest.class);
|
28 |
|
|
|
29 |
|
|
private ReferenceBase sec;
|
30 |
|
|
private ZoologicalName name1;
|
31 |
|
|
private BotanicalName name2;
|
32 |
|
|
private Taxon rootT;
|
33 |
|
|
private Taxon taxon1;
|
34 |
|
|
private Taxon taxon2;
|
35 |
|
|
private Taxon freeT;
|
36 |
|
|
/**
|
37 |
|
|
* @throws java.lang.Exception
|
38 |
|
|
*/
|
39 |
|
|
@BeforeClass
|
40 |
|
|
public static void setUpBeforeClass() throws Exception {
|
41 |
|
|
|
42 |
|
|
}
|
43 |
|
|
|
44 |
|
|
/**
|
45 |
|
|
* @throws java.lang.Exception
|
46 |
|
|
*/
|
47 |
|
|
@AfterClass
|
48 |
|
|
public static void tearDownAfterClass() throws Exception {
|
49 |
|
|
}
|
50 |
|
|
|
51 |
|
|
/**
|
52 |
|
|
* @throws java.lang.Exception
|
53 |
|
|
*/
|
54 |
|
|
@Before
|
55 |
|
|
public void setUp() throws Exception {
|
56 |
|
|
sec=new Book();
|
57 |
|
|
sec.setTitleCache("Schoenes saftiges Allg?u");
|
58 |
|
|
name1=new ZoologicalName(Rank.SPECIES(),"Panthera","onca",null,null,null,"p.1467");
|
59 |
|
|
name2=new BotanicalName(Rank.SPECIES(),"Abies","alba",null,null,null,"p.317");
|
60 |
|
|
// taxa
|
61 |
|
|
taxon1=Taxon.NewInstance(name1,sec);
|
62 |
|
|
taxon2=Taxon.NewInstance(name2,sec);
|
63 |
|
|
freeT = Taxon.NewInstance(null, null);
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
/**
|
67 |
|
|
* @throws java.lang.Exception
|
68 |
|
|
*/
|
69 |
|
|
@After
|
70 |
|
|
public void tearDown() throws Exception {
|
71 |
|
|
}
|
72 |
|
|
|
73 |
|
|
/**************** TESTS **************************************/
|
74 |
|
|
|
75 |
|
|
/**
|
76 |
|
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.TaxonBase#getName()}.
|
77 |
|
|
*/
|
78 |
|
|
@Test
|
79 |
|
|
public final void testGetName() {
|
80 |
|
|
assertEquals(name1.getTitleCache(), taxon1.getName().getTitleCache());
|
81 |
|
|
assertNull(freeT.getName());
|
82 |
|
|
}
|
83 |
|
|
|
84 |
|
|
/**
|
85 |
|
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.TaxonBase#setName(eu.etaxonomy.cdm.model.name.TaxonNameBase)}.
|
86 |
|
|
*/
|
87 |
|
|
@Test
|
88 |
|
|
public final void testSetName() {
|
89 |
|
|
assertNull(freeT.getName());
|
90 |
|
|
freeT.setName(name2);
|
91 |
|
|
assertNotNull(freeT.getName());
|
92 |
|
|
assertSame(freeT.getName(), name2);
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
/**
|
96 |
|
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.TaxonBase#isDoubtful()}.
|
97 |
|
|
*/
|
98 |
|
|
@Test
|
99 |
|
|
public final void testIsDoubtful() {
|
100 |
|
|
boolean oldValue;
|
101 |
|
|
oldValue = taxon1.isDoubtful();
|
102 |
|
|
taxon1.setDoubtful(!oldValue);
|
103 |
|
|
assertEquals(! oldValue, taxon1.isDoubtful());
|
104 |
|
|
taxon1.setDoubtful(oldValue);
|
105 |
|
|
assertEquals( oldValue, taxon1.isDoubtful());
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
/**
|
109 |
|
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.TaxonBase#setDoubtful(boolean)}.
|
110 |
|
|
*/
|
111 |
|
|
@Test
|
112 |
|
|
public final void testSetDoubtful() {
|
113 |
|
|
//covered by testIsDoubtful
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
/**
|
117 |
|
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.TaxonBase#getSec()}.
|
118 |
|
|
*/
|
119 |
|
|
@Test
|
120 |
|
|
public final void testGetSec() {
|
121 |
|
|
assertEquals(sec.getTitleCache(), taxon1.getSec().getTitleCache());
|
122 |
|
|
assertNull(freeT.getSec());
|
123 |
|
|
}
|
124 |
|
|
|
125 |
|
|
/**
|
126 |
|
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.TaxonBase#setSec(eu.etaxonomy.cdm.model.reference.ReferenceBase)}.
|
127 |
|
|
*/
|
128 |
|
|
@Test
|
129 |
|
|
public final void testSetSec() {
|
130 |
|
|
assertNull(freeT.getSec());
|
131 |
|
|
freeT.setSec(sec);
|
132 |
|
|
assertNotNull(freeT.getSec());
|
133 |
|
|
assertSame(freeT.getSec(), sec);
|
134 |
|
|
}
|
135 |
|
|
|
136 |
|
|
/**
|
137 |
|
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.TaxonBase#isSaveable()}.
|
138 |
|
|
*/
|
139 |
|
|
@Test
|
140 |
|
|
public final void testIsSaveable() {
|
141 |
|
|
assertFalse(freeT.isSaveable());
|
142 |
|
|
assertTrue(taxon1.isSaveable());
|
143 |
|
|
freeT.setName(name1);
|
144 |
|
|
assertFalse(freeT.isSaveable());
|
145 |
|
|
freeT.setSec(sec);
|
146 |
|
|
assertTrue(freeT.isSaveable());
|
147 |
|
|
freeT.setName(null);
|
148 |
|
|
assertFalse(freeT.isSaveable());
|
149 |
|
|
}
|
150 |
|
|
|
151 |
|
|
}
|