From d38774c5813229e5b4c4383daa76cd89bca10142 Mon Sep 17 00:00:00 2001 From: Christoph Date: Mon, 21 Mar 2022 23:26:53 +0100 Subject: [PATCH] Fix some fetcher test (#8595) --- .../gui/fieldeditors/LinkedFileViewModel.java | 7 +++++-- .../fieldeditors/LinkedFileViewModelTest.java | 4 ++-- .../fetcher/AstrophysicsDataSystemTest.java | 1 + .../fetcher/CompositeIdFetcherTest.java | 2 +- .../logic/importer/fetcher/DoiFetcherTest.java | 2 +- .../importer/fetcher/DoiResolutionTest.java | 2 ++ .../fetcher/GrobidCitationFetcherTest.java | 5 ++--- .../importer/fetcher/SpringerFetcherTest.java | 18 +++++++++++++++++- 8 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java index 63523c76d9b..9f78d1b34d4 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java @@ -485,6 +485,10 @@ public void download() { downloadTask.messageProperty().set( Localization.lang("Fulltext for") + ": " + entry.getCitationKey().orElse(Localization.lang("New entry"))); downloadTask.showToUser(true); + downloadTask.onFailure(ex -> { + LOGGER.error("Error downloading", ex); + dialogService.showErrorDialogAndWait(Localization.lang("Error downloading"), ex); + }); taskExecutor.execute(downloadTask); } catch (MalformedURLException exception) { dialogService.showErrorDialogAndWait(Localization.lang("Invalid URL"), exception); @@ -524,8 +528,7 @@ public BackgroundTask prepareDownloadTask(Path targetDirectory, URLDownloa return targetDirectory.resolve(fulltextDir).resolve(suggestedName); }) .then(destination -> new FileDownloadTask(urlDownload.getSource(), destination)) - .onFinished(() -> URLDownload.setSSLVerification(defaultSSLSocketFactory, defaultHostnameVerifier)) - .onFailure(exception -> dialogService.showErrorDialogAndWait("Download failed", exception)); + .onFinished(() -> URLDownload.setSSLVerification(defaultSSLSocketFactory, defaultHostnameVerifier)); return downloadTask; } diff --git a/src/test/java/org/jabref/gui/fieldeditors/LinkedFileViewModelTest.java b/src/test/java/org/jabref/gui/fieldeditors/LinkedFileViewModelTest.java index 6c4ddf69385..3f957c33d6b 100644 --- a/src/test/java/org/jabref/gui/fieldeditors/LinkedFileViewModelTest.java +++ b/src/test/java/org/jabref/gui/fieldeditors/LinkedFileViewModelTest.java @@ -225,8 +225,8 @@ void downloadDoesNotOverwriteFileTypeExtension() throws MalformedURLException { @FetcherTest @Test void downloadHtmlWhenLinkedFilePointsToHtml() throws MalformedURLException { - // the link mentioned in issue #7452 - String url = "https://onlinelibrary.wiley.com/doi/abs/10.1002/0470862106.ia615"; + // use google as test url, wiley is protected by clooudfare + String url = "https://google.com"; String fileType = StandardExternalFileType.URL.getName(); linkedFile = new LinkedFile(new URL(url), fileType); diff --git a/src/test/java/org/jabref/logic/importer/fetcher/AstrophysicsDataSystemTest.java b/src/test/java/org/jabref/logic/importer/fetcher/AstrophysicsDataSystemTest.java index f7854d13f53..c5cb7814a11 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/AstrophysicsDataSystemTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/AstrophysicsDataSystemTest.java @@ -134,6 +134,7 @@ public void setUp() throws Exception { luceyPaulEntry.setField(StandardField.URL, "https://ui.adsabs.harvard.edu/abs/2000JGR...10520297L"); luceyPaulEntry.setField(StandardField.MONTH, "#jan#"); luceyPaulEntry.setField(StandardField.NUMBER, "E8"); + luceyPaulEntry.setField(StandardField.ABSTRACT, "The Clementine mission to the Moon returned global imaging data collected by the ultraviolet visible (UVVIS) camera. This data set is now in a final state of calibration, and a five-band multispectral digital image model (DIM) of the lunar surface will soon be available to the science community. We have used observations of the lunar sample-return sites and stations extracted from the final DIM in conjunction with compositional information for returned lunar soils to revise our previously published algorithms for the spectral determination of the FeO and TiO$_{2}$ content of the lunar surface. The algorithms successfully normalize the effects of space weathering so that composition may be determined without regard to a surface's state of maturity. These algorithms permit anyone with access to the standard archived DIM to construct high spatial resolution maps of FeO and TiO$_{2}$ abundance. Such maps will be of great utility in a variety of lunar geologic studies."); } @Test diff --git a/src/test/java/org/jabref/logic/importer/fetcher/CompositeIdFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/CompositeIdFetcherTest.java index c0a08dd00b8..ef4abbec815 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/CompositeIdFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/CompositeIdFetcherTest.java @@ -81,7 +81,7 @@ public static Stream provideTestData() { "performSearchByIdReturnsCorrectEntryForDoiId", new BibEntry(StandardEntryType.Book) .withField(StandardField.TITLE, "Java{\\textregistered} For Dummies{\\textregistered}") - .withField(StandardField.PUBLISHER, "Wiley Publishing, Inc.") + .withField(StandardField.PUBLISHER, "Wiley") .withField(StandardField.YEAR, "2011") .withField(StandardField.AUTHOR, "Barry Burd") .withField(StandardField.MONTH, "jul") diff --git a/src/test/java/org/jabref/logic/importer/fetcher/DoiFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/DoiFetcherTest.java index d824e77cc4c..18d7ac80c02 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/DoiFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/DoiFetcherTest.java @@ -34,7 +34,7 @@ public void setUp() { bibEntryBurd2011.setType(StandardEntryType.Book); bibEntryBurd2011.setCitationKey("Burd_2011"); bibEntryBurd2011.setField(StandardField.TITLE, "Java{\\textregistered} For Dummies{\\textregistered}"); - bibEntryBurd2011.setField(StandardField.PUBLISHER, "Wiley Publishing, Inc."); + bibEntryBurd2011.setField(StandardField.PUBLISHER, "Wiley"); bibEntryBurd2011.setField(StandardField.YEAR, "2011"); bibEntryBurd2011.setField(StandardField.AUTHOR, "Barry Burd"); bibEntryBurd2011.setField(StandardField.MONTH, "jul"); diff --git a/src/test/java/org/jabref/logic/importer/fetcher/DoiResolutionTest.java b/src/test/java/org/jabref/logic/importer/fetcher/DoiResolutionTest.java index 4ba961fa076..1eb5dad88a6 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/DoiResolutionTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/DoiResolutionTest.java @@ -10,6 +10,7 @@ import org.jabref.testutils.category.FetcherTest; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -39,6 +40,7 @@ void linkWithPdfInTitleTag() throws IOException { ); } + @Disabled("Cannot fetch due to Cloudfare protection") @Test void linkWithPdfStringLeadsToFulltext() throws IOException { entry.setField(StandardField.DOI, "10.1002/acr2.11101"); diff --git a/src/test/java/org/jabref/logic/importer/fetcher/GrobidCitationFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/GrobidCitationFetcherTest.java index a2bac4b6ce8..7f7c41b3217 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/GrobidCitationFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/GrobidCitationFetcherTest.java @@ -38,13 +38,12 @@ public class GrobidCitationFetcherTest { static String example1 = "Derwing, T. M., Rossiter, M. J., & Munro, M. J. (2002). Teaching native speakers to listen to foreign-accented speech. Journal of Multilingual and Multicultural Development, 23(4), 245-259."; static BibEntry example1AsBibEntry = new BibEntry(StandardEntryType.Article).withCitationKey("-1") - .withField(StandardField.AUTHOR, "Derwing, Tracey and Rossiter, Marian and Munro, Murray") + .withField(StandardField.AUTHOR, "Derwing, T. and Rossiter, M. and Munro, M.") .withField(StandardField.TITLE, "Teaching Native Speakers to Listen to Foreign-accented Speech") .withField(StandardField.JOURNAL, "Journal of Multilingual and Multicultural Development") .withField(StandardField.DOI, "10.1080/01434630208666468") - .withField(StandardField.DATE, "2002-09") + .withField(StandardField.DATE, "2002") .withField(StandardField.YEAR, "2002") - .withField(StandardField.MONTH, "9") .withField(StandardField.PAGES, "245-259") .withField(StandardField.VOLUME, "23") .withField(StandardField.PUBLISHER, "Informa UK Limited") diff --git a/src/test/java/org/jabref/logic/importer/fetcher/SpringerFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/SpringerFetcherTest.java index 915e5ed6573..12f74732d30 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/SpringerFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/SpringerFetcherTest.java @@ -78,8 +78,24 @@ void searchByQueryFindsEntry() throws Exception { .withField(StandardField.TITLE, "How to Find My Task? Chatbot to Assist Newcomers in Choosing Tasks in OSS Projects") .withField(StandardField.ABSTRACT, "Open Source Software (OSS) is making a meteoric rise in the software industry since several big companies have entered this market. Unfortunately, newcomers enter these projects and usually lose interest in contributing because of several factors. This paper aims to reduce the problems users face when they walk their first steps into OSS projects: finding the appropriate task. This paper presents a chatbot that filters tasks to help newcomers choose a task that fits their skills. We performed a quantitative and a qualitative study comparing the chatbot with the current GitHub issue tracker interface, which uses labels to categorize and identify tasks. The results show that users perceived the chatbot as easier to use than the GitHub issue tracker. Additionally, users tend to interpret the use of chatbots as situational, helping mainly newcomers and inexperienced contributors."); + BibEntry fourthArticle = new BibEntry(StandardEntryType.Article) + .withField(StandardField.AUTHOR, "Calefato, Fabio and Gerosa, Marco Aurélio and Iaffaldano, Giuseppe and Lanubile, Filippo and Steinmacher, Igor") + .withField(StandardField.DATE, "2022-03-19") + .withField(StandardField.DOI, "10.1007/s10664-021-10012-6") + .withField(StandardField.FILE, ":http\\://link.springer.com/openurl/pdf?id=doi\\:10.1007/s10664-021-10012-6:PDF") + .withField(StandardField.ISSN, "1382-3256") + .withField(StandardField.JOURNAL, "Empirical Software Engineering") + .withField(StandardField.MONTH, "#mar#") + .withField(StandardField.NUMBER, "3") + .withField(StandardField.PAGES, "1--41") + .withField(StandardField.PUBLISHER, "Springer") + .withField(StandardField.TITLE, "Will you come back to contribute? Investigating the inactivity of OSS core developers in GitHub") + .withField(StandardField.VOLUME, "27") + .withField(StandardField.YEAR, "2022") + .withField(StandardField.ABSTRACT, "Several Open-Source Software (OSS) projects depend on the continuity of their development communities to remain sustainable. Understanding how developers become inactive or why they take breaks can help communities prevent abandonment and incentivize developers to come back. In this paper, we propose a novel method to identify developers’ inactive periods by analyzing the individual rhythm of contributions to the projects. Using this method, we quantitatively analyze the inactivity of core developers in 18 OSS organizations hosted on GitHub. We also survey core developers to receive their feedback about the identified breaks and transitions. Our results show that our method was effective for identifying developers’ breaks. About 94% of the surveyed core developers agreed with our state model of inactivity; 71% and 79% of them acknowledged their breaks and state transition, respectively. We also show that all core developers take breaks (at least once) and about a half of them (~45%) have completely disengaged from a project for at least one year. We also analyzed the probability of transitions to/from inactivity and found that developers who pause their activity have a ~35 to ~55% chance to return to an active state; yet, if the break lasts for a year or longer, then the probability of resuming activities drops to ~21–26%, with a ~54% chance of complete disengagement. These results may support the creation of policies and mechanisms to make OSS community managers aware of breaks and potential project abandonment."); + List fetchedEntries = fetcher.performSearch("JabRef Social Barriers Steinmacher"); - assertEquals(List.of(thirdArticle, firstArticle, secondArticle), fetchedEntries); + assertEquals(List.of(fourthArticle, thirdArticle, firstArticle, secondArticle), fetchedEntries); } @Test