1e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin/* 2e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin * Copyright (c) 2007 Mockito contributors 3e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin * This program is made available under the terms of the MIT License. 4e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin */ 5e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin 6e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffinpackage org.mockito.verification; 7e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin 8e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffinimport org.mockito.Mockito; 9e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin 10e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin 11e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin/** 122637d96c202372854a7c71466ddcc6e90fc4fc53Paul Duffin * VerificationAfterDelay is a {@link VerificationMode} that allows combining existing verification modes with an initial delay, e.g. 13e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin * <pre class="code"><code class="java"> 14e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin * verify(mock, after(100).atMost(5)).foo(); 152637d96c202372854a7c71466ddcc6e90fc4fc53Paul Duffin * 16e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin * verify(mock, after(100).never()).bar(); 172637d96c202372854a7c71466ddcc6e90fc4fc53Paul Duffin * 18e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin * verify(mock, after(200).atLeastOnce()).baz(); 19e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin * </code></pre> 202637d96c202372854a7c71466ddcc6e90fc4fc53Paul Duffin * 212637d96c202372854a7c71466ddcc6e90fc4fc53Paul Duffin * This is similar to {@link VerificationWithTimeout timeout()} except the assertion will not terminate until either the condition is 22e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin * definitively failed, or the full time has elapsed (whereas timeout() will also stop if the conditions is true at any point, as is 232637d96c202372854a7c71466ddcc6e90fc4fc53Paul Duffin * typically the case with never() etc initially). 242637d96c202372854a7c71466ddcc6e90fc4fc53Paul Duffin * 25e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin * <p> 26e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin * See examples in javadoc for {@link Mockito#verify(Object, VerificationMode)} 27e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin * 28e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin */ 29e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffinpublic interface VerificationAfterDelay extends VerificationMode { 302637d96c202372854a7c71466ddcc6e90fc4fc53Paul Duffin 31e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin /** 32e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin * Verifies that there are exactly N invocations during the given period. This will wait the full period given. 33e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin */ 342637d96c202372854a7c71466ddcc6e90fc4fc53Paul Duffin VerificationMode times(int wantedNumberOfInvocations); 35e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin 36e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin /** 372637d96c202372854a7c71466ddcc6e90fc4fc53Paul Duffin * Allows verification that there are no invocations at any point during the given period. This will wait the 38e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin * full period given, unless an invocation occurs (in which case there will be immediate failure) 39e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin */ 402637d96c202372854a7c71466ddcc6e90fc4fc53Paul Duffin VerificationMode never(); 412637d96c202372854a7c71466ddcc6e90fc4fc53Paul Duffin 42e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin /** 43e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin * Verifies that there is at least 1 invocation during the given period. This will wait the full period given. 44e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin */ 452637d96c202372854a7c71466ddcc6e90fc4fc53Paul Duffin VerificationMode atLeastOnce(); 462637d96c202372854a7c71466ddcc6e90fc4fc53Paul Duffin 47e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin /** 48e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin * Verifies that there is are least N invocations during the given period. This will wait the full period given. 49e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin */ 502637d96c202372854a7c71466ddcc6e90fc4fc53Paul Duffin VerificationMode atLeast(int minNumberOfInvocations); 512637d96c202372854a7c71466ddcc6e90fc4fc53Paul Duffin 52e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin /** 53e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin * Verifies that there is are most N invocations during the given period. This will wait the full period given, 54e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin * unless too many invocations occur (in which case there will be an immediate failure) 55e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin */ 562637d96c202372854a7c71466ddcc6e90fc4fc53Paul Duffin VerificationMode atMost(int maxNumberOfInvocations); 572637d96c202372854a7c71466ddcc6e90fc4fc53Paul Duffin 58e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin /** 592637d96c202372854a7c71466ddcc6e90fc4fc53Paul Duffin * Verifies that there the given method is invoked and is the only method invoked. This will wait the full 60e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin * period given, unless another method is invoked (in which case there will be an immediate failure) 61e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin */ 622637d96c202372854a7c71466ddcc6e90fc4fc53Paul Duffin VerificationMode only(); 632637d96c202372854a7c71466ddcc6e90fc4fc53Paul Duffin 64e03a0f42b85425bffd40bcf790819671a7848c1aPaul Duffin} 65