title: How to mock response of Rest call in spring when you can't controll when the RestTemplate is constructed
body: <p>I want to write an integration level test for a rest method using MockRestServiceServer.  My rest method is a proxy, it ends up creating a restTemplate via a static helper method and proxys the request to a third party.  I want to mock out that third party.  Actually two different rest calls are made to different parties with different configurations to service the request.</p>
  
  <p>I want to use MockRestServiceServer, but it expects me to pass in the restTemplate, which is constructed within my integration test.   I can try to use mocks to ensure that my own restTemplate is used, but now I have to pull in 4 new maven packages and write a bit of code to do the inject safely, and make sure that a different restTemplate is used for the two different external service calls my proxy does.  It also requires me to know a little bit about my code and thus makes my integration test less of a black box then I would prefer.</p>
  
  <p>Is there a cleaner way to mock the services?  I know my approach could work, but it's just feeling overly cumbersome.  Is there a way to mock this without having to inject the RestTemplate ahead of time?</p>