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.taxon;
|
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.assertSame;
|
16
|
import static org.junit.Assert.assertTrue;
|
17
|
|
18
|
import java.util.Set;
|
19
|
|
20
|
import org.apache.log4j.Logger;
|
21
|
import org.junit.Assert;
|
22
|
import org.junit.Before;
|
23
|
import org.junit.BeforeClass;
|
24
|
import org.junit.Test;
|
25
|
import org.springframework.beans.BeanUtils;
|
26
|
|
27
|
import eu.etaxonomy.cdm.model.agent.Person;
|
28
|
import eu.etaxonomy.cdm.model.common.DefaultTermInitializer;
|
29
|
import eu.etaxonomy.cdm.model.description.TaxonDescription;
|
30
|
import eu.etaxonomy.cdm.model.name.BotanicalName;
|
31
|
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
|
32
|
import eu.etaxonomy.cdm.model.name.Rank;
|
33
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
34
|
import eu.etaxonomy.cdm.model.name.ZoologicalName;
|
35
|
//import eu.etaxonomy.cdm.model.reference.Book;
|
36
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
37
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
38
|
import eu.etaxonomy.cdm.test.unit.EntityTestBase;
|
39
|
|
40
|
public class TaxonTest extends EntityTestBase {
|
41
|
private static final Logger logger = Logger.getLogger(TaxonTest.class);
|
42
|
|
43
|
|
44
|
private Reference<?> sec;
|
45
|
private Reference<?> misSec;
|
46
|
private ZoologicalName name1;
|
47
|
private BotanicalName name2;
|
48
|
private Taxon rootT;
|
49
|
private Taxon child1;
|
50
|
private Taxon child2;
|
51
|
private Synonym syn1;
|
52
|
private Synonym syn2;
|
53
|
private BotanicalName name3;
|
54
|
private BotanicalName name4;
|
55
|
private Taxon freeT;
|
56
|
private Taxon misTaxon1;
|
57
|
private Taxon misTaxon2;
|
58
|
|
59
|
@BeforeClass
|
60
|
public static void setUpBeforeClass() {
|
61
|
DefaultTermInitializer vocabularyStore = new DefaultTermInitializer();
|
62
|
vocabularyStore.initialize();
|
63
|
}
|
64
|
|
65
|
@Before
|
66
|
public void setUp() throws Exception {
|
67
|
Person linne =new Person("Carl", "Linné", "L.");
|
68
|
sec= ReferenceFactory.newBook();
|
69
|
sec.setAuthorship(linne);
|
70
|
sec.setTitleCache("Schönes saftiges Allgäu", true);
|
71
|
misSec = ReferenceFactory.newBook();
|
72
|
misSec.setTitleCache("Stupid book", true);
|
73
|
|
74
|
name1 = ZoologicalName.NewInstance(Rank.SPECIES(),"Panthera",null,"onca",null,linne,null,"p.1467", null);
|
75
|
name2 = BotanicalName.NewInstance(Rank.SPECIES(),"Abies",null,"alba",null,linne,null,"p.317", null);
|
76
|
name3 = BotanicalName.NewInstance(Rank.SUBSPECIES(),"Polygala",null,"vulgaris","alpina",linne,null,"p.191", null);
|
77
|
name4 = BotanicalName.NewInstance(Rank.SPECIES(),"Cichoria",null,"carminata",null,linne,null,"p.14", null);
|
78
|
rootT = Taxon.NewInstance(name1,sec);
|
79
|
freeT = Taxon.NewInstance(name4,sec);
|
80
|
// taxonomic children
|
81
|
child1 = Taxon.NewInstance(name2,sec);
|
82
|
child2 = Taxon.NewInstance(name3,sec);
|
83
|
|
84
|
// Classification newTree = Classification.NewInstance("testTree");
|
85
|
// newTree.addParentChild(rootT, child1, sec, "p.998");
|
86
|
// newTree.addParentChild(rootT, child2, sec, "p.987");
|
87
|
|
88
|
rootT.addTaxonomicChild(child1, sec, "p.998");
|
89
|
rootT.addTaxonomicChild(child2, sec, "p.987");
|
90
|
// synonymy
|
91
|
syn1=Synonym.NewInstance(name1,sec);
|
92
|
syn2=Synonym.NewInstance(name2,sec);
|
93
|
child1.addSynonym(syn1, SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF());
|
94
|
child2.addSynonym(syn2, SynonymRelationshipType.HOMOTYPIC_SYNONYM_OF());
|
95
|
//misaplication
|
96
|
misTaxon1 = Taxon.NewInstance(name4, misSec);
|
97
|
misTaxon2 = Taxon.NewInstance(name4, misSec);
|
98
|
rootT.addMisappliedName(misTaxon1, null, "99");
|
99
|
child1.addMisappliedName(misTaxon2, null, "44");
|
100
|
}
|
101
|
|
102
|
@Test
|
103
|
public void testGenerateTitle() {
|
104
|
assertTrue(rootT.generateTitle().startsWith(rootT.getName().getTitleCache()));
|
105
|
}
|
106
|
|
107
|
@Test
|
108
|
public void testAddTaxonomicChild() {
|
109
|
|
110
|
rootT.addTaxonomicChild(freeT, null, null);
|
111
|
Assert.assertEquals(Integer.valueOf(3), Integer.valueOf(rootT.getTaxonomicChildren().size()));
|
112
|
}
|
113
|
|
114
|
@Test
|
115
|
public void testGetTaxonomicParent() {
|
116
|
assertEquals(rootT, child2.getTaxonomicParent());
|
117
|
}
|
118
|
|
119
|
@Test
|
120
|
public void testSetTaxonomicParent() {
|
121
|
child2.setTaxonomicParent(child1, null, null);
|
122
|
assertEquals(child1, child2.getTaxonomicParent());
|
123
|
}
|
124
|
|
125
|
@Test
|
126
|
public void testGetTaxonomicChildren() {
|
127
|
Set<Taxon> kids=rootT.getTaxonomicChildren();
|
128
|
assertTrue(kids.size()==2 && kids.contains(child1) && kids.contains(child2));
|
129
|
}
|
130
|
|
131
|
@Test
|
132
|
public void testHasTaxonomicChildren() {
|
133
|
assertFalse(child2.hasTaxonomicChildren());
|
134
|
assertTrue(rootT.hasTaxonomicChildren());
|
135
|
rootT.removeTaxonomicChild(child1);
|
136
|
assertTrue(rootT.hasTaxonomicChildren());
|
137
|
rootT.removeTaxonomicChild(child2);
|
138
|
assertFalse(rootT.hasTaxonomicChildren());
|
139
|
}
|
140
|
|
141
|
@Test
|
142
|
public void testGetTaxonomicChildrenCount() {
|
143
|
assertEquals(0, child2.getTaxonomicChildrenCount());
|
144
|
assertEquals(2, rootT.getTaxonomicChildrenCount());
|
145
|
rootT.removeTaxonomicChild(child1);
|
146
|
assertEquals(1, rootT.getTaxonomicChildrenCount());
|
147
|
rootT.removeTaxonomicChild(child2);
|
148
|
assertEquals(0, rootT.getTaxonomicChildrenCount());
|
149
|
}
|
150
|
|
151
|
@Test
|
152
|
public void testIsMisappliedName() {
|
153
|
assertFalse(child2.isMisapplication());
|
154
|
assertFalse(rootT.isMisapplication());
|
155
|
assertTrue(misTaxon1.isMisapplication());
|
156
|
assertTrue(misTaxon2.isMisapplication());
|
157
|
}
|
158
|
|
159
|
@Test
|
160
|
public void testGetSynonyms() {
|
161
|
assertTrue(child1.getSynonyms().contains(syn1));
|
162
|
assertTrue(child2.getSynonyms().contains(syn2));
|
163
|
assertTrue(rootT.getSynonyms().isEmpty());
|
164
|
}
|
165
|
|
166
|
@Test
|
167
|
public void testGetSynonymNames() {
|
168
|
assertTrue(child1.getSynonymNames().contains(name1));
|
169
|
assertTrue(child2.getSynonymNames().contains(name2));
|
170
|
assertTrue(rootT.getSynonymNames().isEmpty());
|
171
|
}
|
172
|
|
173
|
@Test
|
174
|
public void testAddSynonym() {
|
175
|
freeT.addSynonym(syn1, SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF());
|
176
|
assertTrue(freeT.getSynonyms().contains(syn1));
|
177
|
assertTrue(syn1.getAcceptedTaxa().contains(freeT));
|
178
|
assertFalse(freeT.getSynonyms().contains(syn2));
|
179
|
}
|
180
|
|
181
|
@Test
|
182
|
public void testAddAndRemoveDescriptionTaxonDescription() {
|
183
|
TaxonDescription desc = TaxonDescription.NewInstance();
|
184
|
rootT.addDescription(desc); //test if reflection method in addDescription() works
|
185
|
assertTrue("The description has not properly been added to the taxon", rootT.getDescriptions().contains(desc));
|
186
|
assertEquals("The taxon has not properly been added to the description", rootT, desc.getTaxon());
|
187
|
rootT.removeDescription(desc); //test if reflection method in removeDescription() works
|
188
|
assertFalse("The description has not properly been removed from the taxon", rootT.getDescriptions().contains(desc));
|
189
|
assertEquals("The taxon has not properly been removed from the description", null, desc.getTaxon());
|
190
|
}
|
191
|
|
192
|
/**
|
193
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#getDescriptions()}.
|
194
|
*/
|
195
|
@Test
|
196
|
public void testGetDescriptions() {
|
197
|
logger.warn("Not yet implemented");
|
198
|
}
|
199
|
|
200
|
/**
|
201
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#setDescriptions(java.util.Set)}.
|
202
|
*/
|
203
|
@Test
|
204
|
public void testSetDescriptions() {
|
205
|
logger.warn("Not yet implemented");
|
206
|
}
|
207
|
|
208
|
/**
|
209
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addDescription(eu.etaxonomy.cdm.model.description.TaxonDescription)}.
|
210
|
*/
|
211
|
@Test
|
212
|
public void testAddDescription() {
|
213
|
logger.warn("Not yet implemented");
|
214
|
}
|
215
|
|
216
|
/**
|
217
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#removeDescription(eu.etaxonomy.cdm.model.description.TaxonDescription)}.
|
218
|
*/
|
219
|
@Test
|
220
|
public void testRemoveDescription() {
|
221
|
logger.warn("Not yet implemented");
|
222
|
}
|
223
|
|
224
|
/**
|
225
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#getSynonymRelations()}.
|
226
|
*/
|
227
|
@Test
|
228
|
public void testGetSynonymRelations() {
|
229
|
logger.warn("Not yet implemented");
|
230
|
}
|
231
|
|
232
|
/**
|
233
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#setSynonymRelations(java.util.Set)}.
|
234
|
*/
|
235
|
@Test
|
236
|
public void testSetSynonymRelations() {
|
237
|
logger.warn("Not yet implemented");
|
238
|
}
|
239
|
|
240
|
/**
|
241
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addSynonymRelation(eu.etaxonomy.cdm.model.taxon.SynonymRelationship)}.
|
242
|
*/
|
243
|
@Test
|
244
|
public void testAddSynonymRelation() {
|
245
|
logger.warn("Not yet implemented");
|
246
|
}
|
247
|
|
248
|
/**
|
249
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#removeSynonymRelation(eu.etaxonomy.cdm.model.taxon.SynonymRelationship)}.
|
250
|
*/
|
251
|
@Test
|
252
|
public void testRemoveSynonymRelation() {
|
253
|
logger.warn("Not yet implemented");
|
254
|
}
|
255
|
|
256
|
/**
|
257
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#getRelationsFromThisTaxon()}.
|
258
|
*/
|
259
|
@Test
|
260
|
public void testGetRelationsFromThisTaxon() {
|
261
|
logger.warn("Not yet implemented");
|
262
|
}
|
263
|
|
264
|
/**
|
265
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#setRelationsFromThisTaxon(java.util.Set)}.
|
266
|
*/
|
267
|
@Test
|
268
|
public void testSetRelationsFromThisTaxon() {
|
269
|
logger.warn("Not yet implemented");
|
270
|
}
|
271
|
|
272
|
/**
|
273
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#getRelationsToThisTaxon()}.
|
274
|
*/
|
275
|
@Test
|
276
|
public void testGetRelationsToThisTaxon() {
|
277
|
logger.warn("Not yet implemented");
|
278
|
}
|
279
|
|
280
|
/**
|
281
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#setRelationsToThisTaxon(java.util.Set)}.
|
282
|
*/
|
283
|
@Test
|
284
|
public void testSetRelationsToThisTaxon() {
|
285
|
logger.warn("Not yet implemented");
|
286
|
}
|
287
|
|
288
|
/**
|
289
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#getTaxonRelations()}.
|
290
|
*/
|
291
|
@Test
|
292
|
public void testGetTaxonRelations() {
|
293
|
Taxon taxon = Taxon.NewInstance(null, null);
|
294
|
taxon.addTaxonRelation(Taxon.NewInstance(null, null), TaxonRelationshipType.CONTRADICTION(), null, null);
|
295
|
Set<TaxonRelationship> relationships = taxon.getTaxonRelations();
|
296
|
assertTrue("There should be exactly one relationship", relationships.size() == 1);
|
297
|
}
|
298
|
|
299
|
/**
|
300
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#removeTaxonRelation(eu.etaxonomy.cdm.model.taxon.TaxonRelationship)}.
|
301
|
*/
|
302
|
@Test
|
303
|
public void testRemoveTaxonRelation() {
|
304
|
Taxon taxon = Taxon.NewInstance(null, null);
|
305
|
taxon.addTaxonRelation(Taxon.NewInstance(null, null), TaxonRelationshipType.CONTRADICTION(), null, null);
|
306
|
assertTrue("There should be exactly one taxon relationship", taxon.getTaxonRelations().size() == 1);
|
307
|
TaxonRelationship relationship = (TaxonRelationship) taxon.getTaxonRelations().toArray()[0];
|
308
|
assertNotNull("Relationship should not be null", relationship);
|
309
|
taxon.removeTaxonRelation(relationship);
|
310
|
assertTrue("There should be no taxon relationships", taxon.getTaxonRelations().size() == 0);
|
311
|
}
|
312
|
|
313
|
/**
|
314
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addTaxonRelation(eu.etaxonomy.cdm.model.taxon.TaxonRelationship)}.
|
315
|
*/
|
316
|
@Test
|
317
|
public void testAddTaxonRelationTaxonRelationship() {
|
318
|
Taxon taxon = Taxon.NewInstance(null, null);
|
319
|
taxon.addTaxonRelation(Taxon.NewInstance(null, null), TaxonRelationshipType.CONTRADICTION(), null, null);
|
320
|
assertTrue("There should be exactly one taxon relationship", taxon.getTaxonRelations().size() == 1);
|
321
|
TaxonRelationship relationship = (TaxonRelationship) taxon.getTaxonRelations().toArray()[0];
|
322
|
assertNotNull("Relationship should not be null", relationship);
|
323
|
taxon.removeTaxonRelation(relationship);
|
324
|
assertTrue("There should be no taxon relationships", taxon.getTaxonRelations().size() == 0);
|
325
|
taxon.addTaxonRelation(relationship);
|
326
|
assertEquals("There should be exactly one taxon relationships", 1, taxon.getTaxonRelations().size());
|
327
|
}
|
328
|
|
329
|
/**
|
330
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addRelationship(eu.etaxonomy.cdm.model.common.RelationshipBase)}.
|
331
|
*/
|
332
|
@Test
|
333
|
public void testAddRelationship() {
|
334
|
logger.warn("Not yet implemented");
|
335
|
}
|
336
|
|
337
|
/**
|
338
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addTaxonRelation(eu.etaxonomy.cdm.model.taxon.Taxon, eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType, eu.etaxonomy.cdm.model.reference.Reference, java.lang.String)}.
|
339
|
*/
|
340
|
@Test
|
341
|
public void testAddTaxonRelationTaxonTaxonRelationshipTypeReferenceBaseString() {
|
342
|
logger.warn("Not yet implemented");
|
343
|
}
|
344
|
|
345
|
/**
|
346
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addMisappliedName(eu.etaxonomy.cdm.model.taxon.Taxon, eu.etaxonomy.cdm.model.reference.Reference, java.lang.String)}.
|
347
|
*/
|
348
|
@Test
|
349
|
public void testAddMisappliedName() {
|
350
|
logger.warn("Not yet implemented");
|
351
|
}
|
352
|
|
353
|
|
354
|
/**
|
355
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#hasSynonyms()}.
|
356
|
*/
|
357
|
@Test
|
358
|
public void testHasSynonyms() {
|
359
|
logger.warn("Not yet implemented");
|
360
|
}
|
361
|
|
362
|
/**
|
363
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#getMisappliedNames()}.
|
364
|
*/
|
365
|
@Test
|
366
|
public void testGetMisappliedNames() {
|
367
|
logger.warn("Not yet implemented");
|
368
|
}
|
369
|
|
370
|
|
371
|
/**
|
372
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#getSynonymsSortedByType()}.
|
373
|
*/
|
374
|
@Test
|
375
|
public void testGetSynonymsSortedByType() {
|
376
|
logger.warn("Not yet implemented");
|
377
|
}
|
378
|
|
379
|
/**
|
380
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addSynonym(eu.etaxonomy.cdm.model.taxon.Synonym, eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType)}.
|
381
|
*/
|
382
|
@Test
|
383
|
public void testAddSynonymSynonymSynonymRelationshipType() {
|
384
|
logger.warn("Not yet implemented");
|
385
|
}
|
386
|
|
387
|
/**
|
388
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addSynonym(eu.etaxonomy.cdm.model.taxon.Synonym, eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType, eu.etaxonomy.cdm.model.reference.Reference, java.lang.String)}.
|
389
|
*/
|
390
|
@Test
|
391
|
public void testAddSynonymSynonymSynonymRelationshipTypeReferenceBaseString() {
|
392
|
logger.warn("Not yet implemented");
|
393
|
}
|
394
|
|
395
|
/**
|
396
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addSynonymName(eu.etaxonomy.cdm.model.name.TaxonNameBase, eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType)}.
|
397
|
*/
|
398
|
@Test
|
399
|
public void testAddSynonymNameTaxonNameBaseSynonymRelationshipType() {
|
400
|
logger.warn("Not yet implemented");
|
401
|
}
|
402
|
|
403
|
/**
|
404
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addSynonymName(eu.etaxonomy.cdm.model.name.TaxonNameBase, eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType, eu.etaxonomy.cdm.model.reference.Reference, java.lang.String)}.
|
405
|
*/
|
406
|
@Test
|
407
|
public void testAddSynonymNameTaxonNameBaseSynonymRelationshipTypeReferenceBaseString() {
|
408
|
logger.warn("Not yet implemented");
|
409
|
}
|
410
|
|
411
|
/**
|
412
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addHeterotypicSynonymName(eu.etaxonomy.cdm.model.name.TaxonNameBase)}.
|
413
|
*/
|
414
|
@Test
|
415
|
public void testAddHeterotypicSynonymNameTaxonNameBase() {
|
416
|
logger.warn("Not yet implemented");
|
417
|
}
|
418
|
|
419
|
/**
|
420
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addHeterotypicSynonymName(eu.etaxonomy.cdm.model.name.TaxonNameBase, eu.etaxonomy.cdm.model.name.HomotypicalGroup, eu.etaxonomy.cdm.model.reference.Reference, java.lang.String)}.
|
421
|
*/
|
422
|
@Test
|
423
|
public void testAddHeterotypicSynonymNameTaxonNameBaseHomotypicalGroupReferenceBaseString() {
|
424
|
logger.warn("Not yet implemented");
|
425
|
}
|
426
|
|
427
|
/**
|
428
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addHomotypicSynonymName(eu.etaxonomy.cdm.model.name.TaxonNameBase, eu.etaxonomy.cdm.model.reference.Reference, java.lang.String)}.
|
429
|
*/
|
430
|
@Test
|
431
|
public void testAddHomotypicSynonymName() {
|
432
|
logger.warn("Not yet implemented");
|
433
|
}
|
434
|
|
435
|
/**
|
436
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addHomotypicSynonym(eu.etaxonomy.cdm.model.taxon.Synonym, eu.etaxonomy.cdm.model.reference.Reference, java.lang.String)}.
|
437
|
*/
|
438
|
@Test
|
439
|
public void testAddHomotypicSynonym() {
|
440
|
logger.warn("Not yet implemented");
|
441
|
}
|
442
|
|
443
|
/**
|
444
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#removeSynonym(eu.etaxonomy.cdm.model.taxon.Synonym)}.
|
445
|
*/
|
446
|
@Test
|
447
|
public void testRemoveSynonym() {
|
448
|
logger.warn("Not yet implemented");
|
449
|
}
|
450
|
|
451
|
/**
|
452
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#iterator()}.
|
453
|
*/
|
454
|
@Test
|
455
|
public void testIterator() {
|
456
|
logger.warn("Not yet implemented");
|
457
|
}
|
458
|
|
459
|
/**
|
460
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#getHomotypicSynonymsByHomotypicGroup()}.
|
461
|
*/
|
462
|
@Test
|
463
|
public void testGetHomotypicSynonymsByHomotypicGroup() {
|
464
|
logger.warn("Not yet implemented");
|
465
|
}
|
466
|
|
467
|
/**
|
468
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#getHomotypicSynonymsByHomotypicRelationship()}.
|
469
|
*/
|
470
|
@Test
|
471
|
public void testGetHomotypicSynonymsByHomotypicRelationship() {
|
472
|
logger.warn("Not yet implemented");
|
473
|
}
|
474
|
|
475
|
/**
|
476
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#getHomotypicSynonymyGroups()}.
|
477
|
*/
|
478
|
@Test
|
479
|
public void testGetHomotypicSynonymyGroups() {
|
480
|
logger.warn("Not yet implemented");
|
481
|
}
|
482
|
|
483
|
/**
|
484
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#getHeterotypicSynonymyGroups()}.
|
485
|
*/
|
486
|
@Test
|
487
|
public void testGetHeterotypicSynonymyGroups() {
|
488
|
logger.warn("Not yet implemented");
|
489
|
}
|
490
|
|
491
|
|
492
|
@Test
|
493
|
public void testAddRemoveSynonymInSameGroup(){
|
494
|
TaxonNameBase<?,?> taxonName = BotanicalName.NewInstance(null);
|
495
|
Taxon taxon = Taxon.NewInstance(taxonName, null);
|
496
|
TaxonNameBase<?,?> synonymName1 = BotanicalName.NewInstance(null);
|
497
|
TaxonNameBase<?,?> synonymName2 = BotanicalName.NewInstance(null);
|
498
|
|
499
|
// add a synonym to the taxon
|
500
|
Synonym synonym1 = taxon.addHeterotypicSynonymName(synonymName1).getSynonym();
|
501
|
// get the homotypic group of that synonym
|
502
|
HomotypicalGroup homotypicGroupOfSynonym = synonym1.getHomotypicGroup();
|
503
|
// add another synonym into the homotypic group we just created
|
504
|
Synonym synonym2 = taxon.addHeterotypicSynonymName(synonymName2, homotypicGroupOfSynonym, null, null).getSynonym();
|
505
|
// everything is fine
|
506
|
Assert.assertEquals("We should have two synonyms in the group", 2, taxon.getSynonymsInGroup(homotypicGroupOfSynonym).size());
|
507
|
|
508
|
// removing the synonym from the taxon
|
509
|
taxon.removeSynonym(synonym2);
|
510
|
|
511
|
// get the homotypical group via the methods in Taxon
|
512
|
HomotypicalGroup homotypicGroupViaTaxon = taxon.getHeterotypicSynonymyGroups().iterator().next();
|
513
|
|
514
|
// the group is for sure the same as the synonyms one
|
515
|
Assert.assertSame("Accessing the homotypic group via the taxon methods should result in the same object", homotypicGroupOfSynonym, homotypicGroupViaTaxon);
|
516
|
|
517
|
// although it might be correct that the synonym is not deleted from the taxonomic group
|
518
|
// we would not expect it to be here, since we just deleted it from the taxon and are accessing synonyms
|
519
|
// via methods in Taxon
|
520
|
Assert.assertEquals("When accessing the homotypic groups via taxon we would not expect the synonym we just deleted",
|
521
|
1, taxon.getSynonymsInGroup(homotypicGroupViaTaxon).size());
|
522
|
}
|
523
|
|
524
|
|
525
|
@Test
|
526
|
public void testClone(){
|
527
|
Taxon clone = (Taxon)child2.clone();
|
528
|
assertNotNull(clone);
|
529
|
assertEquals(0,clone.getTaxonNodes().size());
|
530
|
assertSame(clone.getName(), child2.getName());
|
531
|
}
|
532
|
|
533
|
@Test
|
534
|
public void beanTests(){
|
535
|
// #5307 Test that BeanUtils does not fail
|
536
|
BeanUtils.getPropertyDescriptors(Taxon.class);
|
537
|
BeanUtils.getPropertyDescriptors(Synonym.class);
|
538
|
}
|
539
|
|
540
|
}
|