Skip to content

add test case for multiple authors in csl citaiton#15707

Merged
Siedlerchr merged 2 commits into
mainfrom
cslmultiAuthor
May 9, 2026
Merged

add test case for multiple authors in csl citaiton#15707
Siedlerchr merged 2 commits into
mainfrom
cslmultiAuthor

Conversation

@Siedlerchr

Copy link
Copy Markdown
Member

Related issues and pull requests

Closes _____

PR Description

Steps to test

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

@Siedlerchr Siedlerchr requested a review from pluto-han May 8, 2026 21:40
@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Add test case for multiple authors in CSL citation

🧪 Tests

Grey Divider

Walkthroughs

Description
• Adds test case for multiple authors in CSL citation
• Fixes incorrect style filter in APA citation test
• Adds new test entry reference for multi-entry citation testing
• Tests APA format with multiple bibliography entries
Diagram
flowchart LR
  A["CitationStyleGeneratorTest"] -->|adds testEntry2| B["Multiple Entry Support"]
  A -->|fixes APA style filter| C["APA Citation Test"]
  A -->|new test method| D["aPACitation2Authors"]
  D -->|validates format| E["Multi-entry Citation Output"]
Loading

Grey Divider

File Changes

1. jablib/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java 🧪 Tests +14/-2

Add multi-author APA citation test case

• Adds testEntry2 field initialized with TestEntry.getTestEntryBook() for multi-entry testing
• Fixes aPACitation() test to use correct "APA Style 7th edition" style filter instead of "ACM
 SIGGRAPH"
• Updates expected output in aPACitation() from "[Smith et al. 2016]" to "(Smith et al., 2016)"
 for correct APA format
• Adds new aPACitation2Authors() test method that validates citation generation with multiple
 bibliography entries

jablib/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (1) 📎 Requirement gaps (0)

Grey Divider


Remediation recommended

1. testEntry2 placeholder name 📘 Rule violation ⚙ Maintainability
Description
The new variable name testEntry2 is a non-meaningful placeholder, making the test harder to read
and maintain. This violates the naming guideline that forbids typos/placeholder patterns like
...2/extraEntry2.
Code

jablib/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java[39]

+    private final BibEntry testEntry2 = TestEntry.getTestEntryBook();
Evidence
PR Compliance ID 13 requires meaningful, correctly spelled variable names and explicitly calls out
placeholder patterns (e.g., extraEntry2). The PR introduces testEntry2 and uses it in the new
test, which is a placeholder-style name rather than intention-revealing (e.g., bookEntry,
secondEntry, harrerEntry).

AGENTS.md
jablib/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java[39-39]
jablib/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java[79-79]

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

## Issue description
The test introduces a placeholder-style variable name (`testEntry2`), which reduces readability.
## Issue Context
The project naming guideline requires intention-revealing names and explicitly discourages placeholder suffix patterns like `...2`.
## Fix Focus Areas
- jablib/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java[39-39]
- jablib/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java[75-83]

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


2. Context missing second entry 🐞 Bug ☼ Reliability
Description
In aPACitation2Authors, generateCitation is called with two BibEntry objects but the provided
BibDatabaseContext’s BibDatabase contains only testEntry. This can change resolved-field behavior
(e.g., crossref/string resolution) for testEntry2 and makes the test less representative of real
usage.
Code

jablib/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java[R79-81]

+        String citation = CitationStyleGenerator.generateCitation(List.of(testEntry, testEntry2), style.getSource(), HTML_OUTPUT_FORMAT, testEntryContext, ENTRY_TYPES_MANAGER);
+
+        String expected = "(Harrer et al., 2018; Smith et al., 2016)";
Evidence
The test’s context database is constructed with only testEntry, while the citation generation
includes testEntry2 as well. CSL conversion resolves field values via
BibEntry.getResolvedFieldOrAlias using the BibDatabase from the provided BibDatabaseContext;
crossref and string resolution depend on the database contents, so omitting testEntry2 can produce
different resolved values than a real database containing both entries.

jablib/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java[38-41]
jablib/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java[75-84]
jablib/src/main/java/org/jabref/logic/citationstyle/JabRefItemDataProvider.java[155-167]
jablib/src/main/java/org/jabref/model/entry/BibEntry.java[303-350]

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

