mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-25 22:37:33 +00:00
test: create JunitUtils
to help test with Junit
- [x] create `JunitUtils`to help test with Junit - create `StringJsonConverter` class to use with `@ConvertWith`
This commit is contained in:
parent
6781e85680
commit
3090643256
26
test/net/sourceforge/plantuml/test/JunitUtils.java
Normal file
26
test/net/sourceforge/plantuml/test/JunitUtils.java
Normal file
@ -0,0 +1,26 @@
|
||||
package net.sourceforge.plantuml.test;
|
||||
|
||||
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.");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user