diff options
Diffstat (limited to 'components/slice-analysis-ms/src/test')
17 files changed, 1529 insertions, 285 deletions
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/aai/AaiInterfaceServiceTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/aai/AaiInterfaceServiceTest.java new file mode 100644 index 00000000..31264e8c --- /dev/null +++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/aai/AaiInterfaceServiceTest.java @@ -0,0 +1,284 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2021-2022 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.aai; + +import static org.junit.Assert.assertEquals; + +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.slice.analysis.ms.models.Configuration; +import org.onap.slice.analysis.ms.restclients.AaiRestClient; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.modules.junit4.PowerMockRunnerDelegate; +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(PowerMockRunner.class) +@PowerMockRunnerDelegate(SpringRunner.class) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*"}) +@PrepareForTest({AaiService.class, Configuration.class}) +@SpringBootTest(classes = AaiInterfaceServiceTest.class) +public class AaiInterfaceServiceTest { + + Configuration configuration = Configuration.getInstance(); + + @InjectMocks + AaiService aaiService; + + @Mock + AaiRestClient restClient; + + @Test + public void fetchCurrentConfigurationOfSlice() { + configuration.setAaiUrl("http://aai:30233/aai/v21/business/customers/customer/"); + PowerMockito.mockStatic(AaiService.class); + PowerMockito.mockStatic(Configuration.class); + PowerMockito.when(Configuration.getInstance()).thenReturn(configuration); + Map<String, Integer> responsemap = new HashMap<>(); + responsemap.put("dLThptPerSlice", 60); + responsemap.put("uLThptPerSlice", 54); + try { + String serviceInstance = + new String(Files.readAllBytes(Paths.get("src/test/resources/aaiDetailsList.json"))); + Mockito.when(restClient.sendGetRequest(Mockito.anyString(), Mockito.any())) + .thenReturn(new ResponseEntity<Object>(serviceInstance, HttpStatus.OK)); + + } catch (Exception e) { + e.printStackTrace(); + + } + assertEquals(responsemap, aaiService.fetchCurrentConfigurationOfSlice("001-010000")); + } + + @Test + public void fetchServiceProfile() { + Map<String, String> responseMap = new HashMap<String, String>(); + responseMap.put("sNSSAI", "001-00110"); + responseMap.put("ranNFNSSIId", "4b889f2b-8ee4-4ec7-881f-5b1af8a74039"); + responseMap.put("sliceProfileId", "ab9af40f13f7219099333"); + responseMap.put("globalSubscriberId", "5GCustomer"); + responseMap.put("subscriptionServiceType", "5G"); + + try { + String serviceInstance = + new String(Files.readAllBytes(Paths.get("src/test/resources/aaiDetailsList.json"))); + Mockito.when(restClient.sendGetRequest(Mockito.anyString(), Mockito.any())) + .thenReturn(new ResponseEntity<Object>(serviceInstance, HttpStatus.OK)); + + } catch (Exception e) { + e.printStackTrace(); + + } + + assertEquals(responseMap, aaiService.fetchServiceDetails("001-00110")); + } + + @Test + public void fetchSubscriberAndSubscriptionServiceTypeTest() throws Exception { + + configuration.setAaiUrl("http://aai:30233/aai/v21"); + Map<String, String> expectedResponse = new HashMap<String, String>(); + expectedResponse.put("globalSubscriberId", "5GCustomer"); + expectedResponse.put("subscriptionServiceType", "5G"); + PowerMockito.mockStatic(AaiService.class); + PowerMockito.mockStatic(Configuration.class); + PowerMockito.when(Configuration.getInstance()).thenReturn(configuration); + + try { + + String serviceInstance = + new String(Files.readAllBytes(Paths.get("src/test/resources/aaiDetailsList.json"))); + Mockito.when(restClient.sendGetRequest(Mockito.anyString(), Mockito.any())) + .thenReturn(new ResponseEntity<Object>(serviceInstance, HttpStatus.OK)); + + } catch (Exception e) { + e.printStackTrace(); + } + + Map<String, String> actualResponse = aaiService.fetchSubscriberAndSubscriptionServiceType(); + assertEquals(expectedResponse, actualResponse); + } + + @Test + public void fetchSliceProfilesOfAllotedResourceDataTest() throws Exception { + configuration.setAaiUrl("http://aai:30233/aai/v21"); + List<String> allotedResourceList = new ArrayList<>(); + allotedResourceList.add("530d188d-9087-49af-a44a-90c40e0c2d47"); + List<String> expectedResponse = new ArrayList<>(); + expectedResponse.add("b2ae730f-1d5f-495a-8112-dac017a7348c"); + expectedResponse.add("cad8fa36-2d55-4c12-a92e-1bd551517a0c"); + expectedResponse.add("8d0d698e-77f4-4453-8c09-ae2cbe6a9a04"); + PowerMockito.mockStatic(AaiService.class); + PowerMockito.mockStatic(Configuration.class); + PowerMockito.when(Configuration.getInstance()).thenReturn(configuration); + + try { + + String serviceInstance = + new String(Files.readAllBytes(Paths.get("src/test/resources/alloted-resource.json"))); + Mockito.when(restClient.sendGetRequest(Mockito.anyString(), Mockito.any())) + .thenReturn(new ResponseEntity<Object>(serviceInstance, HttpStatus.OK)); + + } catch (Exception e) { + e.printStackTrace(); + + } + List<String> actualResponse = aaiService.fetchSliceProfilesOfAllotedResourceData(allotedResourceList); + assertEquals(expectedResponse, actualResponse); + } + + @Test + public void fetchSnssaiOfSliceProfileTest() throws Exception { + configuration.setAaiUrl("http://aai:30233/aai/v21"); + List<String> sliceProfileList = new ArrayList<>(); + sliceProfileList.add("b2ae730f-1d5f-495a-8112-dac017a7348c"); + sliceProfileList.add("cad8fa36-2d55-4c12-a92e-1bd551517a0c"); + sliceProfileList.add("8d0d698e-77f4-4453-8c09-ae2cbe6a9a04"); + List<String> expectedResponse = new ArrayList<>(); + expectedResponse.add("01-06E442"); + expectedResponse.add("01-B989BD"); + + PowerMockito.mockStatic(AaiService.class); + PowerMockito.mockStatic(Configuration.class); + PowerMockito.when(Configuration.getInstance()).thenReturn(configuration); + String serviceInstanceUrlAn = "b2ae730f-1d5f-495a-8112-dac017a7348c"; + String serviceInstanceUrlCn = "cad8fa36-2d55-4c12-a92e-1bd551517a0c"; + String serviceInstanceUrlTn = "8d0d698e-77f4-4453-8c09-ae2cbe6a9a04"; + + try { + + String serviceInstanceAn = + new String(Files.readAllBytes(Paths.get("src/test/resources/sliceprofile_an_sa1.json"))); + Mockito.when(restClient.sendGetRequest(Mockito.contains(serviceInstanceUrlAn), Mockito.any())) + .thenReturn(new ResponseEntity<Object>(serviceInstanceAn, HttpStatus.OK)); + + String serviceInstanceCn = + new String(Files.readAllBytes(Paths.get("src/test/resources/sliceprofile_cn_sa1.json"))); + Mockito.when(restClient.sendGetRequest(Mockito.contains(serviceInstanceUrlCn), Mockito.any())) + .thenReturn(new ResponseEntity<Object>(serviceInstanceCn, HttpStatus.OK)); + + String serviceInstanceTn = + new String(Files.readAllBytes(Paths.get("src/test/resources/sliceprofile_tn_sa1.json"))); + Mockito.when(restClient.sendGetRequest(Mockito.contains(serviceInstanceUrlTn), Mockito.any())) + .thenReturn(new ResponseEntity<Object>(serviceInstanceTn, HttpStatus.OK)); + + } catch (Exception e) { + e.printStackTrace(); + + } + List<String> actualResponse = aaiService.fetchSnssaiOfSliceProfile(sliceProfileList); + assertEquals(expectedResponse, actualResponse); + } + + @Test + public void getSnssaiListForNsiTest() throws Exception { + configuration.setAaiUrl("http://aai:30233/aai/v21"); + List<String> expectedResponse = new ArrayList<>(); + expectedResponse.add("01-06E442"); + expectedResponse.add("01-B989BD"); + PowerMockito.mockStatic(AaiService.class); + PowerMockito.mockStatic(Configuration.class); + PowerMockito.when(Configuration.getInstance()).thenReturn(configuration); + + try { + + String allotedResource = + new String(Files.readAllBytes(Paths.get("src/test/resources/alloted-resource.json"))); + Mockito.when( + restClient.sendGetRequest(Mockito.contains("0835fd19-6726-4081-befb-cc8932c47767"), Mockito.any())) + .thenReturn(new ResponseEntity<Object>(allotedResource, HttpStatus.OK)); + + String serviceInstance = new String(Files.readAllBytes(Paths.get("src/test/resources/nsi.json"))); + Mockito.when( + restClient.sendGetRequest(Mockito.contains("09cad94e-fbb8-4c70-9c4d-74ec75e97683"), Mockito.any())) + .thenReturn(new ResponseEntity<Object>(serviceInstance, HttpStatus.OK)); + + String serviceInstanceAn = + new String(Files.readAllBytes(Paths.get("src/test/resources/sliceprofile_an_sa1.json"))); + Mockito.when( + restClient.sendGetRequest(Mockito.contains("b2ae730f-1d5f-495a-8112-dac017a7348c"), Mockito.any())) + .thenReturn(new ResponseEntity<Object>(serviceInstanceAn, HttpStatus.OK)); + + String serviceInstanceCn = + new String(Files.readAllBytes(Paths.get("src/test/resources/sliceprofile_cn_sa1.json"))); + Mockito.when( + restClient.sendGetRequest(Mockito.contains("cad8fa36-2d55-4c12-a92e-1bd551517a0c"), Mockito.any())) + .thenReturn(new ResponseEntity<Object>(serviceInstanceCn, HttpStatus.OK)); + + String serviceInstanceTn = + new String(Files.readAllBytes(Paths.get("src/test/resources/sliceprofile_tn_sa1.json"))); + Mockito.when( + restClient.sendGetRequest(Mockito.contains("8d0d698e-77f4-4453-8c09-ae2cbe6a9a04"), Mockito.any())) + .thenReturn(new ResponseEntity<Object>(serviceInstanceTn, HttpStatus.OK)); + + } catch (Exception e) { + e.printStackTrace(); + + } + List<String> actualResponse = aaiService.getSnssaiList("09cad94e-fbb8-4c70-9c4d-74ec75e97683"); + assertEquals(expectedResponse, actualResponse); + } + + @Test + public void getSnssaiListForNssiTest() throws Exception { + configuration.setAaiUrl("http://aai:30233/aai/v21"); + List<String> expectedResponse = new ArrayList<>(); + expectedResponse.add("01-06E442"); + PowerMockito.mockStatic(AaiService.class); + PowerMockito.mockStatic(Configuration.class); + PowerMockito.when(Configuration.getInstance()).thenReturn(configuration); + try { + + String nssi = new String(Files.readAllBytes(Paths.get("src/test/resources/nssi.json"))); + Mockito.when( + restClient.sendGetRequest(Mockito.contains("50f418a6-804f-4453-bf70-21f0efaf6fcd"), Mockito.any())) + .thenReturn(new ResponseEntity<Object>(nssi, HttpStatus.OK)); + + String serviceInstanceAn = + new String(Files.readAllBytes(Paths.get("src/test/resources/sliceprofile_an_sa1.json"))); + Mockito.when( + restClient.sendGetRequest(Mockito.contains("b2ae730f-1d5f-495a-8112-dac017a7348c"), Mockito.any())) + .thenReturn(new ResponseEntity<Object>(serviceInstanceAn, HttpStatus.OK)); + + } catch (Exception e) { + e.printStackTrace(); + + } + List<String> actualResponse = aaiService.getSnssaiList("50f418a6-804f-4453-bf70-21f0efaf6fcd"); + assertEquals(expectedResponse, actualResponse); + } +} diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/configdb/AaiInterfaceServiceTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/configdb/AaiInterfaceServiceTest.java deleted file mode 100644 index 78607788..00000000 --- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/configdb/AaiInterfaceServiceTest.java +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************* - * ============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.configdb; - -import static org.junit.Assert.assertEquals; - -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.modules.junit4.PowerMockRunnerDelegate; -import org.onap.slice.analysis.ms.models.Configuration; -import org.onap.slice.analysis.ms.models.configdb.CellsModel; -import org.onap.slice.analysis.ms.models.configdb.NetworkFunctionModel; -import org.onap.slice.analysis.ms.restclients.AaiRestClient; -import org.onap.slice.analysis.ms.restclients.ConfigDbRestClient; -import org.onap.slice.analysis.ms.utils.BeanUtil; -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(PowerMockRunner.class) -@PowerMockRunnerDelegate(SpringRunner.class) -@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*"}) -@PrepareForTest({ AaiService.class,Configuration.class }) -@SpringBootTest(classes = AaiInterfaceServiceTest.class) -public class AaiInterfaceServiceTest { - - Configuration configuration = Configuration.getInstance(); - - @InjectMocks - AaiService aaiService; - - @Mock - AaiRestClient restClient; - - @Test - public void fetchCurrentConfigurationOfSlice() { - configuration.setAaiUrl("http://aai:30233/aai/v21/business/customers/customer/"); - PowerMockito.mockStatic(AaiService.class); - PowerMockito.mockStatic(Configuration.class); - PowerMockito.when(Configuration.getInstance()).thenReturn(configuration); - Map<String, Integer> responsemap = new HashMap<>(); - responsemap.put("dLThptPerSlice", 60); - responsemap.put("uLThptPerSlice", 54); - try { - String serviceInstance = new String( - Files.readAllBytes(Paths.get("src/test/resources/aaiDetailsList.json"))); - Mockito.when(restClient.sendGetRequest(Mockito.anyString(), Mockito.any())) - .thenReturn(new ResponseEntity<Object>(serviceInstance, HttpStatus.OK)); - - - } catch (Exception e) { - e.printStackTrace(); - - } - assertEquals(responsemap, aaiService.fetchCurrentConfigurationOfSlice("001-010000")); - } - - @Test - public void fetchServiceProfile() { - Map<String, String> responseMap = new HashMap<String, String>(); - responseMap.put("sNSSAI", "001-00110"); - responseMap.put("ranNFNSSIId", "4b889f2b-8ee4-4ec7-881f-5b1af8a74039"); - responseMap.put("sliceProfileId", "ab9af40f13f7219099333"); - responseMap.put("globalSubscriberId", "5GCustomer"); - responseMap.put("subscriptionServiceType", "5G"); - - try { - String serviceInstance = new String( - Files.readAllBytes(Paths.get("src/test/resources/aaiDetailsList.json"))); - Mockito.when(restClient.sendGetRequest(Mockito.anyString(), Mockito.any())) - .thenReturn(new ResponseEntity<Object>(serviceInstance, HttpStatus.OK)); - - } catch (Exception e) { - e.printStackTrace(); - - } - - assertEquals(responseMap, aaiService.fetchServiceDetails("001-00110")); - } -} - diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/configdb/CpsInterfaceServiceTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/configdb/CpsInterfaceServiceTest.java deleted file mode 100644 index 008736d3..00000000 --- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/configdb/CpsInterfaceServiceTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************* - * ============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.configdb; - -import static org.junit.Assert.assertEquals; - -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.onap.slice.analysis.ms.models.Configuration; -import org.onap.slice.analysis.ms.restclients.CpsRestClient; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.modules.junit4.PowerMockRunnerDelegate; -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(PowerMockRunner.class) -@PowerMockRunnerDelegate(SpringRunner.class) -@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*"}) -@PrepareForTest({ CpsService.class,Configuration.class }) -@SpringBootTest(classes = CpsInterfaceServiceTest.class) -public class CpsInterfaceServiceTest { - @InjectMocks - CpsService cpsService; - - @Mock - CpsRestClient restClient; - - @Test - public void fetchCurrentConfigurationOfRICTest() { - Map<String, Object> map = new HashMap<>(); - map.put("dLThptPerSlice", 10); - map.put("uLThptPerSlice", 10); - map.put("maxNumberOfConns", 10); - Map<String, Map<String, Object>> responseMap = new HashMap<>(); - responseMap.put("11", map); - try { - String serviceInstance = new String( - Files.readAllBytes(Paths.get("src/test/resources/sliceConfig.json"))); - Mockito.when(restClient.sendPostRequest(Mockito.anyString(), Mockito.anyString(), Mockito.any())).thenReturn(new ResponseEntity<>(serviceInstance, HttpStatus.OK)); - } catch (Exception e) { - e.printStackTrace(); - } - assertEquals(responseMap, cpsService.fetchCurrentConfigurationOfRIC("111-1111")); - } - - @Test - public void fetchNetworkFunctionsOfSnssaiTest() { - List<String> responseList=new ArrayList<>(); - responseList.add("22"); - responseList.add("23"); - try { - String serviceInstance = new String( - Files.readAllBytes(Paths.get("src/test/resources/DUList.json"))); - Mockito.when(restClient.sendPostRequest(Mockito.anyString(), Mockito.anyString(), Mockito.any())).thenReturn(new ResponseEntity<>(serviceInstance, HttpStatus.OK)); - } catch (Exception e) { - e.printStackTrace(); - } - assertEquals(responseList, cpsService.fetchNetworkFunctionsOfSnssai("111-1111")); - } - - @Test - public void fetchRICsOfSnssaiTest() { - Map<String,List<String>> responseMap=new HashMap<>(); - List<String> cellslist=new ArrayList<>(); - cellslist.add("1599"); - cellslist.add("1598"); - responseMap.put("11",cellslist); - try { - String serviceInstance = new String( - Files.readAllBytes(Paths.get("src/test/resources/DUCellsList.json"))); - Mockito.when(restClient.sendPostRequest(Mockito.anyString(), Mockito.anyString(), Mockito.any())).thenReturn(new ResponseEntity<>(serviceInstance, HttpStatus.OK)); - } catch (Exception e) { - e.printStackTrace(); - } - assertEquals(responseMap, cpsService.fetchRICsOfSnssai("111-1111")); - } -} diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/controller/SliceConfiguratonTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/controller/SliceConfiguratonTest.java new file mode 100644 index 00000000..b35ecdea --- /dev/null +++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/controller/SliceConfiguratonTest.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2022 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.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.File; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentMatchers; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.slice.analysis.ms.models.SliceConfigRequest; +import org.onap.slice.analysis.ms.models.SliceConfigResponse; +import org.onap.slice.analysis.ms.service.SliceUtilization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; + +@RunWith(SpringRunner.class) +@WebMvcTest(SliceConfiguraton.class) +public class SliceConfiguratonTest { + + @Autowired + private MockMvc mockMvc; + + @MockBean + private SliceUtilization sliceUtilization; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + private static final String UTF8 = StandardCharsets.UTF_8.name(); + + @Test + public void getSnssaiListTest() throws Exception { + SliceConfigRequest sliceConfigRequest = new SliceConfigRequest(); + List<String> sliceIdentifiersList = new ArrayList<>(); + sliceIdentifiersList.add("14559ead-f4fe-4c1c-a94c-8015fad3ea35"); + sliceIdentifiersList.add("14559ead-f4fe-4c1c-a94c-8015fad3ea36"); + sliceConfigRequest.setSliceIdentifiers(sliceIdentifiersList); + List<String> configParamsList = new ArrayList<>(); + configParamsList.add("dLThptPerSlice"); + configParamsList.add("uLThptPerSlice"); + sliceConfigRequest.setConfigParams(configParamsList); + + String executePath = "/api/v1/slices-config"; + String sliceConfigResquestString = + new String(Files.readAllBytes(Paths.get("src/test/resources/sliceConfigRequest.json"))); + ObjectMapper objectMapper = new ObjectMapper(); + SliceConfigResponse sliceConfigResponse = objectMapper + .readValue(new File("src/test/resources/sliceConfigResponse.json"), SliceConfigResponse.class); + Mockito.when(sliceUtilization.getSliceUtilizationData(ArgumentMatchers.any())).thenReturn(sliceConfigResponse); + + mockMvc.perform(get(executePath).contentType(MediaType.APPLICATION_JSON).characterEncoding(UTF8) + .content(objectMapper.writeValueAsString(sliceConfigRequest)).accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().string(objectMapper.writeValueAsString(sliceConfigResponse))); + } +} diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/cps/CpsInterfaceServiceTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/cps/CpsInterfaceServiceTest.java new file mode 100644 index 00000000..0ae7d4f3 --- /dev/null +++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/cps/CpsInterfaceServiceTest.java @@ -0,0 +1,110 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2021-2022 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.cps; + +import static org.junit.Assert.assertEquals; + +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.onap.slice.analysis.ms.models.Configuration; +import org.onap.slice.analysis.ms.restclients.CpsRestClient; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.modules.junit4.PowerMockRunnerDelegate; +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(PowerMockRunner.class) +@PowerMockRunnerDelegate(SpringRunner.class) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*"}) +@PrepareForTest({CpsService.class, Configuration.class}) +@SpringBootTest(classes = CpsInterfaceServiceTest.class) +public class CpsInterfaceServiceTest { + @InjectMocks + CpsService cpsService; + + @Mock + CpsRestClient restClient; + + @Test + public void fetchCurrentConfigurationOfRICTest() { + Map<String, Object> map = new HashMap<>(); + map.put("dLThptPerSlice", 10); + map.put("uLThptPerSlice", 10); + map.put("maxNumberOfConns", 10); + Map<String, Map<String, Object>> responseMap = new HashMap<>(); + responseMap.put("11", map); + try { + String serviceInstance = new String(Files.readAllBytes(Paths.get("src/test/resources/sliceConfig.json"))); + Mockito.when(restClient.sendPostRequest(Mockito.anyString(), Mockito.anyString(), Mockito.any())) + .thenReturn(new ResponseEntity<>(serviceInstance, HttpStatus.OK)); + } catch (Exception e) { + e.printStackTrace(); + } + assertEquals(responseMap, cpsService.fetchCurrentConfigurationOfRIC("111-1111")); + } + + @Test + public void fetchNetworkFunctionsOfSnssaiTest() { + List<String> responseList = new ArrayList<>(); + responseList.add("22"); + responseList.add("23"); + try { + String serviceInstance = new String(Files.readAllBytes(Paths.get("src/test/resources/DUList.json"))); + Mockito.when(restClient.sendPostRequest(Mockito.anyString(), Mockito.anyString(), Mockito.any())) + .thenReturn(new ResponseEntity<>(serviceInstance, HttpStatus.OK)); + } catch (Exception e) { + e.printStackTrace(); + } + assertEquals(responseList, cpsService.fetchNetworkFunctionsOfSnssai("111-1111")); + } + + @Test + public void fetchRICsOfSnssaiTest() { + Map<String, List<String>> responseMap = new HashMap<>(); + List<String> cellslist = new ArrayList<>(); + cellslist.add("1599"); + cellslist.add("1598"); + responseMap.put("11", cellslist); + try { + String serviceInstance = new String(Files.readAllBytes(Paths.get("src/test/resources/DUCellsList.json"))); + Mockito.when(restClient.sendPostRequest(Mockito.anyString(), Mockito.anyString(), Mockito.any())) + .thenReturn(new ResponseEntity<>(serviceInstance, HttpStatus.OK)); + } catch (Exception e) { + e.printStackTrace(); + } + assertEquals(responseMap, cpsService.fetchRICsOfSnssai("111-1111")); + } +} 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 3150fb5c..682bef43 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-2021 Wipro Limited. + * Copyright (C) 2020-2022 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,8 +18,9 @@ * ============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; @@ -29,28 +30,37 @@ 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; + +import org.junit.Test; + public class ModelsTest { @Test public void configDataEqualHashcodeTest() { - EqualsVerifier.simple().forClass(ConfigData.class).verify(); + EqualsVerifier.simple().forClass(ConfigData.class).verify(); } + @Test public void cellCUListEqualHashcodeTest() { - EqualsVerifier.simple().forClass(CellCUList.class).verify(); + EqualsVerifier.simple().forClass(CellCUList.class).verify(); } + @Test public void cuModelEqualHashcodeTest() { - EqualsVerifier.simple().forClass(CUModel.class).verify(); + 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(); + EqualsVerifier.simple().forClass(MeasurementObject.class).verify(); } + @Test public void testGetterSetterSubCounter() { PojoClass pojoclass = PojoClassFactory.getPojoClass(SubCounter.class); @@ -64,34 +74,55 @@ public class ModelsTest { .build(); validator.validate(pojoclass); } + @Test public void testGetterSetterMeasurementObject() { PojoClass pojoclass = PojoClassFactory.getPojoClass(MeasurementObject.class); validateMd(pojoclass); } + @Test public void testGetterSetterCellCUList() { PojoClass pojoclass = PojoClassFactory.getPojoClass(CellCUList.class); validateMd(pojoclass); } + @Test public void testGetterSetterCUModel() { PojoClass pojoclass = PojoClassFactory.getPojoClass(CUModel.class); validateMd(pojoclass); } + @Test public void testGetterSetterConfigData() { PojoClass pojoclass = PojoClassFactory.getPojoClass(ConfigData.class); validateMd(pojoclass); } + + @Test + public void testGetterSetterSliceConfigDetailsModel() { + PojoClass pojoclass = PojoClassFactory.getPojoClass(SliceConfigDetails.class); + validateMd(pojoclass); + } + + @Test + public void testGetterSetterSliceConfigRequestModel() { + PojoClass pojoclass = PojoClassFactory.getPojoClass(SliceConfigRequest.class); + validateMd(pojoclass); + } + + @Test + public void testGetterSetterSliceConfigResponseModel() { + PojoClass pojoclass = PojoClassFactory.getPojoClass(SliceConfigResponse.class); + validateMd(pojoclass); + } + public void validateMd(PojoClass pojoclass) { - Validator validator = ValidatorBuilder + Validator validator = ValidatorBuilder .create() .with(new SetterMustExistRule()) .with(new GetterMustExistRule()) - .with(new SetterTester()) - .with(new GetterTester()) - .build(); + .with(new SetterTester()).with(new GetterTester()).build(); validator.validate(pojoclass); } } diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/MLMessageProcessorTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/MLMessageProcessorTest.java index 6e0d1243..387b5fd0 100644 --- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/MLMessageProcessorTest.java +++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/MLMessageProcessorTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * slice-analysis-ms * ================================================================================ - * Copyright (C) 2020 Wipro Limited. + * Copyright (C) 2020-2022 Wipro Limited. * ============================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,16 @@ package org.onap.slice.analysis.ms.service; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.when; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.anyString; +import static org.mockito.Mockito.anyMap; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; @@ -29,73 +39,71 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.*; - import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.onap.slice.analysis.ms.aai.AaiService; import org.onap.slice.analysis.ms.configdb.IConfigDbService; -import org.onap.slice.analysis.ms.configdb.AaiService; -import org.onap.slice.analysis.ms.configdb.CpsService; +import org.onap.slice.analysis.ms.cps.CpsService; import org.onap.slice.analysis.ms.models.MLOutputModel; import org.onap.slice.analysis.ms.models.policy.AdditionalProperties; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; - @RunWith(SpringRunner.class) @SpringBootTest(classes = MLMessageProcessorTest.class) public class MLMessageProcessorTest { - ObjectMapper obj = new ObjectMapper(); - - @InjectMocks - private MLMessageProcessor mlMessageProcessor; - - @Mock - private IConfigDbService configDbService; + ObjectMapper obj = new ObjectMapper(); + + @InjectMocks + private MLMessageProcessor mlMessageProcessor; + + @Mock + private IConfigDbService configDbService; + + @Mock + AaiService aaiService; + + @Mock + CpsService cpsService; - @Mock - AaiService aaiService; + @Mock + private PolicyService policyService; - @Mock - CpsService cpsService; + @SuppressWarnings({"unchecked"}) + @Test + public void processMLMsgTest() { + MLOutputModel mloutput = null; + MLOutputModel mloutputExp = null; - @Mock - private PolicyService policyService; - - @SuppressWarnings({"unchecked" }) - @Test - public void processMLMsgTest() { - MLOutputModel mloutput = null; - MLOutputModel mloutputExp = null; + Map<String, List<String>> ricToCellMapping = new HashMap<>(); + List<String> myList = new ArrayList<String>(); + myList.add("111"); + myList.add("112"); + ricToCellMapping.put("12", myList); + myList = new ArrayList<String>(); + myList.add("113"); + myList.add("114"); + ricToCellMapping.put("13", myList); - Map<String, List<String>> ricToCellMapping = new HashMap<>(); - List<String> myList = new ArrayList<String>(); - myList.add("111"); - myList.add("112"); - ricToCellMapping.put("12", myList); - myList = new ArrayList<String>(); - myList.add("113"); - myList.add("114"); - ricToCellMapping.put("13", myList); + try { + mloutput = + obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/MLOutputModel1.json"))), + new TypeReference<MLOutputModel>() {}); + mloutputExp = + obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/MLOutputModel.json"))), + new TypeReference<MLOutputModel>() {}); + } catch (IOException e) { + e.printStackTrace(); + } + when(configDbService.fetchRICsOfSnssai("0001-0111")).thenReturn(ricToCellMapping); + AdditionalProperties<MLOutputModel> addProps = new AdditionalProperties<>(); + addProps.setResourceConfig(mloutputExp); + doNothing().when(policyService).sendOnsetMessageToPolicy(anyString(), any(AdditionalProperties.class), + anyMap()); + mlMessageProcessor.processMLMsg(mloutput); + assertEquals(mloutputExp, mloutput); + } - try { - mloutput = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/MLOutputModel1.json"))), new TypeReference<MLOutputModel>(){}); - mloutputExp = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/MLOutputModel.json"))), new TypeReference<MLOutputModel>(){}); - } - catch (IOException e) { - e.printStackTrace(); - } - when(configDbService.fetchRICsOfSnssai("0001-0111")).thenReturn(ricToCellMapping); - AdditionalProperties<MLOutputModel> addProps = new AdditionalProperties<>(); - addProps.setResourceConfig(mloutputExp); - doNothing().when(policyService).sendOnsetMessageToPolicy(anyString(), any(AdditionalProperties.class), anyMap()); - mlMessageProcessor.processMLMsg(mloutput); - assertEquals(mloutputExp, mloutput); - } - } diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/SliceUtilizationTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/SliceUtilizationTest.java new file mode 100644 index 00000000..90202366 --- /dev/null +++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/SliceUtilizationTest.java @@ -0,0 +1,174 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * slice-analysis-ms + * ================================================================================ + * Copyright (C) 2022 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.service; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; + +import org.json.JSONObject; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.slice.analysis.ms.aai.AaiService; +import org.onap.slice.analysis.ms.models.AggregatedConfig; +import org.onap.slice.analysis.ms.models.Configuration; +import org.onap.slice.analysis.ms.models.SliceConfigRequest; +import org.onap.slice.analysis.ms.models.SliceConfigResponse; +import org.onap.slice.analysis.ms.restclients.DesRestClient; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.modules.junit4.PowerMockRunnerDelegate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +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(PowerMockRunner.class) +@PowerMockRunnerDelegate(SpringRunner.class) +@PrepareForTest({SliceUtilization.class, Configuration.class}) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*"}) +@SpringBootTest(classes = SliceUtilizationTest.class) +public class SliceUtilizationTest { + + ObjectMapper objectMapper = new ObjectMapper(); + + Configuration configuration = Configuration.getInstance(); + + @InjectMocks + SliceUtilization sliceUtilization; + + @Mock + AaiService aaiService; + + @Mock + DesRestClient desRestClient; + + @Rule + public ExpectedException exception = ExpectedException.none(); + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void getPmDataTest() throws Exception { + configuration.setDesUrl("http://des:1681/datalake/v1/exposure/pm_data"); + configuration.setPmDataDurationInWeeks(4); + PowerMockito.mockStatic(SliceUtilization.class); + PowerMockito.mockStatic(Configuration.class); + PowerMockito.when(Configuration.getInstance()).thenReturn(configuration); + String pmData = null; + try { + pmData = new String(Files.readAllBytes(Paths.get("src/test/resources/pm_data.json"))); + } catch (Exception e) { + e.printStackTrace(); + + } + Mockito.when(desRestClient.sendPostRequest(Mockito.any(), Mockito.any(), Mockito.any())) + .thenReturn(new ResponseEntity<>(pmData, HttpStatus.OK)); + JSONObject actualResponse = sliceUtilization.getPMData("001-1100"); + assertTrue(actualResponse.has("result")); + + } + + @Test + public void calculateSliceUtilizationTest() throws Exception { + + PowerMockito.mockStatic(SliceUtilization.class); + List<JSONObject> pmDataList = new ArrayList<>(); + String pmData; + try { + pmData = new String(Files.readAllBytes(Paths.get("src/test/resources/pm_data.json"))); + JSONObject pmDataObj = new JSONObject(pmData); + pmDataList.add(pmDataObj); + pmDataList.add(pmDataObj); + pmDataList.add(pmDataObj); + } catch (Exception e) { + e.printStackTrace(); + + } + AggregatedConfig actualResponse = sliceUtilization.calculateSliceUtilization(pmDataList); + assertEquals(190857028, (int) actualResponse.getDLThptPerSlice()); + assertEquals(119285978, (int) actualResponse.getULThptPerSlice()); + } + + @Test + public void getSliceUtilizationDataTest() throws Exception { + + PowerMockito.mockStatic(SliceUtilization.class); + SliceConfigRequest sliceConfigRequest = new SliceConfigRequest(); + List<String> sliceIdentifiersList = new ArrayList<>(); + sliceIdentifiersList.add("14559ead-f4fe-4c1c-a94c-8015fad3ea35"); + sliceIdentifiersList.add("14559ead-f4fe-4c1c-a94c-8015fad3ea36"); + sliceConfigRequest.setSliceIdentifiers(sliceIdentifiersList); + List<String> configParamsList = new ArrayList<>(); + configParamsList.add("dLThptPerSlice"); + configParamsList.add("uLThptPerSlice"); + sliceConfigRequest.setConfigParams(configParamsList); + List<String> snssaiList = new ArrayList<>(); + snssaiList.add("01-06E442"); + snssaiList.add("01-B989BD"); + configuration.setDesUrl("http://des:1681/datalake/v1/exposure/pm_data"); + configuration.setPmDataDurationInWeeks(4); + + PowerMockito.mockStatic(SliceUtilization.class); + PowerMockito.mockStatic(Configuration.class); + PowerMockito.when(Configuration.getInstance()).thenReturn(configuration); + + try { + + Mockito.when(aaiService.getSnssaiList(Mockito.any())).thenReturn(snssaiList); + + String pmData = new String(Files.readAllBytes(Paths.get("src/test/resources/pm_data.json"))); + Mockito.when(desRestClient.sendPostRequest(Mockito.any(), Mockito.any(), Mockito.any())) + .thenReturn(new ResponseEntity<>(pmData, HttpStatus.OK)); + } catch (Exception e) { + e.printStackTrace(); + + } + SliceConfigResponse actualResponse = sliceUtilization.getSliceUtilizationData(sliceConfigRequest); + String actualResponseString = objectMapper.writeValueAsString(actualResponse); + SliceConfigResponse sliceConfigResponse = objectMapper + .readValue(new File("src/test/resources/sliceConfigResponse.json"), SliceConfigResponse.class); + assertEquals(objectMapper.writeValueAsString(sliceConfigResponse), actualResponseString); + } +} diff --git a/components/slice-analysis-ms/src/test/resources/alloted-resource.json b/components/slice-analysis-ms/src/test/resources/alloted-resource.json new file mode 100644 index 00000000..56cfc9f3 --- /dev/null +++ b/components/slice-analysis-ms/src/test/resources/alloted-resource.json @@ -0,0 +1,115 @@ +{ + "service-instance-id":"0835fd19-6726-4081-befb-cc8932c47767", + "service-instance-name":"sa1", + "service-type":"embb", + "service-role":"service-profile", + "environment-context":"01-06E442", + "model-invariant-id":"8b94b147-2233-4e9f-b939-55c1b0e618ac", + "model-version-id":"961ec436-7b16-4d71-9d62-9c4ca5dd94bf", + "resource-version":"1645003055191", + "orchestration-status":"deactivated", + "relationship-list":{ + "relationship":[ + { + "related-to":"service-instance", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/8a6115ef-bbca-48ea-98e2-831a2b0226d2", + "relationship-data":[ + { + "relationship-key":"customer.global-customer-id", + "relationship-value":"5GCustomer" + }, + { + "relationship-key":"service-subscription.service-type", + "relationship-value":"5G" + }, + { + "relationship-key":"service-instance.service-instance-id", + "relationship-value":"8a6115ef-bbca-48ea-98e2-831a2b0226d2" + } + ], + "related-to-property":[ + { + "property-key":"service-instance.service-instance-name", + "property-value":"sa1" + } + ] + }, + { + "related-to":"service-instance", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/b2ae730f-1d5f-495a-8112-dac017a7348c", + "relationship-data":[ + { + "relationship-key":"customer.global-customer-id", + "relationship-value":"5GCustomer" + }, + { + "relationship-key":"service-subscription.service-type", + "relationship-value":"5G" + }, + { + "relationship-key":"service-instance.service-instance-id", + "relationship-value":"b2ae730f-1d5f-495a-8112-dac017a7348c" + } + ], + "related-to-property":[ + { + "property-key":"service-instance.service-instance-name", + "property-value":"sliceprofile_an_sa1" + } + ] + }, + { + "related-to":"service-instance", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/cad8fa36-2d55-4c12-a92e-1bd551517a0c", + "relationship-data":[ + { + "relationship-key":"customer.global-customer-id", + "relationship-value":"5GCustomer" + }, + { + "relationship-key":"service-subscription.service-type", + "relationship-value":"5G" + }, + { + "relationship-key":"service-instance.service-instance-id", + "relationship-value":"cad8fa36-2d55-4c12-a92e-1bd551517a0c" + } + ], + "related-to-property":[ + { + "property-key":"service-instance.service-instance-name", + "property-value":"sliceprofile_cn_sa1" + } + ] + }, + { + "related-to":"service-instance", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/8d0d698e-77f4-4453-8c09-ae2cbe6a9a04", + "relationship-data":[ + { + "relationship-key":"customer.global-customer-id", + "relationship-value":"5GCustomer" + }, + { + "relationship-key":"service-subscription.service-type", + "relationship-value":"5G" + }, + { + "relationship-key":"service-instance.service-instance-id", + "relationship-value":"8d0d698e-77f4-4453-8c09-ae2cbe6a9a04" + } + ], + "related-to-property":[ + { + "property-key":"service-instance.service-instance-name", + "property-value":"sliceprofile_tn_sa1" + } + ] + } + ] + } +} diff --git a/components/slice-analysis-ms/src/test/resources/nsi.json b/components/slice-analysis-ms/src/test/resources/nsi.json new file mode 100644 index 00000000..0ca3e529 --- /dev/null +++ b/components/slice-analysis-ms/src/test/resources/nsi.json @@ -0,0 +1,122 @@ +{ + "service-instance-id":"09cad94e-fbb8-4c70-9c4d-74ec75e97683", + "service-instance-name":"nsi_sa1", + "service-type":"embb", + "service-role":"nsi", + "model-invariant-id":"8a8e6666-6e1e-4f0d-88ee-71b9f12f6399", + "model-version-id":"1938db5a-213e-4ba8-b3a8-b39c66a79562", + "resource-version":"1645003054775", + "orchestration-status":"deactivated", + "service-function":"non-shared", + "relationship-list":{ + "relationship":[ + { + "related-to":"service-instance", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/50f418a6-804f-4453-bf70-21f0efaf6fcd", + "relationship-data":[ + { + "relationship-key":"customer.global-customer-id", + "relationship-value":"5GCustomer" + }, + { + "relationship-key":"service-subscription.service-type", + "relationship-value":"5G" + }, + { + "relationship-key":"service-instance.service-instance-id", + "relationship-value":"50f418a6-804f-4453-bf70-21f0efaf6fcd" + } + ], + "related-to-property":[ + { + "property-key":"service-instance.service-instance-name", + "property-value":"nssi_ansa1" + } + ] + }, + { + "related-to":"service-instance", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/99f24e52-5117-430e-a42d-5f77df3dddef", + "relationship-data":[ + { + "relationship-key":"customer.global-customer-id", + "relationship-value":"5GCustomer" + }, + { + "relationship-key":"service-subscription.service-type", + "relationship-value":"5G" + }, + { + "relationship-key":"service-instance.service-instance-id", + "relationship-value":"99f24e52-5117-430e-a42d-5f77df3dddef" + } + ], + "related-to-property":[ + { + "property-key":"service-instance.service-instance-name", + "property-value":"nssi_cnsa1" + } + ] + }, + { + "related-to":"service-instance", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/23ed8231-016c-4420-be91-c042b68f9ea0", + "relationship-data":[ + { + "relationship-key":"customer.global-customer-id", + "relationship-value":"5GCustomer" + }, + { + "relationship-key":"service-subscription.service-type", + "relationship-value":"5G" + }, + { + "relationship-key":"service-instance.service-instance-id", + "relationship-value":"23ed8231-016c-4420-be91-c042b68f9ea0" + } + ], + "related-to-property":[ + { + "property-key":"service-instance.service-instance-name", + "property-value":"nssi_tnsa1" + } + ] + }, + { + "related-to":"allotted-resource", + "relationship-label":"org.onap.relationships.inventory.Uses", + "related-link":"/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/0835fd19-6726-4081-befb-cc8932c47767/allotted-resources/allotted-resource/530d188d-9087-49af-a44a-90c40e0c2d47", + "relationship-data":[ + { + "relationship-key":"customer.global-customer-id", + "relationship-value":"5GCustomer" + }, + { + "relationship-key":"service-subscription.service-type", + "relationship-value":"5G" + }, + { + "relationship-key":"service-instance.service-instance-id", + "relationship-value":"0835fd19-6726-4081-befb-cc8932c47767" + }, + { + "relationship-key":"allotted-resource.id", + "relationship-value":"530d188d-9087-49af-a44a-90c40e0c2d47" + } + ], + "related-to-property":[ + { + "property-key":"allotted-resource.description" + }, + { + "property-key":"allotted-resource.allotted-resource-name", + "property-value":"Allotted_sa1" + } + ] + } + ] + } +} diff --git a/components/slice-analysis-ms/src/test/resources/nssi.json b/components/slice-analysis-ms/src/test/resources/nssi.json new file mode 100644 index 00000000..42916a70 --- /dev/null +++ b/components/slice-analysis-ms/src/test/resources/nssi.json @@ -0,0 +1,165 @@ +{ + "service-instance-id":"50f418a6-804f-4453-bf70-21f0efaf6fcd", + "service-instance-name":"nssi_ansa1", + "service-type":"embb", + "service-role":"nssi", + "environment-context":"an", + "workload-context":"AN", + "model-invariant-id":"68c76946-95a8-4a15-8100-ea482f31341f", + "model-version-id":"c8c1ba78-b7a2-4d72-a82a-75eb79d95347", + "service-instance-location-id":"39-00", + "resource-version":"1645002869853", + "orchestration-status":"deactivated", + "service-function":"non-shared", + "relationship-list":{ + "relationship":[ + { + "related-to":"service-instance", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/b2ae730f-1d5f-495a-8112-dac017a7348c", + "relationship-data":[ + { + "relationship-key":"customer.global-customer-id", + "relationship-value":"5GCustomer" + }, + { + "relationship-key":"service-subscription.service-type", + "relationship-value":"5G" + }, + { + "relationship-key":"service-instance.service-instance-id", + "relationship-value":"b2ae730f-1d5f-495a-8112-dac017a7348c" + } + ], + "related-to-property":[ + { + "property-key":"service-instance.service-instance-name", + "property-value":"sliceprofile_an_sa1" + } + ] + }, + { + "related-to":"service-instance", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/09cad94e-fbb8-4c70-9c4d-74ec75e97683", + "relationship-data":[ + { + "relationship-key":"customer.global-customer-id", + "relationship-value":"5GCustomer" + }, + { + "relationship-key":"service-subscription.service-type", + "relationship-value":"5G" + }, + { + "relationship-key":"service-instance.service-instance-id", + "relationship-value":"09cad94e-fbb8-4c70-9c4d-74ec75e97683" + } + ], + "related-to-property":[ + { + "property-key":"service-instance.service-instance-name", + "property-value":"nsi_sa1" + } + ] + }, + { + "related-to":"network-route", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/network/network-routes/network-route/450b4494-8f24-4c6b-b0a2-2c8a904bf032", + "relationship-data":[ + { + "relationship-key":"network-route.route-id", + "relationship-value":"450b4494-8f24-4c6b-b0a2-2c8a904bf032" + } + ] + }, + { + "related-to":"network-route", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/network/network-routes/network-route/361b6d8b-ad80-4f55-a8fb-be05cde37d5e", + "relationship-data":[ + { + "relationship-key":"network-route.route-id", + "relationship-value":"361b6d8b-ad80-4f55-a8fb-be05cde37d5e" + } + ] + }, + { + "related-to":"service-instance", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/01dfe2e6-eb8b-4907-bf26-2790a7211a07", + "relationship-data":[ + { + "relationship-key":"customer.global-customer-id", + "relationship-value":"5GCustomer" + }, + { + "relationship-key":"service-subscription.service-type", + "relationship-value":"5G" + }, + { + "relationship-key":"service-instance.service-instance-id", + "relationship-value":"01dfe2e6-eb8b-4907-bf26-2790a7211a07" + } + ], + "related-to-property":[ + { + "property-key":"service-instance.service-instance-name", + "property-value":"nssi_tn_mh_9c6fed98-4ce2-4390-8824-ba7cf921851c" + } + ] + }, + { + "related-to":"service-instance", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/ec4a9f30-f025-4abb-bacd-33bb61bf2aec", + "relationship-data":[ + { + "relationship-key":"customer.global-customer-id", + "relationship-value":"5GCustomer" + }, + { + "relationship-key":"service-subscription.service-type", + "relationship-value":"5G" + }, + { + "relationship-key":"service-instance.service-instance-id", + "relationship-value":"ec4a9f30-f025-4abb-bacd-33bb61bf2aec" + } + ], + "related-to-property":[ + { + "property-key":"service-instance.service-instance-name", + "property-value":"nssi_tn_fh_54aa886f-bb46-474f-96ff-b6f04962a37d" + } + ] + }, + { + "related-to":"service-instance", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/b6085a7b-2b34-48db-8150-70cfdd6f41fc", + "relationship-data":[ + { + "relationship-key":"customer.global-customer-id", + "relationship-value":"5GCustomer" + }, + { + "relationship-key":"service-subscription.service-type", + "relationship-value":"5G" + }, + { + "relationship-key":"service-instance.service-instance-id", + "relationship-value":"b6085a7b-2b34-48db-8150-70cfdd6f41fc" + } + ], + "related-to-property":[ + { + "property-key":"service-instance.service-instance-name", + "property-value":"nssi_an_nf_ff726432-7c66-4afb-a1eb-096b493db635" + } + ] + } + ] + } +} diff --git a/components/slice-analysis-ms/src/test/resources/pm_data.json b/components/slice-analysis-ms/src/test/resources/pm_data.json new file mode 100644 index 00000000..4642e813 --- /dev/null +++ b/components/slice-analysis-ms/src/test/resources/pm_data.json @@ -0,0 +1,17 @@ +{ + "result":[ + { + "measValuesList":"[[\"11220\",\"false\",[[1.0,\"75\"],[2.0,\"84\"]]],[\"11221\",\"false\",[[1.0,\"76\"],[2.0,\"85\"]]],[\"11222\",\"false\",[[1.0,\"90\"],[2.0,\"95\"]]]]", + "sMeasTypesList":"[\"SM.PrbUsedDl.01-06E442\",\"SM.PrbUsedUl.01-06E442\"]" + }, + { + "measValuesList":"[[\"11225\",\"false\",[[1.0,\"175\"],[2.0,\"184\"]]],[\"11224\",\"false\",[[1.0,\"176\"],[2.0,\"185\"]]],[\"11222\",\"false\",[[1.0,\"105\"],[2.0,\"100\"]]]]", + "sMeasTypesList":"[\"SM.PrbUsedDl.01-06E442\",\"SM.PrbUsedUl.01-06E442\"]" + } + ], + "request":{ + "snssai":"SM.PrbUsedDl.001-1100", + "time":"1538478000000" + }, + "result_count":2 +} diff --git a/components/slice-analysis-ms/src/test/resources/sliceConfigRequest.json b/components/slice-analysis-ms/src/test/resources/sliceConfigRequest.json new file mode 100644 index 00000000..133c4a1c --- /dev/null +++ b/components/slice-analysis-ms/src/test/resources/sliceConfigRequest.json @@ -0,0 +1,21 @@ +{ + + "sliceIdentifiers": [ + + "14559ead-f4fe-4c1c-a94c-8015fad3ea35", + + "14559ead-f4fe-4c1c-a94c-8015fad3ea36" + + ], + + "configParams": [ + + "dLThptPerSlice", + + "uLThptPerSlice", + + "maxNumberOfConns" + + ] + +} diff --git a/components/slice-analysis-ms/src/test/resources/sliceConfigResponse.json b/components/slice-analysis-ms/src/test/resources/sliceConfigResponse.json new file mode 100644 index 00000000..c99a92cd --- /dev/null +++ b/components/slice-analysis-ms/src/test/resources/sliceConfigResponse.json @@ -0,0 +1,20 @@ +{ + "sliceConfigDetails":[ + { + "sliceIdentifiers":"14559ead-f4fe-4c1c-a94c-8015fad3ea35", + "aggregatedConfig":{ + "maxNumberOfConns":null, + "dlthptPerSlice":190857028, + "ulthptPerSlice":119285978 + } + }, + { + "sliceIdentifiers":"14559ead-f4fe-4c1c-a94c-8015fad3ea36", + "aggregatedConfig":{ + "maxNumberOfConns":null, + "dlthptPerSlice":190857028, + "ulthptPerSlice":119285978 + } + } + ] +} diff --git a/components/slice-analysis-ms/src/test/resources/sliceprofile_an_sa1.json b/components/slice-analysis-ms/src/test/resources/sliceprofile_an_sa1.json new file mode 100644 index 00000000..aab0d531 --- /dev/null +++ b/components/slice-analysis-ms/src/test/resources/sliceprofile_an_sa1.json @@ -0,0 +1,155 @@ +{ + "service-instance-id":"b2ae730f-1d5f-495a-8112-dac017a7348c", + "service-instance-name":"sliceprofile_an_sa1", + "service-type":"embb", + "service-role":"slice-profile", + "environment-context":"01-06E442", + "workload-context":"AN", + "created-at":"2022-02-16 09:12:27", + "model-invariant-id":"68c76946-95a8-4a15-8100-ea482f31341f", + "model-version-id":"c8c1ba78-b7a2-4d72-a82a-75eb79d95347", + "service-instance-location-id":"39-00", + "resource-version":"1645002869957", + "orchestration-status":"deactivated", + "service-function":"non-shared", + "relationship-list":{ + "relationship":[ + { + "related-to":"service-instance", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/0835fd19-6726-4081-befb-cc8932c47767", + "relationship-data":[ + { + "relationship-key":"customer.global-customer-id", + "relationship-value":"5GCustomer" + }, + { + "relationship-key":"service-subscription.service-type", + "relationship-value":"5G" + }, + { + "relationship-key":"service-instance.service-instance-id", + "relationship-value":"0835fd19-6726-4081-befb-cc8932c47767" + } + ], + "related-to-property":[ + { + "property-key":"service-instance.service-instance-name", + "property-value":"sa1" + } + ] + }, + { + "related-to":"network-route", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/network/network-routes/network-route/361b6d8b-ad80-4f55-a8fb-be05cde37d5e", + "relationship-data":[ + { + "relationship-key":"network-route.route-id", + "relationship-value":"361b6d8b-ad80-4f55-a8fb-be05cde37d5e" + } + ] + }, + { + "related-to":"service-instance", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/29b15561-0d2d-491d-8022-66d19e2175ca", + "relationship-data":[ + { + "relationship-key":"customer.global-customer-id", + "relationship-value":"5GCustomer" + }, + { + "relationship-key":"service-subscription.service-type", + "relationship-value":"5G" + }, + { + "relationship-key":"service-instance.service-instance-id", + "relationship-value":"29b15561-0d2d-491d-8022-66d19e2175ca" + } + ], + "related-to-property":[ + { + "property-key":"service-instance.service-instance-name", + "property-value":"sliceprofile_7bda9caa-4726-4460-bf70-38c598d165e4" + } + ] + }, + { + "related-to":"service-instance", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/50f418a6-804f-4453-bf70-21f0efaf6fcd", + "relationship-data":[ + { + "relationship-key":"customer.global-customer-id", + "relationship-value":"5GCustomer" + }, + { + "relationship-key":"service-subscription.service-type", + "relationship-value":"5G" + }, + { + "relationship-key":"service-instance.service-instance-id", + "relationship-value":"50f418a6-804f-4453-bf70-21f0efaf6fcd" + } + ], + "related-to-property":[ + { + "property-key":"service-instance.service-instance-name", + "property-value":"nssi_ansa1" + } + ] + }, + { + "related-to":"service-instance", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/f08ce80d-0dec-4cbe-934e-197c516cbecc", + "relationship-data":[ + { + "relationship-key":"customer.global-customer-id", + "relationship-value":"5GCustomer" + }, + { + "relationship-key":"service-subscription.service-type", + "relationship-value":"5G" + }, + { + "relationship-key":"service-instance.service-instance-id", + "relationship-value":"f08ce80d-0dec-4cbe-934e-197c516cbecc" + } + ], + "related-to-property":[ + { + "property-key":"service-instance.service-instance-name", + "property-value":"sliceprofile_2b3147bc-4d89-459b-81d4-73c971fb4767" + } + ] + }, + { + "related-to":"service-instance", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/4f2cdc4d-bd1d-466a-bf7a-9d3d3f299dd5", + "relationship-data":[ + { + "relationship-key":"customer.global-customer-id", + "relationship-value":"5GCustomer" + }, + { + "relationship-key":"service-subscription.service-type", + "relationship-value":"5G" + }, + { + "relationship-key":"service-instance.service-instance-id", + "relationship-value":"4f2cdc4d-bd1d-466a-bf7a-9d3d3f299dd5" + } + ], + "related-to-property":[ + { + "property-key":"service-instance.service-instance-name", + "property-value":"sliceprofile_7eed6ea4-d2ae-4319-9613-847cc89cc3ab" + } + ] + } + ] + } +} diff --git a/components/slice-analysis-ms/src/test/resources/sliceprofile_cn_sa1.json b/components/slice-analysis-ms/src/test/resources/sliceprofile_cn_sa1.json new file mode 100644 index 00000000..90c594d7 --- /dev/null +++ b/components/slice-analysis-ms/src/test/resources/sliceprofile_cn_sa1.json @@ -0,0 +1,80 @@ +{ + "service-instance-id":"cad8fa36-2d55-4c12-a92e-1bd551517a0c", + "service-instance-name":"sliceprofile_cn_sa1", + "service-type":"embb", + "service-role":"slice-profile", + "environment-context":"01-06E442", + "workload-context":"CN", + "created-at":"2022-02-16 09:14:30", + "model-invariant-id":"32438b92-1450-4d32-9bb1-9642d08d260e", + "model-version-id":"3cb7b6ad-54a7-4a0f-8e80-d5dcc18f2184", + "service-instance-location-id":"39-00", + "resource-version":"1645002992778", + "orchestration-status":"deactivated", + "service-function":"non-shared", + "relationship-list":{ + "relationship":[ + { + "related-to":"service-instance", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/0835fd19-6726-4081-befb-cc8932c47767", + "relationship-data":[ + { + "relationship-key":"customer.global-customer-id", + "relationship-value":"5GCustomer" + }, + { + "relationship-key":"service-subscription.service-type", + "relationship-value":"5G" + }, + { + "relationship-key":"service-instance.service-instance-id", + "relationship-value":"0835fd19-6726-4081-befb-cc8932c47767" + } + ], + "related-to-property":[ + { + "property-key":"service-instance.service-instance-name", + "property-value":"sa1" + } + ] + }, + { + "related-to":"network-route", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/network/network-routes/network-route/03c281af-f59c-4b3e-a42b-bbc28477e11d", + "relationship-data":[ + { + "relationship-key":"network-route.route-id", + "relationship-value":"03c281af-f59c-4b3e-a42b-bbc28477e11d" + } + ] + }, + { + "related-to":"service-instance", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/99f24e52-5117-430e-a42d-5f77df3dddef", + "relationship-data":[ + { + "relationship-key":"customer.global-customer-id", + "relationship-value":"5GCustomer" + }, + { + "relationship-key":"service-subscription.service-type", + "relationship-value":"5G" + }, + { + "relationship-key":"service-instance.service-instance-id", + "relationship-value":"99f24e52-5117-430e-a42d-5f77df3dddef" + } + ], + "related-to-property":[ + { + "property-key":"service-instance.service-instance-name", + "property-value":"nssi_cnsa1" + } + ] + } + ] + } +} diff --git a/components/slice-analysis-ms/src/test/resources/sliceprofile_tn_sa1.json b/components/slice-analysis-ms/src/test/resources/sliceprofile_tn_sa1.json new file mode 100644 index 00000000..005df5b3 --- /dev/null +++ b/components/slice-analysis-ms/src/test/resources/sliceprofile_tn_sa1.json @@ -0,0 +1,68 @@ +{ + "service-instance-id":"8d0d698e-77f4-4453-8c09-ae2cbe6a9a04", + "service-instance-name":"sliceprofile_tn_sa1", + "service-type":"embb", + "service-role":"slice-profile", + "environment-context":"01-B989BD", + "workload-context":"TN_BH", + "created-at":"2022-02-16 09:16:32", + "model-invariant-id":"60424cf8-591a-4804-b189-9e2251d9d36b", + "model-version-id":"ed5bcf6a-6c0a-4286-96b1-877c5344f91a", + "resource-version":"1645003055020", + "orchestration-status":"deactivated", + "service-function":"non-shared", + "relationship-list":{ + "relationship":[ + { + "related-to":"service-instance", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/0835fd19-6726-4081-befb-cc8932c47767", + "relationship-data":[ + { + "relationship-key":"customer.global-customer-id", + "relationship-value":"5GCustomer" + }, + { + "relationship-key":"service-subscription.service-type", + "relationship-value":"5G" + }, + { + "relationship-key":"service-instance.service-instance-id", + "relationship-value":"0835fd19-6726-4081-befb-cc8932c47767" + } + ], + "related-to-property":[ + { + "property-key":"service-instance.service-instance-name", + "property-value":"sa1" + } + ] + }, + { + "related-to":"service-instance", + "relationship-label":"org.onap.relationships.inventory.ComposedOf", + "related-link":"/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/23ed8231-016c-4420-be91-c042b68f9ea0", + "relationship-data":[ + { + "relationship-key":"customer.global-customer-id", + "relationship-value":"5GCustomer" + }, + { + "relationship-key":"service-subscription.service-type", + "relationship-value":"5G" + }, + { + "relationship-key":"service-instance.service-instance-id", + "relationship-value":"23ed8231-016c-4420-be91-c042b68f9ea0" + } + ], + "related-to-property":[ + { + "property-key":"service-instance.service-instance-name", + "property-value":"nssi_tnsa1" + } + ] + } + ] + } +} |