@@ -0,0 +1,2152 @@
+package org.neo4j.graphalgo.core.utils;%0A%0Aimport com.carrotsearch.randomizedtesting.RandomizedTest;%0Aimport org.junit.Test;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.fail;%0A%0Apublic final class ParallelUtilTest extends RandomizedTest %7B%0A%0A    @Test%0A    public void threadSizeShouldDivideByBatchsize() throws Exception %7B%0A        int batchSize = between(10, 10_000);%0A        int threads = between(10, 10_000);%0A        assertEquals(%0A                threads,%0A                ParallelUtil.threadSize(batchSize, batchSize * threads));%0A    %7D%0A%0A    @Test%0A    public void threadSizeShouldReturnEnoughThreadsForIncompleteBatches() throws%0A            Exception %7B%0A        int batchSize = between(10, 10_000);%0A        int threads = between(10, 10_000);%0A        int elements = batchSize * threads + between(1, batchSize - 1);%0A        assertEquals(threads + 1, ParallelUtil.threadSize(batchSize, elements));%0A    %7D%0A%0A    @Test%0A    public void threadSizeShouldReturn1ForNonCompleteBatches() throws%0A            Exception %7B%0A        int batchSize = between(2, 1_000_000);%0A        assertEquals(%0A                1,%0A                ParallelUtil.threadSize(%0A                        batchSize,%0A                        batchSize - randomInt(batchSize)));%0A    %7D%0A%0A    @Test%0A    public void threadSizeShouldReturn1ForZeroElements() throws Exception %7B%0A        int batchSize = between(2, 1_000_000);%0A        assertEquals(1, ParallelUtil.threadSize(batchSize, 0));%0A    %7D%0A%0A    @Test%0A    public void threadSizeShouldFailForZeroBatchsize() throws Exception %7B%0A        try %7B%0A            ParallelUtil.threadSize(0, randomInt());%0A            fail();%0A        %7D catch (IllegalArgumentException e) %7B%0A            assertEquals(%22Invalid batch size: 0%22, e.getMessage());%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void threadSizeShouldFailForNegativeBatchsize() throws Exception %7B%0A        int batchSize = between(Integer.MIN_VALUE, -1);%0A        try %7B%0A            ParallelUtil.threadSize(batchSize, randomInt());%0A            fail();%0A        %7D catch (IllegalArgumentException e) %7B%0A            assertEquals(%22Invalid batch size: %22 + batchSize, e.getMessage());%0A        %7D%0A    %7D%0A%0A%7D%0A

Add test to ensure edge cases around batch threadsize calculation (#133)