Fix sonar issues 95/139895/1
authoradheli.tavares <adheli.tavares@est.tech>
Fri, 10 Jan 2025 11:50:41 +0000 (11:50 +0000)
committeradheli.tavares <adheli.tavares@est.tech>
Fri, 10 Jan 2025 11:51:51 +0000 (11:51 +0000)
- fixing sonar issues on code to generate new models-* artifacts
with parent new dependencies.

Issue-ID: POLICY-5240
Change-Id: I41e01ededbc20c9b389be1167691aeb4e03cd0fb
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
30 files changed:
models-base/src/test/java/org/onap/policy/models/base/PfReferenceTimestampKeyTest.java
models-base/src/test/java/org/onap/policy/models/base/PfTimestampKeyTest.java
models-dao/src/test/java/org/onap/policy/models/dao/DummyConceptEntity.java
models-dao/src/test/java/org/onap/policy/models/dao/EntityTest.java
models-interactions/model-actors/actor.a1p/src/test/java/org/onap/policy/controlloop/actor/a1p/BasicA1pOperation.java
models-interactions/model-actors/actor.aai/src/test/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperationTest.java
models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.java
models-interactions/model-actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmOperationTest.java
models-interactions/model-actors/actor.cds/src/test/java/org/onap/policy/controlloop/actor/cds/GrpcOperationTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/UtilTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/ActorImplTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/BidirectionalTopicOperatorTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/impl/OperationPartialTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineControllerFutureTest.java
models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/pipeline/PipelineUtilTest.java
models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java
models-interactions/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/SdnrTest.java
models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/CdsSimulatorTest.java
models-pap/src/test/java/org/onap/policy/models/pap/persistence/concepts/JpaPolicyAuditTest.java
models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java
models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderTest.java
models-provider/src/test/java/org/onap/policy/models/provider/revisionhierarchy/HierarchyFetchTest.java
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java
models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntityFilterTest.java
models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTypedEntityFilterTest.java
models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTimeIntervalTest.java
models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithToscaPropertiesTest.java
models-tosca/src/test/java/org/onap/policy/models/tosca/utils/ToscaUtilsTest.java

index 62418d9..c0af351 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * Copyright (C) 2021, 2024 Nordix Foundation.
+ * Copyright (C) 2021, 2024-2025 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@ class PfReferenceTimestampKeyTest {
     private static final String LOCAL_NAME = "LocalName";
     private static final String VERSION002 = "0.0.2";
     private static final String VERSION001 = "0.0.1";
-    private static final long timeStamp = 1613152081L;
+    private static final long TIME_STAMP = 1613152081L;
     private static final Instant DEFAULT_TIMESTAMP = Instant.EPOCH;
 
     @Test
@@ -49,16 +49,16 @@ class PfReferenceTimestampKeyTest {
         assertNotNull(new PfReferenceTimestampKey(new PfReferenceTimestampKey()).getTimeStamp());
 
         assertEquals(LOCAL_NAME,
-                new PfReferenceTimestampKey(new PfReferenceKey(), LOCAL_NAME, Instant.ofEpochSecond(timeStamp))
+                new PfReferenceTimestampKey(new PfReferenceKey(), LOCAL_NAME, Instant.ofEpochSecond(TIME_STAMP))
                         .getReferenceKey().getLocalName());
-        assertEquals(Date.from(Instant.ofEpochSecond(timeStamp)), new PfReferenceTimestampKey(new PfConceptKey(),
-                PARENT_LOCAL_NAME, LOCAL_NAME, Instant.ofEpochSecond(timeStamp)).getTimeStamp());
+        assertEquals(Date.from(Instant.ofEpochSecond(TIME_STAMP)), new PfReferenceTimestampKey(new PfConceptKey(),
+                PARENT_LOCAL_NAME, LOCAL_NAME, Instant.ofEpochSecond(TIME_STAMP)).getTimeStamp());
 
         assertThat(new PfReferenceTimestampKey("ParentKeyName", VERSION001, PARENT_LOCAL_NAME, LOCAL_NAME,
-                Instant.ofEpochSecond(timeStamp))).isInstanceOf(PfReferenceTimestampKey.class);
+                Instant.ofEpochSecond(TIME_STAMP))).isInstanceOf(PfReferenceTimestampKey.class);
 
         assertThat(
-                new PfReferenceTimestampKey("ParentKeyName", VERSION001, LOCAL_NAME, Instant.ofEpochSecond(timeStamp))
+                new PfReferenceTimestampKey("ParentKeyName", VERSION001, LOCAL_NAME, Instant.ofEpochSecond(TIME_STAMP))
                         .getReferenceKey().getParentLocalName()).isEqualTo(PfKey.NULL_KEY_NAME);
 
         assertEquals(PfReferenceTimestampKey.getNullKey().getKey(), PfReferenceTimestampKey.getNullKey());
@@ -71,8 +71,8 @@ class PfReferenceTimestampKeyTest {
         PfReferenceTimestampKey testNullKey = new PfReferenceTimestampKey();
         assertTrue(testNullKey.isNullKey());
 
-        String id = "NULL:0.0.0:NULL:NULL:" + timeStamp;
-        assertThat(new PfReferenceTimestampKey(id).getTimeStamp().getTime()).isEqualTo(timeStamp);
+        String id = "NULL:0.0.0:NULL:NULL:" + TIME_STAMP;
+        assertThat(new PfReferenceTimestampKey(id).getTimeStamp().getTime()).isEqualTo(TIME_STAMP);
     }
 
     @Test
@@ -124,17 +124,17 @@ class PfReferenceTimestampKeyTest {
 
         assertEquals(testReferenceKey, clonedReferenceKey);
         assertNotEquals(testReferenceKey, new PfReferenceTimestampKey("PKN", VERSION001, "PLN",
-            "LN", Instant.ofEpochSecond(timeStamp)));
-        testReferenceKey.setTimeStamp(Date.from(Instant.ofEpochSecond(timeStamp)));
+            "LN", Instant.ofEpochSecond(TIME_STAMP)));
+        testReferenceKey.setTimeStamp(Date.from(Instant.ofEpochSecond(TIME_STAMP)));
         assertEquals(testReferenceKey, new PfReferenceTimestampKey("PKN", VERSION001, PARENT_LOCAL_NAME, "LN",
-                Instant.ofEpochSecond(timeStamp)));
+                Instant.ofEpochSecond(TIME_STAMP)));
 
         assertNotEquals(0, testReferenceKey.compareTo(new PfReferenceTimestampKey()));
         assertNotEquals(0, testReferenceKey.compareTo(new PfReferenceTimestampKey("PKN", VERSION002,
-            "PLN", "LN", Instant.ofEpochSecond(timeStamp))));
+            "PLN", "LN", Instant.ofEpochSecond(TIME_STAMP))));
 
         assertEquals(0, testReferenceKey.compareTo(new PfReferenceTimestampKey("PKN", VERSION001, PARENT_LOCAL_NAME,
-                "LN", Instant.ofEpochSecond(timeStamp))));
+                "LN", Instant.ofEpochSecond(TIME_STAMP))));
 
         assertThatThrownBy(() -> new PfReferenceTimestampKey((PfReferenceTimestampKey) null))
                 .isInstanceOf(NullPointerException.class);
@@ -146,13 +146,13 @@ class PfReferenceTimestampKeyTest {
     @Test
     void testNewerKey() {
         PfReferenceTimestampKey key1 = new PfReferenceTimestampKey("ParentKeyName", VERSION001, PARENT_LOCAL_NAME,
-                LOCAL_NAME, Instant.ofEpochSecond(timeStamp));
+                LOCAL_NAME, Instant.ofEpochSecond(TIME_STAMP));
         PfReferenceTimestampKey key2 = new PfReferenceTimestampKey(key1);
         assertFalse(key2.isNewerThan(key1));
         assertThatThrownBy(() -> key1.isNewerThan((PfKey) null)).isInstanceOf(NullPointerException.class)
                 .hasMessageMatching("^otherKey is marked .*on.*ull but is null$");
 
-        key2.setTimeStamp(Date.from(Instant.ofEpochSecond(timeStamp).plusSeconds(80)));
+        key2.setTimeStamp(Date.from(Instant.ofEpochSecond(TIME_STAMP).plusSeconds(80)));
         assertTrue(key2.isNewerThan(key1));
     }
 
