[ 
https://issues.apache.org/jira/browse/FINERACT-2792?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ashhar Ahmad Khan resolved FINERACT-2792.
-----------------------------------------
    Resolution: Fixed

> Add integration test coverage for /v1/email CRUD lifecycle
> ----------------------------------------------------------
>
>                 Key: FINERACT-2792
>                 URL: https://issues.apache.org/jira/browse/FINERACT-2792
>             Project: Apache Fineract
>          Issue Type: Task
>            Reporter: Ashhar Ahmad Khan
>            Priority: Major
>             Fix For: 1.16.0
>
>
> *What is broken*
> {{/v1/email}} has zero test coverage at any layer — no unit tests for 
> {{{}EmailApiResource{}}}, no integration tests in {{{}integration-tests{}}}, 
> no E2E coverage. This was true even after FINERACT-2782 (missing UPDATE 
> handler), FINERACT-2785 (validator checking wrong constants), and 
> FINERACT-2786 (NPE on CREATE) were all found and fixed independently, purely 
> through manual/code inspection rather than any failing test.
> *Why it matters*
> All three of the above bugs made {{/v1/email}} CREATE and UPDATE completely 
> unusable in production, yet none were caught by CI. A single integration test 
> exercising the real HTTP layer end-to-end would have caught all three: the 
> validator bug and NPE on the first CREATE call, and the missing handler on 
> the first UPDATE call.
> *Changes made*
> Added {{EmailTest.java}} to {{{}integration-tests{}}}, covering:
>  * {{testEmailCreateRetrieveUpdateDeleteLifecycle()}} — full CREATE → 
> RETRIEVE → UPDATE → DELETE → RETRIEVE-after-delete (404) flow, against a 
> client with a real {{{}emailAddress{}}}, since {{EmailMessageAssembler}} 
> derives the recipient from the linked client/staff record.
>  * {{testEmailCreateWithStaffIdOnlyDoesNotThrow()}} — confirms {{staffId}} 
> alone (no {{{}clientId{}}}) satisfies validation, per the 
> {{either.clientId.or.staffId.must.be.provided}} rule in 
> {{{}EmailDataValidator{}}}.
>  * {{testEmailCreateWithoutClientOrStaffIdFails()}} — confirms the same rule 
> rejects requests missing both.
> Verified locally end-to-end via Cargo/Tomcat against a real MariaDB instance.
> *Related*
>  * FINERACT-2782 (missing UPDATE command handler, merged)
>  * FINERACT-2785 (validator constants bug, merged)
>  * FINERACT-2786 (NPE on CREATE, merged)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to