title: Mockito.doNothing() keeps returning null pointer exception
body: <p>I know I should not be testing void methods like this, but I am just testing Mockito.doNothing() as of now with a simple example.</p>
  
  <p>My Service class:</p>
  
  <pre><code>@Service
  public class Service{
      @Autowired
      private Consumer&lt;String, String&gt; kafkaConsumer;
  
      public void clearSubscribtions(){
          kafkaConsumer.unsubscribe();
      }
  }
  </code></pre>
  
  <p>My Test class:</p>
  
  <pre><code> @MockBean
   private Consumer&lt;String, String&gt; kafkaConsumer;
  
   @Test
   public void testClearSubscriptions() {
       Service service = new Service();
  
       Mockito.doNothing().when(kafkaConsumer).unsubscribe();
       service.clearSubscriptions();
   }
  </code></pre>
  
  <p>The test keeps failing with a null pointer exception. When I debugged it, it goes into the clearSubscription method of the service class, and there on the line of kafkaConsumer.unsubscribe(), kafkaConsumer is null. But I mocked the consumer, why is it throwing null pointer exception and I should be skipping over that method, right?</p>
  
  <p>Edit:
  All the declarations of the class:</p>
  
  <pre><code>@Autowired
    private Consumer&lt;String, String&gt; kafkaConsumer;
  
    @Autowired
    private Service2 service2;
  
    private final Object lock = new Object();
  
    private static Logger logger = LoggerFactory.getLogger(Service.class);
  
    private HashMap&lt;String, String&gt; subscribedTopics = new HashMap&lt;&gt;();
  </code></pre>
  
  <p>Figured out what was wrong, I needed to auto wire the service</p>