index 90eacca..81d0c08 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * Copyright (C) 2019-2021, 2024 Nordix Foundation.
+ * Copyright (C) 2019-2021, 2024-2025 Nordix Foundation.
  * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -35,7 +35,7 @@ class PfTimestampKeyTest {
     private static final String CONCEPT_IS_NULL = "^copyConcept is marked .*on.*ull but is null$";
     private static final String NAME_IS_NULL = "^name is marked .*on.*ull but is null$";
     private static final String VERSION_IS_NULL = "^version is marked .*on.*ull but is null$";
-    private static final long timeStamp = 1574832537641L;
+    private static final long TIME_STAMP = 1574832537641L;
 
     @Test
     void testTimestampKey() {
@@ -45,14 +45,14 @@ class PfTimestampKeyTest {
         assertEquals("PfTimestampKey(name=NULL, version=0.0.0, timeStamp=" + Date.from(Instant.EPOCH) + ")",
                 someKey0.toString());
 
-        PfTimestampKey someKey1 = new PfTimestampKey("my-name", VERSION001, Instant.ofEpochSecond(timeStamp));
+        PfTimestampKey someKey1 = new PfTimestampKey("my-name", VERSION001, Instant.ofEpochSecond(TIME_STAMP));
         PfTimestampKey someKey2 = new PfTimestampKey(someKey1);
         PfTimestampKey someKey3 = new PfTimestampKey(someKey1.getId());
         assertEquals(someKey1, someKey2);
         assertEquals(someKey1, someKey3);
         assertFalse(someKey1.isNullVersion());
         assertEquals("PfTimestampKey(name=my-name, version=0.0.1, timeStamp="
-                + Date.from(Instant.ofEpochSecond(timeStamp)) + ")", someKey1.toString());
+                + Date.from(Instant.ofEpochSecond(TIME_STAMP)) + ")", someKey1.toString());
 
         assertEquals("my-name", someKey1.getName());
         assertEquals(VERSION001, someKey1.getVersion());
@@ -69,7 +69,7 @@ class PfTimestampKeyTest {
         assertFalse(someKey1.isNewerThan(someKey2));
         assertThatThrownBy(() -> someKey1.isNewerThan((PfKey) null)).isInstanceOf(NullPointerException.class)
                 .hasMessageMatching("^otherKey is marked .*on.*ull but is null$");
-        someKey2.setTimeStamp(Date.from(Instant.ofEpochSecond(timeStamp).plusMillis(90)));
+        someKey2.setTimeStamp(Date.from(Instant.ofEpochSecond(TIME_STAMP).plusMillis(90)));
         assertTrue(someKey2.isNewerThan(someKey1));
         someKey3.setName("my-name3");
         assertTrue(someKey3.isNewerThan(someKey1));
@@ -79,7 +79,7 @@ class PfTimestampKeyTest {
         assertThatThrownBy(() -> someKey1.compareTo((PfConcept) null)).isInstanceOf(NullPointerException.class)
                 .hasMessageMatching("^otherObj is marked .*on.*ull but is null$");
 
-        PfTimestampKey someKey4 = new PfTimestampKey("NULL", "0.0.0", Instant.ofEpochSecond(timeStamp));
+        PfTimestampKey someKey4 = new PfTimestampKey("NULL", "0.0.0", Instant.ofEpochSecond(TIME_STAMP));
         assertFalse(someKey4.isNullKey());
         assertFalse(someKey1.isNullKey());
     }
index cae8cff..6458794 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2019, 2023 Nordix Foundation.
+ *  Copyright (C) 2019, 2023, 2025 Nordix Foundation.
  *  Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -73,14 +73,6 @@ public class DummyConceptEntity extends PfConcept {
         this.description = source.description;
     }
 
-    public DummyConceptEntity(final Double doubleValue) {
-        this.key = new PfConceptKey();
-    }
-
-    public DummyConceptEntity(final PfConceptKey key, final Double doubleValue) {
-        this.key = key;
-    }
-
     /**
      * Constructor.
      *
@@ -114,7 +106,7 @@ public class DummyConceptEntity extends PfConcept {
     }
 
     @Override
-    public int compareTo(final PfConcept otherObj) {
+    public int compareTo(final @NonNull PfConcept otherObj) {
         Assertions.argumentNotNull(otherObj, "comparison object may not be null");
 
         if (this == otherObj) {
index fb2155c..35080d8 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2019-2021, 2023-2024 Nordix Foundation.
+ *  Copyright (C) 2019-2021, 2023-2025 Nordix Foundation.
  *  Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
  *  Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
  * ================================================================================
@@ -112,17 +112,7 @@ class EntityTest {
     @Test
     void testEntityTestAllOpsJpa() throws PfModelException {
 
-        final DaoParameters daoParameters = new DaoParameters();
-        daoParameters.setPluginClass(DefaultPfDao.class.getName());
-        daoParameters.setPersistenceUnit("DaoTest");
-
-        Properties jdbcProperties = new Properties();
-        jdbcProperties.setProperty("jakarta.persistence.jdbc.driver", "org.h2.Driver");
-        jdbcProperties.setProperty("jakarta.persistence.jdbc.url", "jdbc:h2:mem:EntityTest");
-        jdbcProperties.setProperty("jakarta.persistence.jdbc.user", "sa");
-        jdbcProperties.setProperty("jakarta.persistence.jdbc.password", "");
-
-        daoParameters.setJdbcProperties(jdbcProperties);
+        final DaoParameters daoParameters = getDaoParameters();
 
         pfDao = new PfDaoFactory().createPfDao(daoParameters);
         pfDao.init(daoParameters);
@@ -133,24 +123,14 @@ class EntityTest {
 
         testVersionOps();
 
-        testgetFilteredOps();
+        testGetFilteredOps();
 
         testgetFilteredOps3();
     }
 
     @Test
     void testEntityTestBadVals() throws PfModelException {
-        final DaoParameters daoParameters = new DaoParameters();
-        daoParameters.setPluginClass(DefaultPfDao.class.getName());
-        daoParameters.setPersistenceUnit("DaoTest");
-
-        Properties jdbcProperties = new Properties();
-        jdbcProperties.setProperty("jakarta.persistence.jdbc.driver", "org.h2.Driver");
-        jdbcProperties.setProperty("jakarta.persistence.jdbc.url", "jdbc:h2:mem:EntityTest");
-        jdbcProperties.setProperty("jakarta.persistence.jdbc.user", "sa");
-        jdbcProperties.setProperty("jakarta.persistence.jdbc.password", "");
-
-        daoParameters.setJdbcProperties(jdbcProperties);
+        final DaoParameters daoParameters = getDaoParameters();
 
         pfDao = new PfDaoFactory().createPfDao(daoParameters);
         pfDao.init(daoParameters);
@@ -192,6 +172,21 @@ class EntityTest {
         assertThatCode(() -> pfDao.size(null)).doesNotThrowAnyException();
     }
 
+    private static DaoParameters getDaoParameters() {
+        final DaoParameters daoParameters = new DaoParameters();
+        daoParameters.setPluginClass(DefaultPfDao.class.getName());
+        daoParameters.setPersistenceUnit("DaoTest");
+
+        Properties jdbcProperties = new Properties();
+        jdbcProperties.setProperty("jakarta.persistence.jdbc.driver", "org.h2.Driver");
+        jdbcProperties.setProperty("jakarta.persistence.jdbc.url", "jdbc:h2:mem:EntityTest");
+        jdbcProperties.setProperty("jakarta.persistence.jdbc.user", "sa");
+        jdbcProperties.setProperty("jakarta.persistence.jdbc.password", "");
+
+        daoParameters.setJdbcProperties(jdbcProperties);
+        return daoParameters;
+    }
+
     private void testAllOps() {
         final PfConceptKey aKey0 = new PfConceptKey("A-KEY0", VERSION001);
         final PfConceptKey aKey1 = new PfConceptKey("A-KEY1", VERSION001);
@@ -371,11 +366,9 @@ class EntityTest {
 
         tkeyInfoSetIn.add(tkeyInfo2);
         pfDao.createCollection(tkeyInfoSetIn);
-        tkeyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyTimestampEntity.class));
         assertEquals(keyInfoSetIn, keyInfoSetOut);
 
         pfDao.delete(DummyTimestampEntity.class, atKey2);
-        tkeyInfoSetOut = new TreeSet<>(pfDao.getAll(DummyTimestampEntity.class));
         assertEquals(3, keyInfoSetOut.size());
         assertEquals(1, pfDao.size(DummyTimestampEntity.class));
 
@@ -388,7 +381,7 @@ class EntityTest {
         final PfConceptKey owner1Key = new PfConceptKey("Owner1", VERSION001);
         final PfConceptKey owner2Key = new PfConceptKey("Owner2", VERSION001);
         final PfReferenceTimestampKey arKey0 = new PfReferenceTimestampKey(owner0Key, "AT-KEY0", TIMESTAMP0);
-        final PfReferenceTimestampKey arKey1 = new PfReferenceTimestampKey(owner1Key, "AT-KEY1", TIMESTAMP1);;
+        final PfReferenceTimestampKey arKey1 = new PfReferenceTimestampKey(owner1Key, "AT-KEY1", TIMESTAMP1);
         final PfReferenceTimestampKey arKey2 = new PfReferenceTimestampKey(owner2Key, "AT-KEY2", TIMESTAMP2);
         final DummyReferenceTimestampEntity rkeyInfo0 = new DummyReferenceTimestampEntity(arKey0);
         final DummyReferenceTimestampEntity rkeyInfo1 = new DummyReferenceTimestampEntity(arKey1);
@@ -466,7 +459,7 @@ class EntityTest {
         assertEquals(0, pfDao.getAllVersions(DummyConceptEntity.class, null).size());
     }
 
-    private void testgetFilteredOps() {
+    private void testGetFilteredOps() {
         final PfConceptKey aKey0 = new PfConceptKey("AAA0", VERSION001);
         final PfConceptKey aKey1 = new PfConceptKey("AAA0", VERSION002);
         final PfConceptKey aKey2 = new PfConceptKey("AAA0", VERSION003);
@@ -540,7 +533,7 @@ class EntityTest {
         final PfConceptKey owner1Key = new PfConceptKey("Owner1", VERSION001);
         final PfConceptKey owner2Key = new PfConceptKey("Owner2", VERSION001);
         final PfReferenceTimestampKey arKey0 = new PfReferenceTimestampKey(owner0Key, "AT-KEY0", TIMESTAMP0);
-        final PfReferenceTimestampKey arKey1 = new PfReferenceTimestampKey(owner1Key, "AT-KEY1", TIMESTAMP1);;
+        final PfReferenceTimestampKey arKey1 = new PfReferenceTimestampKey(owner1Key, "AT-KEY1", TIMESTAMP1);
         final PfReferenceTimestampKey arKey2 = new PfReferenceTimestampKey(owner2Key, "AT-KEY2", TIMESTAMP2);
         final DummyReferenceTimestampEntity rkeyInfo0 = new DummyReferenceTimestampEntity(arKey0);
         final DummyReferenceTimestampEntity rkeyInfo1 = new DummyReferenceTimestampEntity(arKey1);
index 6916749..742c61d 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2022 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
+ * Modifications Copyright (C) 2024-2025 Nordix Foundation
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,14 +29,11 @@ import static org.mockito.Mockito.verify;
 
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ExecutionException;
-import java.util.function.BiConsumer;
 import org.onap.policy.common.message.bus.event.TopicSink;
 import org.onap.policy.common.message.bus.event.TopicSource;
-import org.onap.policy.common.utils.coder.StandardCoderObject;
 import org.onap.policy.controlloop.actor.test.BasicBidirectionalTopicOperation;
 import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
 import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
-import org.onap.policy.controlloop.actorserviceprovider.Util;
 import org.onap.policy.sdnr.PciBody;
 import org.onap.policy.sdnr.PciMessage;
 import org.onap.policy.sdnr.PciResponse;
@@ -59,7 +56,7 @@ public abstract class BasicA1pOperation extends BasicBidirectionalTopicOperation
     /**
      * Constructs the object.
      *
-     * @param actor actor name
+     * @param actor     actor name
      * @param operation operation name
      */
     public BasicA1pOperation(String actor, String operation) {
@@ -101,7 +98,7 @@ public abstract class BasicA1pOperation extends BasicBidirectionalTopicOperation
      * @param operation operation to run
      */
     protected void verifyOperation(A1pOperation operation)
-                    throws InterruptedException, ExecutionException {
+        throws InterruptedException, ExecutionException {
 
         CompletableFuture<OperationOutcome> future2 = operation.start();
         executor.runAll(100);
@@ -117,20 +114,4 @@ public abstract class BasicA1pOperation extends BasicBidirectionalTopicOperation
         assertEquals(OperationResult.SUCCESS, outcome.getResult());
     }
 
-    /**
-     * Provides a response to the listener.
-     *
-     * @param listener listener to which to provide the response
-     * @param code response code
-     * @param description response description
-     */
-    protected void provideResponse(BiConsumer<String, StandardCoderObject> listener, int code, String description) {
-        PciResponse response = new PciResponse();
-
-        Status status = new Status();
-        response.setStatus(status);
-        status.setCode(code);
-
-        provideResponse(listener, Util.translate("", response, String.class));
-    }
 }
index 7a101cb..8b81aad 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2025 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,7 +39,6 @@ import java.util.Map;
 import java.util.TreeMap;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeoutException;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
index 6a89312..862d841 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
+ * Modifications Copyright (C) 2024-2025 Nordix Foundation
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -122,7 +122,7 @@ public abstract class BasicAppcOperation extends BasicBidirectionalTopicOperatio
         assertFalse(future2.isDone());
 
         verify(forwarder).register(any(), listenerCaptor.capture());
-        provideResponse(listenerCaptor.getValue(), ResponseCode.SUCCESS.getValue(), MY_DESCRIPTION);
+        provideResponse(listenerCaptor.getValue(), ResponseCode.SUCCESS.getValue());
 
         executor.runAll(100);
         assertTrue(future2.isDone());
@@ -145,18 +145,17 @@ public abstract class BasicAppcOperation extends BasicBidirectionalTopicOperatio
      * Provides a response to the listener.
      *
      * @param listener listener to which to provide the response
-     * @param code response code
-     * @param description response description
+     * @param code     response code
      */
-    protected void provideResponse(BiConsumer<String, StandardCoderObject> listener, int code, String description) {
-        Response response = new Response();
+    protected void provideResponse(BiConsumer<String, StandardCoderObject> listener, int code) {
+        Response response1 = new Response();
 
         ResponseStatus status = new ResponseStatus();
-        response.setStatus(status);
+        response1.setStatus(status);
         status.setCode(code);
-        status.setDescription(description);
+        status.setDescription(BasicAppcOperation.MY_DESCRIPTION);
 
-        provideResponse(listener, Util.translate("", response, String.class));
+        provideResponse(listener, Util.translate("", response1, String.class));
     }
 
     @Override
index 02feae1..3bf7c18 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2025 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -65,13 +65,12 @@ import org.onap.policy.simulators.AppcLcmTopicServer;
 import org.onap.policy.simulators.TopicServer;
 
 @ExtendWith(MockitoExtension.class)
- class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcLcmMessageWrapper> {
+class AppcLcmOperationTest extends BasicBidirectionalTopicOperation<AppcLcmMessageWrapper> {
 
     private static final String EXPECTED_EXCEPTION = "expected exception";
     private static final String PAYLOAD_KEY1 = "key-A";
     private static final String PAYLOAD_VALUE1 = "value-A";
     private static final String MY_MESSAGE = "my-message";
-    protected static final String MY_VNF = "my-vnf";
     protected static final String RESOURCE_ID = "my-resource";
     private static final int SUCCESS_CODE = 400;
 
@@ -79,12 +78,12 @@ import org.onap.policy.simulators.TopicServer;
     private AppcLcmOperation oper;
 
     @BeforeAll
-     static void setUpBeforeClass() throws Exception {
+    static void setUpBeforeClass() throws Exception {
         initBeforeClass(MY_SINK, MY_SOURCE);
     }
 
     @AfterAll
-     static void tearDownAfterClass() {
+    static void tearDownAfterClass() {
         destroyAfterClass();
     }
 
@@ -92,7 +91,7 @@ import org.onap.policy.simulators.TopicServer;
      * Sets up.
      */
     @BeforeEach
-     void setUp() {
+    void setUp() {
         super.setUpBasic();
 
         response = makeResponse();
@@ -102,7 +101,7 @@ import org.onap.policy.simulators.TopicServer;
     }
 
     @AfterEach
-     void tearDown() {
+    void tearDown() {
         super.tearDownBasic();
     }
 
@@ -115,9 +114,9 @@ import org.onap.policy.simulators.TopicServer;
      * Tests "success" case with simulator.
      */
     @Test
-     void testSuccess() throws Exception {
+    void testSuccess() throws Exception {
         BidirectionalTopicParams opParams =
-                        BidirectionalTopicParams.builder().sinkTopic(MY_SINK).sourceTopic(MY_SOURCE).build();
+            BidirectionalTopicParams.builder().sinkTopic(MY_SINK).sourceTopic(MY_SOURCE).build();
         config = new BidirectionalTopicConfig(blockingExecutor, opParams, topicMgr, AppcLcmOperation.SELECTOR_KEYS);
 
         params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).build();
@@ -130,18 +129,18 @@ import org.onap.policy.simulators.TopicServer;
     }
 
     @Test
-     void testConstructor() {
+    void testConstructor() {
         assertEquals(DEFAULT_ACTOR, oper.getActorName());
         assertEquals(DEFAULT_OPERATION, oper.getName());
     }
 
     @Test
-     void testGetPropertyNames() {
+    void testGetPropertyNames() {
         assertThat(oper.getPropertyNames()).isEqualTo(List.of(OperationProperties.AAI_TARGET_ENTITY));
     }
 
     @Test
-     void testMakeRequest() {
+    void testMakeRequest() {
         oper.generateSubRequestId(2);
         String subreq = oper.getSubRequestId();
         assertNotNull(subreq);
@@ -165,16 +164,16 @@ import org.onap.policy.simulators.TopicServer;
      * Tests makeRequest() when a property is missing.
      */
     @Test
-     void testMakeRequestMissingProperty() {
+    void testMakeRequestMissingProperty() {
         oper = new AppcLcmOperation(params, config);
         oper.generateSubRequestId(1);
 
         assertThatIllegalStateException().isThrownBy(() -> oper.makeRequest(1))
-                        .withMessageContaining("missing target entity");
+            .withMessageContaining("missing target entity");
     }
 
     @Test
-     void testConvertPayload() {
+    void testConvertPayload() {
         // only builds a payload for ConfigModify
         params = params.toBuilder().operation(AppcLcmConstants.OPERATION_CONFIG_MODIFY).build();
         oper = new AppcLcmOperation(params, config);
@@ -201,19 +200,19 @@ import org.onap.policy.simulators.TopicServer;
         oper.generateSubRequestId(2);
 
         assertThatIllegalArgumentException().isThrownBy(() -> oper.makeRequest(2))
-                        .withMessageContaining("Cannot convert payload");
+            .withMessageContaining("Cannot convert payload");
     }
 
     @Test
-     void testGetExpectedKeyValues() {
+    void testGetExpectedKeyValues() {
         oper.generateSubRequestId(2);
         AppcLcmMessageWrapper request = oper.makeRequest(2);
         assertEquals(List.of(request.getBody().getInput().getCommonHeader().getSubRequestId()),
-                        oper.getExpectedKeyValues(50, request));
+            oper.getExpectedKeyValues(50, request));
     }
 
     @Test
-     void testDetmStatus() {
+    void testDetmStatus() {
         assertEquals(Status.SUCCESS, oper.detmStatus(null, response));
 
         // failure
@@ -242,7 +241,7 @@ import org.onap.policy.simulators.TopicServer;
     }
 
     @Test
-     void testSetOutcome() {
+    void testSetOutcome() {
         oper.setOutcome(outcome, OperationResult.SUCCESS, response);
         assertEquals(OperationResult.SUCCESS, outcome.getResult());
         assertEquals(MY_MESSAGE, outcome.getMessage());
@@ -268,7 +267,7 @@ import org.onap.policy.simulators.TopicServer;
     }
 
     @Test
-     void testGetStatus() {
+    void testGetStatus() {
         assertNotNull(oper.getStatus(response));
 
         // null status
@@ -288,7 +287,7 @@ import org.onap.policy.simulators.TopicServer;
     }
 
     @Test
-     void testOperationSupportsPayload() {
+    void testOperationSupportsPayload() {
         // these should support a payload
         Set<String> supported = Set.of(AppcLcmConstants.OPERATION_CONFIG_MODIFY);
 
@@ -300,7 +299,7 @@ import org.onap.policy.simulators.TopicServer;
 
         // these should NOT support a payload
         Set<String> unsupported = AppcLcmConstants.OPERATION_NAMES.stream().filter(name -> !supported.contains(name))
-                        .collect(Collectors.toSet());
+            .collect(Collectors.toSet());
 
         for (String name : unsupported) {
             params = params.toBuilder().operation(name).build();
@@ -343,10 +342,10 @@ import org.onap.policy.simulators.TopicServer;
     }
 
     private AppcLcmMessageWrapper makeResponse() {
-        AppcLcmMessageWrapper response = new AppcLcmMessageWrapper();
+        AppcLcmMessageWrapper wrapper = new AppcLcmMessageWrapper();
 
         AppcLcmBody body = new AppcLcmBody();
-        response.setBody(body);
+        wrapper.setBody(body);
 
         AppcLcmOutput output = new AppcLcmOutput();
         body.setOutput(output);
@@ -356,6 +355,6 @@ import org.onap.policy.simulators.TopicServer;
         status.setMessage(MY_MESSAGE);
         status.setCode(SUCCESS_CODE);
 
-        return response;
+        return wrapper;
     }
 }
index c5a20d9..8d99aaf 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * Copyright (C) 2020 Bell Canada. All rights reserved.
  * Modifications Copyright (C) 2020-2022 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
+ * Modifications Copyright (C) 2024-2025 Nordix Foundation
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -62,7 +62,7 @@ import org.onap.policy.simulators.CdsSimulator;
 import org.onap.policy.simulators.Util;
 
 @ExtendWith(MockitoExtension.class)
- class GrpcOperationTest {
+class GrpcOperationTest {
     private static final String MY_VNF = "my-vnf";
     private static final String MY_SVC_ID = "my-service-instance-id";
     private static final String RESOURCE_ID = "my-resource-id";
@@ -88,12 +88,12 @@ import org.onap.policy.simulators.Util;
     private GrpcOperation operation;
 
     @BeforeAll
-     static void setUpBeforeClass() throws Exception {
+    static void setUpBeforeClass() throws Exception {
         sim = Util.buildCdsSim();
     }
 
     @AfterAll
-     static void tearDownAfterClass() {
+    static void tearDownAfterClass() {
         sim.stop();
     }
 
@@ -101,7 +101,7 @@ import org.onap.policy.simulators.Util;
      * Sets up the fields.
      */
     @BeforeEach
-     void setUp() {
+    void setUp() {
         // Setup the CDS properties
         cdsProps = new CdsServerProperties();
         cdsProps.setHost("10.10.10.10");
@@ -117,29 +117,29 @@ import org.onap.policy.simulators.Util;
         targetEntityIds.put(ControlLoopOperationParams.PARAMS_ENTITY_RESOURCEID, RESOURCE_ID);
 
         params = ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR).operation(GrpcOperation.NAME)
-                        .requestId(REQUEST_ID).actorService(new ActorService())
-                        .build();
+            .requestId(REQUEST_ID).actorService(new ActorService())
+            .build();
     }
 
     /**
      * Tests "success" case with simulator.
      */
     @Test
-     void testSuccess() throws Exception {
+    void testSuccess() throws Exception {
         Map<String, Object> payload = Map.of("artifact_name", "my_artifact", "artifact_version", "1.0");
 
         params = ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR).operation("subscribe")
-                        .requestId(REQUEST_ID).actorService(new ActorService())
-                        .retry(0).timeoutSec(5).executor(blockingExecutor).payload(payload)
-                        .build();
+            .requestId(REQUEST_ID).actorService(new ActorService())
+            .retry(0).timeoutSec(5).executor(blockingExecutor).payload(payload)
+            .build();
 
         cdsProps.setHost("localhost");
         cdsProps.setPort(sim.getPort());
         cdsProps.setTimeout(3);
 
-        GrpcConfig config = new GrpcConfig(blockingExecutor, cdsProps);
+        GrpcConfig grpcConfig = new GrpcConfig(blockingExecutor, cdsProps);
 
-        operation = new GrpcOperation(params, config);
+        operation = new GrpcOperation(params, grpcConfig);
 
         // set the properties
         operation.setProperty(OperationProperties.OPT_CDS_GRPC_AAI_PROPERTIES, Collections.emptyMap());
@@ -150,7 +150,7 @@ import org.onap.policy.simulators.Util;
     }
 
     @Test
-     void testGetPropertyNames() {
+    void testGetPropertyNames() {
         /*
          * check VNF case with target entities
          */
@@ -196,50 +196,50 @@ import org.onap.policy.simulators.Util;
     }
 
     @Test
-     void testGetServiceInstanceId() {
+    void testGetServiceInstanceId() {
         params = params.toBuilder().targetType(TargetType.VNF).targetEntityIds(targetEntityIds).build();
         operation = new GrpcOperation(params, config);
         loadVnfData();
         assertEquals(MY_SVC_ID,
             operation.getOpProperties()
-                    .convertToAaiProperties(operation)
-                    .get(GrpcOperationProperties.AAI_SERVICE_INSTANCE_ID_KEY));
+                .convertToAaiProperties(operation)
+                .get(GrpcOperationProperties.AAI_SERVICE_INSTANCE_ID_KEY));
     }
 
     @Test
-     void testGetVnfId() {
+    void testGetVnfId() {
         params = params.toBuilder().targetType(TargetType.VNF).targetEntityIds(targetEntityIds).build();
         operation = new GrpcOperation(params, config);
         loadVnfData();
         assertEquals(MY_VNF,
             operation.getOpProperties()
-                    .convertToAaiProperties(operation)
-                    .get(GrpcOperationProperties.AAI_VNF_ID_KEY));
+                .convertToAaiProperties(operation)
+                .get(GrpcOperationProperties.AAI_VNF_ID_KEY));
 
         params = params.toBuilder().targetEntityIds(null).build();
         operation = new GrpcOperation(params, config);
         assertThatIllegalStateException().isThrownBy(()
             -> operation.getOpProperties()
-                       .convertToAaiProperties(operation)
-                       .get(GrpcOperationProperties.AAI_VNF_ID_KEY));
+            .convertToAaiProperties(operation)
+            .get(GrpcOperationProperties.AAI_VNF_ID_KEY));
 
         operation.setProperty(OperationProperties.AAI_TARGET_ENTITY, MY_VNF);
         assertEquals(MY_VNF,
-                operation.getOpProperties()
-                        .convertToAaiProperties(operation)
-                        .get(GrpcOperationProperties.AAI_VNF_ID_KEY));
+            operation.getOpProperties()
+                .convertToAaiProperties(operation)
+                .get(GrpcOperationProperties.AAI_VNF_ID_KEY));
         operation.setProperty(OperationProperties.AAI_TARGET_ENTITY, null);
     }
 
     @Test
-     void testStartOperationAsync() {
+    void testStartOperationAsync() {
         ControlLoopOperationParams clop =
-                ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR)
-                        .operation(GrpcOperation.NAME)
-                        .requestId(REQUEST_ID)
-                        .actorService(new ActorService())
-                        .targetType(TargetType.VNF)
-                        .build();
+            ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR)
+                .operation(GrpcOperation.NAME)
+                .requestId(REQUEST_ID)
+                .actorService(new ActorService())
+                .targetType(TargetType.VNF)
+                .build();
 
         verifyOperation(clop, () -> operation.setProperty(OperationProperties.AAI_TARGET_ENTITY, MY_VNF));
         verifyOperation(clop.toBuilder().targetEntityIds(targetEntityIds).build(), this::loadVnfData);
@@ -249,33 +249,33 @@ import org.onap.policy.simulators.Util;
      * Tests startOperationAsync() when the target type is PNF.
      */
     @Test
-     void testStartOperationAsyncPnf() {
+    void testStartOperationAsyncPnf() {
         ControlLoopOperationParams clop =
-                ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR)
-                        .operation(GrpcOperation.NAME)
-                        .requestId(REQUEST_ID)
-                        .actorService(new ActorService())
-                        .targetType(TargetType.PNF)
-                        .build();
+            ControlLoopOperationParams.builder().actor(CdsActorConstants.CDS_ACTOR)
+                .operation(GrpcOperation.NAME)
+                .requestId(REQUEST_ID)
+                .actorService(new ActorService())
+                .targetType(TargetType.PNF)
+                .build();
 
         verifyOperation(clop, this::loadPnfData);
     }
 
     @Test
-     void testStartOperationAsyncError() {
+    void testStartOperationAsyncError() {
         operation = new GrpcOperation(params, config);
         assertThatIllegalArgumentException()
-                        .isThrownBy(() -> operation.startOperationAsync(1, params.makeOutcome()));
+            .isThrownBy(() -> operation.startOperationAsync(1, params.makeOutcome()));
     }
 
     private void verifyOperation(ControlLoopOperationParams clop, Runnable loader) {
         Map<String, Object> payloadMap = Map.of(CdsActorConstants.KEY_CBA_NAME, CDS_BLUEPRINT_NAME,
-                        CdsActorConstants.KEY_CBA_VERSION, CDS_BLUEPRINT_VERSION, "data",
-                        "{\"mapInfo\":{\"key\":\"val\"},\"arrayInfo\":[\"one\",\"two\"],\"paramInfo\":\"val\"}");
+            CdsActorConstants.KEY_CBA_VERSION, CDS_BLUEPRINT_VERSION, "data",
+            "{\"mapInfo\":{\"key\":\"val\"},\"arrayInfo\":[\"one\",\"two\"],\"paramInfo\":\"val\"}");
         params = clop.toBuilder().payload(payloadMap).build();
 
-        GrpcConfig config = new GrpcConfig(executor, cdsProps);
-        operation = new GrpcOperation(params, config);
+        GrpcConfig grpcConfig = new GrpcConfig(executor, cdsProps);
+        operation = new GrpcOperation(params, grpcConfig);
         assertEquals(1000, operation.getTimeoutMs(null));
         assertEquals(1000, operation.getTimeoutMs(0));
         assertEquals(2000, operation.getTimeoutMs(2));
index e59c2fd..c4418cf 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
+ * Modifications Copyright (C) 2024-2025 Nordix Foundation
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -42,7 +42,6 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.TreeMap;
 import java.util.function.Consumer;
-import java.util.stream.Collectors;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.onap.policy.common.parameters.ObjectValidationResult;
@@ -244,7 +243,7 @@ class ActorServiceTest {
                         service.getActors().stream()
                             .map(Actor::getName)
                             .sorted()
-                            .collect(Collectors.toList())
+                            .toList()
                             .toString());
         // @formatter:on
     }
@@ -255,7 +254,7 @@ class ActorServiceTest {
         assertEquals("[actor A, actor B, actor C, actor D]",
                         service.getActorNames().stream()
                             .sorted()
-                            .collect(Collectors.toList())
+                            .toList()
                             .toString());
         // @formatter:on
     }
@@ -344,7 +343,7 @@ class ActorServiceTest {
 
     /**
      * Arranges for an actor to throw a validation exception when
-     * {@link Actor#configure(Map)} is invoked.
+     * {@link Actor#configure(Object)} is invoked.
      *
      * @param actor actor of interest
      */
@@ -356,7 +355,7 @@ class ActorServiceTest {
 
     /**
      * Arranges for an actor to throw a runtime exception when
-     * {@link Actor#configure(Map)} is invoked.
+     * {@link Actor#configure(Object)} is invoked.
      *
      * @param actor actor of interest
      */
@@ -367,9 +366,9 @@ class ActorServiceTest {
 
     @Test
     void testLoadActors() {
-        ActorService service = new ActorService();
-        assertFalse(service.getActors().isEmpty());
-        assertNotNull(service.getActor(DummyActor.class.getSimpleName()));
+        ActorService actorService = new ActorService();
+        assertFalse(actorService.getActors().isEmpty());
+        assertNotNull(actorService.getActor(DummyActor.class.getSimpleName()));
     }
 
     /**
index 068a723..ce72630 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
+ * Modifications Copyright (C) 2024-2025 Nordix Foundation
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -87,7 +87,7 @@ class UtilTest {
    void testRunFunction() {
         // no exception, no log
         AtomicInteger count = new AtomicInteger();
-        Util.runFunction(() -> count.incrementAndGet(), "no error");
+        Util.runFunction(count::incrementAndGet, "no error");
         assertEquals(1, count.get());
         assertEquals(0, appender.getExtracted().size());
 
index 1635c16..0a37bf6 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
+ * Modifications Copyright (C) 2024-2025 Nordix Foundation
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -37,7 +37,6 @@ import static org.mockito.Mockito.when;
 
 import java.util.Iterator;
 import java.util.Map;
-import java.util.stream.Collectors;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.onap.policy.common.parameters.ObjectValidationResult;
@@ -74,7 +73,7 @@ class ActorImplTest {
      * Initializes the fields, including a fully populated {@link #actor}.
      */
     @BeforeEach
-   void setUp() {
+    void setUp() {
         oper1 = spy(new MyOper(OPER1));
         oper2 = spy(new MyOper(OPER2));
         oper3 = spy(new MyOper(OPER3));
@@ -91,14 +90,14 @@ class ActorImplTest {
     }
 
     @Test
-   void testActorImpl_testGetName() {
+    void testActorImpl_testGetName() {
         assertEquals(ACTOR_NAME, actor.getName());
         assertEquals(4, actor.getOperationNames().size());
         assertEquals(0, actor.getSequenceNumber());
     }
 
     @Test
-   void testDoStart() {
+    void testDoStart() {
         actor.configure(params);
         assertEquals(4, actor.getOperationNames().size());
 
@@ -131,7 +130,7 @@ class ActorImplTest {
     }
 
     @Test
-   void testDoStop() {
+    void testDoStop() {
         actor.configure(params);
         actor.start();
         assertEquals(4, actor.getOperationNames().size());
@@ -163,7 +162,7 @@ class ActorImplTest {
     }
 
     @Test
-   void testDoShutdown() {
+    void testDoShutdown() {
         actor.configure(params);
         actor.start();
         assertEquals(4, actor.getOperationNames().size());
@@ -230,7 +229,7 @@ class ActorImplTest {
                         actor.getOperators().stream()
                             .map(Operator::getName)
                             .sorted()
-                            .collect(Collectors.toList())
+                            .toList()
                             .toString());
         // @formatter:on
     }
@@ -241,7 +240,7 @@ class ActorImplTest {
         assertEquals("[add, divide, multiply, subtract]",
                         actor.getOperationNames().stream()
                             .sorted()
-                            .collect(Collectors.toList())
+                            .toList()
                             .toString());
         // @formatter:on
     }
@@ -328,19 +327,19 @@ class ActorImplTest {
 
     /**
      * Arranges for an operator to throw a validation exception when
-     * {@link Operator#configure(Map)} is invoked.
+     * {@link Operator#configure(Object)} is invoked.
      *
      * @param oper operator of interest
      */
     private void makeValidException(Operator oper) {
         ParameterValidationRuntimeException ex = new ParameterValidationRuntimeException(
-                        new ObjectValidationResult(actor.getName(), null, ValidationStatus.INVALID, "null"));
+            new ObjectValidationResult(actor.getName(), null, ValidationStatus.INVALID, "null"));
         doThrow(ex).when(oper).configure(any());
     }
 
     /**
      * Arranges for an operator to throw a runtime exception when
-     * {@link Operator#configure(Map)} is invoked.
+     * {@link Operator#configure(Object)} is invoked.
      *
      * @param oper operator of interest
      */
@@ -367,13 +366,13 @@ class ActorImplTest {
      * @return a new actor
      */
     private ActorImpl makeActor(Operator... operators) {
-        ActorImpl actor = new ActorImpl(ACTOR_NAME);
+        ActorImpl actorImpl = new ActorImpl(ACTOR_NAME);
 
         for (Operator oper : operators) {
-            actor.addOperator(oper);
+            actorImpl.addOperator(oper);
         }
 
-        return actor;
+        return actorImpl;
     }
 
     private static class MyOper extends OperatorPartial {
index 38e8a29..d1f42d6 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
+ * Modifications Copyright (C) 2024-2025 Nordix Foundation
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,7 +27,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertSame;
 
-import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicReference;
@@ -66,7 +65,6 @@ class BidirectionalTopicOperatorTest {
     @Mock
     private BidirectionalTopicOperation<String, Integer> operation;
 
-    private List<SelectorKey> keys;
     private BidirectionalTopicParams params;
     private MyOperator oper;
 
@@ -75,7 +73,7 @@ class BidirectionalTopicOperatorTest {
      */
     @BeforeEach
     void setUp() {
-        keys = List.of(new SelectorKey(""));
+        List<SelectorKey> keys = List.of(new SelectorKey(""));
 
         Mockito.lenient().when(mgr.getTopicHandler(MY_SINK, MY_SOURCE)).thenReturn(handler);
         Mockito.lenient().when(handler.addForwarder(keys)).thenReturn(forwarder);
@@ -113,8 +111,8 @@ class BidirectionalTopicOperatorTest {
 
         // @formatter:off
         OperationMaker<BidirectionalTopicConfig, BidirectionalTopicOperation<?, ?>> maker =
-            (params, config) -> {
-                paramsRef.set(params);
+            (operationParams, config) -> {
+                paramsRef.set(operationParams);
                 configRef.set(config);
                 return operation;
             };
@@ -144,7 +142,7 @@ class BidirectionalTopicOperatorTest {
 
         // with no operation-maker
         BidirectionalTopicOperator oper3 =
-                        new BidirectionalTopicOperator(ACTOR, OPERATION, mgr, Arrays.asList(new SelectorKey("")));
+                        new BidirectionalTopicOperator(ACTOR, OPERATION, mgr, List.of(new SelectorKey("")));
         assertThatThrownBy(() -> oper3.buildOperation(params2)).isInstanceOf(UnsupportedOperationException.class);
     }
 
index 04300c4..99e31f2 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation.
+ * Modifications Copyright (C) 2024-2025 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -118,7 +118,7 @@ class OperationPartialTest {
     private PseudoExecutor executor;
     private ControlLoopOperationParams params;
 
-    private MyOper oper;
+    private MyOper myOperation;
 
     private int numStart;
     private int numEnd;
@@ -156,7 +156,7 @@ class OperationPartialTest {
     }
 
     /**
-     * Initializes the fields, including {@link #oper}.
+     * Initializes the fields, including {@link #myOperation}.
      */
     @BeforeEach
     void setUp() {
@@ -168,7 +168,7 @@ class OperationPartialTest {
 
         config = new OperatorConfig(executor);
 
-        oper = new MyOper();
+        myOperation = new MyOper();
 
         tstart = null;
 
@@ -181,9 +181,9 @@ class OperationPartialTest {
 
     @Test
     void testOperatorPartial_testGetActorName_testGetName() {
-        assertEquals(ACTOR, oper.getActorName());
-        assertEquals(OPERATION, oper.getName());
-        assertEquals(ACTOR + "." + OPERATION, oper.getFullName());
+        assertEquals(ACTOR, myOperation.getActorName());
+        assertEquals(OPERATION, myOperation.getName());
+        assertEquals(ACTOR + "." + OPERATION, myOperation.getFullName());
     }
 
     @Test
@@ -205,24 +205,24 @@ class OperationPartialTest {
 
     @Test
      void testGetPropertyNames() {
-        assertThat(oper.getPropertyNames()).isEqualTo(PROP_NAMES);
+        assertThat(myOperation.getPropertyNames()).isEqualTo(PROP_NAMES);
     }
 
     @Test
      void testGetProperty_testSetProperty_testGetRequiredProperty() {
-        oper.setProperty("propertyA", "valueA");
-        oper.setProperty("propertyB", "valueB");
-        oper.setProperty("propertyC", 20);
-        oper.setProperty("propertyD", "valueD");
+        myOperation.setProperty("propertyA", "valueA");
+        myOperation.setProperty("propertyB", "valueB");
+        myOperation.setProperty("propertyC", 20);
+        myOperation.setProperty("propertyD", "valueD");
 
-        assertEquals("valueA", oper.getProperty("propertyA"));
-        assertEquals("valueB", oper.getProperty("propertyB"));
-        assertEquals(Integer.valueOf(20), oper.getProperty("propertyC"));
+        assertEquals("valueA", myOperation.getProperty("propertyA"));
+        assertEquals("valueB", myOperation.getProperty("propertyB"));
+        assertEquals(Integer.valueOf(20), myOperation.getProperty("propertyC"));
 
-        assertEquals("valueD", oper.getRequiredProperty("propertyD", "typeD"));
+        assertEquals("valueD", myOperation.getRequiredProperty("propertyD", "typeD"));
 
-        assertThatIllegalStateException().isThrownBy(() -> oper.getRequiredProperty("propertyUnknown", "some type"))
-                        .withMessage("missing some type");
+        assertThatIllegalStateException().isThrownBy(() ->
+                myOperation.getRequiredProperty("propertyUnknown", "some type")).withMessage("missing some type");
     }
 
     @Test
@@ -236,7 +236,7 @@ class OperationPartialTest {
     @Test
      void testStartMultiple() {
         for (int count = 0; count < MAX_PARALLEL; ++count) {
-            oper.start();
+            myOperation.start();
         }
 
         assertTrue(executor.runAll(MAX_REQUESTS * MAX_PARALLEL));
@@ -246,65 +246,65 @@ class OperationPartialTest {
         assertEquals(OperationResult.SUCCESS, opend.getResult());
 
         assertEquals(MAX_PARALLEL, numStart);
-        assertEquals(MAX_PARALLEL, oper.getCount());
+        assertEquals(MAX_PARALLEL, myOperation.getCount());
         assertEquals(MAX_PARALLEL, numEnd);
     }
 
     @Test
      void testStartOperationAsync() {
-        oper.start();
+        myOperation.start();
         assertTrue(executor.runAll(MAX_REQUESTS));
 
-        assertEquals(1, oper.getCount());
+        assertEquals(1, myOperation.getCount());
     }
 
     @Test
      void testIsSuccess() {
-        assertFalse(oper.isSuccess(null));
+        assertFalse(myOperation.isSuccess(null));
 
         OperationOutcome outcome = new OperationOutcome();
 
         outcome.setResult(OperationResult.SUCCESS);
-        assertTrue(oper.isSuccess(outcome));
+        assertTrue(myOperation.isSuccess(outcome));
 
         for (OperationResult failure : FAILURE_RESULTS) {
             outcome.setResult(failure);
-            assertFalse(oper.isSuccess(outcome), "testIsSuccess-" + failure);
+            assertFalse(myOperation.isSuccess(outcome), "testIsSuccess-" + failure);
         }
     }
 
     @Test
      void testIsActorFailed() {
-        assertFalse(oper.isActorFailed(null));
+        assertFalse(myOperation.isActorFailed(null));
 
         OperationOutcome outcome = params.makeOutcome();
 
         // incorrect outcome
         outcome.setResult(OperationResult.SUCCESS);
-        assertFalse(oper.isActorFailed(outcome));
+        assertFalse(myOperation.isActorFailed(outcome));
 
         outcome.setResult(OperationResult.FAILURE_RETRIES);
-        assertFalse(oper.isActorFailed(outcome));
+        assertFalse(myOperation.isActorFailed(outcome));
 
         // correct outcome
         outcome.setResult(OperationResult.FAILURE);
 
         // incorrect actor
         outcome.setActor(MY_SINK);
-        assertFalse(oper.isActorFailed(outcome));
+        assertFalse(myOperation.isActorFailed(outcome));
         outcome.setActor(null);
-        assertFalse(oper.isActorFailed(outcome));
+        assertFalse(myOperation.isActorFailed(outcome));
         outcome.setActor(ACTOR);
 
         // incorrect operation
         outcome.setOperation(MY_SINK);
-        assertFalse(oper.isActorFailed(outcome));
+        assertFalse(myOperation.isActorFailed(outcome));
         outcome.setOperation(null);
-        assertFalse(oper.isActorFailed(outcome));
+        assertFalse(myOperation.isActorFailed(outcome));
         outcome.setOperation(OPERATION);
 
         // correct values
-        assertTrue(oper.isActorFailed(outcome));
+        assertTrue(myOperation.isActorFailed(outcome));
     }
 
     @Test
@@ -328,7 +328,7 @@ class OperationPartialTest {
         params = params.toBuilder().executor(ForkJoinPool.commonPool()).build();
 
         // trigger timeout very quickly
-        oper = new MyOper() {
+        myOperation = new MyOper() {
             @Override
             protected long getTimeoutMs(Integer timeoutSec) {
                 return 1;
@@ -353,7 +353,7 @@ class OperationPartialTest {
             }
         };
 
-        assertEquals(OperationResult.FAILURE_TIMEOUT, oper.start().get().getResult());
+        assertEquals(OperationResult.FAILURE_TIMEOUT, myOperation.start().get().getResult());
     }
 
     /**
@@ -364,9 +364,9 @@ class OperationPartialTest {
         params = params.toBuilder().retry(0).build();
 
         // new params, thus need a new operation
-        oper = new MyOper();
+        myOperation = new MyOper();
 
-        oper.setMaxFailures(10);
+        myOperation.setMaxFailures(10);
 
         verifyRun("testSetRetryFlag_testRetryOnFailure_ZeroRetries", 1, 1, OperationResult.FAILURE);
     }
@@ -379,9 +379,9 @@ class OperationPartialTest {
         params = params.toBuilder().retry(null).build();
 
         // new params, thus need a new operation
-        oper = new MyOper();
+        myOperation = new MyOper();
 
-        oper.setMaxFailures(10);
+        myOperation.setMaxFailures(10);
 
         verifyRun("testSetRetryFlag_testRetryOnFailure_NullRetries", 1, 1, OperationResult.FAILURE);
     }
@@ -395,9 +395,9 @@ class OperationPartialTest {
         params = params.toBuilder().retry(maxRetries).build();
 
         // new params, thus need a new operation
-        oper = new MyOper();
+        myOperation = new MyOper();
 
-        oper.setMaxFailures(10);
+        myOperation.setMaxFailures(10);
 
         verifyRun("testSetRetryFlag_testRetryOnFailure_RetriesExhausted", maxRetries + 1, maxRetries + 1,
                         OperationResult.FAILURE_RETRIES);
@@ -411,10 +411,10 @@ class OperationPartialTest {
         params = params.toBuilder().retry(10).build();
 
         // new params, thus need a new operation
-        oper = new MyOper();
+        myOperation = new MyOper();
 
         final int maxFailures = 3;
-        oper.setMaxFailures(maxFailures);
+        myOperation.setMaxFailures(maxFailures);
 
         verifyRun("testSetRetryFlag_testRetryOnFailure_SuccessAfterRetries", maxFailures + 1, maxFailures + 1,
                         OperationResult.SUCCESS);
@@ -427,7 +427,7 @@ class OperationPartialTest {
      void testSetRetryFlag_testRetryOnFailure_NullOutcome() {
 
         // arrange to return null from doOperation()
-        oper = new MyOper() {
+        myOperation = new MyOper() {
             @Override
             protected OperationOutcome doOperation(int attempt, OperationOutcome outcome) {
 
@@ -442,12 +442,12 @@ class OperationPartialTest {
 
     @Test
      void testSleep() throws Exception {
-        CompletableFuture<Void> future = oper.sleep(-1, TimeUnit.SECONDS);
+        CompletableFuture<Void> future = myOperation.sleep(-1, TimeUnit.SECONDS);
         assertTrue(future.isDone());
         assertNull(future.get());
 
         // edge case
-        future = oper.sleep(0, TimeUnit.SECONDS);
+        future = myOperation.sleep(0, TimeUnit.SECONDS);
         assertTrue(future.isDone());
         assertNull(future.get());
 
@@ -455,9 +455,9 @@ class OperationPartialTest {
          * Start a second sleep we can use to check the first while it's running.
          */
         tstart = Instant.now();
-        future = oper.sleep(100, TimeUnit.MILLISECONDS);
+        future = myOperation.sleep(100, TimeUnit.MILLISECONDS);
 
-        CompletableFuture<Void> future2 = oper.sleep(10, TimeUnit.MILLISECONDS);
+        CompletableFuture<Void> future2 = myOperation.sleep(10, TimeUnit.MILLISECONDS);
 
         // wait for second to complete and verify that the first has not completed
         future2.get();
@@ -472,31 +472,31 @@ class OperationPartialTest {
 
     @Test
      void testIsSameOperation() {
-        assertFalse(oper.isSameOperation(null));
+        assertFalse(myOperation.isSameOperation(null));
 
         OperationOutcome outcome = params.makeOutcome();
 
         // wrong actor - should be false
         outcome.setActor(null);
-        assertFalse(oper.isSameOperation(outcome));
+        assertFalse(myOperation.isSameOperation(outcome));
         outcome.setActor(MY_SINK);
-        assertFalse(oper.isSameOperation(outcome));
+        assertFalse(myOperation.isSameOperation(outcome));
         outcome.setActor(ACTOR);
 
         // wrong operation - should be null
         outcome.setOperation(null);
-        assertFalse(oper.isSameOperation(outcome));
+        assertFalse(myOperation.isSameOperation(outcome));
         outcome.setOperation(MY_SINK);
-        assertFalse(oper.isSameOperation(outcome));
+        assertFalse(myOperation.isSameOperation(outcome));
         outcome.setOperation(OPERATION);
 
-        assertTrue(oper.isSameOperation(outcome));
+        assertTrue(myOperation.isSameOperation(outcome));
     }
 
     @Test
      void testFromException() {
         // arrange to generate an exception when operation runs
-        oper.setGenException(true);
+        myOperation.setGenException(true);
 
         verifyRun("testFromException", 1, 1, OperationResult.FAILURE_EXCEPTION);
     }
@@ -520,11 +520,11 @@ class OperationPartialTest {
         final OperationOutcome outcome = params.makeOutcome();
 
         tasks.add(() -> CompletableFuture.completedFuture(outcome));
-        tasks.add(() -> new CompletableFuture<>());
+        tasks.add(CompletableFuture::new);
         tasks.add(() -> null);
-        tasks.add(() -> new CompletableFuture<>());
+        tasks.add(CompletableFuture::new);
 
-        CompletableFuture<OperationOutcome> result = oper.anyOf(tasks);
+        CompletableFuture<OperationOutcome> result = myOperation.anyOf(tasks);
         assertTrue(executor.runAll(MAX_REQUESTS));
         assertTrue(result.isDone());
         assertSame(outcome, result.get());
@@ -532,29 +532,29 @@ class OperationPartialTest {
         // repeat using array form
         @SuppressWarnings("unchecked")
         Supplier<CompletableFuture<OperationOutcome>>[] taskArray = new Supplier[tasks.size()];
-        result = oper.anyOf(tasks.toArray(taskArray));
+        result = myOperation.anyOf(tasks.toArray(taskArray));
         assertTrue(executor.runAll(MAX_REQUESTS));
         assertTrue(result.isDone());
         assertSame(outcome, result.get());
 
         // second task completes, others do not
         tasks.clear();
-        tasks.add(() -> new CompletableFuture<>());
+        tasks.add(CompletableFuture::new);
         tasks.add(() -> CompletableFuture.completedFuture(outcome));
-        tasks.add(() -> new CompletableFuture<>());
+        tasks.add(CompletableFuture::new);
 
-        result = oper.anyOf(tasks);
+        result = myOperation.anyOf(tasks);
         assertTrue(executor.runAll(MAX_REQUESTS));
         assertTrue(result.isDone());
         assertSame(outcome, result.get());
 
         // third task completes, others do not
         tasks.clear();
-        tasks.add(() -> new CompletableFuture<>());
-        tasks.add(() -> new CompletableFuture<>());
+        tasks.add(CompletableFuture::new);
+        tasks.add(CompletableFuture::new);
         tasks.add(() -> CompletableFuture.completedFuture(outcome));
 
-        result = oper.anyOf(tasks);
+        result = myOperation.anyOf(tasks);
         assertTrue(executor.runAll(MAX_REQUESTS));
         assertTrue(result.isDone());
         assertSame(outcome, result.get());
@@ -569,15 +569,15 @@ class OperationPartialTest {
         List<Supplier<CompletableFuture<OperationOutcome>>> tasks = new LinkedList<>();
 
         // zero items: check both using a list and using an array
-        assertNull(oper.anyOf(tasks));
-        assertNull(oper.anyOf());
+        assertNull(myOperation.anyOf(tasks));
+        assertNull(myOperation.anyOf());
 
         // one item: : check both using a list and using an array
         CompletableFuture<OperationOutcome> future1 = new CompletableFuture<>();
         tasks.add(() -> future1);
 
-        assertSame(future1, oper.anyOf(tasks));
-        assertSame(future1, oper.anyOf(() -> future1));
+        assertSame(future1, myOperation.anyOf(tasks));
+        assertSame(future1, myOperation.anyOf(() -> future1));
     }
 
     @Test
@@ -590,7 +590,7 @@ class OperationPartialTest {
 
         @SuppressWarnings("unchecked")
         CompletableFuture<OperationOutcome> result =
-                        oper.allOf(() -> future1, () -> future2, () -> null, () -> future3);
+                        myOperation.allOf(() -> future1, () -> future2, () -> null, () -> future3);
 
         assertTrue(executor.runAll(MAX_REQUESTS));
         assertFalse(result.isDone());
@@ -625,7 +625,7 @@ class OperationPartialTest {
         tasks.add(() -> null);
         tasks.add(() -> future3);
 
-        CompletableFuture<OperationOutcome> result = oper.allOf(tasks);
+        CompletableFuture<OperationOutcome> result = myOperation.allOf(tasks);
 
         assertTrue(executor.runAll(MAX_REQUESTS));
         assertFalse(result.isDone());
@@ -655,15 +655,15 @@ class OperationPartialTest {
         List<Supplier<CompletableFuture<OperationOutcome>>> tasks = new LinkedList<>();
 
         // zero items: check both using a list and using an array
-        assertNull(oper.allOf(tasks));
-        assertNull(oper.allOf());
+        assertNull(myOperation.allOf(tasks));
+        assertNull(myOperation.allOf());
 
         // one item: : check both using a list and using an array
         CompletableFuture<OperationOutcome> future1 = new CompletableFuture<>();
         tasks.add(() -> future1);
 
-        assertSame(future1, oper.allOf(tasks));
-        assertSame(future1, oper.allOf(() -> future1));
+        assertSame(future1, myOperation.allOf(tasks));
+        assertSame(future1, myOperation.allOf(() -> future1));
     }
 
     @Test
@@ -681,7 +681,7 @@ class OperationPartialTest {
         });
         tasks.add(() -> future3);
 
-        assertThatIllegalStateException().isThrownBy(() -> oper.anyOf(tasks)).withMessage(EXPECTED_EXCEPTION);
+        assertThatIllegalStateException().isThrownBy(() -> myOperation.anyOf(tasks)).withMessage(EXPECTED_EXCEPTION);
 
         // should have canceled the first two, but not the last
         assertTrue(future1.isCancelled());
@@ -705,7 +705,7 @@ class OperationPartialTest {
         tasks.add(() -> CompletableFuture.completedFuture(params.makeOutcome()));
         tasks.add(() -> CompletableFuture.completedFuture(null));
         tasks.add(() -> CompletableFuture.completedFuture(params.makeOutcome()));
-        CompletableFuture<OperationOutcome> result = oper.allOf(tasks);
+        CompletableFuture<OperationOutcome> result = myOperation.allOf(tasks);
 
         assertTrue(executor.runAll(MAX_REQUESTS));
         assertTrue(result.isDone());
@@ -718,7 +718,7 @@ class OperationPartialTest {
         tasks.add(() -> CompletableFuture.completedFuture(params.makeOutcome()));
         tasks.add(() -> CompletableFuture.failedFuture(except));
         tasks.add(() -> CompletableFuture.completedFuture(params.makeOutcome()));
-        result = oper.allOf(tasks);
+        result = myOperation.allOf(tasks);
 
         assertTrue(executor.runAll(MAX_REQUESTS));
         assertTrue(result.isCompletedExceptionally());
@@ -738,7 +738,7 @@ class OperationPartialTest {
         tasks.add(() -> CompletableFuture.completedFuture(outcome));
         tasks.add(() -> CompletableFuture.completedFuture(outcome));
 
-        CompletableFuture<OperationOutcome> result = oper.sequence(tasks);
+        CompletableFuture<OperationOutcome> result = myOperation.sequence(tasks);
         assertTrue(executor.runAll(MAX_REQUESTS));
         assertTrue(result.isDone());
         assertSame(outcome, result.get());
@@ -746,7 +746,7 @@ class OperationPartialTest {
         // repeat using array form
         @SuppressWarnings("unchecked")
         Supplier<CompletableFuture<OperationOutcome>>[] taskArray = new Supplier[tasks.size()];
-        result = oper.sequence(tasks.toArray(taskArray));
+        result = myOperation.sequence(tasks.toArray(taskArray));
         assertTrue(executor.runAll(MAX_REQUESTS));
         assertTrue(result.isDone());
         assertSame(outcome, result.get());
@@ -759,7 +759,7 @@ class OperationPartialTest {
         tasks.add(() -> CompletableFuture.completedFuture(failure));
         tasks.add(() -> CompletableFuture.completedFuture(outcome));
 
-        result = oper.sequence(tasks);
+        result = myOperation.sequence(tasks);
         assertTrue(executor.runAll(MAX_REQUESTS));
         assertTrue(result.isDone());
         assertSame(failure, result.get());
@@ -774,15 +774,15 @@ class OperationPartialTest {
         List<Supplier<CompletableFuture<OperationOutcome>>> tasks = new LinkedList<>();
 
         // zero items: check both using a list and using an array
-        assertNull(oper.sequence(tasks));
-        assertNull(oper.sequence());
+        assertNull(myOperation.sequence(tasks));
+        assertNull(myOperation.sequence());
 
         // one item: : check both using a list and using an array
         CompletableFuture<OperationOutcome> future1 = new CompletableFuture<>();
         tasks.add(() -> future1);
 
-        assertSame(future1, oper.sequence(tasks));
-        assertSame(future1, oper.sequence(() -> future1));
+        assertSame(future1, myOperation.sequence(tasks));
+        assertSame(future1, myOperation.sequence(() -> future1));
     }
 
     private void verifyOutcomes(int expected, OperationResult... results) throws Exception {
@@ -800,7 +800,7 @@ class OperationPartialTest {
             }
         }
 
-        CompletableFuture<OperationOutcome> result = oper.allOf(tasks);
+        CompletableFuture<OperationOutcome> result = myOperation.allOf(tasks);
 
         assertTrue(executor.runAll(MAX_REQUESTS));
         assertTrue(result.isDone());
@@ -809,7 +809,7 @@ class OperationPartialTest {
 
     @Test
      void testDetmPriority() throws CoderException {
-        assertEquals(1, oper.detmPriority(null));
+        assertEquals(1, myOperation.detmPriority(null));
 
         OperationOutcome outcome = params.makeOutcome();
 
@@ -819,7 +819,7 @@ class OperationPartialTest {
 
         for (Entry<OperationResult, Integer> ent : map.entrySet()) {
             outcome.setResult(ent.getKey());
-            assertEquals(ent.getValue().intValue(), oper.detmPriority(outcome), ent.getKey().toString());
+            assertEquals(ent.getValue().intValue(), myOperation.detmPriority(outcome), ent.getKey().toString());
         }
 
         /*
@@ -827,7 +827,7 @@ class OperationPartialTest {
          * won't allow it. Instead, we decode it from a structure.
          */
         outcome = new StandardCoder().decode("{\"result\":null}", OperationOutcome.class);
-        assertEquals(1, oper.detmPriority(outcome));
+        assertEquals(1, myOperation.detmPriority(outcome));
     }
 
     /**
@@ -841,15 +841,15 @@ class OperationPartialTest {
          * arrange to stop the controller when the start-callback is invoked, but capture
          * the outcome
          */
-        params = params.toBuilder().startCallback(oper -> {
-            starter(oper);
+        params = params.toBuilder().startCallback(outcome -> {
+            starter(outcome);
             future.get().cancel(false);
         }).build();
 
         // new params, thus need a new operation
-        oper = new MyOper();
+        myOperation = new MyOper();
 
-        future.set(oper.start());
+        future.set(myOperation.start());
         assertTrue(executor.runAll(MAX_REQUESTS));
 
         // should have only run once
@@ -864,14 +864,14 @@ class OperationPartialTest {
         AtomicReference<Future<OperationOutcome>> future = new AtomicReference<>();
 
         // arrange to stop the controller when the start-callback is invoked
-        params = params.toBuilder().startCallback(oper -> {
+        params = params.toBuilder().startCallback(outcome -> {
             future.get().cancel(false);
         }).build();
 
         // new params, thus need a new operation
-        oper = new MyOper();
+        myOperation = new MyOper();
 
-        future.set(oper.start());
+        future.set(myOperation.start());
         assertTrue(executor.runAll(MAX_REQUESTS));
 
         // should not have been set
@@ -886,12 +886,12 @@ class OperationPartialTest {
         OperationOutcome outcome;
 
         outcome = new OperationOutcome();
-        oper.setOutcome(outcome, timex);
+        myOperation.setOutcome(outcome, timex);
         assertEquals(ControlLoopOperation.FAILED_MSG, outcome.getMessage());
         assertEquals(OperationResult.FAILURE_TIMEOUT, outcome.getResult());
 
         outcome = new OperationOutcome();
-        oper.setOutcome(outcome, new IllegalStateException(EXPECTED_EXCEPTION));
+        myOperation.setOutcome(outcome, new IllegalStateException(EXPECTED_EXCEPTION));
         assertEquals(ControlLoopOperation.FAILED_MSG, outcome.getMessage());
         assertEquals(OperationResult.FAILURE_EXCEPTION, outcome.getResult());
     }
@@ -901,17 +901,17 @@ class OperationPartialTest {
         OperationOutcome outcome;
 
         outcome = new OperationOutcome();
-        oper.setOutcome(outcome, OperationResult.SUCCESS);
+        myOperation.setOutcome(outcome, OperationResult.SUCCESS);
         assertEquals(ControlLoopOperation.SUCCESS_MSG, outcome.getMessage());
         assertEquals(OperationResult.SUCCESS, outcome.getResult());
 
-        oper.setOutcome(outcome, OperationResult.SUCCESS);
+        myOperation.setOutcome(outcome, OperationResult.SUCCESS);
         assertEquals(ControlLoopOperation.SUCCESS_MSG, outcome.getMessage());
         assertEquals(OperationResult.SUCCESS, outcome.getResult());
 
         for (OperationResult result : FAILURE_RESULTS) {
             outcome = new OperationOutcome();
-            oper.setOutcome(outcome, result);
+            myOperation.setOutcome(outcome, result);
             assertEquals(ControlLoopOperation.FAILED_MSG, outcome.getMessage(), result.toString());
             assertEquals(result, outcome.getResult(), result.toString());
         }
@@ -919,22 +919,22 @@ class OperationPartialTest {
 
     @Test
      void testMakeOutcome() {
-        oper.setProperty(OperationProperties.AAI_TARGET_ENTITY, MY_TARGET_ENTITY);
-        assertEquals(MY_TARGET_ENTITY, oper.makeOutcome().getTarget());
+        myOperation.setProperty(OperationProperties.AAI_TARGET_ENTITY, MY_TARGET_ENTITY);
+        assertEquals(MY_TARGET_ENTITY, myOperation.makeOutcome().getTarget());
     }
 
     @Test
      void testIsTimeout() {
         final TimeoutException timex = new TimeoutException(EXPECTED_EXCEPTION);
 
-        assertFalse(oper.isTimeout(new IllegalStateException(EXPECTED_EXCEPTION)));
-        assertFalse(oper.isTimeout(new IllegalStateException(timex)));
-        assertFalse(oper.isTimeout(new CompletionException(new IllegalStateException(timex))));
-        assertFalse(oper.isTimeout(new CompletionException(null)));
-        assertFalse(oper.isTimeout(new CompletionException(new CompletionException(timex))));
+        assertFalse(myOperation.isTimeout(new IllegalStateException(EXPECTED_EXCEPTION)));
+        assertFalse(myOperation.isTimeout(new IllegalStateException(timex)));
+        assertFalse(myOperation.isTimeout(new CompletionException(new IllegalStateException(timex))));
+        assertFalse(myOperation.isTimeout(new CompletionException(null)));
+        assertFalse(myOperation.isTimeout(new CompletionException(new CompletionException(timex))));
 
-        assertTrue(oper.isTimeout(timex));
-        assertTrue(oper.isTimeout(new CompletionException(timex)));
+        assertTrue(myOperation.isTimeout(timex));
+        assertTrue(myOperation.isTimeout(new CompletionException(timex)));
     }
 
     @Test
@@ -943,7 +943,7 @@ class OperationPartialTest {
 
         // log structured data
         appender.clearExtractions();
-        oper.logMessage(EventType.OUT, SINK_INFRA, MY_SINK, new MyData());
+        myOperation.logMessage(EventType.OUT, SINK_INFRA, MY_SINK, new MyData());
         List<String> output = appender.getExtracted();
         assertEquals(1, output.size());
 
@@ -952,7 +952,7 @@ class OperationPartialTest {
 
         // repeat with a response
         appender.clearExtractions();
-        oper.logMessage(EventType.IN, SOURCE_INFRA, MY_SOURCE, new MyData());
+        myOperation.logMessage(EventType.IN, SOURCE_INFRA, MY_SOURCE, new MyData());
         output = appender.getExtracted();
         assertEquals(1, output.size());
 
@@ -961,14 +961,14 @@ class OperationPartialTest {
 
         // log a plain string
         appender.clearExtractions();
-        oper.logMessage(EventType.OUT, SINK_INFRA, MY_SINK, TEXT);
+        myOperation.logMessage(EventType.OUT, SINK_INFRA, MY_SINK, TEXT);
         output = appender.getExtracted();
         assertEquals(1, output.size());
         assertThat(output.get(0)).contains(infraStr).contains(MY_SINK).contains(TEXT);
 
         // log a null request
         appender.clearExtractions();
-        oper.logMessage(EventType.OUT, SINK_INFRA, MY_SINK, null);
+        myOperation.logMessage(EventType.OUT, SINK_INFRA, MY_SINK, null);
         output = appender.getExtracted();
         assertEquals(1, output.size());
 
@@ -978,7 +978,7 @@ class OperationPartialTest {
         setOperCoderException();
 
         appender.clearExtractions();
-        oper.logMessage(EventType.OUT, SINK_INFRA, MY_SINK, new MyData());
+        myOperation.logMessage(EventType.OUT, SINK_INFRA, MY_SINK, new MyData());
         output = appender.getExtracted();
         assertEquals(2, output.size());
         assertThat(output.get(0)).contains("cannot pretty-print request");
@@ -986,7 +986,7 @@ class OperationPartialTest {
 
         // repeat with a response
         appender.clearExtractions();
-        oper.logMessage(EventType.IN, SOURCE_INFRA, MY_SOURCE, new MyData());
+        myOperation.logMessage(EventType.IN, SOURCE_INFRA, MY_SOURCE, new MyData());
         output = appender.getExtracted();
         assertEquals(2, output.size());
         assertThat(output.get(0)).contains("cannot pretty-print response");
@@ -995,8 +995,8 @@ class OperationPartialTest {
 
     @Test
      void testGetRetry() {
-        assertEquals(0, oper.getRetry(null));
-        assertEquals(10, oper.getRetry(10));
+        assertEquals(0, myOperation.getRetry(null));
+        assertEquals(10, myOperation.getRetry(10));
     }
 
     @Test
@@ -1008,14 +1008,14 @@ class OperationPartialTest {
 
     @Test
      void testGetTimeOutMs() {
-        assertEquals(TIMEOUT * 1000, oper.getTimeoutMs(params.getTimeoutSec()));
+        assertEquals(TIMEOUT * 1000, myOperation.getTimeoutMs(params.getTimeoutSec()));
 
         params = params.toBuilder().timeoutSec(null).build();
 
         // new params, thus need a new operation
-        oper = new MyOper();
+        myOperation = new MyOper();
 
-        assertEquals(0, oper.getTimeoutMs(params.getTimeoutSec()));
+        assertEquals(0, myOperation.getTimeoutMs(params.getTimeoutSec()));
     }
 
     private void starter(OperationOutcome oper) {
@@ -1074,7 +1074,7 @@ class OperationPartialTest {
         starts.clear();
         ends.clear();
 
-        CompletableFuture<OperationOutcome> future = oper.start();
+        CompletableFuture<OperationOutcome> future = myOperation.start();
 
         manipulator.accept(future);
 
@@ -1112,20 +1112,20 @@ class OperationPartialTest {
             }
 
             if (expectedOperations > 0) {
-                assertNotNull(testName, oper.getSubRequestId());
-                assertEquals(oper.getSubRequestId(), opstart.getSubRequestId(), testName + " op start");
-                assertEquals(oper.getSubRequestId(), opend.getSubRequestId(), testName + " op end");
+                assertNotNull(testName, myOperation.getSubRequestId());
+                assertEquals(myOperation.getSubRequestId(), opstart.getSubRequestId(), testName + " op start");
+                assertEquals(myOperation.getSubRequestId(), opend.getSubRequestId(), testName + " op end");
             }
         }
 
-        assertEquals(expectedOperations, oper.getCount(), testName);
+        assertEquals(expectedOperations, myOperation.getCount(), testName);
     }
 
     /**
-     * Creates a new {@link #oper} whose coder will throw an exception.
+     * Creates a new {@link #myOperation} whose coder will throw an exception.
      */
     private void setOperCoderException() {
-        oper = new MyOper() {
+        myOperation = new MyOper() {
             @Override
             protected Coder getCoder() {
                 return new StandardCoder() {
@@ -1141,7 +1141,7 @@ class OperationPartialTest {
 
     @Getter
     static class MyData {
-        private String text = TEXT;
+        private final String text = TEXT;
     }
 
 
index 2c82759..7ed9eb4 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
+ * Modifications Copyright (C) 2024-2025 Nordix Foundation
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ package org.onap.policy.controlloop.actorserviceprovider.pipeline;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNotSame;
 import static org.junit.jupiter.api.Assertions.assertNull;
@@ -253,7 +254,7 @@ class PipelineControllerFutureTest {
      void testNewIncompleteFuture() {
         PipelineControllerFuture<String> future = controller.newIncompleteFuture();
         assertNotNull(future);
-        assertTrue(future instanceof PipelineControllerFuture);
+        assertInstanceOf(PipelineControllerFuture.class, future);
         assertNotSame(controller, future);
         assertFalse(future.isDone());
     }
@@ -402,7 +403,7 @@ class PipelineControllerFutureTest {
         verify(controller, never()).remove(compFuture);
 
         compFuture.completeExceptionally(EXPECTED_EXCEPTION);
-        assertThatThrownBy(() -> future.get()).hasCause(EXPECTED_EXCEPTION);
+        assertThatThrownBy(future::get).hasCause(EXPECTED_EXCEPTION);
 
         verify(controller).remove(compFuture);
     }
index aef170b..a04e0f3 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
+ * Modifications Copyright (C) 2024-2025 Nordix Foundation
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -33,6 +33,6 @@ class PipelineUtilTest {
         ControlLoopOperationParams params = ControlLoopOperationParams.builder().build();
         PipelineUtil util = new PipelineUtil(params);
 
-        assertThatThrownBy(() -> util.start()).isInstanceOf(UnsupportedOperationException.class);
+        assertThatThrownBy(util::start).isInstanceOf(UnsupportedOperationException.class);
     }
 }
index 7a21771..78e5177 100644 (file)
@@ -3,7 +3,7 @@
  * rest
  * ================================================================================
  * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019-2020, 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020, 2023-2025 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,9 +22,9 @@
 package org.onap.policy.rest;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import jakarta.ws.rs.Consumes;
 import jakarta.ws.rs.DELETE;
@@ -104,7 +104,6 @@ public class RestTest {
     /**
      * Tear down server endpoint for the tests.
      *
-     * @throws Exception if there is a problem
      */
     @AfterAll
     public static void tearDown() {
@@ -112,7 +111,7 @@ public class RestTest {
     }
 
     @Test
-    public void testGetUrlNull() {
+    void testGetUrlNull() {
         RestManager mgr = new RestManager();
         assertThrows(NullPointerException.class, () -> {
             mgr.get(null, "user", null, null);
@@ -120,7 +119,7 @@ public class RestTest {
     }
 
     @Test
-    public void testPutUrlNull() {
+    void testPutUrlNull() {
         RestManager mgr = new RestManager();
         assertThrows(NullPointerException.class, () -> {
             mgr.put(null, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
@@ -128,7 +127,7 @@ public class RestTest {
     }
 
     @Test
-    public void testPostUrlNull() {
+    void testPostUrlNull() {
         RestManager mgr = new RestManager();
         assertThrows(NullPointerException.class, () -> {
             mgr.post(null, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD);
@@ -136,7 +135,7 @@ public class RestTest {
     }
 
     @Test
-    public void testDeleteUrlNull() {
+    void testDeleteUrlNull() {
         RestManager mgr = new RestManager();
         assertThrows(NullPointerException.class, () -> {
             mgr.delete(null, "user", null, null, null, null);
@@ -144,7 +143,7 @@ public class RestTest {
     }
 
     @Test
-    public void testPatchUrlNull() {
+    void testPatchUrlNull() {
         RestManager mgr = new RestManager();
         assertThrows(NullPointerException.class, () -> {
             mgr.patch(null, "user", null, null, PAYLOAD);
@@ -152,7 +151,7 @@ public class RestTest {
     }
 
     @Test
-    public void testUsernameNull() {
+    void testUsernameNull() {
         RestManager mgr = new RestManager();
 
         Pair<Integer, String> result = mgr.get(getUri, null, null, null);
@@ -187,12 +186,12 @@ public class RestTest {
     private void checkResult(Pair<Integer, String> result, String expectedText) {
         assertEquals((Integer) 200, result.getLeft());
         assertNotNull(result.getRight());
-        assertTrue(result.getRight().length() > 0);
+        assertFalse(result.getRight().isEmpty());
         assertEquals(expectedText, result.getRight());
     }
 
     @Test
-    public void testUsernameEmpty() {
+    void testUsernameEmpty() {
         RestManager mgr = new RestManager();
 
         Pair<Integer, String> result = mgr.get(getUri, "", null, null);
@@ -222,7 +221,7 @@ public class RestTest {
     }
 
     @Test
-    public void testGoodUrl() {
+    void testGoodUrl() {
         RestManager mgr = new RestManager();
 
         Pair<Integer, String> result = mgr.get(getUri, "user", null, null);
@@ -252,7 +251,7 @@ public class RestTest {
     }
 
     @Test
-    public void testNoUrlParamUrl() {
+    void testNoUrlParamUrl() {
         RestManager mgr = new RestManager();
 
         Pair<Integer, String> result = mgr.get(baseUri + "RestTest/GetHello/", null, null, null);
@@ -274,7 +273,7 @@ public class RestTest {
     }
 
     @Test
-    public void testNoQueryParamUrl() {
+    void testNoQueryParamUrl() {
         RestManager mgr = new RestManager();
 
         Pair<Integer, String> result = mgr.get(baseUri + "RestTest/GetHello/" + NAME_PARAM, null, null, null);
@@ -297,7 +296,7 @@ public class RestTest {
     }
 
     @Test
-    public void testBadUrl() {
+    void testBadUrl() {
         RestManager mgr = new RestManager();
 
         Pair<Integer, String> result = mgr.get(baseUri + "NonExistant/URL/", null, null, null);
@@ -319,7 +318,7 @@ public class RestTest {
     }
 
     @Test
-    public void testWrongUrl() {
+    void testWrongUrl() {
         RestManager mgr = new RestManager();
 
         Pair<Integer, String> result = mgr.get(deleteUri, null, null, null);
index 3fd2cfd..abfd255 100644 (file)
@@ -3,7 +3,7 @@
  * sdnr
  * ================================================================================
  * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019, 2024 Nordix Foundation.
+ * Modifications Copyright (C) 2019, 2024-2025 Nordix Foundation.
  * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -106,7 +106,7 @@ class SdnrTest {
          */
         assertTrue(jsonRequest.contains("Action"));
 
-        logger.debug("Request as JSON: " + jsonRequest + "\n\n");
+        logger.debug("Request as JSON: {} \n\n", jsonRequest);
     }
 
     @Test
@@ -147,7 +147,7 @@ class SdnrTest {
         assertNotNull(sdnrRequest.getAction());
         assertEquals("ModifyConfig", sdnrRequest.getAction());
 
-        logger.debug("Request as a Java Object: \n" + sdnrRequest.toString() + "\n\n");
+        logger.debug("Request as a Java Object:\n {} \n\n", sdnrRequest);
     }
 
     @Test
@@ -172,7 +172,7 @@ class SdnrTest {
         assertTrue(jsonResponse.contains("SubRequestID"));
         assertTrue(jsonResponse.contains("Status"));
 
-        logger.debug("Response as JSON: " + jsonResponse + "\n\n");
+        logger.debug("Response as JSON: {}\n\n", jsonResponse);
     }
 
     @Test
@@ -212,6 +212,6 @@ class SdnrTest {
         assertNotNull(sdnrResponse.getStatus());
         assertEquals(400, sdnrResponse.getStatus().getCode());
 
-        logger.debug("Response as a Java Object: \n" + sdnrResponse.toString() + "\n\n");
+        logger.debug("Response as a Java Object:\n {} \n\n", sdnrResponse);
     }
 }
index d7cfd18..178ee8f 100644 (file)
@@ -4,7 +4,7 @@
  * ================================================================================
  * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2025 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,7 +25,6 @@ package org.onap.policy.simulators;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
-import com.google.protobuf.TextFormat.ParseException;
 import com.google.protobuf.util.JsonFormat;
 import io.grpc.ManagedChannel;
 import io.grpc.netty.NettyChannelBuilder;
index 25b3219..104ca84 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2024 Nordix Foundation.
+ *  Copyright (C) 2021-2025 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -83,7 +83,7 @@ class JpaPolicyAuditTest {
     void testClean() {
         audit.setUser("   user");
         JpaPolicyAudit jpaAudit = new JpaPolicyAudit(audit);
-        assertThatNoException().isThrownBy(() -> jpaAudit.clean());
+        assertThatNoException().isThrownBy(jpaAudit::clean);
         assertEquals(USER, jpaAudit.getUserName());
     }
 
index 0808a40..22fca3d 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2019-2023 Nordix Foundation.
+ *  Copyright (C) 2019-2023, 2025 Nordix Foundation.
  *  Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
  *  Modifications Copyright (C) 2020, 2022 Bell Canada. All rights reserved.
  * ================================================================================
@@ -55,6 +55,15 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
  * @author Chenfei Gao (cgao@research.att.com)
  */
 public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
+
+    private static final String TOSCA_POLICY_GET_RESPONSE_JSON = "dummyimpl/DummyToscaPolicyGetResponse.json";
+    private static final String POLICY_TYPE_DELETE_RESPONSE_JSON = "dummyimpl/DummyToscaPolicyTypeDeleteResponse.json";
+    private static final String SERVICE_TEMPLATE_DELETE_RESPONSE_JSON =
+        "dummyimpl/DummyToscaServiceTemplateDeleteResponse.json";
+    private static final String POLICY_TYPE_GET_RESPONSE_JSON = "dummyimpl/DummyToscaPolicyTypeGetResponse.json";
+    private static final String TOSCA_POLICY_DELETE_RESPONSE_JSON = "dummyimpl/DummyToscaPolicyDeleteResponse.json";
+    private static final String NODE_TEMPLATE_RESPONSE_JSON = "dummyimpl/DummyToscaNodeTemplateResponse.json";
+
     /**
      * Constructor that takes the parameters.
      *
@@ -101,12 +110,12 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
     @Override
     public ToscaServiceTemplate deleteServiceTemplate(@NonNull String name, @NonNull String version)
             throws PfModelException {
-        return getDummyResponse("dummyimpl/DummyToscaServiceTemplateDeleteResponse.json");
+        return getDummyResponse(SERVICE_TEMPLATE_DELETE_RESPONSE_JSON);
     }
 
     @Override
     public ToscaServiceTemplate getPolicyTypes(final String name, final String version) {
-        return getDummyResponse("dummyimpl/DummyToscaPolicyTypeGetResponse.json");
+        return getDummyResponse(POLICY_TYPE_GET_RESPONSE_JSON);
     }
 
     @Override
@@ -115,33 +124,33 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
     }
 
     @Override
-    public ToscaServiceTemplate getFilteredPolicyTypes(ToscaEntityFilter<ToscaPolicyType> filter) {
-        return getDummyResponse("dummyimpl/DummyToscaPolicyTypeGetResponse.json");
+    public ToscaServiceTemplate getFilteredPolicyTypes(@NonNull ToscaEntityFilter<ToscaPolicyType> filter) {
+        return getDummyResponse(POLICY_TYPE_GET_RESPONSE_JSON);
     }
 
     @Override
-    public List<ToscaPolicyType> getFilteredPolicyTypeList(ToscaEntityFilter<ToscaPolicyType> filter) {
+    public List<ToscaPolicyType> getFilteredPolicyTypeList(@NonNull ToscaEntityFilter<ToscaPolicyType> filter) {
         return new ArrayList<>();
     }
 
     @Override
-    public ToscaServiceTemplate createPolicyTypes(final ToscaServiceTemplate serviceTemplate) {
+    public ToscaServiceTemplate createPolicyTypes(final @NonNull ToscaServiceTemplate serviceTemplate) {
         return serviceTemplate;
     }
 
     @Override
-    public ToscaServiceTemplate updatePolicyTypes(final ToscaServiceTemplate serviceTemplate) {
+    public ToscaServiceTemplate updatePolicyTypes(final @NonNull ToscaServiceTemplate serviceTemplate) {
         return serviceTemplate;
     }
 
     @Override
-    public ToscaServiceTemplate deletePolicyType(final String name, final String version) {
-        return getDummyResponse("dummyimpl/DummyToscaPolicyTypeDeleteResponse.json");
+    public ToscaServiceTemplate deletePolicyType(final @NonNull String name, final @NonNull String version) {
+        return getDummyResponse(POLICY_TYPE_DELETE_RESPONSE_JSON);
     }
 
     @Override
     public ToscaServiceTemplate getPolicies(final String name, final String version) {
-        return getDummyResponse("dummyimpl/DummyToscaPolicyGetResponse.json");
+        return getDummyResponse(TOSCA_POLICY_GET_RESPONSE_JSON);
     }
 
     @Override
@@ -150,44 +159,44 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
     }
 
     @Override
-    public ToscaServiceTemplate getFilteredPolicies(ToscaTypedEntityFilter<ToscaPolicy> filter) {
-        return getDummyResponse("dummyimpl/DummyToscaPolicyGetResponse.json");
+    public ToscaServiceTemplate getFilteredPolicies(@NonNull ToscaTypedEntityFilter<ToscaPolicy> filter) {
+        return getDummyResponse(TOSCA_POLICY_GET_RESPONSE_JSON);
     }
 
     @Override
-    public List<ToscaPolicy> getFilteredPolicyList(ToscaTypedEntityFilter<ToscaPolicy> filter) {
+    public List<ToscaPolicy> getFilteredPolicyList(@NonNull ToscaTypedEntityFilter<ToscaPolicy> filter) {
         return new ArrayList<>();
     }
 
     @Override
-    public ToscaServiceTemplate createPolicies(final ToscaServiceTemplate serviceTemplate) {
+    public ToscaServiceTemplate createPolicies(final @NonNull ToscaServiceTemplate serviceTemplate) {
         return serviceTemplate;
     }
 
     @Override
-    public ToscaServiceTemplate updatePolicies(final ToscaServiceTemplate serviceTemplate) {
+    public ToscaServiceTemplate updatePolicies(final @NonNull ToscaServiceTemplate serviceTemplate) {
         return serviceTemplate;
     }
 
     @Override
-    public ToscaServiceTemplate deletePolicy(final String name, final String version) {
-        return getDummyResponse("dummyimpl/DummyToscaPolicyDeleteResponse.json");
+    public ToscaServiceTemplate deletePolicy(final @NonNull String name, final @NonNull String version) {
+        return getDummyResponse(TOSCA_POLICY_DELETE_RESPONSE_JSON);
     }
 
     @Override
     public ToscaServiceTemplate createToscaNodeTemplates(@NonNull ToscaServiceTemplate serviceTemplate) {
-        return getDummyNodeTemplateResponse("dummyimpl/DummyToscaNodeTemplateResponse.json");
+        return getDummyNodeTemplateResponse();
     }
 
     @Override
     public ToscaServiceTemplate updateToscaNodeTemplates(@NonNull ToscaServiceTemplate serviceTemplate)
         throws PfModelRuntimeException {
-        return getDummyNodeTemplateResponse("dummyimpl/DummyToscaNodeTemplateResponse.json");
+        return getDummyNodeTemplateResponse();
     }
 
     @Override
     public ToscaServiceTemplate deleteToscaNodeTemplate(@NonNull String name, @NonNull String version) {
-        return getDummyNodeTemplateResponse("dummyimpl/DummyToscaNodeTemplateResponse.json");
+        return getDummyNodeTemplateResponse();
     }
 
     @Override
@@ -207,32 +216,32 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
     }
 
     @Override
-    public List<PdpGroup> getFilteredPdpGroups(PdpGroupFilter filter) {
+    public List<PdpGroup> getFilteredPdpGroups(@NonNull PdpGroupFilter filter) {
         return new ArrayList<>();
     }
 
     @Override
-    public List<PdpGroup> createPdpGroups(final List<PdpGroup> pdpGroups) {
+    public List<PdpGroup> createPdpGroups(final @NonNull List<PdpGroup> pdpGroups) {
         return new ArrayList<>();
     }
 
     @Override
-    public List<PdpGroup> updatePdpGroups(final List<PdpGroup> pdpGroups) {
+    public List<PdpGroup> updatePdpGroups(final @NonNull List<PdpGroup> pdpGroups) {
         return new ArrayList<>();
     }
 
     @Override
-    public void updatePdpSubGroup(final String pdpGroupName, final PdpSubGroup pdpSubGroup) {
+    public void updatePdpSubGroup(final @NonNull String pdpGroupName, final @NonNull PdpSubGroup pdpSubGroup) {
         // Not implemented
     }
 
     @Override
-    public void updatePdp(String pdpGroupName, String pdpSubGroup, Pdp pdp) {
+    public void updatePdp(@NonNull String pdpGroupName, @NonNull String pdpSubGroup, @NonNull Pdp pdp) {
         // Not implemented
     }
 
     @Override
-    public PdpGroup deletePdpGroup(final String name) {
+    public PdpGroup deletePdpGroup(final @NonNull String name) {
         return null;
     }
 
@@ -249,7 +258,7 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
     }
 
     @Override
-    public List<PdpPolicyStatus> getGroupPolicyStatus(String groupName) {
+    public List<PdpPolicyStatus> getGroupPolicyStatus(@NonNull String groupName) {
         // Not implemented
         return new ArrayList<>();
     }
@@ -261,7 +270,7 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
     }
 
     /**
-     * Return a ToscaServicetemplate dummy response.
+     * Return a ToscaService template dummy response.
      *
      * @param fileName the file name containing the dummy response
      * @return the ToscaServiceTemplate with the dummy response
@@ -286,16 +295,16 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
     /**
      * Return a tosca node template dummy response.
      *
-     * @param fileName the file name containing the dummy response
      * @return the service template with the dummy response
      */
-    protected ToscaServiceTemplate getDummyNodeTemplateResponse(final String fileName) {
+    protected ToscaServiceTemplate getDummyNodeTemplateResponse() {
         var standardCoder = new StandardCoder();
         ToscaServiceTemplate serviceTemplate;
 
         try {
             serviceTemplate =
-                standardCoder.decode(ResourceUtils.getResourceAsString(fileName), ToscaServiceTemplate.class);
+                standardCoder.decode(ResourceUtils.getResourceAsString(NODE_TEMPLATE_RESPONSE_JSON),
+                    ToscaServiceTemplate.class);
             if (serviceTemplate == null) {
                 throw new PfModelException(Response.Status.INTERNAL_SERVER_ERROR, "error reading specified file");
             }
index fe5af6b..ead17d4 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2019-2024 Nordix Foundation.
+ *  Copyright (C) 2019-2025 Nordix Foundation.
  *  Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
  *  Modifications Copyright (C) 2020, 2022 Bell Canada. All rights reserved.
  * ================================================================================
@@ -137,7 +137,6 @@ class DummyPolicyModelsProviderTest {
         parameters.setDatabaseUrl("jdbc:dummy");
         parameters.setPersistenceUnit("dummy");
 
-        PolicyModelsProvider dummyProvider = new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
-        return dummyProvider;
+        return new PolicyModelsProviderFactory().createPolicyModelsProvider(parameters);
     }
 }
index a4a2014..f005ba2 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2020-2021, 2023-2024 Nordix Foundation.
+ *  Copyright (C) 2020-2021, 2023-2025 Nordix Foundation.
  *  Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
  *  Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
@@ -76,9 +76,7 @@ class HierarchyFetchTest {
                 .getTextFileAsString("src/test/resources/servicetemplates/MultipleRevisionServiceTemplate.yaml"),
             ToscaServiceTemplate.class);
 
-        assertThatCode(() -> {
-            databaseProvider.createPolicies(serviceTemplate);
-        }).doesNotThrowAnyException();
+        assertThatCode(() -> databaseProvider.createPolicies(serviceTemplate)).doesNotThrowAnyException();
 
         ToscaServiceTemplate fetchedServiceTemplate = databaseProvider.getPolicies(null, null);
 
index eb573ca..0d71e1d 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP Policy Model
  * ================================================================================
  * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019-2021, 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021, 2023, 2025 Nordix Foundation.
  * Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -152,10 +152,10 @@ public class JpaToscaPolicy extends JpaToscaWithTypeAndStringProperties<ToscaPol
         if (getMetadata().containsKey(METADATA_METADATA_SET_NAME_TAG)
                 && getMetadata().containsKey(METADATA_METADATA_SET_VERSION_TAG)) {
             getMetadata().put(METADATA_METADATA_SET_NAME_TAG, getMetadata().get(METADATA_METADATA_SET_NAME_TAG)
-                    .replaceAll("^\"|\"$", ""));
+                    .replaceAll("^\"|\"$", "")); // NOSONAR operator precedence is explicit
 
             getMetadata().put(METADATA_METADATA_SET_VERSION_TAG, getMetadata().get(METADATA_METADATA_SET_VERSION_TAG)
-                    .replaceAll("^\"|\"$", ""));
+                    .replaceAll("^\"|\"$", "")); // NOSONAR operator precedence is explicit
         }
     }
 
index c1c3f4a..f2fc60c 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2019-2021 Nordix Foundation.
+ *  Copyright (C) 2019-2021, 2025 Nordix Foundation.
  *  Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
  *  Modifications Copyright (C) 2024 Nordix Foundation
  * ================================================================================
@@ -75,7 +75,7 @@ class ToscaEntityFilterTest {
     };
     // @formatter:on
 
-    private static List<ToscaPolicyType> typeList = new ArrayList<>();
+    private static final List<ToscaPolicyType> typeList = new ArrayList<>();
 
     /**
      * Set up a Tosca Policy type list for filtering.
@@ -90,14 +90,14 @@ class ToscaEntityFilterTest {
             String yamlAsJsonString = new GsonBuilder().setPrettyPrinting().create().toJson(yamlObject);
 
             ToscaServiceTemplate serviceTemplate =
-                    new StandardCoder().decode(yamlAsJsonString, ToscaServiceTemplate.class);
+                new StandardCoder().decode(yamlAsJsonString, ToscaServiceTemplate.class);
             assertNotNull(serviceTemplate);
 
             addPolicyTypes(serviceTemplate.getPolicyTypes());
         }
 
         for (ToscaPolicyType type : typeList) {
-            LOGGER.info("using policy type-" + type.getName() + ":" + type.getVersion());
+            LOGGER.info("using policy type-{}:{}", type.getName(), type.getVersion());
         }
     }
 
@@ -136,7 +136,7 @@ class ToscaEntityFilterTest {
     @Test
     void testFilterLatestVersion() {
         ToscaEntityFilter<ToscaPolicyType> filter =
-                ToscaEntityFilter.<ToscaPolicyType>builder().version(ToscaEntityFilter.LATEST_VERSION).build();
+            ToscaEntityFilter.<ToscaPolicyType>builder().version(ToscaEntityFilter.LATEST_VERSION).build();
 
         List<ToscaPolicyType> filteredList = filter.filter(typeList);
         assertEquals(19, filteredList.size());
@@ -157,7 +157,7 @@ class ToscaEntityFilterTest {
     @Test
     void testFilterNameVersion() {
         ToscaEntityFilter<ToscaPolicyType> filter =
-                ToscaEntityFilter.<ToscaPolicyType>builder().name("onap.policies.Monitoring").build();
+            ToscaEntityFilter.<ToscaPolicyType>builder().name("onap.policies.Monitoring").build();
         List<ToscaPolicyType> filteredList = filter.filter(typeList);
         assertEquals(1, filteredList.size());
 
@@ -174,12 +174,12 @@ class ToscaEntityFilterTest {
         assertEquals(19, filteredList.size());
 
         filter = ToscaEntityFilter.<ToscaPolicyType>builder().name("onap.policies.optimization.Vim_fit")
-                .version(VERSION_000).build();
+            .version(VERSION_000).build();
         filteredList = filter.filter(typeList);
         assertEquals(0, filteredList.size());
 
         filter = ToscaEntityFilter.<ToscaPolicyType>builder().name("onap.policies.optimization.Vim_fit")
-                .version("0.0.1").build();
+            .version("0.0.1").build();
         filteredList = filter.filter(typeList);
         assertEquals(0, filteredList.size());
     }
index b224a44..ea9fab7 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2019-2021 Nordix Foundation.
+ *  Copyright (C) 2019-2021, 2025 Nordix Foundation.
  *  Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
  *  Modifications Copyright (C) 2024 Nordix Foundation
  * ================================================================================
@@ -70,7 +70,7 @@ class ToscaTypedEntityFilterTest {
     };
     // @formatter:on
 
-    private static List<ToscaPolicy> policyList = new ArrayList<>();
+    private static final List<ToscaPolicy> policyList = new ArrayList<>();
 
     /**
      * Set up a Tosca Policy type list for filtering.
@@ -96,8 +96,8 @@ class ToscaTypedEntityFilterTest {
         }
 
         for (ToscaPolicy policy : policyList) {
-            LOGGER.info("using policy-" + policy.getName() + ":" + policy.getVersion() + ", type-" + policy.getType()
-                    + ":" + policy.getTypeVersion());
+            LOGGER.info("using policy-{}:{}, type-{}:{}", policy.getName(), policy.getVersion(),
+                policy.getType(), policy.getTypeVersion());
         }
     }
 
@@ -140,7 +140,7 @@ class ToscaTypedEntityFilterTest {
     @Test
     void testFilterLatestVersion() {
         ToscaTypedEntityFilter<ToscaPolicy> filter =
-                ToscaTypedEntityFilter.<ToscaPolicy>builder().version(ToscaTypedEntityFilter.LATEST_VERSION).build();
+            ToscaTypedEntityFilter.<ToscaPolicy>builder().version(ToscaTypedEntityFilter.LATEST_VERSION).build();
 
         List<ToscaPolicy> filteredList = filter.filter(policyList);
         assertEquals(22, filteredList.size());
@@ -182,9 +182,7 @@ class ToscaTypedEntityFilterTest {
         // Change versions back
         //
         policyList.forEach(policy -> {
-            if ("onap.vfirewall.tca".equals(policy.getName())) {
-                policy.setVersion(VERSION_100);
-            } else if ("operational.modifyconfig".equals(policy.getName())) {
+            if ("onap.vfirewall.tca".equals(policy.getName()) || "operational.modifyconfig".equals(policy.getName())) {
                 policy.setVersion(VERSION_100);
             }
         });
@@ -202,7 +200,7 @@ class ToscaTypedEntityFilterTest {
     @Test
     void testFilterNameVersion() {
         ToscaTypedEntityFilter<ToscaPolicy> filter =
-                ToscaTypedEntityFilter.<ToscaPolicy>builder().name("operational.modifyconfig").build();
+            ToscaTypedEntityFilter.<ToscaPolicy>builder().name("operational.modifyconfig").build();
         List<ToscaPolicy> filteredList = filter.filter(policyList);
         assertEquals(1, filteredList.size());
 
@@ -219,12 +217,12 @@ class ToscaTypedEntityFilterTest {
         assertEquals(22, filteredList.size());
 
         filter = ToscaTypedEntityFilter.<ToscaPolicy>builder().name("OSDF_CASABLANCA.SubscriberPolicy_v1")
-                .version(VERSION_100).build();
+            .version(VERSION_100).build();
         filteredList = filter.filter(policyList);
         assertEquals(1, filteredList.size());
 
         filter = ToscaTypedEntityFilter.<ToscaPolicy>builder().name("operational.modifyconfig").version(VERSION_100)
-                .build();
+            .build();
         filteredList = filter.filter(policyList);
         assertEquals(1, filteredList.size());
     }
@@ -233,7 +231,7 @@ class ToscaTypedEntityFilterTest {
     void testFilterVersionPrefix() {
         // null pattern
         ToscaTypedEntityFilter<ToscaPolicy> filter =
-                ToscaTypedEntityFilter.<ToscaPolicy>builder().versionPrefix(null).build();
+            ToscaTypedEntityFilter.<ToscaPolicy>builder().versionPrefix(null).build();
         List<ToscaPolicy> filteredList = filter.filter(policyList);
         assertEquals(22, filteredList.size());
 
@@ -249,17 +247,17 @@ class ToscaTypedEntityFilterTest {
     @Test
     void testFilterTypeVersion() {
         ToscaTypedEntityFilter<ToscaPolicy> filter =
-                ToscaTypedEntityFilter.<ToscaPolicy>builder().type("onap.policies.controlloop.Operational").build();
+            ToscaTypedEntityFilter.<ToscaPolicy>builder().type("onap.policies.controlloop.Operational").build();
         List<ToscaPolicy> filteredList = filter.filter(policyList);
         assertEquals(0, filteredList.size());
 
         filter = ToscaTypedEntityFilter.<ToscaPolicy>builder().type("onap.policies.controlloop.operational.common.Apex")
-                .build();
+            .build();
         filteredList = filter.filter(policyList);
         assertEquals(0, filteredList.size());
 
         filter = ToscaTypedEntityFilter.<ToscaPolicy>builder()
-                .type("onap.policies.controlloop.operational.common.Drools").build();
+            .type("onap.policies.controlloop.operational.common.Drools").build();
         filteredList = filter.filter(policyList);
         assertEquals(3, filteredList.size());
 
@@ -276,12 +274,12 @@ class ToscaTypedEntityFilterTest {
         assertEquals(0, filteredList.size());
 
         filter = ToscaTypedEntityFilter.<ToscaPolicy>builder().type("onap.policies.optimization.resource.HpaPolicy")
-                .typeVersion(VERSION_100).build();
+            .typeVersion(VERSION_100).build();
         filteredList = filter.filter(policyList);
         assertEquals(2, filteredList.size());
 
         filter = ToscaTypedEntityFilter.<ToscaPolicy>builder().type("onap.policies.controlloop.Operational")
-                .typeVersion(VERSION_000).build();
+            .typeVersion(VERSION_000).build();
         filteredList = filter.filter(policyList);
         assertEquals(0, filteredList.size());
     }
index e796645..e80d624 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2019-2021, 2023-2024 Nordix Foundation.
+ *  Copyright (C) 2019-2021, 2023-2025 Nordix Foundation.
  *  Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -459,9 +459,8 @@ class AuthorativeToscaProviderPolicyTest {
         ToscaDataType duplDataType = toscaServiceTemplatePolicyType.getDataTypes().values().iterator().next();
         toscaServiceTemplatePolicyType.getDataTypes().put("DuplicateDataType", duplDataType);
 
-        assertThatThrownBy(() -> {
-            toscaServiceTemplatePolicyType.getDataTypesAsMap();
-        }).hasMessageContaining("list of map of entities contains more than one entity with key");
+        assertThatThrownBy(toscaServiceTemplatePolicyType::getDataTypesAsMap)
+            .hasMessageContaining("list of map of entities contains more than one entity with key");
     }
 
     private void createPolicyTypes() throws CoderException, PfModelException {
index 92a5972..b275b13 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2019-2021 Nordix Foundation.
+ *  Copyright (C) 2019-2021, 2025 Nordix Foundation.
  *  Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
  *  Modifications Copyright (C) 2024 Nordix Foundation
  * ================================================================================
@@ -143,8 +143,7 @@ class JpaToscaTimeIntervalTest {
     private JpaToscaTimeInterval setUpJpaToscaTimeInterval(Instant startTime, Instant endTime) {
         PfConceptKey ttiParentKey = new PfConceptKey("tParentKey", "0.0.1");
         PfReferenceKey ttiKey = new PfReferenceKey(ttiParentKey, "trigger0");
-        JpaToscaTimeInterval tti = new JpaToscaTimeInterval(ttiKey, startTime, endTime);
 
-        return tti;
+        return new JpaToscaTimeInterval(ttiKey, startTime, endTime);
     }
 }
index 6defc85..4bfff20 100644 (file)
@@ -3,7 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation
+ * Modifications Copyright (C) 2024-2025 Nordix Foundation
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ package org.onap.policy.models.tosca.simple.concepts;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
+import java.io.Serial;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -51,8 +52,8 @@ class JpaToscaWithToscaPropertiesTest {
     private static final PfReferenceKey REF_KEY2 = new PfReferenceKey(CONCEPT_KEY2);
     private static final JpaToscaProperty JPA_PROP1 = new JpaToscaProperty(REF_KEY1);
     private static final JpaToscaProperty JPA_PROP2 = new JpaToscaProperty(REF_KEY2);
-    private static ToscaProperty PROP1;
-    private static ToscaProperty PROP2;
+    private static ToscaProperty toscaPropertyOne;
+    private static ToscaProperty toscaPropertyTwo;
     private static final String DESCRIPT1 = "description A";
     private static final String DESCRIPT2 = "description B";
 
@@ -66,8 +67,8 @@ class JpaToscaWithToscaPropertiesTest {
         JPA_PROP1.setDescription(DESCRIPT1);
         JPA_PROP2.setDescription(DESCRIPT2);
 
-        PROP1 = JPA_PROP1.toAuthorative();
-        PROP2 = JPA_PROP2.toAuthorative();
+        toscaPropertyOne = JPA_PROP1.toAuthorative();
+        toscaPropertyTwo = JPA_PROP2.toAuthorative();
     }
 
     @BeforeEach
@@ -118,7 +119,7 @@ class JpaToscaWithToscaPropertiesTest {
 
         MyTosca tosca = jpa.toAuthorative();
         assertEquals(SOME_DESCRIPTION, tosca.getDescription());
-        assertThat(tosca.getProperties()).isEqualTo(Map.of(KEY1, PROP1, KEY2, PROP2));
+        assertThat(tosca.getProperties()).isEqualTo(Map.of(KEY1, toscaPropertyOne, KEY2, toscaPropertyTwo));
     }
 
     @Test
@@ -130,12 +131,12 @@ class JpaToscaWithToscaPropertiesTest {
         assertEquals(SOME_DESCRIPTION, jpa.getDescription());
         assertThat(jpa.getProperties()).isNull();
 
-        tosca.setProperties(Map.of(KEY1, PROP1, KEY2, PROP2));
+        tosca.setProperties(Map.of(KEY1, toscaPropertyOne, KEY2, toscaPropertyTwo));
 
-        JpaToscaProperty jpa1 = new JpaToscaProperty(PROP1);
+        JpaToscaProperty jpa1 = new JpaToscaProperty(toscaPropertyOne);
         jpa1.setKey(new PfReferenceKey(jpa.getKey(), KEY1));
 
-        JpaToscaProperty jpa2 = new JpaToscaProperty(PROP2);
+        JpaToscaProperty jpa2 = new JpaToscaProperty(toscaPropertyTwo);
         jpa2.setKey(new PfReferenceKey(jpa.getKey(), KEY2));
 
         jpa = new MyJpa();
@@ -187,15 +188,15 @@ class JpaToscaWithToscaPropertiesTest {
         tosca.setName("world");
         tosca.setVersion("3.2.1");
         tosca.setDescription(SOME_DESCRIPTION);
-        tosca.setProperties(Map.of(KEY1, PROP1, KEY2, PROP2));
+        tosca.setProperties(Map.of(KEY1, toscaPropertyOne, KEY2, toscaPropertyTwo));
 
         jpa = new MyJpa(tosca);
         assertEquals(SOME_DESCRIPTION, jpa.getDescription());
 
-        JpaToscaProperty jpa1 = new JpaToscaProperty(PROP1);
+        JpaToscaProperty jpa1 = new JpaToscaProperty(toscaPropertyOne);
         jpa1.setKey(new PfReferenceKey(jpa.getKey(), KEY1));
 
-        JpaToscaProperty jpa2 = new JpaToscaProperty(PROP2);
+        JpaToscaProperty jpa2 = new JpaToscaProperty(toscaPropertyTwo);
         jpa2.setKey(new PfReferenceKey(jpa.getKey(), KEY2));
 
         assertThat(jpa.getProperties()).isEqualTo(Map.of(KEY1, jpa1, KEY2, jpa2));
@@ -244,17 +245,18 @@ class JpaToscaWithToscaPropertiesTest {
     }
 
 
-    private static class MyTosca extends ToscaWithToscaProperties {
+    protected static class MyTosca extends ToscaWithToscaProperties {
 
     }
 
+    @Setter
+    @Getter
     @NoArgsConstructor
     protected static class MyJpa extends JpaToscaWithToscaProperties<MyTosca> {
+        @Serial
         private static final long serialVersionUID = 1L;
 
         @NotNull
-        @Getter
-        @Setter
         private String text;
 
         public MyJpa(MyJpa jpa) {
@@ -277,6 +279,7 @@ class JpaToscaWithToscaPropertiesTest {
     }
 
     private static class MyJpa2 extends MyJpa {
+        @Serial
         private static final long serialVersionUID = 1L;
     }
 }
index 9e65590..6cb9298 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2019-2021 Nordix Foundation.
+ *  Copyright (C) 2019-2021, 2025 Nordix Foundation.
  *  Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
  *  Modifications Copyright (C) 2024 Nordix Foundation
  * ================================================================================
@@ -28,6 +28,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import org.junit.jupiter.api.Test;
@@ -72,10 +73,8 @@ class ToscaUtilsTest {
         jpaToscaServiceTemplate.getDataTypes().getConceptMap().put(new PfConceptKey(), null);
 
         assertTrue(ToscaUtils.doDataTypesExist(jpaToscaServiceTemplate));
-        assertEquals(null, ToscaUtils.checkDataTypesExist(jpaToscaServiceTemplate));
-        assertThatCode(() -> {
-            ToscaUtils.assertDataTypesExist(jpaToscaServiceTemplate);
-        }).doesNotThrowAnyException();
+        assertNull(ToscaUtils.checkDataTypesExist(jpaToscaServiceTemplate));
+        assertThatCode(() -> ToscaUtils.assertDataTypesExist(jpaToscaServiceTemplate)).doesNotThrowAnyException();
 
     }
 
@@ -102,10 +101,8 @@ class ToscaUtilsTest {
         jpaToscaServiceTemplate.getPolicyTypes().getConceptMap().put(new PfConceptKey(), null);
 
         assertTrue(ToscaUtils.doPolicyTypesExist(jpaToscaServiceTemplate));
-        assertEquals(null, ToscaUtils.checkPolicyTypesExist(jpaToscaServiceTemplate));
-        assertThatCode(() -> {
-            ToscaUtils.assertPolicyTypesExist(jpaToscaServiceTemplate);
-        }).doesNotThrowAnyException();
+        assertNull(ToscaUtils.checkPolicyTypesExist(jpaToscaServiceTemplate));
+        assertThatCode(() -> ToscaUtils.assertPolicyTypesExist(jpaToscaServiceTemplate)).doesNotThrowAnyException();
     }
 
     @Test
@@ -140,14 +137,12 @@ class ToscaUtilsTest {
         jpaToscaServiceTemplate.getTopologyTemplate().getPolicies().getConceptMap().put(new PfConceptKey(), null);
 
         assertTrue(ToscaUtils.doPoliciesExist(jpaToscaServiceTemplate));
-        assertEquals(null, ToscaUtils.checkPoliciesExist(jpaToscaServiceTemplate));
-        assertThatCode(() -> {
-            ToscaUtils.assertPoliciesExist(jpaToscaServiceTemplate);
-        }).doesNotThrowAnyException();
+        assertNull(ToscaUtils.checkPoliciesExist(jpaToscaServiceTemplate));
+        assertThatCode(() -> ToscaUtils.assertPoliciesExist(jpaToscaServiceTemplate)).doesNotThrowAnyException();
     }
 
     @Test
-    void testGetentityTypeAncestors() {
+    void testGetEntityTypeAncestors() {
         assertThatThrownBy(() -> {
             ToscaUtils.getEntityTypeAncestors(null, null, null);
         }).hasMessageMatching("entityTypes is marked .*on.*ull but is null");
@@ -236,7 +231,7 @@ class ToscaUtilsTest {
 
         dt1.setDerivedFrom(new PfConceptKey("tosca.datatyps.Root", PfKey.NULL_KEY_VERSION));
         checkSingleEmptyEntityTypeAncestor(dataTypes, dt0, result);
-        checkMultipleEmptyEntityTypeAncestors(dataTypes, dt1, dt2, result, 1, 0);
+        checkMultipleEmptyEntityTypeAncestors(dataTypes, dt1, dt2, result);
 
         dataTypes.getConceptMap().remove(dt1.getKey());
         assertThat(ToscaUtils.getEntityTypeAncestors(dataTypes, dt2, result)).isEmpty();
@@ -259,11 +254,11 @@ class ToscaUtilsTest {
     }
 
     private void checkMultipleEmptyEntityTypeAncestors(JpaToscaDataTypes dataTypes, JpaToscaDataType emptydt,
-            JpaToscaDataType notemptydt, BeanValidationResult result, int size1, int size2) {
+            JpaToscaDataType notemptydt, BeanValidationResult result) {
         assertThat(ToscaUtils.getEntityTypeAncestors(dataTypes, emptydt, result)).isEmpty();
         assertFalse(ToscaUtils.getEntityTypeAncestors(dataTypes, notemptydt, result).isEmpty());
-        assertEquals(size1, ToscaUtils.getEntityTypeAncestors(dataTypes, notemptydt, result).size());
-        assertEquals(size2, ToscaUtils.getEntityTypeAncestors(dataTypes, emptydt, result).size());
+        assertEquals(1, ToscaUtils.getEntityTypeAncestors(dataTypes, notemptydt, result).size());
+        assertEquals(0, ToscaUtils.getEntityTypeAncestors(dataTypes, emptydt, result).size());
         assertTrue(result.isValid());
     }
 
@@ -273,7 +268,7 @@ class ToscaUtilsTest {
     }
 
     @Test
-    void testgetEntityTree() {
+    void testGetEntityTree() {
         assertThatThrownBy(() -> {
             ToscaUtils.getEntityTree(null, null, null);
         }).hasMessageMatching("entityTypes is marked .*on.*ull but is null");
@@ -378,7 +373,6 @@ class ToscaUtilsTest {
         assertEquals(3, filteredDataTypes.getConceptMap().size());
 
         dt9.setDerivedFrom(new PfConceptKey("i.dont.Exist", "0.0.0"));
-        filteredDataTypes = new JpaToscaDataTypes(dataTypes);
 
         assertThatThrownBy(() -> {
             final JpaToscaDataTypes badDataTypes = new JpaToscaDataTypes(dataTypes);