Increase code coverage 09/119709/3
authordenilson.l65 <denilson.l65@wipro.com>
Wed, 24 Mar 2021 08:38:53 +0000 (01:38 -0700)
committerdenilson.l65 <denilson.l65@wipro.com>
Mon, 29 Mar 2021 11:21:47 +0000 (04:21 -0700)
Issue-ID: DCAEGEN2-2695
Signed-off-by: denilson.l65 <denilson.l65@wipro.com>
Change-Id: I256ec691bfc967085e2d7335df43701251607c56

components/slice-analysis-ms/pom.xml
components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/controller/HealthCheckTest.java [new file with mode: 0644]
components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/data/beans/PerformanceNotificationsTest.java
components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigPolicyTest.java
components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigurationTest.java
components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/MLOutputModelTest.java [new file with mode: 0644]
components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ModelsTest.java
components/slice-analysis-ms/version.properties

index 0c68fed..e348587 100644 (file)
@@ -4,7 +4,7 @@
  *  ============LICENSE_START=======================================================
  *  slice-analysis-ms
  *  ================================================================================
- *   Copyright (C) 2020 Wipro Limited.
+ *   Copyright (C) 2020-2021 Wipro Limited.
  *   ==============================================================================
  *     Licensed under the Apache License, Version 2.0 (the "License");
  *     you may not use this file except in compliance with the License.
         <artifactId>oparent</artifactId>
         <version>2.0.0</version>
     </parent>
-
        <groupId>org.onap.dcaegen2.services.components</groupId>
        <artifactId>slice-analysis-ms</artifactId>
-       <version>1.0.4-SNAPSHOT</version>
+       <version>1.0.5-SNAPSHOT</version>
        <name>dcaegen2-services-slice-analysis-ms</name>
        <description>Network slice PM analyser</description>
         <packaging>jar</packaging>
-
        <properties>
                <java.version>11</java.version>
                <sdk.version>1.1.4</sdk.version>
@@ -54,7 +52,6 @@
                ${project.reporting.outputDirectory}/jacoco-ut/jacoco.xml
                </sonar.coverage.jacoco.xmlReportPaths>
        </properties>
-
        <dependencies>
                 <!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-util -->
                 <dependency>
                        <artifactId>cbs-client</artifactId>
                        <version>${sdk.version}</version>
                </dependency>
-
                <dependency>
                        <groupId>org.onap.dcaegen2.services.sdk.security.crypt</groupId>
                        <artifactId>crypt-password</artifactId>
                        <version>2.21.0</version>
                        <scope>test</scope>
                </dependency>
-           <dependency>
-               <groupId>com.openpojo</groupId>
-               <artifactId>openpojo</artifactId>
-               <version>0.8.10</version>
-           </dependency>
+               <dependency>
+                       <groupId>com.openpojo</groupId>
+                       <artifactId>openpojo</artifactId>
+                       <version>0.8.10</version>
+               </dependency>
                <dependency>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
                        <version>2.0.2</version>
                        <scope>test</scope>
                </dependency>
-
                <dependency>
                    <groupId>org.functionaljava</groupId>
                    <artifactId>functionaljava</artifactId>
                    <version>3.0</version>
-            </dependency>
-
-           <dependency>
-                   <groupId>org.apache.httpcomponents</groupId>
-                   <artifactId>httpclient</artifactId>
-               <version>4.5.7</version>
-           </dependency>
-
+                </dependency>
+               <dependency>
+                       <groupId>org.apache.httpcomponents</groupId>
+                       <artifactId>httpclient</artifactId>
+                       <version>4.5.7</version>
+               </dependency>
            <!-- https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils -->
             <dependency>
                    <groupId>commons-beanutils</groupId>
                    <artifactId>tomcat-embed-core</artifactId>
                   <version>9.0.36</version>
            </dependency>
+           <!-- https://mvnrepository.com/artifact/nl.jqno.equalsverifier/equalsverifier -->
+           <dependency>
+                   <groupId>nl.jqno.equalsverifier</groupId>
+                   <artifactId>equalsverifier</artifactId>
+                    <version>3.5.5</version>
+                    <scope>test</scope>
+          </dependency>
        </dependencies>
-
                <build>
                <plugins>
-
                        <plugin>
                                <groupId>org.springframework.boot</groupId>
                                <artifactId>spring-boot-maven-plugin</artifactId>
                                <artifactId>docker-maven-plugin</artifactId>
                                <configuration>
                                        <serverId>${onap.nexus.dockerregistry.daily}</serverId>
