mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Upgrade to NullAway 0.12.10 and refine nullability
Closes gh-35492
This commit is contained in:
+7
-8
@@ -596,7 +596,6 @@ class DefaultWebTestClient implements WebTestClient {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1129
|
||||
public <T extends S> T value(Consumer<@Nullable B> consumer) {
|
||||
this.result.assertWithDiagnostics(() -> consumer.accept(this.result.getResponseBody()));
|
||||
return self();
|
||||
@@ -620,7 +619,7 @@ class DefaultWebTestClient implements WebTestClient {
|
||||
}
|
||||
|
||||
|
||||
private static class DefaultListBodySpec<E> extends DefaultBodySpec<List<@Nullable E>, ListBodySpec<E>>
|
||||
private static class DefaultListBodySpec<E extends @Nullable Object> extends DefaultBodySpec<List<E>, ListBodySpec<E>>
|
||||
implements ListBodySpec<E> {
|
||||
|
||||
DefaultListBodySpec(EntityExchangeResult<List<E>> result) {
|
||||
@@ -629,7 +628,7 @@ class DefaultWebTestClient implements WebTestClient {
|
||||
|
||||
@Override
|
||||
public ListBodySpec<E> hasSize(int size) {
|
||||
List<@Nullable E> actual = getResult().getResponseBody();
|
||||
List<E> actual = getResult().getResponseBody();
|
||||
String message = "Response body does not contain " + size + " elements";
|
||||
getResult().assertWithDiagnostics(() ->
|
||||
AssertionErrors.assertEquals(message, size, (actual != null ? actual.size() : 0)));
|
||||
@@ -638,9 +637,9 @@ class DefaultWebTestClient implements WebTestClient {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public ListBodySpec<E> contains(@Nullable E... elements) {
|
||||
public ListBodySpec<E> contains(E... elements) {
|
||||
List<E> expected = Arrays.asList(elements);
|
||||
List<@Nullable E> actual = getResult().getResponseBody();
|
||||
List<E> actual = getResult().getResponseBody();
|
||||
String message = "Response body does not contain " + expected;
|
||||
getResult().assertWithDiagnostics(() ->
|
||||
AssertionErrors.assertTrue(message, (actual != null && actual.containsAll(expected))));
|
||||
@@ -649,9 +648,9 @@ class DefaultWebTestClient implements WebTestClient {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public ListBodySpec<E> doesNotContain(@Nullable E... elements) {
|
||||
public ListBodySpec<E> doesNotContain(E... elements) {
|
||||
List<E> expected = Arrays.asList(elements);
|
||||
List<@Nullable E> actual = getResult().getResponseBody();
|
||||
List<E> actual = getResult().getResponseBody();
|
||||
String message = "Response body should not have contained " + expected;
|
||||
getResult().assertWithDiagnostics(() ->
|
||||
AssertionErrors.assertTrue(message, (actual == null || !actual.containsAll(expected))));
|
||||
@@ -659,7 +658,7 @@ class DefaultWebTestClient implements WebTestClient {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityExchangeResult<List<@Nullable E>> returnResult() {
|
||||
public EntityExchangeResult<List<E>> returnResult() {
|
||||
return getResult();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -975,7 +975,7 @@ public interface WebTestClient {
|
||||
*
|
||||
* @param <E> the body list element type
|
||||
*/
|
||||
interface ListBodySpec<E> extends BodySpec<List<@Nullable E>, ListBodySpec<E>> {
|
||||
interface ListBodySpec<E extends @Nullable Object> extends BodySpec<List<E>, ListBodySpec<E>> {
|
||||
|
||||
/**
|
||||
* Assert the extracted list of values is of the given size.
|
||||
@@ -988,14 +988,14 @@ public interface WebTestClient {
|
||||
* @param elements the elements to check
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
ListBodySpec<E> contains(@Nullable E... elements);
|
||||
ListBodySpec<E> contains(E... elements);
|
||||
|
||||
/**
|
||||
* Assert the extracted list of values doesn't contain the given elements.
|
||||
* @param elements the elements to check
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
ListBodySpec<E> doesNotContain(@Nullable E... elements);
|
||||
ListBodySpec<E> doesNotContain(E... elements);
|
||||
}
|
||||
|
||||
|
||||
|
||||
-2
@@ -367,7 +367,6 @@ class DefaultRestTestClient implements RestTestClient {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1129
|
||||
public <T extends S, R> T value(Function<@Nullable B, @Nullable R> bodyMapper, Matcher<? super @Nullable R> matcher) {
|
||||
this.result.assertWithDiagnostics(() -> {
|
||||
B body = this.result.getResponseBody();
|
||||
@@ -377,7 +376,6 @@ class DefaultRestTestClient implements RestTestClient {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("NullAway") // https://github.com/uber/NullAway/issues/1129
|
||||
public <T extends S> T value(Consumer<@Nullable B> consumer) {
|
||||
this.result.assertWithDiagnostics(() -> consumer.accept(this.result.getResponseBody()));
|
||||
return self();
|
||||
|
||||
Reference in New Issue
Block a user