/checklistbank-ws-test/src/test/java/org/gbif/checklistbank/ws/NameUsageTestIT.java
http://gbif-ecat.googlecode.com/ · Java · 92 lines · 63 code · 17 blank · 12 comment · 0 complexity · 517400ec7a1facece30cf34b2ebf0356 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.NameUsage;
- import org.gbif.checklistbank.api.service.NameUsageService;
- import org.gbif.checklistbank.ws.client.guice.ChecklistBankWsClientModule;
- import org.gbif.checklistbank.ws.guice.ChecklistBankWsModule;
- import java.util.List;
- import java.util.Locale;
- import java.util.UUID;
- import com.google.inject.Guice;
- import com.google.inject.Injector;
- import junit.framework.Assert;
- import org.junit.Before;
- import org.junit.Test;
- public class NameUsageTestIT extends BaseResourceTest {
- private Injector clientInjector;
- private NameUsageService wsClient;
- public NameUsageTestIT() {
- 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));
- wsClient = clientInjector.getInstance(NameUsageService.class);
- }
- @Test
- public void testGet() {
- NameUsage nameUsage = this.wsClient.get(1, new Locale("en"));
- Assert.assertNotNull(nameUsage);
- }
- @Test
- public void testListChildren() {
- PagingResponse<NameUsage> children = this.wsClient.listChildren(6, new Locale("en"), new PagingRequest(0, 20));
- Assert.assertNotNull(children);
- Assert.assertEquals(children.getResults().size(), 20);
- }
- @Test
- public void testListDatasets() {
- List<UUID> datasets = this.wsClient.listRelatedOccurrenceDatasets(6);
- Assert.assertNotNull(datasets);
- }
- @Test
- public void testListParents() {
- List<NameUsage> parents = this.wsClient.listParents(13, new Locale("en"));
- Assert.assertNotNull(parents);
- Assert.assertEquals(parents.size(), 1);
- }
- @Test
- public void testListRelated() {
- PagingResponse<NameUsage> related = this.wsClient.listRelated(6, new Locale("en"), new PagingRequest(0, 20));
- Assert.assertNotNull(related);
- Assert.assertEquals(related.getResults().size(), 16);
- }
- @Test
- public void testListSynonyms() {
- PagingResponse<NameUsage> synonyms = this.wsClient.listSynonyms(6, new Locale("en"), new PagingRequest(0, 20));
- Assert.assertNotNull(synonyms);
- Assert.assertEquals(synonyms.getResults().size(), 1);
- }
- }