Uplift code base to java21 99/142699/1 master
authoradheli.tavares <adheli.tavares@est.tech>
Mon, 8 Dec 2025 15:54:27 +0000 (15:54 +0000)
committeradheli.tavares <adheli.tavares@est.tech>
Mon, 8 Dec 2025 15:55:00 +0000 (15:55 +0000)
Issue-ID: POLICY-5466
Change-Id: I5bd4672ba5a601d9699c8b69fcb071d1db5f049b
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
main/src/test/java/org/onap/policy/pap/main/comm/CommonRequestBase.java
main/src/test/java/org/onap/policy/pap/main/comm/PdpModifyRequestMapTest.java
main/src/test/java/org/onap/policy/pap/main/comm/PdpRequestsTest.java

index 9211742..f8a421e 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP PAP
  * ================================================================================
  * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2021-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2021-2025 OpenInfra Foundation Europe. All rights reserved.
  * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -61,7 +61,8 @@ import org.onap.policy.pap.main.parameters.RequestParams;
 /**
  * Common base class for request tests.
  */
-public class CommonRequestBase {
+@SuppressWarnings({"unchecked", "rawtypes"})
+public class CommonRequestBase { // NOSONAR - class is being extended by other test classes
     protected static final String PDP1 = "pdp_1";
     protected static final String PDP2 = "pdp_2";
     protected static final String PDP3 = "pdp_3";
@@ -90,7 +91,7 @@ public class CommonRequestBase {
     protected PdpModifyRequestMapParams mapParams;
 
     @BeforeAll
-    public static void setupBeforeAll() {
+    public static void setupBeforeAll() { // NOSONAR - class is being extended by other test classes
         Registry.registerOrReplace(PapConstants.REG_METER_REGISTRY, new SimpleMeterRegistry());
     }
 
@@ -100,8 +101,7 @@ public class CommonRequestBase {
      * @throws Exception if an error occurs
      */
     @BeforeEach
-    @SuppressWarnings("unchecked")
-    public void setUp() throws Exception {
+    public void setUp() throws Exception { // NOSONAR - class is being extended by other test classes
         publisher = mock(Publisher.class);
         notifier = mock(PolicyNotifier.class);
         dispatcher = mock(RequestIdDispatcher.class);
@@ -141,9 +141,7 @@ public class CommonRequestBase {
      *
      * @param response the response to pass to the listener
      */
-    @SuppressWarnings("unchecked")
     protected void invokeProcessResponse(PdpStatus response) {
-        @SuppressWarnings("rawtypes")
         ArgumentCaptor<TypedMessageListener> processResp = ArgumentCaptor.forClass(TypedMessageListener.class);
 
         verify(dispatcher).register(any(), processResp.capture());
@@ -154,9 +152,7 @@ public class CommonRequestBase {
     /**
      * Gets the timeout handler that was registered with the timer manager and invokes it.
      */
-    @SuppressWarnings("unchecked")
     protected void invokeTimeoutHandler() {
-        @SuppressWarnings("rawtypes")
         ArgumentCaptor<Consumer> timeoutHdlr = ArgumentCaptor.forClass(Consumer.class);
 
         verify(timers).register(any(), timeoutHdlr.capture());
@@ -184,15 +180,14 @@ public class CommonRequestBase {
      * Makes an update request with a new message.
      *
      * @param pdpName PDP name
-     * @param group group name
-     * @param subgroup subgroup name
      * @return a new update request
      */
-    protected UpdateReq makeUpdateReq(String pdpName, String group, String subgroup) {
+    protected UpdateReq makeUpdateReq(String pdpName) {
         UpdateReq req = mock(UpdateReq.class);
 
         when(req.getName()).thenReturn(MY_REQ_NAME);
-        when(req.getMessage()).thenReturn(makeUpdate(pdpName, group, subgroup));
+        when(req.getMessage()).thenReturn(
+            makeUpdate(pdpName));
 
         return req;
     }
@@ -201,18 +196,16 @@ public class CommonRequestBase {
      * Makes an update message.
      *
      * @param pdpName PDP name
-     * @param group group name
-     * @param subgroup subgroup name
      * @return a new update message
      */
-    protected PdpUpdate makeUpdate(String pdpName, String group, String subgroup) {
+    protected PdpUpdate makeUpdate(String pdpName) {
         PdpUpdate message = new PdpUpdate();
 
         message.setName(pdpName);
         message.setPoliciesToBeDeployed(Collections.emptyList());
         message.setPoliciesToBeUndeployed(Collections.emptyList());
-        message.setPdpGroup(group);
-        message.setPdpSubgroup(subgroup);
+        message.setPdpGroup(CommonRequestBase.MY_GROUP);
+        message.setPdpSubgroup(CommonRequestBase.MY_SUBGROUP);
 
         return message;
     }
@@ -220,15 +213,13 @@ public class CommonRequestBase {
     /**
      * Makes a state-change request with a new message.
      *
-     * @param pdpName PDP name
-     * @param state desired PDP state
      * @return a new state-change request
      */
-    protected StateChangeReq makeStateChangeReq(String pdpName, PdpState state) {
+    protected StateChangeReq makeStateChangeReq() {
         StateChangeReq req = mock(StateChangeReq.class);
 
         when(req.getName()).thenReturn(MY_REQ_NAME);
-        when(req.getMessage()).thenReturn(makeStateChange(pdpName, state));
+        when(req.getMessage()).thenReturn(makeStateChange(CommonRequestBase.PDP1));
 
         return req;
     }
@@ -237,14 +228,13 @@ public class CommonRequestBase {
      * Makes a state-change message.
      *
      * @param pdpName PDP name
-     * @param state desired PDP state
      * @return a new state-change message
      */
-    protected PdpStateChange makeStateChange(String pdpName, PdpState state) {
+    protected PdpStateChange makeStateChange(String pdpName) {
         PdpStateChange message = new PdpStateChange();
 
         message.setName(pdpName);
-        message.setState(state);
+        message.setState(CommonRequestBase.MY_STATE);
 
         return message;
     }
index 57fc5e9..06d1ae8 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP PAP
  * ================================================================================
  * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2020-2021, 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021, 2023-2025 OpenInfra Foundation Europe.
  * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -134,8 +134,8 @@ class PdpModifyRequestMapTest extends CommonRequestBase {
 
         response = new PdpStatus();
 
-        update = makeUpdate(PDP1, MY_GROUP, MY_SUBGROUP);
-        change = makeStateChange(PDP1, MY_STATE);
+        update = makeUpdate(PDP1);
+        change = makeStateChange(PDP1);
 
         when(requests.getPdpName()).thenReturn(PDP1);
         when(requests.isFirstInQueue(any())).thenReturn(true);
@@ -323,7 +323,7 @@ class PdpModifyRequestMapTest extends CommonRequestBase {
         getSingletons(1);
 
         // add another request with the same PDP
-        map.addRequest(makeStateChange(PDP1, MY_STATE));
+        map.addRequest(makeStateChange(PDP1));
         assertEquals(1, map.nalloc);
 
         // should now have another singleton
@@ -331,7 +331,7 @@ class PdpModifyRequestMapTest extends CommonRequestBase {
 
 
         // add another request with a different PDP
-        map.addRequest(makeStateChange(DIFFERENT, MY_STATE));
+        map.addRequest(makeStateChange(DIFFERENT));
 
         // should now have another allocation
         assertEquals(2, map.nalloc);
index 8bafdd2..e514215 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP PAP
  * ================================================================================
  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2025 OpenInfra Foundation Europe.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -48,8 +48,8 @@ class PdpRequestsTest extends CommonRequestBase {
     @Override
     @BeforeEach
     public void setUp() {
-        update = makeUpdateReq(PDP1, MY_GROUP, MY_SUBGROUP);
-        change = makeStateChangeReq(PDP1, MY_STATE);
+        update = makeUpdateReq(PDP1);
+        change = makeStateChangeReq();
 
         data = new PdpRequests(PDP1, notifier);
     }
@@ -73,7 +73,7 @@ class PdpRequestsTest extends CommonRequestBase {
         data.addSingleton(update);
 
         // add duplicate update
-        UpdateReq req2 = makeUpdateReq(PDP1, MY_GROUP, MY_SUBGROUP);
+        UpdateReq req2 = makeUpdateReq(PDP1);
         data.addSingleton(req2);
 
         // should not publish duplicate
@@ -91,11 +91,11 @@ class PdpRequestsTest extends CommonRequestBase {
         data.addSingleton(change);
 
         // add duplicate requests
-        StateChangeReq change2 = makeStateChangeReq(PDP1, MY_STATE);
+        StateChangeReq change2 = makeStateChangeReq();
         when(change.reconfigure(change2.getMessage())).thenReturn(true);
         data.addSingleton(change2);
 
-        UpdateReq update2 = makeUpdateReq(PDP1, MY_GROUP, MY_SUBGROUP);
+        UpdateReq update2 = makeUpdateReq(PDP1);
         when(update.reconfigure(update2.getMessage())).thenReturn(true);
         data.addSingleton(update2);
 
@@ -109,7 +109,7 @@ class PdpRequestsTest extends CommonRequestBase {
 
     @Test
     void testAddSingleton_Broadcast() {
-        UpdateReq req = makeUpdateReq(null, MY_GROUP, MY_SUBGROUP);
+        UpdateReq req = makeUpdateReq(null);
         assertThatIllegalArgumentException().isThrownBy(() -> data.addSingleton(req))
             .withMessage("unexpected broadcast for pdp_1");
     }