Skip to content

Commit

Permalink
feat(impl): [eclipse-tractusx#639] improve test using ParameterizedTest
Browse files Browse the repository at this point in the history
  • Loading branch information
dsmf committed Jul 23, 2024
1 parent 84934fa commit 01dfbf7
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Arguments> 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
Expand All @@ -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();
}

}

0 comments on commit 01dfbf7

Please sign in to comment.