1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-07 02:40:52 +00:00
plantuml/test/test/utils/JunitUtils.java
The-Lum e11d974ce5 refactor: place net.sourceforge.plantuml.test on test.utils
Create `test` folder with:
- `example`
- `utils`

And put all `net.sourceforge.plantuml.test` on `test.utils`.
_[no other change]_
2024-02-12 19:13:02 +00:00

26 lines
819 B
Java

package test.utils;
import org.junit.jupiter.params.converter.ArgumentConversionException;
import org.junit.jupiter.params.converter.SimpleArgumentConverter;
import net.sourceforge.plantuml.json.Json;
import net.sourceforge.plantuml.json.JsonValue;
/**
* Class to help test with `Junit`.
*/
public class JunitUtils {
/**
* `StringJsonConverter` class to use with `@ConvertWith`.
*/
public static class StringJsonConverter extends SimpleArgumentConverter {
@Override
protected Object convert(Object source, Class<?> targetType) throws ArgumentConversionException {
if (source instanceof String)
return (JsonValue) Json.parse((String) source);
else
throw new IllegalArgumentException("Conversion from " + source.getClass() + " to "
+ targetType + " not supported.");
}
}
}