Skip to content

MX-234: Add integration tests for Self Service Transfer to Third Party (TPT) - #130

Merged
IOhacker merged 1 commit into
openMF:developfrom
DeathGun44:MX-234-Add-Transfer-To-Third-Party-Integration-Tests
Apr 12, 2026
Merged

MX-234: Add integration tests for Self Service Transfer to Third Party (TPT)#130
IOhacker merged 1 commit into
openMF:developfrom
DeathGun44:MX-234-Add-Transfer-To-Third-Party-Integration-Tests

Conversation

@DeathGun44

@DeathGun44 DeathGun44 commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

fixes https://mifosforge.jira.com/browse/MX-234

Summary by CodeRabbit

  • Tests
    • Added a new end-to-end integration test for self-service third-party transfers validating permission setup, beneficiary creation, transfer execution, and post-transfer balances.
    • Renamed an existing beneficiary integration test to follow standard integration test naming conventions for consistency.

@coderabbitai

coderabbitai Bot commented Apr 12, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@DeathGun44 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 11 minutes and 43 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 11 minutes and 43 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9ce8961a-a4c7-4165-afa0-4b6ade8f96c4

📥 Commits

Reviewing files that changed from the base of the PR and between dcbd4e7 and ae3c9f9.

📒 Files selected for processing (2)
  • src/test/java/org/apache/fineract/selfservice/account/api/SelfAccountTransferTPTIntegrationTest.java
  • src/test/java/org/apache/fineract/selfservice/account/api/SelfBeneficiaryTPTIntegrationTest.java
📝 Walkthrough

Walkthrough

Adds a new integration test that performs an end-to-end self-service Third-Party Transfer (TPT) flow, including setup/teardown of configuration and permissions, seeding clients/accounts, inserting/authenticating a self-service user, creating a beneficiary, executing the TPT, and asserting balances. Also renames an existing TPT beneficiary test class.

Changes

Cohort / File(s) Summary
New TPT Transfer Integration Test
src/test/java/org/apache/fineract/selfservice/account/api/SelfAccountTransferTPTIntegrationTest.java
Added a comprehensive integration test exercising POST /api/v1/self/accounttransfers?type=tpt. Implements helpers to disable/restore daily TPT limit, grant/restore CREATE_ACCOUNTTRANSFER permission, seed clients and savings accounts (create/open/approve/activate/deposit), insert a self-service DB user and mappings, authenticate, create beneficiary, execute transfer, and verify balances.
Test Class Rename
src/test/java/org/apache/fineract/selfservice/account/api/SelfBeneficiaryTPTIntegrationTest.java
Renamed test class from SelfBeneficiaryTPTIT to SelfBeneficiaryTPTIntegrationTest without functional changes.

Sequence Diagram(s)

