1/*
2 * Copyright (c) 2007 Mockito contributors
3 * This program is made available under the terms of the MIT License.
4 */
5
6package org.mockito.verification;
7
8import org.mockito.Mockito;
9
10
11/**
12 * VerificationAfterDelay is a {@link VerificationMode} that allows combining existing verification modes with an initial delay, e.g.
13 * <pre class="code"><code class="java">
14 * verify(mock, after(100).atMost(5)).foo();
15 *
16 * verify(mock, after(100).never()).bar();
17 *
18 * verify(mock, after(200).atLeastOnce()).baz();
19 * </code></pre>
20 *
21 * This is similar to {@link VerificationWithTimeout timeout()} except the assertion will not terminate until either the condition is
22 * definitively failed, or the full time has elapsed (whereas timeout() will also stop if the conditions is true at any point, as is
23 * typically the case with never() etc initially).
24 *
25 * <p>
26 * See examples in javadoc for {@link Mockito#verify(Object, VerificationMode)}
27 *
28 */
29public interface VerificationAfterDelay extends VerificationMode {
30
31    /**
32     * Verifies that there are exactly N invocations during the given period. This will wait the full period given.
33     */
34    VerificationMode times(int wantedNumberOfInvocations);
35
36    /**
37     * Allows verification that there are no invocations at any point during the given period. This will wait the
38     * full period given, unless an invocation occurs (in which case there will be immediate failure)
39     */
40    VerificationMode never();
41
42    /**
43     * Verifies that there is at least 1 invocation during the given period. This will wait the full period given.
44     */
45    VerificationMode atLeastOnce();
46
47    /**
48     * Verifies that there is are least N invocations during the given period. This will wait the full period given.
49     */
50    VerificationMode atLeast(int minNumberOfInvocations);
51
52    /**
53     * Verifies that there is are most N invocations during the given period. This will wait the full period given,
54     * unless too many invocations occur (in which case there will be an immediate failure)
55     */
56    VerificationMode atMost(int maxNumberOfInvocations);
57
58    /**
59     * Verifies that there the given method is invoked and is the only method invoked. This will wait the full
60     * period given, unless another method is invoked (in which case there will be an immediate failure)
61     */
62    VerificationMode only();
63
64}
65