From aa8802a81d1312386b71786711dbef8639cd35f3 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 31 May 2022 16:13:31 +0200 Subject: [PATCH] Avoid new AssertJ deprecations --- .../format/datetime/DateFormattingTests.java | 18 ++++++++--------- .../standard/DateTimeFormattingTests.java | 20 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/spring-context/src/test/java/org/springframework/format/datetime/DateFormattingTests.java b/spring-context/src/test/java/org/springframework/format/datetime/DateFormattingTests.java index 77db53f069..948040c3b4 100644 --- a/spring-context/src/test/java/org/springframework/format/datetime/DateFormattingTests.java +++ b/spring-context/src/test/java/org/springframework/format/datetime/DateFormattingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -132,11 +132,11 @@ public class DateFormattingTests { TypeMismatchException exception = fieldError.unwrap(TypeMismatchException.class); assertThat(exception) .hasMessageContaining("for property 'styleDate'") - .hasCauseInstanceOf(ConversionFailedException.class).getCause() + .hasCauseInstanceOf(ConversionFailedException.class).cause() .hasMessageContaining("for value '99/01/01'") - .hasCauseInstanceOf(IllegalArgumentException.class).getCause() + .hasCauseInstanceOf(IllegalArgumentException.class).cause() .hasMessageContaining("Parse attempt failed for value [99/01/01]") - .hasCauseInstanceOf(ParseException.class).getCause() + .hasCauseInstanceOf(ParseException.class).cause() // Unable to parse date time value "99/01/01" using configuration from // @org.springframework.format.annotation.DateTimeFormat(pattern=, style=S-, iso=NONE, fallbackPatterns=[]) // We do not check "fallbackPatterns=[]", since the array representation in the toString() @@ -147,7 +147,7 @@ public class DateFormattingTests { "Unable to parse date time value \"99/01/01\" using configuration from", "@org.springframework.format.annotation.DateTimeFormat", "style=", "S-", "iso=NONE") - .hasCauseInstanceOf(ParseException.class).getCause() + .hasCauseInstanceOf(ParseException.class).cause() .hasMessageStartingWith("Unparseable date: \"99/01/01\"") .hasNoCause(); } @@ -352,11 +352,11 @@ public class DateFormattingTests { FieldError fieldError = bindingResult.getFieldError(propertyName); assertThat(fieldError.unwrap(TypeMismatchException.class)) .hasMessageContaining("for property 'patternDateWithFallbackPatterns'") - .hasCauseInstanceOf(ConversionFailedException.class).getCause() + .hasCauseInstanceOf(ConversionFailedException.class).cause() .hasMessageContaining("for value '210302'") - .hasCauseInstanceOf(IllegalArgumentException.class).getCause() + .hasCauseInstanceOf(IllegalArgumentException.class).cause() .hasMessageContaining("Parse attempt failed for value [210302]") - .hasCauseInstanceOf(ParseException.class).getCause() + .hasCauseInstanceOf(ParseException.class).cause() // Unable to parse date time value "210302" using configuration from // @org.springframework.format.annotation.DateTimeFormat( // pattern=yyyy-MM-dd, style=SS, iso=NONE, fallbackPatterns=[M/d/yy, yyyyMMdd, yyyy.MM.dd]) @@ -364,7 +364,7 @@ public class DateFormattingTests { "Unable to parse date time value \"210302\" using configuration from", "@org.springframework.format.annotation.DateTimeFormat", "yyyy-MM-dd", "M/d/yy", "yyyyMMdd", "yyyy.MM.dd") - .hasCauseInstanceOf(ParseException.class).getCause() + .hasCauseInstanceOf(ParseException.class).cause() .hasMessageStartingWith("Unparseable date: \"210302\"") .hasNoCause(); } diff --git a/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormattingTests.java b/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormattingTests.java index 23a62770fd..142bd6b28b 100644 --- a/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormattingTests.java +++ b/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormattingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -332,11 +332,11 @@ class DateTimeFormattingTests { FieldError fieldError = bindingResult.getFieldError(propertyName); assertThat(fieldError.unwrap(TypeMismatchException.class)) .hasMessageContaining("for property 'isoLocalDate'") - .hasCauseInstanceOf(ConversionFailedException.class).getCause() + .hasCauseInstanceOf(ConversionFailedException.class).cause() .hasMessageContaining("for value '2009-31-10'") - .hasCauseInstanceOf(IllegalArgumentException.class).getCause() + .hasCauseInstanceOf(IllegalArgumentException.class).cause() .hasMessageContaining("Parse attempt failed for value [2009-31-10]") - .hasCauseInstanceOf(DateTimeParseException.class).getCause() + .hasCauseInstanceOf(DateTimeParseException.class).cause() // Unable to parse date time value "2009-31-10" using configuration from // @org.springframework.format.annotation.DateTimeFormat(pattern=, style=SS, iso=DATE, fallbackPatterns=[]) // We do not check "fallbackPatterns=[]", since the array representation in the toString() @@ -344,9 +344,9 @@ class DateTimeFormattingTests { .hasMessageContainingAll( "Unable to parse date time value \"2009-31-10\" using configuration from", "@org.springframework.format.annotation.DateTimeFormat", "iso=DATE") - .hasCauseInstanceOf(DateTimeParseException.class).getCause() + .hasCauseInstanceOf(DateTimeParseException.class).cause() .hasMessageStartingWith("Text '2009-31-10'") - .hasCauseInstanceOf(DateTimeException.class).getCause() + .hasCauseInstanceOf(DateTimeException.class).cause() .hasMessageContaining("Invalid value for MonthOfYear (valid values 1 - 12): 31") .hasNoCause(); } @@ -539,11 +539,11 @@ class DateTimeFormattingTests { FieldError fieldError = bindingResult.getFieldError(propertyName); assertThat(fieldError.unwrap(TypeMismatchException.class)) .hasMessageContaining("for property 'patternLocalDateWithFallbackPatterns'") - .hasCauseInstanceOf(ConversionFailedException.class).getCause() + .hasCauseInstanceOf(ConversionFailedException.class).cause() .hasMessageContaining("for value '210302'") - .hasCauseInstanceOf(IllegalArgumentException.class).getCause() + .hasCauseInstanceOf(IllegalArgumentException.class).cause() .hasMessageContaining("Parse attempt failed for value [210302]") - .hasCauseInstanceOf(DateTimeParseException.class).getCause() + .hasCauseInstanceOf(DateTimeParseException.class).cause() // Unable to parse date time value "210302" using configuration from // @org.springframework.format.annotation.DateTimeFormat( // pattern=yyyy-MM-dd, style=SS, iso=NONE, fallbackPatterns=[M/d/yy, yyyyMMdd, yyyy.MM.dd]) @@ -551,7 +551,7 @@ class DateTimeFormattingTests { "Unable to parse date time value \"210302\" using configuration from", "@org.springframework.format.annotation.DateTimeFormat", "yyyy-MM-dd", "M/d/yy", "yyyyMMdd", "yyyy.MM.dd") - .hasCauseInstanceOf(DateTimeParseException.class).getCause() + .hasCauseInstanceOf(DateTimeParseException.class).cause() .hasMessageStartingWith("Text '210302'") .hasNoCause(); }