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
.Country
;
47 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
48 import eu
.etaxonomy
.cdm
.model
.location
.Point
;
49 import eu
.etaxonomy
.cdm
.model
.location
.ReferenceSystem
;
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
;
68 * Test class for {@link DerivedUnitFacade}
73 public class DerivedUnitFacadeTest
extends CdmTransactionalIntegrationTest
{
74 @SuppressWarnings("unused")
75 private static final Logger logger
= Logger
.getLogger(DerivedUnitFacadeTest
.class);
78 private IOccurrenceService service
;
81 private ITermService termService
;
84 private IUserService userService
;
88 DerivationEvent derivationEvent
;
90 GatheringEvent gatheringEvent
;
91 Integer absoluteElevation
= 10;
92 Integer absoluteElevationMaximum
= 14;
93 AgentBase
<?
> collector
= Team
.NewInstance();
94 String collectingMethod
= "Collection Method";
95 Double distanceToGround
= 22.0;
96 Double distanceToSurface
= 0.3;
97 Double distanceToSurfaceMax
= 0.7;
99 ReferenceSystem referenceSystem
= ReferenceSystem
.WGS84();
100 Point exactLocation
= Point
.NewInstance(12.3, 10.567, referenceSystem
, 22);
101 String gatheringEventDescription
= "A nice gathering description";
102 TimePeriod gatheringPeriod
= TimePeriod
.NewInstance(1888, 1889);
104 String fieldNumber
= "15p23B";
105 String fieldNotes
= "such a beautiful specimen";
107 Integer individualCount
= 1;
108 DefinedTerm lifeStage
= DefinedTerm
.NewStageInstance("A wonderful stage", "stage", "st");
109 DefinedTerm sex
= DefinedTerm
.NewSexInstance("FemaleMale", "FM", "FM");
110 LanguageString locality
= LanguageString
.NewInstance("My locality",
113 String accessionNumber
= "888462535";
114 String catalogNumber
= "UU879873590";
115 TaxonNameBase
<?
,?
> taxonName
= BotanicalName
.NewInstance(Rank
.GENUS(), "Abies",
116 null, null, null, null, null, null, null);
117 String collectorsNumber
= "234589913A34";
118 Collection collection
= Collection
.NewInstance();
119 PreservationMethod preservationMethod
= PreservationMethod
.NewInstance(null, "my prservation");
121 DerivedUnitFacade specimenFacade
;
123 DerivedUnit collectionSpecimen
;
124 GatheringEvent existingGatheringEvent
;
125 DerivationEvent firstDerivationEvent
;
126 FieldUnit firstFieldObject
;
127 Media media1
= Media
.NewInstance();
129 DerivedUnitFacade emptyFacade
;
131 NamedArea country
= Country
.GERMANY();
133 // ****************************** SET UP **********************************/
137 * @throws java.lang.Exception
140 public void setUp() throws Exception
{
142 specimen
= DerivedUnit
.NewPreservedSpecimenInstance();
144 derivationEvent
= DerivationEvent
.NewInstance(DerivationEventType
.ACCESSIONING());
145 specimen
.setDerivedFrom(derivationEvent
);
146 fieldUnit
= FieldUnit
.NewInstance();
147 fieldUnit
.addDerivationEvent(derivationEvent
);
148 gatheringEvent
= GatheringEvent
.NewInstance();
149 fieldUnit
.setGatheringEvent(gatheringEvent
);
150 gatheringEvent
.setAbsoluteElevation(absoluteElevation
);
151 gatheringEvent
.setAbsoluteElevationMax(absoluteElevationMaximum
);
152 gatheringEvent
.setActor(collector
);
153 gatheringEvent
.setCollectingMethod(collectingMethod
);
154 gatheringEvent
.setDistanceToGround(distanceToGround
);
155 gatheringEvent
.setDistanceToWaterSurface(distanceToSurface
);
156 gatheringEvent
.setDistanceToWaterSurfaceMax(distanceToSurfaceMax
);
157 gatheringEvent
.setExactLocation(exactLocation
);
158 gatheringEvent
.setDescription(gatheringEventDescription
);
159 gatheringEvent
.setCountry(country
);
161 gatheringEvent
.setTimeperiod(gatheringPeriod
);
162 gatheringEvent
.setLocality(locality
);
164 fieldUnit
.setFieldNumber(fieldNumber
);
165 fieldUnit
.setFieldNotes(fieldNotes
);
166 fieldUnit
.setIndividualCount(individualCount
);
167 fieldUnit
.setSex(sex
);
168 fieldUnit
.setLifeStage(lifeStage
);
170 specimen
.setAccessionNumber(accessionNumber
);
171 specimen
.setCatalogNumber(catalogNumber
);
172 specimen
.setStoredUnder(taxonName
);
173 specimen
.setCollection(collection
);
174 specimen
.setPreservation(preservationMethod
);
176 specimenFacade
= DerivedUnitFacade
.NewInstance(specimen
);
178 // existing specimen with 2 derivation events in line
179 collectionSpecimen
= DerivedUnit
.NewPreservedSpecimenInstance();
180 DerivedUnit middleSpecimen
= DerivedUnit
.NewPreservedSpecimenInstance();
181 firstFieldObject
= FieldUnit
.NewInstance();
183 //TODO maybe we should define concrete event types here
184 DerivationEventType eventType
= DerivationEventType
.ACCESSIONING();
185 DerivationEvent lastDerivationEvent
= DerivationEvent
.NewInstance(eventType
);
186 DerivationEvent middleDerivationEvent
= DerivationEvent
.NewInstance(eventType
);
187 firstDerivationEvent
= DerivationEvent
.NewInstance(eventType
);
189 collectionSpecimen
.setDerivedFrom(lastDerivationEvent
);
191 lastDerivationEvent
.addOriginal(middleSpecimen
);
192 middleSpecimen
.setDerivedFrom(firstDerivationEvent
);
193 firstDerivationEvent
.addOriginal(firstFieldObject
);
194 existingGatheringEvent
= GatheringEvent
.NewInstance();
195 firstFieldObject
.setGatheringEvent(existingGatheringEvent
);
198 emptyFacade
= DerivedUnitFacade
.NewInstance(SpecimenOrObservationType
.PreservedSpecimen
);
202 // ****************************** TESTS*****************************/
204 @Ignore //doesn't run in suite
206 @DataSet("DerivedUnitFacadeTest.testSetFieldObjectImageGallery.xml")
208 public void testSetFieldObjectImageGallery() {
209 UUID imageFeatureUuid
= Feature
.IMAGE().getUuid();
210 Feature imageFeature
= (Feature
) termService
.find(imageFeatureUuid
);
212 DerivedUnitFacade facade
= DerivedUnitFacade
.NewInstance(SpecimenOrObservationType
.PreservedSpecimen
);
213 facade
.innerDerivedUnit().setUuid(UUID
.fromString("77af784f-931b-4857-be9a-48ccf31ed3f1"));
214 facade
.setFieldNumber("12345");
215 Media media
= Media
.NewInstance(URI
.create("www.abc.de"), 200, null,"jpeg");
218 SpecimenDescription imageGallery
= SpecimenDescription
.NewInstance();
219 imageGallery
.setDescribedSpecimenOrObservation(facade
.innerFieldUnit());
220 imageGallery
.setImageGallery(true);
221 TextData textData
= TextData
.NewInstance();
222 textData
.setFeature(imageFeature
);
223 imageGallery
.addElement(textData
);
224 textData
.addMedia(media
);
225 facade
.setFieldObjectImageGallery(imageGallery
);
227 } catch (DerivedUnitFacadeNotSupportedException e1
) {
228 e1
.printStackTrace();
229 Assert
.fail(e1
.getLocalizedMessage());
231 this.service
.save(facade
.innerDerivedUnit());
233 setComplete(); endTransaction();
234 // try {if (true){printDataSet(System.out, new
235 // String[]{"HIBERNATE_SEQUENCES","SPECIMENOROBSERVATIONBASE","SPECIMENOROBSERVATIONBASE_DERIVATIONEVENT"
236 // ,"DERIVATIONEVENT",
237 // "DESCRIPTIONBASE","DESCRIPTIONELEMENTBASE","DESCRIPTIONELEMENTBASE_MEDIA",
238 // "MEDIA", "MEDIAREPRESENTATION","MEDIAREPRESENTATIONPART"});}
239 // } catch(Exception e) { logger.warn(e);}
245 // TODO generally works but has id problems when running together with above
246 // test ()setFieldObjectImageGallery. Therefore set to ignore.
247 @DataSet("DerivedUnitFacadeTest.testSetDerivedUnitImageGallery.xml")
249 public void testSetDerivedUnitImageGallery() {
250 // UUID specimenUUID =
251 // UUID.fromString("25383fc8-789b-4eff-92d3-a770d0622351");
252 // Specimen specimen = (Specimen)service.find(specimenUUID);
253 DerivedUnitFacade facade
= DerivedUnitFacade
.NewInstance(SpecimenOrObservationType
.PreservedSpecimen
);
254 Media media
= Media
.NewInstance(URI
.create("www.derivedUnitImage.de"),200, null, "png");
257 SpecimenDescription imageGallery
= SpecimenDescription
259 imageGallery
.setDescribedSpecimenOrObservation(facade
.innerDerivedUnit());
260 imageGallery
.setImageGallery(true);
261 TextData textData
= TextData
.NewInstance();
262 imageGallery
.addElement(textData
);
263 textData
.addMedia(media
);
264 facade
.setDerivedUnitImageGallery(imageGallery
);
266 } catch (DerivedUnitFacadeNotSupportedException e1
) {
267 e1
.printStackTrace();
268 Assert
.fail(e1
.getLocalizedMessage());
270 this.service
.save(facade
.innerDerivedUnit());
272 // setComplete(); endTransaction();
273 // try {if (true){printDataSet(System.out, new
274 // String[]{"HIBERNATE_SEQUENCES","SPECIMENOROBSERVATIONBASE","SPECIMENOROBSERVATIONBASE_DERIVATIONEVENT"
275 // ,"DERIVATIONEVENT",
276 // "DESCRIPTIONBASE","DESCRIPTIONELEMENTBASE","DESCRIPTIONELEMENTBASE_MEDIA",
277 // "MEDIA", "MEDIAREPRESENTATION","MEDIAREPRESENTATIONPART"});}
278 // } catch(Exception e) { logger.warn(e);}
285 @Ignore // TODO generally works has id problems with following tests when running in suite
286 public void testGetFieldObjectImageGalleryBooleanPersisted() {
287 UUID specimenUUID
= UUID
.fromString("25383fc8-789b-4eff-92d3-a770d0622351");
288 DerivedUnit specimen
= (DerivedUnit
) service
.load(specimenUUID
);
289 Assert
.assertNotNull("Specimen should exist (persisted)", specimen
);
291 DerivedUnitFacade facade
= DerivedUnitFacade
.NewInstance(specimen
);
292 SpecimenDescription imageGallery
= facade
.getFieldObjectImageGallery(true);
293 Assert
.assertNotNull("Image gallery should exist", imageGallery
);
294 Assert
.assertEquals("UUID should be equal to the persisted uuid",
295 UUID
.fromString("8cb772e9-1577-45c6-91ab-dbec1413c060"),
296 imageGallery
.getUuid());
297 Assert
.assertEquals("The image gallery should be flagged as such",true, imageGallery
.isImageGallery());
298 Assert
.assertEquals("There should be one TextData in image gallery", 1,
299 imageGallery
.getElements().size());
300 List
<Media
> media
= imageGallery
.getElements().iterator().next().getMedia();
301 Assert
.assertEquals("There should be 1 media", 1, media
.size());
302 } catch (DerivedUnitFacadeNotSupportedException e
) {
310 // @Ignore // TODO generally works has id problems with following tests when running in suite
311 public void testGetDerivedUnitImageGalleryBooleanPersisted() {
312 UUID specimenUUID
= UUID
.fromString("25383fc8-789b-4eff-92d3-a770d0622351");
313 DerivedUnit specimen
= (DerivedUnit
) service
.load(specimenUUID
);
314 Assert
.assertNotNull("Specimen should exist (persisted)", specimen
);
316 DerivedUnitFacade facade
= DerivedUnitFacade
.NewInstance(specimen
);
317 SpecimenDescription imageGallery
= facade
.getDerivedUnitImageGallery(true);
318 Assert
.assertNotNull("Image gallery should exist", imageGallery
);
319 Assert
.assertEquals("UUID should be equal to the persisted uuid",
320 UUID
.fromString("cb03acc4-8363-4020-aeef-ea8a8bcc0fe9"),
321 imageGallery
.getUuid());
322 Assert
.assertEquals("The image gallery should be flagged as such",
323 true, imageGallery
.isImageGallery());
325 "There should be one TextData in image gallery", 1,
326 imageGallery
.getElements().size());
327 List
<Media
> media
= imageGallery
.getElements().iterator().next().getMedia();
328 Assert
.assertEquals("There should be 1 media", 1, media
.size());
329 } catch (DerivedUnitFacadeNotSupportedException e
) {
336 public void testGetDerivedUnitImageGalleryBoolean() {
337 DerivedUnit specimen
= DerivedUnit
.NewPreservedSpecimenInstance();
339 DerivedUnitFacade facade
= DerivedUnitFacade
.NewInstance(specimen
);
340 SpecimenDescription imageGallery
= facade
.getDerivedUnitImageGallery(true);
341 Assert
.assertNotNull("Image Gallery should have been created",imageGallery
);
342 Assert
.assertEquals("The image gallery should be flagged as such",true, imageGallery
.isImageGallery());
343 } catch (DerivedUnitFacadeNotSupportedException e
) {
352 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#NewInstance()}.
355 public void testNewInstance() {
356 Assert
.assertNotNull("The specimen should have been created",
357 specimenFacade
.innerDerivedUnit());
359 // Assert.assertNotNull("The derivation event should have been created",
360 // specimenFacade.getSpecimen().getDerivedFrom());
361 // Assert.assertNotNull("The field unit should have been created",
362 // specimenFacade.getFieldUnit());
363 // Assert.assertNotNull("The gathering event should have been created",
364 // specimenFacade.getGatheringEvent());
369 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#NewInstance(eu.etaxonomy.cdm.model.occurrence.Specimen)}
373 public void testNewInstanceSpecimen() {
374 Assert
.assertSame("Specimen should be same", specimen
,
375 specimenFacade
.innerDerivedUnit());
376 Assert
.assertSame("Derivation event should be same", derivationEvent
,
377 specimenFacade
.innerDerivedUnit().getDerivedFrom());
378 Assert
.assertSame("Field unit should be same", fieldUnit
,
379 specimenFacade
.innerFieldUnit());
380 Assert
.assertSame("Gathering event should be same", gatheringEvent
,
381 specimenFacade
.innerGatheringEvent());
386 public void testGatheringEventIsConnectedToDerivedUnit() {
387 DerivedUnit specimen
= DerivedUnit
.NewPreservedSpecimenInstance();
388 DerivedUnitFacade specimenFacade
;
390 specimenFacade
= DerivedUnitFacade
.NewInstance(specimen
);
391 specimenFacade
.setDistanceToGround(2.0);
392 FieldUnit specimenFieldUnit
= (FieldUnit
) specimen
.getDerivedFrom().getOriginals().iterator().next();
394 "Facade gathering event and specimen gathering event should be the same",
395 specimenFacade
.innerGatheringEvent(),
396 specimenFieldUnit
.getGatheringEvent());
397 } catch (DerivedUnitFacadeNotSupportedException e
) {
398 Assert
.fail("An error should not occur in NewInstance()");
403 public void testNoGatheringEventAndFieldUnit() {
404 DerivedUnit specimen
= DerivedUnit
.NewPreservedSpecimenInstance();
405 DerivedUnitFacade specimenFacade
;
407 specimenFacade
= DerivedUnitFacade
.NewInstance(specimen
);
408 Assert
.assertNull("No field unit should exists",
409 specimenFacade
.innerFieldUnit());
410 } catch (DerivedUnitFacadeNotSupportedException e
) {
411 Assert
.fail("An error should not occur in NewInstance()");
416 public void testInititializeTextDataWithSupportTest() {
418 DerivedUnit specimen
= DerivedUnit
.NewPreservedSpecimenInstance();
419 DerivedUnitFacade specimenFacade
;
421 specimenFacade
= DerivedUnitFacade
.NewInstance(specimen
);
422 specimenFacade
.setEcology("Ecology");
423 String plantDescription
= specimenFacade
.getPlantDescription();
425 "No plantDescription should exist yet and no NPE should be thrown until now",
427 } catch (DerivedUnitFacadeNotSupportedException e
) {
428 Assert
.fail("An error should not occur in NewInstance()");
433 public void testGetSetType() {
434 Assert
.assertEquals("Type must be same", SpecimenOrObservationType
.PreservedSpecimen
, specimenFacade
.getType());
435 SpecimenOrObservationType newType
= SpecimenOrObservationType
.Fossil
;
436 specimenFacade
.setType(newType
);
437 Assert
.assertEquals("New type must be Fossil", newType
, specimenFacade
.getType());
438 Assert
.assertEquals("DerivedUnit recordBasis must be set to Fossil", newType
, specimenFacade
.innerDerivedUnit().getRecordBasis());
443 public void testGetSetCountry() {
444 Assert
.assertEquals("Country must be same", country
, specimenFacade
.getCountry());
445 specimenFacade
.setCountry(Country
.FRANCEFRENCHREPUBLIC());
446 Assert
.assertEquals("New country must be France", Country
.FRANCEFRENCHREPUBLIC(), specimenFacade
.getCountry());
451 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#addCollectingArea(eu.etaxonomy.cdm.model.location.NamedArea)}
455 public void testAddGetRemoveCollectingArea() {
456 String tdwgLabel
= "GER";
457 NamedArea tdwgArea
= termService
.getAreaByTdwgAbbreviation(tdwgLabel
);
458 NamedArea newCollectingArea
= NamedArea
.NewInstance("A nice area",
460 specimenFacade
.addCollectingArea(newCollectingArea
);
461 Assert
.assertEquals("Exactly 1 area must exist", 1, specimenFacade
462 .getCollectingAreas().size());
463 Assert
.assertSame("Areas should be same", newCollectingArea
,
464 specimenFacade
.innerFieldUnit().getGatheringEvent()
465 .getCollectingAreas().iterator().next());
466 specimenFacade
.addCollectingArea(tdwgArea
);
467 Assert
.assertEquals("Exactly 2 areas must exist", 2, specimenFacade
468 .getCollectingAreas().size());
469 specimenFacade
.removeCollectingArea(newCollectingArea
);
470 Assert
.assertEquals("Exactly 1 area must exist", 1, specimenFacade
471 .getCollectingAreas().size());
472 NamedArea remainingArea
= specimenFacade
.getCollectingAreas()
474 Assert
.assertEquals("Areas should be same", tdwgArea
, remainingArea
);
475 specimenFacade
.removeCollectingArea(tdwgArea
);
476 Assert
.assertEquals("No area should remain", 0, specimenFacade
477 .getCollectingAreas().size());
482 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#addCollectingArea(eu.etaxonomy.cdm.model.location.NamedArea)}
486 public void testAddCollectingAreas() {
487 NamedArea firstArea
= NamedArea
.NewInstance("A nice area", "nice", "n");
488 Assert
.assertEquals("No area must exist", 0, specimenFacade
.getCollectingAreas().size());
489 specimenFacade
.addCollectingArea(firstArea
);
490 Assert
.assertEquals("Exactly 1 area must exist", 1, specimenFacade
.getCollectingAreas().size());
492 String tdwgLabel
= "GER";
493 NamedArea tdwgArea
= termService
.getAreaByTdwgAbbreviation(tdwgLabel
);
494 NamedArea secondArea
= NamedArea
.NewInstance("A nice area", "nice", "n");
496 java
.util
.Collection
<NamedArea
> areaCollection
= new HashSet
<NamedArea
>();
497 areaCollection
.add(secondArea
);
498 areaCollection
.add(tdwgArea
);
499 specimenFacade
.addCollectingAreas(areaCollection
);
500 Assert
.assertEquals("Exactly 3 areas must exist", 3, specimenFacade
501 .getCollectingAreas().size());
506 * Test method for getting and setting absolute elevation.
507 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getAbsoluteElevation()}
511 public void testGetSetAbsoluteElevation() {
512 Assert
.assertEquals("Absolute elevation must be same",absoluteElevation
, specimenFacade
.getAbsoluteElevation());
513 specimenFacade
.setAbsoluteElevation(400);
514 Assert
.assertEquals("Absolute elevation must be 400",Integer
.valueOf(400), specimenFacade
.getAbsoluteElevation());
519 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getAbsoluteElevationError()}
523 public void testGetSetAbsoluteElevationMaximum() {
524 Assert
.assertEquals("Absolute elevation must be same",absoluteElevation
, specimenFacade
.getAbsoluteElevation());
525 Assert
.assertEquals("Absolute elevation maximum must be same",absoluteElevationMaximum
, specimenFacade
.getAbsoluteElevationMaximum());
526 specimenFacade
.setAbsoluteElevationMax(4);
527 Assert
.assertEquals("Absolute elevation maximum must be 4", Integer
.valueOf(4), specimenFacade
.getAbsoluteElevationMaximum());
528 Assert
.assertEquals("Absolute elevation must be same",absoluteElevation
, specimenFacade
.getAbsoluteElevation());
533 public void testGetSetAbsoluteElevationRange() {
534 Assert
.assertEquals("", absoluteElevation
, specimenFacade
.getAbsoluteElevation());
535 Assert
.assertEquals("", absoluteElevationMaximum
,specimenFacade
.getAbsoluteElevationMaximum());
537 specimenFacade
.setAbsoluteElevationRange(30, 36);
538 Assert
.assertEquals("", Integer
.valueOf(36),specimenFacade
.getAbsoluteElevationMaximum());
539 Assert
.assertEquals("", Integer
.valueOf(30),specimenFacade
.getAbsoluteElevation());
540 Assert
.assertEquals("", "30" + UTF8
.EN_DASH_SPATIUM
+ "36 m",specimenFacade
.absoluteElevationToString());
541 Assert
.assertEquals("", null,specimenFacade
.getAbsoluteElevationText());
543 specimenFacade
.setAbsoluteElevationRange(30, 35);
544 Assert
.assertEquals("Odd range should not throw an exception anymore",
545 String
.format("30%s35 m", UTF8
.EN_DASH_SPATIUM
),specimenFacade
.absoluteElevationToString());
547 specimenFacade
.setAbsoluteElevationRange(41, null);
548 Assert
.assertEquals("", null,specimenFacade
.getAbsoluteElevationMaximum());
549 Assert
.assertEquals("", Integer
.valueOf(41),specimenFacade
.getAbsoluteElevation());
550 Assert
.assertEquals("", Integer
.valueOf(41),specimenFacade
.getAbsoluteElevation());
551 Assert
.assertNull("", specimenFacade
.getAbsoluteElevationText());
552 Assert
.assertEquals("", "41 m",specimenFacade
.absoluteElevationToString());
554 specimenFacade
.setAbsoluteElevationRange(null, null);
555 Assert
.assertNull("", specimenFacade
.getAbsoluteElevation());
556 Assert
.assertNull("", specimenFacade
.getAbsoluteElevationMaximum());
557 Assert
.assertNull("", specimenFacade
.absoluteElevationToString());
562 public void testGetSetAbsoluteElevationText() {
563 Assert
.assertEquals("", absoluteElevation
, specimenFacade
.getAbsoluteElevation());
564 Assert
.assertEquals("", absoluteElevationMaximum
,specimenFacade
.getAbsoluteElevationMaximum());
565 Assert
.assertEquals("", null,specimenFacade
.getAbsoluteElevationText());
567 String elevText
= "approx. 30 - 35";
568 specimenFacade
.setAbsoluteElevationText(elevText
);
569 Assert
.assertEquals("", absoluteElevation
, specimenFacade
.getAbsoluteElevation());
570 Assert
.assertEquals("", absoluteElevationMaximum
,specimenFacade
.getAbsoluteElevationMaximum());
571 Assert
.assertEquals("", elevText
,specimenFacade
.absoluteElevationToString());
573 specimenFacade
.setAbsoluteElevationRange(30, 35);
574 Assert
.assertEquals("ToString should not change by setting range if text is set", elevText
,specimenFacade
.absoluteElevationToString());
575 Assert
.assertEquals("", Integer
.valueOf(30), specimenFacade
.getAbsoluteElevation());
576 Assert
.assertEquals("", Integer
.valueOf(35),specimenFacade
.getAbsoluteElevationMaximum());
579 specimenFacade
.setAbsoluteElevationRange(41, null);
580 Assert
.assertEquals("ToString should not change by setting range if text is set", elevText
,specimenFacade
.absoluteElevationToString());
581 Assert
.assertEquals("", Integer
.valueOf(41), specimenFacade
.getAbsoluteElevation());
582 Assert
.assertEquals("", null,specimenFacade
.getAbsoluteElevationMaximum());
585 specimenFacade
.setAbsoluteElevationText(null);
586 Assert
.assertNull("", specimenFacade
.getAbsoluteElevationText());
587 Assert
.assertEquals("ToString should change by setting text to null", "41 m",specimenFacade
.absoluteElevationToString());
588 Assert
.assertEquals("", Integer
.valueOf(41), specimenFacade
.getAbsoluteElevation());
589 Assert
.assertEquals("", null,specimenFacade
.getAbsoluteElevationMaximum());
596 public void testGetSetCollector() {
597 Assert
.assertNotNull("Collector must not be null",
598 specimenFacade
.getCollector());
599 Assert
.assertEquals("Collector must be same", collector
,
600 specimenFacade
.getCollector());
601 specimenFacade
.setCollector(null);
602 Assert
.assertNull("Collector must be null",
603 specimenFacade
.getCollector());
608 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getCollectingMethod()}
612 public void testGetSetCollectingMethod() {
613 Assert
.assertEquals("Collecting method must be same", collectingMethod
,
614 specimenFacade
.getCollectingMethod());
615 specimenFacade
.setCollectingMethod("new method");
616 Assert
.assertEquals("Collecting method must be 'new method'",
617 "new method", specimenFacade
.getCollectingMethod());
622 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getDistanceToGround()}
626 public void testGetSetDistanceToGround() {
627 Assert
.assertEquals("Distance to ground must be same",distanceToGround
, specimenFacade
.getDistanceToGround());
628 specimenFacade
.setDistanceToGround(5.0);
629 Assert
.assertEquals("Distance to ground must be 5", Double
.valueOf(5), specimenFacade
.getDistanceToGround());
634 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getDistanceToWaterSurface()}
638 public void testGetDistanceToWaterSurface() {
639 Assert
.assertEquals("Distance to surface must be same", distanceToSurface
, specimenFacade
.getDistanceToWaterSurface());
640 specimenFacade
.setDistanceToWaterSurface(6.0);
641 Assert
.assertEquals("Distance to surface must be 6", Double
.valueOf(6), specimenFacade
.getDistanceToWaterSurface());
642 // empty facade tests
643 Assert
.assertNull("Empty facace must not have any gathering values", emptyFacade
.getDistanceToWaterSurface());
644 emptyFacade
.setDistanceToWaterSurface(13.0);
645 Assert
.assertNotNull("Field unit must exist if distance to water exists", emptyFacade
.getFieldUnit(false));
646 Assert
.assertNotNull("Gathering event must exist if distance to water exists", emptyFacade
.getGatheringEvent(false));
647 FieldUnit specimenFieldUnit
= (FieldUnit
) emptyFacade
648 .innerDerivedUnit().getDerivedFrom().getOriginals().iterator().next();
649 Assert
.assertSame("Gathering event of facade and of specimen must be the same",
650 specimenFieldUnit
.getGatheringEvent(), emptyFacade
.getGatheringEvent(false));
654 public void testGetSetDistanceToWaterText() {
655 Assert
.assertEquals("", distanceToSurface
, specimenFacade
.getDistanceToWaterSurface());
656 Assert
.assertEquals("", distanceToSurfaceMax
,specimenFacade
.getDistanceToWaterSurfaceMax());
657 Assert
.assertEquals("", null,specimenFacade
.getDistanceToWaterSurfaceText());
659 String distText
= "approx. 0.3 - 0.6";
660 specimenFacade
.setDistanceToWaterSurfaceText(distText
);
661 Assert
.assertEquals("", distanceToSurface
, specimenFacade
.getDistanceToWaterSurface());
662 Assert
.assertEquals("", distanceToSurfaceMax
,specimenFacade
.getDistanceToWaterSurfaceMax());
663 Assert
.assertEquals("", distText
,specimenFacade
.distanceToWaterSurfaceToString());
665 specimenFacade
.setDistanceToWaterSurfaceRange(0.6, 1.4);
666 Assert
.assertEquals("ToString should not change by setting range if text is set", distText
,specimenFacade
.distanceToWaterSurfaceToString());
667 Assert
.assertEquals("", Double
.valueOf(0.6), specimenFacade
.getDistanceToWaterSurface());
668 Assert
.assertEquals("", Double
.valueOf(1.4),specimenFacade
.getDistanceToWaterSurfaceMax());
670 specimenFacade
.setDistanceToWaterSurfaceRange(41.2, null);
671 Assert
.assertEquals("ToString should not change by setting range if text is set", distText
,specimenFacade
.distanceToWaterSurfaceToString());
672 Assert
.assertEquals("", Double
.valueOf(41.2), specimenFacade
.getDistanceToWaterSurface());
673 Assert
.assertEquals("", null,specimenFacade
.getDistanceToWaterSurfaceMax());
675 specimenFacade
.setDistanceToWaterSurfaceText(null);
676 Assert
.assertNull("", specimenFacade
.getDistanceToWaterSurfaceText());
677 Assert
.assertEquals("ToString should change by setting text to null", "41.2 m",specimenFacade
.distanceToWaterSurfaceToString());
678 Assert
.assertEquals("", Double
.valueOf(41.2), specimenFacade
.getDistanceToWaterSurface());
679 Assert
.assertEquals("", null,specimenFacade
.getDistanceToWaterSurfaceMax());
685 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getExactLocation()}.
688 public void testGetSetExactLocation() {
689 Assert
.assertNotNull("Exact location must not be null",
690 specimenFacade
.getExactLocation());
691 Assert
.assertEquals("Exact location must be same", exactLocation
,
692 specimenFacade
.getExactLocation());
693 specimenFacade
.setExactLocation(null);
694 Assert
.assertNull("Exact location must be null",
695 specimenFacade
.getExactLocation());
699 public void testSetExactLocationByParsing() {
702 specimenFacade
.setExactLocationByParsing("112\u00B034'20\"W",
703 "34\u00B030,34'N", null, null);
704 point1
= specimenFacade
.getExactLocation();
705 Assert
.assertNotNull("", point1
.getLatitude());
706 System
.out
.println(point1
.getLatitude().toString());
707 Assert
.assertTrue("",
708 point1
.getLatitude().toString().startsWith("34.505"));
709 System
.out
.println(point1
.getLongitude().toString());
710 Assert
.assertTrue("",
711 point1
.getLongitude().toString().startsWith("-112.5722"));
713 } catch (ParseException e
) {
714 Assert
.fail("No parsing error should occur");
720 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getGatheringEventDescription()}
724 public void testGetSetGatheringEventDescription() {
725 Assert
.assertEquals("Gathering event description must be same",
726 gatheringEventDescription
,
727 specimenFacade
.getGatheringEventDescription());
728 specimenFacade
.setGatheringEventDescription("new description");
730 "Gathering event description must be 'new description' now",
732 specimenFacade
.getGatheringEventDescription());
737 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getTimeperiod()}.
740 public void testGetTimeperiod() {
741 Assert
.assertNotNull("Gathering period must not be null", specimenFacade
.getGatheringPeriod());
742 Assert
.assertFalse("Gathering period must not be empty", specimenFacade
.getGatheringPeriod().isEmpty());
743 Assert
.assertEquals("Gathering period must be same", gatheringPeriod
, specimenFacade
.getGatheringPeriod());
744 specimenFacade
.setGatheringPeriod(null);
745 Assert
.assertTrue("Gathering period must be null", specimenFacade
.getGatheringPeriod().isEmpty());
749 public void testHasFieldObject() throws SecurityException
,
750 NoSuchFieldException
, IllegalArgumentException
,
751 IllegalAccessException
{
752 // this test depends on the current implementation of SpecimenFacade. In
754 // field unit may not be initialized from the beginning. Than the
756 // assert should be set to assertNull
757 Assert
.assertTrue("field object should not be null (depends on specimen facade initialization !!)",
758 specimenFacade
.hasFieldObject());
760 Field fieldUnitField
= DerivedUnitFacade
.class.getDeclaredField("fieldUnit");
761 fieldUnitField
.setAccessible(true);
762 fieldUnitField
.set(specimenFacade
, null);
763 Assert
.assertFalse("The field unit should be null now",
764 specimenFacade
.hasFieldObject());
766 specimenFacade
.setDistanceToGround(33.0);
768 "The field unit should have been created again",
769 specimenFacade
.hasFieldObject());
774 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#addFieldObjectDefinition(java.lang.String, eu.etaxonomy.cdm.model.common.Language)}
778 public void testAddGetRemoveFieldObjectDefinition() {
779 Assert
.assertEquals("There should be no definition yet", 0,
780 specimenFacade
.getFieldObjectDefinition().size());
781 specimenFacade
.addFieldObjectDefinition("Tres interesant",
783 Assert
.assertEquals("There should be exactly one definition", 1,
784 specimenFacade
.getFieldObjectDefinition().size());
786 "The French definition should be 'Tres interesant'",
787 "Tres interesant", specimenFacade
.getFieldObjectDefinition()
788 .get(Language
.FRENCH()).getText());
790 "The French definition should be 'Tres interesant'",
792 specimenFacade
.getFieldObjectDefinition(Language
.FRENCH()));
793 specimenFacade
.addFieldObjectDefinition("Sehr interessant",
795 Assert
.assertEquals("There should be exactly 2 definition", 2,
796 specimenFacade
.getFieldObjectDefinition().size());
797 specimenFacade
.removeFieldObjectDefinition(Language
.FRENCH());
798 Assert
.assertEquals("There should remain exactly 1 definition", 1,
799 specimenFacade
.getFieldObjectDefinition().size());
801 "The remaining German definition should be 'Sehr interessant'",
803 specimenFacade
.getFieldObjectDefinition(Language
.GERMAN()));
804 specimenFacade
.removeFieldObjectDefinition(Language
.GERMAN());
805 Assert
.assertEquals("There should remain no definition", 0,
806 specimenFacade
.getFieldObjectDefinition().size());
811 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#addFieldObjectMedia(eu.etaxonomy.cdm.model.media.Media)}
815 public void testAddGetHasRemoveFieldObjectMedia() {
816 Assert
.assertFalse("There should be no image gallery yet",
817 specimenFacade
.hasFieldObjectImageGallery());
818 Assert
.assertFalse("There should be no specimen image gallery either",
819 specimenFacade
.hasDerivedUnitImageGallery());
821 List
<Media
> media
= specimenFacade
.getFieldObjectMedia();
822 Assert
.assertFalse("There should still not be an image gallery now",
823 specimenFacade
.hasFieldObjectImageGallery());
824 Assert
.assertEquals("There should be no media yet in the gallery", 0,
827 Media media1
= Media
.NewInstance();
828 specimenFacade
.addFieldObjectMedia(media1
);
829 Assert
.assertEquals("There should be exactly one specimen media", 1,
830 specimenFacade
.getFieldObjectMedia().size());
831 Assert
.assertEquals("The only media should be media 1", media1
,
832 specimenFacade
.getFieldObjectMedia().get(0));
834 "There should still no specimen image gallery exist",
835 specimenFacade
.hasDerivedUnitImageGallery());
837 Media media2
= Media
.NewInstance();
838 specimenFacade
.addFieldObjectMedia(media2
);
839 Assert
.assertEquals("There should be exactly 2 specimen media", 2,
840 specimenFacade
.getFieldObjectMedia().size());
841 Assert
.assertEquals("The first media should be media1", media1
,
842 specimenFacade
.getFieldObjectMedia().get(0));
843 Assert
.assertEquals("The second media should be media2", media2
,
844 specimenFacade
.getFieldObjectMedia().get(1));
846 specimenFacade
.removeFieldObjectMedia(media1
);
847 Assert
.assertEquals("There should be exactly one specimen media", 1,
848 specimenFacade
.getFieldObjectMedia().size());
849 Assert
.assertEquals("The only media should be media2", media2
,
850 specimenFacade
.getFieldObjectMedia().get(0));
852 specimenFacade
.removeFieldObjectMedia(media1
);
853 Assert
.assertEquals("There should still be exactly one specimen media",
854 1, specimenFacade
.getFieldObjectMedia().size());
856 specimenFacade
.removeFieldObjectMedia(media2
);
857 Assert
.assertEquals("There should remain no media in the gallery", 0,
864 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#addFieldObjectMedia(eu.etaxonomy.cdm.model.media.Media)}
868 public void testGetSetEcology() {
869 Assert
.assertNotNull(
870 "An empty ecology data should be created when calling getEcology()",
871 specimenFacade
.getEcologyAll());
873 "An empty ecology data should be created when calling getEcology()",
874 0, specimenFacade
.getEcologyAll().size());
875 specimenFacade
.setEcology("Tres jolie ici", Language
.FRENCH());
876 Assert
.assertEquals("Ecology data should exist for 1 language", 1,
877 specimenFacade
.getEcologyAll().size());
879 "Ecology data should be 'Tres jolie ici' for French",
880 "Tres jolie ici", specimenFacade
.getEcology(Language
.FRENCH()));
882 "Ecology data should be null for the default language",
883 specimenFacade
.getEcology());
884 specimenFacade
.setEcology("Nice here");
885 Assert
.assertEquals("Ecology data should exist for 2 languages", 2,
886 specimenFacade
.getEcologyAll().size());
887 Assert
.assertEquals("Ecology data should be 'Tres jolie ici'",
888 "Tres jolie ici", specimenFacade
.getEcology(Language
.FRENCH()));
890 "Ecology data should be 'Nice here' for the default language",
891 "Nice here", specimenFacade
.getEcology());
892 Assert
.assertEquals("Ecology data should be 'Nice here' for english",
893 "Nice here", specimenFacade
.getEcology());
895 specimenFacade
.setEcology("Vert et rouge", Language
.FRENCH());
896 Assert
.assertEquals("Ecology data should exist for 2 languages", 2,
897 specimenFacade
.getEcologyAll().size());
898 Assert
.assertEquals("Ecology data should be 'Vert et rouge'",
899 "Vert et rouge", specimenFacade
.getEcology(Language
.FRENCH()));
901 "Ecology data should be 'Nice here' for the default language",
902 "Nice here", specimenFacade
.getEcology());
904 specimenFacade
.setEcology(null, Language
.FRENCH());
905 Assert
.assertEquals("Ecology data should exist for 1 languages", 1,
906 specimenFacade
.getEcologyAll().size());
908 "Ecology data should be 'Nice here' for the default language",
909 "Nice here", specimenFacade
.getEcology());
910 Assert
.assertNull("Ecology data should be 'null' for French",
911 specimenFacade
.getEcology(Language
.FRENCH()));
913 specimenFacade
.removeEcology(null);
914 Assert
.assertEquals("There should be no ecology left", 0,
915 specimenFacade
.getEcologyAll().size());
916 Assert
.assertNull("Ecology data should be 'null' for default language",
917 specimenFacade
.getEcology());
923 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#addFieldObjectMedia(eu.etaxonomy.cdm.model.media.Media)}
927 public void testGetSetPlantDescription() {
928 Assert
.assertNotNull(
929 "An empty plant description data should be created when calling getPlantDescriptionAll()",
930 specimenFacade
.getPlantDescriptionAll());
932 "An empty plant description data should be created when calling getPlantDescription()",
933 0, specimenFacade
.getPlantDescriptionAll().size());
934 specimenFacade
.setPlantDescription("bleu", Language
.FRENCH());
936 "Plant description data should exist for 1 language", 1,
937 specimenFacade
.getPlantDescriptionAll().size());
939 "Plant description data should be 'bleu' for French", "bleu",
940 specimenFacade
.getPlantDescription(Language
.FRENCH()));
942 "Plant description data should be null for the default language",
943 specimenFacade
.getPlantDescription());
944 specimenFacade
.setPlantDescription("Nice here");
946 "Plant description data should exist for 2 languages", 2,
947 specimenFacade
.getPlantDescriptionAll().size());
948 Assert
.assertEquals("Plant description data should be 'bleu'", "bleu",
949 specimenFacade
.getPlantDescription(Language
.FRENCH()));
951 "Plant description data should be 'Nice here' for the default language",
952 "Nice here", specimenFacade
.getPlantDescription());
954 "Plant description data should be 'Nice here' for english",
955 "Nice here", specimenFacade
.getPlantDescription());
957 specimenFacade
.setPlantDescription("Vert et rouge", Language
.FRENCH());
959 "Plant description data should exist for 2 languages", 2,
960 specimenFacade
.getPlantDescriptionAll().size());
961 Assert
.assertEquals("Plant description data should be 'Vert et rouge'",
963 specimenFacade
.getPlantDescription(Language
.FRENCH()));
965 "Plant description data should be 'Nice here' for the default language",
966 "Nice here", specimenFacade
.getPlantDescription());
968 specimenFacade
.setPlantDescription(null, Language
.FRENCH());
970 "Plant description data should exist for 1 languages", 1,
971 specimenFacade
.getPlantDescriptionAll().size());
973 "Plant description data should be 'Nice here' for the default language",
974 "Nice here", specimenFacade
.getPlantDescription());
975 Assert
.assertNull("Plant description data should be 'null' for French",
976 specimenFacade
.getPlantDescription(Language
.FRENCH()));
978 // test interference with ecology
979 specimenFacade
.setEcology("Tres jolie ici", Language
.FRENCH());
980 Assert
.assertEquals("Ecology data should exist for 1 language", 1,
981 specimenFacade
.getEcologyAll().size());
983 "Ecology data should be 'Tres jolie ici' for French",
984 "Tres jolie ici", specimenFacade
.getEcology(Language
.FRENCH()));
986 "Ecology data should be null for the default language",
987 specimenFacade
.getEcology());
991 "Plant description data should exist for 1 languages", 1,
992 specimenFacade
.getPlantDescriptionAll().size());
994 "Plant description data should be 'Nice here' for the default language",
995 "Nice here", specimenFacade
.getPlantDescription());
996 Assert
.assertNull("Plant description data should be 'null' for French",
997 specimenFacade
.getPlantDescription(Language
.FRENCH()));
999 specimenFacade
.removePlantDescription(null);
1000 Assert
.assertEquals("There should be no plant description left", 0,
1001 specimenFacade
.getPlantDescriptionAll().size());
1003 "Plant description data should be 'null' for default language",
1004 specimenFacade
.getPlantDescription());
1010 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getFieldNumber()}.
1013 public void testGetSetFieldNumber() {
1014 Assert
.assertEquals("Field number must be same", fieldNumber
,
1015 specimenFacade
.getFieldNumber());
1016 specimenFacade
.setFieldNumber("564AB");
1017 Assert
.assertEquals("New field number must be '564AB'", "564AB",
1018 specimenFacade
.getFieldNumber());
1019 // empty facade tests
1020 Assert
.assertNull("Empty facace must not have any field value",
1021 emptyFacade
.getFieldNumber());
1022 emptyFacade
.setFieldNumber("1256A");
1023 Assert
.assertNotNull(
1024 "Field unit must exist if field number exists",
1025 emptyFacade
.getFieldUnit(false));
1026 FieldUnit specimenFieldUnit
= (FieldUnit
) emptyFacade
1027 .innerDerivedUnit().getDerivedFrom().getOriginals().iterator()
1030 "Field unit of facade and of specimen must be the same",
1032 emptyFacade
.getFieldUnit(false));
1033 Assert
.assertEquals("1256A", emptyFacade
.getFieldNumber());
1038 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getFieldNotes()}.
1041 public void testGetSetFieldNotes() {
1042 Assert
.assertEquals("Field notes must be same", fieldNotes
,
1043 specimenFacade
.getFieldNotes());
1044 specimenFacade
.setFieldNotes("A completely new info");
1045 Assert
.assertEquals("New field note must be 'A completely new info'",
1046 "A completely new info", specimenFacade
.getFieldNotes());
1051 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#setGatheringEvent(eu.etaxonomy.cdm.model.occurrence.GatheringEvent)}
1055 @Ignore // #######DerivationEvent ---------------------------------------- 1
1056 public void testSetGatheringEvent() {
1057 GatheringEvent newGatheringEvent
= GatheringEvent
.NewInstance();
1058 newGatheringEvent
.setDistanceToGround(43.0);
1059 Assert
.assertFalse("The initial distance to ground should not be 43",
1060 specimenFacade
.getDistanceToGround() == 43.0);
1061 specimenFacade
.setGatheringEvent(newGatheringEvent
);
1062 Assert
.assertTrue("The final distance to ground should be 43",
1063 specimenFacade
.getDistanceToGround() == 43.0);
1065 "The new gathering event should be 'newGatheringEvent'",
1066 newGatheringEvent
, specimenFacade
.innerGatheringEvent());
1071 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#innerGatheringEvent()}
1075 public void testGetGatheringEvent() {
1076 Assert
.assertNotNull("Gathering event must not be null",
1077 specimenFacade
.innerGatheringEvent());
1078 Assert
.assertEquals(
1079 "Gathering event must be field unit's gathering event",
1080 specimenFacade
.innerFieldUnit().getGatheringEvent(),
1081 specimenFacade
.innerGatheringEvent());
1086 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getIndividualCount()}
1090 public void testGetSetIndividualCount() {
1091 Assert
.assertEquals("Individual count must be same", individualCount
,
1092 specimenFacade
.getIndividualCount());
1093 specimenFacade
.setIndividualCount(4);
1094 Assert
.assertEquals("New individual count must be '4'",
1095 Integer
.valueOf(4), specimenFacade
.getIndividualCount());
1101 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getLifeStage()}.
1104 public void testGetSetLifeStage() {
1105 Assert
.assertNotNull("Life stage must not be null",
1106 specimenFacade
.getLifeStage());
1107 Assert
.assertEquals("Life stage must be same", lifeStage
,
1108 specimenFacade
.getLifeStage());
1109 specimenFacade
.setLifeStage(null);
1110 Assert
.assertNull("Life stage must be null",
1111 specimenFacade
.getLifeStage());
1116 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getSex()}.
1119 public void testGetSetSex() {
1120 Assert
.assertNotNull("Sex must not be null", specimenFacade
.getSex());
1121 Assert
.assertEquals("Sex must be same", sex
, specimenFacade
.getSex());
1122 specimenFacade
.setSex(null);
1123 Assert
.assertNull("Sex must be null", specimenFacade
.getSex());
1128 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getLocality()}.
1131 public void testGetSetLocality() {
1132 Assert
.assertEquals("Locality must be same", locality
,
1133 specimenFacade
.getLocality());
1134 specimenFacade
.setLocality("A completely new place", Language
.FRENCH());
1135 Assert
.assertEquals("New locality must be 'A completely new place'",
1136 "A completely new place", specimenFacade
.getLocalityText());
1137 Assert
.assertEquals("New locality language must be French",
1138 Language
.FRENCH(), specimenFacade
.getLocalityLanguage());
1139 specimenFacade
.setLocality("Another place");
1140 Assert
.assertEquals("New locality must be 'Another place'",
1141 "Another place", specimenFacade
.getLocalityText());
1142 Assert
.assertEquals("New locality language must be default",
1143 Language
.DEFAULT(), specimenFacade
.getLocalityLanguage());
1148 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#addDerivedUnitDefinition(java.lang.String, eu.etaxonomy.cdm.model.common.Language)}
1152 public void testAddGetRemoveSpecimenDefinition() {
1153 Assert
.assertEquals("There should be no definition yet", 0,
1154 specimenFacade
.getDerivedUnitDefinitions().size());
1155 specimenFacade
.addDerivedUnitDefinition("Tres interesant",
1157 Assert
.assertEquals("There should be exactly one definition", 1,
1158 specimenFacade
.getDerivedUnitDefinitions().size());
1159 Assert
.assertEquals(
1160 "The French definition should be 'Tres interesant'",
1161 "Tres interesant", specimenFacade
.getDerivedUnitDefinitions()
1162 .get(Language
.FRENCH()).getText());
1163 Assert
.assertEquals(
1164 "The French definition should be 'Tres interesant'",
1166 specimenFacade
.getDerivedUnitDefinition(Language
.FRENCH()));
1167 specimenFacade
.addDerivedUnitDefinition("Sehr interessant",
1169 Assert
.assertEquals("There should be exactly 2 definition", 2,
1170 specimenFacade
.getDerivedUnitDefinitions().size());
1171 specimenFacade
.removeDerivedUnitDefinition(Language
.FRENCH());
1172 Assert
.assertEquals("There should remain exactly 1 definition", 1,
1173 specimenFacade
.getDerivedUnitDefinitions().size());
1174 Assert
.assertEquals(
1175 "The remaining German definition should be 'Sehr interessant'",
1177 specimenFacade
.getDerivedUnitDefinition(Language
.GERMAN()));
1178 specimenFacade
.removeDerivedUnitDefinition(Language
.GERMAN());
1179 Assert
.assertEquals("There should remain no definition", 0,
1180 specimenFacade
.getDerivedUnitDefinitions().size());
1185 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#addDetermination(eu.etaxonomy.cdm.model.occurrence.DeterminationEvent)}
1189 public void testAddGetRemoveDetermination() {
1190 Assert
.assertEquals("There should be no determination yet", 0,
1191 specimenFacade
.getDeterminations().size());
1192 DeterminationEvent determinationEvent1
= DeterminationEvent
1194 specimenFacade
.addDetermination(determinationEvent1
);
1195 Assert
.assertEquals("There should be exactly one determination", 1,
1196 specimenFacade
.getDeterminations().size());
1197 Assert
.assertEquals("The only determination should be determination 1",
1198 determinationEvent1
, specimenFacade
.getDeterminations()
1199 .iterator().next());
1201 DeterminationEvent determinationEvent2
= DeterminationEvent
1203 specimenFacade
.addDetermination(determinationEvent2
);
1204 Assert
.assertEquals("There should be exactly 2 determinations", 2,
1205 specimenFacade
.getDeterminations().size());
1206 specimenFacade
.removeDetermination(determinationEvent1
);
1208 Assert
.assertEquals("There should remain exactly 1 determination", 1,
1209 specimenFacade
.getDeterminations().size());
1210 Assert
.assertEquals(
1211 "The remaining determinations should be determination 2",
1212 determinationEvent2
, specimenFacade
.getDeterminations()
1213 .iterator().next());
1215 specimenFacade
.removeDetermination(determinationEvent1
);
1216 Assert
.assertEquals("There should remain exactly 1 determination", 1,
1217 specimenFacade
.getDeterminations().size());
1219 specimenFacade
.removeDetermination(determinationEvent2
);
1220 Assert
.assertEquals("There should remain no definition", 0,
1221 specimenFacade
.getDerivedUnitDefinitions().size());
1228 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#addDetermination(eu.etaxonomy.cdm.model.occurrence.DeterminationEvent)}
1232 public void testPreferredOtherDeterminations() {
1233 Assert
.assertEquals("There should be no determination yet", 0,
1234 specimenFacade
.getDeterminations().size());
1235 DeterminationEvent determinationEvent1
= DeterminationEvent
.NewInstance();
1236 specimenFacade
.setPreferredDetermination(determinationEvent1
);
1238 Assert
.assertEquals("There should be exactly one determination", 1,
1239 specimenFacade
.getDeterminations().size());
1240 Assert
.assertEquals("The only determination should be determination 1",
1241 determinationEvent1
, specimenFacade
.getDeterminations()
1242 .iterator().next());
1243 Assert
.assertEquals("determination 1 should be the preferred determination",
1244 determinationEvent1
, specimenFacade
.getPreferredDetermination());
1245 Assert
.assertEquals("There should be no 'non preferred' determination", 0,
1246 specimenFacade
.getOtherDeterminations().size());
1250 DeterminationEvent determinationEvent2
= DeterminationEvent
.NewInstance();
1251 specimenFacade
.addDetermination(determinationEvent2
);
1252 Assert
.assertEquals("There should be exactly 2 determinations", 2,
1253 specimenFacade
.getDeterminations().size());
1254 Assert
.assertEquals("determination 1 should be the preferred determination",
1255 determinationEvent1
, specimenFacade
.getPreferredDetermination());
1256 Assert
.assertEquals("There should be one 'non preferred' determination", 1,
1257 specimenFacade
.getOtherDeterminations().size());
1258 Assert
.assertEquals("The only 'non preferred' determination should be determination 2",
1259 determinationEvent2
, specimenFacade
.getOtherDeterminations().iterator().next());
1262 DeterminationEvent determinationEvent3
= DeterminationEvent
.NewInstance();
1263 specimenFacade
.setPreferredDetermination(determinationEvent3
);
1264 Assert
.assertEquals("There should be exactly 3 determinations", 3,
1265 specimenFacade
.getDeterminations().size());
1266 Assert
.assertEquals("determination 3 should be the preferred determination",
1267 determinationEvent3
, specimenFacade
.getPreferredDetermination());
1268 Assert
.assertEquals("There should be 2 'non preferred' determination", 2,
1269 specimenFacade
.getOtherDeterminations().size());
1270 Assert
.assertTrue("determination 1 should be contained in the set of 'non preferred' determinations",
1271 specimenFacade
.getOtherDeterminations().contains(determinationEvent1
));
1272 Assert
.assertTrue("determination 2 should be contained in the set of 'non preferred' determinations",
1273 specimenFacade
.getOtherDeterminations().contains(determinationEvent2
));
1279 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#addDerivedUnitMedia(eu.etaxonomy.cdm.model.media.Media)}
1283 public void testAddGetHasRemoveSpecimenMedia() {
1284 Assert
.assertFalse("There should be no image gallery yet",
1285 specimenFacade
.hasDerivedUnitImageGallery());
1287 "There should be also no field object image gallery yet",
1288 specimenFacade
.hasFieldObjectImageGallery());
1290 List
<Media
> media
= specimenFacade
.getDerivedUnitMedia();
1292 "There should still not be an empty image gallery now",
1293 specimenFacade
.hasDerivedUnitImageGallery());
1294 Assert
.assertEquals("There should be no media yet in the gallery", 0,
1297 Media media1
= Media
.NewInstance();
1298 specimenFacade
.addDerivedUnitMedia(media1
);
1299 Assert
.assertEquals("There should be exactly one specimen media", 1,
1300 specimenFacade
.getDerivedUnitMedia().size());
1301 Assert
.assertEquals("The only media should be media 1", media1
,
1302 specimenFacade
.getDerivedUnitMedia().get(0));
1304 "There should be still no field object image gallery",
1305 specimenFacade
.hasFieldObjectImageGallery());
1307 Media media2
= Media
.NewInstance();
1308 specimenFacade
.addDerivedUnitMedia(media2
);
1309 Assert
.assertEquals("There should be exactly 2 specimen media", 2,
1310 specimenFacade
.getDerivedUnitMedia().size());
1311 Assert
.assertEquals("The first media should be media1", media1
,
1312 specimenFacade
.getDerivedUnitMedia().get(0));
1313 Assert
.assertEquals("The second media should be media2", media2
,
1314 specimenFacade
.getDerivedUnitMedia().get(1));
1316 specimenFacade
.removeDerivedUnitMedia(media1
);
1317 Assert
.assertEquals("There should be exactly one specimen media", 1,
1318 specimenFacade
.getDerivedUnitMedia().size());
1319 Assert
.assertEquals("The only media should be media2", media2
,
1320 specimenFacade
.getDerivedUnitMedia().get(0));
1322 specimenFacade
.removeDerivedUnitMedia(media1
);
1323 Assert
.assertEquals("There should still be exactly one specimen media",
1324 1, specimenFacade
.getDerivedUnitMedia().size());
1326 specimenFacade
.removeDerivedUnitMedia(media2
);
1327 Assert
.assertEquals("There should remain no media in the gallery", 0,
1333 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getAccessionNumber()}
1337 public void testGetSetAccessionNumber() {
1338 Assert
.assertEquals("Accession number must be same", accessionNumber
,
1339 specimenFacade
.getAccessionNumber());
1340 specimenFacade
.setAccessionNumber("A12345693");
1341 Assert
.assertEquals("New accession number must be 'A12345693'",
1342 "A12345693", specimenFacade
.getAccessionNumber());
1347 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getCatalogNumber()}.
1350 public void testGetCatalogNumber() {
1351 Assert
.assertEquals("Catalog number must be same", catalogNumber
,
1352 specimenFacade
.getCatalogNumber());
1353 specimenFacade
.setCatalogNumber("B12345693");
1354 Assert
.assertEquals("New catalog number must be 'B12345693'",
1355 "B12345693", specimenFacade
.getCatalogNumber());
1360 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getPreservation()}.
1363 public void testGetPreservation() {
1365 Assert
.assertNotNull("Preservation method must not be null",
1366 specimenFacade
.getPreservationMethod());
1367 Assert
.assertEquals("Preservation method must be same",
1368 preservationMethod
, specimenFacade
.getPreservationMethod());
1369 specimenFacade
.setPreservationMethod(null);
1370 Assert
.assertNull("Preservation method must be null",
1371 specimenFacade
.getPreservationMethod());
1372 } catch (MethodNotSupportedByDerivedUnitTypeException e
) {
1373 Assert
.fail("Method not supported should not be thrown for a specimen");
1375 specimenFacade
= DerivedUnitFacade
.NewInstance(SpecimenOrObservationType
.Observation
);
1377 specimenFacade
.setPreservationMethod(preservationMethod
);
1378 Assert
.fail("Method not supported should be thrown for an observation on set preservation method");
1380 } catch (MethodNotSupportedByDerivedUnitTypeException e
) {
1383 specimenFacade
= DerivedUnitFacade
.NewInstance(SpecimenOrObservationType
.LivingSpecimen
);
1385 specimenFacade
.getPreservationMethod();
1386 Assert
.fail("Method not supported should be thrown for a living being on get preservation method");
1387 } catch (MethodNotSupportedByDerivedUnitTypeException e
) {
1395 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getStoredUnder()}.
1398 public void testGetStoredUnder() {
1399 Assert
.assertNotNull("Stored under name must not be null",
1400 specimenFacade
.getStoredUnder());
1401 Assert
.assertEquals("Stored under name must be same", taxonName
,
1402 specimenFacade
.getStoredUnder());
1403 specimenFacade
.setStoredUnder(null);
1404 Assert
.assertNull("Stored under name must be null",
1405 specimenFacade
.getStoredUnder());
1409 // * Test method for
1410 // * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getCollectorsNumber()}
1414 // public void testGetSetCollectorsNumber() {
1415 // Assert.assertEquals("Collectors number must be same", collectorsNumber,
1416 // specimenFacade.getCollectorsNumber());
1417 // specimenFacade.setCollectorsNumber("C12345693");
1418 // Assert.assertEquals("New collectors number must be 'C12345693'",
1419 // "C12345693", specimenFacade.getCollectorsNumber());
1424 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getTitleCache()}.
1427 public void testGetTitleCache() {
1428 Assert
.assertNotNull(
1429 "The title cache should never return null if not protected",
1430 specimenFacade
.getTitleCache());
1431 specimenFacade
.setTitleCache(null, false);
1432 Assert
.assertNotNull(
1433 "The title cache should never return null if not protected",
1434 specimenFacade
.getTitleCache());
1439 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#setTitleCache(java.lang.String)}
1443 public void testSetTitleCache() {
1444 String testTitle
= "Absdwk aksjlf";
1445 specimenFacade
.setTitleCache(testTitle
, true);
1446 Assert
.assertEquals(
1447 "Protected title cache should returns the test title",
1448 testTitle
, specimenFacade
.getTitleCache());
1449 specimenFacade
.setTitleCache(testTitle
, false);
1451 "Unprotected title cache should not return the test title",
1452 testTitle
.equals(specimenFacade
.getTitleCache()));
1457 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#innerDerivedUnit()}.
1460 public void testGetSpecimen() {
1461 Assert
.assertEquals("Specimen must be same", specimen
,
1462 specimenFacade
.innerDerivedUnit());
1467 * {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#getCollection()}.
1470 public void testGetSetCollection() {
1471 Assert
.assertNotNull("Collection must not be null",
1472 specimenFacade
.getCollection());
1473 Assert
.assertEquals("Collection must be same", collection
,
1474 specimenFacade
.getCollection());
1475 specimenFacade
.setCollection(null);
1476 Assert
.assertNull("Collection must be null",
1477 specimenFacade
.getCollection());
1481 public void testAddGetRemoveSource() {
1482 Assert
.assertEquals("No sources should exist yet", 0, specimenFacade
.getSources().size());
1484 Reference
<?
> reference
= ReferenceFactory
.newBook();
1485 IdentifiableSource source1
= specimenFacade
.addSource(OriginalSourceType
.PrimaryTaxonomicSource
, reference
, "54", "myName");
1486 Assert
.assertEquals("One source should exist now", 1, specimenFacade
.getSources().size());
1487 IdentifiableSource source2
= IdentifiableSource
.NewDataImportInstance("1", "myTable");
1488 specimenFacade
.addSource(source2
);
1489 Assert
.assertEquals("One source should exist now", 2, specimenFacade
.getSources().size());
1490 specimenFacade
.removeSource(source1
);
1491 Assert
.assertEquals("One source should exist now", 1, specimenFacade
.getSources().size());
1492 Reference
<?
> reference2
= ReferenceFactory
.newJournal();
1493 IdentifiableSource sourceNotUsed
= specimenFacade
.addSource(OriginalSourceType
.PrimaryTaxonomicSource
, reference2
,null, null);
1494 specimenFacade
.removeSource(sourceNotUsed
);
1495 Assert
.assertEquals("One source should still exist", 1, specimenFacade
.getSources().size());
1496 Assert
.assertEquals("1", specimenFacade
.getSources().iterator().next().getIdInSource());
1497 specimenFacade
.removeSource(source2
);
1498 Assert
.assertEquals("No sources should exist anymore", 0,specimenFacade
.getSources().size());
1502 public void testAddGetRemoveDuplicate() {
1503 Assert
.assertEquals("No duplicates should be available yet", 0,specimenFacade
.getDuplicates().size());
1504 DerivedUnit newSpecimen1
= DerivedUnit
.NewPreservedSpecimenInstance();
1505 specimenFacade
.addDuplicate(newSpecimen1
);
1506 Assert
.assertEquals("There should be 1 duplicate now", 1,specimenFacade
.getDuplicates().size());
1507 DerivedUnit newSpecimen2
= DerivedUnit
.NewPreservedSpecimenInstance();
1508 DerivationEvent newDerivationEvent
= DerivationEvent
.NewInstance(DerivationEventType
.ACCESSIONING());
1509 newSpecimen2
.setDerivedFrom(newDerivationEvent
);
1511 "The derivation event should be 'newDerivationEvent'",
1512 newDerivationEvent
, newSpecimen2
.getDerivedFrom());
1513 specimenFacade
.addDuplicate(newSpecimen2
);
1514 Assert
.assertEquals("There should be 2 duplicates now", 2, specimenFacade
.getDuplicates().size());
1515 Assert
.assertNotSame(
1516 "The derivation event should not be 'newDerivationEvent' anymore",
1517 newDerivationEvent
, newSpecimen2
.getDerivedFrom());
1519 "The derivation event should not be the facades derivation event",
1520 derivationEvent
, newSpecimen2
.getDerivedFrom());
1521 specimenFacade
.removeDuplicate(newSpecimen1
);
1522 Assert
.assertEquals("There should be 1 duplicate now", 1,
1523 specimenFacade
.getDuplicates().size());
1524 Assert
.assertSame("The only duplicate should be 'newSpecimen2' now",
1525 newSpecimen2
, specimenFacade
.getDuplicates().iterator().next());
1526 specimenFacade
.addDuplicate(specimenFacade
.innerDerivedUnit());
1527 Assert
.assertEquals(
1528 "There should be still 1 duplicate because the facade specimen is not a duplicate",
1529 1, specimenFacade
.getDuplicates().size());
1531 Collection newCollection
= Collection
.NewInstance();
1532 String catalogNumber
= "1234890";
1533 String accessionNumber
= "345345";
1534 TaxonNameBase
<?
,?
> storedUnder
= BotanicalName
.NewInstance(Rank
.SPECIES());
1535 PreservationMethod method
= PreservationMethod
.NewInstance();
1536 DerivedUnit duplicateSpecimen
= specimenFacade
.addDuplicate(newCollection
,
1537 catalogNumber
, accessionNumber
, storedUnder
,
1539 Assert
.assertEquals("There should be 2 duplicates now", 2,
1540 specimenFacade
.getDuplicates().size());
1541 specimenFacade
.removeDuplicate(newSpecimen2
);
1542 Assert
.assertEquals("There should be 1 duplicates now", 1,
1543 specimenFacade
.getDuplicates().size());
1544 Collection sameCollection
= specimenFacade
.getDuplicates().iterator().next().getCollection();
1545 Assert
.assertSame("Collections should be same", newCollection
, sameCollection
);
1548 // ************************** Existing Specimen with multiple derivation
1549 // events in line **************/
1552 public void testExistingSpecimen() {
1553 specimenFacade
= null;
1555 specimenFacade
= DerivedUnitFacade
.NewInstance(collectionSpecimen
);
1556 } catch (DerivedUnitFacadeNotSupportedException e
) {
1557 Assert
.fail("Multiple derivation events in line should not throw a not supported exception");
1560 "Gathering event should derive from the derivation line",
1561 existingGatheringEvent
, specimenFacade
.innerGatheringEvent());
1562 Assert
.assertEquals(
1563 "Mediasize should be 0. Only Imagegallery media are supported",
1564 0, specimenFacade
.getFieldObjectMedia().size());
1568 public void testMultipleFieldUnitNotSupported() {
1569 specimenFacade
= null;
1570 FieldUnit secondFieldObject
= FieldUnit
.NewInstance();
1571 firstDerivationEvent
.addOriginal(secondFieldObject
);
1573 specimenFacade
= DerivedUnitFacade
.NewInstance(collectionSpecimen
);
1574 Assert
.fail("Multiple field units for one specimen should no be supported by the facade");
1575 } catch (DerivedUnitFacadeNotSupportedException e
) {
1578 Assert
.assertNull("Specimen facade should not be initialized",
1582 // not required anymore #3597
1583 // @Test // #######DerivationEvent
1584 // public void testOnlyImageGallerySupported() {
1585 // specimenFacade = null;
1586 // firstFieldObject.addMedia(media1);
1588 // specimenFacade = DerivedUnitFacade.NewInstance(collectionSpecimen);
1589 // Assert.fail("Only image galleries are supported by the facade but not direct media");
1590 // } catch (DerivedUnitFacadeNotSupportedException e) {
1593 // Assert.assertNull("Specimen facade should not be initialized",
1597 @Test // #######DerivationEvent
1598 public void testEventPropagation() {
1599 specimenFacade
.setDistanceToGround(24.0);
1603 // @Ignore // set to ignore because I did not want to check knowingly
1604 // failing tests. Remove @Ignore when this is fixed
1606 public void testSetBarcode() {
1607 String barcode
= "barcode";
1608 specimenFacade
.setBarcode(barcode
);
1610 Assert
.assertEquals(barcode
, specimenFacade
.getBarcode());
1614 public void testIsEvenDistance() {
1615 Integer minimum
= 20;
1616 Integer maximum
= 1234;
1618 // this should not throw exceptions
1619 specimenFacade
.setAbsoluteElevationRange(minimum
, maximum
);
1624 * See https://dev.e-taxonomy.eu/trac/ticket/2426
1625 * This test doesn't handle the above issue yet as it doesn't fire events as
1626 * expected (at least it does not reproduce the behaviour in the Taxonomic Editor).
1627 * In the meanwhile the property change framework for the facade has been changed
1628 * so the original problem may have disappeared.
1632 public void testNoRecursiveChangeEvents(){
1633 String username
= "username";
1634 String password
= "password";
1635 User user
= User
.NewInstance(username
, password
);
1636 userService
.save(user
);
1637 UsernamePasswordAuthenticationToken token
= new UsernamePasswordAuthenticationToken(user
, password
);
1638 SecurityContextHolder
.getContext().setAuthentication(token
);
1640 DerivedUnitFacade facade
= DerivedUnitFacade
.NewInstance(SpecimenOrObservationType
.PreservedSpecimen
);
1641 facade
.setLocality("testLocality");
1642 facade
.getTitleCache();
1643 // facade.innerGatheringEvent().firePropertyChange("createdBy", null, user);
1644 this.service
.save(facade
.innerDerivedUnit());
1645 commitAndStartNewTransaction(null);