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

Fix fetcher help links #6513

Merged
merged 2 commits into from
May 24, 2020
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
10 changes: 5 additions & 5 deletions src/main/java/org/jabref/logic/help/HelpFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ public enum HelpFile {
FETCHER_BIBSONOMY_SCRAPER(""),
FETCHER_CITESEERX("import-using-online-bibliographic-database/citeseer"),
FETCHER_DBLP("import-using-online-bibliographic-database/dblp"),
FETCHER_DIVA("import-using-publication-identifiers/divatobibtex"),
FETCHER_DIVA("collect/add-entry-using-an-id"),
FETCHER_DOAJ("import-using-online-bibliographic-database/doaj"),
FETCHER_DOI("import-using-publication-identifiers/doitobibtex"),
FETCHER_DOI("collect/add-entry-using-an-id"),
FETCHER_GOOGLE_SCHOLAR("import-using-online-bibliographic-database/googlescholar"),
FETCHER_GVK("import-using-online-bibliographic-database/gvk"),
FETCHER_IEEEXPLORE("import-using-online-bibliographic-database/ieeexplore"),
FETCHER_INSPIRE("import-using-online-bibliographic-database/inspire"),
FETCHER_ISBN("import-using-publication-identifiers/isbntobibtex"),
FETCHER_ISBN("collect/add-entry-using-an-id"),
FETCHER_MEDLINE("import-using-online-bibliographic-database/medline"),
FETCHER_OAI2_ARXIV("import-using-online-bibliographic-database/arxiv"),
FETCHER_RFC("import-using-publication-identifiers/rfctobibtex"),
FETCHER_RFC("collect/add-entry-using-an-id"),
FETCHER_SPRINGER("import-using-online-bibliographic-database/springer"),
FETCHER_TITLE("import-using-publication-identifiers/titletobibtex"),
FETCHER_TITLE("collect/add-entry-using-an-id"),
FETCHER_SCIENCEDIRECT(""),
DATABASE_PROPERTIES("setup/databaseproperties"),
FIND_DUPLICATES("finding-sorting-and-cleaning-entries/findduplicates"),
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/org/jabref/logic/importer/WebFetchers.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.jabref.logic.importer.fetcher.DoiFetcher;
import org.jabref.logic.importer.fetcher.DoiResolution;
import org.jabref.logic.importer.fetcher.GoogleScholar;
import org.jabref.logic.importer.fetcher.GrobidCitationFetcher;
import org.jabref.logic.importer.fetcher.GvkFetcher;
import org.jabref.logic.importer.fetcher.IEEE;
import org.jabref.logic.importer.fetcher.INSPIREFetcher;
Expand Down Expand Up @@ -100,7 +99,6 @@ public static SortedSet<SearchBasedFetcher> getSearchBasedFetchers(ImportFormatP
set.add(new CiteSeer());
set.add(new DOAJFetcher(importFormatPreferences));
set.add(new IEEE(importFormatPreferences));
set.add(new GrobidCitationFetcher(importFormatPreferences));
return set;
}

Expand Down Expand Up @@ -140,8 +138,8 @@ public static SortedSet<EntryBasedFetcher> getEntryBasedFetchers(ImportFormatPre
/**
* @return sorted set containing id fetchers
*/
public static SortedSet<IdFetcher> getIdFetchers(ImportFormatPreferences importFormatPreferences) {
SortedSet<IdFetcher> set = new TreeSet<>(Comparator.comparing(WebFetcher::getName));
public static SortedSet<IdFetcher<? extends Identifier>> getIdFetchers(ImportFormatPreferences importFormatPreferences) {
SortedSet<IdFetcher<?>> set = new TreeSet<>(Comparator.comparing(WebFetcher::getName));
set.add(new CrossRef());
set.add(new ArXiv(importFormatPreferences));
return set;
Expand Down
7 changes: 3 additions & 4 deletions src/test/java/org/jabref/logic/help/HelpFileTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,19 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import static org.jabref.logic.help.HelpFile.values;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class HelpFileTest {
class HelpFileTest {

private final String jabrefHelp = "https://docs.jabref.org/";

static Stream<HelpFile> getAllHelpFiles() {
return Arrays.stream(values());
return Arrays.stream(HelpFile.values());
}

@ParameterizedTest
@MethodSource("getAllHelpFiles")
public void referToValidPage(HelpFile help) throws IOException {
void referToValidPage(HelpFile help) throws IOException {
URL url = new URL(jabrefHelp + help.getPageName());
HttpURLConnection http = (HttpURLConnection) url.openConnection();
http.setRequestProperty("User-Agent", URLDownload.USER_AGENT);
Expand Down
19 changes: 12 additions & 7 deletions src/test/java/org/jabref/logic/importer/WebFetchersTest.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package org.jabref.logic.importer;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;

import org.jabref.logic.importer.fetcher.ACMPortalFetcher;
import org.jabref.logic.importer.fetcher.AbstractIsbnFetcher;
import org.jabref.logic.importer.fetcher.GrobidCitationFetcher;
import org.jabref.logic.importer.fetcher.IsbnViaEbookDeFetcher;
import org.jabref.logic.importer.fetcher.IsbnViaOttoBibFetcher;
import org.jabref.logic.importer.fetcher.MrDLibFetcher;
Expand All @@ -22,7 +24,7 @@
class WebFetchersTest {

private ImportFormatPreferences importFormatPreferences;
private ClassGraph classGraph = new ClassGraph().enableAllInfo().whitelistPackages("org.jabref");
private final ClassGraph classGraph = new ClassGraph().enableAllInfo().whitelistPackages("org.jabref");

@BeforeEach
void setUp() throws Exception {
Expand All @@ -36,7 +38,7 @@ void getIdBasedFetchersReturnsAllFetcherDerivingFromIdBasedFetcher() throws Exce
try (ScanResult scanResult = classGraph.scan()) {

ClassInfoList controlClasses = scanResult.getClassesImplementing(IdBasedFetcher.class.getCanonicalName());
Set<Class<?>> expected = controlClasses.loadClasses().stream().collect(Collectors.toSet());
Set<Class<?>> expected = new HashSet<>(controlClasses.loadClasses());

expected.remove(AbstractIsbnFetcher.class);
expected.remove(IdBasedParserFetcher.class);
Expand All @@ -58,7 +60,7 @@ void getEntryBasedFetchersReturnsAllFetcherDerivingFromEntryBasedFetcher() throw

try (ScanResult scanResult = classGraph.scan()) {
ClassInfoList controlClasses = scanResult.getClassesImplementing(EntryBasedFetcher.class.getCanonicalName());
Set<Class<?>> expected = controlClasses.loadClasses().stream().collect(Collectors.toSet());
Set<Class<?>> expected = new HashSet<>(controlClasses.loadClasses());

expected.remove(EntryBasedParserFetcher.class);
expected.remove(MrDLibFetcher.class);
Expand All @@ -71,13 +73,16 @@ void getSearchBasedFetchersReturnsAllFetcherDerivingFromSearchBasedFetcher() thr
Set<SearchBasedFetcher> searchBasedFetchers = WebFetchers.getSearchBasedFetchers(importFormatPreferences);
try (ScanResult scanResult = classGraph.scan()) {
ClassInfoList controlClasses = scanResult.getClassesImplementing(SearchBasedFetcher.class.getCanonicalName());
Set<Class<?>> expected = controlClasses.loadClasses().stream().collect(Collectors.toSet());
Set<Class<?>> expected = new HashSet<>(controlClasses.loadClasses());

expected.remove(SearchBasedParserFetcher.class);

// Remove ACM, because it doesn't work currently
expected.remove(ACMPortalFetcher.class);

// Remove GROBID, because we don't want to show this to the user
expected.remove(GrobidCitationFetcher.class);

assertEquals(expected, getClasses(searchBasedFetchers));
}
}
Expand All @@ -88,18 +93,18 @@ void getFullTextFetchersReturnsAllFetcherDerivingFromFullTextFetcher() throws Ex

try (ScanResult scanResult = classGraph.scan()) {
ClassInfoList controlClasses = scanResult.getClassesImplementing(FulltextFetcher.class.getCanonicalName());
Set<Class<?>> expected = controlClasses.loadClasses().stream().collect(Collectors.toSet());
Set<Class<?>> expected = new HashSet<>(controlClasses.loadClasses());
assertEquals(expected, getClasses(fullTextFetchers));
}
}

@Test
void getIdFetchersReturnsAllFetcherDerivingFromIdFetcher() throws Exception {
Set<IdFetcher> idFetchers = WebFetchers.getIdFetchers(importFormatPreferences);
Set<IdFetcher<?>> idFetchers = WebFetchers.getIdFetchers(importFormatPreferences);

try (ScanResult scanResult = classGraph.scan()) {
ClassInfoList controlClasses = scanResult.getClassesImplementing(IdFetcher.class.getCanonicalName());
Set<Class<?>> expected = controlClasses.loadClasses().stream().collect(Collectors.toSet());
Set<Class<?>> expected = new HashSet<>(controlClasses.loadClasses());

expected.remove(IdParserFetcher.class);
assertEquals(expected, getClasses(idFetchers));
Expand Down