summaryrefslogtreecommitdiffstats
path: root/runtime-controlloop/src
diff options
context:
space:
mode:
authorSirisha_Manchikanti <sirisha.manchikanti@est.tech>2021-11-02 05:35:12 +0000
committerSirisha_Manchikanti <sirisha.manchikanti@est.tech>2021-11-02 06:05:15 +0000
commita48252db26e2ccd031ddb2046d87737d47c248a6 (patch)
tree69c6a7e25f1a5b67d0c1d598949d0b6ad815f41a /runtime-controlloop/src
parent9a49920ac001f76d796cbffce823abd7c0c7d9e2 (diff)
Remove code smells in controlloop runtime
Remove code-smells reported by sonar cloud https://sonarcloud.io/project/issues?id=onap_policy-clamp&resolved=false Issue-ID: POLICY-3540 Signed-off-by: Sirisha_Manchikanti <sirisha.manchikanti@est.tech> Change-Id: I8ed1c4599e7eeebbc3a31e74cea4148eb0435847
Diffstat (limited to 'runtime-controlloop/src')
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java7
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java8
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandlerTest.java17
3 files changed, 12 insertions, 20 deletions
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java
index 5ec6158bd..98ceacc3a 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java
@@ -90,6 +90,7 @@ public class ControlLoopInstantiationProvider {
private final ParticipantProvider participantProvider;
private static final Object lockit = new Object();
+ private static final String ENTRY = "entry ";
/**
* Creates Instance Properties and Control Loop.
@@ -239,7 +240,7 @@ public class ControlLoopInstantiationProvider {
var result = new BeanValidationResult("ControlLoops", controlLoops);
for (ControlLoop controlLoop : controlLoops.getControlLoopList()) {
- var subResult = new BeanValidationResult("entry " + controlLoop.getDefinition().getName(), controlLoop);
+ var subResult = new BeanValidationResult(ENTRY + controlLoop.getDefinition().getName(), controlLoop);
List<ToscaNodeTemplate> toscaNodeTemplates = commissioningProvider.getControlLoopDefinitions(
controlLoop.getDefinition().getName(), controlLoop.getDefinition().getVersion());
@@ -280,7 +281,7 @@ public class ControlLoopInstantiationProvider {
*/
private ValidationResult validateDefinition(Map<String, ToscaConceptIdentifier> definitions,
ToscaConceptIdentifier definition) {
- var result = new BeanValidationResult("entry " + definition.getName(), definition);
+ var result = new BeanValidationResult(ENTRY + definition.getName(), definition);
ToscaConceptIdentifier identifier = definitions.get(definition.getName());
if (identifier == null) {
result.setResult(ValidationStatus.INVALID, "Not FOUND");
@@ -383,7 +384,7 @@ public class ControlLoopInstantiationProvider {
for (ControlLoop controlLoop : controlLoops) {
for (var element : controlLoop.getElements().values()) {
- var subResult = new BeanValidationResult("entry " + element.getDefinition().getName(), element);
+ var subResult = new BeanValidationResult(ENTRY + element.getDefinition().getName(), element);
Participant p = participantMap.get(element.getParticipantId());
if (p == null) {
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java
index 1f6246bd6..802413a6a 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java
@@ -232,12 +232,4 @@ public class MonitoringProvider {
}
return clElementId;
}
-
- public void updateClElementStatistics(List<ClElementStatistics> clElementStatistics) {
- // TODO Auto-generated method stub
- }
-
- public void updateParticipantStatistics(List<ParticipantStatistics> statisticsList) {
- // TODO Auto-generated method stub
- }
}
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandlerTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandlerTest.java
index 0fcf52ab9..bbc4deec1 100644
--- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandlerTest.java
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandlerTest.java
@@ -23,7 +23,6 @@ package org.onap.policy.clamp.controlloop.runtime.supervision;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyList;
-import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -137,7 +136,7 @@ class SupervisionHandlerTest {
participant.setParticipantType(participantType);
var participantProvider = mock(ParticipantProvider.class);
- when(participantProvider.getParticipants(eq(participantId.getName()), eq(participantId.getVersion())))
+ when(participantProvider.getParticipants(participantId.getName(), participantId.getVersion()))
.thenReturn(List.of(participant));
var participantDeregisterMessage = new ParticipantDeregister();
@@ -153,7 +152,7 @@ class SupervisionHandlerTest {
handler.handleParticipantMessage(participantDeregisterMessage);
verify(participantProvider).updateParticipants(anyList());
- verify(participantDeregisterAckPublisher).send(eq(participantDeregisterMessage.getMessageId()));
+ verify(participantDeregisterAckPublisher).send(participantDeregisterMessage.getMessageId());
}
@Test
@@ -177,8 +176,8 @@ class SupervisionHandlerTest {
handler.handleParticipantMessage(participantRegisterMessage);
verify(participantProvider).createParticipants(anyList());
- verify(participantRegisterAckPublisher).send(eq(participantRegisterMessage.getMessageId()), eq(participantId),
- eq(participantType));
+ verify(participantRegisterAckPublisher).send(participantRegisterMessage.getMessageId(), participantId,
+ participantType);
}
@Test
@@ -189,7 +188,7 @@ class SupervisionHandlerTest {
participant.setParticipantType(participantType);
var participantProvider = mock(ParticipantProvider.class);
- when(participantProvider.getParticipants(eq(participantId.getName()), eq(participantId.getVersion())))
+ when(participantProvider.getParticipants(participantId.getName(), participantId.getVersion()))
.thenReturn(List.of(participant));
var participantUpdateAckMessage = new ParticipantUpdateAck();
@@ -235,8 +234,8 @@ class SupervisionHandlerTest {
participantUpdatePublisher);
handler.handleSendCommissionMessage(participantId.getName(), participantId.getVersion());
- verify(participantUpdatePublisher).sendComissioningBroadcast(eq(participantId.getName()),
- eq(participantId.getVersion()));
+ verify(participantUpdatePublisher).sendComissioningBroadcast(participantId.getName(),
+ participantId.getVersion());
}
@Test
@@ -264,7 +263,7 @@ class SupervisionHandlerTest {
var controlLoopStateChangePublisher = mock(ControlLoopStateChangePublisher.class);
- when(controlLoopProvider.getControlLoop(eq(identifier))).thenReturn(controlLoop);
+ when(controlLoopProvider.getControlLoop(identifier)).thenReturn(controlLoop);
var modelsProvider = Mockito.mock(PolicyModelsProvider.class);
when(modelsProvider.getServiceTemplateList(any(), any()))