3 * Copyright (C) 2009 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.api
.facade
;
12 import java
.lang
.reflect
.Field
;
14 import java
.text
.ParseException
;
15 import java
.util
.HashSet
;
16 import java
.util
.List
;
17 import java
.util
.UUID
;
19 import org
.apache
.log4j
.Logger
;
20 import org
.junit
.Assert
;
21 import org
.junit
.Before
;
22 import org
.junit
.Ignore
;
23 import org
.junit
.Test
;
24 import org
.springframework
.security
.authentication
.UsernamePasswordAuthenticationToken
;
25 import org
.springframework
.security
.core
.context
.SecurityContextHolder
;
26 import org
.unitils
.dbunit
.annotation
.DataSet
;
27 import org
.unitils
.dbunit
.annotation
.ExpectedDataSet
;
28 import org
.unitils
.spring
.annotation
.SpringBeanByType
;
30 import eu
.etaxonomy
.cdm
.api
.service
.IOccurrenceService
;
31 import eu
.etaxonomy
.cdm
.api
.service
.ITermService
;
32 import eu
.etaxonomy
.cdm
.api
.service
.IUserService
;
33 import eu
.etaxonomy
.cdm
.common
.UTF8
;
34 import eu
.etaxonomy
.cdm
.model
.agent
.AgentBase
;
35 import eu
.etaxonomy
.cdm
.model
.agent
.Team
;
36 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTerm
;
37 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableSource
;
38 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
39 import eu
.etaxonomy
.cdm
.model
.common
.LanguageString
;
40 import eu
.etaxonomy
.cdm
.model
.common
.OriginalSourceType
;
41 import eu
.etaxonomy
.cdm
.model
.common
.TimePeriod
;
42 import eu
.etaxonomy
.cdm
.model
.common
.User
;
43 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
44 import eu
.etaxonomy
.cdm
.model
.description
.SpecimenDescription
;
45 import eu
.etaxonomy
.cdm
.model
.description
.TextData
;
46 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
47 import eu
.etaxonomy
.cdm
.model
.location
.Point
;
48 import eu
.etaxonomy
.cdm
.model
.location
.ReferenceSystem
;
49 import eu
.etaxonomy
.cdm
.model
.location
.Country
;
50 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
51 import eu
.etaxonomy
.cdm
.model
.name
.BotanicalName
;
52 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
53 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
54 import eu
.etaxonomy
.cdm
.model
.occurrence
.Collection
;
55 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivationEvent
;
56 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivationEventType
;
57 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
58 import eu
.etaxonomy
.cdm
.model
.occurrence
.DeterminationEvent
;
59 import eu
.etaxonomy
.cdm
.model
.occurrence
.FieldUnit
;
60 import eu
.etaxonomy
.cdm
.model
.occurrence
.GatheringEvent
;
61 import eu
.etaxonomy
.cdm
.model
.occurrence
.PreservationMethod
;
62 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationType
;
63 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
64 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
65 import eu
.etaxonomy
.cdm
.test
.integration
.CdmTransactionalIntegrationTest
;
75 public class DerivedUnitFacadeTest
extends CdmTransactionalIntegrationTest
{
76 private static final Logger logger
= Logger
.getLogger(DerivedUnitFacadeTest
.class);
79 private IOccurrenceService service
;
82 private ITermService termService
;
85 private IUserService userService
;
89 DerivationEvent derivationEvent
;
91 GatheringEvent gatheringEvent
;
92 Integer absoluteElevation
= 10;
93 Integer absoluteElevationMaximum
= 14;
94 AgentBase
<?
> collector
= Team
.NewInstance();
95 String collectingMethod
= "Collection Method";
96 Double distanceToGround
= 22.0;
97 Double distanceToSurface
= 0.3;
98 Double distanceToSurfaceMax
= 0.7;
100 ReferenceSystem referenceSystem
= ReferenceSystem
.WGS84();
101 Point exactLocation
= Point
.NewInstance(12.3, 10.567, referenceSystem
, 22);
102 String gatheringEventDescription
= "A nice gathering description";
103 TimePeriod gatheringPeriod
= TimePeriod
.NewInstance(1888, 1889);
105 String fieldNumber
= "15p23B";
106 String fieldNotes
= "such a beautiful specimen";
108 Integer individualCount
= 1;
109 DefinedTerm lifeStage
= DefinedTerm
.NewStageInstance("A wonderful stage", "stage", "st");
110 DefinedTerm sex
= DefinedTerm
.NewSexInstance("FemaleMale", "FM", "FM");
111 LanguageString locality
= LanguageString
.NewInstance("My locality",
114 String accessionNumber
= "888462535";
115 String catalogNumber
= "UU879873590";
116 TaxonNameBase
<?
,?
> taxonName
= BotanicalName
.NewInstance(Rank
.GENUS(), "Abies",
117 null, null, null, null, null, null, null);
118 String collectorsNumber
= "234589913A34";
119 Collection collection
= Collection
.NewInstance();
120 PreservationMethod preservationMethod
= PreservationMethod
.NewInstance(
121 "my prservation", null, null);
123 DerivedUnitFacade specimenFacade
;
125 DerivedUnit collectionSpecimen
;
126 GatheringEvent existingGatheringEvent
;
127 DerivationEvent firstDerivationEvent
;
128 FieldUnit firstFieldObject
;
129 Media media1
= Media
.NewInstance();
131 DerivedUnitFacade emptyFacade
;
133 NamedArea country
= Country
.GERMANY();
135 // ****************************** SET UP **********************************/
139 * @throws java.lang.Exception
142 public void setUp() throws Exception
{
144 specimen
= DerivedUnit
.NewPreservedSpecimenInstance();
146 derivationEvent
= DerivationEvent
.NewInstance(DerivationEventType
.ACCESSIONING());
147 specimen
.setDerivedFrom(derivationEvent
);
148 fieldUnit
= FieldUnit
.NewInstance();
149 fieldUnit
.addDerivationEvent(derivationEvent
);
150 gatheringEvent
= GatheringEvent
.NewInstance();
151 fieldUnit
.setGatheringEvent(gatheringEvent
);
152 gatheringEvent
.setAbsoluteElevation(absoluteElevation
);
153 gatheringEvent
.setAbsoluteElevationMax(absoluteElevationMaximum
);
154 gatheringEvent
.setActor(collector
);
155 gatheringEvent
.setCollectingMethod(collectingMethod
);
156 gatheringEvent
.setDistanceToGround(distanceToGround
);
157 gatheringEvent
.setDistanceToWaterSurface(distanceToSurface
);
158 gatheringEvent
.setDistanceToWaterSurfaceMax(distanceToSurfaceMax
);
159 gatheringEvent
.setExactLocation(exactLocation
);
160 gatheringEvent
.setDescription(gatheringEventDescription
);
161 gatheringEvent
.setCountry(country
);
163 gatheringEvent
.setTimeperiod(gatheringPeriod
);
164 gatheringEvent
.setLocality(locality
);
166 fieldUnit
.setFieldNumber(fieldNumber
);
167 fieldUnit
.setFieldNotes(fieldNotes
);
168 fieldUnit
.setIndividualCount(individualCount
);
169 fieldUnit
.setSex(sex
);
170 fieldUnit
.setLifeStage(lifeStage
);
172 specimen
.setAccessionNumber(accessionNumber
);
173 specimen
.setCatalogNumber(catalogNumber
);
174 specimen
.setStoredUnder(taxonName
);
175 specimen
.setCollection(collection
);
176 specimen
.setPreservation(preservationMethod
);
178 specimenFacade
= DerivedUnitFacade
.NewInstance(specimen
);
180 // existing specimen with 2 derivation events in line
181 collectionSpecimen
= DerivedUnit
.NewPreservedSpecimenInstance();
182 DerivedUnit middleSpecimen
= DerivedUnit
.NewPreservedSpecimenInstance();
183 firstFieldObject
= FieldUnit
.NewInstance();
185 //TODO maybe we should define concrete event types here
186 DerivationEvent lastDerivationEvent
= DerivationEvent
.NewInstance();
187 DerivationEvent middleDerivationEvent
= DerivationEvent
.NewInstance();
188 firstDerivationEvent
= DerivationEvent
.NewInstance();
190 collectionSpecimen
.setDerivedFrom(lastDerivationEvent
);
192 lastDerivationEvent
.addOriginal(middleSpecimen
);
193 middleSpecimen
.setDerivedFrom(firstDerivationEvent
);
194 firstDerivationEvent
.addOriginal(firstFieldObject
);
195 existingGatheringEvent
= GatheringEvent
.NewInstance();
196 firstFieldObject
.setGatheringEvent(existingGatheringEvent
);
199 emptyFacade
= DerivedUnitFacade
.NewInstance(SpecimenOrObservationType
.PreservedSpecimen
);
203 // ****************************** TESTS*****************************/
205 @Ignore //doesn't run in suite
207 @DataSet("DerivedUnitFacadeTest.testSetFieldObjectImageGallery.xml")
209 public void testSetFieldObjectImageGallery() {
210 UUID imageFeatureUuid
= Feature
.IMAGE().getUuid();
211 Feature imageFeature
= (Feature
) termService
.find(imageFeatureUuid
);
213 DerivedUnitFacade facade
= DerivedUnitFacade
.NewInstance(SpecimenOrObservationType
.PreservedSpecimen
);
214 facade
.innerDerivedUnit().setUuid(UUID
.fromString("77af784f-931b-4857-be9a-48ccf31ed3f1"));
215 facade
.setFieldNumber("12345");
216 Media media
= Media
.NewInstance(URI
.create("www.abc.de"), 200, null,"jpeg");
219 SpecimenDescription imageGallery
= SpecimenDescription
.NewInstance();
220 imageGallery
.setDescribedSpecimenOrObservation(facade
.innerFieldUnit());
221 imageGallery
.setImageGallery(true);
222 TextData textData
= TextData
.NewInstance();
223 textData
.setFeature(imageFeature
);
224 imageGallery
.addElement(textData
);
225 textData
.addMedia(media
);
226 facade
.setFieldObjectImageGallery(imageGallery
);
228 } catch (DerivedUnitFacadeNotSupportedException e1
) {
229 e1
.printStackTrace();
230 Assert
.fail(e1
.getLocalizedMessage());
232 this.service
.save(facade
.innerDerivedUnit());
234 setComplete(); endTransaction();
235 // try {if (true){printDataSet(System.out, new
236 // String[]{"HIBERNATE_SEQUENCES","SPECIMENOROBSERVATIONBASE","SPECIMENOROBSERVATIONBASE_DERIVATIONEVENT"
237 // ,"DERIVATIONEVENT",
238 // "DESCRIPTIONBASE","DESCRIPTIONELEMENTBASE","DESCRIPTIONELEMENTBASE_MEDIA",
239 // "MEDIA", "MEDIAREPRESENTATION","MEDIAREPRESENTATIONPART"});}
240 // } catch(Exception e) { logger.warn(e);}
246 // TODO generally works but has id problems when running together with above
247 // test ()setFieldObjectImageGallery. Therefore set to ignore.
248 @DataSet("DerivedUnitFacadeTest.testSetDerivedUnitImageGallery.xml")
250 public void testSetDerivedUnitImageGallery() {
251 // UUID specimenUUID =
252 // UUID.fromString("25383fc8-789b-4eff-92d3-a770d0622351");
253 // Specimen specimen = (Specimen)service.find(specimenUUID);
254 DerivedUnitFacade facade
= DerivedUnitFacade
.NewInstance(SpecimenOrObservationType
.PreservedSpecimen
);
255 Media media
= Media
.NewInstance(URI
.create("www.derivedUnitImage.de"),200, null, "png");
258 SpecimenDescription imageGallery
= SpecimenDescription
260 imageGallery
.setDescribedSpecimenOrObservation(facade
.innerDerivedUnit());
261 imageGallery
.setImageGallery(true);
262 TextData textData
= TextData
.NewInstance();
263 imageGallery
.addElement(textData
);
264 textData
.addMedia(media
);
265 facade
.setDerivedUnitImageGallery(imageGallery
);
267 } catch (DerivedUnitFacadeNotSupportedException e1
) {
268 e1
.printStackTrace();
269 Assert
.fail(e1
.getLocalizedMessage());
271 this.service
.save(facade
.innerDerivedUnit());
273 // setComplete(); endTransaction();
274 // try {if (true){printDataSet(System.out, new
275 // String[]{"HIBERNATE_SEQUENCES","SPECIMENOROBSERVATIONBASE","SPECIMENOROBSERVATIONBASE_DERIVATIONEVENT"
276 // ,"DERIVATIONEVENT",
277 // "DESCRIPTIONBASE","DESCRIPTIONELEMENTBASE","DESCRIPTIONELEMENTBASE_MEDIA",
278 // "MEDIA", "MEDIAREPRESENTATION","MEDIAREPRESENTATIONPART"});}
279 // } catch(Exception e) { logger.warn(e);}
286 @Ignore // TODO generally works causes has id problems with following tests when running in suite
287 public void testGetFieldObjectImageGalleryBooleanPersisted() {
288 UUID specimenUUID
= UUID
289 .fromString("25383fc8-789b-4eff-92d3-a770d0622351");
290 DerivedUnit specimen
= (DerivedUnit
) service
.load(specimenUUID
);
291 Assert
.assertNotNull("Specimen should exist (persisted)", specimen
);
293 DerivedUnitFacade facade
= DerivedUnitFacade
.NewInstance(specimen
);
294 SpecimenDescription imageGallery
= facade
.getFieldObjectImageGallery(true);
295 Assert
.assertNotNull("Image gallery should exist", imageGallery
);
296 Assert
.assertEquals("UUID should be equal to the persisted uuid",
297 UUID
.fromString("8cb772e9-1577-45c6-91ab-dbec1413c060"),
298 imageGallery
.getUuid());
299 Assert
.assertEquals("The image gallery should be flagged as such",true, imageGallery
.isImageGallery());
301 "There should be one TextData in image gallery", 1,
302 imageGallery
.getElements().size());
303 List
<Media
> media
= imageGallery
.getElements().iterator().next().getMedia();
304 Assert
.assertEquals("There should be 1 media", 1, media
.size());
305 } catch (DerivedUnitFacadeNotSupportedException e
) {
313 // @Ignore // TODO generally works causes has id problems with following tests when running in suite
314 public void testGetDerivedUnitImageGalleryBooleanPersisted() {
315 UUID specimenUUID
= UUID
.fromString("25383fc8-789b-4eff-92d3-a770d0622351");
316 DerivedUnit specimen
= (DerivedUnit
) service
.load(specimenUUID
);
317 Assert
.assertNotNull("Specimen should exist (persisted)", specimen
);
319 DerivedUnitFacade facade
= DerivedUnitFacade
.NewInstance(specimen
);
320 SpecimenDescription imageGallery
= facade
.getDerivedUnitImageGallery(true);
321 Assert
.assertNotNull("Image gallery should exist", imageGallery
);
322 Assert
.assertEquals("UUID should be equal to the persisted uuid",
323 UUID
.fromString("cb03acc4-8363-4020-aeef-ea8a8bcc0fe9"),
324 imageGallery
.getUuid());
325 Assert
.assertEquals("The image gallery should be flagged as such",
326 true, imageGallery
.isImageGallery());
328 "There should be one TextData in image gallery", 1,
329 imageGallery
.getElements().size());
330 List
<Media
> media
= imageGallery
.getElements().iterator().next().getMedia();
331 Assert
.assertEquals("There should be 1 media", 1, media
.size());
332 } catch (DerivedUnitFacadeNotSupportedException e
) {
339 public void testGetDerivedUnitImageGalleryBoolean() {
340 DerivedUnit specimen
= DerivedUnit
.NewPreservedSpecimenInstance();
342 DerivedUnitFacade facade
= DerivedUnitFacade
.NewInstance(specimen
);
343 SpecimenDescription imageGallery
= facade
.getDerivedUnitImageGallery(true);
344 Assert
.assertNotNull("Image Gallery should have been created",imageGallery
);
345 Assert
.assertEquals("The image gallery should be flagged as such",true, imageGallery
.isImageGallery());
346 } catch (DerivedUnitFacadeNotSupportedException e
) {
355 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#NewInstance()}.
358 public void testNewInstance() {
359 Assert
.assertNotNull("The specimen should have been created",
360 specimenFacade
.innerDerivedUnit());
362 // Assert.assertNotNull("The derivation event should have been created",
363 // specimenFacade.getSpecimen().getDerivedFrom());
364 // Assert.assertNotNull("The field unit should have been created",
365 // specimenFacade.getFieldUnit());
366 // Assert.assertNotNull("The gathering event should have been created",
367 // specimenFacade.getGatheringEvent());
372 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#NewInstance(eu.etaxonomy.cdm.model.occurrence.Specimen)}
376 public void testNewInstanceSpecimen() {
377 Assert
.assertSame("Specimen should be same", specimen
,
378 specimenFacade
.innerDerivedUnit());
379 Assert
.assertSame("Derivation event should be same", derivationEvent
,
380 specimenFacade
.innerDerivedUnit().getDerivedFrom());
381 Assert
.assertSame("Field unit should be same", fieldUnit
,
382 specimenFacade
.innerFieldUnit());
383 Assert
.assertSame("Gathering event should be same", gatheringEvent
,
384 specimenFacade
.innerGatheringEvent());
389 public void testGatheringEventIsConnectedToDerivedUnit() {
390 DerivedUnit specimen
= DerivedUnit
.NewPreservedSpecimenInstance();
391 DerivedUnitFacade specimenFacade
;
393 specimenFacade
= DerivedUnitFacade
.NewInstance(specimen
);
394 specimenFacade
.setDistanceToGround(2.0);
395 FieldUnit specimenFieldUnit
= (FieldUnit
) specimen
.getDerivedFrom().getOriginals().iterator().next();
397 "Facade gathering event and specimen gathering event should be the same",
398 specimenFacade
.innerGatheringEvent(),
399 specimenFieldUnit
.getGatheringEvent());
400 } catch (DerivedUnitFacadeNotSupportedException e
) {
401 Assert
.fail("An error should not occur in NewInstance()");
406 public void testNoGatheringEventAndFieldUnit() {
407 DerivedUnit specimen
= DerivedUnit
.NewPreservedSpecimenInstance();
408 DerivedUnitFacade specimenFacade
;
410 specimenFacade
= DerivedUnitFacade
.NewInstance(specimen
);
411 Assert
.assertNull("No field unit should exists",
412 specimenFacade
.innerFieldUnit());
413 } catch (DerivedUnitFacadeNotSupportedException e
) {
414 Assert
.fail("An error should not occur in NewInstance()");
419 public void testInititializeTextDataWithSupportTest() {
421 DerivedUnit specimen
= DerivedUnit
.NewPreservedSpecimenInstance();
422 DerivedUnitFacade specimenFacade
;
424 specimenFacade
= DerivedUnitFacade
.NewInstance(specimen
);
425 specimenFacade
.setEcology("Ecology");
426 String plantDescription
= specimenFacade
.getPlantDescription();
428 "No plantDescription should exist yet and no NPE should be thrown until now",
430 } catch (DerivedUnitFacadeNotSupportedException e
) {
431 Assert
.fail("An error should not occur in NewInstance()");
436 public void testGetSetCountry() {
437 logger
.warn("Not yet implemented");
442 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#addCollectingArea(eu.etaxonomy.cdm.model.location.NamedArea)}
446 public void testAddGetRemoveCollectingArea() {
447 String tdwgLabel
= "GER";
448 NamedArea tdwgArea
= termService
.getAreaByTdwgAbbreviation(tdwgLabel
);
449 NamedArea newCollectingArea
= NamedArea
.NewInstance("A nice area",
451 specimenFacade
.addCollectingArea(newCollectingArea
);
452 Assert
.assertEquals("Exactly 1 area must exist", 1, specimenFacade
453 .getCollectingAreas().size());
454 Assert
.assertSame("Areas should be same", newCollectingArea
,
455 specimenFacade
.innerFieldUnit().getGatheringEvent()
456 .getCollectingAreas().iterator().next());
457 specimenFacade
.addCollectingArea(tdwgArea
);
458 Assert
.assertEquals("Exactly 2 areas must exist", 2, specimenFacade
459 .getCollectingAreas().size());
460 specimenFacade
.removeCollectingArea(newCollectingArea
);
461 Assert
.assertEquals("Exactly 1 area must exist", 1, specimenFacade
462 .getCollectingAreas().size());
463 NamedArea remainingArea
= specimenFacade
.getCollectingAreas()
465 Assert
.assertEquals("Areas should be same", tdwgArea
, remainingArea
);
466 specimenFacade
.removeCollectingArea(tdwgArea
);
467 Assert
.assertEquals("No area should remain", 0, specimenFacade
468 .getCollectingAreas().size());
473 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#addCollectingArea(eu.etaxonomy.cdm.model.location.NamedArea)}
477 public void testAddCollectingAreas() {
478 NamedArea firstArea
= NamedArea
.NewInstance("A nice area", "nice", "n");
479 Assert
.assertEquals("No area must exist", 0, specimenFacade
.getCollectingAreas().size());
480 specimenFacade
.addCollectingArea(firstArea
);
481 Assert
.assertEquals("Exactly 1 area must exist", 1, specimenFacade
.getCollectingAreas().size());
483 String tdwgLabel
= "GER";
484 NamedArea tdwgArea
= termService
.getAreaByTdwgAbbreviation(tdwgLabel
);
485 NamedArea secondArea
= NamedArea
.NewInstance("A nice area", "nice", "n");
487 java
.util
.Collection
<NamedArea
> areaCollection
= new HashSet
<NamedArea
>();
488 areaCollection
.add(secondArea
);
489 areaCollection
.add(tdwgArea
);
490 specimenFacade
.addCollectingAreas(areaCollection
);
491 Assert
.assertEquals("Exactly 3 areas must exist", 3, specimenFacade
492 .getCollectingAreas().size());
497 * Test method for getting and setting absolute elevation.
498 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getAbsoluteElevation()}
502 public void testGetSetAbsoluteElevation() {
503 Assert
.assertEquals("Absolute elevation must be same",absoluteElevation
, specimenFacade
.getAbsoluteElevation());
504 specimenFacade
.setAbsoluteElevation(400);
505 Assert
.assertEquals("Absolute elevation must be 400",Integer
.valueOf(400), specimenFacade
.getAbsoluteElevation());
510 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getAbsoluteElevationError()}
514 public void testGetSetAbsoluteElevationMaximum() {
515 Assert
.assertEquals("Absolute elevation must be same",absoluteElevation
, specimenFacade
.getAbsoluteElevation());
516 Assert
.assertEquals("Absolute elevation maximum must be same",absoluteElevationMaximum
, specimenFacade
.getAbsoluteElevationMaximum());
517 specimenFacade
.setAbsoluteElevationMax(4);
518 Assert
.assertEquals("Absolute elevation maximum must be 4", Integer
.valueOf(4), specimenFacade
.getAbsoluteElevationMaximum());
519 Assert
.assertEquals("Absolute elevation must be same",absoluteElevation
, specimenFacade
.getAbsoluteElevation());
524 public void testGetSetAbsoluteElevationRange() {
525 Assert
.assertEquals("", absoluteElevation
, specimenFacade
.getAbsoluteElevation());
526 Assert
.assertEquals("", absoluteElevationMaximum
,specimenFacade
.getAbsoluteElevationMaximum());
528 specimenFacade
.setAbsoluteElevationRange(30, 36);
529 Assert
.assertEquals("", Integer
.valueOf(36),specimenFacade
.getAbsoluteElevationMaximum());
530 Assert
.assertEquals("", Integer
.valueOf(30),specimenFacade
.getAbsoluteElevation());
531 Assert
.assertEquals("", "30" + UTF8
.EN_DASH_SPATIUM
+ "36",specimenFacade
.absoluteElevationToString());
532 Assert
.assertEquals("", null,specimenFacade
.getAbsoluteElevationText());
534 specimenFacade
.setAbsoluteElevationRange(30, 35);
535 Assert
.assertEquals("Odd range should not throw an exception anymore", String
.format("30%s35", UTF8
.EN_DASH_SPATIUM
),specimenFacade
.absoluteElevationToString());
537 specimenFacade
.setAbsoluteElevationRange(41, null);
538 Assert
.assertEquals("", null,specimenFacade
.getAbsoluteElevationMaximum());
539 Assert
.assertEquals("", Integer
.valueOf(41),specimenFacade
.getAbsoluteElevation());
540 Assert
.assertEquals("", Integer
.valueOf(41),specimenFacade
.getAbsoluteElevation());
541 Assert
.assertNull("", specimenFacade
.getAbsoluteElevationText());
542 Assert
.assertEquals("", "41",specimenFacade
.absoluteElevationToString());
544 specimenFacade
.setAbsoluteElevationRange(null, null);
545 Assert
.assertNull("", specimenFacade
.getAbsoluteElevation());
546 Assert
.assertNull("", specimenFacade
.getAbsoluteElevationMaximum());
547 Assert
.assertNull("", specimenFacade
.absoluteElevationToString());
552 public void testGetSetAbsoluteElevationText() {
553 Assert
.assertEquals("", absoluteElevation
, specimenFacade
.getAbsoluteElevation());
554 Assert
.assertEquals("", absoluteElevationMaximum
,specimenFacade
.getAbsoluteElevationMaximum());
555 Assert
.assertEquals("", null,specimenFacade
.getAbsoluteElevationText());
557 String elevText
= "approx. 30 - 35";
558 specimenFacade
.setAbsoluteElevationText(elevText
);
559 Assert
.assertEquals("", absoluteElevation
, specimenFacade
.getAbsoluteElevation());
560 Assert
.assertEquals("", absoluteElevationMaximum
,specimenFacade
.getAbsoluteElevationMaximum());
561 Assert
.assertEquals("", elevText
,specimenFacade
.absoluteElevationToString());
563 specimenFacade
.setAbsoluteElevationRange(30, 35);
564 Assert
.assertEquals("ToString should not change by setting range if text is set", elevText
,specimenFacade
.absoluteElevationToString());
565 Assert
.assertEquals("", Integer
.valueOf(30), specimenFacade
.getAbsoluteElevation());
566 Assert
.assertEquals("", Integer
.valueOf(35),specimenFacade
.getAbsoluteElevationMaximum());
569 specimenFacade
.setAbsoluteElevationRange(41, null);
570 Assert
.assertEquals("ToString should not change by setting range if text is set", elevText
,specimenFacade
.absoluteElevationToString());
571 Assert
.assertEquals("", Integer
.valueOf(41), specimenFacade
.getAbsoluteElevation());
572 Assert
.assertEquals("", null,specimenFacade
.getAbsoluteElevationMaximum());
575 specimenFacade
.setAbsoluteElevationText(null);
576 Assert
.assertNull("", specimenFacade
.getAbsoluteElevationText());
577 Assert
.assertEquals("ToString should change by setting text to null", "41",specimenFacade
.absoluteElevationToString());
578 Assert
.assertEquals("", Integer
.valueOf(41), specimenFacade
.getAbsoluteElevation());
579 Assert
.assertEquals("", null,specimenFacade
.getAbsoluteElevationMaximum());
586 public void testGetSetCollector() {
587 Assert
.assertNotNull("Collector must not be null",
588 specimenFacade
.getCollector());
589 Assert
.assertEquals("Collector must be same", collector
,
590 specimenFacade
.getCollector());
591 specimenFacade
.setCollector(null);
592 Assert
.assertNull("Collector must be null",
593 specimenFacade
.getCollector());
598 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getCollectingMethod()}
602 public void testGetSetCollectingMethod() {
603 Assert
.assertEquals("Collecting method must be same", collectingMethod
,
604 specimenFacade
.getCollectingMethod());
605 specimenFacade
.setCollectingMethod("new method");
606 Assert
.assertEquals("Collecting method must be 'new method'",
607 "new method", specimenFacade
.getCollectingMethod());
612 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getDistanceToGround()}
616 public void testGetSetDistanceToGround() {
617 Assert
.assertEquals("Distance to ground must be same",distanceToGround
, specimenFacade
.getDistanceToGround());
618 specimenFacade
.setDistanceToGround(5.0);
619 Assert
.assertEquals("Distance to ground must be 5", Double
.valueOf(5), specimenFacade
.getDistanceToGround());
624 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getDistanceToWaterSurface()}
628 public void testGetDistanceToWaterSurface() {
629 Assert
.assertEquals("Distance to surface must be same", distanceToSurface
, specimenFacade
.getDistanceToWaterSurface());
630 specimenFacade
.setDistanceToWaterSurface(6.0);
631 Assert
.assertEquals("Distance to surface must be 6", Double
.valueOf(6), specimenFacade
.getDistanceToWaterSurface());
632 // empty facade tests
633 Assert
.assertNull("Empty facace must not have any gathering values", emptyFacade
.getDistanceToWaterSurface());
634 emptyFacade
.setDistanceToWaterSurface(13.0);
635 Assert
.assertNotNull("Field unit must exist if distance to water exists", emptyFacade
.getFieldUnit(false));
636 Assert
.assertNotNull("Gathering event must exist if distance to water exists", emptyFacade
.getGatheringEvent(false));
637 FieldUnit specimenFieldUnit
= (FieldUnit
) emptyFacade
638 .innerDerivedUnit().getDerivedFrom().getOriginals().iterator().next();
639 Assert
.assertSame("Gathering event of facade and of specimen must be the same",
640 specimenFieldUnit
.getGatheringEvent(), emptyFacade
.getGatheringEvent(false));
644 public void testGetSetDistanceToWaterText() {
645 Assert
.assertEquals("", distanceToSurface
, specimenFacade
.getDistanceToWaterSurface());
646 Assert
.assertEquals("", distanceToSurfaceMax
,specimenFacade
.getDistanceToWaterSurfaceMax());
647 Assert
.assertEquals("", null,specimenFacade
.getDistanceToWaterSurfaceText());
649 String distText
= "approx. 0.3 - 0.6";
650 specimenFacade
.setDistanceToWaterSurfaceText(distText
);
651 Assert
.assertEquals("", distanceToSurface
, specimenFacade
.getDistanceToWaterSurface());
652 Assert
.assertEquals("", distanceToSurfaceMax
,specimenFacade
.getDistanceToWaterSurfaceMax());
653 Assert
.assertEquals("", distText
,specimenFacade
.distanceToWaterSurfaceToString());
655 specimenFacade
.setDistanceToWaterSurfaceRange(0.6, 1.4);
656 Assert
.assertEquals("ToString should not change by setting range if text is set", distText
,specimenFacade
.distanceToWaterSurfaceToString());
657 Assert
.assertEquals("", Double
.valueOf(0.6), specimenFacade
.getDistanceToWaterSurface());
658 Assert
.assertEquals("", Double
.valueOf(1.4),specimenFacade
.getDistanceToWaterSurfaceMax());
660 specimenFacade
.setDistanceToWaterSurfaceRange(41.2, null);
661 Assert
.assertEquals("ToString should not change by setting range if text is set", distText
,specimenFacade
.distanceToWaterSurfaceToString());
662 Assert
.assertEquals("", Double
.valueOf(41.2), specimenFacade
.getDistanceToWaterSurface());
663 Assert
.assertEquals("", null,specimenFacade
.getDistanceToWaterSurfaceMax());
665 specimenFacade
.setDistanceToWaterSurfaceText(null);
666 Assert
.assertNull("", specimenFacade
.getDistanceToWaterSurfaceText());
667 Assert
.assertEquals("ToString should change by setting text to null", "41.2",specimenFacade
.distanceToWaterSurfaceToString());
668 Assert
.assertEquals("", Double
.valueOf(41.2), specimenFacade
.getDistanceToWaterSurface());
669 Assert
.assertEquals("", null,specimenFacade
.getDistanceToWaterSurfaceMax());
675 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getExactLocation()}.
678 public void testGetSetExactLocation() {
679 Assert
.assertNotNull("Exact location must not be null",
680 specimenFacade
.getExactLocation());
681 Assert
.assertEquals("Exact location must be same", exactLocation
,
682 specimenFacade
.getExactLocation());
683 specimenFacade
.setExactLocation(null);
684 Assert
.assertNull("Exact location must be null",
685 specimenFacade
.getExactLocation());
689 public void testSetExactLocationByParsing() {
692 specimenFacade
.setExactLocationByParsing("112\u00B034'20\"W",
693 "34\u00B030,34'N", null, null);
694 point1
= specimenFacade
.getExactLocation();
695 Assert
.assertNotNull("", point1
.getLatitude());
696 System
.out
.println(point1
.getLatitude().toString());
697 Assert
.assertTrue("",
698 point1
.getLatitude().toString().startsWith("34.505"));
699 System
.out
.println(point1
.getLongitude().toString());
700 Assert
.assertTrue("",
701 point1
.getLongitude().toString().startsWith("-112.5722"));
703 } catch (ParseException e
) {
704 Assert
.fail("No parsing error should occur");
710 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getGatheringEventDescription()}
714 public void testGetSetGatheringEventDescription() {
715 Assert
.assertEquals("Gathering event description must be same",
716 gatheringEventDescription
,
717 specimenFacade
.getGatheringEventDescription());
718 specimenFacade
.setGatheringEventDescription("new description");
720 "Gathering event description must be 'new description' now",
722 specimenFacade
.getGatheringEventDescription());
727 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getTimeperiod()}.
730 public void testGetTimeperiod() {
731 Assert
.assertNotNull("Gathering period must not be null", specimenFacade
.getGatheringPeriod());
732 Assert
.assertFalse("Gathering period must not be empty", specimenFacade
.getGatheringPeriod().isEmpty());
733 Assert
.assertEquals("Gathering period must be same", gatheringPeriod
, specimenFacade
.getGatheringPeriod());
734 specimenFacade
.setGatheringPeriod(null);
735 Assert
.assertTrue("Gathering period must be null", specimenFacade
.getGatheringPeriod().isEmpty());
739 public void testHasFieldObject() throws SecurityException
,
740 NoSuchFieldException
, IllegalArgumentException
,
741 IllegalAccessException
{
742 // this test depends on the current implementation of SpecimenFacade. In
744 // field unit may not be initialized from the beginning. Than the
746 // assert should be set to assertNull
747 Assert
.assertTrue("field object should not be null (depends on specimen facade initialization !!)",
748 specimenFacade
.hasFieldObject());
750 Field fieldUnitField
= DerivedUnitFacade
.class
751 .getDeclaredField("fieldUnit");
752 fieldUnitField
.setAccessible(true);
753 fieldUnitField
.set(specimenFacade
, null);
754 Assert
.assertFalse("The field unit should be null now",
755 specimenFacade
.hasFieldObject());
757 specimenFacade
.setDistanceToGround(33.0);
759 "The field unit should have been created again",
760 specimenFacade
.hasFieldObject());
765 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#addFieldObjectDefinition(java.lang.String, eu.etaxonomy.cdm.model.common.Language)}
769 public void testAddGetRemoveFieldObjectDefinition() {
770 Assert
.assertEquals("There should be no definition yet", 0,
771 specimenFacade
.getFieldObjectDefinition().size());
772 specimenFacade
.addFieldObjectDefinition("Tres interesant",
774 Assert
.assertEquals("There should be exactly one definition", 1,
775 specimenFacade
.getFieldObjectDefinition().size());
777 "The French definition should be 'Tres interesant'",
778 "Tres interesant", specimenFacade
.getFieldObjectDefinition()
779 .get(Language
.FRENCH()).getText());
781 "The French definition should be 'Tres interesant'",
783 specimenFacade
.getFieldObjectDefinition(Language
.FRENCH()));
784 specimenFacade
.addFieldObjectDefinition("Sehr interessant",
786 Assert
.assertEquals("There should be exactly 2 definition", 2,
787 specimenFacade
.getFieldObjectDefinition().size());
788 specimenFacade
.removeFieldObjectDefinition(Language
.FRENCH());
789 Assert
.assertEquals("There should remain exactly 1 definition", 1,
790 specimenFacade
.getFieldObjectDefinition().size());
792 "The remaining German definition should be 'Sehr interessant'",
794 specimenFacade
.getFieldObjectDefinition(Language
.GERMAN()));
795 specimenFacade
.removeFieldObjectDefinition(Language
.GERMAN());
796 Assert
.assertEquals("There should remain no definition", 0,
797 specimenFacade
.getFieldObjectDefinition().size());
802 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#addFieldObjectMedia(eu.etaxonomy.cdm.model.media.Media)}
806 public void testAddGetHasRemoveFieldObjectMedia() {
807 Assert
.assertFalse("There should be no image gallery yet",
808 specimenFacade
.hasFieldObjectImageGallery());
809 Assert
.assertFalse("There should be no specimen image gallery either",
810 specimenFacade
.hasDerivedUnitImageGallery());
812 List
<Media
> media
= specimenFacade
.getFieldObjectMedia();
813 Assert
.assertFalse("There should still not be an image gallery now",
814 specimenFacade
.hasFieldObjectImageGallery());
815 Assert
.assertEquals("There should be no media yet in the gallery", 0,
818 Media media1
= Media
.NewInstance();
819 specimenFacade
.addFieldObjectMedia(media1
);
820 Assert
.assertEquals("There should be exactly one specimen media", 1,
821 specimenFacade
.getFieldObjectMedia().size());
822 Assert
.assertEquals("The only media should be media 1", media1
,
823 specimenFacade
.getFieldObjectMedia().get(0));
825 "There should still no specimen image gallery exist",
826 specimenFacade
.hasDerivedUnitImageGallery());
828 Media media2
= Media
.NewInstance();
829 specimenFacade
.addFieldObjectMedia(media2
);
830 Assert
.assertEquals("There should be exactly 2 specimen media", 2,
831 specimenFacade
.getFieldObjectMedia().size());
832 Assert
.assertEquals("The first media should be media1", media1
,
833 specimenFacade
.getFieldObjectMedia().get(0));
834 Assert
.assertEquals("The second media should be media2", media2
,
835 specimenFacade
.getFieldObjectMedia().get(1));
837 specimenFacade
.removeFieldObjectMedia(media1
);
838 Assert
.assertEquals("There should be exactly one specimen media", 1,
839 specimenFacade
.getFieldObjectMedia().size());
840 Assert
.assertEquals("The only media should be media2", media2
,
841 specimenFacade
.getFieldObjectMedia().get(0));
843 specimenFacade
.removeFieldObjectMedia(media1
);
844 Assert
.assertEquals("There should still be exactly one specimen media",
845 1, specimenFacade
.getFieldObjectMedia().size());
847 specimenFacade
.removeFieldObjectMedia(media2
);
848 Assert
.assertEquals("There should remain no media in the gallery", 0,
855 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#addFieldObjectMedia(eu.etaxonomy.cdm.model.media.Media)}
859 public void testGetSetEcology() {
860 Assert
.assertNotNull(
861 "An empty ecology data should be created when calling getEcology()",
862 specimenFacade
.getEcologyAll());
864 "An empty ecology data should be created when calling getEcology()",
865 0, specimenFacade
.getEcologyAll().size());
866 specimenFacade
.setEcology("Tres jolie ici", Language
.FRENCH());
867 Assert
.assertEquals("Ecology data should exist for 1 language", 1,
868 specimenFacade
.getEcologyAll().size());
870 "Ecology data should be 'Tres jolie ici' for French",
871 "Tres jolie ici", specimenFacade
.getEcology(Language
.FRENCH()));
873 "Ecology data should be null for the default language",
874 specimenFacade
.getEcology());
875 specimenFacade
.setEcology("Nice here");
876 Assert
.assertEquals("Ecology data should exist for 2 languages", 2,
877 specimenFacade
.getEcologyAll().size());
878 Assert
.assertEquals("Ecology data should be 'Tres jolie ici'",
879 "Tres jolie ici", specimenFacade
.getEcology(Language
.FRENCH()));
881 "Ecology data should be 'Nice here' for the default language",
882 "Nice here", specimenFacade
.getEcology());
883 Assert
.assertEquals("Ecology data should be 'Nice here' for english",
884 "Nice here", specimenFacade
.getEcology());
886 specimenFacade
.setEcology("Vert et rouge", Language
.FRENCH());
887 Assert
.assertEquals("Ecology data should exist for 2 languages", 2,
888 specimenFacade
.getEcologyAll().size());
889 Assert
.assertEquals("Ecology data should be 'Vert et rouge'",
890 "Vert et rouge", specimenFacade
.getEcology(Language
.FRENCH()));
892 "Ecology data should be 'Nice here' for the default language",
893 "Nice here", specimenFacade
.getEcology());
895 specimenFacade
.setEcology(null, Language
.FRENCH());
896 Assert
.assertEquals("Ecology data should exist for 1 languages", 1,
897 specimenFacade
.getEcologyAll().size());
899 "Ecology data should be 'Nice here' for the default language",
900 "Nice here", specimenFacade
.getEcology());
901 Assert
.assertNull("Ecology data should be 'null' for French",
902 specimenFacade
.getEcology(Language
.FRENCH()));
904 specimenFacade
.removeEcology(null);
905 Assert
.assertEquals("There should be no ecology left", 0,
906 specimenFacade
.getEcologyAll().size());
907 Assert
.assertNull("Ecology data should be 'null' for default language",
908 specimenFacade
.getEcology());
914 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#addFieldObjectMedia(eu.etaxonomy.cdm.model.media.Media)}
918 public void testGetSetPlantDescription() {
919 Assert
.assertNotNull(
920 "An empty plant description data should be created when calling getPlantDescriptionAll()",
921 specimenFacade
.getPlantDescriptionAll());
923 "An empty plant description data should be created when calling getPlantDescription()",
924 0, specimenFacade
.getPlantDescriptionAll().size());
925 specimenFacade
.setPlantDescription("bleu", Language
.FRENCH());
927 "Plant description data should exist for 1 language", 1,
928 specimenFacade
.getPlantDescriptionAll().size());
930 "Plant description data should be 'bleu' for French", "bleu",
931 specimenFacade
.getPlantDescription(Language
.FRENCH()));
933 "Plant description data should be null for the default language",
934 specimenFacade
.getPlantDescription());
935 specimenFacade
.setPlantDescription("Nice here");
937 "Plant description data should exist for 2 languages", 2,
938 specimenFacade
.getPlantDescriptionAll().size());
939 Assert
.assertEquals("Plant description data should be 'bleu'", "bleu",
940 specimenFacade
.getPlantDescription(Language
.FRENCH()));
942 "Plant description data should be 'Nice here' for the default language",
943 "Nice here", specimenFacade
.getPlantDescription());
945 "Plant description data should be 'Nice here' for english",
946 "Nice here", specimenFacade
.getPlantDescription());
948 specimenFacade
.setPlantDescription("Vert et rouge", Language
.FRENCH());
950 "Plant description data should exist for 2 languages", 2,
951 specimenFacade
.getPlantDescriptionAll().size());
952 Assert
.assertEquals("Plant description data should be 'Vert et rouge'",
954 specimenFacade
.getPlantDescription(Language
.FRENCH()));
956 "Plant description data should be 'Nice here' for the default language",
957 "Nice here", specimenFacade
.getPlantDescription());
959 specimenFacade
.setPlantDescription(null, Language
.FRENCH());
961 "Plant description data should exist for 1 languages", 1,
962 specimenFacade
.getPlantDescriptionAll().size());
964 "Plant description data should be 'Nice here' for the default language",
965 "Nice here", specimenFacade
.getPlantDescription());
966 Assert
.assertNull("Plant description data should be 'null' for French",
967 specimenFacade
.getPlantDescription(Language
.FRENCH()));
969 // test interference with ecology
970 specimenFacade
.setEcology("Tres jolie ici", Language
.FRENCH());
971 Assert
.assertEquals("Ecology data should exist for 1 language", 1,
972 specimenFacade
.getEcologyAll().size());
974 "Ecology data should be 'Tres jolie ici' for French",
975 "Tres jolie ici", specimenFacade
.getEcology(Language
.FRENCH()));
977 "Ecology data should be null for the default language",
978 specimenFacade
.getEcology());
982 "Plant description data should exist for 1 languages", 1,
983 specimenFacade
.getPlantDescriptionAll().size());
985 "Plant description data should be 'Nice here' for the default language",
986 "Nice here", specimenFacade
.getPlantDescription());
987 Assert
.assertNull("Plant description data should be 'null' for French",
988 specimenFacade
.getPlantDescription(Language
.FRENCH()));
990 specimenFacade
.removePlantDescription(null);
991 Assert
.assertEquals("There should be no plant description left", 0,
992 specimenFacade
.getPlantDescriptionAll().size());
994 "Plant description data should be 'null' for default language",
995 specimenFacade
.getPlantDescription());
1001 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getFieldNumber()}.
1004 public void testGetSetFieldNumber() {
1005 Assert
.assertEquals("Field number must be same", fieldNumber
,
1006 specimenFacade
.getFieldNumber());
1007 specimenFacade
.setFieldNumber("564AB");
1008 Assert
.assertEquals("New field number must be '564AB'", "564AB",
1009 specimenFacade
.getFieldNumber());
1010 // empty facade tests
1011 Assert
.assertNull("Empty facace must not have any field value",
1012 emptyFacade
.getFieldNumber());
1013 emptyFacade
.setFieldNumber("1256A");
1014 Assert
.assertNotNull(
1015 "Field unit must exist if field number exists",
1016 emptyFacade
.getFieldUnit(false));
1017 FieldUnit specimenFieldUnit
= (FieldUnit
) emptyFacade
1018 .innerDerivedUnit().getDerivedFrom().getOriginals().iterator()
1021 "Field unit of facade and of specimen must be the same",
1023 emptyFacade
.getFieldUnit(false));
1024 Assert
.assertEquals("1256A", emptyFacade
.getFieldNumber());
1029 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getFieldNotes()}.
1032 public void testGetSetFieldNotes() {
1033 Assert
.assertEquals("Field notes must be same", fieldNotes
,
1034 specimenFacade
.getFieldNotes());
1035 specimenFacade
.setFieldNotes("A completely new info");
1036 Assert
.assertEquals("New field note must be 'A completely new info'",
1037 "A completely new info", specimenFacade
.getFieldNotes());
1042 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#setGatheringEvent(eu.etaxonomy.cdm.model.occurrence.GatheringEvent)}
1046 @Ignore // #######DerivationEvent ---------------------------------------- 1
1047 public void testSetGatheringEvent() {
1048 GatheringEvent newGatheringEvent
= GatheringEvent
.NewInstance();
1049 newGatheringEvent
.setDistanceToGround(43.0);
1050 Assert
.assertFalse("The initial distance to ground should not be 43",
1051 specimenFacade
.getDistanceToGround() == 43.0);
1052 specimenFacade
.setGatheringEvent(newGatheringEvent
);
1053 Assert
.assertTrue("The final distance to ground should be 43",
1054 specimenFacade
.getDistanceToGround() == 43.0);
1056 "The new gathering event should be 'newGatheringEvent'",
1057 newGatheringEvent
, specimenFacade
.innerGatheringEvent());
1062 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#innerGatheringEvent()}
1066 public void testGetGatheringEvent() {
1067 Assert
.assertNotNull("Gathering event must not be null",
1068 specimenFacade
.innerGatheringEvent());
1069 Assert
.assertEquals(
1070 "Gathering event must be field unit's gathering event",
1071 specimenFacade
.innerFieldUnit().getGatheringEvent(),
1072 specimenFacade
.innerGatheringEvent());
1077 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getIndividualCount()}
1081 public void testGetSetIndividualCount() {
1082 Assert
.assertEquals("Individual count must be same", individualCount
,
1083 specimenFacade
.getIndividualCount());
1084 specimenFacade
.setIndividualCount(4);
1085 Assert
.assertEquals("New individual count must be '4'",
1086 Integer
.valueOf(4), specimenFacade
.getIndividualCount());
1092 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getLifeStage()}.
1095 public void testGetSetLifeStage() {
1096 Assert
.assertNotNull("Life stage must not be null",
1097 specimenFacade
.getLifeStage());
1098 Assert
.assertEquals("Life stage must be same", lifeStage
,
1099 specimenFacade
.getLifeStage());
1100 specimenFacade
.setLifeStage(null);
1101 Assert
.assertNull("Life stage must be null",
1102 specimenFacade
.getLifeStage());
1107 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getSex()}.
1110 public void testGetSetSex() {
1111 Assert
.assertNotNull("Sex must not be null", specimenFacade
.getSex());
1112 Assert
.assertEquals("Sex must be same", sex
, specimenFacade
.getSex());
1113 specimenFacade
.setSex(null);
1114 Assert
.assertNull("Sex must be null", specimenFacade
.getSex());
1119 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getLocality()}.
1122 public void testGetSetLocality() {
1123 Assert
.assertEquals("Locality must be same", locality
,
1124 specimenFacade
.getLocality());
1125 specimenFacade
.setLocality("A completely new place", Language
.FRENCH());
1126 Assert
.assertEquals("New locality must be 'A completely new place'",
1127 "A completely new place", specimenFacade
.getLocalityText());
1128 Assert
.assertEquals("New locality language must be French",
1129 Language
.FRENCH(), specimenFacade
.getLocalityLanguage());
1130 specimenFacade
.setLocality("Another place");
1131 Assert
.assertEquals("New locality must be 'Another place'",
1132 "Another place", specimenFacade
.getLocalityText());
1133 Assert
.assertEquals("New locality language must be default",
1134 Language
.DEFAULT(), specimenFacade
.getLocalityLanguage());
1139 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#addDerivedUnitDefinition(java.lang.String, eu.etaxonomy.cdm.model.common.Language)}
1143 public void testAddGetRemoveSpecimenDefinition() {
1144 Assert
.assertEquals("There should be no definition yet", 0,
1145 specimenFacade
.getDerivedUnitDefinitions().size());
1146 specimenFacade
.addDerivedUnitDefinition("Tres interesant",
1148 Assert
.assertEquals("There should be exactly one definition", 1,
1149 specimenFacade
.getDerivedUnitDefinitions().size());
1150 Assert
.assertEquals(
1151 "The French definition should be 'Tres interesant'",
1152 "Tres interesant", specimenFacade
.getDerivedUnitDefinitions()
1153 .get(Language
.FRENCH()).getText());
1154 Assert
.assertEquals(
1155 "The French definition should be 'Tres interesant'",
1157 specimenFacade
.getDerivedUnitDefinition(Language
.FRENCH()));
1158 specimenFacade
.addDerivedUnitDefinition("Sehr interessant",
1160 Assert
.assertEquals("There should be exactly 2 definition", 2,
1161 specimenFacade
.getDerivedUnitDefinitions().size());
1162 specimenFacade
.removeDerivedUnitDefinition(Language
.FRENCH());
1163 Assert
.assertEquals("There should remain exactly 1 definition", 1,
1164 specimenFacade
.getDerivedUnitDefinitions().size());
1165 Assert
.assertEquals(
1166 "The remaining German definition should be 'Sehr interessant'",
1168 specimenFacade
.getDerivedUnitDefinition(Language
.GERMAN()));
1169 specimenFacade
.removeDerivedUnitDefinition(Language
.GERMAN());
1170 Assert
.assertEquals("There should remain no definition", 0,
1171 specimenFacade
.getDerivedUnitDefinitions().size());
1176 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#addDetermination(eu.etaxonomy.cdm.model.occurrence.DeterminationEvent)}
1180 public void testAddGetRemoveDetermination() {
1181 Assert
.assertEquals("There should be no determination yet", 0,
1182 specimenFacade
.getDeterminations().size());
1183 DeterminationEvent determinationEvent1
= DeterminationEvent
1185 specimenFacade
.addDetermination(determinationEvent1
);
1186 Assert
.assertEquals("There should be exactly one determination", 1,
1187 specimenFacade
.getDeterminations().size());
1188 Assert
.assertEquals("The only determination should be determination 1",
1189 determinationEvent1
, specimenFacade
.getDeterminations()
1190 .iterator().next());
1192 DeterminationEvent determinationEvent2
= DeterminationEvent
1194 specimenFacade
.addDetermination(determinationEvent2
);
1195 Assert
.assertEquals("There should be exactly 2 determinations", 2,
1196 specimenFacade
.getDeterminations().size());
1197 specimenFacade
.removeDetermination(determinationEvent1
);
1199 Assert
.assertEquals("There should remain exactly 1 determination", 1,
1200 specimenFacade
.getDeterminations().size());
1201 Assert
.assertEquals(
1202 "The remaining determinations should be determination 2",
1203 determinationEvent2
, specimenFacade
.getDeterminations()
1204 .iterator().next());
1206 specimenFacade
.removeDetermination(determinationEvent1
);
1207 Assert
.assertEquals("There should remain exactly 1 determination", 1,
1208 specimenFacade
.getDeterminations().size());
1210 specimenFacade
.removeDetermination(determinationEvent2
);
1211 Assert
.assertEquals("There should remain no definition", 0,
1212 specimenFacade
.getDerivedUnitDefinitions().size());
1219 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#addDetermination(eu.etaxonomy.cdm.model.occurrence.DeterminationEvent)}
1223 public void testPreferredOtherDeterminations() {
1224 Assert
.assertEquals("There should be no determination yet", 0,
1225 specimenFacade
.getDeterminations().size());
1226 DeterminationEvent determinationEvent1
= DeterminationEvent
.NewInstance();
1227 specimenFacade
.setPreferredDetermination(determinationEvent1
);
1229 Assert
.assertEquals("There should be exactly one determination", 1,
1230 specimenFacade
.getDeterminations().size());
1231 Assert
.assertEquals("The only determination should be determination 1",
1232 determinationEvent1
, specimenFacade
.getDeterminations()
1233 .iterator().next());
1234 Assert
.assertEquals("determination 1 should be the preferred determination",
1235 determinationEvent1
, specimenFacade
.getPreferredDetermination());
1236 Assert
.assertEquals("There should be no 'non preferred' determination", 0,
1237 specimenFacade
.getOtherDeterminations().size());
1241 DeterminationEvent determinationEvent2
= DeterminationEvent
.NewInstance();
1242 specimenFacade
.addDetermination(determinationEvent2
);
1243 Assert
.assertEquals("There should be exactly 2 determinations", 2,
1244 specimenFacade
.getDeterminations().size());
1245 Assert
.assertEquals("determination 1 should be the preferred determination",
1246 determinationEvent1
, specimenFacade
.getPreferredDetermination());
1247 Assert
.assertEquals("There should be one 'non preferred' determination", 1,
1248 specimenFacade
.getOtherDeterminations().size());
1249 Assert
.assertEquals("The only 'non preferred' determination should be determination 2",
1250 determinationEvent2
, specimenFacade
.getOtherDeterminations().iterator().next());
1253 DeterminationEvent determinationEvent3
= DeterminationEvent
.NewInstance();
1254 specimenFacade
.setPreferredDetermination(determinationEvent3
);
1255 Assert
.assertEquals("There should be exactly 3 determinations", 3,
1256 specimenFacade
.getDeterminations().size());
1257 Assert
.assertEquals("determination 3 should be the preferred determination",
1258 determinationEvent3
, specimenFacade
.getPreferredDetermination());
1259 Assert
.assertEquals("There should be 2 'non preferred' determination", 2,
1260 specimenFacade
.getOtherDeterminations().size());
1261 Assert
.assertTrue("determination 1 should be contained in the set of 'non preferred' determinations",
1262 specimenFacade
.getOtherDeterminations().contains(determinationEvent1
));
1263 Assert
.assertTrue("determination 2 should be contained in the set of 'non preferred' determinations",
1264 specimenFacade
.getOtherDeterminations().contains(determinationEvent2
));
1270 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#addDerivedUnitMedia(eu.etaxonomy.cdm.model.media.Media)}
1274 public void testAddGetHasRemoveSpecimenMedia() {
1275 Assert
.assertFalse("There should be no image gallery yet",
1276 specimenFacade
.hasDerivedUnitImageGallery());
1278 "There should be also no field object image gallery yet",
1279 specimenFacade
.hasFieldObjectImageGallery());
1281 List
<Media
> media
= specimenFacade
.getDerivedUnitMedia();
1283 "There should still not be an empty image gallery now",
1284 specimenFacade
.hasDerivedUnitImageGallery());
1285 Assert
.assertEquals("There should be no media yet in the gallery", 0,
1288 Media media1
= Media
.NewInstance();
1289 specimenFacade
.addDerivedUnitMedia(media1
);
1290 Assert
.assertEquals("There should be exactly one specimen media", 1,
1291 specimenFacade
.getDerivedUnitMedia().size());
1292 Assert
.assertEquals("The only media should be media 1", media1
,
1293 specimenFacade
.getDerivedUnitMedia().get(0));
1295 "There should be still no field object image gallery",
1296 specimenFacade
.hasFieldObjectImageGallery());
1298 Media media2
= Media
.NewInstance();
1299 specimenFacade
.addDerivedUnitMedia(media2
);
1300 Assert
.assertEquals("There should be exactly 2 specimen media", 2,
1301 specimenFacade
.getDerivedUnitMedia().size());
1302 Assert
.assertEquals("The first media should be media1", media1
,
1303 specimenFacade
.getDerivedUnitMedia().get(0));
1304 Assert
.assertEquals("The second media should be media2", media2
,
1305 specimenFacade
.getDerivedUnitMedia().get(1));
1307 specimenFacade
.removeDerivedUnitMedia(media1
);
1308 Assert
.assertEquals("There should be exactly one specimen media", 1,
1309 specimenFacade
.getDerivedUnitMedia().size());
1310 Assert
.assertEquals("The only media should be media2", media2
,
1311 specimenFacade
.getDerivedUnitMedia().get(0));
1313 specimenFacade
.removeDerivedUnitMedia(media1
);
1314 Assert
.assertEquals("There should still be exactly one specimen media",
1315 1, specimenFacade
.getDerivedUnitMedia().size());
1317 specimenFacade
.removeDerivedUnitMedia(media2
);
1318 Assert
.assertEquals("There should remain no media in the gallery", 0,
1324 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getAccessionNumber()}
1328 public void testGetSetAccessionNumber() {
1329 Assert
.assertEquals("Accession number must be same", accessionNumber
,
1330 specimenFacade
.getAccessionNumber());
1331 specimenFacade
.setAccessionNumber("A12345693");
1332 Assert
.assertEquals("New accession number must be 'A12345693'",
1333 "A12345693", specimenFacade
.getAccessionNumber());
1338 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getCatalogNumber()}.
1341 public void testGetCatalogNumber() {
1342 Assert
.assertEquals("Catalog number must be same", catalogNumber
,
1343 specimenFacade
.getCatalogNumber());
1344 specimenFacade
.setCatalogNumber("B12345693");
1345 Assert
.assertEquals("New catalog number must be 'B12345693'",
1346 "B12345693", specimenFacade
.getCatalogNumber());
1351 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getPreservation()}.
1354 public void testGetPreservation() {
1356 Assert
.assertNotNull("Preservation method must not be null",
1357 specimenFacade
.getPreservationMethod());
1358 Assert
.assertEquals("Preservation method must be same",
1359 preservationMethod
, specimenFacade
.getPreservationMethod());
1360 specimenFacade
.setPreservationMethod(null);
1361 Assert
.assertNull("Preservation method must be null",
1362 specimenFacade
.getPreservationMethod());
1363 } catch (MethodNotSupportedByDerivedUnitTypeException e
) {
1364 Assert
.fail("Method not supported should not be thrown for a specimen");
1366 specimenFacade
= DerivedUnitFacade
.NewInstance(SpecimenOrObservationType
.Observation
);
1368 specimenFacade
.setPreservationMethod(preservationMethod
);
1369 Assert
.fail("Method not supported should be thrown for an observation on set preservation method");
1371 } catch (MethodNotSupportedByDerivedUnitTypeException e
) {
1374 specimenFacade
= DerivedUnitFacade
.NewInstance(SpecimenOrObservationType
.LivingSpecimen
);
1376 specimenFacade
.getPreservationMethod();
1377 Assert
.fail("Method not supported should be thrown for a living being on get preservation method");
1378 } catch (MethodNotSupportedByDerivedUnitTypeException e
) {
1386 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getStoredUnder()}.
1389 public void testGetStoredUnder() {
1390 Assert
.assertNotNull("Stored under name must not be null",
1391 specimenFacade
.getStoredUnder());
1392 Assert
.assertEquals("Stored under name must be same", taxonName
,
1393 specimenFacade
.getStoredUnder());
1394 specimenFacade
.setStoredUnder(null);
1395 Assert
.assertNull("Stored under name must be null",
1396 specimenFacade
.getStoredUnder());
1400 // * Test method for
1401 // * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getCollectorsNumber()}
1405 // public void testGetSetCollectorsNumber() {
1406 // Assert.assertEquals("Collectors number must be same", collectorsNumber,
1407 // specimenFacade.getCollectorsNumber());
1408 // specimenFacade.setCollectorsNumber("C12345693");
1409 // Assert.assertEquals("New collectors number must be 'C12345693'",
1410 // "C12345693", specimenFacade.getCollectorsNumber());
1415 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getTitleCache()}.
1418 public void testGetTitleCache() {
1419 Assert
.assertNotNull(
1420 "The title cache should never return null if not protected",
1421 specimenFacade
.getTitleCache());
1422 specimenFacade
.setTitleCache(null, false);
1423 Assert
.assertNotNull(
1424 "The title cache should never return null if not protected",
1425 specimenFacade
.getTitleCache());
1430 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#setTitleCache(java.lang.String)}
1434 public void testSetTitleCache() {
1435 String testTitle
= "Absdwk aksjlf";
1436 specimenFacade
.setTitleCache(testTitle
, true);
1437 Assert
.assertEquals(
1438 "Protected title cache should returns the test title",
1439 testTitle
, specimenFacade
.getTitleCache());
1440 specimenFacade
.setTitleCache(testTitle
, false);
1442 "Unprotected title cache should not return the test title",
1443 testTitle
.equals(specimenFacade
.getTitleCache()));
1448 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#innerDerivedUnit()}.
1451 public void testGetSpecimen() {
1452 Assert
.assertEquals("Specimen must be same", specimen
,
1453 specimenFacade
.innerDerivedUnit());
1458 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getCollection()}.
1461 public void testGetSetCollection() {
1462 Assert
.assertNotNull("Collection must not be null",
1463 specimenFacade
.getCollection());
1464 Assert
.assertEquals("Collection must be same", collection
,
1465 specimenFacade
.getCollection());
1466 specimenFacade
.setCollection(null);
1467 Assert
.assertNull("Collection must be null",
1468 specimenFacade
.getCollection());
1472 public void testAddGetRemoveSource() {
1473 Assert
.assertEquals("No sources should exist yet", 0, specimenFacade
.getSources().size());
1475 Reference
<?
> reference
= ReferenceFactory
.newBook();
1476 IdentifiableSource source1
= specimenFacade
.addSource(OriginalSourceType
.PrimaryTaxonomicSource
, reference
, "54", "myName");
1477 Assert
.assertEquals("One source should exist now", 1, specimenFacade
.getSources().size());
1478 IdentifiableSource source2
= IdentifiableSource
.NewDataImportInstance("1", "myTable");
1479 specimenFacade
.addSource(source2
);
1480 Assert
.assertEquals("One source should exist now", 2, specimenFacade
.getSources().size());
1481 specimenFacade
.removeSource(source1
);
1482 Assert
.assertEquals("One source should exist now", 1, specimenFacade
.getSources().size());
1483 Reference
<?
> reference2
= ReferenceFactory
.newJournal();
1484 IdentifiableSource sourceNotUsed
= specimenFacade
.addSource(OriginalSourceType
.PrimaryTaxonomicSource
, reference2
,null, null);
1485 specimenFacade
.removeSource(sourceNotUsed
);
1486 Assert
.assertEquals("One source should still exist", 1, specimenFacade
.getSources().size());
1487 Assert
.assertEquals("1", specimenFacade
.getSources().iterator().next().getIdInSource());
1488 specimenFacade
.removeSource(source2
);
1489 Assert
.assertEquals("No sources should exist anymore", 0,specimenFacade
.getSources().size());
1493 public void testAddGetRemoveDuplicate() {
1494 Assert
.assertEquals("No duplicates should be available yet", 0,specimenFacade
.getDuplicates().size());
1495 DerivedUnit newSpecimen1
= DerivedUnit
.NewPreservedSpecimenInstance();
1496 specimenFacade
.addDuplicate(newSpecimen1
);
1497 Assert
.assertEquals("There should be 1 duplicate now", 1,specimenFacade
.getDuplicates().size());
1498 DerivedUnit newSpecimen2
= DerivedUnit
.NewPreservedSpecimenInstance();
1499 DerivationEvent newDerivationEvent
= DerivationEvent
.NewInstance(DerivationEventType
.ACCESSIONING());
1500 newSpecimen2
.setDerivedFrom(newDerivationEvent
);
1502 "The derivation event should be 'newDerivationEvent'",
1503 newDerivationEvent
, newSpecimen2
.getDerivedFrom());
1504 specimenFacade
.addDuplicate(newSpecimen2
);
1505 Assert
.assertEquals("There should be 2 duplicates now", 2, specimenFacade
.getDuplicates().size());
1506 Assert
.assertNotSame(
1507 "The derivation event should not be 'newDerivationEvent' anymore",
1508 newDerivationEvent
, newSpecimen2
.getDerivedFrom());
1510 "The derivation event should not be the facades derivation event",
1511 derivationEvent
, newSpecimen2
.getDerivedFrom());
1512 specimenFacade
.removeDuplicate(newSpecimen1
);
1513 Assert
.assertEquals("There should be 1 duplicate now", 1,
1514 specimenFacade
.getDuplicates().size());
1515 Assert
.assertSame("The only duplicate should be 'newSpecimen2' now",
1516 newSpecimen2
, specimenFacade
.getDuplicates().iterator().next());
1517 specimenFacade
.addDuplicate(specimenFacade
.innerDerivedUnit());
1518 Assert
.assertEquals(
1519 "There should be still 1 duplicate because the facade specimen is not a duplicate",
1520 1, specimenFacade
.getDuplicates().size());
1522 Collection newCollection
= Collection
.NewInstance();
1523 String catalogNumber
= "1234890";
1524 String accessionNumber
= "345345";
1525 String collectorsNumber
= "lkjewe";
1526 TaxonNameBase
<?
,?
> storedUnder
= BotanicalName
.NewInstance(Rank
.SPECIES());
1527 PreservationMethod method
= PreservationMethod
.NewInstance();
1528 DerivedUnit duplicateSpecimen
= specimenFacade
.addDuplicate(newCollection
,
1529 catalogNumber
, accessionNumber
, storedUnder
,
1531 Assert
.assertEquals("There should be 2 duplicates now", 2,
1532 specimenFacade
.getDuplicates().size());
1533 specimenFacade
.removeDuplicate(newSpecimen2
);
1534 Assert
.assertEquals("There should be 1 duplicates now", 1,
1535 specimenFacade
.getDuplicates().size());
1536 Collection sameCollection
= specimenFacade
.getDuplicates().iterator().next().getCollection();
1537 Assert
.assertSame("Collections should be same", newCollection
, sameCollection
);
1540 // ************************** Existing Specimen with multiple derivation
1541 // events in line **************/
1544 public void testExistingSpecimen() {
1545 specimenFacade
= null;
1547 specimenFacade
= DerivedUnitFacade
.NewInstance(collectionSpecimen
);
1548 } catch (DerivedUnitFacadeNotSupportedException e
) {
1549 Assert
.fail("Multiple derivation events in line should not throw a not supported exception");
1552 "Gathering event should derive from the derivation line",
1553 existingGatheringEvent
, specimenFacade
.innerGatheringEvent());
1554 Assert
.assertEquals(
1555 "Mediasize should be 0. Only Imagegallery media are supported",
1556 0, specimenFacade
.getFieldObjectMedia().size());
1560 public void testMultipleFieldUnitNotSupported() {
1561 specimenFacade
= null;
1562 FieldUnit secondFieldObject
= FieldUnit
.NewInstance();
1563 firstDerivationEvent
.addOriginal(secondFieldObject
);
1565 specimenFacade
= DerivedUnitFacade
.NewInstance(collectionSpecimen
);
1566 Assert
.fail("Multiple field units for one specimen should no be supported by the facade");
1567 } catch (DerivedUnitFacadeNotSupportedException e
) {
1570 Assert
.assertNull("Specimen facade should not be initialized",
1574 // not required anymore #3597
1575 // @Test // #######DerivationEvent
1576 // public void testOnlyImageGallerySupported() {
1577 // specimenFacade = null;
1578 // firstFieldObject.addMedia(media1);
1580 // specimenFacade = DerivedUnitFacade.NewInstance(collectionSpecimen);
1581 // Assert.fail("Only image galleries are supported by the facade but not direct media");
1582 // } catch (DerivedUnitFacadeNotSupportedException e) {
1585 // Assert.assertNull("Specimen facade should not be initialized",
1589 @Test // #######DerivationEvent
1590 public void testEventPropagation() {
1591 specimenFacade
.setDistanceToGround(24.0);
1595 // @Ignore // set to ignore because I did not want to check knowingly
1596 // failing tests. Remove @Ignore when this is fixed
1598 public void testSetBarcode() {
1599 String barcode
= "barcode";
1600 specimenFacade
.setBarcode(barcode
);
1602 Assert
.assertEquals(barcode
, specimenFacade
.getBarcode());
1606 public void testIsEvenDistance() {
1607 Integer minimum
= 20;
1608 Integer maximum
= 1234;
1610 // this should not throw exceptions
1611 specimenFacade
.setAbsoluteElevationRange(minimum
, maximum
);
1616 * See https://dev.e-taxonomy.eu/trac/ticket/2426
1617 * This test doesn't handle the above issue yet as it doesn't fire events as
1618 * expected (at least it does not reproduce the behaviour in the Taxonomic Editor).
1619 * In the meanwhile the property change framework for the facade has been changed
1620 * so the original problem may have disappeared.
1624 public void testNoRecursiveChangeEvents(){
1625 String username
= "username";
1626 String password
= "password";
1627 User user
= User
.NewInstance(username
, password
);
1628 userService
.save(user
);
1629 UsernamePasswordAuthenticationToken token
= new UsernamePasswordAuthenticationToken(user
, password
);
1630 SecurityContextHolder
.getContext().setAuthentication(token
);
1632 DerivedUnitFacade facade
= DerivedUnitFacade
.NewInstance(SpecimenOrObservationType
.PreservedSpecimen
);
1633 facade
.setLocality("testLocality");
1634 facade
.getTitleCache();
1635 // facade.innerGatheringEvent().firePropertyChange("createdBy", null, user);
1636 this.service
.save(facade
.innerDerivedUnit());
1637 commitAndStartNewTransaction(null);