summaryrefslogtreecommitdiffstats
path: root/components/slice-analysis-ms/src/test
diff options
context:
space:
mode:
authordhebeha <dhebeha.mj71@wipro.com>2020-09-08 13:02:32 +0530
committerdhebeha <dhebeha.mj71@wipro.com>2020-09-15 22:11:14 +0530
commit8882e23eedce9e9236e1d979b2056b62dd974d91 (patch)
treeff7bce29e94a814c340df73607b9d0da59a1329a /components/slice-analysis-ms/src/test
parent2c6ad52e8d0e29b8037776fff035f031558cc4b0 (diff)
Add support to consume, process pm message from DB
- Add support for analysing pm data - Add support to trigger closed loop - Add support for configDb Interface Implementation - Add support for Intelligent slicing Issue-ID: DCAEGEN2-2255 Signed-off-by: dhebeha <dhebeha.mj71@wipro.com> Change-Id: I185dbb6da45ae6ee74f0a090e2d604914163588b
Diffstat (limited to 'components/slice-analysis-ms/src/test')
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceServiceTest.java127
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/DmaapClientTest.java51
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/NotificationConsumerTest.java10
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/PolicyDmaapClientTest.java10
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigPolicyTest.java (renamed from components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/beans/ConfigPolicyTest.java)2
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigurationTest.java (renamed from components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/beans/ConfigurationTest.java)2
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ModelsTest.java92
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/pmnotification/PmModelsTest.java106
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/policy/PolicyModelsTest.java69
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/restclients/RestClientTest.java120
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/AverageCalculatorTest.java117
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/MLMessageProcessorTest.java93
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/PmDataQueueTest.java152
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/PmEventProcessorTest.java65
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/PolicyServiceTest.java84
-rw-r--r--components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/SnssaiSamplesProcessorTest.java193
-rw-r--r--components/slice-analysis-ms/src/test/resources/MLOutputModel.json49
-rw-r--r--components/slice-analysis-ms/src/test/resources/MLOutputModel1.json47
-rw-r--r--components/slice-analysis-ms/src/test/resources/appendData.json63
-rw-r--r--components/slice-analysis-ms/src/test/resources/average.json20
-rw-r--r--components/slice-analysis-ms/src/test/resources/config_all.json4
-rw-r--r--components/slice-analysis-ms/src/test/resources/event.json209
-rw-r--r--components/slice-analysis-ms/src/test/resources/eventProcessorOutput.json41
-rw-r--r--components/slice-analysis-ms/src/test/resources/getResponse.json21
-rw-r--r--components/slice-analysis-ms/src/test/resources/measurementObjectList.json42
-rw-r--r--components/slice-analysis-ms/src/test/resources/onsetMessage.json46
-rw-r--r--components/slice-analysis-ms/src/test/resources/ricConfiguration.json10
-rw-r--r--components/slice-analysis-ms/src/test/resources/ricToCellMapping.json4
-rw-r--r--components/slice-analysis-ms/src/test/resources/ricToPrbMap.json10
-rw-r--r--components/slice-analysis-ms/src/test/resources/ricToPrbOutput.json8
-rw-r--r--components/slice-analysis-ms/src/test/resources/ricToThroughputMappingOutput.json10
-rw-r--r--components/slice-analysis-ms/src/test/resources/serviceDetails.json12
-rw-r--r--components/slice-analysis-ms/src/test/resources/sliceMeasurementList.json39
33 files changed, 1890 insertions, 38 deletions
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceServiceTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceServiceTest.java
new file mode 100644
index 00000000..481fee6f
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceServiceTest.java
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * slice-analysis-ms
+ * ================================================================================
+ * Copyright (C) 2020 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.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.configdb.CellsModel;
+import org.onap.slice.analysis.ms.models.configdb.NetworkFunctionModel;
+import org.onap.slice.analysis.ms.restclients.ConfigDbRestClient;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+@RunWith(org.mockito.junit.MockitoJUnitRunner.class)
+public class ConfigDbInterfaceServiceTest {
+
+ @InjectMocks
+ ConfigDbInterfaceService configdbservice;
+
+ @Mock
+ ConfigDbRestClient restclient;
+
+ @Test
+ public void fetchCurrentConfigurationOfSlice() {
+
+ Map<String, Integer> responsemap=new HashMap<>();
+ responsemap.put("dLThptPerSlice", 1);
+ responsemap.put("uLThptPerSlice", 2);
+ Mockito.when(restclient.sendGetRequest(Mockito.anyString(), Mockito.any())).thenReturn(new ResponseEntity<Object>(responsemap, HttpStatus.OK));
+ assertEquals(responsemap, configdbservice.fetchCurrentConfigurationOfSlice("snssai"));
+ }
+
+ @Test
+ public void fetchCurrentConfigurationOfRIC() {
+ Map<String,Integer> map=new HashMap<>();
+ Map<String, Map<String,Integer>> responsemap=new HashMap<>();
+ map.put("dLThptPerSlice", 45);
+ map.put("uLThptPerSlice", 50);
+ responsemap.put("1", map);
+ Mockito.when(restclient.sendGetRequest(Mockito.anyString(), Mockito.any())).thenReturn(new ResponseEntity<Object>(responsemap, HttpStatus.OK));
+ assertEquals(responsemap, configdbservice.fetchCurrentConfigurationOfSlice("snssai"));
+
+ }
+ @Test
+ public void fetchRICsOfSnssai() {
+ Map<String, List<CellsModel>> response=new HashMap<>();
+ List<CellsModel> cellslist=new ArrayList<>();
+ List<CellsModel> cellslist1=new ArrayList<>();
+ CellsModel cellsmodel1=new CellsModel();
+ cellsmodel1.setCellLocalId("1111");
+ CellsModel cellsmodel2=new CellsModel();
+ cellsmodel2.setCellLocalId("2222");
+ cellslist.add(cellsmodel1);
+ cellslist.add(cellsmodel2);
+ response.put("1", cellslist);
+ CellsModel cellsmodel3=new CellsModel();
+ cellsmodel3.setCellLocalId("3333");
+ CellsModel cellsmodel4=new CellsModel();
+ cellsmodel4.setCellLocalId("4444");
+ cellslist1.add(cellsmodel3);
+ cellslist1.add(cellsmodel4);
+ response.put("2", cellslist1);
+ Mockito.when(restclient.sendGetRequest(Mockito.anyString(), Mockito.any())).thenReturn(new ResponseEntity<Object>(response, HttpStatus.OK));
+ List<String> outputlist=new ArrayList<>();
+ outputlist.add("1111");
+ outputlist.add("2222");
+ Map<String,List<String>> output= configdbservice.fetchRICsOfSnssai("snssai");
+ assertEquals(outputlist, output.get("1"));
+
+ }
+
+ @Test
+ public void fetchNetworkFunctionsOfSnssai() {
+
+ List<String> responsemap=new ArrayList<>();
+ List<NetworkFunctionModel> networkfunctionslist=new ArrayList<NetworkFunctionModel>();
+ NetworkFunctionModel nf1=new NetworkFunctionModel();
+ nf1.setgNBDUId("1111");
+ NetworkFunctionModel nf2=new NetworkFunctionModel();
+ nf2.setgNBDUId("2222");
+ NetworkFunctionModel nf3=new NetworkFunctionModel();
+ nf3.setgNBDUId("3333");
+ networkfunctionslist.add(nf1);
+ networkfunctionslist.add(nf2);
+ networkfunctionslist.add(nf3);
+ Mockito.when(restclient.sendGetRequest(Mockito.anyString(), Mockito.any())).thenReturn(new ResponseEntity<Object>(networkfunctionslist, HttpStatus.OK));
+ responsemap=configdbservice.fetchNetworkFunctionsOfSnssai("snssai");
+ assertEquals(3, responsemap.size());
+
+ }
+ public void fetchServiceProfile() {
+ Map<String,String> responseMap=new HashMap<String, String>();
+ responseMap.put("sNSSAI", "001-010");
+ responseMap.put("ranNFNSSIId","1111");
+ responseMap.put("sliceProfileId","2222");
+ responseMap.put("globalSubscriberId","110-345");
+ Mockito.when(restclient.sendGetRequest(Mockito.anyString(), Mockito.any())).thenReturn(new ResponseEntity<Object>(responseMap, HttpStatus.OK));
+ assertEquals(responseMap, configdbservice.fetchServiceDetails("snssai"));
+ }
+}
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/DmaapClientTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/DmaapClientTest.java
index f2420b02..b74056db 100644
--- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/DmaapClientTest.java
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/DmaapClientTest.java
@@ -43,7 +43,7 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-import org.onap.slice.analysis.ms.beans.Configuration;
+import org.onap.slice.analysis.ms.models.Configuration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -54,10 +54,9 @@ public class DmaapClientTest {
@Mock
private CambriaTopicManager topicManager;
-
@InjectMocks
DmaapClient client;
-
+
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
@@ -77,53 +76,53 @@ public class DmaapClientTest {
configuration.setPollingInterval(30);
configuration.setPollingTimeout(100);
configuration.setConfigDbService("sdnrService");
-
+
try {
when(topicManager.getTopics()).thenReturn(topics);
-
+
client=Mockito.mock(DmaapClient.class);
client.initClient();
Mockito.verify(client).initClient();
- // Mockito.verifycreateAndConfigureTopics();
+ // Mockito.verifycreateAndConfigureTopics();
} catch (IOException e) {
e.printStackTrace();
}
}
-
+
@Test
public void startClientTest() {
try {
Configuration configuration = Configuration.getInstance();
String configAllJson = readFromFile("src/test/resources/config_all.json");
- JsonObject configAll = new Gson().fromJson(configAllJson, JsonObject.class);
+ JsonObject configAll = new Gson().fromJson(configAllJson, JsonObject.class);
- JsonObject config = configAll.getAsJsonObject("config");
-
- configuration.updateConfigurationFromJsonObject(config);
+ JsonObject config = configAll.getAsJsonObject("config");
+ System.out.println(configuration);
+ configuration.updateConfigurationFromJsonObject(config);
DmaapClient client= new DmaapClient();
client.initClient();
//Mockito.verify(client).startClient();
- // Mockito.verifycreateAndConfigureTopics();
+ // Mockito.verifycreateAndConfigureTopics();
} catch ( Exception e) {
e.printStackTrace();
}
}
- private static String readFromFile(String file) {
- String content = "";
- try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) {
- content = bufferedReader.readLine();
- String temp;
- while ((temp = bufferedReader.readLine()) != null) {
- content = content.concat(temp);
- }
- content = content.trim();
- } catch (Exception e) {
- content = null;
- }
- return content;
- }
+ private static String readFromFile(String file) {
+ String content = "";
+ try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) {
+ content = bufferedReader.readLine();
+ String temp;
+ while ((temp = bufferedReader.readLine()) != null) {
+ content = content.concat(temp);
+ }
+ content = content.trim();
+ } catch (Exception e) {
+ content = null;
+ }
+ return content;
+ }
}
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/NotificationConsumerTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/NotificationConsumerTest.java
index f4b64397..9aab22c2 100644
--- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/NotificationConsumerTest.java
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/NotificationConsumerTest.java
@@ -21,6 +21,11 @@
package org.onap.slice.analysis.ms.dmaap;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.List;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
@@ -28,11 +33,6 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
import com.att.nsa.cambria.client.CambriaConsumer;
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/PolicyDmaapClientTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/PolicyDmaapClientTest.java
index a458d33c..3ff56ab1 100644
--- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/PolicyDmaapClientTest.java
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/dmaap/PolicyDmaapClientTest.java
@@ -22,10 +22,7 @@
package org.onap.slice.analysis.ms.dmaap;
-import static org.junit.Assert.*;
-
-import com.att.nsa.cambria.client.CambriaBatchingPublisher;
-import com.att.nsa.cambria.client.CambriaConsumer;
+import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.HashMap;
@@ -38,10 +35,13 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.slice.analysis.ms.beans.Configuration;
+import org.onap.slice.analysis.ms.models.Configuration;
import org.onap.slice.analysis.ms.utils.DmaapUtils;
import org.springframework.boot.test.context.SpringBootTest;
+import com.att.nsa.cambria.client.CambriaBatchingPublisher;
+import com.att.nsa.cambria.client.CambriaConsumer;
+
@RunWith(MockitoJUnitRunner.class)
@SpringBootTest(classes = PolicyDmaapClient.class)
public class PolicyDmaapClientTest {
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/beans/ConfigPolicyTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigPolicyTest.java
index 66f97d96..2b137e3a 100644
--- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/beans/ConfigPolicyTest.java
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigPolicyTest.java
@@ -20,7 +20,7 @@
*******************************************************************************/
-package org.onap.slice.analysis.ms.beans;
+package org.onap.slice.analysis.ms.models;
import static org.junit.Assert.assertEquals;
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/beans/ConfigurationTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigurationTest.java
index a3487773..eb492800 100644
--- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/beans/ConfigurationTest.java
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigurationTest.java
@@ -20,7 +20,7 @@
*******************************************************************************/
-package org.onap.slice.analysis.ms.beans;
+package org.onap.slice.analysis.ms.models;
import static org.junit.Assert.assertEquals;
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
new file mode 100644
index 00000000..582abdce
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ModelsTest.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * slice-analysis-ms
+ * ================================================================================
+ * Copyright (C) 2020 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 org.junit.Test;
+
+import com.openpojo.reflection.PojoClass;
+import com.openpojo.reflection.impl.PojoClassFactory;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.rule.impl.EqualsAndHashCodeMatchRule;
+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;
+
+public class ModelsTest {
+
+ @Test
+ public void testGetterSetterSubCounter() {
+ PojoClass pojoclass = PojoClassFactory.getPojoClass(SubCounter.class);
+ Validator validator = ValidatorBuilder
+ .create()
+ .with(new SetterMustExistRule())
+ .with(new GetterMustExistRule())
+ .with(new SetterTester())
+ .with(new GetterTester())
+ .with(new EqualsAndHashCodeMatchRule())
+ .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 testGetterSetterMLOutputModel() {
+ PojoClass pojoclass = PojoClassFactory.getPojoClass(MLOutputModel.class);
+ validateMd(pojoclass);
+ }
+
+ public void validateMd(PojoClass pojoclass) {
+ Validator validator = ValidatorBuilder
+ .create()
+ .with(new SetterMustExistRule())
+ .with(new GetterMustExistRule())
+ .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/models/pmnotification/PmModelsTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/pmnotification/PmModelsTest.java
new file mode 100644
index 00000000..8954ae9b
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/pmnotification/PmModelsTest.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * slice-analysis-ms
+ * ================================================================================
+ * Copyright (C) 2020 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.pmnotification;
+
+import org.junit.Test;
+
+import com.openpojo.reflection.PojoClass;
+import com.openpojo.reflection.impl.PojoClassFactory;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+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;
+
+public class PmModelsTest {
+ @Test
+ public void testGetterSetterCommonEventHeader() {
+ PojoClass pojoclass = PojoClassFactory.getPojoClass(CommonEventHeader.class);
+ validateMd(pojoclass);
+ }
+
+ @Test
+ public void testGetterSetterEvent() {
+ PojoClass pojoclass = PojoClassFactory.getPojoClass(Event.class);
+ validateMd(pojoclass);
+ }
+
+ @Test
+ public void testGetterSetterMeasDataCollection() {
+ PojoClass pojoclass = PojoClassFactory.getPojoClass(MeasDataCollection.class);
+ validateMd(pojoclass);
+ }
+
+ @Test
+ public void testGetterSetterMeasInfoId() {
+ PojoClass pojoclass = PojoClassFactory.getPojoClass(MeasInfoId.class);
+ validateMd(pojoclass);
+ }
+
+ @Test
+ public void testGetterSetterMeasInfoList() {
+ PojoClass pojoclass = PojoClassFactory.getPojoClass(MeasInfoList.class);
+ validateMd(pojoclass);
+ }
+
+ @Test
+ public void testGetterSetterMeasResult() {
+ PojoClass pojoclass = PojoClassFactory.getPojoClass(MeasResult.class);
+ validateMd(pojoclass);
+ }
+
+ @Test
+ public void testGetterSetterMeasTypes() {
+ PojoClass pojoclass = PojoClassFactory.getPojoClass(MeasTypes.class);
+ validateMd(pojoclass);
+ }
+
+ @Test
+ public void testGetterSetterMeasValuesList() {
+ PojoClass pojoclass = PojoClassFactory.getPojoClass(MeasValuesList.class);
+ validateMd(pojoclass);
+ }
+
+ @Test
+ public void testGetterSetterPerf3gppFields() {
+ PojoClass pojoclass = PojoClassFactory.getPojoClass(Perf3gppFields.class);
+ validateMd(pojoclass);
+ }
+
+ @Test
+ public void testGetterSetterPmNotification() {
+ PojoClass pojoclass = PojoClassFactory.getPojoClass(PmNotification.class);
+ validateMd(pojoclass);
+ }
+
+ public void validateMd(PojoClass pojoclass) {
+ Validator validator = ValidatorBuilder
+ .create()
+ .with(new SetterMustExistRule())
+ .with(new GetterMustExistRule())
+ .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/models/policy/PolicyModelsTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/policy/PolicyModelsTest.java
new file mode 100644
index 00000000..958a1f83
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/policy/PolicyModelsTest.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * slice-analysis-ms
+ * ================================================================================
+ * Copyright (C) 2020 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.policy;
+
+import org.junit.Test;
+
+import com.openpojo.reflection.PojoClass;
+import com.openpojo.reflection.impl.PojoClassFactory;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+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;
+
+public class PolicyModelsTest {
+ @Test
+ public void testGetterSetterPayload() {
+ PojoClass pojoclass = PojoClassFactory.getPojoClass(Payload.class);
+ validateMd(pojoclass);
+ }
+
+ @Test
+ public void testGetterSetterAAI() {
+ PojoClass pojoclass = PojoClassFactory.getPojoClass(AAI.class);
+ validateMd(pojoclass);
+ }
+
+ @Test
+ public void testGetterSetterOnsetMessage() {
+ PojoClass pojoclass = PojoClassFactory.getPojoClass(OnsetMessage.class);
+ validateMd(pojoclass);
+ }
+
+ @Test
+ public void testGetterSetterAdditionalProperties() {
+ PojoClass pojoclass = PojoClassFactory.getPojoClass(AdditionalProperties.class);
+ validateMd(pojoclass);
+ }
+
+ public void validateMd(PojoClass pojoclass) {
+ Validator validator = ValidatorBuilder
+ .create()
+ .with(new SetterMustExistRule())
+ .with(new GetterMustExistRule())
+ .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/restclients/RestClientTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/restclients/RestClientTest.java
new file mode 100644
index 00000000..b19b4801
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/restclients/RestClientTest.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * slice-analysis-ms
+ * ================================================================================
+ * Copyright (C) 2020 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.restclients;
+
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Collections;
+import java.util.HashMap;
+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.utils.BeanUtil;
+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.core.ParameterizedTypeReference;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+
+
+
+@RunWith(PowerMockRunner.class)
+@PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*"})
+@PowerMockRunnerDelegate(SpringRunner.class)
+@PrepareForTest({ BeanUtil.class })
+@SpringBootTest(classes = RestClient.class)
+public class RestClientTest {
+
+
+ @Mock
+ RestTemplate restTemplate;
+
+
+ @InjectMocks
+ RestClient restclient;
+
+
+ @SuppressWarnings({ "static-access", "unchecked", "rawtypes" })
+ @Test
+ public void sendGetRequestTest() {
+
+ PowerMockito.mockStatic(BeanUtil.class);
+ PowerMockito.when(BeanUtil.getBean(Mockito.any())).thenReturn(restTemplate);
+ ParameterizedTypeReference<Map<String,Integer>> responseType = null;
+ HttpHeaders headers = new HttpHeaders();
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ HttpEntity<Object> requestEntity = new HttpEntity<>( headers);
+ Map<String, Integer> responsemap=new HashMap<>();
+ responsemap.put("dLThptPerSlice", 1);
+ responsemap.put("uLThptPerSlice", 2);
+ String requestUrl="";
+ PowerMockito.when(restTemplate.exchange(requestUrl, HttpMethod.GET,requestEntity,responseType)).thenReturn(ResponseEntity.ok(responsemap));
+ ResponseEntity<Map<String,Integer>> resp = restclient.sendGetRequest(headers, requestUrl, responseType);
+ assertEquals(resp.getBody(),responsemap);
+ }
+
+ @SuppressWarnings({ "static-access", "unchecked", "rawtypes" })
+ @Test
+ public void sendPostRequestTest() {
+ PowerMockito.mockStatic(BeanUtil.class);
+ PowerMockito.when(BeanUtil.getBean(RestTemplate.class)).thenReturn(restTemplate);
+ ParameterizedTypeReference<String> responseType = null;
+ HttpHeaders headers = new HttpHeaders();
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ String requestUrl = "Url"; String requestBody = null;
+ HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
+ PowerMockito.when(restTemplate.exchange(requestUrl, HttpMethod.POST,requestEntity,responseType)).thenReturn(new ResponseEntity(HttpStatus.OK));
+ ResponseEntity<String> resp = restclient.sendPostRequest(headers, requestUrl, requestBody,responseType);
+ assertEquals(resp.getStatusCode(), HttpStatus.OK);
+ }
+
+ @Test
+ public void sendPostRequestTest2() {
+ ParameterizedTypeReference<String> responseType = null;
+ HttpHeaders headers = new HttpHeaders();
+ headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ String requestUrl = "Url"; String requestBody = null;
+ HttpEntity<Object> requestEntity = new HttpEntity<>(requestBody, headers);
+ PowerMockito.when(restTemplate.exchange(requestUrl, HttpMethod.POST,requestEntity,responseType)).thenReturn(new ResponseEntity(HttpStatus.NOT_FOUND));
+ ResponseEntity<String> resp = restclient.sendPostRequest(headers, requestUrl, requestBody,responseType);
+ assertEquals(resp.getStatusCode(), HttpStatus.NOT_FOUND);
+ }
+
+
+}
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/AverageCalculatorTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/AverageCalculatorTest.java
new file mode 100644
index 00000000..e9c134f7
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/AverageCalculatorTest.java
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * slice-analysis-ms
+ * ================================================================================
+ * Copyright (C) 2020 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 java.io.IOException;
+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.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.onap.slice.analysis.ms.models.MeasurementObject;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.util.ReflectionTestUtils;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = AverageCalculatorTest.class)
+public class AverageCalculatorTest {
+
+ @InjectMocks
+ AverageCalculator averageCalculator;
+
+ @Before
+ public void setup() {
+ List<String> pmNames = new ArrayList<>();
+ pmNames.add("PrbUsedDl");
+ pmNames.add("PrbUsedUl");
+ ReflectionTestUtils.setField(averageCalculator, "pmNames", pmNames);
+ }
+
+ @Test
+ public void findAverageOfSamplesTest() {
+ ObjectMapper obj = new ObjectMapper();
+ List<List<MeasurementObject>> input = null;
+ List<MeasurementObject> output = null;
+ try {
+ input = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/measurementObjectList.json"))), new TypeReference<List<List<MeasurementObject>>>(){});
+ output = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/average.json"))), new TypeReference<List<MeasurementObject>>(){});
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ assertEquals(output, averageCalculator.findAverageOfSamples(input));
+ }
+
+ @Test
+ public void findAvgTest() {
+ List<MeasurementObject> result = new ArrayList<>();
+ Map<String, Integer> pmData = new HashMap<>();
+ pmData.put("PrbUsedDl", 50);
+ pmData.put("PrbUsedUl", 48);
+ result.add(new MeasurementObject("cell11", pmData));
+ pmData.put("PrbUsedDl", 40);
+ pmData.put("PrbUsedUl", 38);
+ result.add(new MeasurementObject("cell12", pmData));
+
+ List<MeasurementObject> exp = new ArrayList<>();
+ pmData.put("PrbUsedDl", 25);
+ pmData.put("PrbUsedUl", 24);
+ exp.add(new MeasurementObject("cell11", pmData));
+ pmData.put("PrbUsedDl", 20);
+ pmData.put("PrbUsedUl", 19);
+ exp.add(new MeasurementObject("cell12", pmData));
+
+ assertEquals(exp, averageCalculator.findAvg(result, 2));
+ }
+
+ @Test
+ public void findAvgSum() {
+ Map<String, Integer> existingMap = new HashMap<>();
+ existingMap.put("PrbUsedDl", 50);
+ existingMap.put("PrbUsedUl", 48);
+
+ Map<String, Integer> currentMap = new HashMap<>();
+ currentMap.put("PrbUsedDl", 40);
+ currentMap.put("PrbUsedUl", 38);
+
+ Map<String, Integer> result = new HashMap<>();
+ result.put("PrbUsedDl", 90);
+ result.put("PrbUsedUl", 86);
+
+ assertEquals(new MeasurementObject("cell1", result),
+ averageCalculator.findSum(new MeasurementObject("cell1", existingMap), new MeasurementObject("cell1", currentMap)));
+ }
+}
+
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
new file mode 100644
index 00000000..d80160c9
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/MLMessageProcessorTest.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * slice-analysis-ms
+ * ================================================================================
+ * Copyright (C) 2020 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 java.io.IOException;
+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 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.configdb.IConfigDbService;
+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;
+
+ @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);
+
+ 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/PmDataQueueTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/PmDataQueueTest.java
new file mode 100644
index 00000000..b2c2243d
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/PmDataQueueTest.java
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * slice-analysis-ms
+ * ================================================================================
+ * Copyright (C) 2020 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 java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.onap.slice.analysis.ms.models.MeasurementObject;
+import org.onap.slice.analysis.ms.models.SubCounter;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.util.ReflectionTestUtils;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = PmDataQueueTest.class)
+public class PmDataQueueTest {
+ ObjectMapper obj = new ObjectMapper();
+
+ @InjectMocks
+ PmDataQueue pmDataQueue;
+
+ @Before
+ public void setup() {
+ Queue<List<MeasurementObject>> measList = null;
+ try {
+ measList = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/measurementObjectList.json"))), new TypeReference<Queue<List<MeasurementObject>>>(){});
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ SubCounter sub1 = new SubCounter("nf1", "nssai1");
+ Map<SubCounter, Queue<List<MeasurementObject>>> subCounterMap = Collections.synchronizedMap(new LinkedHashMap<SubCounter, Queue<List<MeasurementObject>>>());
+ subCounterMap.put(sub1, measList);
+ ReflectionTestUtils.setField(pmDataQueue, "subCounterMap", subCounterMap);
+
+ Queue<String> snssaiList = new LinkedBlockingQueue<>();
+ snssaiList.add("nssai1");
+ snssaiList.add("nssai2");
+ snssaiList.add("nssai3");
+ ReflectionTestUtils.setField(pmDataQueue, "snssaiList", snssaiList);
+
+ }
+
+ @Test
+ public void putDataToQueueSameNssaiTest() {
+ SubCounter sub1 = new SubCounter("nf1", "nssai1");
+ Map<SubCounter, Queue<List<MeasurementObject>>> subCounterMapExp = Collections.synchronizedMap(new LinkedHashMap<SubCounter, Queue<List<MeasurementObject>>>());
+ List<MeasurementObject> measObj = null;
+ Queue<List<MeasurementObject>> measObjExp = null;
+ try {
+ measObj = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/average.json"))), new TypeReference<List<MeasurementObject>>(){});
+ measObjExp = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/appendData.json"))), new TypeReference<Queue<List<MeasurementObject>>>(){});
+
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ subCounterMapExp.put(sub1, measObjExp);
+ pmDataQueue.putDataToQueue(sub1, measObj);
+ assertEquals(subCounterMapExp, ReflectionTestUtils.getField(pmDataQueue, "subCounterMap"));
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void putDataToQueueDiffNssaiTest() {
+ SubCounter sub = new SubCounter("nf1", "nssai1");
+ SubCounter sub1 = new SubCounter("nf1", "nssai2");
+ Map<SubCounter, Queue<List<MeasurementObject>>> subCounterMapExp = Collections.synchronizedMap(new LinkedHashMap<SubCounter, Queue<List<MeasurementObject>>>());
+ List<MeasurementObject> measObj = null;
+ Queue<List<MeasurementObject>> measObjExp = null;
+ Queue<List<MeasurementObject>> measObjExp1 = new LinkedBlockingQueue<>();
+ try {
+ measObj = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/average.json"))), new TypeReference<List<MeasurementObject>>(){});
+ measObjExp = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/measurementObjectList.json"))), new TypeReference<Queue<List<MeasurementObject>>>(){});
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ measObjExp1.add(measObj);
+ subCounterMapExp.put(sub, measObjExp);
+ subCounterMapExp.put(sub1, measObjExp1);
+ pmDataQueue.putDataToQueue(sub1, measObj);
+ assertEquals(subCounterMapExp.get(sub), ((Map<SubCounter,Queue<List<MeasurementObject>>>) ReflectionTestUtils.getField(pmDataQueue, "subCounterMap")).get(sub));
+ assertEquals(subCounterMapExp.get(sub1).contains(measObj), ((Map<SubCounter,Queue<List<MeasurementObject>>>) ReflectionTestUtils.getField(pmDataQueue, "subCounterMap")).get(sub1).contains(measObj));
+ }
+
+ @Test
+ public void getSamplesFromQueueTest() {
+ SubCounter sub = new SubCounter("nf1", "nssai1");
+ List<List<MeasurementObject>> measObj = null;
+ try {
+ measObj = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/getResponse.json"))), new TypeReference<List<List<MeasurementObject>>>(){});
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ assertEquals(measObj, pmDataQueue.getSamplesFromQueue(sub, 1));
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void putSnssaiToQueueTest() {
+ pmDataQueue.putSnssaiToQueue("nssai1");
+ assertEquals(3, ((Queue<String>)ReflectionTestUtils.getField(pmDataQueue, "snssaiList")).size());
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void putNewSnssaiToQueueTest() {
+ pmDataQueue.putSnssaiToQueue("nssai9");
+ assertEquals(4, ((Queue<String>)ReflectionTestUtils.getField(pmDataQueue, "snssaiList")).size());
+ }
+
+ @Test
+ public void getSnnsaiFromQueueTest() {
+ assertEquals("nssai1", pmDataQueue.getSnnsaiFromQueue());
+ }
+}
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/PmEventProcessorTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/PmEventProcessorTest.java
new file mode 100644
index 00000000..ae4f5471
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/PmEventProcessorTest.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * slice-analysis-ms
+ * ================================================================================
+ * Copyright (C) 2020 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 java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.onap.slice.analysis.ms.models.MeasurementObject;
+import org.onap.slice.analysis.ms.models.pmnotification.Event;
+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 = PmEventProcessorTest.class)
+public class PmEventProcessorTest {
+
+ @InjectMocks
+ PmEventProcessor pmEventProcessor;
+
+ @Test
+ public void processEventTest() {
+ ObjectMapper obj = new ObjectMapper();
+ Event input = null;
+ Map<String, List<MeasurementObject>> output = null;
+ try {
+ input = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/event.json"))), Event.class);
+ output = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/eventProcessorOutput.json"))), new TypeReference<Map<String, List<MeasurementObject>>>(){});
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ assertEquals(output, pmEventProcessor.processEvent(input));
+ }
+}
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/PolicyServiceTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/PolicyServiceTest.java
new file mode 100644
index 00000000..1131a5e5
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/PolicyServiceTest.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * slice-analysis-ms
+ * ================================================================================
+ * Copyright (C) 2020 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 net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.onap.slice.analysis.ms.models.policy.AdditionalProperties;
+import org.onap.slice.analysis.ms.models.policy.OnsetMessage;
+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;
+import com.google.gson.Gson;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = PolicyServiceTest.class)
+public class PolicyServiceTest {
+ ObjectMapper obj = new ObjectMapper();
+
+ @InjectMocks
+ PolicyService policyService;
+
+ @Test
+ public void formPolicyOnsetMessageTest() {
+ String snssai = "001-100001";
+ Map<String, String> input = null;
+ OnsetMessage output = null;
+ String expected = "";
+ String actual = "";
+ Map<String, Map<String, Integer>> ricToThroughputMapping = new HashMap<>();
+ Map<String, Integer> ric1 = new HashMap<>();
+ Map<String, Integer> ric2 = new HashMap<>();
+ ric1.put("dLThptPerSlice",50);
+ ric1.put("uLThptPerSlice",40);
+ ric2.put("dLThptPerSlice",50);
+ ric2.put("uLThptPerSlice",30);
+ ricToThroughputMapping.put("1", ric1);
+ ricToThroughputMapping.put("2", ric2);
+ try {
+ input = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/serviceDetails.json"))), new TypeReference<Map<String,String>>(){});
+ output = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/onsetMessage.json"))), OnsetMessage.class);
+ expected = obj.writeValueAsString(output);
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ AdditionalProperties<Map<String, Map<String, Integer>>> addProps = new AdditionalProperties<>();
+ addProps.setResourceConfig(ricToThroughputMapping);
+ actual = new Gson().toJson(policyService.formPolicyOnsetMessage(snssai,addProps,input));
+
+ assertThatJson(actual)
+ .whenIgnoringPaths("requestID","payload.additionalProperties.nsiInfo.nsiId","closedLoopAlarmStart", "AAI", "target_type", "aai", "targetType")
+ .isEqualTo(expected);
+ }
+}
diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/SnssaiSamplesProcessorTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/SnssaiSamplesProcessorTest.java
new file mode 100644
index 00000000..b8316dfe
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/SnssaiSamplesProcessorTest.java
@@ -0,0 +1,193 @@
+/*******************************************************************************
+ * ============LICENSE_START=======================================================
+ * slice-analysis-ms
+ * ================================================================================
+ * Copyright (C) 2020 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 java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.onap.slice.analysis.ms.models.MeasurementObject;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.util.ReflectionTestUtils;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SnssaiSamplesProcessorTest.class)
+public class SnssaiSamplesProcessorTest {
+ ObjectMapper obj = new ObjectMapper();
+
+ @InjectMocks
+ SnssaiSamplesProcessor snssaiSamplesProcessor;
+
+ @Before
+ public void setup() {
+ Map<String, Map<String, Integer>> ricToThroughputMapping = new HashMap<>();
+ Map<String, Integer> ric1 = new HashMap<>();
+ Map<String, Integer> ric2 = new HashMap<>();
+ ric1.put("dLThptPerSlice",50);
+ ric1.put("uLThptPerSlice",40);
+ ric2.put("dLThptPerSlice",50);
+ ric2.put("uLThptPerSlice",30);
+ ricToThroughputMapping.put("1", ric1);
+ ricToThroughputMapping.put("2", ric2);
+ ReflectionTestUtils.setField(snssaiSamplesProcessor, "ricToThroughputMapping", ricToThroughputMapping);
+
+ Map<String, Map<String, Integer>> ricToPrbsMapping = null;
+ List<MeasurementObject> sliceMeasList = null;
+ Map<String, List<String>> ricToCellMapping = null;
+ Map<String, String> prbThroughputMapping = new HashMap<>();
+ prbThroughputMapping = new HashMap<>();
+ prbThroughputMapping.put("PrbUsedDl", "dLThptPerSlice");
+ prbThroughputMapping.put("PrbUsedUl", "uLThptPerSlice");
+
+ try {
+ ricToPrbsMapping = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/ricToPrbMap.json"))), new TypeReference<Map<String, Map<String, Integer>>>(){});
+ sliceMeasList = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/sliceMeasurementList.json"))), new TypeReference<List<MeasurementObject>>(){});
+ ricToCellMapping = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/ricToCellMapping.json"))), new TypeReference<Map<String, List<String>>>(){});
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ ReflectionTestUtils.setField(snssaiSamplesProcessor, "ricToPrbsMapping", ricToPrbsMapping);
+ ReflectionTestUtils.setField(snssaiSamplesProcessor, "minPercentageChange", 6);
+ ReflectionTestUtils.setField(snssaiSamplesProcessor, "snssaiMeasurementList", sliceMeasList);
+ ReflectionTestUtils.setField(snssaiSamplesProcessor, "ricToCellMapping", ricToCellMapping);
+ ReflectionTestUtils.setField(snssaiSamplesProcessor, "prbThroughputMapping", prbThroughputMapping);
+ }
+
+ @Test
+ public void computeSumTest() {
+ assertEquals(Integer.valueOf(100), snssaiSamplesProcessor.computeSum("PrbUsedDl"));
+ }
+
+ @Test
+ public void updateConfigurationTest() {
+ Map<String, Map<String, Integer>> ricToThroughputMappingExp = new HashMap<>();
+ Map<String, Integer> ric1 = new HashMap<>();
+ Map<String, Integer> ric2 = new HashMap<>();
+ ric1.put("dLThptPerSlice",50);
+ ric1.put("uLThptPerSlice",40);
+ ric2.put("dLThptPerSlice",50);
+ ric2.put("uLThptPerSlice",30);
+ ricToThroughputMappingExp.put("1", ric1);
+ ricToThroughputMappingExp.put("2", ric2);
+ snssaiSamplesProcessor.updateConfiguration();
+ assertEquals(ricToThroughputMappingExp,ReflectionTestUtils.getField(snssaiSamplesProcessor, "ricToThroughputMapping"));
+ }
+
+ @Test
+ public void updateConfigurationTrueTest() {
+ Map<String, Map<String, Integer>> ricToThroughputMappingExp = new HashMap<>();
+ Map<String, Integer> ric2 = new HashMap<>();
+ ric2.put("dLThptPerSlice",50);
+ ric2.put("uLThptPerSlice",30);
+ ricToThroughputMappingExp.put("2", ric2);
+
+ Map<String, Map<String, Integer>> ricToThroughputMapping = new HashMap<>();
+ Map<String, Integer> ric1 = new HashMap<>();
+ ric2 = new HashMap<>();
+ ric2.put("dLThptPerSlice",50);
+ ric2.put("uLThptPerSlice",30);
+ ricToThroughputMapping.put("1", ric1);
+ ricToThroughputMapping.put("2", ric2);
+ ReflectionTestUtils.setField(snssaiSamplesProcessor, "ricToThroughputMapping", ricToThroughputMapping);
+
+ snssaiSamplesProcessor.updateConfiguration();
+ System.out.println();
+ assertEquals(ricToThroughputMappingExp, ReflectionTestUtils.getField(snssaiSamplesProcessor, "ricToThroughputMapping"));
+ }
+
+ @Test
+ public void calculatePercentageChangeTest() {
+ Map<String, Map<String, Integer>> ricConfiguration = null;
+ Map<String, Map<String, Integer>> exp = new HashMap<>();
+ Map<String, Integer> ric1 = new HashMap<>();
+ Map<String, Integer> ric2 = new HashMap<>();
+ ric1.put("dLThptPerSlice", 50);
+ ric2.put("dLThptPerSlice", 50);
+ ric2.put("uLThptPerSlice", 30);
+ exp.put("1", ric1);
+ exp.put("2", ric2);
+ try {
+ ricConfiguration = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/ricConfiguration.json"))), new TypeReference<Map<String, Map<String, Integer>>>(){});
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ snssaiSamplesProcessor.calculatePercentageChange(ricConfiguration, "uLThptPerSlice");
+ assertEquals(exp,ReflectionTestUtils.getField(snssaiSamplesProcessor, "ricToThroughputMapping"));
+
+ ricConfiguration.get("2").put("dLThptPerSlice",60);
+ exp.get("1").remove("dLThptPerSlice");
+ snssaiSamplesProcessor.calculatePercentageChange(ricConfiguration, "dLThptPerSlice");
+ assertEquals(exp,ReflectionTestUtils.getField(snssaiSamplesProcessor, "ricToThroughputMapping"));
+ }
+
+ @Test
+ public void sumOfPrbsAcrossCellsTest() {
+ Map<String, Map<String, Integer>> ricToPrbsMapping = new HashMap<>();
+ Map<String, Map<String, Integer>> ricToPrbsMappingExp = new HashMap<>();
+
+ ReflectionTestUtils.setField(snssaiSamplesProcessor, "ricToPrbsMapping", ricToPrbsMapping);
+
+ try {
+ ricToPrbsMappingExp = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/ricToPrbOutput.json"))), new TypeReference<Map<String, Map<String, Integer>>>(){});
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ snssaiSamplesProcessor.sumOfPrbsAcrossCells("PrbUsedDl");
+ assertEquals(ricToPrbsMappingExp, ReflectionTestUtils.getField(snssaiSamplesProcessor, "ricToPrbsMapping"));
+ }
+
+ @Test
+ public void computeThroughputTest() {
+ Map<String, Map<String, Integer>> ricToThroughputMapping = new HashMap<>();
+ ReflectionTestUtils.setField(snssaiSamplesProcessor, "ricToThroughputMapping", ricToThroughputMapping);
+
+ Map<String, Map<String, Integer>> ricToThroughputMappingExp = new HashMap<>();
+ try {
+ ricToThroughputMappingExp = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/ricToThroughputMappingOutput.json"))), new TypeReference<Map<String, Map<String, Integer>>>(){});
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ Map<String, Integer> sliceConfiguration = new HashMap<String, Integer>();
+ sliceConfiguration.put("dLThptPerSlice",120);
+ sliceConfiguration.put("uLThptPerSlice",100);
+ snssaiSamplesProcessor.computeThroughput(sliceConfiguration, 100, "PrbUsedDl");
+ snssaiSamplesProcessor.computeThroughput(sliceConfiguration, 70, "PrbUsedUl");
+ assertEquals(ricToThroughputMappingExp, ReflectionTestUtils.getField(snssaiSamplesProcessor, "ricToThroughputMapping"));
+ }
+}
diff --git a/components/slice-analysis-ms/src/test/resources/MLOutputModel.json b/components/slice-analysis-ms/src/test/resources/MLOutputModel.json
new file mode 100644
index 00000000..b4082b3f
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/resources/MLOutputModel.json
@@ -0,0 +1,49 @@
+{
+ "snssai":"0001-0111",
+ "data":[
+ {
+ "gNBCUName":"cucpName",
+ "nearRTRICId": "12",
+ "cellCUList":[
+ {
+ "cellLocalId":111,
+ "configData":{
+ "maxNumberofConns":"20",
+ "predictedMaxNumberofConns":"25",
+ "lastUpdatedTS":"yyyy/MM/dd HH:mm:ss"
+ }
+ },
+ {
+ "cellLocalId":112,
+ "configData":{
+ "maxNumberofConns":"20",
+ "predictedMaxNumberofConns":"25",
+ "lastUpdatedTS":"yyyy/MM/dd HH:mm:ss"
+ }
+ }
+ ]
+ },
+ {
+ "gNBCUName":"cucpName2",
+ "nearRTRICId": "13",
+ "cellCUList":[
+ {
+ "cellLocalId":113,
+ "configData":{
+ "maxNumberofConns":"20",
+ "predictedMaxNumberofConns":"25",
+ "lastUpdatedTS":"yyyy/MM/dd HH:mm:ss"
+ }
+ },
+ {
+ "cellLocalId":114,
+ "configData":{
+ "maxNumberofConns":"20",
+ "predictedMaxNumberofConns":"25",
+ "lastUpdatedTS":"yyyy/MM/dd HH:mm:ss"
+ }
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/components/slice-analysis-ms/src/test/resources/MLOutputModel1.json b/components/slice-analysis-ms/src/test/resources/MLOutputModel1.json
new file mode 100644
index 00000000..c9524807
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/resources/MLOutputModel1.json
@@ -0,0 +1,47 @@
+{
+ "snssai":"0001-0111",
+ "data":[
+ {
+ "gNBCUName":"cucpName",
+ "cellCUList":[
+ {
+ "cellLocalId":111,
+ "configData":{
+ "maxNumberofConns":"20",
+ "predictedMaxNumberofConns":"25",
+ "lastUpdatedTS":"yyyy/MM/dd HH:mm:ss"
+ }
+ },
+ {
+ "cellLocalId":112,
+ "configData":{
+ "maxNumberofConns":"20",
+ "predictedMaxNumberofConns":"25",
+ "lastUpdatedTS":"yyyy/MM/dd HH:mm:ss"
+ }
+ }
+ ]
+ },
+ {
+ "gNBCUName":"cucpName2",
+ "cellCUList":[
+ {
+ "cellLocalId":113,
+ "configData":{
+ "maxNumberofConns":"20",
+ "predictedMaxNumberofConns":"25",
+ "lastUpdatedTS":"yyyy/MM/dd HH:mm:ss"
+ }
+ },
+ {
+ "cellLocalId":114,
+ "configData":{
+ "maxNumberofConns":"20",
+ "predictedMaxNumberofConns":"25",
+ "lastUpdatedTS":"yyyy/MM/dd HH:mm:ss"
+ }
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/components/slice-analysis-ms/src/test/resources/appendData.json b/components/slice-analysis-ms/src/test/resources/appendData.json
new file mode 100644
index 00000000..39802dd2
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/resources/appendData.json
@@ -0,0 +1,63 @@
+[
+[
+ {"measurementObjectId":"cell1",
+ "pmData":{
+ "PrbUsedDl":"30",
+ "PrbUsedUl":"40"
+ }
+ },
+ {"measurementObjectId":"cell2",
+ "pmData":{
+ "PrbUsedDl":"20",
+ "PrbUsedUl":"30"
+ }
+ },
+ {"measurementObjectId":"cell3",
+ "pmData":{
+ "PrbUsedDl":"30",
+ "PrbUsedUl":"40"
+ }
+ }
+ ],
+[
+ {"measurementObjectId":"cell1",
+ "pmData":{
+ "PrbUsedDl":"40",
+ "PrbUsedUl":"35"
+ }
+ },
+ {"measurementObjectId":"cell2",
+ "pmData":{
+ "PrbUsedDl":"25",
+ "PrbUsedUl":"30"
+ }
+ },
+ {"measurementObjectId":"cell3",
+ "pmData":{
+ "PrbUsedDl":"30",
+ "PrbUsedUl":"40"
+ }
+ }
+ ],
+[
+ {"measurementObjectId":"cell1",
+ "pmData":{
+ "PrbUsedDl":"35",
+ "PrbUsedUl":"37"
+ }
+ },
+ {"measurementObjectId":"cell2",
+ "pmData":{
+ "PrbUsedDl":"22",
+ "PrbUsedUl":"30"
+ }
+ },
+ {"measurementObjectId":"cell3",
+ "pmData":{
+ "PrbUsedDl":"25",
+ "PrbUsedUl":"40"
+ }
+ }
+]
+
+] \ No newline at end of file
diff --git a/components/slice-analysis-ms/src/test/resources/average.json b/components/slice-analysis-ms/src/test/resources/average.json
new file mode 100644
index 00000000..81838b6d
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/resources/average.json
@@ -0,0 +1,20 @@
+[
+ {"measurementObjectId":"cell1",
+ "pmData":{
+ "PrbUsedDl":"35",
+ "PrbUsedUl":"37"
+ }
+ },
+ {"measurementObjectId":"cell2",
+ "pmData":{
+ "PrbUsedDl":"22",
+ "PrbUsedUl":"30"
+ }
+ },
+ {"measurementObjectId":"cell3",
+ "pmData":{
+ "PrbUsedDl":"25",
+ "PrbUsedUl":"40"
+ }
+ }
+] \ No newline at end of file
diff --git a/components/slice-analysis-ms/src/test/resources/config_all.json b/components/slice-analysis-ms/src/test/resources/config_all.json
index 21a82344..79d70202 100644
--- a/components/slice-analysis-ms/src/test/resources/config_all.json
+++ b/components/slice-analysis-ms/src/test/resources/config_all.json
@@ -49,6 +49,10 @@
"sliceanalysisms.pollingInterval": 20,
"sliceanalysisms.cid": "sliceanalysisms-cid",
"sliceanalysisms.configDb.service": "http://sdnc.onap:8181",
+ "sliceanalysisms.pollingTimeout":4,
+ "sliceanalysisms.samples": 5,
+ "sliceanalysisms.minPercentageChange":4,
+ "sliceanalysisms.initialDelaySeconds": 60000,
"service_calls": {
"policy-req": []
}
diff --git a/components/slice-analysis-ms/src/test/resources/event.json b/components/slice-analysis-ms/src/test/resources/event.json
new file mode 100644
index 00000000..b30bca81
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/resources/event.json
@@ -0,0 +1,209 @@
+{
+
+ "commonEventHeader":{
+
+ "domain":"perf3gpp",
+
+ "eventId":"f576d0bf-ef92-45e9-a8a3-96fe7ea1d0fb",
+
+ "sequence":0,
+
+ "eventName":"perf3gpp_AcmeNode-Acme_pmMeasResult",
+
+ "sourceName":"oteNB5309",
+
+ "reportingEntityName":"",
+
+ "priority":"Normal",
+
+ "startEpochMicrosec":1597402800000,
+
+ "lastEpochMicrosec":1597403700000,
+
+ "version":"4.0",
+
+ "vesEventListenerVersion":"7.1",
+
+ "timeZoneOffset":"UTC+05:00"
+
+ },
+
+ "perf3gppFields":{
+
+ "perf3gppFieldsVersion":"1.0",
+
+ "measDataCollection":{
+
+ "granularityPeriod":1597407300000,
+
+ "measuredEntityUserName":"",
+
+ "measuredEntityDn":"ncserver1",
+
+ "measuredEntitySoftwareVersion":"r0.1",
+
+ "measInfoList":[
+
+ {
+
+ "measInfoId":{
+
+ "sMeasInfoId":"some measInfoId"
+
+ },
+
+ "measTypes":{
+
+ "sMeasTypesList":[
+
+ "SM.PrbUsedDl.001-100001",
+
+ "SM.PrbUsedUl.001-100001",
+
+ "SM.PrbUsedDl.001-100011",
+
+ "SM.PrbUsedUl.001-100011"
+
+ ]
+
+ },
+
+ "measValuesList":[
+
+ {
+
+ "measObjInstId":"chn001",
+
+ "suspectFlag":"false",
+
+ "measResults":[
+
+ {
+
+ "p":1,
+
+ "sValue":"55"
+
+ },
+
+ {
+
+ "p":2,
+
+ "sValue":"53"
+
+ },
+ {
+
+ "p":3,
+
+ "sValue":"40"
+
+ },
+ {
+
+ "p":4,
+
+ "sValue":"33"
+
+ }
+
+ ]
+
+ },
+
+ {
+
+ "measObjInstId":"chn002",
+
+ "suspectFlag":"false",
+
+ "measResults":[
+
+ {
+
+ "p":1,
+
+ "sValue":"22"
+
+ },
+
+ {
+
+ "p":2,
+
+ "sValue":"30"
+
+ },
+ {
+
+ "p":3,
+
+ "sValue":"22"
+
+ },
+ {
+
+ "p":4,
+
+ "sValue":"30"
+
+ }
+
+ ]
+
+ },
+ {
+
+ "measObjInstId":"chn003",
+
+ "suspectFlag":"false",
+
+ "measResults":[
+
+ {
+
+ "p":1,
+
+ "sValue":"25"
+
+ },
+
+ {
+
+ "p":2,
+
+ "sValue":"56"
+
+ },
+ {
+
+ "p":3,
+
+ "sValue":"50"
+
+ },
+ {
+
+ "p":4,
+
+ "sValue":"40"
+
+ }
+
+ ]
+
+ }
+
+ ]
+
+ }
+
+ ]
+
+ }
+
+ }
+
+ }
+
diff --git a/components/slice-analysis-ms/src/test/resources/eventProcessorOutput.json b/components/slice-analysis-ms/src/test/resources/eventProcessorOutput.json
new file mode 100644
index 00000000..3f29c2af
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/resources/eventProcessorOutput.json
@@ -0,0 +1,41 @@
+{"001-100001":[
+ {"measurementObjectId":"chn001",
+ "pmData":{
+ "PrbUsedDl":"55",
+ "PrbUsedUl":"53"
+ }
+ },
+ {"measurementObjectId":"chn002",
+ "pmData":{
+ "PrbUsedDl":"22",
+ "PrbUsedUl":"30"
+ }
+ },
+ {"measurementObjectId":"chn003",
+ "pmData":{
+ "PrbUsedDl":"25",
+ "PrbUsedUl":"56"
+ }
+ }
+],
+"001-100011":[
+ {"measurementObjectId":"chn001",
+ "pmData":{
+ "PrbUsedDl":"40",
+ "PrbUsedUl":"33"
+ }
+ },
+ {"measurementObjectId":"chn002",
+ "pmData":{
+ "PrbUsedDl":"22",
+ "PrbUsedUl":"30"
+ }
+ },
+ {"measurementObjectId":"chn003",
+ "pmData":{
+ "PrbUsedDl":"50",
+ "PrbUsedUl":"40"
+ }
+ }
+]
+} \ No newline at end of file
diff --git a/components/slice-analysis-ms/src/test/resources/getResponse.json b/components/slice-analysis-ms/src/test/resources/getResponse.json
new file mode 100644
index 00000000..09880652
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/resources/getResponse.json
@@ -0,0 +1,21 @@
+[[
+ {"measurementObjectId":"cell1",
+ "pmData":{
+ "PrbUsedDl":"30",
+ "PrbUsedUl":"40"
+ }
+ },
+ {"measurementObjectId":"cell2",
+ "pmData":{
+ "PrbUsedDl":"20",
+ "PrbUsedUl":"30"
+ }
+ },
+ {"measurementObjectId":"cell3",
+ "pmData":{
+ "PrbUsedDl":"30",
+ "PrbUsedUl":"40"
+ }
+ }
+ ]
+] \ No newline at end of file
diff --git a/components/slice-analysis-ms/src/test/resources/measurementObjectList.json b/components/slice-analysis-ms/src/test/resources/measurementObjectList.json
new file mode 100644
index 00000000..f398da8c
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/resources/measurementObjectList.json
@@ -0,0 +1,42 @@
+[
+[
+ {"measurementObjectId":"cell1",
+ "pmData":{
+ "PrbUsedDl":"30",
+ "PrbUsedUl":"40"
+ }
+ },
+ {"measurementObjectId":"cell2",
+ "pmData":{
+ "PrbUsedDl":"20",
+ "PrbUsedUl":"30"
+ }
+ },
+ {"measurementObjectId":"cell3",
+ "pmData":{
+ "PrbUsedDl":"30",
+ "PrbUsedUl":"40"
+ }
+ }
+ ],
+[
+ {"measurementObjectId":"cell1",
+ "pmData":{
+ "PrbUsedDl":"40",
+ "PrbUsedUl":"35"
+ }
+ },
+ {"measurementObjectId":"cell2",
+ "pmData":{
+ "PrbUsedDl":"25",
+ "PrbUsedUl":"30"
+ }
+ },
+ {"measurementObjectId":"cell3",
+ "pmData":{
+ "PrbUsedDl":"30",
+ "PrbUsedUl":"40"
+ }
+ }
+ ]
+] \ No newline at end of file
diff --git a/components/slice-analysis-ms/src/test/resources/onsetMessage.json b/components/slice-analysis-ms/src/test/resources/onsetMessage.json
new file mode 100644
index 00000000..7f91ad12
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/resources/onsetMessage.json
@@ -0,0 +1,46 @@
+{
+ "closedLoopControlName": "ControlLoop-Slicing-116d7b00-dbeb-4d03-8719-d0a658fa735b",
+ "closedLoopAlarmStart": 1463679805324,
+ "closedLoopEventClient": "microservice.sliceAnalysisMS",
+ "closedLoopEventStatus": "ONSET",
+ "requestID": "c7c6a4aa-bb61-4a15-b831-ba1472dd4a65",
+ "target_type": "VNF",
+ "target": "vserver.vserver-name",
+ "AAI": {
+ "vserver.is-closed-loop-disabled": "false",
+ "vserver.prov-status": "ACTIVE",
+ "vserver.vserver-name": "e51a9b12-f313-11ea-adc1-0242ac120003"
+ },
+ "payload": {
+ "name":"e51a9b12-f313-11ea-adc1-0242ac120003",
+ "globalSubscriberId":"5GCustomer",
+ "subscriptionServiceType":"5G",
+ "networkType":"AN",
+ "serviceInstanceID":"e51a9b12-f313-11ea-adc1-0242ac120003",
+ "additionalProperties":{
+ "modifyAction":"reconfigure",
+ "snssaiList":[
+ "001-100001"
+ ],
+ "sliceProfileId":"e51a9b12-f313-11ea-adc1-0242ac120002",
+ "resourceConfig":{
+ "1":{
+ "dLThptPerSlice":50,
+ "uLThptPerSlice":40
+ },
+ "2":{
+ "dLThptPerSlice":50,
+ "uLThptPerSlice":30
+ }
+ },
+ "nsiInfo":{
+ "nsiId":"UUID",
+ "nsiName":""
+ },
+ "scriptName": "AN"
+ }
+
+},
+ "from": "DCAE",
+ "version": "1.0.2"
+} \ No newline at end of file
diff --git a/components/slice-analysis-ms/src/test/resources/ricConfiguration.json b/components/slice-analysis-ms/src/test/resources/ricConfiguration.json
new file mode 100644
index 00000000..add9666a
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/resources/ricConfiguration.json
@@ -0,0 +1,10 @@
+{
+"1":{
+ "dLThptPerSlice":50,
+ "uLThptPerSlice":38
+ },
+ "2":{
+ "dLThptPerSlice":50,
+ "uLThptPerSlice":40
+ }
+} \ No newline at end of file
diff --git a/components/slice-analysis-ms/src/test/resources/ricToCellMapping.json b/components/slice-analysis-ms/src/test/resources/ricToCellMapping.json
new file mode 100644
index 00000000..f685580f
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/resources/ricToCellMapping.json
@@ -0,0 +1,4 @@
+{
+"1":["cell1","cell2","cell4"],
+"2":["cell3","cell5","cell6"]
+} \ No newline at end of file
diff --git a/components/slice-analysis-ms/src/test/resources/ricToPrbMap.json b/components/slice-analysis-ms/src/test/resources/ricToPrbMap.json
new file mode 100644
index 00000000..c6194f02
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/resources/ricToPrbMap.json
@@ -0,0 +1,10 @@
+{
+ "1":{
+ "PrbUsedDl":50,
+ "PrbUsedUl":40
+ },
+ "2":{
+ "PrbUsedDl":50,
+ "PrbUsedUl":30
+ }
+} \ No newline at end of file
diff --git a/components/slice-analysis-ms/src/test/resources/ricToPrbOutput.json b/components/slice-analysis-ms/src/test/resources/ricToPrbOutput.json
new file mode 100644
index 00000000..8f134782
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/resources/ricToPrbOutput.json
@@ -0,0 +1,8 @@
+{
+ "1":{
+ "PrbUsedDl":90
+ },
+ "2":{
+ "PrbUsedDl":85
+ }
+} \ No newline at end of file
diff --git a/components/slice-analysis-ms/src/test/resources/ricToThroughputMappingOutput.json b/components/slice-analysis-ms/src/test/resources/ricToThroughputMappingOutput.json
new file mode 100644
index 00000000..bff52dc9
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/resources/ricToThroughputMappingOutput.json
@@ -0,0 +1,10 @@
+{
+ "1":{
+ "dLThptPerSlice":60,
+ "uLThptPerSlice":57
+ },
+ "2":{
+ "dLThptPerSlice":60,
+ "uLThptPerSlice":43
+ }
+} \ No newline at end of file
diff --git a/components/slice-analysis-ms/src/test/resources/serviceDetails.json b/components/slice-analysis-ms/src/test/resources/serviceDetails.json
new file mode 100644
index 00000000..accde978
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/resources/serviceDetails.json
@@ -0,0 +1,12 @@
+{
+ "sNSSAI":"001-100001",
+
+ "ranNFNSSIId":"e51a9b12-f313-11ea-adc1-0242ac120003",
+
+ "sliceProfileId":"e51a9b12-f313-11ea-adc1-0242ac120002",
+
+ "globalSubscriberId":"5GCustomer",
+
+ "subscriptionServiceType":"5G"
+
+} \ No newline at end of file
diff --git a/components/slice-analysis-ms/src/test/resources/sliceMeasurementList.json b/components/slice-analysis-ms/src/test/resources/sliceMeasurementList.json
new file mode 100644
index 00000000..1ab63aa4
--- /dev/null
+++ b/components/slice-analysis-ms/src/test/resources/sliceMeasurementList.json
@@ -0,0 +1,39 @@
+[
+ {"measurementObjectId":"cell1",
+ "pmData":{
+ "PrbUsedDl":"30",
+ "PrbUsedUl":"40"
+ }
+ },
+ {"measurementObjectId":"cell2",
+ "pmData":{
+ "PrbUsedDl":"20",
+ "PrbUsedUl":"30"
+ }
+ },
+ {"measurementObjectId":"cell3",
+ "pmData":{
+ "PrbUsedDl":"30",
+ "PrbUsedUl":"40"
+ }
+ },
+ {"measurementObjectId":"cell4",
+ "pmData":{
+ "PrbUsedDl":"40",
+ "PrbUsedUl":"35"
+ }
+ },
+ {"measurementObjectId":"cell5",
+ "pmData":{
+ "PrbUsedDl":"25",
+ "PrbUsedUl":"30"
+ }
+ },
+ {"measurementObjectId":"cell6",
+ "pmData":{
+ "PrbUsedDl":"30",
+ "PrbUsedUl":"40"
+ }
+ }
+
+] \ No newline at end of file