Skip to content

Test/cucumber fetch and save#71

Merged
MayuriXx merged 5 commits into
mainfrom
test/cucumber_fetch_and_save
Apr 20, 2026
Merged

Test/cucumber fetch and save#71
MayuriXx merged 5 commits into
mainfrom
test/cucumber_fetch_and_save

Conversation

@profotoce59
Copy link
Copy Markdown
Collaborator

@profotoce59 profotoce59 commented Apr 16, 2026

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

@profotoce59 profotoce59 linked an issue Apr 16, 2026 that may be closed by this pull request
@profotoce59 profotoce59 force-pushed the test/cucumber_fetch_and_save branch from 886067f to 0c753cb Compare April 17, 2026 09:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 StepDefinition to call the endpoint with/without query params and assert response shape/size.
  • Enable method validation and add ConstraintViolationException handling (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.

Comment thread src/test/resources/features/get_random_users.feature
@sonarqube-xpeho
Copy link
Copy Markdown

Copy link
Copy Markdown
Collaborator

@Theo-lbg Theo-lbg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM les tests passent !! ^^

@MayuriXx MayuriXx merged commit 4c0bb39 into main Apr 20, 2026
9 checks passed
@MayuriXx MayuriXx deleted the test/cucumber_fetch_and_save branch April 20, 2026 13:28
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.

Create a cucumber scenario to test the fetch and save endpoint

5 participants