Created
July 14, 2022 22:20
-
-
Save beyondxscratch/cd885e754b60b810738c55908ea09bd0 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
@ParameterizedTest | |
@ValueSource(strings = {"JANUARY", "FEBRUARY", "MARCH"}) | |
void a_test_with_explicit_conversion( | |
@ConvertWith(MonthToNumberConverter.class) int month) { | |
assertTrue(month <= 3); | |
} | |
class MonthToNumberConverter extends SimpleArgumentConverter { | |
@Override | |
protected Object convert(Object source, Class<?> targetType) { | |
Month month = Month.valueOf((String) source); | |
return month.getValue(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment