Alphavantage mockito doubts thread

Yesterday the alphvantage service was returning me more proper api response through get from object. I run the exact same code today and its injecting the mockito value. I am not able to understand what went wrong without even changing the code.

solved it. temporarily.
did AlphavantageService = new AlphavantageService(new RestTemplate())
but the whole this doesn’t fit well with code if we keep factory pattern in mind I suppose

to my previous response;
new RestTemplate() would allow you to verify whether you’re api giving you right call.
Otherwise keep the statement as
AlphavantageService alp = new AlphavantageService(restTemplate) as you will be receiving an instance of rest template from other part of code

Hi @tejasjd_78,

The temporary solution might give you issues with the tests, since they also test if you have actually used the passed RestTemplate object by checking its properties. In your case, that’ll lead to a null and a second part of assertion may fail.

The error may lie somewhere else. I’ll recommend you use the passed rest template and discuss what errors are coming, so that we can resolve them. Otherwise this might fail during the assessments.

If you have any issues implementing this, please let me know!

@tejasjd_78 Is your issue resolved or not?

yes sir the issue has been resolved

Closing this topic as your issue is resolved by the mentor. If it is still not resolved, please feel free to create a new topic and post this question as a reference link in the description of the new topic.