diff options
author | Sirisha_Manchikanti <sirisha.manchikanti@est.tech> | 2021-11-02 05:35:12 +0000 |
---|---|---|
committer | Sirisha_Manchikanti <sirisha.manchikanti@est.tech> | 2021-11-02 06:05:15 +0000 |
commit | a48252db26e2ccd031ddb2046d87737d47c248a6 (patch) | |
tree | 69c6a7e25f1a5b67d0c1d598949d0b6ad815f41a /models | |
parent | 9a49920ac001f76d796cbffce823abd7c0c7d9e2 (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 'models')
4 files changed, 6 insertions, 9 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java index 4d3d37236..cf22b7228 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoop.java @@ -107,7 +107,7 @@ public class ControlLoop extends ToscaEntity implements Comparable<ControlLoop> */ public List<ClElementStatistics> getControlLoopElementStatisticsList(final ControlLoop controlLoop) { if (MapUtils.isEmpty(controlLoop.elements)) { - return null; + return List.of(); } return controlLoop.elements.values().stream().map(ControlLoopElement::getClElementStatistics) diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimedResponse.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimedResponse.java index 993c6e592..4d2dfaf01 100644 --- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimedResponse.java +++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/ControlLoopPrimedResponse.java @@ -24,8 +24,6 @@ import java.util.List; import lombok.Getter; import lombok.Setter; import lombok.ToString; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState; -import org.onap.policy.clamp.controlloop.models.messages.rest.GenericNameVersion; import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse; diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopTest.java index 51a4fc7ae..d9c518b53 100644 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopTest.java +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/concepts/ControlLoopTest.java @@ -107,7 +107,7 @@ class ControlLoopTest { void testControlLoopElementStatisticsList() { var cl = new ControlLoop(); List<ClElementStatistics> emptylist = cl.getControlLoopElementStatisticsList(cl); - assertNull(emptylist); + assertEquals(List.of(), emptylist); var cl1 = getControlLoopTest(); List<ClElementStatistics> list = cl1.getControlLoopElementStatisticsList(cl1); diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ServiceTemplateProviderTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ServiceTemplateProviderTest.java index a4cbbfb0b..7f2731abf 100644 --- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ServiceTemplateProviderTest.java +++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ServiceTemplateProviderTest.java @@ -25,7 +25,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -78,7 +77,7 @@ class ServiceTemplateProviderTest { var serviceTemplateProvider = new ServiceTemplateProvider(modelsProvider); var serviceTemplate = new ToscaServiceTemplate(); - when(modelsProvider.createServiceTemplate(eq(serviceTemplate))).thenReturn(serviceTemplate); + when(modelsProvider.createServiceTemplate(serviceTemplate)).thenReturn(serviceTemplate); var result = serviceTemplateProvider.createServiceTemplate(serviceTemplate); @@ -91,7 +90,7 @@ class ServiceTemplateProviderTest { serviceTemplate.setName("Name"); serviceTemplate.setVersion("1.0.0"); var modelsProvider = mock(PolicyModelsProvider.class); - when(modelsProvider.deleteServiceTemplate(eq(serviceTemplate.getName()), eq(serviceTemplate.getVersion()))) + when(modelsProvider.deleteServiceTemplate(serviceTemplate.getName(), serviceTemplate.getVersion())) .thenReturn(serviceTemplate); var serviceTemplateProvider = new ServiceTemplateProvider(modelsProvider); @@ -117,7 +116,7 @@ class ServiceTemplateProviderTest { serviceTemplate.setName("Name"); serviceTemplate.setVersion("1.0.0"); var modelsProvider = mock(PolicyModelsProvider.class); - when(modelsProvider.getServiceTemplateList(eq(serviceTemplate.getName()), eq(serviceTemplate.getVersion()))) + when(modelsProvider.getServiceTemplateList(serviceTemplate.getName(), serviceTemplate.getVersion())) .thenReturn(List.of(serviceTemplate)); var serviceTemplateProvider = new ServiceTemplateProvider(modelsProvider); @@ -133,7 +132,7 @@ class ServiceTemplateProviderTest { serviceTemplate.setName("Name"); serviceTemplate.setVersion("1.0.0"); var modelsProvider = mock(PolicyModelsProvider.class); - when(modelsProvider.getServiceTemplateList(eq(serviceTemplate.getName()), eq(serviceTemplate.getVersion()))) + when(modelsProvider.getServiceTemplateList(serviceTemplate.getName(), serviceTemplate.getVersion())) .thenReturn(List.of(serviceTemplate)); var serviceTemplateProvider = new ServiceTemplateProvider(modelsProvider); |