Skip to content

Commit 8450c69

Browse files
committed
Add ListBodySpec.size implementation
Added implementation for WebTestClient.ListBodySpec.size().
1 parent 262e5f7 commit 8450c69

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClient.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.test.web.reactive.server;
1718

1819
import java.net.URI;
@@ -429,6 +430,9 @@ public <T> EntityExchangeResult<List<T>> isEqualTo(List<T> expected) {
429430

430431
@Override
431432
public ListBodySpec hasSize(int size) {
433+
List<?> actual = this.result.getResponseBody();
434+
String message = "Response body does not contain " + size + " elements";
435+
this.result.assertWithDiagnostics(() -> assertEquals(message, size, actual.size()));
432436
return this;
433437
}
434438

0 commit comments

Comments
 (0)