Fix sonars in clamp 80/123780/2
authorJim Hahn <jrh3@att.com>
Wed, 1 Sep 2021 21:16:53 +0000 (17:16 -0400)
committerJim Hahn <jrh3@att.com>
Wed, 1 Sep 2021 22:02:18 +0000 (18:02 -0400)
Fixed some sonars:
- no assertion in test case
- unused fields
- unthrown exception
- define a constant
- use boolean instead of Boolean
- remove unused parameter

Fixed some eclipse warnings:
- unused imports
- unused methods
- suppress warnings
- add type parameter

Renamed directory from "org.onap.policy..." to "org/onap/policy/...".

Issue-ID: POLICY-3200
Change-Id: I76f7cd4a508ac421c37e457fdca6894e6100c802
Signed-off-by: Jim Hahn <jrh3@att.com>
25 files changed:
participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandlerTest.java [moved from participant/participant-impl/participant-impl-kubernetes/src/test/java/org.onap.policy.clamp.controlloop.participant.kubernetes/handler/ControlLoopElementHandlerTest.java with 98% similarity]
participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClientTest.java [moved from participant/participant-impl/participant-impl-kubernetes/src/test/java/org.onap.policy.clamp.controlloop.participant.kubernetes/helm/HelmClientTest.java with 98% similarity]
participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/PodStatusValidatorTest.java [moved from participant/participant-impl/participant-impl-kubernetes/src/test/java/org.onap.policy.clamp.controlloop.participant.kubernetes/helm/PodStatusValidatorTest.java with 98% similarity]
participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/CommonTestData.java [moved from participant/participant-impl/participant-impl-kubernetes/src/test/java/org.onap.policy.clamp.controlloop.participant.kubernetes/parameters/CommonTestData.java with 98% similarity]
participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/parameters/ParticipantK8sParametersTest.java [moved from participant/participant-impl/participant-impl-kubernetes/src/test/java/org.onap.policy.clamp.controlloop.participant.kubernetes/parameters/ParticipantK8sParametersTest.java with 97% similarity]
participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/rest/ChartControllerTest.java [moved from participant/participant-impl/participant-impl-kubernetes/src/test/java/org.onap.policy.clamp.controlloop.participant.kubernetes/rest/ChartControllerTest.java with 99% similarity]
participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartServiceTest.java [moved from participant/participant-impl/participant-impl-kubernetes/src/test/java/org.onap.policy.clamp.controlloop.participant.kubernetes/service/ChartServiceTest.java with 98% similarity]
participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStoreTest.java [moved from participant/participant-impl/participant-impl-kubernetes/src/test/java/org.onap.policy.clamp.controlloop.participant.kubernetes/service/ChartStoreTest.java with 98% similarity]
participant/participant-impl/participant-impl-kubernetes/src/test/java/org/onap/policy/clamp/controlloop/participant/kubernetes/utils/TestUtils.java [moved from participant/participant-impl/participant-impl-kubernetes/src/test/java/org.onap.policy.clamp.controlloop.participant.kubernetes/utils/TestUtils.java with 95% similarity]
participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/endtoend/ParticipantMessagesTest.java
participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java
participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java
participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/ParticipantMessagePublisher.java
participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java
runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java
runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/InstantiationController.java
runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java
runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java
runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningControllerTest.java
runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java
runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationControllerTest.java
runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java
runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionAspectTest.java
runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java

@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
index 8187378..ce368eb 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -24,22 +25,11 @@ import static org.assertj.core.api.Assertions.assertThatCode;
 import static org.junit.Assert.assertEquals;
 
 import java.time.Instant;
-import java.util.ArrayList;
 import java.util.Collections;
-import java.util.List;
-import java.util.Map;
 import java.util.UUID;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mockito;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatisticsList;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopInfo;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopStatistics;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition;
-import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ControlLoopUpdate;
 import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregister;
 import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregisterAck;
 import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister;
@@ -47,7 +37,6 @@ import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.Parti
 import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus;
 import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
 import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdateAck;
