diff options
author | 2021-03-24 01:38:53 -0700 | |
---|---|---|
committer | 2021-03-29 04:21:47 -0700 | |
commit | cb9221b9e2afdf363b97c2cf60d1dbd1195ea196 (patch) | |
tree | 7037c108aa2d1102e5fb7ded17a0fc195a77088b /components/slice-analysis-ms/src/test | |
parent | a652db5d8c8fb8a353893cf0e8c811cf0f3448e6 (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/src/test')
6 files changed, 171 insertions, 74 deletions
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); - } + } } |