title: how to make sure mocked object is called only once in mockito
body: <p>I have a while loop as follows</p>
  
  <pre><code>while (nodeIterator.hasNext())
  </code></pre>
  
  <p>I have mocked this method hasNext to return true so that I can test the code inside while loop  but now the problem is everytime it returns true and this loop will never end. Please tell me is there anyway by which I can make sure that this method is called only once, or if not then how can I return false after first execution </p>