-
Notifications
You must be signed in to change notification settings - Fork 0
feat(cucumberDeleteUser): implement delete user functionality and cor… #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| package com.xpeho.spring_boot_java_random_user.domain.usecases; | ||
|
|
||
| import com.xpeho.spring_boot_java_random_user.domain.services.LocalUserService; | ||
| import com.xpeho.spring_boot_java_random_user.domain.exceptions.UserNotFoundException; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| @Service | ||
|
|
@@ -12,6 +13,7 @@ public DeleteUserByIdUseCase(LocalUserService userService) { | |
| } | ||
|
|
||
| public void execute(long id) { | ||
| userService.getById(id).orElseThrow(() -> new UserNotFoundException(id)); | ||
| userService.deleteById(id); | ||
|
Comment on lines
15
to
17
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -132,7 +132,7 @@ ResponseEntity<List<UserEntity>> filterUsers( | |||||
| @ApiResponse(responseCode = "204", description = "User successfully deleted") | ||||||
| @ApiResponse(responseCode = "404", description = "The requested user does not exist") | ||||||
| @ApiResponse(responseCode = "500", description = "Internal server error") | ||||||
| void deleteUserById( | ||||||
| ResponseEntity<Void> deleteUserById( | ||||||
|
||||||
| ResponseEntity<Void> deleteUserById( | |
| ResponseEntity<Void> deleteUserById( |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,17 @@ | ||||||||||||||
| Feature: Delete user endpoint | ||||||||||||||
|
||||||||||||||
|
|
||||||||||||||
| Scenario: Delete a user successfully after creation | ||||||||||||||
| Given a valid user payload for creation | ||||||||||||||
| When the client call to POST /random-users | ||||||||||||||
| Then the response status should be 201 | ||||||||||||||
| And the user profile | ||||||||||||||
| | id | <generated_id> | | ||||||||||||||
| | firstname | Emma | | ||||||||||||||
| When the client call to DELETE the created user | ||||||||||||||
| Then the response status should be 204 | ||||||||||||||
| When the client call to GET the deleted user | ||||||||||||||
|
Comment on lines
+10
to
+12
|
||||||||||||||
| When the client call to DELETE the created user | |
| Then the response status should be 204 | |
| When the client call to GET the deleted user | |
| When the client call to DELETE /random-users/<generated_id> | |
| Then the response status should be 204 | |
| When the client call to GET /random-users/<generated_id> |
Copilot
AI
Apr 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This scenario uses the step text "When the client call to DELETE /random-users/999", but there is no matching step definition in StepDefinition.java. Add a parameterized @When step for DELETE /random-users/{int} that calls executeDelete("/random-users/" + id).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This use case now calls
userService.getById(id).orElseThrow(...)before deleting. Existing unit tests forDeleteUserByIdUseCasethat don't stubgetByIdwill start failing with aNullPointerException(Mockito returnsnullby default for unstubbed calls returningOptional). Update the tests to stubgetByIdand/or adjust interaction verifications accordingly.