Skip to content

[Misc] Use assertEquals/assertNotEquals instead of boolean assertions in bridge and eventstream-api tests (SonarCloud java:S5785)#5824

Open
vmassol wants to merge 1 commit into
masterfrom
claude/vigilant-dirac-d5hd3s
Open

[Misc] Use assertEquals/assertNotEquals instead of boolean assertions in bridge and eventstream-api tests (SonarCloud java:S5785)#5824
vmassol wants to merge 1 commit into
masterfrom
claude/vigilant-dirac-d5hd3s

Conversation

@vmassol

@vmassol vmassol commented Jul 12, 2026

Copy link
Copy Markdown
Member

Summary

Mechanical, behaviour-preserving cleanup of SonarCloud rule java:S5785 ("Fix this assertion to correctly compare these two values") across two modules. 31 issues fixed in 3 test files.

Using a dedicated equality assertion instead of a boolean one makes a test failure report the actual and expected values instead of just expected: <true> but was: <false>.

Details

  • assertTrue(a.equals(b))assertEquals(a, b)
  • assertFalse(a.equals(b))assertNotEquals(a, b)
  • assertTrue(x == 0)assertEquals(0, x) and assertTrue(x != 0)assertNotEquals(0, x) (hashCode checks)

The receiver is kept as the first argument (assertEquals(receiver, arg) calls receiver.equals(arg)) so the exact equals() direction of each original assertion is preserved. This matters in ActionExecutingEventTest.doesntEqualDifferentTypeOfAction, which compares an ActionExecutingEvent against an ActionExecutedEvent (a different type).

Static imports adjusted accordingly: assertNotEquals added to ActionExecutingEventTest; the now-unused assertTrue/assertFalse removed from AbstractRecordableEventDescriptorTest; SimpleEventQueryTest keeps both (still used elsewhere).

No production code changed; only test assertions.

Files:

  • xwiki-platform-bridgeActionExecutingEventTest (14)
  • xwiki-platform-eventstream-apiSimpleEventQueryTest (12), AbstractRecordableEventDescriptorTest (5)

All fixed issues belong to SonarCloud rule java:S5785. See the open S5785 issues for this project.

Test plan

  • mvn clean install -Plegacy,snapshot on xwiki-platform-bridge and xwiki-platform-eventstream-api with tests — BUILD SUCCESS (all tests pass, Checkstyle passes). Building with tests confirms the receiver-first operand ordering preserves each assertion's semantics.

Generated by Claude Code

… in bridge and eventstream-api tests (SonarCloud java:S5785)

Replace assertTrue(a.equals(b))/assertFalse(a.equals(b)) and
assertTrue(x == 0)/assertTrue(x != 0) with assertEquals/assertNotEquals so
that a failure reports the actual and expected values. The receiver is kept
as the first argument to preserve the exact equals() direction (matters for
the cross-type comparison against ActionExecutedEvent).

Co-Authored-By: Vincent Massol <vincent@massol.net>
@vmassol vmassol added the llm-agent To be used for PRs created autonomously by LLM agents. label Jul 12, 2026 — with Claude
@vmassol vmassol self-assigned this Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llm-agent To be used for PRs created autonomously by LLM agents.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant