Alright folks, finally I got my code to work. Here are the issues in QMoney Module 4 that I've identified. I suggest @Team Crio @Crio Assist to please re-visit this module to fix them. Will save a lot of time in future for other people 🙂 :-
-
The cloned code stub has missing implementations
- In
PortfolioManagerApplication.java
there's a method calledreadFileAsString()
used whose implementation is missing (although this function serves no use later). Similarly, there's agetStockQuote()
method inPortfolioManagerImpl.java
which is also missing. If these are the TODOs then what we're supposed to implement in them is missing (had to copy them from intro video). The TODO comments within the files are also not clear. If possible they should be added in milestones only. These two methods were newly introduced in this module only. There's also a constructor used for initializing this class withRestTemplate
but the variable is missing. So we also need to add this line at the startRestTemplate restTemplate;
- In
-
The test cases have problems :-
- In
PortfolioManagerTest.java
they use Mockito forgetStockQuote()
method based onString moduleToRun = null;
It gives two errors: a) If used as it is thenNullPointerException
. b) If changed tomoduleToRun = "REFACTOR";
thenUnneccesaryStubbingException
. The solution is to change it to "REFACTOR" and mandatorily usegetStockQuote()
method incalculateAnnualizedReturn()
method. From the signature you can see that thegetStockQuote()
method returns a list of quotes for a symbol. - Another test case fails because there's also a case when no
endDate
is provided tobuildUri()
method. There could be no end date passed should be mentioned in the module instructions only so this test doesn't fail. It could be easily implemented because the API call doesn't mandatorily needs the end date. - The list of annualized returns needs to be sorted before returning is also not mentioned.
- In
-
In
PortfolioManagerApplication.java
formainCalculateReturnsAfterRefactor()
method it uses aportfolioManager
object for returning and needs implementation. It confuses withPortfolioManager
class. Again figured this out using method signature and what was probably expected.
All in all this module needs a lot of changes in sync with what we have done previously and needs proper explanation and correct code stubs. If there wasn't this life-saver FAQ that one of the TA sent one couldn't have probably figured out what was going on.
I hope it makes sense. 🙂
Author
Surya Saini 👨💻