From: Andreas Müller Date: Thu, 7 Aug 2014 16:25:33 +0000 (+0000) Subject: move vocabulary tests to vocabulary service and fix @Ignore, remove deprecated method... X-Git-Tag: cdmlib-parent-3.3.7~51 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/cdmlib.git/commitdiff_plain/b26b6c5112e1246d61c6179cfc834d6fac9c236e move vocabulary tests to vocabulary service and fix @Ignore, remove deprecated methods from INameService --- diff --git a/.gitattributes b/.gitattributes index 0ef0ff3681..be7cc54d7f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2358,6 +2358,7 @@ cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/TaxonServiceSearchTes cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/TermServiceImplTest.java -text cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/TransmissionEngineDistributionTest.java -text cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/UserAndGroupServiceImplTest.java -text +cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/VocabularyServiceImplTest.java -text cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/lsid/LSIDAuthorityServiceTest.java -text cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/lsid/LSIDDataServiceTest.java -text cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/lsid/LSIDMetadataServiceTest.java -text diff --git a/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/INameService.java b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/INameService.java index 0e661b1d51..dc5f0ad7f6 100644 --- a/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/INameService.java +++ b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/INameService.java @@ -263,15 +263,15 @@ public interface INameService extends IIdentifiableEntityService @Deprecated public List getAllRelationships(int limit, int start); - /** - * Returns all Ranks - * @return - * @deprecated use VocabularyService#getVocabulary(VocabularyEnum) instead, - * this is not possible since VocabularyService#getVocabulary(VocabularyEnum) - * is not returning a OrderedTermVocabulary !!! see also http://dev.e-taxonomy.eu/trac/ticket/3327 - */ - @Deprecated - public OrderedTermVocabulary getRankVocabulary(); +// /** +// * Returns all Ranks +// * @return +// * @deprecated use VocabularyService#getVocabulary(VocabularyEnum) instead, +// * this is not possible since VocabularyService#getVocabulary(VocabularyEnum) +// * is not returning a OrderedTermVocabulary !!! see also http://dev.e-taxonomy.eu/trac/ticket/3327 +// */ +// @Deprecated +// public OrderedTermVocabulary getRankVocabulary(); /** * Returns all NomenclaturalStatusTypes @@ -280,14 +280,14 @@ public interface INameService extends IIdentifiableEntityService */ @Deprecated public TermVocabulary getStatusTypeVocabulary(); - - /** - * Returns TypeDesignationStatus vocabulary - * @return - * @deprecated use VocabularyService#getVocabulary(VocabularyEnum) instead - */ - @Deprecated - public TermVocabulary getSpecimenTypeDesignationStatusVocabulary(); +// +// /** +// * Returns TypeDesignationStatus vocabulary +// * @return +// * @deprecated use VocabularyService#getVocabulary(VocabularyEnum) instead +// */ +// @Deprecated +// public TermVocabulary getSpecimenTypeDesignationStatusVocabulary(); /** * Returns TypeDesignationStatus ordered vocabulary diff --git a/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/NameServiceImpl.java b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/NameServiceImpl.java index b6ccef5b0e..04a8fd5f8e 100644 --- a/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/NameServiceImpl.java +++ b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/NameServiceImpl.java @@ -518,22 +518,22 @@ public class NameServiceImpl extends IdentifiableServiceBase getRankVocabulary() { - String uuidString = "ef0d1ce1-26e3-4e83-b47b-ca74eed40b1b"; - UUID uuid = UUID.fromString(uuidString); - OrderedTermVocabulary rankVocabulary = - (OrderedTermVocabulary)orderedVocabularyDao.findByUuid(uuid); - return rankVocabulary; - } +// /** +// * FIXME Candidate for harmonization +// * is this not the same as termService.getVocabulary(VocabularyEnum.Rank) +// * since this returns OrderedTermVocabulary +// * +// * (non-Javadoc) +// * @see eu.etaxonomy.cdm.api.service.INameService#getRankVocabulary() +// */ +// @Override +// public OrderedTermVocabulary getRankVocabulary() { +// String uuidString = "ef0d1ce1-26e3-4e83-b47b-ca74eed40b1b"; +// UUID uuid = UUID.fromString(uuidString); +// OrderedTermVocabulary rankVocabulary = +// (OrderedTermVocabulary)orderedVocabularyDao.findByUuid(uuid); +// return rankVocabulary; +// } /** * FIXME Candidate for harmonization @@ -553,8 +553,6 @@ public class NameServiceImpl extends IdentifiableServiceBase getStatusTypeVocabulary() { @@ -565,20 +563,20 @@ public class NameServiceImpl extends IdentifiableServiceBase getSpecimenTypeDesignationStatusVocabulary() { - String uuidString = "ab177bd7-d3c8-4e58-a388-226fff6ba3c2"; - UUID uuid = UUID.fromString(uuidString); - TermVocabulary typeDesigStatusVocabulary = - vocabularyDao.findByUuid(uuid); - return typeDesigStatusVocabulary; - } +// /** +// * FIXME Candidate for harmonization +// * is this the same as termService.getVocabulary(VocabularyEnum.SpecimenTypeDesignationStatus) +// * (non-Javadoc) +// * @see eu.etaxonomy.cdm.api.service.INameService#getTypeDesignationStatusVocabulary() +// */ +// @Override +// public TermVocabulary getSpecimenTypeDesignationStatusVocabulary() { +// String uuidString = "ab177bd7-d3c8-4e58-a388-226fff6ba3c2"; +// UUID uuid = UUID.fromString(uuidString); +// TermVocabulary typeDesigStatusVocabulary = +// vocabularyDao.findByUuid(uuid); +// return typeDesigStatusVocabulary; +// } /** * FIXME Candidate for harmonization diff --git a/cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/NameServiceImplTest.java b/cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/NameServiceImplTest.java index e90f243d90..98f4af3c4f 100644 --- a/cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/NameServiceImplTest.java +++ b/cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/NameServiceImplTest.java @@ -105,40 +105,7 @@ public class NameServiceImplTest extends CdmTransactionalIntegrationTest { logger.warn("Not yet implemented"); } - /** - * Test method for {@link eu.etaxonomy.cdm.api.service.NameServiceImpl#getRankVocabulary()}. - */ - @Test - @Ignore //FIXME assertSame does not work yet - public void testGetRankVocabulary() { - //TODO move test to vocabulary service - OrderedTermVocabulary rankVocabulary = nameService.getRankVocabulary(); - assertNotNull(rankVocabulary); - assertEquals(66, rankVocabulary.size()); - Rank highestRank = rankVocabulary.getHighestTerm(); - assertEquals(Rank.EMPIRE(), highestRank); - assertEquals(Rank.DOMAIN(), rankVocabulary.getNextLowerTerm(highestRank)); - assertSame(Rank.EMPIRE(), highestRank); - assertSame(Rank.DOMAIN(), rankVocabulary.getNextLowerTerm(highestRank)); - } - /** - * Test method for {@link eu.etaxonomy.cdm.api.service.NameServiceImpl#getTypeDesignationVocabulary()}. - */ - @Test - @Ignore //not yet correctly implemented - public void testGetTypeDesignationVocabulary() { - //TODO move test to vocabulary service - OrderedTermVocabulary typeDesignationVocabulary = - nameService.getSpecimenTypeDesignationVocabulary(); - assertNotNull(typeDesignationVocabulary); - assertEquals(20, typeDesignationVocabulary.size()); - SpecimenTypeDesignationStatus highestType = typeDesignationVocabulary.getHighestTerm(); - assertEquals(SpecimenTypeDesignationStatus.EPITYPE(), highestType); - assertEquals(SpecimenTypeDesignationStatus.HOLOTYPE(), typeDesignationVocabulary.getNextLowerTerm(highestType)); - assertSame(SpecimenTypeDesignationStatus.EPITYPE(), highestType); - assertSame(SpecimenTypeDesignationStatus.HOLOTYPE(), typeDesignationVocabulary.getNextLowerTerm(highestType)); - } /** * Test method for {@link eu.etaxonomy.cdm.api.service.NameServiceImpl#generateTitleCache()}. diff --git a/cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/VocabularyServiceImplTest.java b/cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/VocabularyServiceImplTest.java new file mode 100644 index 0000000000..c1575dd039 --- /dev/null +++ b/cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/VocabularyServiceImplTest.java @@ -0,0 +1,91 @@ +// $Id$ +/** +* Copyright (C) 2007 EDIT +* European Distributed Institute of Taxonomy +* http://www.e-taxonomy.eu +* +* The contents of this file are subject to the Mozilla Public License Version 1.1 +* See LICENSE.TXT at the top of this package for the full license terms. +*/ + +package eu.etaxonomy.cdm.api.service; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.unitils.spring.annotation.SpringBeanByType; + +import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary; +import eu.etaxonomy.cdm.model.common.TermType; +import eu.etaxonomy.cdm.model.common.TermVocabulary; +import eu.etaxonomy.cdm.model.name.Rank; +import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus; +import eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest; + +/** + * @author a.mueller + * @created Aug 07, 2014 + */ +//@SpringApplicationContext("file:./target/test-classes/eu/etaxonomy/cdm/applicationContext-test.xml") +public class VocabularyServiceImplTest extends CdmTransactionalIntegrationTest{ + + + @SpringBeanByType + private IVocabularyService vocabularyService; + + + + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + } + + + /** + * Test method for {@link eu.etaxonomy.cdm.api.service.NameServiceImpl#getRankVocabulary()}. + */ + @Test +// @Ignore //FIXME assertSame does not work yet + public void testGetRankVocabulary() { + List> rankVocabularyList = vocabularyService.findByTermType(TermType.Rank); + assertTrue(rankVocabularyList.size() == 1); + OrderedTermVocabulary rankVocabulary = (OrderedTermVocabulary)rankVocabularyList.get(0); + assertNotNull(rankVocabulary); + assertEquals(62, rankVocabulary.size()); + Rank highestRank = rankVocabulary.getHighestTerm(); + assertEquals(Rank.EMPIRE(), highestRank); + assertEquals(Rank.DOMAIN(), rankVocabulary.getNextLowerTerm(highestRank)); +// assertSame(Rank.EMPIRE(), highestRank); //as we do not use second level cache this is not required +// assertSame(Rank.DOMAIN(), rankVocabulary.getNextLowerTerm(highestRank)); //as we do not use second level cache this is not required + } + + /** + * Test method for {@link eu.etaxonomy.cdm.api.service.NameServiceImpl#getTypeDesignationVocabulary()}. + */ + @Test +// @Ignore //not yet correctly implemented + public void testGetTypeDesignationVocabulary() { + List> typeDesignationVocabularyList = + vocabularyService.findByTermType(TermType.SpecimenTypeDesignationStatus); + assertTrue(typeDesignationVocabularyList.size() == 1); + OrderedTermVocabulary typeDesignationVocabulary = (OrderedTermVocabulary)typeDesignationVocabularyList.get(0); + + assertNotNull(typeDesignationVocabulary); + assertEquals(16, typeDesignationVocabulary.size()); + SpecimenTypeDesignationStatus highestType = typeDesignationVocabulary.getHighestTerm(); + assertEquals(SpecimenTypeDesignationStatus.HOLOTYPE(), highestType); + assertEquals(SpecimenTypeDesignationStatus.LECTOTYPE(), typeDesignationVocabulary.getNextLowerTerm(highestType)); +// assertSame(SpecimenTypeDesignationStatus.EPITYPE(), highestType); //as we do not use second level cache this is not required +// assertSame(SpecimenTypeDesignationStatus.HOLOTYPE(), typeDesignationVocabulary.getNextLowerTerm(highestType)); //as we do not use second level cache this is not required + } + +}