feat test: array converter for parametrized tests
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package appointmentplanner;
|
||||
|
||||
import org.junit.jupiter.params.converter.ArgumentConversionException;
|
||||
import org.junit.jupiter.params.converter.SimpleArgumentConverter;
|
||||
|
||||
public class StringArrayConverter extends SimpleArgumentConverter {
|
||||
|
||||
@Override
|
||||
protected Object convert(Object source, Class<?> targetType) throws ArgumentConversionException {
|
||||
if (source instanceof String && String[].class.isAssignableFrom(targetType)) {
|
||||
return ((String) source).split("\\s*,\\s*");
|
||||
} else {
|
||||
throw new IllegalArgumentException("Conversion from " + source.getClass() + " to "
|
||||
+ targetType + " not supported.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user