Skip to content

Commit

Permalink
Refine ACS test code
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor committed Sep 7, 2024
1 parent 4b633aa commit fd3d2f5
Showing 1 changed file with 13 additions and 22 deletions.
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());
}
}

0 comments on commit fd3d2f5

Please sign in to comment.