Revision c38734e6
Added by Andreas Müller over 8 years ago
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/occurrence/SpecimenTest.java | ||
---|---|---|
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.occurrence; |
|
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.assertNotSame; |
|
16 |
import static org.junit.Assert.assertNull; |
|
17 |
import static org.junit.Assert.assertSame; |
|
18 |
import static org.junit.Assert.assertTrue; |
|
19 |
|
|
20 |
import java.util.Calendar; |
|
21 |
import java.util.UUID; |
|
22 |
|
|
23 |
import org.apache.log4j.Logger; |
|
24 |
import org.joda.time.DateTime; |
|
25 |
import org.junit.Assert; |
|
26 |
import org.junit.Before; |
|
27 |
import org.junit.Test; |
|
28 |
|
|
29 |
import com.ibm.lsid.MalformedLSIDException; |
|
30 |
|
|
31 |
import eu.etaxonomy.cdm.model.agent.Person; |
|
32 |
import eu.etaxonomy.cdm.model.common.Annotation; |
|
33 |
import eu.etaxonomy.cdm.model.common.DefinedTerm; |
|
34 |
import eu.etaxonomy.cdm.model.common.Extension; |
|
35 |
import eu.etaxonomy.cdm.model.common.IdentifiableSource; |
|
36 |
import eu.etaxonomy.cdm.model.common.LSID; |
|
37 |
import eu.etaxonomy.cdm.model.common.Language; |
|
38 |
import eu.etaxonomy.cdm.model.common.LanguageStringBase; |
|
39 |
import eu.etaxonomy.cdm.model.common.Marker; |
|
40 |
import eu.etaxonomy.cdm.model.common.MarkerType; |
|
41 |
import eu.etaxonomy.cdm.model.common.OriginalSourceBase; |
|
42 |
import eu.etaxonomy.cdm.model.description.SpecimenDescription; |
|
43 |
import eu.etaxonomy.cdm.model.media.Media; |
|
44 |
import eu.etaxonomy.cdm.model.media.Rights; |
|
45 |
import eu.etaxonomy.cdm.model.name.BotanicalName; |
|
46 |
import eu.etaxonomy.cdm.model.name.Rank; |
|
47 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
|
48 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
|
49 |
|
|
50 |
/** |
|
51 |
* @author a.mueller |
|
52 |
* @created 28.10.2008 |
|
53 |
*/ |
|
54 |
public class SpecimenTest { |
|
55 |
private static final Logger logger = Logger.getLogger(SpecimenTest.class); |
|
56 |
|
|
57 |
private DerivedUnit specimen; |
|
58 |
|
|
59 |
@Before |
|
60 |
public void setUp() throws Exception { |
|
61 |
specimen = DerivedUnit.NewPreservedSpecimenInstance(); |
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* Test method for {@link eu.etaxonomy.cdm.model.occurrence.Specimen#NewInstance()}. |
|
66 |
*/ |
|
67 |
@Test |
|
68 |
public void testNewInstance() { |
|
69 |
DerivedUnit specimen = DerivedUnit.NewPreservedSpecimenInstance(); |
|
70 |
assertNotNull(specimen); |
|
71 |
assertTrue(specimen instanceof DerivedUnit); |
|
72 |
assertTrue(specimen.getRecordBasis().equals(SpecimenOrObservationType.PreservedSpecimen)); |
|
73 |
} |
|
74 |
|
|
75 |
/** |
|
76 |
* Test method for {@link eu.etaxonomy.cdm.model.occurrence.Specimen#getPreservation()} and |
|
77 |
* {@link eu.etaxonomy.cdm.model.occurrence.Specimen#setPreservation(eu.etaxonomy.cdm.model.occurrence.PreservationMethod)}. |
|
78 |
*/ |
|
79 |
@Test |
|
80 |
public void testGetSetPreservation() { |
|
81 |
PreservationMethod preservation = PreservationMethod.NewInstance(); |
|
82 |
specimen.setPreservation(preservation); |
|
83 |
assertSame(preservation, specimen.getPreservation()); |
|
84 |
specimen.setPreservation(null); |
|
85 |
} |
|
86 |
|
|
87 |
@Test |
|
88 |
public void testBidirectionalSpecimenDescription(){ |
|
89 |
Assert.assertNotNull("Specimen should exist", specimen); |
|
90 |
|
|
91 |
SpecimenDescription desc = SpecimenDescription.NewInstance(specimen); |
|
92 |
Assert.assertNotNull("Description should exist.", desc); |
|
93 |
Assert.assertSame("Descriptions specimen should be set correctly", desc.getDescribedSpecimenOrObservation(),specimen); |
|
94 |
Assert.assertTrue("Specimen should contain description", specimen.getDescriptions().contains(desc)); |
|
95 |
|
|
96 |
SpecimenDescription desc2 = SpecimenDescription.NewInstance(); |
|
97 |
Assert.assertNotNull("Description should exist.", desc2); |
|
98 |
specimen.addDescription(desc2); |
|
99 |
Assert.assertSame("Description2 specimen should be set correctly", desc2.getDescribedSpecimenOrObservation(),specimen); |
|
100 |
Assert.assertSame("Descriptions specimen should still be set correctly", desc.getDescribedSpecimenOrObservation(),specimen); |
|
101 |
Assert.assertTrue("Specimen should contain description2", specimen.getDescriptions().contains(desc2)); |
|
102 |
Assert.assertTrue("Specimen should still contain description", specimen.getDescriptions().contains(desc)); |
|
103 |
|
|
104 |
SpecimenDescription desc3 = SpecimenDescription.NewInstance(); |
|
105 |
Assert.assertNotNull("Description should exist.", desc3); |
|
106 |
desc3.setDescribedSpecimenOrObservation(specimen); |
|
107 |
Assert.assertSame("Description3 specimen should be set correctly", desc3.getDescribedSpecimenOrObservation(),specimen); |
|
108 |
Assert.assertSame("Descriptions2 specimen should still be set correctly", desc2.getDescribedSpecimenOrObservation(),specimen); |
|
109 |
Assert.assertSame("Descriptions specimen should still be set correctly", desc.getDescribedSpecimenOrObservation(),specimen); |
|
110 |
Assert.assertTrue("Specimen should contain description3", specimen.getDescriptions().contains(desc3)); |
|
111 |
Assert.assertTrue("Specimen should still contain description2", specimen.getDescriptions().contains(desc2)); |
|
112 |
Assert.assertTrue("Specimen should still contain description", specimen.getDescriptions().contains(desc)); |
|
113 |
|
|
114 |
|
|
115 |
//change specimen of a given description |
|
116 |
DerivedUnit specimen2 = DerivedUnit.NewPreservedSpecimenInstance(); |
|
117 |
Assert.assertNotNull("Specimen should exist.", specimen2); |
|
118 |
desc3.setDescribedSpecimenOrObservation(specimen2); |
|
119 |
Assert.assertSame("Description3 new specimen should be set correctly", desc3.getDescribedSpecimenOrObservation(),specimen2); |
|
120 |
Assert.assertSame("Descriptions2 specimen should still be set correctly", desc2.getDescribedSpecimenOrObservation(),specimen); |
|
121 |
Assert.assertSame("Descriptions specimen should still be set correctly", desc.getDescribedSpecimenOrObservation(),specimen); |
|
122 |
Assert.assertTrue("Specimen2 should contain description3", specimen2.getDescriptions().contains(desc3)); |
|
123 |
Assert.assertEquals("Specimen2 should contain exactly 1 description", 1, specimen2.getDescriptions().size()); |
|
124 |
Assert.assertFalse("Specimen should no longer contain description3", specimen.getDescriptions().contains(desc3)); |
|
125 |
Assert.assertTrue("Specimen should still contain description2", specimen.getDescriptions().contains(desc2)); |
|
126 |
Assert.assertTrue("Specimen should still contain description", specimen.getDescriptions().contains(desc)); |
|
127 |
|
|
128 |
//remove description which is not contained |
|
129 |
specimen.removeDescription(desc3); |
|
130 |
Assert.assertSame("Nothing should have changed", desc3.getDescribedSpecimenOrObservation(),specimen2); |
|
131 |
Assert.assertSame("Nothing should have changed", desc2.getDescribedSpecimenOrObservation(),specimen); |
|
132 |
Assert.assertSame("Nothing should have changed", desc.getDescribedSpecimenOrObservation(),specimen); |
|
133 |
Assert.assertTrue("Nothing should have changed", specimen2.getDescriptions().contains(desc3)); |
|
134 |
Assert.assertEquals("Nothing should have changed", 1, specimen2.getDescriptions().size()); |
|
135 |
Assert.assertFalse("Nothing should have changed", specimen.getDescriptions().contains(desc3)); |
|
136 |
Assert.assertTrue("Nothing should have changed", specimen.getDescriptions().contains(desc2)); |
|
137 |
Assert.assertTrue("Nothing should have changed", specimen.getDescriptions().contains(desc)); |
|
138 |
|
|
139 |
//remove description |
|
140 |
specimen.removeDescription(desc2); |
|
141 |
Assert.assertNull("Descriptions2 specimen should not exist anymore", desc2.getDescribedSpecimenOrObservation()); |
|
142 |
Assert.assertSame("Description3 specimen should still be set correctly", desc3.getDescribedSpecimenOrObservation(),specimen2); |
|
143 |
Assert.assertSame("Descriptions specimen should still be set correctly", desc.getDescribedSpecimenOrObservation(),specimen); |
|
144 |
Assert.assertTrue("Specimen2 should still contain description3", specimen2.getDescriptions().contains(desc3)); |
|
145 |
Assert.assertEquals("Specimen2 should still contain exactly 1 description", 1, specimen2.getDescriptions().size()); |
|
146 |
Assert.assertFalse("Specimen should not contain description2 anymore", specimen.getDescriptions().contains(desc2)); |
|
147 |
Assert.assertFalse("Specimen should still no longer contain description3", specimen.getDescriptions().contains(desc3)); |
|
148 |
Assert.assertTrue("Specimen should still contain description", specimen.getDescriptions().contains(desc)); |
|
149 |
|
|
150 |
//remove description by setting null specimen |
|
151 |
desc3.setDescribedSpecimenOrObservation(null); |
|
152 |
Assert.assertNull("Description3 specimen should not exist anymore", desc3.getDescribedSpecimenOrObservation()); |
|
153 |
Assert.assertNull("Descriptions2 specimen should still not exist anymore", desc2.getDescribedSpecimenOrObservation()); |
|
154 |
Assert.assertSame("Descriptions specimen should still be set correctly", desc.getDescribedSpecimenOrObservation(),specimen); |
|
155 |
Assert.assertFalse("Specimen2 should not contain description3 anymore", specimen2.getDescriptions().contains(desc3)); |
|
156 |
Assert.assertEquals("Specimen2 should contain no description now", 0, specimen2.getDescriptions().size()); |
|
157 |
Assert.assertFalse("Specimen should still no longer contain description2", specimen.getDescriptions().contains(desc2)); |
|
158 |
Assert.assertFalse("Specimen should still no longer contain description3", specimen.getDescriptions().contains(desc3)); |
|
159 |
Assert.assertTrue("Specimen should still contain description", specimen.getDescriptions().contains(desc)); |
|
160 |
|
|
161 |
|
|
162 |
} |
|
163 |
|
|
164 |
|
|
165 |
@Test |
|
166 |
public void testBidirectionalTypeDesignation(){ |
|
167 |
SpecimenTypeDesignation desig1 = SpecimenTypeDesignation.NewInstance(); |
|
168 |
SpecimenTypeDesignation desig2 = SpecimenTypeDesignation.NewInstance(); |
|
169 |
DerivedUnit specimen2 = DerivedUnit.NewPreservedSpecimenInstance(); |
|
170 |
|
|
171 |
specimen.addSpecimenTypeDesignation(desig1); |
|
172 |
Assert.assertEquals("Specimen1 should be the designations specimen", specimen, desig1.getTypeSpecimen()); |
|
173 |
Assert.assertEquals("specimen1 should have exactly 1 designation", 1, specimen.getSpecimenTypeDesignations().size()); |
|
174 |
Assert.assertEquals("specimen1's designation should be desig1", desig1, specimen.getSpecimenTypeDesignations().iterator().next()); |
|
175 |
|
|
176 |
specimen.addSpecimenTypeDesignation(desig2); |
|
177 |
Assert.assertEquals("Specimen1 should be the desig2's specimen", specimen, desig2.getTypeSpecimen()); |
|
178 |
Assert.assertEquals("specimen1 should have exactly 2 designation", 2, specimen.getSpecimenTypeDesignations().size()); |
|
179 |
|
|
180 |
specimen2.addSpecimenTypeDesignation(desig2); |
|
181 |
Assert.assertEquals("Specimen2 should have replaced specimen1 as desig2's specimen", specimen2, desig2.getTypeSpecimen()); |
|
182 |
Assert.assertEquals("Specimen2 should have exactly 1 designation", 1, specimen2.getSpecimenTypeDesignations().size()); |
|
183 |
Assert.assertEquals("Specimen1's designation should be desig2", desig2, specimen2.getSpecimenTypeDesignations().iterator().next()); |
|
184 |
Assert.assertEquals("specimen1 should have exactly 1 designation", 1, specimen.getSpecimenTypeDesignations().size()); |
|
185 |
|
|
186 |
specimen2.removeSpecimenTypeDesignation(desig2); |
|
187 |
Assert.assertEquals("Desig2 should not have a specimen anymore", null, desig2.getTypeSpecimen()); |
|
188 |
Assert.assertEquals("Specimen2 should have no designation", 0, specimen2.getSpecimenTypeDesignations().size()); |
|
189 |
Assert.assertEquals("specimen1 should have exactly 1 designation", 1, specimen.getSpecimenTypeDesignations().size()); |
|
190 |
|
|
191 |
specimen.addSpecimenTypeDesignation(desig2); |
|
192 |
Assert.assertEquals("Specimen1 should be the desig2's specimen", specimen, desig2.getTypeSpecimen()); |
|
193 |
Assert.assertEquals("specimen1 should have exactly 2 designation", 2, specimen.getSpecimenTypeDesignations().size()); |
|
194 |
|
|
195 |
desig1.setTypeSpecimen(null); |
|
196 |
Assert.assertEquals("Desig1 should not have a specimen anymore", null, desig1.getTypeSpecimen()); |
|
197 |
Assert.assertEquals("Specimen1 should have 1 designation", 1, specimen.getSpecimenTypeDesignations().size()); |
|
198 |
Assert.assertEquals("Specimen1's designation should be desig2", desig2, specimen.getSpecimenTypeDesignations().iterator().next()); |
|
199 |
|
|
200 |
desig1.setTypeSpecimen(specimen); |
|
201 |
Assert.assertEquals("Desig1 should have specimen1 as specimen again", specimen, desig1.getTypeSpecimen()); |
|
202 |
Assert.assertEquals("Specimen1 should have 2 designation", 2, specimen.getSpecimenTypeDesignations().size()); |
|
203 |
|
|
204 |
} |
|
205 |
|
|
206 |
|
|
207 |
/** |
|
208 |
* Test method for {@link eu.etaxonomy.cdm.model.occurrence.Specimen#clone()}. |
|
209 |
*/ |
|
210 |
@Test |
|
211 |
public void testClone() { |
|
212 |
logger.debug("Start testClone"); |
|
213 |
|
|
214 |
//Null test is not full implemented, but an error is thrown if null throws |
|
215 |
//null pointer exception somewhere |
|
216 |
DerivedUnit specimenNullClone = (DerivedUnit)specimen.clone(); |
|
217 |
|
|
218 |
String accessionNumber = "accNumber"; |
|
219 |
String catalogNumber = "catNumber"; |
|
220 |
Collection collection = Collection.NewInstance(); |
|
221 |
collection.setCode("code"); |
|
222 |
DateTime created = new DateTime(); |
|
223 |
Person createdBy = Person.NewTitledInstance("creator"); |
|
224 |
DerivationEvent derivedFrom = DerivationEvent.NewInstance(null); |
|
225 |
int id = 22; |
|
226 |
int individualCount = 25; |
|
227 |
DefinedTerm lifeStage = DefinedTerm.NewStageInstance(null, null, null); |
|
228 |
LSID lsid = null; |
|
229 |
try { |
|
230 |
lsid = new LSID("urn:lsid:example.com:foo:1"); |
|
231 |
} catch (MalformedLSIDException e) { |
|
232 |
// TODO Auto-generated catch block |
|
233 |
e.printStackTrace(); |
|
234 |
} |
|
235 |
DerivedUnit nextVersion = DerivedUnit.NewPreservedSpecimenInstance(); |
|
236 |
DerivedUnit previousVersion = DerivedUnit.NewPreservedSpecimenInstance(); |
|
237 |
PreservationMethod preservation = PreservationMethod.NewInstance(); |
|
238 |
boolean protectedTitleCache = true; |
|
239 |
DefinedTerm sex = DefinedTerm.SEX_FEMALE(); |
|
240 |
TaxonNameBase<?, ?> storedUnder = BotanicalName.NewInstance(Rank.GENUS()); |
|
241 |
String titleCache = "title"; |
|
242 |
Calendar updated = Calendar.getInstance(); |
|
243 |
Person updatedBy = Person.NewTitledInstance("updatedPerson"); |
|
244 |
UUID uuid = UUID.randomUUID(); |
|
245 |
|
|
246 |
Annotation annotation = Annotation.NewDefaultLanguageInstance("annotation"); |
|
247 |
String definition = "definition"; |
|
248 |
//TODO |
|
249 |
DerivationEvent derivationEvent = DerivationEvent.NewInstance(null); |
|
250 |
SpecimenDescription description = SpecimenDescription.NewInstance(); |
|
251 |
DeterminationEvent determination = DeterminationEvent.NewInstance(); |
|
252 |
Extension extension = Extension.NewInstance(); |
|
253 |
extension.setValue("extension"); |
|
254 |
Marker marker = Marker.NewInstance(MarkerType.COMPLETE(), false); |
|
255 |
Rights right = Rights.NewInstance("right", Language.DEFAULT()); |
|
256 |
Media media = Media.NewInstance(); |
|
257 |
IdentifiableSource source = IdentifiableSource.NewDataImportInstance("12", "idNamespace"); |
|
258 |
|
|
259 |
specimen.setAccessionNumber(accessionNumber); |
|
260 |
specimen.setCatalogNumber(catalogNumber); |
|
261 |
specimen.setCollection(collection); |
|
262 |
specimen.setCreated(created); |
|
263 |
// specimen.setCreatedBy(createdBy); |
|
264 |
specimen.setDerivedFrom(derivedFrom); |
|
265 |
specimen.setId(id); |
|
266 |
specimen.setIndividualCount(individualCount); |
|
267 |
specimen.setLifeStage(lifeStage); |
|
268 |
specimen.setLsid(lsid); |
|
269 |
specimen.setPreservation(preservation); |
|
270 |
specimen.setProtectedTitleCache(protectedTitleCache); |
|
271 |
specimen.setSex(sex); |
|
272 |
specimen.setStoredUnder(storedUnder); |
|
273 |
specimen.setTitleCache(titleCache, protectedTitleCache); |
|
274 |
// specimen.setUpdated(updated); |
|
275 |
// specimen.setUpdatedBy(updatedBy); |
|
276 |
specimen.setUuid(uuid); |
|
277 |
|
|
278 |
specimen.addAnnotation(annotation); |
|
279 |
specimen.putDefinition(Language.DEFAULT(), definition); |
|
280 |
specimen.addDerivationEvent(derivationEvent); |
|
281 |
specimen.addDescription(description); |
|
282 |
specimen.addDetermination(determination); |
|
283 |
specimen.addExtension(extension); |
|
284 |
specimen.addMarker(marker); |
|
285 |
// specimen.addMedia(media); #3597 |
|
286 |
specimen.addRights(right); |
|
287 |
specimen.addSource(source); |
|
288 |
|
|
289 |
try { |
|
290 |
Thread.sleep(200); |
|
291 |
} catch (InterruptedException e) { |
|
292 |
//ignore |
|
293 |
} |
|
294 |
DerivedUnit specimenClone = (DerivedUnit)specimen.clone(); |
|
295 |
|
|
296 |
assertFalse(id == specimenClone.getId()); |
|
297 |
assertFalse(created.equals(specimenClone.getCreated())); |
|
298 |
assertFalse(createdBy.equals(specimenClone.getCreatedBy())); |
|
299 |
assertFalse(updated.equals(specimenClone.getUpdated())); |
|
300 |
assertFalse(updatedBy.equals(specimenClone.getUpdatedBy())); |
|
301 |
assertNull(specimenClone.getUpdatedBy()); |
|
302 |
assertNull(specimenClone.getCreatedBy()); |
|
303 |
assertFalse(uuid.equals(specimenClone.getUuid())); |
|
304 |
|
|
305 |
|
|
306 |
assertEquals(accessionNumber, specimenClone.getAccessionNumber()); |
|
307 |
assertEquals(catalogNumber, specimenClone.getCatalogNumber()); |
|
308 |
assertEquals(collection, specimenClone.getCollection()); |
|
309 |
assertEquals(derivedFrom, specimenClone.getDerivedFrom()); |
|
310 |
assertEquals(lifeStage, specimenClone.getLifeStage()); |
|
311 |
assertEquals(lsid, specimenClone.getLsid()); |
|
312 |
assertEquals(preservation, specimenClone.getPreservation()); |
|
313 |
assertEquals(protectedTitleCache, specimenClone.isProtectedTitleCache()); |
|
314 |
assertEquals(storedUnder, specimenClone.getStoredUnder()); |
|
315 |
assertEquals(sex, specimenClone.getSex()); |
|
316 |
assertEquals(titleCache, specimenClone.getTitleCache()); |
|
317 |
|
|
318 |
Annotation clonedAnnotation = specimenClone.getAnnotations().iterator().next(); |
|
319 |
assertFalse(annotation.equals(clonedAnnotation)); |
|
320 |
assertEquals(annotation.getText(), ((LanguageStringBase)specimenClone.getAnnotations().iterator().next()).getText() ); |
|
321 |
assertNotSame(annotation, specimenClone.getAnnotations().iterator().next() ); |
|
322 |
|
|
323 |
assertEquals(definition, specimenClone.getDefinition().get(Language.DEFAULT()).getText()); |
|
324 |
//TODO |
|
325 |
// assertNotSame(definition, specimenClone.getDefinition().getText(Language.DEFAULT())); |
|
326 |
|
|
327 |
assertEquals(derivationEvent, specimenClone.getDerivationEvents().iterator().next()); |
|
328 |
assertSame(derivationEvent, specimenClone.getDerivationEvents().iterator().next()); |
|
329 |
|
|
330 |
assertEquals(description, specimenClone.getDescriptions().iterator().next()); |
|
331 |
// TODO ? |
|
332 |
assertSame(description, specimenClone.getDescriptions().iterator().next()); |
|
333 |
|
|
334 |
assertEquals(determination, specimenClone.getDeterminations().iterator().next()); |
|
335 |
// TODO ? |
|
336 |
assertSame(determination, specimenClone.getDeterminations().iterator().next()); |
|
337 |
|
|
338 |
assertFalse(extension.equals(specimenClone.getExtensions().iterator().next())); |
|
339 |
assertEquals(extension.getValue(), ((Extension)specimenClone.getExtensions().iterator().next()).getValue()); |
|
340 |
assertNotSame(extension, specimenClone.getExtensions().iterator().next()); |
|
341 |
assertEquals(1, specimen.getExtensions().size()); |
|
342 |
|
|
343 |
assertFalse(marker.equals(specimenClone.getMarkers().iterator().next())); |
|
344 |
assertEquals(marker.getFlag(), ((Marker)specimenClone.getMarkers().iterator().next()).getFlag()); |
|
345 |
assertNotSame(marker, specimenClone.getMarkers().iterator().next()); |
|
346 |
assertEquals(1, specimenClone.getMarkers().size()); |
|
347 |
|
|
348 |
// assertEquals(media, specimenClone.getMedia().iterator().next()); #3597 |
|
349 |
assertEquals(right, specimenClone.getRights().iterator().next()); |
|
350 |
|
|
351 |
assertFalse(source.equals(specimenClone.getSources().iterator().next())); |
|
352 |
assertEquals(source.getId(), ((OriginalSourceBase)specimenClone.getSources().iterator().next()).getId()); |
|
353 |
assertNotSame(source, specimenClone.getSources().iterator().next()); |
|
354 |
assertEquals(1, specimenClone.getSources().size()); |
|
355 |
} |
|
356 |
} |
|
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.occurrence; |
|
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.assertNotSame; |
|
16 |
import static org.junit.Assert.assertNull; |
|
17 |
import static org.junit.Assert.assertSame; |
|
18 |
import static org.junit.Assert.assertTrue; |
|
19 |
|
|
20 |
import java.util.Calendar; |
|
21 |
import java.util.UUID; |
|
22 |
|
|
23 |
import org.apache.log4j.Logger; |
|
24 |
import org.joda.time.DateTime; |
|
25 |
import org.junit.Assert; |
|
26 |
import org.junit.Before; |
|
27 |
import org.junit.Test; |
|
28 |
import org.springframework.beans.BeanUtils; |
|
29 |
|
|
30 |
import com.ibm.lsid.MalformedLSIDException; |
|
31 |
|
|
32 |
import eu.etaxonomy.cdm.model.agent.Person; |
|
33 |
import eu.etaxonomy.cdm.model.common.Annotation; |
|
34 |
import eu.etaxonomy.cdm.model.common.DefinedTerm; |
|
35 |
import eu.etaxonomy.cdm.model.common.Extension; |
|
36 |
import eu.etaxonomy.cdm.model.common.IdentifiableSource; |
|
37 |
import eu.etaxonomy.cdm.model.common.LSID; |
|
38 |
import eu.etaxonomy.cdm.model.common.Language; |
|
39 |
import eu.etaxonomy.cdm.model.common.LanguageStringBase; |
|
40 |
import eu.etaxonomy.cdm.model.common.Marker; |
|
41 |
import eu.etaxonomy.cdm.model.common.MarkerType; |
|
42 |
import eu.etaxonomy.cdm.model.common.OriginalSourceBase; |
|
43 |
import eu.etaxonomy.cdm.model.description.SpecimenDescription; |
|
44 |
import eu.etaxonomy.cdm.model.media.Media; |
|
45 |
import eu.etaxonomy.cdm.model.media.Rights; |
|
46 |
import eu.etaxonomy.cdm.model.molecular.DnaSample; |
|
47 |
import eu.etaxonomy.cdm.model.name.BotanicalName; |
|
48 |
import eu.etaxonomy.cdm.model.name.Rank; |
|
49 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
|
50 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
|
51 |
|
|
52 |
/** |
|
53 |
* @author a.mueller |
|
54 |
* @created 28.10.2008 |
|
55 |
*/ |
|
56 |
public class SpecimenTest { |
|
57 |
private static final Logger logger = Logger.getLogger(SpecimenTest.class); |
|
58 |
|
|
59 |
private DerivedUnit specimen; |
|
60 |
|
|
61 |
@Before |
|
62 |
public void setUp() throws Exception { |
|
63 |
specimen = DerivedUnit.NewPreservedSpecimenInstance(); |
|
64 |
} |
|
65 |
|
|
66 |
/** |
|
67 |
* Test method for {@link eu.etaxonomy.cdm.model.occurrence.Specimen#NewInstance()}. |
|
68 |
*/ |
|
69 |
@Test |
|
70 |
public void testNewInstance() { |
|
71 |
DerivedUnit specimen = DerivedUnit.NewPreservedSpecimenInstance(); |
|
72 |
assertNotNull(specimen); |
|
73 |
assertTrue(specimen instanceof DerivedUnit); |
|
74 |
assertTrue(specimen.getRecordBasis().equals(SpecimenOrObservationType.PreservedSpecimen)); |
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* Test method for {@link eu.etaxonomy.cdm.model.occurrence.Specimen#getPreservation()} and |
|
79 |
* {@link eu.etaxonomy.cdm.model.occurrence.Specimen#setPreservation(eu.etaxonomy.cdm.model.occurrence.PreservationMethod)}. |
|
80 |
*/ |
|
81 |
@Test |
|
82 |
public void testGetSetPreservation() { |
|
83 |
PreservationMethod preservation = PreservationMethod.NewInstance(); |
|
84 |
specimen.setPreservation(preservation); |
|
85 |
assertSame(preservation, specimen.getPreservation()); |
|
86 |
specimen.setPreservation(null); |
|
87 |
} |
|
88 |
|
|
89 |
@Test |
|
90 |
public void testBidirectionalSpecimenDescription(){ |
|
91 |
Assert.assertNotNull("Specimen should exist", specimen); |
|
92 |
|
|
93 |
SpecimenDescription desc = SpecimenDescription.NewInstance(specimen); |
|
94 |
Assert.assertNotNull("Description should exist.", desc); |
|
95 |
Assert.assertSame("Descriptions specimen should be set correctly", desc.getDescribedSpecimenOrObservation(),specimen); |
|
96 |
Assert.assertTrue("Specimen should contain description", specimen.getDescriptions().contains(desc)); |
|
97 |
|
|
98 |
SpecimenDescription desc2 = SpecimenDescription.NewInstance(); |
|
99 |
Assert.assertNotNull("Description should exist.", desc2); |
|
100 |
specimen.addDescription(desc2); |
|
101 |
Assert.assertSame("Description2 specimen should be set correctly", desc2.getDescribedSpecimenOrObservation(),specimen); |
|
102 |
Assert.assertSame("Descriptions specimen should still be set correctly", desc.getDescribedSpecimenOrObservation(),specimen); |
|
103 |
Assert.assertTrue("Specimen should contain description2", specimen.getDescriptions().contains(desc2)); |
|
104 |
Assert.assertTrue("Specimen should still contain description", specimen.getDescriptions().contains(desc)); |
|
105 |
|
|
106 |
SpecimenDescription desc3 = SpecimenDescription.NewInstance(); |
|
107 |
Assert.assertNotNull("Description should exist.", desc3); |
|
108 |
desc3.setDescribedSpecimenOrObservation(specimen); |
|
109 |
Assert.assertSame("Description3 specimen should be set correctly", desc3.getDescribedSpecimenOrObservation(),specimen); |
|
110 |
Assert.assertSame("Descriptions2 specimen should still be set correctly", desc2.getDescribedSpecimenOrObservation(),specimen); |
|
111 |
Assert.assertSame("Descriptions specimen should still be set correctly", desc.getDescribedSpecimenOrObservation(),specimen); |
|
112 |
Assert.assertTrue("Specimen should contain description3", specimen.getDescriptions().contains(desc3)); |
|
113 |
Assert.assertTrue("Specimen should still contain description2", specimen.getDescriptions().contains(desc2)); |
|
114 |
Assert.assertTrue("Specimen should still contain description", specimen.getDescriptions().contains(desc)); |
|
115 |
|
|
116 |
|
|
117 |
//change specimen of a given description |
|
118 |
DerivedUnit specimen2 = DerivedUnit.NewPreservedSpecimenInstance(); |
|
119 |
Assert.assertNotNull("Specimen should exist.", specimen2); |
|
120 |
desc3.setDescribedSpecimenOrObservation(specimen2); |
|
121 |
Assert.assertSame("Description3 new specimen should be set correctly", desc3.getDescribedSpecimenOrObservation(),specimen2); |
|
122 |
Assert.assertSame("Descriptions2 specimen should still be set correctly", desc2.getDescribedSpecimenOrObservation(),specimen); |
|
123 |
Assert.assertSame("Descriptions specimen should still be set correctly", desc.getDescribedSpecimenOrObservation(),specimen); |
|
124 |
Assert.assertTrue("Specimen2 should contain description3", specimen2.getDescriptions().contains(desc3)); |
|
125 |
Assert.assertEquals("Specimen2 should contain exactly 1 description", 1, specimen2.getDescriptions().size()); |
|
126 |
Assert.assertFalse("Specimen should no longer contain description3", specimen.getDescriptions().contains(desc3)); |
|
127 |
Assert.assertTrue("Specimen should still contain description2", specimen.getDescriptions().contains(desc2)); |
|
128 |
Assert.assertTrue("Specimen should still contain description", specimen.getDescriptions().contains(desc)); |
|
129 |
|
|
130 |
//remove description which is not contained |
|
131 |
specimen.removeDescription(desc3); |
|
132 |
Assert.assertSame("Nothing should have changed", desc3.getDescribedSpecimenOrObservation(),specimen2); |
|
133 |
Assert.assertSame("Nothing should have changed", desc2.getDescribedSpecimenOrObservation(),specimen); |
|
134 |
Assert.assertSame("Nothing should have changed", desc.getDescribedSpecimenOrObservation(),specimen); |
|
135 |
Assert.assertTrue("Nothing should have changed", specimen2.getDescriptions().contains(desc3)); |
|
136 |
Assert.assertEquals("Nothing should have changed", 1, specimen2.getDescriptions().size()); |
|
137 |
Assert.assertFalse("Nothing should have changed", specimen.getDescriptions().contains(desc3)); |
|
138 |
Assert.assertTrue("Nothing should have changed", specimen.getDescriptions().contains(desc2)); |
|
139 |
Assert.assertTrue("Nothing should have changed", specimen.getDescriptions().contains(desc)); |
|
140 |
|
|
141 |
//remove description |
|
142 |
specimen.removeDescription(desc2); |
|
143 |
Assert.assertNull("Descriptions2 specimen should not exist anymore", desc2.getDescribedSpecimenOrObservation()); |
|
144 |
Assert.assertSame("Description3 specimen should still be set correctly", desc3.getDescribedSpecimenOrObservation(),specimen2); |
|
145 |
Assert.assertSame("Descriptions specimen should still be set correctly", desc.getDescribedSpecimenOrObservation(),specimen); |
|
146 |
Assert.assertTrue("Specimen2 should still contain description3", specimen2.getDescriptions().contains(desc3)); |
|
147 |
Assert.assertEquals("Specimen2 should still contain exactly 1 description", 1, specimen2.getDescriptions().size()); |
|
148 |
Assert.assertFalse("Specimen should not contain description2 anymore", specimen.getDescriptions().contains(desc2)); |
|
149 |
Assert.assertFalse("Specimen should still no longer contain description3", specimen.getDescriptions().contains(desc3)); |
|
150 |
Assert.assertTrue("Specimen should still contain description", specimen.getDescriptions().contains(desc)); |
|
151 |
|
|
152 |
//remove description by setting null specimen |
|
153 |
desc3.setDescribedSpecimenOrObservation(null); |
|
154 |
Assert.assertNull("Description3 specimen should not exist anymore", desc3.getDescribedSpecimenOrObservation()); |
|
155 |
Assert.assertNull("Descriptions2 specimen should still not exist anymore", desc2.getDescribedSpecimenOrObservation()); |
|
156 |
Assert.assertSame("Descriptions specimen should still be set correctly", desc.getDescribedSpecimenOrObservation(),specimen); |
|
157 |
Assert.assertFalse("Specimen2 should not contain description3 anymore", specimen2.getDescriptions().contains(desc3)); |
|
158 |
Assert.assertEquals("Specimen2 should contain no description now", 0, specimen2.getDescriptions().size()); |
|
159 |
Assert.assertFalse("Specimen should still no longer contain description2", specimen.getDescriptions().contains(desc2)); |
|
160 |
Assert.assertFalse("Specimen should still no longer contain description3", specimen.getDescriptions().contains(desc3)); |
|
161 |
Assert.assertTrue("Specimen should still contain description", specimen.getDescriptions().contains(desc)); |
|
162 |
|
|
163 |
|
|
164 |
} |
|
165 |
|
|
166 |
|
|
167 |
@Test |
|
168 |
public void testBidirectionalTypeDesignation(){ |
|
169 |
SpecimenTypeDesignation desig1 = SpecimenTypeDesignation.NewInstance(); |
|
170 |
SpecimenTypeDesignation desig2 = SpecimenTypeDesignation.NewInstance(); |
|
171 |
DerivedUnit specimen2 = DerivedUnit.NewPreservedSpecimenInstance(); |
|
172 |
|
|
173 |
specimen.addSpecimenTypeDesignation(desig1); |
|
174 |
Assert.assertEquals("Specimen1 should be the designations specimen", specimen, desig1.getTypeSpecimen()); |
|
175 |
Assert.assertEquals("specimen1 should have exactly 1 designation", 1, specimen.getSpecimenTypeDesignations().size()); |
|
176 |
Assert.assertEquals("specimen1's designation should be desig1", desig1, specimen.getSpecimenTypeDesignations().iterator().next()); |
|
177 |
|
|
178 |
specimen.addSpecimenTypeDesignation(desig2); |
|
179 |
Assert.assertEquals("Specimen1 should be the desig2's specimen", specimen, desig2.getTypeSpecimen()); |
|
180 |
Assert.assertEquals("specimen1 should have exactly 2 designation", 2, specimen.getSpecimenTypeDesignations().size()); |
|
181 |
|
|
182 |
specimen2.addSpecimenTypeDesignation(desig2); |
|
183 |
Assert.assertEquals("Specimen2 should have replaced specimen1 as desig2's specimen", specimen2, desig2.getTypeSpecimen()); |
|
184 |
Assert.assertEquals("Specimen2 should have exactly 1 designation", 1, specimen2.getSpecimenTypeDesignations().size()); |
|
185 |
Assert.assertEquals("Specimen1's designation should be desig2", desig2, specimen2.getSpecimenTypeDesignations().iterator().next()); |
|
186 |
Assert.assertEquals("specimen1 should have exactly 1 designation", 1, specimen.getSpecimenTypeDesignations().size()); |
|
187 |
|
|
188 |
specimen2.removeSpecimenTypeDesignation(desig2); |
|
189 |
Assert.assertEquals("Desig2 should not have a specimen anymore", null, desig2.getTypeSpecimen()); |
|
190 |
Assert.assertEquals("Specimen2 should have no designation", 0, specimen2.getSpecimenTypeDesignations().size()); |
|
191 |
Assert.assertEquals("specimen1 should have exactly 1 designation", 1, specimen.getSpecimenTypeDesignations().size()); |
|
192 |
|
|
193 |
specimen.addSpecimenTypeDesignation(desig2); |
|
194 |
Assert.assertEquals("Specimen1 should be the desig2's specimen", specimen, desig2.getTypeSpecimen()); |
|
195 |
Assert.assertEquals("specimen1 should have exactly 2 designation", 2, specimen.getSpecimenTypeDesignations().size()); |
|
196 |
|
|
197 |
desig1.setTypeSpecimen(null); |
|
198 |
Assert.assertEquals("Desig1 should not have a specimen anymore", null, desig1.getTypeSpecimen()); |
|
199 |
Assert.assertEquals("Specimen1 should have 1 designation", 1, specimen.getSpecimenTypeDesignations().size()); |
|
200 |
Assert.assertEquals("Specimen1's designation should be desig2", desig2, specimen.getSpecimenTypeDesignations().iterator().next()); |
|
201 |
|
|
202 |
desig1.setTypeSpecimen(specimen); |
|
203 |
Assert.assertEquals("Desig1 should have specimen1 as specimen again", specimen, desig1.getTypeSpecimen()); |
|
204 |
Assert.assertEquals("Specimen1 should have 2 designation", 2, specimen.getSpecimenTypeDesignations().size()); |
|
205 |
|
|
206 |
} |
|
207 |
|
|
208 |
|
|
209 |
/** |
|
210 |
* Test method for {@link eu.etaxonomy.cdm.model.occurrence.Specimen#clone()}. |
|
211 |
*/ |
|
212 |
@Test |
|
213 |
public void testClone() { |
|
214 |
logger.debug("Start testClone"); |
|
215 |
|
|
216 |
//Null test is not full implemented, but an error is thrown if null throws |
|
217 |
//null pointer exception somewhere |
|
218 |
DerivedUnit specimenNullClone = (DerivedUnit)specimen.clone(); |
|
219 |
|
|
220 |
String accessionNumber = "accNumber"; |
|
221 |
String catalogNumber = "catNumber"; |
|
222 |
Collection collection = Collection.NewInstance(); |
|
223 |
collection.setCode("code"); |
|
224 |
DateTime created = new DateTime(); |
|
225 |
Person createdBy = Person.NewTitledInstance("creator"); |
|
226 |
DerivationEvent derivedFrom = DerivationEvent.NewInstance(null); |
|
227 |
int id = 22; |
|
228 |
int individualCount = 25; |
|
229 |
DefinedTerm lifeStage = DefinedTerm.NewStageInstance(null, null, null); |
|
230 |
LSID lsid = null; |
|
231 |
try { |
|
232 |
lsid = new LSID("urn:lsid:example.com:foo:1"); |
|
233 |
} catch (MalformedLSIDException e) { |
|
234 |
// TODO Auto-generated catch block |
|
235 |
e.printStackTrace(); |
|
236 |
} |
|
237 |
DerivedUnit nextVersion = DerivedUnit.NewPreservedSpecimenInstance(); |
|
238 |
DerivedUnit previousVersion = DerivedUnit.NewPreservedSpecimenInstance(); |
|
239 |
PreservationMethod preservation = PreservationMethod.NewInstance(); |
|
240 |
boolean protectedTitleCache = true; |
|
241 |
DefinedTerm sex = DefinedTerm.SEX_FEMALE(); |
|
242 |
TaxonNameBase<?, ?> storedUnder = BotanicalName.NewInstance(Rank.GENUS()); |
|
243 |
String titleCache = "title"; |
|
244 |
Calendar updated = Calendar.getInstance(); |
|
245 |
Person updatedBy = Person.NewTitledInstance("updatedPerson"); |
|
246 |
UUID uuid = UUID.randomUUID(); |
|
247 |
|
|
248 |
Annotation annotation = Annotation.NewDefaultLanguageInstance("annotation"); |
|
249 |
String definition = "definition"; |
|
250 |
//TODO |
|
251 |
DerivationEvent derivationEvent = DerivationEvent.NewInstance(null); |
|
252 |
SpecimenDescription description = SpecimenDescription.NewInstance(); |
|
253 |
DeterminationEvent determination = DeterminationEvent.NewInstance(); |
|
254 |
Extension extension = Extension.NewInstance(); |
|
255 |
extension.setValue("extension"); |
|
256 |
Marker marker = Marker.NewInstance(MarkerType.COMPLETE(), false); |
|
257 |
Rights right = Rights.NewInstance("right", Language.DEFAULT()); |
|
258 |
Media media = Media.NewInstance(); |
|
259 |
IdentifiableSource source = IdentifiableSource.NewDataImportInstance("12", "idNamespace"); |
|
260 |
|
|
261 |
specimen.setAccessionNumber(accessionNumber); |
|
262 |
specimen.setCatalogNumber(catalogNumber); |
|
263 |
specimen.setCollection(collection); |
|
264 |
specimen.setCreated(created); |
|
265 |
// specimen.setCreatedBy(createdBy); |
|
266 |
specimen.setDerivedFrom(derivedFrom); |
|
267 |
specimen.setId(id); |
|
268 |
specimen.setIndividualCount(individualCount); |
|
269 |
specimen.setLifeStage(lifeStage); |
|
270 |
specimen.setLsid(lsid); |
|
271 |
specimen.setPreservation(preservation); |
|
272 |
specimen.setProtectedTitleCache(protectedTitleCache); |
|
273 |
specimen.setSex(sex); |
|
274 |
specimen.setStoredUnder(storedUnder); |
|
275 |
specimen.setTitleCache(titleCache, protectedTitleCache); |
|
276 |
// specimen.setUpdated(updated); |
|
277 |
// specimen.setUpdatedBy(updatedBy); |
|
278 |
specimen.setUuid(uuid); |
|
279 |
|
|
280 |
specimen.addAnnotation(annotation); |
|
281 |
specimen.putDefinition(Language.DEFAULT(), definition); |
|
282 |
specimen.addDerivationEvent(derivationEvent); |
|
283 |
specimen.addDescription(description); |
|
284 |
specimen.addDetermination(determination); |
|
285 |
specimen.addExtension(extension); |
|
286 |
specimen.addMarker(marker); |
|
287 |
// specimen.addMedia(media); #3597 |
|
288 |
specimen.addRights(right); |
|
289 |
specimen.addSource(source); |
|
290 |
|
|
291 |
try { |
|
292 |
Thread.sleep(200); |
|
293 |
} catch (InterruptedException e) { |
|
294 |
//ignore |
|
295 |
} |
|
296 |
DerivedUnit specimenClone = (DerivedUnit)specimen.clone(); |
|
297 |
|
|
298 |
assertFalse(id == specimenClone.getId()); |
|
299 |
assertFalse(created.equals(specimenClone.getCreated())); |
|
300 |
assertFalse(createdBy.equals(specimenClone.getCreatedBy())); |
|
301 |
assertFalse(updated.equals(specimenClone.getUpdated())); |
|
302 |
assertFalse(updatedBy.equals(specimenClone.getUpdatedBy())); |
|
303 |
assertNull(specimenClone.getUpdatedBy()); |
|
304 |
assertNull(specimenClone.getCreatedBy()); |
|
305 |
assertFalse(uuid.equals(specimenClone.getUuid())); |
|
306 |
|
|
307 |
|
|
308 |
assertEquals(accessionNumber, specimenClone.getAccessionNumber()); |
|
309 |
assertEquals(catalogNumber, specimenClone.getCatalogNumber()); |
|
310 |
assertEquals(collection, specimenClone.getCollection()); |
|
311 |
assertEquals(derivedFrom, specimenClone.getDerivedFrom()); |
|
312 |
assertEquals(lifeStage, specimenClone.getLifeStage()); |
|
313 |
assertEquals(lsid, specimenClone.getLsid()); |
|
314 |
assertEquals(preservation, specimenClone.getPreservation()); |
|
315 |
assertEquals(protectedTitleCache, specimenClone.isProtectedTitleCache()); |
|
316 |
assertEquals(storedUnder, specimenClone.getStoredUnder()); |
|
317 |
assertEquals(sex, specimenClone.getSex()); |
|
318 |
assertEquals(titleCache, specimenClone.getTitleCache()); |
|
319 |
|
|
320 |
Annotation clonedAnnotation = specimenClone.getAnnotations().iterator().next(); |
|
321 |
assertFalse(annotation.equals(clonedAnnotation)); |
|
322 |
assertEquals(annotation.getText(), ((LanguageStringBase)specimenClone.getAnnotations().iterator().next()).getText() ); |
|
323 |
assertNotSame(annotation, specimenClone.getAnnotations().iterator().next() ); |
|
324 |
|
|
325 |
assertEquals(definition, specimenClone.getDefinition().get(Language.DEFAULT()).getText()); |
|
326 |
//TODO |
|
327 |
// assertNotSame(definition, specimenClone.getDefinition().getText(Language.DEFAULT())); |
|
328 |
|
|
329 |
assertEquals(derivationEvent, specimenClone.getDerivationEvents().iterator().next()); |
|
330 |
assertSame(derivationEvent, specimenClone.getDerivationEvents().iterator().next()); |
|
331 |
|
|
332 |
assertEquals(description, specimenClone.getDescriptions().iterator().next()); |
|
333 |
// TODO ? |
|
334 |
assertSame(description, specimenClone.getDescriptions().iterator().next()); |
|
335 |
|
|
336 |
assertEquals(determination, specimenClone.getDeterminations().iterator().next()); |
|
337 |
// TODO ? |
|
338 |
assertSame(determination, specimenClone.getDeterminations().iterator().next()); |
|
339 |
|
|
340 |
assertFalse(extension.equals(specimenClone.getExtensions().iterator().next())); |
|
341 |
assertEquals(extension.getValue(), specimenClone.getExtensions().iterator().next().getValue()); |
|
342 |
assertNotSame(extension, specimenClone.getExtensions().iterator().next()); |
|
343 |
assertEquals(1, specimen.getExtensions().size()); |
|
344 |
|
|
345 |
assertFalse(marker.equals(specimenClone.getMarkers().iterator().next())); |
|
346 |
assertEquals(marker.getFlag(), specimenClone.getMarkers().iterator().next().getFlag()); |
|
347 |
assertNotSame(marker, specimenClone.getMarkers().iterator().next()); |
|
348 |
assertEquals(1, specimenClone.getMarkers().size()); |
|
349 |
|
|
350 |
// assertEquals(media, specimenClone.getMedia().iterator().next()); #3597 |
|
351 |
assertEquals(right, specimenClone.getRights().iterator().next()); |
|
352 |
|
|
353 |
assertFalse(source.equals(specimenClone.getSources().iterator().next())); |
|
354 |
assertEquals(source.getId(), ((OriginalSourceBase)specimenClone.getSources().iterator().next()).getId()); |
|
355 |
assertNotSame(source, specimenClone.getSources().iterator().next()); |
|
356 |
assertEquals(1, specimenClone.getSources().size()); |
|
357 |
} |
|
358 |
|
|
359 |
|
|
360 |
@Test |
|
361 |
public void beanTests(){ |
|
362 |
// #5307 Test that BeanUtils does not fail |
|
363 |
BeanUtils.getPropertyDescriptors(DerivedUnit.class); |
|
364 |
BeanUtils.getPropertyDescriptors(SpecimenOrObservationBase.class); |
|
365 |
BeanUtils.getPropertyDescriptors(FieldUnit.class); |
|
366 |
BeanUtils.getPropertyDescriptors(MediaSpecimen.class); |
|
367 |
BeanUtils.getPropertyDescriptors(DnaSample.class); |
|
368 |
} |
|
369 |
} |
Also available in: Unified diff
Add some more BeanUtil test to other classes #5307