Avoid nullability warnings
This commit is contained in:
parent
2a268701c4
commit
15a6373fed
|
@ -17,6 +17,7 @@
|
||||||
package org.springframework.test.web.reactive.server;
|
package org.springframework.test.web.reactive.server;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import org.hamcrest.Matcher;
|
import org.hamcrest.Matcher;
|
||||||
|
@ -210,10 +211,10 @@ public class CookieAssertions {
|
||||||
private ResponseCookie getCookie(String name) {
|
private ResponseCookie getCookie(String name) {
|
||||||
ResponseCookie cookie = this.exchangeResult.getResponseCookies().getFirst(name);
|
ResponseCookie cookie = this.exchangeResult.getResponseCookies().getFirst(name);
|
||||||
if (cookie == null) {
|
if (cookie == null) {
|
||||||
String message = "No cookie with name '" + name + "'";
|
this.exchangeResult.assertWithDiagnostics(() ->
|
||||||
this.exchangeResult.assertWithDiagnostics(() -> AssertionErrors.fail(message));
|
AssertionErrors.fail("No cookie with name '" + name + "'"));
|
||||||
}
|
}
|
||||||
return cookie;
|
return Objects.requireNonNull(cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getMessage(String cookie) {
|
private String getMessage(String cookie) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2020 the original author or authors.
|
* Copyright 2002-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -19,6 +19,7 @@ package org.springframework.test.web.reactive.server;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import org.hamcrest.Matcher;
|
import org.hamcrest.Matcher;
|
||||||
|
@ -73,7 +74,7 @@ public class HeaderAssertions {
|
||||||
String actual = getHeaders().getFirst(headerName);
|
String actual = getHeaders().getFirst(headerName);
|
||||||
this.exchangeResult.assertWithDiagnostics(() ->
|
this.exchangeResult.assertWithDiagnostics(() ->
|
||||||
assertTrue("Response does not contain header '" + headerName + "'", actual != null));
|
assertTrue("Response does not contain header '" + headerName + "'", actual != null));
|
||||||
return assertHeader(headerName, value, Long.parseLong(actual));
|
return assertHeader(headerName, value, Long.parseLong(Objects.requireNonNull(actual)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -203,7 +204,7 @@ public class HeaderAssertions {
|
||||||
this.exchangeResult.assertWithDiagnostics(() ->
|
this.exchangeResult.assertWithDiagnostics(() ->
|
||||||
AssertionErrors.fail(getMessage(name) + " not found"));
|
AssertionErrors.fail(getMessage(name) + " not found"));
|
||||||
}
|
}
|
||||||
return values;
|
return Objects.requireNonNull(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue