Class VerificationOverTimeImpl
java.lang.Object
org.mockito.internal.verification.VerificationOverTimeImpl
- All Implemented Interfaces:
VerificationMode
Verifies that another verification mode (the delegate) is satisfied within a certain timeframe
(before timeoutMillis has passed, measured from the call to verify()), and either returns immediately
once it does, or waits until it is definitely satisfied once the full time has passed.
-
Constructor Summary
ConstructorsConstructorDescriptionVerificationOverTimeImpl
(long pollingPeriodMillis, long durationMillis, VerificationMode delegate, boolean returnOnSuccess) Create this verification mode, to be used to verify invocation ongoing data later.VerificationOverTimeImpl
(long pollingPeriodMillis, long durationMillis, VerificationMode delegate, boolean returnOnSuccess, Timer timer) Create this verification mode, to be used to verify invocation ongoing data later. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
canRecoverFromFailure
(VerificationMode verificationMode) long
long
void
verify
(VerificationData data) Verify the given ongoing verification data, and confirm that it satisfies the delegate verification mode before the full duration has passed.
-
Constructor Details
-
VerificationOverTimeImpl
public VerificationOverTimeImpl(long pollingPeriodMillis, long durationMillis, VerificationMode delegate, boolean returnOnSuccess) Create this verification mode, to be used to verify invocation ongoing data later.- Parameters:
pollingPeriodMillis
- The frequency to poll delegate.verify(), to check whether the delegate has been satisfieddurationMillis
- The max time to wait (in millis) for the delegate verification mode to be satisfieddelegate
- The verification mode to delegate overall success or failure toreturnOnSuccess
- Whether to immediately return successfully once the delegate is satisfied (as inVerificationWithTimeout
, or to only return once the delegate is satisfied and the full duration has passed (as inVerificationAfterDelay
).
-
VerificationOverTimeImpl
public VerificationOverTimeImpl(long pollingPeriodMillis, long durationMillis, VerificationMode delegate, boolean returnOnSuccess, Timer timer) Create this verification mode, to be used to verify invocation ongoing data later.- Parameters:
pollingPeriodMillis
- The frequency to poll delegate.verify(), to check whether the delegate has been satisfieddurationMillis
- The max time to wait (in millis) for the delegate verification mode to be satisfieddelegate
- The verification mode to delegate overall success or failure toreturnOnSuccess
- Whether to immediately return successfully once the delegate is satisfied (as inVerificationWithTimeout
, or to only return once the delegate is satisfied and the full duration has passed (as inVerificationAfterDelay
).timer
- Checker of whether the duration of the verification is still acceptable
-
-
Method Details
-
verify
Verify the given ongoing verification data, and confirm that it satisfies the delegate verification mode before the full duration has passed. In practice, this polls the delegate verification mode until it is satisfied. If it is not satisfied once the full duration has passed, the last error returned by the delegate verification mode will be thrown here in turn. This may be thrown early if the delegate is unsatisfied and the verification mode is known to never recover from this situation (e.g.AtMost
). If it is satisfied before the full duration has passed, behaviour is dependent on the returnOnSuccess parameter given in the constructor. If true, this verification mode is immediately satisfied once the delegate is. If false, this verification mode is not satisfied until the delegate is satisfied and the full time has passed.- Specified by:
verify
in interfaceVerificationMode
- Throws:
MockitoAssertionError
- if the delegate verification mode does not succeed before the timeout
-
canRecoverFromFailure
-
getPollingPeriod
public long getPollingPeriod() -
getDuration
public long getDuration() -
getDelegate
-