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
|
|
10
|
package eu.etaxonomy.cdm.persistence.dao.hibernate.common;
|
11
|
|
12
|
import java.io.FileNotFoundException;
|
13
|
|
14
|
import org.junit.Assert;
|
15
|
import org.junit.Test;
|
16
|
import org.unitils.dbunit.annotation.DataSet;
|
17
|
import org.unitils.spring.annotation.SpringBeanByType;
|
18
|
|
19
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
|
20
|
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
|
21
|
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
|
22
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
|
23
|
import eu.etaxonomy.cdm.persistence.dao.common.IPreferenceDao;
|
24
|
import eu.etaxonomy.cdm.test.integration.CdmIntegrationTest;
|
25
|
|
26
|
/**
|
27
|
* @author a.mueller
|
28
|
*
|
29
|
*/
|
30
|
public class PreferenceDaoTest extends CdmIntegrationTest {
|
31
|
|
32
|
@SpringBeanByType
|
33
|
IPreferenceDao dao;
|
34
|
|
35
|
/************ TESTS ********************************/
|
36
|
|
37
|
@Test
|
38
|
@DataSet
|
39
|
public void testDao() {
|
40
|
Assert.assertNotNull(dao);
|
41
|
}
|
42
|
|
43
|
@Test
|
44
|
@DataSet
|
45
|
public void testGet() {
|
46
|
PrefKey key = CdmPreference.NewKey(PreferenceSubject.Database, PreferencePredicate.NomenclaturalCode);
|
47
|
CdmPreference pref = dao.get(key);
|
48
|
Assert.assertNotNull("CdmPreference for given key must exist", pref);
|
49
|
Assert.assertEquals("ICNAFP", pref.getValue());
|
50
|
|
51
|
key = CdmPreference.NewKey(PreferenceSubject.Database, PreferencePredicate.Test);
|
52
|
pref = dao.get(key);
|
53
|
Assert.assertNull("CdmPreference for given key must not exist", pref);
|
54
|
}
|
55
|
|
56
|
|
57
|
@Test
|
58
|
@DataSet
|
59
|
public void testCount() {
|
60
|
int countStart = dao.count();
|
61
|
Assert.assertEquals("There should be 1 preference in the CDM store", 1, countStart);
|
62
|
}
|
63
|
|
64
|
@Test
|
65
|
@DataSet
|
66
|
public void testSet() {
|
67
|
int countStart = dao.count();
|
68
|
Assert.assertEquals(1, countStart);
|
69
|
|
70
|
CdmPreference pref = CdmPreference.NewInstance(PreferenceSubject.Database, PreferencePredicate.Test, "200");
|
71
|
dao.set(pref);
|
72
|
int count = dao.count();
|
73
|
Assert.assertEquals("There should be 1 new preference", countStart + 1, count);
|
74
|
|
75
|
pref = CdmPreference.NewInstance(PreferenceSubject.Database, PreferencePredicate.NomenclaturalCode, "ICZN");
|
76
|
dao.set(pref);
|
77
|
|
78
|
count = dao.count();
|
79
|
Assert.assertEquals("There should be only 1 new preference", countStart + 1, count);
|
80
|
|
81
|
}
|
82
|
|
83
|
/* (non-Javadoc)
|
84
|
* @see eu.etaxonomy.cdm.test.integration.CdmIntegrationTest#createTestData()
|
85
|
*/
|
86
|
@Override
|
87
|
public void createTestDataSet() throws FileNotFoundException {
|
88
|
// TODO Auto-generated method stub
|
89
|
|
90
|
}
|
91
|
}
|