diff --git a/warehouse/src/test/java/com/usthe/warehouse/WarehouseWorkerPoolTest.java b/warehouse/src/test/java/com/usthe/warehouse/WarehouseWorkerPoolTest.java index 8665e3f6cd3..365dcd86ec8 100644 --- a/warehouse/src/test/java/com/usthe/warehouse/WarehouseWorkerPoolTest.java +++ b/warehouse/src/test/java/com/usthe/warehouse/WarehouseWorkerPoolTest.java @@ -1,30 +1,33 @@ package com.usthe.warehouse; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Test case for {@link WarehouseWorkerPool} */ class WarehouseWorkerPoolTest { + + private static final int NUMBER_OF_THREADS = 10; private WarehouseWorkerPool pool; + private AtomicInteger counter; + private CountDownLatch latch; @BeforeEach void setUp() { pool = new WarehouseWorkerPool(); + counter = new AtomicInteger(); + latch = new CountDownLatch(NUMBER_OF_THREADS); + } @Test void executeJob() throws InterruptedException { - int numberOfThreads = 10; - AtomicInteger counter = new AtomicInteger(); - CountDownLatch latch = new CountDownLatch(numberOfThreads); - - for (int i = 0; i < numberOfThreads; i++) { + for (int i = 0; i < NUMBER_OF_THREADS; i++) { pool.executeJob(() -> { counter.incrementAndGet(); latch.countDown(); @@ -32,7 +35,7 @@ void executeJob() throws InterruptedException { } latch.await(); - Assertions.assertEquals(numberOfThreads, counter.get()); + assertEquals(NUMBER_OF_THREADS, counter.get()); } }