Skip to content

Commit 4f8eca1

Browse files
committed
Order methods that take a type as a lambda consistently
Closes gh-32062
1 parent 18ea43c commit 4f8eca1

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -146,10 +146,21 @@ public <T> WebTestClient.BodyContentSpec value(Matcher<? super T> matcher) {
146146
return this.bodySpec;
147147
}
148148

149+
/**
150+
* Delegates to {@link JsonPathExpectationsHelper#assertValue(String, Matcher, Class)}.
151+
* @since 6.2
152+
*/
153+
public <T> WebTestClient.BodyContentSpec value(Class<T> targetType, Matcher<? super T> matcher) {
154+
this.pathHelper.assertValue(this.content, matcher, targetType);
155+
return this.bodySpec;
156+
}
157+
149158
/**
150159
* Delegates to {@link JsonPathExpectationsHelper#assertValue(String, Matcher, Class)}.
151160
* @since 5.1
161+
* @deprecated in favor of {@link #value(Class, Matcher)}
152162
*/
163+
@Deprecated(since = "6.2", forRemoval = true)
153164
public <T> WebTestClient.BodyContentSpec value(Matcher<? super T> matcher, Class<T> targetType) {
154165
this.pathHelper.assertValue(this.content, matcher, targetType);
155166
return this.bodySpec;
@@ -168,15 +179,24 @@ public <T> WebTestClient.BodyContentSpec value(Consumer<T> consumer) {
168179

169180
/**
170181
* Consume the result of the JSONPath evaluation and provide a target class.
171-
* @since 5.1
182+
* @since 6.2
172183
*/
173184
@SuppressWarnings("unchecked")
174-
public <T> WebTestClient.BodyContentSpec value(Consumer<T> consumer, Class<T> targetType) {
185+
public <T> WebTestClient.BodyContentSpec value(Class<T> targetType, Consumer<T> consumer) {
175186
Object value = this.pathHelper.evaluateJsonPath(this.content, targetType);
176187
consumer.accept((T) value);
177188
return this.bodySpec;
178189
}
179190

191+
/**
192+
* Consume the result of the JSONPath evaluation and provide a target class.
193+
* @since 5.1
194+
* @deprecated in favor of {@link #value(Class, Consumer)}
195+
*/
196+
@Deprecated(since = "6.2", forRemoval = true)
197+
public <T> WebTestClient.BodyContentSpec value(Consumer<T> consumer, Class<T> targetType) {
198+
return value(targetType, consumer);
199+
}
180200

181201
@Override
182202
public boolean equals(@Nullable Object obj) {

spring-test/src/test/java/org/springframework/test/web/servlet/samples/client/standalone/ResponseBodyTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -48,7 +48,7 @@ void json() {
4848
.jsonPath("$.name").isEqualTo("Lee")
4949
.jsonPath("$.age").isEqualTo(42)
5050
.jsonPath("$.age").value(equalTo(42))
51-
.jsonPath("$.age").value(equalTo(42.0f), Float.class);
51+
.jsonPath("$.age").value(Float.class, equalTo(42.0f));
5252
}
5353

5454

0 commit comments

Comments
 (0)