title: How to stop method calling a method in another class in Mockito?
body: <p>I have the following method to test in my <code>Java</code> service class:</p>
  
  <pre><code>public void findPersonToDelete(String id){
  
      //repository method then called
     personRepository.findPersonAndDelete(id);
  
  
  }
  </code></pre>
  
  <p>The issue is that the personRepository calls other code which throws a <code>Null Pointer</code>. </p>
  
  <p>I tried to use the following line to stop the personRepository from calling other methods:</p>
  
  <pre><code>  Mockito.doNothing().when(personRepository).findPersonAndDelete(id);
  </code></pre>
  
  <p>However the error is still persisting? How can I fix this?</p>