Skip to content

Commit

Permalink
Fix some fetcher tests (#8258)
Browse files Browse the repository at this point in the history
  • Loading branch information
Siedlerchr authored Nov 21, 2021
1 parent d0d3d5e commit 5c96ddf
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.jabref.model.entry.types.StandardEntryType;
import org.jabref.testutils.category.FetcherTest;

import com.google.common.base.Optional;
import org.apache.lucene.queryparser.flexible.core.QueryNodeParseException;
import org.apache.lucene.queryparser.flexible.core.parser.SyntaxParser;
import org.apache.lucene.queryparser.flexible.standard.parser.StandardSyntaxParser;
Expand All @@ -20,7 +21,6 @@

import static org.jabref.logic.importer.fetcher.transformers.AbstractQueryTransformer.NO_EXPLICIT_FIELD;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;

@FetcherTest
class ACMPortalFetcherTest {
Expand Down Expand Up @@ -57,8 +57,7 @@ void searchByQueryFindsEntry() throws Exception {
for (BibEntry bibEntry : fetchedEntries) {
bibEntry.clearField(StandardField.ABSTRACT);
}
assertFalse(fetchedEntries.isEmpty());
assertEquals(searchEntry, fetchedEntries.get(0));
assertEquals(Optional.of(searchEntry), fetchedEntries.stream().findFirst());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void findFullTextByTitle() throws IOException {
void findFullTextByTitleWithCurlyBracket() throws IOException {
entry.setField(StandardField.TITLE, "Machine versus {Human} {Attention} in {Deep} {Reinforcement} {Learning} {Tasks}");

assertEquals(Optional.of(new URL("http://arxiv.org/pdf/2010.15942v2")), fetcher.findFullText(entry));
assertEquals(Optional.of(new URL("http://arxiv.org/pdf/2010.15942v3")), fetcher.findFullText(entry));
}

@Test
Expand Down Expand Up @@ -130,7 +130,7 @@ void findFullTextByTitleWithCurlyBracketAndPartOfAuthor() throws IOException {
entry.setField(StandardField.TITLE, "Machine versus {Human} {Attention} in {Deep} {Reinforcement} {Learning} {Tasks}");
entry.setField(StandardField.AUTHOR, "Zhang, Ruohan and Guo");

assertEquals(Optional.of(new URL("http://arxiv.org/pdf/2010.15942v2")), fetcher.findFullText(entry));
assertEquals(Optional.of(new URL("http://arxiv.org/pdf/2010.15942v3")), fetcher.findFullText(entry));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void setUp() {
bibEntry.setField(StandardField.PUBLISHER, "Addison Wesley");
bibEntry.setField(StandardField.YEAR, "2018");
bibEntry.setField(StandardField.AUTHOR, "Bloch, Joshua");
bibEntry.setField(StandardField.DATE, "2018-01-01");
bibEntry.setField(StandardField.DATE, "2018-01-31");
bibEntry.setField(new UnknownField("ean"), "9780134685991");
bibEntry.setField(StandardField.ISBN, "0134685997");
bibEntry.setField(StandardField.URL, "https://www.ebook.de/de/product/28983211/joshua_bloch_effective_java.html");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void setUp() {
bibEntry.setField(StandardField.PUBLISHER, "Addison Wesley");
bibEntry.setField(StandardField.YEAR, "2018");
bibEntry.setField(StandardField.AUTHOR, "Bloch, Joshua");
bibEntry.setField(StandardField.DATE, "2018-01-01");
bibEntry.setField(StandardField.DATE, "2018-01-31");
bibEntry.setField(new UnknownField("ean"), "9780134685991");
bibEntry.setField(StandardField.ISBN, "0134685997");
bibEntry.setField(StandardField.URL, "https://www.ebook.de/de/product/28983211/joshua_bloch_effective_java.html");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.field.UnknownField;
import org.jabref.model.entry.types.StandardEntryType;
import org.jabref.testutils.category.FetcherTest;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -22,6 +23,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@FetcherTest
class PdfMergeMetadataImporterTest {

private PdfMergeMetadataImporter importer;
Expand Down Expand Up @@ -71,7 +73,7 @@ void importWorksAsExpected() throws Exception {
expected.setField(StandardField.DOI, "10.1002/9781118257517");

// From ISBN (contained on first page verbatim bib entry)
expected.setField(StandardField.DATE, "2018-01-01");
expected.setField(StandardField.DATE, "2018-01-31");
expected.setField(new UnknownField("ean"), "9780134685991");
expected.setField(StandardField.ISBN, "0134685997");
expected.setField(StandardField.URL, "https://www.ebook.de/de/product/28983211/joshua_bloch_effective_java.html");
Expand Down

0 comments on commit 5c96ddf

Please sign in to comment.