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.name;
|
11
|
|
12
|
|
13
|
import static org.junit.Assert.assertEquals;
|
14
|
import static org.junit.Assert.assertNotNull;
|
15
|
import static org.junit.Assert.assertTrue;
|
16
|
|
17
|
import java.util.Set;
|
18
|
|
19
|
import org.apache.log4j.Logger;
|
20
|
import org.junit.Before;
|
21
|
import org.junit.BeforeClass;
|
22
|
import org.junit.Test;
|
23
|
import org.springframework.beans.BeanUtils;
|
24
|
|
25
|
import eu.etaxonomy.cdm.model.common.DefaultTermInitializer;
|
26
|
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
|
27
|
|
28
|
/**
|
29
|
* @author a.babadshanjan
|
30
|
* @created 19.05.2009
|
31
|
* @version 1.0
|
32
|
*/
|
33
|
public class SpecimenTypeDesignationTest {
|
34
|
@SuppressWarnings("unused")
|
35
|
private static final Logger logger = Logger.getLogger(SpecimenTypeDesignationTest.class);
|
36
|
|
37
|
private SpecimenTypeDesignation term1 = null;
|
38
|
private SpecimenTypeDesignation term2 = null;
|
39
|
|
40
|
@BeforeClass
|
41
|
public static void setUpBeforeClass() {
|
42
|
DefaultTermInitializer vocabularyStore = new DefaultTermInitializer();
|
43
|
vocabularyStore.initialize();
|
44
|
}
|
45
|
|
46
|
@Before
|
47
|
public void setUp() {
|
48
|
term1 = new SpecimenTypeDesignation();
|
49
|
term2 = new SpecimenTypeDesignation(DerivedUnit.NewPreservedSpecimenInstance(),
|
50
|
SpecimenTypeDesignationStatus.ISOTYPE(), null, null, null, false);
|
51
|
}
|
52
|
|
53
|
@Test
|
54
|
public void testSpecimenTypeDesignation() {
|
55
|
assertNotNull(term1);
|
56
|
assertNotNull(term2);
|
57
|
}
|
58
|
|
59
|
@Test
|
60
|
public void testGetTypeStatus() {
|
61
|
SpecimenTypeDesignationStatus std = term1.getTypeStatus();
|
62
|
std = term2.getTypeStatus();
|
63
|
term1.setTypeStatus(SpecimenTypeDesignationStatus.EPITYPE());
|
64
|
assertEquals(term1.getTypeStatus(), SpecimenTypeDesignationStatus.EPITYPE());
|
65
|
assertTrue(term1.getTypeStatus().isInstanceOf(SpecimenTypeDesignationStatus.class));
|
66
|
}
|
67
|
|
68
|
@Test
|
69
|
public void testBidirectionalRelationship(){
|
70
|
term2 = new SpecimenTypeDesignation(DerivedUnit.NewPreservedSpecimenInstance(), SpecimenTypeDesignationStatus.ISOTYPE(),
|
71
|
null, null, null, false);
|
72
|
DerivedUnit specimen = term2.getTypeSpecimen();
|
73
|
Set<SpecimenTypeDesignation> set = specimen.getSpecimenTypeDesignations();
|
74
|
boolean contains = false;
|
75
|
for (SpecimenTypeDesignation spec: set){
|
76
|
if (spec.equals(term2)){
|
77
|
contains = true;
|
78
|
break;
|
79
|
}
|
80
|
}
|
81
|
assertTrue(contains);
|
82
|
}
|
83
|
|
84
|
@Test
|
85
|
public void beanTests(){
|
86
|
// #5307 Test that BeanUtils does not fail
|
87
|
BeanUtils.getPropertyDescriptors(SpecimenTypeDesignation.class);
|
88
|
BeanUtils.getPropertyDescriptors(NameTypeDesignation.class);
|
89
|
BeanUtils.getPropertyDescriptors(HomotypicalGroup.class);
|
90
|
BeanUtils.getPropertyDescriptors(NomenclaturalStatusType.class);
|
91
|
BeanUtils.getPropertyDescriptors(Rank.class);
|
92
|
}
|
93
|
|
94
|
|
95
|
}
|