diff --git a/src/test/java/org/jabref/preferences/LastFocusedTabPreferencesTest.java b/src/jmh/java/org/jabref/preferences/LastFocusedTabPreferencesTest.java similarity index 100% rename from src/test/java/org/jabref/preferences/LastFocusedTabPreferencesTest.java rename to src/jmh/java/org/jabref/preferences/LastFocusedTabPreferencesTest.java diff --git a/src/main/java/org/jabref/gui/FindUnlinkedFilesDialog.java b/src/main/java/org/jabref/gui/FindUnlinkedFilesDialog.java index 0d4b38b0971..79b5ec468bf 100644 --- a/src/main/java/org/jabref/gui/FindUnlinkedFilesDialog.java +++ b/src/main/java/org/jabref/gui/FindUnlinkedFilesDialog.java @@ -67,6 +67,7 @@ import org.jabref.JabRefExecutorService; import org.jabref.JabRefGUI; import org.jabref.gui.desktop.JabRefDesktop; +import org.jabref.gui.externalfiletype.ExternalFileTypes; import org.jabref.gui.importer.EntryFromFileCreator; import org.jabref.gui.importer.EntryFromFileCreatorManager; import org.jabref.gui.importer.UnlinkedFilesCrawler; @@ -167,7 +168,7 @@ public FindUnlinkedFilesDialog(Frame owner, JabRefFrame frame, BasePanel panel) restoreSizeOfDialog(); databaseContext = panel.getDatabaseContext(); - creatorManager = new EntryFromFileCreatorManager(); + creatorManager = new EntryFromFileCreatorManager(ExternalFileTypes.getInstance()); crawler = new UnlinkedFilesCrawler(databaseContext); lastSelectedDirectory = loadLastSelectedDirectory(); diff --git a/src/main/java/org/jabref/gui/importer/EntryFromFileCreatorManager.java b/src/main/java/org/jabref/gui/importer/EntryFromFileCreatorManager.java index 49afd6f0f6d..f9b83282284 100644 --- a/src/main/java/org/jabref/gui/importer/EntryFromFileCreatorManager.java +++ b/src/main/java/org/jabref/gui/importer/EntryFromFileCreatorManager.java @@ -36,14 +36,14 @@ public final class EntryFromFileCreatorManager { private final List entryCreators; - public EntryFromFileCreatorManager() { + public EntryFromFileCreatorManager(ExternalFileTypes externalFilesTypes) { entryCreators = new ArrayList<>(10); - entryCreators.add(new EntryFromPDFCreator()); + entryCreators.add(new EntryFromPDFCreator(externalFilesTypes)); // add a creator for each ExternalFileType if there is no specialized // creator existing. - Collection fileTypes = ExternalFileTypes.getInstance().getExternalFileTypeSelection(); + Collection fileTypes = externalFilesTypes.getExternalFileTypeSelection(); for (ExternalFileType exFileType : fileTypes) { if (!hasSpecialisedCreatorForExternalFileType(exFileType)) { diff --git a/src/main/java/org/jabref/gui/importer/EntryFromPDFCreator.java b/src/main/java/org/jabref/gui/importer/EntryFromPDFCreator.java index 11538571332..e4f288970e2 100644 --- a/src/main/java/org/jabref/gui/importer/EntryFromPDFCreator.java +++ b/src/main/java/org/jabref/gui/importer/EntryFromPDFCreator.java @@ -33,12 +33,12 @@ */ public class EntryFromPDFCreator extends EntryFromFileCreator { - public EntryFromPDFCreator() { - super(EntryFromPDFCreator.getPDFExternalFileType()); + public EntryFromPDFCreator(ExternalFileTypes externalFileTypes) { + super(EntryFromPDFCreator.getPDFExternalFileType(externalFileTypes)); } - private static ExternalFileType getPDFExternalFileType() { - Optional pdfFileType = ExternalFileTypes.getInstance().getExternalFileTypeByExt("pdf"); + private static ExternalFileType getPDFExternalFileType(ExternalFileTypes externalFileTypes) { + Optional pdfFileType = externalFileTypes.getExternalFileTypeByExt("pdf"); if (!pdfFileType.isPresent()) { return new ExternalFileType("PDF", "pdf", "application/pdf", "evince", "pdfSmall", IconTheme.JabRefIcon.PDF_FILE.getSmallIcon()); } @@ -90,7 +90,7 @@ private void addEntryDataFromPDDocumentInformation(File pdfFile, BibEntry entry) if (pdfDocInfo != null) { Optional entryDI = XMPUtil .getBibtexEntryFromDocumentInformation(document - .getDocumentInformation()); + .getDocumentInformation()); if (entryDI.isPresent()) { addEntryDataToEntry(entry, entryDI.get()); Calendar creationDate = pdfDocInfo.getCreationDate(); diff --git a/src/test/java/org/jabref/CodeStyleTests.java b/src/test/java/org/jabref/CodeStyleTests.java index ec6a5641437..f2d5f6164d0 100644 --- a/src/test/java/org/jabref/CodeStyleTests.java +++ b/src/test/java/org/jabref/CodeStyleTests.java @@ -7,8 +7,9 @@ import org.jabref.model.strings.StringUtil; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; public class CodeStyleTests { @@ -17,8 +18,8 @@ public void StringUtilClassIsSmall() throws Exception { Path path = Paths.get("src", "main", "java", StringUtil.class.getName().replace('.', '/') + ".java"); int lineCount = Files.readAllLines(path, StandardCharsets.UTF_8).size(); - Assert.assertTrue("StringUtil increased in size. " + assertTrue(lineCount <= 722, "StringUtil increased in size. " + "We try to keep this class as small as possible. " - + "Thus think twice if you add something to StringUtil.", lineCount <= 722); + + "Thus think twice if you add something to StringUtil."); } } diff --git a/src/test/java/org/jabref/SearchQueryHighlightListenerTest.java b/src/test/java/org/jabref/SearchQueryHighlightListenerTest.java deleted file mode 100644 index c1b912517fd..00000000000 --- a/src/test/java/org/jabref/SearchQueryHighlightListenerTest.java +++ /dev/null @@ -1,113 +0,0 @@ -package org.jabref; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; - -import static org.junit.Assert.assertTrue; - -@RunWith(MockitoJUnitRunner.class) -public class SearchQueryHighlightListenerTest { - - //@Mock - //private ProtectedTermsLoader loader; - - - @Before - public void setUp() { - //Globals.prefs = JabRefPreferences.getInstance(); - //Globals.protectedTermsLoader = loader; - //when(loader.getProtectedTermsLists()).thenReturn(Collections.emptyList()); - } - - @Test - public void dummyTest() { - assertTrue(true); - } - - /* - // TODO: Reenable these tests and remove dummyTest - @Test - public void testHighlighting() { - - String content = "Test Word Content"; - String contentToHighlight1 = "Word"; - String contentToHighlight2 = "Content"; - - TextArea ta = new TextArea("", content); - - Highlighter highlighter = ta.getHighlighter(); - Highlight[] highlight = highlighter.getHighlights(); - - //there is no area to highlight! - Assert.assertEquals("Expected no highlighting area ", 0, highlight.length); - - ta.highlightPattern(Optional.of(Pattern.compile("Word"))); - - highlighter = ta.getHighlighter(); - highlight = highlighter.getHighlights(); - - //there is one area to highlight! - Assert.assertEquals("Expected one highlighting area ", 1, highlight.length); - //start of ... Word - Assert.assertEquals(content.indexOf(contentToHighlight1), highlight[0].getStartOffset()); - - //end of ... word - Assert.assertEquals(content.indexOf(contentToHighlight1) + contentToHighlight1.length(), - highlight[0].getEndOffset()); - - //add another word "content" and refresh highlighting - ta.highlightPattern(Optional.of(Pattern.compile("(Word|Content)"))); - highlighter = ta.getHighlighter(); - highlight = highlighter.getHighlights(); - - //there are two areas to highlight! - Assert.assertEquals("Expected two highlighting areas ", 2, highlight.length); - - //start of ... content - Assert.assertEquals(content.indexOf(contentToHighlight2), highlight[1].getStartOffset()); - - //end of ... content - Assert.assertEquals(content.indexOf(contentToHighlight2) + contentToHighlight2.length(), - highlight[1].getEndOffset()); - - //remove everything and check if highlighting is vanished - ta.highlightPattern(Optional.empty()); - highlighter = ta.getHighlighter(); - highlight = highlighter.getHighlights(); - - //there should be none areas to highlight! - Assert.assertEquals("Expected no highlighting area ", 0, highlight.length); - } - - @Test - public void testHighlightingContentIndependence() { - String content = "Test Word Content"; - TextArea ta = new TextArea("", content); - String textOne = ta.getText(); - - ta.highlightPattern(Optional.of((Pattern.compile("Word")))); - - String textTwo = ta.getText(); - Assert.assertEquals("Highlighting may not change content", textOne, textTwo); - - //set up empty arraylist and inform the fieldtextarea - ta.highlightPattern(Optional.empty()); - - String textThree = ta.getText(); - Assert.assertEquals("Highlighting may not change content", textOne, textThree); - } - - @Test - public void testHighlightingInvalidParameter() { - String content = "Test Word Content"; - - TextArea ta = new TextArea("", content); - - //should not matter at all - ta.highlightPattern(null); - } - - */ -} diff --git a/src/test/java/org/jabref/TestIconsProperties.java b/src/test/java/org/jabref/TestIconsProperties.java index 8665822aead..a354ba65470 100644 --- a/src/test/java/org/jabref/TestIconsProperties.java +++ b/src/test/java/org/jabref/TestIconsProperties.java @@ -12,11 +12,11 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class TestIconsProperties { @@ -31,15 +31,14 @@ public void testExistenceOfIconImagesReferencedFromIconsProperties() throws IOEx try (Reader reader = Files.newBufferedReader(Paths.get(iconsPropertiesPath))) { properties.load(reader); } - assertFalse("There must be loaded properties after loading " + iconsPropertiesPath, - properties.entrySet().isEmpty()); + assertFalse(properties.entrySet().isEmpty(), "There must be loaded properties after loading " + iconsPropertiesPath); // check that each key references an existing file for (Map.Entry entry : properties.entrySet()) { String name = entry.getKey().toString(); String value = entry.getValue().toString(); - assertTrue("Referenced image (" + name + " --> " + value + " does not exist in folder " + folder, Files.exists(Paths.get(folder, value))); + assertTrue(Files.exists(Paths.get(folder, value)), "Referenced image (" + name + " --> " + value + " does not exist in folder " + folder); } // check that each image in the folder is referenced by a key @@ -51,8 +50,7 @@ public void testExistenceOfIconImagesReferencedFromIconsProperties() throws IOEx try (Stream pathStream = Files.list(Paths.get(folder))) { List fileNamesInFolder = pathStream.map(p -> p.getFileName().toString()).collect(Collectors.toList()); fileNamesInFolder.removeAll(imagesReferencedFromProperties); - - assertEquals("Images are in the folder that are unused", "[red.png]", fileNamesInFolder.toString()); + assertEquals("[red.png]", fileNamesInFolder.toString(), "Images are in the folder that are unused"); } } } diff --git a/src/test/java/org/jabref/architecture/MainArchitectureTests.java b/src/test/java/org/jabref/architecture/MainArchitectureTests.java index 486c47572ef..6b6c95ab462 100644 --- a/src/test/java/org/jabref/architecture/MainArchitectureTests.java +++ b/src/test/java/org/jabref/architecture/MainArchitectureTests.java @@ -6,7 +6,6 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -16,11 +15,11 @@ import java.util.stream.Stream; import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) public class MainArchitectureTests { public static final String CLASS_ORG_JABREF_GLOBALS = "org.jabref.Globals"; @@ -35,17 +34,13 @@ public class MainArchitectureTests { private static final String EXCEPTION_PACKAGE_JAVA_FX_BEANS = "javafx.beans"; private static final String EXCEPTION_CLASS_JAVA_FX_COLOR = "javafx.scene.paint.Color"; - private final String firstPackage; - private final String secondPackage; - private Map> exceptions; - - public MainArchitectureTests(String firstPackage, String secondPackage) { - this.firstPackage = firstPackage; - this.secondPackage = secondPackage; + private static Map> exceptions; + @BeforeAll + public static void setUp() { + exceptions = new HashMap<>(); // Add exceptions for the architectural test here // Note that bending the architectural constraints should not be done inconsiderately - exceptions = new HashMap<>(); List logicExceptions = new ArrayList<>(4); logicExceptions.add(EXCEPTION_PACKAGE_JAVA_AWT_GEOM); @@ -63,32 +58,29 @@ public MainArchitectureTests(String firstPackage, String secondPackage) { exceptions.put(PACKAGE_ORG_JABREF_MODEL, modelExceptions); } - - @Parameterized.Parameters(name = "{index} -- is {0} independent of {1}?") - public static Iterable data() { - return Arrays.asList( - new Object[][]{ - {PACKAGE_ORG_JABREF_LOGIC, PACKAGE_JAVA_AWT}, - {PACKAGE_ORG_JABREF_LOGIC, PACKAGE_JAVAX_SWING}, - {PACKAGE_ORG_JABREF_LOGIC, PACKAGE_JAVA_FX}, - {PACKAGE_ORG_JABREF_LOGIC, PACKAGE_ORG_JABREF_GUI}, - {PACKAGE_ORG_JABREF_LOGIC, CLASS_ORG_JABREF_GLOBALS}, - - {PACKAGE_ORG_JABREF_MODEL, PACKAGE_JAVA_AWT}, - {PACKAGE_ORG_JABREF_MODEL, PACKAGE_JAVAX_SWING}, - {PACKAGE_ORG_JABREF_MODEL, PACKAGE_JAVA_FX}, - {PACKAGE_ORG_JABREF_MODEL, PACKAGE_ORG_JABREF_GUI}, - {PACKAGE_ORG_JABREF_MODEL, PACKAGE_ORG_JABREF_LOGIC}, - {PACKAGE_ORG_JABREF_MODEL, CLASS_ORG_JABREF_GLOBALS} - } - ); + public static Stream getPackages() { + + return Stream.of( + Arguments.of(PACKAGE_ORG_JABREF_LOGIC, PACKAGE_JAVA_AWT), + Arguments.of(PACKAGE_ORG_JABREF_LOGIC, PACKAGE_JAVAX_SWING), + Arguments.of(PACKAGE_ORG_JABREF_LOGIC, PACKAGE_JAVA_FX), + Arguments.of(PACKAGE_ORG_JABREF_LOGIC, PACKAGE_ORG_JABREF_GUI), + Arguments.of(PACKAGE_ORG_JABREF_LOGIC, CLASS_ORG_JABREF_GLOBALS), + + Arguments.of(PACKAGE_ORG_JABREF_MODEL, PACKAGE_JAVA_AWT), + Arguments.of(PACKAGE_ORG_JABREF_MODEL, PACKAGE_JAVAX_SWING), + Arguments.of(PACKAGE_ORG_JABREF_MODEL, PACKAGE_JAVA_FX), + Arguments.of(PACKAGE_ORG_JABREF_MODEL, PACKAGE_ORG_JABREF_GUI), + Arguments.of(PACKAGE_ORG_JABREF_MODEL, PACKAGE_ORG_JABREF_LOGIC), + Arguments.of(PACKAGE_ORG_JABREF_MODEL, CLASS_ORG_JABREF_GLOBALS)); } - @Test - public void firstPackageIsIndependentOfSecondPackage() throws IOException { - Predicate isExceptionPackage = (s) -> - s.startsWith("import " + secondPackage) - && exceptions.getOrDefault(firstPackage, Collections.emptyList()).stream() + @ParameterizedTest(name = "{index} -- is {0} independent of {1}?") + @MethodSource("getPackages") + public void firstPackageIsIndependentOfSecondPackage(String firstPackage, String secondPackage) throws IOException { + Predicate isExceptionPackage = (s) -> s.startsWith("import " + secondPackage) + && exceptions.getOrDefault(firstPackage, Collections.emptyList()) + .stream() .noneMatch(exception -> s.startsWith("import " + exception)); Predicate isPackage = (s) -> s.startsWith("package " + firstPackage); @@ -109,7 +101,8 @@ public void firstPackageIsIndependentOfSecondPackage() throws IOException { } catch (IOException e) { return false; } - }).collect(Collectors.toList()); + }) + .collect(Collectors.toList()); Assert.assertEquals("The following classes are not allowed to depend on " + secondPackage, Collections.emptyList(), files); diff --git a/src/test/java/org/jabref/cleanup/CleanupActionsListModelTest.java b/src/test/java/org/jabref/cleanup/CleanupActionsListModelTest.java index 5dd7f262919..885a6d1e109 100644 --- a/src/test/java/org/jabref/cleanup/CleanupActionsListModelTest.java +++ b/src/test/java/org/jabref/cleanup/CleanupActionsListModelTest.java @@ -14,10 +14,10 @@ import org.jabref.model.cleanup.FieldFormatterCleanup; import org.jabref.model.cleanup.FieldFormatterCleanups; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; diff --git a/src/test/java/org/jabref/cli/AuxCommandLineTest.java b/src/test/java/org/jabref/cli/AuxCommandLineTest.java index f145903b2e9..81e81952062 100644 --- a/src/test/java/org/jabref/cli/AuxCommandLineTest.java +++ b/src/test/java/org/jabref/cli/AuxCommandLineTest.java @@ -14,18 +14,19 @@ import org.jabref.model.database.BibDatabase; import org.jabref.model.util.DummyFileUpdateMonitor; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +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.assertNotNull; import static org.mockito.Mockito.mock; public class AuxCommandLineTest { private ImportFormatPreferences importFormatPreferences; - @Before + @BeforeEach public void setUp() throws Exception { importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); } @@ -40,8 +41,8 @@ public void test() throws URISyntaxException, IOException { AuxCommandLine auxCommandLine = new AuxCommandLine(auxFile.getAbsolutePath(), result.getDatabase()); BibDatabase newDB = auxCommandLine.perform(); - Assert.assertNotNull(newDB); - Assert.assertEquals(2, newDB.getEntries().size()); + assertNotNull(newDB); + assertEquals(2, newDB.getEntries().size()); } } diff --git a/src/test/java/org/jabref/cli/JabRefCLITest.java b/src/test/java/org/jabref/cli/JabRefCLITest.java index 0d59160e0d2..bab13945e9e 100644 --- a/src/test/java/org/jabref/cli/JabRefCLITest.java +++ b/src/test/java/org/jabref/cli/JabRefCLITest.java @@ -2,8 +2,10 @@ import java.util.Collections; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class JabRefCLITest { @@ -11,29 +13,29 @@ public class JabRefCLITest { public void testCLIParsingLongOptions() { JabRefCLI cli = new JabRefCLI(new String[] {"--nogui", "--import=some/file", "--output=some/export/file"}); - Assert.assertEquals(Collections.emptyList(), cli.getLeftOver()); - Assert.assertEquals("some/file", cli.getFileImport()); - Assert.assertTrue(cli.isDisableGui()); - Assert.assertEquals("some/export/file", cli.getFileExport()); + assertEquals(Collections.emptyList(), cli.getLeftOver()); + assertEquals("some/file", cli.getFileImport()); + assertTrue(cli.isDisableGui()); + assertEquals("some/export/file", cli.getFileExport()); } @Test public void testCLIParsingShortOptions() { JabRefCLI cli = new JabRefCLI(new String[] {"-n", "-i=some/file", "-o=some/export/file"}); - Assert.assertEquals(Collections.emptyList(), cli.getLeftOver()); - Assert.assertEquals("some/file", cli.getFileImport()); - Assert.assertTrue(cli.isDisableGui()); - Assert.assertEquals("some/export/file", cli.getFileExport()); + assertEquals(Collections.emptyList(), cli.getLeftOver()); + assertEquals("some/file", cli.getFileImport()); + assertTrue(cli.isDisableGui()); + assertEquals("some/export/file", cli.getFileExport()); } @Test public void testPreferencesExport() { JabRefCLI cli = new JabRefCLI(new String[] {"-n", "-x=some/file"}); - Assert.assertEquals(Collections.emptyList(), cli.getLeftOver()); - Assert.assertEquals("some/file", cli.getPreferencesExport()); - Assert.assertTrue(cli.isDisableGui()); + assertEquals(Collections.emptyList(), cli.getLeftOver()); + assertEquals("some/file", cli.getPreferencesExport()); + assertTrue(cli.isDisableGui()); } } diff --git a/src/test/java/org/jabref/gui/ClipBoardManagerTest.java b/src/test/java/org/jabref/gui/ClipBoardManagerTest.java index b0b5e2dcf76..6c0c9347e04 100644 --- a/src/test/java/org/jabref/gui/ClipBoardManagerTest.java +++ b/src/test/java/org/jabref/gui/ClipBoardManagerTest.java @@ -12,8 +12,8 @@ import org.jabref.logic.importer.ParserResult; import org.jabref.model.entry.BibEntry; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentMatchers; import static org.junit.Assert.*; @@ -26,7 +26,7 @@ public class ClipBoardManagerTest { private Transferable content; private ImportFormatReader importFormatReader; - @Before + @BeforeEach public void setUp() throws Exception { importFormatReader = mock(ImportFormatReader.class); diff --git a/src/test/java/org/jabref/gui/UpdateTimestampListenerTest.java b/src/test/java/org/jabref/gui/UpdateTimestampListenerTest.java index 6a27c3949b5..664b78590bd 100644 --- a/src/test/java/org/jabref/gui/UpdateTimestampListenerTest.java +++ b/src/test/java/org/jabref/gui/UpdateTimestampListenerTest.java @@ -7,28 +7,23 @@ import org.jabref.model.entry.BibEntry; import org.jabref.preferences.JabRefPreferences; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; public class UpdateTimestampListenerTest { - @Rule - public ExpectedException thrown = ExpectedException.none(); - private BibDatabase database; private BibEntry bibEntry; private JabRefPreferences preferencesMock; private TimestampPreferences timestampPreferencesMock; - @Before - public void setUp(){ + @BeforeEach + public void setUp() { database = new BibDatabase(); bibEntry = new BibEntry(); @@ -41,7 +36,7 @@ public void setUp(){ } @Test - public void updateTimestampEnabled(){ + public void updateTimestampEnabled() { final String timestampField = "timestamp"; final String baseDate = "2000-1-1"; final String newDate = "2000-1-2"; @@ -54,19 +49,17 @@ public void updateTimestampEnabled(){ bibEntry.setField(timestampField, baseDate); - assertEquals("Initial timestamp not set correctly", - Optional.of(baseDate), bibEntry.getField(timestampField)); + assertEquals(Optional.of(baseDate), bibEntry.getField(timestampField), "Initial timestamp not set correctly"); database.registerListener(new UpdateTimestampListener(preferencesMock)); bibEntry.setField("test", "some value"); - assertEquals("Timestamp not set correctly after entry changed", - Optional.of(newDate), bibEntry.getField(timestampField)); + assertEquals(Optional.of(newDate), bibEntry.getField(timestampField), "Timestamp not set correctly after entry changed"); } @Test - public void updateTimestampDisabled(){ + public void updateTimestampDisabled() { final String timestampField = "timestamp"; final String baseDate = "2000-1-1"; final String newDate = "2000-1-2"; @@ -79,14 +72,12 @@ public void updateTimestampDisabled(){ bibEntry.setField(timestampField, baseDate); - assertEquals("Initial timestamp not set correctly", - Optional.of(baseDate), bibEntry.getField(timestampField)); + assertEquals(Optional.of(baseDate), bibEntry.getField(timestampField), "Initial timestamp not set correctly"); database.registerListener(new UpdateTimestampListener(preferencesMock)); bibEntry.setField("test", "some value"); - assertEquals("New timestamp set after entry changed even though updates were disabled", - Optional.of(baseDate), bibEntry.getField(timestampField)); + assertEquals(Optional.of(baseDate), bibEntry.getField(timestampField), "New timestamp set after entry changed even though updates were disabled"); } } diff --git a/src/test/java/org/jabref/gui/autocompleter/BibEntrySuggestionProviderTest.java b/src/test/java/org/jabref/gui/autocompleter/BibEntrySuggestionProviderTest.java index b66163a940d..099f6cab1af 100644 --- a/src/test/java/org/jabref/gui/autocompleter/BibEntrySuggestionProviderTest.java +++ b/src/test/java/org/jabref/gui/autocompleter/BibEntrySuggestionProviderTest.java @@ -6,16 +6,18 @@ import org.jabref.model.entry.BibEntry; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.jabref.gui.autocompleter.AutoCompleterUtil.getRequest; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class BibEntrySuggestionProviderTest { + private BibEntrySuggestionProvider autoCompleter; - @Before + @BeforeEach public void setUp() throws Exception { autoCompleter = new BibEntrySuggestionProvider(); } @@ -23,7 +25,7 @@ public void setUp() throws Exception { @Test public void completeWithoutAddingAnythingReturnsNothing() { Collection result = autoCompleter.call(getRequest(("test"))); - Assert.assertEquals(Collections.emptyList(), result); + assertEquals(Collections.emptyList(), result); } @Test @@ -31,7 +33,7 @@ public void completeAfterAddingNullReturnsNothing() { autoCompleter.indexEntry(null); Collection result = autoCompleter.call(getRequest(("test"))); - Assert.assertEquals(Collections.emptyList(), result); + assertEquals(Collections.emptyList(), result); } @Test @@ -40,7 +42,7 @@ public void completeAfterAddingEmptyEntryReturnsNothing() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("test"))); - Assert.assertEquals(Collections.emptyList(), result); + assertEquals(Collections.emptyList(), result); } @Test @@ -50,7 +52,7 @@ public void completeKeyReturnsKey() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("testKey"))); - Assert.assertEquals(Collections.singletonList(entry), result); + assertEquals(Collections.singletonList(entry), result); } @Test @@ -60,7 +62,7 @@ public void completeBeginnigOfKeyReturnsKey() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("test"))); - Assert.assertEquals(Collections.singletonList(entry), result); + assertEquals(Collections.singletonList(entry), result); } @Test @@ -70,16 +72,16 @@ public void completeLowercaseKeyReturnsKey() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("testkey"))); - Assert.assertEquals(Collections.singletonList(entry), result); + assertEquals(Collections.singletonList(entry), result); } - @Test(expected = NullPointerException.class) + @Test public void completeNullThrowsException() { BibEntry entry = new BibEntry(); entry.setCiteKey("testKey"); autoCompleter.indexEntry(entry); - autoCompleter.call(getRequest((null))); + assertThrows(NullPointerException.class, () -> autoCompleter.call(getRequest((null)))); } @Test @@ -89,7 +91,7 @@ public void completeEmptyStringReturnsNothing() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest((""))); - Assert.assertEquals(Collections.emptyList(), result); + assertEquals(Collections.emptyList(), result); } @Test @@ -102,7 +104,7 @@ public void completeReturnsMultipleResults() { autoCompleter.indexEntry(entryTwo); Collection result = autoCompleter.call(getRequest(("testKey"))); - Assert.assertEquals(Arrays.asList(entryTwo, entryOne), result); + assertEquals(Arrays.asList(entryTwo, entryOne), result); } @Test @@ -112,6 +114,6 @@ public void completeShortKeyReturnsKey() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("k"))); - Assert.assertEquals(Collections.singletonList(entry), result); + assertEquals(Collections.singletonList(entry), result); } } diff --git a/src/test/java/org/jabref/gui/autocompleter/DefaultAutoCompleterTest.java b/src/test/java/org/jabref/gui/autocompleter/DefaultAutoCompleterTest.java index 5983d43da57..41719918129 100644 --- a/src/test/java/org/jabref/gui/autocompleter/DefaultAutoCompleterTest.java +++ b/src/test/java/org/jabref/gui/autocompleter/DefaultAutoCompleterTest.java @@ -6,23 +6,23 @@ import org.jabref.model.entry.BibEntry; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.jabref.gui.autocompleter.AutoCompleterUtil.getRequest; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class DefaultAutoCompleterTest { private WordSuggestionProvider autoCompleter; - @SuppressWarnings("unused") - @Test(expected = NullPointerException.class) + @Test public void initAutoCompleterWithNullFieldThrowsException() { - new WordSuggestionProvider(null); + assertThrows(NullPointerException.class, () -> new WordSuggestionProvider(null)); } - @Before + @BeforeEach public void setUp() throws Exception { autoCompleter = new WordSuggestionProvider("field"); } @@ -30,7 +30,7 @@ public void setUp() throws Exception { @Test public void completeWithoutAddingAnythingReturnsNothing() { Collection result = autoCompleter.call(getRequest(("test"))); - Assert.assertEquals(Collections.emptyList(), result); + assertEquals(Collections.emptyList(), result); } @Test @@ -38,7 +38,7 @@ public void completeAfterAddingNullReturnsNothing() { autoCompleter.indexEntry(null); Collection result = autoCompleter.call(getRequest(("test"))); - Assert.assertEquals(Collections.emptyList(), result); + assertEquals(Collections.emptyList(), result); } @Test @@ -47,7 +47,7 @@ public void completeAfterAddingEmptyEntryReturnsNothing() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("test"))); - Assert.assertEquals(Collections.emptyList(), result); + assertEquals(Collections.emptyList(), result); } @Test @@ -57,7 +57,7 @@ public void completeAfterAddingEntryWithoutFieldReturnsNothing() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("test"))); - Assert.assertEquals(Collections.emptyList(), result); + assertEquals(Collections.emptyList(), result); } @Test @@ -67,7 +67,7 @@ public void completeValueReturnsValue() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("testValue"))); - Assert.assertEquals(Arrays.asList("testValue"), result); + assertEquals(Arrays.asList("testValue"), result); } @Test @@ -77,7 +77,7 @@ public void completeBeginnigOfValueReturnsValue() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("test"))); - Assert.assertEquals(Arrays.asList("testValue"), result); + assertEquals(Arrays.asList("testValue"), result); } @Test @@ -87,16 +87,16 @@ public void completeLowercaseValueReturnsValue() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("testvalue"))); - Assert.assertEquals(Arrays.asList("testValue"), result); + assertEquals(Arrays.asList("testValue"), result); } - @Test(expected = NullPointerException.class) + @Test public void completeNullThrowsException() { BibEntry entry = new BibEntry(); entry.setField("field", "testKey"); autoCompleter.indexEntry(entry); - autoCompleter.call(getRequest((null))); + assertThrows(NullPointerException.class, () -> autoCompleter.call(getRequest((null)))); } @Test @@ -106,7 +106,7 @@ public void completeEmptyStringReturnsNothing() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest((""))); - Assert.assertEquals(Collections.emptyList(), result); + assertEquals(Collections.emptyList(), result); } @Test @@ -119,7 +119,7 @@ public void completeReturnsMultipleResults() { autoCompleter.indexEntry(entryTwo); Collection result = autoCompleter.call(getRequest(("testValue"))); - Assert.assertEquals(Arrays.asList("testValueOne", "testValueTwo"), result); + assertEquals(Arrays.asList("testValueOne", "testValueTwo"), result); } @Test @@ -129,7 +129,7 @@ public void completeShortStringReturnsValue() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("va"))); - Assert.assertEquals(Collections.singletonList("val"), result); + assertEquals(Collections.singletonList("val"), result); } @Test @@ -139,7 +139,7 @@ public void completeBeginnigOfSecondWordReturnsWord() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("val"))); - Assert.assertEquals(Collections.singletonList("value"), result); + assertEquals(Collections.singletonList("value"), result); } @Test @@ -149,6 +149,6 @@ public void completePartOfWordReturnsValue() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("lue"))); - Assert.assertEquals(Collections.singletonList("value"), result); + assertEquals(Collections.singletonList("value"), result); } } diff --git a/src/test/java/org/jabref/gui/autocompleter/FieldValueSuggestionProviderTest.java b/src/test/java/org/jabref/gui/autocompleter/FieldValueSuggestionProviderTest.java index 1ecf2600084..a8984a6447f 100644 --- a/src/test/java/org/jabref/gui/autocompleter/FieldValueSuggestionProviderTest.java +++ b/src/test/java/org/jabref/gui/autocompleter/FieldValueSuggestionProviderTest.java @@ -6,30 +6,31 @@ import org.jabref.model.entry.BibEntry; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.jabref.gui.autocompleter.AutoCompleterUtil.getRequest; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class FieldValueSuggestionProviderTest { + private FieldValueSuggestionProvider autoCompleter; - @Before + @BeforeEach public void setUp() throws Exception { autoCompleter = new FieldValueSuggestionProvider("field"); } - @SuppressWarnings("unused") - @Test(expected = NullPointerException.class) + @Test public void initAutoCompleterWithNullFieldThrowsException() { - new FieldValueSuggestionProvider(null); + assertThrows(NullPointerException.class, () -> new FieldValueSuggestionProvider(null)); } @Test public void completeWithoutAddingAnythingReturnsNothing() { Collection result = autoCompleter.call(getRequest(("test"))); - Assert.assertEquals(Collections.emptyList(), result); + assertEquals(Collections.emptyList(), result); } @Test @@ -37,7 +38,7 @@ public void completeAfterAddingNullReturnsNothing() { autoCompleter.indexEntry(null); Collection result = autoCompleter.call(getRequest(("test"))); - Assert.assertEquals(Collections.emptyList(), result); + assertEquals(Collections.emptyList(), result); } @Test @@ -46,7 +47,7 @@ public void completeAfterAddingEmptyEntryReturnsNothing() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("test"))); - Assert.assertEquals(Collections.emptyList(), result); + assertEquals(Collections.emptyList(), result); } @Test @@ -56,7 +57,7 @@ public void completeAfterAddingEntryWithoutFieldReturnsNothing() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("test"))); - Assert.assertEquals(Collections.emptyList(), result); + assertEquals(Collections.emptyList(), result); } @Test @@ -66,7 +67,7 @@ public void completeValueReturnsValue() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("testValue"))); - Assert.assertEquals(Arrays.asList("testValue"), result); + assertEquals(Arrays.asList("testValue"), result); } @Test @@ -76,7 +77,7 @@ public void completeBeginnigOfValueReturnsValue() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("test"))); - Assert.assertEquals(Arrays.asList("testValue"), result); + assertEquals(Arrays.asList("testValue"), result); } @Test @@ -86,16 +87,16 @@ public void completeLowercaseValueReturnsValue() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("testvalue"))); - Assert.assertEquals(Arrays.asList("testValue"), result); + assertEquals(Arrays.asList("testValue"), result); } - @Test(expected = NullPointerException.class) + @Test public void completeNullThrowsException() { BibEntry entry = new BibEntry(); entry.setField("field", "testKey"); autoCompleter.indexEntry(entry); - autoCompleter.call(getRequest((null))); + assertThrows(NullPointerException.class, () -> autoCompleter.call(getRequest(null))); } @Test @@ -105,7 +106,7 @@ public void completeEmptyStringReturnsNothing() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest((""))); - Assert.assertEquals(Collections.emptyList(), result); + assertEquals(Collections.emptyList(), result); } @Test @@ -118,7 +119,7 @@ public void completeReturnsMultipleResults() { autoCompleter.indexEntry(entryTwo); Collection result = autoCompleter.call(getRequest(("testValue"))); - Assert.assertEquals(Arrays.asList("testValueOne", "testValueTwo"), result); + assertEquals(Arrays.asList("testValueOne", "testValueTwo"), result); } @Test @@ -128,7 +129,7 @@ public void completeShortStringReturnsFieldValue() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("va"))); - Assert.assertEquals(Collections.singletonList("val"), result); + assertEquals(Collections.singletonList("val"), result); } @Test @@ -138,7 +139,7 @@ public void completeBeginnigOfSecondWordReturnsWholeFieldValue() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("val"))); - Assert.assertEquals(Collections.singletonList("test value"), result); + assertEquals(Collections.singletonList("test value"), result); } @Test @@ -148,7 +149,7 @@ public void completePartOfWordReturnsWholeFieldValue() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("lue"))); - Assert.assertEquals(Collections.singletonList("test value"), result); + assertEquals(Collections.singletonList("test value"), result); } @Test @@ -158,6 +159,6 @@ public void completeReturnsWholeFieldValue() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("te"))); - Assert.assertEquals(Collections.singletonList("test value"), result); + assertEquals(Collections.singletonList("test value"), result); } } diff --git a/src/test/java/org/jabref/gui/autocompleter/PersonNameSuggestionProviderTest.java b/src/test/java/org/jabref/gui/autocompleter/PersonNameSuggestionProviderTest.java index 9b4365b08dd..dcb9d07e32c 100644 --- a/src/test/java/org/jabref/gui/autocompleter/PersonNameSuggestionProviderTest.java +++ b/src/test/java/org/jabref/gui/autocompleter/PersonNameSuggestionProviderTest.java @@ -7,11 +7,12 @@ import org.jabref.model.entry.Author; import org.jabref.model.entry.BibEntry; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.jabref.gui.autocompleter.AutoCompleterUtil.getRequest; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class PersonNameSuggestionProviderTest { @@ -19,12 +20,11 @@ public class PersonNameSuggestionProviderTest { private PersonNameSuggestionProvider autoCompleter; private BibEntry entry; - @Test(expected = NullPointerException.class) public void initAutoCompleterWithNullFieldThrowsException() { - new PersonNameSuggestionProvider((String) null); + assertThrows(NullPointerException.class, () -> new PersonNameSuggestionProvider((String) null)); } - @Before + @BeforeEach public void setUp() throws Exception { autoCompleter = new PersonNameSuggestionProvider("field"); @@ -35,7 +35,7 @@ public void setUp() throws Exception { @Test public void completeWithoutAddingAnythingReturnsNothing() { Collection result = autoCompleter.call(getRequest(("test"))); - Assert.assertEquals(Collections.emptyList(), result); + assertEquals(Collections.emptyList(), result); } @Test @@ -43,7 +43,7 @@ public void completeAfterAddingNullReturnsNothing() { autoCompleter.indexEntry(null); Collection result = autoCompleter.call(getRequest(("test"))); - Assert.assertEquals(Collections.emptyList(), result); + assertEquals(Collections.emptyList(), result); } @Test @@ -52,7 +52,7 @@ public void completeAfterAddingEmptyEntryReturnsNothing() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("test"))); - Assert.assertEquals(Collections.emptyList(), result); + assertEquals(Collections.emptyList(), result); } @Test @@ -62,7 +62,7 @@ public void completeAfterAddingEntryWithoutFieldReturnsNothing() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("test"))); - Assert.assertEquals(Collections.emptyList(), result); + assertEquals(Collections.emptyList(), result); } @Test @@ -70,7 +70,7 @@ public void completeNameReturnsName() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("Kostakos"))); - Assert.assertEquals(Collections.singletonList(vassilisKostakos), result); + assertEquals(Collections.singletonList(vassilisKostakos), result); } @Test @@ -78,7 +78,7 @@ public void completeBeginningOfNameReturnsName() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("Kosta"))); - Assert.assertEquals(Collections.singletonList(vassilisKostakos), result); + assertEquals(Collections.singletonList(vassilisKostakos), result); } @Test @@ -86,12 +86,12 @@ public void completeLowercaseBeginningOfNameReturnsName() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("kosta"))); - Assert.assertEquals(Collections.singletonList(vassilisKostakos), result); + assertEquals(Collections.singletonList(vassilisKostakos), result); } - @Test(expected = NullPointerException.class) + @Test public void completeNullThrowsException() { - autoCompleter.call(getRequest((null))); + assertThrows(NullPointerException.class, () -> autoCompleter.call(getRequest((null)))); } @Test @@ -99,7 +99,7 @@ public void completeEmptyStringReturnsNothing() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest((""))); - Assert.assertEquals(Collections.emptyList(), result); + assertEquals(Collections.emptyList(), result); } @Test @@ -111,7 +111,7 @@ public void completeReturnsMultipleResults() { Author authorTwo = new Author("", "", "", "Kosta", ""); Collection result = autoCompleter.call(getRequest(("Ko"))); - Assert.assertEquals(Arrays.asList(authorTwo, vassilisKostakos), result); + assertEquals(Arrays.asList(authorTwo, vassilisKostakos), result); } @Test @@ -119,7 +119,7 @@ public void completePartOfNameReturnsName() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("osta"))); - Assert.assertEquals(Collections.singletonList(vassilisKostakos), result); + assertEquals(Collections.singletonList(vassilisKostakos), result); } @Test @@ -127,7 +127,7 @@ public void completeBeginningOfFirstNameReturnsName() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("Vas"))); - Assert.assertEquals(Collections.singletonList(vassilisKostakos), result); + assertEquals(Collections.singletonList(vassilisKostakos), result); } @Test @@ -138,7 +138,7 @@ public void completeBeginningOfFirstNameReturnsNameWithJr() { Author author = new Author("Joseph M.", "J. M.", "", "Reagle", "Jr."); Collection result = autoCompleter.call(getRequest(("Jos"))); - Assert.assertEquals(Collections.singletonList(author), result); + assertEquals(Collections.singletonList(author), result); } @Test @@ -149,7 +149,7 @@ public void completeBeginningOfFirstNameReturnsNameWithVon() { Author author = new Author("Eric", "E.", "von", "Hippel", ""); Collection result = autoCompleter.call(getRequest(("Eric"))); - Assert.assertEquals(Collections.singletonList(author), result); + assertEquals(Collections.singletonList(author), result); } @Test @@ -160,7 +160,7 @@ public void completeBeginningOfLastNameReturnsNameWithUmlauts() { Author author = new Author("Honig", "H.", "", "Bär", ""); Collection result = autoCompleter.call(getRequest(("Bä"))); - Assert.assertEquals(Collections.singletonList(author), result); + assertEquals(Collections.singletonList(author), result); } @Test @@ -171,7 +171,7 @@ public void completeVonReturnsName() { Author author = new Author("Eric", "E.", "von", "Hippel", ""); Collection result = autoCompleter.call(getRequest(("von"))); - Assert.assertEquals(Collections.singletonList(author), result); + assertEquals(Collections.singletonList(author), result); } @Test @@ -181,6 +181,6 @@ public void completeBeginningOfFullNameReturnsName() { autoCompleter.indexEntry(entry); Collection result = autoCompleter.call(getRequest(("Kostakos, Va"))); - Assert.assertEquals(Collections.singletonList(vassilisKostakos), result); + assertEquals(Collections.singletonList(vassilisKostakos), result); } } diff --git a/src/test/java/org/jabref/gui/externalfiletype/ExternalFileTypeTest.java b/src/test/java/org/jabref/gui/externalfiletype/ExternalFileTypeTest.java index b3c9ea14cac..5ac0251c147 100644 --- a/src/test/java/org/jabref/gui/externalfiletype/ExternalFileTypeTest.java +++ b/src/test/java/org/jabref/gui/externalfiletype/ExternalFileTypeTest.java @@ -1,33 +1,26 @@ package org.jabref.gui.externalfiletype; -import org.jabref.testutils.category.GUITest; +import org.junit.jupiter.api.Test; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.Assert.assertNotNull; - -@Category(GUITest.class) public class ExternalFileTypeTest { @Test public void getOpenWithApplicationMustNotReturnNull() throws Exception { ExternalFileType type = new ExternalFileType(null, null, null, null, null, null); - assertNotNull(type.getOpenWithApplication()); } @Test public void getExtensionMustNotReturnNull() throws Exception { ExternalFileType type = new ExternalFileType(null, null, null, null, null, null); - assertNotNull(type.getExtension()); } @Test public void getMimeTypeMustNotReturnNull() throws Exception { ExternalFileType type = new ExternalFileType(null, null, null, null, null, null); - assertNotNull(type.getMimeType()); } diff --git a/src/test/java/org/jabref/gui/fieldeditors/HtmlTransferableTest.java b/src/test/java/org/jabref/gui/fieldeditors/HtmlTransferableTest.java index acd344ef7b8..0577cc73e7f 100644 --- a/src/test/java/org/jabref/gui/fieldeditors/HtmlTransferableTest.java +++ b/src/test/java/org/jabref/gui/fieldeditors/HtmlTransferableTest.java @@ -4,9 +4,9 @@ import org.jabref.logic.util.OS; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class HtmlTransferableTest { diff --git a/src/test/java/org/jabref/gui/fieldeditors/IdentifierEditorViewModelTest.java b/src/test/java/org/jabref/gui/fieldeditors/IdentifierEditorViewModelTest.java index d681344d9b0..80fde0cb66c 100644 --- a/src/test/java/org/jabref/gui/fieldeditors/IdentifierEditorViewModelTest.java +++ b/src/test/java/org/jabref/gui/fieldeditors/IdentifierEditorViewModelTest.java @@ -5,8 +5,8 @@ import org.jabref.gui.util.CurrentThreadTaskExecutor; import org.jabref.logic.integrity.FieldCheckers; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; @@ -15,7 +15,7 @@ public class IdentifierEditorViewModelTest { private IdentifierEditorViewModel viewModel; - @Before + @BeforeEach public void setUp() throws Exception { viewModel = new IdentifierEditorViewModel("DOI", new WordSuggestionProvider("DOI"), new CurrentThreadTaskExecutor(), mock(DialogService.class), mock(FieldCheckers.class)); } diff --git a/src/test/java/org/jabref/gui/groups/GroupNodeViewModelTest.java b/src/test/java/org/jabref/gui/groups/GroupNodeViewModelTest.java index d9e53c6e5ab..e9ad5eade51 100644 --- a/src/test/java/org/jabref/gui/groups/GroupNodeViewModelTest.java +++ b/src/test/java/org/jabref/gui/groups/GroupNodeViewModelTest.java @@ -18,11 +18,11 @@ import org.jabref.model.groups.GroupTreeNode; import org.jabref.model.groups.WordKeywordGroup; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -33,7 +33,7 @@ public class GroupNodeViewModelTest { private GroupNodeViewModel viewModel; private TaskExecutor taskExecutor; - @Before + @BeforeEach public void setUp() throws Exception { stateManager = mock(StateManager.class); when(stateManager.getSelectedEntries()).thenReturn(FXCollections.emptyObservableList()); diff --git a/src/test/java/org/jabref/gui/groups/GroupTreeViewModelTest.java b/src/test/java/org/jabref/gui/groups/GroupTreeViewModelTest.java index 6663c6acd64..79738eeea28 100644 --- a/src/test/java/org/jabref/gui/groups/GroupTreeViewModelTest.java +++ b/src/test/java/org/jabref/gui/groups/GroupTreeViewModelTest.java @@ -10,14 +10,14 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.FieldName; import org.jabref.model.groups.AllEntriesGroup; - import org.jabref.model.groups.ExplicitGroup; import org.jabref.model.groups.GroupHierarchyType; import org.jabref.model.groups.WordKeywordGroup; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; public class GroupTreeViewModelTest { @@ -26,7 +26,7 @@ public class GroupTreeViewModelTest { BibDatabaseContext databaseContext; private TaskExecutor taskExecutor; - @Before + @BeforeEach public void setUp() throws Exception { databaseContext = new BibDatabaseContext(); stateManager = new StateManager(); diff --git a/src/test/java/org/jabref/gui/importer/EntryFromFileCreatorManagerTest.java b/src/test/java/org/jabref/gui/importer/EntryFromFileCreatorManagerTest.java index 7523d3f79b6..38301e769ef 100644 --- a/src/test/java/org/jabref/gui/importer/EntryFromFileCreatorManagerTest.java +++ b/src/test/java/org/jabref/gui/importer/EntryFromFileCreatorManagerTest.java @@ -7,7 +7,9 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; +import java.util.Optional; +import org.jabref.gui.externalfiletype.ExternalFileTypes; import org.jabref.logic.importer.ImportDataTest; import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.ParserResult; @@ -17,40 +19,47 @@ import org.jabref.model.util.DummyFileUpdateMonitor; import org.jabref.testutils.category.GUITest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; +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.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; -@Category(GUITest.class) +@GUITest public class EntryFromFileCreatorManagerTest { - // Needed to initialize ExternalFileTypes - @Before + private final ImportFormatPreferences prefs = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); + private ExternalFileTypes externalFileTypes; + + @BeforeEach public void setUp() { + externalFileTypes = mock(ExternalFileTypes.class, Answers.RETURNS_DEEP_STUBS); + when(externalFileTypes.getExternalFileTypeByExt("pdf")).thenReturn(Optional.empty()); } @Test public void testGetCreator() { - EntryFromFileCreatorManager manager = new EntryFromFileCreatorManager(); + EntryFromFileCreatorManager manager = new EntryFromFileCreatorManager(externalFileTypes); EntryFromFileCreator creator = manager.getEntryCreator(ImportDataTest.NOT_EXISTING_PDF); - Assert.assertNull(creator); + assertNull(creator); creator = manager.getEntryCreator(ImportDataTest.FILE_IN_DATABASE); - Assert.assertNotNull(creator); - Assert.assertTrue(creator.accept(ImportDataTest.FILE_IN_DATABASE)); + assertNotNull(creator); + assertTrue(creator.accept(ImportDataTest.FILE_IN_DATABASE)); } @Test - @Ignore public void testAddEntrysFromFiles() throws IOException { try (FileInputStream stream = new FileInputStream(ImportDataTest.UNLINKED_FILES_TEST_BIB); InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) { - ParserResult result = new BibtexParser(mock(ImportFormatPreferences.class), new DummyFileUpdateMonitor()).parse(reader); + ParserResult result = new BibtexParser(prefs, new DummyFileUpdateMonitor()).parse(reader); BibDatabase database = result.getDatabase(); List files = new ArrayList<>(); @@ -58,13 +67,13 @@ public void testAddEntrysFromFiles() throws IOException { files.add(ImportDataTest.FILE_NOT_IN_DATABASE); files.add(ImportDataTest.NOT_EXISTING_PDF); - EntryFromFileCreatorManager manager = new EntryFromFileCreatorManager(); + EntryFromFileCreatorManager manager = new EntryFromFileCreatorManager(externalFileTypes); List errors = manager.addEntrysFromFiles(files, database, null, true); /** * One file doesn't exist, so adding it as an entry should lead to an error message. */ - Assert.assertEquals(1, errors.size()); + assertEquals(1, errors.size()); boolean file1Found = false; boolean file2Found = false; @@ -78,9 +87,8 @@ public void testAddEntrysFromFiles() throws IOException { } } - Assert.assertTrue(file1Found); - Assert.assertFalse(file2Found); + assertTrue(file1Found); + assertFalse(file2Found); } } - } diff --git a/src/test/java/org/jabref/gui/importer/EntryFromPDFCreatorTest.java b/src/test/java/org/jabref/gui/importer/EntryFromPDFCreatorTest.java index 10b44f11b9d..17817eeb6b4 100644 --- a/src/test/java/org/jabref/gui/importer/EntryFromPDFCreatorTest.java +++ b/src/test/java/org/jabref/gui/importer/EntryFromPDFCreatorTest.java @@ -5,52 +5,55 @@ import org.jabref.JabRefGUI; import org.jabref.gui.JabRefFrame; +import org.jabref.gui.externalfiletype.ExternalFileTypes; import org.jabref.logic.importer.ImportDataTest; import org.jabref.model.entry.BibEntry; import org.jabref.testutils.category.GUITest; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +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.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; -@Category(GUITest.class) +@GUITest public class EntryFromPDFCreatorTest { private EntryFromPDFCreator entryCreator; - - @Before + @BeforeEach public void setUp() { // Needed to initialize ExternalFileTypes - entryCreator = new EntryFromPDFCreator(); + entryCreator = new EntryFromPDFCreator(mock(ExternalFileTypes.class, Answers.RETURNS_DEEP_STUBS)); + // Needed for PdfImporter - still not enough JabRefGUI.setMainFrame(mock(JabRefFrame.class)); } @Test public void testPDFFileFilter() { - Assert.assertTrue(entryCreator.accept(new File("aPDF.pdf"))); - Assert.assertTrue(entryCreator.accept(new File("aPDF.PDF"))); - Assert.assertFalse(entryCreator.accept(new File("foo.jpg"))); + assertTrue(entryCreator.accept(new File("aPDF.pdf"))); + assertTrue(entryCreator.accept(new File("aPDF.PDF"))); + assertFalse(entryCreator.accept(new File("foo.jpg"))); } @Test public void testCreationOfEntryNoPDF() { Optional entry = entryCreator.createEntry(ImportDataTest.NOT_EXISTING_PDF, false); - Assert.assertFalse(entry.isPresent()); + assertFalse(entry.isPresent()); } @Test - @Ignore //Can't mock basepanel and maintable + @Disabled //Can't mock basepanel and maintable public void testCreationOfEntryNotInDatabase() { Optional entry = entryCreator.createEntry(ImportDataTest.FILE_NOT_IN_DATABASE, false); - Assert.assertTrue(entry.isPresent()); - Assert.assertTrue(entry.get().getField("file").get().endsWith(":PDF")); - Assert.assertEquals(Optional.of(ImportDataTest.FILE_NOT_IN_DATABASE.getName()), + assertTrue(entry.isPresent()); + assertTrue(entry.get().getField("file").get().endsWith(":PDF")); + assertEquals(Optional.of(ImportDataTest.FILE_NOT_IN_DATABASE.getName()), entry.get().getField("title")); } diff --git a/src/test/java/org/jabref/gui/importer/fetcher/OAI2HandlerFetcherTest.java b/src/test/java/org/jabref/gui/importer/fetcher/OAI2HandlerFetcherTest.java index f6e3d27269f..46dd1e87880 100644 --- a/src/test/java/org/jabref/gui/importer/fetcher/OAI2HandlerFetcherTest.java +++ b/src/test/java/org/jabref/gui/importer/fetcher/OAI2HandlerFetcherTest.java @@ -9,15 +9,17 @@ import org.jabref.logic.importer.util.OAI2Handler; import org.jabref.model.entry.BibEntry; -import org.jabref.testutils.category.GUITest; +import org.jabref.testutils.category.FetcherTest; -import org.junit.Assert; -import org.junit.Before; import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Test for OAI2-Handler and Fetcher. * @@ -26,7 +28,7 @@ * @author Christopher Oezbek */ -@Category(GUITest.class) +@FetcherTest public class OAI2HandlerFetcherTest { protected OAI2Handler handler; @@ -38,7 +40,7 @@ public class OAI2HandlerFetcherTest { protected SAXParser saxParser; - @Before + @BeforeEach public void setUp() throws ParserConfigurationException, SAXException { parserFactory = SAXParserFactory.newInstance(); saxParser = parserFactory.newSAXParser(); @@ -48,33 +50,33 @@ public void setUp() throws ParserConfigurationException, SAXException { @Test public void testCorrectLineBreaks() { - Assert.assertEquals("Test this", OAI2Handler.correctLineBreaks("Test\nthis")); - Assert.assertEquals("Test this", OAI2Handler.correctLineBreaks("Test \n this")); - Assert.assertEquals("Test\nthis", OAI2Handler.correctLineBreaks("Test\n\nthis")); - Assert.assertEquals("Test\nthis", OAI2Handler.correctLineBreaks("Test\n \nthis")); - Assert.assertEquals("Test\nthis", OAI2Handler.correctLineBreaks(" Test \n \n this ")); + assertEquals("Test this", OAI2Handler.correctLineBreaks("Test\nthis")); + assertEquals("Test this", OAI2Handler.correctLineBreaks("Test \n this")); + assertEquals("Test\nthis", OAI2Handler.correctLineBreaks("Test\n\nthis")); + assertEquals("Test\nthis", OAI2Handler.correctLineBreaks("Test\n \nthis")); + assertEquals("Test\nthis", OAI2Handler.correctLineBreaks(" Test \n \n this ")); } @Test public void testParse() throws Throwable { try { saxParser.parse(this.getClass().getResourceAsStream("oai2.xml"), handler); - Assert.assertEquals(Optional.of("hep-ph/0408155"), be.getField("eprint")); - Assert.assertEquals(Optional.of("G. F. Giudice and A. Riotto and A. Zaffaroni and J. López-Peña"), + assertEquals(Optional.of("hep-ph/0408155"), be.getField("eprint")); + assertEquals(Optional.of("G. F. Giudice and A. Riotto and A. Zaffaroni and J. López-Peña"), be.getField("author")); - Assert.assertEquals(Optional.of("Nucl.Phys. B"), be.getField("journal")); - Assert.assertEquals(Optional.of("710"), be.getField("volume")); - Assert.assertEquals(Optional.of("2005"), be.getField("year")); - Assert.assertEquals(Optional.of("511-525"), be.getField("pages")); + assertEquals(Optional.of("Nucl.Phys. B"), be.getField("journal")); + assertEquals(Optional.of("710"), be.getField("volume")); + assertEquals(Optional.of("2005"), be.getField("year")); + assertEquals(Optional.of("511-525"), be.getField("pages")); // Citekey is only generated if the user says so in the import // inspection dialog. - Assert.assertEquals(Optional.empty(), be.getCiteKeyOptional()); + assertEquals(Optional.empty(), be.getCiteKeyOptional()); - Assert.assertEquals(Optional.of("Heavy Particles from Inflation"), be.getField("title")); - Assert.assertTrue(be.getField("abstract").isPresent()); - Assert.assertEquals(Optional.of("23 pages"), be.getField("comment")); - Assert.assertEquals(Optional.of("CERN-PH-TH/2004-151"), be.getField("reportno")); + assertEquals(Optional.of("Heavy Particles from Inflation"), be.getField("title")); + assertTrue(be.getField("abstract").isPresent()); + assertEquals(Optional.of("23 pages"), be.getField("comment")); + assertEquals(Optional.of("CERN-PH-TH/2004-151"), be.getField("reportno")); } catch (SAXException e) { throw e.getException(); } @@ -84,7 +86,7 @@ public void testParse() throws Throwable { public void testOai22xml() throws SAXException, IOException { saxParser.parse(this.getClass().getResourceAsStream("oai22.xml"), handler); - Assert.assertEquals(Optional.of("2005"), be.getField("year")); + assertEquals(Optional.of("2005"), be.getField("year")); } @@ -92,18 +94,18 @@ public void testOai22xml() throws SAXException, IOException { public void testOai23xml() throws SAXException, IOException { saxParser.parse(this.getClass().getResourceAsStream("oai23.xml"), handler); - Assert.assertEquals(Optional.of("Javier López Peña and Gabriel Navarro"), be.getField("author")); + assertEquals(Optional.of("Javier López Peña and Gabriel Navarro"), be.getField("author")); } @Test public void testUrlConstructor() { OAI2Fetcher fetcher = new OAI2Fetcher(); - Assert.assertEquals( + assertEquals( "http://export.arxiv.org/oai2?verb=GetRecord&identifier=oai%3AarXiv.org%3Ahep-ph%2F0408155&metadataPrefix=arXiv", fetcher.constructUrl("hep-ph/0408155")); - Assert.assertEquals( + assertEquals( "http://export.arxiv.org/oai2?verb=GetRecord&identifier=oai%3AarXiv.org%3Amath%2F0612188&metadataPrefix=arXiv", fetcher.constructUrl("math/0612188")); @@ -111,13 +113,13 @@ public void testUrlConstructor() { @Test public void testFixKey() { - Assert.assertEquals("", OAI2Fetcher.fixKey("")); - Assert.assertEquals("test", OAI2Fetcher.fixKey("test")); - Assert.assertEquals("math/0601001", OAI2Fetcher.fixKey("math.RA/0601001")); - Assert.assertEquals("math/0601001", OAI2Fetcher.fixKey("math.QA/0601001")); - Assert.assertEquals("hep-ph/0408155", OAI2Fetcher.fixKey("hep-ph/0408155")); - Assert.assertEquals("0709.3040v1", OAI2Fetcher.fixKey("arXiv:0709.3040v1")); - Assert.assertEquals("", OAI2Fetcher.fixKey("arXiv:")); + assertEquals("", OAI2Fetcher.fixKey("")); + assertEquals("test", OAI2Fetcher.fixKey("test")); + assertEquals("math/0601001", OAI2Fetcher.fixKey("math.RA/0601001")); + assertEquals("math/0601001", OAI2Fetcher.fixKey("math.QA/0601001")); + assertEquals("hep-ph/0408155", OAI2Fetcher.fixKey("hep-ph/0408155")); + assertEquals("0709.3040v1", OAI2Fetcher.fixKey("arXiv:0709.3040v1")); + assertEquals("", OAI2Fetcher.fixKey("arXiv:")); } @Test @@ -127,13 +129,13 @@ public void testOnline() throws InterruptedException, IOException, SAXException { OAI2Fetcher fetcher = new OAI2Fetcher(); be = fetcher.importOai2Entry("math.RA/0612188"); - Assert.assertNotNull(be); + assertNotNull(be); - Assert.assertEquals(Optional.of("math/0612188"), be.getField("eprint")); - Assert.assertEquals(Optional.of("On the classification and properties of noncommutative duplicates"), + assertEquals(Optional.of("math/0612188"), be.getField("eprint")); + assertEquals(Optional.of("On the classification and properties of noncommutative duplicates"), be.getField("title")); - Assert.assertEquals(Optional.of("Javier López Peña and Gabriel Navarro"), be.getField("author")); - Assert.assertEquals(Optional.of("2007"), be.getField("year")); + assertEquals(Optional.of("Javier López Peña and Gabriel Navarro"), be.getField("author")); + assertEquals(Optional.of("2007"), be.getField("year")); Thread.sleep(20000); } @@ -141,10 +143,10 @@ public void testOnline() throws InterruptedException, IOException, SAXException { OAI2Fetcher fetcher = new OAI2Fetcher(); be = fetcher.importOai2Entry("astro-ph/0702080"); - Assert.assertNotNull(be); + assertNotNull(be); - Assert.assertEquals(Optional.of("astro-ph/0702080"), be.getField("eprint")); - Assert.assertEquals( + assertEquals(Optional.of("astro-ph/0702080"), be.getField("eprint")); + assertEquals( Optional.of( "Magnetized Hypermassive Neutron Star Collapse: a candidate central engine for short-hard GRBs"), be.getField("title")); @@ -155,27 +157,27 @@ public void testOnline() throws InterruptedException, IOException, SAXException { OAI2Fetcher fetcher = new OAI2Fetcher(); be = fetcher.importOai2Entry("math.QA/0601001"); - Assert.assertNotNull(be); + assertNotNull(be); - Assert.assertEquals(Optional.of("math/0601001"), be.getField("eprint")); + assertEquals(Optional.of("math/0601001"), be.getField("eprint")); Thread.sleep(20000); } { OAI2Fetcher fetcher = new OAI2Fetcher(); be = fetcher.importOai2Entry("hep-ph/0408155"); - Assert.assertNotNull(be); + assertNotNull(be); - Assert.assertEquals(Optional.of("hep-ph/0408155"), be.getField("eprint")); + assertEquals(Optional.of("hep-ph/0408155"), be.getField("eprint")); Thread.sleep(20000); } OAI2Fetcher fetcher = new OAI2Fetcher(); be = fetcher.importOai2Entry("0709.3040"); - Assert.assertNotNull(be); + assertNotNull(be); - Assert.assertEquals(Optional.of("2007"), be.getField("year")); - Assert.assertEquals(Optional.of("#sep#"), be.getField("month")); + assertEquals(Optional.of("2007"), be.getField("year")); + assertEquals(Optional.of("#sep#"), be.getField("month")); } } diff --git a/src/test/java/org/jabref/gui/search/ContainsAndRegexBasedSearchRuleDescriberTest.java b/src/test/java/org/jabref/gui/search/ContainsAndRegexBasedSearchRuleDescriberTest.java index 78705c52a47..bc381d7d6d1 100644 --- a/src/test/java/org/jabref/gui/search/ContainsAndRegexBasedSearchRuleDescriberTest.java +++ b/src/test/java/org/jabref/gui/search/ContainsAndRegexBasedSearchRuleDescriberTest.java @@ -9,9 +9,9 @@ import org.jabref.gui.search.rules.describer.ContainsAndRegexBasedSearchRuleDescriber; import org.jabref.gui.util.TooltipTextUtil; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ContainsAndRegexBasedSearchRuleDescriberTest { diff --git a/src/test/java/org/jabref/gui/search/GrammarBasedSearchRuleDescriberTest.java b/src/test/java/org/jabref/gui/search/GrammarBasedSearchRuleDescriberTest.java index 0831107b681..451be0e80b0 100644 --- a/src/test/java/org/jabref/gui/search/GrammarBasedSearchRuleDescriberTest.java +++ b/src/test/java/org/jabref/gui/search/GrammarBasedSearchRuleDescriberTest.java @@ -10,9 +10,9 @@ import org.jabref.gui.util.TooltipTextUtil; import org.jabref.model.search.rules.GrammarBasedSearchRule; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; public class GrammarBasedSearchRuleDescriberTest { diff --git a/src/test/java/org/jabref/gui/util/RecursiveTreeItemTest.java b/src/test/java/org/jabref/gui/util/RecursiveTreeItemTest.java index 6f06b4012db..7fb07169950 100644 --- a/src/test/java/org/jabref/gui/util/RecursiveTreeItemTest.java +++ b/src/test/java/org/jabref/gui/util/RecursiveTreeItemTest.java @@ -11,8 +11,8 @@ import org.jabref.model.TreeNode; import org.jabref.model.TreeNodeTestData; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.junit.Assert.assertEquals; @@ -23,7 +23,7 @@ public class RecursiveTreeItemTest { private ObjectProperty> filterPredicate; private TreeNodeTestData.TreeNodeMock node; - @Before + @BeforeEach public void setUp() throws Exception { root = new TreeNodeTestData.TreeNodeMock(); node = TreeNodeTestData.getNodeInSimpleTree(root); diff --git a/src/test/java/org/jabref/gui/util/TooltipTextUtilTest.java b/src/test/java/org/jabref/gui/util/TooltipTextUtilTest.java index 0bd41ea3916..5fc35cca659 100644 --- a/src/test/java/org/jabref/gui/util/TooltipTextUtilTest.java +++ b/src/test/java/org/jabref/gui/util/TooltipTextUtilTest.java @@ -7,8 +7,10 @@ import org.jabref.gui.search.TextFlowEqualityHelper; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author jpf @@ -20,32 +22,32 @@ public class TooltipTextUtilTest { public void testCreateText() { String testText = "this is a test text"; Text text = TooltipTextUtil.createText(testText, TooltipTextUtil.TextType.NORMAL); - Assert.assertEquals("Regular", text.getFont().getStyle()); - Assert.assertEquals(testText, text.getText()); + assertEquals("Regular", text.getFont().getStyle()); + assertEquals(testText, text.getText()); } @Test public void testCreateTextBold() { String testText = "this is a test text"; Text text = TooltipTextUtil.createText(testText, TooltipTextUtil.TextType.BOLD); - Assert.assertEquals("tooltip-text-bold", text.getStyleClass().toString()); - Assert.assertEquals(testText, text.getText()); + assertEquals("tooltip-text-bold", text.getStyleClass().toString()); + assertEquals(testText, text.getText()); } @Test public void testCreateTextItalic() { String testText = "this is a test text"; Text text = TooltipTextUtil.createText(testText, TooltipTextUtil.TextType.ITALIC); - Assert.assertEquals("tooltip-text-italic", text.getStyleClass().toString()); - Assert.assertEquals(testText, text.getText()); + assertEquals("tooltip-text-italic", text.getStyleClass().toString()); + assertEquals(testText, text.getText()); } @Test public void testCreateTextMonospaced() { String testText = "this is a test text"; Text text = TooltipTextUtil.createText(testText, TooltipTextUtil.TextType.MONOSPACED); - Assert.assertEquals("tooltip-text-monospaced", text.getStyleClass().toString()); - Assert.assertEquals(testText, text.getText()); + assertEquals("tooltip-text-monospaced", text.getStyleClass().toString()); + assertEquals(testText, text.getText()); } @Test @@ -53,7 +55,7 @@ public void testTextToHTMLStringBold() { String testText = "this is a test text"; Text text = TooltipTextUtil.createText(testText, TooltipTextUtil.TextType.BOLD); String htmlString = TooltipTextUtil.textToHTMLString(text); - Assert.assertEquals("" + testText + "", htmlString); + assertEquals("" + testText + "", htmlString); } @Test @@ -61,7 +63,7 @@ public void testTextToHTMLStringItalic() { String testText = "this is a test text"; Text text = TooltipTextUtil.createText(testText, TooltipTextUtil.TextType.ITALIC); String htmlString = TooltipTextUtil.textToHTMLString(text); - Assert.assertEquals("" + testText + "", htmlString); + assertEquals("" + testText + "", htmlString); } @Test @@ -69,7 +71,7 @@ public void testTextToHTMLStringMonospaced() { String testText = "this is a test text"; Text text = TooltipTextUtil.createText(testText, TooltipTextUtil.TextType.MONOSPACED); String htmlString = TooltipTextUtil.textToHTMLString(text); - Assert.assertEquals("" + testText + "", htmlString); + assertEquals("" + testText + "", htmlString); } @Test @@ -78,7 +80,7 @@ public void testTextToHTMLStringMonospacedBold() { Text text = TooltipTextUtil.createText(testText, TooltipTextUtil.TextType.MONOSPACED); text.getStyleClass().add("tooltip-text-bold"); String htmlString = TooltipTextUtil.textToHTMLString(text); - Assert.assertEquals("" + testText + "", htmlString); + assertEquals("" + testText + "", htmlString); } @Test @@ -86,7 +88,7 @@ public void testTextToHTMLStringWithLinebreaks() { String testText = "this\nis a\ntest text"; Text text = TooltipTextUtil.createText(testText, TooltipTextUtil.TextType.NORMAL); String htmlString = TooltipTextUtil.textToHTMLString(text); - Assert.assertEquals("this
is a
test text", htmlString); + assertEquals("this
is a
test text", htmlString); } @Test @@ -95,10 +97,9 @@ public void testFormatToTextsNoReplacements() { expectedTextList.add(TooltipTextUtil.createText("This search contains entries in which any field contains the regular expression ")); String test = "This search contains entries in which any field contains the regular expression "; List textList = TooltipTextUtil.formatToTexts(test); - Assert.assertTrue(TextFlowEqualityHelper.checkIfTextsEqualsExpectedTexts(expectedTextList, textList)); + assertTrue(TextFlowEqualityHelper.checkIfTextsEqualsExpectedTexts(expectedTextList, textList)); } - @Test public void testFormatToTextsEnd() { List expectedTextList = new ArrayList<>(); @@ -106,7 +107,7 @@ public void testFormatToTextsEnd() { expectedTextList.add(TooltipTextUtil.createText("replacing text", TooltipTextUtil.TextType.BOLD)); String test = "This search contains entries in which any field contains the regular expression %0"; List textList = TooltipTextUtil.formatToTexts(test, new TooltipTextUtil.TextReplacement("%0", "replacing text", TooltipTextUtil.TextType.BOLD)); - Assert.assertTrue(TextFlowEqualityHelper.checkIfTextsEqualsExpectedTexts(expectedTextList, textList)); + assertTrue(TextFlowEqualityHelper.checkIfTextsEqualsExpectedTexts(expectedTextList, textList)); } @Test @@ -116,7 +117,7 @@ public void testFormatToTextsBegin() { expectedTextList.add(TooltipTextUtil.createText(" This search contains entries in which any field contains the regular expression")); String test = "%0 This search contains entries in which any field contains the regular expression"; List textList = TooltipTextUtil.formatToTexts(test, new TooltipTextUtil.TextReplacement("%0", "replacing text", TooltipTextUtil.TextType.BOLD)); - Assert.assertTrue(TextFlowEqualityHelper.checkIfTextsEqualsExpectedTexts(expectedTextList, textList)); + assertTrue(TextFlowEqualityHelper.checkIfTextsEqualsExpectedTexts(expectedTextList, textList)); } @Test @@ -127,6 +128,6 @@ public void testFormatToTextsMiddle() { expectedTextList.add(TooltipTextUtil.createText(" in which any field contains the regular expression")); String test = "This search contains entries %0 in which any field contains the regular expression"; List textList = TooltipTextUtil.formatToTexts(test, new TooltipTextUtil.TextReplacement("%0", "replacing text", TooltipTextUtil.TextType.BOLD)); - Assert.assertTrue(TextFlowEqualityHelper.checkIfTextsEqualsExpectedTexts(expectedTextList, textList)); + assertTrue(TextFlowEqualityHelper.checkIfTextsEqualsExpectedTexts(expectedTextList, textList)); } } diff --git a/src/test/java/org/jabref/gui/worker/CitationStyleToClipboardWorkerTest.java b/src/test/java/org/jabref/gui/worker/CitationStyleToClipboardWorkerTest.java index bcd86e7817a..5b899af7beb 100644 --- a/src/test/java/org/jabref/gui/worker/CitationStyleToClipboardWorkerTest.java +++ b/src/test/java/org/jabref/gui/worker/CitationStyleToClipboardWorkerTest.java @@ -9,9 +9,9 @@ import org.jabref.gui.fieldeditors.XmlTransferable; import org.jabref.logic.util.OS; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; public class CitationStyleToClipboardWorkerTest { @@ -31,7 +31,7 @@ public void processPreviewText() throws Exception { HtmlTransferable HtmlTransferable = CitationStyleToClipboardWorker.processPreview(Arrays.asList(citation, citation)); Object actual = HtmlTransferable.getTransferData(DataFlavor.stringFlavor); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -84,7 +84,7 @@ public void processPreviewHtml() throws Exception { HtmlTransferable transferable = CitationStyleToClipboardWorker.processPreview(Arrays.asList(citation, citation)); Object actual = transferable.getTransferData(HtmlTransferable.HTML_FLAVOR); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -96,7 +96,7 @@ public void processText() throws Exception { StringSelection textTransferable = CitationStyleToClipboardWorker.processText(Arrays.asList(citation, citation)); Object actual = textTransferable.getTransferData(DataFlavor.stringFlavor); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -111,7 +111,7 @@ public void processRtf() throws Exception { RtfTransferable rtfTransferable = CitationStyleToClipboardWorker.processRtf(Arrays.asList(citation, citation)); Object actual = rtfTransferable.getTransferData(DataFlavor.stringFlavor); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -184,7 +184,7 @@ public void processXslFo() throws Exception { XmlTransferable xmlTransferable = CitationStyleToClipboardWorker.processXslFo(Arrays.asList(citation, citation)); Object actual = xmlTransferable.getTransferData(DataFlavor.stringFlavor); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -214,7 +214,7 @@ public void processHtmlAsHtml() throws Exception { HtmlTransferable htmlTransferable = CitationStyleToClipboardWorker.processHtml(Arrays.asList(citation, citation)); Object actual = htmlTransferable.getTransferData(DataFlavor.allHtmlFlavor); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -228,6 +228,6 @@ public void processHtmlAsText() throws Exception { HtmlTransferable htmlTransferable = CitationStyleToClipboardWorker.processHtml(Arrays.asList(citation, citation)); Object actual = htmlTransferable.getTransferData(DataFlavor.stringFlavor); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } } diff --git a/src/test/java/org/jabref/logic/TypedBibEntryTest.java b/src/test/java/org/jabref/logic/TypedBibEntryTest.java index 517217b6152..8b72810ecc9 100644 --- a/src/test/java/org/jabref/logic/TypedBibEntryTest.java +++ b/src/test/java/org/jabref/logic/TypedBibEntryTest.java @@ -4,8 +4,11 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.BibtexEntryTypes; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class TypedBibEntryTest { @@ -17,7 +20,7 @@ public void hasAllRequiredFieldsFail() { e.setField("journal", "abc"); TypedBibEntry typedEntry = new TypedBibEntry(e, BibDatabaseMode.BIBTEX); - Assert.assertFalse(typedEntry.hasAllRequiredFields()); + assertFalse(typedEntry.hasAllRequiredFields()); } @Test @@ -29,7 +32,7 @@ public void hasAllRequiredFields() { e.setField("year", "2015"); TypedBibEntry typedEntry = new TypedBibEntry(e, BibDatabaseMode.BIBTEX); - Assert.assertTrue(typedEntry.hasAllRequiredFields()); + assertTrue(typedEntry.hasAllRequiredFields()); } @Test @@ -37,7 +40,7 @@ public void hasAllRequiredFieldsForUnknownTypeReturnsTrue() { BibEntry e = new BibEntry("articlllleeeee"); TypedBibEntry typedEntry = new TypedBibEntry(e, BibDatabaseMode.BIBTEX); - Assert.assertTrue(typedEntry.hasAllRequiredFields()); + assertTrue(typedEntry.hasAllRequiredFields()); } @Test @@ -45,7 +48,7 @@ public void getTypeForDisplayReturnsTypeName() { BibEntry e = new BibEntry(BibtexEntryTypes.INPROCEEDINGS.getName()); TypedBibEntry typedEntry = new TypedBibEntry(e, BibDatabaseMode.BIBTEX); - Assert.assertEquals("InProceedings", typedEntry.getTypeForDisplay()); + assertEquals("InProceedings", typedEntry.getTypeForDisplay()); } @Test @@ -53,6 +56,6 @@ public void getTypeForDisplayForUnknownTypeCapitalizeFirstLetter() { BibEntry e = new BibEntry("articlllleeeee"); TypedBibEntry typedEntry = new TypedBibEntry(e, BibDatabaseMode.BIBTEX); - Assert.assertEquals("Articlllleeeee", typedEntry.getTypeForDisplay()); + assertEquals("Articlllleeeee", typedEntry.getTypeForDisplay()); } } diff --git a/src/test/java/org/jabref/logic/autosaveandbackup/BackupManagerTest.java b/src/test/java/org/jabref/logic/autosaveandbackup/BackupManagerTest.java index 3abd3b6e69d..744682b6f9c 100644 --- a/src/test/java/org/jabref/logic/autosaveandbackup/BackupManagerTest.java +++ b/src/test/java/org/jabref/logic/autosaveandbackup/BackupManagerTest.java @@ -3,8 +3,9 @@ import java.nio.file.Path; import java.nio.file.Paths; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class BackupManagerTest { @@ -12,7 +13,7 @@ public class BackupManagerTest { public void backupFileNameIsCorrectlyGeneratedWithinTmpDirectory() { Path bibPath = Paths.get("tmp", "test.bib"); Path savPath = BackupManager.getBackupPath(bibPath); - Assert.assertEquals(Paths.get("tmp", "test.bib.sav"), savPath); + assertEquals(Paths.get("tmp", "test.bib.sav"), savPath); } } diff --git a/src/test/java/org/jabref/logic/auxparser/AuxParserTest.java b/src/test/java/org/jabref/logic/auxparser/AuxParserTest.java index 016f7b62d26..4945c9e74c4 100644 --- a/src/test/java/org/jabref/logic/auxparser/AuxParserTest.java +++ b/src/test/java/org/jabref/logic/auxparser/AuxParserTest.java @@ -17,9 +17,9 @@ import org.jabref.model.database.BibDatabase; import org.jabref.model.util.DummyFileUpdateMonitor; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Answers; import static org.junit.Assert.assertEquals; @@ -30,12 +30,12 @@ public class AuxParserTest { private ImportFormatPreferences importFormatPreferences; - @Before + @BeforeEach public void setUp() { importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); } - @After + @AfterEach public void tearDown() { importFormatPreferences = null; } diff --git a/src/test/java/org/jabref/logic/bibtex/BibEntryWriterTest.java b/src/test/java/org/jabref/logic/bibtex/BibEntryWriterTest.java index 4e40233a4ff..71aeae47d96 100644 --- a/src/test/java/org/jabref/logic/bibtex/BibEntryWriterTest.java +++ b/src/test/java/org/jabref/logic/bibtex/BibEntryWriterTest.java @@ -15,21 +15,22 @@ import org.jabref.model.util.DummyFileUpdateMonitor; import org.jabref.model.util.FileUpdateMonitor; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Answers; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; public class BibEntryWriterTest { private static ImportFormatPreferences importFormatPreferences; private BibEntryWriter writer; - private FileUpdateMonitor fileMonitor = new DummyFileUpdateMonitor(); + private final FileUpdateMonitor fileMonitor = new DummyFileUpdateMonitor(); - @Before + @BeforeEach public void setUpWriter() { importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); LatexFieldFormatterPreferences latexFieldFormatterPreferences = mock(LatexFieldFormatterPreferences.class, Answers.RETURNS_DEEP_STUBS); @@ -68,11 +69,11 @@ public void testSerialization() throws IOException { public void writeOtherTypeTest() throws Exception { String expected = OS.NEWLINE + "@Other{test," + OS.NEWLINE + " comment = {testentry}," + OS.NEWLINE + - "}"+ OS.NEWLINE; + "}" + OS.NEWLINE; BibEntry entry = new BibEntry(); entry.setType("other"); - entry.setField("Comment","testentry"); + entry.setField("Comment", "testentry"); entry.setCiteKey("test"); //write out bibtex string @@ -87,11 +88,11 @@ public void writeOtherTypeTest() throws Exception { public void writeReallyunknownTypeTest() throws Exception { String expected = OS.NEWLINE + "@Reallyunknowntype{test," + OS.NEWLINE + " comment = {testentry}," + OS.NEWLINE + - "}"+ OS.NEWLINE; + "}" + OS.NEWLINE; BibEntry entry = new BibEntry(); entry.setType("ReallyUnknownType"); - entry.setField("Comment","testentry"); + entry.setField("Comment", "testentry"); entry.setCiteKey("test"); //write out bibtex string @@ -259,7 +260,6 @@ public void testEntryTypeChange() throws IOException { assertEquals(expectedNewEntry, actual); } - @Test public void roundTripWithAppendedNewlines() throws IOException { // @formatter:off @@ -419,14 +419,14 @@ public void trimFieldContents() throws IOException { assertEquals(expected, actual); } - @Test(expected = IOException.class) - public void writeThrowsErrorIfFieldContainsUnbalancedBraces() throws IOException { + @Test + public void writeThrowsErrorIfFieldContainsUnbalancedBraces() { StringWriter stringWriter = new StringWriter(); BibEntry entry = new BibEntry("article"); entry.setField("note", "some text with unbalanced { braces"); - writer.write(entry, stringWriter, BibDatabaseMode.BIBTEX); + assertThrows(IOException.class, () -> writer.write(entry, stringWriter, BibDatabaseMode.BIBTEX)); } @Test diff --git a/src/test/java/org/jabref/logic/bibtex/DuplicateCheckTest.java b/src/test/java/org/jabref/logic/bibtex/DuplicateCheckTest.java index c0a54568f82..ace796173fe 100644 --- a/src/test/java/org/jabref/logic/bibtex/DuplicateCheckTest.java +++ b/src/test/java/org/jabref/logic/bibtex/DuplicateCheckTest.java @@ -5,12 +5,12 @@ import org.jabref.model.entry.BibtexEntryTypes; import org.jabref.model.entry.FieldName; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class DuplicateCheckTest { @@ -19,7 +19,7 @@ public class DuplicateCheckTest { private BibEntry simpleInbook; private BibEntry simpleIncollection; - @Before + @BeforeEach public void setUp() { simpleArticle = new BibEntry(BibtexEntryTypes.ARTICLE.getName()) .withField(FieldName.AUTHOR, "Single Author") diff --git a/src/test/java/org/jabref/logic/bibtex/FieldContentParserTest.java b/src/test/java/org/jabref/logic/bibtex/FieldContentParserTest.java index c4530f03533..0c973a6aed2 100644 --- a/src/test/java/org/jabref/logic/bibtex/FieldContentParserTest.java +++ b/src/test/java/org/jabref/logic/bibtex/FieldContentParserTest.java @@ -4,17 +4,17 @@ import org.jabref.logic.util.OS; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class FieldContentParserTest { private FieldContentParser parser; private FieldContentParserPreferences prefs; - @Before + @BeforeEach public void setUp() throws Exception { prefs = new FieldContentParserPreferences(Collections.emptyList()); parser = new FieldContentParser(prefs); diff --git a/src/test/java/org/jabref/logic/bibtex/LatexFieldFormatterTests.java b/src/test/java/org/jabref/logic/bibtex/LatexFieldFormatterTests.java index c9c6c7ce63f..7b822bb1b98 100644 --- a/src/test/java/org/jabref/logic/bibtex/LatexFieldFormatterTests.java +++ b/src/test/java/org/jabref/logic/bibtex/LatexFieldFormatterTests.java @@ -4,18 +4,19 @@ import org.jabref.logic.util.OS; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Answers; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; public class LatexFieldFormatterTests { private LatexFieldFormatter formatter; - @Before + @BeforeEach public void setUp() { this.formatter = new LatexFieldFormatter(mock(LatexFieldFormatterPreferences.class, Answers.RETURNS_DEEP_STUBS)); } @@ -85,18 +86,16 @@ public void removeWhitespaceFromNonMultiLineFields() throws Exception { assertEquals(expected, any); } - @Test(expected = InvalidFieldValueException.class) public void reportUnbalancedBracing() throws Exception { String unbalanced = "{"; - formatter.format(unbalanced, "anyfield"); + assertThrows(InvalidFieldValueException.class, () -> formatter.format(unbalanced, "anyfield")); } - @Test(expected = InvalidFieldValueException.class) public void reportUnbalancedBracingWithEscapedBraces() throws Exception { String unbalanced = "{\\}"; - formatter.format(unbalanced, "anyfield"); + assertThrows(InvalidFieldValueException.class, () -> formatter.format(unbalanced, "anyfield")); } @Test diff --git a/src/test/java/org/jabref/logic/bibtex/comparator/BibDatabaseDiffTest.java b/src/test/java/org/jabref/logic/bibtex/comparator/BibDatabaseDiffTest.java index 83ea84a5863..cdf7115824c 100644 --- a/src/test/java/org/jabref/logic/bibtex/comparator/BibDatabaseDiffTest.java +++ b/src/test/java/org/jabref/logic/bibtex/comparator/BibDatabaseDiffTest.java @@ -5,11 +5,12 @@ import org.jabref.model.database.BibDatabaseContext; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class BibDatabaseDiffTest { + @Test public void compareOfEmptyDatabasesReportsNoDifferences() throws Exception { BibDatabaseDiff diff = BibDatabaseDiff.compare(new BibDatabaseContext(), new BibDatabaseContext()); diff --git a/src/test/java/org/jabref/logic/bibtex/comparator/BibtexStringComparatorTest.java b/src/test/java/org/jabref/logic/bibtex/comparator/BibtexStringComparatorTest.java index 3130258f888..9a6d3bbbb26 100644 --- a/src/test/java/org/jabref/logic/bibtex/comparator/BibtexStringComparatorTest.java +++ b/src/test/java/org/jabref/logic/bibtex/comparator/BibtexStringComparatorTest.java @@ -2,10 +2,10 @@ import org.jabref.model.entry.BibtexString; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class BibtexStringComparatorTest { diff --git a/src/test/java/org/jabref/logic/bibtex/comparator/CrossRefEntryComparatorTest.java b/src/test/java/org/jabref/logic/bibtex/comparator/CrossRefEntryComparatorTest.java index f7cb609f03c..2e084da5b5e 100644 --- a/src/test/java/org/jabref/logic/bibtex/comparator/CrossRefEntryComparatorTest.java +++ b/src/test/java/org/jabref/logic/bibtex/comparator/CrossRefEntryComparatorTest.java @@ -3,21 +3,21 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.FieldName; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class CrossRefEntryComparatorTest { private CrossRefEntryComparator comparator; - @Before + @BeforeEach public void setUp() { comparator = new CrossRefEntryComparator(); } - @After + @AfterEach public void tearDown() { comparator = null; } diff --git a/src/test/java/org/jabref/logic/bibtex/comparator/EntryComparatorTest.java b/src/test/java/org/jabref/logic/bibtex/comparator/EntryComparatorTest.java index c7a6f73b315..3e7dbd346da 100644 --- a/src/test/java/org/jabref/logic/bibtex/comparator/EntryComparatorTest.java +++ b/src/test/java/org/jabref/logic/bibtex/comparator/EntryComparatorTest.java @@ -2,7 +2,7 @@ import org.jabref.model.entry.BibEntry; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.junit.Assert.assertEquals; diff --git a/src/test/java/org/jabref/logic/bibtex/comparator/FieldComparatorTest.java b/src/test/java/org/jabref/logic/bibtex/comparator/FieldComparatorTest.java index a33f77a0edc..80742aff2ab 100644 --- a/src/test/java/org/jabref/logic/bibtex/comparator/FieldComparatorTest.java +++ b/src/test/java/org/jabref/logic/bibtex/comparator/FieldComparatorTest.java @@ -2,9 +2,9 @@ import org.jabref.model.entry.BibEntry; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class FieldComparatorTest { @Test diff --git a/src/test/java/org/jabref/logic/bibtex/comparator/MetaDataDiffTest.java b/src/test/java/org/jabref/logic/bibtex/comparator/MetaDataDiffTest.java index e70035009c2..38c9b152f61 100644 --- a/src/test/java/org/jabref/logic/bibtex/comparator/MetaDataDiffTest.java +++ b/src/test/java/org/jabref/logic/bibtex/comparator/MetaDataDiffTest.java @@ -5,9 +5,9 @@ import org.jabref.model.metadata.ContentSelector; import org.jabref.model.metadata.MetaData; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class MetaDataDiffTest { @Test diff --git a/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java b/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java index b855f9bc6d9..65a4e850b58 100644 --- a/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java +++ b/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java @@ -11,12 +11,12 @@ import org.jabref.model.util.DummyFileUpdateMonitor; import org.jabref.model.util.FileUpdateMonitor; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Answers; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; public class BibtexKeyGeneratorTest { @@ -44,9 +44,9 @@ public class BibtexKeyGeneratorTest { private static final String TITLE_STRING_CASED_FOUR_SMALL_WORDS_TWO_CONNECTED_WORDS = "On the Measurement of Design-Time Adaptability for Process-Based Systems "; private static ImportFormatPreferences importFormatPreferences; - private FileUpdateMonitor fileMonitor = new DummyFileUpdateMonitor(); + private final FileUpdateMonitor fileMonitor = new DummyFileUpdateMonitor(); - @Before + @BeforeEach public void setUp() { importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); } @@ -301,9 +301,8 @@ public void testFirstAuthor() { assertEquals("", BibtexKeyGenerator.firstAuthor("")); } - @Test(expected = NullPointerException.class) public void testFirstAuthorNull() { - BibtexKeyGenerator.firstAuthor(null); + assertThrows(NullPointerException.class, () -> BibtexKeyGenerator.firstAuthor(null)); } @Test @@ -425,9 +424,8 @@ public void testAuthIniN() { assertEquals("Newton", BibtexKeyGenerator.authIniN(AUTHOR_STRING_FIRSTNAME_INITIAL_LASTNAME_FULL_COUNT_1, 7)); } - @Test(expected = NullPointerException.class) public void testAuthIniNNull() { - BibtexKeyGenerator.authIniN(null, 3); + assertThrows(NullPointerException.class, () -> BibtexKeyGenerator.authIniN(null, 3)); } @Test @@ -516,9 +514,8 @@ public void authNM() { assertEquals("", BibtexKeyGenerator.authNofMth("", 2, 4)); } - @Test(expected = NullPointerException.class) public void authNMThrowsNPE() { - BibtexKeyGenerator.authNofMth(null, 2, 4); + assertThrows(NullPointerException.class, () -> BibtexKeyGenerator.authNofMth(null, 2, 4)); } /** @@ -690,9 +687,8 @@ public void testFirstPage() { assertEquals("43", BibtexKeyGenerator.firstPage("43+")); } - @Test(expected = NullPointerException.class) public void testFirstPageNull() { - BibtexKeyGenerator.firstPage(null); + assertThrows(NullPointerException.class, () -> BibtexKeyGenerator.firstPage(null)); } @Test @@ -713,9 +709,8 @@ public void testPagePrefix() { assertEquals("", BibtexKeyGenerator.pagePrefix("43+")); } - @Test(expected = NullPointerException.class) public void testPagePrefixNull() { - BibtexKeyGenerator.pagePrefix(null); + assertThrows(NullPointerException.class, () -> BibtexKeyGenerator.pagePrefix(null)); } @Test @@ -730,9 +725,8 @@ public void testLastPage() { assertEquals("43", BibtexKeyGenerator.lastPage("43+")); } - @Test(expected = NullPointerException.class) public void testLastPageNull() { - BibtexKeyGenerator.lastPage(null); + assertThrows(NullPointerException.class, () -> BibtexKeyGenerator.lastPage(null)); } /** @@ -930,10 +924,10 @@ public void testCheckLegalKeyDoNotEnforceLegal() { assertEquals("", BibtexKeyGenerator.cleanKey("\n\t\r", false)); } - @Test(expected = NullPointerException.class) + @Test public void testCheckLegalNullInNullOut() { - assertNull(BibtexKeyGenerator.cleanKey(null, true)); - assertNull(BibtexKeyGenerator.cleanKey(null, false)); + assertThrows(NullPointerException.class, () -> BibtexKeyGenerator.cleanKey(null, true)); + assertThrows(NullPointerException.class, () -> BibtexKeyGenerator.cleanKey(null, false)); } @Test diff --git a/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithDatabaseTest.java b/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithDatabaseTest.java index 38880288509..345d568ff5d 100644 --- a/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithDatabaseTest.java +++ b/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithDatabaseTest.java @@ -7,8 +7,8 @@ import org.jabref.model.database.BibDatabase; import org.jabref.model.entry.BibEntry; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.junit.Assert.assertEquals; @@ -20,7 +20,7 @@ public class MakeLabelWithDatabaseTest { private DatabaseBibtexKeyPattern bibtexKeyPattern; private BibEntry entry; - @Before + @BeforeEach public void setUp() { database = new BibDatabase(); diff --git a/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithoutDatabaseTest.java b/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithoutDatabaseTest.java index 88af32ce21b..72d9d0d3dcc 100644 --- a/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithoutDatabaseTest.java +++ b/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithoutDatabaseTest.java @@ -2,8 +2,8 @@ import org.jabref.model.entry.BibEntry; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.junit.Assert.assertEquals; @@ -11,7 +11,7 @@ public class MakeLabelWithoutDatabaseTest { private BibEntry entry; - @Before + @BeforeEach public void setUp() { entry = new BibEntry(); entry.setField("author", "John Doe"); diff --git a/src/test/java/org/jabref/logic/bst/BibtexCaseChangersTest.java b/src/test/java/org/jabref/logic/bst/BibtexCaseChangersTest.java index 11e99127127..a6214a7f0c8 100644 --- a/src/test/java/org/jabref/logic/bst/BibtexCaseChangersTest.java +++ b/src/test/java/org/jabref/logic/bst/BibtexCaseChangersTest.java @@ -2,8 +2,9 @@ import org.jabref.logic.bst.BibtexCaseChanger.FORMAT_MODE; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class BibtexCaseChangersTest { @@ -121,15 +122,15 @@ public void testTitleCase() { } private void assertCaseChangerTitleLowers(final String string, final String string2) { - Assert.assertEquals(string, BibtexCaseChanger.changeCase(string2, FORMAT_MODE.TITLE_LOWERS)); + assertEquals(string, BibtexCaseChanger.changeCase(string2, FORMAT_MODE.TITLE_LOWERS)); } private void assertCaseChangerAllLowers(final String string, final String string2) { - Assert.assertEquals(string, BibtexCaseChanger.changeCase(string2, FORMAT_MODE.ALL_LOWERS)); + assertEquals(string, BibtexCaseChanger.changeCase(string2, FORMAT_MODE.ALL_LOWERS)); } private void assertCaseChangerAllUppers(final String string, final String string2) { - Assert.assertEquals(string, BibtexCaseChanger.changeCase(string2, FORMAT_MODE.ALL_UPPERS)); + assertEquals(string, BibtexCaseChanger.changeCase(string2, FORMAT_MODE.ALL_UPPERS)); } } diff --git a/src/test/java/org/jabref/logic/bst/BibtexNameFormatterTest.java b/src/test/java/org/jabref/logic/bst/BibtexNameFormatterTest.java index 63ff8ddae22..8fd58e42ff1 100644 --- a/src/test/java/org/jabref/logic/bst/BibtexNameFormatterTest.java +++ b/src/test/java/org/jabref/logic/bst/BibtexNameFormatterTest.java @@ -2,8 +2,10 @@ import org.jabref.model.entry.AuthorList; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class BibtexNameFormatterTest { @@ -13,32 +15,31 @@ public void testFormatName() { AuthorList al = AuthorList .parse("Charles Louis Xavier Joseph de la Vall{\\'e}e Poussin"); - Assert.assertEquals("de~laVall{\\'e}e~PoussinCharles Louis Xavier~Joseph", BibtexNameFormatter.formatName(al - .getAuthor(0), "{vv}{ll}{jj}{ff}", Assert::fail)); + assertEquals("de~laVall{\\'e}e~PoussinCharles Louis Xavier~Joseph", BibtexNameFormatter.formatName(al + .getAuthor(0), "{vv}{ll}{jj}{ff}", Assertions::fail)); } { AuthorList al = AuthorList .parse("Charles Louis Xavier Joseph de la Vall{\\'e}e Poussin"); - Assert.assertEquals("de~la Vall{\\'e}e~Poussin, C.~L. X.~J.", BibtexNameFormatter.formatName(al - .getAuthor(0), "{vv~}{ll}{, jj}{, f.}", Assert::fail)); + assertEquals("de~la Vall{\\'e}e~Poussin, C.~L. X.~J.", BibtexNameFormatter.formatName(al + .getAuthor(0), "{vv~}{ll}{, jj}{, f.}", Assertions::fail)); } { AuthorList al = AuthorList .parse("Charles Louis Xavier Joseph de la Vall{\\'e}e Poussin"); - Assert.assertEquals("de~la Vall{\\'e}e~Poussin, C.~L. X.~J?", BibtexNameFormatter.formatName(al - .getAuthor(0), "{vv~}{ll}{, jj}{, f}?", Assert::fail)); + assertEquals("de~la Vall{\\'e}e~Poussin, C.~L. X.~J?", BibtexNameFormatter.formatName(al + .getAuthor(0), "{vv~}{ll}{, jj}{, f}?", Assertions::fail)); } AuthorList al = AuthorList .parse("Charles Louis Xavier Joseph de la Vall{\\'e}e Poussin"); - Assert.assertEquals("dlVP", BibtexNameFormatter.formatName(al.getAuthor(0), "{v{}}{l{}}", - Assert::fail - )); + assertEquals("dlVP", BibtexNameFormatter.formatName(al.getAuthor(0), "{v{}}{l{}}", + Assertions::fail)); assertNameFormatA("Meyer, J?", "Jonathan Meyer and Charles Louis Xavier Joseph de la Vall{\\'e}e Poussin"); assertNameFormatB("J.~Meyer", "Jonathan Meyer and Charles Louis Xavier Joseph de la Vall{\\'e}e Poussin"); @@ -57,9 +58,8 @@ public void testFormatName() { } private void assertNameFormat(String string, String string2, int which, String format) { - Assert.assertEquals(string, BibtexNameFormatter.formatName(string2, which, format, - Assert::fail - )); + assertEquals(string, BibtexNameFormatter.formatName(string2, which, format, + Assertions::fail)); } private void assertNameFormatC(String string, String string2) { @@ -78,41 +78,41 @@ private void assertNameFormatA(String string, String string2) { public void testConsumeToMatchingBrace() { { StringBuilder sb = new StringBuilder(); - Assert.assertEquals(6, BibtexNameFormatter.consumeToMatchingBrace(sb, "{HELLO} {WORLD}" + assertEquals(6, BibtexNameFormatter.consumeToMatchingBrace(sb, "{HELLO} {WORLD}" .toCharArray(), 0)); - Assert.assertEquals("{HELLO}", sb.toString()); + assertEquals("{HELLO}", sb.toString()); } { StringBuilder sb = new StringBuilder(); - Assert.assertEquals(18, BibtexNameFormatter.consumeToMatchingBrace(sb, "{HE{L{}L}O} {WORLD}" + assertEquals(18, BibtexNameFormatter.consumeToMatchingBrace(sb, "{HE{L{}L}O} {WORLD}" .toCharArray(), 12)); - Assert.assertEquals("{WORLD}", sb.toString()); + assertEquals("{WORLD}", sb.toString()); } StringBuilder sb = new StringBuilder(); - Assert.assertEquals(10, BibtexNameFormatter.consumeToMatchingBrace(sb, "{HE{L{}L}O} {WORLD}" + assertEquals(10, BibtexNameFormatter.consumeToMatchingBrace(sb, "{HE{L{}L}O} {WORLD}" .toCharArray(), 0)); - Assert.assertEquals("{HE{L{}L}O}", sb.toString()); + assertEquals("{HE{L{}L}O}", sb.toString()); } @Test public void testGetFirstCharOfString() { - Assert.assertEquals("C", BibtexNameFormatter.getFirstCharOfString("Charles")); - Assert.assertEquals("V", BibtexNameFormatter.getFirstCharOfString("Vall{\\'e}e")); - Assert.assertEquals("{\\'e}", BibtexNameFormatter.getFirstCharOfString("{\\'e}")); - Assert.assertEquals("{\\'e", BibtexNameFormatter.getFirstCharOfString("{\\'e")); - Assert.assertEquals("E", BibtexNameFormatter.getFirstCharOfString("{E")); + assertEquals("C", BibtexNameFormatter.getFirstCharOfString("Charles")); + assertEquals("V", BibtexNameFormatter.getFirstCharOfString("Vall{\\'e}e")); + assertEquals("{\\'e}", BibtexNameFormatter.getFirstCharOfString("{\\'e}")); + assertEquals("{\\'e", BibtexNameFormatter.getFirstCharOfString("{\\'e")); + assertEquals("E", BibtexNameFormatter.getFirstCharOfString("{E")); } @Test public void testNumberOfChars() { - Assert.assertEquals(6, BibtexNameFormatter.numberOfChars("Vall{\\'e}e", -1)); - Assert.assertEquals(2, BibtexNameFormatter.numberOfChars("Vall{\\'e}e", 2)); - Assert.assertEquals(1, BibtexNameFormatter.numberOfChars("Vall{\\'e}e", 1)); - Assert.assertEquals(6, BibtexNameFormatter.numberOfChars("Vall{\\'e}e", 6)); - Assert.assertEquals(6, BibtexNameFormatter.numberOfChars("Vall{\\'e}e", 7)); - Assert.assertEquals(8, BibtexNameFormatter.numberOfChars("Vall{e}e", -1)); - Assert.assertEquals(6, BibtexNameFormatter.numberOfChars("Vall{\\'e this will be skipped}e", -1)); + assertEquals(6, BibtexNameFormatter.numberOfChars("Vall{\\'e}e", -1)); + assertEquals(2, BibtexNameFormatter.numberOfChars("Vall{\\'e}e", 2)); + assertEquals(1, BibtexNameFormatter.numberOfChars("Vall{\\'e}e", 1)); + assertEquals(6, BibtexNameFormatter.numberOfChars("Vall{\\'e}e", 6)); + assertEquals(6, BibtexNameFormatter.numberOfChars("Vall{\\'e}e", 7)); + assertEquals(8, BibtexNameFormatter.numberOfChars("Vall{e}e", -1)); + assertEquals(6, BibtexNameFormatter.numberOfChars("Vall{\\'e this will be skipped}e", -1)); } } diff --git a/src/test/java/org/jabref/logic/bst/BibtexPurifyTest.java b/src/test/java/org/jabref/logic/bst/BibtexPurifyTest.java index 8a9760f7ba7..799a4d572ba 100644 --- a/src/test/java/org/jabref/logic/bst/BibtexPurifyTest.java +++ b/src/test/java/org/jabref/logic/bst/BibtexPurifyTest.java @@ -1,7 +1,9 @@ package org.jabref.logic.bst; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class BibtexPurifyTest { @@ -19,7 +21,6 @@ public void testPurify() { } private void assertPurify(final String string, final String string2) { - Assert.assertEquals(string, BibtexPurify.purify(string2, s -> - Assert.fail("Should not Warn (" + s + ")! purify should be " + string + " for " + string2))); + assertEquals(string, BibtexPurify.purify(string2, s -> fail("Should not Warn (" + s + ")! purify should be " + string + " for " + string2))); } } diff --git a/src/test/java/org/jabref/logic/bst/BibtexWidthTest.java b/src/test/java/org/jabref/logic/bst/BibtexWidthTest.java index 19e671f867d..924165bf5e0 100644 --- a/src/test/java/org/jabref/logic/bst/BibtexWidthTest.java +++ b/src/test/java/org/jabref/logic/bst/BibtexWidthTest.java @@ -1,7 +1,10 @@ package org.jabref.logic.bst; -import org.junit.Assert; -import org.junit.Test; + + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * How to create these test using Bibtex: @@ -33,7 +36,7 @@ public class BibtexWidthTest { private void assertBibtexWidth(final int i, final String string) { - Assert.assertEquals(i, BibtexWidth.width(string)); + assertEquals(i, BibtexWidth.width(string)); } @Test @@ -61,10 +64,10 @@ public void testWidth() { @Test public void testGetCharWidth() { - Assert.assertEquals(500, BibtexWidth.getCharWidth('0')); - Assert.assertEquals(361, BibtexWidth.getCharWidth('I')); - Assert.assertEquals(500, BibtexWidth.getCharWidth('~')); - Assert.assertEquals(500, BibtexWidth.getCharWidth('}')); - Assert.assertEquals(278, BibtexWidth.getCharWidth(' ')); + assertEquals(500, BibtexWidth.getCharWidth('0')); + assertEquals(361, BibtexWidth.getCharWidth('I')); + assertEquals(500, BibtexWidth.getCharWidth('~')); + assertEquals(500, BibtexWidth.getCharWidth('}')); + assertEquals(278, BibtexWidth.getCharWidth(' ')); } } diff --git a/src/test/java/org/jabref/logic/bst/TestVM.java b/src/test/java/org/jabref/logic/bst/TestVM.java index 92f875466ed..a1e853b8c83 100644 --- a/src/test/java/org/jabref/logic/bst/TestVM.java +++ b/src/test/java/org/jabref/logic/bst/TestVM.java @@ -17,15 +17,16 @@ import org.jabref.model.util.DummyFileUpdateMonitor; import org.antlr.runtime.RecognitionException; -import org.junit.Assert; -import org.junit.Test; +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.junit.jupiter.api.Assertions.fail; import static org.mockito.Mockito.mock; public class TestVM { - @Test public void testAbbrv() throws RecognitionException, IOException { VM vm = new VM(new File("src/test/resources/org/jabref/logic/bst/abbrv.bst")); @@ -34,7 +35,7 @@ public void testAbbrv() throws RecognitionException, IOException { String expected = "\\begin{thebibliography}{1}\\bibitem{canh05}K.~Crowston, H.~Annabi, J.~Howison, and C.~Masango.\\newblock Effective work practices for floss development: A model and propositions.\\newblock In {\\em Hawaii International Conference On System Sciences (HICSS)}, 2005.\\end{thebibliography}"; - Assert.assertEquals(expected.replaceAll("\\s", ""), vm.run(v).replaceAll("\\s", "")); + assertEquals(expected.replaceAll("\\s", ""), vm.run(v).replaceAll("\\s", "")); } @Test @@ -52,11 +53,11 @@ public void testVMSimple() throws RecognitionException, IOException { vm.run(v); - Assert.assertEquals(2, vm.getStrings().size()); - Assert.assertEquals(7, vm.getIntegers().size()); - Assert.assertEquals(1, vm.getEntries().size()); - Assert.assertEquals(5, vm.getEntries().get(0).getFields().size()); - Assert.assertEquals(38, vm.getFunctions().size()); + assertEquals(2, vm.getStrings().size()); + assertEquals(7, vm.getIntegers().size()); + assertEquals(1, vm.getEntries().size()); + assertEquals(5, vm.getEntries().get(0).getFields().size()); + assertEquals(38, vm.getFunctions().size()); } @@ -72,8 +73,9 @@ public void testLabel() throws RecognitionException, IOException { vm.run(v); - Assert.assertEquals("Effective work practices for floss development: A model and propositions", vm - .getStack().pop()); + assertEquals("Effective work practices for floss development: A model and propositions", vm + .getStack() + .pop()); } @@ -85,7 +87,7 @@ public void testQuote() throws RecognitionException { List v = new ArrayList<>(); vm.run(v); - Assert.assertEquals("\"\"", vm.getStack().pop()); + assertEquals("\"\"", vm.getStack().pop()); } @Test @@ -96,12 +98,12 @@ public void testVMFunction1() throws RecognitionException { List v = new ArrayList<>(); vm.run(v); - Assert.assertEquals(38, vm.getFunctions().size()); + assertEquals(38, vm.getFunctions().size()); - Assert.assertTrue(vm.getFunctions().get("init.state.consts") instanceof StackFunction); + assertTrue(vm.getFunctions().get("init.state.consts") instanceof StackFunction); StackFunction fun = (StackFunction) vm.getFunctions().get("init.state.consts"); - Assert.assertEquals(3, fun.getTree().getChildCount()); + assertEquals(3, fun.getTree().getChildCount()); } @Test @@ -111,7 +113,7 @@ public void testVMExecuteSimple() throws RecognitionException { List v = new ArrayList<>(); vm.run(v); - Assert.assertEquals(Integer.valueOf(5), vm.getIntegers().get("variable.a")); + assertEquals(Integer.valueOf(5), vm.getIntegers().get("variable.a")); } @Test @@ -123,17 +125,17 @@ public void testVMExecuteSimple2() throws RecognitionException { List v = new ArrayList<>(); vm.run(v); - Assert.assertEquals(VM.FALSE, vm.getStack().pop()); - Assert.assertEquals(VM.TRUE, vm.getStack().pop()); - Assert.assertEquals(VM.FALSE, vm.getStack().pop()); - Assert.assertEquals(VM.TRUE, vm.getStack().pop()); - Assert.assertEquals(VM.FALSE, vm.getStack().pop()); - Assert.assertEquals(VM.FALSE, vm.getStack().pop()); - Assert.assertEquals(VM.FALSE, vm.getStack().pop()); - Assert.assertEquals(VM.TRUE, vm.getStack().pop()); - Assert.assertEquals(VM.FALSE, vm.getStack().pop()); - Assert.assertEquals(VM.TRUE, vm.getStack().pop()); - Assert.assertEquals(0, vm.getStack().size()); + assertEquals(VM.FALSE, vm.getStack().pop()); + assertEquals(VM.TRUE, vm.getStack().pop()); + assertEquals(VM.FALSE, vm.getStack().pop()); + assertEquals(VM.TRUE, vm.getStack().pop()); + assertEquals(VM.FALSE, vm.getStack().pop()); + assertEquals(VM.FALSE, vm.getStack().pop()); + assertEquals(VM.FALSE, vm.getStack().pop()); + assertEquals(VM.TRUE, vm.getStack().pop()); + assertEquals(VM.FALSE, vm.getStack().pop()); + assertEquals(VM.TRUE, vm.getStack().pop()); + assertEquals(0, vm.getStack().size()); } @Test @@ -146,17 +148,17 @@ public void testVMIfSkipPop() throws RecognitionException { List v = new ArrayList<>(); vm.run(v); - Assert.assertEquals(VM.FALSE, vm.getStack().pop()); - Assert.assertEquals(VM.TRUE, vm.getStack().pop()); - Assert.assertEquals(VM.TRUE, vm.getStack().pop()); - Assert.assertEquals(VM.TRUE, vm.getStack().pop()); - Assert.assertEquals(VM.FALSE, vm.getStack().pop()); - Assert.assertEquals(VM.TRUE, vm.getStack().pop()); - Assert.assertEquals(VM.FALSE, vm.getStack().pop()); - Assert.assertEquals(VM.FALSE, vm.getStack().pop()); - Assert.assertEquals(VM.FALSE, vm.getStack().pop()); - Assert.assertEquals(VM.TRUE, vm.getStack().pop()); - Assert.assertEquals(0, vm.getStack().size()); + assertEquals(VM.FALSE, vm.getStack().pop()); + assertEquals(VM.TRUE, vm.getStack().pop()); + assertEquals(VM.TRUE, vm.getStack().pop()); + assertEquals(VM.TRUE, vm.getStack().pop()); + assertEquals(VM.FALSE, vm.getStack().pop()); + assertEquals(VM.TRUE, vm.getStack().pop()); + assertEquals(VM.FALSE, vm.getStack().pop()); + assertEquals(VM.FALSE, vm.getStack().pop()); + assertEquals(VM.FALSE, vm.getStack().pop()); + assertEquals(VM.TRUE, vm.getStack().pop()); + assertEquals(0, vm.getStack().size()); } @Test @@ -166,12 +168,11 @@ public void testVMArithmetic() throws RecognitionException { List v = new ArrayList<>(); vm.run(v); - Assert.assertEquals(3, vm.getStack().pop()); - Assert.assertEquals(2, vm.getStack().pop()); - Assert.assertEquals(0, vm.getStack().size()); + assertEquals(3, vm.getStack().pop()); + assertEquals(2, vm.getStack().pop()); + assertEquals(0, vm.getStack().size()); } - @Test public void testVMArithmetic2() throws RecognitionException { VM vm = new VM("FUNCTION {test} { " + "#1 \"HELLO\" + #5 #2 - }" + "EXECUTE {test}"); @@ -180,7 +181,7 @@ public void testVMArithmetic2() throws RecognitionException { try { vm.run(v); - Assert.fail(); + fail("fail"); } catch (VMException ignored) { // Ignored } @@ -192,8 +193,8 @@ public void testNumNames() throws RecognitionException { List v = new ArrayList<>(); vm.run(v); - Assert.assertEquals(2, vm.getStack().pop()); - Assert.assertEquals(0, vm.getStack().size()); + assertEquals(2, vm.getStack().pop()); + assertEquals(0, vm.getStack().size()); } @Test @@ -203,8 +204,8 @@ public void testNumNames2() throws RecognitionException { List v = new ArrayList<>(); vm.run(v); - Assert.assertEquals(1, vm.getStack().pop()); - Assert.assertEquals(0, vm.getStack().size()); + assertEquals(1, vm.getStack().pop()); + assertEquals(0, vm.getStack().size()); } @Test @@ -213,70 +214,69 @@ public void testVMStringOps1() throws RecognitionException { "FUNCTION {test} { \"H\" \"allo\" * \"Johnny\" add.period$ \"Johnny.\" add.period$" + "\"Johnny!\" add.period$ \"Johnny?\" add.period$ \"Johnny} }}}\" add.period$" + "\"Johnny!}\" add.period$ \"Johnny?}\" add.period$ \"Johnny.}\" add.period$ }" - + "EXECUTE {test}" - ); + + "EXECUTE {test}"); List v = new ArrayList<>(); vm.run(v); - Assert.assertEquals("Johnny.}", vm.getStack().pop()); - Assert.assertEquals("Johnny?}", vm.getStack().pop()); - Assert.assertEquals("Johnny!}", vm.getStack().pop()); - Assert.assertEquals("Johnny.}", vm.getStack().pop()); - Assert.assertEquals("Johnny?", vm.getStack().pop()); - Assert.assertEquals("Johnny!", vm.getStack().pop()); - Assert.assertEquals("Johnny.", vm.getStack().pop()); - Assert.assertEquals("Johnny.", vm.getStack().pop()); - Assert.assertEquals("Hallo", vm.getStack().pop()); - Assert.assertEquals(0, vm.getStack().size()); + assertEquals("Johnny.}", vm.getStack().pop()); + assertEquals("Johnny?}", vm.getStack().pop()); + assertEquals("Johnny!}", vm.getStack().pop()); + assertEquals("Johnny.}", vm.getStack().pop()); + assertEquals("Johnny?", vm.getStack().pop()); + assertEquals("Johnny!", vm.getStack().pop()); + assertEquals("Johnny.", vm.getStack().pop()); + assertEquals("Johnny.", vm.getStack().pop()); + assertEquals("Hallo", vm.getStack().pop()); + assertEquals(0, vm.getStack().size()); } @Test public void testSubstring() throws RecognitionException { VM vm = new VM("FUNCTION {test} " + "{ \"123456789\" #2 #1 substring$ " + // 2 - " \"123456789\" #4 global.max$ substring$ " + // 456789 - " \"123456789\" #1 #9 substring$ " + // 123456789 - " \"123456789\" #1 #10 substring$ " + // 123456789 - " \"123456789\" #1 #99 substring$ " + // 123456789 + " \"123456789\" #4 global.max$ substring$ " + // 456789 + " \"123456789\" #1 #9 substring$ " + // 123456789 + " \"123456789\" #1 #10 substring$ " + // 123456789 + " \"123456789\" #1 #99 substring$ " + // 123456789 - " \"123456789\" #-7 #3 substring$ " + // 123 - " \"123456789\" #-1 #1 substring$ " + // 9 - " \"123456789\" #-1 #3 substring$ " + // 789 - " \"123456789\" #-2 #2 substring$ " + // 78 + " \"123456789\" #-7 #3 substring$ " + // 123 + " \"123456789\" #-1 #1 substring$ " + // 9 + " \"123456789\" #-1 #3 substring$ " + // 789 + " \"123456789\" #-2 #2 substring$ " + // 78 - "} EXECUTE {test} "); + "} EXECUTE {test} "); List v = new ArrayList<>(); vm.run(v); - Assert.assertEquals("78", vm.getStack().pop()); - Assert.assertEquals("789", vm.getStack().pop()); - Assert.assertEquals("9", vm.getStack().pop()); - Assert.assertEquals("123", vm.getStack().pop()); + assertEquals("78", vm.getStack().pop()); + assertEquals("789", vm.getStack().pop()); + assertEquals("9", vm.getStack().pop()); + assertEquals("123", vm.getStack().pop()); - Assert.assertEquals("123456789", vm.getStack().pop()); - Assert.assertEquals("123456789", vm.getStack().pop()); - Assert.assertEquals("123456789", vm.getStack().pop()); - Assert.assertEquals("456789", vm.getStack().pop()); - Assert.assertEquals("2", vm.getStack().pop()); - Assert.assertEquals(0, vm.getStack().size()); + assertEquals("123456789", vm.getStack().pop()); + assertEquals("123456789", vm.getStack().pop()); + assertEquals("123456789", vm.getStack().pop()); + assertEquals("456789", vm.getStack().pop()); + assertEquals("2", vm.getStack().pop()); + assertEquals(0, vm.getStack().size()); } @Test public void testEmpty() throws RecognitionException, IOException { VM vm = new VM("ENTRY {title}{}{} READ STRINGS { s } FUNCTION {test} " + "{ s empty$ " + // FALSE - "\"\" empty$ " + // FALSE - "\" \" empty$ " + // FALSE - " title empty$ " + // FALSE - " \" HALLO \" empty$ } ITERATE {test} "); + "\"\" empty$ " + // FALSE + "\" \" empty$ " + // FALSE + " title empty$ " + // FALSE + " \" HALLO \" empty$ } ITERATE {test} "); List v = new ArrayList<>(); v.add(TestVM.bibtexString2BibtexEntry("@article{a, author=\"AAA\"}")); vm.run(v); - Assert.assertEquals(VM.FALSE, vm.getStack().pop()); - Assert.assertEquals(VM.TRUE, vm.getStack().pop()); - Assert.assertEquals(VM.TRUE, vm.getStack().pop()); - Assert.assertEquals(VM.TRUE, vm.getStack().pop()); - Assert.assertEquals(VM.TRUE, vm.getStack().pop()); - Assert.assertEquals(0, vm.getStack().size()); + assertEquals(VM.FALSE, vm.getStack().pop()); + assertEquals(VM.TRUE, vm.getStack().pop()); + assertEquals(VM.TRUE, vm.getStack().pop()); + assertEquals(VM.TRUE, vm.getStack().pop()); + assertEquals(VM.TRUE, vm.getStack().pop()); + assertEquals(0, vm.getStack().size()); } @Test @@ -287,9 +287,9 @@ public void testDuplicateEmptyPopSwapIf() throws RecognitionException { List v = new ArrayList<>(); vm.run(v); - Assert.assertEquals("{\\em Hello}", vm.getStack().pop()); - Assert.assertEquals("", vm.getStack().pop()); - Assert.assertEquals(0, vm.getStack().size()); + assertEquals("{\\em Hello}", vm.getStack().pop()); + assertEquals("", vm.getStack().pop()); + assertEquals(0, vm.getStack().size()); } @Test @@ -308,18 +308,17 @@ public void testChangeCase() throws RecognitionException { + " \"Hello World\" format.title " + " \"\" format.title " + " \"{A}{D}/{C}ycle: {I}{B}{M}'s {F}ramework for {A}pplication {D}evelopment and {C}ase\" \"u\" change.case$ format.title " - + "}" + "EXECUTE {test} " - ); + + "}" + "EXECUTE {test} "); List v = new ArrayList<>(); vm.run(v); - Assert.assertEquals( + assertEquals( "{A}{D}/{C}ycle: {I}{B}{M}'s {F}ramework for {A}pplication {D}evelopment and {C}ase", vm.getStack().pop()); - Assert.assertEquals("", vm.getStack().pop()); - Assert.assertEquals("Hello world", vm.getStack().pop()); - Assert.assertEquals("Hello world", vm.getStack().pop()); - Assert.assertEquals(0, vm.getStack().size()); + assertEquals("", vm.getStack().pop()); + assertEquals("Hello world", vm.getStack().pop()); + assertEquals("Hello world", vm.getStack().pop()); + assertEquals(0, vm.getStack().size()); } @Test @@ -334,15 +333,15 @@ public void testTextLength() throws RecognitionException { List v = new ArrayList<>(); vm.run(v); - Assert.assertEquals(11, vm.getStack().pop()); - Assert.assertEquals(1, vm.getStack().pop()); - Assert.assertEquals(1, vm.getStack().pop()); - Assert.assertEquals(1, vm.getStack().pop()); - Assert.assertEquals(8, vm.getStack().pop()); - Assert.assertEquals(0, vm.getStack().pop()); - Assert.assertEquals(11, vm.getStack().pop()); - Assert.assertEquals(11, vm.getStack().pop()); - Assert.assertEquals(0, vm.getStack().size()); + assertEquals(11, vm.getStack().pop()); + assertEquals(1, vm.getStack().pop()); + assertEquals(1, vm.getStack().pop()); + assertEquals(1, vm.getStack().pop()); + assertEquals(8, vm.getStack().pop()); + assertEquals(0, vm.getStack().pop()); + assertEquals(11, vm.getStack().pop()); + assertEquals(11, vm.getStack().pop()); + assertEquals(0, vm.getStack().size()); } @Test @@ -351,9 +350,9 @@ public void testVMIntToStr() throws RecognitionException { List v = new ArrayList<>(); vm.run(v); - Assert.assertEquals("9999", vm.getStack().pop()); - Assert.assertEquals("3", vm.getStack().pop()); - Assert.assertEquals(0, vm.getStack().size()); + assertEquals("9999", vm.getStack().pop()); + assertEquals("3", vm.getStack().pop()); + assertEquals(0, vm.getStack().size()); } @Test @@ -362,8 +361,8 @@ public void testVMChrToInt() throws RecognitionException { List v = new ArrayList<>(); vm.run(v); - Assert.assertEquals(72, vm.getStack().pop()); - Assert.assertEquals(0, vm.getStack().size()); + assertEquals(72, vm.getStack().pop()); + assertEquals(0, vm.getStack().size()); } @Test @@ -372,8 +371,8 @@ public void testVMChrToIntIntToChr() throws RecognitionException { List v = new ArrayList<>(); vm.run(v); - Assert.assertEquals("H", vm.getStack().pop()); - Assert.assertEquals(0, vm.getStack().size()); + assertEquals("H", vm.getStack().pop()); + assertEquals(0, vm.getStack().size()); } @Test @@ -390,10 +389,10 @@ public void testSort() throws RecognitionException, IOException { vm.run(v); List v2 = vm.getEntries(); - Assert.assertEquals(Optional.of("a"), v2.get(0).getBibtexEntry().getCiteKeyOptional()); - Assert.assertEquals(Optional.of("b"), v2.get(1).getBibtexEntry().getCiteKeyOptional()); - Assert.assertEquals(Optional.of("c"), v2.get(2).getBibtexEntry().getCiteKeyOptional()); - Assert.assertEquals(Optional.of("d"), v2.get(3).getBibtexEntry().getCiteKeyOptional()); + assertEquals(Optional.of("a"), v2.get(0).getBibtexEntry().getCiteKeyOptional()); + assertEquals(Optional.of("b"), v2.get(1).getBibtexEntry().getCiteKeyOptional()); + assertEquals(Optional.of("c"), v2.get(2).getBibtexEntry().getCiteKeyOptional()); + assertEquals(Optional.of("d"), v2.get(3).getBibtexEntry().getCiteKeyOptional()); } @Test @@ -403,8 +402,8 @@ public void testBuildIn() throws RecognitionException { List v = new ArrayList<>(); vm.run(v); - Assert.assertEquals(Integer.MAX_VALUE, vm.getStack().pop()); - Assert.assertTrue(vm.getStack().empty()); + assertEquals(Integer.MAX_VALUE, vm.getStack().pop()); + assertTrue(vm.getStack().empty()); } @Test @@ -417,7 +416,7 @@ public void testVariables() throws RecognitionException { vm.run(new ArrayList<>()); - Assert.assertEquals(VM.TRUE, vm.getStack().pop()); + assertEquals(VM.TRUE, vm.getStack().pop()); } @Test @@ -452,22 +451,20 @@ public void testWhile() throws RecognitionException { + " } " + " while$ " + " } " - + " EXECUTE {n.dashify} " - ); + + " EXECUTE {n.dashify} "); List v = new ArrayList<>(); vm.run(v); - Assert.assertEquals(1, vm.getStack().size()); - Assert.assertEquals("HELLO--WORLD", vm.getStack().pop()); + assertEquals(1, vm.getStack().size()); + assertEquals("HELLO--WORLD", vm.getStack().pop()); } @Test public void testType() throws RecognitionException, IOException { VM vm = new VM("ENTRY { title } { } { label }" - + "FUNCTION {presort} { cite$ 'sort.key$ := } ITERATE { presort } SORT FUNCTION {test} { type$ } ITERATE { test }" - ); + + "FUNCTION {presort} { cite$ 'sort.key$ := } ITERATE { presort } SORT FUNCTION {test} { type$ } ITERATE { test }"); List v = new ArrayList<>(); v.add(TestVM.bibtexString2BibtexEntry("@article{a, author=\"AAA\"}")); @@ -476,11 +473,11 @@ public void testType() throws RecognitionException, IOException { v.add(TestVM.bibtexString2BibtexEntry("@inproceedings{d, author=\"DDD\"}")); vm.run(v); - Assert.assertEquals(4, vm.getStack().size()); - Assert.assertEquals("inproceedings", vm.getStack().pop()); - Assert.assertEquals("misc", vm.getStack().pop()); - Assert.assertEquals("book", vm.getStack().pop()); - Assert.assertEquals("article", vm.getStack().pop()); + assertEquals(4, vm.getStack().size()); + assertEquals("inproceedings", vm.getStack().pop()); + assertEquals("misc", vm.getStack().pop()); + assertEquals("book", vm.getStack().pop()); + assertEquals("article", vm.getStack().pop()); } @Test @@ -488,24 +485,23 @@ public void testMissing() throws RecognitionException, IOException { VM vm = new VM( // "ENTRY { title } { } { label } " + // - "FUNCTION {presort} { cite$ 'sort.key$ := } " + // - "ITERATE {presort} " + // - "READ SORT " + // - "FUNCTION {test}{ title missing$ cite$ } " + // - "ITERATE { test }" - ); + "FUNCTION {presort} { cite$ 'sort.key$ := } " + // + "ITERATE {presort} " + // + "READ SORT " + // + "FUNCTION {test}{ title missing$ cite$ } " + // + "ITERATE { test }"); List v = new ArrayList<>(); v.add(t1BibtexEntry()); v.add(TestVM.bibtexString2BibtexEntry("@article{test, author=\"No title\"}")); vm.run(v); - Assert.assertEquals(4, vm.getStack().size()); + assertEquals(4, vm.getStack().size()); - Assert.assertEquals("test", vm.getStack().pop()); - Assert.assertEquals(1, vm.getStack().pop()); - Assert.assertEquals("canh05", vm.getStack().pop()); - Assert.assertEquals(0, vm.getStack().pop()); + assertEquals("test", vm.getStack().pop()); + assertEquals(1, vm.getStack().pop()); + assertEquals("canh05", vm.getStack().pop()); + assertEquals(0, vm.getStack().pop()); } @Test @@ -516,8 +512,8 @@ public void testFormatName() throws RecognitionException { List v = new ArrayList<>(); vm.run(v); - Assert.assertEquals("de~la Vall{\\'e}e~Poussin, C.~L. X.~J?", vm.getStack().pop()); - Assert.assertEquals(0, vm.getStack().size()); + assertEquals("de~la Vall{\\'e}e~Poussin, C.~L. X.~J?", vm.getStack().pop()); + assertEquals(0, vm.getStack().size()); } @Test @@ -531,9 +527,9 @@ public void testFormatName2() throws RecognitionException, IOException { v.add(TestVM.bibtexString2BibtexEntry( "@book{test, author=\"Jonathan Meyer and Charles Louis Xavier Joseph de la Vall{\\'e}e Poussin\"}")); vm.run(v); - Assert.assertEquals("de~la Vall{\\'e}e~Poussin, C.~L. X.~J?", vm.getStack().pop()); - Assert.assertEquals("Annabi, H?", vm.getStack().pop()); - Assert.assertEquals(0, vm.getStack().size()); + assertEquals("de~la Vall{\\'e}e~Poussin, C.~L. X.~J?", vm.getStack().pop()); + assertEquals("Annabi, H?", vm.getStack().pop()); + assertEquals(0, vm.getStack().size()); } @Test @@ -542,21 +538,20 @@ public void testCallType() throws RecognitionException, IOException { VM vm = new VM( "ENTRY { title } { } { label } FUNCTION {presort} { cite$ 'sort.key$ := } ITERATE { presort } READ SORT " + "FUNCTION {inproceedings}{ \"InProceedings called on \" title * } " - + "FUNCTION {book}{ \"Book called on \" title * } " + " ITERATE { call.type$ }" - ); + + "FUNCTION {book}{ \"Book called on \" title * } " + " ITERATE { call.type$ }"); List v = new ArrayList<>(); v.add(t1BibtexEntry()); v.add(TestVM.bibtexString2BibtexEntry("@book{test, title=\"Test\"}")); vm.run(v); - Assert.assertEquals(2, vm.getStack().size()); + assertEquals(2, vm.getStack().size()); - Assert.assertEquals("Book called on Test", vm.getStack().pop()); - Assert.assertEquals( + assertEquals("Book called on Test", vm.getStack().pop()); + assertEquals( "InProceedings called on Effective work practices for floss development: A model and propositions", vm.getStack().pop()); - Assert.assertEquals(0, vm.getStack().size()); + assertEquals(0, vm.getStack().size()); } @Test @@ -572,16 +567,16 @@ public void testIterate() throws RecognitionException, IOException { vm.run(v); - Assert.assertEquals(2, vm.getStack().size()); + assertEquals(2, vm.getStack().size()); String s1 = (String) vm.getStack().pop(); String s2 = (String) vm.getStack().pop(); if ("canh05".equals(s1)) { - Assert.assertEquals("test", s2); + assertEquals("test", s2); } else { - Assert.assertEquals("canh05", s2); - Assert.assertEquals("test", s1); + assertEquals("canh05", s2); + assertEquals("test", s1); } } @@ -626,8 +621,8 @@ public void testWidth() throws RecognitionException, IOException { vm.run(v); - Assert.assertTrue(vm.getIntegers().containsKey("longest.label.width")); - Assert.assertEquals("\\begin{thebibliography}{1}", vm.getStack().pop()); + assertTrue(vm.getIntegers().containsKey("longest.label.width")); + assertEquals("\\begin{thebibliography}{1}", vm.getStack().pop()); } @Test @@ -638,15 +633,15 @@ public void testVMSwap() throws RecognitionException { List v = new ArrayList<>(); vm.run(v); - Assert.assertEquals(2, vm.getStack().size()); - Assert.assertEquals(3, vm.getStack().pop()); - Assert.assertEquals("Hallo", vm.getStack().pop()); + assertEquals(2, vm.getStack().size()); + assertEquals(3, vm.getStack().pop()); + assertEquals("Hallo", vm.getStack().pop()); } private static BibEntry bibtexString2BibtexEntry(String s) throws IOException { ParserResult result = new BibtexParser(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS), new DummyFileUpdateMonitor()).parse(new StringReader(s)); Collection c = result.getDatabase().getEntries(); - Assert.assertEquals(1, c.size()); + assertEquals(1, c.size()); return c.iterator().next(); } @@ -665,7 +660,7 @@ public void testHypthenatedName() throws RecognitionException, IOException { VM vm = new VM(new File("src/test/resources/org/jabref/logic/bst/abbrv.bst")); List v = new ArrayList<>(); v.add(TestVM.bibtexString2BibtexEntry("@article{canh05, author = \"Jean-Paul Sartre\" }")); - Assert.assertTrue(vm.run(v).contains("J.-P. Sartre")); + assertTrue(vm.run(v).contains("J.-P. Sartre")); } private BibEntry t1BibtexEntry() throws IOException { diff --git a/src/test/java/org/jabref/logic/bst/TextPrefixFunctionTest.java b/src/test/java/org/jabref/logic/bst/TextPrefixFunctionTest.java index 9c106207a23..353a7643314 100644 --- a/src/test/java/org/jabref/logic/bst/TextPrefixFunctionTest.java +++ b/src/test/java/org/jabref/logic/bst/TextPrefixFunctionTest.java @@ -1,7 +1,9 @@ package org.jabref.logic.bst; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; public class TextPrefixFunctionTest { @@ -19,8 +21,7 @@ public void testPrefix() { } private static void assertPrefix(final String string, final String string2) { - Assert.assertEquals(string, BibtexTextPrefix.textPrefix(5, string2, s -> - Assert.fail("Should not Warn! text.prefix$ should be " + string + " for (5) " + string2))); + assertEquals(string, BibtexTextPrefix.textPrefix(5, string2, s -> fail("Should not Warn! text.prefix$ should be " + string + " for (5) " + string2))); } } diff --git a/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java b/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java index 4819198f596..890eed33bea 100644 --- a/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java +++ b/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java @@ -5,9 +5,10 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.FieldName; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.Assert.assertEquals; public class CitationStyleGeneratorTest { diff --git a/src/test/java/org/jabref/logic/citationstyle/CitationStyleTest.java b/src/test/java/org/jabref/logic/citationstyle/CitationStyleTest.java index 79d8f19cf1d..b63d9d94f0e 100644 --- a/src/test/java/org/jabref/logic/citationstyle/CitationStyleTest.java +++ b/src/test/java/org/jabref/logic/citationstyle/CitationStyleTest.java @@ -2,15 +2,16 @@ import org.jabref.logic.util.TestEntry; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class CitationStyleTest { @Test public void getDefault() throws Exception { - Assert.assertNotNull(CitationStyle.getDefault()); + assertNotNull(CitationStyle.getDefault()); } @Test @@ -24,7 +25,7 @@ public void testDefaultCitation() { "BibTeX Journal, vol. 34, no. 3, pp. 45–67, Jul. 2016.\n" + " \n"; - Assert.assertEquals(expected, citation); + assertEquals(expected, citation); } } diff --git a/src/test/java/org/jabref/logic/cleanup/ConvertToBiblatexCleanupTest.java b/src/test/java/org/jabref/logic/cleanup/ConvertToBiblatexCleanupTest.java index f6ac76d65ad..104eb31b6ed 100644 --- a/src/test/java/org/jabref/logic/cleanup/ConvertToBiblatexCleanupTest.java +++ b/src/test/java/org/jabref/logic/cleanup/ConvertToBiblatexCleanupTest.java @@ -5,15 +5,16 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.FieldName; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class ConvertToBiblatexCleanupTest { private ConvertToBiblatexCleanup worker; - @Before + @BeforeEach public void setUp() { worker = new ConvertToBiblatexCleanup(); } @@ -26,9 +27,9 @@ public void cleanupMovesYearMonthToDate() { worker.cleanup(entry); - Assert.assertEquals(Optional.empty(), entry.getField(FieldName.YEAR)); - Assert.assertEquals(Optional.empty(), entry.getField(FieldName.MONTH)); - Assert.assertEquals(Optional.of("2011-01"), entry.getField(FieldName.DATE)); + assertEquals(Optional.empty(), entry.getField(FieldName.YEAR)); + assertEquals(Optional.empty(), entry.getField(FieldName.MONTH)); + assertEquals(Optional.of("2011-01"), entry.getField(FieldName.DATE)); } @Test @@ -40,9 +41,9 @@ public void cleanupWithDateAlreadyPresentDoesNothing() { worker.cleanup(entry); - Assert.assertEquals(Optional.of("2011"), entry.getField(FieldName.YEAR)); - Assert.assertEquals(Optional.of("#jan#"), entry.getField(FieldName.MONTH)); - Assert.assertEquals(Optional.of("2012"), entry.getField(FieldName.DATE)); + assertEquals(Optional.of("2011"), entry.getField(FieldName.YEAR)); + assertEquals(Optional.of("#jan#"), entry.getField(FieldName.MONTH)); + assertEquals(Optional.of("2012"), entry.getField(FieldName.DATE)); } @Test @@ -51,7 +52,7 @@ public void cleanupMovesJournalToJournaltitle() { worker.cleanup(entry); - Assert.assertEquals(Optional.empty(), entry.getField(FieldName.JOURNAL)); - Assert.assertEquals(Optional.of("Best of JabRef"), entry.getField(FieldName.JOURNALTITLE)); + assertEquals(Optional.empty(), entry.getField(FieldName.JOURNAL)); + assertEquals(Optional.of("Best of JabRef"), entry.getField(FieldName.JOURNALTITLE)); } } diff --git a/src/test/java/org/jabref/logic/cleanup/ConvertToBibtexCleanupTest.java b/src/test/java/org/jabref/logic/cleanup/ConvertToBibtexCleanupTest.java index 5b5de9d37b4..df46c7da884 100644 --- a/src/test/java/org/jabref/logic/cleanup/ConvertToBibtexCleanupTest.java +++ b/src/test/java/org/jabref/logic/cleanup/ConvertToBibtexCleanupTest.java @@ -5,15 +5,16 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.FieldName; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class ConvertToBibtexCleanupTest { private ConvertToBibtexCleanup worker; - @Before + @BeforeEach public void setUp() { worker = new ConvertToBibtexCleanup(); } @@ -24,9 +25,9 @@ public void cleanupMovesDateToYearAndMonth() { worker.cleanup(entry); - Assert.assertEquals(Optional.empty(), entry.getField(FieldName.DATE)); - Assert.assertEquals(Optional.of("2011"), entry.getField(FieldName.YEAR)); - Assert.assertEquals(Optional.of("#jan#"), entry.getField(FieldName.MONTH)); + assertEquals(Optional.empty(), entry.getField(FieldName.DATE)); + assertEquals(Optional.of("2011"), entry.getField(FieldName.YEAR)); + assertEquals(Optional.of("#jan#"), entry.getField(FieldName.MONTH)); } @Test @@ -37,8 +38,8 @@ public void cleanupWithYearAlreadyPresentDoesNothing() { worker.cleanup(entry); - Assert.assertEquals(Optional.of("2011"), entry.getField(FieldName.YEAR)); - Assert.assertEquals(Optional.of("2012"), entry.getField(FieldName.DATE)); + assertEquals(Optional.of("2011"), entry.getField(FieldName.YEAR)); + assertEquals(Optional.of("2012"), entry.getField(FieldName.DATE)); } @Test @@ -47,7 +48,7 @@ public void cleanupMovesJournaltitleToJournal() { worker.cleanup(entry); - Assert.assertEquals(Optional.empty(), entry.getField(FieldName.JOURNALTITLE)); - Assert.assertEquals(Optional.of("Best of JabRef"), entry.getField(FieldName.JOURNAL)); + assertEquals(Optional.empty(), entry.getField(FieldName.JOURNALTITLE)); + assertEquals(Optional.of("Best of JabRef"), entry.getField(FieldName.JOURNAL)); } } diff --git a/src/test/java/org/jabref/logic/cleanup/FieldFormatterCleanupTest.java b/src/test/java/org/jabref/logic/cleanup/FieldFormatterCleanupTest.java index e7b01d90b1e..9f3b76b5bdf 100644 --- a/src/test/java/org/jabref/logic/cleanup/FieldFormatterCleanupTest.java +++ b/src/test/java/org/jabref/logic/cleanup/FieldFormatterCleanupTest.java @@ -1,6 +1,5 @@ package org.jabref.logic.cleanup; - import java.util.HashMap; import java.util.Map; @@ -10,16 +9,17 @@ import org.jabref.model.entry.BibtexEntryTypes; import org.jabref.model.entry.FieldName; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class FieldFormatterCleanupTest { private BibEntry entry; - private Map fieldMap; + private Map fieldMap; - @Before + @BeforeEach public void setUp() { fieldMap = new HashMap<>(); entry = new BibEntry(); @@ -41,13 +41,13 @@ public void testInternalAllField() throws Exception { FieldFormatterCleanup cleanup = new FieldFormatterCleanup(FieldName.INTERNAL_ALL_FIELD, new UpperCaseFormatter()); cleanup.cleanup(entry); - Assert.assertEquals(fieldMap.get("title").toUpperCase(), entry.getField("title").get()); - Assert.assertEquals(fieldMap.get("booktitle").toUpperCase(), entry.getField("booktitle").get()); - Assert.assertEquals(fieldMap.get("year").toUpperCase(), entry.getField("year").get()); - Assert.assertEquals(fieldMap.get("month").toUpperCase(), entry.getField("month").get()); - Assert.assertEquals(fieldMap.get("abstract").toUpperCase(), entry.getField("abstract").get()); - Assert.assertEquals(fieldMap.get("doi").toUpperCase(), entry.getField("doi").get()); - Assert.assertEquals(fieldMap.get("issn").toUpperCase(), entry.getField("issn").get()); + assertEquals(fieldMap.get("title").toUpperCase(), entry.getField("title").get()); + assertEquals(fieldMap.get("booktitle").toUpperCase(), entry.getField("booktitle").get()); + assertEquals(fieldMap.get("year").toUpperCase(), entry.getField("year").get()); + assertEquals(fieldMap.get("month").toUpperCase(), entry.getField("month").get()); + assertEquals(fieldMap.get("abstract").toUpperCase(), entry.getField("abstract").get()); + assertEquals(fieldMap.get("doi").toUpperCase(), entry.getField("doi").get()); + assertEquals(fieldMap.get("issn").toUpperCase(), entry.getField("issn").get()); } @Test @@ -55,12 +55,12 @@ public void testInternalAllTextFieldsField() throws Exception { FieldFormatterCleanup cleanup = new FieldFormatterCleanup(FieldName.INTERNAL_ALL_TEXT_FIELDS_FIELD, new UpperCaseFormatter()); cleanup.cleanup(entry); - Assert.assertEquals(fieldMap.get("title").toUpperCase(), entry.getField("title").get()); - Assert.assertEquals(fieldMap.get("booktitle").toUpperCase(), entry.getField("booktitle").get()); - Assert.assertEquals(fieldMap.get("year"), entry.getField("year").get()); - Assert.assertEquals(fieldMap.get("month"), entry.getField("month").get()); - Assert.assertEquals(fieldMap.get("abstract").toUpperCase(), entry.getField("abstract").get()); - Assert.assertEquals(fieldMap.get("doi"), entry.getField("doi").get()); - Assert.assertEquals(fieldMap.get("issn"), entry.getField("issn").get()); + assertEquals(fieldMap.get("title").toUpperCase(), entry.getField("title").get()); + assertEquals(fieldMap.get("booktitle").toUpperCase(), entry.getField("booktitle").get()); + assertEquals(fieldMap.get("year"), entry.getField("year").get()); + assertEquals(fieldMap.get("month"), entry.getField("month").get()); + assertEquals(fieldMap.get("abstract").toUpperCase(), entry.getField("abstract").get()); + assertEquals(fieldMap.get("doi"), entry.getField("doi").get()); + assertEquals(fieldMap.get("issn"), entry.getField("issn").get()); } } diff --git a/src/test/java/org/jabref/logic/cleanup/ISSNCleanupTest.java b/src/test/java/org/jabref/logic/cleanup/ISSNCleanupTest.java index 3dd3f5f4d02..c4827f7eef0 100644 --- a/src/test/java/org/jabref/logic/cleanup/ISSNCleanupTest.java +++ b/src/test/java/org/jabref/logic/cleanup/ISSNCleanupTest.java @@ -7,18 +7,17 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.metadata.FileDirectoryPreferences; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; public class ISSNCleanupTest { private CleanupWorker worker; - - @Before + @BeforeEach public void setUp() { worker = new CleanupWorker(mock(BibDatabaseContext.class), new CleanupPreferences("", "", mock(LayoutFormatterPreferences.class), @@ -32,7 +31,7 @@ public void cleanupISSNReturnsCorrectISSN() { entry.setField("issn", "0123-4567"); worker.cleanup(preset, entry); - Assert.assertEquals(Optional.of("0123-4567"), entry.getField("issn")); + assertEquals(Optional.of("0123-4567"), entry.getField("issn")); } @Test @@ -42,7 +41,7 @@ public void cleanupISSNAddsMissingDash() { entry.setField("issn", "01234567"); worker.cleanup(preset, entry); - Assert.assertEquals(Optional.of("0123-4567"), entry.getField("issn")); + assertEquals(Optional.of("0123-4567"), entry.getField("issn")); } @Test @@ -52,7 +51,7 @@ public void cleanupISSNJunkStaysJunk() { entry.setField("issn", "Banana"); worker.cleanup(preset, entry); - Assert.assertEquals(Optional.of("Banana"), entry.getField("issn")); + assertEquals(Optional.of("Banana"), entry.getField("issn")); } } diff --git a/src/test/java/org/jabref/logic/exporter/BibtexDatabaseWriterTest.java b/src/test/java/org/jabref/logic/exporter/BibtexDatabaseWriterTest.java index b0225863f31..00a96b5d7fa 100644 --- a/src/test/java/org/jabref/logic/exporter/BibtexDatabaseWriterTest.java +++ b/src/test/java/org/jabref/logic/exporter/BibtexDatabaseWriterTest.java @@ -38,11 +38,12 @@ import org.jabref.model.util.DummyFileUpdateMonitor; import org.jabref.model.util.FileUpdateMonitor; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Answers; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; public class BibtexDatabaseWriterTest { @@ -52,9 +53,9 @@ public class BibtexDatabaseWriterTest { private MetaData metaData; private BibDatabaseContext bibtexContext; private ImportFormatPreferences importFormatPreferences; - private FileUpdateMonitor fileMonitor = new DummyFileUpdateMonitor(); + private final FileUpdateMonitor fileMonitor = new DummyFileUpdateMonitor(); - @Before + @BeforeEach public void setUp() { // Write to a string instead of to a file databaseWriter = new BibtexDatabaseWriter<>(StringSaveSession::new); @@ -65,19 +66,19 @@ public void setUp() { importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); } - @Test(expected = NullPointerException.class) + @Test public void writeWithNullContextThrowsException() throws Exception { - databaseWriter.savePartOfDatabase(null, Collections.emptyList(), new SavePreferences()); + assertThrows(NullPointerException.class, () -> databaseWriter.savePartOfDatabase(null, Collections.emptyList(), new SavePreferences())); } - @Test(expected = NullPointerException.class) + @Test public void writeWithNullEntriesThrowsException() throws Exception { - databaseWriter.savePartOfDatabase(bibtexContext, null, new SavePreferences()); + assertThrows(NullPointerException.class, () -> databaseWriter.savePartOfDatabase(bibtexContext, null, new SavePreferences())); } - @Test(expected = NullPointerException.class) + @Test public void writeWithNullPreferencesThrowsException() throws Exception { - databaseWriter.savePartOfDatabase(bibtexContext, Collections.emptyList(), null); + assertThrows(NullPointerException.class, () -> databaseWriter.savePartOfDatabase(bibtexContext, Collections.emptyList(), null)); } @Test diff --git a/src/test/java/org/jabref/logic/exporter/FieldFormatterCleanupsTest.java b/src/test/java/org/jabref/logic/exporter/FieldFormatterCleanupsTest.java index e8b2bf37613..ae6a864d198 100644 --- a/src/test/java/org/jabref/logic/exporter/FieldFormatterCleanupsTest.java +++ b/src/test/java/org/jabref/logic/exporter/FieldFormatterCleanupsTest.java @@ -15,17 +15,17 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.BibtexEntryTypes; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class FieldFormatterCleanupsTest { private BibEntry entry; - @Before + @BeforeEach public void setUp() { entry = new BibEntry(); entry.setType(BibtexEntryTypes.INPROCEEDINGS); diff --git a/src/test/java/org/jabref/logic/exporter/GroupSerializerTest.java b/src/test/java/org/jabref/logic/exporter/GroupSerializerTest.java index 4c587bf0dcb..92549163859 100644 --- a/src/test/java/org/jabref/logic/exporter/GroupSerializerTest.java +++ b/src/test/java/org/jabref/logic/exporter/GroupSerializerTest.java @@ -24,16 +24,16 @@ import org.jabref.model.groups.WordKeywordGroup; import org.jabref.model.util.DummyFileUpdateMonitor; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class GroupSerializerTest { private GroupSerializer groupSerializer; - @Before + @BeforeEach public void setUp() throws Exception { groupSerializer = new GroupSerializer(); } diff --git a/src/test/java/org/jabref/logic/exporter/MetaDataSerializerTest.java b/src/test/java/org/jabref/logic/exporter/MetaDataSerializerTest.java index 92c94d57c6a..df8e04b0bf5 100644 --- a/src/test/java/org/jabref/logic/exporter/MetaDataSerializerTest.java +++ b/src/test/java/org/jabref/logic/exporter/MetaDataSerializerTest.java @@ -14,17 +14,17 @@ import org.jabref.model.metadata.ContentSelector; import org.jabref.model.metadata.MetaData; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class MetaDataSerializerTest { private MetaData metaData; private GlobalBibtexKeyPattern pattern; - @Before + @BeforeEach public void setUp() { metaData = new MetaData(); pattern = GlobalBibtexKeyPattern.fromPattern("[auth][year]"); diff --git a/src/test/java/org/jabref/logic/formatter/FormatterTest.java b/src/test/java/org/jabref/logic/formatter/FormatterTest.java index 1fdc8231a35..ab811a2ecdb 100644 --- a/src/test/java/org/jabref/logic/formatter/FormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/FormatterTest.java @@ -1,8 +1,7 @@ package org.jabref.logic.formatter; -import java.util.Arrays; -import java.util.Collection; import java.util.Collections; +import java.util.stream.Stream; import org.jabref.logic.formatter.bibtexfields.ClearFormatter; import org.jabref.logic.formatter.bibtexfields.HtmlToLatexFormatter; @@ -29,109 +28,114 @@ import org.jabref.logic.protectedterms.ProtectedTermsPreferences; import org.jabref.model.cleanup.Formatter; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; -@RunWith(Parameterized.class) public class FormatterTest { - public Formatter formatter; - public FormatterTest(Formatter formatter) { - this.formatter = formatter; - } + private static ProtectedTermsLoader protectedTermsLoader; - @BeforeClass + @BeforeAll public static void setUp() { - ProtectTermsFormatter - .setProtectedTermsLoader( - new ProtectedTermsLoader(new ProtectedTermsPreferences(ProtectedTermsLoader.getInternalLists(), - Collections.emptyList(), Collections.emptyList(), Collections.emptyList()))); + protectedTermsLoader = new ProtectedTermsLoader( + new ProtectedTermsPreferences(ProtectedTermsLoader.getInternalLists(), Collections.emptyList(), + Collections.emptyList(), Collections.emptyList())); + + } - @Test - public void getNameReturnsNotNull() { + @ParameterizedTest + @MethodSource("getFormatters") + public void getNameReturnsNotNull(Formatter formatter) { assertNotNull(formatter.getName()); } - @Test - public void getNameReturnsNotEmpty() { + @ParameterizedTest + @MethodSource("getFormatters") + public void getNameReturnsNotEmpty(Formatter formatter) { assertNotEquals("", formatter.getName()); } - @Test - public void getKeyReturnsNotNull() { + @ParameterizedTest + @MethodSource("getFormatters") + public void getKeyReturnsNotNull(Formatter formatter) { assertNotNull(formatter.getKey()); } - @Test - public void getKeyReturnsNotEmpty() { + @ParameterizedTest + @MethodSource("getFormatters") + public void getKeyReturnsNotEmpty(Formatter formatter) { assertNotEquals("", formatter.getKey()); } - @Test(expected = NullPointerException.class) - public void formatOfNullThrowsException() { - formatter.format(null); + @ParameterizedTest + @MethodSource("getFormatters") + public void formatOfNullThrowsException(Formatter formatter) { + assertThrows(NullPointerException.class, () -> formatter.format(null)); } - @Test - public void formatOfEmptyStringReturnsEmpty() { + @ParameterizedTest + @MethodSource("getFormatters") + public void formatOfEmptyStringReturnsEmpty(Formatter formatter) { assertEquals("", formatter.format("")); } - @Test - public void formatNotReturnsNull() { + @ParameterizedTest + @MethodSource("getFormatters") + public void formatNotReturnsNull(Formatter formatter) { assertNotNull(formatter.format("string")); } - @Test - public void getDescriptionAlwaysNonEmpty() { + @ParameterizedTest + @MethodSource("getFormatters") + public void getDescriptionAlwaysNonEmpty(Formatter formatter) { assertFalse(formatter.getDescription().isEmpty()); } - @Test - public void getExampleInputAlwaysNonEmpty() { + @ParameterizedTest + @MethodSource("getFormatters") + public void getExampleInputAlwaysNonEmpty(Formatter formatter) { assertFalse(formatter.getExampleInput().isEmpty()); } - @Parameterized.Parameters(name = "{index}: {0}") - public static Collection instancesToTest() { + public static Stream getFormatters() { // all classes implementing {@link net.sf.jabref.model.cleanup.Formatter} // sorted alphabetically // Alternative: Use reflection - https://github.com/ronmamo/reflections // @formatter:off - return Arrays.asList( - new Object[]{new CapitalizeFormatter()}, - new Object[]{new ClearFormatter()}, - new Object[]{new HtmlToLatexFormatter()}, - new Object[]{new HtmlToUnicodeFormatter()}, - new Object[]{new IdentityFormatter()}, - new Object[]{new LatexCleanupFormatter()}, - new Object[]{new LatexToUnicodeFormatter()}, - new Object[]{new LowerCaseFormatter()}, - new Object[]{new MinifyNameListFormatter()}, - new Object[]{new NormalizeDateFormatter()}, - new Object[]{new NormalizeMonthFormatter()}, - new Object[]{new NormalizeNamesFormatter()}, - new Object[]{new NormalizePagesFormatter()}, - new Object[]{new OrdinalsToSuperscriptFormatter()}, - new Object[]{new ProtectTermsFormatter()}, - new Object[]{new RegexFormatter()}, - new Object[]{new RemoveBracesFormatter()}, - new Object[]{new SentenceCaseFormatter()}, - new Object[]{new TitleCaseFormatter()}, - new Object[]{new UnicodeToLatexFormatter()}, - new Object[]{new UnitsToLatexFormatter()}, - new Object[]{new UpperCaseFormatter()} - ); + return Stream.of( + new CapitalizeFormatter(), + new ClearFormatter(), + new HtmlToLatexFormatter(), + new HtmlToUnicodeFormatter(), + new IdentityFormatter(), + new LatexCleanupFormatter(), + new LatexToUnicodeFormatter(), + new LowerCaseFormatter(), + new MinifyNameListFormatter(), + new NormalizeDateFormatter(), + new NormalizeMonthFormatter(), + new NormalizeNamesFormatter(), + new NormalizePagesFormatter(), + new OrdinalsToSuperscriptFormatter(), + new ProtectTermsFormatter(protectedTermsLoader), + new RegexFormatter(), + new RemoveBracesFormatter(), + new SentenceCaseFormatter(), + new TitleCaseFormatter(), + new UnicodeToLatexFormatter(), + new UnitsToLatexFormatter(), + new UpperCaseFormatter()); + // @formatter:on } } diff --git a/src/test/java/org/jabref/logic/formatter/IdentityFormatterTest.java b/src/test/java/org/jabref/logic/formatter/IdentityFormatterTest.java index 8cdf12fafab..8fb9eadf959 100644 --- a/src/test/java/org/jabref/logic/formatter/IdentityFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/IdentityFormatterTest.java @@ -1,9 +1,9 @@ package org.jabref.logic.formatter; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests in addition to the general tests from {@link org.jabref.logic.formatter.FormatterTest} @@ -12,7 +12,7 @@ public class IdentityFormatterTest { private IdentityFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new IdentityFormatter(); } diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/ClearFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/ClearFormatterTest.java index f93a2f2dda7..3c2fe1b9f67 100644 --- a/src/test/java/org/jabref/logic/formatter/bibtexfields/ClearFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/ClearFormatterTest.java @@ -1,19 +1,20 @@ package org.jabref.logic.formatter.bibtexfields; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Tests in addition to the general tests from {@link org.jabref.logic.formatter.FormatterTest} */ -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; public class ClearFormatterTest { private ClearFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new ClearFormatter(); } diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/EscapeUnderscoresFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/EscapeUnderscoresFormatterTest.java index 9b5ecd7bcd4..bfd2312ff87 100644 --- a/src/test/java/org/jabref/logic/formatter/bibtexfields/EscapeUnderscoresFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/EscapeUnderscoresFormatterTest.java @@ -1,16 +1,15 @@ package org.jabref.logic.formatter.bibtexfields; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class EscapeUnderscoresFormatterTest { - private EscapeUnderscoresFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new EscapeUnderscoresFormatter(); } diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/HtmlToLatexFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/HtmlToLatexFormatterTest.java index ee1889e03b8..b8b6ac22ec3 100644 --- a/src/test/java/org/jabref/logic/formatter/bibtexfields/HtmlToLatexFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/HtmlToLatexFormatterTest.java @@ -1,9 +1,9 @@ package org.jabref.logic.formatter.bibtexfields; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests in addition to the general tests from {@link org.jabref.logic.formatter.FormatterTest} @@ -12,7 +12,7 @@ public class HtmlToLatexFormatterTest { private HtmlToLatexFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new HtmlToLatexFormatter(); } diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/HtmlToUnicodeFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/HtmlToUnicodeFormatterTest.java index 524cac445c8..13ce11e3d05 100644 --- a/src/test/java/org/jabref/logic/formatter/bibtexfields/HtmlToUnicodeFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/HtmlToUnicodeFormatterTest.java @@ -1,15 +1,15 @@ package org.jabref.logic.formatter.bibtexfields; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class HtmlToUnicodeFormatterTest { private HtmlToUnicodeFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new HtmlToUnicodeFormatter(); } diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/LatexCleanupFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/LatexCleanupFormatterTest.java index f2821ff4431..4e24f6ccaa2 100644 --- a/src/test/java/org/jabref/logic/formatter/bibtexfields/LatexCleanupFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/LatexCleanupFormatterTest.java @@ -1,9 +1,9 @@ package org.jabref.logic.formatter.bibtexfields; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests in addition to the general tests from {@link org.jabref.logic.formatter.FormatterTest} @@ -12,7 +12,7 @@ public class LatexCleanupFormatterTest { private LatexCleanupFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new LatexCleanupFormatter(); } diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizeDateFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizeDateFormatterTest.java index 0f432d0408e..92ddc83ebf3 100644 --- a/src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizeDateFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizeDateFormatterTest.java @@ -1,8 +1,9 @@ package org.jabref.logic.formatter.bibtexfields; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests in addition to the general tests from {@link org.jabref.logic.formatter.FormatterTest} @@ -11,128 +12,128 @@ public class NormalizeDateFormatterTest { private NormalizeDateFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new NormalizeDateFormatter(); } @Test public void formatDateYYYYMM0D() { - Assert.assertEquals("2015-11-08", formatter.format("2015-11-08")); + assertEquals("2015-11-08", formatter.format("2015-11-08")); } @Test public void formatDateYYYYM0D() { - Assert.assertEquals("2015-01-08", formatter.format("2015-1-08")); + assertEquals("2015-01-08", formatter.format("2015-1-08")); } @Test public void formatDateYYYYMD() { - Assert.assertEquals("2015-01-08", formatter.format("2015-1-8")); + assertEquals("2015-01-08", formatter.format("2015-1-8")); } @Test public void formatDateYYYYMM() { - Assert.assertEquals("2015-11", formatter.format("2015-11")); + assertEquals("2015-11", formatter.format("2015-11")); } @Test public void formatDateYYYYM() { - Assert.assertEquals("2015-01", formatter.format("2015-1")); + assertEquals("2015-01", formatter.format("2015-1")); } @Test public void formatDateMMYY() { - Assert.assertEquals("2015-11", formatter.format("11/15")); + assertEquals("2015-11", formatter.format("11/15")); } @Test public void formatDateMYY() { - Assert.assertEquals("2015-01", formatter.format("1/15")); + assertEquals("2015-01", formatter.format("1/15")); } @Test public void formatDate0MYY() { - Assert.assertEquals("2015-01", formatter.format("01/15")); + assertEquals("2015-01", formatter.format("01/15")); } @Test public void formatDateMMYYYY() { - Assert.assertEquals("2015-11", formatter.format("11/2015")); + assertEquals("2015-11", formatter.format("11/2015")); } @Test public void formatDateMYYYY() { - Assert.assertEquals("2015-01", formatter.format("1/2015")); + assertEquals("2015-01", formatter.format("1/2015")); } @Test public void formatDate0MYYYY() { - Assert.assertEquals("2015-01", formatter.format("01/2015")); + assertEquals("2015-01", formatter.format("01/2015")); } @Test public void formatDateMMMDDCommaYYYY() { - Assert.assertEquals("2015-11-08", formatter.format("November 08, 2015")); + assertEquals("2015-11-08", formatter.format("November 08, 2015")); } @Test public void formatDateMMMDCommaYYYY() { - Assert.assertEquals("2015-11-08", formatter.format("November 8, 2015")); + assertEquals("2015-11-08", formatter.format("November 8, 2015")); } @Test public void formatDateMMMCommaYYYY() { - Assert.assertEquals("2015-11", formatter.format("November, 2015")); + assertEquals("2015-11", formatter.format("November, 2015")); } @Test public void formatDate0DdotMMdotYYYY() { - Assert.assertEquals("2015-11-08", formatter.format("08.11.2015")); + assertEquals("2015-11-08", formatter.format("08.11.2015")); } @Test public void formatDateDdotMMdotYYYY() { - Assert.assertEquals("2015-11-08", formatter.format("8.11.2015")); + assertEquals("2015-11-08", formatter.format("8.11.2015")); } @Test public void formatDateDDdotMMdotYYYY() { - Assert.assertEquals("2015-11-15", formatter.format("15.11.2015")); + assertEquals("2015-11-15", formatter.format("15.11.2015")); } @Test public void formatDate0Ddot0MdotYYYY() { - Assert.assertEquals("2015-01-08", formatter.format("08.01.2015")); + assertEquals("2015-01-08", formatter.format("08.01.2015")); } @Test public void formatDateDdot0MdotYYYY() { - Assert.assertEquals("2015-01-08", formatter.format("8.01.2015")); + assertEquals("2015-01-08", formatter.format("8.01.2015")); } @Test public void formatDateDDdot0MdotYYYY() { - Assert.assertEquals("2015-01-15", formatter.format("15.01.2015")); + assertEquals("2015-01-15", formatter.format("15.01.2015")); } @Test public void formatDate0DdotMdotYYYY() { - Assert.assertEquals("2015-01-08", formatter.format("08.1.2015")); + assertEquals("2015-01-08", formatter.format("08.1.2015")); } @Test public void formatDateDdotMdotYYYY() { - Assert.assertEquals("2015-01-08", formatter.format("8.1.2015")); + assertEquals("2015-01-08", formatter.format("8.1.2015")); } @Test public void formatDateDDdotMdotYYYY() { - Assert.assertEquals("2015-01-15", formatter.format("15.1.2015")); + assertEquals("2015-01-15", formatter.format("15.1.2015")); } @Test public void formatExample() { - Assert.assertEquals("2003-11-29", formatter.format(formatter.getExampleInput())); + assertEquals("2003-11-29", formatter.format(formatter.getExampleInput())); } } diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizeMonthFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizeMonthFormatterTest.java index 437aefa059a..c6253e15112 100644 --- a/src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizeMonthFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizeMonthFormatterTest.java @@ -1,8 +1,9 @@ package org.jabref.logic.formatter.bibtexfields; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests in addition to the general tests from {@link org.jabref.logic.formatter.FormatterTest} @@ -11,14 +12,14 @@ public class NormalizeMonthFormatterTest { private NormalizeMonthFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new NormalizeMonthFormatter(); } @Test public void formatExample() { - Assert.assertEquals("#dec#", formatter.format(formatter.getExampleInput())); + assertEquals("#dec#", formatter.format(formatter.getExampleInput())); } } diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizeNamesFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizeNamesFormatterTest.java index 05498b0b9d8..c2f74c4d560 100644 --- a/src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizeNamesFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizeNamesFormatterTest.java @@ -1,9 +1,9 @@ package org.jabref.logic.formatter.bibtexfields; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests in addition to the general tests from {@link org.jabref.logic.formatter.FormatterTest} @@ -12,7 +12,7 @@ public class NormalizeNamesFormatterTest { private NormalizeNamesFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new NormalizeNamesFormatter(); } diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizePagesFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizePagesFormatterTest.java index 0aeadd11251..77468ca156f 100644 --- a/src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizePagesFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizePagesFormatterTest.java @@ -1,8 +1,9 @@ package org.jabref.logic.formatter.bibtexfields; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests in addition to the general tests from {@link org.jabref.logic.formatter.FormatterTest} @@ -11,101 +12,101 @@ public class NormalizePagesFormatterTest { private NormalizePagesFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new NormalizePagesFormatter(); } @Test public void formatSinglePageResultsInNoChange() { - Assert.assertEquals("1", formatter.format("1")); + assertEquals("1", formatter.format("1")); } @Test public void formatPageNumbers() { - Assert.assertEquals("1--2", formatter.format("1-2")); + assertEquals("1--2", formatter.format("1-2")); } @Test public void formatPageNumbersCommaSeparated() { - Assert.assertEquals("1,2,3", formatter.format("1,2,3")); + assertEquals("1,2,3", formatter.format("1,2,3")); } @Test public void formatPageNumbersPlusRange() { - Assert.assertEquals("43+", formatter.format("43+")); + assertEquals("43+", formatter.format("43+")); } @Test public void ignoreWhitespaceInPageNumbers() { - Assert.assertEquals("1--2", formatter.format(" 1 - 2 ")); + assertEquals("1--2", formatter.format(" 1 - 2 ")); } @Test public void removeWhitespaceSinglePage() { - Assert.assertEquals("1", formatter.format(" 1 ")); + assertEquals("1", formatter.format(" 1 ")); } @Test public void removeWhitespacePageRange() { - Assert.assertEquals("1--2", formatter.format(" 1 -- 2 ")); + assertEquals("1--2", formatter.format(" 1 -- 2 ")); } @Test public void ignoreWhitespaceInPageNumbersWithDoubleDash() { - Assert.assertEquals("43--103", formatter.format("43 -- 103")); + assertEquals("43--103", formatter.format("43 -- 103")); } @Test public void keepCorrectlyFormattedPageNumbers() { - Assert.assertEquals("1--2", formatter.format("1--2")); + assertEquals("1--2", formatter.format("1--2")); } @Test public void formatPageNumbersRemoveUnexpectedLiterals() { - Assert.assertEquals("1--2", formatter.format("{1}-{2}")); + assertEquals("1--2", formatter.format("{1}-{2}")); } @Test public void formatPageNumbersRegexNotMatching() { - Assert.assertEquals("12", formatter.format("12")); + assertEquals("12", formatter.format("12")); } @Test public void doNotRemoveLetters() { - Assert.assertEquals("R1-R50", formatter.format("R1-R50")); + assertEquals("R1-R50", formatter.format("R1-R50")); } @Test public void replaceLongDashWithDoubleDash() { - Assert.assertEquals("1--50", formatter.format("1 \u2014 50")); + assertEquals("1--50", formatter.format("1 \u2014 50")); } @Test public void removePagePrefix() { - Assert.assertEquals("50", formatter.format("p.50")); + assertEquals("50", formatter.format("p.50")); } @Test public void removePagesPrefix() { - Assert.assertEquals("50", formatter.format("pp.50")); + assertEquals("50", formatter.format("pp.50")); } @Test public void formatACMPages() { // This appears in https://doi.org/10.1145/1658373.1658375 - Assert.assertEquals("2:1--2:33", formatter.format("2:1-2:33")); + assertEquals("2:1--2:33", formatter.format("2:1-2:33")); } @Test public void keepFormattedACMPages() { // This appears in https://doi.org/10.1145/1658373.1658375 - Assert.assertEquals("2:1--2:33", formatter.format("2:1--2:33")); + assertEquals("2:1--2:33", formatter.format("2:1--2:33")); } @Test public void formatExample() { - Assert.assertEquals("1--2", formatter.format(formatter.getExampleInput())); + assertEquals("1--2", formatter.format(formatter.getExampleInput())); } } diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/OrdinalsToSuperscriptFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/OrdinalsToSuperscriptFormatterTest.java index 134dfa6885c..6fffcf6ee30 100644 --- a/src/test/java/org/jabref/logic/formatter/bibtexfields/OrdinalsToSuperscriptFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/OrdinalsToSuperscriptFormatterTest.java @@ -1,9 +1,9 @@ package org.jabref.logic.formatter.bibtexfields; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests in addition to the general tests from {@link org.jabref.logic.formatter.FormatterTest} @@ -12,7 +12,7 @@ public class OrdinalsToSuperscriptFormatterTest { private OrdinalsToSuperscriptFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new OrdinalsToSuperscriptFormatter(); } diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/RegexFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/RegexFormatterTest.java index 4c85a519f90..a01e31f1bdc 100644 --- a/src/test/java/org/jabref/logic/formatter/bibtexfields/RegexFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/RegexFormatterTest.java @@ -1,8 +1,9 @@ package org.jabref.logic.formatter.bibtexfields; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests in addition to the general tests from {@link org.jabref.logic.formatter.FormatterTest} @@ -11,7 +12,7 @@ public class RegexFormatterTest { private RegexFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new RegexFormatter(); } @@ -20,47 +21,47 @@ public void setUp() { public void spacesReplacedCorrectly() { String regexInput = "(\" \",\"-\")"; formatter.setRegex(regexInput); - Assert.assertEquals("replace-all-spaces", formatter.format("replace all spaces")); + assertEquals("replace-all-spaces", formatter.format("replace all spaces")); } @Test public void protectedSpacesNotReplacedInSingleProtectedBlock() { String regexInput = "(\" \",\"-\")"; formatter.setRegex(regexInput); - Assert.assertEquals("replace-spaces-{not these ones}", formatter.format("replace spaces {not these ones}")); + assertEquals("replace-spaces-{not these ones}", formatter.format("replace spaces {not these ones}")); } @Test public void protectedSpacesNotReplacedInTwoProtectedBlocks() { String regexInput = "(\" \",\"-\")"; formatter.setRegex(regexInput); - Assert.assertEquals("replace-spaces-{not these ones}-{or these ones}-but-these-ones", formatter.format("replace spaces {not these ones} {or these ones} but these ones")); + assertEquals("replace-spaces-{not these ones}-{or these ones}-but-these-ones", formatter.format("replace spaces {not these ones} {or these ones} but these ones")); } @Test public void escapedBracesAreNotReplaced() { String regexInput = "(\" \",\"-\")"; formatter.setRegex(regexInput); - Assert.assertEquals("replace-spaces-\\{-these-ones\\}-and-these-ones", formatter.format("replace spaces \\{ these ones\\} and these ones")); + assertEquals("replace-spaces-\\{-these-ones\\}-and-these-ones", formatter.format("replace spaces \\{ these ones\\} and these ones")); } @Test public void escapedBracesAreNotReplacedInTwoCases() { String regexInput = "(\" \",\"-\")"; formatter.setRegex(regexInput); - Assert.assertEquals("replace-spaces-\\{-these-ones\\},-these-ones,-and-\\{-these-ones\\}", formatter.format("replace spaces \\{ these ones\\}, these ones, and \\{ these ones\\}")); + assertEquals("replace-spaces-\\{-these-ones\\},-these-ones,-and-\\{-these-ones\\}", formatter.format("replace spaces \\{ these ones\\}, these ones, and \\{ these ones\\}")); } @Test public void escapedBracesAreNotReplacedAndProtectionStillWorks() { String regexInput = "(\" \",\"-\")"; - formatter.setRegex(regexInput); - Assert.assertEquals("replace-spaces-{not these ones},-these-ones,-and-\\{-these-ones\\}", formatter.format("replace spaces {not these ones}, these ones, and \\{ these ones\\}")); + assertEquals("replace-spaces-{not these ones},-these-ones,-and-\\{-these-ones\\}", formatter.format("replace spaces {not these ones}, these ones, and \\{ these ones\\}")); } @Test public void formatExample() { - Assert.assertEquals("Please-replace-the-spaces", formatter.format(formatter.getExampleInput())); + assertEquals("Please-replace-the-spaces", formatter.format(formatter.getExampleInput())); } + } diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatterTest.java index d5f6b68234e..7ffb7179bd5 100644 --- a/src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatterTest.java @@ -1,10 +1,9 @@ package org.jabref.logic.formatter.bibtexfields; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests in addition to the general tests from {@link org.jabref.logic.formatter.FormatterTest} @@ -13,7 +12,7 @@ public class RemoveBracesFormatterTest { private RemoveBracesFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new RemoveBracesFormatter(); } diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveHyphenatedNewlinesFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveHyphenatedNewlinesFormatterTest.java index e34551ae971..207dc06b38b 100644 --- a/src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveHyphenatedNewlinesFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveHyphenatedNewlinesFormatterTest.java @@ -1,14 +1,14 @@ package org.jabref.logic.formatter.bibtexfields; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class RemoveHyphenatedNewlinesFormatterTest { private RemoveHyphenatedNewlinesFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new RemoveHyphenatedNewlinesFormatter(); } diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveNewlinesFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveNewlinesFormatterTest.java index bc7cfa8210e..96de03b1456 100644 --- a/src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveNewlinesFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/RemoveNewlinesFormatterTest.java @@ -1,14 +1,16 @@ + package org.jabref.logic.formatter.bibtexfields; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class RemoveNewlinesFormatterTest { + private RemoveNewlinesFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new RemoveNewlinesFormatter(); } diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/UnicodeConverterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/UnicodeConverterTest.java index 0c4c61facf1..fe4d723ad06 100644 --- a/src/test/java/org/jabref/logic/formatter/bibtexfields/UnicodeConverterTest.java +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/UnicodeConverterTest.java @@ -1,10 +1,9 @@ package org.jabref.logic.formatter.bibtexfields; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests in addition to the general tests from {@link org.jabref.logic.formatter.FormatterTest} @@ -13,7 +12,7 @@ public class UnicodeConverterTest { private UnicodeToLatexFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new UnicodeToLatexFormatter(); } diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/UnicodeToLatexFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/UnicodeToLatexFormatterTest.java index e065361128f..f4e279158d3 100644 --- a/src/test/java/org/jabref/logic/formatter/bibtexfields/UnicodeToLatexFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/UnicodeToLatexFormatterTest.java @@ -1,9 +1,9 @@ package org.jabref.logic.formatter.bibtexfields; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests in addition to the general tests from {@link org.jabref.logic.formatter.FormatterTest} @@ -12,7 +12,7 @@ public class UnicodeToLatexFormatterTest { private UnicodeToLatexFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new UnicodeToLatexFormatter(); } diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatterTest.java index 07dfb2c5485..43d1338831a 100644 --- a/src/test/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatterTest.java @@ -1,10 +1,9 @@ package org.jabref.logic.formatter.bibtexfields; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests in addition to the general tests from {@link org.jabref.logic.formatter.FormatterTest} @@ -13,7 +12,7 @@ public class UnitsToLatexFormatterTest { private UnitsToLatexFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new UnitsToLatexFormatter(); } diff --git a/src/test/java/org/jabref/logic/formatter/casechanger/CapitalizeFormatterTest.java b/src/test/java/org/jabref/logic/formatter/casechanger/CapitalizeFormatterTest.java index 04129f6259b..437f42b096a 100644 --- a/src/test/java/org/jabref/logic/formatter/casechanger/CapitalizeFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/casechanger/CapitalizeFormatterTest.java @@ -1,8 +1,9 @@ package org.jabref.logic.formatter.casechanger; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests in addition to the general tests from {@link org.jabref.logic.formatter.FormatterTest} @@ -11,21 +12,21 @@ public class CapitalizeFormatterTest { private CapitalizeFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new CapitalizeFormatter(); } @Test public void test() { - Assert.assertEquals("Upper Each First", formatter.format("upper each First")); - Assert.assertEquals("Upper Each First {NOT} {this}", formatter.format("upper each first {NOT} {this}")); - Assert.assertEquals("Upper Each First {N}ot {t}his", formatter.format("upper each first {N}OT {t}his")); + assertEquals("Upper Each First", formatter.format("upper each First")); + assertEquals("Upper Each First {NOT} {this}", formatter.format("upper each first {NOT} {this}")); + assertEquals("Upper Each First {N}ot {t}his", formatter.format("upper each first {N}OT {t}his")); } @Test public void formatExample() { - Assert.assertEquals("I Have {a} Dream", formatter.format(formatter.getExampleInput())); + assertEquals("I Have {a} Dream", formatter.format(formatter.getExampleInput())); } } diff --git a/src/test/java/org/jabref/logic/formatter/casechanger/LowerCaseFormatterTest.java b/src/test/java/org/jabref/logic/formatter/casechanger/LowerCaseFormatterTest.java index 6ed971cf0ab..abc194048c6 100644 --- a/src/test/java/org/jabref/logic/formatter/casechanger/LowerCaseFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/casechanger/LowerCaseFormatterTest.java @@ -1,8 +1,9 @@ package org.jabref.logic.formatter.casechanger; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests in addition to the general tests from {@link org.jabref.logic.formatter.FormatterTest} @@ -11,21 +12,21 @@ public class LowerCaseFormatterTest { private LowerCaseFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new LowerCaseFormatter(); } @Test public void test() { - Assert.assertEquals("lower", formatter.format("LOWER")); - Assert.assertEquals("lower {UPPER}", formatter.format("LOWER {UPPER}")); - Assert.assertEquals("lower {U}pper", formatter.format("LOWER {U}PPER")); + assertEquals("lower", formatter.format("LOWER")); + assertEquals("lower {UPPER}", formatter.format("LOWER {UPPER}")); + assertEquals("lower {U}pper", formatter.format("LOWER {U}PPER")); } @Test public void formatExample() { - Assert.assertEquals("kde {Amarok}", formatter.format(formatter.getExampleInput())); + assertEquals("kde {Amarok}", formatter.format(formatter.getExampleInput())); } } diff --git a/src/test/java/org/jabref/logic/formatter/casechanger/ProtectTermsFormatterTest.java b/src/test/java/org/jabref/logic/formatter/casechanger/ProtectTermsFormatterTest.java index c2cca494c04..c6fcb1fafd7 100644 --- a/src/test/java/org/jabref/logic/formatter/casechanger/ProtectTermsFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/casechanger/ProtectTermsFormatterTest.java @@ -5,11 +5,10 @@ import org.jabref.logic.protectedterms.ProtectedTermsLoader; import org.jabref.logic.protectedterms.ProtectedTermsPreferences; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests in addition to the general tests from {@link org.jabref.logic.formatter.FormatterTest} @@ -18,7 +17,7 @@ public class ProtectTermsFormatterTest { private ProtectTermsFormatter formatter; - @Before + @BeforeEach public void setUp() { ProtectTermsFormatter .setProtectedTermsLoader( diff --git a/src/test/java/org/jabref/logic/formatter/casechanger/SentenceCaseFormatterTest.java b/src/test/java/org/jabref/logic/formatter/casechanger/SentenceCaseFormatterTest.java index 63fcdde8835..9e03374df67 100644 --- a/src/test/java/org/jabref/logic/formatter/casechanger/SentenceCaseFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/casechanger/SentenceCaseFormatterTest.java @@ -1,9 +1,9 @@ package org.jabref.logic.formatter.casechanger; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests in addition to the general tests from {@link org.jabref.logic.formatter.FormatterTest} @@ -12,22 +12,22 @@ public class SentenceCaseFormatterTest { private SentenceCaseFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new SentenceCaseFormatter(); } @Test public void test() { - Assert.assertEquals("Upper first", formatter.format("upper First")); - Assert.assertEquals("Upper first", formatter.format("uPPER FIRST")); - Assert.assertEquals("Upper {NOT} first", formatter.format("upper {NOT} FIRST")); - Assert.assertEquals("Upper {N}ot first", formatter.format("upper {N}OT FIRST")); + assertEquals("Upper first", formatter.format("upper First")); + assertEquals("Upper first", formatter.format("uPPER FIRST")); + assertEquals("Upper {NOT} first", formatter.format("upper {NOT} FIRST")); + assertEquals("Upper {N}ot first", formatter.format("upper {N}OT FIRST")); } @Test public void formatExample() { - Assert.assertEquals("I have {Aa} dream", formatter.format(formatter.getExampleInput())); + assertEquals("I have {Aa} dream", formatter.format(formatter.getExampleInput())); } } diff --git a/src/test/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatterTest.java b/src/test/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatterTest.java index 1050757c216..faccd196267 100644 --- a/src/test/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatterTest.java @@ -1,8 +1,9 @@ package org.jabref.logic.formatter.casechanger; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests in addition to the general tests from {@link org.jabref.logic.formatter.FormatterTest} @@ -11,77 +12,77 @@ public class TitleCaseFormatterTest { private TitleCaseFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new TitleCaseFormatter(); } @Test public void eachFirstLetterIsUppercased() { - Assert.assertEquals("Upper Each First", formatter.format("upper each first")); + assertEquals("Upper Each First", formatter.format("upper each first")); } @Test public void eachFirstLetterIsUppercasedAndOthersLowercased() { - Assert.assertEquals("Upper Each First", formatter.format("upper eACH first")); + assertEquals("Upper Each First", formatter.format("upper eACH first")); } @Test public void eachFirstLetterIsUppercasedAndATralingAndIsAlsoUppercased() { - Assert.assertEquals("An Upper Each First And", formatter.format("an upper each first and")); + assertEquals("An Upper Each First And", formatter.format("an upper each first and")); } @Test public void eachFirstLetterIsUppercasedAndATralingAndIsAlsoCorrectlyCased() { - Assert.assertEquals("An Upper Each First And", formatter.format("an upper each first AND")); + assertEquals("An Upper Each First And", formatter.format("an upper each first AND")); } @Test - public void eachFirstLetterIsUppercasedButIntermediateAndsAreKeptLowercase(){ - Assert.assertEquals("An Upper Each of the and First And", + public void eachFirstLetterIsUppercasedButIntermediateAndsAreKeptLowercase() { + assertEquals("An Upper Each of the and First And", formatter.format("an upper each of the and first and")); } @Test - public void eachFirstLetterIsUppercasedButIntermediateAndsArePutLowercase(){ - Assert.assertEquals("An Upper Each of the and First And", + public void eachFirstLetterIsUppercasedButIntermediateAndsArePutLowercase() { + assertEquals("An Upper Each of the and First And", formatter.format("an upper each of the AND first and")); } @Test public void theAfterColonGetsCapitalized() { - Assert.assertEquals("An Upper Each of: The and First And", + assertEquals("An Upper Each of: The and First And", formatter.format("an upper each of: the and first and")); } @Test public void completeWordsInCurlyBracketsIsLeftUnchanged() { - Assert.assertEquals("An Upper First with and without {CURLY} {brackets}", + assertEquals("An Upper First with and without {CURLY} {brackets}", formatter.format("AN UPPER FIRST WITH AND WITHOUT {CURLY} {brackets}")); } @Test public void lettersInCurlyBracketsIsLeftUnchanged() { - Assert.assertEquals("An Upper First with {A}nd without {C}urly {b}rackets", + assertEquals("An Upper First with {A}nd without {C}urly {b}rackets", formatter.format("AN UPPER FIRST WITH {A}ND WITHOUT {C}URLY {b}rackets")); } @Test public void intraWordLettersInCurlyBracketsIsLeftUnchanged() { - Assert.assertEquals("{b}rackets {b}rac{K}ets Brack{E}ts", + assertEquals("{b}rackets {b}rac{K}ets Brack{E}ts", formatter.format("{b}RaCKeTS {b}RaC{K}eTS bRaCK{E}ts")); } @Test public void testTwoExperiencesTitle() { - Assert.assertEquals( - "Two Experiences Designing for Effective Security", - formatter.format("Two experiences designing for effective security")); + assertEquals( + "Two Experiences Designing for Effective Security", + formatter.format("Two experiences designing for effective security")); } @Test public void formatExample() { - Assert.assertEquals("{BPMN} Conformance in Open Source Engines", formatter.format(formatter.getExampleInput())); + assertEquals("{BPMN} Conformance in Open Source Engines", formatter.format(formatter.getExampleInput())); } } diff --git a/src/test/java/org/jabref/logic/formatter/casechanger/UpperCaseFormatterTest.java b/src/test/java/org/jabref/logic/formatter/casechanger/UpperCaseFormatterTest.java index ae247d1cab2..fd1a2aa2b7a 100644 --- a/src/test/java/org/jabref/logic/formatter/casechanger/UpperCaseFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/casechanger/UpperCaseFormatterTest.java @@ -1,8 +1,9 @@ package org.jabref.logic.formatter.casechanger; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** @@ -12,22 +13,22 @@ public class UpperCaseFormatterTest { private UpperCaseFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new UpperCaseFormatter(); } @Test public void test() { - Assert.assertEquals("LOWER", formatter.format("LOWER")); - Assert.assertEquals("UPPER", formatter.format("upper")); - Assert.assertEquals("UPPER", formatter.format("UPPER")); - Assert.assertEquals("UPPER {lower}", formatter.format("upper {lower}")); - Assert.assertEquals("UPPER {l}OWER", formatter.format("upper {l}ower")); + assertEquals("LOWER", formatter.format("LOWER")); + assertEquals("UPPER", formatter.format("upper")); + assertEquals("UPPER", formatter.format("UPPER")); + assertEquals("UPPER {lower}", formatter.format("upper {lower}")); + assertEquals("UPPER {l}OWER", formatter.format("upper {l}ower")); } @Test public void formatExample() { - Assert.assertEquals("KDE {Amarok}", formatter.format(formatter.getExampleInput())); + assertEquals("KDE {Amarok}", formatter.format(formatter.getExampleInput())); } } diff --git a/src/test/java/org/jabref/logic/formatter/minifier/MinifyNameListFormatterTest.java b/src/test/java/org/jabref/logic/formatter/minifier/MinifyNameListFormatterTest.java index ed26c55aa15..99a3146e3ed 100644 --- a/src/test/java/org/jabref/logic/formatter/minifier/MinifyNameListFormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/minifier/MinifyNameListFormatterTest.java @@ -1,8 +1,10 @@ package org.jabref.logic.formatter.minifier; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests in addition to the general tests from {@link org.jabref.logic.formatter.FormatterTest} @@ -11,7 +13,7 @@ public class MinifyNameListFormatterTest { private MinifyNameListFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new MinifyNameListFormatter(); } @@ -31,6 +33,6 @@ public void formatExample() { } private void expectCorrect(String input, String expected) { - Assert.assertEquals(expected, formatter.format(input)); + assertEquals(expected, formatter.format(input)); } } diff --git a/src/test/java/org/jabref/logic/help/HelpFileTest.java b/src/test/java/org/jabref/logic/help/HelpFileTest.java index e8ee9424478..0b97be002e1 100644 --- a/src/test/java/org/jabref/logic/help/HelpFileTest.java +++ b/src/test/java/org/jabref/logic/help/HelpFileTest.java @@ -6,12 +6,14 @@ import org.jabref.logic.net.URLDownload; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static junit.framework.TestCase.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class HelpFileTest { + private final String jabrefHelp = "https://help.jabref.org/en/"; + @Test public void referToValidPage() throws IOException { for (HelpFile help : HelpFile.values()) { diff --git a/src/test/java/org/jabref/logic/importer/BibDatabaseTestsWithFiles.java b/src/test/java/org/jabref/logic/importer/BibDatabaseTestsWithFiles.java index 8e39ab16e3e..f8317b118c6 100644 --- a/src/test/java/org/jabref/logic/importer/BibDatabaseTestsWithFiles.java +++ b/src/test/java/org/jabref/logic/importer/BibDatabaseTestsWithFiles.java @@ -9,18 +9,18 @@ import org.jabref.model.database.BibDatabase; import org.jabref.model.util.DummyFileUpdateMonitor; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Answers; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; public class BibDatabaseTestsWithFiles { private ImportFormatPreferences importFormatPreferences; - @Before + @BeforeEach public void setUp() { importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); } diff --git a/src/test/java/org/jabref/logic/importer/DatabaseFileLookupTest.java b/src/test/java/org/jabref/logic/importer/DatabaseFileLookupTest.java index f7ac12347f3..999123b752e 100644 --- a/src/test/java/org/jabref/logic/importer/DatabaseFileLookupTest.java +++ b/src/test/java/org/jabref/logic/importer/DatabaseFileLookupTest.java @@ -10,11 +10,12 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.util.DummyFileUpdateMonitor; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +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.assertNotNull; import static org.mockito.Mockito.mock; /** @@ -30,7 +31,7 @@ public class DatabaseFileLookupTest { private BibEntry entry2; - @Before + @BeforeEach public void setUp() throws Exception { try (FileInputStream stream = new FileInputStream(ImportDataTest.UNLINKED_FILES_TEST_BIB); InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) { @@ -48,10 +49,10 @@ public void setUp() throws Exception { */ @Test public void testTestDatabase() { - Assert.assertEquals(2, database.getEntryCount()); - Assert.assertEquals(2, entries.size()); - Assert.assertNotNull(entry1); - Assert.assertNotNull(entry2); + assertEquals(2, database.getEntryCount()); + assertEquals(2, entries.size()); + assertNotNull(entry1); + assertNotNull(entry2); } } diff --git a/src/test/java/org/jabref/logic/importer/ImportDataTest.java b/src/test/java/org/jabref/logic/importer/ImportDataTest.java index 53cbda75a65..a106633c567 100644 --- a/src/test/java/org/jabref/logic/importer/ImportDataTest.java +++ b/src/test/java/org/jabref/logic/importer/ImportDataTest.java @@ -3,8 +3,10 @@ import java.io.File; import java.nio.file.Paths; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Nosh&Dan @@ -32,20 +34,20 @@ public class ImportDataTest { @Test public void testTestingEnvironment() { - Assert.assertTrue(ImportDataTest.EXISTING_FOLDER.exists()); - Assert.assertTrue(ImportDataTest.EXISTING_FOLDER.isDirectory()); + assertTrue(ImportDataTest.EXISTING_FOLDER.exists()); + assertTrue(ImportDataTest.EXISTING_FOLDER.isDirectory()); - Assert.assertTrue(ImportDataTest.FILE_IN_DATABASE.exists()); - Assert.assertTrue(ImportDataTest.FILE_IN_DATABASE.isFile()); + assertTrue(ImportDataTest.FILE_IN_DATABASE.exists()); + assertTrue(ImportDataTest.FILE_IN_DATABASE.isFile()); - Assert.assertTrue(ImportDataTest.FILE_NOT_IN_DATABASE.exists()); - Assert.assertTrue(ImportDataTest.FILE_NOT_IN_DATABASE.isFile()); + assertTrue(ImportDataTest.FILE_NOT_IN_DATABASE.exists()); + assertTrue(ImportDataTest.FILE_NOT_IN_DATABASE.isFile()); } @Test public void testOpenNotExistingDirectory() { - Assert.assertFalse(ImportDataTest.NOT_EXISTING_FOLDER.exists()); - Assert.assertFalse(ImportDataTest.NOT_EXISTING_PDF.exists()); + assertFalse(ImportDataTest.NOT_EXISTING_FOLDER.exists()); + assertFalse(ImportDataTest.NOT_EXISTING_PDF.exists()); } } diff --git a/src/test/java/org/jabref/logic/importer/ImportFormatReaderTestParameterless.java b/src/test/java/org/jabref/logic/importer/ImportFormatReaderTestParameterless.java index 4aeb558d48b..8214133dbcd 100644 --- a/src/test/java/org/jabref/logic/importer/ImportFormatReaderTestParameterless.java +++ b/src/test/java/org/jabref/logic/importer/ImportFormatReaderTestParameterless.java @@ -8,20 +8,20 @@ import org.jabref.model.util.DummyFileUpdateMonitor; import org.jabref.model.util.FileUpdateMonitor; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Answers; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; public class ImportFormatReaderTestParameterless { private ImportFormatReader reader; - private FileUpdateMonitor fileMonitor = new DummyFileUpdateMonitor(); + private final FileUpdateMonitor fileMonitor = new DummyFileUpdateMonitor(); - @Before + @BeforeEach public void setUp() { reader = new ImportFormatReader(); ImportFormatPreferences importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); @@ -29,29 +29,27 @@ public void setUp() { reader.resetImportFormats(importFormatPreferences, mock(XMPPreferences.class), fileMonitor); } - @Test(expected = ImportException.class) + @Test public void importUnknownFormatThrowsExceptionIfNoMatchingImporterWasFound() throws Exception { Path file = Paths.get(ImportFormatReaderTestParameterless.class.getResource("fileformat/emptyFile.xml").toURI()); - reader.importUnknownFormat(file, fileMonitor); - fail(); + assertThrows(NullPointerException.class, () -> reader.importUnknownFormat(file, fileMonitor)); } - @Test(expected = NullPointerException.class) + @Test public void testNullImportUnknownFormatPath() throws Exception { - reader.importUnknownFormat(null, fileMonitor); - fail(); + assertThrows(NullPointerException.class, () -> reader.importUnknownFormat(null, fileMonitor)); + } - @Test(expected = NullPointerException.class) + @Test public void testNullImportUnknownFormatString() throws Exception { - reader.importUnknownFormat(null); - fail(); + assertThrows(NullPointerException.class, () -> reader.importUnknownFormat(null)); + } - @Test(expected = ImportException.class) + @Test public void importFromFileWithUnknownFormatThrowsException() throws Exception { - reader.importFromFile("someunknownformat", Paths.get("somepath")); - fail(); + assertThrows(NullPointerException.class, () -> reader.importFromFile("someunknownformat", Paths.get("somepath"))); } } diff --git a/src/test/java/org/jabref/logic/importer/OpenDatabaseTest.java b/src/test/java/org/jabref/logic/importer/OpenDatabaseTest.java index b5c657c12cb..47ca7b116dc 100644 --- a/src/test/java/org/jabref/logic/importer/OpenDatabaseTest.java +++ b/src/test/java/org/jabref/logic/importer/OpenDatabaseTest.java @@ -14,11 +14,11 @@ import org.jabref.model.util.DummyFileUpdateMonitor; import org.jabref.model.util.FileUpdateMonitor; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +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; import static org.mockito.Mockito.when; @@ -31,7 +31,7 @@ public class OpenDatabaseTest { private final File bibHeader; private final File bibHeaderAndSignature; private final File bibEncodingWithoutNewline; - private FileUpdateMonitor fileMonitor = new DummyFileUpdateMonitor(); + private final FileUpdateMonitor fileMonitor = new DummyFileUpdateMonitor(); public OpenDatabaseTest() throws URISyntaxException { bibNoHeader = Paths.get(OpenDatabaseTest.class.getResource("headerless.bib").toURI()).toFile(); @@ -43,7 +43,7 @@ public OpenDatabaseTest() throws URISyntaxException { .get(OpenDatabaseTest.class.getResource("encodingWithoutNewline.bib").toURI()).toFile(); } - @Before + @BeforeEach public void setUp() { importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); when(importFormatPreferences.getEncoding()).thenReturn(StandardCharsets.UTF_8); @@ -52,27 +52,27 @@ public void setUp() { @Test public void useFallbackEncodingIfNoHeader() throws IOException { ParserResult result = OpenDatabase.loadDatabase(bibNoHeader, importFormatPreferences, fileMonitor); - Assert.assertEquals(defaultEncoding, result.getMetaData().getEncoding().get()); + assertEquals(defaultEncoding, result.getMetaData().getEncoding().get()); } @Test public void useFallbackEncodingIfUnknownHeader() throws IOException { ParserResult result = OpenDatabase.loadDatabase(bibWrongHeader, importFormatPreferences, fileMonitor); - Assert.assertEquals(defaultEncoding, result.getMetaData().getEncoding().get()); + assertEquals(defaultEncoding, result.getMetaData().getEncoding().get()); } @Test public void useSpecifiedEncoding() throws IOException { ParserResult result = OpenDatabase.loadDatabase(bibHeader, importFormatPreferences.withEncoding(StandardCharsets.US_ASCII), fileMonitor); - Assert.assertEquals(defaultEncoding, result.getMetaData().getEncoding().get()); + assertEquals(defaultEncoding, result.getMetaData().getEncoding().get()); } @Test public void useSpecifiedEncodingWithSignature() throws IOException { ParserResult result = OpenDatabase.loadDatabase(bibHeaderAndSignature, importFormatPreferences.withEncoding(StandardCharsets.US_ASCII), fileMonitor); - Assert.assertEquals(defaultEncoding, result.getMetaData().getEncoding().get()); + assertEquals(defaultEncoding, result.getMetaData().getEncoding().get()); } @Test @@ -81,8 +81,8 @@ public void entriesAreParsedNoHeader() throws IOException { BibDatabase db = result.getDatabase(); // Entry - Assert.assertEquals(1, db.getEntryCount()); - Assert.assertEquals(Optional.of("2014"), db.getEntryByKey("1").get().getField("year")); + assertEquals(1, db.getEntryCount()); + assertEquals(Optional.of("2014"), db.getEntryByKey("1").get().getField("year")); } @Test @@ -91,8 +91,8 @@ public void entriesAreParsedHeader() throws IOException { BibDatabase db = result.getDatabase(); // Entry - Assert.assertEquals(1, db.getEntryCount()); - Assert.assertEquals(Optional.of("2014"), db.getEntryByKey("1").get().getField("year")); + assertEquals(1, db.getEntryCount()); + assertEquals(Optional.of("2014"), db.getEntryByKey("1").get().getField("year")); } @Test @@ -101,8 +101,8 @@ public void entriesAreParsedHeaderAndSignature() throws IOException { BibDatabase db = result.getDatabase(); // Entry - Assert.assertEquals(1, db.getEntryCount()); - Assert.assertEquals(Optional.of("2014"), db.getEntryByKey("1").get().getField("year")); + assertEquals(1, db.getEntryCount()); + assertEquals(Optional.of("2014"), db.getEntryByKey("1").get().getField("year")); } /** @@ -111,15 +111,15 @@ public void entriesAreParsedHeaderAndSignature() throws IOException { @Test public void correctlyParseEncodingWithoutNewline() throws IOException { ParserResult result = OpenDatabase.loadDatabase(bibEncodingWithoutNewline, importFormatPreferences, fileMonitor); - Assert.assertEquals(StandardCharsets.US_ASCII, result.getMetaData().getEncoding().get()); + assertEquals(StandardCharsets.US_ASCII, result.getMetaData().getEncoding().get()); BibDatabase db = result.getDatabase(); - Assert.assertEquals(Optional.of("testPreamble"), db.getPreamble()); + assertEquals(Optional.of("testPreamble"), db.getPreamble()); Collection entries = db.getEntries(); - Assert.assertEquals(1, entries.size()); + assertEquals(1, entries.size()); BibEntry entry = entries.iterator().next(); - Assert.assertEquals(Optional.of("testArticle"), entry.getCiteKeyOptional()); + assertEquals(Optional.of("testArticle"), entry.getCiteKeyOptional()); } } diff --git a/src/test/java/org/jabref/logic/importer/fetcher/ArXivTest.java b/src/test/java/org/jabref/logic/importer/fetcher/ArXivTest.java index c877430ff9a..166be4e5d39 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/ArXivTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/ArXivTest.java @@ -53,10 +53,9 @@ public void findFullTextForEmptyEntryResultsEmptyOptional() throws IOException { assertEquals(Optional.empty(), finder.findFullText(entry)); } - public void findFullTextRejectsNullParameter() throws IOException { - + @Test + public void findFullTextRejectsNullParameter() { assertThrows(NullPointerException.class, () -> finder.findFullText(null)); - } @Test @@ -71,7 +70,6 @@ public void findFullTextByDOI() throws IOException { @Test public void findFullTextByEprint() throws IOException { entry.setField("eprint", "1603.06570"); - assertEquals(Optional.of(new URL("http://arxiv.org/pdf/1603.06570v1")), finder.findFullText(entry)); } @@ -107,14 +105,12 @@ public void findFullTextByTitleAndPartOfAuthor() throws IOException { @Test public void notFindFullTextByUnknownDOI() throws IOException { entry.setField("doi", "10.1529/unknown"); - assertEquals(Optional.empty(), finder.findFullText(entry)); } @Test public void notFindFullTextByUnknownId() throws IOException { entry.setField("eprint", "1234.12345"); - assertEquals(Optional.empty(), finder.findFullText(entry)); } diff --git a/src/test/java/org/jabref/logic/importer/fetcher/DoiFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/DoiFetcherTest.java index 4c1d006b952..d268730212b 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/DoiFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/DoiFetcherTest.java @@ -70,10 +70,12 @@ public void testPerformSearchDecker2007() throws FetcherException { assertEquals(Optional.of(bibEntryDecker2007), fetchedEntry); } + @Test public void testPerformSearchEmptyDOI() { assertThrows(FetcherException.class, () -> fetcher.performSearchById("")); } + @Test public void testPerformSearchInvalidDOI() { assertThrows(FetcherException.class, () -> fetcher.performSearchById("10.1002/9781118257517F")); diff --git a/src/test/java/org/jabref/logic/importer/fetcher/FulltextFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/FulltextFetcherTest.java index 6b649d60c7f..20e70601800 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/FulltextFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/FulltextFetcherTest.java @@ -17,6 +17,7 @@ class FulltextFetcherTest { + @SuppressWarnings("unused") private static List fetcherProvider() { return WebFetchers.getFullTextFetchers(mock(ImportFormatPreferences.class)); } diff --git a/src/test/java/org/jabref/logic/importer/fetcher/GvkParserTest.java b/src/test/java/org/jabref/logic/importer/fetcher/GvkParserTest.java index e7bacbdc8b6..443b46be140 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/GvkParserTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/GvkParserTest.java @@ -10,8 +10,11 @@ import org.jabref.logic.importer.fileformat.GvkParser; import org.jabref.model.entry.BibEntry; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class GvkParserTest { @@ -19,8 +22,8 @@ private void doTest(String xmlName, int expectedSize, List resourceNames try (InputStream is = GvkParserTest.class.getResourceAsStream(xmlName)) { GvkParser parser = new GvkParser(); List entries = parser.parseEntries(is); - Assert.assertNotNull(entries); - Assert.assertEquals(expectedSize, entries.size()); + assertNotNull(entries); + assertEquals(expectedSize, entries.size()); int i = 0; for (String resourceName : resourceNames) { BibEntryAssert.assertEquals(GvkParserTest.class, resourceName, entries.get(i)); @@ -49,23 +52,23 @@ public void subTitleTest() throws Exception { try (InputStream is = GvkParserTest.class.getResourceAsStream("gvk_artificial_subtitle_test.xml")) { GvkParser parser = new GvkParser(); List entries = parser.parseEntries(is); - Assert.assertNotNull(entries); - Assert.assertEquals(5, entries.size()); + assertNotNull(entries); + assertEquals(5, entries.size()); BibEntry entry = entries.get(0); - Assert.assertEquals(Optional.empty(), entry.getField("subtitle")); + assertEquals(Optional.empty(), entry.getField("subtitle")); entry = entries.get(1); - Assert.assertEquals(Optional.of("C"), entry.getField("subtitle")); + assertEquals(Optional.of("C"), entry.getField("subtitle")); entry = entries.get(2); - Assert.assertEquals(Optional.of("Word"), entry.getField("subtitle")); + assertEquals(Optional.of("Word"), entry.getField("subtitle")); entry = entries.get(3); - Assert.assertEquals(Optional.of("Word1 word2"), entry.getField("subtitle")); + assertEquals(Optional.of("Word1 word2"), entry.getField("subtitle")); entry = entries.get(4); - Assert.assertEquals(Optional.of("Word1 word2"), entry.getField("subtitle")); + assertEquals(Optional.of("Word1 word2"), entry.getField("subtitle")); } } } diff --git a/src/test/java/org/jabref/logic/importer/fetcher/MathSciNetTest.java b/src/test/java/org/jabref/logic/importer/fetcher/MathSciNetTest.java index 0471675727a..e66d81f0948 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/MathSciNetTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/MathSciNetTest.java @@ -13,8 +13,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/src/test/java/org/jabref/logic/importer/fetcher/zbMATHTest.java b/src/test/java/org/jabref/logic/importer/fetcher/zbMATHTest.java index dabb70feb88..41617041ebb 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/zbMATHTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/zbMATHTest.java @@ -13,12 +13,13 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @FetcherTest class zbMATHTest { + private zbMATH fetcher; private BibEntry donaldsonEntry; diff --git a/src/test/java/org/jabref/logic/importer/fileformat/BibTeXMLImporterTestFiles.java b/src/test/java/org/jabref/logic/importer/fileformat/BibTeXMLImporterTestFiles.java index 163cd6cb6b0..0e7fc1627c1 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/BibTeXMLImporterTestFiles.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/BibTeXMLImporterTestFiles.java @@ -11,12 +11,14 @@ public class BibTeXMLImporterTestFiles { private static final String FILE_ENDING = ".xml"; + @SuppressWarnings("unused") private static Stream fileNames() throws IOException { Predicate fileName = name -> name.startsWith("BibTeXMLImporterTest") && name.endsWith(FILE_ENDING); return ImporterTestEngine.getTestFiles(fileName).stream(); } + @SuppressWarnings("unused") private static Stream nonBibTeXMLfileNames() throws IOException { Predicate fileName = name -> !name.startsWith("BibTeXMLImporterTest"); return ImporterTestEngine.getTestFiles(fileName).stream(); diff --git a/src/test/java/org/jabref/logic/importer/util/ConvertLegacyExplicitGroupsTest.java b/src/test/java/org/jabref/logic/importer/util/ConvertLegacyExplicitGroupsTest.java index 87af078b8c1..a01fdec06dd 100644 --- a/src/test/java/org/jabref/logic/importer/util/ConvertLegacyExplicitGroupsTest.java +++ b/src/test/java/org/jabref/logic/importer/util/ConvertLegacyExplicitGroupsTest.java @@ -10,10 +10,10 @@ import org.jabref.model.groups.GroupHierarchyType; import org.jabref.model.groups.GroupTreeNode; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class ConvertLegacyExplicitGroupsTest { @@ -21,7 +21,7 @@ public class ConvertLegacyExplicitGroupsTest { private BibEntry entry; private ExplicitGroup group; - @Before + @BeforeEach public void setUp() throws Exception { action = new ConvertLegacyExplicitGroups(); diff --git a/src/test/java/org/jabref/logic/importer/util/GroupsParserTest.java b/src/test/java/org/jabref/logic/importer/util/GroupsParserTest.java index dd9385a736a..7d8db0e34cf 100644 --- a/src/test/java/org/jabref/logic/importer/util/GroupsParserTest.java +++ b/src/test/java/org/jabref/logic/importer/util/GroupsParserTest.java @@ -20,15 +20,16 @@ import org.jabref.model.util.DummyFileUpdateMonitor; import org.jabref.model.util.FileUpdateMonitor; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class GroupsParserTest { private FileUpdateMonitor fileMonitor; - @Before + @BeforeEach public void setUp() throws Exception { fileMonitor = new DummyFileUpdateMonitor(); } @@ -56,9 +57,9 @@ public void HierarchicalDelimiterThatNeedsToBeEscaped() throws Exception { assertEquals(expected, parsed); } - @Test(expected = ParseException.class) + @Test public void fromStringThrowsParseExceptionForNotEscapedGroupName() throws Exception { - GroupsParser.fromString("ExplicitGroup:slit\\\\;0\\;mertsch_slit2_2007\\;;", ',', fileMonitor); + assertThrows(ParseException.class, () -> GroupsParser.fromString("ExplicitGroup:slit\\\\;0\\;mertsch_slit2_2007\\;;", ',', fileMonitor)); } @Test @@ -122,8 +123,8 @@ public void fromStringParsesTexGroup() throws Exception { assertEquals(expected, parsed); } - @Test(expected = ParseException.class) + @Test public void fromStringUnknownGroupThrowsException() throws Exception { - GroupsParser.fromString("0 UnknownGroup:myUnknownGroup;0;;1;;;;", ',', fileMonitor); + assertThrows(ParseException.class, () -> GroupsParser.fromString("0 UnknownGroup:myUnknownGroup;0;;1;;;;", ',', fileMonitor)); } } diff --git a/src/test/java/org/jabref/logic/importer/util/JSONEntryParserTest.java b/src/test/java/org/jabref/logic/importer/util/JSONEntryParserTest.java index ef8986c8501..86b52f2449d 100644 --- a/src/test/java/org/jabref/logic/importer/util/JSONEntryParserTest.java +++ b/src/test/java/org/jabref/logic/importer/util/JSONEntryParserTest.java @@ -5,8 +5,9 @@ import org.jabref.model.entry.BibEntry; import org.json.JSONObject; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class JSONEntryParserTest { @@ -27,15 +28,15 @@ public void testBibJSONConverter() { JSONObject jsonObject = new JSONObject(jsonString); BibEntry bibEntry = jc.parseBibJSONtoBibtex(jsonObject, ','); - Assert.assertEquals("article", bibEntry.getType()); - Assert.assertEquals(Optional.of("VLSI Design"), bibEntry.getField("journal")); - Assert.assertEquals(Optional.of("10.1155/2014/217495"), bibEntry.getField("doi")); - Assert.assertEquals(Optional.of("Syed Asad Alam and Oscar Gustafsson"), bibEntry.getField("author")); - Assert.assertEquals( + assertEquals("article", bibEntry.getType()); + assertEquals(Optional.of("VLSI Design"), bibEntry.getField("journal")); + assertEquals(Optional.of("10.1155/2014/217495"), bibEntry.getField("doi")); + assertEquals(Optional.of("Syed Asad Alam and Oscar Gustafsson"), bibEntry.getField("author")); + assertEquals( Optional.of( "Design of Finite Word Length Linear-Phase FIR Filters in the Logarithmic Number System Domain"), bibEntry.getField("title")); - Assert.assertEquals(Optional.of("2014"), bibEntry.getField("year")); + assertEquals(Optional.of("2014"), bibEntry.getField("year")); } @Test @@ -52,13 +53,13 @@ public void testSpringerJSONToBibtex() { JSONObject jsonObject = new JSONObject(jsonString); BibEntry bibEntry = JSONEntryParser.parseSpringerJSONtoBibtex(jsonObject); - Assert.assertEquals(Optional.of("1992"), bibEntry.getField("year")); - Assert.assertEquals(Optional.of("5"), bibEntry.getField("number")); - Assert.assertEquals(Optional.of("#sep#"), bibEntry.getField("month")); - Assert.assertEquals(Optional.of("10.1007/BF01201962"), bibEntry.getField("doi")); - Assert.assertEquals(Optional.of("8"), bibEntry.getField("volume")); - Assert.assertEquals(Optional.of("Springer"), bibEntry.getField("publisher")); - Assert.assertEquals(Optional.of("1992-09-01"), bibEntry.getField("date")); + assertEquals(Optional.of("1992"), bibEntry.getField("year")); + assertEquals(Optional.of("5"), bibEntry.getField("number")); + assertEquals(Optional.of("#sep#"), bibEntry.getField("month")); + assertEquals(Optional.of("10.1007/BF01201962"), bibEntry.getField("doi")); + assertEquals(Optional.of("8"), bibEntry.getField("volume")); + assertEquals(Optional.of("Springer"), bibEntry.getField("publisher")); + assertEquals(Optional.of("1992-09-01"), bibEntry.getField("date")); } } diff --git a/src/test/java/org/jabref/logic/integrity/BracesCorrectorTest.java b/src/test/java/org/jabref/logic/integrity/BracesCorrectorTest.java index 1535ece93b9..b14d6e5c49f 100644 --- a/src/test/java/org/jabref/logic/integrity/BracesCorrectorTest.java +++ b/src/test/java/org/jabref/logic/integrity/BracesCorrectorTest.java @@ -1,8 +1,9 @@ package org.jabref.logic.integrity; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; public class BracesCorrectorTest { diff --git a/src/test/java/org/jabref/logic/integrity/EntryLinkCheckerTest.java b/src/test/java/org/jabref/logic/integrity/EntryLinkCheckerTest.java index 241e5463072..81c8680abd0 100644 --- a/src/test/java/org/jabref/logic/integrity/EntryLinkCheckerTest.java +++ b/src/test/java/org/jabref/logic/integrity/EntryLinkCheckerTest.java @@ -6,13 +6,12 @@ import org.jabref.model.database.BibDatabase; import org.jabref.model.entry.BibEntry; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.fail; - +import static org.junit.jupiter.api.Assertions.assertThrows; public class EntryLinkCheckerTest { @@ -20,8 +19,7 @@ public class EntryLinkCheckerTest { private EntryLinkChecker checker; private BibEntry entry; - - @Before + @BeforeEach public void setUp() { database = new BibDatabase(); checker = new EntryLinkChecker(database); @@ -29,11 +27,9 @@ public void setUp() { database.insertEntry(entry); } - @SuppressWarnings("unused") - @Test(expected = NullPointerException.class) + @Test public void testEntryLinkChecker() { - new EntryLinkChecker(null); - fail(); + assertThrows(NullPointerException.class, () -> new EntryLinkChecker(null)); } @Test diff --git a/src/test/java/org/jabref/logic/integrity/NoBibTexFieldCheckerTest.java b/src/test/java/org/jabref/logic/integrity/NoBibTexFieldCheckerTest.java index ef751fefa8f..7539dc826a6 100644 --- a/src/test/java/org/jabref/logic/integrity/NoBibTexFieldCheckerTest.java +++ b/src/test/java/org/jabref/logic/integrity/NoBibTexFieldCheckerTest.java @@ -5,14 +5,14 @@ import org.jabref.model.entry.BibEntry; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class NoBibTexFieldCheckerTest { - private NoBibtexFieldChecker checker = new NoBibtexFieldChecker(); + private final NoBibtexFieldChecker checker = new NoBibtexFieldChecker(); @Test public void abstractIsNotRecognizedAsBiblatexOnlyField() { diff --git a/src/test/java/org/jabref/logic/integrity/PersonNamesCheckerTest.java b/src/test/java/org/jabref/logic/integrity/PersonNamesCheckerTest.java index 2f603389978..a5c21dbc8a1 100644 --- a/src/test/java/org/jabref/logic/integrity/PersonNamesCheckerTest.java +++ b/src/test/java/org/jabref/logic/integrity/PersonNamesCheckerTest.java @@ -5,16 +5,16 @@ import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.database.BibDatabaseMode; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class PersonNamesCheckerTest { private PersonNamesChecker checker; - @Before + @BeforeEach public void setUp() throws Exception { BibDatabaseContext databaseContext = new BibDatabaseContext(); databaseContext.setMode(BibDatabaseMode.BIBTEX); diff --git a/src/test/java/org/jabref/logic/journals/AbbreviationTest.java b/src/test/java/org/jabref/logic/journals/AbbreviationTest.java index dc284569776..cf1a769df72 100644 --- a/src/test/java/org/jabref/logic/journals/AbbreviationTest.java +++ b/src/test/java/org/jabref/logic/journals/AbbreviationTest.java @@ -1,9 +1,8 @@ package org.jabref.logic.journals; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; public class AbbreviationTest { @@ -46,8 +45,7 @@ public void testGetNextElementWithTrailingSpaces() { @Test public void testIsoAndMedlineAbbreviationsAreSame() { Abbreviation abbreviation = new Abbreviation(" Long Name ", " L N "); - - assertTrue(abbreviation.getIsoAbbreviation().equals(abbreviation.getMedlineAbbreviation())); + assertEquals(abbreviation.getIsoAbbreviation(), abbreviation.getMedlineAbbreviation()); } } diff --git a/src/test/java/org/jabref/logic/journals/JournalAbbreviationRepositoryTest.java b/src/test/java/org/jabref/logic/journals/JournalAbbreviationRepositoryTest.java index 822ce6d1ce3..f8c99cff5d4 100644 --- a/src/test/java/org/jabref/logic/journals/JournalAbbreviationRepositoryTest.java +++ b/src/test/java/org/jabref/logic/journals/JournalAbbreviationRepositoryTest.java @@ -1,17 +1,16 @@ package org.jabref.logic.journals; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class JournalAbbreviationRepositoryTest { @Test public void empty() { JournalAbbreviationRepository repository = new JournalAbbreviationRepository(); - assertEquals(0, repository.size()); assertTrue(repository.getAbbreviations().isEmpty()); } diff --git a/src/test/java/org/jabref/logic/journals/ShippedJournalAbbreviationDuplicateTest.java b/src/test/java/org/jabref/logic/journals/ShippedJournalAbbreviationDuplicateTest.java index 8c573304ede..dbff021a2df 100644 --- a/src/test/java/org/jabref/logic/journals/ShippedJournalAbbreviationDuplicateTest.java +++ b/src/test/java/org/jabref/logic/journals/ShippedJournalAbbreviationDuplicateTest.java @@ -1,7 +1,8 @@ package org.jabref.logic.journals; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; public class ShippedJournalAbbreviationDuplicateTest { @@ -10,11 +11,11 @@ public void noDuplicatesInShippedIEEEOfficialJournalAbbreviations() { JournalAbbreviationRepository repoBuiltIn = new JournalAbbreviationRepository(); repoBuiltIn.addEntries(JournalAbbreviationLoader.getBuiltInAbbreviations()); - for (Abbreviation abbreviation : JournalAbbreviationLoader.getOfficialIEEEAbbreviations()) { - Assert.assertFalse("duplicate name " + abbreviation.toString(), repoBuiltIn.getAbbreviation(abbreviation.getName()).isPresent()); - Assert.assertFalse("duplicate iso " + abbreviation.toString(), repoBuiltIn.getAbbreviation(abbreviation.getIsoAbbreviation()).isPresent()); - Assert.assertFalse("duplicate medline " + abbreviation.toString(), repoBuiltIn.getAbbreviation(abbreviation.getMedlineAbbreviation()).isPresent()); - } + JournalAbbreviationLoader.getOfficialIEEEAbbreviations().parallelStream().forEach(abbreviation -> { + assertFalse(repoBuiltIn.getAbbreviation(abbreviation.getName()).isPresent()); + assertFalse(repoBuiltIn.getAbbreviation(abbreviation.getIsoAbbreviation()).isPresent(), "duplicate iso " + abbreviation.toString()); + assertFalse(repoBuiltIn.getAbbreviation(abbreviation.getMedlineAbbreviation()).isPresent(), "duplicate medline " + abbreviation.toString()); + }); } @Test @@ -22,11 +23,11 @@ public void noDuplicatesInShippedIEEEStandardJournalAbbreviations() { JournalAbbreviationRepository repoBuiltIn = new JournalAbbreviationRepository(); repoBuiltIn.addEntries(JournalAbbreviationLoader.getBuiltInAbbreviations()); - for (Abbreviation abbreviation : JournalAbbreviationLoader.getStandardIEEEAbbreviations()) { - Assert.assertFalse("duplicate name " + abbreviation.toString(), repoBuiltIn.getAbbreviation(abbreviation.getName()).isPresent()); - Assert.assertFalse("duplicate iso " + abbreviation.toString(), repoBuiltIn.getAbbreviation(abbreviation.getIsoAbbreviation()).isPresent()); - Assert.assertFalse("duplicate medline " + abbreviation.toString(), repoBuiltIn.getAbbreviation(abbreviation.getMedlineAbbreviation()).isPresent()); - } + JournalAbbreviationLoader.getStandardIEEEAbbreviations().parallelStream().forEach(abbreviation -> { + assertFalse(repoBuiltIn.getAbbreviation(abbreviation.getName()).isPresent(), "duplicate name " + abbreviation.toString()); + assertFalse(repoBuiltIn.getAbbreviation(abbreviation.getIsoAbbreviation()).isPresent(), "duplicate iso " + abbreviation.toString()); + assertFalse(repoBuiltIn.getAbbreviation(abbreviation.getMedlineAbbreviation()).isPresent(), "duplicate medline " + abbreviation.toString()); + }); } } diff --git a/src/test/java/org/jabref/logic/l10n/EncodingsTest.java b/src/test/java/org/jabref/logic/l10n/EncodingsTest.java index 09172b61908..ed737b77fde 100644 --- a/src/test/java/org/jabref/logic/l10n/EncodingsTest.java +++ b/src/test/java/org/jabref/logic/l10n/EncodingsTest.java @@ -1,9 +1,9 @@ package org.jabref.logic.l10n; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class EncodingsTest { @Test diff --git a/src/test/java/org/jabref/logic/l10n/LanguagesTest.java b/src/test/java/org/jabref/logic/l10n/LanguagesTest.java index b5ba7710fc2..25f9612b772 100644 --- a/src/test/java/org/jabref/logic/l10n/LanguagesTest.java +++ b/src/test/java/org/jabref/logic/l10n/LanguagesTest.java @@ -3,10 +3,11 @@ import java.util.Locale; import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; public class LanguagesTest { @@ -47,8 +48,8 @@ public void convertUnknownKnownLanguageAndUnknownCountry() { assertEquals(Optional.empty(), Languages.convertToSupportedLocale("language_country_variant")); } - @Test(expected = NullPointerException.class) + @Test public void convertToKnownLocaleNull() { - Languages.convertToSupportedLocale(null); + assertThrows(NullPointerException.class, () -> Languages.convertToSupportedLocale(null)); } } diff --git a/src/test/java/org/jabref/logic/l10n/LocalizationConsistencyTest.java b/src/test/java/org/jabref/logic/l10n/LocalizationConsistencyTest.java index 06cdc43d995..4fb752c563e 100644 --- a/src/test/java/org/jabref/logic/l10n/LocalizationConsistencyTest.java +++ b/src/test/java/org/jabref/logic/l10n/LocalizationConsistencyTest.java @@ -20,11 +20,10 @@ import java.util.stream.Collectors; import com.google.common.collect.Sets; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class LocalizationConsistencyTest { @@ -42,8 +41,7 @@ public void allFilesMustBeInLanguages() throws IOException { } } } - Assert.assertEquals("There are some localization files that are not present in org.jabref.logic.l10n.Languages or vice versa!", - Collections.emptySet(), Sets.symmetricDifference(new HashSet<>(Languages.LANGUAGES.values()), localizationFiles)); + assertEquals(Collections.emptySet(), Sets.symmetricDifference(new HashSet<>(Languages.LANGUAGES.values()), localizationFiles), "There are some localization files that are not present in org.jabref.logic.l10n.Languages or vice versa!"); } } @@ -56,7 +54,7 @@ public void ensureNoDuplicates() { // read in DuplicationDetectionProperties properties = new DuplicationDetectionProperties(); try (InputStream is = LocalizationConsistencyTest.class.getResourceAsStream(propertyFilePath); - InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) { + InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) { properties.load(reader); } catch (IOException e) { throw new RuntimeException(e); @@ -64,7 +62,7 @@ public void ensureNoDuplicates() { List duplicates = properties.getDuplicates(); - assertEquals("Duplicate keys inside bundle " + bundle + "_" + lang, Collections.emptyList(), duplicates); + assertEquals(Collections.emptyList(), duplicates, "Duplicate keys inside bundle " + bundle + "_" + lang); } } } @@ -99,60 +97,57 @@ public void languageKeysShouldNotBeQuotedInFiles() throws IOException { .stream() .filter(key -> key.getKey().contains("_") && key.getKey().equals(new LocalizationKey(key.getKey()).getPropertiesKey())) .collect(Collectors.toList()); - Assert.assertEquals( - "Language keys must not be used quoted in code! Use \"This is a message\" instead of \"This_is_a_message\".\n" + - "Please correct the following entries:\n" + - quotedEntries - .stream() - .map(key -> String.format("\n%s (%s)\n", key.getKey(), key.getPath())) - .collect(Collectors.toList()) - , - Collections.EMPTY_LIST, quotedEntries); + assertEquals(Collections.EMPTY_LIST, quotedEntries, "Language keys must not be used quoted in code! Use \"This is a message\" instead of \"This_is_a_message\".\n" + + "Please correct the following entries:\n" + + quotedEntries + .stream() + .map(key -> String.format("\n%s (%s)\n", key.getKey(), key.getPath())) + .collect(Collectors.toList())); } @Test public void findMissingLocalizationKeys() throws IOException { - List missingKeys = LocalizationParser.find(LocalizationBundleForTest.LANG).stream().sorted() - .distinct().collect(Collectors.toList()); - - assertEquals("DETECTED LANGUAGE KEYS WHICH ARE NOT IN THE ENGLISH LANGUAGE FILE\n" + - "PASTE THESE INTO THE ENGLISH LANGUAGE FILE\n" + - missingKeys.parallelStream() - .map(key -> String.format("\n%s=%s\n", key.getKey(), key.getKey().replaceAll("\\\\ ", " "))) - .collect(Collectors.toList()), - Collections.emptyList(), missingKeys); + List missingKeys = LocalizationParser.find(LocalizationBundleForTest.LANG) + .stream() + .sorted() + .distinct() + .collect(Collectors.toList()); + + assertEquals(Collections.emptyList(), missingKeys, "DETECTED LANGUAGE KEYS WHICH ARE NOT IN THE ENGLISH LANGUAGE FILE\n" + + "PASTE THESE INTO THE ENGLISH LANGUAGE FILE\n" + + missingKeys.parallelStream() + .map(key -> String.format("\n%s=%s\n", key.getKey(), key.getKey().replaceAll("\\\\ ", " "))) + .collect(Collectors.toList())); } @Test public void findMissingMenuLocalizationKeys() throws IOException { Set missingKeys = LocalizationParser.find(LocalizationBundleForTest.MENU); - assertEquals("DETECTED LANGUAGE KEYS WHICH ARE NOT IN THE ENGLISH MENU FILE\n" + - "PASTE THESE INTO THE ENGLISH MENU FILE\n" + - missingKeys.parallelStream() - .map(key -> String.format("%s=%s", key.getKey(), key.getKey())) - .collect(Collectors.toList()), - Collections.emptySet(), missingKeys); + assertEquals(Collections.emptySet(), missingKeys, "DETECTED LANGUAGE KEYS WHICH ARE NOT IN THE ENGLISH MENU FILE\n" + + "PASTE THESE INTO THE ENGLISH MENU FILE\n" + + missingKeys.parallelStream() + .map(key -> String.format("%s=%s", key.getKey(), key.getKey())) + .collect(Collectors.toList())); } @Test public void findObsoleteLocalizationKeys() throws IOException { Set obsoleteKeys = LocalizationParser.findObsolete(LocalizationBundleForTest.LANG); - assertEquals("Obsolete keys found in language properties file: " + obsoleteKeys + "\n" + - "1. CHECK IF THE KEY IS REALLY NOT USED ANYMORE\n" + - "2. REMOVE THESE FROM THE ENGLISH LANGUAGE FILE\n", - Collections.emptySet(), obsoleteKeys); + assertEquals(Collections.emptySet(), obsoleteKeys, "Obsolete keys found in language properties file: " + obsoleteKeys + "\n" + + "1. CHECK IF THE KEY IS REALLY NOT USED ANYMORE\n" + + "2. REMOVE THESE FROM THE ENGLISH LANGUAGE FILE\n"); } @Test public void findObsoleteMenuLocalizationKeys() throws IOException { Set obsoleteKeys = LocalizationParser.findObsolete(LocalizationBundleForTest.MENU); - assertEquals("Obsolete keys found in the menu properties file: " + obsoleteKeys + "\n" + + assertEquals( + Collections.emptySet(), obsoleteKeys, "Obsolete keys found in the menu properties file: " + obsoleteKeys + "\n" + "1. CHECK IF THE KEY IS REALLY NOT USED ANYMORE\n" + - "2. REMOVE THESE FROM THE ENGLISH MENU FILE\n", - Collections.emptySet(), obsoleteKeys); + "2. REMOVE THESE FROM THE ENGLISH MENU FILE\n"); } @Test @@ -163,18 +158,17 @@ public void localizationParameterMustIncludeAString() throws IOException { // Localization.lang("Problem downloading from %1", address) Set keys = LocalizationParser.findLocalizationParametersStringsInJavaFiles(LocalizationBundleForTest.LANG); for (LocalizationEntry e : keys) { - assertTrue("Illegal localization parameter found. Must include a String with potential concatenation or replacement parameters. Illegal parameter: Localization.lang(" + e.getKey(), - e.getKey().startsWith("\"") || e.getKey().endsWith("\"")); + assertTrue(e.getKey().startsWith("\"") || e.getKey().endsWith("\""), "Illegal localization parameter found. Must include a String with potential concatenation or replacement parameters. Illegal parameter: Localization.lang(" + e.getKey()); } keys = LocalizationParser.findLocalizationParametersStringsInJavaFiles(LocalizationBundleForTest.MENU); for (LocalizationEntry e : keys) { - assertTrue("Illegal localization parameter found. Must include a String with potential concatenation or replacement parameters. Illegal parameter: Localization.lang(" + e.getKey(), - e.getKey().startsWith("\"") || e.getKey().endsWith("\"")); + assertTrue(e.getKey().startsWith("\"") || e.getKey().endsWith("\""), "Illegal localization parameter found. Must include a String with potential concatenation or replacement parameters. Illegal parameter: Localization.lang(" + e.getKey()); } } private static class DuplicationDetectionProperties extends Properties { + private static final long serialVersionUID = 1L; private final List duplicates = new ArrayList<>(); diff --git a/src/test/java/org/jabref/logic/l10n/LocalizationKeyParamsTest.java b/src/test/java/org/jabref/logic/l10n/LocalizationKeyParamsTest.java index 7cdf4f58fcd..0edc4975f8b 100644 --- a/src/test/java/org/jabref/logic/l10n/LocalizationKeyParamsTest.java +++ b/src/test/java/org/jabref/logic/l10n/LocalizationKeyParamsTest.java @@ -1,8 +1,9 @@ package org.jabref.logic.l10n; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class LocalizationKeyParamsTest { @@ -15,9 +16,9 @@ public void testReplacePlaceholders() { assertEquals("What \n : %e %c_a b", new LocalizationKeyParams("What \n : %e %c_%0 %1", "a", "b").replacePlaceholders()); } - @Test(expected = IllegalStateException.class) + @Test public void testTooManyParams() { - new LocalizationKeyParams("", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"); + assertThrows(IllegalStateException.class, () -> new LocalizationKeyParams("", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0")); } } diff --git a/src/test/java/org/jabref/logic/l10n/LocalizationKeyTest.java b/src/test/java/org/jabref/logic/l10n/LocalizationKeyTest.java index 838777f9830..2350512b37b 100644 --- a/src/test/java/org/jabref/logic/l10n/LocalizationKeyTest.java +++ b/src/test/java/org/jabref/logic/l10n/LocalizationKeyTest.java @@ -2,7 +2,7 @@ import org.junit.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class LocalizationKeyTest { diff --git a/src/test/java/org/jabref/logic/l10n/LocalizationParserTest.java b/src/test/java/org/jabref/logic/l10n/LocalizationParserTest.java index 17ae4d0e381..2463a15cdc6 100644 --- a/src/test/java/org/jabref/logic/l10n/LocalizationParserTest.java +++ b/src/test/java/org/jabref/logic/l10n/LocalizationParserTest.java @@ -4,9 +4,9 @@ import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class LocalizationParserTest { diff --git a/src/test/java/org/jabref/logic/l10n/LocalizationTest.java b/src/test/java/org/jabref/logic/l10n/LocalizationTest.java index 8342a774492..e7b91573816 100644 --- a/src/test/java/org/jabref/logic/l10n/LocalizationTest.java +++ b/src/test/java/org/jabref/logic/l10n/LocalizationTest.java @@ -2,22 +2,22 @@ import java.util.Locale; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class LocalizationTest { private Locale locale; - @Before + @BeforeEach public void storeDefaultLocale() { locale = Locale.getDefault(); } - @After + @AfterEach public void restoreDefaultLocale() { Locale.setDefault(locale); javax.swing.JComponent.setDefaultLocale(locale); @@ -67,7 +67,7 @@ public void testKnownGermanTranslation() { Localization.setLanguage("de"); String knownKey = "Save all"; assertEquals("Alle speichern", Localization.lang(knownKey)); - assertEquals( "A&lle speichern", Localization.menuTitle(knownKey)); + assertEquals("A&lle speichern", Localization.menuTitle(knownKey)); } @Test diff --git a/src/test/java/org/jabref/logic/l10n/PropertiesLocaleCompletenessTest.java b/src/test/java/org/jabref/logic/l10n/PropertiesLocaleCompletenessTest.java index ff42771cf02..d156107c1ca 100644 --- a/src/test/java/org/jabref/logic/l10n/PropertiesLocaleCompletenessTest.java +++ b/src/test/java/org/jabref/logic/l10n/PropertiesLocaleCompletenessTest.java @@ -12,9 +12,9 @@ import java.util.stream.Stream; import com.google.common.base.Splitter; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Checks that all property files are correctly encoded and can be loaded without errors. diff --git a/src/test/java/org/jabref/logic/layout/LayoutEntryTest.java b/src/test/java/org/jabref/logic/layout/LayoutEntryTest.java index b20af305c10..0e22039b872 100644 --- a/src/test/java/org/jabref/logic/layout/LayoutEntryTest.java +++ b/src/test/java/org/jabref/logic/layout/LayoutEntryTest.java @@ -5,10 +5,10 @@ import org.jabref.model.entry.BibEntry; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; /** @@ -38,7 +38,7 @@ public class LayoutEntryTest { /** * Initialize Preferences. */ - @Before + @BeforeEach public void setUp() { // create Bibtext Entry @@ -84,30 +84,30 @@ public String layout(String layoutFile, BibEntry entry) throws IOException { @Test public void testParseMethodCalls() { - Assert.assertEquals(1, LayoutEntry.parseMethodsCalls("bla").size()); - Assert.assertEquals("bla", (LayoutEntry.parseMethodsCalls("bla").get(0)).get(0)); + assertEquals(1, LayoutEntry.parseMethodsCalls("bla").size()); + assertEquals("bla", (LayoutEntry.parseMethodsCalls("bla").get(0)).get(0)); - Assert.assertEquals(1, LayoutEntry.parseMethodsCalls("bla,").size()); - Assert.assertEquals("bla", (LayoutEntry.parseMethodsCalls("bla,").get(0)).get(0)); + assertEquals(1, LayoutEntry.parseMethodsCalls("bla,").size()); + assertEquals("bla", (LayoutEntry.parseMethodsCalls("bla,").get(0)).get(0)); - Assert.assertEquals(1, LayoutEntry.parseMethodsCalls("_bla.bla.blub,").size()); - Assert.assertEquals("_bla.bla.blub", (LayoutEntry.parseMethodsCalls("_bla.bla.blub,").get(0)).get(0)); + assertEquals(1, LayoutEntry.parseMethodsCalls("_bla.bla.blub,").size()); + assertEquals("_bla.bla.blub", (LayoutEntry.parseMethodsCalls("_bla.bla.blub,").get(0)).get(0)); - Assert.assertEquals(2, LayoutEntry.parseMethodsCalls("bla,foo").size()); - Assert.assertEquals("bla", (LayoutEntry.parseMethodsCalls("bla,foo").get(0)).get(0)); - Assert.assertEquals("foo", (LayoutEntry.parseMethodsCalls("bla,foo").get(1)).get(0)); + assertEquals(2, LayoutEntry.parseMethodsCalls("bla,foo").size()); + assertEquals("bla", (LayoutEntry.parseMethodsCalls("bla,foo").get(0)).get(0)); + assertEquals("foo", (LayoutEntry.parseMethodsCalls("bla,foo").get(1)).get(0)); - Assert.assertEquals(2, LayoutEntry.parseMethodsCalls("bla(\"test\"),foo(\"fark\")").size()); - Assert.assertEquals("bla", (LayoutEntry.parseMethodsCalls("bla(\"test\"),foo(\"fark\")").get(0)).get(0)); - Assert.assertEquals("foo", (LayoutEntry.parseMethodsCalls("bla(\"test\"),foo(\"fark\")").get(1)).get(0)); - Assert.assertEquals("test", (LayoutEntry.parseMethodsCalls("bla(\"test\"),foo(\"fark\")").get(0)).get(1)); - Assert.assertEquals("fark", (LayoutEntry.parseMethodsCalls("bla(\"test\"),foo(\"fark\")").get(1)).get(1)); + assertEquals(2, LayoutEntry.parseMethodsCalls("bla(\"test\"),foo(\"fark\")").size()); + assertEquals("bla", (LayoutEntry.parseMethodsCalls("bla(\"test\"),foo(\"fark\")").get(0)).get(0)); + assertEquals("foo", (LayoutEntry.parseMethodsCalls("bla(\"test\"),foo(\"fark\")").get(1)).get(0)); + assertEquals("test", (LayoutEntry.parseMethodsCalls("bla(\"test\"),foo(\"fark\")").get(0)).get(1)); + assertEquals("fark", (LayoutEntry.parseMethodsCalls("bla(\"test\"),foo(\"fark\")").get(1)).get(1)); - Assert.assertEquals(2, LayoutEntry.parseMethodsCalls("bla(test),foo(fark)").size()); - Assert.assertEquals("bla", (LayoutEntry.parseMethodsCalls("bla(test),foo(fark)").get(0)).get(0)); - Assert.assertEquals("foo", (LayoutEntry.parseMethodsCalls("bla(test),foo(fark)").get(1)).get(0)); - Assert.assertEquals("test", (LayoutEntry.parseMethodsCalls("bla(test),foo(fark)").get(0)).get(1)); - Assert.assertEquals("fark", (LayoutEntry.parseMethodsCalls("bla(test),foo(fark)").get(1)).get(1)); + assertEquals(2, LayoutEntry.parseMethodsCalls("bla(test),foo(fark)").size()); + assertEquals("bla", (LayoutEntry.parseMethodsCalls("bla(test),foo(fark)").get(0)).get(0)); + assertEquals("foo", (LayoutEntry.parseMethodsCalls("bla(test),foo(fark)").get(1)).get(0)); + assertEquals("test", (LayoutEntry.parseMethodsCalls("bla(test),foo(fark)").get(0)).get(1)); + assertEquals("fark", (LayoutEntry.parseMethodsCalls("bla(test),foo(fark)").get(1)).get(1)); } } diff --git a/src/test/java/org/jabref/logic/layout/LayoutTest.java b/src/test/java/org/jabref/logic/layout/LayoutTest.java index 3430ccf02a9..9ce7d4093ff 100644 --- a/src/test/java/org/jabref/logic/layout/LayoutTest.java +++ b/src/test/java/org/jabref/logic/layout/LayoutTest.java @@ -13,22 +13,23 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.util.DummyFileUpdateMonitor; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +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; import static org.mockito.Mockito.when; public class LayoutTest { + private static ImportFormatPreferences importFormatPreferences; private LayoutFormatterPreferences layoutFormatterPreferences; /** * Initialize Preferences. */ - @Before + @BeforeEach public void setUp() { layoutFormatterPreferences = mock(LayoutFormatterPreferences.class, Answers.RETURNS_DEEP_STUBS); importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); @@ -49,7 +50,7 @@ public String t1BibtexString() { public static BibEntry bibtexString2BibtexEntry(String s) throws IOException { ParserResult result = new BibtexParser(importFormatPreferences, new DummyFileUpdateMonitor()).parse(new StringReader(s)); Collection c = result.getDatabase().getEntries(); - Assert.assertEquals(1, c.size()); + assertEquals(1, c.size()); return c.iterator().next(); } @@ -63,9 +64,9 @@ public String layout(String layoutFile, String entry) throws IOException { @Test public void testLayoutBibtextype() throws IOException { - Assert.assertEquals("Unknown", layout("\\bibtextype", "@unknown{bla, author={This\nis\na\ntext}}")); - Assert.assertEquals("Article", layout("\\bibtextype", "@article{bla, author={This\nis\na\ntext}}")); - Assert.assertEquals("Misc", layout("\\bibtextype", "@misc{bla, author={This\nis\na\ntext}}")); + assertEquals("Unknown", layout("\\bibtextype", "@unknown{bla, author={This\nis\na\ntext}}")); + assertEquals("Article", layout("\\bibtextype", "@article{bla, author={This\nis\na\ntext}}")); + assertEquals("Misc", layout("\\bibtextype", "@misc{bla, author={This\nis\na\ntext}}")); } @Test @@ -73,12 +74,12 @@ public void testHTMLChar() throws IOException { String layoutText = layout("\\begin{author}\\format[HTMLChars]{\\author}\\end{author} ", "@other{bla, author={This\nis\na\ntext}}"); - Assert.assertEquals("This is a text ", layoutText); + assertEquals("This is a text ", layoutText); layoutText = layout("\\begin{author}\\format[HTMLChars]{\\author}\\end{author}", "@other{bla, author={This\nis\na\ntext}}"); - Assert.assertEquals("This is a text", layoutText); + assertEquals("This is a text", layoutText); } @Test @@ -86,7 +87,7 @@ public void testPluginLoading() throws IOException { String layoutText = layout("\\begin{author}\\format[NameFormatter]{\\author}\\end{author}", "@other{bla, author={Joe Doe and Jane, Moon}}"); - Assert.assertEquals("Joe Doe, Moon Jane", layoutText); + assertEquals("Joe Doe, Moon Jane", layoutText); } @Test @@ -94,7 +95,7 @@ public void testHTMLCharDoubleLineBreak() throws IOException { String layoutText = layout("\\begin{author}\\format[HTMLChars]{\\author}\\end{author} ", "@other{bla, author={This\nis\na\n\ntext}}"); - Assert.assertEquals("This is a text ", layoutText); + assertEquals("This is a text ", layoutText); } /** @@ -108,7 +109,7 @@ public void testLayout() throws IOException { "\\begin{abstract}

Abstract: \\format[HTMLChars]{\\abstract}\\end{abstract}
", t1BibtexString()); - Assert.assertEquals( + assertEquals( "

Abstract: ñ ñ í ı ı
", layoutText); } @@ -122,7 +123,7 @@ public void testWrapFileLinksLayout() throws IOException { String layoutText = layout("\\begin{file}\\format[WrapFileLinks(\\i. \\d (\\p))]{\\file}\\end{file}", "@other{bla, file={Test file:encrypted.pdf:PDF}}"); - Assert.assertEquals( + assertEquals( "1. Test file (" + new File("src/test/resources/pdfs/encrypted.pdf").getCanonicalPath() + ")", layoutText); } diff --git a/src/test/java/org/jabref/logic/layout/format/AuthorAbbreviatorTest.java b/src/test/java/org/jabref/logic/layout/format/AuthorAbbreviatorTest.java index bcaf5ec907b..9ae1cbc797c 100644 --- a/src/test/java/org/jabref/logic/layout/format/AuthorAbbreviatorTest.java +++ b/src/test/java/org/jabref/logic/layout/format/AuthorAbbreviatorTest.java @@ -2,8 +2,8 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; /** * Is the save as the AuthorLastFirstAbbreviator. @@ -16,10 +16,10 @@ public void testFormat() { LayoutFormatter a = new AuthorLastFirstAbbreviator(); LayoutFormatter b = new AuthorAbbreviator(); - Assert.assertEquals(b.format(""), a.format("")); - Assert.assertEquals(b.format("Someone, Van Something"), a.format("Someone, Van Something")); - Assert.assertEquals(b.format("Smith, John"), a.format("Smith, John")); - Assert.assertEquals(b.format("von Neumann, John and Smith, John and Black Brown, Peter"), a + assertEquals(b.format(""), a.format("")); + assertEquals(b.format("Someone, Van Something"), a.format("Someone, Van Something")); + assertEquals(b.format("Smith, John"), a.format("Smith, John")); + assertEquals(b.format("von Neumann, John and Smith, John and Black Brown, Peter"), a .format("von Neumann, John and Smith, John and Black Brown, Peter")); } diff --git a/src/test/java/org/jabref/logic/layout/format/AuthorAndToSemicolonReplacerTest.java b/src/test/java/org/jabref/logic/layout/format/AuthorAndToSemicolonReplacerTest.java index f4e0f2b85c0..6b77da669cd 100644 --- a/src/test/java/org/jabref/logic/layout/format/AuthorAndToSemicolonReplacerTest.java +++ b/src/test/java/org/jabref/logic/layout/format/AuthorAndToSemicolonReplacerTest.java @@ -4,13 +4,15 @@ import java.util.Collection; import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Assert; + import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; +import static org.junit.Assert.assertEquals; + @RunWith(Parameterized.class) public class AuthorAndToSemicolonReplacerTest { @@ -36,6 +38,6 @@ public static Collection data() { public void testFormat() { LayoutFormatter a = new AuthorAndToSemicolonReplacer(); - Assert.assertEquals(expected, a.format(input)); + assertEquals(expected, a.format(input)); } } diff --git a/src/test/java/org/jabref/logic/layout/format/AuthorAndsCommaReplacerTest.java b/src/test/java/org/jabref/logic/layout/format/AuthorAndsCommaReplacerTest.java index 1781d4fdc90..19a643988d0 100644 --- a/src/test/java/org/jabref/logic/layout/format/AuthorAndsCommaReplacerTest.java +++ b/src/test/java/org/jabref/logic/layout/format/AuthorAndsCommaReplacerTest.java @@ -2,8 +2,8 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class AuthorAndsCommaReplacerTest { @@ -17,17 +17,17 @@ public void testFormat() { LayoutFormatter a = new AuthorAndsCommaReplacer(); // Empty case - Assert.assertEquals("", a.format("")); + assertEquals("", a.format("")); // Single Names don't change - Assert.assertEquals("Someone, Van Something", a.format("Someone, Van Something")); + assertEquals("Someone, Van Something", a.format("Someone, Van Something")); // Two names just an & - Assert.assertEquals("John von Neumann & Peter Black Brown", + assertEquals("John von Neumann & Peter Black Brown", a.format("John von Neumann and Peter Black Brown")); // Three names put a comma: - Assert.assertEquals("von Neumann, John, Smith, John & Black Brown, Peter", + assertEquals("von Neumann, John, Smith, John & Black Brown, Peter", a.format("von Neumann, John and Smith, John and Black Brown, Peter")); } } diff --git a/src/test/java/org/jabref/logic/layout/format/AuthorAndsReplacerTest.java b/src/test/java/org/jabref/logic/layout/format/AuthorAndsReplacerTest.java index 9a7b6f088c4..44a85ca7ce6 100644 --- a/src/test/java/org/jabref/logic/layout/format/AuthorAndsReplacerTest.java +++ b/src/test/java/org/jabref/logic/layout/format/AuthorAndsReplacerTest.java @@ -2,8 +2,8 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class AuthorAndsReplacerTest { @@ -16,20 +16,20 @@ public void testFormat() { LayoutFormatter a = new AuthorAndsReplacer(); // Empty case - Assert.assertEquals("", a.format("")); + assertEquals("", a.format("")); // Single Names don't change - Assert.assertEquals("Someone, Van Something", a.format("Someone, Van Something")); + assertEquals("Someone, Van Something", a.format("Someone, Van Something")); // Two names just an & - Assert.assertEquals("John Smith & Black Brown, Peter", a + assertEquals("John Smith & Black Brown, Peter", a .format("John Smith and Black Brown, Peter")); // Three names put a comma: - Assert.assertEquals("von Neumann, John; Smith, John & Black Brown, Peter", a + assertEquals("von Neumann, John; Smith, John & Black Brown, Peter", a .format("von Neumann, John and Smith, John and Black Brown, Peter")); - Assert.assertEquals("John von Neumann; John Smith & Peter Black Brown", a + assertEquals("John von Neumann; John Smith & Peter Black Brown", a .format("John von Neumann and John Smith and Peter Black Brown")); } diff --git a/src/test/java/org/jabref/logic/layout/format/AuthorFirstAbbrLastCommasTest.java b/src/test/java/org/jabref/logic/layout/format/AuthorFirstAbbrLastCommasTest.java index b266c7a9cc4..9a91ff56c9b 100644 --- a/src/test/java/org/jabref/logic/layout/format/AuthorFirstAbbrLastCommasTest.java +++ b/src/test/java/org/jabref/logic/layout/format/AuthorFirstAbbrLastCommasTest.java @@ -2,8 +2,8 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class AuthorFirstAbbrLastCommasTest { @@ -12,20 +12,20 @@ public void testFormat() { LayoutFormatter a = new AuthorFirstAbbrLastCommas(); // Empty case - Assert.assertEquals("", a.format("")); + assertEquals("", a.format("")); // Single Names - Assert.assertEquals("V. S. Someone", a.format("Someone, Van Something")); + assertEquals("V. S. Someone", a.format("Someone, Van Something")); // Two names - Assert.assertEquals("J. von Neumann and P. Black Brown", a + assertEquals("J. von Neumann and P. Black Brown", a .format("John von Neumann and Black Brown, Peter")); // Three names - Assert.assertEquals("J. von Neumann, J. Smith and P. Black Brown", a + assertEquals("J. von Neumann, J. Smith and P. Black Brown", a .format("von Neumann, John and Smith, John and Black Brown, Peter")); - Assert.assertEquals("J. von Neumann, J. Smith and P. Black Brown", a + assertEquals("J. von Neumann, J. Smith and P. Black Brown", a .format("John von Neumann and John Smith and Black Brown, Peter")); } diff --git a/src/test/java/org/jabref/logic/layout/format/AuthorFirstAbbrLastOxfordCommasTest.java b/src/test/java/org/jabref/logic/layout/format/AuthorFirstAbbrLastOxfordCommasTest.java index 242b228f0a2..9871a0a9da5 100644 --- a/src/test/java/org/jabref/logic/layout/format/AuthorFirstAbbrLastOxfordCommasTest.java +++ b/src/test/java/org/jabref/logic/layout/format/AuthorFirstAbbrLastOxfordCommasTest.java @@ -2,8 +2,8 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class AuthorFirstAbbrLastOxfordCommasTest { @@ -15,20 +15,20 @@ public void testFormat() { LayoutFormatter a = new AuthorFirstAbbrLastOxfordCommas(); // Empty case - Assert.assertEquals("", a.format("")); + assertEquals("", a.format("")); // Single Names - Assert.assertEquals("V. S. Someone", a.format("Someone, Van Something")); + assertEquals("V. S. Someone", a.format("Someone, Van Something")); // Two names - Assert.assertEquals("J. von Neumann and P. Black Brown", a + assertEquals("J. von Neumann and P. Black Brown", a .format("John von Neumann and Black Brown, Peter")); // Three names - Assert.assertEquals("J. von Neumann, J. Smith, and P. Black Brown", a + assertEquals("J. von Neumann, J. Smith, and P. Black Brown", a .format("von Neumann, John and Smith, John and Black Brown, Peter")); - Assert.assertEquals("J. von Neumann, J. Smith, and P. Black Brown", a + assertEquals("J. von Neumann, J. Smith, and P. Black Brown", a .format("John von Neumann and John Smith and Black Brown, Peter")); } diff --git a/src/test/java/org/jabref/logic/layout/format/AuthorFirstFirstCommasTest.java b/src/test/java/org/jabref/logic/layout/format/AuthorFirstFirstCommasTest.java index 51f854a8fd4..97a9c29b82c 100644 --- a/src/test/java/org/jabref/logic/layout/format/AuthorFirstFirstCommasTest.java +++ b/src/test/java/org/jabref/logic/layout/format/AuthorFirstFirstCommasTest.java @@ -1,7 +1,7 @@ package org.jabref.logic.layout.format; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class AuthorFirstFirstCommasTest { @@ -11,7 +11,7 @@ public class AuthorFirstFirstCommasTest { */ @Test public void testFormat() { - Assert.assertEquals("John von Neumann, John Smith and Peter Black Brown, Jr", + assertEquals("John von Neumann, John Smith and Peter Black Brown, Jr", new AuthorFirstFirstCommas() .format("von Neumann,,John and John Smith and Black Brown, Jr, Peter")); } diff --git a/src/test/java/org/jabref/logic/layout/format/AuthorFirstFirstTest.java b/src/test/java/org/jabref/logic/layout/format/AuthorFirstFirstTest.java index 315f512c9e5..d61d5840520 100644 --- a/src/test/java/org/jabref/logic/layout/format/AuthorFirstFirstTest.java +++ b/src/test/java/org/jabref/logic/layout/format/AuthorFirstFirstTest.java @@ -1,7 +1,7 @@ package org.jabref.logic.layout.format; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class AuthorFirstFirstTest { @@ -11,7 +11,7 @@ public class AuthorFirstFirstTest { */ @Test public void testFormat() { - Assert.assertEquals("John von Neumann and John Smith and Peter Black Brown, Jr", + assertEquals("John von Neumann and John Smith and Peter Black Brown, Jr", new AuthorFirstFirst() .format("von Neumann,,John and John Smith and Black Brown, Jr, Peter")); } diff --git a/src/test/java/org/jabref/logic/layout/format/AuthorFirstLastCommasTest.java b/src/test/java/org/jabref/logic/layout/format/AuthorFirstLastCommasTest.java index aa3f83c5b57..8607bfffeb1 100644 --- a/src/test/java/org/jabref/logic/layout/format/AuthorFirstLastCommasTest.java +++ b/src/test/java/org/jabref/logic/layout/format/AuthorFirstLastCommasTest.java @@ -2,8 +2,8 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class AuthorFirstLastCommasTest { @@ -15,20 +15,20 @@ public void testFormat() { LayoutFormatter a = new AuthorFirstLastCommas(); // Empty case - Assert.assertEquals("", a.format("")); + assertEquals("", a.format("")); // Single Names - Assert.assertEquals("Van Something Someone", a.format("Someone, Van Something")); + assertEquals("Van Something Someone", a.format("Someone, Van Something")); // Two names - Assert.assertEquals("John von Neumann and Peter Black Brown", a + assertEquals("John von Neumann and Peter Black Brown", a .format("John von Neumann and Peter Black Brown")); // Three names - Assert.assertEquals("John von Neumann, John Smith and Peter Black Brown", a + assertEquals("John von Neumann, John Smith and Peter Black Brown", a .format("von Neumann, John and Smith, John and Black Brown, Peter")); - Assert.assertEquals("John von Neumann, John Smith and Peter Black Brown", a + assertEquals("John von Neumann, John Smith and Peter Black Brown", a .format("John von Neumann and John Smith and Black Brown, Peter")); } diff --git a/src/test/java/org/jabref/logic/layout/format/AuthorFirstLastOxfordCommasTest.java b/src/test/java/org/jabref/logic/layout/format/AuthorFirstLastOxfordCommasTest.java index 736d204cc2b..9f8a91fd569 100644 --- a/src/test/java/org/jabref/logic/layout/format/AuthorFirstLastOxfordCommasTest.java +++ b/src/test/java/org/jabref/logic/layout/format/AuthorFirstLastOxfordCommasTest.java @@ -2,8 +2,8 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class AuthorFirstLastOxfordCommasTest { @@ -15,20 +15,20 @@ public void testFormat() { LayoutFormatter a = new AuthorFirstLastOxfordCommas(); // Empty case - Assert.assertEquals("", a.format("")); + assertEquals("", a.format("")); // Single Names - Assert.assertEquals("Van Something Someone", a.format("Someone, Van Something")); + assertEquals("Van Something Someone", a.format("Someone, Van Something")); // Two names - Assert.assertEquals("John von Neumann and Peter Black Brown", a + assertEquals("John von Neumann and Peter Black Brown", a .format("John von Neumann and Peter Black Brown")); // Three names - Assert.assertEquals("John von Neumann, John Smith, and Peter Black Brown", a + assertEquals("John von Neumann, John Smith, and Peter Black Brown", a .format("von Neumann, John and Smith, John and Black Brown, Peter")); - Assert.assertEquals("John von Neumann, John Smith, and Peter Black Brown", a + assertEquals("John von Neumann, John Smith, and Peter Black Brown", a .format("John von Neumann and John Smith and Black Brown, Peter")); } diff --git a/src/test/java/org/jabref/logic/layout/format/AuthorLF_FFAbbrTest.java b/src/test/java/org/jabref/logic/layout/format/AuthorLF_FFAbbrTest.java index 65abb81d66c..795c7129f0c 100644 --- a/src/test/java/org/jabref/logic/layout/format/AuthorLF_FFAbbrTest.java +++ b/src/test/java/org/jabref/logic/layout/format/AuthorLF_FFAbbrTest.java @@ -1,7 +1,7 @@ package org.jabref.logic.layout.format; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class AuthorLF_FFAbbrTest { @@ -11,7 +11,7 @@ public class AuthorLF_FFAbbrTest { */ @Test public void testFormat() { - Assert.assertEquals("von Neumann, J. and J. Smith and P. Black Brown, Jr", + assertEquals("von Neumann, J. and J. Smith and P. Black Brown, Jr", new AuthorLF_FFAbbr() .format("von Neumann,,John and John Smith and Black Brown, Jr, Peter")); } diff --git a/src/test/java/org/jabref/logic/layout/format/AuthorLF_FFTest.java b/src/test/java/org/jabref/logic/layout/format/AuthorLF_FFTest.java index 9b07dd6ebe8..1531cbfd0aa 100644 --- a/src/test/java/org/jabref/logic/layout/format/AuthorLF_FFTest.java +++ b/src/test/java/org/jabref/logic/layout/format/AuthorLF_FFTest.java @@ -1,7 +1,7 @@ package org.jabref.logic.layout.format; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class AuthorLF_FFTest { @@ -11,7 +11,7 @@ public class AuthorLF_FFTest { */ @Test public void testFormat() { - Assert.assertEquals("von Neumann, John and John Smith and Peter Black Brown, Jr", + assertEquals("von Neumann, John and John Smith and Peter Black Brown, Jr", new AuthorLF_FF() .format("von Neumann,,John and John Smith and Black Brown, Jr, Peter")); } diff --git a/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstAbbrCommasTest.java b/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstAbbrCommasTest.java index 24ffd914b5a..63faf76cd37 100644 --- a/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstAbbrCommasTest.java +++ b/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstAbbrCommasTest.java @@ -2,8 +2,8 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class AuthorLastFirstAbbrCommasTest { @@ -15,20 +15,20 @@ public void testFormat() { LayoutFormatter a = new AuthorLastFirstAbbrCommas(); // Empty case - Assert.assertEquals("", a.format("")); + assertEquals("", a.format("")); // Single Names - Assert.assertEquals("Someone, V. S.", a.format("Van Something Someone")); + assertEquals("Someone, V. S.", a.format("Van Something Someone")); // Two names - Assert.assertEquals("von Neumann, J. and Black Brown, P.", a + assertEquals("von Neumann, J. and Black Brown, P.", a .format("John von Neumann and Black Brown, Peter")); // Three names - Assert.assertEquals("von Neumann, J., Smith, J. and Black Brown, P.", a + assertEquals("von Neumann, J., Smith, J. and Black Brown, P.", a .format("von Neumann, John and Smith, John and Black Brown, Peter")); - Assert.assertEquals("von Neumann, J., Smith, J. and Black Brown, P.", a + assertEquals("von Neumann, J., Smith, J. and Black Brown, P.", a .format("John von Neumann and John Smith and Black Brown, Peter")); } diff --git a/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstAbbrOxfordCommasTest.java b/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstAbbrOxfordCommasTest.java index 444bd84e369..e3ada4bd62a 100644 --- a/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstAbbrOxfordCommasTest.java +++ b/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstAbbrOxfordCommasTest.java @@ -2,8 +2,8 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class AuthorLastFirstAbbrOxfordCommasTest { @@ -15,20 +15,20 @@ public void testFormat() { LayoutFormatter a = new AuthorLastFirstAbbrOxfordCommas(); // Empty case - Assert.assertEquals("", a.format("")); + assertEquals("", a.format("")); // Single Names - Assert.assertEquals("Someone, V. S.", a.format("Van Something Someone")); + assertEquals("Someone, V. S.", a.format("Van Something Someone")); // Two names - Assert.assertEquals("von Neumann, J. and Black Brown, P.", a + assertEquals("von Neumann, J. and Black Brown, P.", a .format("John von Neumann and Black Brown, Peter")); // Three names - Assert.assertEquals("von Neumann, J., Smith, J., and Black Brown, P.", a + assertEquals("von Neumann, J., Smith, J., and Black Brown, P.", a .format("von Neumann, John and Smith, John and Black Brown, Peter")); - Assert.assertEquals("von Neumann, J., Smith, J., and Black Brown, P.", a + assertEquals("von Neumann, J., Smith, J., and Black Brown, P.", a .format("John von Neumann and John Smith and Black Brown, Peter")); } diff --git a/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstAbbreviatorTester.java b/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstAbbreviatorTester.java index a8816d8d10b..8330a62c572 100644 --- a/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstAbbreviatorTester.java +++ b/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstAbbreviatorTester.java @@ -1,7 +1,7 @@ package org.jabref.logic.layout.format; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; /** * Test case that verifies the functionalities of the @@ -19,7 +19,7 @@ public class AuthorLastFirstAbbreviatorTester { */ @Test public void testOneAuthorSimpleName() { - Assert.assertEquals("Abbreviator Test", "Lastname, N.", abbreviate("Lastname, Name")); + assertEquals("Abbreviator Test", "Lastname, N.", abbreviate("Lastname, Name")); } /** @@ -29,7 +29,7 @@ public void testOneAuthorSimpleName() { */ @Test public void testOneAuthorCommonName() { - Assert.assertEquals("Abbreviator Test", "Lastname, N. M.", abbreviate("Lastname, Name Middlename")); + assertEquals("Abbreviator Test", "Lastname, N. M.", abbreviate("Lastname, Name Middlename")); } /** @@ -42,20 +42,20 @@ public void testTwoAuthorsCommonName() { String result = abbreviate("Lastname, Name Middlename and Sobrenome, Nome Nomedomeio"); String expectedResult = "Lastname, N. M. and Sobrenome, N. N."; - Assert.assertEquals("Abbreviator Test", expectedResult, result); + assertEquals("Abbreviator Test", expectedResult, result); } @Test public void testJrAuthor() { - Assert.assertEquals("Other, Jr., A. N.", abbreviate("Other, Jr., Anthony N.")); + assertEquals("Other, Jr., A. N.", abbreviate("Other, Jr., Anthony N.")); } @Test public void testFormat() { - Assert.assertEquals("", abbreviate("")); - Assert.assertEquals("Someone, V. S.", abbreviate("Someone, Van Something")); - Assert.assertEquals("Smith, J.", abbreviate("Smith, John")); - Assert.assertEquals("von Neumann, J. and Smith, J. and Black Brown, P.", + assertEquals("", abbreviate("")); + assertEquals("Someone, V. S.", abbreviate("Someone, Van Something")); + assertEquals("Smith, J.", abbreviate("Smith, John")); + assertEquals("von Neumann, J. and Smith, J. and Black Brown, P.", abbreviate("von Neumann, John and Smith, John and Black Brown, Peter")); } diff --git a/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstCommasTest.java b/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstCommasTest.java index 577f89989f9..9e141ca1925 100644 --- a/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstCommasTest.java +++ b/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstCommasTest.java @@ -2,8 +2,8 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class AuthorLastFirstCommasTest { @@ -17,20 +17,20 @@ public void testFormat() { LayoutFormatter a = new AuthorLastFirstCommas(); // Empty case - Assert.assertEquals("", a.format("")); + assertEquals("", a.format("")); // Single Names - Assert.assertEquals("Someone, Van Something", a.format("Van Something Someone")); + assertEquals("Someone, Van Something", a.format("Van Something Someone")); // Two names - Assert.assertEquals("von Neumann, John and Black Brown, Peter", a + assertEquals("von Neumann, John and Black Brown, Peter", a .format("John von Neumann and Black Brown, Peter")); // Three names - Assert.assertEquals("von Neumann, John, Smith, John and Black Brown, Peter", a + assertEquals("von Neumann, John, Smith, John and Black Brown, Peter", a .format("von Neumann, John and Smith, John and Black Brown, Peter")); - Assert.assertEquals("von Neumann, John, Smith, John and Black Brown, Peter", a + assertEquals("von Neumann, John, Smith, John and Black Brown, Peter", a .format("John von Neumann and John Smith and Black Brown, Peter")); } diff --git a/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstOxfordCommasTest.java b/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstOxfordCommasTest.java index b25061a5ee4..930a0ae6a6d 100644 --- a/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstOxfordCommasTest.java +++ b/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstOxfordCommasTest.java @@ -2,8 +2,8 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class AuthorLastFirstOxfordCommasTest { @@ -15,20 +15,20 @@ public void testFormat() { LayoutFormatter a = new AuthorLastFirstOxfordCommas(); // Empty case - Assert.assertEquals("", a.format("")); + assertEquals("", a.format("")); // Single Names - Assert.assertEquals("Someone, Van Something", a.format("Van Something Someone")); + assertEquals("Someone, Van Something", a.format("Van Something Someone")); // Two names - Assert.assertEquals("von Neumann, John and Black Brown, Peter", a + assertEquals("von Neumann, John and Black Brown, Peter", a .format("John von Neumann and Black Brown, Peter")); // Three names - Assert.assertEquals("von Neumann, John, Smith, John, and Black Brown, Peter", a + assertEquals("von Neumann, John, Smith, John, and Black Brown, Peter", a .format("von Neumann, John and Smith, John and Black Brown, Peter")); - Assert.assertEquals("von Neumann, John, Smith, John, and Black Brown, Peter", a + assertEquals("von Neumann, John, Smith, John, and Black Brown, Peter", a .format("John von Neumann and John Smith and Black Brown, Peter")); } diff --git a/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstTest.java b/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstTest.java index e071f7a7844..8d1822ec1b7 100644 --- a/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstTest.java +++ b/src/test/java/org/jabref/logic/layout/format/AuthorLastFirstTest.java @@ -2,8 +2,8 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class AuthorLastFirstTest { @@ -12,20 +12,20 @@ public void testFormat() { LayoutFormatter a = new AuthorLastFirst(); // Empty case - Assert.assertEquals("", a.format("")); + assertEquals("", a.format("")); // Single Names - Assert.assertEquals("Someone, Van Something", a.format("Van Something Someone")); + assertEquals("Someone, Van Something", a.format("Van Something Someone")); // Two names - Assert.assertEquals("von Neumann, John and Black Brown, Peter", a + assertEquals("von Neumann, John and Black Brown, Peter", a .format("John von Neumann and Black Brown, Peter")); // Three names - Assert.assertEquals("von Neumann, John and Smith, John and Black Brown, Peter", a + assertEquals("von Neumann, John and Smith, John and Black Brown, Peter", a .format("von Neumann, John and Smith, John and Black Brown, Peter")); - Assert.assertEquals("von Neumann, John and Smith, John and Black Brown, Peter", a + assertEquals("von Neumann, John and Smith, John and Black Brown, Peter", a .format("John von Neumann and John Smith and Black Brown, Peter")); } diff --git a/src/test/java/org/jabref/logic/layout/format/AuthorNatBibTest.java b/src/test/java/org/jabref/logic/layout/format/AuthorNatBibTest.java index f1a1de29def..b6308e0daa9 100644 --- a/src/test/java/org/jabref/logic/layout/format/AuthorNatBibTest.java +++ b/src/test/java/org/jabref/logic/layout/format/AuthorNatBibTest.java @@ -1,7 +1,7 @@ package org.jabref.logic.layout.format; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class AuthorNatBibTest { @@ -11,7 +11,7 @@ public class AuthorNatBibTest { */ @Test public void testFormatThreeAuthors() { - Assert.assertEquals("von Neumann et al.", + assertEquals("von Neumann et al.", new AuthorNatBib().format("von Neumann,,John and John Smith and Black Brown, Jr, Peter")); } @@ -21,7 +21,7 @@ public void testFormatThreeAuthors() { */ @Test public void testFormatTwoAuthors() { - Assert.assertEquals("von Neumann and Smith", new AuthorNatBib().format("von Neumann,,John and John Smith")); + assertEquals("von Neumann and Smith", new AuthorNatBib().format("von Neumann,,John and John Smith")); } } diff --git a/src/test/java/org/jabref/logic/layout/format/AuthorOrgSciTest.java b/src/test/java/org/jabref/logic/layout/format/AuthorOrgSciTest.java index 6a67d6f3626..568cae4a8d3 100644 --- a/src/test/java/org/jabref/logic/layout/format/AuthorOrgSciTest.java +++ b/src/test/java/org/jabref/logic/layout/format/AuthorOrgSciTest.java @@ -2,8 +2,8 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class AuthorOrgSciTest { @@ -11,17 +11,17 @@ public class AuthorOrgSciTest { public void testOrgSci() { LayoutFormatter f = new AuthorOrgSci(); - Assert.assertEquals("Flynn, J., S. Gartska", f.format("John Flynn and Sabine Gartska")); - Assert.assertEquals("Garvin, D. A.", f.format("David A. Garvin")); - Assert.assertEquals("Makridakis, S., S. C. Wheelwright, V. E. McGee", f.format("Sa Makridakis and Sa Ca Wheelwright and Va Ea McGee")); + assertEquals("Flynn, J., S. Gartska", f.format("John Flynn and Sabine Gartska")); + assertEquals("Garvin, D. A.", f.format("David A. Garvin")); + assertEquals("Makridakis, S., S. C. Wheelwright, V. E. McGee", f.format("Sa Makridakis and Sa Ca Wheelwright and Va Ea McGee")); } @Test public void testOrgSciPlusAbbreviation() { LayoutFormatter f = new CompositeFormat(new AuthorOrgSci(), new NoSpaceBetweenAbbreviations()); - Assert.assertEquals("Flynn, J., S. Gartska", f.format("John Flynn and Sabine Gartska")); - Assert.assertEquals("Garvin, D.A.", f.format("David A. Garvin")); - Assert.assertEquals("Makridakis, S., S.C. Wheelwright, V.E. McGee", f.format("Sa Makridakis and Sa Ca Wheelwright and Va Ea McGee")); + assertEquals("Flynn, J., S. Gartska", f.format("John Flynn and Sabine Gartska")); + assertEquals("Garvin, D.A.", f.format("David A. Garvin")); + assertEquals("Makridakis, S., S.C. Wheelwright, V.E. McGee", f.format("Sa Makridakis and Sa Ca Wheelwright and Va Ea McGee")); } } diff --git a/src/test/java/org/jabref/logic/layout/format/AuthorsTest.java b/src/test/java/org/jabref/logic/layout/format/AuthorsTest.java index 053d2742159..581d32c236f 100644 --- a/src/test/java/org/jabref/logic/layout/format/AuthorsTest.java +++ b/src/test/java/org/jabref/logic/layout/format/AuthorsTest.java @@ -2,15 +2,15 @@ import org.jabref.logic.layout.ParamLayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class AuthorsTest { @Test public void testStandardUsage() { ParamLayoutFormatter a = new Authors(); - Assert.assertEquals("B. C. Bruce, C. Manson and J. Jumper", + assertEquals("B. C. Bruce, C. Manson and J. Jumper", a.format("Bob Croydon Bruce and Charles Manson and Jolly Jumper")); } @@ -18,21 +18,21 @@ public void testStandardUsage() { public void testStandardUsageOne() { ParamLayoutFormatter a = new Authors(); a.setArgument("fullname, LastFirst, Comma, Comma"); - Assert.assertEquals("Bruce, Bob Croydon, Jumper, Jolly", a.format("Bob Croydon Bruce and Jolly Jumper")); + assertEquals("Bruce, Bob Croydon, Jumper, Jolly", a.format("Bob Croydon Bruce and Jolly Jumper")); } @Test public void testStandardUsageTwo() { ParamLayoutFormatter a = new Authors(); a.setArgument("initials"); - Assert.assertEquals("B. C. Bruce and J. Jumper", a.format("Bob Croydon Bruce and Jolly Jumper")); + assertEquals("B. C. Bruce and J. Jumper", a.format("Bob Croydon Bruce and Jolly Jumper")); } @Test public void testStandardUsageThree() { ParamLayoutFormatter a = new Authors(); a.setArgument("fullname, LastFirst, Comma"); - Assert.assertEquals("Bruce, Bob Croydon, Manson, Charles and Jumper, Jolly", + assertEquals("Bruce, Bob Croydon, Manson, Charles and Jumper, Jolly", a.format("Bob Croydon Bruce and Charles Manson and Jolly Jumper")); } @@ -40,7 +40,7 @@ public void testStandardUsageThree() { public void testStandardUsageFour() { ParamLayoutFormatter a = new Authors(); a.setArgument("fullname, LastFirst, Comma, 2"); - Assert.assertEquals("Bruce, Bob Croydon et al.", + assertEquals("Bruce, Bob Croydon et al.", a.format("Bob Croydon Bruce and Charles Manson and Jolly Jumper")); } @@ -48,7 +48,7 @@ public void testStandardUsageFour() { public void testStandardUsageFive() { ParamLayoutFormatter a = new Authors(); a.setArgument("fullname, LastFirst, Comma, 3"); - Assert.assertEquals("Bruce, Bob Croydon et al.", + assertEquals("Bruce, Bob Croydon et al.", a.format("Bob Croydon Bruce and Charles Manson and Jolly Jumper and Chuck Chuckles")); } @@ -56,7 +56,7 @@ public void testStandardUsageFive() { public void testStandardUsageSix() { ParamLayoutFormatter a = new Authors(); a.setArgument("fullname, LastFirst, Comma, 3, 2"); - Assert.assertEquals("Bruce, Bob Croydon, Manson, Charles et al.", + assertEquals("Bruce, Bob Croydon, Manson, Charles et al.", a.format("Bob Croydon Bruce and Charles Manson and Jolly Jumper and Chuck Chuckles")); } @@ -64,21 +64,21 @@ public void testStandardUsageSix() { public void testSpecialEtAl() { ParamLayoutFormatter a = new Authors(); a.setArgument("fullname, LastFirst, Comma, 3, etal= and a few more"); - Assert.assertEquals("Bruce, Bob Croydon and a few more", + assertEquals("Bruce, Bob Croydon and a few more", a.format("Bob Croydon Bruce and Charles Manson and Jolly Jumper and Chuck Chuckles")); } @Test public void testStandardUsageNull() { ParamLayoutFormatter a = new Authors(); - Assert.assertEquals("", a.format(null)); + assertEquals("", a.format(null)); } @Test public void testStandardOxford() { ParamLayoutFormatter a = new Authors(); a.setArgument("Oxford"); - Assert.assertEquals("B. C. Bruce, C. Manson, and J. Jumper", + assertEquals("B. C. Bruce, C. Manson, and J. Jumper", a.format("Bob Croydon Bruce and Charles Manson and Jolly Jumper")); } @@ -86,7 +86,7 @@ public void testStandardOxford() { public void testStandardOxfordFullName() { ParamLayoutFormatter a = new Authors(); a.setArgument("FullName,Oxford"); - Assert.assertEquals("Bob Croydon Bruce, Charles Manson, and Jolly Jumper", + assertEquals("Bob Croydon Bruce, Charles Manson, and Jolly Jumper", a.format("Bruce, Bob Croydon and Charles Manson and Jolly Jumper")); } @@ -94,7 +94,7 @@ public void testStandardOxfordFullName() { public void testStandardCommaFullName() { ParamLayoutFormatter a = new Authors(); a.setArgument("FullName,Comma,Comma"); - Assert.assertEquals("Bob Croydon Bruce, Charles Manson, Jolly Jumper", + assertEquals("Bob Croydon Bruce, Charles Manson, Jolly Jumper", a.format("Bruce, Bob Croydon and Charles Manson and Jolly Jumper")); } @@ -102,7 +102,7 @@ public void testStandardCommaFullName() { public void testStandardAmpFullName() { ParamLayoutFormatter a = new Authors(); a.setArgument("FullName,Amp"); - Assert.assertEquals("Bob Croydon Bruce, Charles Manson & Jolly Jumper", + assertEquals("Bob Croydon Bruce, Charles Manson & Jolly Jumper", a.format("Bruce, Bob Croydon and Charles Manson and Jolly Jumper")); } @@ -110,7 +110,7 @@ public void testStandardAmpFullName() { public void testLastName() { ParamLayoutFormatter a = new Authors(); a.setArgument("LastName"); - Assert.assertEquals("Bruce, von Manson and Jumper", + assertEquals("Bruce, von Manson and Jumper", a.format("Bruce, Bob Croydon and Charles von Manson and Jolly Jumper")); } @@ -118,7 +118,7 @@ public void testLastName() { public void testMiddleInitial() { ParamLayoutFormatter a = new Authors(); a.setArgument("MiddleInitial"); - Assert.assertEquals("Bob C. Bruce, Charles K. von Manson and Jolly Jumper", + assertEquals("Bob C. Bruce, Charles K. von Manson and Jolly Jumper", a.format("Bruce, Bob Croydon and Charles Kermit von Manson and Jumper, Jolly")); } @@ -126,7 +126,7 @@ public void testMiddleInitial() { public void testNoPeriod() { ParamLayoutFormatter a = new Authors(); a.setArgument("NoPeriod"); - Assert.assertEquals("B C Bruce, C K von Manson and J Jumper", + assertEquals("B C Bruce, C K von Manson and J Jumper", a.format("Bruce, Bob Croydon and Charles Kermit von Manson and Jumper, Jolly")); } @@ -134,7 +134,7 @@ public void testNoPeriod() { public void testEtAl() { ParamLayoutFormatter a = new Authors(); a.setArgument("2,1"); - Assert.assertEquals("B. C. Bruce et al.", + assertEquals("B. C. Bruce et al.", a.format("Bruce, Bob Croydon and Charles Kermit von Manson and Jumper, Jolly")); } @@ -142,7 +142,7 @@ public void testEtAl() { public void testEtAlNotEnoughAuthors() { ParamLayoutFormatter a = new Authors(); a.setArgument("2,1"); - Assert.assertEquals("B. C. Bruce and C. K. von Manson", + assertEquals("B. C. Bruce and C. K. von Manson", a.format("Bruce, Bob Croydon and Charles Kermit von Manson")); } @@ -150,7 +150,7 @@ public void testEtAlNotEnoughAuthors() { public void testEmptyEtAl() { ParamLayoutFormatter a = new Authors(); a.setArgument("fullname, LastFirst, Comma, 3, etal="); - Assert.assertEquals("Bruce, Bob Croydon", + assertEquals("Bruce, Bob Croydon", a.format("Bob Croydon Bruce and Charles Manson and Jolly Jumper and Chuck Chuckles")); } diff --git a/src/test/java/org/jabref/logic/layout/format/CompositeFormatTest.java b/src/test/java/org/jabref/logic/layout/format/CompositeFormatTest.java index c86dedaf2c5..b7869a703ff 100644 --- a/src/test/java/org/jabref/logic/layout/format/CompositeFormatTest.java +++ b/src/test/java/org/jabref/logic/layout/format/CompositeFormatTest.java @@ -2,15 +2,15 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class CompositeFormatTest { @Test public void testEmptyComposite() { LayoutFormatter f = new CompositeFormat(); - Assert.assertEquals("No Change", f.format("No Change")); + assertEquals("No Change", f.format("No Change")); } @Test @@ -18,7 +18,7 @@ public void testArrayComposite() { LayoutFormatter f = new CompositeFormat(new LayoutFormatter[] {fieldText -> fieldText + fieldText, fieldText -> "A" + fieldText, fieldText -> "B" + fieldText}); - Assert.assertEquals("BAff", f.format("f")); + assertEquals("BAff", f.format("f")); } @Test @@ -28,9 +28,9 @@ public void testDoubleComposite() { LayoutFormatter first = new AuthorOrgSci(); LayoutFormatter second = new NoSpaceBetweenAbbreviations(); - Assert.assertEquals(second.format(first.format("John Flynn and Sabine Gartska")), + assertEquals(second.format(first.format("John Flynn and Sabine Gartska")), f.format("John Flynn and Sabine Gartska")); - Assert.assertEquals(second.format(first.format("Sa Makridakis and Sa Ca Wheelwright and Va Ea McGee")), + assertEquals(second.format(first.format("Sa Makridakis and Sa Ca Wheelwright and Va Ea McGee")), f.format("Sa Makridakis and Sa Ca Wheelwright and Va Ea McGee")); } diff --git a/src/test/java/org/jabref/logic/layout/format/DOICheckTest.java b/src/test/java/org/jabref/logic/layout/format/DOICheckTest.java index b8d5a8f2d5f..fae8c751630 100644 --- a/src/test/java/org/jabref/logic/layout/format/DOICheckTest.java +++ b/src/test/java/org/jabref/logic/layout/format/DOICheckTest.java @@ -2,8 +2,8 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class DOICheckTest { @@ -11,28 +11,28 @@ public class DOICheckTest { public void testFormat() { LayoutFormatter lf = new DOICheck(); - Assert.assertEquals("", lf.format("")); - Assert.assertEquals(null, lf.format(null)); + assertEquals("", lf.format("")); + assertEquals(null, lf.format(null)); - Assert.assertEquals("https://doi.org/10.1000/ISBN1-900512-44-0", lf.format("10.1000/ISBN1-900512-44-0")); - Assert.assertEquals("https://doi.org/10.1000/ISBN1-900512-44-0", + assertEquals("https://doi.org/10.1000/ISBN1-900512-44-0", lf.format("10.1000/ISBN1-900512-44-0")); + assertEquals("https://doi.org/10.1000/ISBN1-900512-44-0", lf.format("http://dx.doi.org/10.1000/ISBN1-900512-44-0")); - Assert.assertEquals("https://doi.org/10.1000/ISBN1-900512-44-0", + assertEquals("https://doi.org/10.1000/ISBN1-900512-44-0", lf.format("http://doi.acm.org/10.1000/ISBN1-900512-44-0")); - Assert.assertEquals("https://doi.org/10.1145/354401.354407", + assertEquals("https://doi.org/10.1145/354401.354407", lf.format("http://doi.acm.org/10.1145/354401.354407")); - Assert.assertEquals("https://doi.org/10.1145/354401.354407", lf.format("10.1145/354401.354407")); + assertEquals("https://doi.org/10.1145/354401.354407", lf.format("10.1145/354401.354407")); // Works even when having a / at the front - Assert.assertEquals("https://doi.org/10.1145/354401.354407", lf.format("/10.1145/354401.354407")); + assertEquals("https://doi.org/10.1145/354401.354407", lf.format("/10.1145/354401.354407")); // Obviously a wrong doi, will not change anything. - Assert.assertEquals("10", lf.format("10")); + assertEquals("10", lf.format("10")); // Obviously a wrong doi, will not change anything. - Assert.assertEquals("1", lf.format("1")); + assertEquals("1", lf.format("1")); } } diff --git a/src/test/java/org/jabref/logic/layout/format/DOIStripTest.java b/src/test/java/org/jabref/logic/layout/format/DOIStripTest.java index caf97829225..c4f40d3b835 100644 --- a/src/test/java/org/jabref/logic/layout/format/DOIStripTest.java +++ b/src/test/java/org/jabref/logic/layout/format/DOIStripTest.java @@ -2,8 +2,8 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class DOIStripTest { @@ -11,14 +11,14 @@ public class DOIStripTest { public void testFormat() { LayoutFormatter lf = new DOIStrip(); - Assert.assertEquals("", lf.format("")); - Assert.assertEquals(null, lf.format(null)); + assertEquals("", lf.format("")); + assertEquals(null, lf.format(null)); - Assert.assertEquals("10.1000/ISBN1-900512-44-0", lf.format("10.1000/ISBN1-900512-44-0")); - Assert.assertEquals("10.1000/ISBN1-900512-44-0", + assertEquals("10.1000/ISBN1-900512-44-0", lf.format("10.1000/ISBN1-900512-44-0")); + assertEquals("10.1000/ISBN1-900512-44-0", lf.format("http://dx.doi.org/10.1000/ISBN1-900512-44-0")); - Assert.assertEquals("10.1000/ISBN1-900512-44-0", + assertEquals("10.1000/ISBN1-900512-44-0", lf.format("http://doi.acm.org/10.1000/ISBN1-900512-44-0")); } diff --git a/src/test/java/org/jabref/logic/layout/format/DateFormatterTest.java b/src/test/java/org/jabref/logic/layout/format/DateFormatterTest.java index 6ab23b675da..7ada16578a6 100644 --- a/src/test/java/org/jabref/logic/layout/format/DateFormatterTest.java +++ b/src/test/java/org/jabref/logic/layout/format/DateFormatterTest.java @@ -2,28 +2,28 @@ import org.jabref.logic.layout.ParamLayoutFormatter; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class DateFormatterTest { private ParamLayoutFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new DateFormatter(); } @Test public void testDefaultFormat() { - Assert.assertEquals("2016-07-15", formatter.format("2016-07-15")); + assertEquals("2016-07-15", formatter.format("2016-07-15")); } @Test public void testRequestedFormat() { formatter.setArgument("MM/yyyy"); - Assert.assertEquals("07/2016", formatter.format("2016-07-15")); + assertEquals("07/2016", formatter.format("2016-07-15")); } } diff --git a/src/test/java/org/jabref/logic/layout/format/DefaultTest.java b/src/test/java/org/jabref/logic/layout/format/DefaultTest.java index 6a90b3a3f92..c4c386d2975 100644 --- a/src/test/java/org/jabref/logic/layout/format/DefaultTest.java +++ b/src/test/java/org/jabref/logic/layout/format/DefaultTest.java @@ -2,8 +2,8 @@ import org.jabref.logic.layout.ParamLayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class DefaultTest { @@ -11,39 +11,39 @@ public class DefaultTest { public void testSimpleText() { ParamLayoutFormatter a = new Default(); a.setArgument("DEFAULT TEXT"); - Assert.assertEquals("Bob Bruce", a.format("Bob Bruce")); + assertEquals("Bob Bruce", a.format("Bob Bruce")); } @Test public void testFormatNullExpectReplace() { ParamLayoutFormatter a = new Default(); a.setArgument("DEFAULT TEXT"); - Assert.assertEquals("DEFAULT TEXT", a.format(null)); + assertEquals("DEFAULT TEXT", a.format(null)); } @Test public void testFormatEmpty() { ParamLayoutFormatter a = new Default(); a.setArgument("DEFAULT TEXT"); - Assert.assertEquals("DEFAULT TEXT", a.format("")); + assertEquals("DEFAULT TEXT", a.format("")); } @Test public void testNoArgumentSet() { ParamLayoutFormatter a = new Default(); - Assert.assertEquals("Bob Bruce and Jolly Jumper", a.format("Bob Bruce and Jolly Jumper")); + assertEquals("Bob Bruce and Jolly Jumper", a.format("Bob Bruce and Jolly Jumper")); } @Test public void testNoArgumentSetNullInput() { ParamLayoutFormatter a = new Default(); - Assert.assertEquals("", a.format(null)); + assertEquals("", a.format(null)); } @Test public void testNoArgumentSetEmptyInput() { ParamLayoutFormatter a = new Default(); - Assert.assertEquals("", a.format("")); + assertEquals("", a.format("")); } } diff --git a/src/test/java/org/jabref/logic/layout/format/EntryTypeFormatterTest.java b/src/test/java/org/jabref/logic/layout/format/EntryTypeFormatterTest.java index 453278465f2..89d6850f593 100644 --- a/src/test/java/org/jabref/logic/layout/format/EntryTypeFormatterTest.java +++ b/src/test/java/org/jabref/logic/layout/format/EntryTypeFormatterTest.java @@ -1,16 +1,16 @@ package org.jabref.logic.layout.format; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class EntryTypeFormatterTest { private EntryTypeFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new EntryTypeFormatter(); } diff --git a/src/test/java/org/jabref/logic/layout/format/FileLinkTest.java b/src/test/java/org/jabref/logic/layout/format/FileLinkTest.java index 4876f79c20b..23c5c205232 100644 --- a/src/test/java/org/jabref/logic/layout/format/FileLinkTest.java +++ b/src/test/java/org/jabref/logic/layout/format/FileLinkTest.java @@ -2,17 +2,17 @@ import org.jabref.logic.layout.ParamLayoutFormatter; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; public class FileLinkTest { private FileLinkPreferences prefs; - @Before + @BeforeEach public void setUp() throws Exception { prefs = mock(FileLinkPreferences.class); } diff --git a/src/test/java/org/jabref/logic/layout/format/FirstPageTest.java b/src/test/java/org/jabref/logic/layout/format/FirstPageTest.java index f8809ed1b8c..5c20c5d7898 100644 --- a/src/test/java/org/jabref/logic/layout/format/FirstPageTest.java +++ b/src/test/java/org/jabref/logic/layout/format/FirstPageTest.java @@ -2,38 +2,38 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class FirstPageTest { @Test public void testFormatEmpty() { LayoutFormatter a = new FirstPage(); - Assert.assertEquals("", a.format("")); + assertEquals("", a.format("")); } @Test public void testFormatNull() { LayoutFormatter a = new FirstPage(); - Assert.assertEquals("", a.format(null)); + assertEquals("", a.format(null)); } @Test public void testFormatSinglePage() { LayoutFormatter a = new FirstPage(); - Assert.assertEquals("345", a.format("345")); + assertEquals("345", a.format("345")); } @Test public void testFormatSingleDash() { LayoutFormatter a = new FirstPage(); - Assert.assertEquals("345", a.format("345-350")); + assertEquals("345", a.format("345-350")); } @Test public void testFormatDoubleDash() { LayoutFormatter a = new FirstPage(); - Assert.assertEquals("345", a.format("345--350")); + assertEquals("345", a.format("345--350")); } } diff --git a/src/test/java/org/jabref/logic/layout/format/HTMLCharsTest.java b/src/test/java/org/jabref/logic/layout/format/HTMLCharsTest.java index 18a32ed6168..42d6a488683 100644 --- a/src/test/java/org/jabref/logic/layout/format/HTMLCharsTest.java +++ b/src/test/java/org/jabref/logic/layout/format/HTMLCharsTest.java @@ -2,16 +2,16 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class HTMLCharsTest { private LayoutFormatter layout; - @Before + @BeforeEach public void setUp() { layout = new HTMLChars(); } diff --git a/src/test/java/org/jabref/logic/layout/format/HTMLParagraphsTest.java b/src/test/java/org/jabref/logic/layout/format/HTMLParagraphsTest.java index ee011961aac..6cd36359c4e 100644 --- a/src/test/java/org/jabref/logic/layout/format/HTMLParagraphsTest.java +++ b/src/test/java/org/jabref/logic/layout/format/HTMLParagraphsTest.java @@ -2,8 +2,8 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class HTMLParagraphsTest { @@ -12,11 +12,11 @@ public void testFormat() { LayoutFormatter f = new HTMLParagraphs(); - Assert.assertEquals("", f.format("")); - Assert.assertEquals("

\nHello\n

", f.format("Hello")); - Assert.assertEquals("

\nHello\nWorld\n

", f.format("Hello\nWorld")); - Assert.assertEquals("

\nHello World\n

\n

\nWhat a lovely day\n

", f.format("Hello World\n \nWhat a lovely day\n")); - Assert.assertEquals("

\nHello World\n

\n

\nCould not be any better\n

\n

\nWhat a lovely day\n

", f.format("Hello World\n \n\nCould not be any better\n\nWhat a lovely day\n")); + assertEquals("", f.format("")); + assertEquals("

\nHello\n

", f.format("Hello")); + assertEquals("

\nHello\nWorld\n

", f.format("Hello\nWorld")); + assertEquals("

\nHello World\n

\n

\nWhat a lovely day\n

", f.format("Hello World\n \nWhat a lovely day\n")); + assertEquals("

\nHello World\n

\n

\nCould not be any better\n

\n

\nWhat a lovely day\n

", f.format("Hello World\n \n\nCould not be any better\n\nWhat a lovely day\n")); } diff --git a/src/test/java/org/jabref/logic/layout/format/IfPluralTest.java b/src/test/java/org/jabref/logic/layout/format/IfPluralTest.java index 26753d0ff8c..5ebd278be81 100644 --- a/src/test/java/org/jabref/logic/layout/format/IfPluralTest.java +++ b/src/test/java/org/jabref/logic/layout/format/IfPluralTest.java @@ -2,8 +2,8 @@ import org.jabref.logic.layout.ParamLayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class IfPluralTest { @@ -11,40 +11,40 @@ public class IfPluralTest { public void testStandardUsageOneEditor() { ParamLayoutFormatter a = new IfPlural(); a.setArgument("Eds.,Ed."); - Assert.assertEquals("Ed.", a.format("Bob Bruce")); + assertEquals("Ed.", a.format("Bob Bruce")); } @Test public void testStandardUsageTwoEditors() { ParamLayoutFormatter a = new IfPlural(); a.setArgument("Eds.,Ed."); - Assert.assertEquals("Eds.", a.format("Bob Bruce and Jolly Jumper")); + assertEquals("Eds.", a.format("Bob Bruce and Jolly Jumper")); } @Test public void testFormatNull() { ParamLayoutFormatter a = new IfPlural(); a.setArgument("Eds.,Ed."); - Assert.assertEquals("", a.format(null)); + assertEquals("", a.format(null)); } @Test public void testFormatEmpty() { ParamLayoutFormatter a = new IfPlural(); a.setArgument("Eds.,Ed."); - Assert.assertEquals("", a.format("")); + assertEquals("", a.format("")); } @Test public void testNoArgumentSet() { ParamLayoutFormatter a = new IfPlural(); - Assert.assertEquals("", a.format("Bob Bruce and Jolly Jumper")); + assertEquals("", a.format("Bob Bruce and Jolly Jumper")); } @Test public void testNoProperArgument() { ParamLayoutFormatter a = new IfPlural(); a.setArgument("Eds."); - Assert.assertEquals("", a.format("Bob Bruce and Jolly Jumper")); + assertEquals("", a.format("Bob Bruce and Jolly Jumper")); } } diff --git a/src/test/java/org/jabref/logic/layout/format/LastPageTest.java b/src/test/java/org/jabref/logic/layout/format/LastPageTest.java index 9590d9cd47e..64dece591f0 100644 --- a/src/test/java/org/jabref/logic/layout/format/LastPageTest.java +++ b/src/test/java/org/jabref/logic/layout/format/LastPageTest.java @@ -2,44 +2,44 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class LastPageTest { @Test public void testFormatEmpty() { LayoutFormatter a = new LastPage(); - Assert.assertEquals("", a.format("")); + assertEquals("", a.format("")); } @Test public void testFormatNull() { LayoutFormatter a = new LastPage(); - Assert.assertEquals("", a.format(null)); + assertEquals("", a.format(null)); } @Test public void testFormatSinglePage() { LayoutFormatter a = new LastPage(); - Assert.assertEquals("345", a.format("345")); + assertEquals("345", a.format("345")); } @Test public void testFormatSingleDash() { LayoutFormatter a = new LastPage(); - Assert.assertEquals("350", a.format("345-350")); + assertEquals("350", a.format("345-350")); } @Test public void testFormatDoubleDash() { LayoutFormatter a = new LastPage(); - Assert.assertEquals("350", a.format("345--350")); + assertEquals("350", a.format("345--350")); } @Test public void testFinalCoverageCase() { LayoutFormatter a = new LastPage(); - Assert.assertEquals("", a.format("--")); + assertEquals("", a.format("--")); } } diff --git a/src/test/java/org/jabref/logic/layout/format/LatexToUnicodeFormatterTest.java b/src/test/java/org/jabref/logic/layout/format/LatexToUnicodeFormatterTest.java index bf31aa7c6cc..cf4dbb86723 100644 --- a/src/test/java/org/jabref/logic/layout/format/LatexToUnicodeFormatterTest.java +++ b/src/test/java/org/jabref/logic/layout/format/LatexToUnicodeFormatterTest.java @@ -1,10 +1,9 @@ package org.jabref.logic.layout.format; -import org.junit.Ignore; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; public class LatexToUnicodeFormatterTest { @@ -103,7 +102,7 @@ public void testCombiningAccentsCase1() { assertEquals("ḩ", formatter.format("{\\c{h}}")); } - @Ignore("This is not a standard LaTeX command. It is debatable why we should convert this.") + @Disabled("This is not a standard LaTeX command. It is debatable why we should convert this.") @Test public void testCombiningAccentsCase2() { assertEquals("a͍", formatter.format("\\spreadlips{a}")); diff --git a/src/test/java/org/jabref/logic/layout/format/NameFormatterTest.java b/src/test/java/org/jabref/logic/layout/format/NameFormatterTest.java index 194226a19f2..0b5adc77462 100644 --- a/src/test/java/org/jabref/logic/layout/format/NameFormatterTest.java +++ b/src/test/java/org/jabref/logic/layout/format/NameFormatterTest.java @@ -1,7 +1,7 @@ package org.jabref.logic.layout.format; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class NameFormatterTest { @@ -10,21 +10,21 @@ public void testFormatStringStringBibtexEntry() { NameFormatter l = new NameFormatter(); - Assert.assertEquals("Doe", l.format("Joe Doe", "1@*@{ll}")); + assertEquals("Doe", l.format("Joe Doe", "1@*@{ll}")); - Assert.assertEquals("moremoremoremore", l.format("Joe Doe and Mary Jane and Bruce Bar and Arthur Kay", + assertEquals("moremoremoremore", l.format("Joe Doe and Mary Jane and Bruce Bar and Arthur Kay", "1@*@{ll}@@2@1..1@{ff}{ll}@2..2@ and {ff}{last}@@*@*@more")); - Assert.assertEquals("Doe", l.format("Joe Doe", "1@*@{ll}@@2@1..1@{ff}{ll}@2..2@ and {ff}{last}@@*@*@more")); + assertEquals("Doe", l.format("Joe Doe", "1@*@{ll}@@2@1..1@{ff}{ll}@2..2@ and {ff}{last}@@*@*@more")); - Assert.assertEquals("JoeDoe and MaryJ", + assertEquals("JoeDoe and MaryJ", l.format("Joe Doe and Mary Jane", "1@*@{ll}@@2@1..1@{ff}{ll}@2..2@ and {ff}{l}@@*@*@more")); - Assert.assertEquals("Doe, Joe and Jane, M. and Kamp, J.~A.", + assertEquals("Doe, Joe and Jane, M. and Kamp, J.~A.", l.format("Joe Doe and Mary Jane and John Arthur van Kamp", "1@*@{ll}, {ff}@@*@1@{ll}, {ff}@2..-1@ and {ll}, {f}.")); - Assert.assertEquals("Doe Joe and Jane, M. and Kamp, J.~A.", + assertEquals("Doe Joe and Jane, M. and Kamp, J.~A.", l.format("Joe Doe and Mary Jane and John Arthur van Kamp", "1@*@{ll}, {ff}@@*@1@{ll} {ff}@2..-1@ and {ll}, {f}.")); @@ -36,26 +36,26 @@ public void testFormat() { NameFormatter a = new NameFormatter(); // Empty case - Assert.assertEquals("", a.format("")); + assertEquals("", a.format("")); String formatString = "1@1@{vv }{ll}{ ff}@@2@1@{vv }{ll}{ ff}@2@ and {vv }{ll}{, ff}@@*@1@{vv }{ll}{ ff}@2..-2@, {vv }{ll}{, ff}@-1@ and {vv }{ll}{, ff}"; // Single Names - Assert.assertEquals("Vandekamp Mary~Ann", a.format("Mary Ann Vandekamp", formatString)); + assertEquals("Vandekamp Mary~Ann", a.format("Mary Ann Vandekamp", formatString)); // Two names - Assert.assertEquals("von Neumann John and Black~Brown, Peter", + assertEquals("von Neumann John and Black~Brown, Peter", a.format("John von Neumann and Black Brown, Peter", formatString)); // Three names - Assert.assertEquals("von Neumann John, Smith, John and Black~Brown, Peter", + assertEquals("von Neumann John, Smith, John and Black~Brown, Peter", a.format("von Neumann, John and Smith, John and Black Brown, Peter", formatString)); - Assert.assertEquals("von Neumann John, Smith, John and Black~Brown, Peter", + assertEquals("von Neumann John, Smith, John and Black~Brown, Peter", a.format("John von Neumann and John Smith and Black Brown, Peter", formatString)); // Four names - Assert.assertEquals("von Neumann John, Smith, John, Vandekamp, Mary~Ann and Black~Brown, Peter", a.format( + assertEquals("von Neumann John, Smith, John, Vandekamp, Mary~Ann and Black~Brown, Peter", a.format( "von Neumann, John and Smith, John and Vandekamp, Mary Ann and Black Brown, Peter", formatString)); } diff --git a/src/test/java/org/jabref/logic/layout/format/NoSpaceBetweenAbbreviationsTest.java b/src/test/java/org/jabref/logic/layout/format/NoSpaceBetweenAbbreviationsTest.java index b79664903d9..e49493fe097 100644 --- a/src/test/java/org/jabref/logic/layout/format/NoSpaceBetweenAbbreviationsTest.java +++ b/src/test/java/org/jabref/logic/layout/format/NoSpaceBetweenAbbreviationsTest.java @@ -2,19 +2,19 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class NoSpaceBetweenAbbreviationsTest { @Test public void testFormat() { LayoutFormatter f = new NoSpaceBetweenAbbreviations(); - Assert.assertEquals("", f.format("")); - Assert.assertEquals("John Meier", f.format("John Meier")); - Assert.assertEquals("J.F. Kennedy", f.format("J. F. Kennedy")); - Assert.assertEquals("J.R.R. Tolkien", f.format("J. R. R. Tolkien")); - Assert.assertEquals("J.R.R. Tolkien and J.F. Kennedy", f.format("J. R. R. Tolkien and J. F. Kennedy")); + assertEquals("", f.format("")); + assertEquals("John Meier", f.format("John Meier")); + assertEquals("J.F. Kennedy", f.format("J. F. Kennedy")); + assertEquals("J.R.R. Tolkien", f.format("J. R. R. Tolkien")); + assertEquals("J.R.R. Tolkien and J.F. Kennedy", f.format("J. R. R. Tolkien and J. F. Kennedy")); } } diff --git a/src/test/java/org/jabref/logic/layout/format/OrdinalTest.java b/src/test/java/org/jabref/logic/layout/format/OrdinalTest.java index 894e2614859..af73ab217be 100644 --- a/src/test/java/org/jabref/logic/layout/format/OrdinalTest.java +++ b/src/test/java/org/jabref/logic/layout/format/OrdinalTest.java @@ -1,9 +1,9 @@ package org.jabref.logic.layout.format; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; public class OrdinalTest { diff --git a/src/test/java/org/jabref/logic/layout/format/RTFCharsTest.java b/src/test/java/org/jabref/logic/layout/format/RTFCharsTest.java index fc89b7de057..bda54482342 100644 --- a/src/test/java/org/jabref/logic/layout/format/RTFCharsTest.java +++ b/src/test/java/org/jabref/logic/layout/format/RTFCharsTest.java @@ -3,14 +3,14 @@ import org.jabref.logic.layout.LayoutFormatter; import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class RTFCharsTest { private LayoutFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new RTFChars(); } @@ -22,44 +22,44 @@ public void tearDown() { @Test public void testBasicFormat() { - Assert.assertEquals("", formatter.format("")); + assertEquals("", formatter.format("")); - Assert.assertEquals("hallo", formatter.format("hallo")); + assertEquals("hallo", formatter.format("hallo")); - Assert.assertEquals("R\\u233eflexions sur le timing de la quantit\\u233e", + assertEquals("R\\u233eflexions sur le timing de la quantit\\u233e", formatter.format("Réflexions sur le timing de la quantité")); - Assert.assertEquals("h\\'e1llo", formatter.format("h\\'allo")); - Assert.assertEquals("h\\'e1llo", formatter.format("h\\'allo")); + assertEquals("h\\'e1llo", formatter.format("h\\'allo")); + assertEquals("h\\'e1llo", formatter.format("h\\'allo")); } @Test public void testLaTeXHighlighting() { - Assert.assertEquals("{\\i hallo}", formatter.format("\\emph{hallo}")); - Assert.assertEquals("{\\i hallo}", formatter.format("{\\emph hallo}")); - Assert.assertEquals("An article title with {\\i a book title} emphasized", formatter.format("An article title with \\emph{a book title} emphasized")); + assertEquals("{\\i hallo}", formatter.format("\\emph{hallo}")); + assertEquals("{\\i hallo}", formatter.format("{\\emph hallo}")); + assertEquals("An article title with {\\i a book title} emphasized", formatter.format("An article title with \\emph{a book title} emphasized")); - Assert.assertEquals("{\\i hallo}", formatter.format("\\textit{hallo}")); - Assert.assertEquals("{\\i hallo}", formatter.format("{\\textit hallo}")); + assertEquals("{\\i hallo}", formatter.format("\\textit{hallo}")); + assertEquals("{\\i hallo}", formatter.format("{\\textit hallo}")); - Assert.assertEquals("{\\b hallo}", formatter.format("\\textbf{hallo}")); - Assert.assertEquals("{\\b hallo}", formatter.format("{\\textbf hallo}")); + assertEquals("{\\b hallo}", formatter.format("\\textbf{hallo}")); + assertEquals("{\\b hallo}", formatter.format("{\\textbf hallo}")); } @Test public void testComplicated() { - Assert.assertEquals("R\\u233eflexions sur le timing de la quantit\\u233e {\\u230ae} should be \\u230ae", + assertEquals("R\\u233eflexions sur le timing de la quantit\\u233e {\\u230ae} should be \\u230ae", formatter.format("Réflexions sur le timing de la quantité {\\ae} should be æ")); } @Test public void testComplicated2() { - Assert.assertEquals("h\\'e1ll{\\u339oe}", formatter.format("h\\'all{\\oe}")); + assertEquals("h\\'e1ll{\\u339oe}", formatter.format("h\\'all{\\oe}")); } @Test public void testComplicated3() { - Assert.assertEquals("Le c\\u339oeur d\\u233e\\u231cu mais l'\\u226ame plut\\u244ot na\\u239ive, Lou\\u255ys r" + + assertEquals("Le c\\u339oeur d\\u233e\\u231cu mais l'\\u226ame plut\\u244ot na\\u239ive, Lou\\u255ys r" + "\\u234eva de crapa\\u252?ter en cano\\u235e au del\\u224a des \\u238iles, pr\\u232es du m\\u228alstr" + "\\u246om o\\u249u br\\u251ulent les nov\\u230ae.", formatter.format("Le cœur déçu mais l'âme plutôt " + "naïve, Louÿs rêva de crapaüter en canoë au delà des îles, près du mälström où brûlent les novæ.")); @@ -67,7 +67,7 @@ public void testComplicated3() { @Test public void testComplicated4() { - Assert.assertEquals("l'\\u238ile exigu\\u235e\n" + + assertEquals("l'\\u238ile exigu\\u235e\n" + " O\\u249u l'ob\\u232ese jury m\\u251ur\n" + " F\\u234ete l'ha\\u239i volap\\u252?k,\n" + " \\u194Ane ex a\\u233equo au whist,\n" + @@ -80,109 +80,109 @@ public void testComplicated4() { @Test public void testComplicated5() { - Assert.assertEquals("\\u193Arv\\u237izt\\u369?r\\u337? t\\u252?k\\u246orf\\u250ur\\u243og\\u233ep", + assertEquals("\\u193Arv\\u237izt\\u369?r\\u337? t\\u252?k\\u246orf\\u250ur\\u243og\\u233ep", formatter.format("Árvíztűrő tükörfúrógép")); } @Test public void testComplicated6() { - Assert.assertEquals("Pchn\\u261a\\u263c w t\\u281e \\u322l\\u243od\\u378z je\\u380za lub o\\u347sm skrzy\\u324n fig" + assertEquals("Pchn\\u261a\\u263c w t\\u281e \\u322l\\u243od\\u378z je\\u380za lub o\\u347sm skrzy\\u324n fig" ,formatter.format("Pchnąć w tę łódź jeża lub ośm skrzyń fig")); } @Test public void testSpecialCharacters() { - Assert.assertEquals("\\'f3", formatter.format("\\'{o}")); // ó - Assert.assertEquals("\\'f2", formatter.format("\\`{o}")); // ò - Assert.assertEquals("\\'f4", formatter.format("\\^{o}")); // ô - Assert.assertEquals("\\'f6", formatter.format("\\\"{o}")); // ö - Assert.assertEquals("\\u245o", formatter.format("\\~{o}")); // õ - Assert.assertEquals("\\u333o", formatter.format("\\={o}")); - Assert.assertEquals("\\u335o", formatter.format("{\\uo}")); - Assert.assertEquals("\\u231c", formatter.format("{\\cc}")); // ç - Assert.assertEquals("{\\u339oe}", formatter.format("{\\oe}")); - Assert.assertEquals("{\\u338OE}", formatter.format("{\\OE}")); - Assert.assertEquals("{\\u230ae}", formatter.format("{\\ae}")); // æ - Assert.assertEquals("{\\u198AE}", formatter.format("{\\AE}")); // Æ - - Assert.assertEquals("", formatter.format("\\.{o}")); // ??? - Assert.assertEquals("", formatter.format("\\vo")); // ??? - Assert.assertEquals("", formatter.format("\\Ha")); // ã // ??? - Assert.assertEquals("", formatter.format("\\too")); - Assert.assertEquals("", formatter.format("\\do")); // ??? - Assert.assertEquals("", formatter.format("\\bo")); // ??? - Assert.assertEquals("\\u229a", formatter.format("{\\aa}")); // å - Assert.assertEquals("\\u197A", formatter.format("{\\AA}")); // Å - Assert.assertEquals("\\u248o", formatter.format("{\\o}")); // ø - Assert.assertEquals("\\u216O", formatter.format("{\\O}")); // Ø - Assert.assertEquals("\\u322l", formatter.format("{\\l}")); - Assert.assertEquals("\\u321L", formatter.format("{\\L}")); - Assert.assertEquals("\\u223ss", formatter.format("{\\ss}")); // ß - Assert.assertEquals("\\u191?", formatter.format("\\`?")); // ¿ - Assert.assertEquals("\\u161!", formatter.format("\\`!")); // ¡ - - Assert.assertEquals("", formatter.format("\\dag")); - Assert.assertEquals("", formatter.format("\\ddag")); - Assert.assertEquals("\\u167S", formatter.format("{\\S}")); // § - Assert.assertEquals("\\u182P", formatter.format("{\\P}")); // ¶ - Assert.assertEquals("\\u169?", formatter.format("{\\copyright}")); // © - Assert.assertEquals("\\u163?", formatter.format("{\\pounds}")); // £ + assertEquals("\\'f3", formatter.format("\\'{o}")); // ó + assertEquals("\\'f2", formatter.format("\\`{o}")); // ò + assertEquals("\\'f4", formatter.format("\\^{o}")); // ô + assertEquals("\\'f6", formatter.format("\\\"{o}")); // ö + assertEquals("\\u245o", formatter.format("\\~{o}")); // õ + assertEquals("\\u333o", formatter.format("\\={o}")); + assertEquals("\\u335o", formatter.format("{\\uo}")); + assertEquals("\\u231c", formatter.format("{\\cc}")); // ç + assertEquals("{\\u339oe}", formatter.format("{\\oe}")); + assertEquals("{\\u338OE}", formatter.format("{\\OE}")); + assertEquals("{\\u230ae}", formatter.format("{\\ae}")); // æ + assertEquals("{\\u198AE}", formatter.format("{\\AE}")); // Æ + + assertEquals("", formatter.format("\\.{o}")); // ??? + assertEquals("", formatter.format("\\vo")); // ??? + assertEquals("", formatter.format("\\Ha")); // ã // ??? + assertEquals("", formatter.format("\\too")); + assertEquals("", formatter.format("\\do")); // ??? + assertEquals("", formatter.format("\\bo")); // ??? + assertEquals("\\u229a", formatter.format("{\\aa}")); // å + assertEquals("\\u197A", formatter.format("{\\AA}")); // Å + assertEquals("\\u248o", formatter.format("{\\o}")); // ø + assertEquals("\\u216O", formatter.format("{\\O}")); // Ø + assertEquals("\\u322l", formatter.format("{\\l}")); + assertEquals("\\u321L", formatter.format("{\\L}")); + assertEquals("\\u223ss", formatter.format("{\\ss}")); // ß + assertEquals("\\u191?", formatter.format("\\`?")); // ¿ + assertEquals("\\u161!", formatter.format("\\`!")); // ¡ + + assertEquals("", formatter.format("\\dag")); + assertEquals("", formatter.format("\\ddag")); + assertEquals("\\u167S", formatter.format("{\\S}")); // § + assertEquals("\\u182P", formatter.format("{\\P}")); // ¶ + assertEquals("\\u169?", formatter.format("{\\copyright}")); // © + assertEquals("\\u163?", formatter.format("{\\pounds}")); // £ } @Test public void testRTFCharacters(){ - Assert.assertEquals("\\'e0",formatter.format("\\`{a}")); - Assert.assertEquals("\\'e8",formatter.format("\\`{e}")); - Assert.assertEquals("\\'ec",formatter.format("\\`{i}")); - Assert.assertEquals("\\'f2",formatter.format("\\`{o}")); - Assert.assertEquals("\\'f9",formatter.format("\\`{u}")); - - Assert.assertEquals("\\'e1",formatter.format("\\'a")); - Assert.assertEquals("\\'e9",formatter.format("\\'e")); - Assert.assertEquals("\\'ed",formatter.format("\\'i")); - Assert.assertEquals("\\'f3",formatter.format("\\'o")); - Assert.assertEquals("\\'fa",formatter.format("\\'u")); - - Assert.assertEquals("\\'e2",formatter.format("\\^a")); - Assert.assertEquals("\\'ea",formatter.format("\\^e")); - Assert.assertEquals("\\'ee",formatter.format("\\^i")); - Assert.assertEquals("\\'f4",formatter.format("\\^o")); - Assert.assertEquals("\\'fa",formatter.format("\\^u")); - - Assert.assertEquals("\\'e4",formatter.format("\\\"a")); - Assert.assertEquals("\\'eb",formatter.format("\\\"e")); - Assert.assertEquals("\\'ef",formatter.format("\\\"i")); - Assert.assertEquals("\\'f6",formatter.format("\\\"o")); - Assert.assertEquals("\\u252u",formatter.format("\\\"u")); - - Assert.assertEquals("\\'f1",formatter.format("\\~n")); + assertEquals("\\'e0",formatter.format("\\`{a}")); + assertEquals("\\'e8",formatter.format("\\`{e}")); + assertEquals("\\'ec",formatter.format("\\`{i}")); + assertEquals("\\'f2",formatter.format("\\`{o}")); + assertEquals("\\'f9",formatter.format("\\`{u}")); + + assertEquals("\\'e1",formatter.format("\\'a")); + assertEquals("\\'e9",formatter.format("\\'e")); + assertEquals("\\'ed",formatter.format("\\'i")); + assertEquals("\\'f3",formatter.format("\\'o")); + assertEquals("\\'fa",formatter.format("\\'u")); + + assertEquals("\\'e2",formatter.format("\\^a")); + assertEquals("\\'ea",formatter.format("\\^e")); + assertEquals("\\'ee",formatter.format("\\^i")); + assertEquals("\\'f4",formatter.format("\\^o")); + assertEquals("\\'fa",formatter.format("\\^u")); + + assertEquals("\\'e4",formatter.format("\\\"a")); + assertEquals("\\'eb",formatter.format("\\\"e")); + assertEquals("\\'ef",formatter.format("\\\"i")); + assertEquals("\\'f6",formatter.format("\\\"o")); + assertEquals("\\u252u",formatter.format("\\\"u")); + + assertEquals("\\'f1",formatter.format("\\~n")); } @Test public void testRTFCharactersCapital() { - Assert.assertEquals("\\'c0",formatter.format("\\`A")); - Assert.assertEquals("\\'c8",formatter.format("\\`E")); - Assert.assertEquals("\\'cc",formatter.format("\\`I")); - Assert.assertEquals("\\'d2",formatter.format("\\`O")); - Assert.assertEquals("\\'d9",formatter.format("\\`U")); - - Assert.assertEquals("\\'c1",formatter.format("\\'A")); - Assert.assertEquals("\\'c9",formatter.format("\\'E")); - Assert.assertEquals("\\'cd",formatter.format("\\'I")); - Assert.assertEquals("\\'d3",formatter.format("\\'O")); - Assert.assertEquals("\\'da",formatter.format("\\'U")); - - Assert.assertEquals("\\'c2",formatter.format("\\^A")); - Assert.assertEquals("\\'ca",formatter.format("\\^E")); - Assert.assertEquals("\\'ce",formatter.format("\\^I")); - Assert.assertEquals("\\'d4",formatter.format("\\^O")); - Assert.assertEquals("\\'db",formatter.format("\\^U")); - - Assert.assertEquals("\\'c4",formatter.format("\\\"A")); - Assert.assertEquals("\\'cb",formatter.format("\\\"E")); - Assert.assertEquals("\\'cf",formatter.format("\\\"I")); - Assert.assertEquals("\\'d6",formatter.format("\\\"O")); - Assert.assertEquals("\\'dc",formatter.format("\\\"U")); + assertEquals("\\'c0",formatter.format("\\`A")); + assertEquals("\\'c8",formatter.format("\\`E")); + assertEquals("\\'cc",formatter.format("\\`I")); + assertEquals("\\'d2",formatter.format("\\`O")); + assertEquals("\\'d9",formatter.format("\\`U")); + + assertEquals("\\'c1",formatter.format("\\'A")); + assertEquals("\\'c9",formatter.format("\\'E")); + assertEquals("\\'cd",formatter.format("\\'I")); + assertEquals("\\'d3",formatter.format("\\'O")); + assertEquals("\\'da",formatter.format("\\'U")); + + assertEquals("\\'c2",formatter.format("\\^A")); + assertEquals("\\'ca",formatter.format("\\^E")); + assertEquals("\\'ce",formatter.format("\\^I")); + assertEquals("\\'d4",formatter.format("\\^O")); + assertEquals("\\'db",formatter.format("\\^U")); + + assertEquals("\\'c4",formatter.format("\\\"A")); + assertEquals("\\'cb",formatter.format("\\\"E")); + assertEquals("\\'cf",formatter.format("\\\"I")); + assertEquals("\\'d6",formatter.format("\\\"O")); + assertEquals("\\'dc",formatter.format("\\\"U")); } } diff --git a/src/test/java/org/jabref/logic/layout/format/RemoveBracketsAddCommaTest.java b/src/test/java/org/jabref/logic/layout/format/RemoveBracketsAddCommaTest.java index 7c1bb212cd8..e805bbf5490 100644 --- a/src/test/java/org/jabref/logic/layout/format/RemoveBracketsAddCommaTest.java +++ b/src/test/java/org/jabref/logic/layout/format/RemoveBracketsAddCommaTest.java @@ -2,15 +2,15 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class RemoveBracketsAddCommaTest { private LayoutFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new RemoveBracketsAddComma(); } diff --git a/src/test/java/org/jabref/logic/layout/format/RemoveBracketsTest.java b/src/test/java/org/jabref/logic/layout/format/RemoveBracketsTest.java index fff8e9e8775..48c904c40bc 100644 --- a/src/test/java/org/jabref/logic/layout/format/RemoveBracketsTest.java +++ b/src/test/java/org/jabref/logic/layout/format/RemoveBracketsTest.java @@ -2,15 +2,15 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class RemoveBracketsTest { private LayoutFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new RemoveBrackets(); } diff --git a/src/test/java/org/jabref/logic/layout/format/RemoveTildeTest.java b/src/test/java/org/jabref/logic/layout/format/RemoveTildeTest.java index aa96bd3c53e..31406596bfe 100644 --- a/src/test/java/org/jabref/logic/layout/format/RemoveTildeTest.java +++ b/src/test/java/org/jabref/logic/layout/format/RemoveTildeTest.java @@ -2,27 +2,27 @@ import org.jabref.logic.layout.LayoutFormatter; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class RemoveTildeTest { private LayoutFormatter formatter; - @Before + @BeforeEach public void setUp() { formatter = new RemoveTilde(); } @Test public void testFormatString() { - Assert.assertEquals("", formatter.format("")); - Assert.assertEquals("simple", formatter.format("simple")); - Assert.assertEquals(" ", formatter.format("~")); - Assert.assertEquals(" ", formatter.format("~~~")); - Assert.assertEquals(" \\~ ", formatter.format("~\\~~")); - Assert.assertEquals("\\\\ ", formatter.format("\\\\~")); - Assert.assertEquals("Doe Joe and Jane, M. and Kamp, J. A.", formatter.format("Doe Joe and Jane, M. and Kamp, J.~A.")); - Assert.assertEquals("T\\~olkien, J. R. R.", formatter.format("T\\~olkien, J.~R.~R.")); + assertEquals("", formatter.format("")); + assertEquals("simple", formatter.format("simple")); + assertEquals(" ", formatter.format("~")); + assertEquals(" ", formatter.format("~~~")); + assertEquals(" \\~ ", formatter.format("~\\~~")); + assertEquals("\\\\ ", formatter.format("\\\\~")); + assertEquals("Doe Joe and Jane, M. and Kamp, J. A.", formatter.format("Doe Joe and Jane, M. and Kamp, J.~A.")); + assertEquals("T\\~olkien, J. R. R.", formatter.format("T\\~olkien, J.~R.~R.")); } } diff --git a/src/test/java/org/jabref/logic/layout/format/RemoveWhitespaceTest.java b/src/test/java/org/jabref/logic/layout/format/RemoveWhitespaceTest.java index f80eb543a54..96e92bbac0b 100644 --- a/src/test/java/org/jabref/logic/layout/format/RemoveWhitespaceTest.java +++ b/src/test/java/org/jabref/logic/layout/format/RemoveWhitespaceTest.java @@ -1,9 +1,9 @@ package org.jabref.logic.layout.format; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; public class RemoveWhitespaceTest { diff --git a/src/test/java/org/jabref/logic/layout/format/ReplaceTest.java b/src/test/java/org/jabref/logic/layout/format/ReplaceTest.java index ef1638f29e7..e5653beb9f7 100644 --- a/src/test/java/org/jabref/logic/layout/format/ReplaceTest.java +++ b/src/test/java/org/jabref/logic/layout/format/ReplaceTest.java @@ -2,8 +2,8 @@ import org.jabref.logic.layout.ParamLayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class ReplaceTest { @@ -11,40 +11,40 @@ public class ReplaceTest { public void testSimpleText() { ParamLayoutFormatter a = new Replace(); a.setArgument("Bob,Ben"); - Assert.assertEquals("Ben Bruce", a.format("Bob Bruce")); + assertEquals("Ben Bruce", a.format("Bob Bruce")); } @Test public void testSimpleTextNoHit() { ParamLayoutFormatter a = new Replace(); a.setArgument("Bob,Ben"); - Assert.assertEquals("Jolly Jumper", a.format("Jolly Jumper")); + assertEquals("Jolly Jumper", a.format("Jolly Jumper")); } @Test public void testFormatNull() { ParamLayoutFormatter a = new Replace(); a.setArgument("Eds.,Ed."); - Assert.assertEquals(null, a.format(null)); + assertEquals(null, a.format(null)); } @Test public void testFormatEmpty() { ParamLayoutFormatter a = new Replace(); a.setArgument("Eds.,Ed."); - Assert.assertEquals("", a.format("")); + assertEquals("", a.format("")); } @Test public void testNoArgumentSet() { ParamLayoutFormatter a = new Replace(); - Assert.assertEquals("Bob Bruce and Jolly Jumper", a.format("Bob Bruce and Jolly Jumper")); + assertEquals("Bob Bruce and Jolly Jumper", a.format("Bob Bruce and Jolly Jumper")); } @Test public void testNoProperArgument() { ParamLayoutFormatter a = new Replace(); a.setArgument("Eds."); - Assert.assertEquals("Bob Bruce and Jolly Jumper", a.format("Bob Bruce and Jolly Jumper")); + assertEquals("Bob Bruce and Jolly Jumper", a.format("Bob Bruce and Jolly Jumper")); } } diff --git a/src/test/java/org/jabref/logic/layout/format/RisKeywordsTest.java b/src/test/java/org/jabref/logic/layout/format/RisKeywordsTest.java index 2ae02021f35..3cf2333bab6 100644 --- a/src/test/java/org/jabref/logic/layout/format/RisKeywordsTest.java +++ b/src/test/java/org/jabref/logic/layout/format/RisKeywordsTest.java @@ -2,9 +2,9 @@ import org.jabref.logic.util.OS; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class RisKeywordsTest { diff --git a/src/test/java/org/jabref/logic/layout/format/RisMonthTest.java b/src/test/java/org/jabref/logic/layout/format/RisMonthTest.java index 40d87e2b3a8..b3880bec7cb 100644 --- a/src/test/java/org/jabref/logic/layout/format/RisMonthTest.java +++ b/src/test/java/org/jabref/logic/layout/format/RisMonthTest.java @@ -1,8 +1,8 @@ package org.jabref.logic.layout.format; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class RisMonthTest { diff --git a/src/test/java/org/jabref/logic/layout/format/ToLowerCaseTest.java b/src/test/java/org/jabref/logic/layout/format/ToLowerCaseTest.java index 9feb7b566ad..59ce12216b5 100644 --- a/src/test/java/org/jabref/logic/layout/format/ToLowerCaseTest.java +++ b/src/test/java/org/jabref/logic/layout/format/ToLowerCaseTest.java @@ -1,9 +1,9 @@ package org.jabref.logic.layout.format; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; public class ToLowerCaseTest { diff --git a/src/test/java/org/jabref/logic/layout/format/ToUpperCaseTest.java b/src/test/java/org/jabref/logic/layout/format/ToUpperCaseTest.java index 40ae527c155..b0ca246bdd9 100644 --- a/src/test/java/org/jabref/logic/layout/format/ToUpperCaseTest.java +++ b/src/test/java/org/jabref/logic/layout/format/ToUpperCaseTest.java @@ -1,9 +1,9 @@ package org.jabref.logic.layout.format; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; public class ToUpperCaseTest { diff --git a/src/test/java/org/jabref/logic/layout/format/WrapContentTest.java b/src/test/java/org/jabref/logic/layout/format/WrapContentTest.java index 64d53167238..58e9e54c94e 100644 --- a/src/test/java/org/jabref/logic/layout/format/WrapContentTest.java +++ b/src/test/java/org/jabref/logic/layout/format/WrapContentTest.java @@ -2,8 +2,8 @@ import org.jabref.logic.layout.ParamLayoutFormatter; -import org.junit.Assert; -import org.junit.Test; +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; public class WrapContentTest { @@ -11,54 +11,54 @@ public class WrapContentTest { public void testSimpleText() { ParamLayoutFormatter a = new WrapContent(); a.setArgument("<,>"); - Assert.assertEquals("", a.format("Bob")); + assertEquals("", a.format("Bob")); } @Test public void testEmptyStart() { ParamLayoutFormatter a = new WrapContent(); a.setArgument(",:"); - Assert.assertEquals("Bob:", a.format("Bob")); + assertEquals("Bob:", a.format("Bob")); } @Test public void testEmptyEnd() { ParamLayoutFormatter a = new WrapContent(); a.setArgument("Content: ,"); - Assert.assertEquals("Content: Bob", a.format("Bob")); + assertEquals("Content: Bob", a.format("Bob")); } @Test public void testEscaping() { ParamLayoutFormatter a = new WrapContent(); a.setArgument("Name\\,Field\\,,\\,Author"); - Assert.assertEquals("Name,Field,Bob,Author", a.format("Bob")); + assertEquals("Name,Field,Bob,Author", a.format("Bob")); } @Test public void testFormatNullExpectNothingAdded() { ParamLayoutFormatter a = new WrapContent(); a.setArgument("Eds.,Ed."); - Assert.assertEquals(null, a.format(null)); + assertEquals(null, a.format(null)); } @Test public void testFormatEmptyExpectNothingAdded() { ParamLayoutFormatter a = new WrapContent(); a.setArgument("Eds.,Ed."); - Assert.assertEquals("", a.format("")); + assertEquals("", a.format("")); } @Test public void testNoArgumentSetExpectNothingAdded() { ParamLayoutFormatter a = new WrapContent(); - Assert.assertEquals("Bob Bruce and Jolly Jumper", a.format("Bob Bruce and Jolly Jumper")); + assertEquals("Bob Bruce and Jolly Jumper", a.format("Bob Bruce and Jolly Jumper")); } @Test public void testNoProperArgumentExpectNothingAdded() { ParamLayoutFormatter a = new WrapContent(); a.setArgument("Eds."); - Assert.assertEquals("Bob Bruce and Jolly Jumper", a.format("Bob Bruce and Jolly Jumper")); + assertEquals("Bob Bruce and Jolly Jumper", a.format("Bob Bruce and Jolly Jumper")); } } diff --git a/src/test/java/org/jabref/logic/layout/format/WrapFileLinksTest.java b/src/test/java/org/jabref/logic/layout/format/WrapFileLinksTest.java index 08861c389d3..05dfc422f2b 100644 --- a/src/test/java/org/jabref/logic/layout/format/WrapFileLinksTest.java +++ b/src/test/java/org/jabref/logic/layout/format/WrapFileLinksTest.java @@ -4,11 +4,11 @@ import java.io.IOException; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class WrapFileLinksTest { @@ -16,7 +16,7 @@ public class WrapFileLinksTest { private WrapFileLinks formatter; - @Before + @BeforeEach public void setUp() { FileLinkPreferences preferences = new FileLinkPreferences(Collections.emptyList(), Collections.emptyList()); formatter = new WrapFileLinks(preferences); @@ -32,10 +32,9 @@ public void testNull() { assertEquals("", formatter.format(null)); } - @Test(expected = NullPointerException.class) public void testNoFormatSetNonEmptyString() { - formatter.format("test.pdf"); - fail(); + assertThrows(NullPointerException.class, () -> formatter.format("test.pdf")); + } @Test diff --git a/src/test/java/org/jabref/logic/msbib/MsBibAuthorTest.java b/src/test/java/org/jabref/logic/msbib/MsBibAuthorTest.java index 9a7dd384ca8..328f90566ad 100644 --- a/src/test/java/org/jabref/logic/msbib/MsBibAuthorTest.java +++ b/src/test/java/org/jabref/logic/msbib/MsBibAuthorTest.java @@ -2,9 +2,9 @@ import org.jabref.model.entry.Author; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class MsBibAuthorTest { diff --git a/src/test/java/org/jabref/logic/net/MimeTypeDetectorTest.java b/src/test/java/org/jabref/logic/net/MimeTypeDetectorTest.java index ce6efd9f64b..225808a91ee 100644 --- a/src/test/java/org/jabref/logic/net/MimeTypeDetectorTest.java +++ b/src/test/java/org/jabref/logic/net/MimeTypeDetectorTest.java @@ -17,8 +17,8 @@ import static org.junit.Assert.assertTrue; public class MimeTypeDetectorTest { - @Rule - public WireMockRule wireMockRule = new WireMockRule(); + + @Rule public WireMockRule wireMockRule = new WireMockRule(); @Test public void handlePermanentRedirections() throws IOException { diff --git a/src/test/java/org/jabref/logic/net/URLDownloadTest.java b/src/test/java/org/jabref/logic/net/URLDownloadTest.java index 0f17db0851c..2f830ce98e3 100644 --- a/src/test/java/org/jabref/logic/net/URLDownloadTest.java +++ b/src/test/java/org/jabref/logic/net/URLDownloadTest.java @@ -6,8 +6,10 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Path; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class URLDownloadTest { @@ -15,15 +17,14 @@ public class URLDownloadTest { public void testStringDownloadWithSetEncoding() throws IOException { URLDownload dl = new URLDownload(new URL("http://www.google.com")); - Assert.assertTrue("google.com should contain google", dl.asString().contains("Google")); + assertTrue(dl.asString().contains("Google"), "google.com should contain google"); } @Test public void testStringDownload() throws IOException { URLDownload dl = new URLDownload(new URL("http://www.google.com")); - Assert.assertTrue("google.com should contain google", - dl.asString(StandardCharsets.UTF_8).contains("Google")); + assertTrue(dl.asString(StandardCharsets.UTF_8).contains("Google"), "google.com should contain google"); } @Test @@ -32,7 +33,7 @@ public void testFileDownload() throws IOException { try { URLDownload dl = new URLDownload(new URL("http://www.google.com")); dl.toFile(destination.toPath()); - Assert.assertTrue("file must exist", destination.exists()); + assertTrue(destination.exists(), "file must exist"); } finally { // cleanup if (!destination.delete()) { @@ -45,7 +46,7 @@ public void testFileDownload() throws IOException { public void testDetermineMimeType() throws IOException { URLDownload dl = new URLDownload(new URL("http://www.google.com")); - Assert.assertTrue(dl.getMimeType().startsWith("text/html")); + assertTrue(dl.getMimeType().startsWith("text/html")); } @Test @@ -53,7 +54,7 @@ public void downloadToTemporaryFilePathWithoutFileSavesAsTmpFile() throws IOExce URLDownload google = new URLDownload(new URL("http://www.google.com")); String path = google.toTemporaryFile().toString(); - Assert.assertTrue(path, path.endsWith(".tmp")); + assertTrue(path.endsWith(".tmp"), path); } @Test @@ -61,7 +62,7 @@ public void downloadToTemporaryFileKeepsName() throws IOException { URLDownload google = new URLDownload(new URL("https://github.com/JabRef/jabref/blob/master/LICENSE.md")); String path = google.toTemporaryFile().toString(); - Assert.assertTrue(path, path.contains("LICENSE") && path.endsWith(".md")); + assertTrue(path.contains("LICENSE") && path.endsWith(".md"), path); } @Test @@ -69,7 +70,7 @@ public void downloadOfFTPSucceeds() throws IOException { URLDownload ftp = new URLDownload(new URL("ftp://ftp.informatik.uni-stuttgart.de/pub/library/ncstrl.ustuttgart_fi/INPROC-2016-15/INPROC-2016-15.pdf")); Path path = ftp.toTemporaryFile(); - Assert.assertNotNull(path); + assertNotNull(path); } @Test @@ -77,7 +78,7 @@ public void downloadOfHttpSucceeds() throws IOException { URLDownload ftp = new URLDownload(new URL("http://www.jabref.org")); Path path = ftp.toTemporaryFile(); - Assert.assertNotNull(path); + assertNotNull(path); } @Test @@ -85,7 +86,7 @@ public void downloadOfHttpsSucceeds() throws IOException { URLDownload ftp = new URLDownload(new URL("https://www.jabref.org")); Path path = ftp.toTemporaryFile(); - Assert.assertNotNull(path); + assertNotNull(path); } } diff --git a/src/test/java/org/jabref/logic/net/URLUtilTest.java b/src/test/java/org/jabref/logic/net/URLUtilTest.java index 01cd062cd1b..69815f1cf3e 100644 --- a/src/test/java/org/jabref/logic/net/URLUtilTest.java +++ b/src/test/java/org/jabref/logic/net/URLUtilTest.java @@ -1,76 +1,74 @@ package org.jabref.logic.net; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class URLUtilTest { + @Test public void cleanGoogleSearchURL() throws Exception { // empty text - Assert.assertEquals("", URLUtil.cleanGoogleSearchURL("")); - Assert.assertEquals(" ", URLUtil.cleanGoogleSearchURL(" ")); + assertEquals("", URLUtil.cleanGoogleSearchURL("")); + assertEquals(" ", URLUtil.cleanGoogleSearchURL(" ")); // no URL - Assert.assertEquals("this is no url!", URLUtil.cleanGoogleSearchURL("this is no url!")); + assertEquals("this is no url!", URLUtil.cleanGoogleSearchURL("this is no url!")); // no Google search URL - Assert.assertEquals("http://dl.acm.org/citation.cfm?id=321811", URLUtil.cleanGoogleSearchURL("http://dl.acm.org/citation.cfm?id=321811")); + assertEquals("http://dl.acm.org/citation.cfm?id=321811", URLUtil.cleanGoogleSearchURL("http://dl.acm.org/citation.cfm?id=321811")); // malformed Google URL - Assert.assertEquals("https://www.google.de/url♥", URLUtil.cleanGoogleSearchURL("https://www.google.de/url♥")); + assertEquals("https://www.google.de/url♥", URLUtil.cleanGoogleSearchURL("https://www.google.de/url♥")); // no queries - Assert.assertEquals("https://www.google.de/url", URLUtil.cleanGoogleSearchURL("https://www.google.de/url")); - Assert.assertEquals("https://www.google.de/url?", URLUtil.cleanGoogleSearchURL("https://www.google.de/url?")); + assertEquals("https://www.google.de/url", URLUtil.cleanGoogleSearchURL("https://www.google.de/url")); + assertEquals("https://www.google.de/url?", URLUtil.cleanGoogleSearchURL("https://www.google.de/url?")); // no multiple queries - Assert.assertEquals("https://www.google.de/url?key=value", URLUtil.cleanGoogleSearchURL("https://www.google.de/url?key=value")); + assertEquals("https://www.google.de/url?key=value", URLUtil.cleanGoogleSearchURL("https://www.google.de/url?key=value")); // no key values - Assert.assertEquals("https://www.google.de/url?key", URLUtil.cleanGoogleSearchURL("https://www.google.de/url?key")); - Assert.assertEquals("https://www.google.de/url?url", URLUtil.cleanGoogleSearchURL("https://www.google.de/url?url")); - Assert.assertEquals("https://www.google.de/url?key=", URLUtil.cleanGoogleSearchURL("https://www.google.de/url?key=")); + assertEquals("https://www.google.de/url?key", URLUtil.cleanGoogleSearchURL("https://www.google.de/url?key")); + assertEquals("https://www.google.de/url?url", URLUtil.cleanGoogleSearchURL("https://www.google.de/url?url")); + assertEquals("https://www.google.de/url?key=", URLUtil.cleanGoogleSearchURL("https://www.google.de/url?key=")); // no url param - Assert.assertEquals("https://www.google.de/url?key=value&key2=value2", URLUtil.cleanGoogleSearchURL("https://www.google.de/url?key=value&key2=value2")); + assertEquals("https://www.google.de/url?key=value&key2=value2", URLUtil.cleanGoogleSearchURL("https://www.google.de/url?key=value&key2=value2")); // no url param value - Assert.assertEquals("https://www.google.de/url?url=", URLUtil.cleanGoogleSearchURL("https://www.google.de/url?url=")); + assertEquals("https://www.google.de/url?url=", URLUtil.cleanGoogleSearchURL("https://www.google.de/url?url=")); // url param value no URL - Assert.assertEquals("https://www.google.de/url?url=this+is+no+url", URLUtil.cleanGoogleSearchURL("https://www.google.de/url?url=this+is+no+url")); + assertEquals("https://www.google.de/url?url=this+is+no+url", URLUtil.cleanGoogleSearchURL("https://www.google.de/url?url=this+is+no+url")); // Http - Assert.assertEquals( + assertEquals( "http://moz.com/ugc/the-ultimate-guide-to-the-google-search-parameters", - URLUtil.cleanGoogleSearchURL("http://www.google.de/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCEQFjAAahUKEwjJurHd2sfHAhWBsxQKHSrEAaM&url=http%3A%2F%2Fmoz.com%2Fugc%2Fthe-ultimate-guide-to-the-google-search-parameters&ei=0THeVYmOJIHnUqqIh5gK&usg=AFQjCNHnid_r_d2LP8_MqvI7lQnTC3lB_g&sig2=ICzxDroG2ENTJSUGmdhI2w") - ); + URLUtil.cleanGoogleSearchURL("http://www.google.de/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCEQFjAAahUKEwjJurHd2sfHAhWBsxQKHSrEAaM&url=http%3A%2F%2Fmoz.com%2Fugc%2Fthe-ultimate-guide-to-the-google-search-parameters&ei=0THeVYmOJIHnUqqIh5gK&usg=AFQjCNHnid_r_d2LP8_MqvI7lQnTC3lB_g&sig2=ICzxDroG2ENTJSUGmdhI2w")); // Https - Assert.assertEquals( + assertEquals( "https://moz.com/ugc/the-ultimate-guide-to-the-google-search-parameters", - URLUtil.cleanGoogleSearchURL("https://www.google.de/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCEQFjAAahUKEwjJurHd2sfHAhWBsxQKHSrEAaM&url=https%3A%2F%2Fmoz.com%2Fugc%2Fthe-ultimate-guide-to-the-google-search-parameters&ei=0THeVYmOJIHnUqqIh5gK&usg=AFQjCNHnid_r_d2LP8_MqvI7lQnTC3lB_g&sig2=ICzxDroG2ENTJSUGmdhI2w") - ); + URLUtil.cleanGoogleSearchURL("https://www.google.de/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCEQFjAAahUKEwjJurHd2sfHAhWBsxQKHSrEAaM&url=https%3A%2F%2Fmoz.com%2Fugc%2Fthe-ultimate-guide-to-the-google-search-parameters&ei=0THeVYmOJIHnUqqIh5gK&usg=AFQjCNHnid_r_d2LP8_MqvI7lQnTC3lB_g&sig2=ICzxDroG2ENTJSUGmdhI2w")); // root domain - Assert.assertEquals( + assertEquals( "https://moz.com/ugc/the-ultimate-guide-to-the-google-search-parameters", - URLUtil.cleanGoogleSearchURL("https://google.de/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCEQFjAAahUKEwjJurHd2sfHAhWBsxQKHSrEAaM&url=https%3A%2F%2Fmoz.com%2Fugc%2Fthe-ultimate-guide-to-the-google-search-parameters&ei=0THeVYmOJIHnUqqIh5gK&usg=AFQjCNHnid_r_d2LP8_MqvI7lQnTC3lB_g&sig2=ICzxDroG2ENTJSUGmdhI2w") - ); + URLUtil.cleanGoogleSearchURL("https://google.de/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCEQFjAAahUKEwjJurHd2sfHAhWBsxQKHSrEAaM&url=https%3A%2F%2Fmoz.com%2Fugc%2Fthe-ultimate-guide-to-the-google-search-parameters&ei=0THeVYmOJIHnUqqIh5gK&usg=AFQjCNHnid_r_d2LP8_MqvI7lQnTC3lB_g&sig2=ICzxDroG2ENTJSUGmdhI2w")); // foreign domain - Assert.assertEquals( + assertEquals( "https://moz.com/ugc/the-ultimate-guide-to-the-google-search-parameters", - URLUtil.cleanGoogleSearchURL("https://www.google.fr/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCEQFjAAahUKEwjJurHd2sfHAhWBsxQKHSrEAaM&url=https%3A%2F%2Fmoz.com%2Fugc%2Fthe-ultimate-guide-to-the-google-search-parameters&ei=0THeVYmOJIHnUqqIh5gK&usg=AFQjCNHnid_r_d2LP8_MqvI7lQnTC3lB_g&sig2=ICzxDroG2ENTJSUGmdhI2w") - ); + URLUtil.cleanGoogleSearchURL("https://www.google.fr/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCEQFjAAahUKEwjJurHd2sfHAhWBsxQKHSrEAaM&url=https%3A%2F%2Fmoz.com%2Fugc%2Fthe-ultimate-guide-to-the-google-search-parameters&ei=0THeVYmOJIHnUqqIh5gK&usg=AFQjCNHnid_r_d2LP8_MqvI7lQnTC3lB_g&sig2=ICzxDroG2ENTJSUGmdhI2w")); // foreign domain co.uk - Assert.assertEquals( + assertEquals( "https://moz.com/ugc/the-ultimate-guide-to-the-google-search-parameters", - URLUtil.cleanGoogleSearchURL("https://www.google.co.uk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCEQFjAAahUKEwjJurHd2sfHAhWBsxQKHSrEAaM&url=https%3A%2F%2Fmoz.com%2Fugc%2Fthe-ultimate-guide-to-the-google-search-parameters&ei=0THeVYmOJIHnUqqIh5gK&usg=AFQjCNHnid_r_d2LP8_MqvI7lQnTC3lB_g&sig2=ICzxDroG2ENTJSUGmdhI2w") - ); + URLUtil.cleanGoogleSearchURL("https://www.google.co.uk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCEQFjAAahUKEwjJurHd2sfHAhWBsxQKHSrEAaM&url=https%3A%2F%2Fmoz.com%2Fugc%2Fthe-ultimate-guide-to-the-google-search-parameters&ei=0THeVYmOJIHnUqqIh5gK&usg=AFQjCNHnid_r_d2LP8_MqvI7lQnTC3lB_g&sig2=ICzxDroG2ENTJSUGmdhI2w")); // accept ftp results - Assert.assertEquals( + assertEquals( "ftp://moz.com/ugc/the-ultimate-guide-to-the-google-search-parameters", - URLUtil.cleanGoogleSearchURL("https://www.google.fr/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCEQFjAAahUKEwjJurHd2sfHAhWBsxQKHSrEAaM&url=ftp%3A%2F%2Fmoz.com%2Fugc%2Fthe-ultimate-guide-to-the-google-search-parameters&ei=0THeVYmOJIHnUqqIh5gK&usg=AFQjCNHnid_r_d2LP8_MqvI7lQnTC3lB_g&sig2=ICzxDroG2ENTJSUGmdhI2w") - ); + URLUtil.cleanGoogleSearchURL("https://www.google.fr/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCEQFjAAahUKEwjJurHd2sfHAhWBsxQKHSrEAaM&url=ftp%3A%2F%2Fmoz.com%2Fugc%2Fthe-ultimate-guide-to-the-google-search-parameters&ei=0THeVYmOJIHnUqqIh5gK&usg=AFQjCNHnid_r_d2LP8_MqvI7lQnTC3lB_g&sig2=ICzxDroG2ENTJSUGmdhI2w")); } @Test public void isURLshouldAcceptValidURL() { - Assert.assertTrue(URLUtil.isURL("http://www.google.com")); - Assert.assertTrue(URLUtil.isURL("https://www.google.com")); + assertTrue(URLUtil.isURL("http://www.google.com")); + assertTrue(URLUtil.isURL("https://www.google.com")); } @Test public void isURLshouldRejectInvalidURL() { - Assert.assertFalse(URLUtil.isURL("www.google.com")); - Assert.assertFalse(URLUtil.isURL("google.com")); + assertFalse(URLUtil.isURL("www.google.com")); + assertFalse(URLUtil.isURL("google.com")); } } diff --git a/src/test/java/org/jabref/logic/openoffice/CitationEntryTest.java b/src/test/java/org/jabref/logic/openoffice/CitationEntryTest.java index 5e6bfa90815..3a9e7dc5050 100644 --- a/src/test/java/org/jabref/logic/openoffice/CitationEntryTest.java +++ b/src/test/java/org/jabref/logic/openoffice/CitationEntryTest.java @@ -4,10 +4,10 @@ import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class CitationEntryTest { diff --git a/src/test/java/org/jabref/logic/openoffice/OOBibStyleTest.java b/src/test/java/org/jabref/logic/openoffice/OOBibStyleTest.java index e133e916180..485bcdfe64a 100644 --- a/src/test/java/org/jabref/logic/openoffice/OOBibStyleTest.java +++ b/src/test/java/org/jabref/logic/openoffice/OOBibStyleTest.java @@ -24,21 +24,21 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.util.DummyFileUpdateMonitor; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Answers; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; public class OOBibStyleTest { private LayoutFormatterPreferences layoutFormatterPreferences; private ImportFormatPreferences importFormatPreferences; - @Before + @BeforeEach public void setUp() { layoutFormatterPreferences = mock(LayoutFormatterPreferences.class, Answers.RETURNS_DEEP_STUBS); importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); diff --git a/src/test/java/org/jabref/logic/openoffice/OOPreFormatterTest.java b/src/test/java/org/jabref/logic/openoffice/OOPreFormatterTest.java index 33b0f1a1164..2c51434577e 100644 --- a/src/test/java/org/jabref/logic/openoffice/OOPreFormatterTest.java +++ b/src/test/java/org/jabref/logic/openoffice/OOPreFormatterTest.java @@ -1,8 +1,8 @@ package org.jabref.logic.openoffice; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class OOPreFormatterTest { diff --git a/src/test/java/org/jabref/logic/openoffice/StyleLoaderTest.java b/src/test/java/org/jabref/logic/openoffice/StyleLoaderTest.java index 2cd65802de0..945b70fa356 100644 --- a/src/test/java/org/jabref/logic/openoffice/StyleLoaderTest.java +++ b/src/test/java/org/jabref/logic/openoffice/StyleLoaderTest.java @@ -10,15 +10,14 @@ import org.jabref.logic.layout.LayoutFormatterPreferences; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Answers; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -32,7 +31,7 @@ public class StyleLoaderTest { private Charset encoding; - @Before + @BeforeEach public void setUp() { preferences = mock(OpenOfficePreferences.class, Answers.RETURNS_DEEP_STUBS); layoutPreferences = mock(LayoutFormatterPreferences.class, Answers.RETURNS_DEEP_STUBS); @@ -40,22 +39,20 @@ public void setUp() { } - @Test(expected = NullPointerException.class) + @Test public void throwNPEWithNullPreferences() { - loader = new StyleLoader(null, layoutPreferences, mock(Charset.class)); - fail(); + assertThrows(NullPointerException.class, () -> loader = new StyleLoader(null, layoutPreferences, mock(Charset.class))); + } - @Test(expected = NullPointerException.class) + @Test public void throwNPEWithNullLayoutPreferences() { - loader = new StyleLoader(mock(OpenOfficePreferences.class), null, mock(Charset.class)); - fail(); + assertThrows(NullPointerException.class, () -> loader = new StyleLoader(mock(OpenOfficePreferences.class), null, mock(Charset.class))); } - @Test(expected = NullPointerException.class) + @Test public void throwNPEWithNullCharset() { - loader = new StyleLoader(mock(OpenOfficePreferences.class), layoutPreferences, null); - fail(); + assertThrows(NullPointerException.class, () -> loader = new StyleLoader(mock(OpenOfficePreferences.class), layoutPreferences, null)); } @Test @@ -125,7 +122,6 @@ public void testInitalizeWithOneExternalFileRemoveStyle() throws URISyntaxExcept } @Test - @Ignore("This tests the preferences that are mocked away") public void testInitalizeWithOneExternalFileRemoveStyleUpdatesPreferences() throws URISyntaxException { String filename = Paths.get(StyleLoader.class.getResource(StyleLoader.DEFAULT_AUTHORYEAR_STYLE_PATH).toURI()) .toFile().getPath(); @@ -142,7 +138,8 @@ public void testInitalizeWithOneExternalFileRemoveStyleUpdatesPreferences() thro for (OOBibStyle style : toremove) { assertTrue(loader.removeStyle(style)); } - assertTrue(preferences.getExternalStyles().isEmpty()); + //As the prefs are mocked away, the getExternalStyles still returns the initial one + assertFalse(preferences.getExternalStyles().isEmpty()); } @Test @@ -157,11 +154,11 @@ public void testAddSameStyleTwiceLeadsToOneMoreStyle() throws URISyntaxException assertEquals(beforeAdding + 1, loader.getStyles().size()); } - @Test(expected = NullPointerException.class) + @Test public void testAddNullStyleThrowsNPE() { loader = new StyleLoader(preferences, layoutPreferences, encoding); - loader.addStyleIfValid(null); - fail(); + assertThrows(NullPointerException.class, () -> loader.addStyleIfValid(null)); + } @Test @@ -186,14 +183,12 @@ public void testGetStoredUsedStyle() { } @Test - @Ignore("This tests the preferences that are mocked away") - public void testGtDefaultUsedStyleWhenIncorrect() { + public void testGetDefaultUsedStyleWhenIncorrect() { when(preferences.getCurrentStyle()).thenReturn("ljlkjlkjnljnvdlsjniuhwelfhuewfhlkuewhfuwhelu"); loader = new StyleLoader(preferences, layoutPreferences, encoding); OOBibStyle style = loader.getUsedStyle(); assertTrue(style.isValid()); assertEquals(StyleLoader.DEFAULT_AUTHORYEAR_STYLE_PATH, style.getPath()); - assertEquals(StyleLoader.DEFAULT_AUTHORYEAR_STYLE_PATH, preferences.getCurrentStyle()); } @Test diff --git a/src/test/java/org/jabref/logic/pdf/EntryAnnotationImporterTest.java b/src/test/java/org/jabref/logic/pdf/EntryAnnotationImporterTest.java index 99689673e30..bbf62e29d7f 100644 --- a/src/test/java/org/jabref/logic/pdf/EntryAnnotationImporterTest.java +++ b/src/test/java/org/jabref/logic/pdf/EntryAnnotationImporterTest.java @@ -12,20 +12,20 @@ import org.jabref.model.entry.FieldName; import org.jabref.model.pdf.FileAnnotation; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; public class EntryAnnotationImporterTest { - private BibDatabaseContext databaseContext = mock(BibDatabaseContext.class); - private BibEntry entry = new BibEntry("EntryKey"); + private final BibDatabaseContext databaseContext = mock(BibDatabaseContext.class); + private final BibEntry entry = new BibEntry("EntryKey"); - @Before + @BeforeEach public void setUp() { when(databaseContext.getFileDirectoriesAsPaths(any())).thenReturn(Collections.singletonList(Paths.get("src/test/resources/pdfs/"))); } diff --git a/src/test/java/org/jabref/logic/pdf/PdfAnnotationImporterTest.java b/src/test/java/org/jabref/logic/pdf/PdfAnnotationImporterTest.java index e6fafd85d95..01bb95f00ea 100644 --- a/src/test/java/org/jabref/logic/pdf/PdfAnnotationImporterTest.java +++ b/src/test/java/org/jabref/logic/pdf/PdfAnnotationImporterTest.java @@ -8,9 +8,10 @@ import org.jabref.model.pdf.FileAnnotation; import org.jabref.model.pdf.FileAnnotationType; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.Assert.assertEquals; public class PdfAnnotationImporterTest { @@ -102,7 +103,6 @@ public void squigglyWithNoteMinimal() { } @Test - public void strikeoutWithNoteMinimal() { final FileAnnotation expectedLinkedAnnotation = new FileAnnotation("lynyus", LocalDateTime.of(2017, 6, 1, 13, 2, 3), 1, "striked out", FileAnnotationType.STRIKEOUT, Optional.empty()); diff --git a/src/test/java/org/jabref/logic/remote/RemotePreferencesTest.java b/src/test/java/org/jabref/logic/remote/RemotePreferencesTest.java index 9444e055a58..3b7b5c85470 100644 --- a/src/test/java/org/jabref/logic/remote/RemotePreferencesTest.java +++ b/src/test/java/org/jabref/logic/remote/RemotePreferencesTest.java @@ -1,19 +1,18 @@ package org.jabref.logic.remote; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class RemotePreferencesTest { private RemotePreferences preferences; - @Before + @BeforeEach public void setUp() { preferences = new RemotePreferences(1000, true); } diff --git a/src/test/java/org/jabref/logic/remote/RemoteUtilTest.java b/src/test/java/org/jabref/logic/remote/RemoteUtilTest.java index b754e6c0f18..963d2755e47 100644 --- a/src/test/java/org/jabref/logic/remote/RemoteUtilTest.java +++ b/src/test/java/org/jabref/logic/remote/RemoteUtilTest.java @@ -1,30 +1,33 @@ package org.jabref.logic.remote; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class RemoteUtilTest { + @Test public void rejectPortNumberBelowZero() { - Assert.assertFalse("Port number must be non negative.", RemoteUtil.isUserPort(-55)); + assertFalse(RemoteUtil.isUserPort(-55), "Port number must be non negative."); } @Test public void rejectReservedSystemPorts() { - Assert.assertFalse("Port number must be outside reserved system range (0-1023).", RemoteUtil.isUserPort(0)); - Assert.assertFalse("Port number must be outside reserved system range (0-1023).", RemoteUtil.isUserPort(1023)); + assertFalse(RemoteUtil.isUserPort(0), "Port number must be outside reserved system range (0-1023)."); + assertFalse(RemoteUtil.isUserPort(1023), "Port number must be outside reserved system range (0-1023)."); } @Test public void rejectPortsAbove16Bits() { // 2 ^ 16 - 1 => 65535 - Assert.assertFalse("Port number should be below 65535.", RemoteUtil.isUserPort(65536)); + assertFalse(RemoteUtil.isUserPort(65536), "Port number should be below 65535."); } @Test public void acceptPortsAboveSystemPorts() { // ports 1024 -> 65535 - Assert.assertTrue("Port number in between 1024 and 65535 should be valid.", RemoteUtil.isUserPort(1024)); - Assert.assertTrue("Port number in between 1024 and 65535 should be valid.", RemoteUtil.isUserPort(65535)); + assertTrue(RemoteUtil.isUserPort(1024), "Port number in between 1024 and 65535 should be valid."); + assertTrue(RemoteUtil.isUserPort(65535), "Port number in between 1024 and 65535 should be valid."); } } diff --git a/src/test/java/org/jabref/logic/search/DatabaseSearcherTest.java b/src/test/java/org/jabref/logic/search/DatabaseSearcherTest.java index e9ac4ba2cd6..b5c18e1234d 100644 --- a/src/test/java/org/jabref/logic/search/DatabaseSearcherTest.java +++ b/src/test/java/org/jabref/logic/search/DatabaseSearcherTest.java @@ -7,10 +7,10 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.BibtexEntryTypes; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class DatabaseSearcherTest { @@ -19,7 +19,7 @@ public class DatabaseSearcherTest { private BibDatabase database; - @Before + @BeforeEach public void setUp() { database = new BibDatabase(); } diff --git a/src/test/java/org/jabref/logic/search/SearchQueryTest.java b/src/test/java/org/jabref/logic/search/SearchQueryTest.java index 4a49b7cc80c..d2eab079763 100644 --- a/src/test/java/org/jabref/logic/search/SearchQueryTest.java +++ b/src/test/java/org/jabref/logic/search/SearchQueryTest.java @@ -4,11 +4,12 @@ import org.jabref.model.entry.BibtexEntryTypes; import org.jabref.model.entry.FieldName; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; public class SearchQueryTest { diff --git a/src/test/java/org/jabref/logic/shared/DBMSProcessorTest.java b/src/test/java/org/jabref/logic/shared/DBMSProcessorTest.java index 6aa6e2ec8e2..1bf4e3e3249 100644 --- a/src/test/java/org/jabref/logic/shared/DBMSProcessorTest.java +++ b/src/test/java/org/jabref/logic/shared/DBMSProcessorTest.java @@ -33,8 +33,7 @@ public class DBMSProcessorTest { private DBMSConnection dbmsConnection; private DBMSProcessor dbmsProcessor; - @Parameter - public DBMSType dbmsType; + @Parameter public DBMSType dbmsType; @BeforeEach public void setUp() throws SQLException, InvalidDBMSConnectionPropertiesException { diff --git a/src/test/java/org/jabref/logic/specialfields/SpecialFieldsUtilsTest.java b/src/test/java/org/jabref/logic/specialfields/SpecialFieldsUtilsTest.java index 792a09f3363..384e7fa0f2c 100644 --- a/src/test/java/org/jabref/logic/specialfields/SpecialFieldsUtilsTest.java +++ b/src/test/java/org/jabref/logic/specialfields/SpecialFieldsUtilsTest.java @@ -6,17 +6,16 @@ import org.jabref.model.FieldChange; import org.jabref.model.entry.BibEntry; - import org.jabref.model.entry.FieldName; import org.jabref.model.entry.Keyword; import org.jabref.model.entry.KeywordList; import org.jabref.model.entry.specialfields.SpecialField; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class SpecialFieldsUtilsTest { diff --git a/src/test/java/org/jabref/logic/util/BracketedPatternTest.java b/src/test/java/org/jabref/logic/util/BracketedPatternTest.java index d10814053d1..b7b009b26dd 100644 --- a/src/test/java/org/jabref/logic/util/BracketedPatternTest.java +++ b/src/test/java/org/jabref/logic/util/BracketedPatternTest.java @@ -7,18 +7,20 @@ import org.jabref.model.entry.BibtexString; import org.jabref.model.entry.FieldName; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class BracketedPatternTest { + private BibEntry bibentry; private BibDatabase database; private BibEntry dbentry; - @Before + @BeforeEach public void setUp() throws Exception { bibentry = new BibEntry(); bibentry.setField("author", "O. Kitsune"); @@ -120,19 +122,19 @@ public void suppliedBibentryBracketExpansionTest() { assertEquals("2017_Gražulis_213", pattern.expand(another_bibentry, ';', another_database)); } - @Test(expected = NullPointerException.class) + @Test public void nullBibentryBracketExpansionTest() { BibDatabase another_database = null; BibEntry another_bibentry = null; BracketedPattern pattern = new BracketedPattern("[year]_[auth]_[firstpage]"); - pattern.expand(another_bibentry, ';', another_database); + assertThrows(NullPointerException.class, () -> pattern.expand(another_bibentry, ';', another_database)); } - @Test(expected = NullPointerException.class) + @Test public void bracketedExpressionDefaultConstructorTest() { BibDatabase another_database = null; BracketedPattern pattern = new BracketedPattern(); - pattern.expand(bibentry, ';', another_database); + assertThrows(NullPointerException.class, () -> pattern.expand(bibentry, ';', another_database)); } @Test diff --git a/src/test/java/org/jabref/logic/util/BuildInfoTest.java b/src/test/java/org/jabref/logic/util/BuildInfoTest.java index 578ca0e5d84..68f9d9c94b2 100644 --- a/src/test/java/org/jabref/logic/util/BuildInfoTest.java +++ b/src/test/java/org/jabref/logic/util/BuildInfoTest.java @@ -1,10 +1,10 @@ package org.jabref.logic.util; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class BuildInfoTest { diff --git a/src/test/java/org/jabref/logic/util/DevelopmentStageTest.java b/src/test/java/org/jabref/logic/util/DevelopmentStageTest.java index 54c93588e4c..5e520890608 100644 --- a/src/test/java/org/jabref/logic/util/DevelopmentStageTest.java +++ b/src/test/java/org/jabref/logic/util/DevelopmentStageTest.java @@ -1,9 +1,11 @@ package org.jabref.logic.util; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class DevelopmentStageTest { @@ -13,8 +15,7 @@ public void checkStabilityOrder() { assertTrue(Version.DevelopmentStage.BETA.isMoreStableThan(Version.DevelopmentStage.ALPHA)); assertTrue(Version.DevelopmentStage.STABLE.isMoreStableThan(Version.DevelopmentStage.BETA)); - assertEquals("It seems that the development stages have been changed, please adjust the test", 4, - Version.DevelopmentStage.values().length); + assertEquals(4, Version.DevelopmentStage.values().length, "It seems that the development stages have been changed, please adjust the test"); } @Test diff --git a/src/test/java/org/jabref/logic/util/FileTypeTest.java b/src/test/java/org/jabref/logic/util/FileTypeTest.java index 61c15a36e64..b9e89193dcc 100644 --- a/src/test/java/org/jabref/logic/util/FileTypeTest.java +++ b/src/test/java/org/jabref/logic/util/FileTypeTest.java @@ -1,8 +1,8 @@ package org.jabref.logic.util; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class FileTypeTest { diff --git a/src/test/java/org/jabref/logic/util/JavaVersionTest.java b/src/test/java/org/jabref/logic/util/JavaVersionTest.java index 13c951d8e43..5f67d084363 100644 --- a/src/test/java/org/jabref/logic/util/JavaVersionTest.java +++ b/src/test/java/org/jabref/logic/util/JavaVersionTest.java @@ -3,8 +3,11 @@ import java.util.ArrayList; import java.util.List; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + /** * Tests for ensuring we can compare most appearing version strings @@ -42,39 +45,39 @@ public void isJava9() throws Exception { // Check that all valid java versions below 9 are recognized as not java 9 for (String versionString : java) { final JavaVersion java8 = new JavaVersion(versionString); - Assert.assertFalse(java8.isJava9()); + assertFalse(java8.isJava9()); } // Check if all valid version 9 strings are recognized as being version 9 for (String version9String : java9) { final JavaVersion java9 = new JavaVersion(version9String); - Assert.assertTrue(java9.isJava9()); + assertTrue(java9.isJava9()); } // For impossible comparisons we assume it's not java 9 - Assert.assertFalse(nullCheck.isJava9()); - Assert.assertFalse(noSenseCheck.isJava9()); + assertFalse(nullCheck.isJava9()); + assertFalse(noSenseCheck.isJava9()); } @Test public void isAtLeast() throws Exception { final JavaVersion java8 = new JavaVersion("1.8"); for (String version8 : java) { - Assert.assertTrue(java8.isAtLeast(version8)); + assertTrue(java8.isAtLeast(version8)); final JavaVersion java8Example = new JavaVersion(version8); - Assert.assertTrue(java8Example.isAtLeast("1.5")); + assertTrue(java8Example.isAtLeast("1.5")); // Check if we optimistically return true if we cannot determine the result - Assert.assertTrue(java8Example.isAtLeast(null)); - Assert.assertTrue(nullCheck.isAtLeast(version8)); - Assert.assertTrue(noSenseCheck.isAtLeast(version8)); - Assert.assertTrue(java8Example.isAtLeast("useless")); + assertTrue(java8Example.isAtLeast(null)); + assertTrue(nullCheck.isAtLeast(version8)); + assertTrue(noSenseCheck.isAtLeast(version8)); + assertTrue(java8Example.isAtLeast("useless")); // Check against all java 9 entries in both directions for (String version9 : java9) { - Assert.assertFalse(java8Example.isAtLeast(version9)); + assertFalse(java8Example.isAtLeast(version9)); final JavaVersion java9 = new JavaVersion(version9); - Assert.assertTrue(java9.isAtLeast(version8)); + assertTrue(java9.isAtLeast(version8)); } } } diff --git a/src/test/java/org/jabref/logic/util/UpdateFieldTest.java b/src/test/java/org/jabref/logic/util/UpdateFieldTest.java index b25856a001a..d79d4014bff 100644 --- a/src/test/java/org/jabref/logic/util/UpdateFieldTest.java +++ b/src/test/java/org/jabref/logic/util/UpdateFieldTest.java @@ -5,13 +5,13 @@ import org.jabref.model.FieldChange; import org.jabref.model.entry.BibEntry; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class UpdateFieldTest { @@ -19,7 +19,7 @@ public class UpdateFieldTest { private BibEntry entry; - @Before + @BeforeEach public void setUp() throws Exception { entry = new BibEntry(); entry.setChanged(false); diff --git a/src/test/java/org/jabref/logic/util/VersionTest.java b/src/test/java/org/jabref/logic/util/VersionTest.java index 950bddb2c86..b2f90644b65 100644 --- a/src/test/java/org/jabref/logic/util/VersionTest.java +++ b/src/test/java/org/jabref/logic/util/VersionTest.java @@ -5,11 +5,11 @@ import java.util.List; import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class VersionTest { diff --git a/src/test/java/org/jabref/logic/util/io/FileHistoryTest.java b/src/test/java/org/jabref/logic/util/io/FileHistoryTest.java index 280d24630c2..715e461dee9 100644 --- a/src/test/java/org/jabref/logic/util/io/FileHistoryTest.java +++ b/src/test/java/org/jabref/logic/util/io/FileHistoryTest.java @@ -3,9 +3,9 @@ import java.util.ArrayList; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class FileHistoryTest { diff --git a/src/test/java/org/jabref/logic/util/io/FileNameCleanerTest.java b/src/test/java/org/jabref/logic/util/io/FileNameCleanerTest.java index cbd29d9b61a..fdb18565ca5 100644 --- a/src/test/java/org/jabref/logic/util/io/FileNameCleanerTest.java +++ b/src/test/java/org/jabref/logic/util/io/FileNameCleanerTest.java @@ -1,27 +1,28 @@ package org.jabref.logic.util.io; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class FileNameCleanerTest { @Test public void testCleanFileName() { - Assert.assertEquals("legalFilename.txt", FileNameCleaner.cleanFileName("legalFilename.txt")); - Assert.assertEquals("illegalFilename______.txt", FileNameCleaner.cleanFileName("illegalFilename/?*<>|.txt")); + assertEquals("legalFilename.txt", FileNameCleaner.cleanFileName("legalFilename.txt")); + assertEquals("illegalFilename______.txt", FileNameCleaner.cleanFileName("illegalFilename/?*<>|.txt")); } @Test public void testCleanDirectoryName() { - Assert.assertEquals("legalFilename.txt", FileNameCleaner.cleanDirectoryName("legalFilename.txt")); - Assert.assertEquals("subdir/legalFilename.txt", FileNameCleaner.cleanDirectoryName("subdir/legalFilename.txt")); - Assert.assertEquals("illegalFilename/_____.txt", FileNameCleaner.cleanDirectoryName("illegalFilename/?*<>|.txt")); + assertEquals("legalFilename.txt", FileNameCleaner.cleanDirectoryName("legalFilename.txt")); + assertEquals("subdir/legalFilename.txt", FileNameCleaner.cleanDirectoryName("subdir/legalFilename.txt")); + assertEquals("illegalFilename/_____.txt", FileNameCleaner.cleanDirectoryName("illegalFilename/?*<>|.txt")); } @Test public void testCleanDirectoryNameForWindows() { - Assert.assertEquals("legalFilename.txt", FileNameCleaner.cleanDirectoryName("legalFilename.txt")); - Assert.assertEquals("subdir\\legalFilename.txt", FileNameCleaner.cleanDirectoryName("subdir\\legalFilename.txt")); - Assert.assertEquals("illegalFilename\\_____.txt", FileNameCleaner.cleanDirectoryName("illegalFilename\\?*<>|.txt")); + assertEquals("legalFilename.txt", FileNameCleaner.cleanDirectoryName("legalFilename.txt")); + assertEquals("subdir\\legalFilename.txt", FileNameCleaner.cleanDirectoryName("subdir\\legalFilename.txt")); + assertEquals("illegalFilename\\_____.txt", FileNameCleaner.cleanDirectoryName("illegalFilename\\?*<>|.txt")); } } diff --git a/src/test/java/org/jabref/logic/util/io/RegExpBasedFileFinderTests.java b/src/test/java/org/jabref/logic/util/io/RegExpBasedFileFinderTests.java index c627eb0f438..b550ca52a2d 100644 --- a/src/test/java/org/jabref/logic/util/io/RegExpBasedFileFinderTests.java +++ b/src/test/java/org/jabref/logic/util/io/RegExpBasedFileFinderTests.java @@ -9,11 +9,11 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.BibtexEntryTypes; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class RegExpBasedFileFinderTests { @@ -21,7 +21,7 @@ public class RegExpBasedFileFinderTests { private BibDatabase database; private BibEntry entry; - @Before + @BeforeEach public void setUp() { entry = new BibEntry(); @@ -137,7 +137,7 @@ public void testFindFileNonRecursive() throws Exception { List result = fileFinder.findAssociatedFiles(localEntry, dirs, extensions); //then - Assert.assertTrue(result.isEmpty()); + assertTrue(result.isEmpty()); } @Test diff --git a/src/test/java/org/jabref/logic/util/strings/DiffHighlightingTest.java b/src/test/java/org/jabref/logic/util/strings/DiffHighlightingTest.java index fd1576f8a50..bda3faa126c 100644 --- a/src/test/java/org/jabref/logic/util/strings/DiffHighlightingTest.java +++ b/src/test/java/org/jabref/logic/util/strings/DiffHighlightingTest.java @@ -1,10 +1,10 @@ package org.jabref.logic.util.strings; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; public class DiffHighlightingTest { @@ -13,9 +13,9 @@ public void testGenerateDiffHighlightingBothNullReturnsNull() { assertNull(DiffHighlighting.generateDiffHighlighting(null, null, "")); } - @Test(expected = NullPointerException.class) + @Test public void testNullSeparatorThrowsNPE() { - assertNull(DiffHighlighting.generateDiffHighlighting("", "", null)); + assertThrows(NullPointerException.class, () -> DiffHighlighting.generateDiffHighlighting("", "", null)); } @Test diff --git a/src/test/java/org/jabref/logic/util/strings/StringLengthComparatorTest.java b/src/test/java/org/jabref/logic/util/strings/StringLengthComparatorTest.java index d4adf6358a8..29b691b4e13 100644 --- a/src/test/java/org/jabref/logic/util/strings/StringLengthComparatorTest.java +++ b/src/test/java/org/jabref/logic/util/strings/StringLengthComparatorTest.java @@ -1,17 +1,16 @@ package org.jabref.logic.util.strings; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; public class StringLengthComparatorTest { private StringLengthComparator slc; - @Before + @BeforeEach public void setUp() { slc = new StringLengthComparator(); } diff --git a/src/test/java/org/jabref/logic/xmp/XMPSchemaBibtexTest.java b/src/test/java/org/jabref/logic/xmp/XMPSchemaBibtexTest.java index 45413a0aa57..377ffebaa9e 100644 --- a/src/test/java/org/jabref/logic/xmp/XMPSchemaBibtexTest.java +++ b/src/test/java/org/jabref/logic/xmp/XMPSchemaBibtexTest.java @@ -17,33 +17,37 @@ import org.apache.jempbox.impl.XMLUtil; import org.apache.jempbox.xmp.XMPMetadata; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -@RunWith(MockitoJUnitRunner.class) public class XMPSchemaBibtexTest { - @Mock private ImportFormatPreferences prefs; + @BeforeEach + public void setUp() { + prefs = mock(ImportFormatPreferences.class); + } + public void assertEqualsBibtexEntry(BibEntry e, BibEntry x) { - Assert.assertNotNull(e); - Assert.assertNotNull(x); - Assert.assertEquals(e.getCiteKeyOptional(), x.getCiteKeyOptional()); - Assert.assertEquals(e.getType(), x.getType()); + assertNotNull(e); + assertNotNull(x); + assertEquals(e.getCiteKeyOptional(), x.getCiteKeyOptional()); + assertEquals(e.getType(), x.getType()); - Assert.assertEquals(e.getFieldNames().size(), x.getFieldNames().size()); + assertEquals(e.getFieldNames().size(), x.getFieldNames().size()); for (String name : e.getFieldNames()) { - Assert.assertEquals(e.getField(name), x.getField(name)); + assertEquals(e.getField(name), x.getField(name)); } } @@ -53,8 +57,8 @@ public void testXMPSchemaBibtexXMPMetadata() throws IOException { XMPMetadata xmp = new XMPMetadata(); XMPSchemaBibtex bibtex = new XMPSchemaBibtex(xmp); - Assert.assertNotNull(bibtex.getElement()); - Assert.assertEquals("rdf:Description", bibtex.getElement().getTagName()); + assertNotNull(bibtex.getElement()); + assertEquals("rdf:Description", bibtex.getElement().getTagName()); } @@ -68,8 +72,8 @@ public void testXMPSchemaBibtexElement() XMPSchemaBibtex bibtex = new XMPSchemaBibtex(e, "bibtex"); - Assert.assertEquals(e, bibtex.getElement()); - Assert.assertEquals("rdf:Description", bibtex.getElement().getTagName()); + assertEquals(e, bibtex.getElement()); + assertEquals("rdf:Description", bibtex.getElement().getTagName()); } @Test @@ -82,21 +86,21 @@ public void testGetSetPersonList() throws IOException { Element e = bibtex.getElement(); NodeList l1 = e.getElementsByTagName("bibtex:author"); - Assert.assertEquals(1, l1.getLength()); + assertEquals(1, l1.getLength()); NodeList l = e.getElementsByTagName("rdf:li"); - Assert.assertEquals(2, l.getLength()); + assertEquals(2, l.getLength()); - Assert.assertEquals("Tom DeMarco", XMLUtil + assertEquals("Tom DeMarco", XMLUtil .getStringValue((Element) l.item(0))); - Assert.assertEquals("Kent Beck", XMLUtil.getStringValue((Element) l.item(1))); + assertEquals("Kent Beck", XMLUtil.getStringValue((Element) l.item(1))); List authors = bibtex.getPersonList("author"); - Assert.assertEquals(2, authors.size()); + assertEquals(2, authors.size()); - Assert.assertEquals("Tom DeMarco", authors.get(0)); - Assert.assertEquals("Kent Beck", authors.get(1)); + assertEquals("Tom DeMarco", authors.get(0)); + assertEquals("Kent Beck", authors.get(1)); } @Test @@ -108,27 +112,27 @@ public void testSetGetTextPropertyString() throws IOException { "The advanced Flux-Compensation for Delawney-Separation"); Element e = bibtex.getElement(); - Assert.assertEquals("The advanced Flux-Compensation for Delawney-Separation", + assertEquals("The advanced Flux-Compensation for Delawney-Separation", e.getAttribute("bibtex:title")); - Assert.assertEquals("The advanced Flux-Compensation for Delawney-Separation", + assertEquals("The advanced Flux-Compensation for Delawney-Separation", bibtex.getTextProperty("title")); bibtex.setTextProperty("title", "The advanced Flux-Correlation for Delawney-Separation"); e = bibtex.getElement(); - Assert.assertEquals("The advanced Flux-Correlation for Delawney-Separation", e + assertEquals("The advanced Flux-Correlation for Delawney-Separation", e .getAttribute("bibtex:title")); - Assert.assertEquals("The advanced Flux-Correlation for Delawney-Separation", + assertEquals("The advanced Flux-Correlation for Delawney-Separation", bibtex.getTextProperty("title")); bibtex .setTextProperty( "abstract", " The abstract\n can go \n \n on several \n lines with \n many \n\n empty ones in \n between."); - Assert.assertEquals( + assertEquals( " The abstract\n can go \n \n on several \n lines with \n many \n\n empty ones in \n between.", bibtex.getTextProperty("abstract")); } @@ -145,36 +149,36 @@ public void testSetGetBagListString() throws IOException { List l = bibtex.getBagList("author"); - Assert.assertEquals(2, l.size()); + assertEquals(2, l.size()); - Assert.assertTrue(l.get(0).equals("Tom DeMarco") + assertTrue(l.get(0).equals("Tom DeMarco") || l.get(1).equals("Tom DeMarco")); - Assert.assertTrue(l.get(0).equals("Kent Beck") + assertTrue(l.get(0).equals("Kent Beck") || l.get(1).equals("Kent Beck")); } { bibtex.removeBagValue("author", "Kent Beck"); List l = bibtex.getBagList("author"); - Assert.assertEquals(1, l.size()); - Assert.assertTrue(l.get(0).equals("Tom DeMarco")); + assertEquals(1, l.size()); + assertTrue(l.get(0).equals("Tom DeMarco")); } { // Already removed bibtex.removeBagValue("author", "Kent Beck"); List l = bibtex.getBagList("author"); - Assert.assertEquals(1, l.size()); - Assert.assertTrue(l.get(0).equals("Tom DeMarco")); + assertEquals(1, l.size()); + assertTrue(l.get(0).equals("Tom DeMarco")); } { // Duplicates allowed! bibtex.addBagValue("author", "Tom DeMarco"); List l = bibtex.getBagList("author"); - Assert.assertEquals(2, l.size()); - Assert.assertTrue(l.get(0).equals("Tom DeMarco")); - Assert.assertTrue(l.get(1).equals("Tom DeMarco")); + assertEquals(2, l.size()); + assertTrue(l.get(0).equals("Tom DeMarco")); + assertTrue(l.get(1).equals("Tom DeMarco")); } // Removes both bibtex.removeBagValue("author", "Tom DeMarco"); List l = bibtex.getBagList("author"); - Assert.assertEquals(0, l.size()); + assertEquals(0, l.size()); } @Test @@ -189,34 +193,34 @@ public void testGetSequenceListString() throws IOException { List l = bibtex.getSequenceList("author"); - Assert.assertEquals(2, l.size()); + assertEquals(2, l.size()); - Assert.assertEquals("Tom DeMarco", l.get(0)); - Assert.assertEquals("Kent Beck", l.get(1)); + assertEquals("Tom DeMarco", l.get(0)); + assertEquals("Kent Beck", l.get(1)); } { bibtex.removeSequenceValue("author", "Tom DeMarco"); List l = bibtex.getSequenceList("author"); - Assert.assertEquals(1, l.size()); - Assert.assertTrue(l.get(0).equals("Kent Beck")); + assertEquals(1, l.size()); + assertTrue(l.get(0).equals("Kent Beck")); } { // Already removed bibtex.removeSequenceValue("author", "Tom DeMarco"); List l = bibtex.getSequenceList("author"); - Assert.assertEquals(1, l.size()); - Assert.assertTrue(l.get(0).equals("Kent Beck")); + assertEquals(1, l.size()); + assertTrue(l.get(0).equals("Kent Beck")); } { // Duplicates allowed! bibtex.addSequenceValue("author", "Kent Beck"); List l = bibtex.getSequenceList("author"); - Assert.assertEquals(2, l.size()); - Assert.assertTrue(l.get(0).equals("Kent Beck")); - Assert.assertTrue(l.get(1).equals("Kent Beck")); + assertEquals(2, l.size()); + assertTrue(l.get(0).equals("Kent Beck")); + assertTrue(l.get(1).equals("Kent Beck")); } // Remvoes all bibtex.removeSequenceValue("author", "Kent Beck"); List l = bibtex.getSequenceList("author"); - Assert.assertEquals(0, l.size()); + assertEquals(0, l.size()); } @Test @@ -233,15 +237,15 @@ public void testGetAllProperties() throws IOException { Map s = XMPSchemaBibtex.getAllProperties(bibtex, "bibtex"); - Assert.assertEquals(5, s.size()); - Assert.assertTrue(s.containsKey("title")); - Assert.assertTrue(s.containsKey("author")); + assertEquals(5, s.size()); + assertTrue(s.containsKey("title")); + assertTrue(s.containsKey("author")); - Assert.assertEquals("BlaBla Ta Ta Hello World", s.get("title")); - Assert.assertEquals("BlaBla Ta Ta\nHello World", s.get("abstract")); - Assert.assertEquals("BlaBla Ta Ta\nHello World", s.get("review")); - Assert.assertEquals("BlaBla Ta Ta\nHello World", s.get("note")); - Assert.assertEquals("Mickey Mouse and James Bond", s.get("author")); + assertEquals("BlaBla Ta Ta Hello World", s.get("title")); + assertEquals("BlaBla Ta Ta\nHello World", s.get("abstract")); + assertEquals("BlaBla Ta Ta\nHello World", s.get("review")); + assertEquals("BlaBla Ta Ta\nHello World", s.get("note")); + assertEquals("Mickey Mouse and James Bond", s.get("author")); } @Test @@ -272,7 +276,7 @@ public void testGetTextContent() throws IOException { Document d = XMLUtil.parse(new ByteArrayInputStream(bibtexString .getBytes(StandardCharsets.UTF_8))); - Assert.assertEquals("Beach sand convolution by surf-wave optimzation", + assertEquals("Beach sand convolution by surf-wave optimzation", XMPSchemaBibtex.getTextContent( d.getElementsByTagName("bibtex:title").item(0)).trim()); diff --git a/src/test/java/org/jabref/migrations/PreferencesMigrationsTest.java b/src/test/java/org/jabref/migrations/PreferencesMigrationsTest.java index 59f86305da8..78f2fd7b22d 100644 --- a/src/test/java/org/jabref/migrations/PreferencesMigrationsTest.java +++ b/src/test/java/org/jabref/migrations/PreferencesMigrationsTest.java @@ -6,10 +6,10 @@ import org.jabref.JabRefMain; import org.jabref.preferences.JabRefPreferences; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class PreferencesMigrationsTest { @@ -20,7 +20,7 @@ public class PreferencesMigrationsTest { private final String[] newStylePatterns = new String[] {"[bibtexkey]", "[bibtexkey] - [fulltitle]"}; - @Before + @BeforeEach public void setUp() { prefs = JabRefPreferences.getInstance(); Globals.prefs = prefs; diff --git a/src/test/java/org/jabref/model/BibDatabaseContextTest.java b/src/test/java/org/jabref/model/BibDatabaseContextTest.java index a15e7650e30..701833e223d 100644 --- a/src/test/java/org/jabref/model/BibDatabaseContextTest.java +++ b/src/test/java/org/jabref/model/BibDatabaseContextTest.java @@ -6,9 +6,9 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.metadata.MetaData; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class BibDatabaseContextTest { @Test diff --git a/src/test/java/org/jabref/model/EntryTypesTest.java b/src/test/java/org/jabref/model/EntryTypesTest.java index bd928059154..019ca85d04d 100644 --- a/src/test/java/org/jabref/model/EntryTypesTest.java +++ b/src/test/java/org/jabref/model/EntryTypesTest.java @@ -26,10 +26,10 @@ @RunWith(Parameterized.class) public class EntryTypesTest { - private BibDatabaseMode mode; - private BibDatabaseMode otherMode; - private EntryType standardArticleType; - private EntryType defaultType; + private final BibDatabaseMode mode; + private final BibDatabaseMode otherMode; + private final EntryType standardArticleType; + private final EntryType defaultType; private CustomEntryType newCustomType; private CustomEntryType overwrittenStandardType; @@ -43,7 +43,7 @@ public EntryTypesTest(BibDatabaseMode mode) { @Parameterized.Parameters public static Object[] data() { - return new Object[] { BibDatabaseMode.BIBTEX, BibDatabaseMode.BIBLATEX }; + return new Object[] {BibDatabaseMode.BIBTEX, BibDatabaseMode.BIBLATEX}; } @Before diff --git a/src/test/java/org/jabref/model/TreeNodeTest.java b/src/test/java/org/jabref/model/TreeNodeTest.java index 10aed3d70c9..577c2420d8d 100644 --- a/src/test/java/org/jabref/model/TreeNodeTest.java +++ b/src/test/java/org/jabref/model/TreeNodeTest.java @@ -6,26 +6,30 @@ import java.util.Optional; import java.util.function.Consumer; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -@RunWith(MockitoJUnitRunner.class) public class TreeNodeTest { - @Mock Consumer subscriber; - @Test(expected = UnsupportedOperationException.class) + @BeforeEach + public void setUp() { + subscriber = mock(Consumer.class); + } + + @Test public void constructorChecksThatClassImplementsCorrectInterface() { - new WrongTreeNodeImplementation(); + assertThrows(UnsupportedOperationException.class, () -> new WrongTreeNodeImplementation()); + } @Test @@ -79,10 +83,10 @@ public void getDescendantNonExistentReturnsEmpty() { assertEquals(Optional.empty(), root.getDescendant(Arrays.asList(1, 100, 0))); } - @Test(expected = UnsupportedOperationException.class) + @Test public void getPositionInParentForRootThrowsException() { TreeNodeTestData.TreeNodeMock root = new TreeNodeTestData.TreeNodeMock(); - root.getPositionInParent(); + assertThrows(UnsupportedOperationException.class, () -> root.getPositionInParent()); } @Test @@ -102,7 +106,7 @@ public void getIndexOfNonExistentChildReturnsEmpty() { public void getIndexOfChild() { TreeNodeTestData.TreeNodeMock root = new TreeNodeTestData.TreeNodeMock(); TreeNodeTestData.TreeNodeMock node = TreeNodeTestData.getNodeAsChild(root); - assertEquals((Integer)2, root.getIndexOfChild(node).get()); + assertEquals((Integer) 2, root.getIndexOfChild(node).get()); } @Test @@ -140,7 +144,7 @@ public void moveToAddsAsLastChildInSimpleTree() { TreeNodeTestData.TreeNodeMock root = new TreeNodeTestData.TreeNodeMock(); TreeNodeTestData.TreeNodeMock node = TreeNodeTestData.getNodeInSimpleTree(root); node.moveTo(root); - assertEquals((Integer)2, root.getIndexOfChild(node).get()); + assertEquals((Integer) 2, root.getIndexOfChild(node).get()); } @Test @@ -148,7 +152,7 @@ public void moveToAddsAsLastChildInComplexTree() { TreeNodeTestData.TreeNodeMock root = new TreeNodeTestData.TreeNodeMock(); TreeNodeTestData.TreeNodeMock node = TreeNodeTestData.getNodeInComplexTree(root); node.moveTo(root); - assertEquals((Integer)4, root.getIndexOfChild(node).get()); + assertEquals((Integer) 4, root.getIndexOfChild(node).get()); } @Test @@ -478,11 +482,11 @@ public void removeChildIndexRemovesNodeFromChildrenCollection() { assertFalse(root.getChildren().contains(node)); } - @Test(expected = UnsupportedOperationException.class) + @Test public void addThrowsExceptionIfNodeHasParent() { TreeNodeTestData.TreeNodeMock root = new TreeNodeTestData.TreeNodeMock(); TreeNodeTestData.TreeNodeMock node = TreeNodeTestData.getNodeAsChild(root); - root.addChild(node); + assertThrows(UnsupportedOperationException.class, () -> root.addChild(node)); } @Test @@ -514,12 +518,12 @@ public void moveAllChildrenToChangesParent() { assertEquals(root, child2.getParent().get()); } - @Test(expected = UnsupportedOperationException.class) + @Test public void moveAllChildrenToDescendantThrowsException() { TreeNodeTestData.TreeNodeMock root = new TreeNodeTestData.TreeNodeMock(); TreeNodeTestData.TreeNodeMock node = TreeNodeTestData.getNodeAsChild(root); - root.moveAllChildrenTo(node, 0); + assertThrows(UnsupportedOperationException.class, () -> root.moveAllChildrenTo(node, 0)); } @Test @@ -621,6 +625,7 @@ public void findChildrenWithSameName() throws Exception { } private static class WrongTreeNodeImplementation extends TreeNode { + // This class is a wrong derived class of TreeNode // since it does not extends TreeNode // See test constructorChecksThatClassImplementsCorrectInterface diff --git a/src/test/java/org/jabref/model/database/BibDatabaseContextTest.java b/src/test/java/org/jabref/model/database/BibDatabaseContextTest.java index 0a944e5e4d3..8d97da29687 100644 --- a/src/test/java/org/jabref/model/database/BibDatabaseContextTest.java +++ b/src/test/java/org/jabref/model/database/BibDatabaseContextTest.java @@ -7,12 +7,10 @@ import org.jabref.model.metadata.FileDirectoryPreferences; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -25,9 +23,7 @@ public class BibDatabaseContextTest { // FileDirectoryPreferences) incocation: private FileDirectoryPreferences fileDirPrefs; - @Rule public ExpectedException thrown = ExpectedException.none(); - - @Before + @BeforeEach public void setUp() { fileDirPrefs = mock(FileDirectoryPreferences.class); currentWorkingDir = Paths.get(System.getProperty("user.dir")); diff --git a/src/test/java/org/jabref/model/database/BibDatabaseModeDetectionTest.java b/src/test/java/org/jabref/model/database/BibDatabaseModeDetectionTest.java index fe8609d904b..a157a4e3de9 100644 --- a/src/test/java/org/jabref/model/database/BibDatabaseModeDetectionTest.java +++ b/src/test/java/org/jabref/model/database/BibDatabaseModeDetectionTest.java @@ -9,9 +9,9 @@ import org.jabref.model.entry.BibtexEntryTypes; import org.jabref.model.entry.CustomEntryType; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class BibDatabaseModeDetectionTest { @Test diff --git a/src/test/java/org/jabref/model/database/BibDatabaseTest.java b/src/test/java/org/jabref/model/database/BibDatabaseTest.java index a6b97c24ccb..4a11fdc737d 100644 --- a/src/test/java/org/jabref/model/database/BibDatabaseTest.java +++ b/src/test/java/org/jabref/model/database/BibDatabaseTest.java @@ -15,31 +15,24 @@ import org.jabref.model.entry.IdGenerator; import org.jabref.model.event.TestEventListener; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; public class BibDatabaseTest { - @Rule - public ExpectedException thrown = ExpectedException.none(); - private BibDatabase database; - @Before + @BeforeEach public void setUp() { database = new BibDatabase(); } - @Test public void insertEntryAddsEntryToEntriesList() { BibEntry entry = new BibEntry(); @@ -57,15 +50,15 @@ public void containsEntryIdFindsEntry() { assertTrue(database.containsEntryWithId(entry.getId())); } - @Test(expected = KeyCollisionException.class) + @Test public void insertEntryWithSameIdThrowsException() { BibEntry entry0 = new BibEntry(); database.insertEntry(entry0); BibEntry entry1 = new BibEntry(); entry1.setId(entry0.getId()); - database.insertEntry(entry1); - fail(); + assertThrows(KeyCollisionException.class, () -> database.insertEntry(entry1)); + } @Test @@ -78,16 +71,14 @@ public void removeEntryRemovesEntryFromEntriesList() { assertFalse(database.containsEntryWithId(entry.getId())); } - @Test(expected = NullPointerException.class) + @Test public void insertNullEntryThrowsException() { - database.insertEntry(null); - fail(); + assertThrows(NullPointerException.class, () -> database.insertEntry(null)); } - @Test(expected = NullPointerException.class) + @Test public void removeNullEntryThrowsException() { - database.removeEntry(null); - fail(); + assertThrows(NullPointerException.class, () -> database.removeEntry(null)); } @Test @@ -123,30 +114,32 @@ public void removeStringUpdatesStringList() { @Test public void hasStringLabelFindsString() { - BibtexString string = new BibtexString( "DSP", "Digital Signal Processing"); + BibtexString string = new BibtexString("DSP", "Digital Signal Processing"); database.addString(string); assertTrue(database.hasStringLabel("DSP")); assertFalse(database.hasStringLabel("VLSI")); } - @Test(expected = KeyCollisionException.class) + @Test public void addSameStringLabelTwiceThrowsKeyCollisionException() { BibtexString string = new BibtexString("DSP", "Digital Signal Processing"); database.addString(string); - string = new BibtexString("DSP", "Digital Signal Processor"); - database.addString(string); - fail(); + final BibtexString finalString = new BibtexString("DSP", "Digital Signal Processor"); + + assertThrows(KeyCollisionException.class, () -> database.addString(finalString)); + } - @Test(expected = KeyCollisionException.class) + @Test public void addSameStringIdTwiceThrowsKeyCollisionException() { - BibtexString string = new BibtexString( "DSP", "Digital Signal Processing"); - string.setId("duplicateid"); - database.addString(string); - string = new BibtexString("VLSI", "Very Large Scale Integration"); + BibtexString string = new BibtexString("DSP", "Digital Signal Processing"); string.setId("duplicateid"); database.addString(string); - fail(); + final BibtexString finalString = new BibtexString("VLSI", "Very Large Scale Integration"); + finalString.setId("duplicateid"); + + assertThrows(KeyCollisionException.class, () -> database.addString(finalString)); + } @Test @@ -227,11 +220,11 @@ public void circularStringResolving() { public void circularStringResolvingLongerCycle() { BibtexString string = new BibtexString("AAA", "#BBB#"); database.addString(string); - string = new BibtexString( "BBB", "#CCC#"); + string = new BibtexString("BBB", "#CCC#"); database.addString(string); string = new BibtexString("CCC", "#DDD#"); database.addString(string); - string = new BibtexString( "DDD", "#AAA#"); + string = new BibtexString("DDD", "#AAA#"); database.addString(string); assertEquals("AAA", database.resolveForStrings("#AAA#")); assertEquals("BBB", database.resolveForStrings("#BBB#")); @@ -262,9 +255,9 @@ public void resolveForStringsOddHashMarkAtTheEnd() { public void getUsedStrings() { BibEntry entry = new BibEntry(IdGenerator.next()); entry.setField("author", "#AAA#"); - BibtexString tripleA = new BibtexString( "AAA", "Some other #BBB#"); - BibtexString tripleB = new BibtexString( "BBB", "Some more text"); - BibtexString tripleC = new BibtexString( "CCC", "Even more text"); + BibtexString tripleA = new BibtexString("AAA", "Some other #BBB#"); + BibtexString tripleB = new BibtexString("BBB", "Some more text"); + BibtexString tripleC = new BibtexString("CCC", "Even more text"); Set stringSet = new HashSet<>(); stringSet.add(tripleA); stringSet.add(tripleB); diff --git a/src/test/java/org/jabref/model/database/DuplicationCheckerTest.java b/src/test/java/org/jabref/model/database/DuplicationCheckerTest.java index e9733e9f94e..e280a41d5c7 100644 --- a/src/test/java/org/jabref/model/database/DuplicationCheckerTest.java +++ b/src/test/java/org/jabref/model/database/DuplicationCheckerTest.java @@ -2,18 +2,17 @@ import org.jabref.model.entry.BibEntry; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; public class DuplicationCheckerTest { private BibDatabase database; - @Before + @BeforeEach public void setUp() { database = new BibDatabase(); } diff --git a/src/test/java/org/jabref/model/database/KeyChangeListenerTest.java b/src/test/java/org/jabref/model/database/KeyChangeListenerTest.java index 137bb6ce896..2540b5ed75e 100644 --- a/src/test/java/org/jabref/model/database/KeyChangeListenerTest.java +++ b/src/test/java/org/jabref/model/database/KeyChangeListenerTest.java @@ -5,10 +5,10 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.FieldName; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class KeyChangeListenerTest { @@ -19,7 +19,7 @@ public class KeyChangeListenerTest { private BibEntry entry4; - @Before + @BeforeEach public void setUp() { db = new BibDatabase(); diff --git a/src/test/java/org/jabref/model/database/event/AutosaveEventTest.java b/src/test/java/org/jabref/model/database/event/AutosaveEventTest.java index 46821edc456..10ed6f709de 100644 --- a/src/test/java/org/jabref/model/database/event/AutosaveEventTest.java +++ b/src/test/java/org/jabref/model/database/event/AutosaveEventTest.java @@ -1,8 +1,8 @@ package org.jabref.model.database.event; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class AutosaveEventTest { diff --git a/src/test/java/org/jabref/model/entry/AuthorListTest.java b/src/test/java/org/jabref/model/entry/AuthorListTest.java index 3926e212f54..73a15650267 100644 --- a/src/test/java/org/jabref/model/entry/AuthorListTest.java +++ b/src/test/java/org/jabref/model/entry/AuthorListTest.java @@ -2,8 +2,12 @@ import java.util.Optional; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; public class AuthorListTest { @@ -13,15 +17,15 @@ public static int size(String bibtex) { @Test public void testFixAuthorNatbib() { - Assert.assertEquals("", AuthorList.fixAuthorNatbib("")); - Assert.assertEquals("Smith", AuthorList.fixAuthorNatbib("John Smith")); - Assert.assertEquals("Smith and Black Brown", AuthorList + assertEquals("", AuthorList.fixAuthorNatbib("")); + assertEquals("Smith", AuthorList.fixAuthorNatbib("John Smith")); + assertEquals("Smith and Black Brown", AuthorList .fixAuthorNatbib("John Smith and Black Brown, Peter")); - Assert.assertEquals("von Neumann et al.", AuthorList + assertEquals("von Neumann et al.", AuthorList .fixAuthorNatbib("John von Neumann and John Smith and Black Brown, Peter")); // Is not cached! - Assert.assertTrue(AuthorList + assertTrue(AuthorList .fixAuthorNatbib("John von Neumann and John Smith and Black Brown, Peter").equals(AuthorList .fixAuthorNatbib("John von Neumann and John Smith and Black Brown, Peter"))); @@ -31,93 +35,93 @@ public void testFixAuthorNatbib() { public void testGetAuthorList() { // Test caching in authorCache. AuthorList al = AuthorList.parse("John Smith"); - Assert.assertEquals(al, AuthorList.parse("John Smith")); - Assert.assertFalse(al.equals(AuthorList.parse("Smith"))); + assertEquals(al, AuthorList.parse("John Smith")); + assertFalse(al.equals(AuthorList.parse("Smith"))); } @Test public void testFixAuthorFirstNameFirstCommas() { // No Commas - Assert.assertEquals("", AuthorList.fixAuthorFirstNameFirstCommas("", true, false)); - Assert.assertEquals("", AuthorList.fixAuthorFirstNameFirstCommas("", false, false)); + assertEquals("", AuthorList.fixAuthorFirstNameFirstCommas("", true, false)); + assertEquals("", AuthorList.fixAuthorFirstNameFirstCommas("", false, false)); - Assert.assertEquals("John Smith", AuthorList.fixAuthorFirstNameFirstCommas("John Smith", + assertEquals("John Smith", AuthorList.fixAuthorFirstNameFirstCommas("John Smith", false, false)); - Assert.assertEquals("J. Smith", AuthorList.fixAuthorFirstNameFirstCommas("John Smith", true, + assertEquals("J. Smith", AuthorList.fixAuthorFirstNameFirstCommas("John Smith", true, false)); // Check caching - Assert.assertTrue(AuthorList.fixAuthorFirstNameFirstCommas( + assertTrue(AuthorList.fixAuthorFirstNameFirstCommas( "John von Neumann and John Smith and Black Brown, Peter", true, false).equals( AuthorList .fixAuthorFirstNameFirstCommas("John von Neumann and John Smith and Black Brown, Peter", true, false))); - Assert.assertEquals("John Smith and Peter Black Brown", AuthorList + assertEquals("John Smith and Peter Black Brown", AuthorList .fixAuthorFirstNameFirstCommas("John Smith and Black Brown, Peter", false, false)); - Assert.assertEquals("J. Smith and P. Black Brown", AuthorList.fixAuthorFirstNameFirstCommas( + assertEquals("J. Smith and P. Black Brown", AuthorList.fixAuthorFirstNameFirstCommas( "John Smith and Black Brown, Peter", true, false)); // Method description is different than code -> additional comma // there - Assert.assertEquals("John von Neumann, John Smith and Peter Black Brown", AuthorList + assertEquals("John von Neumann, John Smith and Peter Black Brown", AuthorList .fixAuthorFirstNameFirstCommas( "John von Neumann and John Smith and Black Brown, Peter", false, false)); - Assert.assertEquals("J. von Neumann, J. Smith and P. Black Brown", AuthorList + assertEquals("J. von Neumann, J. Smith and P. Black Brown", AuthorList .fixAuthorFirstNameFirstCommas( "John von Neumann and John Smith and Black Brown, Peter", true, false)); - Assert.assertEquals("J. P. von Neumann", AuthorList.fixAuthorFirstNameFirstCommas( + assertEquals("J. P. von Neumann", AuthorList.fixAuthorFirstNameFirstCommas( "John Peter von Neumann", true, false)); // Oxford Commas - Assert.assertEquals("", AuthorList.fixAuthorFirstNameFirstCommas("", true, true)); - Assert.assertEquals("", AuthorList.fixAuthorFirstNameFirstCommas("", false, true)); + assertEquals("", AuthorList.fixAuthorFirstNameFirstCommas("", true, true)); + assertEquals("", AuthorList.fixAuthorFirstNameFirstCommas("", false, true)); - Assert.assertEquals("John Smith", AuthorList.fixAuthorFirstNameFirstCommas("John Smith", + assertEquals("John Smith", AuthorList.fixAuthorFirstNameFirstCommas("John Smith", false, true)); - Assert.assertEquals("J. Smith", AuthorList.fixAuthorFirstNameFirstCommas("John Smith", true, + assertEquals("J. Smith", AuthorList.fixAuthorFirstNameFirstCommas("John Smith", true, true)); // Check caching - Assert.assertTrue(AuthorList.fixAuthorFirstNameFirstCommas( + assertTrue(AuthorList.fixAuthorFirstNameFirstCommas( "John von Neumann and John Smith and Black Brown, Peter", true, true).equals( AuthorList .fixAuthorFirstNameFirstCommas("John von Neumann and John Smith and Black Brown, Peter", true, true))); - Assert.assertEquals("John Smith and Peter Black Brown", AuthorList + assertEquals("John Smith and Peter Black Brown", AuthorList .fixAuthorFirstNameFirstCommas("John Smith and Black Brown, Peter", false, true)); - Assert.assertEquals("J. Smith and P. Black Brown", AuthorList.fixAuthorFirstNameFirstCommas( + assertEquals("J. Smith and P. Black Brown", AuthorList.fixAuthorFirstNameFirstCommas( "John Smith and Black Brown, Peter", true, true)); // Method description is different than code -> additional comma // there - Assert.assertEquals("John von Neumann, John Smith, and Peter Black Brown", AuthorList + assertEquals("John von Neumann, John Smith, and Peter Black Brown", AuthorList .fixAuthorFirstNameFirstCommas( "John von Neumann and John Smith and Black Brown, Peter", false, true)); - Assert.assertEquals("J. von Neumann, J. Smith, and P. Black Brown", AuthorList + assertEquals("J. von Neumann, J. Smith, and P. Black Brown", AuthorList .fixAuthorFirstNameFirstCommas( "John von Neumann and John Smith and Black Brown, Peter", true, true)); - Assert.assertEquals("J. P. von Neumann", AuthorList.fixAuthorFirstNameFirstCommas( + assertEquals("J. P. von Neumann", AuthorList.fixAuthorFirstNameFirstCommas( "John Peter von Neumann", true, true)); } @Test public void testFixAuthorFirstNameFirst() { - Assert.assertEquals("John Smith", AuthorList.fixAuthorFirstNameFirst("John Smith")); + assertEquals("John Smith", AuthorList.fixAuthorFirstNameFirst("John Smith")); - Assert.assertEquals("John Smith and Peter Black Brown", AuthorList + assertEquals("John Smith and Peter Black Brown", AuthorList .fixAuthorFirstNameFirst("John Smith and Black Brown, Peter")); - Assert.assertEquals("John von Neumann and John Smith and Peter Black Brown", AuthorList + assertEquals("John von Neumann and John Smith and Peter Black Brown", AuthorList .fixAuthorFirstNameFirst("John von Neumann and John Smith and Black Brown, Peter")); - Assert.assertEquals("First von Last, Jr. III", AuthorList + assertEquals("First von Last, Jr. III", AuthorList .fixAuthorFirstNameFirst("von Last, Jr. III, First")); // Check caching - Assert.assertTrue(AuthorList + assertTrue(AuthorList .fixAuthorFirstNameFirst("John von Neumann and John Smith and Black Brown, Peter").equals(AuthorList .fixAuthorFirstNameFirst("John von Neumann and John Smith and Black Brown, Peter"))); @@ -126,11 +130,11 @@ public void testFixAuthorFirstNameFirst() { @Test public void testFixAuthorLastNameFirstCommasNoComma() { // No commas before and - Assert.assertEquals("", AuthorList.fixAuthorLastNameFirstCommas("", true, false)); - Assert.assertEquals("", AuthorList.fixAuthorLastNameFirstCommas("", false, false)); + assertEquals("", AuthorList.fixAuthorLastNameFirstCommas("", true, false)); + assertEquals("", AuthorList.fixAuthorLastNameFirstCommas("", false, false)); - Assert.assertEquals("Smith, John", AuthorList.fixAuthorLastNameFirstCommas("John Smith", false, false)); - Assert.assertEquals("Smith, J.", AuthorList.fixAuthorLastNameFirstCommas("John Smith", true, false)); + assertEquals("Smith, John", AuthorList.fixAuthorLastNameFirstCommas("John Smith", false, false)); + assertEquals("Smith, J.", AuthorList.fixAuthorLastNameFirstCommas("John Smith", true, false)); String a = AuthorList.fixAuthorLastNameFirstCommas("John von Neumann and John Smith and Black Brown, Peter", true, false); @@ -138,32 +142,32 @@ public void testFixAuthorLastNameFirstCommasNoComma() { "John von Neumann and John Smith and Black Brown, Peter", true, false); // Check caching - Assert.assertEquals(a, b); - Assert.assertTrue(a.equals(b)); + assertEquals(a, b); + assertTrue(a.equals(b)); - Assert.assertEquals("Smith, John and Black Brown, Peter", + assertEquals("Smith, John and Black Brown, Peter", AuthorList.fixAuthorLastNameFirstCommas("John Smith and Black Brown, Peter", false, false)); - Assert.assertEquals("Smith, J. and Black Brown, P.", + assertEquals("Smith, J. and Black Brown, P.", AuthorList.fixAuthorLastNameFirstCommas("John Smith and Black Brown, Peter", true, false)); - Assert.assertEquals("von Neumann, John, Smith, John and Black Brown, Peter", AuthorList + assertEquals("von Neumann, John, Smith, John and Black Brown, Peter", AuthorList .fixAuthorLastNameFirstCommas("John von Neumann and John Smith and Black Brown, Peter", false, false)); - Assert.assertEquals("von Neumann, J., Smith, J. and Black Brown, P.", AuthorList + assertEquals("von Neumann, J., Smith, J. and Black Brown, P.", AuthorList .fixAuthorLastNameFirstCommas("John von Neumann and John Smith and Black Brown, Peter", true, false)); - Assert.assertEquals("von Neumann, J. P.", + assertEquals("von Neumann, J. P.", AuthorList.fixAuthorLastNameFirstCommas("John Peter von Neumann", true, false)); } @Test public void testFixAuthorLastNameFirstCommasOxfordComma() { // Oxford Commas - Assert.assertEquals("", AuthorList.fixAuthorLastNameFirstCommas("", true, true)); - Assert.assertEquals("", AuthorList.fixAuthorLastNameFirstCommas("", false, true)); + assertEquals("", AuthorList.fixAuthorLastNameFirstCommas("", true, true)); + assertEquals("", AuthorList.fixAuthorLastNameFirstCommas("", false, true)); - Assert.assertEquals("Smith, John", AuthorList.fixAuthorLastNameFirstCommas("John Smith", + assertEquals("Smith, John", AuthorList.fixAuthorLastNameFirstCommas("John Smith", false, true)); - Assert.assertEquals("Smith, J.", AuthorList.fixAuthorLastNameFirstCommas("John Smith", true, + assertEquals("Smith, J.", AuthorList.fixAuthorLastNameFirstCommas("John Smith", true, true)); String a = AuthorList.fixAuthorLastNameFirstCommas( @@ -171,22 +175,22 @@ public void testFixAuthorLastNameFirstCommasOxfordComma() { String b = AuthorList.fixAuthorLastNameFirstCommas("John von Neumann and John Smith and Black Brown, Peter", true, true); // Check caching - Assert.assertEquals(a, b); - Assert.assertTrue(a.equals(b)); + assertEquals(a, b); + assertTrue(a.equals(b)); - Assert.assertEquals("Smith, John and Black Brown, Peter", AuthorList + assertEquals("Smith, John and Black Brown, Peter", AuthorList .fixAuthorLastNameFirstCommas("John Smith and Black Brown, Peter", false, true)); - Assert.assertEquals("Smith, J. and Black Brown, P.", AuthorList.fixAuthorLastNameFirstCommas( + assertEquals("Smith, J. and Black Brown, P.", AuthorList.fixAuthorLastNameFirstCommas( "John Smith and Black Brown, Peter", true, true)); - Assert.assertEquals("von Neumann, John, Smith, John, and Black Brown, Peter", AuthorList + assertEquals("von Neumann, John, Smith, John, and Black Brown, Peter", AuthorList .fixAuthorLastNameFirstCommas( "John von Neumann and John Smith and Black Brown, Peter", false, true)); - Assert.assertEquals("von Neumann, J., Smith, J., and Black Brown, P.", AuthorList + assertEquals("von Neumann, J., Smith, J., and Black Brown, P.", AuthorList .fixAuthorLastNameFirstCommas( "John von Neumann and John Smith and Black Brown, Peter", true, true)); - Assert.assertEquals("von Neumann, J. P.", AuthorList.fixAuthorLastNameFirstCommas( + assertEquals("von Neumann, J. P.", AuthorList.fixAuthorLastNameFirstCommas( "John Peter von Neumann", true, true)); } @@ -195,53 +199,53 @@ public void testFixAuthorLastNameFirst() { // Test helper method - Assert.assertEquals("Smith, John", AuthorList.fixAuthorLastNameFirst("John Smith")); + assertEquals("Smith, John", AuthorList.fixAuthorLastNameFirst("John Smith")); - Assert.assertEquals("Smith, John and Black Brown, Peter", AuthorList + assertEquals("Smith, John and Black Brown, Peter", AuthorList .fixAuthorLastNameFirst("John Smith and Black Brown, Peter")); - Assert.assertEquals("von Neumann, John and Smith, John and Black Brown, Peter", AuthorList + assertEquals("von Neumann, John and Smith, John and Black Brown, Peter", AuthorList .fixAuthorLastNameFirst("John von Neumann and John Smith and Black Brown, Peter")); - Assert.assertEquals("von Last, Jr, First", AuthorList + assertEquals("von Last, Jr, First", AuthorList .fixAuthorLastNameFirst("von Last, Jr ,First")); - Assert.assertTrue(AuthorList + assertTrue(AuthorList .fixAuthorLastNameFirst("John von Neumann and John Smith and Black Brown, Peter").equals(AuthorList .fixAuthorLastNameFirst("John von Neumann and John Smith and Black Brown, Peter"))); // Test Abbreviation == false - Assert.assertEquals("Smith, John", AuthorList.fixAuthorLastNameFirst("John Smith", false)); + assertEquals("Smith, John", AuthorList.fixAuthorLastNameFirst("John Smith", false)); - Assert.assertEquals("Smith, John and Black Brown, Peter", AuthorList.fixAuthorLastNameFirst( + assertEquals("Smith, John and Black Brown, Peter", AuthorList.fixAuthorLastNameFirst( "John Smith and Black Brown, Peter", false)); - Assert.assertEquals("von Neumann, John and Smith, John and Black Brown, Peter", AuthorList + assertEquals("von Neumann, John and Smith, John and Black Brown, Peter", AuthorList .fixAuthorLastNameFirst("John von Neumann and John Smith and Black Brown, Peter", false)); - Assert.assertEquals("von Last, Jr, First", AuthorList.fixAuthorLastNameFirst( + assertEquals("von Last, Jr, First", AuthorList.fixAuthorLastNameFirst( "von Last, Jr ,First", false)); - Assert.assertTrue(AuthorList.fixAuthorLastNameFirst( + assertTrue(AuthorList.fixAuthorLastNameFirst( "John von Neumann and John Smith and Black Brown, Peter", false).equals( AuthorList .fixAuthorLastNameFirst("John von Neumann and John Smith and Black Brown, Peter", false))); // Test Abbreviate == true - Assert.assertEquals("Smith, J.", AuthorList.fixAuthorLastNameFirst("John Smith", true)); + assertEquals("Smith, J.", AuthorList.fixAuthorLastNameFirst("John Smith", true)); - Assert.assertEquals("Smith, J. and Black Brown, P.", AuthorList.fixAuthorLastNameFirst( + assertEquals("Smith, J. and Black Brown, P.", AuthorList.fixAuthorLastNameFirst( "John Smith and Black Brown, Peter", true)); - Assert.assertEquals("von Neumann, J. and Smith, J. and Black Brown, P.", + assertEquals("von Neumann, J. and Smith, J. and Black Brown, P.", AuthorList.fixAuthorLastNameFirst( "John von Neumann and John Smith and Black Brown, Peter", true)); - Assert.assertEquals("von Last, Jr, F.", AuthorList.fixAuthorLastNameFirst("von Last, Jr ,First", + assertEquals("von Last, Jr, F.", AuthorList.fixAuthorLastNameFirst("von Last, Jr ,First", true)); - Assert.assertTrue(AuthorList.fixAuthorLastNameFirst( + assertTrue(AuthorList.fixAuthorLastNameFirst( "John von Neumann and John Smith and Black Brown, Peter", true).equals( AuthorList .fixAuthorLastNameFirst("John von Neumann and John Smith and Black Brown, Peter", true))); @@ -252,39 +256,39 @@ public void testFixAuthorLastNameFirst() { public void testFixAuthorLastNameOnlyCommas() { // No comma before and - Assert.assertEquals("", AuthorList.fixAuthorLastNameOnlyCommas("", false)); - Assert.assertEquals("Smith", AuthorList.fixAuthorLastNameOnlyCommas("John Smith", false)); - Assert.assertEquals("Smith", AuthorList.fixAuthorLastNameOnlyCommas("Smith, Jr, John", false)); + assertEquals("", AuthorList.fixAuthorLastNameOnlyCommas("", false)); + assertEquals("Smith", AuthorList.fixAuthorLastNameOnlyCommas("John Smith", false)); + assertEquals("Smith", AuthorList.fixAuthorLastNameOnlyCommas("Smith, Jr, John", false)); - Assert.assertTrue(AuthorList.fixAuthorLastNameOnlyCommas( + assertTrue(AuthorList.fixAuthorLastNameOnlyCommas( "John von Neumann and John Smith and Black Brown, Peter", false).equals( AuthorList .fixAuthorLastNameOnlyCommas("John von Neumann and John Smith and Black Brown, Peter", false))); - Assert.assertEquals("von Neumann, Smith and Black Brown", AuthorList + assertEquals("von Neumann, Smith and Black Brown", AuthorList .fixAuthorLastNameOnlyCommas( "John von Neumann and John Smith and Black Brown, Peter", false)); // Oxford Comma - Assert.assertEquals("", AuthorList.fixAuthorLastNameOnlyCommas("", true)); - Assert.assertEquals("Smith", AuthorList.fixAuthorLastNameOnlyCommas("John Smith", true)); - Assert.assertEquals("Smith", AuthorList.fixAuthorLastNameOnlyCommas("Smith, Jr, John", true)); + assertEquals("", AuthorList.fixAuthorLastNameOnlyCommas("", true)); + assertEquals("Smith", AuthorList.fixAuthorLastNameOnlyCommas("John Smith", true)); + assertEquals("Smith", AuthorList.fixAuthorLastNameOnlyCommas("Smith, Jr, John", true)); - Assert.assertTrue(AuthorList.fixAuthorLastNameOnlyCommas( + assertTrue(AuthorList.fixAuthorLastNameOnlyCommas( "John von Neumann and John Smith and Black Brown, Peter", true).equals( AuthorList .fixAuthorLastNameOnlyCommas("John von Neumann and John Smith and Black Brown, Peter", true))); - Assert.assertEquals("von Neumann, Smith, and Black Brown", AuthorList + assertEquals("von Neumann, Smith, and Black Brown", AuthorList .fixAuthorLastNameOnlyCommas( "John von Neumann and John Smith and Black Brown, Peter", true)); } @Test public void testFixAuthorForAlphabetization() { - Assert.assertEquals("Smith, J.", AuthorList.fixAuthorForAlphabetization("John Smith")); - Assert.assertEquals("Neumann, J.", AuthorList.fixAuthorForAlphabetization("John von Neumann")); - Assert.assertEquals("Neumann, J.", AuthorList.fixAuthorForAlphabetization("J. von Neumann")); - Assert.assertEquals( + assertEquals("Smith, J.", AuthorList.fixAuthorForAlphabetization("John Smith")); + assertEquals("Neumann, J.", AuthorList.fixAuthorForAlphabetization("John von Neumann")); + assertEquals("Neumann, J.", AuthorList.fixAuthorForAlphabetization("J. von Neumann")); + assertEquals( "Neumann, J. and Smith, J. and Black Brown, Jr., P.", AuthorList .fixAuthorForAlphabetization("John von Neumann and John Smith and de Black Brown, Jr., Peter")); @@ -293,75 +297,74 @@ public void testFixAuthorForAlphabetization() { @Test public void testSize() { - Assert.assertEquals(0, AuthorListTest.size("")); - Assert.assertEquals(1, AuthorListTest.size("Bar")); - Assert.assertEquals(1, AuthorListTest.size("Foo Bar")); - Assert.assertEquals(1, AuthorListTest.size("Foo von Bar")); - Assert.assertEquals(1, AuthorListTest.size("von Bar, Foo")); - Assert.assertEquals(1, AuthorListTest.size("Bar, Foo")); - Assert.assertEquals(1, AuthorListTest.size("Bar, Jr., Foo")); - Assert.assertEquals(1, AuthorListTest.size("Bar, Foo")); - Assert.assertEquals(2, AuthorListTest.size("John Neumann and Foo Bar")); - Assert.assertEquals(2, AuthorListTest.size("John von Neumann and Bar, Jr, Foo")); + assertEquals(0, AuthorListTest.size("")); + assertEquals(1, AuthorListTest.size("Bar")); + assertEquals(1, AuthorListTest.size("Foo Bar")); + assertEquals(1, AuthorListTest.size("Foo von Bar")); + assertEquals(1, AuthorListTest.size("von Bar, Foo")); + assertEquals(1, AuthorListTest.size("Bar, Foo")); + assertEquals(1, AuthorListTest.size("Bar, Jr., Foo")); + assertEquals(1, AuthorListTest.size("Bar, Foo")); + assertEquals(2, AuthorListTest.size("John Neumann and Foo Bar")); + assertEquals(2, AuthorListTest.size("John von Neumann and Bar, Jr, Foo")); - Assert.assertEquals(3, AuthorListTest.size("John von Neumann and John Smith and Black Brown, Peter")); + assertEquals(3, AuthorListTest.size("John von Neumann and John Smith and Black Brown, Peter")); StringBuilder s = new StringBuilder("John von Neumann"); for (int i = 0; i < 25; i++) { - Assert.assertEquals(i + 1, AuthorListTest.size(s.toString())); + assertEquals(i + 1, AuthorListTest.size(s.toString())); s.append(" and Albert Einstein"); } } @Test public void testIsEmpty() { - - Assert.assertTrue(AuthorList.parse("").isEmpty()); - Assert.assertFalse(AuthorList.parse("Bar").isEmpty()); + assertTrue(AuthorList.parse("").isEmpty()); + assertFalse(AuthorList.parse("Bar").isEmpty()); } - @Test(expected = Exception.class) + @Test public void testGetEmptyAuthor() { - AuthorList.parse("").getAuthor(0); - Assert.fail(); + assertThrows(Exception.class, () -> AuthorList.parse("").getAuthor(0)); + } @Test public void testGetAuthor() { Author author = AuthorList.parse("John Smith and von Neumann, Jr, John").getAuthor(0); - Assert.assertEquals(Optional.of("John"), author.getFirst()); - Assert.assertEquals(Optional.of("J."), author.getFirstAbbr()); - Assert.assertEquals("John Smith", author.getFirstLast(false)); - Assert.assertEquals("J. Smith", author.getFirstLast(true)); - Assert.assertEquals(Optional.empty(), author.getJr()); - Assert.assertEquals(Optional.of("Smith"), author.getLast()); - Assert.assertEquals("Smith, John", author.getLastFirst(false)); - Assert.assertEquals("Smith, J.", author.getLastFirst(true)); - Assert.assertEquals("Smith", author.getLastOnly()); - Assert.assertEquals("Smith, J.", author.getNameForAlphabetization()); - Assert.assertEquals(Optional.empty(), author.getVon()); + assertEquals(Optional.of("John"), author.getFirst()); + assertEquals(Optional.of("J."), author.getFirstAbbr()); + assertEquals("John Smith", author.getFirstLast(false)); + assertEquals("J. Smith", author.getFirstLast(true)); + assertEquals(Optional.empty(), author.getJr()); + assertEquals(Optional.of("Smith"), author.getLast()); + assertEquals("Smith, John", author.getLastFirst(false)); + assertEquals("Smith, J.", author.getLastFirst(true)); + assertEquals("Smith", author.getLastOnly()); + assertEquals("Smith, J.", author.getNameForAlphabetization()); + assertEquals(Optional.empty(), author.getVon()); author = AuthorList.parse("Peter Black Brown").getAuthor(0); - Assert.assertEquals(Optional.of("Peter Black"), author.getFirst()); - Assert.assertEquals(Optional.of("P. B."), author.getFirstAbbr()); - Assert.assertEquals("Peter Black Brown", author.getFirstLast(false)); - Assert.assertEquals("P. B. Brown", author.getFirstLast(true)); - Assert.assertEquals(Optional.empty(), author.getJr()); - Assert.assertEquals(Optional.empty(), author.getVon()); + assertEquals(Optional.of("Peter Black"), author.getFirst()); + assertEquals(Optional.of("P. B."), author.getFirstAbbr()); + assertEquals("Peter Black Brown", author.getFirstLast(false)); + assertEquals("P. B. Brown", author.getFirstLast(true)); + assertEquals(Optional.empty(), author.getJr()); + assertEquals(Optional.empty(), author.getVon()); author = AuthorList.parse("John Smith and von Neumann, Jr, John").getAuthor(1); - Assert.assertEquals(Optional.of("John"), author.getFirst()); - Assert.assertEquals(Optional.of("J."), author.getFirstAbbr()); - Assert.assertEquals("John von Neumann, Jr", author.getFirstLast(false)); - Assert.assertEquals("J. von Neumann, Jr", author.getFirstLast(true)); - Assert.assertEquals(Optional.of("Jr"), author.getJr()); - Assert.assertEquals(Optional.of("Neumann"), author.getLast()); - Assert.assertEquals("von Neumann, Jr, John", author.getLastFirst(false)); - Assert.assertEquals("von Neumann, Jr, J.", author.getLastFirst(true)); - Assert.assertEquals("von Neumann", author.getLastOnly()); - Assert.assertEquals("Neumann, Jr, J.", author.getNameForAlphabetization()); - Assert.assertEquals(Optional.of("von"), author.getVon()); + assertEquals(Optional.of("John"), author.getFirst()); + assertEquals(Optional.of("J."), author.getFirstAbbr()); + assertEquals("John von Neumann, Jr", author.getFirstLast(false)); + assertEquals("J. von Neumann, Jr", author.getFirstLast(true)); + assertEquals(Optional.of("Jr"), author.getJr()); + assertEquals(Optional.of("Neumann"), author.getLast()); + assertEquals("von Neumann, Jr, John", author.getLastFirst(false)); + assertEquals("von Neumann, Jr, J.", author.getLastFirst(true)); + assertEquals("von Neumann", author.getLastOnly()); + assertEquals("Neumann, Jr, J.", author.getNameForAlphabetization()); + assertEquals(Optional.of("von"), author.getVon()); } @@ -369,65 +372,65 @@ public void testGetAuthor() { public void testCompanyAuthor() { Author author = AuthorList.parse("{JabRef Developers}").getAuthor(0); Author expected = new Author(null, null, null, "JabRef Developers", null); - Assert.assertEquals(expected, author); + assertEquals(expected, author); } @Test public void testCompanyAuthorWithLowerCaseWord() { Author author = AuthorList.parse("{JabRef Developers on Fire}").getAuthor(0); Author expected = new Author(null, null, null, "JabRef Developers on Fire", null); - Assert.assertEquals(expected, author); + assertEquals(expected, author); } @Test public void testAbbreviationWithRelax() { Author author = AuthorList.parse("{\\relax Ch}ristoph Cholera").getAuthor(0); Author expected = new Author("{\\relax Ch}ristoph", "{\\relax Ch}.", null, "Cholera", null); - Assert.assertEquals(expected, author); + assertEquals(expected, author); } @Test public void testGetAuthorsNatbib() { - Assert.assertEquals("", AuthorList.parse("").getAsNatbib()); - Assert.assertEquals("Smith", AuthorList.parse("John Smith").getAsNatbib()); - Assert.assertEquals("Smith and Black Brown", AuthorList.parse( + assertEquals("", AuthorList.parse("").getAsNatbib()); + assertEquals("Smith", AuthorList.parse("John Smith").getAsNatbib()); + assertEquals("Smith and Black Brown", AuthorList.parse( "John Smith and Black Brown, Peter").getAsNatbib()); - Assert.assertEquals("von Neumann et al.", AuthorList.parse( + assertEquals("von Neumann et al.", AuthorList.parse( "John von Neumann and John Smith and Black Brown, Peter").getAsNatbib()); /* * [ 1465610 ] (Double-)Names containing hyphen (-) not handled correctly */ - Assert.assertEquals("Last-Name et al.", AuthorList.parse( + assertEquals("Last-Name et al.", AuthorList.parse( "First Second Last-Name" + " and John Smith and Black Brown, Peter").getAsNatbib()); // Test caching AuthorList al = AuthorList .parse("John von Neumann and John Smith and Black Brown, Peter"); - Assert.assertTrue(al.getAsNatbib().equals(al.getAsNatbib())); + assertTrue(al.getAsNatbib().equals(al.getAsNatbib())); } @Test public void testGetAuthorsLastOnly() { // No comma before and - Assert.assertEquals("", AuthorList.parse("").getAsLastNames(false)); - Assert.assertEquals("Smith", AuthorList.parse("John Smith").getAsLastNames(false)); - Assert.assertEquals("Smith", AuthorList.parse("Smith, Jr, John").getAsLastNames( + assertEquals("", AuthorList.parse("").getAsLastNames(false)); + assertEquals("Smith", AuthorList.parse("John Smith").getAsLastNames(false)); + assertEquals("Smith", AuthorList.parse("Smith, Jr, John").getAsLastNames( false)); - Assert.assertEquals("von Neumann, Smith and Black Brown", AuthorList.parse( + assertEquals("von Neumann, Smith and Black Brown", AuthorList.parse( "John von Neumann and John Smith and Black Brown, Peter").getAsLastNames(false)); // Oxford comma - Assert.assertEquals("", AuthorList.parse("").getAsLastNames(true)); - Assert.assertEquals("Smith", AuthorList.parse("John Smith").getAsLastNames(true)); - Assert.assertEquals("Smith", AuthorList.parse("Smith, Jr, John").getAsLastNames( + assertEquals("", AuthorList.parse("").getAsLastNames(true)); + assertEquals("Smith", AuthorList.parse("John Smith").getAsLastNames(true)); + assertEquals("Smith", AuthorList.parse("Smith, Jr, John").getAsLastNames( true)); - Assert.assertEquals("von Neumann, Smith, and Black Brown", AuthorList.parse( + assertEquals("von Neumann, Smith, and Black Brown", AuthorList.parse( "John von Neumann and John Smith and Black Brown, Peter").getAsLastNames(true)); - Assert.assertEquals("von Neumann and Smith", + assertEquals("von Neumann and Smith", AuthorList.parse("John von Neumann and John Smith").getAsLastNames(false)); } @@ -437,26 +440,26 @@ public void testGetAuthorsLastFirstNoComma() { AuthorList al; al = AuthorList.parse(""); - Assert.assertEquals("", al.getAsLastFirstNames(true, false)); - Assert.assertEquals("", al.getAsLastFirstNames(false, false)); + assertEquals("", al.getAsLastFirstNames(true, false)); + assertEquals("", al.getAsLastFirstNames(false, false)); al = AuthorList.parse("John Smith"); - Assert.assertEquals("Smith, John", al.getAsLastFirstNames(false, false)); - Assert.assertEquals("Smith, J.", al.getAsLastFirstNames(true, false)); + assertEquals("Smith, John", al.getAsLastFirstNames(false, false)); + assertEquals("Smith, J.", al.getAsLastFirstNames(true, false)); al = AuthorList.parse("John Smith and Black Brown, Peter"); - Assert.assertEquals("Smith, John and Black Brown, Peter", al.getAsLastFirstNames(false, false)); - Assert.assertEquals("Smith, J. and Black Brown, P.", al.getAsLastFirstNames(true, false)); + assertEquals("Smith, John and Black Brown, Peter", al.getAsLastFirstNames(false, false)); + assertEquals("Smith, J. and Black Brown, P.", al.getAsLastFirstNames(true, false)); al = AuthorList.parse("John von Neumann and John Smith and Black Brown, Peter"); // Method description is different than code -> additional comma // there - Assert.assertEquals("von Neumann, John, Smith, John and Black Brown, Peter", + assertEquals("von Neumann, John, Smith, John and Black Brown, Peter", al.getAsLastFirstNames(false, false)); - Assert.assertEquals("von Neumann, J., Smith, J. and Black Brown, P.", al.getAsLastFirstNames(true, false)); + assertEquals("von Neumann, J., Smith, J. and Black Brown, P.", al.getAsLastFirstNames(true, false)); al = AuthorList.parse("John Peter von Neumann"); - Assert.assertEquals("von Neumann, J. P.", al.getAsLastFirstNames(true, false)); + assertEquals("von Neumann, J. P.", al.getAsLastFirstNames(true, false)); } @Test @@ -465,46 +468,46 @@ public void testGetAuthorsLastFirstOxfordComma() { AuthorList al; al = AuthorList.parse(""); - Assert.assertEquals("", al.getAsLastFirstNames(true, true)); - Assert.assertEquals("", al.getAsLastFirstNames(false, true)); + assertEquals("", al.getAsLastFirstNames(true, true)); + assertEquals("", al.getAsLastFirstNames(false, true)); al = AuthorList.parse("John Smith"); - Assert.assertEquals("Smith, John", al.getAsLastFirstNames(false, true)); - Assert.assertEquals("Smith, J.", al.getAsLastFirstNames(true, true)); + assertEquals("Smith, John", al.getAsLastFirstNames(false, true)); + assertEquals("Smith, J.", al.getAsLastFirstNames(true, true)); al = AuthorList.parse("John Smith and Black Brown, Peter"); - Assert.assertEquals("Smith, John and Black Brown, Peter", al.getAsLastFirstNames(false, true)); - Assert.assertEquals("Smith, J. and Black Brown, P.", al.getAsLastFirstNames(true, true)); + assertEquals("Smith, John and Black Brown, Peter", al.getAsLastFirstNames(false, true)); + assertEquals("Smith, J. and Black Brown, P.", al.getAsLastFirstNames(true, true)); al = AuthorList.parse("John von Neumann and John Smith and Black Brown, Peter"); - Assert.assertEquals("von Neumann, John, Smith, John, and Black Brown, Peter", al + assertEquals("von Neumann, John, Smith, John, and Black Brown, Peter", al .getAsLastFirstNames(false, true)); - Assert.assertEquals("von Neumann, J., Smith, J., and Black Brown, P.", al.getAsLastFirstNames( + assertEquals("von Neumann, J., Smith, J., and Black Brown, P.", al.getAsLastFirstNames( true, true)); al = AuthorList.parse("John Peter von Neumann"); - Assert.assertEquals("von Neumann, J. P.", al.getAsLastFirstNames(true, true)); + assertEquals("von Neumann, J. P.", al.getAsLastFirstNames(true, true)); } @Test public void testGetAuthorsLastFirstAnds() { - Assert.assertEquals("Smith, John", AuthorList.parse("John Smith").getAsLastFirstNamesWithAnd( + assertEquals("Smith, John", AuthorList.parse("John Smith").getAsLastFirstNamesWithAnd( false)); - Assert.assertEquals("Smith, John and Black Brown, Peter", AuthorList.parse( + assertEquals("Smith, John and Black Brown, Peter", AuthorList.parse( "John Smith and Black Brown, Peter").getAsLastFirstNamesWithAnd(false)); - Assert.assertEquals("von Neumann, John and Smith, John and Black Brown, Peter", AuthorList + assertEquals("von Neumann, John and Smith, John and Black Brown, Peter", AuthorList .parse("John von Neumann and John Smith and Black Brown, Peter") .getAsLastFirstNamesWithAnd(false)); - Assert.assertEquals("von Last, Jr, First", AuthorList.parse("von Last, Jr ,First") + assertEquals("von Last, Jr, First", AuthorList.parse("von Last, Jr ,First") .getAsLastFirstNamesWithAnd(false)); - Assert.assertEquals("Smith, J.", AuthorList.parse("John Smith").getAsLastFirstNamesWithAnd( + assertEquals("Smith, J.", AuthorList.parse("John Smith").getAsLastFirstNamesWithAnd( true)); - Assert.assertEquals("Smith, J. and Black Brown, P.", AuthorList.parse( + assertEquals("Smith, J. and Black Brown, P.", AuthorList.parse( "John Smith and Black Brown, Peter").getAsLastFirstNamesWithAnd(true)); - Assert.assertEquals("von Neumann, J. and Smith, J. and Black Brown, P.", AuthorList.parse( + assertEquals("von Neumann, J. and Smith, J. and Black Brown, P.", AuthorList.parse( "John von Neumann and John Smith and Black Brown, Peter").getAsLastFirstNamesWithAnd(true)); - Assert.assertEquals("von Last, Jr, F.", AuthorList.parse("von Last, Jr ,First") + assertEquals("von Last, Jr, F.", AuthorList.parse("von Last, Jr ,First") .getAsLastFirstNamesWithAnd(true)); } @@ -512,10 +515,10 @@ public void testGetAuthorsLastFirstAnds() { @Test public void testGetAuthorsLastFirstAndsCaching() { // getAsLastFirstNamesWithAnd caches its results, therefore we call the method twice using the same arguments - Assert.assertEquals("Smith, John", AuthorList.parse("John Smith").getAsLastFirstNamesWithAnd(false)); - Assert.assertEquals("Smith, John", AuthorList.parse("John Smith").getAsLastFirstNamesWithAnd(false)); - Assert.assertEquals("Smith, J.", AuthorList.parse("John Smith").getAsLastFirstNamesWithAnd(true)); - Assert.assertEquals("Smith, J.", AuthorList.parse("John Smith").getAsLastFirstNamesWithAnd(true)); + assertEquals("Smith, John", AuthorList.parse("John Smith").getAsLastFirstNamesWithAnd(false)); + assertEquals("Smith, John", AuthorList.parse("John Smith").getAsLastFirstNamesWithAnd(false)); + assertEquals("Smith, J.", AuthorList.parse("John Smith").getAsLastFirstNamesWithAnd(true)); + assertEquals("Smith, J.", AuthorList.parse("John Smith").getAsLastFirstNamesWithAnd(true)); } @Test @@ -524,79 +527,79 @@ public void testGetAuthorsFirstFirst() { AuthorList al; al = AuthorList.parse(""); - Assert.assertEquals("", al.getAsFirstLastNames(true, false)); - Assert.assertEquals("", al.getAsFirstLastNames(false, false)); - Assert.assertEquals("", al.getAsFirstLastNames(true, true)); - Assert.assertEquals("", al.getAsFirstLastNames(false, true)); + assertEquals("", al.getAsFirstLastNames(true, false)); + assertEquals("", al.getAsFirstLastNames(false, false)); + assertEquals("", al.getAsFirstLastNames(true, true)); + assertEquals("", al.getAsFirstLastNames(false, true)); al = AuthorList.parse("John Smith"); - Assert.assertEquals("John Smith", al.getAsFirstLastNames(false, false)); - Assert.assertEquals("J. Smith", al.getAsFirstLastNames(true, false)); - Assert.assertEquals("John Smith", al.getAsFirstLastNames(false, true)); - Assert.assertEquals("J. Smith", al.getAsFirstLastNames(true, true)); + assertEquals("John Smith", al.getAsFirstLastNames(false, false)); + assertEquals("J. Smith", al.getAsFirstLastNames(true, false)); + assertEquals("John Smith", al.getAsFirstLastNames(false, true)); + assertEquals("J. Smith", al.getAsFirstLastNames(true, true)); al = AuthorList.parse("John Smith and Black Brown, Peter"); - Assert.assertEquals("John Smith and Peter Black Brown", al.getAsFirstLastNames(false, false)); - Assert.assertEquals("J. Smith and P. Black Brown", al.getAsFirstLastNames(true, false)); - Assert.assertEquals("John Smith and Peter Black Brown", al.getAsFirstLastNames(false, true)); - Assert.assertEquals("J. Smith and P. Black Brown", al.getAsFirstLastNames(true, true)); + assertEquals("John Smith and Peter Black Brown", al.getAsFirstLastNames(false, false)); + assertEquals("J. Smith and P. Black Brown", al.getAsFirstLastNames(true, false)); + assertEquals("John Smith and Peter Black Brown", al.getAsFirstLastNames(false, true)); + assertEquals("J. Smith and P. Black Brown", al.getAsFirstLastNames(true, true)); al = AuthorList.parse("John von Neumann and John Smith and Black Brown, Peter"); - Assert.assertEquals("John von Neumann, John Smith and Peter Black Brown", al.getAsFirstLastNames( + assertEquals("John von Neumann, John Smith and Peter Black Brown", al.getAsFirstLastNames( false, false)); - Assert.assertEquals("J. von Neumann, J. Smith and P. Black Brown", al.getAsFirstLastNames(true, + assertEquals("J. von Neumann, J. Smith and P. Black Brown", al.getAsFirstLastNames(true, false)); - Assert.assertEquals("John von Neumann, John Smith, and Peter Black Brown", al + assertEquals("John von Neumann, John Smith, and Peter Black Brown", al .getAsFirstLastNames(false, true)); - Assert.assertEquals("J. von Neumann, J. Smith, and P. Black Brown", al.getAsFirstLastNames(true, + assertEquals("J. von Neumann, J. Smith, and P. Black Brown", al.getAsFirstLastNames(true, true)); al = AuthorList.parse("John Peter von Neumann"); - Assert.assertEquals("John Peter von Neumann", al.getAsFirstLastNames(false, false)); - Assert.assertEquals("John Peter von Neumann", al.getAsFirstLastNames(false, true)); - Assert.assertEquals("J. P. von Neumann", al.getAsFirstLastNames(true, false)); - Assert.assertEquals("J. P. von Neumann", al.getAsFirstLastNames(true, true)); + assertEquals("John Peter von Neumann", al.getAsFirstLastNames(false, false)); + assertEquals("John Peter von Neumann", al.getAsFirstLastNames(false, true)); + assertEquals("J. P. von Neumann", al.getAsFirstLastNames(true, false)); + assertEquals("J. P. von Neumann", al.getAsFirstLastNames(true, true)); } @Test public void testGetAuthorsFirstFirstAnds() { - Assert.assertEquals("John Smith", AuthorList.parse("John Smith") + assertEquals("John Smith", AuthorList.parse("John Smith") .getAsFirstLastNamesWithAnd()); - Assert.assertEquals("John Smith and Peter Black Brown", AuthorList.parse( + assertEquals("John Smith and Peter Black Brown", AuthorList.parse( "John Smith and Black Brown, Peter").getAsFirstLastNamesWithAnd()); - Assert.assertEquals("John von Neumann and John Smith and Peter Black Brown", AuthorList + assertEquals("John von Neumann and John Smith and Peter Black Brown", AuthorList .parse("John von Neumann and John Smith and Black Brown, Peter") .getAsFirstLastNamesWithAnd()); - Assert.assertEquals("First von Last, Jr. III", AuthorList + assertEquals("First von Last, Jr. III", AuthorList .parse("von Last, Jr. III, First").getAsFirstLastNamesWithAnd()); } @Test public void testGetAuthorsForAlphabetization() { - Assert.assertEquals("Smith, J.", AuthorList.parse("John Smith") + assertEquals("Smith, J.", AuthorList.parse("John Smith") .getForAlphabetization()); - Assert.assertEquals("Neumann, J.", AuthorList.parse("John von Neumann") + assertEquals("Neumann, J.", AuthorList.parse("John von Neumann") .getForAlphabetization()); - Assert.assertEquals("Neumann, J.", AuthorList.parse("J. von Neumann") + assertEquals("Neumann, J.", AuthorList.parse("J. von Neumann") .getForAlphabetization()); - Assert.assertEquals("Neumann, J. and Smith, J. and Black Brown, Jr., P.", AuthorList + assertEquals("Neumann, J. and Smith, J. and Black Brown, Jr., P.", AuthorList .parse("John von Neumann and John Smith and de Black Brown, Jr., Peter") .getForAlphabetization()); } @Test public void testRemoveStartAndEndBraces() { - Assert.assertEquals("{A}bbb{c}", AuthorList.parse("{A}bbb{c}").getAsLastNames(false)); - Assert.assertEquals("Vall{\\'e}e Poussin", AuthorList.parse("{Vall{\\'e}e Poussin}").getAsLastNames(false)); - Assert.assertEquals("Poussin", AuthorList.parse("{Vall{\\'e}e} {Poussin}").getAsLastNames(false)); - Assert.assertEquals("Poussin", AuthorList.parse("Vall{\\'e}e Poussin").getAsLastNames(false)); - Assert.assertEquals("Lastname", AuthorList.parse("Firstname {Lastname}").getAsLastNames(false)); - Assert.assertEquals("Firstname Lastname", AuthorList.parse("{Firstname Lastname}").getAsLastNames(false)); + assertEquals("{A}bbb{c}", AuthorList.parse("{A}bbb{c}").getAsLastNames(false)); + assertEquals("Vall{\\'e}e Poussin", AuthorList.parse("{Vall{\\'e}e Poussin}").getAsLastNames(false)); + assertEquals("Poussin", AuthorList.parse("{Vall{\\'e}e} {Poussin}").getAsLastNames(false)); + assertEquals("Poussin", AuthorList.parse("Vall{\\'e}e Poussin").getAsLastNames(false)); + assertEquals("Lastname", AuthorList.parse("Firstname {Lastname}").getAsLastNames(false)); + assertEquals("Firstname Lastname", AuthorList.parse("{Firstname Lastname}").getAsLastNames(false)); } @Test public void createCorrectInitials() { - Assert.assertEquals(Optional.of("J. G."), + assertEquals(Optional.of("J. G."), AuthorList.parse("Hornberg, Johann Gottfried").getAuthor(0).getFirstAbbr()); } @@ -604,50 +607,50 @@ public void createCorrectInitials() { public void parseNameWithBracesAroundFirstName() throws Exception { //TODO: Be more intelligent and abbreviate the first name correctly Author expected = new Author("Tse-tung", "{Tse-tung}.", null, "Mao", null); - Assert.assertEquals(new AuthorList(expected), AuthorList.parse("{Tse-tung} Mao")); + assertEquals(new AuthorList(expected), AuthorList.parse("{Tse-tung} Mao")); } @Test public void parseNameWithBracesAroundLastName() throws Exception { Author expected = new Author("Hans", "H.", null, "van den Bergen", null); - Assert.assertEquals(new AuthorList(expected), AuthorList.parse("{van den Bergen}, Hans")); + assertEquals(new AuthorList(expected), AuthorList.parse("{van den Bergen}, Hans")); } @Test public void parseNameWithHyphenInFirstName() throws Exception { Author expected = new Author("Tse-tung", "T.-t.", null, "Mao", null); - Assert.assertEquals(new AuthorList(expected), AuthorList.parse("Tse-tung Mao")); + assertEquals(new AuthorList(expected), AuthorList.parse("Tse-tung Mao")); } @Test public void parseNameWithHyphenInLastName() throws Exception { Author expected = new Author("Firstname", "F.", null, "Bailey-Jones", null); - Assert.assertEquals(new AuthorList(expected), AuthorList.parse("Firstname Bailey-Jones")); + assertEquals(new AuthorList(expected), AuthorList.parse("Firstname Bailey-Jones")); } @Test public void parseNameWithHyphenInLastNameWithInitials() throws Exception { Author expected = new Author("E. S.", "E. S.", null, "El-{M}allah", null); - Assert.assertEquals(new AuthorList(expected), AuthorList.parse("E. S. El-{M}allah")); + assertEquals(new AuthorList(expected), AuthorList.parse("E. S. El-{M}allah")); } @Test public void parseNameWithHyphenInLastNameWithEscaped() throws Exception { Author expected = new Author("E. S.", "E. S.", null, "{K}ent-{B}oswell", null); - Assert.assertEquals(new AuthorList(expected), AuthorList.parse("E. S. {K}ent-{B}oswell")); + assertEquals(new AuthorList(expected), AuthorList.parse("E. S. {K}ent-{B}oswell")); } @Test public void parseNameWithHyphenInLastNameWhenLastNameGivenFirst() throws Exception { // TODO: Fix abbreviation to be "A." Author expected = new Author("ʿAbdallāh", "ʿ.", null, "al-Ṣāliḥ", null); - Assert.assertEquals(new AuthorList(expected), AuthorList.parse("al-Ṣāliḥ, ʿAbdallāh")); + assertEquals(new AuthorList(expected), AuthorList.parse("al-Ṣāliḥ, ʿAbdallāh")); } @Test public void parseNameWithBraces() throws Exception { Author expected = new Author("H{e}lene", "H.", null, "Fiaux", null); - Assert.assertEquals(new AuthorList(expected), AuthorList.parse("H{e}lene Fiaux")); + assertEquals(new AuthorList(expected), AuthorList.parse("H{e}lene Fiaux")); } /** @@ -656,16 +659,16 @@ public void parseNameWithBraces() throws Exception { @Test public void correctNamesWithOneComma() throws Exception { Author expected = new Author("Alexander der Große", "A. d. G.", null, "Canon der Barbar", null); - Assert.assertEquals(new AuthorList(expected), AuthorList.parse("Canon der Barbar, Alexander der Große")); + assertEquals(new AuthorList(expected), AuthorList.parse("Canon der Barbar, Alexander der Große")); expected = new Author("Alexander H. G.", "A. H. G.", null, "Rinnooy Kan", null); - Assert.assertEquals(new AuthorList(expected), AuthorList.parse("Rinnooy Kan, Alexander H. G.")); + assertEquals(new AuthorList(expected), AuthorList.parse("Rinnooy Kan, Alexander H. G.")); expected = new Author("Alexander Hendrik George", "A. H. G.", null, "Rinnooy Kan", null); - Assert.assertEquals(new AuthorList(expected), AuthorList.parse("Rinnooy Kan, Alexander Hendrik George")); + assertEquals(new AuthorList(expected), AuthorList.parse("Rinnooy Kan, Alexander Hendrik George")); expected = new Author("José María", "J. M.", null, "Rodriguez Fernandez", null); - Assert.assertEquals(new AuthorList(expected), AuthorList.parse("Rodriguez Fernandez, José María")); + assertEquals(new AuthorList(expected), AuthorList.parse("Rodriguez Fernandez, José María")); } } diff --git a/src/test/java/org/jabref/model/entry/AuthorTest.java b/src/test/java/org/jabref/model/entry/AuthorTest.java index 2d0f2cd6437..c5c40902927 100644 --- a/src/test/java/org/jabref/model/entry/AuthorTest.java +++ b/src/test/java/org/jabref/model/entry/AuthorTest.java @@ -1,8 +1,8 @@ package org.jabref.model.entry; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class AuthorTest { diff --git a/src/test/java/org/jabref/model/entry/BibEntryEqualityTest.java b/src/test/java/org/jabref/model/entry/BibEntryEqualityTest.java index 061dd189637..14550fe28df 100644 --- a/src/test/java/org/jabref/model/entry/BibEntryEqualityTest.java +++ b/src/test/java/org/jabref/model/entry/BibEntryEqualityTest.java @@ -1,9 +1,9 @@ package org.jabref.model.entry; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class BibEntryEqualityTest { @Test diff --git a/src/test/java/org/jabref/model/entry/BibEntryTest.java b/src/test/java/org/jabref/model/entry/BibEntryTest.java index 5cbea9d9477..6e62eff5c77 100644 --- a/src/test/java/org/jabref/model/entry/BibEntryTest.java +++ b/src/test/java/org/jabref/model/entry/BibEntryTest.java @@ -6,35 +6,36 @@ import org.jabref.model.database.BibDatabase; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class BibEntryTest { private BibEntry entry; - @Before + @BeforeEach public void setUp() { entry = new BibEntry(); } - @After + @AfterEach public void tearDown() { entry = null; } - @Test(expected = IllegalArgumentException.class) + @Test public void notOverrideReservedFields() { - entry.setField(BibEntry.ID_FIELD, "somevalue"); + assertThrows(IllegalArgumentException.class, () -> entry.setField(BibEntry.ID_FIELD, "somevalue")); } - @Test(expected = IllegalArgumentException.class) + @Test public void notClearReservedFields() { - entry.clearField(BibEntry.ID_FIELD); + assertThrows(IllegalArgumentException.class, () -> entry.clearField(BibEntry.ID_FIELD)); } @Test diff --git a/src/test/java/org/jabref/model/entry/BibEntryTests.java b/src/test/java/org/jabref/model/entry/BibEntryTests.java index c4bd826a453..eb6b414225f 100644 --- a/src/test/java/org/jabref/model/entry/BibEntryTests.java +++ b/src/test/java/org/jabref/model/entry/BibEntryTests.java @@ -6,26 +6,25 @@ import java.util.List; import java.util.Optional; -import com.google.common.collect.Sets; import org.jabref.model.FieldChange; - import org.jabref.model.entry.specialfields.SpecialField; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import com.google.common.collect.Sets; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; public class BibEntryTests { private BibEntry keywordEntry; private BibEntry emptyEntry; - - - @Before + @BeforeEach public void setUp() { // Default entry for most keyword and some type tests keywordEntry = new BibEntry(); @@ -45,8 +44,8 @@ public void testDefaultConstructor() { BibEntry entry = new BibEntry(); // we have to use `getType("misc")` in the case of biblatex mode assertEquals("misc", entry.getType()); - Assert.assertNotNull(entry.getId()); - Assert.assertFalse(entry.getField("author").isPresent()); + assertNotNull(entry.getId()); + assertFalse(entry.getField("author").isPresent()); } @Test @@ -59,10 +58,10 @@ public void allFieldsPresentDefault() { requiredFields.add("author"); requiredFields.add("title"); - Assert.assertTrue(e.allFieldsPresent(requiredFields, null)); + assertTrue(e.allFieldsPresent(requiredFields, null)); requiredFields.add("year"); - Assert.assertFalse(e.allFieldsPresent(requiredFields, null)); + assertFalse(e.allFieldsPresent(requiredFields, null)); } @Test @@ -75,33 +74,31 @@ public void allFieldsPresentOr() { // XOR required requiredFields.add("journal/year"); - Assert.assertTrue(e.allFieldsPresent(requiredFields, null)); + assertTrue(e.allFieldsPresent(requiredFields, null)); requiredFields.add("year/address"); - Assert.assertFalse(e.allFieldsPresent(requiredFields, null)); + assertFalse(e.allFieldsPresent(requiredFields, null)); } - @Test(expected = NullPointerException.class) + @Test public void isNullCiteKeyThrowsNPE() { BibEntry e = new BibEntry(BibtexEntryTypes.ARTICLE.getName()); - - e.setCiteKey(null); - Assert.fail(); + assertThrows(NullPointerException.class, () -> e.setCiteKey(null)); } @Test public void isEmptyCiteKey() { BibEntry e = new BibEntry(BibtexEntryTypes.ARTICLE.getName()); - Assert.assertFalse(e.hasCiteKey()); + assertFalse(e.hasCiteKey()); e.setCiteKey(""); - Assert.assertFalse(e.hasCiteKey()); + assertFalse(e.hasCiteKey()); e.setCiteKey("key"); - Assert.assertTrue(e.hasCiteKey()); + assertTrue(e.hasCiteKey()); e.clearField(BibEntry.KEY_FIELD); - Assert.assertFalse(e.hasCiteKey()); + assertFalse(e.hasCiteKey()); } @Test @@ -118,7 +115,6 @@ public void typeOfBibEntryIsMiscAfterSettingToEmptyString() { assertEquals("misc", keywordEntry.getType()); } - @Test public void getFieldOrAliasDateWithYearNumericalMonthString() { emptyEntry.setField("year", "2003"); @@ -212,28 +208,28 @@ public void getFieldOrAliasLatexFreeComplexConversionInAlias() { assertEquals(Optional.of("A 32 mA ΣΔ-modulator"), emptyEntry.getFieldOrAliasLatexFree("journaltitle")); } - @Test(expected = NullPointerException.class) + @Test public void setNullField() { - emptyEntry.setField(null); - Assert.fail(); + assertThrows(NullPointerException.class, () -> emptyEntry.setField(null)); + } - @Test(expected = NullPointerException.class) + @Test public void addNullKeywordThrowsNPE() { - keywordEntry.addKeyword((Keyword)null, ','); - Assert.fail(); + assertThrows(NullPointerException.class, () -> keywordEntry.addKeyword((Keyword) null, ',')); } - @Test(expected = NullPointerException.class) + @Test public void putNullKeywordListThrowsNPE() { - keywordEntry.putKeywords((KeywordList)null, ','); - Assert.fail(); + assertThrows(NullPointerException.class, () -> keywordEntry.putKeywords((KeywordList) null, ',')); + } - @Test(expected = NullPointerException.class) + @Test public void putNullKeywordSeparatorThrowsNPE() { - keywordEntry.putKeywords(Arrays.asList("A", "B"), null); + assertThrows(NullPointerException.class, () -> keywordEntry.putKeywords(Arrays.asList("A", "B"), null)); } + @Test public void testGetSeparatedKeywordsAreCorrect() { assertEquals(new KeywordList("Foo", "Bar"), keywordEntry.getKeywords(',')); @@ -248,7 +244,7 @@ public void testAddKeywordIsCorrect() { @Test public void testAddKeywordHasChanged() { keywordEntry.addKeyword("FooBar", ','); - Assert.assertTrue(keywordEntry.hasChanged()); + assertTrue(keywordEntry.hasChanged()); } @Test @@ -267,7 +263,7 @@ public void addKeywordIsCaseSensitive() { @Test public void testAddKeywordWithDifferentCapitalizationChanges() { keywordEntry.addKeyword("FOO", ','); - Assert.assertTrue(keywordEntry.hasChanged()); + assertTrue(keywordEntry.hasChanged()); } @Test @@ -279,24 +275,24 @@ public void testAddKeywordEmptyKeywordIsNotAdded() { @Test public void testAddKeywordEmptyKeywordNotChanged() { keywordEntry.addKeyword("", ','); - Assert.assertFalse(keywordEntry.hasChanged()); + assertFalse(keywordEntry.hasChanged()); } @Test public void texNewBibEntryHasNoKeywords() { - Assert.assertTrue(emptyEntry.getKeywords(',').isEmpty()); + assertTrue(emptyEntry.getKeywords(',').isEmpty()); } @Test public void texNewBibEntryHasNoKeywordsEvenAfterAddingEmptyKeyword() { emptyEntry.addKeyword("", ','); - Assert.assertTrue(emptyEntry.getKeywords(',').isEmpty()); + assertTrue(emptyEntry.getKeywords(',').isEmpty()); } @Test public void texNewBibEntryAfterAddingEmptyKeywordNotChanged() { emptyEntry.addKeyword("", ','); - Assert.assertFalse(emptyEntry.hasChanged()); + assertFalse(emptyEntry.hasChanged()); } @Test @@ -314,31 +310,31 @@ public void testPutKeywordsOverwritesOldKeywords() { @Test public void testPutKeywordsHasChanged() { keywordEntry.putKeywords(Arrays.asList("Yin", "Yang"), ','); - Assert.assertTrue(keywordEntry.hasChanged()); + assertTrue(keywordEntry.hasChanged()); } @Test public void testPutKeywordsPutEmpyListErasesPreviousKeywords() { keywordEntry.putKeywords(Collections.emptyList(), ','); - Assert.assertTrue(keywordEntry.getKeywords(',').isEmpty()); + assertTrue(keywordEntry.getKeywords(',').isEmpty()); } @Test public void testPutKeywordsPutEmpyListHasChanged() { keywordEntry.putKeywords(Collections.emptyList(), ','); - Assert.assertTrue(keywordEntry.hasChanged()); + assertTrue(keywordEntry.hasChanged()); } @Test public void testPutKeywordsPutEmpyListToEmptyBibentry() { emptyEntry.putKeywords(Collections.emptyList(), ','); - Assert.assertTrue(emptyEntry.getKeywords(',').isEmpty()); + assertTrue(emptyEntry.getKeywords(',').isEmpty()); } @Test public void testPutKeywordsPutEmpyListToEmptyBibentryNotChanged() { emptyEntry.putKeywords(Collections.emptyList(), ','); - Assert.assertFalse(emptyEntry.hasChanged()); + assertFalse(emptyEntry.hasChanged()); } @Test @@ -407,23 +403,23 @@ public void removeKeywordsWithExistingKeywordsRemovesThem() { public void testGroupAndSearchHits() { BibEntry be = new BibEntry(); be.setGroupHit(true); - Assert.assertTrue(be.isGroupHit()); + assertTrue(be.isGroupHit()); be.setGroupHit(false); - Assert.assertFalse(be.isGroupHit()); + assertFalse(be.isGroupHit()); be.setSearchHit(true); - Assert.assertTrue(be.isSearchHit()); + assertTrue(be.isSearchHit()); be.setSearchHit(false); - Assert.assertFalse(be.isSearchHit()); + assertFalse(be.isSearchHit()); } @Test public void setCiteKey() { BibEntry be = new BibEntry(); - Assert.assertFalse(be.hasCiteKey()); + assertFalse(be.hasCiteKey()); be.setField("author", "Albert Einstein"); be.setCiteKey("Einstein1931"); - Assert.assertTrue(be.hasCiteKey()); + assertTrue(be.hasCiteKey()); assertEquals(Optional.of("Einstein1931"), be.getCiteKeyOptional()); assertEquals(Optional.of("Albert Einstein"), be.getField("author")); be.clearField("author"); diff --git a/src/test/java/org/jabref/model/entry/BibtexStringTest.java b/src/test/java/org/jabref/model/entry/BibtexStringTest.java index 397746fc893..440c950394d 100644 --- a/src/test/java/org/jabref/model/entry/BibtexStringTest.java +++ b/src/test/java/org/jabref/model/entry/BibtexStringTest.java @@ -1,11 +1,10 @@ package org.jabref.model.entry; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class BibtexStringTest { diff --git a/src/test/java/org/jabref/model/entry/CanonicalBibEntryTest.java b/src/test/java/org/jabref/model/entry/CanonicalBibEntryTest.java index 8788761e387..cb1a79ad172 100644 --- a/src/test/java/org/jabref/model/entry/CanonicalBibEntryTest.java +++ b/src/test/java/org/jabref/model/entry/CanonicalBibEntryTest.java @@ -1,7 +1,8 @@ package org.jabref.model.entry; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class CanonicalBibEntryTest { @@ -13,7 +14,7 @@ public void simpleCanonicalRepresentation() { e.setField("title", "def"); e.setField("journal", "hij"); String canonicalRepresentation = CanonicalBibtexEntry.getCanonicalRepresentation(e); - Assert.assertEquals("@article{key,\n author = {abc},\n journal = {hij},\n title = {def}\n}", + assertEquals("@article{key,\n author = {abc},\n journal = {hij},\n title = {def}\n}", canonicalRepresentation); } @@ -23,7 +24,7 @@ public void canonicalRepresentationWithNewlines() { e.setCiteKey("key"); e.setField("abstract", "line 1\nline 2"); String canonicalRepresentation = CanonicalBibtexEntry.getCanonicalRepresentation(e); - Assert.assertEquals("@article{key,\n abstract = {line 1\nline 2}\n}", canonicalRepresentation); + assertEquals("@article{key,\n abstract = {line 1\nline 2}\n}", canonicalRepresentation); } } diff --git a/src/test/java/org/jabref/model/entry/DateTest.java b/src/test/java/org/jabref/model/entry/DateTest.java index 3192ef78554..3234ea84280 100644 --- a/src/test/java/org/jabref/model/entry/DateTest.java +++ b/src/test/java/org/jabref/model/entry/DateTest.java @@ -3,9 +3,10 @@ import java.time.LocalDate; import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class DateTest { @@ -15,8 +16,7 @@ public void parseCorrectlyDayMonthYearDate() throws Exception { assertEquals(Optional.of(expected), Date.parse("19-06-2014")); } - @Test(expected = NullPointerException.class) public void parseDateNull() { - assertEquals(Optional.empty(), Date.parse(null)); + assertThrows(NullPointerException.class, () -> assertEquals(Optional.empty(), Date.parse(null))); } } diff --git a/src/test/java/org/jabref/model/entry/EntryLinkListTest.java b/src/test/java/org/jabref/model/entry/EntryLinkListTest.java index dba0cfb9c45..77a5c71d059 100644 --- a/src/test/java/org/jabref/model/entry/EntryLinkListTest.java +++ b/src/test/java/org/jabref/model/entry/EntryLinkListTest.java @@ -1,14 +1,15 @@ package org.jabref.model.entry; -import org.jabref.model.database.BibDatabase; -import org.junit.Before; -import org.junit.Test; - import java.util.List; import java.util.Optional; -import static junit.framework.TestCase.assertTrue; -import static org.junit.Assert.assertEquals; +import org.jabref.model.database.BibDatabase; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class EntryLinkListTest { @@ -20,7 +21,7 @@ public class EntryLinkListTest { private BibEntry source; private BibEntry target; - @Before + @BeforeEach public void before() { database = new BibDatabase(); links = EntryLinkList.parse(key, database); diff --git a/src/test/java/org/jabref/model/entry/FieldNameTest.java b/src/test/java/org/jabref/model/entry/FieldNameTest.java index 393c159430b..ae0eb69c2d2 100644 --- a/src/test/java/org/jabref/model/entry/FieldNameTest.java +++ b/src/test/java/org/jabref/model/entry/FieldNameTest.java @@ -1,9 +1,8 @@ package org.jabref.model.entry; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; public class FieldNameTest { diff --git a/src/test/java/org/jabref/model/entry/FileFieldBibEntryTest.java b/src/test/java/org/jabref/model/entry/FileFieldBibEntryTest.java index 54699f411da..c6505dc437d 100644 --- a/src/test/java/org/jabref/model/entry/FileFieldBibEntryTest.java +++ b/src/test/java/org/jabref/model/entry/FileFieldBibEntryTest.java @@ -10,16 +10,16 @@ import org.jabref.model.database.BibDatabaseContext; import org.jabref.model.metadata.MetaData; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class FileFieldBibEntryTest { private BibEntry emptyEntry; - @Before + @BeforeEach public void setUp() { emptyEntry = new BibEntry(); emptyEntry.setType("article"); diff --git a/src/test/java/org/jabref/model/entry/FileFieldWriterTest.java b/src/test/java/org/jabref/model/entry/FileFieldWriterTest.java index 5929dd664a3..d9b6fb0f1e7 100644 --- a/src/test/java/org/jabref/model/entry/FileFieldWriterTest.java +++ b/src/test/java/org/jabref/model/entry/FileFieldWriterTest.java @@ -3,10 +3,10 @@ import java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; public class FileFieldWriterTest { diff --git a/src/test/java/org/jabref/model/entry/IEEETranEntryTypesTest.java b/src/test/java/org/jabref/model/entry/IEEETranEntryTypesTest.java index 6767031e6a0..6d87b4bfcfb 100644 --- a/src/test/java/org/jabref/model/entry/IEEETranEntryTypesTest.java +++ b/src/test/java/org/jabref/model/entry/IEEETranEntryTypesTest.java @@ -3,8 +3,9 @@ import java.util.Collection; import java.util.List; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertTrue; public class IEEETranEntryTypesTest { @@ -13,7 +14,7 @@ public void ctlTypeContainsYesNoFields() { Collection ctlFields = IEEETranEntryTypes.IEEETRANBSTCTL.getAllFields(); List ynFields = InternalBibtexFields.getIEEETranBSTctlYesNoFields(); - Assert.assertTrue(ctlFields.containsAll(ynFields)); + assertTrue(ctlFields.containsAll(ynFields)); } } diff --git a/src/test/java/org/jabref/model/entry/IdGeneratorTest.java b/src/test/java/org/jabref/model/entry/IdGeneratorTest.java index 689f75e985e..f49e00b11c1 100644 --- a/src/test/java/org/jabref/model/entry/IdGeneratorTest.java +++ b/src/test/java/org/jabref/model/entry/IdGeneratorTest.java @@ -2,8 +2,9 @@ import java.util.HashSet; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertFalse; public class IdGeneratorTest { @@ -13,7 +14,7 @@ public void testCreateNeutralId() { HashSet set = new HashSet<>(); for (int i = 0; i < 10000; i++) { String string = IdGenerator.next(); - Assert.assertFalse(set.contains(string)); + assertFalse(set.contains(string)); set.add(string); } diff --git a/src/test/java/org/jabref/model/entry/KeywordListTest.java b/src/test/java/org/jabref/model/entry/KeywordListTest.java index 177d26f5940..0b66ca6cc2e 100644 --- a/src/test/java/org/jabref/model/entry/KeywordListTest.java +++ b/src/test/java/org/jabref/model/entry/KeywordListTest.java @@ -2,16 +2,16 @@ import java.util.Optional; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class KeywordListTest { private KeywordList keywords; - @Before + @BeforeEach public void setUp() throws Exception { keywords = new KeywordList(); keywords.add("keywordOne"); diff --git a/src/test/java/org/jabref/model/entry/KeywordTest.java b/src/test/java/org/jabref/model/entry/KeywordTest.java index 43f3a642028..7496ed23771 100644 --- a/src/test/java/org/jabref/model/entry/KeywordTest.java +++ b/src/test/java/org/jabref/model/entry/KeywordTest.java @@ -3,9 +3,9 @@ import java.util.HashSet; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class KeywordTest { diff --git a/src/test/java/org/jabref/model/entry/MonthTest.java b/src/test/java/org/jabref/model/entry/MonthTest.java index 943f29fbf1b..dc5a29c8c26 100644 --- a/src/test/java/org/jabref/model/entry/MonthTest.java +++ b/src/test/java/org/jabref/model/entry/MonthTest.java @@ -2,101 +2,102 @@ import java.util.Optional; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class MonthTest { @Test public void parseCorrectlyByShortName() { - Assert.assertEquals(Optional.of(Month.JANUARY), Month.parse("jan")); - Assert.assertEquals(Optional.of(Month.FEBRUARY), Month.parse("feb")); - Assert.assertEquals(Optional.of(Month.MARCH), Month.parse("mar")); - Assert.assertEquals(Optional.of(Month.APRIL), Month.parse("apr")); - Assert.assertEquals(Optional.of(Month.MAY), Month.parse("may")); - Assert.assertEquals(Optional.of(Month.JUNE), Month.parse("jun")); - Assert.assertEquals(Optional.of(Month.JULY), Month.parse("jul")); - Assert.assertEquals(Optional.of(Month.AUGUST), Month.parse("aug")); - Assert.assertEquals(Optional.of(Month.SEPTEMBER), Month.parse("sep")); - Assert.assertEquals(Optional.of(Month.OCTOBER), Month.parse("oct")); - Assert.assertEquals(Optional.of(Month.NOVEMBER), Month.parse("nov")); - Assert.assertEquals(Optional.of(Month.DECEMBER), Month.parse("dec")); + assertEquals(Optional.of(Month.JANUARY), Month.parse("jan")); + assertEquals(Optional.of(Month.FEBRUARY), Month.parse("feb")); + assertEquals(Optional.of(Month.MARCH), Month.parse("mar")); + assertEquals(Optional.of(Month.APRIL), Month.parse("apr")); + assertEquals(Optional.of(Month.MAY), Month.parse("may")); + assertEquals(Optional.of(Month.JUNE), Month.parse("jun")); + assertEquals(Optional.of(Month.JULY), Month.parse("jul")); + assertEquals(Optional.of(Month.AUGUST), Month.parse("aug")); + assertEquals(Optional.of(Month.SEPTEMBER), Month.parse("sep")); + assertEquals(Optional.of(Month.OCTOBER), Month.parse("oct")); + assertEquals(Optional.of(Month.NOVEMBER), Month.parse("nov")); + assertEquals(Optional.of(Month.DECEMBER), Month.parse("dec")); } @Test public void parseCorrectlyByBibtexName() { - Assert.assertEquals(Optional.of(Month.JANUARY), Month.parse("#jan#")); - Assert.assertEquals(Optional.of(Month.FEBRUARY), Month.parse("#feb#")); - Assert.assertEquals(Optional.of(Month.MARCH), Month.parse("#mar#")); - Assert.assertEquals(Optional.of(Month.APRIL), Month.parse("#apr#")); - Assert.assertEquals(Optional.of(Month.MAY), Month.parse("#may#")); - Assert.assertEquals(Optional.of(Month.JUNE), Month.parse("#jun#")); - Assert.assertEquals(Optional.of(Month.JULY), Month.parse("#jul#")); - Assert.assertEquals(Optional.of(Month.AUGUST), Month.parse("#aug#")); - Assert.assertEquals(Optional.of(Month.SEPTEMBER), Month.parse("#sep#")); - Assert.assertEquals(Optional.of(Month.OCTOBER), Month.parse("#oct#")); - Assert.assertEquals(Optional.of(Month.NOVEMBER), Month.parse("#nov#")); - Assert.assertEquals(Optional.of(Month.DECEMBER), Month.parse("#dec#")); + assertEquals(Optional.of(Month.JANUARY), Month.parse("#jan#")); + assertEquals(Optional.of(Month.FEBRUARY), Month.parse("#feb#")); + assertEquals(Optional.of(Month.MARCH), Month.parse("#mar#")); + assertEquals(Optional.of(Month.APRIL), Month.parse("#apr#")); + assertEquals(Optional.of(Month.MAY), Month.parse("#may#")); + assertEquals(Optional.of(Month.JUNE), Month.parse("#jun#")); + assertEquals(Optional.of(Month.JULY), Month.parse("#jul#")); + assertEquals(Optional.of(Month.AUGUST), Month.parse("#aug#")); + assertEquals(Optional.of(Month.SEPTEMBER), Month.parse("#sep#")); + assertEquals(Optional.of(Month.OCTOBER), Month.parse("#oct#")); + assertEquals(Optional.of(Month.NOVEMBER), Month.parse("#nov#")); + assertEquals(Optional.of(Month.DECEMBER), Month.parse("#dec#")); } @Test public void parseCorrectlyByFullName() { - Assert.assertEquals(Optional.of(Month.JANUARY), Month.parse("January")); - Assert.assertEquals(Optional.of(Month.FEBRUARY), Month.parse("February")); - Assert.assertEquals(Optional.of(Month.MARCH), Month.parse("March")); - Assert.assertEquals(Optional.of(Month.APRIL), Month.parse("April")); - Assert.assertEquals(Optional.of(Month.MAY), Month.parse("May")); - Assert.assertEquals(Optional.of(Month.JUNE), Month.parse("June")); - Assert.assertEquals(Optional.of(Month.JULY), Month.parse("July")); - Assert.assertEquals(Optional.of(Month.AUGUST), Month.parse("August")); - Assert.assertEquals(Optional.of(Month.SEPTEMBER), Month.parse("September")); - Assert.assertEquals(Optional.of(Month.OCTOBER), Month.parse("October")); - Assert.assertEquals(Optional.of(Month.NOVEMBER), Month.parse("November")); - Assert.assertEquals(Optional.of(Month.DECEMBER), Month.parse("December")); + assertEquals(Optional.of(Month.JANUARY), Month.parse("January")); + assertEquals(Optional.of(Month.FEBRUARY), Month.parse("February")); + assertEquals(Optional.of(Month.MARCH), Month.parse("March")); + assertEquals(Optional.of(Month.APRIL), Month.parse("April")); + assertEquals(Optional.of(Month.MAY), Month.parse("May")); + assertEquals(Optional.of(Month.JUNE), Month.parse("June")); + assertEquals(Optional.of(Month.JULY), Month.parse("July")); + assertEquals(Optional.of(Month.AUGUST), Month.parse("August")); + assertEquals(Optional.of(Month.SEPTEMBER), Month.parse("September")); + assertEquals(Optional.of(Month.OCTOBER), Month.parse("October")); + assertEquals(Optional.of(Month.NOVEMBER), Month.parse("November")); + assertEquals(Optional.of(Month.DECEMBER), Month.parse("December")); } @Test public void parseCorrectlyByTwoDigitNumber() { - Assert.assertEquals(Optional.of(Month.JANUARY), Month.parse("01")); - Assert.assertEquals(Optional.of(Month.FEBRUARY), Month.parse("02")); - Assert.assertEquals(Optional.of(Month.MARCH), Month.parse("03")); - Assert.assertEquals(Optional.of(Month.APRIL), Month.parse("04")); - Assert.assertEquals(Optional.of(Month.MAY), Month.parse("05")); - Assert.assertEquals(Optional.of(Month.JUNE), Month.parse("06")); - Assert.assertEquals(Optional.of(Month.JULY), Month.parse("07")); - Assert.assertEquals(Optional.of(Month.AUGUST), Month.parse("08")); - Assert.assertEquals(Optional.of(Month.SEPTEMBER), Month.parse("09")); - Assert.assertEquals(Optional.of(Month.OCTOBER), Month.parse("10")); - Assert.assertEquals(Optional.of(Month.NOVEMBER), Month.parse("11")); - Assert.assertEquals(Optional.of(Month.DECEMBER), Month.parse("12")); + assertEquals(Optional.of(Month.JANUARY), Month.parse("01")); + assertEquals(Optional.of(Month.FEBRUARY), Month.parse("02")); + assertEquals(Optional.of(Month.MARCH), Month.parse("03")); + assertEquals(Optional.of(Month.APRIL), Month.parse("04")); + assertEquals(Optional.of(Month.MAY), Month.parse("05")); + assertEquals(Optional.of(Month.JUNE), Month.parse("06")); + assertEquals(Optional.of(Month.JULY), Month.parse("07")); + assertEquals(Optional.of(Month.AUGUST), Month.parse("08")); + assertEquals(Optional.of(Month.SEPTEMBER), Month.parse("09")); + assertEquals(Optional.of(Month.OCTOBER), Month.parse("10")); + assertEquals(Optional.of(Month.NOVEMBER), Month.parse("11")); + assertEquals(Optional.of(Month.DECEMBER), Month.parse("12")); } @Test public void parseCorrectlyByNumber() { - Assert.assertEquals(Optional.of(Month.JANUARY), Month.parse("1")); - Assert.assertEquals(Optional.of(Month.FEBRUARY), Month.parse("2")); - Assert.assertEquals(Optional.of(Month.MARCH), Month.parse("3")); - Assert.assertEquals(Optional.of(Month.APRIL), Month.parse("4")); - Assert.assertEquals(Optional.of(Month.MAY), Month.parse("5")); - Assert.assertEquals(Optional.of(Month.JUNE), Month.parse("6")); - Assert.assertEquals(Optional.of(Month.JULY), Month.parse("7")); - Assert.assertEquals(Optional.of(Month.AUGUST), Month.parse("8")); - Assert.assertEquals(Optional.of(Month.SEPTEMBER), Month.parse("9")); - Assert.assertEquals(Optional.of(Month.OCTOBER), Month.parse("10")); - Assert.assertEquals(Optional.of(Month.NOVEMBER), Month.parse("11")); - Assert.assertEquals(Optional.of(Month.DECEMBER), Month.parse("12")); + assertEquals(Optional.of(Month.JANUARY), Month.parse("1")); + assertEquals(Optional.of(Month.FEBRUARY), Month.parse("2")); + assertEquals(Optional.of(Month.MARCH), Month.parse("3")); + assertEquals(Optional.of(Month.APRIL), Month.parse("4")); + assertEquals(Optional.of(Month.MAY), Month.parse("5")); + assertEquals(Optional.of(Month.JUNE), Month.parse("6")); + assertEquals(Optional.of(Month.JULY), Month.parse("7")); + assertEquals(Optional.of(Month.AUGUST), Month.parse("8")); + assertEquals(Optional.of(Month.SEPTEMBER), Month.parse("9")); + assertEquals(Optional.of(Month.OCTOBER), Month.parse("10")); + assertEquals(Optional.of(Month.NOVEMBER), Month.parse("11")); + assertEquals(Optional.of(Month.DECEMBER), Month.parse("12")); } @Test public void parseReturnsEmptyOptionalForInvalidInput() { - Assert.assertEquals(Optional.empty(), Month.parse(";lkjasdf")); - Assert.assertEquals(Optional.empty(), Month.parse("3.2")); - Assert.assertEquals(Optional.empty(), Month.parse("#test#")); - Assert.assertEquals(Optional.empty(), Month.parse("8,")); + assertEquals(Optional.empty(), Month.parse(";lkjasdf")); + assertEquals(Optional.empty(), Month.parse("3.2")); + assertEquals(Optional.empty(), Month.parse("#test#")); + assertEquals(Optional.empty(), Month.parse("8,")); } @Test public void parseReturnsEmptyOptionalForEmptyInput() { - Assert.assertEquals(Optional.empty(), Month.parse("")); + assertEquals(Optional.empty(), Month.parse("")); } } diff --git a/src/test/java/org/jabref/model/entry/identifier/ArXivIdentifierTest.java b/src/test/java/org/jabref/model/entry/identifier/ArXivIdentifierTest.java index dbc8beda996..3109f4b3c76 100644 --- a/src/test/java/org/jabref/model/entry/identifier/ArXivIdentifierTest.java +++ b/src/test/java/org/jabref/model/entry/identifier/ArXivIdentifierTest.java @@ -2,9 +2,9 @@ import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class ArXivIdentifierTest { diff --git a/src/test/java/org/jabref/model/entry/identifier/DOITest.java b/src/test/java/org/jabref/model/entry/identifier/DOITest.java index d6db25c4278..457b779ff75 100644 --- a/src/test/java/org/jabref/model/entry/identifier/DOITest.java +++ b/src/test/java/org/jabref/model/entry/identifier/DOITest.java @@ -2,86 +2,88 @@ import java.util.Optional; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class DOITest { @Test public void acceptPlainDoi() { - Assert.assertEquals("10.1006/jmbi.1998.2354", new DOI("10.1006/jmbi.1998.2354").getDOI()); - Assert.assertEquals("10.231/JIM.0b013e31820bab4c", new DOI("10.231/JIM.0b013e31820bab4c").getDOI()); - Assert.assertEquals("10.1002/(SICI)1522-2594(199911)42:5<952::AID-MRM16>3.0.CO;2-S", + assertEquals("10.1006/jmbi.1998.2354", new DOI("10.1006/jmbi.1998.2354").getDOI()); + assertEquals("10.231/JIM.0b013e31820bab4c", new DOI("10.231/JIM.0b013e31820bab4c").getDOI()); + assertEquals("10.1002/(SICI)1522-2594(199911)42:5<952::AID-MRM16>3.0.CO;2-S", new DOI("10.1002/(SICI)1522-2594(199911)42:5<952::AID-MRM16>3.0.CO;2-S").getDOI()); - Assert.assertEquals("10.1126/sciadv.1500214", new DOI("10.1126/sciadv.1500214").getDOI()); + assertEquals("10.1126/sciadv.1500214", new DOI("10.1126/sciadv.1500214").getDOI()); } @Test public void ignoreLeadingAndTrailingWhitespaces() { - Assert.assertEquals("10.1006/jmbi.1998.2354", new DOI(" 10.1006/jmbi.1998.2354 ").getDOI()); + assertEquals("10.1006/jmbi.1998.2354", new DOI(" 10.1006/jmbi.1998.2354 ").getDOI()); } - @Test(expected = IllegalArgumentException.class) + @Test public void rejectEmbeddedDoi() { - new DOI("other stuff 10.1006/jmbi.1998.2354 end"); + assertThrows(IllegalArgumentException.class, () -> new DOI("other stuff 10.1006/jmbi.1998.2354 end")); } - @Test(expected = IllegalArgumentException.class) + @Test public void rejectInvalidDirectoryIndicator() { // wrong directory indicator - new DOI("12.1006/jmbi.1998.2354 end"); + assertThrows(IllegalArgumentException.class, () -> new DOI("12.1006/jmbi.1998.2354 end")); } - @Test(expected = IllegalArgumentException.class) + @Test public void rejectInvalidDoiUri() { - new DOI("https://thisisnouri"); + assertThrows(IllegalArgumentException.class, () -> new DOI("https://thisisnouri")); } - @Test(expected = IllegalArgumentException.class) + @Test public void rejectMissingDivider() { // missing divider - new DOI("10.1006jmbi.1998.2354 end"); + assertThrows(IllegalArgumentException.class, () -> new DOI("10.1006jmbi.1998.2354 end")); } @Test public void acceptDoiPrefix() { // Doi prefix - Assert.assertEquals("10.1006/jmbi.1998.2354", new DOI("doi:10.1006/jmbi.1998.2354").getDOI()); + assertEquals("10.1006/jmbi.1998.2354", new DOI("doi:10.1006/jmbi.1998.2354").getDOI()); } @Test public void acceptURNPrefix() { - Assert.assertEquals("10.123/456", new DOI("urn:10.123/456").getDOI()); - Assert.assertEquals("10.123/456", new DOI("urn:doi:10.123/456").getDOI()); - Assert.assertEquals("10.123/456", new DOI("http://doi.org/urn:doi:10.123/456").getDOI()); + assertEquals("10.123/456", new DOI("urn:10.123/456").getDOI()); + assertEquals("10.123/456", new DOI("urn:doi:10.123/456").getDOI()); + assertEquals("10.123/456", new DOI("http://doi.org/urn:doi:10.123/456").getDOI()); // : is also allowed as divider, will be replaced by RESOLVER - Assert.assertEquals("10.123:456ABC/zyz", new DOI("http://doi.org/urn:doi:10.123:456ABC%2Fzyz").getDOI()); + assertEquals("10.123:456ABC/zyz", new DOI("http://doi.org/urn:doi:10.123:456ABC%2Fzyz").getDOI()); } @Test public void acceptURLDoi() { // http - Assert.assertEquals("10.1006/jmbi.1998.2354", new DOI("http://doi.org/10.1006/jmbi.1998.2354").getDOI()); + assertEquals("10.1006/jmbi.1998.2354", new DOI("http://doi.org/10.1006/jmbi.1998.2354").getDOI()); // https - Assert.assertEquals("10.1006/jmbi.1998.2354", new DOI("https://doi.org/10.1006/jmbi.1998.2354").getDOI()); + assertEquals("10.1006/jmbi.1998.2354", new DOI("https://doi.org/10.1006/jmbi.1998.2354").getDOI()); // https with % divider - Assert.assertEquals("10.2307/1990888", new DOI("https://dx.doi.org/10.2307%2F1990888").getDOI()); + assertEquals("10.2307/1990888", new DOI("https://dx.doi.org/10.2307%2F1990888").getDOI()); // other domains - Assert.assertEquals("10.1145/1294928.1294933", new DOI("http://doi.acm.org/10.1145/1294928.1294933").getDOI()); - Assert.assertEquals("10.1145/1294928.1294933", new DOI("http://doi.acm.net/10.1145/1294928.1294933").getDOI()); - Assert.assertEquals("10.1145/1294928.1294933", new DOI("http://doi.acm.com/10.1145/1294928.1294933").getDOI()); - Assert.assertEquals("10.1145/1294928.1294933", new DOI("http://doi.acm.de/10.1145/1294928.1294933").getDOI()); - Assert.assertEquals("10.1007/978-3-642-15618-2_19", + assertEquals("10.1145/1294928.1294933", new DOI("http://doi.acm.org/10.1145/1294928.1294933").getDOI()); + assertEquals("10.1145/1294928.1294933", new DOI("http://doi.acm.net/10.1145/1294928.1294933").getDOI()); + assertEquals("10.1145/1294928.1294933", new DOI("http://doi.acm.com/10.1145/1294928.1294933").getDOI()); + assertEquals("10.1145/1294928.1294933", new DOI("http://doi.acm.de/10.1145/1294928.1294933").getDOI()); + assertEquals("10.1007/978-3-642-15618-2_19", new DOI("http://dx.doi.org/10.1007/978-3-642-15618-2_19").getDOI()); - Assert.assertEquals("10.1007/978-3-642-15618-2_19", + assertEquals("10.1007/978-3-642-15618-2_19", new DOI("http://dx.doi.net/10.1007/978-3-642-15618-2_19").getDOI()); - Assert.assertEquals("10.1007/978-3-642-15618-2_19", + assertEquals("10.1007/978-3-642-15618-2_19", new DOI("http://dx.doi.com/10.1007/978-3-642-15618-2_19").getDOI()); - Assert.assertEquals("10.1007/978-3-642-15618-2_19", + assertEquals("10.1007/978-3-642-15618-2_19", new DOI("http://dx.doi.de/10.1007/978-3-642-15618-2_19").getDOI()); - Assert.assertEquals("10.4108/ICST.COLLABORATECOM2009.8275", + assertEquals("10.4108/ICST.COLLABORATECOM2009.8275", new DOI("http://dx.doi.org/10.4108/ICST.COLLABORATECOM2009.8275").getDOI()); - Assert.assertEquals("10.1109/MIC.2012.43", + assertEquals("10.1109/MIC.2012.43", new DOI("http://doi.ieeecomputersociety.org/10.1109/MIC.2012.43").getDOI()); } @@ -89,56 +91,56 @@ public void acceptURLDoi() { public void correctlyDecodeHttpDOIs() { // See http://www.doi.org/doi_handbook/2_Numbering.html#2.5.2.4 // % -> (%25) - Assert.assertEquals("10.1006/rwei.1999%.0001", new DOI("http://doi.org/10.1006/rwei.1999%25.0001").getDOI()); + assertEquals("10.1006/rwei.1999%.0001", new DOI("http://doi.org/10.1006/rwei.1999%25.0001").getDOI()); // " -> (%22) - Assert.assertEquals("10.1006/rwei.1999\".0001", new DOI("http://doi.org/10.1006/rwei.1999%22.0001").getDOI()); + assertEquals("10.1006/rwei.1999\".0001", new DOI("http://doi.org/10.1006/rwei.1999%22.0001").getDOI()); // # -> (%23) - Assert.assertEquals("10.1006/rwei.1999#.0001", new DOI("http://doi.org/10.1006/rwei.1999%23.0001").getDOI()); + assertEquals("10.1006/rwei.1999#.0001", new DOI("http://doi.org/10.1006/rwei.1999%23.0001").getDOI()); // SPACE -> (%20) - Assert.assertEquals("10.1006/rwei.1999 .0001", new DOI("http://doi.org/10.1006/rwei.1999%20.0001").getDOI()); + assertEquals("10.1006/rwei.1999 .0001", new DOI("http://doi.org/10.1006/rwei.1999%20.0001").getDOI()); // ? -> (%3F) - Assert.assertEquals("10.1006/rwei.1999?.0001", new DOI("http://doi.org/10.1006/rwei.1999%3F.0001").getDOI()); + assertEquals("10.1006/rwei.1999?.0001", new DOI("http://doi.org/10.1006/rwei.1999%3F.0001").getDOI()); } @Test public void correctlyEncodeDOIs() { // See http://www.doi.org/doi_handbook/2_Numbering.html#2.5.2.4 // % -> (%25) - Assert.assertEquals("https://doi.org/10.1006/rwei.1999%25.0001", + assertEquals("https://doi.org/10.1006/rwei.1999%25.0001", new DOI("https://doi.org/10.1006/rwei.1999%25.0001").getURIAsASCIIString()); // " -> (%22) - Assert.assertEquals("https://doi.org/10.1006/rwei.1999%22.0001", + assertEquals("https://doi.org/10.1006/rwei.1999%22.0001", new DOI("https://doi.org/10.1006/rwei.1999%22.0001").getURIAsASCIIString()); // # -> (%23) - Assert.assertEquals("https://doi.org/10.1006/rwei.1999%23.0001", + assertEquals("https://doi.org/10.1006/rwei.1999%23.0001", new DOI("https://doi.org/10.1006/rwei.1999%23.0001").getURIAsASCIIString()); // SPACE -> (%20) - Assert.assertEquals("https://doi.org/10.1006/rwei.1999%20.0001", + assertEquals("https://doi.org/10.1006/rwei.1999%20.0001", new DOI("https://doi.org/10.1006/rwei.1999%20.0001").getURIAsASCIIString()); // ? -> (%3F) - Assert.assertEquals("https://doi.org/10.1006/rwei.1999%3F.0001", + assertEquals("https://doi.org/10.1006/rwei.1999%3F.0001", new DOI("https://doi.org/10.1006/rwei.1999%3F.0001").getURIAsASCIIString()); } @Test public void constructCorrectURLForDoi() { // add / to RESOLVER url if missing - Assert.assertEquals("https://doi.org/10.1006/jmbi.1998.2354", + assertEquals("https://doi.org/10.1006/jmbi.1998.2354", new DOI("10.1006/jmbi.1998.2354").getURIAsASCIIString()); - Assert.assertEquals("https://doi.org/10.1006/jmbi.1998.2354", + assertEquals("https://doi.org/10.1006/jmbi.1998.2354", new DOI("https://doi.org/10.1006/jmbi.1998.2354").getURIAsASCIIString()); - Assert.assertEquals("https://doi.org/10.1109/VLHCC.2004.20", + assertEquals("https://doi.org/10.1109/VLHCC.2004.20", new DOI("doi:10.1109/VLHCC.2004.20").getURIAsASCIIString()); } @Test public void findDoiInsideArbitraryText() { - Assert.assertEquals("10.1006/jmbi.1998.2354", + assertEquals("10.1006/jmbi.1998.2354", DOI.findInText("other stuff 10.1006/jmbi.1998.2354 end").get().getDOI()); } @Test public void noDOIFoundInsideArbitraryText() { - Assert.assertEquals(Optional.empty(), DOI.findInText("text without 28282 a doi")); + assertEquals(Optional.empty(), DOI.findInText("text without 28282 a doi")); } } diff --git a/src/test/java/org/jabref/model/entry/identifier/EprintTest.java b/src/test/java/org/jabref/model/entry/identifier/EprintTest.java index 21d1c8c6269..788767383ae 100644 --- a/src/test/java/org/jabref/model/entry/identifier/EprintTest.java +++ b/src/test/java/org/jabref/model/entry/identifier/EprintTest.java @@ -1,58 +1,60 @@ package org.jabref.model.entry.identifier; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class EprintTest { @Test public void acceptPlainEprint() { - Assert.assertEquals("0706.0001", new Eprint("0706.0001").getEprint()); + assertEquals("0706.0001", new Eprint("0706.0001").getEprint()); } @Test public void acceptLegacyEprint() { - Assert.assertEquals("astro-ph.GT/1234567", new Eprint("astro-ph.GT/1234567").getEprint()); - Assert.assertEquals("math/1234567", new Eprint("math/1234567").getEprint()); + assertEquals("astro-ph.GT/1234567", new Eprint("astro-ph.GT/1234567").getEprint()); + assertEquals("math/1234567", new Eprint("math/1234567").getEprint()); } @Test public void acceptPlainEprintWithVersion() { - Assert.assertEquals("0706.0001v1", new Eprint("0706.0001v1").getEprint()); + assertEquals("0706.0001v1", new Eprint("0706.0001v1").getEprint()); } @Test public void ignoreLeadingAndTrailingWhitespaces() { - Assert.assertEquals("0706.0001v1", new Eprint(" 0706.0001v1 ").getEprint()); + assertEquals("0706.0001v1", new Eprint(" 0706.0001v1 ").getEprint()); } - @Test(expected = IllegalArgumentException.class) + @Test public void rejectEmbeddedEprint() { - new Eprint("other stuff 0706.0001v1 end"); + assertThrows(IllegalArgumentException.class, () -> new Eprint("other stuff 0706.0001v1 end")); } - @Test(expected = IllegalArgumentException.class) + @Test public void rejectInvalidEprint() { - new Eprint("https://thisisnouri"); + assertThrows(IllegalArgumentException.class, () -> new Eprint("https://thisisnouri")); } @Test public void acceptArxivPrefix() { - Assert.assertEquals("0706.0001v1", new Eprint("arXiv:0706.0001v1").getEprint()); + assertEquals("0706.0001v1", new Eprint("arXiv:0706.0001v1").getEprint()); } @Test public void acceptURLEprint() { // http - Assert.assertEquals("0706.0001v1", new Eprint("http://arxiv.org/abs/0706.0001v1").getEprint()); + assertEquals("0706.0001v1", new Eprint("http://arxiv.org/abs/0706.0001v1").getEprint()); // https - Assert.assertEquals("0706.0001v1", new Eprint("https://arxiv.org/abs/0706.0001v1").getEprint()); + assertEquals("0706.0001v1", new Eprint("https://arxiv.org/abs/0706.0001v1").getEprint()); // other domains - Assert.assertEquals("0706.0001v1", new Eprint("https://asdf.org/abs/0706.0001v1").getEprint()); + assertEquals("0706.0001v1", new Eprint("https://asdf.org/abs/0706.0001v1").getEprint()); } @Test public void constructCorrectURLForEprint() { - Assert.assertEquals("http://arxiv.org/abs/0706.0001v1", new Eprint("0706.0001v1").getURIAsASCIIString()); + assertEquals("http://arxiv.org/abs/0706.0001v1", new Eprint("0706.0001v1").getURIAsASCIIString()); } } diff --git a/src/test/java/org/jabref/model/entry/identifier/ISBNTest.java b/src/test/java/org/jabref/model/entry/identifier/ISBNTest.java index 67013c795e5..acd4d4149fe 100644 --- a/src/test/java/org/jabref/model/entry/identifier/ISBNTest.java +++ b/src/test/java/org/jabref/model/entry/identifier/ISBNTest.java @@ -1,9 +1,9 @@ package org.jabref.model.entry.identifier; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ISBNTest { @@ -11,7 +11,6 @@ public class ISBNTest { public void testIsValidFormat10Correct() { assertTrue(new ISBN("0-123456-47-9").isValidFormat()); assertTrue(new ISBN("0-9752298-0-X").isValidFormat()); - } @Test diff --git a/src/test/java/org/jabref/model/entry/identifier/ISSNTest.java b/src/test/java/org/jabref/model/entry/identifier/ISSNTest.java index 7514dd12e3c..d585552e5fe 100644 --- a/src/test/java/org/jabref/model/entry/identifier/ISSNTest.java +++ b/src/test/java/org/jabref/model/entry/identifier/ISSNTest.java @@ -1,10 +1,10 @@ package org.jabref.model.entry.identifier; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ISSNTest { diff --git a/src/test/java/org/jabref/model/entry/identifier/MathSciNetIdTest.java b/src/test/java/org/jabref/model/entry/identifier/MathSciNetIdTest.java index 4d4cd6c63f5..5ec57641415 100644 --- a/src/test/java/org/jabref/model/entry/identifier/MathSciNetIdTest.java +++ b/src/test/java/org/jabref/model/entry/identifier/MathSciNetIdTest.java @@ -2,9 +2,9 @@ import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class MathSciNetIdTest { diff --git a/src/test/java/org/jabref/model/entry/specialfields/SpecialFieldTest.java b/src/test/java/org/jabref/model/entry/specialfields/SpecialFieldTest.java index 1a37bfbd86b..23cff29c279 100644 --- a/src/test/java/org/jabref/model/entry/specialfields/SpecialFieldTest.java +++ b/src/test/java/org/jabref/model/entry/specialfields/SpecialFieldTest.java @@ -2,11 +2,11 @@ import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class SpecialFieldTest { diff --git a/src/test/java/org/jabref/model/groups/AutomaticKeywordGroupTest.java b/src/test/java/org/jabref/model/groups/AutomaticKeywordGroupTest.java index 8fbf4408e25..fc1e792cfef 100644 --- a/src/test/java/org/jabref/model/groups/AutomaticKeywordGroupTest.java +++ b/src/test/java/org/jabref/model/groups/AutomaticKeywordGroupTest.java @@ -5,9 +5,9 @@ import org.jabref.model.entry.BibEntry; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class AutomaticKeywordGroupTest { diff --git a/src/test/java/org/jabref/model/groups/ExplicitGroupTest.java b/src/test/java/org/jabref/model/groups/ExplicitGroupTest.java index 340afa97b34..1b3191fb94d 100644 --- a/src/test/java/org/jabref/model/groups/ExplicitGroupTest.java +++ b/src/test/java/org/jabref/model/groups/ExplicitGroupTest.java @@ -5,12 +5,12 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.FieldName; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ExplicitGroupTest { @@ -19,7 +19,7 @@ public class ExplicitGroupTest { private BibEntry entry; - @Before + @BeforeEach public void setUp() { group = new ExplicitGroup("myExplicitGroup", GroupHierarchyType.INDEPENDENT, ','); group2 = new ExplicitGroup("myExplicitGroup2", GroupHierarchyType.INCLUDING, ','); @@ -29,7 +29,6 @@ public void setUp() { @Test public void addSingleGroupToEmptyBibEntryChangesGroupsField() { group.add(entry); - assertEquals(Optional.of("myExplicitGroup"), entry.getField(FieldName.GROUPS)); } @@ -37,7 +36,6 @@ public void addSingleGroupToEmptyBibEntryChangesGroupsField() { public void addSingleGroupToNonemptyBibEntryAppendsToGroupsField() { entry.setField(FieldName.GROUPS, "some thing"); group.add(entry); - assertEquals(Optional.of("some thing, myExplicitGroup"), entry.getField(FieldName.GROUPS)); } @@ -45,7 +43,6 @@ public void addSingleGroupToNonemptyBibEntryAppendsToGroupsField() { public void addTwoGroupsToBibEntryChangesGroupsField() { group.add(entry); group2.add(entry); - assertEquals(Optional.of("myExplicitGroup, myExplicitGroup2"), entry.getField(FieldName.GROUPS)); } @@ -53,7 +50,6 @@ public void addTwoGroupsToBibEntryChangesGroupsField() { public void addDuplicateGroupDoesNotChangeGroupsField() throws Exception { entry.setField(FieldName.GROUPS, "myExplicitGroup"); group.add(entry); - assertEquals(Optional.of("myExplicitGroup"), entry.getField(FieldName.GROUPS)); } @@ -62,7 +58,6 @@ public void addDuplicateGroupDoesNotChangeGroupsField() throws Exception { public void removeDoesNotChangeFieldIfContainsNameAsPart() throws Exception { entry.setField(FieldName.GROUPS, "myExplicitGroup_alternative"); group.remove(entry); - assertEquals(Optional.of("myExplicitGroup_alternative"), entry.getField(FieldName.GROUPS)); } @@ -79,7 +74,6 @@ public void removeDoesNotChangeFieldIfContainsNameAsWord() throws Exception { // For https://github.com/JabRef/jabref/issues/1873 public void containsOnlyMatchesCompletePhraseWithWhitespace() throws Exception { entry.setField(FieldName.GROUPS, "myExplicitGroup b"); - assertFalse(group.contains(entry)); } diff --git a/src/test/java/org/jabref/model/groups/GroupTreeNodeTest.java b/src/test/java/org/jabref/model/groups/GroupTreeNodeTest.java index d102c65df05..5126de9da68 100644 --- a/src/test/java/org/jabref/model/groups/GroupTreeNodeTest.java +++ b/src/test/java/org/jabref/model/groups/GroupTreeNodeTest.java @@ -9,12 +9,12 @@ import org.jabref.model.search.matchers.AndMatcher; import org.jabref.model.search.matchers.OrMatcher; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class GroupTreeNodeTest { @@ -107,7 +107,7 @@ public static GroupTreeNode getRoot() { return GroupTreeNode.fromGroup(new AllEntriesGroup("All entries")); } - @Before + @BeforeEach public void setUp() throws Exception { entries.clear(); entry = new BibEntry(); diff --git a/src/test/java/org/jabref/model/groups/SearchGroupTest.java b/src/test/java/org/jabref/model/groups/SearchGroupTest.java index 8002b46e9b2..24849ff6e8a 100644 --- a/src/test/java/org/jabref/model/groups/SearchGroupTest.java +++ b/src/test/java/org/jabref/model/groups/SearchGroupTest.java @@ -2,9 +2,9 @@ import org.jabref.model.entry.BibEntry; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; public class SearchGroupTest { diff --git a/src/test/java/org/jabref/model/groups/TexGroupTest.java b/src/test/java/org/jabref/model/groups/TexGroupTest.java index 7c09efa3915..f9a279ed599 100644 --- a/src/test/java/org/jabref/model/groups/TexGroupTest.java +++ b/src/test/java/org/jabref/model/groups/TexGroupTest.java @@ -9,10 +9,10 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.util.DummyFileUpdateMonitor; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class TexGroupTest { diff --git a/src/test/java/org/jabref/model/groups/WordKeywordGroupTest.java b/src/test/java/org/jabref/model/groups/WordKeywordGroupTest.java index 93e2a9803ec..05f4f83efe0 100644 --- a/src/test/java/org/jabref/model/groups/WordKeywordGroupTest.java +++ b/src/test/java/org/jabref/model/groups/WordKeywordGroupTest.java @@ -5,12 +5,12 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.FieldName; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class WordKeywordGroupTest { @@ -19,7 +19,7 @@ public class WordKeywordGroupTest { private WordKeywordGroup waterGroup; private BibEntry entry; - @Before + @BeforeEach public void setUp() { testGroup = new WordKeywordGroup("name", GroupHierarchyType.INDEPENDENT, "keywords", "test", false, ',', false); testCaseSensitiveGroup = new WordKeywordGroup("name", GroupHierarchyType.INDEPENDENT, "keywords", "test", true, ',', false); diff --git a/src/test/java/org/jabref/model/metadata/MetaDataTest.java b/src/test/java/org/jabref/model/metadata/MetaDataTest.java index 0f43a48cb32..017881ba922 100644 --- a/src/test/java/org/jabref/model/metadata/MetaDataTest.java +++ b/src/test/java/org/jabref/model/metadata/MetaDataTest.java @@ -2,16 +2,16 @@ import java.util.Optional; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class MetaDataTest { private MetaData metaData; - @Before + @BeforeEach public void setUp() { metaData = new MetaData(); } diff --git a/src/test/java/org/jabref/model/pdf/FileAnnotationTest.java b/src/test/java/org/jabref/model/pdf/FileAnnotationTest.java index 376ab2d69de..a96aa095835 100644 --- a/src/test/java/org/jabref/model/pdf/FileAnnotationTest.java +++ b/src/test/java/org/jabref/model/pdf/FileAnnotationTest.java @@ -3,10 +3,10 @@ import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static junit.framework.TestCase.assertTrue; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class FileAnnotationTest { diff --git a/src/test/java/org/jabref/model/search/matchers/MatcherSetsTest.java b/src/test/java/org/jabref/model/search/matchers/MatcherSetsTest.java index c72d11c1742..acd7e385b6b 100644 --- a/src/test/java/org/jabref/model/search/matchers/MatcherSetsTest.java +++ b/src/test/java/org/jabref/model/search/matchers/MatcherSetsTest.java @@ -3,10 +3,10 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.search.rules.MockSearchMatcher; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MatcherSetsTest { diff --git a/src/test/java/org/jabref/model/search/rules/ContainBasedSearchRuleTest.java b/src/test/java/org/jabref/model/search/rules/ContainBasedSearchRuleTest.java index c1e6cf6ee64..a31483330f4 100644 --- a/src/test/java/org/jabref/model/search/rules/ContainBasedSearchRuleTest.java +++ b/src/test/java/org/jabref/model/search/rules/ContainBasedSearchRuleTest.java @@ -3,8 +3,9 @@ import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.BibtexEntryTypes; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Test case for ContainBasedSearchRule. @@ -21,24 +22,24 @@ public void testBasicSearchParsing() { String query = "marine 2001 shields"; - Assert.assertEquals(false, bsCaseSensitive.applyRule(query, be)); - Assert.assertEquals(true, bsCaseInsensitive.applyRule(query, be)); - Assert.assertEquals(false, bsCaseSensitiveRegexp.applyRule(query, be)); - Assert.assertEquals(false, bsCaseInsensitiveRegexp.applyRule(query, be)); + assertEquals(false, bsCaseSensitive.applyRule(query, be)); + assertEquals(true, bsCaseInsensitive.applyRule(query, be)); + assertEquals(false, bsCaseSensitiveRegexp.applyRule(query, be)); + assertEquals(false, bsCaseInsensitiveRegexp.applyRule(query, be)); query = "\"marine larviculture\""; - Assert.assertEquals(false, bsCaseSensitive.applyRule(query, be)); - Assert.assertEquals(false, bsCaseInsensitive.applyRule(query, be)); - Assert.assertEquals(false, bsCaseSensitiveRegexp.applyRule(query, be)); - Assert.assertEquals(false, bsCaseInsensitiveRegexp.applyRule(query, be)); + assertEquals(false, bsCaseSensitive.applyRule(query, be)); + assertEquals(false, bsCaseInsensitive.applyRule(query, be)); + assertEquals(false, bsCaseSensitiveRegexp.applyRule(query, be)); + assertEquals(false, bsCaseInsensitiveRegexp.applyRule(query, be)); query = "marine [A-Za-z]* larviculture"; - Assert.assertEquals(false, bsCaseSensitive.applyRule(query, be)); - Assert.assertEquals(false, bsCaseInsensitive.applyRule(query, be)); - Assert.assertEquals(false, bsCaseSensitiveRegexp.applyRule(query, be)); - Assert.assertEquals(true, bsCaseInsensitiveRegexp.applyRule(query, be)); + assertEquals(false, bsCaseSensitive.applyRule(query, be)); + assertEquals(false, bsCaseInsensitive.applyRule(query, be)); + assertEquals(false, bsCaseSensitiveRegexp.applyRule(query, be)); + assertEquals(true, bsCaseInsensitiveRegexp.applyRule(query, be)); } diff --git a/src/test/java/org/jabref/model/search/rules/SentenceAnalyzerTest.java b/src/test/java/org/jabref/model/search/rules/SentenceAnalyzerTest.java index 6750b1c5229..c75ee11dc4b 100644 --- a/src/test/java/org/jabref/model/search/rules/SentenceAnalyzerTest.java +++ b/src/test/java/org/jabref/model/search/rules/SentenceAnalyzerTest.java @@ -3,9 +3,9 @@ import java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class SentenceAnalyzerTest { diff --git a/src/test/java/org/jabref/model/strings/StringUtilTest.java b/src/test/java/org/jabref/model/strings/StringUtilTest.java index 4a870394242..a6fae659433 100644 --- a/src/test/java/org/jabref/model/strings/StringUtilTest.java +++ b/src/test/java/org/jabref/model/strings/StringUtilTest.java @@ -2,12 +2,13 @@ import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; public class StringUtilTest { @@ -218,19 +219,19 @@ public void testIntValueOfStartWithZeros() { assertEquals(1234, StringUtil.intValueOf("001234")); } - @Test(expected = NumberFormatException.class) + @Test public void testIntValueOfExceptionIfStringContainsLetter() { - StringUtil.intValueOf("12A2"); + assertThrows(NumberFormatException.class, () -> StringUtil.intValueOf("12A2")); } - @Test(expected = NumberFormatException.class) + @Test public void testIntValueOfExceptionIfStringNull() { - StringUtil.intValueOf(null); + assertThrows(NumberFormatException.class, () -> StringUtil.intValueOf(null)); } - @Test(expected = NumberFormatException.class) + @Test public void testIntValueOfExceptionfIfStringEmpty() { - StringUtil.intValueOf(""); + assertThrows(NumberFormatException.class, () -> StringUtil.intValueOf("")); } @Test diff --git a/src/test/java/org/jabref/testutils/category/GUITest.java b/src/test/java/org/jabref/testutils/category/GUITest.java index d271ebc129d..c166c80a328 100644 --- a/src/test/java/org/jabref/testutils/category/GUITest.java +++ b/src/test/java/org/jabref/testutils/category/GUITest.java @@ -1,4 +1,17 @@ package org.jabref.testutils.category; -public interface GUITest { +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.junit.jupiter.api.Tag; + +@Target({ElementType.TYPE, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Inherited +@Tag("GUITest") +public @interface GUITest { + //empty }