Fix sonar code smells 36/136136/1
authoradheli.tavares <adheli.tavares@est.tech>
Fri, 29 Sep 2023 08:05:58 +0000 (09:05 +0100)
committeradheli.tavares <adheli.tavares@est.tech>
Fri, 29 Sep 2023 08:10:44 +0000 (09:10 +0100)
Issue-ID: POLICY-4832
Change-Id: Icb8013fe566e9cb265f5b75340d4bb51211a890a
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java
main/src/test/java/org/onap/policy/pap/main/comm/msgdata/RequestImplTest.java
main/src/test/java/org/onap/policy/pap/main/comm/msgdata/StateChangeReqTest.java
main/src/test/java/org/onap/policy/pap/main/rest/e2e/PdpGroupCreateOrUpdateTest.java

index 696a694..1426d1c 100644 (file)
@@ -24,7 +24,6 @@ package org.onap.policy.pap.main.comm;
 
 import java.sql.SQLIntegrityConstraintViolationException;
 import java.time.Instant;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedList;
index f4be140..3d8dc0a 100644 (file)
@@ -77,7 +77,7 @@ class RequestImplTest extends CommonRequestBase {
     }
 
     @Test
-    public void testRequest_InvalidArgs() {
+    void testRequest_InvalidArgs() {
         // null params
         assertThatThrownBy(() -> new MyRequest(null, MY_REQ_NAME, msg)).isInstanceOf(NullPointerException.class);
 
@@ -92,13 +92,13 @@ class RequestImplTest extends CommonRequestBase {
     }
 
     @Test
-    public void testReconfigure2_WrongMsgClass() {
+    void testReconfigure2_WrongMsgClass() {
         assertThatIllegalArgumentException().isThrownBy(() -> req.reconfigure(new PdpUpdate()))
                         .withMessage("expecting PdpStateChange instead of PdpUpdate");
     }
 
     @Test
-    public void testReconfigure2_NotPublishing() {
+    void testReconfigure2_NotPublishing() {
 
         // replace the message with a new message
         req.reconfigure(new PdpStateChange());
@@ -108,7 +108,7 @@ class RequestImplTest extends CommonRequestBase {
     }
 
     @Test
-    public void testRequestImpl_testReconfigure2_Publishing() {
+    void testRequestImpl_testReconfigure2_Publishing() {
         req.startPublishing();
 
         // replace the message with a new message
@@ -135,7 +135,7 @@ class RequestImplTest extends CommonRequestBase {
     }
 
     @Test
-    public void testIsPublishing() {
+    void testIsPublishing() {
         assertFalse(req.isPublishing());
 
         req.startPublishing();
@@ -146,14 +146,14 @@ class RequestImplTest extends CommonRequestBase {
     }
 
     @Test
-    public void testStartPublishingQueueToken_NoListener() {
+    void testStartPublishingQueueToken_NoListener() {
         req.setListener(null);
         assertThatIllegalStateException().isThrownBy(() -> req.startPublishing())
                         .withMessage("listener has not been set");
     }
 
     @Test
-    public void testStartPublishing() {
+    void testStartPublishing() {
         req.startPublishing();
 
         assertTrue(req.isPublishing());
@@ -176,7 +176,7 @@ class RequestImplTest extends CommonRequestBase {
     }
 
     @Test
-    public void testStopPublishing() {
+    void testStopPublishing() {
         // not publishing yet
         req.stopPublishing();
         assertFalse(req.isPublishing());
@@ -197,13 +197,13 @@ class RequestImplTest extends CommonRequestBase {
     }
 
     @Test
-    public void testStopPublishingBoolean_NotPublishing() {
+    void testStopPublishingBoolean_NotPublishing() {
         // should not throw an exception
         Assertions.assertThatCode(() -> req.stopPublishing()).doesNotThrowAnyException();
     }
 
     @Test
-    public void testStopPublishingBoolean_TruePublishing() {
+    void testStopPublishingBoolean_TruePublishing() {
         req.startPublishing();
 
         req.stopPublishing();
@@ -225,7 +225,7 @@ class RequestImplTest extends CommonRequestBase {
     }
 
     @Test
-    public void testEnqueue() {
+    void testEnqueue() {
         req.startPublishing();
 
         // replace the message with a new message
@@ -267,7 +267,7 @@ class RequestImplTest extends CommonRequestBase {
     }
 
     @Test
-    public void testResetRetryCount_testBumpRetryCount() {
+    void testResetRetryCount_testBumpRetryCount() {
         req = new MyRequest(new RequestParams().setMaxRetryCount(2).setModifyLock(lock).setPdpPublisher(publisher)
             .setResponseDispatcher(dispatcher).setTimers(timers), MY_REQ_NAME, msg);
         req.setListener(listener);
@@ -287,7 +287,7 @@ class RequestImplTest extends CommonRequestBase {
     }
 
     @Test
-    public void testProcessResponse() {
+    void testProcessResponse() {
         req.startPublishing();
 
         invokeProcessResponse(response);
@@ -298,7 +298,7 @@ class RequestImplTest extends CommonRequestBase {
     }
 
     @Test
-    public void testProcessResponse_NotPublishing() {
+    void testProcessResponse_NotPublishing() {
         // force registration with the dispatcher - needed by invokeProcessResponse(response)
         req.startPublishing();
         req.stopPublishing();
@@ -310,7 +310,7 @@ class RequestImplTest extends CommonRequestBase {
     }
 
     @Test
-    public void testProcessResponse_WrongRequest() {
+    void testProcessResponse_WrongRequest() {
         req.startPublishing();
 
         response.getResponse().setResponseTo(DIFFERENT);
@@ -323,7 +323,7 @@ class RequestImplTest extends CommonRequestBase {
     }
 
     @Test
-    public void testProcessResponse_ResponseFailed() {
+    void testProcessResponse_ResponseFailed() {
         req.startPublishing();
 
         response.setName(DIFFERENT);
@@ -336,7 +336,7 @@ class RequestImplTest extends CommonRequestBase {
     }
 
     @Test
-    public void testHandleTimeout() {
+    void testHandleTimeout() {
         req.startPublishing();
 
         // remove it from the queue
@@ -352,7 +352,7 @@ class RequestImplTest extends CommonRequestBase {
     }
 
     @Test
-    public void testHandleTimeout_NotPublishing() {
+    void testHandleTimeout_NotPublishing() {
         req.startPublishing();
 
         req.stopPublishing();
@@ -365,7 +365,7 @@ class RequestImplTest extends CommonRequestBase {
     }
 
     @Test
-    public void testHandleTimeout_RetryExhausted() {
+    void testHandleTimeout_RetryExhausted() {
         req.startPublishing();
 
         // exhaust the count
@@ -385,7 +385,7 @@ class RequestImplTest extends CommonRequestBase {
     }
 
     @Test
-    public void testCheckResponse_Matched() {
+    void testCheckResponse_Matched() {
         req.startPublishing();
 
         invokeProcessResponse(response);
@@ -395,7 +395,7 @@ class RequestImplTest extends CommonRequestBase {
     }
 
     @Test
-    public void testCheckResponse_NullName() {
+    void testCheckResponse_NullName() {
         req.startPublishing();
 
         response.setName(null);
@@ -407,7 +407,7 @@ class RequestImplTest extends CommonRequestBase {
     }
 
     @Test
-    public void testCheckResponse_MismatchedName() {
+    void testCheckResponse_MismatchedName() {
         req.startPublishing();
 
         response.setName(DIFFERENT);
@@ -419,7 +419,7 @@ class RequestImplTest extends CommonRequestBase {
     }
 
     @Test
-    public void testCheckResponse_MismatchedNameWithBroadcast() {
+    void testCheckResponse_MismatchedNameWithBroadcast() {
         msg.setName(null);
         req.startPublishing();
 
@@ -432,12 +432,12 @@ class RequestImplTest extends CommonRequestBase {
     }
 
     @Test
-    public void testGetName() {
+    void testGetName() {
         assertEquals(MY_REQ_NAME, req.getName());
     }
 
     @Test
-    public void testGetMessage() {
+    void testGetMessage() {
         assertSame(msg, req.getMessage());
 
         PdpStateChange msg2 = new PdpStateChange();
@@ -446,12 +446,12 @@ class RequestImplTest extends CommonRequestBase {
     }
 
     @Test
-    public void testGetParams() {
+    void testGetParams() {
         assertSame(reqParams, req.getParams());
     }
 
     @Test
-    public void testGetUndeployPolicies() {
+    void testGetUndeployPolicies() {
         assertTrue(req.getUndeployPolicies().isEmpty());
     }
 
index 7cf731d..1ec2335 100644 (file)
@@ -63,39 +63,39 @@ class StateChangeReqTest extends CommonRequestBase {
     }
 
     @Test
-    public void testGetMessage() {
+    void testGetMessage() {
         assertEquals(MY_REQ_NAME, data.getName());
         assertSame(msg, data.getMessage());
     }
 
     @Test
-    public void testCheckResponse() {
+    void testCheckResponse() {
         assertNull(data.checkResponse(response));
     }
 
     @Test
-    public void testCheckResponse_NullName() {
+    void testCheckResponse_NullName() {
         response.setName(null);
 
         assertEquals("null PDP name", data.checkResponse(response));
     }
 
     @Test
-    public void testCheckResponse_NullMsgName() {
+    void testCheckResponse_NullMsgName() {
         msg.setName(null);
 
         assertNull(data.checkResponse(response));
     }
 
     @Test
-    public void testCheckResponse_MismatchedState() {
+    void testCheckResponse_MismatchedState() {
         response.setState(DIFF_STATE);
 
         assertEquals("state is TERMINATED, but expected SAFE", data.checkResponse(response));
     }
 
     @Test
-    public void testReconfigure() {
+    void testReconfigure() {
         // different message type should fail and leave message unchanged
         assertFalse(data.reconfigure(new PdpUpdate()));
         assertSame(msg, data.getMessage());
index e7fc09c..9b4239b 100644 (file)
@@ -88,7 +88,7 @@ class PdpGroupCreateOrUpdateTest extends End2EndBase {
         createPdpGroups("createGroups.yaml", "application/yaml");
     }
 
-    private void createPdpGroups(String fileName, String mediaType) throws Exception, InterruptedException {
+    private void createPdpGroups(String fileName, String mediaType) throws Exception {
         context.addPdp("pdpAA_1", CREATE_SUBGROUP);
         context.addPdp("pdpAA_2", CREATE_SUBGROUP);
         context.addPdp("pdpAB_1", "pdpTypeB");
@@ -127,7 +127,7 @@ class PdpGroupCreateOrUpdateTest extends End2EndBase {
     }
 
     @Test
-    public void testCreateAndUpdate_MultipleGroups() throws Exception {
+    void testCreateAndUpdate_MultipleGroups() throws Exception {
 
         Invocation.Builder invocationBuilderForGroupUpdate = sendRequest(CREATEORUPDATE_GROUPS_ENDPOINT);