-import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ControlLoopUpdateListener;
 import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantDeregisterAckListener;
 import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantMessagePublisher;
 import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantRegisterAckListener;
@@ -57,7 +46,6 @@ import org.onap.policy.clamp.controlloop.participant.policy.main.utils.TestListe
 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.common.endpoints.event.comm.TopicSink;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
@@ -87,7 +75,8 @@ class ParticipantMessagesTest {
             ParticipantMessagePublisher participantMessagePublisher =
                     new ParticipantMessagePublisher();
             participantMessagePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
-            participantMessagePublisher.sendParticipantRegister(participantRegisterMsg);
+            assertThatCode(() -> participantMessagePublisher.sendParticipantRegister(participantRegisterMsg))
+                            .doesNotThrowAnyException();
         }
     }
 
@@ -101,7 +90,8 @@ class ParticipantMessagesTest {
         synchronized (lockit) {
             ParticipantRegisterAckListener participantRegisterAckListener =
                 new ParticipantRegisterAckListener(participantHandler);
-            participantRegisterAckListener.onTopicEvent(INFRA, TOPIC, null, participantRegisterAckMsg);
+            assertThatCode(() -> participantRegisterAckListener.onTopicEvent(INFRA, TOPIC, null,
+                            participantRegisterAckMsg)).doesNotThrowAnyException();
         }
     }
 
@@ -116,7 +106,8 @@ class ParticipantMessagesTest {
             ParticipantMessagePublisher participantMessagePublisher =
                     new ParticipantMessagePublisher();
             participantMessagePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
-            participantMessagePublisher.sendParticipantDeregister(participantDeregisterMsg);
+            assertThatCode(() -> participantMessagePublisher.sendParticipantDeregister(participantDeregisterMsg))
+                            .doesNotThrowAnyException();
         }
     }
 
@@ -129,8 +120,9 @@ class ParticipantMessagesTest {
 
         synchronized (lockit) {
             ParticipantDeregisterAckListener participantDeregisterAckListener =
-                    new ParticipantDeregisterAckListener(participantHandler);
-            participantDeregisterAckListener.onTopicEvent(INFRA, TOPIC, null, participantDeregisterAckMsg);
+                            new ParticipantDeregisterAckListener(participantHandler);
+            assertThatCode(() -> participantDeregisterAckListener.onTopicEvent(INFRA, TOPIC, null,
+                            participantDeregisterAckMsg)).doesNotThrowAnyException();
         }
     }
 
@@ -157,7 +149,8 @@ class ParticipantMessagesTest {
         synchronized (lockit) {
             ParticipantMessagePublisher participantMessagePublisher = new ParticipantMessagePublisher();
             participantMessagePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
-            participantMessagePublisher.sendParticipantUpdateAck(participantUpdateAckMsg);
+            assertThatCode(() -> participantMessagePublisher.sendParticipantUpdateAck(participantUpdateAckMsg))
+                            .doesNotThrowAnyException();
         }
     }
 
