Skip to content

Commit

Permalink
Javadocs and the outline of the idea to newly added automated tests h…
Browse files Browse the repository at this point in the history
…as been written for feature JabRef#6189
  • Loading branch information
David Yu authored and David Yu committed Mar 8, 2021
1 parent e9112e7 commit 7e120ef
Showing 1 changed file with 30 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.jabref.gui.fieldeditors;

import java.io.File;
import java.nio.file.Path;
import java.util.Optional;

Expand All @@ -14,48 +13,61 @@
class JournalEditorPopOverTest {

private Path tempFolder;
// Create object that loads in data from file

/**
* Each test should begin with assigning a temp folder to find the generated files
* from the download. Then we have to create our object that loads in the file
* and stores it temporarily.
* @param tempFolder
* @throws Exception
*/
@BeforeEach
void setUp(@TempDir Path tempFolder) throws Exception {
this.tempFolder = tempFolder; // Set up the temp folder
// 1) Create Journal Object

// Test entry
// 6, 58530, National vital statistics reports : from the Centers for Disease Control and Prevention,
// National Center for Health Statistics, National Vital Statistics System, book series, 15518922, 15518930
// 29,810, Q1, 95, 14, 30, 379, 1059, 30, 41,61, 27,07, United States, Northern America
// Public Health Services, US Dept of Health and Human Services 1998-2020 Life-span and Life-course Studies (Q1)
// Instantiate object that is used to read in data from file
}

/**
* Given a valid ISSN this test should be able to find the file and return the correct
* title for the journal corresponding to the valid ISSN.
*/
@Test
void testValidISSN() {
// Check if valid ISSN returns something
Path file = tempFolder.resolve("<Filename>.json"); // Load in the file
// Call method with valid ISSN
// String expectedJournalName = journalObject.getJournalNameByISSN(file, 15518922);
String expectedJournalName = "Hello";

// Call method with valid ISSN with the object created during setup
String expectedJournalName = ""; // This variable should hold a method call to finding the correct journal given a valid ISSN
String trueJournalName = "National vital statistics reports : from the Centers for Disease Control and Prevention, " +
"National Center for Health Statistics, National Vital Statistics System";
"National Center for Health Statistics, National Vital Statistics System"; // true title of the found journal

assertEquals(trueJournalName, expectedJournalName);
}

/**
* Given an invalid ISSN this test should be able to find the file and
* return an empty title for the given ISSN because the ISSN is non-existent.
*/
@Test
void testInvalidISSN() {
// Check if invalid ISSN returns something
Path file = tempFolder.resolve("<Filename>.json"); // Load in the file
// Call method with valid ISSN
// String expectedJournalName = journalObject.getJournalNameByISSN(file, 15518922); // Should return null or something
String expectedJournalName = null;

// Call method with invalid ISSN with the object created during setup
String expectedJournalName = null; // This variable is suppose to hold the title of the journal for the invalid ISSN
String trueJournalName = null; // Or empty String

assertEquals(expectedJournalName, trueJournalName);
}

/**
* This test regards testing whether the Python script or something similar is
* able to download data and store it in a file located in a temp folder.
*/
@Test
void testReadInput() {
Path expectedFile = tempFolder.resolve("test.json"); // Load in the file
Optional<String> file = journalObject.getFileByISSN(); // .... Load in the file
// Use the object to call a method that loads in the file
Optional<String> file = null; // This is where we would store our found file

// If file is not found
assertTrue(file.isPresent()); // File is present
Expand Down

0 comments on commit 7e120ef

Please sign in to comment.