|
|
|
@ -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.
|
|
|
|
|
private final List<Object[]> testParameters = new ArrayList<>(256); |
|
|
|
|
|
|
|
|
|
public void add(final String name, final S value) { |
|
|
|
|
if (includes(name)) { |
|
|
|
|
testParameters.add(new Object[] {name, value}); |
|
|
|
|
} |
|
|
|
|
public void add(final String name, final S value, final boolean runTest) { |
|
|
|
|
testParameters.add(new Object[] {name, value, runTest && includes(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) { |
|
|
|
|
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( |
|
|
|
@ -187,13 +185,13 @@ public class JsonTestParameters<S, T> { |
|
|
|
|
for (final String path : paths) { |
|
|
|
|
final URL url = classLoader.getResource(path); |
|
|
|
|
checkState(url != null, "Cannot find test directory " + path); |
|
|
|
|
Path dir; |
|
|
|
|
final Path dir; |
|
|
|
|
try { |
|
|
|
|
dir = Paths.get(url.toURI()); |
|
|
|
|
} catch (final URISyntaxException 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) |
|
|
|
|
.filter(f -> f.getPath().endsWith(".json")) |
|
|
|
|
.filter(f -> !fileExcludes.contains(f.getName())) |
|
|
|
|