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