2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.api
.service
;
12 import java
.io
.FileNotFoundException
;
14 import org
.junit
.Assert
;
15 import org
.junit
.Test
;
16 import org
.unitils
.dbunit
.annotation
.DataSet
;
17 import org
.unitils
.spring
.annotation
.SpringBeanByType
;
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
.test
.integration
.CdmIntegrationTest
;
29 public class PreferenceServiceImplTest
extends CdmIntegrationTest
{
32 IPreferenceService service
;
34 /************ TESTS ********************************/
38 public void testService() {
39 Assert
.assertNotNull(service
);
44 public void testGet() {
45 PrefKey key
= CdmPreference
.NewKey(PreferenceSubject
.Database
, PreferencePredicate
.NomenclaturalCode
);
46 CdmPreference pref
= service
.get(key
);
47 Assert
.assertNotNull("CdmPreference for given key must exist", pref
);
48 Assert
.assertEquals("ICNAFP", pref
.getValue());
50 key
= CdmPreference
.NewKey(PreferenceSubject
.Database
, PreferencePredicate
.Test
);
51 pref
= service
.get(key
);
52 Assert
.assertNull("CdmPreference for given key must not exist", pref
);
58 public void testCount() {
59 int countStart
= service
.count();
60 Assert
.assertEquals("There should be 1 preference in the CDM store", 1, countStart
);
65 public void testSet() {
66 int countStart
= service
.count();
67 Assert
.assertEquals(1, countStart
);
69 CdmPreference pref
= CdmPreference
.NewInstance(PreferenceSubject
.Database
, PreferencePredicate
.Test
, "200");
71 int count
= service
.count();
72 Assert
.assertEquals("There should be 1 new preference", countStart
+ 1, count
);
75 pref
= CdmPreference
.NewInstance(PreferenceSubject
.Database
, PreferencePredicate
.NomenclaturalCode
, "ICZN");
78 count
= service
.count();
79 Assert
.assertEquals("There should be only 1 new preference", countStart
+ 1, count
);
84 * @see eu.etaxonomy.cdm.test.integration.CdmIntegrationTest#createTestData()
87 public void createTestDataSet() throws FileNotFoundException
{
88 // TODO Auto-generated method stub