Skip to content

Commit

Permalink
Remove Grobid also from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez committed May 23, 2020
1 parent 9882c6d commit e277c0c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/logic/importer/WebFetchers.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,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
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

0 comments on commit e277c0c

Please sign in to comment.