4 package eu
.etaxonomy
.cdm
.ext
.ipni
;
8 import org
.junit
.Assert
;
9 import org
.junit
.Before
;
10 import org
.junit
.Test
;
12 import eu
.etaxonomy
.cdm
.api
.application
.ICdmApplicationConfiguration
;
13 import eu
.etaxonomy
.cdm
.ext
.ipni
.IIpniService
;
14 import eu
.etaxonomy
.cdm
.ext
.ipni
.IpniService
;
15 import eu
.etaxonomy
.cdm
.ext
.ipni
.IpniServiceAuthorConfigurator
;
16 import eu
.etaxonomy
.cdm
.ext
.ipni
.IpniServiceNamesConfigurator
;
17 import eu
.etaxonomy
.cdm
.ext
.ipni
.IpniServicePublicationConfigurator
;
18 import eu
.etaxonomy
.cdm
.ext
.ipni
.IIpniService
.DelimitedFormat
;
19 import eu
.etaxonomy
.cdm
.ext
.ipni
.IpniService
.IpniRank
;
20 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
21 import eu
.etaxonomy
.cdm
.model
.common
.Extension
;
22 import eu
.etaxonomy
.cdm
.model
.name
.BotanicalName
;
23 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
24 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
30 public class IpniServiceTest
{
32 static String strUrl1
;
34 private IpniService service1
;
37 * @throws java.lang.Exception
40 public void setUp() throws Exception
{
41 service1
= new IpniService();
44 // ******************************* TESTS ******************************************************/
47 * Test method for {@link eu.etaxonomy.cdm.ext.ipni.IpniService#IpniService(java.net.URL)}.
50 public void testIpniService() {
51 Assert
.assertNotNull("Service should not be null", service1
);
52 Assert
.assertNotNull("URL1 should not be null", service1
.getServiceUrl(IIpniService
.ADVANCED_NAME_SERVICE_URL
));
56 public void testGetAuthors(){
57 ICdmApplicationConfiguration services
= null;
58 IpniServiceAuthorConfigurator config
= new IpniServiceAuthorConfigurator();
59 config
.setFormat(DelimitedFormat
.EXTENDED
);
60 List
<Person
> authorList
= service1
.getAuthors(null, "Greuter", null, null, services
, config
);
61 //expected web service result: 3379-1%1.1%Greuter%Werner Rodolfo%Greuter%PS%1938-%>Greuter, Werner Rodolfo
63 Assert
.assertEquals("There should be exactly 1 result for 'Greuter'", 1, authorList
.size());
64 Person author
= authorList
.get(0);
66 Assert
.assertEquals("Title Cache for Greuter should be 'Werner Rodolfo Greuter'", "Werner Rodolfo Greuter", author
.getTitleCache());
68 Assert
.assertEquals("One extension for the alternative name should exist", 1, author
.getExtensions().size());
69 Extension alternativeName
= author
.getExtensions().iterator().next();
70 Assert
.assertEquals("Alternative name should be ", "Greuter, Werner Rodolfo", alternativeName
.getValue());
72 String year
= author
.getLifespan().getYear();
73 Assert
.assertNotNull("Year should be not null", year
);
74 Assert
.assertEquals("Year should be 1938", "1938", year
);
76 authorList
= service1
.getAuthors(null, "Greu*", null, null, null, config
);
77 //29367-1%1.1%Greuet%Claude%Greuet%A%%>Greuet, Claude
78 //20000981-1%1.1%Greuning%J.V. van%Greuning%M%1993%>Greuning, J.V. van
79 //3379-1%1.1%Greuter%Werner Rodolfo%Greuter%PS%1938-%>Greuter, Werner Rodolfo
80 Assert
.assertEquals("There should be exactly 3 result for 'Greu*'. But maybe this changes over time", 3, authorList
.size());
83 // for (Person person : authorList){
84 // System.out.println(person.getTitleCache() + "; " + person.getNomenclaturalTitle());
87 config
.setFormat(DelimitedFormat
.MINIMAL
);
88 authorList
= service1
.getAuthors(null, "Greuter", null, null, services
, config
);
89 Assert
.assertEquals("There should be exactly 1 result for 'Greuter'", 1, authorList
.size());
90 author
= authorList
.get(0);
91 Assert
.assertTrue("No alternative names should exist in the minimal version", author
.getExtensions().isEmpty());
97 public void testGetNamesSimple(){
98 ICdmApplicationConfiguration services
= null;
99 IpniServiceNamesConfigurator config
= null;
100 List
<BotanicalName
> nameList
= service1
.getNamesSimple("Abies albertiana", services
, config
);
101 //expected web service result: 3379-1%1.1%Greuter%Werner Rodolfo%Greuter%PS%1938-%>Greuter, Werner Rodolfo
103 Assert
.assertEquals("There should be exactly 1 result for 'Abies albertiana'", 1, nameList
.size());
104 BotanicalName name
= nameList
.get(0);
106 Assert
.assertEquals("Title Cache for Abies albertiana should be 'Abies albertiana'", "Abies albertiana A.Murr.", name
.getTitleCache());
108 // for (BotanicalName listName : nameList){
109 // System.out.println(name.getFullTitleCache());
115 public void testGetNamesAdvanced(){
116 ICdmApplicationConfiguration services
= null;
117 IpniServiceNamesConfigurator config
= new IpniServiceNamesConfigurator();
119 //http://www.uk.ipni.org/ipni/advPlantNameSearch.do?find_family=&find_genus=Abies&find_species=alba&find_infrafamily=&find_infragenus=&find_infraspecies=&find_authorAbbrev=B*&find_includePublicationAuthors=on&find_includePublicationAuthors=off&find_includeBasionymAuthors=on&find_includeBasionymAuthors=off&find_publicationTitle=&find_isAPNIRecord=on&find_isAPNIRecord=false&find_isGCIRecord=on&find_isGCIRecord=false&find_isIKRecord=on&find_isIKRecord=false&find_rankToReturn=infraspec&output_format=normal&find_sortByFamily=on&find_sortByFamily=off&query_type=by_query&back_page=plantsearch
121 String genus
= "Abies";
122 String species
= "alba";
123 String infraFamily
= "";
124 String infraGenus
= "";
125 String infraSpecies
= "";
126 String authorAbbrev
= "B*";
127 Boolean includePublicationAuthors
= null;
128 Boolean includeBasionymAuthors
= null;
129 String publicationTitle
= "";
130 Boolean isAPNIRecord
= null;
131 Boolean isGCIRecord
= null;
132 Boolean isIKRecord
= null;
133 IpniRank rankToReturn
= IpniRank
.valueOf(Rank
.SUBSPECIES());
134 Boolean sortByFamily
= null;
136 List
<BotanicalName
> nameList
= service1
.getNamesAdvanced(family
, genus
, species
, infraFamily
, infraGenus
, infraSpecies
, authorAbbrev
, includePublicationAuthors
, includeBasionymAuthors
, publicationTitle
, isAPNIRecord
, isGCIRecord
, isIKRecord
, rankToReturn
, sortByFamily
, config
, services
);
137 //expected web service result: 3379-1%1.1%Greuter%Werner Rodolfo%Greuter%PS%1938-%>Greuter, Werner Rodolfo
139 Assert
.assertEquals("There should be exactly 1 result for 'Abies', 'alba', 'B*', Infraspecific ", 1, nameList
.size());
140 BotanicalName name
= nameList
.get(0);
142 Assert
.assertEquals("Title Cache for 'Abies', 'alba', 'ap*' should be 'Abies alba subsp. apennina Brullo, Scelsi & Spamp.'", "Abies alba subsp. apennina Brullo, Scelsi & Spamp.", name
.getTitleCache());
144 // for (BotanicalName listName : nameList){
145 // System.out.println(name.getFullTitleCache());
151 public void testPublications(){
152 ICdmApplicationConfiguration services
= null;
153 IpniServicePublicationConfigurator config
= null;
154 List
<ReferenceBase
> refList
= service1
.getPublications("Species Plantarum, Edition 3", "Sp. Pl.", services
, config
);
155 //20009158-1%1.2%Pinaceae%%N%Abies%%N%alba%apennina%subsp.%Brullo, Scelsi & Spamp.%%Brullo, Scelsi & Spamp.%Abies alba subsp. apennina%Vegetaz. Aspromonte%41 (2001)%2001%%%%%%Italy%tax. nov.
157 Assert
.assertEquals("There should be exactly 1 result for 'Species Plantarum, Edition 3'", 1, refList
.size());
158 ReferenceBase name
= refList
.get(0);
160 Assert
.assertEquals("Title Cache for Abies albertiana should be 'Species Plantarum, Edition 3'", "Species Plantarum, Edition 3. 1764", name
.getTitleCache());
162 // for (ReferenceBase ref : refList){
163 // System.out.println(ref.getTitleCache());
169 * Test method for {@link eu.etaxonomy.cdm.ext.ipni.IpniService#getServiceUrl()}.
172 public void testGetServiceUrl() {
173 Assert
.assertNotNull("Service should not be null", service1
);
174 Assert
.assertNotNull("URL1 should not be null", service1
.getServiceUrl(IIpniService
.ADVANCED_NAME_SERVICE_URL
));