Add ExpectedCount#never()
Issue: SPR-15168
This commit is contained in:
@@ -137,6 +137,7 @@ public class DefaultRequestExpectation implements RequestExpectation {
|
||||
}
|
||||
|
||||
public boolean isSatisfied() {
|
||||
// Only validate min count since max count is checked on every request...
|
||||
return (getMatchedRequestCount() >= getExpectedCount().getMinCount());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,6 +32,7 @@ import org.springframework.util.Assert;
|
||||
* min(2)
|
||||
* max(4)
|
||||
* between(2, 4)
|
||||
* never()
|
||||
* </pre>
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -49,7 +50,7 @@ public class ExpectedCount {
|
||||
* See static factory methods in this class.
|
||||
*/
|
||||
private ExpectedCount(int minCount, int maxCount) {
|
||||
Assert.isTrue(minCount >= 1, "minCount >= 0 is required");
|
||||
Assert.isTrue(minCount >= 0, "minCount >= 0 is required");
|
||||
Assert.isTrue(maxCount >= minCount, "maxCount >= minCount is required");
|
||||
this.minCount = minCount;
|
||||
this.maxCount = maxCount;
|
||||
@@ -116,6 +117,14 @@ public class ExpectedCount {
|
||||
return new ExpectedCount(1, max);
|
||||
}
|
||||
|
||||
/**
|
||||
* No calls expected at all, i.e. min=0 and max=0.
|
||||
* @since 4.3.6
|
||||
*/
|
||||
public static ExpectedCount never() {
|
||||
return new ExpectedCount(0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Between {@code min} and {@code max} number of times.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user