Revision b18e16cd
Added by Andreas Kohlbecker almost 7 years ago
src/test/java/eu/etaxonomy/cdm/vaadin/util/converter/TypeDesignationSetManagerTest.java | ||
---|---|---|
19 | 19 |
import java.util.Map; |
20 | 20 |
|
21 | 21 |
import org.apache.log4j.Logger; |
22 |
import org.junit.Before; |
|
22 | 23 |
import org.junit.Test; |
23 | 24 |
|
24 | 25 |
import eu.etaxonomy.cdm.model.name.NameTypeDesignation; |
... | ... | |
49 | 50 |
public class TypeDesignationSetManagerTest extends CdmVaadinBaseTest{ |
50 | 51 |
|
51 | 52 |
|
52 |
@Test |
|
53 |
public void test1() throws RegistrationValidationException{ |
|
54 |
|
|
53 |
private NameTypeDesignation ntd; |
|
54 |
private SpecimenTypeDesignation std_IT; |
|
55 |
private SpecimenTypeDesignation std_HT; |
|
56 |
private SpecimenTypeDesignation std_IT_2; |
|
57 |
private SpecimenTypeDesignation std_IT_3; |
|
55 | 58 |
|
56 |
TaxonName typifiedName = TaxonNameFactory.NewBacterialInstance(Rank.SPECIES());
|
|
57 |
typifiedName.setTitleCache("Prionus coriatius L.", true);
|
|
59 |
@Before
|
|
60 |
public void init(){
|
|
58 | 61 |
|
59 |
NameTypeDesignation ntd = NameTypeDesignation.NewInstance();
|
|
62 |
ntd = NameTypeDesignation.NewInstance(); |
|
60 | 63 |
ntd.setId(1); |
61 | 64 |
TaxonName typeName = TaxonNameFactory.NewBacterialInstance(Rank.SPECIES()); |
62 | 65 |
typeName.setTitleCache("Prionus L.", true); |
63 | 66 |
ntd.setTypeName(typeName); |
64 | 67 |
Reference citation = ReferenceFactory.newGeneric(); |
65 |
citation.setTitleCache("Species Platarum", true); |
|
68 |
citation.setTitleCache("Species Plantarum", true);
|
|
66 | 69 |
ntd.setCitation(citation); |
67 |
typifiedName.addTypeDesignation(ntd, false); |
|
68 | 70 |
|
69 | 71 |
FieldUnit fu_1 = FieldUnit.NewInstance(); |
70 | 72 |
fu_1.setId(1); |
... | ... | |
74 | 76 |
fu_2.setId(2); |
75 | 77 |
fu_2.setTitleCache("Dreamland, near Kissingen, A.Kohlbecker 66211, 2017", true); |
76 | 78 |
|
77 |
SpecimenTypeDesignation std_HT = SpecimenTypeDesignation.NewInstance();
|
|
79 |
std_HT = SpecimenTypeDesignation.NewInstance(); |
|
78 | 80 |
std_HT.setId(1); |
79 | 81 |
DerivedUnit specimen_HT = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen); |
80 | 82 |
specimen_HT.setTitleCache("OHA", true); |
... | ... | |
84 | 86 |
specimen_HT.getOriginals().add(fu_1); |
85 | 87 |
std_HT.setTypeSpecimen(specimen_HT); |
86 | 88 |
std_HT.setTypeStatus(SpecimenTypeDesignationStatus.HOLOTYPE()); |
87 |
typifiedName.addTypeDesignation(std_HT, false); |
|
88 | 89 |
|
89 |
SpecimenTypeDesignation std_IT = SpecimenTypeDesignation.NewInstance();
|
|
90 |
std_IT = SpecimenTypeDesignation.NewInstance(); |
|
90 | 91 |
std_IT.setId(2); |
91 | 92 |
DerivedUnit specimen_IT = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen); |
92 | 93 |
specimen_IT.setTitleCache("BER", true); |
... | ... | |
95 | 96 |
derivationEvent_2.addDerivative(specimen_IT); |
96 | 97 |
std_IT.setTypeSpecimen(specimen_IT); |
97 | 98 |
std_IT.setTypeStatus(SpecimenTypeDesignationStatus.ISOTYPE()); |
98 |
typifiedName.addTypeDesignation(std_IT, false); |
|
99 | 99 |
|
100 |
SpecimenTypeDesignation std_IT_2 = SpecimenTypeDesignation.NewInstance();
|
|
100 |
std_IT_2 = SpecimenTypeDesignation.NewInstance(); |
|
101 | 101 |
std_IT_2.setId(3); |
102 | 102 |
DerivedUnit specimen_IT_2 = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen); |
103 | 103 |
specimen_IT_2.setTitleCache("KEW", true); |
... | ... | |
106 | 106 |
derivationEvent_3.addDerivative(specimen_IT_2); |
107 | 107 |
std_IT_2.setTypeSpecimen(specimen_IT_2); |
108 | 108 |
std_IT_2.setTypeStatus(SpecimenTypeDesignationStatus.ISOTYPE()); |
109 |
typifiedName.addTypeDesignation(std_IT_2, false); |
|
110 | 109 |
|
111 |
SpecimenTypeDesignation std_IT_3 = SpecimenTypeDesignation.NewInstance();
|
|
110 |
std_IT_3 = SpecimenTypeDesignation.NewInstance(); |
|
112 | 111 |
std_IT_3.setId(4); |
113 | 112 |
DerivedUnit specimen_IT_3 = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen); |
114 | 113 |
specimen_IT_3.setTitleCache("M", true); |
115 | 114 |
std_IT_3.setTypeSpecimen(specimen_IT_3); |
116 | 115 |
std_IT_3.setTypeStatus(SpecimenTypeDesignationStatus.ISOTYPE()); |
117 |
typifiedName.addTypeDesignation(std_IT_3, false); |
|
116 |
} |
|
117 |
|
|
118 |
@Test |
|
119 |
public void test1() throws RegistrationValidationException{ |
|
118 | 120 |
|
119 | 121 |
List<TypeDesignationBase> tds = new ArrayList<>(); |
120 | 122 |
tds.add(ntd); |
... | ... | |
123 | 125 |
tds.add(std_IT_2); |
124 | 126 |
tds.add(std_IT_3); |
125 | 127 |
|
126 |
TypeDesignationSetManager typeDesignationManager = new TypeDesignationSetManager(typifiedName, tds); |
|
128 |
TaxonName typifiedName = TaxonNameFactory.NewBacterialInstance(Rank.SPECIES()); |
|
129 |
typifiedName.setTitleCache("Prionus coriatius L.", true); |
|
130 |
|
|
131 |
typifiedName.addTypeDesignation(ntd, false); |
|
132 |
typifiedName.addTypeDesignation(std_HT, false); |
|
133 |
typifiedName.addTypeDesignation(std_IT, false); |
|
134 |
typifiedName.addTypeDesignation(std_IT_2, false); |
|
135 |
typifiedName.addTypeDesignation(std_IT_3, false); |
|
136 |
|
|
137 |
TypeDesignationSetManager typeDesignationManager = new TypeDesignationSetManager(tds); |
|
127 | 138 |
String result = typeDesignationManager.buildString().print(); |
128 |
System.err.println(result); |
|
129 | 139 |
|
130 | 140 |
Logger.getLogger(this.getClass()).debug(result); |
131 | 141 |
assertNotNull(result); |
132 | 142 |
assertEquals( |
133 |
"Prionus coriatius L. Type: Testland, near Bughausen, A.Kohlbecker 81989, 2017 (Holotype, OHA; Isotypes: BER, KEW); Type: (Isotype, M); NameType: Prionus L. Species Platarum" |
|
143 |
"Prionus coriatius L. Type: Testland, near Bughausen, A.Kohlbecker 81989, 2017 (Holotype, OHA; Isotypes: BER, KEW); Type: (Isotype, M); NameType: Prionus L. Species Plantarum"
|
|
134 | 144 |
, result |
135 | 145 |
); |
136 | 146 |
|
... | ... | |
142 | 152 |
assertEquals("Isotype", keyIt.next().getLabel()); |
143 | 153 |
} |
144 | 154 |
|
155 |
@Test |
|
156 |
public void test2() throws RegistrationValidationException{ |
|
157 |
|
|
158 |
TaxonName typifiedName = TaxonNameFactory.NewBacterialInstance(Rank.SPECIES()); |
|
159 |
typifiedName.setTitleCache("Prionus coriatius L.", true); |
|
160 |
|
|
161 |
TypeDesignationSetManager typeDesignationManager = new TypeDesignationSetManager(typifiedName); |
|
162 |
String result = typeDesignationManager.buildString().print(); |
|
163 |
Logger.getLogger(this.getClass()).debug(result); |
|
164 |
assertNotNull(result); |
|
165 |
assertEquals( |
|
166 |
"Prionus coriatius L." |
|
167 |
, result |
|
168 |
); |
|
169 |
|
|
170 |
typifiedName.addTypeDesignation(ntd, false); |
|
171 |
typeDesignationManager.addTypeDesigations(null, ntd); |
|
172 |
|
|
173 |
assertEquals( |
|
174 |
"Prionus coriatius L. NameType: Prionus L. Species Plantarum" |
|
175 |
, typeDesignationManager.buildString().print() |
|
176 |
); |
|
177 |
|
|
178 |
typifiedName.addTypeDesignation(std_HT, false); |
|
179 |
typeDesignationManager.addTypeDesigations(null, std_HT); |
|
180 |
|
|
181 |
assertEquals( |
|
182 |
"Prionus coriatius L. Type: Testland, near Bughausen, A.Kohlbecker 81989, 2017 (Holotype, OHA); NameType: Prionus L. Species Plantarum" |
|
183 |
, typeDesignationManager.buildString().print() |
|
184 |
); |
|
185 |
|
|
186 |
} |
|
145 | 187 |
} |
188 |
|
Also available in: Unified diff
ref #6169 TypeDesignationSetManager can handle empty sets and can add typeDesignations