From 203b152e4e097a1cc9cc63d5c41b00190c4216b1 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Wed, 20 Apr 2022 21:47:54 +0200 Subject: [PATCH] Fix style of parameterized tests - and remove one test case (because there are two results) Co-authored-by: Christoph Co-authored-by: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> --- .../importer/fetcher/DOABFetcherTest.java | 280 ++++++------------ 1 file changed, 86 insertions(+), 194 deletions(-) diff --git a/src/test/java/org/jabref/logic/importer/fetcher/DOABFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/DOABFetcherTest.java index fe25cfb43177..9adf06040961 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/DOABFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/DOABFetcherTest.java @@ -1,6 +1,7 @@ package org.jabref.logic.importer.fetcher; import java.util.List; +import java.util.stream.Stream; import org.jabref.logic.importer.FetcherException; import org.jabref.model.entry.BibEntry; @@ -8,213 +9,104 @@ import org.jabref.model.entry.types.StandardEntryType; import org.jabref.testutils.category.FetcherTest; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; @FetcherTest public class DOABFetcherTest { - private DOABFetcher fetcher; - private BibEntry David_Pol; - private BibEntry Ronald_Snijder; - private BibEntry Andrew_Perrin; - private BibEntry Felipe_Gonzalez; - private BibEntry Carl_Marnewick; - private BibEntry Antonios_Tsourdos; - private List bibs; - - @BeforeEach - public void setUp() throws Exception { - fetcher = new DOABFetcher(); - - David_Pol = new BibEntry(StandardEntryType.Book) - .withField(StandardField.AUTHOR, "David Pol") - .withField(StandardField.TITLE, "I Open Fire") - .withField(StandardField.DOI, "10.21983/P3.0086.1.00") - .withField(StandardField.PAGES, "56") - .withField(StandardField.YEAR, "2014") - .withField(StandardField.URL, "http://library.oapen.org/handle/20.500.12657/25535") - .withField(StandardField.URI, "https://directory.doabooks.org/handle/20.500.12854/34739") - .withField(StandardField.ABSTRACT, "David Pol presents an ontology of war in the form of " + - "the lyric poem. “Do you hear what I’m shooting at you?” In I Open Fire, all relation is " + - "warfare. Minefields compromise movement. Intention aims. Touch burns. Sex explodes bodies. " + - "Time ticks in bomb countdowns. Sound is sirens. Plenitude is debris. All of it under " + - "surveillance. “My world is critically injured. It was ambushed.” The poems in this book perform" + - " the reductions and repetitions endemic to war itself, each one returning the reader to the same," + - " unthinkable place in which the range of human experience has been so flattened that, despite all" + - " the explosive action, “Almost nothing is happening.” Against this backdrop, we continue to fall" + - " in love. But Pol’s poems remind us that this is no reason for optimism. Does love offer a" + - " delusional escape from war, or are relationships the very definition of combat? These poems take" + - " up the themes of love, sex, marriage, touch, hope — in short, the many dimensions of" + - " interpersonal connection — in a world in unprecedentedly critical condition. “And when the night" + - " goes off the shock wave throws us apart toward each other.”") - .withField(StandardField.LANGUAGE, "English") - .withField(StandardField.KEYWORDS, "poetry, love, warfare") - .withField(StandardField.PUBLISHER, "punctum books"); - - Ronald_Snijder = new BibEntry(StandardEntryType.Book) - .withField(StandardField.AUTHOR, "Ronald Snijder") - .withField(StandardField.TITLE, "The deliverance of open access books") - .withField(StandardField.SUBTITLE, "Examining usage and dissemination") - .withField(StandardField.DOI, "10.26530/OAPEN_1004809") - .withField(StandardField.PAGES, "234") - .withField(StandardField.YEAR, "2019") - .withField(StandardField.URL, "http://library.oapen.org/handle/20.500.12657/25287") - .withField(StandardField.URI, "https://directory.doabooks.org/handle/20.500.12854/26303") - .withField(StandardField.ABSTRACT, "In many scholarly disciplines, books - not articles" + - " - are the norm. As print runs become smaller, the question arises whether publishing monographs" + - " in open access helps to make their contents globally accessible. To answer this question, the" + - " results of multiple studies on the usage of open access books are presented. The research" + - " focuses on three areas: economic viability; optimization of open access monographs" + - " infrastructure and measuring the effects of open access in terms of scholarly impact and" + - " societal influence. Each chapter reviews a different aspect: book sales, digital dissemination," + - " open licenses, user communities, measuring usage, developing countries and the effects on" + - " citations and social media.") - .withField(StandardField.LANGUAGE, "English") - .withField(StandardField.KEYWORDS, "Open Access, Monographs, OAPEN Library, " + - "Directory of Open Access Books") - .withField(StandardField.PUBLISHER, "Amsterdam University Press"); - - Andrew_Perrin = new BibEntry(StandardEntryType.Book) - .withField(StandardField.EDITOR, "Andrew Perrin and Loren T. Stuckenbruck") - .withField(StandardField.TITLE, "Four Kingdom Motifs before and beyond the Book of Daniel") - .withField(StandardField.DOI, "10.1163/9789004443280") - .withField(StandardField.PAGES, "354") - .withField(StandardField.YEAR, "2020") - .withField(StandardField.URL, "https://library.oapen.org/handle/20.500.12657/48312") - .withField(StandardField.URI, "https://directory.doabooks.org/handle/20.500.12854/68086") - .withField(StandardField.ABSTRACT, "The four kingdoms motif enabled writers of various " + - "cultures, times, and places, to periodize history as the staged succession of empires " + - "barrelling towards an utopian age. The motif provided order to lived experiences under empire" + - " (the present), in view of ancestral traditions and cultural heritage (the past), and inspired" + - " outlooks assuring hope, deliverance, and restoration (the future). Four Kingdom Motifs before" + - " and beyond the Book of Daniel includes thirteen essays that explore the reach and redeployment" + - " of the motif in classical and ancient Near Eastern writings, Jewish and Christian scriptures," + - " texts among the Dead Sea Scrolls, Apocrypha and pseudepigrapha, depictions in European" + - " architecture and cartography, as well as patristic, rabbinic, Islamic, and African writings " + - "from antiquity through the Mediaeval eras. Readership: Advanced students and scholars of the " + - "textual formation, apocalyptic theology, and historiographies of the book of Daniel and its " + - "diverse reception by writers and communities.") - .withField(StandardField.LANGUAGE, "English") - .withField(StandardField.KEYWORDS, "Religion") - .withField(StandardField.PUBLISHER, "Brill"); - - Felipe_Gonzalez = new BibEntry(StandardEntryType.Book) - .withField(StandardField.EDITOR, "Felipe Gonzalez Toro and Antonios Tsourdos") - .withField(StandardField.TITLE, "UAV Sensors for Environmental Monitoring") - .withField(StandardField.DOI, "10.3390/books978-3-03842-754-4") - .withField(StandardField.PAGES, "670") - .withField(StandardField.YEAR, "2018") - .withField(StandardField.URI, "https://directory.doabooks.org/handle/20.500.12854/39793") - .withField(StandardField.ABSTRACT, "The rapid development and growth of UAVs as a " + - "remote sensing platform, as well as advances in the miniaturization of instrumentation and data" + - " systems, are catalyzing a renaissance in remote sensing in a variety of fields and disciplines" + - " from precision agriculture to ecology, atmospheric research, and disaster response. This" + - " Special Issue was open for submissions that highlight advances in the development and use of" + - " sensors deployed on UAVs. Topics include, but were not limited, to: • Optical, multi-spectral," + - " hyperspectral, laser, and optical SAR technologies • Gas analyzers and sensors • Artificial" + - " intelligence and data mining based strategies from UAVs • UAV onboard data storage," + - " transmission, and retrieval • Collaborative strategies and mechanisms to control multiple UAVs" + - " and sensor networks • UAV sensor applications: precision agriculture; pest detection, forestry," + - " mammal species tracking search and rescue; target tracking, the monitoring of the atmosphere;" + - " chemical, biological, and natural disaster phenomena; fire prevention, flood prevention;" + - " volcanic monitoring, pollution monitoring, micro-climates and land use") - .withField(StandardField.LANGUAGE, "English") - .withField(StandardField.KEYWORDS, "UAV sensors, Environmental Monitoring, drones, unmanned aerial vehicles") - .withField(StandardField.PUBLISHER, "MDPI - Multidisciplinary Digital Publishing Institute"); - - Carl_Marnewick = new BibEntry(StandardEntryType.Book) - .withField(StandardField.AUTHOR, "Carl Marnewick and Wikus Erasmus and Joseph Nazeer") - .withField(StandardField.TITLE, "The symbiosis between information system project complexity and information system project success") - .withField(StandardField.DOI, "10.4102/aosis.2017.itpsc45") - .withField(StandardField.PAGES, "184") - .withField(StandardField.YEAR, "2017") - .withField(StandardField.URL, "http://library.oapen.org/handle/20.500.12657/30652") - .withField(StandardField.URI, "https://directory.doabooks.org/handle/20.500.12854/38792") - .withField(StandardField.ABSTRACT, "Project success is widely covered, and the " + - "discourse on project complexity is proliferating. The purpose of this book is to merge and" + - " investigate the two concepts within the context of information system (IS) projects and" + - " understand the symbiosis between success and complexity in these projects. In this original" + - " and innovative research, exploratory modelling is employed to identify the aspects that" + - " constitute the success and complexity of projects based on the perceptions of IS project" + - " participants. This scholarly book aims at deepening the academic discourse on the relationship" + - " between the success and complexity of projects and to guide IS project managers towards" + - " improved project performance through the complexity lens. The research methodology stems from" + - " the realisation that the complexity of IS projects and its relationship to project success are" + - " under-documented. A post positivistic approach is applied in order to accommodate the" + - " subjective interpretation of IS-project participants through a quantitative design. The" + - " researchers developed an online survey strategy regarding literature concerning the success and" + - " complexity of projects. The views of 617 participants are documented. In the book, descriptive" + - " statistics and exploratory factor analysis pave the way for identifying the key success and" + - " complexity constructs of IS projects. These constructs are used in structural-equation" + - " modelling to build various validated and predictive models. Knowledge concerning the success" + - " and complexity of projects is mostly generic with little exposure to the field of IS project" + - " management. The contribution to current knowledge includes how the success of IS projects" + - " should be considered as well as what the complexity constructs of IS projects are. The success" + - " of IS projects encompasses strategic success, deliverable success, process success and the" + - " ‘unknowns’ of project success. The complexity of IS projects embodies organisational complexity" + - ", environmental complexity, technical complexity, dynamics and uncertainty. These constructs of" + - " success and complexity are mapped according to their underlying latent relationships to each" + - " other. The intended audience of this book is fellow researchers and project and IS specialists," + - " including information technology managers, executives, project managers, project team members," + - " the project management office (PMO), general managers and executives that initiate and conduct" + - " project-related work. The work presented in this first edition of the book is original and has" + - " not been plagiarised or presented before. It is not a revised version of a thesis or research" + - " previously published. Comments resulted from the blind peer review process were carefully" + - " considered and incorporated accordingly.") - .withField(StandardField.LANGUAGE, "English") - .withField(StandardField.KEYWORDS, "agile, structural equation modelling, information technology, success, models, strategic alignment, complexity, waterfall, project management, quantitative, Agile software development, Change management, Deliverable, Exploratory factor analysis, South Africa") - .withField(StandardField.PUBLISHER, "AOSIS"); - - Antonios_Tsourdos = new BibEntry(StandardEntryType.Book) - .withField(StandardField.EDITOR, "Felipe Gonzalez Toro and Antonios Tsourdos") - .withField(StandardField.TITLE, "UAV‐Based Remote Sensing Volume 2") - .withField(StandardField.PAGES, "VIII, 396") - .withField(StandardField.YEAR, "2018") - .withField(StandardField.URI, "https://directory.doabooks.org/handle/20.500.12854/61443") - .withField(StandardField.ABSTRACT, "ctive technological development has fuelled " + - "rapid growth in the number of Unmanned Aerial Vehicle (UAV) platforms being deployed around" + - " the globe. Novel UAV platforms, UAV-based sensors, robotic sensing and imaging techniques," + - " the development of processing workflows, as well as the capacity of ultra-high temporal and" + - " spatial resolution data, provide both opportunities and challenges that will allow engineers" + - " and scientists to address novel and important scientific questions in UAV and sensor design," + - " remote sensing and environmental monitoring. This work features papers on UAV sensor design," + - " improvements in UAV sensor technology, obstacle detection, methods for measuring optical " + - "flow, target tracking, gimbal influence on the stability of UAV images, augmented reality " + - "tools, segmentation in digital surface models for 3D reconstruction, detection, location and " + - "grasping objects, multi-target localization, vision-based tracking in cooperative multi-UAV " + - "systems, noise suppression techniques , rectification for oblique images, two-UAV " + - "communication system, fuzzy-based hybrid control algorithms, pedestrian detection and tracking" + - " as well as a range of atmospheric, geological, , agricultural, ecological, reef, wildlife, " + - "building and construction, coastal area coverage, search and rescue (SAR), water plume " + - "temperature measurements, aeromagnetic and archaeological surveys applications") - .withField(StandardField.LANGUAGE, "English") - .withField(StandardField.VOLUME, "2") - .withField(StandardField.KEYWORDS, "UAV-Based Remote Sensing, drones, pedestrian detection and tracking as well as a range of atmospheric, UAV images, fuzzy-based hybrid control algorithms, water plume temperature measurements, aeromagnetic and archaeological surveys, geological, two-UAV communication system, agricultural, wildlife, reef, detection, multi-target localization, ecological, search and rescue (SAR), coastal area coverage, remote sensing, environmental science, segmentation in digital surface models for 3D reconstruction, location and grasping objects, augmented reality tools, building and construction, aerial robotics, noise suppression techniques, rectification for oblique images, vision-based tracking in cooperative multi-UAV systems") - .withField(StandardField.PUBLISHER, "MDPI - Multidisciplinary Digital Publishing Institute"); - - bibs = List.of(David_Pol, Ronald_Snijder, Felipe_Gonzalez, Antonios_Tsourdos, Carl_Marnewick, - Andrew_Perrin); - } + private DOABFetcher fetcher = new DOABFetcher(); @Test public void testGetName() { assertEquals("DOAB", fetcher.getName()); } + public static Stream testPerformSearch() { + return Stream.of( + Arguments.of( + new BibEntry(StandardEntryType.Book) + .withField(StandardField.AUTHOR, "David Pol") + .withField(StandardField.TITLE, "I Open Fire") + .withField(StandardField.DOI, "10.21983/P3.0086.1.00") + .withField(StandardField.PAGES, "56") + .withField(StandardField.YEAR, "2014") + .withField(StandardField.URL, "http://library.oapen.org/handle/20.500.12657/25535") + .withField(StandardField.URI, "https://directory.doabooks.org/handle/20.500.12854/34739") + .withField(StandardField.LANGUAGE, "English") + .withField(StandardField.KEYWORDS, "poetry, love, warfare") + .withField(StandardField.PUBLISHER, "punctum books"), + "i open fire" + ), + Arguments.of( + new BibEntry(StandardEntryType.Book) + .withField(StandardField.AUTHOR, "Ronald Snijder") + .withField(StandardField.TITLE, "The deliverance of open access books") + .withField(StandardField.SUBTITLE, "Examining usage and dissemination") + .withField(StandardField.DOI, "10.26530/OAPEN_1004809") + .withField(StandardField.PAGES, "234") + .withField(StandardField.YEAR, "2019") + .withField(StandardField.URL, "http://library.oapen.org/handle/20.500.12657/25287") + .withField(StandardField.URI, "https://directory.doabooks.org/handle/20.500.12854/26303") + .withField(StandardField.LANGUAGE, "English") + .withField(StandardField.KEYWORDS, "Open Access, Monographs, OAPEN Library, " + + "Directory of Open Access Books") + .withField(StandardField.PUBLISHER, "Amsterdam University Press"), + "the deliverance of open access books" + ), + Arguments.of( + new BibEntry(StandardEntryType.Book) + .withField(StandardField.EDITOR, "Andrew Perrin and Loren T. Stuckenbruck") + .withField(StandardField.TITLE, "Four Kingdom Motifs before and beyond the Book of Daniel") + .withField(StandardField.DOI, "10.1163/9789004443280") + .withField(StandardField.PAGES, "354") + .withField(StandardField.YEAR, "2020") + .withField(StandardField.URL, "https://library.oapen.org/handle/20.500.12657/48312") + .withField(StandardField.URI, "https://directory.doabooks.org/handle/20.500.12854/68086") + .withField(StandardField.LANGUAGE, "English") + .withField(StandardField.KEYWORDS, "Religion") + .withField(StandardField.PUBLISHER, "Brill"), + "Four Kingdom Motifs before and beyond the Book of Daniel" + ), + Arguments.of( + new BibEntry(StandardEntryType.Book) + .withField(StandardField.EDITOR, "Felipe Gonzalez Toro and Antonios Tsourdos") + .withField(StandardField.TITLE, "UAV Sensors for Environmental Monitoring") + .withField(StandardField.DOI, "10.3390/books978-3-03842-754-4") + .withField(StandardField.PAGES, "670") + .withField(StandardField.YEAR, "2018") + .withField(StandardField.URI, "https://directory.doabooks.org/handle/20.500.12854/39793") + .withField(StandardField.LANGUAGE, "English") + .withField(StandardField.KEYWORDS, "UAV sensors, Environmental Monitoring, drones, unmanned aerial vehicles") + .withField(StandardField.PUBLISHER, "MDPI - Multidisciplinary Digital Publishing Institute"), + "UAV Sensors for Environmental Monitoring" + ), + Arguments.of( + new BibEntry(StandardEntryType.Book) + .withField(StandardField.AUTHOR, "Carl Marnewick and Wikus Erasmus and Joseph Nazeer") + .withField(StandardField.TITLE, "The symbiosis between information system project complexity and information system project success") + .withField(StandardField.DOI, "10.4102/aosis.2017.itpsc45") + .withField(StandardField.PAGES, "184") + .withField(StandardField.YEAR, "2017") + .withField(StandardField.URL, "http://library.oapen.org/handle/20.500.12657/30652") + .withField(StandardField.URI, "https://directory.doabooks.org/handle/20.500.12854/38792") + .withField(StandardField.LANGUAGE, "English") + .withField(StandardField.KEYWORDS, "agile, structural equation modelling, information technology, success, models, strategic alignment, complexity, waterfall, project management, quantitative, Agile software development, Change management, Deliverable, Exploratory factor analysis, South Africa") + .withField(StandardField.PUBLISHER, "AOSIS"), + "The symbiosis between information system project complexity and information system project success" + ) + ); + } + @ParameterizedTest - @ValueSource(strings = {"i open fire", "the deliverance of open access books", - "UAV Sensors for Environmental Monitoring", "Four Kingdom Motifs before and beyond the Book of Daniel", - "The symbiosis between information system project complexity and information system project success", - "UAV‐Based Remote Sensing Volume 2"}) - public void testPerformSearch(String query) throws FetcherException { - List entries; - entries = fetcher.performSearch(query); - assertTrue(bibs.contains(entries.get(0))); - // assertEquals(David_Pol, entries); + @MethodSource + public void testPerformSearch(BibEntry expected, String query) throws FetcherException { + List entries = fetcher.performSearch(query); + // We must not contain abstracts in our code base; thus we remove the abstracts from the fetched results + entries.stream().forEach(entry -> entry.clearField(StandardField.ABSTRACT)); + assertEquals(List.of(expected), entries); } }