Skip to content

Commit

Permalink
Remove redundant parallel processing tests (#929)
Browse files Browse the repository at this point in the history
  • Loading branch information
pivovarit authored Sep 15, 2024
1 parent 0d2fe7f commit 5bdffa2
Showing 1 changed file with 0 additions and 17 deletions.
17 changes: 0 additions & 17 deletions src/test/java/com/pivovarit/collectors/FunctionalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ void shouldExecuteEagerlyOnProvidedThreadPool() {

private static <R extends Collection<Integer>> Stream<DynamicTest> virtualThreadsTests(CollectorSupplier<Function<Integer, Integer>, Executor, Integer, Collector<Integer, ?, CompletableFuture<R>>> collector, String name, boolean maintainsOrder) {
var tests = of(
shouldCollectNElementsWithNParallelism(collector, name, 1),
shouldCollectNElementsWithNParallelism(collector, name, PARALLELISM),
shouldStartConsumingImmediately(collector, name),
shouldNotBlockTheCallingThread(collector, name),
shouldHandleThrowable(collector, name),
Expand All @@ -182,8 +180,6 @@ private static <R extends Collection<Integer>> Stream<DynamicTest> virtualThread

private static <R extends Collection<Integer>> Stream<DynamicTest> tests(CollectorSupplier<Function<Integer, Integer>, Executor, Integer, Collector<Integer, ?, CompletableFuture<R>>> collector, String name, boolean maintainsOrder, boolean limitedParallelism) {
var tests = of(
shouldCollectNElementsWithNParallelism(collector, name, 1),
shouldCollectNElementsWithNParallelism(collector, name, PARALLELISM),
shouldStartConsumingImmediately(collector, name),
shouldNotBlockTheCallingThread(collector, name),
shouldHandleThrowable(collector, name),
Expand Down Expand Up @@ -313,19 +309,6 @@ private static <R extends Collection<Integer>> DynamicTest shouldProcessOnNThrea
});
}

private static <R extends Collection<Integer>> DynamicTest shouldCollectNElementsWithNParallelism(CollectorSupplier<Function<Integer, Integer>, Executor, Integer, Collector<Integer, ?, CompletableFuture<R>>> factory, String name, int parallelism) {
return dynamicTest(format("%s: should collect %s elements with parallelism %s", name, parallelism, parallelism), () -> {
var elements = IntStream.iterate(0, i -> i + 1).limit(parallelism).boxed().toList();

withExecutor(e -> {
Collector<Integer, ?, CompletableFuture<R>> ctor = factory.apply(i -> i, e, parallelism);
Collection<Integer> result = elements.stream().collect(ctor).join();

assertThat(result).hasSameElementsAs(elements);
});
});
}

private static <R extends Collection<Integer>> DynamicTest shouldMaintainOrder(CollectorSupplier<Function<Integer, Integer>, Executor, Integer, Collector<Integer, ?, CompletableFuture<R>>> collector, String name) {
return dynamicTest(format("%s: should maintain order", name), () -> {
int parallelism = 4;
Expand Down

0 comments on commit 5bdffa2

Please sign in to comment.