Skip to content

Instantly share code, notes, and snippets.

@dnno
Created June 2, 2019 19:02
Show Gist options
  • Select an option

  • Save dnno/04b12508c6c9e4be196c949d3844522b to your computer and use it in GitHub Desktop.

Select an option

Save dnno/04b12508c6c9e4be196c949d3844522b to your computer and use it in GitHub Desktop.
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