Skip to content

Commit

Permalink
feat(impl): [#639] fix broken tests after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
dsmf committed Jul 23, 2024
1 parent 3a8f43e commit 01fef00
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public static boolean isDateBefore(final OffsetDateTime dateTime, final String r
}

public static boolean isDateAfter(final OffsetDateTime dateTime, final String referenceDateString) {
if (StringUtils.isBlank(referenceDateString)) {
throw new IllegalArgumentException("Invalid date: must not be blank!");
}
if (isDateWithoutTime(referenceDateString)) {
return dateTime.isAfter(toOffsetDateTimeAtEndOfDay(referenceDateString));
} else {
Expand Down Expand Up @@ -99,7 +102,7 @@ public static boolean isDateWithoutTime(final String referenceDateString) {
return false;
} catch (DateTimeParseException e) {
log.trace(e.getMessage(), e);
throw new IllegalArgumentException("Invalid date format: " + referenceDateString);
throw new IllegalArgumentException("Invalid date format: " + referenceDateString, e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,14 @@ public void testIsDateWithoutTimeWithInvalidDate() {
}

@ParameterizedTest
@ValueSource(strings = { "3333-11-11T11:11:11.111Z",
"3333-11-",
@ValueSource(strings = { "3333-11-",
"2222",
"asdf"
})
void testInvalidDate(final String referenceDateStr) {
final ThrowingCallable call = () -> DateUtils.isDateAfter(OffsetDateTime.now(), referenceDateStr);
assertThatThrownBy(call).isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("Invalid date")
.hasMessageContaining("refer to the documentation")
.hasCauseInstanceOf(DateTimeParseException.class);
}

Expand Down

0 comments on commit 01fef00

Please sign in to comment.