Skip to content

Feature/ft categories on off authorization#14

Merged
soraiayugulis merged 4 commits into
mainfrom
feature/ft-categories-on-off-authorization
Jun 12, 2026
Merged

Feature/ft categories on off authorization#14
soraiayugulis merged 4 commits into
mainfrom
feature/ft-categories-on-off-authorization

Conversation

@soraiayugulis

Copy link
Copy Markdown
Owner

Summary

Phase 2 of the ft-categories-on-off feature — authorization rule enforcement with category status checks. Implements Rule 4 (Category Active Check) and Rule 5 (Fallback Chain Skips Inactive Categories) from the specification.

Changes

Authorization Service

  • AuthorizationService.java: Added category status check before balance check. If requested category is INACTIVE, returns CATEGORY_INACTIVE rejection reason without modifying balance.

Category Balance Checker

  • CategoryBalanceChecker.java:
    • Changed signature from checkBalance(Map<Category, Balance>, Category, BigDecimal) to checkBalance(Card, Category, BigDecimal)
    • Added category status check for requested category (returns empty if INACTIVE)
    • Modified fallback loop to skip categories where getCategoryStatus(fallback) == INACTIVE
    • Added private getBalances(Card) helper method

Tests

  • AuthorizationServiceTest.java:

    • Added test for category inactive check (TC-007): transaction denied with CATEGORY_INACTIVE when category is inactive, balance unchanged
    • Added test for active category (TC-008): transaction proceeds to balance check when category is active
    • Added test for MEAL fallback skipping inactive FOOD (TC-014): FOOD skipped when inactive, GENERAL used instead
  • CategoryBalanceCheckerTest.java:

    • Updated all tests to use Card instead of Map<Category, Balance>
    • All existing tests continue to pass with new signature

Notes

  • TDD Approach: All changes followed red-green-refactor cycle
  • Signature Change: CategoryBalanceChecker.checkBalance now receives Card instead of balances map to enable category status checks
  • Fallback Behavior: MEAL fallback chain now skips inactive categories; if all fallback categories are inactive, transaction is denied with INSUFFICIENT_BALANCE
  • No Balance Modification: When category is inactive, balance is not modified (verified in test)
  • All Tests Pass: 138 tests passing

Checklist

  • Category status check enforced before balance check in AuthorizationService
  • CategoryBalanceChecker modified to receive Card and check category status
  • Fallback loop skips inactive categories
  • Test for category inactive check (TC-007)
  • Test for active category proceeding to balance check (TC-008)
  • Test for MEAL fallback skipping inactive FOOD (TC-014)
  • All 138 tests passing

@soraiayugulis soraiayugulis self-assigned this Jun 12, 2026
@soraiayugulis soraiayugulis merged commit 23d7ec7 into main Jun 12, 2026
2 checks passed
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.

1 participant