Repository navigation
Fix 4 AccountService bugs found by bug hunt (with failing tests) - #382
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
…e amounts, UsernameNotFoundException 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)".
|
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 results for
AccountService. Each bug has a test that failed before this change and passes after it. Full suite: 11 tests, 0 failures (./mvnw clean test, H2 test profile).hasSufficientFundsusedcompareTo(amount) > 0, but its Javadoc says "at least", so users couldn't withdraw or transfer their entire balancehasSufficientFunds_isTrueWhenBalanceEqualsAmount,withdraw_entireBalanceSucceeds,transfer_entireBalanceSucceeds> 0→>= 0getTransactionHistory(account, from, to)documents "both days inclusive" but usedend = to.atStartOfDay(), so the wholetoday was dropped (a one-day range was always empty)transactionHistoryRange_includesTheToDay,transactionHistoryRange_includesLastMinuteOfToDayend = to.plusDays(1).atStartOfDay()(exclusive upper bound)deposit/withdraw/transferAmountaccepted negative amounts, e.g.transferAmount(alice, "bob", -500)moved 500 out of bob's account into alice'stransfer_negativeAmountIsRejected,withdraw_negativeAmountIsRejected,deposit_negativeAmountIsRejected,BankControllerDepositTest.deposit_negativeAmountShowsErrorOnDashboardrequirePositive(amount)throwsIllegalArgumentException("Amount must be greater than zero")for null, zero, or negative amounts./depositnow catches it and renders the dashboard error, the same way/withdrawand/transferalready do (without this, a negative deposit returned a 500)loadUserByUsernamethrew a plainRuntimeExceptionfor unknown users, which breaks theUserDetailsServicecontract; itsaccount == nullcheck could never runloadUserByUsername_unknownUserThrowsUsernameNotFoundExceptionfindAccountByUsernamethrowsUsernameNotFoundException(aRuntimeExceptionsubclass, so existing controllercatchblocks are unaffected); removed the dead null checkDropped suspects (no failing test could be written): self-transfer (the balance nets to zero), and
transferAmountnot being@Transactional(no partial write could be triggered in a test).Devin-Org: engineering
Link to Devin session: https://devin-gtm.devinenterprise.com/sessions/f15bb6af671c4ef094a7f6cce6692af6
Open in Devin Desktop: https://devin-gtm.devinenterprise.com/desktop/session/f15bb6af671c4ef094a7f6cce6692af6?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.