Polishing in RestTestClient AssertJ support

See gh-35701
This commit is contained in:
rstoyanchev
2025-11-04 12:29:11 +00:00
parent 125002844e
commit cd8690254b
4 changed files with 8 additions and 7 deletions
@@ -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
@@ -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;
}
@@ -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() {
@@ -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() {