forked from JabRef/jabref
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b95c4b
commit 11a5be1
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
src/test/java/org/jabref/logic/importer/fetcher/BiodiversityHeritageLibraryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.jabref.logic.importer.fetcher; | ||
|
||
import java.net.MalformedURLException; | ||
import java.net.URISyntaxException; | ||
|
||
import org.jabref.logic.importer.FetcherException; | ||
import org.jabref.logic.util.BuildInfo; | ||
import org.jabref.testutils.category.FetcherTest; | ||
|
||
import org.apache.lucene.queryparser.flexible.core.QueryNodeParseException; | ||
import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode; | ||
import org.apache.lucene.queryparser.flexible.core.parser.SyntaxParser; | ||
import org.apache.lucene.queryparser.flexible.standard.parser.StandardSyntaxParser; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.jabref.logic.importer.fetcher.transformers.AbstractQueryTransformer.NO_EXPLICIT_FIELD; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
@FetcherTest | ||
public class BiodiversityHeritageLibraryTest { | ||
|
||
private BiodiversityHeritageLibrary fetcher; | ||
private String API_KEI; | ||
|
||
@BeforeEach | ||
public void setUp() throws Exception { | ||
fetcher = new BiodiversityHeritageLibrary(); | ||
API_KEI = new BuildInfo().BiodiversityHeritageLibraryAPIkey; | ||
} | ||
|
||
@Test | ||
public void getNameTest() { | ||
assertEquals("Biodiversity Heritage Library", fetcher.getName()); | ||
} | ||
|
||
@Test | ||
public void getURLForQueryTest() throws QueryNodeParseException, MalformedURLException, URISyntaxException, FetcherException { | ||
String url = "https://www.biodiversitylibrary.org/api3?op=PublicationSearch&searchterm=The+birds+of+Cocos+Island&searchtype=C&page=1&apikey=" + API_KEI + "&format=json"; | ||
SyntaxParser parser = new StandardSyntaxParser(); | ||
QueryNode queryNode = parser.parse("The birds of Cocos Island", NO_EXPLICIT_FIELD); | ||
|
||
assertEquals(url, fetcher.getURLForQuery(queryNode).toString()); | ||
} | ||
|
||
@Test | ||
public void getURLForQueryTestWithSingleWord() throws QueryNodeParseException, MalformedURLException, URISyntaxException, FetcherException { | ||
String url = "https://www.biodiversitylibrary.org/api3?op=PublicationSearch&searchterm=Foo&searchtype=C&page=1&apikey=" + API_KEI + "&format=json"; | ||
SyntaxParser parser = new StandardSyntaxParser(); | ||
QueryNode queryNode = parser.parse("Foo", NO_EXPLICIT_FIELD); | ||
|
||
assertEquals(url, fetcher.getURLForQuery(queryNode).toString()); | ||
} | ||
} |