@@ -178,47 +171,4 @@ class ParticipantMessagesTest {
     private ToscaConceptIdentifier getParticipantType() {
         return new ToscaConceptIdentifier("org.onap.policy.controlloop.PolicyControlLoopParticipant", "2.3.1");
     }
-
-    private ToscaConceptIdentifier getControlLoopId() {
-        return new ToscaConceptIdentifier("PMSHInstance0", "1.0.0");
-    }
-
-    private ControlLoopInfo getControlLoopInfo(ToscaConceptIdentifier id) {
-        ControlLoopInfo clInfo = new ControlLoopInfo();
-        clInfo.setState(ControlLoopState.PASSIVE2RUNNING);
-
-        ControlLoopStatistics clStatistics = new ControlLoopStatistics();
-        clStatistics.setControlLoopId(id);
-        clStatistics.setAverageExecutionTime(12345);
-        clStatistics.setEventCount(12345);
-        clStatistics.setLastEnterTime(12345);
-        clStatistics.setLastExecutionTime(12345);
-        clStatistics.setLastStart(12345);
-        clStatistics.setTimeStamp(Instant.ofEpochMilli(3000));
-        clStatistics.setUpTime(12345);
-        ClElementStatisticsList clElementStatisticsList = new ClElementStatisticsList();
-        ClElementStatistics clElementStatistics = new ClElementStatistics();
-        clElementStatistics.setParticipantId(new ToscaConceptIdentifier("defName", "0.0.1"));
-        clElementStatistics.setTimeStamp(Instant.now());
-        clElementStatisticsList.setClElementStatistics(List.of(clElementStatistics));
-        clStatistics.setClElementStatisticsList(clElementStatisticsList);
-
-        clInfo.setControlLoopStatistics(clStatistics);
-        return clInfo;
-    }
-
-    private ControlLoopElementDefinition getClElementDefinition() {
-        ToscaNodeTemplate toscaNodeTemplate = new ToscaNodeTemplate();
-        toscaNodeTemplate.setName("serviceTemplate");
-        toscaNodeTemplate.setDerivedFrom("parentServiceTemplate");
-        toscaNodeTemplate.setDescription("Description of serviceTemplate");
-        toscaNodeTemplate.setVersion("1.2.3");
-
-        ControlLoopElementDefinition clDefinition = new ControlLoopElementDefinition();
-        clDefinition.setCommonPropertiesMap(Map.of("Prop1", "Prop1Value"));
-        clDefinition.setControlLoopElementToscaNodeTemplate(toscaNodeTemplate);
-        Map<String, String> commonPropertiesMap = Map.of("Prop1", "PropValue");
-        clDefinition.setCommonPropertiesMap(commonPropertiesMap);
-        return clDefinition;
-    }
 }
index 2ca14fd..7292f8d 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -33,7 +34,6 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant
 import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics;
 import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
 
 /**
  * This interface is used by participant implementations to use the participant intermediary.
index f6d7cd1..f8ef8d5 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -38,7 +39,6 @@ import org.onap.policy.clamp.controlloop.participant.intermediary.api.ControlLoo
 import org.onap.policy.clamp.controlloop.participant.intermediary.api.ParticipantIntermediaryApi;
 import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
 import org.springframework.stereotype.Component;
 
 /**
@@ -124,8 +124,7 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp
     @Override
     public ControlLoopElement updateControlLoopElementState(UUID id, ControlLoopOrderedState currentState,
             ControlLoopState newState, ParticipantMessageType messageType) {
-        return participantHandler.getControlLoopHandler().updateControlLoopElementState(id, currentState, newState,
-            messageType);
+        return participantHandler.getControlLoopHandler().updateControlLoopElementState(id, currentState, newState);
     }
 
     @Override
index 2941e9f..79d6262 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -42,6 +43,7 @@ import org.springframework.stereotype.Component;
 @Component
 public class ParticipantMessagePublisher implements Publisher {
     private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantMessagePublisher.class);
+    private static final String NOT_ACTIVE_TEXT = "Not Active!";
 
     private boolean active = false;
     private TopicSinkClient topicSinkClient;
@@ -67,7 +69,7 @@ public class ParticipantMessagePublisher implements Publisher {
      */
     public void sendParticipantStatus(final ParticipantStatus participantStatus) {
         if (!active) {
-            throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, "Not Active!");
+            throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
         }
         topicSinkClient.send(participantStatus);
         LOGGER.debug("Sent Participant Status message to CLAMP - {}", participantStatus);
