Skip to content

test: migrate remaining JUnit 4 Assert calls to Jupiter Assertions#1325

Merged
joaodinissf merged 1 commit into
dsldevkit:masterfrom
joaodinissf:chore/junit4-assert-migration-step-2-follow-up
May 6, 2026
Merged

test: migrate remaining JUnit 4 Assert calls to Jupiter Assertions#1325
joaodinissf merged 1 commit into
dsldevkit:masterfrom
joaodinissf:chore/junit4-assert-migration-step-2-follow-up

Conversation

@joaodinissf
Copy link
Copy Markdown
Collaborator

@joaodinissf joaodinissf commented Apr 30, 2026

Summary

Migrates the ten surviving helper / utility classes that still imported org.junit.Assert.* to Jupiter's org.junit.jupiter.api.Assertions. No production source file in DDK references org.junit.Assert.

What's changed

10 helper files migrated:

  • com.avaloq.tools.ddk.test.core: ServiceMock, ExtensionRegistryMock, SimpleProgressMonitor, JobMatcher
  • com.avaloq.tools.ddk.test.ui: SwtBotWizardUtil, SwtWizardBot, CoreSwtbotTools
  • com.avaloq.tools.ddk.xtext.test.core: ModelUtil, AcfContentAssistProcessorTestBuilder, jupiter/AbstractAcfContentAssistTest

Argument order swapped at every call site: Jupiter takes the optional message last (assertTrue(condition, message) etc.), JUnit 4 took it first. Concretely:

- Assert.assertEquals("Wrong number of jobs were scheduled", expected, newJobs.size());
+ Assertions.assertEquals(expected, newJobs.size(), "Wrong number of jobs were scheduled");

Bonus correctness fix

jupiter/AbstractAcfContentAssistTest had a latent argument-order bug: it imported org.junit.Assert.assertFalse / assertNotEquals / fail statically (still JUnit 4) but called them with the JUnit 4 message-first order. The class compiled because the simple names match between the two libraries. Switching the static imports to Jupiter and fixing the argument order at each call site means the messages are now actually attached to the failures rather than being interpreted as the condition / expected value.

MANIFEST update

com.avaloq.tools.ddk.test.ui's Require-Bundle was missing junit-jupiter-api. Added it.

Verification

Local mvn verify (macOS aarch64): 307 tests / 0 failures / 0 errors / 1 skipped, BUILD SUCCESS.

🤖 Generated with Claude Code

The dead-code deletion in the prior commit removed every JUnit-4 test
class but kept ten helper / utility classes still using
org.junit.Assert.* statics. Migrate each call site to
org.junit.jupiter.api.Assertions.

Note the argument-order swap: Jupiter assertion methods take
(condition, [message]) or (expected, actual, [message]) - the
optional message moves to LAST position.

Files migrated:
  com.avaloq.tools.ddk.test.core/src/.../mock/ServiceMock.java
  com.avaloq.tools.ddk.test.core/src/.../mock/ExtensionRegistryMock.java
  com.avaloq.tools.ddk.test.core/src/.../util/SimpleProgressMonitor.java
  com.avaloq.tools.ddk.test.core/src/.../util/JobMatcher.java
  com.avaloq.tools.ddk.test.ui/src/.../swtbot/util/SwtBotWizardUtil.java
  com.avaloq.tools.ddk.test.ui/src/.../swtbot/SwtWizardBot.java
  com.avaloq.tools.ddk.test.ui/src/.../swtbot/CoreSwtbotTools.java
  com.avaloq.tools.ddk.xtext.test.core/src/.../model/ModelUtil.java
  com.avaloq.tools.ddk.xtext.test.core/src/.../AcfContentAssistProcessorTestBuilder.java

Bonus fix: jupiter/AbstractAcfContentAssistTest still imported
org.junit.Assert.assertFalse / assertNotEquals / fail (the JUnit 4
twins of Jupiter's same-named statics). The Java compiler accepted
this because the import names happen to match Jupiter symbols, but
the call-sites used the JUnit 4 message-FIRST argument order, so the
intended message was being passed as `unexpected`/`condition`. Switch
the static imports to org.junit.jupiter.api.Assertions.* and fix the
argument order at each call site.

MANIFEST fix: com.avaloq.tools.ddk.test.ui's Require-Bundle was
missing junit-jupiter-api, so the static-import-only call sites in
SwtWizardBot/CoreSwtbotTools/SwtBotWizardUtil hit "Access restriction:
The type 'Assertions' is not API". Added junit-jupiter-api to the
bundle's Require-Bundle.

Verified locally: tests=357 failures=0 errors=0 - first BUILD SUCCESS
on this branch since rebasing onto the step-1.5 fix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@joaodinissf joaodinissf force-pushed the chore/junit4-assert-migration-step-2-follow-up branch from d28ca4d to 425c26f Compare May 6, 2026 09:49
@joaodinissf joaodinissf enabled auto-merge (rebase) May 6, 2026 09:57
@joaodinissf joaodinissf merged commit 20ce2e9 into dsldevkit:master May 6, 2026
4 checks passed
@joaodinissf joaodinissf deleted the chore/junit4-assert-migration-step-2-follow-up branch May 19, 2026 13:21
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.

2 participants