/checklistbank-ws-test/src/test/java/org/gbif/checklistbank/ws/NameUsageComponentTestIT.java
Java | 131 lines | 103 code | 16 blank | 12 comment | 0 complexity | f8205a016bb104db450ce3869ff7b0d8 MD5 | raw file
- /*
- * Copyright 2011 Global Biodiversity Information Facility (GBIF)
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- package org.gbif.checklistbank.ws;
- import org.gbif.api.paging.PagingRequest;
- import org.gbif.api.paging.PagingResponse;
- import org.gbif.checklistbank.api.model.Description;
- import org.gbif.checklistbank.api.model.Distribution;
- import org.gbif.checklistbank.api.model.Identifier;
- import org.gbif.checklistbank.api.model.Image;
- import org.gbif.checklistbank.api.model.Reference;
- import org.gbif.checklistbank.api.model.SpeciesProfile;
- import org.gbif.checklistbank.api.model.TypeSpecimen;
- import org.gbif.checklistbank.api.model.VernacularName;
- import org.gbif.checklistbank.api.service.DescriptionService;
- import org.gbif.checklistbank.api.service.DistributionService;
- import org.gbif.checklistbank.api.service.IdentifierService;
- import org.gbif.checklistbank.api.service.ImageService;
- import org.gbif.checklistbank.api.service.NameUsageComponentService;
- import org.gbif.checklistbank.api.service.ReferenceService;
- import org.gbif.checklistbank.api.service.SpeciesProfileService;
- import org.gbif.checklistbank.api.service.TypeSpecimenService;
- import org.gbif.checklistbank.api.service.VernacularNameService;
- import org.gbif.checklistbank.ws.client.guice.ChecklistBankWsClientModule;
- import org.gbif.checklistbank.ws.guice.ChecklistBankWsModule;
- import com.google.inject.Guice;
- import com.google.inject.Injector;
- import junit.framework.Assert;
- import org.junit.Before;
- import org.junit.Test;
- public class NameUsageComponentTestIT extends BaseResourceTest {
- private Injector clientInjector;
- public NameUsageComponentTestIT() {
- super("org.gbif.checklistbank.ws", "clb", ChecklistBankWsModule.class, "/name_usage/");
- }
- @Before
- public void init() {
- clientInjector =
- Guice
- .createInjector(new UrlBindingModule(this.getBaseURI(), "clb"), new ChecklistBankWsClientModule(false, true));
- }
- @Test
- public void testListDescriptions() {
- NameUsageComponentService<Description, Description> wsClient;
- wsClient = clientInjector.getInstance(DescriptionService.class);
- PagingResponse<Description> descriptions = wsClient.listByUsage(100026167, new PagingRequest(0, 20));
- Assert.assertNotNull(descriptions);
- Assert.assertEquals(descriptions.getResults().size(), 1);
- }
- @Test
- public void testListDistributions() {
- NameUsageComponentService<Distribution, Distribution> wsClient;
- wsClient = clientInjector.getInstance(DistributionService.class);
- PagingResponse<Distribution> distributions = wsClient.listByUsage(100425637, new PagingRequest(0, 20));
- Assert.assertNotNull(distributions);
- Assert.assertEquals(distributions.getResults().size(), 20);
- }
- @Test
- public void testListIdentifiers() {
- NameUsageComponentService<Identifier, Identifier> wsClient;
- wsClient = clientInjector.getInstance(IdentifierService.class);
- PagingResponse<Identifier> identifiers = wsClient.listByUsage(100026088, new PagingRequest(0, 20));
- Assert.assertNotNull(identifiers);
- Assert.assertEquals(identifiers.getResults().size(), 1);
- }
- @Test
- public void testListImages() {
- NameUsageComponentService<Image, Image> wsClient;
- wsClient = clientInjector.getInstance(ImageService.class);
- PagingResponse<Image> images = wsClient.listByUsage(100027553, new PagingRequest(0, 20));
- Assert.assertNotNull(images);
- Assert.assertEquals(images.getResults().size(), 1);
- }
- @Test
- public void testListReferences() {
- NameUsageComponentService<Reference, Reference> wsClient;
- wsClient = clientInjector.getInstance(ReferenceService.class);
- PagingResponse<Reference> references = wsClient.listByUsage(100027553, new PagingRequest(0, 20));
- Assert.assertNotNull(references);
- Assert.assertEquals(references.getResults().size(), 4);
- }
- @Test
- public void testListSpeciesProfiles() {
- NameUsageComponentService<SpeciesProfile, SpeciesProfile> wsClient;
- wsClient = clientInjector.getInstance(SpeciesProfileService.class);
- PagingResponse<SpeciesProfile> speciesProfiles = wsClient.listByUsage(100027553, new PagingRequest(0, 20));
- Assert.assertNotNull(speciesProfiles);
- Assert.assertEquals(speciesProfiles.getResults().size(), 1);
- }
- @Test
- public void testListTypeSpecimens() {
- NameUsageComponentService<TypeSpecimen, TypeSpecimen> wsClient;
- wsClient = clientInjector.getInstance(TypeSpecimenService.class);
- PagingResponse<TypeSpecimen> typesSpecimens = wsClient.listByUsage(100026699, new PagingRequest(0, 20));
- Assert.assertNotNull(typesSpecimens);
- Assert.assertEquals(typesSpecimens.getResults().size(), 1);
- }
- @Test
- public void testListVernacularNames() {
- NameUsageComponentService<VernacularName, VernacularName> wsClient;
- wsClient = clientInjector.getInstance(VernacularNameService.class);
- PagingResponse<VernacularName> vernacularNames = wsClient.listByUsage(6, new PagingRequest(0, 20));
- Assert.assertNotNull(vernacularNames);
- Assert.assertEquals(vernacularNames.getResults().size(), 6);
- }
- }