diff options
author | waynedunican <wayne.dunican@est.tech> | 2024-07-23 09:23:51 +0100 |
---|---|---|
committer | waynedunican <wayne.dunican@est.tech> | 2024-08-13 08:49:10 +0100 |
commit | b7804abcf865dc58a01bed3f2be4756e731d9288 (patch) | |
tree | 7f6fc3b50622578bb8612de9fe5e5c6adddfaf28 /models-interactions/model-actors/actorServiceProvider | |
parent | a029ccab07f2dd71286804da620c513da9fdfc0e (diff) |
Improve code coverage and sonar fixes
Increased code coverage to 90%
SONAR - Removed TODO comments
SONAR - Added NOSONAR where appropriate
SONAR - Replaced stream.Collect() with stream.toList() where applicable
SONAR - Made variables serializable or transient to comply with sonar rules
Issue-ID: POLICY-5069
Change-Id: Ife256eaf4e6f427fe40b138bacc6f112dc5bcea4
Signed-off-by: waynedunican <wayne.dunican@est.tech>
Diffstat (limited to 'models-interactions/model-actors/actorServiceProvider')
9 files changed, 26 insertions, 29 deletions
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java index 5765f35ba..8f2199f05 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperation.java @@ -95,7 +95,6 @@ public abstract class BidirectionalTopicOperation<Q, S> extends OperationPartial */ @Override protected long getTimeoutMs(Integer timeoutSec) { - // TODO move this method to the superclass return (timeoutSec == null || timeoutSec == 0 ? getTimeoutMs() : super.getTimeoutMs(timeoutSec)); } diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicActorTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicActorTest.java index 5ecebd668..7e4543eca 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicActorTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicActorTest.java @@ -98,7 +98,7 @@ class BidirectionalTopicActorTest { } @Test - void testDoStart() throws BidirectionalTopicClientException { + void testDoStart() { // allocate some handlers actor.getTopicHandler(MY_SINK, MY_SOURCE1); actor.getTopicHandler(MY_SINK, MY_SOURCE2); @@ -117,7 +117,7 @@ class BidirectionalTopicActorTest { } @Test - void testDoStop() throws BidirectionalTopicClientException { + void testDoStop() { // allocate some handlers actor.getTopicHandler(MY_SINK, MY_SOURCE1); actor.getTopicHandler(MY_SINK, MY_SOURCE2); @@ -136,7 +136,7 @@ class BidirectionalTopicActorTest { } @Test - void testDoShutdown() throws BidirectionalTopicClientException { + void testDoShutdown() { // allocate some handlers actor.getTopicHandler(MY_SINK, MY_SOURCE1); @@ -187,7 +187,7 @@ class BidirectionalTopicActorTest { } @Test - void testGetTopicHandler() throws BidirectionalTopicClientException { + void testGetTopicHandler() { assertSame(handler1, actor.getTopicHandler(MY_SINK, MY_SOURCE1)); assertSame(handler2, actor.getTopicHandler(MY_SINK, MY_SOURCE2)); @@ -195,7 +195,7 @@ class BidirectionalTopicActorTest { } @Test - void testMakeTopicHandler() throws BidirectionalTopicClientException { + void testMakeTopicHandler() { // use a real actor actor = new BidirectionalTopicActor<>(ACTOR, BidirectionalTopicActorParams.class); diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java index 1fc8cc18e..67283f5d4 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperationTest.java @@ -174,7 +174,7 @@ class BidirectionalTopicOperationTest { * Tests startOperationAsync() when processResponse() throws an exception. */ @Test - void testStartOperationAsyncProcException() throws Exception { + void testStartOperationAsyncProcException() { oper = new MyOperation(params, config) { @Override protected OperationOutcome processResponse(OperationOutcome outcome, String rawResponse, @@ -202,7 +202,7 @@ class BidirectionalTopicOperationTest { * Tests startOperationAsync() when the publisher throws an exception. */ @Test - void testStartOperationAsyncPubException() throws Exception { + void testStartOperationAsyncPubException() { // indicate that nothing was published when(handler.send(any())).thenReturn(false); @@ -302,7 +302,7 @@ class BidirectionalTopicOperationTest { * Tests processResponse() when the decoder succeeds. */ @Test - void testProcessResponseDecodeOk() throws CoderException { + void testProcessResponseDecodeOk() { assertSame(outcome, oper.processResponse(outcome, responseText, stdResponse)); assertEquals(OperationResult.SUCCESS, outcome.getResult()); assertEquals(response, outcome.getResponse()); @@ -312,7 +312,7 @@ class BidirectionalTopicOperationTest { * Tests processResponse() when the decoder throws an exception. */ @Test - void testProcessResponseDecodeExcept() throws CoderException { + void testProcessResponseDecodeExcept() { assertThatIllegalArgumentException().isThrownBy( () -> oper.processResponse(outcome, "{invalid json", stdResponse)); } diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java index 9813d1b7a..8e1a8783a 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperationTest.java @@ -260,7 +260,7 @@ class HttpOperationTest { * Tests handleResponse() when it fails. */ @Test - void testHandleResponseFailed() throws Exception { + void testHandleResponseFailed() { CompletableFuture<OperationOutcome> future2 = oper.handleResponse(outcome, PATH, cb -> { callback.set(cb); return future; @@ -322,7 +322,7 @@ class HttpOperationTest { * Tests processResponse() when the decoder throws an exception. */ @Test - void testProcessResponseDecodeExcept() throws CoderException { + void testProcessResponseDecodeExcept() { MyGetOperation<Integer> oper2 = new MyGetOperation<>(Integer.class); assertThatIllegalArgumentException().isThrownBy(() -> oper2.processResponse(outcome, PATH, response)); diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperationTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperationTest.java index 0850bb358..78f465ea8 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperationTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperationTest.java @@ -89,7 +89,7 @@ class HttpPollingOperationTest { * Sets up. */ @BeforeEach - void setUp() throws Exception { + void setUp() { Mockito.lenient().when(client.getBaseUrl()).thenReturn(BASE_URI); Mockito.lenient().when(config.getClient()).thenReturn(client); diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperatorTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperatorTest.java index ca81e2eb3..13a16bfc2 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperatorTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpPollingOperatorTest.java @@ -29,7 +29,6 @@ import static org.mockito.Mockito.when; import java.util.Collections; import java.util.Map; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java index 27b841a91..d2ca7dbc6 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java @@ -137,7 +137,7 @@ class OperationPartialTest { * Attaches the appender to the logger. */ @BeforeAll - static void setUpBeforeClass() throws Exception { + static void setUpBeforeClass() { /* * Attach appender to the logger. */ @@ -565,7 +565,7 @@ class OperationPartialTest { */ @Test @SuppressWarnings("unchecked") - void testAnyOfEdge() throws Exception { + void testAnyOfEdge() { List<Supplier<CompletableFuture<OperationOutcome>>> tasks = new LinkedList<>(); // zero items: check both using a list and using an array @@ -651,7 +651,7 @@ class OperationPartialTest { */ @Test @SuppressWarnings("unchecked") - void testAllOfEdge() throws Exception { + void testAllOfEdge() { List<Supplier<CompletableFuture<OperationOutcome>>> tasks = new LinkedList<>(); // zero items: check both using a list and using an array @@ -667,7 +667,7 @@ class OperationPartialTest { } @Test - void testAttachFutures() throws Exception { + void testAttachFutures() { List<Supplier<CompletableFuture<OperationOutcome>>> tasks = new LinkedList<>(); // third task throws an exception during construction @@ -770,7 +770,7 @@ class OperationPartialTest { */ @Test @SuppressWarnings("unchecked") - void testSequenceEdge() throws Exception { + void testSequenceEdge() { List<Supplier<CompletableFuture<OperationOutcome>>> tasks = new LinkedList<>(); // zero items: check both using a list and using an array diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineControllerFutureTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineControllerFutureTest.java index c0d3a0df8..2c8275986 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineControllerFutureTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineControllerFutureTest.java @@ -157,7 +157,7 @@ class PipelineControllerFutureTest { * Tests completeAsync(executor) when canceled before execution. */ @Test - void testCompleteAsyncSupplierOfQextendsTExecutorCanceled() throws Exception { + void testCompleteAsyncSupplierOfQextendsTExecutorCanceled() { CompletableFuture<String> future = controller.completeAsync(() -> TEXT, executor); assertTrue(future.cancel(false)); @@ -181,7 +181,7 @@ class PipelineControllerFutureTest { * Tests completeAsync() when canceled. */ @Test - void testCompleteAsyncSupplierOfQextendsTCanceled() throws Exception { + void testCompleteAsyncSupplierOfQextendsTCanceled() { CountDownLatch canceled = new CountDownLatch(1); // run async, but await until canceled @@ -210,7 +210,7 @@ class PipelineControllerFutureTest { @Test void testCompleteOnTimeoutTLongTimeUnit() throws Exception { CountDownLatch stopped = new CountDownLatch(1); - controller.add(() -> stopped.countDown()); + controller.add(stopped::countDown); CompletableFuture<String> future = controller.completeOnTimeout(TEXT, 1, TimeUnit.MILLISECONDS); @@ -288,7 +288,7 @@ class PipelineControllerFutureTest { * Tests delayedComplete() when an exception is generated. */ @Test - void testDelayedCompleteWithException() throws Exception { + void testDelayedCompleteWithException() { controller.add(runnable1); BiConsumer<String, Throwable> stopper = controller.delayedComplete(); @@ -314,7 +314,7 @@ class PipelineControllerFutureTest { } @Test - void testDelayedRemoveFutureOfF() throws Exception { + void testDelayedRemoveFutureOfF() { BiConsumer<String, Throwable> remover = controller.delayedRemove(future1); remover.accept(TEXT, EXPECTED_EXCEPTION); @@ -331,7 +331,7 @@ class PipelineControllerFutureTest { } @Test - void testDelayedRemoveRunnable() throws Exception { + void testDelayedRemoveRunnable() { BiConsumer<String, Throwable> remover = controller.delayedRemove(runnable1); remover.accept(TEXT, EXPECTED_EXCEPTION); @@ -380,7 +380,7 @@ class PipelineControllerFutureTest { * Tests wrap(), when the controller is not running. */ @Test - void testWrapNotRunning() throws Exception { + void testWrapNotRunning() { controller.cancel(false); controller = spy(controller); @@ -395,7 +395,7 @@ class PipelineControllerFutureTest { * Tests wrap(), when the future throws an exception. */ @Test - void testWrapException() throws Exception { + void testWrapException() { controller = spy(controller); CompletableFuture<String> future = controller.wrap(compFuture); @@ -428,7 +428,7 @@ class PipelineControllerFutureTest { * Tests wrap(Function) when the controller is canceled after the future is added. */ @Test - void testWrapFunctionCancel() throws Exception { + void testWrapFunctionCancel() { Function<String, CompletableFuture<String>> func = controller.wrap(input -> compFuture); CompletableFuture<String> future = func.apply(TEXT); diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/ForwarderTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/ForwarderTest.java index e050416f5..f27eb6ae5 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/ForwarderTest.java +++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/topic/ForwarderTest.java @@ -31,7 +31,6 @@ import static org.mockito.Mockito.verify; import java.util.Arrays; import java.util.Map; import java.util.function.BiConsumer; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; |