title: Mock FeignClient response
body: <p>It's possible to mock response FeignClient via MockRestServiceServer(restTemplate)? 
  This example dosn't work:</p>
  
  <p><strong>Application.class</strong></p>
  
  <pre><code>@SpringBootApplication
  @EnableFeignClients
  public class Application {
  
      public static void main(String[] args) {
          SpringApplication.run(Application.class, args);
      }
  
  }
  </code></pre>
  
  <p><strong>TicketService.class</strong></p>
  
  <pre><code>@FeignClient("ws")
  public interface TicketService {
  
      @RequestMapping(value = "/tickets/")
      List&lt;Ticket&gt; findAllTickets();
  
  }
  </code></pre>
  
  <p><strong>TestConfig.class</strong></p>
  
  <pre><code>@Profile("test")
  @Configuration
  public class TestConfig {
  
      @Bean
      @Primary
      public RestTemplate restTemplate() {
          return new RestTemplate();
      }
  
  }
  </code></pre>
  
  <p><strong>MyTest.class</strong></p>
  
  <pre><code>@ActiveProfiles("test")
  @RunWith(SpringRunner.class)
  @SpringBootTest(classes = {Application.class}, properties = {"ws.ribbon.listOfServers:example.com"})
  public class MyTest {
  
      @Autowired
      RestTemplate restTemplate;
      @Autowired
      DispatcherService dispatcherService; // service where the execution of the method TicketService.findAllTickets();
  
      private MockRestServiceServer mockServer;
  
      @Before
      public void setUp() {
          mockServer = MockRestServiceServer.createServer(restTemplate);
      }
  
      @Test
      public void ticket() {
          mockServer.expect(requestTo("http://example.com/tickets/"))
                  .andExpect(method(HttpMethod.GET))
                  .andRespond(withSuccess(new ClassPathResource("tickets.json"), MediaType.APPLICATION_JSON));
          dispatcherService.run();
      }
  }
  </code></pre>
  
  <p>But going a request to the real server example.com.</p>