title: Mock RestTemplate in SubSubclass
body: <p>there's a problem here!</p>
  <p>In my application I have a Consumer (kafka) that uses a Facade that uses a Client that calls a rest Api with RestTemplate</p>
  <p>I want (have) to test the whole flow excluded the rest call. so I've tried to mock RestTemplate but without success -_-</p>
  <p>here an example of my classes</p>
  <pre><code>@Service
  public class KafkaConsumer{
      @Autowired MyFacade facade;
  
      @KafkaListener
      public void onMessage(){
          facade.awesomeMethod();
      }
  }
  
  
  @Service
  public class MyFacade{
      @Autowired MyClient client;
     
      public void awesomeMethod(){
          client.callApi();
      }
  }
  
  @Service
  public class MyClient{
      @Autowired RestTemplate restTemplate;
  
      public void callApi(){
          restTemplate.exchange(.....);
      }
  }
  </code></pre>
  <p>now I'm tring to build a test with mock but something goes wrong and RestTemplate call real server</p>
  <p>here test class</p>
  <pre><code>@ActiveProfile(&quot;test&quot;)
  @RunWith(SpringRunner.class)
  @SpringbootTest
  @EmbeddedKafka
  public class MyFailTest{
  
      @Mock RestTemplate restTemplate;
      @InjectMocks MyFacade facade;
      @InjectMocks MyClient client;
      @InjectMocks KafkaConsumer consumer;
      @Autowired KafkaProducer producer;
  
      @Test
      public void test(){
  
          Mokito.when(restTemplate.exchange(....)).thenReturn(new ResponseEntity&lt;Void&gt;(HttpStatus.OK);)
  
          producer.send(&quot;My Kafka Message&quot;);
      }
  }
  </code></pre>
  <p>here my test dependecies</p>
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.kafka&lt;/groupId&gt;
          &lt;artifactId&gt;spring-kafka-test&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.assertj&lt;/groupId&gt;
          &lt;artifactId&gt;assertj-core&lt;/artifactId&gt;
          &lt;version&gt;3.11.1&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt;
          &lt;artifactId&gt;junit-jupiter-engine&lt;/artifactId&gt;
          &lt;version&gt;5.4.0&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
  </code></pre>
  <p>Junit4 and Springboot 2.6.7</p>
  <p>I think I'm failing in @Mock and @InjecMock logic, i've tried some combination of them ; ) but without success</p>