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.util.validators.identifierschemes; 015 016import org.junit.jupiter.api.Test; 017 018import static org.junit.jupiter.api.Assertions.assertFalse; 019import static org.junit.jupiter.api.Assertions.assertTrue; 020 021/** Tests the {@link ResearcherIdValidator}. */ 022public class ResearcherIdValidatorTest { 023 024 private static final ResearcherIdValidator VALIDATOR = new ResearcherIdValidator(); 025 026 @Test 027 public void researcherIsValidTest() { 028 assertTrue(VALIDATOR.isValid("http://www.researcherid.com/rid/M-6306-2017")); 029 assertTrue(VALIDATOR.isValid("https://www.researcherid.com/rid/M-6306-2017")); 030 assertTrue(VALIDATOR.isValid("https://researcherid.com/rid/M-6306-2017")); 031 assertTrue(VALIDATOR.isValid("M-6306-2017")); 032 assertTrue(VALIDATOR.isValid("https://www.webofscience.com/wos/author/record/AAK-3007-2021")); 033 assertTrue(VALIDATOR.isValid("AAK-3007-2021")); 034 035 036 assertFalse(VALIDATOR.isValid("http://www.researcherid.com/rid/M-63063-2017")); 037 assertFalse(VALIDATOR.isValid("http://www.researcherid.com/rid/M-A306-2017")); 038 assertFalse(VALIDATOR.isValid("http://www.researcherid.com/rid/My Name")); 039 } 040 041 @Test 042 public void publonsIsValidTest() { 043 assertTrue(VALIDATOR.isValid("http://publons.com/researcher/M-5306-2017")); 044 assertTrue(VALIDATOR.isValid("https://publons.com/researcher/M-5306-2017")); 045 assertTrue(VALIDATOR.isValid("https://www.publons.com/researcher/M-5306-2017")); 046 assertTrue(VALIDATOR.isValid("https://publons.com/researcher/1/my-name/")); 047 048 assertFalse(VALIDATOR.isValid("https://publons.com/researcher/M-A306-2017")); 049 assertFalse(VALIDATOR.isValid("https://publons.com/researcher/M-55306-2017")); 050 assertFalse(VALIDATOR.isValid("https://publons.com/researcher/my-name")); 051 } 052}