FINERACT-2086: Fix ClassCastException in AccountAssociations and add unit tests

- Simplified conversion using Number.intValue() to handle Short and Integer types.
- Removed redundant null checks as per feedback.
- Added unit tests for type-safety verification.
This commit is contained in:
Kengne-yvana
2026-01-16 22:18:05 +01:00
committed by Adam Saghy
parent 0891adb267
commit 44b6b29dc5
2 changed files with 81 additions and 1 deletions
@@ -99,7 +99,9 @@ public class AccountAssociationsReadPlatformServiceImpl implements AccountAssoci
final List<Map<String, Object>> statusList = this.jdbcTemplate.queryForList(sql1, savingsId);
for (final Map<String, Object> statusMap : statusList) {
AccountAssociationType associationType = AccountAssociationType.fromInt((Integer) statusMap.get("type"));
// Direct conversion using Number handles both Short and Integer safely
final Integer typeValue = ((Number) statusMap.get("type")).intValue();
final AccountAssociationType associationType = AccountAssociationType.fromInt(typeValue);
if (!associationType.isLinkedAccountAssociation() && (Boolean) statusMap.get("active")) {
hasActiveAccount = true;
break;