From dda69a052b6ee02a3206eed7cc2fbe4ff814e2f1 Mon Sep 17 00:00:00 2001 From: Hilbrand Bouwkamp Date: Fri, 10 Jan 2025 15:57:27 +0100 Subject: [PATCH] A number of code style improvments Mainly Sonar related issues. --- .../client/BrokerConnectionFactory.java | 4 +-- .../client/TaskManagerClientSender.java | 4 --- .../ConnectionConfiguration.java | 10 ++++---- .../client/mq/RabbitMQWorkerMonitor.java | 4 +-- .../taskmanager/client/util/QueueHelper.java | 2 +- .../client/BrokerConnectionFactoryTest.java | 25 +++++++++---------- .../client/MockTaskResultHandler.java | 4 +-- .../client/TaskManagerClientTest.java | 22 ++++++++-------- .../test/MockedChannelFactory.java | 6 ++++- .../taskmanager/ConfigurationManager.java | 2 +- .../aerius/taskmanager/FIFOTaskScheduler.java | 2 +- .../taskmanager/mq/RabbitMQQueueMonitor.java | 2 +- .../taskmanager/ConfigurationManagerTest.java | 2 +- .../PriorityTaskSchedulerTest.java | 2 +- .../aerius/taskmanager/QueueWatchDogTest.java | 2 +- .../taskmanager/TaskDispatcherTest.java | 10 ++++---- .../aerius/taskmanager/TaskManagerTest.java | 6 ++--- .../mq/RabbitMQQueueMonitorTest.java | 2 +- 18 files changed, 54 insertions(+), 57 deletions(-) diff --git a/source/taskmanager-client/src/main/java/nl/aerius/taskmanager/client/BrokerConnectionFactory.java b/source/taskmanager-client/src/main/java/nl/aerius/taskmanager/client/BrokerConnectionFactory.java index 14dcba3..4ebddf1 100644 --- a/source/taskmanager-client/src/main/java/nl/aerius/taskmanager/client/BrokerConnectionFactory.java +++ b/source/taskmanager-client/src/main/java/nl/aerius/taskmanager/client/BrokerConnectionFactory.java @@ -104,7 +104,7 @@ private Connection openConnection() { delayRetry(retryTime); } } - localConnection.addShutdownListener((cause) -> { + localConnection.addShutdownListener(cause -> { if (cause.isInitiatedByApplication()) { LOG.info("Connection was shut down (by application)"); } else { @@ -114,7 +114,7 @@ private Connection openConnection() { return localConnection; } - private void delayRetry(final int retryTime) { + private static void delayRetry(final int retryTime) { try { Thread.sleep(TimeUnit.SECONDS.toMillis(retryTime)); } catch (final InterruptedException ex) { diff --git a/source/taskmanager-client/src/main/java/nl/aerius/taskmanager/client/TaskManagerClientSender.java b/source/taskmanager-client/src/main/java/nl/aerius/taskmanager/client/TaskManagerClientSender.java index fc51c90..62c568a 100644 --- a/source/taskmanager-client/src/main/java/nl/aerius/taskmanager/client/TaskManagerClientSender.java +++ b/source/taskmanager-client/src/main/java/nl/aerius/taskmanager/client/TaskManagerClientSender.java @@ -46,10 +46,6 @@ public class TaskManagerClientSender implements TaskWrapperSender { private static final Logger LOG = LoggerFactory.getLogger(TaskManagerClientSender.class); - private static final boolean QUEUE_DURABLE = true; - private static final boolean QUEUE_EXCLUSIVE = false; - private static final boolean QUEUE_AUTO_DELETE = false; - private static final int DELIVERY_MODE_NON_PERSISTENT = 1; private static final int DELIVERY_MODE_PERSISTENT = 2; diff --git a/source/taskmanager-client/src/main/java/nl/aerius/taskmanager/client/configuration/ConnectionConfiguration.java b/source/taskmanager-client/src/main/java/nl/aerius/taskmanager/client/configuration/ConnectionConfiguration.java index b70877e..ece2555 100644 --- a/source/taskmanager-client/src/main/java/nl/aerius/taskmanager/client/configuration/ConnectionConfiguration.java +++ b/source/taskmanager-client/src/main/java/nl/aerius/taskmanager/client/configuration/ConnectionConfiguration.java @@ -227,7 +227,7 @@ public ConnectionConfiguration build() { return connectionConfiguration; } - private void checkBlank(final String name, final String value) { + private static void checkBlank(final String name, final String value) { if (value == null || value.isEmpty()) { throw new IllegalArgumentException(name + " not allowed to be null or empty."); } @@ -235,7 +235,7 @@ private void checkBlank(final String name, final String value) { public ConnectionConfiguration.Builder brokerHost(final String brokerHost) { if (brokerHost == null) { - throw new NullPointerException("Null brokerHost"); + throw new IllegalArgumentException("brokerHost null"); } this.brokerHost = brokerHost; return this; @@ -248,7 +248,7 @@ public ConnectionConfiguration.Builder brokerPort(final int brokerPort) { public ConnectionConfiguration.Builder brokerUsername(final String brokerUsername) { if (brokerUsername == null) { - throw new NullPointerException("Null brokerUsername"); + throw new IllegalArgumentException("brokerUsername null"); } this.brokerUsername = brokerUsername; return this; @@ -256,7 +256,7 @@ public ConnectionConfiguration.Builder brokerUsername(final String brokerUsernam public ConnectionConfiguration.Builder brokerPassword(final String brokerPassword) { if (brokerPassword == null) { - throw new NullPointerException("Null brokerPassword"); + throw new IllegalArgumentException("brokerPassword null"); } this.brokerPassword = brokerPassword; return this; @@ -264,7 +264,7 @@ public ConnectionConfiguration.Builder brokerPassword(final String brokerPasswor public ConnectionConfiguration.Builder brokerVirtualHost(final String brokerVirtualHost) { if (brokerVirtualHost == null) { - throw new NullPointerException("Null brokerVirtualHost"); + throw new IllegalArgumentException("brokerVirtualHost null"); } this.brokerVirtualHost = brokerVirtualHost; return this; diff --git a/source/taskmanager-client/src/main/java/nl/aerius/taskmanager/client/mq/RabbitMQWorkerMonitor.java b/source/taskmanager-client/src/main/java/nl/aerius/taskmanager/client/mq/RabbitMQWorkerMonitor.java index cb11b39..03ee343 100644 --- a/source/taskmanager-client/src/main/java/nl/aerius/taskmanager/client/mq/RabbitMQWorkerMonitor.java +++ b/source/taskmanager-client/src/main/java/nl/aerius/taskmanager/client/mq/RabbitMQWorkerMonitor.java @@ -192,7 +192,7 @@ private void handleDelivery(final AMQP.BasicProperties properties) { * @param param param to return the value for * @return value of param or null if not present */ - private String getParam(final Map headers, final String param) { + private static String getParam(final Map headers, final String param) { final Object value = headers.get(param); return value == null ? null : value.toString(); @@ -206,7 +206,7 @@ private String getParam(final Map headers, final String param) { * @param other if param is not present this value is returned * @return int value of param or other if not present */ - private int getParamInt(final Map headers, final String param, final int other) { + private static int getParamInt(final Map headers, final String param, final int other) { final String value = getParam(headers, param); try { diff --git a/source/taskmanager-client/src/main/java/nl/aerius/taskmanager/client/util/QueueHelper.java b/source/taskmanager-client/src/main/java/nl/aerius/taskmanager/client/util/QueueHelper.java index f0e9f83..ae40701 100644 --- a/source/taskmanager-client/src/main/java/nl/aerius/taskmanager/client/util/QueueHelper.java +++ b/source/taskmanager-client/src/main/java/nl/aerius/taskmanager/client/util/QueueHelper.java @@ -26,7 +26,7 @@ import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; -import com.rabbitmq.client.AMQP.BasicProperties; +import com.rabbitmq.client.BasicProperties; import com.rabbitmq.client.LongString; /** diff --git a/source/taskmanager-client/src/test/java/nl/aerius/taskmanager/client/BrokerConnectionFactoryTest.java b/source/taskmanager-client/src/test/java/nl/aerius/taskmanager/client/BrokerConnectionFactoryTest.java index b2f50e5..48b2f52 100644 --- a/source/taskmanager-client/src/test/java/nl/aerius/taskmanager/client/BrokerConnectionFactoryTest.java +++ b/source/taskmanager-client/src/test/java/nl/aerius/taskmanager/client/BrokerConnectionFactoryTest.java @@ -18,7 +18,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows; -import java.io.IOException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -46,8 +45,8 @@ static void afterClass() { } @Test - void testTaskManagerClientWithoutBrokerHost() throws IOException { - assertThrows(NullPointerException.class, () -> { + void testTaskManagerClientWithoutBrokerHost() { + assertThrows(IllegalArgumentException.class, () -> { final ConnectionConfiguration.Builder builder = getFullConnectionConfigurationBuilder(); builder.brokerHost(null); new BrokerConnectionFactory(executor, builder.build()); @@ -55,7 +54,7 @@ void testTaskManagerClientWithoutBrokerHost() throws IOException { } @Test - void testTaskManagerClientWithEmptyBrokerHost() throws IOException { + void testTaskManagerClientWithEmptyBrokerHost() { assertThrows(IllegalArgumentException.class, () -> { final ConnectionConfiguration.Builder builder = getFullConnectionConfigurationBuilder(); builder.brokerHost(""); @@ -64,8 +63,8 @@ void testTaskManagerClientWithEmptyBrokerHost() throws IOException { } @Test - void testTaskManagerClientWithoutBrokerUsername() throws IOException { - assertThrows(NullPointerException.class, () -> { + void testTaskManagerClientWithoutBrokerUsername() { + assertThrows(IllegalArgumentException.class, () -> { final ConnectionConfiguration.Builder builder = getFullConnectionConfigurationBuilder(); builder.brokerUsername(null); new BrokerConnectionFactory(executor, builder.build()); @@ -73,7 +72,7 @@ void testTaskManagerClientWithoutBrokerUsername() throws IOException { } @Test - void testTaskManagerClientWithEmptyBrokerUsername() throws IOException { + void testTaskManagerClientWithEmptyBrokerUsername() { assertThrows(IllegalArgumentException.class, () -> { final ConnectionConfiguration.Builder builder = getFullConnectionConfigurationBuilder(); builder.brokerUsername(""); @@ -82,8 +81,8 @@ void testTaskManagerClientWithEmptyBrokerUsername() throws IOException { } @Test - void testTaskManagerClientWithoutBrokerPassword() throws IOException { - assertThrows(NullPointerException.class, () -> { + void testTaskManagerClientWithoutBrokerPassword() { + assertThrows(IllegalArgumentException.class, () -> { final ConnectionConfiguration.Builder builder = getFullConnectionConfigurationBuilder(); builder.brokerPassword(null); new BrokerConnectionFactory(executor, builder.build()); @@ -91,7 +90,7 @@ void testTaskManagerClientWithoutBrokerPassword() throws IOException { } @Test - void testTaskManagerClientWithEmptyBrokerPassword() throws IOException { + void testTaskManagerClientWithEmptyBrokerPassword() { assertThrows(IllegalArgumentException.class, () -> { final ConnectionConfiguration.Builder builder = getFullConnectionConfigurationBuilder(); builder.brokerPassword(""); @@ -100,8 +99,8 @@ void testTaskManagerClientWithEmptyBrokerPassword() throws IOException { } @Test - void testTaskManagerClientWithoutBrokerVirtualHost() throws IOException { - assertThrows(NullPointerException.class, () -> { + void testTaskManagerClientWithoutBrokerVirtualHost() { + assertThrows(IllegalArgumentException.class, () -> { final ConnectionConfiguration.Builder builder = getFullConnectionConfigurationBuilder(); builder.brokerVirtualHost(null); new BrokerConnectionFactory(executor, builder.build()); @@ -109,7 +108,7 @@ void testTaskManagerClientWithoutBrokerVirtualHost() throws IOException { } @Test - void testTaskManagerClientWithEmptyBrokerVirtualHost() throws IOException { + void testTaskManagerClientWithEmptyBrokerVirtualHost() { assertThrows(IllegalArgumentException.class, () -> { final ConnectionConfiguration.Builder builder = getFullConnectionConfigurationBuilder(); builder.brokerVirtualHost(""); diff --git a/source/taskmanager-client/src/test/java/nl/aerius/taskmanager/client/MockTaskResultHandler.java b/source/taskmanager-client/src/test/java/nl/aerius/taskmanager/client/MockTaskResultHandler.java index 8fbcba7..fb5b8e2 100644 --- a/source/taskmanager-client/src/test/java/nl/aerius/taskmanager/client/MockTaskResultHandler.java +++ b/source/taskmanager-client/src/test/java/nl/aerius/taskmanager/client/MockTaskResultHandler.java @@ -21,10 +21,8 @@ import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; -import nl.aerius.taskmanager.client.TaskResultCallback; - /** - * + * Util class to more easily mock a {@link TaskResultCallback}. */ class MockTaskResultHandler implements TaskResultCallback { diff --git a/source/taskmanager-client/src/test/java/nl/aerius/taskmanager/client/TaskManagerClientTest.java b/source/taskmanager-client/src/test/java/nl/aerius/taskmanager/client/TaskManagerClientTest.java index 4dd45fc..096d202 100644 --- a/source/taskmanager-client/src/test/java/nl/aerius/taskmanager/client/TaskManagerClientTest.java +++ b/source/taskmanager-client/src/test/java/nl/aerius/taskmanager/client/TaskManagerClientTest.java @@ -48,26 +48,26 @@ class TaskManagerClientTest { private static final WorkerQueueType WORKER_TYPE_TEST = new WorkerQueueType("TEST"); private static final String NORMAL_TASK_ID = "SomeTaskId"; private static final String TASK_QUEUE_NAME = "taskmanagerclienttest.task"; - private static ExecutorService EXECUTOR; + private static ExecutorService executor; private WorkerQueueType workerType; private TaskManagerClientSender taskManagerClient; private MockTaskResultHandler mockTaskResultHandler; @BeforeAll static void setupClass() { - EXECUTOR = Executors.newSingleThreadExecutor(); + executor = Executors.newSingleThreadExecutor(); } @AfterAll static void afterClass() { - EXECUTOR.shutdown(); + executor.shutdown(); } @BeforeEach - void setUp() throws Exception { + void setUp() { mockTaskResultHandler = new MockTaskResultHandler(); workerType = WORKER_TYPE_TEST; - taskManagerClient = new TaskManagerClientSender(new BrokerConnectionFactory(EXECUTOR) { + taskManagerClient = new TaskManagerClientSender(new BrokerConnectionFactory(executor) { @Override protected Connection createNewConnection() throws IOException { return new MockConnection(); @@ -76,7 +76,7 @@ protected Connection createNewConnection() throws IOException { } @AfterEach - void tearDown() throws Exception { + void tearDown() { taskManagerClient.shutdown(); } @@ -104,7 +104,7 @@ void testSendTasks() throws IOException { } @Test - void testSendTasksWithNullId() throws IOException, InterruptedException { + void testSendTasksWithNullId() throws IOException { taskManagerClient.sendTask(new MockTaskInput(), null, mockTaskResultHandler, workerType, TASK_QUEUE_NAME); assertTrue(taskManagerClient.isUsable(), "Taskmanagerclient should still be usable."); } @@ -131,7 +131,7 @@ void testTaskManagerClientWithConnectionConfigurationBean() throws IOException, * @throws InterruptedException */ @Test - void testSendUnserializableTask() throws IOException, InterruptedException { + void testSendUnserializableTask() { assertThrows(NotSerializableException.class, () -> { //anonymous inner type isn't serializable (even if the type is Serializable). final Serializable input = new Serializable() { @@ -158,7 +158,7 @@ void testExit() throws IOException, InterruptedException { * @throws InterruptedException */ @Test - void testSendTaskAfterExit() throws IOException, InterruptedException { + void testSendTaskAfterExit() { assertThrows(IllegalStateException.class, () -> { taskManagerClient.shutdown(); testSendTask(); @@ -169,7 +169,7 @@ void testSendTaskAfterExit() throws IOException, InterruptedException { * Test method for {@link TaskManagerClientSender#sendTask(Object, String, String)}. */ @Test - void testSendTaskToNullQueue() throws IOException { + void testSendTaskToNullQueue() { assertThrows(IllegalArgumentException.class, () -> taskManagerClient.sendTask(new MockTaskInput(), NORMAL_TASK_ID, mockTaskResultHandler, workerType, null)); } @@ -178,7 +178,7 @@ void testSendTaskToNullQueue() throws IOException { * Test method for {@link TaskManagerClientSender#sendTask(Object, String, String)}. */ @Test - void testSendNullObjectAsTask() throws IOException { + void testSendNullObjectAsTask() { assertThrows(IllegalArgumentException.class, () -> taskManagerClient.sendTask(null, null, mockTaskResultHandler, workerType, TASK_QUEUE_NAME)); } diff --git a/source/taskmanager-test/src/main/java/nl/aerius/taskmanager/test/MockedChannelFactory.java b/source/taskmanager-test/src/main/java/nl/aerius/taskmanager/test/MockedChannelFactory.java index 24d7058..bee59af 100644 --- a/source/taskmanager-test/src/main/java/nl/aerius/taskmanager/test/MockedChannelFactory.java +++ b/source/taskmanager-test/src/main/java/nl/aerius/taskmanager/test/MockedChannelFactory.java @@ -51,13 +51,17 @@ * * This class keeps some state */ -public class MockedChannelFactory { +public final class MockedChannelFactory { private static final ExecutorService EXECUTOR = Executors.newCachedThreadPool(); private static final Map> QUEUES = new ConcurrentHashMap<>(); private static final Map QUEUED = new ConcurrentHashMap<>(); private static byte[] received; + private MockedChannelFactory() { + // Util class + } + /** * Creates a new mocked channel. * diff --git a/source/taskmanager/src/main/java/nl/aerius/taskmanager/ConfigurationManager.java b/source/taskmanager/src/main/java/nl/aerius/taskmanager/ConfigurationManager.java index a77e932..76620b9 100644 --- a/source/taskmanager/src/main/java/nl/aerius/taskmanager/ConfigurationManager.java +++ b/source/taskmanager/src/main/java/nl/aerius/taskmanager/ConfigurationManager.java @@ -35,7 +35,7 @@ */ final class ConfigurationManager { - private static final Logger LOG = LoggerFactory.getLogger(TaskManagerConfiguration.class); + private static final Logger LOG = LoggerFactory.getLogger(ConfigurationManager.class); private ConfigurationManager() { } diff --git a/source/taskmanager/src/main/java/nl/aerius/taskmanager/FIFOTaskScheduler.java b/source/taskmanager/src/main/java/nl/aerius/taskmanager/FIFOTaskScheduler.java index 63df85b..e8cfaf1 100644 --- a/source/taskmanager/src/main/java/nl/aerius/taskmanager/FIFOTaskScheduler.java +++ b/source/taskmanager/src/main/java/nl/aerius/taskmanager/FIFOTaskScheduler.java @@ -27,7 +27,7 @@ */ class FIFOTaskScheduler implements TaskScheduler { - private final BlockingQueue tasks = new LinkedBlockingQueue(); + private final BlockingQueue tasks = new LinkedBlockingQueue<>(); @Override public void addTask(final Task task) { diff --git a/source/taskmanager/src/main/java/nl/aerius/taskmanager/mq/RabbitMQQueueMonitor.java b/source/taskmanager/src/main/java/nl/aerius/taskmanager/mq/RabbitMQQueueMonitor.java index e50d7de..629e809 100644 --- a/source/taskmanager/src/main/java/nl/aerius/taskmanager/mq/RabbitMQQueueMonitor.java +++ b/source/taskmanager/src/main/java/nl/aerius/taskmanager/mq/RabbitMQQueueMonitor.java @@ -107,7 +107,7 @@ public void updateWorkerQueueState(final String queueName, final WorkerSizeObser // Use RabbitMQ HTTP-API. // URL: [host]:[port]/api/queues/[virtualHost]/[QueueName] final String virtualHost = configuration.getBrokerVirtualHost().replace("/", "%2f"); - final String apiPath = "/api/queues/" + virtualHost + "/" + queueName; + final String apiPath = String.format("/api/queues/%s/%s", virtualHost, queueName); try { final JsonNode jsonObject = getJsonResultFromApi(apiPath); diff --git a/source/taskmanager/src/test/java/nl/aerius/taskmanager/ConfigurationManagerTest.java b/source/taskmanager/src/test/java/nl/aerius/taskmanager/ConfigurationManagerTest.java index 36ee34e..05804df 100644 --- a/source/taskmanager/src/test/java/nl/aerius/taskmanager/ConfigurationManagerTest.java +++ b/source/taskmanager/src/test/java/nl/aerius/taskmanager/ConfigurationManagerTest.java @@ -42,7 +42,7 @@ void before() throws IOException { @Test @Timeout(2000) - void testLoadConfiguration() throws IOException { + void testLoadConfiguration() { final TaskManagerConfiguration tmc = ConfigurationManager.loadConfiguration(properties); assertNotNull(tmc.getBrokerConfiguration().getBrokerUsername(), "No username could be read from configuration file"); diff --git a/source/taskmanager/src/test/java/nl/aerius/taskmanager/PriorityTaskSchedulerTest.java b/source/taskmanager/src/test/java/nl/aerius/taskmanager/PriorityTaskSchedulerTest.java index b92a5df..b47b482 100644 --- a/source/taskmanager/src/test/java/nl/aerius/taskmanager/PriorityTaskSchedulerTest.java +++ b/source/taskmanager/src/test/java/nl/aerius/taskmanager/PriorityTaskSchedulerTest.java @@ -184,7 +184,7 @@ void testGetTask() throws InterruptedException, ExecutionException { assertEquals(0, chkCounter.intValue(), "Counter should still be zero when 1 slot priorty available"); assertFalse(receivedTask.isDone(), "Should not be done yet"); scheduler.onTaskFinished(task1a.getMessage().getMetaData().getQueueName()); - await().atMost(1, TimeUnit.SECONDS).until(() -> receivedTask.isDone()); + await().atMost(1, TimeUnit.SECONDS).until(receivedTask::isDone); assertNotNull(receivedTask.get(), "Received task"); // task1a finished, now task1b may be executed. assertEquals(1, chkCounter.intValue(), "Counter should still be 1"); diff --git a/source/taskmanager/src/test/java/nl/aerius/taskmanager/QueueWatchDogTest.java b/source/taskmanager/src/test/java/nl/aerius/taskmanager/QueueWatchDogTest.java index b025e13..e57682e 100644 --- a/source/taskmanager/src/test/java/nl/aerius/taskmanager/QueueWatchDogTest.java +++ b/source/taskmanager/src/test/java/nl/aerius/taskmanager/QueueWatchDogTest.java @@ -30,7 +30,7 @@ class QueueWatchDogTest { @Test - void testIsItDead() throws InterruptedException { + void testIsItDead() { final AtomicReference now = new AtomicReference<>(LocalDateTime.now()); final QueueWatchDog qwd = new QueueWatchDog() { @Override diff --git a/source/taskmanager/src/test/java/nl/aerius/taskmanager/TaskDispatcherTest.java b/source/taskmanager/src/test/java/nl/aerius/taskmanager/TaskDispatcherTest.java index 3ef0f56..897b814 100644 --- a/source/taskmanager/src/test/java/nl/aerius/taskmanager/TaskDispatcherTest.java +++ b/source/taskmanager/src/test/java/nl/aerius/taskmanager/TaskDispatcherTest.java @@ -71,7 +71,7 @@ void after() throws InterruptedException { @Test @Timeout(3000) - void testNoFreeWorkers() throws InterruptedException { + void testNoFreeWorkers() { // Add Worker which will unlock workerPool.onNumberOfWorkersUpdate(1, 0); executor.execute(dispatcher); @@ -89,21 +89,21 @@ void testNoFreeWorkers() throws InterruptedException { @Test @Timeout(3000) - void testForwardTest() throws InterruptedException { + void testForwardTest() { final Task task = createTask(); final Future future = forwardTaskAsync(task, null); executor.execute(dispatcher); await().until(() -> dispatcher.isLocked(task)); workerPool.onNumberOfWorkersUpdate(1, 0); //add worker which will unlock await().until(() -> dispatcher.getState() == State.WAIT_FOR_WORKER); - await().until(() -> future.isDone()); + await().until(future::isDone); assertFalse(future.isCancelled(), "Taskconsumer must be unlocked at this point without error"); } @Disabled("TaskAlreadySendexception error willl not be thrown") @Test @Timeout(3000) - void testForwardDuplicateTask() throws InterruptedException { + void testForwardDuplicateTask() { final Task task = createTask(); executor.execute(dispatcher); final Future future = forwardTaskAsync(task, null); @@ -124,7 +124,7 @@ void testForwardDuplicateTask() throws InterruptedException { @Test @Timeout(3000) - void testExceptionDuringForward() throws InterruptedException { + void testExceptionDuringForward() { workerProducer.setShutdownExceptionOnForward(true); final Task task = createTask(); executor.execute(dispatcher); diff --git a/source/taskmanager/src/test/java/nl/aerius/taskmanager/TaskManagerTest.java b/source/taskmanager/src/test/java/nl/aerius/taskmanager/TaskManagerTest.java index d794a4b..b4de6a3 100644 --- a/source/taskmanager/src/test/java/nl/aerius/taskmanager/TaskManagerTest.java +++ b/source/taskmanager/src/test/java/nl/aerius/taskmanager/TaskManagerTest.java @@ -62,14 +62,14 @@ void after() throws InterruptedException { } @Test - void testAddScheduler() throws IOException, InterruptedException { + void testAddScheduler() throws InterruptedException { assertTrue(taskManager.updateTaskScheduler(schedule), "TaskScheduler running"); assertEquals(RabbitMQQueueType.STREAM, schedule.getQueueType(), "Should have queueType STREAM"); taskManager.removeTaskScheduler(schedule.getWorkerQueueName()); } @Test - void testModifyQueue() throws IOException, InterruptedException { + void testModifyQueue() throws InterruptedException { assertTrue(taskManager.updateTaskScheduler(schedule), "TaskScheduler running"); schedule.getQueues().get(0).setPriority(30); assertTrue(taskManager.updateTaskScheduler(schedule), "TaskScheduler updated"); @@ -77,7 +77,7 @@ void testModifyQueue() throws IOException, InterruptedException { } @Test - void testRemoveQueue() throws IOException, InterruptedException { + void testRemoveQueue() throws InterruptedException { assertTrue(taskManager.updateTaskScheduler(schedule), "TaskScheduler running"); schedule.getQueues().remove(0); assertTrue(taskManager.updateTaskScheduler(schedule), "TaskScheduler updated"); diff --git a/source/taskmanager/src/test/java/nl/aerius/taskmanager/mq/RabbitMQQueueMonitorTest.java b/source/taskmanager/src/test/java/nl/aerius/taskmanager/mq/RabbitMQQueueMonitorTest.java index 16182ac..1d26054 100644 --- a/source/taskmanager/src/test/java/nl/aerius/taskmanager/mq/RabbitMQQueueMonitorTest.java +++ b/source/taskmanager/src/test/java/nl/aerius/taskmanager/mq/RabbitMQQueueMonitorTest.java @@ -40,7 +40,7 @@ class RabbitMQQueueMonitorTest { private final ObjectMapper objectMapper = new ObjectMapper(); @Test - void testGetWorkerQueueState() throws InterruptedException { + void testGetWorkerQueueState() { final ConnectionConfiguration configuration = ConnectionConfiguration.builder() .brokerHost(DUMMY).brokerPort(0).brokerUsername(DUMMY).brokerPassword(DUMMY).build(); final AtomicInteger workerSize = new AtomicInteger();