001/*
002 * Copyright 2020 Global Biodiversity Information Facility (GBIF)
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.gbif.api.model.common.search;
017
018import org.gbif.api.model.checklistbank.search.NameUsageSearchParameter;
019import org.gbif.api.model.checklistbank.search.NameUsageSuggestRequest;
020import org.gbif.api.model.occurrence.search.OccurrenceSearchParameter;
021import org.gbif.api.model.occurrence.search.OccurrenceSearchRequest;
022import org.gbif.api.vocabulary.BasisOfRecord;
023import org.gbif.api.vocabulary.Rank;
024
025import org.junit.jupiter.api.Test;
026
027import static org.junit.jupiter.api.Assertions.assertEquals;
028
029/**
030 * Test class for SearchRequest model class
031 */
032public class SearchRequestTest {
033
034  @Test
035  public void testEnumFacet() {
036    SearchRequest<NameUsageSearchParameter> req = new NameUsageSuggestRequest();
037    req.addParameter(NameUsageSearchParameter.RANK, Rank.SPECIES);
038    assertEquals("SPECIES", req.getParameters().get(NameUsageSearchParameter.RANK).iterator().next());
039
040    SearchRequest<OccurrenceSearchParameter> reqO = new OccurrenceSearchRequest();
041    reqO.addParameter(OccurrenceSearchParameter.BASIS_OF_RECORD, BasisOfRecord.LITERATURE);
042    assertEquals("LITERATURE",
043      reqO.getParameters().get(OccurrenceSearchParameter.BASIS_OF_RECORD).iterator().next());
044  }
045
046}