Repository navigation
Fix 4 AccountService bugs found in bug hunt (each proven by a failing test) - #384
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…nd unknown-user exception in AccountService Co-Authored-By: Grace Juan <grace.juan@cognition.ai>
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Author
This branch has not been deployed
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.
Summary
Bug hunt on
bug-hunt-demo. Every bug below had a test that failed onbug-hunt-demo(11 failing → 11 passing). Fixes are the smallest change that makes each test pass.hasSufficientFundsis documented as "at leastamount" but usescompareTo(amount) > 0. Withdrawing or transferring your entire balance is rejected with "Insufficient funds".hasSufficientFunds_isTrueWhenBalanceEqualsAmount,withdraw_entireBalance_succeeds,transfer_entireBalance_succeeds> 0→>= 0getTransactionHistory(account, from, to)is documented as "both days inclusive" but usesend = to.atStartOfDay()withisBefore(end), so it drops the wholetoday (a single-day query returns nothing).transactionHistoryByDate_includesTransactionsOnTheToDayend = to.plusDays(1).atStartOfDay()deposit/withdraw/transferAmountaccept zero and negative amounts. A negative deposit lowers the balance, a negative withdrawal raises it, and a negative transfer pulls money out of the recipient's account.deposit_negativeAmount_isRejected,withdraw_negativeAmount_isRejected,transfer_negativeAmount_doesNotPullMoneyFromRecipient,transfer_zeroAmount_isRejected,BankControllerDepositTest.negativeDeposit_showsErrorOnDashboardAndLeavesBalanceUnchangedrequirePositive(amount)guard at the start of each method;/depositnow catches the error and re-renders the dashboard with it (same pattern as/withdrawand/transfer) instead of returning a 500.loadUserByUsernamecallsfindAccountByUsername, which throws a plainRuntimeExceptionfor unknown users, so theUserDetailsServicecontract (UsernameNotFoundException) is broken and thenullcheck was unreachable code.loadUserByUsername_unknownUser_throwsUsernameNotFoundExceptionaccountRepository.findByUsername(...).orElseThrow(UsernameNotFoundException::new)Tests:
src/test/.../service/AccountServiceBugHuntTest.java(Mockito unit tests) andsrc/test/.../controller/BankControllerDepositTest.java(MockMvc on the H2testprofile). Full suite:./mvnw clean test→ 11/11 pass.Note: PRs #382 and #383 (earlier bug-hunt runs on the same base) cover the same bugs; only one should land.
Link to Devin session: https://devin-gtm.devinenterprise.com/sessions/01a2548792fa4eb1bb8f3a2abf1049c6
Open in Devin Desktop: https://devin-gtm.devinenterprise.com/desktop/session/01a2548792fa4eb1bb8f3a2abf1049c6?variant=devin
Requested by: @gracejuan-star
Note
Devin errored when opening this Pull Request as gracejuan-star.
As a fallback, Devin opened this PR as itself.