1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.model.term.init;
|
10
|
|
11
|
import static org.junit.Assert.assertNotNull;
|
12
|
import static org.junit.Assert.assertTrue;
|
13
|
|
14
|
import java.util.HashMap;
|
15
|
import java.util.Map;
|
16
|
import java.util.UUID;
|
17
|
|
18
|
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
|
19
|
import org.junit.Assert;
|
20
|
import org.junit.Before;
|
21
|
import org.junit.Test;
|
22
|
|
23
|
import eu.etaxonomy.cdm.model.common.AnnotationType;
|
24
|
import eu.etaxonomy.cdm.model.name.NameTypeDesignationStatus;
|
25
|
import eu.etaxonomy.cdm.model.name.Rank;
|
26
|
import eu.etaxonomy.cdm.model.term.DefaultTermInitializer;
|
27
|
import eu.etaxonomy.cdm.model.term.DefinedTermBase;
|
28
|
import eu.etaxonomy.cdm.model.term.TermVocabulary;
|
29
|
import eu.etaxonomy.cdm.model.term.VocabularyEnum;
|
30
|
|
31
|
/**
|
32
|
* @author a.mueller
|
33
|
*/
|
34
|
public class TermLoaderTest {
|
35
|
static Logger logger = LogManager.getLogger(TermLoaderTest.class);
|
36
|
|
37
|
private TermLoader termLoader;
|
38
|
private Map<UUID,DefinedTermBase> terms;
|
39
|
|
40
|
private UUID uuidGenus;
|
41
|
private UUID uuidTautonymy;
|
42
|
|
43
|
@Before
|
44
|
public void setUp() throws Exception {
|
45
|
termLoader = new TermLoader();
|
46
|
terms = new HashMap<>();
|
47
|
uuidGenus = UUID.fromString("1b11c34c-48a8-4efa-98d5-84f7f66ef43a");
|
48
|
uuidTautonymy = UUID.fromString("84521f09-3e10-43f5-aa6f-2173a55a6790");
|
49
|
}
|
50
|
|
51
|
/************** TESTS **********************************/
|
52
|
|
53
|
@Test
|
54
|
public void testLoadRanks() {
|
55
|
TermVocabulary<Rank> defaultRanks = termLoader.loadTerms(VocabularyEnum.Rank, terms);
|
56
|
assertNotNull(defaultRanks.findTermByUuid(uuidGenus));
|
57
|
assertTrue(terms.containsKey(uuidGenus));
|
58
|
}
|
59
|
|
60
|
@Test
|
61
|
public void testLoadNameTypeDesignationStatus() {
|
62
|
TermVocabulary<NameTypeDesignationStatus> defaultStatus = termLoader.loadTerms(VocabularyEnum.NameTypeDesignationStatus, terms);
|
63
|
assertNotNull(defaultStatus.findTermByUuid(uuidTautonymy));
|
64
|
assertTrue(terms.containsKey(uuidTautonymy));
|
65
|
}
|
66
|
|
67
|
@Test
|
68
|
public void testUnloadAllTerms(){
|
69
|
DefaultTermInitializer initializer = new DefaultTermInitializer();
|
70
|
initializer.initialize();
|
71
|
Assert.assertNotNull("Editorial annotation type should be loaded", AnnotationType.EDITORIAL());
|
72
|
termLoader.unloadAllTerms();
|
73
|
Assert.assertNull("Editorial annotation type should be unloaded now", AnnotationType.EDITORIAL());
|
74
|
}
|
75
|
}
|