Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beyondxscratch/cd885e754b60b810738c55908ea09bd0 to your computer and use it in GitHub Desktop.
Save beyondxscratch/cd885e754b60b810738c55908ea09bd0 to your computer and use it in GitHub Desktop.
@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