mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Polishing in RestTestClient AssertJ support
See gh-35701
This commit is contained in:
+4
-2
@@ -35,12 +35,13 @@ import org.assertj.core.api.Assertions;
|
||||
*/
|
||||
public class CookieMapAssert extends AbstractMapAssert<CookieMapAssert, Map<String, Cookie>, String, Cookie> {
|
||||
|
||||
|
||||
public CookieMapAssert(Cookie[] actual) {
|
||||
super(mapCookies(actual), CookieMapAssert.class);
|
||||
super(toMap(actual), CookieMapAssert.class);
|
||||
as("Cookies");
|
||||
}
|
||||
|
||||
private static Map<String, Cookie> mapCookies(Cookie[] cookies) {
|
||||
private static Map<String, Cookie> toMap(Cookie[] cookies) {
|
||||
Map<String, Cookie> map = new LinkedHashMap<>();
|
||||
for (Cookie cookie : cookies) {
|
||||
map.putIfAbsent(cookie.getName(), cookie);
|
||||
@@ -48,6 +49,7 @@ public class CookieMapAssert extends AbstractMapAssert<CookieMapAssert, Map<Stri
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Verify that the actual cookies contain a cookie with the given {@code name}.
|
||||
* @param name the name of an expected cookie
|
||||
|
||||
+2
-2
@@ -203,9 +203,9 @@ public class ExchangeResult {
|
||||
|
||||
/**
|
||||
* Return a {@link JsonConverterDelegate} based on the configured HTTP message converters.
|
||||
* Mainly for internal use from AssertJ support.
|
||||
* Mainly for internal use from AssertJ support classes.
|
||||
*/
|
||||
public @Nullable JsonConverterDelegate getConverterDelegate() {
|
||||
public @Nullable JsonConverterDelegate getJsonConverterDelegate() {
|
||||
return this.converterDelegate;
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -40,8 +40,7 @@ final class DefaultRestTestClientResponse implements RestTestClientResponse {
|
||||
}
|
||||
|
||||
/**
|
||||
* Use AssertJ's {@link org.assertj.core.api.Assertions#assertThat assertThat}
|
||||
* instead.
|
||||
* Use AssertJ's {@link org.assertj.core.api.Assertions#assertThat assertThat} instead.
|
||||
*/
|
||||
@Override
|
||||
public RestTestClientResponseAssert assertThat() {
|
||||
|
||||
+1
-1
@@ -342,7 +342,7 @@ public class RestTestClientResponseAssert
|
||||
* </code></pre>
|
||||
*/
|
||||
public AbstractJsonContentAssert<?> bodyJson() {
|
||||
return new JsonContentAssert(new JsonContent(readBody(), getExchangeResult().getConverterDelegate()));
|
||||
return new JsonContentAssert(new JsonContent(readBody(), getExchangeResult().getJsonConverterDelegate()));
|
||||
}
|
||||
|
||||
private String readBody() {
|
||||
|
||||
Reference in New Issue
Block a user