-
                                        <imageName>${onap.nexus.dockerregistry.daily}/${docker.image.name}</imageName>
                                        <imageTags>
                                                 <imageTag>${project.version}-${maven.build.timestamp}Z</imageTag>
                        </plugin>
                </plugins>
        </build>
-
 </project>
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/controller/HealthCheckTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/controller/HealthCheckTest.java
new file mode 100644 (file)
index 0000000..806eb75
--- /dev/null
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2021 Wipro Limited.
+ *   ==============================================================================
+ *     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.slice.analysis.ms.controller;
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.junit4.SpringRunner;
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes=HealthCheck.class)
+public class HealthCheckTest {
+    @Autowired
+    private HealthCheck healthcheck;
+    @Test
+    public void testHealthCheck() {
+       ResponseEntity<HttpStatus> response= new ResponseEntity<>(HttpStatus.OK);
+       assertEquals(response,healthcheck.healthCheck());
+       }
+}
index e865400..e55fba7 100644 (file)
@@ -2,7 +2,7 @@
  *  ============LICENSE_START=======================================================
  *  slice-analysis-ms
  *  ================================================================================
- *   Copyright (C) 2020 Wipro Limited.
+ *   Copyright (C) 2020-2021 Wipro Limited.
  *   ==============================================================================
  *     Licensed under the Apache License, Version 2.0 (the "License");
  *     you may not use this file except in compliance with the License.
  *     ============LICENSE_END=========================================================
  *
  *******************************************************************************/
-
 package org.onap.slice.analysis.ms.data.beans;
-
 import static org.junit.Assert.*;
-
 import java.sql.Timestamp;
-
 import org.junit.Test;
-
 public class PerformanceNotificationsTest {
     private Timestamp createdAt;
-
-       @Test
-       public void test() {
-               
-                PerformanceNotifications performanceNotifications = new PerformanceNotifications();
-                performanceNotifications.setNotification("notification");
-                performanceNotifications.setCreatedAt(createdAt);
-            assertEquals("notification", performanceNotifications.getNotification());
-            assertEquals(createdAt, performanceNotifications.getCreatedAt());  }
-
+    @Test
+    public void methodTest() {
+        PerformanceNotifications performanceNotifications = new PerformanceNotifications();
+        performanceNotifications.setNotification("notification");
+        performanceNotifications.setCreatedAt(createdAt);
+        assertEquals("notification", performanceNotifications.getNotification());
+        assertEquals(createdAt, performanceNotifications.getCreatedAt());
+    }
+    @Test
+    public void constructorTest(){
+       PerformanceNotifications performanceNotification = new PerformanceNotifications("notifications",createdAt);
+       assertEquals("notifications", performanceNotification.getNotification());
+       assertEquals(createdAt, performanceNotification.getCreatedAt());
+}
 }
index 2b137e3..899ee0d 100644 (file)
@@ -2,7 +2,7 @@
  *  ============LICENSE_START=======================================================
  *  slice-analysis-ms
  *  ================================================================================
- *   Copyright (C) 2020 Wipro Limited.
+ *   Copyright (C) 2020-2021 Wipro Limited.
  *   ==============================================================================
  *     Licensed under the Apache License, Version 2.0 (the "License");
  *     you may not use this file except in compliance with the License.
  *     ============LICENSE_END=========================================================
  *
  *******************************************************************************/
-
-
 package org.onap.slice.analysis.ms.models;
-
 import static org.junit.Assert.assertEquals;
-
 import java.util.HashMap;
 import java.util.Map;
-
 import org.junit.Test;
-
-
 public class ConfigPolicyTest {
-
     @Test
     public void configPolicyTest() {
         ConfigPolicy configPolicy = ConfigPolicy.getInstance();
-        Map<String, Object> config = new HashMap<String, Object>();
+        Map<String, Object> config = new HashMap<>();
         config.put("policyName", "pcims_policy");
         configPolicy.setConfig(config);
         assertEquals(config, configPolicy.getConfig());
     }
+    @Test
+    public void toStringTest() {
+        ConfigPolicy configPolicy = ConfigPolicy.getInstance();
+        Map<String, Object> config = new HashMap<String, Object>();
+        config.put("policyName", "pcims_policy");
+        configPolicy.setConfig(config);
+        String expected="ConfigPolicy [config={policyName=pcims_policy}]";
+        assertEquals(expected,configPolicy.toString());
+    }
 }
