title: Mockito - ignore order when verifying a method with varargs
body: <p>First of all I'll present some code:</p>
  
  <pre><code>    class ResourceContainerTest {
  
          // Normally, in beforeTest
          ResourceContainer container = mock(ResourceContainer.class);
  
          @Test
          public void testClearResources(){
              container.addResources("resource1");
              container.addResources("resource2");
              container.addResources("resource3");
              container.removeResources("resource3");
  
              // the following line should invoke 
              // container.removeResources("resource1", "resource2") 
              // or container.removeResources("resource1", "resource2"):
              container.clearResources();  
  
              // Now, let's verify it:
              verifyThatRemoveResourcesWasInvokedForVararg("resource1", "resource2");
          }
  
          private void verifyThatRemoveResourcesWasInvokedForVararg(String... resourceNameList){
              verify(container).removeResources(resourceNameList);
          }
      }
  </code></pre>
  
  <p>In this short example I want to test if <code>resource1</code> and <code>resource2</code> will be removed in one invocation of removeResources(). </p>
  
  <p><strong>The question is how can I ignore the order of vararg so the test will be passed for both <code>verifyThatRemoveResourcesWasInvokedForVararg("resource1", "resource2")</code> and <code>verifyThatRemoveResourcesWasInvokedForVararg("resource2", "resource1")</code> ?</strong> </p>
  
  <p>I've already tried an approach with <code>ArgumentCaptor</code>:</p>
  
  <pre><code>ArgumentCaptor&lt;String&gt; resNamesCaptor = ArgumentCaptor.forClass(String.class);
          verify(container).removeResources(resNamesCaptor.capture());
          Assert.assertEquals(new HashSet&lt;&gt;(Arrays.asList(resourceNameList)), new HashSet&lt;&gt;(resNamesCaptor.getAllValues()));
  </code></pre>
  
  <p>but in this case I get an <code>org.mockito.exceptions.verification.TooManyActualInvocations</code>  </p>
  
  <p>Any tips?</p>