## Issue description
`aPACitation2Authors` passes `List.of(testEntry, testEntry2)` to `generateCitation`, but `testEntryContext` is built from a `BibDatabase` containing only `testEntry`. This can affect resolved fields (e.g., crossref and string resolution) and makes the test setup inconsistent.
## Issue Context
`JabRefItemDataProvider` resolves fields via `bibEntry.getResolvedFieldOrAlias(key, bibDatabaseContext.getDatabase())`. `BibEntry#getResolvedFieldOrAlias` uses the provided database for string resolution and to follow `crossref` links.
## Fix Focus Areas
- jablib/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java[38-41]
- jablib/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java[75-84]
## Suggested fix
In `aPACitation2Authors`, create a dedicated `BibDatabaseContext` that contains *both* entries (e.g., `new BibDatabase(List.of(testEntry, testEntry2))`) and use that context for the call. This avoids changing shared test state for other tests while making the multi-entry test realistic.

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



Advisory comments

3. Misleading test name ✓ Resolved 🐞 Bug ⚙ Maintainability
Description
The method name aPACitation2Authors suggests it tests “two authors”, but it actually tests citing
two different entries in one combined citation. This can mislead future maintenance and weaken
understanding of coverage.
Code

jablib/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java[76]

+    void aPACitation2Authors() {
Evidence
The test passes two BibEntry instances to generateCitation (two works in one citation), so the
behavior under test is multi-entry/multi-citation formatting rather than a single-entry ‘two
authors’ case.

jablib/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java[75-83]

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

## Issue description
`aPACitation2Authors` is named like it validates a two-author scenario, but the test actually validates a combined in-text citation for two entries.
## Issue Context
The method calls `generateCitation(List.of(testEntry, testEntry2), ...)` and asserts the combined output.
## Fix Focus Areas
- jablib/src/test/java/org/jabref/logic/citationstyle/CitationStyleGeneratorTest.java[75-84]
## Suggested fix
Rename the test to something like `aPACitationMultipleEntries()` or `aPACitationTwoEntries()` (or similar) so the name matches what is asserted.

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


Grey Divider

Qodo Logo

@Siedlerchr Siedlerchr changed the title add test case for multilpe authors in csl citaiton add test case for multiple authors in csl citaiton May 8, 2026

@subhramit subhramit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yep, good idea

@pluto-han pluto-han left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good idea!

@pluto-han pluto-han enabled auto-merge May 9, 2026 08:08
@Siedlerchr Siedlerchr disabled auto-merge May 9, 2026 09:56
@Siedlerchr Siedlerchr merged commit cc371f7 into main May 9, 2026
68 of 70 checks passed
@Siedlerchr Siedlerchr deleted the cslmultiAuthor branch May 9, 2026 09:56
Siedlerchr added a commit to pluto-han/jabref that referenced this pull request May 11, 2026
* upstream/main: (21 commits)
  chore(deps): update dependency com.konghq:unirest-modules-gson to v4.10.0 (JabRef#15715)
  Add manual tests (JabRef#15351)
  Refactored the comments for UnlinkedFilesCrawler (JabRef#15709)
  Replace inline styles with CSS classes (JabRef#15694)
  add test case for multiple authors in csl citaiton (JabRef#15707)
  fix invalid desktop file for linux (JabRef#15702)
  Change FileKeystore and Folder fields to disable/enable (JabRef#15685)
  Chore(deps): Bump org.openrewrite.recipe:rewrite-recipe-bom from 3.30.0 to 3.30.1 (JabRef#15696)
  New Crowdin updates (JabRef#15693)
  Chore(deps): Bump dev.langchain4j:langchain4j-bom in /versions (JabRef#15698)
  Chore(deps): Bump org.apache.logging.log4j:log4j-to-slf4j in /versions (JabRef#15700)
  chore(deps): update dependency org.apache.logging.log4j:log4j-to-slf4j to v2.26.0 (JabRef#15699)
  Chore(deps): Bump org.openrewrite.rewrite from 7.32.1 to 7.32.2 (JabRef#15697)
  Chore(deps): Bump jablib/src/main/resources/csl-locales (JabRef#15689)
  Fix month checker regex (JabRef#15678)
  Chore(deps): Bump com.dlsc.gemsfx:gemsfx in /versions (JabRef#15692)
  Chore(deps): Bump org.hisp.dhis:json-tree in /versions (JabRef#15691)
  Chore(deps): Bump jablib/src/main/resources/csl-styles (JabRef#15690)
  New Crowdin updates (JabRef#15687)
  Chore(deps): Bump com.konghq:unirest-java-core in /versions (JabRef#15683)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants