title: Mockito verify throws UnfinishedVerificationException
body: <p>In a test, I am using a mockobject:</p>
  
  <pre><code>@Mock
  ListMultipleChoice&lt;String&gt; listMultipleChoiceMock;
  </code></pre>
  
  <p>I try to verify the use of its methods:</p>
  
  <pre><code>verify(listMultipleChoiceMock).setRequired(true);
  verify(listMultipleChoiceMock).setMaxRows(2);
  verify(listMultipleChoiceMock).setDefaultModel(any(IModel.class));
  </code></pre>
  
  <p>But it throws the following exception:</p>
  
  <blockquote>
    <p>org.mockito.exceptions.misusing.UnfinishedVerificationException: 
    Missing method call for verify(mock) here:</p>
  </blockquote>
  
  <p>The exception points at this line:</p>
  
  <pre><code>verify(listMultipleChoiceMock).setMaxRows(2);
  </code></pre>
  
  <p>setMaxRows accepts an int.</p>
  
  <p>When I comment this line out, the test succeeds. When I debug my program, I can see the method setMaxRows being set:</p>
  
  <pre><code>brandsListMultipleChoice.setMaxRows(brandLabels.size());
  </code></pre>
  
  <p>brandLabels is a List and size() returns an int.</p>
  
  <p>I check the size of brandLabels and it is 2. I have tried anyInt() and 0 as well, both result in an exception being thrown.</p>
  
  <p>What am I doing wrong? Why is this verification not succeeding?</p>
  
  <p>Here is an example of my code, which will fail:</p>
  
  <pre><code>import org.apache.wicket.markup.html.form.ListMultipleChoice;
  import org.junit.Before;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  import org.mockito.Mock;
  import org.powermock.core.classloader.annotations.PrepareForTest;
  import org.powermock.modules.junit4.PowerMockRunner;
  
  import static org.mockito.Matchers.anyObject;
  import static org.mockito.Mockito.verify;
  import static org.powermock.api.mockito.PowerMockito.whenNew;
  
  @RunWith(PowerMockRunner.class)
  @PrepareForTest({Example.class})
  public class ExampleTest {
  
      @Mock
      ListMultipleChoice&lt;String&gt; brandsListMultipleChoiceMock;
  
      @Before
      public void setUp() throws Exception {
          whenNew(ListMultipleChoice.class).withAnyArguments().thenReturn(brandsListMultipleChoiceMock);
  
          Example example = new Example();
      }
  
      @Test
      public void test() throws Exception {
          verify(brandsListMultipleChoiceMock).setRequired(true);
          verify(brandsListMultipleChoiceMock).setMaxRows(1);
          verify(brandsListMultipleChoiceMock).setDefaultModel(anyObject());
  
      }
  }
  </code></pre>
  
  <p>And the class being tested:</p>
  
  <pre><code>import org.apache.wicket.markup.html.form.ListMultipleChoice;
  import org.apache.wicket.model.IModel;
  import org.apache.wicket.model.PropertyModel;
  
  import java.util.ArrayList;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Set;
  
  public class Example {
  
      private ListMultipleChoice&lt;String&gt; brandsListMultipleChoice;
  
      public Example() {
  
          List&lt;String&gt; brandLabels = new ArrayList&lt;&gt;();
          brandLabels.add("DEMO");
  
          brandsListMultipleChoice = new ListMultipleChoice&lt;&gt;("brands", new PropertyModel&lt;Set&lt;String&gt;&gt;(this, "brandProperty"), brandLabels);
          brandsListMultipleChoice.setRequired(true);
          brandsListMultipleChoice.setMaxRows(brandLabels.size());
          brandsListMultipleChoice.setDefaultModel(new IModel&lt;Set&lt;String&gt;&gt;() {
              private Set&lt;String&gt; list = new HashSet&lt;&gt;();
  
              @Override
              public Set&lt;String&gt; getObject() {
                  return list;
              }
  
              @Override
              public void setObject(Set&lt;String&gt; ts) {
                  list = ts;
              }
  
              @Override
              public void detach() {
              }
          });
      }
  }
  </code></pre>
  
  <p>When I comment out either the second or the third verify rule, the test succeeds.</p>