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.*;
|
13
|
|
14
|
import java.util.Set;
|
15
|
|
16
|
import org.apache.log4j.Logger;
|
17
|
import org.junit.Assert;
|
18
|
import org.junit.Before;
|
19
|
import org.junit.Test;
|
20
|
|
21
|
import eu.etaxonomy.cdm.model.agent.Person;
|
22
|
import eu.etaxonomy.cdm.model.name.BotanicalName;
|
23
|
import eu.etaxonomy.cdm.model.name.Rank;
|
24
|
import eu.etaxonomy.cdm.model.name.ZoologicalName;
|
25
|
import eu.etaxonomy.cdm.model.reference.Book;
|
26
|
import eu.etaxonomy.cdm.model.reference.ReferenceBase;
|
27
|
import eu.etaxonomy.cdm.test.unit.EntityTestBase;
|
28
|
|
29
|
public class TaxonTest extends EntityTestBase {
|
30
|
private static final Logger logger = Logger.getLogger(TaxonTest.class);
|
31
|
|
32
|
|
33
|
private ReferenceBase sec;
|
34
|
private ReferenceBase misSec;
|
35
|
private ZoologicalName name1;
|
36
|
private BotanicalName name2;
|
37
|
private Taxon rootT;
|
38
|
private Taxon child1;
|
39
|
private Taxon child2;
|
40
|
private Synonym syn1;
|
41
|
private Synonym syn2;
|
42
|
private BotanicalName name3;
|
43
|
private BotanicalName name4;
|
44
|
private Taxon freeT;
|
45
|
private Taxon misTaxon1;
|
46
|
private Taxon misTaxon2;
|
47
|
|
48
|
|
49
|
@Before
|
50
|
public void setUpBeforeClass() throws Exception {
|
51
|
Person linne =new Person("Carl", "Linné", "L.");
|
52
|
sec= Book.NewInstance();
|
53
|
sec.setAuthorTeam(linne);
|
54
|
sec.setTitleCache("Schönes saftiges Allgäu");
|
55
|
misSec = Book.NewInstance();
|
56
|
misSec.setTitleCache("Stupid book");
|
57
|
|
58
|
name1 = ZoologicalName.NewInstance(Rank.SPECIES(),"Panthera",null,"onca",null,linne,null,"p.1467", null);
|
59
|
name2 = BotanicalName.NewInstance(Rank.SPECIES(),"Abies",null,"alba",null,linne,null,"p.317", null);
|
60
|
name3 = BotanicalName.NewInstance(Rank.SUBSPECIES(),"Polygala",null,"vulgaris","alpina",linne,null,"p.191", null);
|
61
|
name4 = BotanicalName.NewInstance(Rank.SPECIES(),"Cichoria",null,"carminata",null,linne,null,"p.14", null);
|
62
|
rootT = Taxon.NewInstance(name1,sec);
|
63
|
freeT = Taxon.NewInstance(name4,sec);
|
64
|
// taxonomic children
|
65
|
child1 = Taxon.NewInstance(name2,sec);
|
66
|
child2 = Taxon.NewInstance(name3,sec);
|
67
|
rootT.addTaxonomicChild(child1, sec, "p.998");
|
68
|
rootT.addTaxonomicChild(child2, sec, "p.987");
|
69
|
// synonymy
|
70
|
syn1=Synonym.NewInstance(name1,sec);
|
71
|
syn2=Synonym.NewInstance(name2,sec);
|
72
|
child1.addSynonym(syn1, SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF());
|
73
|
child2.addSynonym(syn2, SynonymRelationshipType.HOMOTYPIC_SYNONYM_OF());
|
74
|
//misaplication
|
75
|
misTaxon1 = Taxon.NewInstance(name4, misSec);
|
76
|
misTaxon2 = Taxon.NewInstance(name4, misSec);
|
77
|
rootT.addMisappliedName(misTaxon1, null, "99");
|
78
|
child1.addMisappliedName(misTaxon2, null, "44");
|
79
|
}
|
80
|
|
81
|
@Test
|
82
|
public void testGenerateTitle() {
|
83
|
assertTrue(rootT.generateTitle().startsWith(rootT.getName().getTitleCache()));
|
84
|
}
|
85
|
|
86
|
@Test
|
87
|
public void testAddTaxonomicChild() {
|
88
|
rootT.addTaxonomicChild(freeT, null, null);
|
89
|
Assert.assertEquals(Integer.valueOf(3), Integer.valueOf(rootT.getTaxonomicChildren().size()));
|
90
|
}
|
91
|
|
92
|
@Test
|
93
|
public void testGetTaxonomicParent() {
|
94
|
assertEquals(rootT, child2.getTaxonomicParent());
|
95
|
}
|
96
|
|
97
|
@Test
|
98
|
public void testSetTaxonomicParent() {
|
99
|
child2.setTaxonomicParent(child1, null, null);
|
100
|
assertEquals(child1, child2.getTaxonomicParent());
|
101
|
}
|
102
|
|
103
|
@Test
|
104
|
public void testGetTaxonomicChildren() {
|
105
|
Set<Taxon> kids=rootT.getTaxonomicChildren();
|
106
|
assertTrue(kids.size()==2 && kids.contains(child1) && kids.contains(child2));
|
107
|
}
|
108
|
|
109
|
@Test
|
110
|
public void testHasTaxonomicChildren() {
|
111
|
assertFalse(child2.hasTaxonomicChildren());
|
112
|
assertTrue(rootT.hasTaxonomicChildren());
|
113
|
rootT.removeTaxonomicChild(child1);
|
114
|
assertTrue(rootT.hasTaxonomicChildren());
|
115
|
rootT.removeTaxonomicChild(child2);
|
116
|
assertFalse(rootT.hasTaxonomicChildren());
|
117
|
}
|
118
|
|
119
|
@Test
|
120
|
public void testGetTaxonomicChildrenCount() {
|
121
|
assertEquals(0, child2.getTaxonomicChildrenCount());
|
122
|
assertEquals(2, rootT.getTaxonomicChildrenCount());
|
123
|
rootT.removeTaxonomicChild(child1);
|
124
|
assertEquals(1, rootT.getTaxonomicChildrenCount());
|
125
|
rootT.removeTaxonomicChild(child2);
|
126
|
assertEquals(0, rootT.getTaxonomicChildrenCount());
|
127
|
}
|
128
|
|
129
|
@Test
|
130
|
public void testIsMisappliedName() {
|
131
|
assertFalse(child2.isMisappliedName());
|
132
|
assertFalse(rootT.isMisappliedName());
|
133
|
assertTrue(misTaxon1.isMisappliedName());
|
134
|
assertTrue(misTaxon2.isMisappliedName());
|
135
|
}
|
136
|
|
137
|
@Test
|
138
|
public void testGetSynonyms() {
|
139
|
assertTrue(child1.getSynonyms().contains(syn1));
|
140
|
assertTrue(child2.getSynonyms().contains(syn2));
|
141
|
assertTrue(rootT.getSynonyms().isEmpty());
|
142
|
}
|
143
|
|
144
|
@Test
|
145
|
public void testGetSynonymNames() {
|
146
|
assertTrue(child1.getSynonymNames().contains(name1));
|
147
|
assertTrue(child2.getSynonymNames().contains(name2));
|
148
|
assertTrue(rootT.getSynonymNames().isEmpty());
|
149
|
}
|
150
|
|
151
|
@Test
|
152
|
public void testAddSynonym() {
|
153
|
freeT.addSynonym(syn1, SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF());
|
154
|
assertTrue(freeT.getSynonyms().contains(syn1));
|
155
|
assertTrue(syn1.getAcceptedTaxa().contains(freeT));
|
156
|
assertFalse(freeT.getSynonyms().contains(syn2));
|
157
|
}
|
158
|
|
159
|
/**
|
160
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#NewInstance(eu.etaxonomy.cdm.model.name.TaxonNameBase, eu.etaxonomy.cdm.model.reference.ReferenceBase)}.
|
161
|
*/
|
162
|
@Test
|
163
|
public void testNewInstance() {
|
164
|
logger.warn("Not yet implemented");
|
165
|
}
|
166
|
|
167
|
/**
|
168
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#Taxon()}.
|
169
|
*/
|
170
|
@Test
|
171
|
public void testTaxon() {
|
172
|
logger.warn("Not yet implemented");
|
173
|
}
|
174
|
|
175
|
/**
|
176
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#Taxon(eu.etaxonomy.cdm.model.name.TaxonNameBase, eu.etaxonomy.cdm.model.reference.ReferenceBase)}.
|
177
|
*/
|
178
|
@Test
|
179
|
public void testTaxonTaxonNameBaseReferenceBase() {
|
180
|
logger.warn("Not yet implemented");
|
181
|
}
|
182
|
|
183
|
/**
|
184
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#getDescriptions()}.
|
185
|
*/
|
186
|
@Test
|
187
|
public void testGetDescriptions() {
|
188
|
logger.warn("Not yet implemented");
|
189
|
}
|
190
|
|
191
|
/**
|
192
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#setDescriptions(java.util.Set)}.
|
193
|
*/
|
194
|
@Test
|
195
|
public void testSetDescriptions() {
|
196
|
logger.warn("Not yet implemented");
|
197
|
}
|
198
|
|
199
|
/**
|
200
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addDescription(eu.etaxonomy.cdm.model.description.TaxonDescription)}.
|
201
|
*/
|
202
|
@Test
|
203
|
public void testAddDescription() {
|
204
|
logger.warn("Not yet implemented");
|
205
|
}
|
206
|
|
207
|
/**
|
208
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#removeDescription(eu.etaxonomy.cdm.model.description.TaxonDescription)}.
|
209
|
*/
|
210
|
@Test
|
211
|
public void testRemoveDescription() {
|
212
|
logger.warn("Not yet implemented");
|
213
|
}
|
214
|
|
215
|
/**
|
216
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#getSynonymRelations()}.
|
217
|
*/
|
218
|
@Test
|
219
|
public void testGetSynonymRelations() {
|
220
|
logger.warn("Not yet implemented");
|
221
|
}
|
222
|
|
223
|
/**
|
224
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#setSynonymRelations(java.util.Set)}.
|
225
|
*/
|
226
|
@Test
|
227
|
public void testSetSynonymRelations() {
|
228
|
logger.warn("Not yet implemented");
|
229
|
}
|
230
|
|
231
|
/**
|
232
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addSynonymRelation(eu.etaxonomy.cdm.model.taxon.SynonymRelationship)}.
|
233
|
*/
|
234
|
@Test
|
235
|
public void testAddSynonymRelation() {
|
236
|
logger.warn("Not yet implemented");
|
237
|
}
|
238
|
|
239
|
/**
|
240
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#removeSynonymRelation(eu.etaxonomy.cdm.model.taxon.SynonymRelationship)}.
|
241
|
*/
|
242
|
@Test
|
243
|
public void testRemoveSynonymRelation() {
|
244
|
logger.warn("Not yet implemented");
|
245
|
}
|
246
|
|
247
|
/**
|
248
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#getRelationsFromThisTaxon()}.
|
249
|
*/
|
250
|
@Test
|
251
|
public void testGetRelationsFromThisTaxon() {
|
252
|
logger.warn("Not yet implemented");
|
253
|
}
|
254
|
|
255
|
/**
|
256
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#setRelationsFromThisTaxon(java.util.Set)}.
|
257
|
*/
|
258
|
@Test
|
259
|
public void testSetRelationsFromThisTaxon() {
|
260
|
logger.warn("Not yet implemented");
|
261
|
}
|
262
|
|
263
|
/**
|
264
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#getRelationsToThisTaxon()}.
|
265
|
*/
|
266
|
@Test
|
267
|
public void testGetRelationsToThisTaxon() {
|
268
|
logger.warn("Not yet implemented");
|
269
|
}
|
270
|
|
271
|
/**
|
272
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#setRelationsToThisTaxon(java.util.Set)}.
|
273
|
*/
|
274
|
@Test
|
275
|
public void testSetRelationsToThisTaxon() {
|
276
|
logger.warn("Not yet implemented");
|
277
|
}
|
278
|
|
279
|
/**
|
280
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#getTaxonRelations()}.
|
281
|
*/
|
282
|
@Test
|
283
|
public void testGetTaxonRelations() {
|
284
|
logger.warn("Not yet implemented");
|
285
|
}
|
286
|
|
287
|
/**
|
288
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#removeTaxonRelation(eu.etaxonomy.cdm.model.taxon.TaxonRelationship)}.
|
289
|
*/
|
290
|
@Test
|
291
|
public void testRemoveTaxonRelation() {
|
292
|
logger.warn("Not yet implemented");
|
293
|
}
|
294
|
|
295
|
/**
|
296
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addTaxonRelation(eu.etaxonomy.cdm.model.taxon.TaxonRelationship)}.
|
297
|
*/
|
298
|
@Test
|
299
|
public void testAddTaxonRelationTaxonRelationship() {
|
300
|
logger.warn("Not yet implemented");
|
301
|
}
|
302
|
|
303
|
/**
|
304
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addRelationship(eu.etaxonomy.cdm.model.common.RelationshipBase)}.
|
305
|
*/
|
306
|
@Test
|
307
|
public void testAddRelationship() {
|
308
|
logger.warn("Not yet implemented");
|
309
|
}
|
310
|
|
311
|
/**
|
312
|
* 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.ReferenceBase, java.lang.String)}.
|
313
|
*/
|
314
|
@Test
|
315
|
public void testAddTaxonRelationTaxonTaxonRelationshipTypeReferenceBaseString() {
|
316
|
logger.warn("Not yet implemented");
|
317
|
}
|
318
|
|
319
|
/**
|
320
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addMisappliedName(eu.etaxonomy.cdm.model.taxon.Taxon, eu.etaxonomy.cdm.model.reference.ReferenceBase, java.lang.String)}.
|
321
|
*/
|
322
|
@Test
|
323
|
public void testAddMisappliedName() {
|
324
|
logger.warn("Not yet implemented");
|
325
|
}
|
326
|
|
327
|
|
328
|
/**
|
329
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#hasSynonyms()}.
|
330
|
*/
|
331
|
@Test
|
332
|
public void testHasSynonyms() {
|
333
|
logger.warn("Not yet implemented");
|
334
|
}
|
335
|
|
336
|
/**
|
337
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#getMisappliedNames()}.
|
338
|
*/
|
339
|
@Test
|
340
|
public void testGetMisappliedNames() {
|
341
|
logger.warn("Not yet implemented");
|
342
|
}
|
343
|
|
344
|
|
345
|
/**
|
346
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#getSynonymsSortedByType()}.
|
347
|
*/
|
348
|
@Test
|
349
|
public void testGetSynonymsSortedByType() {
|
350
|
logger.warn("Not yet implemented");
|
351
|
}
|
352
|
|
353
|
/**
|
354
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addSynonym(eu.etaxonomy.cdm.model.taxon.Synonym, eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType)}.
|
355
|
*/
|
356
|
@Test
|
357
|
public void testAddSynonymSynonymSynonymRelationshipType() {
|
358
|
logger.warn("Not yet implemented");
|
359
|
}
|
360
|
|
361
|
/**
|
362
|
* 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.ReferenceBase, java.lang.String)}.
|
363
|
*/
|
364
|
@Test
|
365
|
public void testAddSynonymSynonymSynonymRelationshipTypeReferenceBaseString() {
|
366
|
logger.warn("Not yet implemented");
|
367
|
}
|
368
|
|
369
|
/**
|
370
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addSynonymName(eu.etaxonomy.cdm.model.name.TaxonNameBase, eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType)}.
|
371
|
*/
|
372
|
@Test
|
373
|
public void testAddSynonymNameTaxonNameBaseSynonymRelationshipType() {
|
374
|
logger.warn("Not yet implemented");
|
375
|
}
|
376
|
|
377
|
/**
|
378
|
* 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.ReferenceBase, java.lang.String)}.
|
379
|
*/
|
380
|
@Test
|
381
|
public void testAddSynonymNameTaxonNameBaseSynonymRelationshipTypeReferenceBaseString() {
|
382
|
logger.warn("Not yet implemented");
|
383
|
}
|
384
|
|
385
|
/**
|
386
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addHeterotypicSynonymName(eu.etaxonomy.cdm.model.name.TaxonNameBase)}.
|
387
|
*/
|
388
|
@Test
|
389
|
public void testAddHeterotypicSynonymNameTaxonNameBase() {
|
390
|
logger.warn("Not yet implemented");
|
391
|
}
|
392
|
|
393
|
/**
|
394
|
* 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.ReferenceBase, java.lang.String)}.
|
395
|
*/
|
396
|
@Test
|
397
|
public void testAddHeterotypicSynonymNameTaxonNameBaseHomotypicalGroupReferenceBaseString() {
|
398
|
logger.warn("Not yet implemented");
|
399
|
}
|
400
|
|
401
|
/**
|
402
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addHomotypicSynonymName(eu.etaxonomy.cdm.model.name.TaxonNameBase, eu.etaxonomy.cdm.model.reference.ReferenceBase, java.lang.String)}.
|
403
|
*/
|
404
|
@Test
|
405
|
public void testAddHomotypicSynonymName() {
|
406
|
logger.warn("Not yet implemented");
|
407
|
}
|
408
|
|
409
|
/**
|
410
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#addHomotypicSynonym(eu.etaxonomy.cdm.model.taxon.Synonym, eu.etaxonomy.cdm.model.reference.ReferenceBase, java.lang.String)}.
|
411
|
*/
|
412
|
@Test
|
413
|
public void testAddHomotypicSynonym() {
|
414
|
logger.warn("Not yet implemented");
|
415
|
}
|
416
|
|
417
|
/**
|
418
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#removeSynonym(eu.etaxonomy.cdm.model.taxon.Synonym)}.
|
419
|
*/
|
420
|
@Test
|
421
|
public void testRemoveSynonym() {
|
422
|
logger.warn("Not yet implemented");
|
423
|
}
|
424
|
|
425
|
/**
|
426
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#iterator()}.
|
427
|
*/
|
428
|
@Test
|
429
|
public void testIterator() {
|
430
|
logger.warn("Not yet implemented");
|
431
|
}
|
432
|
|
433
|
/**
|
434
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#getHomotypicSynonymsByHomotypicGroup()}.
|
435
|
*/
|
436
|
@Test
|
437
|
public void testGetHomotypicSynonymsByHomotypicGroup() {
|
438
|
logger.warn("Not yet implemented");
|
439
|
}
|
440
|
|
441
|
/**
|
442
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#getHomotypicSynonymsByHomotypicRelationship()}.
|
443
|
*/
|
444
|
@Test
|
445
|
public void testGetHomotypicSynonymsByHomotypicRelationship() {
|
446
|
logger.warn("Not yet implemented");
|
447
|
}
|
448
|
|
449
|
/**
|
450
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#getHomotypicSynonymyGroups()}.
|
451
|
*/
|
452
|
@Test
|
453
|
public void testGetHomotypicSynonymyGroups() {
|
454
|
logger.warn("Not yet implemented");
|
455
|
}
|
456
|
|
457
|
/**
|
458
|
* Test method for {@link eu.etaxonomy.cdm.model.taxon.Taxon#getHeterotypicSynonymyGroups()}.
|
459
|
*/
|
460
|
@Test
|
461
|
public void testGetHeterotypicSynonymyGroups() {
|
462
|
logger.warn("Not yet implemented");
|
463
|
}
|
464
|
|
465
|
}
|