Introduce DoubleListProvider
This commit is contained in:
19
test/aud/exam/prep/DoubleListProvider.java
Normal file
19
test/aud/exam/prep/DoubleListProvider.java
Normal file
@ -0,0 +1,19 @@
|
||||
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.stream.Stream;
|
||||
|
||||
public class DoubleListProvider implements ArgumentsProvider {
|
||||
|
||||
@Override
|
||||
public Stream<? extends Arguments> provideArguments(ExtensionContext extensionContext) {
|
||||
return Stream
|
||||
.generate(() ->
|
||||
Arguments.of(Tests.randomList(), Tests.randomList()))
|
||||
.limit(Tests.STEAM_SIZE);
|
||||
}
|
||||
|
||||
}
|
@ -4,8 +4,6 @@ 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 {
|
||||
@ -13,16 +11,9 @@ public class ListProvider implements ArgumentsProvider {
|
||||
@Override
|
||||
public Stream<? extends Arguments> provideArguments(ExtensionContext extensionContext) {
|
||||
return Stream
|
||||
.generate(this::randomList)
|
||||
.generate(Tests::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());
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,20 @@
|
||||
package aud.exam.prep;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Tests {
|
||||
|
||||
public static final int STEAM_SIZE = 50;
|
||||
|
||||
public static final Random RANDOM = new Random();
|
||||
|
||||
static List<Integer> randomList() {
|
||||
var size = RANDOM.nextInt(50);
|
||||
return RANDOM
|
||||
.ints(size, 0, 100)
|
||||
.boxed()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user