Test/cucumber fetch and save#71
Merged
Merged
Conversation
…rn a 500 when the fetching size is too big
886067f to
0c753cb
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Cucumber coverage for the GET /random-users endpoint and introduces supporting validation/error-handling changes in the presentation layer to return 400s for invalid pagination inputs.
Changes:
- Add a new Gherkin feature covering default pagination, custom pagination, and invalid page size for
GET /random-users. - Extend Cucumber
StepDefinitionto call the endpoint with/without query params and assert response shape/size. - Enable method validation and add
ConstraintViolationExceptionhandling (plus a unit test) for 400 error responses.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/resources/features/get_random_users.feature | New Cucumber scenarios for fetching random users and invalid pagination. |
| src/test/java/feature/StepDefinition.java | Adds step definitions for GET list calls and basic JSON assertions on data. |
| src/test/java/com/xpeho/spring_boot_java_random_user/presentation/exceptions/GlobalExceptionHandlerTest.java | Adds unit test coverage for the new constraint-violation handler behavior. |
| src/main/java/com/xpeho/spring_boot_java_random_user/presentation/handlers/UserHandler.java | Enables method validation and adjusts logging behavior. |
| src/main/java/com/xpeho/spring_boot_java_random_user/presentation/exceptions/GlobalExceptionHandler.java | Adds ConstraintViolationException -> 400 error mapping. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
MayuriXx
approved these changes
Apr 17, 2026
Theo-lbg
approved these changes
Apr 17, 2026
Collaborator
Theo-lbg
left a comment
There was a problem hiding this comment.
LGTM les tests passent !! ^^
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.




Tests
New Cucumber scenarios: default params, custom page/size, size above max, page/size below min
Assert HTTP status and error code in error responses
Remove unit test for manual pagination validation (no longer applicable without Spring AOP context)
Exception handling
UserHandler: remove redundant manual page/size checks, rely on @validated + @Min/@max from the interface
GlobalExceptionHandler: ConstraintViolationException now returns INVALID_PAGINATION instead of INVALID_PARAMETER to keep a consistent API contract
Logger: pass exception as last argument to preserve stack trace