Skip to content

Commit aa8802a

Browse files
committed
Avoid new AssertJ deprecations
1 parent 1beb706 commit aa8802a

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

spring-context/src/test/java/org/springframework/format/datetime/DateFormattingTests.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -132,11 +132,11 @@ void styleDateWithInvalidFormat() {
132132
TypeMismatchException exception = fieldError.unwrap(TypeMismatchException.class);
133133
assertThat(exception)
134134
.hasMessageContaining("for property 'styleDate'")
135-
.hasCauseInstanceOf(ConversionFailedException.class).getCause()
135+
.hasCauseInstanceOf(ConversionFailedException.class).cause()
136136
.hasMessageContaining("for value '99/01/01'")
137-
.hasCauseInstanceOf(IllegalArgumentException.class).getCause()
137+
.hasCauseInstanceOf(IllegalArgumentException.class).cause()
138138
.hasMessageContaining("Parse attempt failed for value [99/01/01]")
139-
.hasCauseInstanceOf(ParseException.class).getCause()
139+
.hasCauseInstanceOf(ParseException.class).cause()
140140
// Unable to parse date time value "99/01/01" using configuration from
141141
// @org.springframework.format.annotation.DateTimeFormat(pattern=, style=S-, iso=NONE, fallbackPatterns=[])
142142
// We do not check "fallbackPatterns=[]", since the array representation in the toString()
@@ -147,7 +147,7 @@ void styleDateWithInvalidFormat() {
147147
"Unable to parse date time value \"99/01/01\" using configuration from",
148148
"@org.springframework.format.annotation.DateTimeFormat",
149149
"style=", "S-", "iso=NONE")
150-
.hasCauseInstanceOf(ParseException.class).getCause()
150+
.hasCauseInstanceOf(ParseException.class).cause()
151151
.hasMessageStartingWith("Unparseable date: \"99/01/01\"")
152152
.hasNoCause();
153153
}
@@ -352,19 +352,19 @@ void patternDateWithUnsupportedPattern() {
352352
FieldError fieldError = bindingResult.getFieldError(propertyName);
353353
assertThat(fieldError.unwrap(TypeMismatchException.class))
354354
.hasMessageContaining("for property 'patternDateWithFallbackPatterns'")
355-
.hasCauseInstanceOf(ConversionFailedException.class).getCause()
355+
.hasCauseInstanceOf(ConversionFailedException.class).cause()
356356
.hasMessageContaining("for value '210302'")
357-
.hasCauseInstanceOf(IllegalArgumentException.class).getCause()
357+
.hasCauseInstanceOf(IllegalArgumentException.class).cause()
358358
.hasMessageContaining("Parse attempt failed for value [210302]")
359-
.hasCauseInstanceOf(ParseException.class).getCause()
359+
.hasCauseInstanceOf(ParseException.class).cause()
360360
// Unable to parse date time value "210302" using configuration from
361361
// @org.springframework.format.annotation.DateTimeFormat(
362362
// pattern=yyyy-MM-dd, style=SS, iso=NONE, fallbackPatterns=[M/d/yy, yyyyMMdd, yyyy.MM.dd])
363363
.hasMessageContainingAll(
364364
"Unable to parse date time value \"210302\" using configuration from",
365365
"@org.springframework.format.annotation.DateTimeFormat",
366366
"yyyy-MM-dd", "M/d/yy", "yyyyMMdd", "yyyy.MM.dd")
367-
.hasCauseInstanceOf(ParseException.class).getCause()
367+
.hasCauseInstanceOf(ParseException.class).cause()
368368
.hasMessageStartingWith("Unparseable date: \"210302\"")
369369
.hasNoCause();
370370
}

spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormattingTests.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -332,21 +332,21 @@ void isoLocalDateWithInvalidFormat() {
332332
FieldError fieldError = bindingResult.getFieldError(propertyName);
333333
assertThat(fieldError.unwrap(TypeMismatchException.class))
334334
.hasMessageContaining("for property 'isoLocalDate'")
335-
.hasCauseInstanceOf(ConversionFailedException.class).getCause()
335+
.hasCauseInstanceOf(ConversionFailedException.class).cause()
336336
.hasMessageContaining("for value '2009-31-10'")
337-
.hasCauseInstanceOf(IllegalArgumentException.class).getCause()
337+
.hasCauseInstanceOf(IllegalArgumentException.class).cause()
338338
.hasMessageContaining("Parse attempt failed for value [2009-31-10]")
339-
.hasCauseInstanceOf(DateTimeParseException.class).getCause()
339+
.hasCauseInstanceOf(DateTimeParseException.class).cause()
340340
// Unable to parse date time value "2009-31-10" using configuration from
341341
// @org.springframework.format.annotation.DateTimeFormat(pattern=, style=SS, iso=DATE, fallbackPatterns=[])
342342
// We do not check "fallbackPatterns=[]", since the array representation in the toString()
343343
// implementation for annotations changed from [] to {} in Java 9.
344344
.hasMessageContainingAll(
345345
"Unable to parse date time value \"2009-31-10\" using configuration from",
346346
"@org.springframework.format.annotation.DateTimeFormat", "iso=DATE")
347-
.hasCauseInstanceOf(DateTimeParseException.class).getCause()
347+
.hasCauseInstanceOf(DateTimeParseException.class).cause()
348348
.hasMessageStartingWith("Text '2009-31-10'")
349-
.hasCauseInstanceOf(DateTimeException.class).getCause()
349+
.hasCauseInstanceOf(DateTimeException.class).cause()
350350
.hasMessageContaining("Invalid value for MonthOfYear (valid values 1 - 12): 31")
351351
.hasNoCause();
352352
}
@@ -539,19 +539,19 @@ void patternLocalDateWithUnsupportedPattern() {
539539
FieldError fieldError = bindingResult.getFieldError(propertyName);
540540
assertThat(fieldError.unwrap(TypeMismatchException.class))
541541
.hasMessageContaining("for property 'patternLocalDateWithFallbackPatterns'")
542-
.hasCauseInstanceOf(ConversionFailedException.class).getCause()
542+
.hasCauseInstanceOf(ConversionFailedException.class).cause()
543543
.hasMessageContaining("for value '210302'")
544-
.hasCauseInstanceOf(IllegalArgumentException.class).getCause()
544+
.hasCauseInstanceOf(IllegalArgumentException.class).cause()
545545
.hasMessageContaining("Parse attempt failed for value [210302]")
546-
.hasCauseInstanceOf(DateTimeParseException.class).getCause()
546+
.hasCauseInstanceOf(DateTimeParseException.class).cause()
547547
// Unable to parse date time value "210302" using configuration from
548548
// @org.springframework.format.annotation.DateTimeFormat(
549549
// pattern=yyyy-MM-dd, style=SS, iso=NONE, fallbackPatterns=[M/d/yy, yyyyMMdd, yyyy.MM.dd])
550550
.hasMessageContainingAll(
551551
"Unable to parse date time value \"210302\" using configuration from",
552552
"@org.springframework.format.annotation.DateTimeFormat",
553553
"yyyy-MM-dd", "M/d/yy", "yyyyMMdd", "yyyy.MM.dd")
554-
.hasCauseInstanceOf(DateTimeParseException.class).getCause()
554+
.hasCauseInstanceOf(DateTimeParseException.class).cause()
555555
.hasMessageStartingWith("Text '210302'")
556556
.hasNoCause();
557557
}

0 commit comments

Comments
 (0)