In my service impl , when I use RestTemplate, I am unable to unit test my class methods(that have dependency on custom error response handler) as MockBean for resttemplate can't be used to setErrorHandler etc.
So I have to inject the RestTemplate into the method- pass it as method parameter, in my serviceimpl class.
Could you please let me know if it's a good practise to replace a Autowired RestTemplate injected from application context, with a method parameter(which helps in unit test) resttemplate which allows me create a RestTemplate instance and set required data on this object.
Appreciate if someone who has experienced this can respond.Thanks