From 64a827d8a4f360acdf4a92fb6caa1c481096c63d Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 26 Aug 2023 17:48:12 +0200 Subject: [PATCH 1/8] Enable ISBN search with GVK Fixes #10123 Tested with the ISBNs --- .../org/jabref/gui/EntryTypeViewModel.java | 2 +- .../jabref/logic/importer/WebFetchers.java | 2 +- .../logic/importer/fetcher/GvkFetcher.java | 38 ++++++- .../fetcher/isbntobibtex/IsbnFetcher.java | 15 ++- .../CompositeSearchBasedFetcherTest.java | 2 +- .../importer/fetcher/GvkFetcherTest.java | 17 +-- .../isbntobibtex/GVKIsbnFetcherTest.java | 105 ++++++++++++++++++ 7 files changed, 164 insertions(+), 17 deletions(-) create mode 100644 src/test/java/org/jabref/logic/importer/fetcher/isbntobibtex/GVKIsbnFetcherTest.java diff --git a/src/main/java/org/jabref/gui/EntryTypeViewModel.java b/src/main/java/org/jabref/gui/EntryTypeViewModel.java index 5ec83f26aaf..892229d6b3e 100644 --- a/src/main/java/org/jabref/gui/EntryTypeViewModel.java +++ b/src/main/java/org/jabref/gui/EntryTypeViewModel.java @@ -159,7 +159,7 @@ public void runFetcherWorker() { dialogService.showInformationDialogAndWait(Localization.lang("Failed to import by ID"), Localization.lang("Error message %0", fetcherExceptionMessage)); } - LOGGER.error(String.format("Exception during fetching when using fetcher '%s' with entry id '%s'.", searchId, fetcher), exception); + LOGGER.error(String.format("Exception during fetching when using fetcher '%s' with entry id '%s'.", fetcher, searchId), exception); searchingProperty.set(false); fetcherWorker = new FetcherWorker(); diff --git a/src/main/java/org/jabref/logic/importer/WebFetchers.java b/src/main/java/org/jabref/logic/importer/WebFetchers.java index 7038e270946..90ee0a2eabf 100644 --- a/src/main/java/org/jabref/logic/importer/WebFetchers.java +++ b/src/main/java/org/jabref/logic/importer/WebFetchers.java @@ -99,7 +99,7 @@ public static SortedSet getSearchBasedFetchers(ImportFormatP SortedSet set = new TreeSet<>(Comparator.comparing(WebFetcher::getName)); set.add(new ArXivFetcher(importFormatPreferences)); set.add(new INSPIREFetcher(importFormatPreferences)); - set.add(new GvkFetcher()); + set.add(new GvkFetcher(importFormatPreferences)); set.add(new BvbFetcher()); set.add(new MedlineFetcher()); set.add(new AstrophysicsDataSystem(importFormatPreferences, importerPreferences)); diff --git a/src/main/java/org/jabref/logic/importer/fetcher/GvkFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/GvkFetcher.java index 81e011ccde0..5ae34a92fa8 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/GvkFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/GvkFetcher.java @@ -7,19 +7,25 @@ import java.util.Collection; import java.util.Optional; +import org.jabref.logic.cleanup.FieldFormatterCleanup; +import org.jabref.logic.formatter.bibtexfields.NormalizeNamesFormatter; +import org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter; import org.jabref.logic.help.HelpFile; import org.jabref.logic.importer.FetcherException; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.Parser; import org.jabref.logic.importer.SearchBasedParserFetcher; import org.jabref.logic.importer.fetcher.transformers.GVKQueryTransformer; import org.jabref.logic.importer.fileformat.PicaXmlParser; +import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.field.StandardField; import org.apache.http.client.utils.URIBuilder; import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode; -public class GvkFetcher implements SearchBasedParserFetcher { +public class GvkFetcher extends AbstractIsbnFetcher implements SearchBasedParserFetcher { - private static final String URL_PATTERN = "https://sru.k10plus.de/gvk?"; + private static final String URL_PATTERN = "https://sru.k10plus.de/opac-de-627?"; /** * Searchkeys are used to specify a search request. For example "tit" stands for "title". @@ -27,6 +33,10 @@ public class GvkFetcher implements SearchBasedParserFetcher { */ private final Collection searchKeys = Arrays.asList("all", "tit", "per", "thm", "slw", "txt", "num", "kon", "ppn", "bkl", "erj"); + public GvkFetcher(ImportFormatPreferences importFormatPreferences) { + super(importFormatPreferences); + } + @Override public String getName() { return "GVK"; @@ -49,8 +59,32 @@ public URL getURLForQuery(QueryNode luceneQuery) throws URISyntaxException, Malf return uriBuilder.build().toURL(); } + @Override + public URL getUrlForIdentifier(String identifier) throws URISyntaxException, MalformedURLException, FetcherException { + this.ensureThatIsbnIsValid(identifier); + URIBuilder uriBuilder = new URIBuilder(URL_PATTERN); + uriBuilder.addParameter("version", "1.1"); + uriBuilder.addParameter("operation", "searchRetrieve"); + uriBuilder.addParameter("query", "pica.isb=" + identifier); + uriBuilder.addParameter("maximumRecords", "50"); + uriBuilder.addParameter("recordSchema", "picaxml"); + uriBuilder.addParameter("sortKeys", "Year,,1"); + return uriBuilder.build().toURL(); + } + @Override public Parser getParser() { return new PicaXmlParser(); } + + @Override + public void doPostCleanup(BibEntry entry) { + super.doPostCleanup(entry); + + // Fetcher returns page numbers as "30 Seiten" -> remove every non-digit character in the PAGETOTAL field + entry.getField(StandardField.PAGETOTAL).ifPresent(pages -> + entry.setField(StandardField.PAGETOTAL, pages.replaceAll("[\\D]", ""))); + new FieldFormatterCleanup(StandardField.PAGETOTAL, new NormalizePagesFormatter()).cleanup(entry); + new FieldFormatterCleanup(StandardField.AUTHOR, new NormalizeNamesFormatter()).cleanup(entry); + } } diff --git a/src/main/java/org/jabref/logic/importer/fetcher/isbntobibtex/IsbnFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/isbntobibtex/IsbnFetcher.java index 04062621325..88dc3c4df47 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/isbntobibtex/IsbnFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/isbntobibtex/IsbnFetcher.java @@ -13,9 +13,12 @@ import org.jabref.logic.importer.FetcherException; import org.jabref.logic.importer.IdBasedFetcher; import org.jabref.logic.importer.ImportFormatPreferences; +import org.jabref.logic.importer.ParseException; import org.jabref.logic.importer.fetcher.AbstractIsbnFetcher; +import org.jabref.logic.importer.fetcher.GvkFetcher; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; +import org.jabref.model.entry.identifier.ISBN; import org.jabref.model.strings.StringUtil; import org.jabref.model.util.OptionalUtil; @@ -35,11 +38,14 @@ public class IsbnFetcher implements EntryBasedFetcher, IdBasedFetcher { protected final ImportFormatPreferences importFormatPreferences; private final OpenLibraryIsbnFetcher openLibraryIsbnFetcher; private final List retryIsbnFetcher; + private final GvkFetcher gvkIbsnFetcher; public IsbnFetcher(ImportFormatPreferences importFormatPreferences) { this.importFormatPreferences = importFormatPreferences; this.openLibraryIsbnFetcher = new OpenLibraryIsbnFetcher(importFormatPreferences); + this.gvkIbsnFetcher = new GvkFetcher(importFormatPreferences); this.retryIsbnFetcher = new ArrayList<>(); + this.addRetryFetcher(openLibraryIsbnFetcher); } @Override @@ -54,15 +60,14 @@ public Optional getHelpPage() { @Override public Optional performSearchById(String identifier) throws FetcherException { - if (StringUtil.isBlank(identifier)) { - return Optional.empty(); - } - Optional bibEntry = Optional.empty(); try { identifier = removeNewlinesAndSpacesFromIdentifier(identifier); - bibEntry = openLibraryIsbnFetcher.performSearchById(identifier); + Optional isbn = ISBN.parse(identifier); + if(isbn.isPresent()) { + bibEntry = gvkIbsnFetcher.performSearchById(isbn.get().getNormalized()); + } } catch (FetcherException ex) { LOGGER.debug("Got a fetcher exception for IBSN search", ex); if (retryIsbnFetcher.isEmpty()) { diff --git a/src/test/java/org/jabref/logic/importer/fetcher/CompositeSearchBasedFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/CompositeSearchBasedFetcherTest.java index 991e6ed91f9..27b781014fb 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/CompositeSearchBasedFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/CompositeSearchBasedFetcherTest.java @@ -100,7 +100,7 @@ static Stream performSearchParameters() { List list = List.of( new ArXivFetcher(importFormatPreferences), new INSPIREFetcher(importFormatPreferences), - new GvkFetcher(), + new GvkFetcher(importFormatPreferences), new AstrophysicsDataSystem(importFormatPreferences, importerPreferences), new MathSciNet(importFormatPreferences), new ZbMATH(importFormatPreferences), diff --git a/src/test/java/org/jabref/logic/importer/fetcher/GvkFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/GvkFetcherTest.java index f47e4ad9180..7ba45ee9aad 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/GvkFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/GvkFetcherTest.java @@ -5,6 +5,7 @@ import java.util.List; import org.jabref.logic.importer.FetcherException; +import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.fetcher.transformers.AbstractQueryTransformer; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; @@ -16,9 +17,11 @@ import org.apache.lucene.queryparser.flexible.standard.parser.StandardSyntaxParser; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.mockito.Answers; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.mock; @FetcherTest public class GvkFetcherTest { @@ -29,19 +32,19 @@ public class GvkFetcherTest { @BeforeEach public void setUp() { - fetcher = new GvkFetcher(); + fetcher = new GvkFetcher(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS)); bibEntryPPN591166003 = new BibEntry(StandardEntryType.Book) .withField(StandardField.TITLE, "Effective Java") .withField(StandardField.PUBLISHER, "Addison-Wesley") .withField(StandardField.YEAR, "2008") - .withField(StandardField.AUTHOR, "Joshua Bloch") + .withField(StandardField.AUTHOR, "Bloch, Joshua") .withField(StandardField.SERIES, "The Java series ... from the source") .withField(StandardField.ADDRESS, "Upper Saddle River, NJ") .withField(StandardField.EDITION, "2. ed., 5. print.") .withField(StandardField.NOTE, "Includes bibliographical references and index. - Previous ed.: 2001. - Hier auch später erschienene, unveränderte Nachdrucke") .withField(StandardField.ISBN, "9780321356680") - .withField(StandardField.PAGETOTAL, "XXI, 346") + .withField(StandardField.PAGETOTAL, "346") .withField(new UnknownField("ppn_gvk"), "591166003") .withField(StandardField.SUBTITLE, "[revised and updated for JAVA SE 6]"); @@ -49,10 +52,10 @@ public void setUp() { .withField(StandardField.TITLE, "Effective unit testing") .withField(StandardField.PUBLISHER, "Manning") .withField(StandardField.YEAR, "2013") - .withField(StandardField.AUTHOR, "Lasse Koskela") + .withField(StandardField.AUTHOR, "Koskela, Lasse") .withField(StandardField.ADDRESS, "Shelter Island, NY") .withField(StandardField.ISBN, "9781935182573") - .withField(StandardField.PAGETOTAL, "XXIV, 223") + .withField(StandardField.PAGETOTAL, "223") .withField(new UnknownField("ppn_gvk"), "66391437X") .withField(StandardField.SUBTITLE, "A guide for Java developers"); } @@ -67,7 +70,7 @@ public void simpleSearchQueryURLCorrect() throws Exception { String query = "java jdk"; QueryNode luceneQuery = new StandardSyntaxParser().parse(query, AbstractQueryTransformer.NO_EXPLICIT_FIELD); URL url = fetcher.getURLForQuery(luceneQuery); - assertEquals("https://sru.k10plus.de/gvk?version=1.1&operation=searchRetrieve&query=pica.all%3Djava+and+pica.all%3Djdk&maximumRecords=50&recordSchema=picaxml&sortKeys=Year%2C%2C1", url.toString()); + assertEquals("https://sru.k10plus.de/opac-de-627?version=1.1&operation=searchRetrieve&query=pica.all%3Djava+and+pica.all%3Djdk&maximumRecords=50&recordSchema=picaxml&sortKeys=Year%2C%2C1", url.toString()); } @Test @@ -75,7 +78,7 @@ public void complexSearchQueryURLCorrect() throws Exception { String query = "kon:java tit:jdk"; QueryNode luceneQuery = new StandardSyntaxParser().parse(query, AbstractQueryTransformer.NO_EXPLICIT_FIELD); URL url = fetcher.getURLForQuery(luceneQuery); - assertEquals("https://sru.k10plus.de/gvk?version=1.1&operation=searchRetrieve&query=pica.kon%3Djava+and+pica.tit%3Djdk&maximumRecords=50&recordSchema=picaxml&sortKeys=Year%2C%2C1", url.toString()); + assertEquals("https://sru.k10plus.de/opac-de-627?version=1.1&operation=searchRetrieve&query=pica.kon%3Djava+and+pica.tit%3Djdk&maximumRecords=50&recordSchema=picaxml&sortKeys=Year%2C%2C1", url.toString()); } @Test diff --git a/src/test/java/org/jabref/logic/importer/fetcher/isbntobibtex/GVKIsbnFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/isbntobibtex/GVKIsbnFetcherTest.java new file mode 100644 index 00000000000..de0d8d1ff77 --- /dev/null +++ b/src/test/java/org/jabref/logic/importer/fetcher/isbntobibtex/GVKIsbnFetcherTest.java @@ -0,0 +1,105 @@ +package org.jabref.logic.importer.fetcher.isbntobibtex; + +import java.util.Optional; + +import org.jabref.logic.importer.FetcherClientException; +import org.jabref.logic.importer.FetcherException; +import org.jabref.logic.importer.ImportFormatPreferences; +import org.jabref.logic.importer.fetcher.AbstractIsbnFetcherTest; +import org.jabref.logic.importer.fetcher.GvkFetcher; +import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.field.StandardField; +import org.jabref.model.entry.field.UnknownField; +import org.jabref.model.entry.types.StandardEntryType; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Answers; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.mock; + +public class GVKIsbnFetcherTest extends AbstractIsbnFetcherTest { + + private BibEntry bibEntryEffectiveJavaLongISBN; + + @BeforeEach + public void setUp() { + bibEntryEffectiveJava = new BibEntry(StandardEntryType.Book) + .withField(StandardField.TITLE, "Effective Java(TM) Programming Language Guide (2nd Edition) (The Java Series)") + .withField(StandardField.PUBLISHER, "Prentice Hall PTR") + .withField(StandardField.YEAR, "2007") + .withField(StandardField.AUTHOR, "Bloch, Joshua") + .withField(StandardField.ISBN, "9780321356680") + .withField(StandardField.PAGES, "256"); + + bibEntryEffectiveJavaLongISBN = new BibEntry(StandardEntryType.Book) + .withField(StandardField.TITLE, "Effective Java") + .withField(StandardField.PUBLISHER, "Addison-Wesley") + .withField(StandardField.YEAR, "2011") + .withField(StandardField.AUTHOR, "Bloch, Joshua") + .withField(StandardField.SERIES, "The @Java series") + .withField(StandardField.ADDRESS, "Upper Saddle River, NJ [u.a.]") + .withField(StandardField.EDITION, "2. ed., rev. and updated for Java SE 6") + .withField(StandardField.NOTE, "*Hier auch später erschienene, unveränderte Nachdrucke*") + .withField(StandardField.ISBN, "9780321356680") + .withField(StandardField.PAGETOTAL, "346") + .withField(new UnknownField("ppn_gvk"), "67954951X") + .withField(StandardField.SUBTITLE, "[revised and updated for Java SE 6]"); + + + fetcher = new GvkFetcher(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS)); + } + + @Test + @Override + public void testName() { + assertEquals("GVK", fetcher.getName()); + } + + @Test + @Override + public void searchByIdSuccessfulWithShortISBN() throws FetcherException { + Optional fetchedEntry = fetcher.performSearchById("0321356683"); + assertEquals(Optional.of(bibEntryEffectiveJavaLongISBN), fetchedEntry); + } + + @Test + @Override + public void searchByIdSuccessfulWithLongISBN() throws FetcherException { + Optional fetchedEntry = fetcher.performSearchById("9780321356680"); + assertEquals(Optional.of(bibEntryEffectiveJavaLongISBN), fetchedEntry); + } + + @Test + @Override + public void authorsAreCorrectlyFormatted() throws Exception { + BibEntry bibEntry = new BibEntry(StandardEntryType.Misc) + .withField(StandardField.TITLE, "Repository") + .withField(StandardField.SUBTITLE, "Eine Einführung") + .withField(StandardField.PUBLISHER, "De Gruyter Oldenbourg") + .withField(StandardField.AUTHOR, "Habermann, Hans-Joachim") + .withField(StandardField.ISBN, "9783110702125") + .withField(StandardField.YEAR, "2020") + .withField(StandardField.ADDRESS, "München") + .withField(StandardField.EDITION, "Reprint 2020") + .withField(StandardField.EDITOR, "Frank Leymann") + .withField(StandardField.NUMBER, "8.1") + .withField(StandardField.PAGETOTAL, "1294") + .withField(StandardField.SERIES, "Handbuch der Informatik") + .withField(new UnknownField("ppn_gvk"), "1738076555"); + + Optional fetchedEntry = fetcher.performSearchById("9783110702125"); + assertEquals(Optional.of(bibEntry), fetchedEntry); + } + + /** + * Checks whether the given ISBN is NOT available at any ISBN fetcher + */ + @Test + public void testIsbnNeitherAvailableOnEbookDeNorOrViaOpenLibrary() throws Exception { + // In this test, the ISBN needs to be a valid (syntax+checksum) ISBN number + // However, the ISBN number must not be assigned to a real book + assertEquals(Optional.empty(), fetcher.performSearchById("9785646216541")); + } +} From 4272194a0bb7ec4b74a78cbf6181c948d1f1850f Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 26 Aug 2023 17:53:01 +0200 Subject: [PATCH 2/8] checkstyle --- .../logic/importer/fetcher/isbntobibtex/IsbnFetcher.java | 4 +--- .../importer/fetcher/isbntobibtex/GVKIsbnFetcherTest.java | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/org/jabref/logic/importer/fetcher/isbntobibtex/IsbnFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/isbntobibtex/IsbnFetcher.java index 88dc3c4df47..8b9fcd56e50 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/isbntobibtex/IsbnFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/isbntobibtex/IsbnFetcher.java @@ -13,13 +13,11 @@ import org.jabref.logic.importer.FetcherException; import org.jabref.logic.importer.IdBasedFetcher; import org.jabref.logic.importer.ImportFormatPreferences; -import org.jabref.logic.importer.ParseException; import org.jabref.logic.importer.fetcher.AbstractIsbnFetcher; import org.jabref.logic.importer.fetcher.GvkFetcher; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; import org.jabref.model.entry.identifier.ISBN; -import org.jabref.model.strings.StringUtil; import org.jabref.model.util.OptionalUtil; import org.slf4j.Logger; @@ -65,7 +63,7 @@ public Optional performSearchById(String identifier) throws FetcherExc try { identifier = removeNewlinesAndSpacesFromIdentifier(identifier); Optional isbn = ISBN.parse(identifier); - if(isbn.isPresent()) { + if (isbn.isPresent()) { bibEntry = gvkIbsnFetcher.performSearchById(isbn.get().getNormalized()); } } catch (FetcherException ex) { diff --git a/src/test/java/org/jabref/logic/importer/fetcher/isbntobibtex/GVKIsbnFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/isbntobibtex/GVKIsbnFetcherTest.java index de0d8d1ff77..0f8e7f76368 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/isbntobibtex/GVKIsbnFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/isbntobibtex/GVKIsbnFetcherTest.java @@ -2,7 +2,6 @@ import java.util.Optional; -import org.jabref.logic.importer.FetcherClientException; import org.jabref.logic.importer.FetcherException; import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.fetcher.AbstractIsbnFetcherTest; @@ -47,7 +46,6 @@ public void setUp() { .withField(new UnknownField("ppn_gvk"), "67954951X") .withField(StandardField.SUBTITLE, "[revised and updated for Java SE 6]"); - fetcher = new GvkFetcher(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS)); } From 5b59c5134d344daf91fbb24cf370faee31fe5ba6 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 26 Aug 2023 18:05:49 +0200 Subject: [PATCH 3/8] fix architecture test --- src/test/java/org/jabref/logic/importer/WebFetchersTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/org/jabref/logic/importer/WebFetchersTest.java b/src/test/java/org/jabref/logic/importer/WebFetchersTest.java index acd70190b6e..396c2a28e2b 100644 --- a/src/test/java/org/jabref/logic/importer/WebFetchersTest.java +++ b/src/test/java/org/jabref/logic/importer/WebFetchersTest.java @@ -9,6 +9,7 @@ import org.jabref.logic.importer.fetcher.AbstractIsbnFetcher; 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.JstorFetcher; import org.jabref.logic.importer.fetcher.MrDLibFetcher; import org.jabref.logic.importer.fetcher.isbntobibtex.DoiToBibtexConverterComIsbnFetcher; @@ -74,6 +75,7 @@ void getIdBasedFetchersReturnsAllFetcherDerivingFromIdBasedFetcher() { // Remove special ISBN fetcher since we don't want to expose them to the user expected.remove(OpenLibraryIsbnFetcher.class); expected.remove(EbookDeIsbnFetcher.class); + expected.remove(GvkFetcher.class); expected.remove(DoiToBibtexConverterComIsbnFetcher.class); // Remove the following, because they don't work at the moment From 19780de02f0168e67f3a87a2a9fb682f406f0a28 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 26 Aug 2023 18:11:49 +0200 Subject: [PATCH 4/8] fix isbn fetcher test --- .../fetcher/isbntobibtex/IsbnFetcherTest.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/jabref/logic/importer/fetcher/isbntobibtex/IsbnFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/isbntobibtex/IsbnFetcherTest.java index 4b71b09416a..d2afbfb2b00 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/isbntobibtex/IsbnFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/isbntobibtex/IsbnFetcherTest.java @@ -8,6 +8,7 @@ import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; +import org.jabref.model.entry.field.UnknownField; import org.jabref.model.entry.types.StandardEntryType; import org.jabref.testutils.category.FetcherTest; @@ -33,10 +34,14 @@ void setUp() { bibEntry = new BibEntry(StandardEntryType.Book) .withField(StandardField.AUTHOR, "Bloch, Joshua") .withField(StandardField.TITLE, "Effective Java") - .withField(StandardField.PUBLISHER, "Addison-Wesley Professional") - .withField(StandardField.YEAR, "2017") - .withField(StandardField.PAGES, "416") - .withField(StandardField.ISBN, "9780134685991"); + .withField(StandardField.PUBLISHER, "Addison-Wesley") + .withField(StandardField.YEAR, "2018") + .withField(StandardField.ISBN, "9780134685991") + .withField(StandardField.NOTE, "Titelzusätze auf dem Umschlag: \"Updated for Java 9. Best practices for ... the Java platform\"") + .withField(StandardField.PAGETOTAL, "392") + .withField(new UnknownField("ppn_gvk"), "100121840X") + .withField(StandardField.EDITION, "Third edition") + .withField(StandardField.ADDRESS, "Boston"); } @Test From ac842ce48bb2a2b36007831e78bc0f1c56049192 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 26 Aug 2023 18:16:28 +0200 Subject: [PATCH 5/8] fix grobid --- .../jabref/logic/importer/util/GrobidServiceTest.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/test/java/org/jabref/logic/importer/util/GrobidServiceTest.java b/src/test/java/org/jabref/logic/importer/util/GrobidServiceTest.java index 69c3693f2d1..755f802c701 100644 --- a/src/test/java/org/jabref/logic/importer/util/GrobidServiceTest.java +++ b/src/test/java/org/jabref/logic/importer/util/GrobidServiceTest.java @@ -47,16 +47,13 @@ public static void setup() { @Test public void processValidCitationTest() throws IOException, ParseException { BibEntry exampleBibEntry = new BibEntry(StandardEntryType.Article).withCitationKey("-1") - .withField(StandardField.AUTHOR, "Derwing, Tracey and Rossiter, Marian and Munro, Murray") - .withField(StandardField.TITLE, "Teaching Native Speakers to Listen to Foreign-accented Speech") + .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.PAGES, "245--259") .withField(StandardField.VOLUME, "23") - .withField(StandardField.PUBLISHER, "Informa UK Limited") .withField(StandardField.NUMBER, "4"); Optional response = grobidService.processCitation("Derwing, T. M., Rossiter, M. J., & Munro, " + "M. J. (2002). Teaching native speakers to listen to foreign-accented speech. " + From 30906afbd322cde9dac625d388fcffcfba9d15f2 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 26 Aug 2023 18:17:23 +0200 Subject: [PATCH 6/8] fix diva --- src/test/java/org/jabref/logic/importer/fetcher/DiVATest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/jabref/logic/importer/fetcher/DiVATest.java b/src/test/java/org/jabref/logic/importer/fetcher/DiVATest.java index dbb2d8a21be..bd00f6d1627 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/DiVATest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/DiVATest.java @@ -38,7 +38,7 @@ public void testPerformSearchById() throws Exception { entry.setType(StandardEntryType.Article); entry.setCitationKey("Gustafsson260746"); entry.setField(StandardField.AUTHOR, "Gustafsson, Oscar"); - entry.setField(StandardField.INSTITUTION, "Linköping University, The Institute of Technology"); + entry.setField(StandardField.INSTITUTION, "The Institute of Technology"); entry.setField(StandardField.JOURNAL, "IEEE transactions on circuits and systems. 2, Analog and digital signal processing (Print)"); entry.setField(StandardField.NUMBER, "11"); From 8f0371cd25147a7acad51d3dc365bfd2521a914d Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 26 Aug 2023 18:20:44 +0200 Subject: [PATCH 7/8] fix acm test --- .../jabref/logic/importer/fileformat/ACMPortalParserTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/jabref/logic/importer/fileformat/ACMPortalParserTest.java b/src/test/java/org/jabref/logic/importer/fileformat/ACMPortalParserTest.java index f4d4978c4a4..059890bd01b 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/ACMPortalParserTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/ACMPortalParserTest.java @@ -8,6 +8,7 @@ import java.net.URL; import java.util.Collections; import java.util.List; +import java.util.Optional; import org.jabref.logic.importer.FetcherException; import org.jabref.logic.importer.ParseException; @@ -74,7 +75,7 @@ void testParseEntries() throws IOException, ParseException { for (BibEntry bibEntry : bibEntries) { bibEntry.clearField(StandardField.ABSTRACT); } - assertEquals(searchEntryList.get(0), bibEntries.get(0)); + assertEquals(Optional.of(searchEntryList.get(0)), bibEntries.stream().findFirst()); } @Test From 503c0dfb8763602f560210465e666b41b216fbdf Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sun, 27 Aug 2023 12:58:08 +0200 Subject: [PATCH 8/8] fix test --- .../importer/fetcher/CompositeIdFetcherTest.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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 0440b67d06a..d171ed5d8e1 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/CompositeIdFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/CompositeIdFetcherTest.java @@ -79,12 +79,16 @@ public static Stream performSearchByIdReturnsCorrectEntryForIdentifie Arguments.arguments( "performSearchByIdReturnsCorrectEntryForIsbnId", new BibEntry(StandardEntryType.Book) - .withField(StandardField.TITLE, "Effective Java") - .withField(StandardField.PUBLISHER, "Addison-Wesley Professional") - .withField(StandardField.YEAR, "2017") .withField(StandardField.AUTHOR, "Bloch, Joshua") - .withField(StandardField.PAGES, "416") - .withField(StandardField.ISBN, "9780134685991"), + .withField(StandardField.TITLE, "Effective Java") + .withField(StandardField.PUBLISHER, "Addison-Wesley") + .withField(StandardField.YEAR, "2018") + .withField(StandardField.ISBN, "9780134685991") + .withField(StandardField.NOTE, "Titelzusätze auf dem Umschlag: \"Updated for Java 9. Best practices for ... the Java platform\"") + .withField(StandardField.PAGETOTAL, "392") + .withField(new UnknownField("ppn_gvk"), "100121840X") + .withField(StandardField.EDITION, "Third edition") + .withField(StandardField.ADDRESS, "Boston"), "9780134685991" ), Arguments.arguments(