1
|
/**
|
2
|
* Copyright (C) 2009 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
|
|
10
|
package eu.etaxonomy.cdm.database;
|
11
|
|
12
|
import static org.junit.Assert.assertEquals;
|
13
|
import static org.junit.Assert.assertFalse;
|
14
|
import static org.junit.Assert.assertNotNull;
|
15
|
import static org.junit.Assert.assertNull;
|
16
|
|
17
|
import java.util.HashMap;
|
18
|
import java.util.UUID;
|
19
|
import java.util.Map;
|
20
|
|
21
|
import org.junit.Ignore;
|
22
|
import org.junit.Test;
|
23
|
import org.unitils.dbunit.annotation.DataSet;
|
24
|
import org.unitils.spring.annotation.SpringApplicationContext;
|
25
|
import org.unitils.spring.annotation.SpringBeanByType;
|
26
|
|
27
|
import eu.etaxonomy.cdm.model.common.DefaultTermInitializer;
|
28
|
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
|
29
|
import eu.etaxonomy.cdm.model.common.Language;
|
30
|
import eu.etaxonomy.cdm.model.common.TermVocabulary;
|
31
|
import eu.etaxonomy.cdm.model.common.VocabularyEnum;
|
32
|
import eu.etaxonomy.cdm.model.name.Rank;
|
33
|
import eu.etaxonomy.cdm.test.integration.CdmIntegrationTest;
|
34
|
|
35
|
@Ignore
|
36
|
@SpringApplicationContext("classpath:eu/etaxonomy/cdm/applicationContext-testPersistentDataSource.xml")
|
37
|
public class PersistentTermInitializerTest extends CdmIntegrationTest {
|
38
|
|
39
|
@SpringBeanByType
|
40
|
private PersistentTermInitializer persistentTermInitializer;
|
41
|
|
42
|
@Test
|
43
|
public void testInit() {
|
44
|
assertNotNull("TermInitializer should exist",persistentTermInitializer);
|
45
|
}
|
46
|
|
47
|
|
48
|
@Test
|
49
|
@DataSet("TermsDataSet.xml")
|
50
|
public void testFirstPass() {
|
51
|
Map<UUID, DefinedTermBase> persistedTerms = new HashMap<UUID, DefinedTermBase>();
|
52
|
persistentTermInitializer.firstPass(VocabularyEnum.Rank, persistedTerms);
|
53
|
}
|
54
|
|
55
|
/**
|
56
|
* Test method for {@link eu.etaxonomy.cdm.model.common.DefaultTermInitializer#initialize()}.
|
57
|
*/
|
58
|
@Test
|
59
|
@Ignore // does not run yet in a test suite as the Language.DEFAULT() is not null then
|
60
|
public void testInitialize() {
|
61
|
assertNull("At the beginning of the initialization test the default language should still be null but is not", Language.DEFAULT());
|
62
|
persistentTermInitializer.initialize();
|
63
|
assertNotNull("TermInitializer should exist",persistentTermInitializer);
|
64
|
assertNotNull("TermInitializer should have initialized Language.DEFAULT",Language.DEFAULT());
|
65
|
assertEquals("Language.DEFAULT should equal Language.ENGLISH",Language.DEFAULT(),Language.ENGLISH());
|
66
|
TermVocabulary<Language> voc = Language.DEFAULT().getVocabulary();
|
67
|
assertNotNull("language for language vocabulary representation was null but must be default language", voc.getRepresentation(Language.DEFAULT()));
|
68
|
}
|
69
|
|
70
|
@Ignore //please commit only with ignore
|
71
|
@Test
|
72
|
public void testPrintData() {
|
73
|
printDataSet(System.out);
|
74
|
}
|
75
|
|
76
|
@Test
|
77
|
public void testGetRepresentations() {
|
78
|
assertNotNull("Rank.SPECIES() should not be null", Rank.SPECIES());
|
79
|
assertFalse("Rank.SPECIES().getRepresentations() should not be empty",Rank.SPECIES().getRepresentations().isEmpty());
|
80
|
assertEquals("Rank.SPECIES().getLabel() should return \"Species\"","Species",Rank.SPECIES().getLabel());
|
81
|
|
82
|
}
|
83
|
|
84
|
|
85
|
|
86
|
}
|