From 01dfbf7f31f84b6e19a2bfc76c75a84b6f1452f8 Mon Sep 17 00:00:00 2001 From: Matthias Fischer Date: Tue, 23 Jul 2024 12:07:34 +0200 Subject: [PATCH] feat(impl): [#639] improve test using ParameterizedTest --- .../irs/policystore/common/DateUtilsTest.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) 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 cfce3680d..bc1e301a1 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 @@ -95,14 +95,18 @@ private static OffsetDateTime atEndOfDay(final String dateStr) { return LocalDate.parse(dateStr).atTime(LocalTime.MAX).atOffset(ZoneOffset.UTC); } - @Test - public void testIsDateWithoutTimeWithDateOnly() { - assertThat(DateUtils.isDateWithoutTime("2023-07-23")).isTrue(); + @ParameterizedTest + @MethodSource("provideDatesForIsDateWithoutTime") + public void isDateWithoutTime(final String dateString, final boolean expected) { + assertThat(DateUtils.isDateWithoutTime(dateString)).isEqualTo(expected); } - @Test - public void testIsDateWithoutTimeWithDateTime() { - assertThat(DateUtils.isDateWithoutTime("2023-07-23T10:15:30+01:00")).isFalse(); + static Stream provideDatesForIsDateWithoutTime() { + return Stream.of( // + Arguments.of("2023-07-23", true), // + Arguments.of("2023-07-23T10:15:30+01:00", false), // + Arguments.of("2023-07-23T10:15:30Z", false) // + ); } @Test @@ -111,9 +115,4 @@ public void testIsDateWithoutTimeWithInvalidDate() { IllegalArgumentException.class).hasMessageContaining("Invalid date format: invalid-date"); } - @Test - public void testIsDateWithoutTimeWithDifferentFormatDateTime() { - assertThat(DateUtils.isDateWithoutTime("2023-07-23T10:15:30Z")).isFalse(); - } - } \ No newline at end of file