Last active
March 14, 2022 10:58
-
-
Save dblevins/546fb7cf74da49b847bc0f74a8b23856 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.jupiter.api.Assertions; | |
import org.junit.jupiter.params.ParameterizedTest; | |
import org.junit.jupiter.params.provider.Arguments; | |
import org.junit.jupiter.params.provider.MethodSource; | |
import java.time.LocalDate; | |
import java.util.stream.Stream; | |
import static org.junit.jupiter.params.provider.Arguments.arguments; | |
public class DatesTest { | |
private static Stream<Arguments> data() { | |
return Stream.of( | |
arguments(Dates.yyyy_MM_dd, "2022-03-30"), | |
arguments(Dates.MMM_dd_yyyy, "Mar 30, 2022") | |
); | |
} | |
@ParameterizedTest | |
@MethodSource("data") | |
public void parse(final Dates dateEnum, final String dateString) { | |
final LocalDate expected = LocalDate.of(2022, 3, 30); | |
final LocalDate actual = dateEnum.parse(dateString); | |
Assertions.assertEquals(expected, actual); | |
} | |
@ParameterizedTest | |
@MethodSource("data") | |
public void format(final Dates dateEnum, final String expected) { | |
final LocalDate date = LocalDate.of(2022, 3, 30); | |
final String actual = dateEnum.format(date); | |
Assertions.assertEquals(expected, actual); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment