001/* 002 * Licensed under the Apache License, Version 2.0 (the "License"); 003 * you may not use this file except in compliance with the License. 004 * You may obtain a copy of the License at 005 * 006 * http://www.apache.org/licenses/LICENSE-2.0 007 * 008 * Unless required by applicable law or agreed to in writing, software 009 * distributed under the License is distributed on an "AS IS" BASIS, 010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 011 * See the License for the specific language governing permissions and 012 * limitations under the License. 013 */ 014package org.gbif.api.model.predicate; 015 016import org.gbif.api.model.occurrence.search.OccurrenceSearchParameter; 017 018import org.junit.jupiter.api.Test; 019 020import static org.junit.jupiter.api.Assertions.assertThrows; 021 022public class LikePredicateTest { 023 024 @Test 025 public void testInvalidConstructor() { 026 assertThrows( 027 IllegalArgumentException.class, 028 () -> new LikePredicate<>(OccurrenceSearchParameter.ELEVATION, "123.2%", null)); 029 } 030 031 @Test 032 public void testInvalidConstructor2() { 033 assertThrows( 034 IllegalArgumentException.class, 035 () -> new LikePredicate<>(OccurrenceSearchParameter.BASIS_OF_RECORD, "%FOSSIL%", null)); 036 } 037 038 @Test 039 public void testInvalidConstructor4() { 040 assertThrows( 041 IllegalArgumentException.class, 042 () -> new LikePredicate<>(OccurrenceSearchParameter.COUNTRY, "D%", null)); 043 } 044 045 @Test 046 public void testValidConstructor() { 047 new LikePredicate<>(OccurrenceSearchParameter.SCIENTIFIC_NAME, "Abies%", null); 048 new LikePredicate<>(OccurrenceSearchParameter.CATALOG_NUMBER, "kew-%", null); 049 } 050}