move vocabulary tests to vocabulary service and fix @Ignore, remove deprecated method...
[cdmlib.git] / cdmlib-services / src / test / java / eu / etaxonomy / cdm / api / service / VocabularyServiceImplTest.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10
11 package eu.etaxonomy.cdm.api.service;
12
13 import static org.junit.Assert.assertEquals;
14 import static org.junit.Assert.assertNotNull;
15 import static org.junit.Assert.assertSame;
16 import static org.junit.Assert.assertTrue;
17
18 import java.util.List;
19
20 import org.junit.Before;
21 import org.junit.Test;
22 import org.unitils.spring.annotation.SpringBeanByType;
23
24 import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
25 import eu.etaxonomy.cdm.model.common.TermType;
26 import eu.etaxonomy.cdm.model.common.TermVocabulary;
27 import eu.etaxonomy.cdm.model.name.Rank;
28 import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
29 import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest;
30
31 /**
32 * @author a.mueller
33 * @created Aug 07, 2014
34 */
35 //@SpringApplicationContext("file:./target/test-classes/eu/etaxonomy/cdm/applicationContext-test.xml")
36 public class VocabularyServiceImplTest extends CdmTransactionalIntegrationTest{
37
38
39 @SpringBeanByType
40 private IVocabularyService vocabularyService;
41
42
43
44
45 /**
46 * @throws java.lang.Exception
47 */
48 @Before
49 public void setUp() throws Exception {
50 }
51
52
53 /**
54 * Test method for {@link eu.etaxonomy.cdm.api.service.NameServiceImpl#getRankVocabulary()}.
55 */
56 @Test
57 // @Ignore //FIXME assertSame does not work yet
58 public void testGetRankVocabulary() {
59 List<TermVocabulary<Rank>> rankVocabularyList = vocabularyService.findByTermType(TermType.Rank);
60 assertTrue(rankVocabularyList.size() == 1);
61 OrderedTermVocabulary<Rank> rankVocabulary = (OrderedTermVocabulary<Rank>)rankVocabularyList.get(0);
62 assertNotNull(rankVocabulary);
63 assertEquals(62, rankVocabulary.size());
64 Rank highestRank = rankVocabulary.getHighestTerm();
65 assertEquals(Rank.EMPIRE(), highestRank);
66 assertEquals(Rank.DOMAIN(), rankVocabulary.getNextLowerTerm(highestRank));
67 // assertSame(Rank.EMPIRE(), highestRank); //as we do not use second level cache this is not required
68 // assertSame(Rank.DOMAIN(), rankVocabulary.getNextLowerTerm(highestRank)); //as we do not use second level cache this is not required
69 }
70
71 /**
72 * Test method for {@link eu.etaxonomy.cdm.api.service.NameServiceImpl#getTypeDesignationVocabulary()}.
73 */
74 @Test
75 // @Ignore //not yet correctly implemented
76 public void testGetTypeDesignationVocabulary() {
77 List<TermVocabulary<SpecimenTypeDesignationStatus>> typeDesignationVocabularyList =
78 vocabularyService.findByTermType(TermType.SpecimenTypeDesignationStatus);
79 assertTrue(typeDesignationVocabularyList.size() == 1);
80 OrderedTermVocabulary<SpecimenTypeDesignationStatus> typeDesignationVocabulary = (OrderedTermVocabulary<SpecimenTypeDesignationStatus>)typeDesignationVocabularyList.get(0);
81
82 assertNotNull(typeDesignationVocabulary);
83 assertEquals(16, typeDesignationVocabulary.size());
84 SpecimenTypeDesignationStatus highestType = typeDesignationVocabulary.getHighestTerm();
85 assertEquals(SpecimenTypeDesignationStatus.HOLOTYPE(), highestType);
86 assertEquals(SpecimenTypeDesignationStatus.LECTOTYPE(), typeDesignationVocabulary.getNextLowerTerm(highestType));
87 // assertSame(SpecimenTypeDesignationStatus.EPITYPE(), highestType); //as we do not use second level cache this is not required
88 // assertSame(SpecimenTypeDesignationStatus.HOLOTYPE(), typeDesignationVocabulary.getNextLowerTerm(highestType)); //as we do not use second level cache this is not required
89 }
90
91 }