-
Notifications
You must be signed in to change notification settings - Fork 0
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
RL-SM: Add Functionality for onBuy, onSell Buttons, updating totalWealth using 2 PUT endpoints #51
Conversation
Codecov Report
@@ Coverage Diff @@
## main #51 +/- ##
============================================
+ Coverage 81.09% 81.27% +0.18%
- Complexity 75 78 +3
============================================
Files 52 49 -3
Lines 439 438 -1
Branches 12 11 -1
============================================
Hits 356 356
+ Misses 83 82 -1
Continue to review full report at Codecov.
|
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.
Where are the controller tests for the new methods?
I realized we were missing this right after we made the request -- working on it now! |
…e sense to save a usercommons to a nonexistent commons
…l as 2 for non-existing sell and buy
The PR has been completed with controller tests for UserCommonsController. |
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.
Looks like you have some merge conflicts to resolve, but everything else LGTM!
57897ea
to
6bbb27d
Compare
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.
Couple of "TODOs left in the code"...
when(commonsRepository.findById(eq(1L))).thenReturn(Optional.of(randomCommons)); | ||
|
||
// act | ||
MvcResult response = mockMvc.perform(put("/api/usercommons/buy?id=1") //oof, accidentally made PUT endpoints id variable instead of commonsId. TODO: Fix later. |
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.
Fix now maybe?
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
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.
As long as we are fixing things, maybe this white space too...
when(commonsRepository.findById(eq(1L))).thenReturn(Optional.of(randomCommons)); | ||
|
||
// act | ||
MvcResult response = mockMvc.perform(put("/api/usercommons/buy?id=234") //oof, accidentally made PUT endpoints id variable instead of commonsId. TODO: Fix later. |
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.
oof indeed :-)
7a14585
to
75b7c14
Compare
…ing for when only commons doesn't exist
ad8cc6d
to
ee26650
Compare
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.
LGTM
79e7054
to
1c4cb86
Compare
Bad PR |
Overview
We added two PUT endpoints for BUY and SELL, and created onBuy and onSell basic functionality to update totalWealth of a user on the Playpage.
Issues Addressed
We addressed some of the points in #15 . This issue isn't completed yet however, but we wanted to get a PR in for CI/CD.
We addressed these issues:
These are still left for future work
Details
When a user presses the "+"(onBuy) or "-"(onSell) button on the play page on the website, we call the 2 PUT endpoints /buy and /sell. These buy and sell 1 cow respectively each time they're called. Currently, it sells at cowPrice (value of which comes from when an admin creates a new commons), and buys at cowPrice (although this needs to be changed in a future edit to factor in average cowHealth).
User totalWealth comes from startingBalance, which is set by an admin when creating a new commons.
We created 4 tests for the buy and sell endpoint (2 of which are for checking when the usercommons doesn't exist).
We deleted a line of code from a backend test created by w22-6pm-4 (see commit message regarding it).
Testing Plan