Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACM-Fetchers: Allow the search to return multiple entries. #8038

Merged
merged 1 commit into from
Aug 31, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

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 All @@ -33,8 +34,7 @@ void setUp() {
@Test
void searchByQueryFindsEntry() throws Exception {

List<BibEntry> searchEntryList = List.of(
new BibEntry(StandardEntryType.Conference)
BibEntry searchEntry = new BibEntry(StandardEntryType.Conference)
.withField(StandardField.AUTHOR, "Tobias Olsson and Morgan Ericsson and Anna Wingkvist")
.withField(StandardField.YEAR, "2017")
.withField(StandardField.MONTH, "9")
Expand All @@ -50,16 +50,15 @@ void searchByQueryFindsEntry() throws Exception {
.withField(StandardField.TITLE, "The relationship of code churn and architectural violations in the open source software JabRef")
.withField(StandardField.URL, "https://doi.org/10.1145/3129790.3129810")
.withField(StandardField.PAGETOTAL, "7")
.withField(StandardField.PAGES, "152–158")
);
.withField(StandardField.PAGES, "152–158");

List<BibEntry> fetchedEntries = fetcher.performSearch("The relationship of code churn and architectural violations in the open source software JabRef");
// we clear the abstract due to copyright reasons (JabRef's code should not contain copyrighted abstracts)
for (BibEntry bibEntry : fetchedEntries) {
bibEntry.clearField(StandardField.ABSTRACT);
}
// check for a) that a single entry is returned and b) that the entry itself is the expected one
assertEquals(searchEntryList, fetchedEntries);
assertFalse(fetchedEntries.isEmpty());
assertEquals(searchEntry, fetchedEntries.get(0));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;

@FetcherTest
public class ACMPortalParserTest {
Expand Down Expand Up @@ -77,10 +78,11 @@ void testParseEntries() throws IOException, ParseException {

@Test
void testParseDoiSearchPage() throws ParseException, IOException {
List<String> testDoiList = List.of("10.1145/3129790.3129810");
String testDoi = "10.1145/3129790.3129810";
CookieHandler.setDefault(new CookieManager());
List<String> doiList = parser.parseDoiSearchPage(new URLDownload(searchUrl).asInputStream());
assertEquals(testDoiList, doiList);
assertFalse(doiList.isEmpty());
assertEquals(testDoi, doiList.get(0));
}

@Test
Expand Down