Skip to content

Commit 7e1b41f

Browse files
committed
Add assertion messages to understand failures on GH CI
1 parent 58e0095 commit 7e1b41f

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,44 +1308,52 @@ void testToCalendarWithTimeZoneNull() {
13081308
@ParameterizedTest
13091309
@MethodSource("testToLocalDateTimeTimeZone")
13101310
void testToLocalDateTime(final LocalDateTime expected, final Date date, final TimeZone timeZone) {
1311-
assertEquals(LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()), DateUtils.toLocalDateTime(date));
1311+
assertEquals(LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()), DateUtils.toLocalDateTime(date),
1312+
() -> String.format("expected = %s, date = %s, timeZone = %s, TimeZone..getDefault() = %s", expected, date, timeZone, TimeZone.getDefault()));
13121313
}
13131314

13141315
@ParameterizedTest
13151316
@MethodSource
13161317
void testToLocalDateTimeTimeZone(final LocalDateTime expected, final Date date, final TimeZone timeZone) {
1317-
assertEquals(expected, DateUtils.toLocalDateTime(date, timeZone));
1318+
assertEquals(expected, DateUtils.toLocalDateTime(date, timeZone),
1319+
() -> String.format("expected = %s, date = %s, timeZone = %s, TimeZone..getDefault() = %s", expected, date, timeZone, TimeZone.getDefault()));
13181320
}
13191321

13201322
@ParameterizedTest
13211323
@MethodSource("testToLocalDateTimeTimeZone")
13221324
void testToOffsetDateTime(final LocalDateTime expected, final Date date, final TimeZone timeZone) {
13231325
final OffsetDateTime offsetDateTime = DateUtils.toOffsetDateTime(date);
1324-
assertEquals(OffsetDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()), offsetDateTime);
1326+
assertEquals(OffsetDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()), offsetDateTime,
1327+
() -> String.format("expected = %s, date = %s, timeZone = %s, TimeZone..getDefault() = %s", expected, date, timeZone, TimeZone.getDefault()));
13251328
}
13261329

13271330
@ParameterizedTest
13281331
@MethodSource("testToLocalDateTimeTimeZone")
13291332
void testToOffsetDateTimeTimeZone(final LocalDateTime expected, final Date date, final TimeZone timeZone) {
1330-
assertEquals(expected, DateUtils.toOffsetDateTime(date, timeZone).toLocalDateTime());
1333+
assertEquals(expected, DateUtils.toOffsetDateTime(date, timeZone).toLocalDateTime(),
1334+
() -> String.format("expected = %s, date = %s, timeZone = %s, TimeZone..getDefault() = %s", expected, date, timeZone, TimeZone.getDefault()));
13311335
}
13321336

13331337
@ParameterizedTest
13341338
@MethodSource("testToLocalDateTimeTimeZone")
13351339
void testToZonedDateTime(final LocalDateTime expected, final Date date, final TimeZone timeZone) {
13361340
final ZonedDateTime zonedDateTime = DateUtils.toZonedDateTime(date);
1337-
assertEquals(ZonedDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()), zonedDateTime);
1341+
assertEquals(ZonedDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()), zonedDateTime,
1342+
() -> String.format("expected = %s, date = %s, timeZone = %s, TimeZone..getDefault() = %s", expected, date, timeZone, TimeZone.getDefault()));
13381343
// Using atZone()
1339-
assertEquals(date.toInstant().atZone(ZoneId.systemDefault()), zonedDateTime);
1344+
assertEquals(date.toInstant().atZone(ZoneId.systemDefault()), zonedDateTime,
1345+
() -> String.format("expected = %s, date = %s, timeZone = %s, TimeZone..getDefault() = %s", expected, date, timeZone, TimeZone.getDefault()));
13401346
}
13411347

13421348
@ParameterizedTest
13431349
@MethodSource("testToLocalDateTimeTimeZone")
13441350
void testToZonedDateTimeTimeZone(final LocalDateTime expected, final Date date, final TimeZone timeZone) {
13451351
final ZonedDateTime zonedDateTime = DateUtils.toZonedDateTime(date, timeZone);
1346-
assertEquals(expected, zonedDateTime.toOffsetDateTime().toLocalDateTime());
1352+
assertEquals(expected, zonedDateTime.toOffsetDateTime().toLocalDateTime(),
1353+
() -> String.format("expected = %s, date = %s, timeZone = %s, TimeZone..getDefault() = %s", expected, date, timeZone, TimeZone.getDefault()));
13471354
// Using atZone()
1348-
assertEquals(date.toInstant().atZone(TimeZones.toTimeZone(timeZone).toZoneId()), zonedDateTime);
1355+
assertEquals(date.toInstant().atZone(TimeZones.toTimeZone(timeZone).toZoneId()), zonedDateTime,
1356+
() -> String.format("expected = %s, date = %s, timeZone = %s, TimeZone..getDefault() = %s", expected, date, timeZone, TimeZone.getDefault()));
13491357
}
13501358

13511359
/**

0 commit comments

Comments
 (0)