Doubt in PortfolioManagerImpl

Didn’t understand what this Todo means
// Modify the function #getStockQuote and start delegating to calls to
// stockQuoteService provided via newly added constructor of the class.
// You also have a liberty to completely get rid of that function itself, however, make sure
// that you do not delete the #getStockQuote function.

because i am getting test failed in
calculateExtrapolatedAnnualizedReturn

stackTrace

org.mockito.exceptions.misusing.UnnecessaryStubbingException: 
Unnecessary stubbings detected.
Clean & maintainable test code requires zero unnecessary code.
Following stubbings are unnecessary (click to navigate to relevant line of code):
  1. -> at com.crio.warmup.stock.portfolio.PortfolioManagerTest.calculateExtrapolatedAnnualizedReturn(PortfolioManagerTest.java:110)
  2. -> at com.crio.warmup.stock.portfolio.PortfolioManagerTest.calculateExtrapolatedAnnualizedReturn(PortfolioManagerTest.java:112)
  3. -> at com.crio.warmup.stock.portfolio.PortfolioManagerTest.calculateExtrapolatedAnnualizedReturn(PortfolioManagerTest.java:114)
Please remove unnecessary stubbings or use 'lenient' strictness. More info: javadoc for UnnecessaryStubbingException class.

@senti143

The TODO’s and the stubbing error are telling you the following things

1: If you remember in module 4 we were dealing with the same issue, here also the deal is the same. ( No implementation of the same method again and again )

2: So as a Hint let me give you some Idea, the implementation of getStockQuote() method is also repeated somewhere else in the specific file of the directory, so all you need here is to use that method is this file.

So, We have to change the current method i.e
public List<TiingoCandle> getStockQuote(String symbol, LocalDate from, LocalDate to)
in portfolimanagerimpl
to
List<Candle> getStockQuote(String symbol, LocalDate from, LocalDate to) of stockQuotesService??

or the method return type will be same List<TiingoCandle> and we have to change the getStockQuote to call the method of StockQuoteService which will return List<Candle>
and then change this List<Candle> to the return type

Yeah you need to call the method of StockQuoteService in this case.

You can take eighter List as Candle or TiingoCandle No problem, depends on the implementation :slight_smile:

Asking because in test file of portfoliManager it is using TiingoCandle as well Method Calculateannualisedreturn will take input of type tiingocandel?

Then change the method signature according to it. You have both as options.

okk thanks Solved it. :smiley: :smiley:

Closing this topic as your issue has been resolved by the community.