KRYSTALM7 opened a new pull request, #22: URL: https://github.com/apache/fineract-loan-origination/pull/22
## FINERACT-2442 — Loan Origination State Machine Implements the core state machine, with full unit test coverage. ### Components Added **LoanStateTransitionException** - Unchecked exception thrown on invalid transition attempts - Carries fromStatus and toStatus for precise error reporting - Mapped to HTTP 409 Conflict by the global exception handler **LoanStateTransitionValidator** - Single source of truth for all permitted transitions - Uses EnumMap + EnumSet for O(1) lookup performance - Adding a new transition requires one line change only **LoanOriginationStateMachine** - Only component permitted to call LoanApplication#setStatus - Stateless — concurrency safety delegated to @Version on entity - Guard clause pattern — terminal state checked before validation - Every transition logged at INFO, every rejection at WARN ### Valid Transitions Implemented DRAFT → SUBMITTED SUBMITTED → UNDER_REVIEW UNDER_REVIEW → APPROVED UNDER_REVIEW → REJECTED UNDER_REVIEW → REFERRED REFERRED → UNDER_REVIEW APPROVED → DISBURSED ### Unit Tests **LoanOriginationStateMachineTest** — 25 tests - All 7 valid transitions verified - 9 invalid transitions verified - Terminal state guard for REJECTED and DISBURSED - permittedTransitions query coverage - Null input guards - Status mutation in-place verification - Failed transition does not mutate status - Full DRAFT → DISBURSED sequential flow - REFER and re-review cycle **LoanStateTransitionValidatorTest** — 20 parameterized cases - All valid and invalid transitions in one parameterized test - permittedTransitions coverage for terminal and non-terminal states No Spring context loaded — pure unit tests, runs in milliseconds. ### Related - JIRA: https://issues.apache.org/jira/browse/FINERACT-2442 - Depends on: domain enums and entities -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