@@ -80,7 +82,7 @@ public class ParticipantMessagePublisher implements Publisher {
      */
     public void sendParticipantRegister(final ParticipantRegister participantRegister) {
         if (!active) {
-            throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, "Not Active!");
+            throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
         }
         topicSinkClient.send(participantRegister);
         LOGGER.debug("Sent Participant Register message to CLAMP - {}", participantRegister);
@@ -93,7 +95,7 @@ public class ParticipantMessagePublisher implements Publisher {
      */
     public void sendParticipantDeregister(final ParticipantDeregister participantDeregister) {
         if (!active) {
-            throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, "Not Active!");
+            throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
         }
         topicSinkClient.send(participantDeregister);
         LOGGER.debug("Sent Participant Deregister message to CLAMP - {}", participantDeregister);
@@ -106,7 +108,7 @@ public class ParticipantMessagePublisher implements Publisher {
      */
     public void sendParticipantUpdateAck(final ParticipantUpdateAck participantUpdateAck) {
         if (!active) {
-            throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, "Not Active!");
+            throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
         }
         topicSinkClient.send(participantUpdateAck);
         LOGGER.debug("Sent Participant Update Ack message to CLAMP - {}", participantUpdateAck);
@@ -119,7 +121,7 @@ public class ParticipantMessagePublisher implements Publisher {
      */
     public void sendControlLoopAck(final ControlLoopAck controlLoopAck) {
         if (!active) {
-            throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, "Not Active!");
+            throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
         }
         topicSinkClient.send(controlLoopAck);
         LOGGER.debug("Sent ControlLoop Update/StateChange Ack to runtime - {}", controlLoopAck);
@@ -132,7 +134,7 @@ public class ParticipantMessagePublisher implements Publisher {
      */
     public void sendHeartbeat(final ParticipantStatus participantStatus) {
         if (!active) {
-            throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, "Not Active!");
+            throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, NOT_ACTIVE_TEXT);
         }
         topicSinkClient.send(participantStatus);
         LOGGER.debug("Sent Participant heartbeat to CLAMP - {}", participantStatus);
index 8b4c61d..9cd032a 100644 (file)
@@ -1,8 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -98,7 +97,7 @@ public class ControlLoopHandler {
      * @return controlLoopElement the updated controlloop element
      */
     public ControlLoopElement updateControlLoopElementState(UUID id, ControlLoopOrderedState orderedState,
-            ControlLoopState newState, ParticipantMessageType messageType) {
+            ControlLoopState newState) {
 
         if (id == null) {
             LOGGER.warn("Cannot update Control loop element state, id is null");
index 74b5394..fbfc1de 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  * Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -500,7 +501,7 @@ public class CommissioningProvider {
      *
      * @return true if exists instance properties
      */
-    private Boolean verifyIfInstancePropertiesExists() {
+    private boolean verifyIfInstancePropertiesExists() {
         return clProvider.getNodeTemplates(null, null).stream()
             .anyMatch(nodeTemplate -> nodeTemplate.getKey().getName().contains("_Instance"));
 
index da85b0a..a717726 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  * Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -58,6 +59,8 @@ import org.springframework.stereotype.Component;
 @Component
 @AllArgsConstructor
 public class ControlLoopInstantiationProvider {
+    private static final String INSTANCE_TEXT = "_Instance";
+
     private final ControlLoopProvider controlLoopProvider;
     private final CommissioningProvider commissioningProvider;
     private final SupervisionHandler supervisionHandler;
@@ -350,12 +353,12 @@ public class ControlLoopInstantiationProvider {
 
         int instanceNumber =
             nodeTemplates.stream().map(ToscaNodeTemplate::getName)
-                .filter(name -> name.contains("_Instance")).map(n -> {
-                    String[] defNameArr = n.split("_Instance");
+                .filter(name -> name.contains(INSTANCE_TEXT)).map(n -> {
+                    String[] defNameArr = n.split(INSTANCE_TEXT);
 
                     return Integer.parseInt(defNameArr[1]);
                 }).reduce(0, Math::max);
 
-        return "_Instance" + (instanceNumber + 1);
+        return INSTANCE_TEXT + (instanceNumber + 1);
     }
 }
index d2a85c4..5a8275f 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -186,8 +187,7 @@ public class InstantiationController extends AbstractRestController {
             @RequestHeader(
                 name = REQUEST_ID_NAME,
                 required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
-            @ApiParam(value = "Body of instance properties", required = true) @RequestBody ToscaServiceTemplate body)
-        throws PfModelException {
+            @ApiParam(value = "Body of instance properties", required = true) @RequestBody ToscaServiceTemplate body) {
 
         return ResponseEntity.ok().body(provider.saveInstanceProperties(body));
     }
index c68b7fd..789e4fa 100644 (file)
@@ -1,8 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -217,10 +216,9 @@ public class SupervisionHandler {
      * Supervise a control loop, performing whatever actions need to be performed on the control loop.
      *
      * @param controlLoop the control loop to supervises
-     * @throws PfModelException on accessing models in the database
      * @throws ControlLoopException on supervision errors
      */
-    private void superviseControlLoop(ControlLoop controlLoop) throws ControlLoopException, PfModelException {
+    private void superviseControlLoop(ControlLoop controlLoop) throws ControlLoopException {
         switch (controlLoop.getOrderedState()) {
             case UNINITIALISED:
                 superviseControlLoopUninitialization(controlLoop);
index 5c49b85..3e038f3 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -231,7 +232,7 @@ class CommissioningProviderTest {
 
         mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
 
-        Map<String, Class> sections = Map.of(
+        Map<String, Class<?>> sections = Map.of(
             "all", ToscaServiceTemplate.class,
             "data_types", ToscaDataType.class,
             "capability_types", ToscaCapabilityType.class,
@@ -241,7 +242,7 @@ class CommissioningProviderTest {
             "topology_template", ToscaTopologyTemplate.class,
             "node_templates", List.class);
 
-        for (Map.Entry<String, Class> entry : sections.entrySet()) {
+        for (Map.Entry<String, Class<?>> entry : sections.entrySet()) {
             String returnedServiceTemplateSchema = provider.getToscaServiceTemplateSchema(entry.getKey());
             assertThat(returnedServiceTemplateSchema).isNotNull();
 
index 58ae1f6..4811929 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -176,7 +177,10 @@ class CommissioningControllerTest extends CommonRestController {
             + "/getCommonOrInstanceProperties" + "?common=true&name=ToscaServiceTemplateSimple&version=1.0.0");
         Response rawresp = invocationBuilder.buildGet().invoke();
         assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
+
+        @SuppressWarnings("unchecked")
         Map<String, ToscaNodeTemplate> commonProperties = rawresp.readEntity(Map.class);
+
         assertNotNull(commonProperties);
         assertThat(commonProperties).hasSize(6);
 
index d1aaddc..f136b9f 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -55,10 +56,8 @@ import org.onap.policy.common.utils.coder.YamlJsonTranslator;
 import org.onap.policy.common.utils.resources.ResourceUtils;
 import org.onap.policy.models.base.PfModelException;
 import org.onap.policy.models.provider.PolicyModelsProvider;
-import org.onap.policy.models.provider.PolicyModelsProviderFactory;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.springframework.beans.factory.annotation.Autowired;
 
 /**
  * Class to perform unit test of {@link ControlLoopInstantiationProvider}}.
index 41c55dd..a6756ee 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -28,7 +29,6 @@ import static org.junit.jupiter.api.Assertions.assertNull;
 import javax.ws.rs.client.Entity;
 import javax.ws.rs.client.Invocation;
 import javax.ws.rs.core.Response;
-import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.BeforeEach;
index 3ac6b6f..2fcbf12 100644 (file)
@@ -1,8 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -25,7 +24,6 @@ package org.onap.policy.clamp.controlloop.runtime.monitoring;
 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.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.when;
 
 import java.io.File;
index b31aa8e..f5ab9f2 100644 (file)
@@ -1,8 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation.
- * ================================================================================
- * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -22,7 +21,6 @@
 
 package org.onap.policy.clamp.controlloop.runtime.supervision;
 
-import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.timeout;
index 3bf0138..1b0362d 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2021 Nordix Foundation.
+ *  Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -20,6 +21,8 @@
 
 package org.onap.policy.clamp.controlloop.runtime.supervision.comm;
 
+import static org.assertj.core.api.Assertions.assertThatCode;
+
 import java.time.Instant;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -68,15 +71,12 @@ class SupervisionMessagesTest extends CommonRestController {
     private static final Object lockit = new Object();
     private static final CommInfrastructure INFRA = CommInfrastructure.NOOP;
     private static final String TOPIC = "my-topic";
-    private static final long interval = 1000;
     private static SupervisionHandler supervisionHandler;
     private static CommissioningProvider commissioningProvider;
     private static ControlLoopProvider clProvider;
     private static PolicyModelsProvider modelsProvider;
     private static ParticipantProvider participantProvider;
     private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
-    private static final String TOSCA_TEMPLATE_YAML =
-            "src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml";
     private static final String CONTROL_LOOP_ELEMENT = "org.onap.policy.clamp.controlloop.ControlLoopElement";
     private static final Coder CODER = new StandardCoder();
 
@@ -132,7 +132,8 @@ class SupervisionMessagesTest extends CommonRestController {
 
             // List<ToscaNodeTemplate> listOfTemplates = commissioningProvider.getControlLoopDefinitions(null, null);
             commissioningProvider.createControlLoopDefinitions(serviceTemplate);
-            participantRegisterListener.onTopicEvent(INFRA, TOPIC, null, participantRegisterMsg);
+            assertThatCode(() -> participantRegisterListener.onTopicEvent(INFRA, TOPIC, null, participantRegisterMsg))
+                            .doesNotThrowAnyException();
         }
     }
 
@@ -146,7 +147,7 @@ class SupervisionMessagesTest extends CommonRestController {
         synchronized (lockit) {
             ParticipantRegisterAckPublisher clRegisterAckPublisher = new ParticipantRegisterAckPublisher();
             clRegisterAckPublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
-            clRegisterAckPublisher.send(participantRegisterAckMsg);
+            assertThatCode(() -> clRegisterAckPublisher.send(participantRegisterAckMsg)).doesNotThrowAnyException();
         }
     }
 
@@ -159,8 +160,9 @@ class SupervisionMessagesTest extends CommonRestController {
 
         synchronized (lockit) {
             ParticipantDeregisterListener participantDeregisterListener =
-                    new ParticipantDeregisterListener(supervisionHandler);
-            participantDeregisterListener.onTopicEvent(INFRA, TOPIC, null, participantDeregisterMsg);
+                            new ParticipantDeregisterListener(supervisionHandler);
+            assertThatCode(() -> participantDeregisterListener.onTopicEvent(INFRA, TOPIC, null,
+                            participantDeregisterMsg)).doesNotThrowAnyException();
         }
     }
 
@@ -174,7 +176,7 @@ class SupervisionMessagesTest extends CommonRestController {
         synchronized (lockit) {
             ParticipantDeregisterAckPublisher clDeregisterAckPublisher = new ParticipantDeregisterAckPublisher();
             clDeregisterAckPublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
-            clDeregisterAckPublisher.send(participantDeregisterAckMsg);
+            assertThatCode(() -> clDeregisterAckPublisher.send(participantDeregisterAckMsg)).doesNotThrowAnyException();
         }
     }
 
@@ -210,7 +212,7 @@ class SupervisionMessagesTest extends CommonRestController {
             ParticipantUpdatePublisher participantUpdatePublisher =
                 new ParticipantUpdatePublisher(modelsProvider);
             participantUpdatePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
-            participantUpdatePublisher.send(participantUpdateMsg);
+            assertThatCode(() -> participantUpdatePublisher.send(participantUpdateMsg)).doesNotThrowAnyException();
         }
     }
 
@@ -260,8 +262,9 @@ class SupervisionMessagesTest extends CommonRestController {
 
         synchronized (lockit) {
             ParticipantUpdateAckListener participantUpdateAckListener =
-                    new ParticipantUpdateAckListener(supervisionHandler);
-            participantUpdateAckListener.onTopicEvent(INFRA, TOPIC, null, participantUpdateAckMsg);
+                            new ParticipantUpdateAckListener(supervisionHandler);
+            assertThatCode(() -> participantUpdateAckListener.onTopicEvent(INFRA, TOPIC, null, participantUpdateAckMsg))
+                            .doesNotThrowAnyException();
         }
     }