com.fitbur.mockito.verification.Timeout Maven / Gradle / Ivy
/*
* Copyright (c) 2007 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package com.fitbur.mockito.verification;
import static com.fitbur.mockito.exceptions.Reporter.atMostAndNeverShouldNotBeUsedWithTimeout;
import com.fitbur.mockito.internal.util.Timer;
import com.fitbur.mockito.internal.verification.VerificationModeFactory;
import com.fitbur.mockito.internal.verification.VerificationOverTimeImpl;
/**
* See the javadoc for {@link VerificationWithTimeout}
*
* Typically, you won't use this class explicitly. Instead use timeout() method on Mockito class.
* See javadoc for {@link VerificationWithTimeout}
*/
public class Timeout extends VerificationWrapper implements VerificationWithTimeout {
/**
* See the javadoc for {@link VerificationWithTimeout}
*
* Typically, you won't use this class explicitly. Instead use timeout() method on Mockito class.
* See javadoc for {@link VerificationWithTimeout}
*/
public Timeout(long millis, VerificationMode delegate) {
this(10, millis, delegate);
}
/**
* See the javadoc for {@link VerificationWithTimeout}
*/
Timeout(long pollingPeriodMillis, long millis, VerificationMode delegate) {
this(new VerificationOverTimeImpl(pollingPeriodMillis, millis, delegate, true));
}
/**
* See the javadoc for {@link VerificationWithTimeout}
*/
Timeout(long pollingPeriodMillis, VerificationMode delegate, Timer timer) {
this(new VerificationOverTimeImpl(pollingPeriodMillis, delegate, true, timer));
}
Timeout(VerificationOverTimeImpl verificationOverTime) {
super(verificationOverTime);
}
@Override
protected VerificationMode copySelfWithNewVerificationMode(VerificationMode newVerificationMode) {
return new Timeout(wrappedVerification.copyWithVerificationMode(newVerificationMode));
}
public VerificationMode atMost(int maxNumberOfInvocations) {
throw atMostAndNeverShouldNotBeUsedWithTimeout();
}
public VerificationMode never() {
throw atMostAndNeverShouldNotBeUsedWithTimeout();
}
@Override
public VerificationMode description(String description) {
return VerificationModeFactory.description(this, description);
}
}