index eb49280..ed583ca 100644 (file)
@@ -2,7 +2,7 @@
  *  ============LICENSE_START=======================================================
  *  slice-analysis-ms
  *  ================================================================================
- *   Copyright (C) 2020 Wipro Limited.
+ *   Copyright (C) 2020-2021 Wipro Limited.
  *   ==============================================================================
  *     Licensed under the Apache License, Version 2.0 (the "License");
  *     you may not use this file except in compliance with the License.
  *     ============LICENSE_END=========================================================
  *
  *******************************************************************************/
-
-
 package org.onap.slice.analysis.ms.models;
-
 import static org.junit.Assert.assertEquals;
-
 import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
-
 import org.junit.Test;
-
-
 public class ConfigurationTest {
     Configuration configuration = Configuration.getInstance();
-
     @Test
     public void configurationTest() {
-
         List<String> list = new ArrayList<String>();
         list.add("server");
-        Map<String, Object> subscribes = new HashMap<>();
-        
+        Map<String, Object> subscribes = Collections.emptyMap();
         configuration.setStreamsSubscribes(subscribes);
         configuration.setStreamsPublishes(subscribes);
         configuration.setDmaapServers(list);
@@ -56,18 +46,32 @@ public class ConfigurationTest {
         configuration.setPollingInterval(30);
         configuration.setPollingTimeout(100);
         configuration.setConfigDbService("sdnrService");
-     
-        assertEquals("cg", configuration.getCg());
-        assertEquals("cid", configuration.getCid());
+        configuration.setCpsUrl("");
+        configuration.setAaiUrl("");
+        configuration.setConfigDbEnabled(true);
+        configuration.setSamples(10);
+        configuration.setMinPercentageChange(50);
+        configuration.setInitialDelaySeconds(1000);
+        assertEquals(true,configuration.isSecured());
         assertEquals("user", configuration.getAafUsername());
         assertEquals("password", configuration.getAafPassword());
-        assertEquals("user", configuration.getPgUsername());
-        assertEquals("password", configuration.getPgPassword());
-        assertEquals("pg", configuration.getPgHost());
-        assertEquals(5432, configuration.getPgPort());
+        assertEquals(subscribes,configuration.getStreamsSubscribes());
+        assertEquals(subscribes,configuration.getStreamsPublishes());
+        assertEquals("cg", configuration.getCg());
+        assertEquals("cid", configuration.getCid());
         assertEquals(30, configuration.getPollingInterval());
         assertEquals(100, configuration.getPollingTimeout());
-        assertEquals("sdnrService", configuration.getConfigDbService());
+        assertEquals("pg", configuration.getPgHost());
+        assertEquals(5432, configuration.getPgPort());
+        assertEquals("user", configuration.getPgUsername());
+        assertEquals("password", configuration.getPgPassword());
         assertEquals(list, configuration.getDmaapServers());
+        assertEquals("sdnrService", configuration.getConfigDbService());
+        assertEquals("",configuration.getCpsUrl());
+        assertEquals("",configuration.getAaiUrl());
+        assertEquals(true,configuration.getConfigDbEnabled());
+        assertEquals(10,configuration.getSamples());
+        assertEquals(50,configuration.getMinPercentageChange());
+        assertEquals(1000,configuration.getInitialDelaySeconds());
     }
 }
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/MLOutputModelTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/MLOutputModelTest.java
new file mode 100644 (file)
index 0000000..4b656b8
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ *  ============LICENSE_START=======================================================
+ *  slice-analysis-ms
+ *  ================================================================================
+ *   Copyright (C) 2021 Wipro Limited.
+ *   ==============================================================================
+ *     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.slice.analysis.ms.models;
+import static org.junit.Assert.assertEquals;
+import java.util.Collections;
+import java.util.List;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+import nl.jqno.equalsverifier.EqualsVerifier;
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes=MLOutputModelTest.class)
+public class MLOutputModelTest {
+    @InjectMocks
+    private final MLOutputModel mlOutputModel =new MLOutputModel();
+    @Test
+    public void mlOutputModelEqualHashcodeTest() {
+        EqualsVerifier.simple().forClass(MLOutputModel.class).verify();
+    }
+    @Test
+    public void mlOutputModelMethodTest() {
+       List<CUModel> data = Collections.emptyList();
+       mlOutputModel.setSnssai("message");
+       mlOutputModel.setData(data);
+       assertEquals("message",mlOutputModel.getSnssai());
+       assertEquals(data,mlOutputModel.getData());
+       assertEquals("MLOutputModel [snssai=message, data=[]]",mlOutputModel.toString());
+    }
+}
index 582abdc..3150fb5 100644 (file)
@@ -2,7 +2,7 @@
  *  ============LICENSE_START=======================================================
  *  slice-analysis-ms
  *  ================================================================================
