29 lines
808 B
Java
29 lines
808 B
Java
package aud.exam.prep;
|
|
|
|
import org.junit.jupiter.api.extension.ExtensionContext;
|
|
import org.junit.jupiter.params.provider.Arguments;
|
|
import org.junit.jupiter.params.provider.ArgumentsProvider;
|
|
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Stream;
|
|
|
|
public class ListProvider implements ArgumentsProvider {
|
|
|
|
@Override
|
|
public Stream<? extends Arguments> provideArguments(ExtensionContext extensionContext) {
|
|
return Stream
|
|
.generate(this::randomList)
|
|
.map(Arguments::of)
|
|
.limit(Tests.STEAM_SIZE);
|
|
}
|
|
|
|
private List<Integer> randomList() {
|
|
var size = Tests.RANDOM.nextInt(50);
|
|
return Tests.RANDOM
|
|
.ints(size, 0, 100)
|
|
.boxed()
|
|
.collect(Collectors.toList());
|
|
}
|
|
}
|