(Skipped — changes are test additions and a class rename; no new runtime control flow requiring visualization.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the primary change: adding integration tests for Self Service Transfer to Third Party (TPT), which matches the substantial new test class and supporting infrastructure added in the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

@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.

Actionable comments posted: 4

🧹 Nitpick comments (1)
src/test/java/org/apache/fineract/selfservice/account/api/SelfAccountTransferTPTIntegrationTest.java (1)

197-425: Extract the shared seeding flow into test support.

The client/savings/self-service-user bootstrap here overlaps heavily with src/test/java/org/apache/fineract/selfservice/account/api/SelfBeneficiaryTPTIntegrationTest.java, especially the direct user seeding and authentication path. Pull that fixture code into org.apache.fineract.selfservice.testing.support so these tests only describe scenario-specific setup and assertions.

As per coding guidelines, **: Apply DRY, SOLID, and Clean Architecture principles.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/test/java/org/apache/fineract/selfservice/account/api/SelfAccountTransferTPTIntegrationTest.java`
around lines 197 - 425, Extract the duplicated seeding/bootstrap logic
(seedClientWithFundedSavings, seedClientWithActiveSavings,
createClientAndExtract, createZeroFeeSavingsProduct, openSavingsAccount,
approveSavingsAccount, activateSavingsAccount, depositToSavingsAccount,
insertSelfServiceUserDirectly, authenticateSelfUser) into a new test support
class under package org.apache.fineract.selfservice.testing.support (e.g.,
SelfServiceTestFixture) and implement reusable methods for client creation,
savings product/account lifecycle, DB self-service user insertion and
authentication; refactor both SelfAccountTransferTPTIntegrationTest and
SelfBeneficiaryTPTIntegrationTest to call these support methods (passing in
parameters like label, today) so tests only perform scenario-specific
actions/assertions and delete the duplicated private helper methods from the
tests. Ensure the support class uses the existing SelfServiceTestUtils helpers
and preserves current behavior and exceptions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/test/java/org/apache/fineract/selfservice/account/api/SelfAccountTransferTPTIntegrationTest.java`:
- Around line 178-195: The grantTransferPermissionToSelfServiceRole method
mutates the shared role; update it to snapshot the role's existing permissions
before modifying and restore them after the test (use try/finally or test
teardown). Specifically: call the ADMIN_ROLES_PATH GET (using
SELF_SERVICE_USER_ROLE to locate roleId) to extract the current permissions map,
then PUT the modified permissions (adding CREATE_ACCOUNTTRANSFER) for the test,
and in the finally/teardown PUT the original permissions map back to
ADMIN_ROLES_PATH + "/" + roleId + "/permissions to restore state. Ensure the
snapshot variable is local to this method and that restoration runs even if
assertions fail.
- Around line 149-176: The test helper disableDailyTptLimit currently flips the
global "daily-tpt-limit" config without restoring it; modify it to read and
store the original configuration value (the enabled flag and/or full config
object) when querying ADMIN_CONFIGURATIONS_PATH, then disable it, and ensure the
original value is restored in a finally block or an `@AfterEach` teardown; update
the method (disableDailyTptLimit) to either return the original state or make a
paired restoreDailyTptLimit(original) method and call that in test cleanup so
the global state is reset after the test.
- Around line 348-416: The method insertSelfServiceUserDirectly currently uses a
plain JDBC Connection (conn) with auto-commit on, causing each INSERT to commit
independently; disable auto-commit on conn (conn.setAutoCommit(false)) before
running the multiple INSERTs, call conn.commit() after all statements succeed,
and ensure conn.rollback() is invoked in the exception path (or a finally block)
to revert partial changes; update the try-with-resources structure around
Connection/PreparedStatement/ResultSet so the transaction boundaries are managed
for the sequence of statements (INSERT INTO m_appuser, m_appuser_role,
m_appselfservice_user, m_appselfservice_user_role,
m_selfservice_user_client_mapping) and rethrow the original exception as
currently done.
- Around line 35-36: The test uses JVM defaults for locale/timezone causing
flaky month names and date offsets; update SelfAccountTransferTPTIntegrationTest
to pin both: change FORMATTER to DateTimeFormatter.ofPattern(DATE_FORMAT,
Locale.ENGLISH) and ensure any date construction/formatting uses UTC (e.g., use
ZonedDateTime.now(ZoneOffset.UTC) or LocalDate.now(ZoneId.of("UTC")) when
producing the request date) so DATE_FORMAT and FORMATTER produce consistent
English month names and UTC-based dates.

---

Nitpick comments:
In
`@src/test/java/org/apache/fineract/selfservice/account/api/SelfAccountTransferTPTIntegrationTest.java`:
- Around line 197-425: Extract the duplicated seeding/bootstrap logic
(seedClientWithFundedSavings, seedClientWithActiveSavings,
createClientAndExtract, createZeroFeeSavingsProduct, openSavingsAccount,
approveSavingsAccount, activateSavingsAccount, depositToSavingsAccount,
insertSelfServiceUserDirectly, authenticateSelfUser) into a new test support
class under package org.apache.fineract.selfservice.testing.support (e.g.,
SelfServiceTestFixture) and implement reusable methods for client creation,
savings product/account lifecycle, DB self-service user insertion and
authentication; refactor both SelfAccountTransferTPTIntegrationTest and
SelfBeneficiaryTPTIntegrationTest to call these support methods (passing in
parameters like label, today) so tests only perform scenario-specific
actions/assertions and delete the duplicated private helper methods from the
tests. Ensure the support class uses the existing SelfServiceTestUtils helpers
and preserves current behavior and exceptions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 223b223d-24ee-4fa2-a3cd-73c993280a76

📥 Commits

Reviewing files that changed from the base of the PR and between 46d6cb6 and e8b909a.

📒 Files selected for processing (2)
  • src/test/java/org/apache/fineract/selfservice/account/api/SelfAccountTransferTPTIntegrationTest.java
  • src/test/java/org/apache/fineract/selfservice/account/api/SelfBeneficiaryTPTIntegrationTest.java

@DeathGun44
DeathGun44 force-pushed the MX-234-Add-Transfer-To-Third-Party-Integration-Tests branch from e8b909a to dcbd4e7 Compare April 12, 2026 08:26

@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.

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/test/java/org/apache/fineract/selfservice/account/api/SelfAccountTransferTPTIntegrationTest.java (2)

35-35: Rename the integration test class to *IT (and file accordingly).

Use the integration-test naming pattern to align with repository test standards.

As per coding guidelines, src/test/java/**: Name tests ClassNameTest or ClassNameIT (for integration).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/test/java/org/apache/fineract/selfservice/account/api/SelfAccountTransferTPTIntegrationTest.java`
at line 35, Rename the test class SelfAccountTransferTPTIntegrationTest to
follow the integration-test pattern by changing the class name to
SelfAccountTransferTPTIT and renaming the file accordingly; update the class
declaration (class SelfAccountTransferTPTIT extends
SelfServiceIntegrationTestBase), rename the Java file to match the new class
name, and update any references/imports/usages (test suites, CI configs, or
other classes referencing SelfAccountTransferTPTIntegrationTest) to the new
identifier so compilation and test discovery continue to work.

10-11: Use AssertJ assertions instead of JUnit Assertions/Hamcrest in test assertions.

This class mixes JUnit Assertions and Hamcrest matchers; switch assertions to AssertJ for consistency with project testing standards.

As per coding guidelines, src/test/java/**: Use JUnit 5, Mockito, and AssertJ.

Also applies to: 31-31, 122-149

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/test/java/org/apache/fineract/selfservice/account/api/SelfAccountTransferTPTIntegrationTest.java`
around lines 10 - 11, The test class SelfAccountTransferTPTIntegrationTest
currently uses JUnit Assertions and Hamcrest (e.g., static import equalTo) —
replace those with AssertJ: remove Hamcrest and JUnit assert imports and add
org.assertj.core.api.Assertions.assertThat; convert patterns like
assertThat(actual, equalTo(expected)) or Assertions.assertEquals(expected,
actual) to assertThat(actual).isEqualTo(expected), and replace other Hamcrest
matchers with the equivalent AssertJ fluent assertions
(isTrue/isFalse/isNotNull/contains/...); apply these changes across all
assertions in this class (including assertions referenced around the other
occurrences) so the tests consistently use AssertJ.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@src/test/java/org/apache/fineract/selfservice/account/api/SelfAccountTransferTPTIntegrationTest.java`:
- Around line 58-61: The setup mutates global state before the try block (calls
to disableDailyTptLimit() and grantTransferPermissionToSelfServiceRole()), so if
either fails the corresponding restoration never runs; move the state-mutation
calls into a protected section and ensure both
restoreDailyTptLimit(originalTptLimit) and
restoreTransferPermission(originalPermission) are invoked from a finally block
that always executes (and call each restore inside its own try/catch so a
failure in one does not prevent the other). Update
SelfAccountTransferTPTIntegrationTest to capture the original values, perform
mutations inside the try, and in finally attempt both restoreDailyTptLimit and
restoreTransferPermission regardless of earlier failures, logging or swallowing
individual restore exceptions so both are attempted.
- Around line 53-154: Add at least one negative integration test in
SelfAccountTransferTPTIntegrationTest (e.g., new method
transferToThirdParty_exceedsBeneficiaryLimit_returns4xx or
transferToThirdParty_insufficientBalance_returns4xx) that follows the same setup
steps as transferToThirdParty_movesExpectedFunds_returns200 (use
seedClientWithFundedSavings/seedClientWithActiveSavings,
insertSelfServiceUserDirectly, authenticateSelfUser, create a beneficiary via
BENEFICIARIES_PATH) but modifies the scenario to fail (set
beneficiary.transferLimit smaller than transferAmount, or revoke permission via
restoreTransferPermission/grantTransferPermissionToSelfServiceRole, or use a
sender with insufficient balance), perform the POST to ACCOUNT_TRANSFERS_PATH +
"?type=tpt", assert the expected error status code and message, and verify
balances remain unchanged; ensure you clean up by restoring DailyTptLimit and
permissions with restoreDailyTptLimit/restoreTransferPermission as in the
existing test.

---

Nitpick comments:
In
`@src/test/java/org/apache/fineract/selfservice/account/api/SelfAccountTransferTPTIntegrationTest.java`:
- Line 35: Rename the test class SelfAccountTransferTPTIntegrationTest to follow
the integration-test pattern by changing the class name to
SelfAccountTransferTPTIT and renaming the file accordingly; update the class
declaration (class SelfAccountTransferTPTIT extends
SelfServiceIntegrationTestBase), rename the Java file to match the new class
name, and update any references/imports/usages (test suites, CI configs, or
other classes referencing SelfAccountTransferTPTIntegrationTest) to the new
identifier so compilation and test discovery continue to work.
- Around line 10-11: The test class SelfAccountTransferTPTIntegrationTest
currently uses JUnit Assertions and Hamcrest (e.g., static import equalTo) —
replace those with AssertJ: remove Hamcrest and JUnit assert imports and add
org.assertj.core.api.Assertions.assertThat; convert patterns like
assertThat(actual, equalTo(expected)) or Assertions.assertEquals(expected,
actual) to assertThat(actual).isEqualTo(expected), and replace other Hamcrest
matchers with the equivalent AssertJ fluent assertions
(isTrue/isFalse/isNotNull/contains/...); apply these changes across all
assertions in this class (including assertions referenced around the other
occurrences) so the tests consistently use AssertJ.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0054240a-d559-4cf8-afd9-849d4febc139

📥 Commits

Reviewing files that changed from the base of the PR and between e8b909a and dcbd4e7.

📒 Files selected for processing (2)
  • src/test/java/org/apache/fineract/selfservice/account/api/SelfAccountTransferTPTIntegrationTest.java
  • src/test/java/org/apache/fineract/selfservice/account/api/SelfBeneficiaryTPTIntegrationTest.java
✅ Files skipped from review due to trivial changes (1)
  • src/test/java/org/apache/fineract/selfservice/account/api/SelfBeneficiaryTPTIntegrationTest.java

@DeathGun44
DeathGun44 force-pushed the MX-234-Add-Transfer-To-Third-Party-Integration-Tests branch from dcbd4e7 to 6fe0ab2 Compare April 12, 2026 08:32
…y (TPT)

- Explicitly specify UTC timezone and format locale for API dates
- Extract Beneficiary creation and validation boundaries
- Manage state cleanly by storing/restoring global configs and privileges
- Implement explicitly bounded JDBC transactions for local database seeding
- Add out-of-bounds transfer edge case coverage
@DeathGun44
DeathGun44 force-pushed the MX-234-Add-Transfer-To-Third-Party-Integration-Tests branch from 6fe0ab2 to ae3c9f9 Compare April 12, 2026 08:33

@IOhacker IOhacker left a comment

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.

LGTM

@IOhacker
IOhacker merged commit 8de06be into openMF:develop Apr 12, 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