Verifier { public <T> T collectiveVerify(Class<T> mockClass, Collection<T> collection) { return collectiveVerify(mockClass, collection, times(1)); }  T collectiveVerify(Class<T> mockClass, Collection<T> collection); T collectiveVerify(Class<T> mockClass, Collection<T> collection, VerificationMode mode); void collectiveVerifyZeroInteractions(Collection<T>... mocks); void collectiveVerifyNoMoreInteractions(Collection<T>... mocks);  }
@Test public void shouldCollectiveVerifyGivenWantedButNotInvoked() throws IOException { Closeable mock = mock(Closeable.class); Collection<Closeable> collection = Collections.singleton(mock); thrown.expect(new ThrowableCausedByMatcher(WantedButNotInvoked.class)); verification.collectiveVerify(Closeable.class, collection).close(); }
@Test public void shouldCollectiveVerifyGivenWantedAndInvoked() throws IOException { Closeable mock = mock(Closeable.class); mock.close(); Collection<Closeable> collection = Collections.singleton(mock); verification.collectiveVerify(Closeable.class, collection).close(); }
@Test public void shouldCollectiveVerifyGivenWantedButNotAllInvoked() throws IOException { Closeable mock1 = mock(Closeable.class); Closeable mock2 = mock(Closeable.class); mock1.close(); Collection<Closeable> collection = Arrays.asList(mock1, mock2); thrown.expect(new ThrowableCausedByMatcher(WantedButNotInvoked.class)); verification.collectiveVerify(Closeable.class, collection).close(); }