|
|
@ -50,10 +50,8 @@ public class JsonTestParameters<S, T> { |
|
|
|
// memory when we run a single test, but it's not the case we're trying to optimize.
|
|
|
|
// memory when we run a single test, but it's not the case we're trying to optimize.
|
|
|
|
private final List<Object[]> testParameters = new ArrayList<>(256); |
|
|
|
private final List<Object[]> testParameters = new ArrayList<>(256); |
|
|
|
|
|
|
|
|
|
|
|
public void add(final String name, final S value) { |
|
|
|
public void add(final String name, final S value, final boolean runTest) { |
|
|
|
if (includes(name)) { |
|
|
|
testParameters.add(new Object[] {name, value, runTest && includes(name)}); |
|
|
|
testParameters.add(new Object[] {name, value}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean includes(final String name) { |
|
|
|
private boolean includes(final String name) { |
|
|
@ -104,7 +102,7 @@ public class JsonTestParameters<S, T> { |
|
|
|
|
|
|
|
|
|
|
|
public static <T> JsonTestParameters<T, T> create(final Class<T> testCaseSpec) { |
|
|
|
public static <T> JsonTestParameters<T, T> create(final Class<T> testCaseSpec) { |
|
|
|
return new JsonTestParameters<>(testCaseSpec, testCaseSpec) |
|
|
|
return new JsonTestParameters<>(testCaseSpec, testCaseSpec) |
|
|
|
.generator((name, testCase, collector) -> collector.add(name, testCase)); |
|
|
|
.generator((name, testCase, collector) -> collector.add(name, testCase, true)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static <S, T> JsonTestParameters<S, T> create( |
|
|
|
public static <S, T> JsonTestParameters<S, T> create( |
|
|
@ -187,13 +185,13 @@ public class JsonTestParameters<S, T> { |
|
|
|
for (final String path : paths) { |
|
|
|
for (final String path : paths) { |
|
|
|
final URL url = classLoader.getResource(path); |
|
|
|
final URL url = classLoader.getResource(path); |
|
|
|
checkState(url != null, "Cannot find test directory " + path); |
|
|
|
checkState(url != null, "Cannot find test directory " + path); |
|
|
|
Path dir; |
|
|
|
final Path dir; |
|
|
|
try { |
|
|
|
try { |
|
|
|
dir = Paths.get(url.toURI()); |
|
|
|
dir = Paths.get(url.toURI()); |
|
|
|
} catch (final URISyntaxException e) { |
|
|
|
} catch (final URISyntaxException e) { |
|
|
|
throw new RuntimeException("Problem converting URL to URI " + url, e); |
|
|
|
throw new RuntimeException("Problem converting URL to URI " + url, e); |
|
|
|
} |
|
|
|
} |
|
|
|
try (Stream<Path> s = Files.walk(dir)) { |
|
|
|
try (final Stream<Path> s = Files.walk(dir)) { |
|
|
|
s.map(Path::toFile) |
|
|
|
s.map(Path::toFile) |
|
|
|
.filter(f -> f.getPath().endsWith(".json")) |
|
|
|
.filter(f -> f.getPath().endsWith(".json")) |
|
|
|
.filter(f -> !fileExcludes.contains(f.getName())) |
|
|
|
.filter(f -> !fileExcludes.contains(f.getName())) |
|
|
|