title: Mock a method that returns a future to throw an exception
body: <p>I'm using Java and Mockito to mock some methods for unit testing. I want to mock the producer in the below code so that I can test for the log messages that are sent when the exception is thrown. I tried mocking the future however I get the error that the future.get() method cannot be mocked, and the <code>RecordMetadata</code> class is final and cannot be mocked. Any help would be greatly appreciated.</p>
  
  <p>The producer in the below example is a <code>KafkaProducer</code>.</p>
  
  <pre><code>public void send(Log log){
    Future&lt;RecordMetadata&gt; future = producer.send(new ProducerRecord&lt;(this.topic, record));
    try {
       RecordMetadata recordMetadata = send.get();
    } catch (InterruptedException e) {
       LOG.error("Sending the message to kafka was interrupted. "+e);
    }
  }
  </code></pre>