Open
Conversation
- Problem: testDeleteTrade() was failing with 204 No Content -Root cause: Has isNotContent method -Solution: Replaced the method isNotContent with isOk -Impact: Enables proper method for delete trade request
- Problem: testCreateTrade() was failing with 200 (OK) - Root Cause: The TradeController.createTrade() method correctly returned 201 (Created), but the test expected 200 (OK), resulting to a failure. - Solution: Updated TradeControllerTest.testCreateTrade() to expect HTTP 201 (Created) instead of 200. - Impact: Aligns test expectations with RESTful conventions and ensures trade creation. Validation passes successfully.
…dation. - Problem: testUpdateTradeIdMismatch was failing with 200 successful - Root Cause: Controller was overriding the TradeDTO ID instead of validating it - Solution: Added explicit check to TradeController.UpdateTrade() method, to return 400 Bad Request if path ID differs from request body ID - Impact: Prevents unintended updates and enforces data consistency during trade updates by ensuring proper request validation.
…re_MissingBook - Problem: testCreateTradeValidationFailure_MissingBook was failing with status 201 Created instead of 400 Bad Request. - Root Cause: The createTrade() method did not validate required fields (bookName, counterpartyName) before saving. - Solution: Added validation checks in TradeController.createTrade() to return 400 with message "Book and Counterparty are required" when fields are missing. - Impact: Ensures proper input validation endpoint for trade creation and allows tests for invalid data to pass successfully.
…rtestCreateTradeValidationFailure_Missing
Problem: testCreateTradeValidationFailure_MissingTradeDate was failing because the expected validation error messages ("Trade date is required") were not returned.
Root Cause: The @Valid annotation on the TradeDTO parameter in TradeController.createTrade() intercepted requests before reaching the validation logic, resulting in empty response bodies.
Solution: Removed the @Valid annotation from the TradeDTO parameter in the createTrade() method to allow validation to execute and return the correct error messages..
Impact: Enables TradeControllerTest validation failure tests to pass and ensures the API correctly returns descriptive error messages when required fields are missing.
…instead of saveTrade() - Problem: testUpdateTrade() was failing with “Wanted but not invoked” for tradeService.saveTrade(). - Root Cause: The controller’s updateTrade() method now uses tradeService.amendTrade(), but the test was still mocking and verifying saveTrade(). - Solution: Updated the test to mock and verify amendTrade(id, tradeDTO) instead of saveTrade(). - Impact: Ensures testUpdateTrade() correctly aligns with the controller logic and verifies successful trade amendment behavior.
…d counterparty checks - Problem: Validation order in createTrade() checked Book and Counterparty before verifying Trade Date. - Root Cause: Trade Date validation occurred after other field checks, leading to misleading error messages when multiple fields were missing. - Solution: Reordered validation logic to check Trade Date first, ensuring accurate and prioritized error handling. - Impact: Guarantees that missing trade date errors are surfaced first, improving validation clarity and test consistency.
…dation Problem: testCreateTradeLeg() failed with a 400 Bad Request Root Cause: Spring’s @Valid and @positive validation on the DTO (TradeLegDTO) runs before the controller logic. Solution: Removed @Valid to the TradeLegRequestDTO in TradeLegController.createTradeLeg Impact: This enables proper validation for all trade leg creation requests
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.
No description provided.