Use modern language features in tests
This commit is contained in:
@@ -52,8 +52,7 @@ public abstract class AbstractHttpHandlerIntegrationTests {
|
||||
*/
|
||||
@RegisterExtension
|
||||
TestExecutionExceptionHandler serverErrorToAssertionErrorConverter = (context, throwable) -> {
|
||||
if (throwable instanceof HttpServerErrorException) {
|
||||
HttpServerErrorException ex = (HttpServerErrorException) throwable;
|
||||
if (throwable instanceof HttpServerErrorException ex) {
|
||||
String responseBody = ex.getResponseBodyAsString();
|
||||
if (StringUtils.hasText(responseBody)) {
|
||||
String prefix = AssertionError.class.getName() + ": ";
|
||||
|
||||
@@ -1282,8 +1282,7 @@ public class MockHttpServletRequest implements HttpServletRequest {
|
||||
|
||||
public void setSession(HttpSession session) {
|
||||
this.session = session;
|
||||
if (session instanceof MockHttpSession) {
|
||||
MockHttpSession mockSession = ((MockHttpSession) session);
|
||||
if (session instanceof MockHttpSession mockSession) {
|
||||
mockSession.access();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -447,8 +447,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
if (cookie.isHttpOnly()) {
|
||||
buf.append("; HttpOnly");
|
||||
}
|
||||
if (cookie instanceof MockCookie) {
|
||||
MockCookie mockCookie = (MockCookie) cookie;
|
||||
if (cookie instanceof MockCookie mockCookie) {
|
||||
if (StringUtils.hasText(mockCookie.getSameSite())) {
|
||||
buf.append("; SameSite=").append(mockCookie.getSameSite());
|
||||
}
|
||||
|
||||
@@ -57,8 +57,7 @@ public class Pojo {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o instanceof Pojo) {
|
||||
Pojo other = (Pojo) o;
|
||||
if (o instanceof Pojo other) {
|
||||
return this.foo.equals(other.foo) && this.bar.equals(other.bar);
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user