Skip to content

Commit

Permalink
Changed the name and deleted comments in newly added JUnit tests to i…
Browse files Browse the repository at this point in the history
…ssue JabRef#6189.
  • Loading branch information
David Yu authored and David Yu committed Mar 8, 2021
1 parent 2533f7c commit 6559949
Showing 1 changed file with 5 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Optional;

import org.jabref.logic.journals.JournalStatistics;

Expand All @@ -20,7 +19,6 @@ class JournalEditorPopOverTest {
private Path tempFolder;
private final String testEntry = "1;28773;CA - A Cancer Journal for Clinicians;journal;15424863, 00079235;88,192;Q1;156;36;129;2924;22644;89;255,73;81,22;United States;Northern America;Wiley-Blackwell;1950-2020;Hematology (Q1), Oncology (Q1)";
private JournalStatistics jsReader;
// Create object that loads in data from file

/**
* Each test should begin with assigning a temp folder to find the generated files
Expand All @@ -40,7 +38,7 @@ void setUp(@TempDir Path tempFolder) throws Exception {
* title for the journal corresponding to the valid ISSN.
*/
@Test
void testValidISSN() throws IOException {
void validISSNreturnsCorrectData() throws IOException {
Path file = tempFolder.resolve("test.csv"); // Load in the file
Files.writeString(file,
testEntry, StandardOpenOption.CREATE); // Write the test entry to temp file
Expand All @@ -49,8 +47,7 @@ void testValidISSN() throws IOException {

jsReader = new JournalStatistics(file);
// Call method with valid ISSN with the object created during setup
boolean found = jsReader.getTitleByISSN(ISSN); // This variable should hold a method call to finding the correct journal given a valid ISSN
String trueJournalName = "CA - A Cancer Journal for Clinicians"; // true title of the found journal
boolean found = jsReader.getTitleByISSN(ISSN);

assertTrue(found);
}
Expand All @@ -60,35 +57,17 @@ void testValidISSN() throws IOException {
* return an empty title for the given ISSN because the ISSN is non-existent.
*/
@Test
void testInvalidISSN() throws IOException {
void invalidISSNreturnsEmptyData() throws IOException {
Path file = tempFolder.resolve("test.csv"); // Load in the file
Files.writeString(file,
testEntry, StandardOpenOption.CREATE); // Write test entry to temp file

int ISSN = 12300000;

jsReader = new JournalStatistics(file);
boolean found = jsReader.getTitleByISSN(ISSN);

// Call method with invalid ISSN with the object created during setup
String expectedJournalName = ""; // This variable is suppose to hold the title of the journal for the invalid ISSN
String trueJournalName = "Nature Reviews Genetics"; // Or empty String
boolean found = jsReader.getTitleByISSN(ISSN);

assertFalse(found);
}

/**
* 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() throws IOException {
Path expectedFile = tempFolder.resolve("test.csv"); // Load in the file
Files.writeString(expectedFile,
testEntry, StandardOpenOption.CREATE);

Optional<String> file = null; // This is where we would store our found file

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

0 comments on commit 6559949

Please sign in to comment.