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

[WIP] Fix fetcher tests #5674

Merged
merged 13 commits into from
Nov 29, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import org.jabref.logic.formatter.bibtexfields.ClearFormatter;
Expand All @@ -28,6 +26,10 @@
import org.jabref.model.util.DummyFileUpdateMonitor;

import org.apache.http.client.utils.URIBuilder;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

/**
* Fetches data from the INSPIRE database.
Expand Down Expand Up @@ -73,11 +75,14 @@ public Parser getParser() {

List<BibEntry> entries = new ArrayList<>();
BibtexParser bibtexParser = new BibtexParser(preferences, new DummyFileUpdateMonitor());
Pattern pattern = Pattern.compile("<pre>(?s)(.*)</pre>");
Matcher matcher = pattern.matcher(response);
while (matcher.find()) {
String bibtexEntryString = matcher.group(1);
entries.addAll(bibtexParser.parseEntries(bibtexEntryString));

Document doc = Jsoup.parse(response);
Elements preElements = doc.getElementsByTag("pre");

for (Element elem : preElements) {
//TODO: Second and third entry are not parsed
List<BibEntry> entry = bibtexParser.parseEntries(elem.wholeText());
entries.addAll(entry);
}
return entries;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ void findSingleEntry() throws FetcherException {
void find20Entries() throws FetcherException {
List<BibEntry> foundEntries = finder.performSearch("random test string");

assertEquals(20, foundEntries.size());
assertEquals(10, foundEntries.size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void testGetName() {

@Test
public void testGetHelpPage() {
assertEquals("GVK", fetcher.getHelpPage().get().getPageName());
assertEquals("import-using-online-bibliographic-database/gvk", fetcher.getHelpPage().get().getPageName());
}

@Test
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/org/jabref/logic/importer/fetcher/IEEETest.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ void searchResultHasNoKeywordTerms() throws FetcherException {
expected.setField(StandardField.DOI, "10.1049/iet-rpg.2018.5648");
expected.setField(StandardField.FILE, ":https\\://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=8636659:PDF");
expected.setField(StandardField.ISSUE, "3");
expected.setField(StandardField.ISSN, "1752-1424");
expected.setField(StandardField.JOURNALTITLE, "IET Renewable Power Generation");
expected.setField(StandardField.PAGES, "418--426");
expected.setField(StandardField.PUBLISHER, "IET");
Expand All @@ -125,6 +126,8 @@ void searchByQueryFindsEntry() throws Exception {
expected.setField(StandardField.DOI, "10.1145/2884781.2884806");
expected.setField(StandardField.JOURNALTITLE, "2016 IEEE/ACM 38th International Conference on Software Engineering (ICSE)");
expected.setField(StandardField.PAGES, "273--284");
expected.setField(StandardField.ISBN, "978-1-5090-2071-3");
expected.setField(StandardField.ISSN, "1558-1225");
expected.setField(StandardField.PUBLISHER, "IEEE");
expected.setField(StandardField.KEYWORDS, "Portals, Documentation, Computer bugs, Joining processes, Industries, Open source software, Newcomers, Newbies, Novices, Beginners, Open Source Software, Barriers, Obstacles, Onboarding, Joining Process");
expected.setField(StandardField.TITLE, "Overcoming Open Source Project Entry Barriers with a Portal for Newcomers");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void testGetName() {

@Test
public void testGetHelpPage() {
assertEquals("Medline", fetcher.getHelpPage().get().getPageName());
assertEquals("import-using-online-bibliographic-database/medline", fetcher.getHelpPage().get().getPageName());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void getNameReturnsEqualIdName() {

@Test
public void getHelpPageReturnsEqualHelpPage() {
assertEquals("RFCtoBibTeX", fetcher.getHelpPage().get().getPageName());
assertEquals("import-using-publication-identifiers/rfctobibtex", fetcher.getHelpPage().get().getPageName());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@ void setUp() {
void searchByQueryFindsEntry() throws Exception {
BibEntry expected = new BibEntry(StandardEntryType.Article);
expected.setField(StandardField.AUTHOR, "Steinmacher, Igor and Gerosa, Marco and Conte, Tayana U. and Redmiles, David F.");
expected.setField(StandardField.DATE, "2018-06-14");
expected.setField(StandardField.DATE, "2019-04-15");
expected.setField(StandardField.DOI, "10.1007/s10606-018-9335-z");
expected.setField(StandardField.ISSN, "0925-9724");
expected.setField(StandardField.JOURNAL, "Computer Supported Cooperative Work (CSCW)");
expected.setField(StandardField.MONTH, "#jun#");
expected.setField(StandardField.PAGES, "1--44");
expected.setField(StandardField.MONTH, "#apr#");
expected.setField(StandardField.PAGES, "247--290");
expected.setField(StandardField.NUMBER, "1-2");
expected.setField(StandardField.VOLUME, "28");
expected.setField(StandardField.PUBLISHER, "Springer");
expected.setField(StandardField.TITLE, "Overcoming Social Barriers When Contributing to Open Source Software Projects");
expected.setField(StandardField.YEAR, "2018");
expected.setField(StandardField.YEAR, "2019");
expected.setField(StandardField.FILE, "online:http\\://link.springer.com/openurl/pdf?id=doi\\:10.1007/s10606-018-9335-z:PDF");
expected.setField(StandardField.ABSTRACT, "An influx of newcomers is critical to the survival, long-term success, and continuity of many Open Source Software (OSS) community-based projects. However, newcomers face many barriers when making their first contribution, leading in many cases to dropouts. Due to the collaborative nature of community-based OSS projects, newcomers may be susceptible to social barriers, such as communication breakdowns and reception issues. In this article, we report a two-phase study aimed at better understanding social barriers faced by newcomers. In the first phase, we qualitatively analyzed the literature and data collected from practitioners to identify barriers that hinder newcomers’ first contribution. We designed a model composed of 58 barriers, including 13 social barriers. In the second phase, based on the barriers model, we developed FLOSScoach, a portal to support newcomers making their first contribution. We evaluated the portal in a diary-based study and found that the portal guided the newcomers and reduced the need for communication. Our results provide insights for communities that want to support newcomers and lay a foundation for building better onboarding tools. The contributions of this paper include identifying and gathering empirical evidence of social barriers faced by newcomers; understanding how social barriers can be reduced or avoided by using a portal that organizes proper information for newcomers (FLOSScoach); presenting guidelines for communities and newcomers on how to reduce or avoid social barriers; and identifying new streams of research.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void testGetName() {

@Test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be OK for me to remove these kind of tests completely. Think, the have been introduced in 2015 by students to increase test coverage.

public void testGetHelpPage() {
assertEquals("TitleToBibTeX", fetcher.getHelpPage().get().getPageName());
assertEquals("import-using-publication-identifiers/titletobibtex", fetcher.getHelpPage().get().getPageName());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void setUp() throws Exception {
donaldsonEntry = new BibEntry();
donaldsonEntry.setType(StandardEntryType.Article);
donaldsonEntry.setCiteKey("zbMATH03800580");
donaldsonEntry.setField(StandardField.AUTHOR, "S.K. {Donaldson}");
donaldsonEntry.setField(StandardField.AUTHOR, "S. K. {Donaldson}");
donaldsonEntry.setField(StandardField.JOURNAL, "Journal of Differential Geometry");
donaldsonEntry.setField(StandardField.ISSN, "0022-040X; 1945-743X/e");
donaldsonEntry.setField(StandardField.LANGUAGE, "English");
Expand Down