Skip to content

Commit

Permalink
Fix FetcherTests (#11644)
Browse files Browse the repository at this point in the history
* Fix FetcherTests

* Discard changes to src/test/java/org/jabref/logic/importer/fetcher/OpenAccessDoiTest.java
  • Loading branch information
koppor committed Aug 19, 2024
1 parent 1534516 commit b41593a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public GrobidCitationFetcher(GrobidPreferences grobidPreferences, ImportFormatPr
* server has to look up the entry.
*
* @return A BibTeX string if extraction is successful
* @throws FetcherException
*/
private Optional<BibEntry> parseUsingGrobid(String plainText) throws FetcherException {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void simpleSearchQueryURLCorrect() throws Exception {
String query = "java jdk";
QueryNode luceneQuery = new StandardSyntaxParser().parse(query, NO_EXPLICIT_FIELD);
URL url = fetcher.getURLForQuery(luceneQuery);
assertEquals("bvbr.bib-bvb.de:5661/bvb01sru?version=1.1&recordSchema=marcxml&operation=searchRetrieve&query=java%20jdk&maximumRecords=30", url.toString());
assertEquals("http://bvbr.bib-bvb.de:5661/bvb01sru?version=1.1&recordSchema=marcxml&operation=searchRetrieve&query=java%20jdk&maximumRecords=30", url.toString());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ public void grobidPerformSearchWithEmptyStringsTest() throws FetcherException {
@ParameterizedTest
@MethodSource("provideInvalidInput")
public void grobidPerformSearchWithInvalidDataTest(String invalidInput) throws FetcherException {
List<BibEntry> entries = grobidCitationFetcher.performSearch(invalidInput);
assertEquals(Collections.emptyList(), entries);
assertThrows(FetcherException.class, () ->
grobidCitationFetcher.performSearch("invalidInput"), "performSearch should throw an FetcherException.");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ public void simpleSearchQueryURLCorrect() throws Exception {
String query = "java jdk";
QueryNode luceneQuery = new StandardSyntaxParser().parse(query, AbstractQueryTransformer.NO_EXPLICIT_FIELD);
URL url = fetcher.getURLForQuery(luceneQuery);
assertEquals("https://sru.k10plus.de/opac-de-627?version=1.1&operation=searchRetrieve&query=pica.all%3Djava+and+pica.all%3Djdk&maximumRecords=50&recordSchema=picaxml&sortKeys=Year%2C%2C1", url.toString());
assertEquals("https://sru.k10plus.de/opac-de-627?version=1.1&operation=searchRetrieve&query=pica.all%3Djava%20and%20pica.all%3Djdk&maximumRecords=50&recordSchema=picaxml&sortKeys=Year%2C%2C1", url.toString());
}

@Test
public void complexSearchQueryURLCorrect() throws Exception {
String query = "kon:java tit:jdk";
QueryNode luceneQuery = new StandardSyntaxParser().parse(query, AbstractQueryTransformer.NO_EXPLICIT_FIELD);
URL url = fetcher.getURLForQuery(luceneQuery);
assertEquals("https://sru.k10plus.de/opac-de-627?version=1.1&operation=searchRetrieve&query=pica.kon%3Djava+and+pica.tit%3Djdk&maximumRecords=50&recordSchema=picaxml&sortKeys=Year%2C%2C1", url.toString());
assertEquals("https://sru.k10plus.de/opac-de-627?version=1.1&operation=searchRetrieve&query=pica.kon%3Djava%20and%20pica.tit%3Djdk&maximumRecords=50&recordSchema=picaxml&sortKeys=Year%2C%2C1", url.toString());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,19 @@ public void supportsYearRangeSearch() {
}

@Test
@Disabled("401 as of 2024-08-18")
@Override
public void supportsAuthorSearch() {
}

@Test
@Disabled("401 as of 2024-08-18")
@Override
public void supportsJournalSearch() {
}

@Test
@Disabled("401 as of 2024-08-18")
public void supportsPhraseSearch() throws Exception {
// Normal search should match due to Redmiles, Elissa M., phrase search on the other hand should not find it.
BibEntry expected = new BibEntry(StandardEntryType.InCollection)
Expand All @@ -193,6 +206,7 @@ public void supportsPhraseSearch() throws Exception {
}

@Test
@Disabled("401 as of 2024-08-18")
public void supportsBooleanANDSearch() throws Exception {
List<BibEntry> resultJustByAuthor = fetcher.performSearch("author:\"Redmiles, David\"");
List<BibEntry> result = fetcher.performSearch("author:\"Redmiles, David\" AND journal:\"Computer Supported Cooperative Work\"");
Expand Down

0 comments on commit b41593a

Please sign in to comment.