title: How to mock result from KafkaTemplate
body: <p>I have a method for sending kafka message like this: </p>
  
  <pre><code>@Async
  public void sendMessage(String topicName, Message message) {
      ListenableFuture&lt;SendResult&lt;String, Message &gt;&gt; future = kafkaTemplate.send(topicName, message);
  
      future.addCallback(new ListenableFutureCallback&lt;&gt;() {
  
          @Override
          public void onSuccess(SendResult&lt;String, Message &gt; result) {
              //do nothing
          }
  
          @Override
          public void onFailure(Throwable ex) {
              log.error("something wrong happened"!);
          }
      });
  }
  </code></pre>
  
  <p>And now I am writing unit tests for it. I would like to test also the two callback methods <code>onSuccess</code> and <code>onFailure</code> methods, so my I idea is to mock the KafkaTemplate, something like : </p>
  
  <pre><code>KafkaTemplate kafkaTemplate = Mockito.mock(KafkaTemplate.class);
  </code></pre>
  
  <p>But now I am getting stuck on the mocking result for these two cases:</p>
  
  <pre><code>when(kafkaTemplate.send(anyString(), any(Message.class))).thenReturn(????);
  </code></pre>
  
  <p>what should I put in the <code>thenReturn</code> method for the case success and for the case failure? Does anyone have an idea please? Thank you very much!</p>