Verify mocked service call with ArgumentCaptor fails
<p>In a test I use a mocked service. I want to check that the service was called once with a specific attribute of one of the parameters.
However, the method is also called mutiple times with other parameters, but I am only interested in the one call above.</p>

<p>My intention was to verify the call with an argument captor to check that the call of interest is invoked only once.
However this fails, because the method is called multiple times and the argument captor is checked afterwards.</p>

<p>See example below: </p>

<pre><code>// service method
void serviceMethod(String someString, MyType myType);

// parameter type
class MyType {
  private String id;
  ...
  String getID() {
    return id;
  }
}

// test verification
ArgumentCaptor&lt;MyType&gt; paramCaptor = ArgumentCaptor.forClass(MyType.class);
// fail in verify 
Mockito.verify(serviceMock, times(1)).serviceMethod(eq("someConstantValue"), paramCaptor);
assertEquals("123", paramCaptor.getValue().getID());
</code></pre>