title: Mockito Mock a method call called twice
body: <p>I am trying to use mockito to mock a method. However the class I am injecting mocks with calls the method twice while sending in two different objects of the same type, but depending the values in the object determine the output of the method. </p>
  
  <p>So, for example, If I am trying to mock</p>
  
  <pre><code>public ArrayList&lt;example&gt; attemptToMock(testObject testing)
  </code></pre>
  
  <p>Lets sat type <code>testObject</code> has a string value in it.</p>
  
  <p>So if the string value in testObject is "OK" then <code>attemptToMock</code> should output an array of two objects in it. If <code>testObject</code> string value is "NO" then the Array list sent out only has one Object.</p>
  
  <p>How to I write a test to handle a call so that a class can call <code>attemptToMock</code> twice, within the same method, and I can mock out its output it so depending on the values within <code>testObject</code>. I can mock it to send out different arrays.</p>