Add comprehensive @WebMvcTest for PatronProfileController #20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add comprehensive @WebMvcTest for PatronProfileController
Summary
This PR adds comprehensive unit tests for the
PatronProfileControllerREST API, which previously had zero test coverage despite being a critical 189-line controller handling all patron profile operations.Changes:
PatronProfileControllerTest.groovywith 15 test cases covering all 7 HTTP endpointsPatronProfiles,PlacingOnHold,CancelingHold) are properly mocked using@MockBeanTest Coverage:
/profiles/{patronId}- patron profile with HATEOAS links/profiles/{patronId}/holds/- holds collection (with/without data)/profiles/{patronId}/holds/{bookId}- specific hold (200/404)/profiles/{patronId}/checkouts/- checkouts collection (with/without data)/profiles/{patronId}/checkouts/{bookId}- specific checkout (200/404)/profiles/{patronId}/holds- place hold (200/500)/profiles/{patronId}/holds/{bookId}- cancel hold (204/404/500)Technical Notes:
@WebMvcTest(PatronProfileController.class)for focused controller testing@Import(WebConfiguration.class)for HATEOAS support (WebConfiguration is excluded by default in @WebMvcTest)when().thenReturn()API for mocking (not Spock's>>) because@MockBeancreates Mockito mocksReview & Testing Checklist for Human
mvn test -Dtest=PatronProfileControllerTestto verify all 15 tests passTry.success(),Try.failure(),Option.some(),Option.none())Notes
@MockBeanrequirementsLink to Devin run: https://app.devin.ai/sessions/7cd5d6d1d4ca463f9b509eeeb5246aad
Requested by: @callummiles