refactor: migrate validations from services to controllers#183
refactor: migrate validations from services to controllers#183nanotaboada merged 1 commit intomasterfrom
Conversation
WalkthroughThe changes refactor the book management API and its supporting layers to streamline validation, response handling, and testing. Controller methods now rely on validation annotations and simplified service calls, returning more appropriate HTTP statuses and headers. The service layer removes manual validation logic, focusing on repository existence checks and CRUD operations. Supporting test utilities are renamed for clarity, and all tests are updated to use the new method and class names. Test logic is revised to align with the updated service and controller flows, removing validation mocks and focusing on repository interactions and response codes. Editor settings are also updated to disable Java inlay hints. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant BooksController
participant BooksService
participant BooksRepository
Client->>BooksController: POST /books (BookDTO)
BooksController->>BooksService: create(BookDTO)
BooksService->>BooksRepository: existsById(isbn)
alt Book exists
BooksService-->>BooksController: false
BooksController-->>Client: 409 Conflict
else Book does not exist
BooksService->>BooksRepository: save(Book)
BooksService-->>BooksController: true
BooksController-->>Client: 201 Created (Location header)
end
Client->>BooksController: PUT /books (BookDTO)
BooksController->>BooksService: update(BookDTO)
BooksService->>BooksRepository: existsById(isbn)
alt Book exists
BooksService->>BooksRepository: save(Book)
BooksService-->>BooksController: true
BooksController-->>Client: 204 No Content
else Book does not exist
BooksService-->>BooksController: false
BooksController-->>Client: 404 Not Found
end
Client->>BooksController: DELETE /books/{isbn}
BooksController->>BooksService: delete(isbn)
BooksService->>BooksRepository: existsById(isbn)
alt Book exists
BooksService->>BooksRepository: deleteById(isbn)
BooksService-->>BooksController: true
BooksController-->>Client: 204 No Content
else Book does not exist
BooksService-->>BooksController: false
BooksController-->>Client: 404 Not Found
end
Client->>BooksController: GET /books/{isbn}
BooksController->>BooksService: retrieveByIsbn(isbn)
BooksService->>BooksRepository: findById(isbn)
alt Book found
BooksService-->>BooksController: BookDTO
BooksController-->>Client: 200 OK (BookDTO)
else Book not found
BooksService-->>BooksController: null
BooksController-->>Client: 404 Not Found
end
Client->>BooksController: GET /books
BooksController->>BooksService: retrieveAll()
BooksService->>BooksRepository: findAll()
BooksService-->>BooksController: List<BookDTO>
BooksController-->>Client: 200 OK (List<BookDTO>)
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (8)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (4)
🧰 Additional context used🧬 Code Graph Analysis (3)src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/services/BooksServiceTests.java (2)
src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/controllers/BooksControllerTests.java (1)
src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/repositories/BooksRepositoryTests.java (1)
🪛 GitHub Check: Codeac Code Qualitysrc/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/services/BooksServiceTests.java[failure] 49-61: MethodNamingConventions [failure] 64-80: MethodNamingConventions [warning] 75-83: CodeDuplication [warning] 56-68: CodeDuplication [warning] 164-172: CodeDuplication [failure] 152-169: MethodNamingConventions [failure] 193-205: MethodNamingConventions src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/controllers/BooksControllerTests.java[warning] 244-256: CodeDuplication [warning] 221-233: CodeDuplication [failure] 285-303: MethodNamingConventions [failure] 306-324: MethodNamingConventions [warning] 314-324: CodeDuplication [warning] 293-303: CodeDuplication src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/repositories/BooksRepositoryTests.java[failure] 25-34: MethodNamingConventions [failure] 37-44: MethodNamingConventions ⏰ Context from checks skipped due to timeout of 90000ms (1)
🔇 Additional comments (26)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/BookDTOFakes.java
Outdated
Show resolved
Hide resolved
src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/BookFakes.java
Outdated
Show resolved
Hide resolved
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #183 +/- ##
===========================================
Coverage 100.00% 100.00%
+ Complexity 26 20 -6
===========================================
Files 2 2
Lines 56 49 -7
Branches 6 4 -2
===========================================
- Hits 56 49 -7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
assets/images/structure.svgis excluded by!**/*.svg
📒 Files selected for processing (8)
.vscode/settings.json(1 hunks)src/main/java/ar/com/nanotaboada/java/samples/spring/boot/controllers/BooksController.java(7 hunks)src/main/java/ar/com/nanotaboada/java/samples/spring/boot/services/BooksService.java(4 hunks)src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/BookDTOFakes.java(3 hunks)src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/BookFakes.java(3 hunks)src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/controllers/BooksControllerTests.java(9 hunks)src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/repositories/BooksRepositoryTests.java(3 hunks)src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/services/BooksServiceTests.java(6 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/repositories/BooksRepositoryTests.java (1)
src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/BookFakes.java (1)
BookFakes(9-152)
src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/controllers/BooksControllerTests.java (1)
src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/BookDTOFakes.java (1)
BookDTOFakes(9-153)
src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/services/BooksServiceTests.java (2)
src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/BookDTOFakes.java (1)
BookDTOFakes(9-153)src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/BookFakes.java (1)
BookFakes(9-152)
🪛 GitHub Check: Codeac Code Quality
src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/repositories/BooksRepositoryTests.java
[failure] 25-34: MethodNamingConventions
The JUnit 5 test method name 'givenFindByIsbn_whenISBNAlreadyExists_thenShouldReturnExistingBook' doesn't match '[a-z][a-zA-Z0-9]*'
[failure] 37-44: MethodNamingConventions
The JUnit 5 test method name 'givenFindByIsbn_whenISBNDoesNotExist_thenShouldReturnEmptyOptional' doesn't match '[a-z][a-zA-Z0-9]*'
src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/controllers/BooksControllerTests.java
[failure] 213-233: MethodNamingConventions
The JUnit 5 test method name 'givenPut_whenRequestBodyIsValidAndExistingBook_thenResponseStatusIsNoContent' doesn't match '[a-z][a-zA-Z0-9]*'
[failure] 236-256: MethodNamingConventions
The JUnit 5 test method name 'givenPut_whenRequestBodyIsValidButNonExistentBook_thenResponseStatusIsNotFound' doesn't match '[a-z][a-zA-Z0-9]*'
[warning] 244-256: CodeDuplication
This block of 12 lines is too similar to src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/controllers/BooksControllerTests.java:221
[warning] 221-233: CodeDuplication
This block of 12 lines is too similar to src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/controllers/BooksControllerTests.java:244
[failure] 285-303: MethodNamingConventions
The JUnit 5 test method name 'givenDelete_whenPathVariableIsValidAndExistingISBN_thenResponseStatusIsNoContent' doesn't match '[a-z][a-zA-Z0-9]*'
[failure] 306-324: MethodNamingConventions
The JUnit 5 test method name 'givenDelete_whenPathVariableIsValidButNonExistentISBN_thenResponseStatusIsNotFound' doesn't match '[a-z][a-zA-Z0-9]*'
[warning] 314-324: CodeDuplication
This block of 10 lines is too similar to src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/controllers/BooksControllerTests.java:293
[warning] 293-303: CodeDuplication
This block of 10 lines is too similar to src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/controllers/BooksControllerTests.java:314
src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/services/BooksServiceTests.java
[warning] 75-83: CodeDuplication
This block of 8 lines is too similar to src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/services/BooksServiceTests.java:164
[warning] 56-68: CodeDuplication
This block of 12 lines is too similar to src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/services/BooksServiceTests.java:179
[failure] 49-61: MethodNamingConventions
The JUnit 5 test method name 'givenCreate_whenRepositoryExistsByIdReturnsTrue_thenRepositoryNeverSaveBookAndResultIsFalse' doesn't match '[a-z][a-zA-Z0-9]*'
[failure] 64-80: MethodNamingConventions
The JUnit 5 test method name 'givenCreate_whenRepositoryExistsByIdReturnsFalse_thenRepositorySaveBookAndResultIsTrue' doesn't match '[a-z][a-zA-Z0-9]*'
[warning] 164-172: CodeDuplication
This block of 8 lines is too similar to src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/services/BooksServiceTests.java:75
[failure] 152-169: MethodNamingConventions
The JUnit 5 test method name 'givenUpdate_whenRepositoryExistsByIdReturnsTrue_thenRepositorySaveBookAndResultIsTrue' doesn't match '[a-z][a-zA-Z0-9]*'
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Codacy Static Code Analysis
- GitHub Check: Analyze (java-kotlin)
🔇 Additional comments (46)
.vscode/settings.json (1)
8-9: Disable Java Inlay Hints for a Cleaner WorkspaceAdding
"editor.inlayHints.enabled": "off"under the[java]scope silences parameter and type hints in Java files, complementing the existing default formatter ("redhat.java") and improving readability during the ongoing refactor. Since this is a workspace‑level setting, please confirm that it’s intended to be committed for the entire team rather than as a personal preference.src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/BookDTOFakes.java (2)
9-9: Class name change improves clarity.The renaming from
BookDTOsBuildertoBookDTOFakesbetter represents the purpose of this class - to create fake DTO objects for testing, rather than using a builder pattern.
11-11: Method naming update establishes consistency.Changing method names from
buildOneValid(),buildOneInvalid(), andbuildManyValid()to use thecreateprefix better reflects what these methods do and aligns with other test utility classes likeBookFakes. This also makes the naming consistent across your test utilities.Also applies to: 31-31, 45-45
src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/BookFakes.java (2)
9-9: Class name change clarifies intent.Renaming from
BooksBuildertoBookFakeseffectively communicates the purpose of this class - providing fake Book objects for testing rather than using a builder pattern.
11-11: Method naming update establishes consistency.Changing method names from
buildOneValid(),buildOneInvalid(), andbuildManyValid()to use thecreateprefix better reflects the actual functionality and maintains consistency with other test utilities likeBookDTOFakes.Also applies to: 31-31, 45-45
src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/repositories/BooksRepositoryTests.java (3)
15-15: Import update properly reflects class renaming.Updated import statement correctly references the renamed
BookFakesclass, maintaining code functionality after the refactoring.
25-25: Method naming improvement for acronym capitalization.The test method names now properly capitalize "ISBN" as an acronym, improving readability and consistency with naming conventions.
Also applies to: 37-37
🧰 Tools
🪛 GitHub Check: Codeac Code Quality
[failure] 25-34: MethodNamingConventions
The JUnit 5 test method name 'givenFindByIsbn_whenISBNAlreadyExists_thenShouldReturnExistingBook' doesn't match '[a-z][a-zA-Z0-9]*'
27-27: Usage of renamed factory methods.Updated to use
BookFakes.createOneValid()instead of the previous builder method, maintaining functionality while adapting to the refactored helper class.Also applies to: 39-39
src/main/java/ar/com/nanotaboada/java/samples/spring/boot/services/BooksService.java (4)
6-7: Added Lombok annotation simplifies constructor requirements.Adding
@RequiredArgsConstructoreliminates boilerplate constructor code while ensuring that all final fields (repositories and mappers) are properly initialized.
33-35: Simplified create method logic.Validation logic has been removed from the create method, focusing it on core business logic - checking existence and saving the entity. This supports the refactoring goal of moving validations to controllers.
71-77: Simplified update method with cleaner control flow.The update method now uses a more straightforward if-else structure without intermediate variables, making the code more readable while maintaining the same functionality.
91-92: Simplified delete method with cleaner control flow.The delete method has been restructured with a clearer if-else pattern that directly returns the result, making the code more concise and readable.
src/main/java/ar/com/nanotaboada/java/samples/spring/boot/controllers/BooksController.java (11)
3-4: Added static import for LOCATION header constant.This improves code readability by directly using the well-defined constant name rather than referencing through the HttpHeaders class.
8-11: Add validation annotations support.Adding imports for validation annotations (
@Validand@ISBN) aligns with the PR objective of moving validations from services to controllers.
60-64: Improved request validation and response handling.The method now:
- Uses
@Validannotation for automatic bean validation- Returns a boolean result from the service layer
- Handles conflict case clearly with HTTP 409
This approach properly moves validation to the controller layer and simplifies the error handling flow.
65-71: Improved location header construction.Using
MvcUriComponentsBuilder.fromMethodCall()with the controller method reference is more type-safe than using string-based method names. The response construction is also more readable using the builder pattern.
81-81: Updated API documentation for accuracy.The operation summary now correctly references ISBN instead of ID, improving API documentation clarity.
88-90: Simplified response handling with ternary operator.The ternary operator provides a more concise way to handle the conditional response while maintaining readability.
100-100: Standardized response creation pattern.Using
ResponseEntity.status().body()pattern improves consistency with other controller methods.
110-110: Updated API documentation for accuracy.The operation summary now correctly specifies updating by ISBN rather than a generic reference.
116-120: Streamlined update logic with validation.The method now:
- Uses
@Validannotation for automatic bean validation- Calls the service method directly, eliminating redundant checks
- Uses a ternary operator for cleaner response handling
- Returns the appropriate status code based on the result
This approach properly moves validation to the controller layer and simplifies the flow.
130-130: Updated API documentation for accuracy.The operation summary now correctly references ISBN instead of ID, improving API documentation clarity.
136-140: Added validation and simplified delete logic.The method now:
- Uses
@ISBNannotation to validate the ISBN path variable- Directly calls the service method with simplified flow
- Uses a ternary operator for cleaner response handling
- Returns the appropriate status code based on the result
This approach properly moves validation to the controller layer and simplifies the flow.
src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/services/BooksServiceTests.java (10)
26-27: Test utility classes renamed for better clarity.Changing from
BookDTOsBuilderandBooksBuildertoBookDTOFakesandBookFakesbetter reflects the purpose of these classes - providing test fake objects rather than just building them.
49-61: Updated test to reflect validation removal from service layer.The test now focuses on repository interactions rather than validation, specifically:
- The method name clearly describes the test scenario
- The test verifies that when a book already exists, the repository never saves it
- Added verification that model mapper is never called in this scenario
This aligns with the PR objective of moving validations from services to controllers.
🧰 Tools
🪛 GitHub Check: Codeac Code Quality
[failure] 49-61: MethodNamingConventions
The JUnit 5 test method name 'givenCreate_whenRepositoryExistsByIdReturnsTrue_thenRepositoryNeverSaveBookAndResultIsFalse' doesn't match '[a-z][a-zA-Z0-9]*'
64-79: Test updated to use the new test fake factories.The test now uses
BookDTOFakesandBookFakesinstead of builder classes while maintaining the same verification logic, ensuring that when a book doesn't exist, it gets properly mapped and saved to the repository.🧰 Tools
🪛 GitHub Check: Codeac Code Quality
[failure] 64-80: MethodNamingConventions
The JUnit 5 test method name 'givenCreate_whenRepositoryExistsByIdReturnsFalse_thenRepositorySaveBookAndResultIsTrue' doesn't match '[a-z][a-zA-Z0-9]*'
89-105: Test updated to use the new test fake factories.The test now uses
BookFakesandBookDTOFakesto create test objects with the same verification logic for retrieving an existing book.🧰 Tools
🪛 GitHub Check: Codeac Code Quality
[failure] 89-105: MethodNamingConventions
The JUnit 5 test method name 'givenRetrieveByIsbn_whenRepositoryFindByIdReturnsBook_thenResultIsEqualToBook' doesn't match '[a-z][a-zA-Z0-9]*'
108-119: Enhanced verification in retrieveByIsbn test.The test now explicitly verifies that the model mapper is never called when the repository returns empty, which is an important assertion that was missing before.
🧰 Tools
🪛 GitHub Check: Codeac Code Quality
[failure] 108-120: MethodNamingConventions
The JUnit 5 test method name 'givenRetrieveByIsbn_whenRepositoryFindByIdReturnsEmpty_thenResultIsNull' doesn't match '[a-z][a-zA-Z0-9]*'
123-142: Improved test for retrieveAll method.The test now:
- Uses the renamed fake object factories
- Has a more explicit verification of the model mapper being called for each book
- Maintains the same overall verification logic
This refactoring maintains test coverage while using the updated test utilities.
🧰 Tools
🪛 GitHub Check: Codeac Code Quality
[failure] 123-143: MethodNamingConventions
The JUnit 5 test method name 'givenRetrieveAll_whenRepositoryFindAllReturnsBooks_thenResultIsEqualToBooks' doesn't match '[a-z][a-zA-Z0-9]*'
152-169: Updated update test to focus on repository interaction.The test now focuses on repository interactions rather than validation, verifying that when a book exists, it gets properly mapped and saved to the repository. This aligns with moving validations to the controller layer.
🧰 Tools
🪛 GitHub Check: Codeac Code Quality
[failure] 152-169: MethodNamingConventions
The JUnit 5 test method name 'givenUpdate_whenRepositoryExistsByIdReturnsTrue_thenRepositorySaveBookAndResultIsTrue' doesn't match '[a-z][a-zA-Z0-9]*'
172-183: Enhanced verification in update test.The test now explicitly verifies that the model mapper is never called when the book doesn't exist, which is an important assertion that focuses on the core service behavior without validation concerns.
🧰 Tools
🪛 GitHub Check: Codeac Code Quality
[failure] 172-184: MethodNamingConventions
The JUnit 5 test method name 'givenUpdate_whenRepositoryExistsByIdReturnsFalse_thenRepositoryNeverSaveBookAndResultIsFalse' doesn't match '[a-z][a-zA-Z0-9]*'
193-204: Test refactored to focus on repository interaction.The test now verifies that when a book doesn't exist, the delete operation is never called and the model mapper is never involved, focusing purely on the repository interaction pattern.
208-218: Test refactored for successful deletion scenario.The test now correctly verifies that the repository's deleteById method is called when a book exists, while ensuring the model mapper is never called during a delete operation.
src/test/java/ar/com/nanotaboada/java/samples/spring/boot/test/controllers/BooksControllerTests.java (13)
6-6: Added verification for never interactions.Adding the static import for Mockito.never allows verifying that certain methods are never called, which is important for validating that the controller respects validation annotations before calling service methods.
33-33: Updated import for test data generation.The import now uses
BookDTOFakesinstead ofBookDTOsBuilder, aligning with the renamed test utility class for creating fake test data.
57-77: Updated POST test for conflict scenario.The test now:
- Uses
BookDTOFakesfor creating test data- Mocks the
createmethod to return false (existing book)- Verifies that the service method is called once
- Checks the response status is 409 Conflict
These changes align with the updated controller implementation.
81-107: Updated POST test for successful creation.The test now:
- Uses
BookDTOFakesfor creating test data- Mocks the
createmethod to return true (successful creation)- Verifies that the service method is called once
- Checks the response status is 201 Created and location header is set
These changes align with the updated controller implementation.
111-127: Updated POST test for validation failure.The test now:
- Uses
BookDTOFakesfor creating an invalid test object- Verifies that the service method is never called (validation fails before)
- Checks the response status is 400 Bad Request
These changes confirm that controller-level validation works properly.
137-158: Updated GET test for successful retrieval.The test now:
- Uses
BookDTOFakesfor creating test data- Properly verifies both the response status and the returned object
- Maintains the same core verification logic
This refactoring adapts the test to use the updated test utilities.
162-178: Updated GET test for non-existent resource.The test now explicitly mocks the service to return null for a non-existent book and verifies the 404 Not Found response.
182-203: Updated GetAll test to use new test utilities.The test now uses
BookDTOFakesto create test data while maintaining the same verification logic.
213-232: Updated PUT test for successful update.The test now:
- Uses
BookDTOFakesfor creating test data- Mocks the
updatemethod to return true (successful update)- Verifies that the service method is called once
- Checks the response status is 204 No Content
These changes align with the updated controller implementation.
🧰 Tools
🪛 GitHub Check: Codeac Code Quality
[failure] 213-233: MethodNamingConventions
The JUnit 5 test method name 'givenPut_whenRequestBodyIsValidAndExistingBook_thenResponseStatusIsNoContent' doesn't match '[a-z][a-zA-Z0-9]*'
236-255: Updated PUT test for non-existent resource.The test now:
- Uses
BookDTOFakesfor creating test data- Mocks the
updatemethod to return false (book not found)- Verifies that the service method is called once
- Checks the response status is 404 Not Found
These changes align with the updated controller implementation.
🧰 Tools
🪛 GitHub Check: Codeac Code Quality
[failure] 236-256: MethodNamingConventions
The JUnit 5 test method name 'givenPut_whenRequestBodyIsValidButNonExistentBook_thenResponseStatusIsNotFound' doesn't match '[a-z][a-zA-Z0-9]*'
259-275: Updated PUT test for validation failure.The test now:
- Uses
BookDTOFakesfor creating an invalid test object- Verifies that the service method is never called (validation fails before)
- Checks the response status is 400 Bad Request
These changes confirm that controller-level validation works properly.
🧰 Tools
🪛 GitHub Check: Codeac Code Quality
[failure] 259-276: MethodNamingConventions
The JUnit 5 test method name 'givenPut_whenRequestBodyIsInvalidBook_thenResponseStatusIsBadRequest' doesn't match '[a-z][a-zA-Z0-9]*'
285-302: Updated DELETE test for successful deletion.The test now:
- Uses
BookDTOFakesfor creating test data- Mocks the
deletemethod to return true (successful deletion)- Verifies that the service method is called once
- Checks the response status is 204 No Content
These changes align with the updated controller implementation.
🧰 Tools
🪛 GitHub Check: Codeac Code Quality
[failure] 285-303: MethodNamingConventions
The JUnit 5 test method name 'givenDelete_whenPathVariableIsValidAndExistingISBN_thenResponseStatusIsNoContent' doesn't match '[a-z][a-zA-Z0-9]*'
306-323: Updated DELETE test for non-existent resource.The test now:
- Uses
BookDTOFakesfor creating test data- Mocks the
deletemethod to return false (book not found)- Verifies that the service method is called once
- Checks the response status is 404 Not Found
These changes align with the updated controller implementation.
🧰 Tools
🪛 GitHub Check: Codeac Code Quality
[failure] 306-324: MethodNamingConventions
The JUnit 5 test method name 'givenDelete_whenPathVariableIsValidButNonExistentISBN_thenResponseStatusIsNotFound' doesn't match '[a-z][a-zA-Z0-9]*'
.../java/ar/com/nanotaboada/java/samples/spring/boot/test/controllers/BooksControllerTests.java
Outdated
Show resolved
Hide resolved
9202e5f to
2b44db7
Compare
|
Code Climate has analyzed commit 2b44db7 and detected 2 issues on this pull request. Here's the issue category breakdown:
Note: there are 2 critical issues. View more on Code Climate. |
|



This change is
Summary by CodeRabbit