Skip to content

Add test case to FileHistoryTest#15528

Merged
Siedlerchr merged 1 commit intoJabRef:mainfrom
HoussemNasri:add-test-case
Apr 11, 2026
Merged

Add test case to FileHistoryTest#15528
Siedlerchr merged 1 commit intoJabRef:mainfrom
HoussemNasri:add-test-case

Conversation

@HoussemNasri
Copy link
Copy Markdown
Member

Related issues and pull requests

PR Description

Added test case.

Checklist

  • I own the copyright of the code submitted and I license it under the MIT license
  • I manually tested my changes in running JabRef (always required)
  • I added JUnit tests for changes (if applicable)
  • [/] I added screenshots in the PR description (if change is visible to the user)
  • [/] I added a screenshot in the PR description showing a library with a single entry with me as author and as title the issue number
  • [/] I described the change in CHANGELOG.md in a way that can be understood by the average user (if change is visible to the user)
  • I checked the user documentation for up to dateness and submitted a pull request to our user documentation repository

@qodo-free-for-open-source-projects
Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Add test for file history size limit enforcement

🧪 Tests

Grey Divider

Walkthroughs

Description
• Adds test verifying oldest entry removal when file history exceeds limit
• Tests that file history maintains maximum size of 8 entries
• Validates that newest file becomes first entry after overflow
Diagram
flowchart LR
  A["Add 8 files to history"] -- "size = 8" --> B["Add 9th file"]
  B -- "size stays 8" --> C["Verify oldest file dropped"]
  C -- "file9 at index 0" --> D["file1 no longer in history"]
Loading

Grey Divider

File Changes

1. jablib/src/test/java/org/jabref/logic/util/io/FileHistoryTest.java 🧪 Tests +14/-0

Add file history size limit enforcement test

• Added new test method oldestEntryIsDroppedWhenSizeExceedsLimit()
• Tests that file history maintains maximum size of 8 entries
• Verifies oldest entry is removed when new file exceeds limit
• Confirms newest file becomes first entry in history

jablib/src/test/java/org/jabref/logic/util/io/FileHistoryTest.java


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects
Copy link
Copy Markdown
Contributor

qodo-free-for-open-source-projects bot commented Apr 10, 2026

Code Review by Qodo

🐞 Bugs (0)   📘 Rule violations (1)   📎 Requirement gaps (0)   🎨 UX Issues (0)
📘\ ≡ Correctness (1)

Grey Divider


Action required

1. Weak contains() assertion 📘
Description
The new test uses assertFalse(history.contains(...)), which is a weak predicate check and does not
assert the exact expected history contents. This can miss regressions where the list content/order
is wrong but still does not contain that one element.
Code

jablib/src/test/java/org/jabref/logic/util/io/FileHistoryTest.java[83]

+        assertFalse(history.contains(Path.of("file1")));
Evidence
Compliance requires tests to assert exact expected values/structures and avoid weak predicate checks
like contains(...). The added assertion at line 83 is exactly such a weak predicate check.

AGENTS.md
jablib/src/test/java/org/jabref/logic/util/io/FileHistoryTest.java[83-83]
Best Practice: Learned patterns

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`oldestEntryIsDroppedWhenSizeExceedsLimit()` uses a weak predicate assertion (`assertFalse(history.contains(...))`) instead of asserting the exact expected contents/order of `history`.

## Issue Context
The project requires tests to assert exact expected values/structures and avoid predicate checks like `contains(...)` that can miss regressions.

## Fix Focus Areas
- jablib/src/test/java/org/jabref/logic/util/io/FileHistoryTest.java[72-84]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo


assertEquals(8, history.size());
assertEquals(Path.of("file9"), history.get(0));
assertFalse(history.contains(Path.of("file1")));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Weak contains() assertion 📘 Rule violation ≡ Correctness

The new test uses assertFalse(history.contains(...)), which is a weak predicate check and does not
assert the exact expected history contents. This can miss regressions where the list content/order
is wrong but still does not contain that one element.
Agent Prompt
## Issue description
`oldestEntryIsDroppedWhenSizeExceedsLimit()` uses a weak predicate assertion (`assertFalse(history.contains(...))`) instead of asserting the exact expected contents/order of `history`.

## Issue Context
The project requires tests to assert exact expected values/structures and avoid predicate checks like `contains(...)` that can miss regressions.

## Fix Focus Areas
- jablib/src/test/java/org/jabref/logic/util/io/FileHistoryTest.java[72-84]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@Siedlerchr Siedlerchr added this pull request to the merge queue Apr 11, 2026
@github-actions github-actions bot added the status: to-be-merged PRs which are accepted and should go into the merge-queue. label Apr 11, 2026
Merged via the queue into JabRef:main with commit fab5916 Apr 11, 2026
63 of 64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: no-bot-comments status: to-be-merged PRs which are accepted and should go into the merge-queue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants