Fix Sonar Issues for clamp/acm 77/136077/2
authorFrancescoFioraEst <francesco.fiora@est.tech>
Fri, 29 Sep 2023 14:29:55 +0000 (15:29 +0100)
committerFrancesco Fiora <francesco.fiora@est.tech>
Mon, 2 Oct 2023 16:47:37 +0000 (16:47 +0000)
Issue-ID: POLICY-4834
Change-Id: I4489dc66e9b20c8264ec88593f0b5d89d62f1ef8
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
29 files changed:
examples/src/main/resources/clamp/acm/acelement-helm/acelement/values.yaml [changed mode: 0644->0755]
models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionNotification.java [deleted file]
models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionStatus.java [deleted file]
models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionElementTest.java [changed mode: 0644->0755]
models/src/test/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionTest.java [changed mode: 0644->0755]
models/src/test/java/org/onap/policy/clamp/models/acm/concepts/ParticipantTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionNotificationTest.java [deleted file]
models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionStatusTest.java [deleted file]
models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/NotificationPojosTest.java [deleted file]
models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/participant/ParticipantMessageUtils.java [changed mode: 0644->0755]
models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionElementTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantSupportedElementTypeTest.java
models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaParticipantTest.java
participant/participant-impl/participant-impl-a1pms/src/test/java/org/onap/policy/clamp/acm/participant/a1pms/utils/CommonActuatorController.java
participant/participant-impl/participant-impl-acelement/src/main/java/org/onap/policy/clamp/acm/element/main/rest/AcElementErrorController.java
participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/rest/AcElementControllerTest.java
participant/participant-impl/participant-impl-acelement/src/test/java/org/onap/policy/clamp/acm/element/utils/CommonActuatorController.java
participant/participant-impl/participant-impl-http/src/test/java/org/onap/policy/clamp/acm/participant/http/utils/CommonActuatorController.java
participant/participant-impl/participant-impl-kserve/src/test/java/org/onap/policy/clamp/acm/participant/kserve/utils/CommonActuatorController.java
participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/HelmClient.java [changed mode: 0644->0755]
participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/acm/participant/kubernetes/helm/PodStatusValidator.java [changed mode: 0644->0755]
participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/acm/participant/kubernetes/utils/CommonActuatorController.java
participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/CommonActuatorController.java
participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/acm/participant/policy/main/utils/TestListenerUtils.java
participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/utils/CommonActuatorController.java
runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/web/RuntimeErrorController.java
runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProviderTest.java
runtime-acm/src/test/java/org/onap/policy/clamp/acm/runtime/util/rest/CommonRestController.java

old mode 100644 (file)
new mode 100755 (executable)
index 53d9560..272484b
@@ -1,5 +1,5 @@
 # ============LICENSE_START=======================================================
-# Copyright (C) 2022 Nordix Foundation.
+# Copyright (C) 2022-2023 Nordix Foundation.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@ image:
   repository: nexus3.onap.org:10001
   name: onap/policy-clamp-acm-element-impl
   pullPolicy: IfNotPresent
-  tag: "6.4-SNAPSHOT-latest"
+  tag: "7.0-SNAPSHOT-latest"
 
 nameOverride: "ac-element-impl"
 
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionNotification.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionNotification.java
deleted file mode 100644 (file)
index 4b89863..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.models.acm.messages.dmaap.notification;
-
-import com.google.gson.annotations.SerializedName;
-import java.util.ArrayList;
-import java.util.List;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import org.apache.commons.collections4.CollectionUtils;
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class AutomationCompositionNotification {
-
-    /**
-     * Status of automation compositions that are being added to participants.
-     */
-    @SerializedName("deployed-automation-compositions")
-    private List<AutomationCompositionStatus> added = new ArrayList<>();
-
-    /**
-     * Status of policies that are being deleted from PDPs.
-     */
-    @SerializedName("undeployed-automation-compositions")
-    private List<AutomationCompositionStatus> deleted = new ArrayList<>();
-
-
-    /**
-     * Determines if the notification is empty (i.e., has no added or delete automation composition
-     * notifications).
-     *
-     * @return {@code true} if the notification is empty, {@code false} otherwise
-     */
-    public boolean isEmpty() {
-        return (CollectionUtils.isEmpty(added) && CollectionUtils.isEmpty(deleted));
-    }
-}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionStatus.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionStatus.java
deleted file mode 100644 (file)
index f65c621..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.models.acm.messages.dmaap.notification;
-
-import com.google.gson.annotations.SerializedName;
-import java.util.UUID;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-
-@Data
-@NoArgsConstructor
-@AllArgsConstructor
-public class AutomationCompositionStatus {
-    @SerializedName("automation-composition-id")
-    private UUID id;
-
-    private ToscaConceptIdentifier definition;
-}
old mode 100644 (file)
new mode 100755 (executable)
index f29858f..d2648b0
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2022 Nordix Foundation.
+ *  Copyright (C) 2021-2023 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,7 +24,6 @@ import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.util.UUID;
 import org.junit.jupiter.api.Test;
