diff --git a/buildSrc/src/main/java/org/springframework/build/TestConventions.java b/buildSrc/src/main/java/org/springframework/build/TestConventions.java
index b47cda51c13..6f949bf43dc 100644
--- a/buildSrc/src/main/java/org/springframework/build/TestConventions.java
+++ b/buildSrc/src/main/java/org/springframework/build/TestConventions.java
@@ -26,8 +26,8 @@ import org.gradle.testretry.TestRetryTaskExtension;
* Conventions that are applied in the presence of the {@link JavaBasePlugin}. When the
* plugin is applied:
*
- * - The {@link TestRetryPlugin Test Retry} plugins is applied so that flaky tests
- * are retried 3 times when running on the CI.
+ *
- The {@link TestRetryPlugin Test Retry} plugin is applied so that flaky tests
+ * are retried 3 times when running on the CI server.
*
*
* @author Brian Clozel
@@ -41,7 +41,7 @@ class TestConventions {
private void configureTestConventions(Project project) {
project.getTasks().withType(Test.class,
- (test) -> project.getPlugins().withType(TestRetryPlugin.class, (testRetryPlugin) -> {
+ test -> project.getPlugins().withType(TestRetryPlugin.class, testRetryPlugin -> {
TestRetryTaskExtension testRetry = test.getExtensions().getByType(TestRetryTaskExtension.class);
testRetry.getFailOnPassedAfterRetry().set(true);
testRetry.getMaxRetries().set(isCi() ? 3 : 0);
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 657bd164e3a..03da5996314 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-2022 the original author or authors.
+ * Copyright 2002-2023 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.
@@ -106,7 +106,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localDate", "10/31/09");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("localDate")).isEqualTo("10/31/09");
}
@@ -115,7 +115,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localDate", "2009-10-31");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("localDate")).isEqualTo("10/31/09");
}
@@ -127,7 +127,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localDate", "October 31, 2009");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("localDate")).isEqualTo("October 31, 2009");
}
@@ -139,7 +139,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localDate", "20091031");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("localDate")).isEqualTo("20091031");
}
@@ -148,7 +148,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localDate", new String[] {"10/31/09"});
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
}
@Test
@@ -156,7 +156,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("styleLocalDate", "Oct 31, 2009");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("styleLocalDate")).isEqualTo("Oct 31, 2009");
}
@@ -174,7 +174,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("children[0].styleLocalDate", "Oct 31, 2009");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("children[0].styleLocalDate")).isEqualTo("Oct 31, 2009");
}
@@ -184,7 +184,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("styleLocalDate", "Oct 31, 2009");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("styleLocalDate")).isEqualTo("Oct 31, 2009");
}
@@ -203,7 +203,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localDate", new GregorianCalendar(2009, 9, 31, 0, 0));
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("localDate")).isEqualTo("10/31/09");
}
@@ -212,7 +212,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localTime", "12:00 PM");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("localTime")).isEqualTo("12:00 PM");
}
@@ -221,7 +221,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localTime", "12:00:00");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("localTime")).isEqualTo("12:00 PM");
}
@@ -233,7 +233,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localTime", "12:00:00 PM");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("localTime")).isEqualTo("12:00:00 PM");
}
@@ -245,7 +245,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localTime", "130000");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("localTime")).isEqualTo("130000");
}
@@ -254,7 +254,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("styleLocalTime", "12:00:00 PM");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("styleLocalTime")).isEqualTo("12:00:00 PM");
}
@@ -263,7 +263,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localTime", new GregorianCalendar(1970, 0, 0, 12, 0));
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("localTime")).isEqualTo("12:00 PM");
}
@@ -272,10 +272,11 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localDateTime", LocalDateTime.of(2009, 10, 31, 12, 0));
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
String value = binder.getBindingResult().getFieldValue("localDateTime").toString();
- assertThat(value.startsWith("10/31/09")).isTrue();
- assertThat(value.endsWith("12:00 PM")).isTrue();
+ assertThat(value)
+ .startsWith("10/31/09")
+ .endsWith("12:00 PM");
}
@Test
@@ -283,10 +284,11 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localDateTime", "2009-10-31T12:00:00");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
String value = binder.getBindingResult().getFieldValue("localDateTime").toString();
- assertThat(value.startsWith("10/31/09")).isTrue();
- assertThat(value.endsWith("12:00 PM")).isTrue();
+ assertThat(value)
+ .startsWith("10/31/09")
+ .endsWith("12:00 PM");
}
@Test
@@ -294,10 +296,11 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("styleLocalDateTime", LocalDateTime.of(2009, 10, 31, 12, 0));
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
String value = binder.getBindingResult().getFieldValue("styleLocalDateTime").toString();
- assertThat(value.startsWith("Oct 31, 2009")).isTrue();
- assertThat(value.endsWith("12:00:00 PM")).isTrue();
+ assertThat(value)
+ .startsWith("Oct 31, 2009")
+ .endsWith("12:00:00 PM");
}
@Test
@@ -305,10 +308,11 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localDateTime", new GregorianCalendar(2009, 9, 31, 12, 0));
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
String value = binder.getBindingResult().getFieldValue("localDateTime").toString();
- assertThat(value.startsWith("10/31/09")).isTrue();
- assertThat(value.endsWith("12:00 PM")).isTrue();
+ assertThat(value)
+ .startsWith("10/31/09")
+ .endsWith("12:00 PM");
}
@Test
@@ -319,10 +323,11 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("localDateTime", LocalDateTime.of(2009, 10, 31, 12, 0));
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
String value = binder.getBindingResult().getFieldValue("localDateTime").toString();
- assertThat(value.startsWith("Oct 31, 2009")).isTrue();
- assertThat(value.endsWith("12:00:00 PM")).isTrue();
+ assertThat(value)
+ .startsWith("Oct 31, 2009")
+ .endsWith("12:00:00 PM");
}
@Test
@@ -330,7 +335,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("patternLocalDateTime", "10/31/09 12:00 PM");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("patternLocalDateTime")).isEqualTo("10/31/09 12:00 PM");
}
@@ -347,7 +352,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("isoLocalDate", "2009-10-31");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("isoLocalDate")).isEqualTo("2009-10-31");
}
@@ -386,7 +391,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("isoLocalTime", "12:00:00");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("isoLocalTime")).isEqualTo("12:00:00");
}
@@ -395,7 +400,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("isoLocalTime", "12:00:00.000-05:00");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("isoLocalTime")).isEqualTo("12:00:00");
}
@@ -404,7 +409,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("isoLocalDateTime", "2009-10-31T12:00:00");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("isoLocalDateTime")).isEqualTo("2009-10-31T12:00:00");
}
@@ -413,7 +418,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("isoLocalDateTime", "2009-10-31T12:00:00.000Z");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("isoLocalDateTime")).isEqualTo("2009-10-31T12:00:00");
}
@@ -422,8 +427,8 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("instant", "2009-10-31T12:00:00.000Z");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
- assertThat(binder.getBindingResult().getFieldValue("instant").toString().startsWith("2009-10-31T12:00")).isTrue();
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
+ assertThat(binder.getBindingResult().getFieldValue("instant").toString()).startsWith("2009-10-31T12:00");
}
@Test
@@ -431,7 +436,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("styleInstant", "2017-02-21T13:00");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("styleInstant")).isEqualTo("2017-02-21T13:00");
}
@@ -444,8 +449,8 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("instant", new Date(109, 9, 31, 12, 0));
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
- assertThat(binder.getBindingResult().getFieldValue("instant").toString().startsWith("2009-10-31")).isTrue();
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
+ assertThat(binder.getBindingResult().getFieldValue("instant").toString()).startsWith("2009-10-31");
}
finally {
TimeZone.setDefault(defaultZone);
@@ -457,7 +462,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("period", "P6Y3M1D");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("period").toString().equals("P6Y3M1D")).isTrue();
}
@@ -466,7 +471,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("duration", "PT8H6M12.345S");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("duration").toString().equals("PT8H6M12.345S")).isTrue();
}
@@ -475,7 +480,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("year", "2007");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("year").toString().equals("2007")).isTrue();
}
@@ -484,7 +489,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("month", "JULY");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("month").toString().equals("JULY")).isTrue();
}
@@ -493,7 +498,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("month", "July");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("month").toString().equals("JULY")).isTrue();
}
@@ -502,7 +507,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("yearMonth", "2007-12");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("yearMonth").toString().equals("2007-12")).isTrue();
}
@@ -511,7 +516,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("yearMonthAnnotatedPattern", "12/2007");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("yearMonthAnnotatedPattern")).isEqualTo("12/2007");
assertThat(binder.getBindingResult().getRawFieldValue("yearMonthAnnotatedPattern")).isEqualTo(YearMonth.parse("2007-12"));
}
@@ -521,7 +526,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("monthDay", "--12-03");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("monthDay").toString().equals("--12-03")).isTrue();
}
@@ -530,7 +535,7 @@ class DateTimeFormattingTests {
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("monthDayAnnotatedPattern", "1/3");
binder.bind(propertyValues);
- assertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
+ assertThat(binder.getBindingResult().getErrorCount()).isZero();
assertThat(binder.getBindingResult().getFieldValue("monthDayAnnotatedPattern")).isEqualTo("1/3");
assertThat(binder.getBindingResult().getRawFieldValue("monthDayAnnotatedPattern")).isEqualTo(MonthDay.parse("--01-03"));
}
@@ -546,7 +551,7 @@ class DateTimeFormattingTests {
propertyValues.add(propertyName, propertyValue);
binder.bind(propertyValues);
BindingResult bindingResult = binder.getBindingResult();
- assertThat(bindingResult.getErrorCount()).isEqualTo(0);
+ assertThat(bindingResult.getErrorCount()).isZero();
assertThat(bindingResult.getFieldValue(propertyName)).isEqualTo("3/2/21");
}
@@ -558,11 +563,12 @@ class DateTimeFormattingTests {
propertyValues.add(propertyName, propertyValue);
binder.bind(propertyValues);
BindingResult bindingResult = binder.getBindingResult();
- assertThat(bindingResult.getErrorCount()).isEqualTo(0);
+ assertThat(bindingResult.getErrorCount()).isZero();
assertThat(bindingResult.getFieldValue(propertyName)).isEqualTo("2021-03-02");
}
@ParameterizedTest(name = "input date: {0}")
+ // @ValueSource(strings = {"12:00:00\u202FPM", "12:00:00", "12:00"})
@ValueSource(strings = {"12:00:00 PM", "12:00:00", "12:00"})
void styleLocalTime(String propertyValue) {
String propertyName = "styleLocalTimeWithFallbackPatterns";
@@ -570,7 +576,8 @@ class DateTimeFormattingTests {
propertyValues.add(propertyName, propertyValue);
binder.bind(propertyValues);
BindingResult bindingResult = binder.getBindingResult();
- assertThat(bindingResult.getErrorCount()).isEqualTo(0);
+ assertThat(bindingResult.getErrorCount()).isZero();
+ // assertThat(bindingResult.getFieldValue(propertyName)).asString().matches("12:00:00\\SPM");
assertThat(bindingResult.getFieldValue(propertyName)).isEqualTo("12:00:00 PM");
}
@@ -582,7 +589,7 @@ class DateTimeFormattingTests {
propertyValues.add(propertyName, propertyValue);
binder.bind(propertyValues);
BindingResult bindingResult = binder.getBindingResult();
- assertThat(bindingResult.getErrorCount()).isEqualTo(0);
+ assertThat(bindingResult.getErrorCount()).isZero();
assertThat(bindingResult.getFieldValue(propertyName)).isEqualTo("2021-03-02T12:00:00");
}
diff --git a/spring-web/src/test/java/org/springframework/http/converter/json/GsonFactoryBeanTests.java b/spring-web/src/test/java/org/springframework/http/converter/json/GsonFactoryBeanTests.java
index 51d0e986502..89bc00bf8ea 100644
--- a/spring-web/src/test/java/org/springframework/http/converter/json/GsonFactoryBeanTests.java
+++ b/spring-web/src/test/java/org/springframework/http/converter/json/GsonFactoryBeanTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2019 the original author or authors.
+ * Copyright 2002-2023 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.
@@ -29,79 +29,79 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Roy Clarkson
*/
-public class GsonFactoryBeanTests {
+class GsonFactoryBeanTests {
private static final String DATE_FORMAT = "yyyy-MM-dd";
- private GsonFactoryBean factory = new GsonFactoryBean();
+ private final GsonFactoryBean factory = new GsonFactoryBean();
@Test
- public void serializeNulls() throws Exception {
+ void serializeNulls() throws Exception {
this.factory.setSerializeNulls(true);
this.factory.afterPropertiesSet();
Gson gson = this.factory.getObject();
StringBean bean = new StringBean();
- String result = gson.toJson(bean);
- assertThat(result).isEqualTo("{\"name\":null}");
+
+ assertThat(gson.toJson(bean)).isEqualTo("{\"name\":null}");
}
@Test
- public void serializeNullsFalse() throws Exception {
+ void serializeNullsFalse() throws Exception {
this.factory.setSerializeNulls(false);
this.factory.afterPropertiesSet();
Gson gson = this.factory.getObject();
StringBean bean = new StringBean();
- String result = gson.toJson(bean);
- assertThat(result).isEqualTo("{}");
+
+ assertThat(gson.toJson(bean)).isEqualTo("{}");
}
@Test
- public void prettyPrinting() throws Exception {
+ void prettyPrinting() throws Exception {
this.factory.setPrettyPrinting(true);
this.factory.afterPropertiesSet();
Gson gson = this.factory.getObject();
StringBean bean = new StringBean();
bean.setName("Jason");
- String result = gson.toJson(bean);
- assertThat(result.contains(" \"name\": \"Jason\"")).isTrue();
+
+ assertThat(gson.toJson(bean)).contains(" \"name\": \"Jason\"");
}
@Test
- public void prettyPrintingFalse() throws Exception {
+ void prettyPrintingFalse() throws Exception {
this.factory.setPrettyPrinting(false);
this.factory.afterPropertiesSet();
Gson gson = this.factory.getObject();
StringBean bean = new StringBean();
bean.setName("Jason");
- String result = gson.toJson(bean);
- assertThat(result).isEqualTo("{\"name\":\"Jason\"}");
+
+ assertThat(gson.toJson(bean)).isEqualTo("{\"name\":\"Jason\"}");
}
@Test
- public void disableHtmlEscaping() throws Exception {
+ void disableHtmlEscaping() throws Exception {
this.factory.setDisableHtmlEscaping(true);
this.factory.afterPropertiesSet();
Gson gson = this.factory.getObject();
StringBean bean = new StringBean();
bean.setName("Bob=Bob");
- String result = gson.toJson(bean);
- assertThat(result).isEqualTo("{\"name\":\"Bob=Bob\"}");
+
+ assertThat(gson.toJson(bean)).isEqualTo("{\"name\":\"Bob=Bob\"}");
}
@Test
- public void disableHtmlEscapingFalse() throws Exception {
+ void disableHtmlEscapingFalse() throws Exception {
this.factory.setDisableHtmlEscaping(false);
this.factory.afterPropertiesSet();
Gson gson = this.factory.getObject();
StringBean bean = new StringBean();
bean.setName("Bob=Bob");
- String result = gson.toJson(bean);
- assertThat(result).isEqualTo("{\"name\":\"Bob\\u003dBob\"}");
+
+ assertThat(gson.toJson(bean)).isEqualTo("{\"name\":\"Bob\\u003dBob\"}");
}
@Test
- public void customizeDateFormatPattern() throws Exception {
+ void customizeDateFormatPattern() throws Exception {
this.factory.setDateFormatPattern(DATE_FORMAT);
this.factory.afterPropertiesSet();
Gson gson = this.factory.getObject();
@@ -113,12 +113,12 @@ public class GsonFactoryBeanTests {
cal.set(Calendar.DATE, 1);
Date date = cal.getTime();
bean.setDate(date);
- String result = gson.toJson(bean);
- assertThat(result).isEqualTo("{\"date\":\"2014-01-01\"}");
+
+ assertThat(gson.toJson(bean)).isEqualTo("{\"date\":\"2014-01-01\"}");
}
@Test
- public void customizeDateFormatNone() throws Exception {
+ void customizeDateFormatNone() throws Exception {
this.factory.afterPropertiesSet();
Gson gson = this.factory.getObject();
DateBean bean = new DateBean();
@@ -129,43 +129,44 @@ public class GsonFactoryBeanTests {
cal.set(Calendar.DATE, 1);
Date date = cal.getTime();
bean.setDate(date);
- String result = gson.toJson(bean);
- assertThat(result.startsWith("{\"date\":\"Jan 1, 2014")).isTrue();
- assertThat(result.endsWith("12:00:00 AM\"}")).isTrue();
+
+ assertThat(gson.toJson(bean))
+ .startsWith("{\"date\":\"Jan 1, 2014")
+ .endsWith("12:00:00 AM\"}");
}
@Test
- public void base64EncodeByteArrays() throws Exception {
+ void base64EncodeByteArrays() throws Exception {
this.factory.setBase64EncodeByteArrays(true);
this.factory.afterPropertiesSet();
Gson gson = this.factory.getObject();
ByteArrayBean bean = new ByteArrayBean();
bean.setBytes(new byte[] {0x1, 0x2});
- String result = gson.toJson(bean);
- assertThat(result).isEqualTo("{\"bytes\":\"AQI\\u003d\"}");
+
+ assertThat(gson.toJson(bean)).isEqualTo("{\"bytes\":\"AQI\\u003d\"}");
}
@Test
- public void base64EncodeByteArraysDisableHtmlEscaping() throws Exception {
+ void base64EncodeByteArraysDisableHtmlEscaping() throws Exception {
this.factory.setBase64EncodeByteArrays(true);
this.factory.setDisableHtmlEscaping(true);
this.factory.afterPropertiesSet();
Gson gson = this.factory.getObject();
ByteArrayBean bean = new ByteArrayBean();
bean.setBytes(new byte[] {0x1, 0x2});
- String result = gson.toJson(bean);
- assertThat(result).isEqualTo("{\"bytes\":\"AQI=\"}");
+
+ assertThat(gson.toJson(bean)).isEqualTo("{\"bytes\":\"AQI=\"}");
}
@Test
- public void base64EncodeByteArraysFalse() throws Exception {
+ void base64EncodeByteArraysFalse() throws Exception {
this.factory.setBase64EncodeByteArrays(false);
this.factory.afterPropertiesSet();
Gson gson = this.factory.getObject();
ByteArrayBean bean = new ByteArrayBean();
bean.setBytes(new byte[] {0x1, 0x2});
- String result = gson.toJson(bean);
- assertThat(result).isEqualTo("{\"bytes\":[1,2]}");
+
+ assertThat(gson.toJson(bean)).isEqualTo("{\"bytes\":[1,2]}");
}