From fd3d2f5fd7ea3f060ab22bfdaa6a4c1104a36aee Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sat, 7 Sep 2024 19:54:54 +0200 Subject: [PATCH] Refine ACS test code --- .../logic/importer/fetcher/ACSTest.java | 35 +++++++------------ 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/src/test/java/org/jabref/logic/importer/fetcher/ACSTest.java b/src/test/java/org/jabref/logic/importer/fetcher/ACSTest.java index 2552b5cc735..dca2cb16424 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/ACSTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/ACSTest.java @@ -1,56 +1,47 @@ package org.jabref.logic.importer.fetcher; -import java.io.IOException; import java.net.URL; import java.util.Optional; +import org.jabref.logic.importer.FulltextFetcher; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; import org.jabref.support.DisabledOnCIServer; import org.jabref.testutils.category.FetcherTest; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; @FetcherTest class ACSTest { - private ACS finder; - private BibEntry entry; - - @BeforeEach - void setUp() { - finder = new ACS(); - entry = new BibEntry(); - } + private FulltextFetcher fetcher = new ACS(); @Test @DisabledOnCIServer("CI server is unreliable") - void findByDOI() throws IOException { - entry.setField(StandardField.DOI, "10.1021/bk-2006-STYG.ch014"); - + void findByDOI() throws Exception { + // DOI randomly chosen from https://pubs.acs.org/toc/acscii/0/0 + BibEntry entry = new BibEntry().withField(StandardField.DOI, "10.1021/acscentsci.4c00971"); assertEquals( - Optional.of(new URL("https://pubs.acs.org/doi/pdf/10.1021/bk-2006-STYG.ch014")), - finder.findFullText(entry) + Optional.of(new URL("https://pubs.acs.org/doi/pdf/10.1021/acscentsci.4c00971")), + fetcher.findFullText(entry) ); } @Test @DisabledOnCIServer("CI server is unreliable") - void notFoundByDOI() throws IOException { - entry.setField(StandardField.DOI, "10.1021/bk-2006-WWW.ch014"); - - assertEquals(Optional.empty(), finder.findFullText(entry)); + void notFoundByDOI() throws Exception { + BibEntry entry = new BibEntry().withField(StandardField.DOI, "10.1021/bk-2006-WWW.ch014"); + assertEquals(Optional.empty(), fetcher.findFullText(entry)); } @Test - void entityWithoutDoi() throws IOException { - assertEquals(Optional.empty(), finder.findFullText(entry)); + void entityWithoutDoi() throws Exception { + assertEquals(Optional.empty(), fetcher.findFullText(new BibEntry())); } @Test void trustLevel() { - assertEquals(TrustLevel.PUBLISHER, finder.getTrustLevel()); + assertEquals(TrustLevel.PUBLISHER, fetcher.getTrustLevel()); } }