@@ -53,7 +52,6 @@ class AutomationCompositionElementTest {
 
         assertThat(ace0.toString()).contains("AutomationCompositionElement(");
         assertThat(ace0.hashCode()).isNotZero();
-        assertThat(ace0).isEqualTo(ace0);
         assertNotEquals(null, ace0);
 
         var ace1 = new AutomationCompositionElement();
old mode 100644 (file)
new mode 100755 (executable)
index 64dc6f7..99c980c
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2022 Nordix Foundation.
+ *  Copyright (C) 2021-2023 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.clamp.models.acm.concepts;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
 
 import java.util.LinkedHashMap;
@@ -45,13 +45,12 @@ class AutomationCompositionTest {
 
     @Test
     void testAutomationCompositionLombok() {
-        assertNotNull(new AutomationComposition());
+        assertDoesNotThrow(() -> new AutomationComposition());
         var ac0 = new AutomationComposition();
         ac0.setElements(new LinkedHashMap<>());
 
         assertThat(ac0.toString()).contains("AutomationComposition(");
         assertThat(ac0.hashCode()).isNotZero();
-        assertEquals(ac0, ac0);
         assertNotEquals(null, ac0);
 
         var ac1 = new AutomationComposition();
index c6af967..7486d0d 100644 (file)
@@ -22,9 +22,9 @@ package org.onap.policy.clamp.models.acm.concepts;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.util.Map;
 import java.util.UUID;
@@ -35,12 +35,11 @@ class ParticipantTest {
 
     @Test
     void testParticipantLombok() {
-        assertNotNull(new Participant());
+        assertDoesNotThrow(() -> new Participant());
         var p0 = new Participant();
 
         assertThat(p0.toString()).contains("Participant(");
         assertThat(p0.hashCode()).isNotZero();
-        assertEquals(p0, p0);
         assertNotEquals(null, p0);
 
 
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionNotificationTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionNotificationTest.java
deleted file mode 100644 (file)
index 5902b93..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2022 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.models.acm.messages.dmaap.notification;
-
-import static org.assertj.core.api.Assertions.assertThat;
-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.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.junit.jupiter.api.Test;
-
-class AutomationCompositionNotificationTest {
-
-    @Test
-    void testAutomationCompositionNotification() {
-        AutomationCompositionNotification acn0 = new AutomationCompositionNotification();
-
-        List<AutomationCompositionStatus> addedList = new ArrayList<>();
-        addedList.add(new AutomationCompositionStatus());
-
-        List<AutomationCompositionStatus> deletedList = new ArrayList<>();
-        deletedList.add(new AutomationCompositionStatus());
-
-        assertTrue(acn0.isEmpty());
-
-        acn0.setAdded(addedList);
-        assertFalse(acn0.isEmpty());
-        acn0.setAdded(null);
-        assertTrue(acn0.isEmpty());
-
-        acn0.setDeleted(deletedList);
-        assertFalse(acn0.isEmpty());
-        acn0.setDeleted(null);
-        assertTrue(acn0.isEmpty());
-
-        acn0.setAdded(addedList);
-        acn0.setDeleted(deletedList);
-        assertFalse(acn0.isEmpty());
-        acn0.setAdded(null);
-        acn0.setDeleted(null);
-        assertTrue(acn0.isEmpty());
-    }
-
-    @Test
-    void testAutomationCompositionNotificationLombok() {
-        assertNotNull(new AutomationCompositionNotification());
-        assertNotNull(new AutomationCompositionNotification(new ArrayList<>(), new ArrayList<>()));
-
-        AutomationCompositionNotification acn0 = new AutomationCompositionNotification();
-
-        assertThat(acn0.toString()).contains("AutomationCompositionNotification(");
-        assertNotEquals(0, acn0.hashCode());
-        assertEquals(acn0, acn0);
-        assertNotEquals(null, acn0);
-
-
-        AutomationCompositionNotification acn1 = new AutomationCompositionNotification();
-
-        assertThat(acn1.toString()).contains("AutomationCompositionNotification(");
-        assertNotEquals(0, acn1.hashCode());
-        assertEquals(acn1, acn0);
-        assertNotEquals(null, acn1);
-    }
-}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionStatusTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/AutomationCompositionStatusTest.java
deleted file mode 100644 (file)
index d4e3004..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2022 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.models.acm.messages.dmaap.notification;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import java.util.UUID;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-
-class AutomationCompositionStatusTest {
-
-    @Test
-    void testAutomationCompositionStatusLombok() {
-        assertNotNull(new AutomationCompositionStatus());
-        assertNotNull(new AutomationCompositionStatus(UUID.randomUUID(), new ToscaConceptIdentifier()));
-
-        AutomationCompositionStatus acn0 = new AutomationCompositionStatus();
-
-        assertThat(acn0.toString()).contains("AutomationCompositionStatus(");
-        assertNotEquals(0, acn0.hashCode());
-        assertEquals(acn0, acn0);
-        assertNotEquals(null, acn0);
-
-        AutomationCompositionStatus acn1 = new AutomationCompositionStatus();
-        assertEquals(acn1, acn0);
-    }
-}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/NotificationPojosTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/dmaap/notification/NotificationPojosTest.java
deleted file mode 100644 (file)
index 494252a..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.clamp.models.acm.messages.dmaap.notification;
-
-import com.openpojo.reflection.PojoClass;
-import com.openpojo.reflection.impl.PojoClassFactory;
-import com.openpojo.validation.Validator;
-import com.openpojo.validation.ValidatorBuilder;
-import com.openpojo.validation.rule.impl.GetterMustExistRule;
-import com.openpojo.validation.rule.impl.SetterMustExistRule;
-import com.openpojo.validation.test.impl.GetterTester;
-import com.openpojo.validation.test.impl.SetterTester;
-import java.util.List;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.common.utils.test.ToStringTester;
-
-/**
- * Class to perform unit tests of all pojos.
- */
-class NotificationPojosTest {
-
-    @Test
-    void testPojos() {
-        List<PojoClass> pojoClasses =
-                PojoClassFactory.getPojoClasses(NotificationPojosTest.class.getPackageName());
-
-        // @formatter:off
-        final Validator validator = ValidatorBuilder
-                .create()
-                .with(new ToStringTester())
-                .with(new SetterMustExistRule())
-                .with(new GetterMustExistRule())
-                .with(new SetterTester())
-                .with(new GetterTester())
-                .build();
-
-        validator.validate(pojoClasses);
-        // @formatter:on
-    }
-}
old mode 100644 (file)
new mode 100755 (executable)
index 4ff4f3b..0f32fe9
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * Copyright (C) 2021,2023 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
 
 package org.onap.policy.clamp.models.acm.messages.dmaap.participant;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.coder.StandardCoder;
index 7cb8f84..2eda9a9 100644 (file)
@@ -22,9 +22,9 @@ package org.onap.policy.clamp.models.acm.persistence.concepts;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.Map;
@@ -33,7 +33,6 @@ import org.junit.jupiter.api.Test;
 import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
 import org.onap.policy.clamp.models.acm.concepts.DeployState;
 import org.onap.policy.clamp.models.acm.concepts.LockState;
-import org.onap.policy.clamp.models.acm.concepts.Participant;
 import org.onap.policy.clamp.models.acm.utils.CommonTestData;
 import org.onap.policy.models.base.PfConceptKey;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -95,9 +94,9 @@ class JpaAutomationCompositionElementTest {
                 DeployState.UNDEPLOYED, null);
         }).hasMessageMatching("lockState" + NULL_ERROR);
 
-        assertNotNull(new JpaAutomationCompositionElement());
-        assertNotNull(new JpaAutomationCompositionElement("key", "key"));
-        assertNotNull(new JpaAutomationCompositionElement("key", "key",
+        assertDoesNotThrow(() -> new JpaAutomationCompositionElement());
+        assertDoesNotThrow(() -> new JpaAutomationCompositionElement("key", "key"));
+        assertDoesNotThrow(() -> new JpaAutomationCompositionElement("key", "key",
             new PfConceptKey(), DeployState.UNDEPLOYED, LockState.LOCKED));
     }
 
@@ -211,12 +210,10 @@ class JpaAutomationCompositionElementTest {
 
     @Test
     void testJpaAutomationCompositionElementLombok() {
-        assertNotNull(new Participant());
         var ace0 = new JpaAutomationCompositionElement();
 
         assertThat(ace0.toString()).contains("JpaAutomationCompositionElement(");
         assertThat(ace0.hashCode()).isNotZero();
-        assertEquals(ace0, ace0);
         assertNotEquals(null, ace0);
 
         var ace1 = new JpaAutomationCompositionElement(ace0.getElementId(), ace0.getInstanceId());
index 697b4e1..66554e7 100755 (executable)
@@ -22,9 +22,9 @@ package org.onap.policy.clamp.models.acm.persistence.concepts;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.ArrayList;
@@ -72,22 +72,22 @@ class JpaAutomationCompositionTest {
         }).hasMessageMatching("compositionId" + NULL_TEXT_ERROR);
 
         assertThatThrownBy(() -> {
-            new JpaAutomationComposition(INSTANCE_ID, new PfConceptKey(), COMPOSITION_ID.toString(), null,
+            new JpaAutomationComposition(INSTANCE_ID, new PfConceptKey(), COMPOSITION_ID, null,
                     DeployState.UNDEPLOYED, LockState.LOCKED);
         }).hasMessageMatching("elements" + NULL_TEXT_ERROR);
 
         assertThatThrownBy(() -> {
-            new JpaAutomationComposition(INSTANCE_ID, new PfConceptKey(), COMPOSITION_ID.toString(), new ArrayList<>(),
+            new JpaAutomationComposition(INSTANCE_ID, new PfConceptKey(), COMPOSITION_ID, new ArrayList<>(),
                     null, LockState.LOCKED);
         }).hasMessageMatching("deployState" + NULL_TEXT_ERROR);
 
         assertThatThrownBy(() -> {
-            new JpaAutomationComposition(INSTANCE_ID, new PfConceptKey(), COMPOSITION_ID.toString(), new ArrayList<>(),
+            new JpaAutomationComposition(INSTANCE_ID, new PfConceptKey(), COMPOSITION_ID, new ArrayList<>(),
                     DeployState.UNDEPLOYED, null);
         }).hasMessageMatching("lockState" + NULL_TEXT_ERROR);
 
-        assertNotNull(new JpaAutomationComposition());
-        assertNotNull(new JpaAutomationComposition(INSTANCE_ID, new PfConceptKey(), COMPOSITION_ID.toString(),
+        assertDoesNotThrow(() -> new JpaAutomationComposition());
+        assertDoesNotThrow(() -> new JpaAutomationComposition(INSTANCE_ID, new PfConceptKey(), COMPOSITION_ID,
                 new ArrayList<>(), DeployState.UNDEPLOYED, LockState.LOCKED));
     }
 
@@ -198,13 +198,11 @@ class JpaAutomationCompositionTest {
 
     @Test
     void testJpaAutomationCompositionLombok() {
-        assertNotNull(new AutomationComposition());
         var ac0 = new JpaAutomationComposition();
         ac0.setCompositionId(COMPOSITION_ID);
 
         assertThat(ac0.toString()).contains("JpaAutomationComposition(");
         assertThat(ac0.hashCode()).isNotZero();
-        assertEquals(ac0, ac0);
         assertNotEquals(null, ac0);
 
         var ac1 = new JpaAutomationComposition();
index 8afb5ae..d74ce03 100644 (file)
@@ -21,9 +21,9 @@
 package org.onap.policy.clamp.models.acm.persistence.concepts;
 
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import java.util.UUID;
 import org.junit.jupiter.api.Test;
@@ -74,9 +74,9 @@ class JpaParticipantSupportedElementTypeTest {
             new JpaParticipantSupportedElementType("key", "key", "name", null);
         }).hasMessageMatching("typeVersion" + NULL_ERROR);
 
-        assertNotNull(new JpaParticipantSupportedElementType());
-        assertNotNull(new JpaParticipantSupportedElementType("key", "key"));
-        assertNotNull(new JpaParticipantSupportedElementType("key", "key", "name",
+        assertDoesNotThrow(() -> new JpaParticipantSupportedElementType());
+        assertDoesNotThrow(() -> new JpaParticipantSupportedElementType("key", "key"));
+        assertDoesNotThrow(() -> new JpaParticipantSupportedElementType("key", "key", "name",
             "1.0.0"));
     }
 
index 1ad757f..05ab495 100644 (file)
@@ -22,9 +22,9 @@ package org.onap.policy.clamp.models.acm.persistence.concepts;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.util.ArrayList;
@@ -57,9 +57,9 @@ class JpaParticipantTest {
         assertThatThrownBy(() -> new JpaParticipant(UUID.randomUUID().toString(), ParticipantState.ON_LINE, null))
             .hasMessageMatching("supportedElements is marked .*ull but is null");
 
-        assertNotNull(new JpaParticipant());
-        assertNotNull(new JpaParticipant(UUID.randomUUID().toString(), ParticipantState.ON_LINE, new ArrayList<>()));
-
+        assertDoesNotThrow(() -> new JpaParticipant());
+        assertDoesNotThrow(() -> new JpaParticipant(UUID.randomUUID().toString(),
+            ParticipantState.ON_LINE, new ArrayList<>()));
     }
 
     @Test
@@ -121,12 +121,10 @@ class JpaParticipantTest {
 
     @Test
     void testJpaParticipantLombok() {
-        assertNotNull(new Participant());
         var p0 = new JpaParticipant();
 
         assertThat(p0.toString()).contains("JpaParticipant(");
         assertThat(p0.hashCode()).isNotZero();
-        assertEquals(p0, p0);
         assertNotEquals(null, p0);
 
 
index f2e150d..c4a9347 100755 (executable)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2022 Nordix Foundation.
+ *  Copyright (C) 2022-2023 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
 
 package org.onap.policy.clamp.acm.participant.a1pms.utils;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import jakarta.ws.rs.client.Client;
 import jakarta.ws.rs.client.ClientBuilder;
index 3442eed..081eb03 100755 (executable)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2022 Nordix Foundation.
+ *  Copyright (C) 2021-2023 Nordix Foundation.
  * ================================================================================
  * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
@@ -27,7 +27,6 @@ import jakarta.servlet.http.HttpServletRequest;
 import java.util.Map;
 import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse;
 import org.onap.policy.clamp.models.acm.messages.rest.TypedSimpleResponse;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.web.error.ErrorAttributeOptions;
 import org.springframework.boot.web.servlet.error.ErrorAttributes;
 import org.springframework.boot.web.servlet.error.ErrorController;
@@ -43,9 +42,6 @@ public class AcElementErrorController implements ErrorController {
 
     private final ErrorAttributes errorAttributes;
 
-    @Value("${server.error.path}")
-    private String path;
-
     /**
      * Constructor.
      *
@@ -56,7 +52,7 @@ public class AcElementErrorController implements ErrorController {
     }
 
     protected HttpStatus getStatus(HttpServletRequest request) {
-        Integer statusCode = (Integer) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
+        var statusCode = (Integer) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
         if (statusCode == null) {
             return HttpStatus.INTERNAL_SERVER_ERROR;
         }
@@ -73,19 +69,20 @@ public class AcElementErrorController implements ErrorController {
      * @param request HttpServletRequest
      * @return ResponseEntity
      */
+    @SuppressWarnings("squid:S3752")
     @RequestMapping(value = "${server.error.path}", produces = MediaType.APPLICATION_JSON_VALUE)
     public ResponseEntity<TypedSimpleResponse<SimpleResponse>> handleError(HttpServletRequest request) {
         Map<String, Object> map = this.errorAttributes.getErrorAttributes(new ServletWebRequest(request),
                 ErrorAttributeOptions.defaults());
 
         var sb = new StringBuilder();
-        final Object error = map.get("error");
+        final var error = map.get("error");
         if (error != null) {
-            sb.append(error.toString() + " ");
+            sb.append(error).append(" ");
         }
-        final Object message = map.get("message");
+        final var message = map.get("message");
         if (message != null) {
-            sb.append(message.toString());
+            sb.append(message);
         }
 
         TypedSimpleResponse<SimpleResponse> resp = new TypedSimpleResponse<>();
index 1ffe7d1..a2ed1ca 100755 (executable)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2022 Nordix Foundation.
+ *  Copyright (C) 2022-2023 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@
 package org.onap.policy.clamp.acm.element.rest;
 
 import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doThrow;
@@ -165,5 +165,4 @@ class AcElementControllerTest {
     private String getElementConfigJson() throws IOException {
         return FileUtils.readFileToString(new File(ELEMENT_CONFIG_YAML), StandardCharsets.UTF_8);
     }
-
 }
index 1b43e60..a1d2203 100755 (executable)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2022 Nordix Foundation.
+ *  Copyright (C) 2022-2023 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
 
 package org.onap.policy.clamp.acm.element.utils;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import jakarta.ws.rs.client.Client;
 import jakarta.ws.rs.client.ClientBuilder;
index 0c595d6..fa9068a 100755 (executable)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2022 Nordix Foundation.
+ *  Copyright (C) 2021-2023 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
 
 package org.onap.policy.clamp.acm.participant.http.utils;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import jakarta.ws.rs.client.Client;
 import jakarta.ws.rs.client.ClientBuilder;
old mode 100644 (file)
new mode 100755 (executable)
index a05dfbc..8aca524
@@ -1,6 +1,6 @@
 /*-
  * ========================LICENSE_START=================================
- * Copyright (C) 2021-2022 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2021-2023 Nordix Foundation. All rights reserved.
  * ======================================================================
  * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
  * ======================================================================
@@ -26,7 +26,6 @@ import java.lang.invoke.MethodHandles;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.onap.policy.clamp.acm.participant.kubernetes.exception.ServiceException;
@@ -49,6 +48,9 @@ public class HelmClient {
 
     private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
     private static final String PATH_DELIMITER = "/";
+    public static final String COMMAND_SH = "/bin/sh";
+    private static final String COMMAND_HELM = "/usr/local/bin/helm";
+    public static final String COMMAND_KUBECTL = "/usr/local/bin/kubectl";
 
     /**
      * Install a chart.
@@ -193,7 +195,7 @@ public class HelmClient {
         // @formatter:off
         List<String> helmArguments = new ArrayList<>(
                 List.of(
-                        "helm",
+                    COMMAND_HELM,
                         "repo",
                         "add", repo.getRepoName(), repo.getAddress()
                 ));
@@ -206,7 +208,7 @@ public class HelmClient {
     private boolean verifyHelmRepoAlreadyExist(HelmRepository repo) {
         try {
             logger.debug("Verify the repo already exist in helm repositories");
-            List<String> helmArguments = List.of("sh", "-c", "helm repo list | grep " + repo.getRepoName());
+            var helmArguments = List.of(COMMAND_SH, "-c", COMMAND_HELM + " repo list | grep " + repo.getRepoName());
             String response = executeCommand(new ProcessBuilder().command(helmArguments));
             if (StringUtils.isEmpty(response)) {
                 return false;
@@ -219,7 +221,7 @@ public class HelmClient {
     }
 
     private ProcessBuilder prepareVerifyNamespaceCommand(String namespace) {
-        List<String> helmArguments = List.of("sh", "-c", "kubectl get ns | grep " + namespace);
+        var helmArguments = List.of(COMMAND_SH, "-c", COMMAND_KUBECTL + " get ns | grep " + namespace);
         return new ProcessBuilder().command(helmArguments);
     }
 
@@ -228,7 +230,7 @@ public class HelmClient {
         // @formatter:off
         List<String> helmArguments = new ArrayList<>(
             List.of(
-                "helm",
+                COMMAND_HELM,
                 "install", chart.getReleaseName(), chart.getRepository().getRepoName() + "/"
                             + chart.getChartId().getName(),
                 "--version", chart.getChartId().getVersion(),
@@ -245,7 +247,7 @@ public class HelmClient {
         }
 
         if (chart.getOverrideParams() != null) {
-            for (Map.Entry<String, String> entry : chart.getOverrideParams().entrySet()) {
+            for (var entry : chart.getOverrideParams().entrySet()) {
                 helmArguments.addAll(List.of("--set", entry.getKey() + "=" + entry.getValue()));
             }
         }
@@ -253,23 +255,23 @@ public class HelmClient {
     }
 
     private ProcessBuilder prepareUnInstallCommand(ChartInfo chart) {
-        return new ProcessBuilder("helm", "delete", chart.getReleaseName(), "--namespace",
+        return new ProcessBuilder(COMMAND_HELM, "delete", chart.getReleaseName(), "--namespace",
             chart.getNamespace());
     }
 
     private ProcessBuilder prepareCreateNamespaceCommand(String namespace) {
-        return new ProcessBuilder().command("kubectl", "create", "namespace", namespace);
+        return new ProcessBuilder().command(COMMAND_KUBECTL, "create", "namespace", namespace);
     }
 
     private ProcessBuilder helmRepoVerifyCommand(String chartName) {
-        return new ProcessBuilder().command("sh", "-c", "helm search repo | grep " + chartName);
+        return new ProcessBuilder().command(COMMAND_SH, "-c", COMMAND_HELM + " search repo | grep " + chartName);
     }
 
 
     private boolean updateHelmRepo() {
         try {
             logger.info("Updating local helm repositories before verifying the chart");
-            executeCommand(new ProcessBuilder().command("helm", "repo", "update"));
+            executeCommand(new ProcessBuilder().command(COMMAND_HELM, "repo", "update"));
             logger.debug("Helm repositories updated successfully");
         } catch (ServiceException e) {
             logger.error("Failed to update the helm repo: ", e);
old mode 100644 (file)
new mode 100755 (executable)
index 0a14241..6c9656b
@@ -1,6 +1,6 @@
 /*-
  * ========================LICENSE_START=================================
- * Copyright (C) 2021-2022 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2021-2023 Nordix Foundation. All rights reserved.
  * ======================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -101,8 +101,9 @@ public class PodStatusValidator {
     }
 
     private ProcessBuilder verifyPodStatusCommand(ChartInfo chart) {
-        String cmd = "kubectl get pods --namespace " + chart.getNamespace() + " | grep " + getPodName();
-        return new ProcessBuilder("sh", "-c", cmd);
+        String cmd = HelmClient.COMMAND_KUBECTL
+            + " get pods --namespace " + chart.getNamespace() + " | grep " + getPodName();
+        return new ProcessBuilder(HelmClient.COMMAND_SH, "-c", cmd);
     }
 
     private String getPodName() {
index 2176478..4487dbe 100755 (executable)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2022 Nordix Foundation.
+ *  Copyright (C) 2021-2023 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
 
 package org.onap.policy.clamp.acm.participant.kubernetes.utils;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import jakarta.ws.rs.client.ClientBuilder;
 import jakarta.ws.rs.client.Invocation;
index e5f5aec..2b77452 100755 (executable)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2022 Nordix Foundation.
+ *  Copyright (C) 2021-2023 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
 
 package org.onap.policy.clamp.acm.participant.policy.main.utils;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import jakarta.ws.rs.client.Client;
 import jakarta.ws.rs.client.ClientBuilder;
index f7feba3..a7faf04 100755 (executable)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021 Nordix Foundation.
+ *  Copyright (C) 2021,2023 Nordix Foundation.
  * ================================================================================
  * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
@@ -30,7 +30,6 @@ import org.onap.policy.clamp.models.acm.messages.rest.SimpleResponse;
 import org.onap.policy.clamp.models.acm.messages.rest.TypedSimpleResponse;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.web.error.ErrorAttributeOptions;
 import org.springframework.boot.web.servlet.error.ErrorAttributes;
 import org.springframework.boot.web.servlet.error.ErrorController;
@@ -49,9 +48,6 @@ public class RuntimeErrorController implements ErrorController {
 
     private final ErrorAttributes errorAttributes;
 
-    @Value("${server.error.path}")
-    private String path;
-
     /**
      * Constructor.
      *
@@ -62,7 +58,7 @@ public class RuntimeErrorController implements ErrorController {
     }
 
     protected HttpStatus getStatus(HttpServletRequest request) {
-        Integer statusCode = (Integer) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
+        var statusCode = (Integer) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
         if (statusCode == null) {
             return HttpStatus.INTERNAL_SERVER_ERROR;
         }
@@ -80,25 +76,25 @@ public class RuntimeErrorController implements ErrorController {
      * @param request HttpServletRequest
      * @return ResponseEntity
      */
+    @SuppressWarnings("squid:S3752")
     @RequestMapping(value = "${server.error.path}", produces = MediaType.APPLICATION_JSON_VALUE)
     public ResponseEntity<TypedSimpleResponse<SimpleResponse>> handleError(HttpServletRequest request) {
         Map<String, Object> map = this.errorAttributes.getErrorAttributes(new ServletWebRequest(request),
                 ErrorAttributeOptions.defaults());
 
         var sb = new StringBuilder();
-        final Object error = map.get("error");
+        final var error = map.get("error");
         if (error != null) {
-            sb.append(error.toString()).append(" ");
+            sb.append(error).append(" ");
         }
-        final Object message = map.get("message");
+        final var message = map.get("message");
         if (message != null) {
-            sb.append(message.toString());
+            sb.append(message);
         }
 
         TypedSimpleResponse<SimpleResponse> resp = new TypedSimpleResponse<>();
         resp.setErrorDetails(sb.toString());
 
         return ResponseEntity.status(getStatus(request)).body(resp);
-
     }
 }
index 8f7a4fe..8dca669 100755 (executable)
@@ -36,7 +36,6 @@ import java.util.UUID;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 import org.onap.policy.clamp.acm.runtime.main.parameters.AcRuntimeParameterGroup;
-import org.onap.policy.clamp.acm.runtime.main.parameters.AcmParameters;
 import org.onap.policy.clamp.acm.runtime.participants.AcmParticipantProvider;
 import org.onap.policy.clamp.acm.runtime.supervision.SupervisionAcHandler;
 import org.onap.policy.clamp.acm.runtime.util.CommonTestData;
index f822bda..fec0f21 100755 (executable)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2021-2022 Nordix Foundation.
+ *  Copyright (C) 2021-2023 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,8 +20,7 @@
 
 package org.onap.policy.clamp.acm.runtime.util.rest;
 
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import jakarta.ws.rs.client.Client;
 import jakarta.ws.rs.client.ClientBuilder;