- *   Copyright (C) 2020 Wipro Limited.
+ *   Copyright (C) 2020-2021 Wipro Limited.
  *   ==============================================================================
  *     Licensed under the Apache License, Version 2.0 (the "License");
  *     you may not use this file except in compliance with the License.
  *     ============LICENSE_END=========================================================
  *
  *******************************************************************************/
-
 package org.onap.slice.analysis.ms.models;
-
 import org.junit.Test;
-
 import com.openpojo.reflection.PojoClass;
 import com.openpojo.reflection.impl.PojoClassFactory;
 import com.openpojo.validation.Validator;
@@ -32,10 +29,29 @@ 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 nl.jqno.equalsverifier.EqualsVerifier;
 public class ModelsTest {
-       
-       @Test
+    @Test
+    public void configDataEqualHashcodeTest() {
+       EqualsVerifier.simple().forClass(ConfigData.class).verify();
+    }
+    @Test
+    public void cellCUListEqualHashcodeTest() {
+       EqualsVerifier.simple().forClass(CellCUList.class).verify();
+    }
+    @Test
+    public void cuModelEqualHashcodeTest() {
+       EqualsVerifier.simple().forClass(CUModel.class).verify();
+    }
+    @Test
+    public void subCounterEqualHashcodeTest() {
+        EqualsVerifier.simple().forClass(SubCounter.class).verify();
+    }
+    @Test
+    public void measurementObjectEqualHashcodeTest() {
+       EqualsVerifier.simple().forClass(MeasurementObject.class).verify();
+    }
+    @Test
     public void testGetterSetterSubCounter() {
         PojoClass pojoclass = PojoClassFactory.getPojoClass(SubCounter.class);
         Validator validator = ValidatorBuilder
@@ -47,40 +63,29 @@ public class ModelsTest {
                 .with(new EqualsAndHashCodeMatchRule())
                 .build();
         validator.validate(pojoclass);
-    }  
-       
-       @Test
+    }
+    @Test
     public void testGetterSetterMeasurementObject() {
         PojoClass pojoclass = PojoClassFactory.getPojoClass(MeasurementObject.class);
         validateMd(pojoclass);
     }
-       
-       @Test
+    @Test
     public void testGetterSetterCellCUList() {
         PojoClass pojoclass = PojoClassFactory.getPojoClass(CellCUList.class);
         validateMd(pojoclass);
     }
-       
-       @Test
+    @Test
     public void testGetterSetterCUModel() {
         PojoClass pojoclass = PojoClassFactory.getPojoClass(CUModel.class);
         validateMd(pojoclass);
     }
-       
-       @Test
+    @Test
     public void testGetterSetterConfigData() {
         PojoClass pojoclass = PojoClassFactory.getPojoClass(ConfigData.class);
         validateMd(pojoclass);
     }
-       
-       @Test
-    public void testGetterSetterMLOutputModel() {
-        PojoClass pojoclass = PojoClassFactory.getPojoClass(MLOutputModel.class);
-        validateMd(pojoclass);
-    }
-       
-       public void validateMd(PojoClass pojoclass) {
-               Validator validator = ValidatorBuilder
+    public void validateMd(PojoClass pojoclass) {
+       Validator validator = ValidatorBuilder
                 .create()
                 .with(new SetterMustExistRule())
                 .with(new GetterMustExistRule())
@@ -88,5 +93,5 @@ public class ModelsTest {
                 .with(new GetterTester())
                 .build();
         validator.validate(pojoclass);
-       }
+    }
 }
index a4b5afa..a2c346b 100644 (file)
@@ -2,7 +2,7 @@
 #  ============LICENSE_START=======================================================
 #  slice-analysis-ms
 #  ================================================================================
-#   Copyright (C) 2020 Wipro Limited.
+#   Copyright (C) 2020-2021 Wipro Limited.
 #   ==============================================================================
 #     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 @@
 ###############################################################################
 major=1
 minor=0
-patch=4
+patch=5
 base_version=${major}.${minor}.${patch}
 release_version=${base_version}
 snapshot_version=${base_version}-SNAPSHOT