diff --git a/src/main/java/org/jabref/logic/importer/fetcher/ACS.java b/src/main/java/org/jabref/logic/importer/fetcher/ACS.java
index 2fa068e1eb4..b2fff10f38f 100644
--- a/src/main/java/org/jabref/logic/importer/fetcher/ACS.java
+++ b/src/main/java/org/jabref/logic/importer/fetcher/ACS.java
@@ -26,7 +26,7 @@ public class ACS implements FulltextFetcher {
/**
* Tries to find a fulltext URL for a given BibTex entry.
- *
+ *
* Currently only uses the DOI if found.
*
* @param entry The Bibtex entry
@@ -37,23 +37,24 @@ public class ACS implements FulltextFetcher {
@Override
public Optional findFullText(BibEntry entry) throws IOException {
Objects.requireNonNull(entry);
- Optional pdfLink = Optional.empty();
// DOI search
Optional doi = entry.getField(StandardField.DOI).flatMap(DOI::parse);
- if (doi.isPresent()) {
- String source = String.format(SOURCE, doi.get().getDOI());
- // Retrieve PDF link
- Document html = Jsoup.connect(source).ignoreHttpErrors(true).get();
- Element link = html.select("a.button_primary").first();
+ if (!doi.isPresent()) {
+ return Optional.empty();
+ }
+
+ String source = String.format(SOURCE, doi.get().getDOI());
+ // Retrieve PDF link
+ Document html = Jsoup.connect(source).ignoreHttpErrors(true).get();
+ Element link = html.select("a.button_primary").first();
- if (link != null) {
- LOGGER.info("Fulltext PDF found @ ACS.");
- pdfLink = Optional.of(new URL(source.replaceFirst("/abs/", "/pdf/")));
- }
+ if (link != null) {
+ LOGGER.info("Fulltext PDF found @ ACS.");
+ return Optional.of(new URL(source.replaceFirst("/abs/", "/pdf/")));
}
- return pdfLink;
+ return Optional.empty();
}
@Override
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 8a58fd47819..2552b5cc735 100644
--- a/src/test/java/org/jabref/logic/importer/fetcher/ACSTest.java
+++ b/src/test/java/org/jabref/logic/importer/fetcher/ACSTest.java
@@ -16,7 +16,6 @@
@FetcherTest
class ACSTest {
-
private ACS finder;
private BibEntry entry;
@@ -44,4 +43,14 @@ void notFoundByDOI() throws IOException {
assertEquals(Optional.empty(), finder.findFullText(entry));
}
+
+ @Test
+ void entityWithoutDoi() throws IOException {
+ assertEquals(Optional.empty(), finder.findFullText(entry));
+ }
+
+ @Test
+ void trustLevel() {
+ assertEquals(TrustLevel.PUBLISHER, finder.getTrustLevel());
+ }
}