Created
June 2, 2019 19:02
-
-
Save dnno/04b12508c6c9e4be196c949d3844522b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class JsonArgumentsProvider implements ArgumentsProvider, AnnotationConsumer { | |
| private String[] values; | |
| private Class<?> type; | |
| @Override | |
| public void accept(final JsonSource annotation) { | |
| values = annotation.value(); | |
| type = annotation.type(); | |
| } | |
| @Override | |
| public Stream<? extends Arguments> provideArguments(final ExtensionContext context) { | |
| return Arrays.stream(values) | |
| .map(value -> new Gson().fromJson(value, type)) | |
| .map(Arguments::of); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment