Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,12 @@ dependencies {

implementation 'org.controlsfx:controlsfx:11.2.1'

// region HTTP clients
implementation 'org.jsoup:jsoup:1.18.1'
implementation 'com.konghq:unirest-java-core:4.4.4'
implementation 'com.konghq:unirest-modules-gson:4.4.4'
implementation 'org.apache.httpcomponents.client5:httpclient5:5.3.1'
// endregion

implementation 'org.slf4j:slf4j-api:2.0.16'
implementation 'org.tinylog:tinylog-api:2.7.0'
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@
// dependency injection using HK2
requires org.glassfish.hk2.api;

// region: http clients
requires unirest.java.core;
requires unirest.modules.gson;
// region HTTP clients
requires org.apache.httpcomponents.core5.httpcore5;
requires org.jsoup;
requires unirest.java.core;
requires unirest.modules.gson;
// endregion

// region: SQL databases
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/logic/importer/fetcher/ACS.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.slf4j.LoggerFactory;

/**
* FulltextFetcher implementation that attempts to find a PDF URL at ACS.
* FulltextFetcher implementation that attempts to find a PDF URL at <a href="https://pubs.acs.org/">ACS</a>.
*/
public class ACS implements FulltextFetcher {
private static final Logger LOGGER = LoggerFactory.getLogger(ACS.class);
Expand Down
35 changes: 13 additions & 22 deletions src/test/java/org/jabref/logic/importer/fetcher/ACSTest.java
Original file line number Diff line number Diff line change
@@ -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());
}
}