Skip to content

Commit

Permalink
Adjust tests to use OffsetDateTime validation error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Morten Haraldsen committed Dec 27, 2023
1 parent 0444c9b commit 3d8b01f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/test/java/com/ethlo/time/CorrectnessTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,42 +193,42 @@ public void testFormat4()
public void testParseMoreThanNanoResolutionFails()
{
final DateTimeException exception = assertThrows(DateTimeException.class, () -> parser.parseDateTime("2017-02-21T15:00:00.1234567891Z"));
assertThat(exception.getMessage()).isEqualTo("Field NANO out of bounds. Expected 0-999999999, got 1234567891");
assertThat(exception.getMessage()).isEqualTo("Invalid value for NanoOfSecond (valid values 0 - 999999999): 1234567891");
}

@Test
public void testParseMonthOutOfBounds()
{
final DateTimeException exception = assertThrows(DateTimeException.class, () -> parser.parseDateTime("2017-13-21T15:00:00Z"));
assertThat(exception.getMessage()).isEqualTo("Field MONTH out of bounds. Expected 1-12, got 13");
assertThat(exception.getMessage()).isEqualTo("Invalid value for MonthOfYear (valid values 1 - 12): 13");
}

@Test
public void testParseDayOutOfBounds()
{
final DateTimeException exception = assertThrows(DateTimeException.class, () -> parser.parseDateTime("2017-11-32T15:00:00Z"));
assertThat(exception.getMessage()).isEqualTo("Field DAY out of bounds. Expected 1-31, got 32");
assertThat(exception.getMessage()).isEqualTo("Invalid value for DayOfMonth (valid values 1 - 28/31): 32");
}

@Test
public void testParseHourOutOfBounds()
{
final DateTimeException exception = assertThrows(DateTimeException.class, () -> parser.parseDateTime("2017-12-21T24:00:00Z"));
assertThat(exception.getMessage()).isEqualTo("Field HOUR out of bounds. Expected 0-23, got 24");
assertThat(exception.getMessage()).isEqualTo("Invalid value for HourOfDay (valid values 0 - 23): 24");
}

@Test
public void testParseMinuteOfBounds()
{
final DateTimeException exception = assertThrows(DateTimeException.class, () -> parser.parseDateTime("2017-12-21T23:60:00Z"));
assertThat(exception.getMessage()).isEqualTo("Field MINUTE out of bounds. Expected 0-59, got 60");
assertThat(exception.getMessage()).isEqualTo("Invalid value for MinuteOfHour (valid values 0 - 59): 60");
}

@Test
public void testParseSecondOutOfBounds()
{
final DateTimeException exception = assertThrows(DateTimeException.class, () -> parser.parseDateTime("2017-12-21T23:00:61Z"));
assertThat(exception.getMessage()).isEqualTo("Field SECOND out of bounds. Expected 0-60, got 61");
assertThat(exception.getMessage()).isEqualTo("Invalid value for SecondOfMinute (valid values 0 - 59): 61");
}

@Test
Expand Down

0 comments on commit 3d8b01f

Please sign in to comment.