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.common.Identifier;
|
17
|
import eu.etaxonomy.cdm.model.common.Language;
|
18
|
import eu.etaxonomy.cdm.model.molecular.DnaSample;
|
19
|
import eu.etaxonomy.cdm.model.occurrence.Collection;
|
20
|
import eu.etaxonomy.cdm.model.term.DefinedTerm;
|
21
|
import eu.etaxonomy.cdm.test.TermTestBase;
|
22
|
|
23
|
/**
|
24
|
* @author a.mueller
|
25
|
* @since 09.01.2021
|
26
|
*/
|
27
|
public class DnaSampleDefaultCacheStrategyTest extends TermTestBase {
|
28
|
|
29
|
@Test
|
30
|
public void test() {
|
31
|
DnaSample specimen = DnaSample.NewInstance();
|
32
|
specimen.setUuid(UUID.fromString("b5fa679f-12a1-4f47-906a-28b41c90f019"));
|
33
|
DnaSampleDefaultCacheStrategy strategy = new DnaSampleDefaultCacheStrategy();
|
34
|
|
35
|
Assert.assertEquals("DnaSample#0<b5fa679f-12a1-4f47-906a-28b41c90f019>", strategy.getTitleCache(specimen));
|
36
|
|
37
|
Collection collection = Collection.NewInstance();
|
38
|
collection.setCode("B");
|
39
|
specimen.setCollection(collection);
|
40
|
Assert.assertEquals("B", strategy.getTitleCache(specimen));
|
41
|
|
42
|
specimen.setAccessionNumber("123");
|
43
|
Assert.assertEquals("B 123", strategy.getTitleCache(specimen));
|
44
|
|
45
|
Identifier identifier = Identifier.NewInstance(specimen, "id3", DefinedTerm.IDENTIFIER_NAME_IPNI());
|
46
|
Assert.assertEquals("B 123", strategy.getTitleCache(specimen));
|
47
|
specimen.setCollection(null);
|
48
|
specimen.setAccessionNumber(null);
|
49
|
Assert.assertEquals("id3", strategy.getTitleCache(specimen));
|
50
|
|
51
|
specimen.putDefinition(Language.ENGLISH(), "sample definition");
|
52
|
Assert.assertEquals("id3", strategy.getTitleCache(specimen));
|
53
|
specimen.removeIdentifier(identifier);
|
54
|
Assert.assertEquals("sample definition", strategy.getTitleCache(specimen));
|
55
|
|
56
|
specimen.addImportSource("123", "dna", null, null);
|
57
|
Assert.assertEquals("sample definition", strategy.getTitleCache(specimen));
|
58
|
specimen.removeDefinition(Language.ENGLISH());
|
59
|
Assert.assertEquals("dna:123", strategy.getTitleCache(specimen));
|
60
|
|
61
|
Assert.assertNull(strategy.getTitleCache(null));
|
62
|
}
|
63
|
}
|