Skip to content

fix(MX-384): update enrollment and transfer test setup - #183

Merged
IOhacker merged 1 commit into
openMF:developfrom
AnvayKharb:fix/MX-381-transfer-source-idor
Aug 1, 2026
Merged

fix(MX-384): update enrollment and transfer test setup#183
IOhacker merged 1 commit into
openMF:developfrom
AnvayKharb:fix/MX-381-transfer-source-idor

Conversation

@AnvayKharb

@AnvayKharb AnvayKharb commented Aug 1, 2026

Copy link
Copy Markdown
Member

Summary

  • Add missing date utility mocks/stubs for self account transfer tests
  • Stub tenant-aware registration time and fixed expiry in registration tests
  • Keep MX-384 scoped to test setup only

Tests

  • ./mvnw -Dtest=SelfAccountTransferWritePlatformServiceImplTest test (selected tests pass; JaCoCo gate fails due targeted coverage)
  • ./mvnw -Dtest=SelfServiceRegistrationWritePlatformServiceImplTest test (selected tests pass; JaCoCo gate fails due targeted coverage)
  • ./mvnw -Dtest=SelfAccountTransferWritePlatformServiceImplTest,SelfServiceRegistrationWritePlatformServiceImplTest test (34 selected tests pass; JaCoCo gate fails due targeted coverage)
  • ./mvnw -Dtest=SelfAccountTransferWritePlatformServiceImplTest,SelfServiceRegistrationWritePlatformServiceImplTest -Djacoco.skip=true test (pass)

Summary by CodeRabbit

  • Tests
    • Improved test reliability by using deterministic transaction and registration timestamps.
    • Added consistent tenant-context setup and cleanup across service tests.
    • Stabilized token-expiry verification with fixed expected values.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@AnvayKharb, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 50 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8854a823-cdac-4ada-8394-8f46e487afed

📥 Commits

Reviewing files that changed from the base of the PR and between 2648d20 and 3ac85bd.

📒 Files selected for processing (5)
  • src/test/java/org/apache/fineract/selfservice/account/service/SelfAccountTransferWritePlatformServiceImplTest.java
  • src/test/java/org/apache/fineract/selfservice/registration/domain/SelfServiceRegistrationTest.java
  • src/test/java/org/apache/fineract/selfservice/registration/service/ExpiredTokenPurgeServiceTest.java
  • src/test/java/org/apache/fineract/selfservice/registration/service/SelfServiceForgotPasswordWritePlatformServiceImplTest.java
  • src/test/java/org/apache/fineract/selfservice/registration/service/SelfServiceRegistrationWritePlatformServiceImplTest.java
📝 Walkthrough

Walkthrough

The tests now initialize tenant context and use fixed transaction dates. Account transfer tests mock transaction-date services and reset thread-local tenant state. Registration tests stub fixed creation and token-expiry timestamps.

Changes

Self-service test determinism

Layer / File(s) Summary
Account transfer date and tenant fixture
src/test/java/org/apache/fineract/selfservice/account/service/SelfAccountTransferWritePlatformServiceImplTest.java
The test mocks transaction-date services, uses fixed dates, initializes a default tenant, and resets tenant context after each test.
Registration persistence date fixture
src/test/java/org/apache/fineract/selfservice/registration/service/SelfServiceRegistrationWritePlatformServiceImplTest.java
The test initializes a default platform tenant and stubs fixed creation and token-expiry timestamps.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: ⏱️ <10 Min Review

Suggested reviewers: iohacker

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the enrollment and transfer test setup changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
src/test/java/org/apache/fineract/selfservice/account/service/SelfAccountTransferWritePlatformServiceImplTest.java (1)

15-15: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Use the Fineract transfer date constants in the date stub.

getCurrentDateForFineract(...) is only called from this service with FINERACT_TRANSFER_DATE_FORMAT and FINERACT_TRANSFER_LOCALE in this PR code, and these constants are already available in the class under test and the test file. Replace the generic anyString() matchers with eq(FINERACT_TRANSFER_DATE_FORMAT, FINERACT_TRANSFER_LOCALE) so the stub matches the real caller contract and rejects unexpected argument changes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/test/java/org/apache/fineract/selfservice/account/service/SelfAccountTransferWritePlatformServiceImplTest.java`
at line 15, Update the date stubbing in
SelfAccountTransferWritePlatformServiceImplTest to match
getCurrentDateForFineract with the specific FINERACT_TRANSFER_DATE_FORMAT and
FINERACT_TRANSFER_LOCALE constants using eq matchers, replacing the generic
anyString matcher while preserving the service’s caller contract.
src/test/java/org/apache/fineract/selfservice/registration/service/SelfServiceRegistrationWritePlatformServiceImplTest.java (1)

230-233: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Make the timestamp stubs verify the date flow.

calculateExpiry(any()) returns expectedExpiry for every argument. The test can therefore miss an incorrect creation timestamp or missing timestamp persistence. Match createdAt exactly and verify the saved registration contains createdAt and expectedExpiry.

Proposed matcher change
-    when(selfServiceAuthorizationTokenService.calculateExpiry(any())).thenReturn(expectedExpiry);
+    when(selfServiceAuthorizationTokenService.calculateExpiry(eq(createdAt)))
+        .thenReturn(expectedExpiry);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/test/java/org/apache/fineract/selfservice/registration/service/SelfServiceRegistrationWritePlatformServiceImplTest.java`
around lines 230 - 233, Update the timestamp stubs in
SelfServiceRegistrationWritePlatformServiceImplTest to make calculateExpiry
match the exact createdAt value instead of any argument, then verify the
persisted registration uses createdAt as its creation timestamp and
expectedExpiry as its expiry timestamp. Preserve the existing test flow while
asserting both values on the saved registration.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@src/test/java/org/apache/fineract/selfservice/account/service/SelfAccountTransferWritePlatformServiceImplTest.java`:
- Line 15: Update the date stubbing in
SelfAccountTransferWritePlatformServiceImplTest to match
getCurrentDateForFineract with the specific FINERACT_TRANSFER_DATE_FORMAT and
FINERACT_TRANSFER_LOCALE constants using eq matchers, replacing the generic
anyString matcher while preserving the service’s caller contract.

In
`@src/test/java/org/apache/fineract/selfservice/registration/service/SelfServiceRegistrationWritePlatformServiceImplTest.java`:
- Around line 230-233: Update the timestamp stubs in
SelfServiceRegistrationWritePlatformServiceImplTest to make calculateExpiry
match the exact createdAt value instead of any argument, then verify the
persisted registration uses createdAt as its creation timestamp and
expectedExpiry as its expiry timestamp. Preserve the existing test flow while
asserting both values on the saved registration.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: bee6b771-f4f6-47b0-ba35-e9d66772317e

📥 Commits

Reviewing files that changed from the base of the PR and between 42e6af0 and 2648d20.

📒 Files selected for processing (2)
  • src/test/java/org/apache/fineract/selfservice/account/service/SelfAccountTransferWritePlatformServiceImplTest.java
  • src/test/java/org/apache/fineract/selfservice/registration/service/SelfServiceRegistrationWritePlatformServiceImplTest.java

@AnvayKharb
AnvayKharb force-pushed the fix/MX-381-transfer-source-idor branch from 2648d20 to 3ac85bd Compare August 1, 2026 09:24
@IOhacker
IOhacker merged commit f6f6298 into openMF:develop Aug 1, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants