2 testcases are failing

com.crio.warmup.stock.portfolio.PortfolioManagerTest > calculateExtrapolatedAnnualizedReturn() FAILED
com.fasterxml.jackson.databind.exc.InvalidDefinitionException at PortfolioManagerTest.java:117

com.crio.warmup.stock.quotes.AlphavantageServiceTest > getStockQuoteSingle() FAILED
org.opentest4j.AssertionFailedError at AlphavantageServiceTest.java:87

AssertionFailedError: expected: <true> but was: <false>

I had performed the following steps but still unable to resolve :

For AlphavantageService.java

  1. Sorted the List of Candle.
  2. Filter dates from startdate to enddate
  3. Checked my URI

For PortfolioManagerTest
I am using the same functions as in module 4 but its giving error.

Kindly help me to resolve these errors.

Hey we have an Faq for the first error

can you check this as well

I have already added -
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());

Also I have filtered objects on basis of date already.

Hey on the taskboard, you can see this
in MileStone 3
something is done in AlphavantageDailyResponse.java , check the response from the API, it could probably mean that you have not mapped the API response properly, The response should be mapped from Json String to AlphaVantageCandle , can you verify this

Yes, I have verified my API in postman.I think I am able to map from string to candle.

Hey, please try to follow up with the following FAQs -

Also, please try to run the individual test cases and see the report to know at what point you are facing the issue.

As suggested in Error : com.fasterxml.jackson.databind.exc.InvalidDefinitionException, I have added ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());

As suggested in Extrapolated Annualized Return test case fails, My logic is correct since it has passed module 4 and I have not made any changes to it.

By running individual tests,

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `com.crio.warmup.stock.dto.Candle` (no Creators, like default construct, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
 at [Source: (StringReader); line: 1, column: 2] (through reference chain: java.util.ArrayList[0])
org.opentest4j.AssertionFailedError: expected: <true> but was: <false>
	at org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:55)

Hi @Vaishnavi_Singh, I think you might have missed out on some implementation details, that’s okay the refactoring on module 6 is kind of big and I have faced some issues myself too. In this type of scenario, I suggest you break down the list of things to do by where to do it.

i) qmoney/src/main/java/com/crio/warmup/stock/dto/AlphavantageCandle.java

  • Implement the required methods with annotations for the candle to correctly map with the API response.

ii) qmoney/src/main/java/com/crio/warmup/stock/dto/AlphavantageDailyResponse.java

  • As you have realized that the date from the AlphaVantage is provided as a key, think of how you will get the date data inside the candle.

iii) qmoney/src/main/java/com/crio/warmup/stock/portfolio/PortfolioManagerFactory.java

  • You need to refactor the code here to use the StockQuoteService to get the stock data, Think of how you’ll implement it.

iv) qmoney/src/main/java/com/crio/warmup/stock/portfolio/PortfolioManagerImpl.java

  • Same here, use the StockQuoteService to get the stock data.

v) qmoney/src/main/java/com/crio/warmup/stock/quotes/AlphavantageService.java

  • You need to implement the actual logic to get the stock quotes from the AlphaVantage service in here.

vi) qmoney/src/main/java/com/crio/warmup/stock/quotes/StockQuoteServiceFactory.java

  • You’ll need to implement the getService() method here which returns the service according to the parameter String provider.

vii) qmoney/src/main/java/com/crio/warmup/stock/quotes/TiingoService.java

  • You’ll need to refactor out the Tiingo API call code to this class.

Other than this you need to debug the code using the vscode debugger to get a better understanding what happens in the code on runtme. I’m sharing some links below that might help you.

Closing this topic as your issue has been resolved by the community. If not Kindly un-mark the accepted solution to re-open the topic or feel free to create a new topic and post a link to this topic as a reference.