diff --git a/irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/common/DateUtils.java b/irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/common/DateUtils.java index 07f1daf0c..11f5c8eb4 100644 --- a/irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/common/DateUtils.java +++ b/irs-policy-store/src/main/java/org/eclipse/tractusx/irs/policystore/common/DateUtils.java @@ -59,7 +59,7 @@ private static LocalDate parseDate(final String dateString) { try { return LocalDate.parse(dateString); } catch (DateTimeParseException e) { - throw new IllegalArgumentException("Invalid date format (please refer to the documentation)"); + throw new IllegalArgumentException("Invalid date format (please refer to the documentation)", e); } } } diff --git a/irs-policy-store/src/test/java/org/eclipse/tractusx/irs/policystore/common/DateUtilsTest.java b/irs-policy-store/src/test/java/org/eclipse/tractusx/irs/policystore/common/DateUtilsTest.java index 8a6c6f2b4..3d2ebd8f4 100644 --- a/irs-policy-store/src/test/java/org/eclipse/tractusx/irs/policystore/common/DateUtilsTest.java +++ b/irs-policy-store/src/test/java/org/eclipse/tractusx/irs/policystore/common/DateUtilsTest.java @@ -26,6 +26,7 @@ import java.time.LocalTime; import java.time.OffsetDateTime; import java.time.ZoneOffset; +import java.time.format.DateTimeParseException; import java.util.stream.Stream; import org.assertj.core.api.ThrowableAssert.ThrowingCallable; @@ -78,7 +79,8 @@ 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"); + .hasMessageContaining("refer to the documentation") + .hasCauseInstanceOf(DateTimeParseException.class); } @ParameterizedTest @@ -91,7 +93,8 @@ void testInvalidDateBlank(final String referenceDateStr) { final ThrowingCallable call = () -> DateUtils.isDateAfter(OffsetDateTime.now(), referenceDateStr); assertThatThrownBy(call).isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Invalid date") - .hasMessageContaining("must not be blank"); + .hasMessageContaining("must not be blank") + .hasNoCause(); } }