summaryrefslogtreecommitdiffstats
path: root/components/slice-analysis-ms
diff options
context:
space:
mode:
authordenilson.l65 <denilson.l65@wipro.com>2021-03-24 01:38:53 -0700
committerdenilson.l65 <denilson.l65@wipro.com>2021-03-29 04:21:47 -0700
commitcb9221b9e2afdf363b97c2cf60d1dbd1195ea196 (patch)
tree7037c108aa2d1102e5fb7ded17a0fc195a77088b /components/slice-analysis-ms
parenta652db5d8c8fb8a353893cf0e8c811cf0f3448e6 (diff)
Increase code coverage
Issue-ID: DCAEGEN2-2695 Signed-off-by: denilson.l65 <denilson.l65@wipro.com> Change-Id: I256ec691bfc967085e2d7335df43701251607c56
Diffstat (limited to 'components/slice-analysis-ms')
-rw-r--r--components/slice-analysis-ms/pom.xml44
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/controller/HealthCheckTest.java40
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/data/beans/PerformanceNotificationsTest.java32
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigPolicyTest.java21
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigurationTest.java46
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/MLOutputModelTest.java49
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ModelsTest.java57
-rw-r--r--components/slice-analysis-ms/version.properties4
8 files changed, 193 insertions, 100 deletions
diff --git a/components/slice-analysis-ms/pom.xml b/components/slice-analysis-ms/pom.xml
index 0c68fed2..e3485872 100644
--- a/components/slice-analysis-ms/pom.xml
+++ b/components/slice-analysis-ms/pom.xml
@@ -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.
@@ -29,14 +29,12 @@
<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>
@@ -109,7 +106,6 @@
<artifactId>cbs-client</artifactId>
<version>${sdk.version}</version>
</dependency>
-
<dependency>
<groupId>org.onap.dcaegen2.services.sdk.security.crypt</groupId>
<artifactId>crypt-password</artifactId>
@@ -197,11 +193,11 @@
<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>
@@ -227,19 +223,16 @@
<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>
@@ -275,11 +268,16 @@
<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>
@@ -297,7 +295,6 @@
<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>
@@ -333,5 +330,4 @@
</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
index 00000000..806eb752
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/controller/HealthCheckTest.java
@@ -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());
+ }
+}
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/data/beans/PerformanceNotificationsTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/data/beans/PerformanceNotificationsTest.java
index e8654003..e55fba74 100644
--- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/data/beans/PerformanceNotificationsTest.java
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/data/beans/PerformanceNotificationsTest.java
@@ -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.
@@ -18,26 +18,24 @@
* ============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());
+}
}
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigPolicyTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigPolicyTest.java
index 2b137e3a..899ee0d8 100644
--- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigPolicyTest.java
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigPolicyTest.java
@@ -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.
@@ -18,26 +18,27 @@
* ============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());
+ }
}
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigurationTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigurationTest.java
index eb492800..ed583cad 100644
--- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigurationTest.java
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigurationTest.java
@@ -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.
@@ -18,30 +18,20 @@
* ============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
index 00000000..4b656b83
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/MLOutputModelTest.java
@@ -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());
+ }
+}
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ModelsTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ModelsTest.java
index 582abdce..3150fb5c 100644
--- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ModelsTest.java
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ModelsTest.java
@@ -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.
@@ -18,11 +18,8 @@
* ============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);
- }
+ }
}
diff --git a/components/slice-analysis-ms/version.properties b/components/slice-analysis-ms/version.properties
index a4b5afab..a2c346b8 100644
--- a/components/slice-analysis-ms/version.properties
+++ b/components/slice-analysis-ms/version.properties
@@ -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