diff --git a/.github/heylogs.java b/.github/heylogs.java deleted file mode 100644 index aeeb31f8f45..00000000000 --- a/.github/heylogs.java +++ /dev/null @@ -1,6 +0,0 @@ -//DEPS com.github.nbbrd.heylogs:heylogs-cli:0.7.1 -public class heylogs { - public static void main(String... args) throws Exception { - nbbrd.heylogs.cli.HeylogsCommand.main(args); - } -} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9f1022654ff..86ae1543a1a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -49,20 +49,6 @@ jobs: checkstyle_version: '10.3' - name: Run checkstyle using gradle run: ./gradlew checkstyleMain checkstyleTest checkstyleJmh - - name: Add comment on pull request - if: ${{ failure() }} - uses: thollander/actions-comment-pull-request@v2 - with: - message: > - Your code currently does not meet JabRef's code guidelines. - We use [Checkstyle](https://checkstyle.sourceforge.io/) to identify issues. - The tool reviewdog already placed comments on GitHub to indicate the places. See the tab "Files" in you PR. - Please carefully follow [the setup guide for the codestyle](https://devdocs.jabref.org/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-13-code-style.html). - Afterwards, please run checkstyle locally and fix the issues. - - - More information on code quality in JabRef is available at . - comment_tag: checkstyle openrewrite: name: OpenRewrite runs-on: ubuntu-latest @@ -81,19 +67,6 @@ jobs: - name: Run OpenRewrite run: | ./gradlew rewriteDryRun - - name: Add comment on pull request - if: ${{ failure() }} - uses: thollander/actions-comment-pull-request@v2 - with: - message: > - Your code currently does not meet JabRef's code guidelines. - We use [OpenRewrite](https://docs.openrewrite.org/) to ensure "modern" Java coding practices. - The issues found can be **automatically fixed**. - Please execute the gradle task *`rewriteRun`*, check the results, commit, and push. - - - You can check the detailed error output at the tab "Checks", section "Tests" (on the left), subsection "OpenRewrite". - comment_tag: openrewrite modernizer: name: Modernizer runs-on: ubuntu-latest @@ -114,18 +87,6 @@ jobs: # enable failing of this task if modernizer complains sed -i "s/failOnViolations = false/failOnViolations = true/" build.gradle ./gradlew modernizer - - name: Add comment on pull request - if: ${{ failure() }} - uses: thollander/actions-comment-pull-request@v2 - with: - message: > - Your code currently does not meet JabRef's code guidelines. - We use [Gradle Modernizer Plugin](https://github.com/andygoossens/gradle-modernizer-plugin#gradle-modernizer-plugin) to ensure "modern" Java coding practices. - Please fix the detected errors, commit, and push. - - - You can check the detailed error output at the tab "Checks", section "Tests" (on the left), subsection "Modernizer". - comment_tag: modernizer markdown: name: Markdown runs-on: ubuntu-latest @@ -141,18 +102,7 @@ jobs: globs: | *.md docs/**/*.md - - name: Add comment on pull request - if: ${{ failure() }} - uses: thollander/actions-comment-pull-request@v2 - with: - message: > - You modified Markdown (*.md) files. - To ensure consistent styling, we have [markdown-lint](https://github.com/DavidAnson/markdownlint) in place. - [Markdown lint's rules](https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#rules) help to keep our Markdown files consistent within this repository and consistent with the Markdown files outside here. - - You can check the detailed error output at the tab "Checks", section "Tests" (on the left), subsection "Markdown". - comment_tag: markdown - changelog-non-frozen: + changelog: name: CHANGELOG.md runs-on: ubuntu-latest steps: @@ -161,22 +111,16 @@ jobs: with: submodules: 'false' show-progress: 'false' - fetch-depth: 0 - name: Lint CHANGELOG.md run: | # Install jbang curl -Ls https://sh.jbang.dev | bash -s - app setup export PATH=$PATH:$HOME/.jbang/bin - # ensure that refs are available - BRANCH=`git rev-parse HEAD` - git checkout main - # run heylogs verification - jbang --repos jitpack,central -m nbbrd.heylogs.cli.HeylogsCommand com.github.koppor.heylogs:heylogs-cli:jitpack-SNAPSHOT check CHANGELOG.md --gitdiff main...$BRANCH > heylogs.txt || true + jbang com.github.nbbrd.heylogs:heylogs-cli:0.7.2:bin check CHANGELOG.md > heylogs.txt || true # improve output - sed -i 's/consistent-separator/consistent-separator (ignored)/' heylogs.txt sed -i 's/all-h2-contain-a-version/all-h2-contain-a-version (ignored)/' heylogs.txt cat heylogs.txt @@ -184,18 +128,26 @@ jobs: # exit 1 in case of error # We have 1 "valid" issue in CHANGELOG.md grep -q "1 problem" heylogs.txt || exit 1 - - name: Add comment on pull request - if: ${{ failure() }} - uses: thollander/actions-comment-pull-request@v2 + changelog-unreleased-only: + name: CHANGELOG.md - only unreleased touched + runs-on: ubuntu-latest + steps: + - name: Checkout source + uses: actions/checkout@v4 with: - message: > - While the PR was in progress, JabRef released a new version. - You have to merge `upstream/main` and move your entry in `CHANGELOG.md` to section `## [Unreleased]`. - - - It might also be that another CHANGELOG.md issue arose. - You can check the detailed error output at the tab "Checks", section "Tests" (on the left), subsection "CHANGELOG.md". - comment_tag: changelog + submodules: 'false' + show-progress: 'false' + fetch-depth: 0 + - name: Install clparse + run: | + curl -LO https://github.com/marcaddeo/clparse/releases/download/0.9.1/clparse-0.9.1-x86_64-unknown-linux-musl.tar.gz + tar xzvf clparse-0.9.1-x86_64-unknown-linux-musl.tar.gz + sudo mv clparse /usr/local/bin/clparse + - name: Check CHANGELOG.md diff + run: | + diff \ + <(git show origin/main:CHANGELOG.md | clparse --format=json --separator=– - | jq '.releases[] | select(.version != null)') \ + <(git show HEAD:CHANGELOG.md | clparse --format=json --separator=– - | jq '.releases[] | select(.version != null)') tests: name: Unit tests runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index d36c03d2576..8560e5739a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,9 +32,15 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We fixed an issue where the added protected term has unwanted leading and trailing whitespaces, where the formatted text has unwanted empty brackets and where the word at the cursor in the textbox can be added to the list. [#10415](https://github.com/JabRef/jabref/issues/10415) - We fixed an issue where in the merge dialog the file field of entries was not correctly merged when the first and second entry both contained values inside the file field. [#10572](https://github.com/JabRef/jabref/issues/10572) - We fixed some small inconsistencies in the user interface. [#10507](https://github.com/JabRef/jabref/issues/10507) [#10458](https://github.com/JabRef/jabref/issues/10458) +- We fixed the issue where the Hayagriva YAML exporter would not include a parent field for the publisher/series. [#10596](https://github.com/JabRef/jabref/issues/10596) ### Removed +- We removed duplicate filtering and sorting operations in the MainTable when editing BibEntries. [#10619](https://github.com/JabRef/jabref/pull/10619) + + + + ## [5.11] – 2023-10-22 ### Added diff --git a/build.gradle b/build.gradle index bd9b9ff149d..c336057e81d 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ plugins { id 'idea' - id 'org.openrewrite.rewrite' version '6.4.0' + id 'org.openrewrite.rewrite' version '6.5.4' } // Enable following for debugging @@ -144,7 +144,7 @@ dependencies { implementation group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '6.7.0.202309050840-r' - implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.15.3' + implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.16.0' implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.15.3' implementation 'com.fasterxml:aalto-xml:1.3.2' @@ -173,14 +173,14 @@ dependencies { implementation 'de.saxsys:mvvmfx:1.8.0' implementation('com.tobiasdiez:easybind:2.2.1-SNAPSHOT') implementation 'org.fxmisc.flowless:flowless:0.7.2' - implementation 'org.fxmisc.richtext:richtextfx:0.11.1' + implementation 'org.fxmisc.richtext:richtextfx:0.11.2' implementation (group: 'com.dlsc.gemsfx', name: 'gemsfx', version: '1.90.0') { exclude module: 'javax.inject' // Split package, use only jakarta.inject exclude group: 'org.apache.logging.log4j' } implementation 'org.controlsfx:controlsfx:11.2.0' - implementation 'com.github.Dansoftowner:jSystemThemeDetector:3.6' + implementation 'com.github.Dansoftowner:jSystemThemeDetector:3.8' implementation 'org.jsoup:jsoup:1.16.2' implementation 'com.konghq:unirest-java:3.14.5' @@ -235,25 +235,25 @@ dependencies { // Allow objects "magically" to be mapped to JSON using GSON // implementation 'org.glassfish.jersey.media:jersey-media-json-gson:3.1.1' - testImplementation 'io.github.classgraph:classgraph:4.8.163' + testImplementation 'io.github.classgraph:classgraph:4.8.164' testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1' - testImplementation 'org.junit.platform:junit-platform-launcher:1.10.0' + testImplementation 'org.junit.platform:junit-platform-launcher:1.10.1' - testImplementation 'org.mockito:mockito-core:5.6.0' + testImplementation 'org.mockito:mockito-core:5.7.0' testImplementation 'org.xmlunit:xmlunit-core:2.9.1' testImplementation 'org.xmlunit:xmlunit-matchers:2.9.1' - testRuntimeOnly 'com.tngtech.archunit:archunit-junit5-engine:1.1.0' + testRuntimeOnly 'com.tngtech.archunit:archunit-junit5-engine:1.2.0' testImplementation 'com.tngtech.archunit:archunit-junit5-api:1.2.0' testImplementation "org.testfx:testfx-core:4.0.16-alpha" testImplementation "org.testfx:testfx-junit5:4.0.16-alpha" testImplementation "org.hamcrest:hamcrest-library:2.2" - checkstyle 'com.puppycrawl.tools:checkstyle:10.12.4' + checkstyle 'com.puppycrawl.tools:checkstyle:10.12.5' // xjc needs the runtime as well for the ant task, otherwise it fails xjc group: 'org.glassfish.jaxb', name: 'jaxb-xjc', version: '3.0.2' xjc group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '3.0.2' - rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:2.4.1")) + rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:2.5.0")) rewrite("org.openrewrite.recipe:rewrite-static-analysis") rewrite("org.openrewrite.recipe:rewrite-logging-frameworks") rewrite("org.openrewrite.recipe:rewrite-testing-frameworks") diff --git a/buildSrc/src/main/groovy/org/jabref/build/xjc/XjcTask.groovy b/buildSrc/src/main/groovy/org/jabref/build/xjc/XjcTask.groovy index 8b68e35ab98..fb7bbf7cdb6 100644 --- a/buildSrc/src/main/groovy/org/jabref/build/xjc/XjcTask.groovy +++ b/buildSrc/src/main/groovy/org/jabref/build/xjc/XjcTask.groovy @@ -103,8 +103,9 @@ class XjcTask extends DefaultTask { } private void updateOutput() { - if (outputDirectory != null && javaPackage != null) - outputs.dir(new File(getOutputDirectory(), packageAsPath(javaPackage))) + if (outputDirectory != null && javaPackage != null) { + outputs.dir(new File(getOutputDirectory(), packageAsPath(javaPackage))) + } } private static String packageAsPath(String pkg) { diff --git a/buildres/abbrv.jabref.org b/buildres/abbrv.jabref.org index cf71cb48dbd..5a48c1b35b7 160000 --- a/buildres/abbrv.jabref.org +++ b/buildres/abbrv.jabref.org @@ -1 +1 @@ -Subproject commit cf71cb48dbd78b2d85856e689e2834f14b91fdbc +Subproject commit 5a48c1b35b762f7c14a973099dd53bc686413498 diff --git a/rewrite.yml b/rewrite.yml index 7d5eaad4866..bcb32628d3c 100644 --- a/rewrite.yml +++ b/rewrite.yml @@ -163,7 +163,7 @@ recipeList: - org.openrewrite.staticanalysis.RemoveExtraSemicolons - org.openrewrite.staticanalysis.RemoveJavaDocAuthorTag - org.openrewrite.staticanalysis.RemoveHashCodeCallsFromArrayInstances - - org.openrewrite.staticanalysis.RemoveRedundantTypeCast +# - org.openrewrite.staticanalysis.RemoveRedundantTypeCast - org.openrewrite.staticanalysis.RemoveToStringCallsFromArrayInstances - org.openrewrite.staticanalysis.RemoveUnneededAssertion - org.openrewrite.staticanalysis.RemoveUnneededBlock @@ -195,3 +195,6 @@ recipeList: - org.openrewrite.staticanalysis.UseSystemLineSeparator - org.openrewrite.staticanalysis.WhileInsteadOfFor # - org.openrewrite.staticanalysis.WriteOctalValuesAsDecimal + + - org.openrewrite.java.testing.junit5.CleanupAssertions +# - org.openrewrite.java.testing.junit5.JUnit5BestPractices diff --git a/src/main/java/org/jabref/gui/LibraryTab.java b/src/main/java/org/jabref/gui/LibraryTab.java index fc4880d2562..137a9548678 100644 --- a/src/main/java/org/jabref/gui/LibraryTab.java +++ b/src/main/java/org/jabref/gui/LibraryTab.java @@ -66,7 +66,6 @@ import org.jabref.model.entry.BibEntryTypesManager; import org.jabref.model.entry.LinkedFile; import org.jabref.model.entry.event.EntriesEventSource; -import org.jabref.model.entry.event.EntryChangedEvent; import org.jabref.model.entry.event.FieldChangedEvent; import org.jabref.model.entry.field.Field; import org.jabref.model.entry.field.FieldFactory; @@ -156,7 +155,6 @@ public LibraryTab(BibDatabaseContext bibDatabaseContext, setupMainPanel(); setupAutoCompletion(); - this.getDatabase().registerListener(new SearchListener()); this.getDatabase().registerListener(new IndexUpdateListener()); this.getDatabase().registerListener(new EntriesRemovedListener()); @@ -277,7 +275,6 @@ public void feedData(BibDatabaseContext bibDatabaseContextFromParserResult) { setupMainPanel(); setupAutoCompletion(); - this.getDatabase().registerListener(new SearchListener()); this.getDatabase().registerListener(new EntriesRemovedListener()); // ensure that at each addition of a new entry, the entry is added to the groups interface @@ -918,28 +915,6 @@ public void listen(EntriesRemovedEvent entriesRemovedEvent) { } } - /** - * Ensures that the results of the current search are updated when a new entry is inserted into the database Actual methods for performing search must run in javafx thread - */ - private class SearchListener { - - @Subscribe - public void listen(EntriesAddedEvent addedEntryEvent) { - DefaultTaskExecutor.runInJavaFXThread(() -> frame.getGlobalSearchBar().performSearch()); - } - - @Subscribe - public void listen(EntryChangedEvent entryChangedEvent) { - DefaultTaskExecutor.runInJavaFXThread(() -> frame.getGlobalSearchBar().performSearch()); - } - - @Subscribe - public void listen(EntriesRemovedEvent removedEntriesEvent) { - // IMO only used to update the status (found X entries) - DefaultTaskExecutor.runInJavaFXThread(() -> frame.getGlobalSearchBar().performSearch()); - } - } - private class IndexUpdateListener { @Subscribe diff --git a/src/main/java/org/jabref/gui/search/GlobalSearchBar.java b/src/main/java/org/jabref/gui/search/GlobalSearchBar.java index 34ac62b9de0..e419c97b827 100644 --- a/src/main/java/org/jabref/gui/search/GlobalSearchBar.java +++ b/src/main/java/org/jabref/gui/search/GlobalSearchBar.java @@ -201,7 +201,7 @@ public GlobalSearchBar(JabRefFrame frame, StateManager stateManager, Preferences this.setSpacing(4.0); this.setAlignment(Pos.CENTER_LEFT); - Timer searchTask = FxTimer.create(Duration.ofMillis(SEARCH_DELAY), this::performSearch); + Timer searchTask = FxTimer.create(Duration.ofMillis(SEARCH_DELAY), this::updateSearchQuery); BindingsHelper.bindBidirectional( stateManager.activeSearchQueryProperty(), searchField.textProperty(), @@ -238,7 +238,7 @@ private void initSearchModifierButtons() { initSearchModifierButton(regularExpressionButton); regularExpressionButton.setOnAction(event -> { searchPreferences.setSearchFlag(SearchRules.SearchFlags.REGULAR_EXPRESSION, regularExpressionButton.isSelected()); - performSearch(); + updateSearchQuery(); }); caseSensitiveButton.setSelected(searchPreferences.isCaseSensitive()); @@ -246,7 +246,7 @@ private void initSearchModifierButtons() { initSearchModifierButton(caseSensitiveButton); caseSensitiveButton.setOnAction(event -> { searchPreferences.setSearchFlag(SearchRules.SearchFlags.CASE_SENSITIVE, caseSensitiveButton.isSelected()); - performSearch(); + updateSearchQuery(); }); fulltextButton.setSelected(searchPreferences.isFulltext()); @@ -254,7 +254,7 @@ private void initSearchModifierButtons() { initSearchModifierButton(fulltextButton); fulltextButton.setOnAction(event -> { searchPreferences.setSearchFlag(SearchRules.SearchFlags.FULLTEXT, fulltextButton.isSelected()); - performSearch(); + updateSearchQuery(); }); keepSearchString.setSelected(searchPreferences.shouldKeepSearchString()); @@ -262,7 +262,7 @@ private void initSearchModifierButtons() { initSearchModifierButton(keepSearchString); keepSearchString.setOnAction(evt -> { searchPreferences.setSearchFlag(SearchRules.SearchFlags.KEEP_SEARCH_STRING, keepSearchString.isSelected()); - performSearch(); + updateSearchQuery(); }); openGlobalSearchButton.disableProperty().bindBidirectional(globalSearchActive); @@ -271,7 +271,7 @@ private void initSearchModifierButtons() { openGlobalSearchButton.setOnAction(evt -> { globalSearchActive.setValue(true); globalSearchResultDialog = new GlobalSearchResultDialog(undoManager); - performSearch(); + updateSearchQuery(); dialogService.showCustomDialogAndWait(globalSearchResultDialog); globalSearchActive.setValue(false); }); @@ -298,9 +298,9 @@ public void focus() { searchField.selectAll(); } - public void performSearch() { + public void updateSearchQuery() { LOGGER.debug("Flags: {}", searchPreferences.getSearchFlags()); - LOGGER.debug("Run search {}", searchField.getText()); + LOGGER.debug("Updated search query: {}", searchField.getText()); // An empty search field should cause the search to be cleared. if (searchField.getText().isEmpty()) { diff --git a/src/main/resources/csl-styles b/src/main/resources/csl-styles index 010b77c19b0..5bea241e5a2 160000 --- a/src/main/resources/csl-styles +++ b/src/main/resources/csl-styles @@ -1 +1 @@ -Subproject commit 010b77c19b0928db4cc046258d6797a937e0f460 +Subproject commit 5bea241e5a2acacc29b947e21539be9cbe79c8bd diff --git a/src/main/resources/resource/layout/hayagrivayaml.layout b/src/main/resources/resource/layout/hayagrivayaml.layout index cd19524d406..b60553bec16 100644 --- a/src/main/resources/resource/layout/hayagrivayaml.layout +++ b/src/main/resources/resource/layout/hayagrivayaml.layout @@ -6,11 +6,24 @@ - \format[Authors(LastFirst, MiddleInitial, Sep =\n - , LastSep =\n - )]{\author} \end{author} \begin{date} date: \date\end{date} +\begin{journal} + parent: + type: periodical + title: \journal +\end{journal} + \begin{journal&&volume}volume: \volume\end{journal&&volume} + \begin{journal&&number}issue: \number\end{journal&&number} + \begin{journal&&publisher}publisher: \publisher\end{journal&&publisher} +\begin{series} + parent: + type: book + title: "\series" +\end{series} +\begin{editor&&number} issue: \number\end{editor&&number} +\begin{editor&&publisher} publisher: \publisher\end{editor&&publisher} \begin{editor} editor: \editor\end{editor} -\begin{publisher} publisher: \publisher\end{publisher} \begin{address} location: \address\end{address} \begin{institution} organization: \institution\end{institution} -\begin{volume} volume: \volume\end{volume} \begin{edition} edition: \edition\end{edition} \begin{pages} page-range: \pages\end{pages} \begin{url} url: \url\end{url} diff --git a/src/test/java/org/jabref/gui/externalfiles/FileFilterUtilsTest.java b/src/test/java/org/jabref/gui/externalfiles/FileFilterUtilsTest.java index 9af4b1364bb..9deab592e8f 100755 --- a/src/test/java/org/jabref/gui/externalfiles/FileFilterUtilsTest.java +++ b/src/test/java/org/jabref/gui/externalfiles/FileFilterUtilsTest.java @@ -16,7 +16,9 @@ import org.junit.jupiter.api.io.TempDir; 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 FileFilterUtilsTest { @@ -25,42 +27,42 @@ public class FileFilterUtilsTest { @Test public void isDuringLastDayNegativeTest() { - assertEquals(fileFilterUtils.isDuringLastDay(time.minusHours(24)), false); + assertFalse(fileFilterUtils.isDuringLastDay(time.minusHours(24))); } @Test public void isDuringLastDayPositiveTest() { - assertEquals(fileFilterUtils.isDuringLastDay(time.minusHours(23)), true); + assertTrue(fileFilterUtils.isDuringLastDay(time.minusHours(23))); } @Test public void isDuringLastWeekNegativeTest() { - assertEquals(fileFilterUtils.isDuringLastWeek(time.minusDays(7)), false); + assertFalse(fileFilterUtils.isDuringLastWeek(time.minusDays(7))); } @Test public void isDuringLastWeekPositiveTest() { - assertEquals(fileFilterUtils.isDuringLastWeek(time.minusDays(6).minusHours(23)), true); + assertTrue(fileFilterUtils.isDuringLastWeek(time.minusDays(6).minusHours(23))); } @Test public void isDuringLastMonthNegativeTest() { - assertEquals(fileFilterUtils.isDuringLastMonth(time.minusDays(30)), false); + assertFalse(fileFilterUtils.isDuringLastMonth(time.minusDays(30))); } @Test public void isDuringLastMonthPositiveTest() { - assertEquals(fileFilterUtils.isDuringLastMonth(time.minusDays(29).minusHours(23)), true); + assertTrue(fileFilterUtils.isDuringLastMonth(time.minusDays(29).minusHours(23))); } @Test public void isDuringLastYearNegativeTest() { - assertEquals(fileFilterUtils.isDuringLastYear(time.minusDays(365)), false); + assertFalse(fileFilterUtils.isDuringLastYear(time.minusDays(365))); } @Test public void isDuringLastYearPositiveTest() { - assertEquals(fileFilterUtils.isDuringLastYear(time.minusDays(364).minusHours(23)), true); + assertTrue(fileFilterUtils.isDuringLastYear(time.minusDays(364).minusHours(23))); } @Nested diff --git a/src/test/java/org/jabref/gui/maintable/MainTableColumnModelTest.java b/src/test/java/org/jabref/gui/maintable/MainTableColumnModelTest.java index a344886401a..750d92708fb 100644 --- a/src/test/java/org/jabref/gui/maintable/MainTableColumnModelTest.java +++ b/src/test/java/org/jabref/gui/maintable/MainTableColumnModelTest.java @@ -52,6 +52,6 @@ public void typeOnlyMainTableColumnModelParserRetrievesCorrectType() { public void typeOnlyMainTableColumnModelParserRetrievesCorrectQualifier() { MainTableColumnModel testColumnModel = MainTableColumnModel.parse(testTypeOnlyName); - assertEquals(testColumnModel.getQualifier(), ""); + assertEquals("", testColumnModel.getQualifier()); } } diff --git a/src/test/java/org/jabref/gui/sidepane/SidePaneViewModelTest.java b/src/test/java/org/jabref/gui/sidepane/SidePaneViewModelTest.java index 27db78fe64d..0419752b78e 100644 --- a/src/test/java/org/jabref/gui/sidepane/SidePaneViewModelTest.java +++ b/src/test/java/org/jabref/gui/sidepane/SidePaneViewModelTest.java @@ -76,30 +76,30 @@ void setUp() { void moveUp() { sidePaneViewModel.moveUp(SidePaneType.WEB_SEARCH); - assertEquals(sidePaneComponents.get(0), SidePaneType.WEB_SEARCH); - assertEquals(sidePaneComponents.get(1), SidePaneType.GROUPS); + assertEquals(SidePaneType.WEB_SEARCH, sidePaneComponents.get(0)); + assertEquals(SidePaneType.GROUPS, sidePaneComponents.get(1)); } @Test void moveUpFromFirstPosition() { sidePaneViewModel.moveUp(SidePaneType.GROUPS); - assertEquals(sidePaneComponents.get(0), SidePaneType.GROUPS); + assertEquals(SidePaneType.GROUPS, sidePaneComponents.get(0)); } @Test void moveDown() { sidePaneViewModel.moveDown(SidePaneType.WEB_SEARCH); - assertEquals(sidePaneComponents.get(1), SidePaneType.OPEN_OFFICE); - assertEquals(sidePaneComponents.get(2), SidePaneType.WEB_SEARCH); + assertEquals(SidePaneType.OPEN_OFFICE, sidePaneComponents.get(1)); + assertEquals(SidePaneType.WEB_SEARCH, sidePaneComponents.get(2)); } @Test void moveDownFromLastPosition() { sidePaneViewModel.moveDown(SidePaneType.OPEN_OFFICE); - assertEquals(sidePaneComponents.get(2), SidePaneType.OPEN_OFFICE); + assertEquals(SidePaneType.OPEN_OFFICE, sidePaneComponents.get(2)); } @Test diff --git a/src/test/java/org/jabref/gui/theme/ThemeManagerTest.java b/src/test/java/org/jabref/gui/theme/ThemeManagerTest.java index f96308c18b8..87e1d1a654c 100644 --- a/src/test/java/org/jabref/gui/theme/ThemeManagerTest.java +++ b/src/test/java/org/jabref/gui/theme/ThemeManagerTest.java @@ -145,7 +145,7 @@ public void largeCustomThemeNotHeldInMemory() throws IOException { Files.move(largeCssTestFile, largeCssTestFile.resolveSibling("renamed.css")); // getAdditionalStylesheet() should no longer offer the deleted stylesheet as it is not been held in memory - assertEquals(themeManager.getActiveTheme().getAdditionalStylesheet().get().getWebEngineStylesheet(), "", + assertEquals("", themeManager.getActiveTheme().getAdditionalStylesheet().get().getWebEngineStylesheet(), "didn't expect additional stylesheet after css was deleted"); Files.move(largeCssTestFile.resolveSibling("renamed.css"), largeCssTestFile); @@ -194,7 +194,7 @@ public void installThemeOnWebEngine() throws IOException { }); Assertions.assertDoesNotThrow(() -> { - assertEquals(webEngineStyleSheetLocation.get(), TEST_CSS_DATA); + assertEquals(TEST_CSS_DATA, webEngineStyleSheetLocation.get()); }); } diff --git a/src/test/java/org/jabref/logic/bibtex/comparator/BibStringDiffTest.java b/src/test/java/org/jabref/logic/bibtex/comparator/BibStringDiffTest.java index 28f8ed4d801..03527cb4387 100644 --- a/src/test/java/org/jabref/logic/bibtex/comparator/BibStringDiffTest.java +++ b/src/test/java/org/jabref/logic/bibtex/comparator/BibStringDiffTest.java @@ -10,9 +10,7 @@ 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.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -54,17 +52,17 @@ void notEqualTest() { @Test void identicalObjectsAreEqual() { BibStringDiff other = diff; - assertTrue(other.equals(diff)); + assertEquals(other, diff); } @Test void compareToNullObjectIsFalse() { - assertFalse(diff.equals(null)); + assertNotEquals(null, diff); } @Test void compareToDifferentClassIsFalse() { - assertFalse(diff.equals(new Object())); + assertNotEquals(diff, new Object()); } @Test diff --git a/src/test/java/org/jabref/logic/database/DatabaseMergerTest.java b/src/test/java/org/jabref/logic/database/DatabaseMergerTest.java index a7464dbaed5..b6a874c93b6 100644 --- a/src/test/java/org/jabref/logic/database/DatabaseMergerTest.java +++ b/src/test/java/org/jabref/logic/database/DatabaseMergerTest.java @@ -162,7 +162,7 @@ void mergeMetaDataWithoutAllEntriesGroup() { // Assert that groups of other are children of root node of target assertEquals(targetRootGroup, target.getGroups().get()); - assertEquals(target.getGroups().get().getChildren().size(), 1); + assertEquals(1, target.getGroups().get().getChildren().size()); assertEquals(otherRootGroup, target.getGroups().get().getChildren().get(0)); } @@ -185,7 +185,7 @@ void mergeMetaDataWithAllEntriesGroup() { // Assert that groups of other are children of root node of target assertEquals(targetRootGroup, target.getGroups().get()); - assertEquals(target.getGroups().get().getChildren().size(), 1); + assertEquals(1, target.getGroups().get().getChildren().size()); assertEquals(expectedImportedGroupNode, target.getGroups().get().getChildren().get(0)); assertEquals(expectedContentSelectors, target.getContentSelectorList()); } diff --git a/src/test/java/org/jabref/logic/exporter/HayagrivaYamlExporterTest.java b/src/test/java/org/jabref/logic/exporter/HayagrivaYamlExporterTest.java index 7a058ec059d..0b6356906e9 100644 --- a/src/test/java/org/jabref/logic/exporter/HayagrivaYamlExporterTest.java +++ b/src/test/java/org/jabref/logic/exporter/HayagrivaYamlExporterTest.java @@ -183,4 +183,35 @@ void passesModifiedCharsetNull(@TempDir Path tempFile) throws Exception { "---"); assertEquals(expected, Files.readAllLines(file)); } + + @Test + public final void exportsCorrectParentField(@TempDir Path tempFile) throws Exception { + BibEntry entry = new BibEntry(StandardEntryType.Article) + .withCitationKey("test") + .withField(StandardField.AUTHOR, "Test Author") + .withField(StandardField.TITLE, "Test Title") + .withField(StandardField.JOURNAL, "Test Publisher") + .withField(StandardField.URL, "http://example.com") + .withField(StandardField.DATE, "2020-10-14"); + + Path file = tempFile.resolve("RandomFileName"); + Files.createFile(file); + hayagrivaYamlExporter.export(databaseContext, file, Collections.singletonList(entry)); + + List expected = List.of( + "---", + "test:", + " type: article", + " title: \"Test Title\"", + " author:", + " - Author, Test", + " date: 2020-10-14", + " parent:", + " type: periodical", + " title: Test Publisher", + " url: http://example.com", + "---"); + + assertEquals(expected, Files.readAllLines(file)); + } } diff --git a/src/test/java/org/jabref/logic/importer/fetcher/IacrEprintFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/IacrEprintFetcherTest.java index 2eb837d2364..c168c4bceb7 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/IacrEprintFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/IacrEprintFetcherTest.java @@ -168,7 +168,7 @@ public void searchByIdWithOldHtmlFormatWithoutDateCheck(String id) throws Fetche Optional fetchedEntry = fetcher.performSearchById(id); assertTrue(fetchedEntry.isPresent(), "Expected to get an entry for id " + id); assertNotEquals(Optional.empty(), fetchedEntry.get().getField(StandardField.DATE), "Expected non empty date field, entry is\n" + fetchedEntry.toString()); - assertTrue(fetchedEntry.get().getField(StandardField.DATE).get().length() == 10, "Expected yyyy-MM-dd date format, entry is\n" + fetchedEntry.toString()); + assertEquals(10, fetchedEntry.get().getField(StandardField.DATE).get().length(), "Expected yyyy-MM-dd date format, entry is\n" + fetchedEntry.toString()); assertNotEquals(Optional.empty(), fetchedEntry.get().getField(StandardField.ABSTRACT), "Expected non empty abstract field, entry is\n" + fetchedEntry.toString()); } diff --git a/src/test/java/org/jabref/logic/journals/AbbreviationTest.java b/src/test/java/org/jabref/logic/journals/AbbreviationTest.java index 1f3ba7a8eab..423e235c0c2 100644 --- a/src/test/java/org/jabref/logic/journals/AbbreviationTest.java +++ b/src/test/java/org/jabref/logic/journals/AbbreviationTest.java @@ -105,10 +105,10 @@ void testDefaultAndShortestUniqueAbbreviationsAreSame() { @Test void testEquals() { - Abbreviation abbreviation = new Abbreviation("Long Name", "L N", "LN"); - Abbreviation otherAbbreviation = new Abbreviation("Long Name", "L N", "LN"); - assertEquals(abbreviation, otherAbbreviation); - assertNotEquals(abbreviation, "String"); + Abbreviation abbreviation = new Abbreviation("Long Name", "L N", "LN"); + Abbreviation otherAbbreviation = new Abbreviation("Long Name", "L N", "LN"); + assertEquals(abbreviation, otherAbbreviation); + assertNotEquals("String", abbreviation); } @Test 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 3d1eb4ebb9b..31bc81144f5 100644 --- a/src/test/java/org/jabref/logic/layout/format/ReplaceTest.java +++ b/src/test/java/org/jabref/logic/layout/format/ReplaceTest.java @@ -5,6 +5,7 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; public class ReplaceTest { @@ -26,7 +27,7 @@ public void testSimpleTextNoHit() { public void testFormatNull() { ParamLayoutFormatter a = new Replace(); a.setArgument("Eds.,Ed."); - assertEquals(null, a.format(null)); + assertNull(a.format(null)); } @Test diff --git a/src/test/java/org/jabref/logic/msbib/MsBibAuthorTest.java b/src/test/java/org/jabref/logic/msbib/MsBibAuthorTest.java index 3b09b26c7d9..2ccef4f8722 100644 --- a/src/test/java/org/jabref/logic/msbib/MsBibAuthorTest.java +++ b/src/test/java/org/jabref/logic/msbib/MsBibAuthorTest.java @@ -5,6 +5,7 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; public class MsBibAuthorTest { @@ -26,14 +27,14 @@ public void testGetMiddleName() { public void testGetNoMiddleName() { Author author = new Author("Gustav", null, null, "Bach", null); MsBibAuthor msBibAuthor = new MsBibAuthor(author); - assertEquals(null, msBibAuthor.getMiddleName()); + assertNull(msBibAuthor.getMiddleName()); } @Test public void testGetNoFirstName() { Author author = new Author(null, null, null, "Bach", null); MsBibAuthor msBibAuthor = new MsBibAuthor(author); - assertEquals(null, msBibAuthor.getMiddleName()); + assertNull(msBibAuthor.getMiddleName()); } @Test diff --git a/src/test/java/org/jabref/logic/net/ProxyTest.java b/src/test/java/org/jabref/logic/net/ProxyTest.java index 6b6e844d1b6..20f904441cb 100644 --- a/src/test/java/org/jabref/logic/net/ProxyTest.java +++ b/src/test/java/org/jabref/logic/net/ProxyTest.java @@ -3,6 +3,7 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ProxyTest { /** @@ -31,10 +32,10 @@ public void testProxyPreferencesStorePassword() { persist); // Check if mock data is stored in object memory and can be extracted - assertEquals(proxyPref.shouldUseProxy(), true); + assertTrue(proxyPref.shouldUseProxy()); assertEquals(proxyPref.getHostname(), hostname); assertEquals(proxyPref.getPort(), port); - assertEquals(proxyPref.shouldUseAuthentication(), true); + assertTrue(proxyPref.shouldUseAuthentication()); assertEquals(proxyPref.getUsername(), username); assertEquals(proxyPref.getPassword(), password); assertEquals(proxyPref.shouldPersistPassword(), persist); diff --git a/src/test/java/org/jabref/model/FieldChangeTest.java b/src/test/java/org/jabref/model/FieldChangeTest.java index 1625a1ae652..b2a6b77f64b 100644 --- a/src/test/java/org/jabref/model/FieldChangeTest.java +++ b/src/test/java/org/jabref/model/FieldChangeTest.java @@ -57,7 +57,7 @@ void selfEqualsFieldchangeDifferentEntry() { @Test void fieldChangeDoesNotEqualString() { - assertNotEquals(fc, "foo"); + assertNotEquals("foo", fc); } @Test diff --git a/src/test/java/org/jabref/model/entry/BibEntryTest.java b/src/test/java/org/jabref/model/entry/BibEntryTest.java index b913030cc73..63cd6657bc9 100644 --- a/src/test/java/org/jabref/model/entry/BibEntryTest.java +++ b/src/test/java/org/jabref/model/entry/BibEntryTest.java @@ -364,17 +364,17 @@ void isEmptyCiteKey() { @Test void identicObjectsareEqual() throws Exception { BibEntry otherEntry = entry; - assertTrue(entry.equals(otherEntry)); + assertEquals(entry, otherEntry); } @Test void compareToNullObjectIsFalse() throws Exception { - assertFalse(entry.equals(null)); + assertNotEquals(null, entry); } @Test void compareToDifferentClassIsFalse() throws Exception { - assertFalse(entry.equals(new Object())); + assertNotEquals(entry, new Object()); } @Test diff --git a/src/test/java/org/jabref/model/openoffice/CitationEntryTest.java b/src/test/java/org/jabref/model/openoffice/CitationEntryTest.java index 8648d9b5df9..481afa00eac 100644 --- a/src/test/java/org/jabref/model/openoffice/CitationEntryTest.java +++ b/src/test/java/org/jabref/model/openoffice/CitationEntryTest.java @@ -48,7 +48,7 @@ void testCitationEntryEquals() { assertEquals(citationEntry1, citationEntry1); assertEquals(citationEntry1, citationEntry3); assertNotEquals(citationEntry1, citationEntry2); - assertNotEquals(citationEntry1, "Random String"); + assertNotEquals("Random String", citationEntry1); } @Test diff --git a/src/test/java/org/jabref/model/strings/StringUtilTest.java b/src/test/java/org/jabref/model/strings/StringUtilTest.java index a1ba47b247a..f41584e1939 100644 --- a/src/test/java/org/jabref/model/strings/StringUtilTest.java +++ b/src/test/java/org/jabref/model/strings/StringUtilTest.java @@ -14,6 +14,7 @@ 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.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -142,7 +143,7 @@ void testStripBrackets() { assertEquals("]", StringUtil.stripBrackets("]")); assertEquals("", StringUtil.stripBrackets("[]")); assertEquals("f[]f", StringUtil.stripBrackets("f[]f")); - assertEquals(null, StringUtil.stripBrackets(null)); + assertNull(StringUtil.stripBrackets(null)); } @Test