1
|
/**
|
2
|
* Copyright (C) 2021 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.strategy.cache.occurrence;
|
10
|
|
11
|
import java.util.UUID;
|
12
|
|
13
|
import org.junit.Assert;
|
14
|
import org.junit.Test;
|
15
|
|
16
|
import eu.etaxonomy.cdm.model.media.Media;
|
17
|
import eu.etaxonomy.cdm.model.occurrence.Collection;
|
18
|
import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen;
|
19
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
|
20
|
import eu.etaxonomy.cdm.test.TermTestBase;
|
21
|
|
22
|
/**
|
23
|
* @author a.mueller
|
24
|
* @since 08.01.2021
|
25
|
*/
|
26
|
public class MediaSpecimenDefaultCacheStrategyTest extends TermTestBase {
|
27
|
|
28
|
@Test
|
29
|
public void test() {
|
30
|
MediaSpecimen specimen = MediaSpecimen.NewInstance(SpecimenOrObservationType.Media);
|
31
|
specimen.setUuid(UUID.fromString("b5fa679f-12a1-4f47-906a-28b41c90f019"));
|
32
|
MediaSpecimenDefaultCacheStrategy strategy = new MediaSpecimenDefaultCacheStrategy();
|
33
|
|
34
|
Assert.assertEquals("MediaSpecimen#0<b5fa679f-12a1-4f47-906a-28b41c90f019>", strategy.getTitleCache(specimen));
|
35
|
|
36
|
Collection collection = Collection.NewInstance();
|
37
|
collection.setCode("B");
|
38
|
specimen.setCollection(collection);
|
39
|
Assert.assertEquals("B", strategy.getTitleCache(specimen));
|
40
|
|
41
|
specimen.setAccessionNumber("123");
|
42
|
Assert.assertEquals("B 123", strategy.getTitleCache(specimen));
|
43
|
|
44
|
Media media = Media.NewInstance();
|
45
|
media.setTitleCache("Media title");
|
46
|
specimen.setMediaSpecimen(media);
|
47
|
Assert.assertEquals("B 123 (Media title)", strategy.getTitleCache(specimen));
|
48
|
|
49
|
specimen.setCollection(null);
|
50
|
specimen.setAccessionNumber(null);
|
51
|
Assert.assertEquals("Media title", strategy.getTitleCache(specimen));
|
52
|
|
53
|
Assert.assertNull(strategy.getTitleCache(null));
|
54
|
}
|
55
|
}
|