Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@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