From 8882e23eedce9e9236e1d979b2056b62dd974d91 Mon Sep 17 00:00:00 2001 From: dhebeha Date: Tue, 8 Sep 2020 13:02:32 +0530 Subject: 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 Change-Id: I185dbb6da45ae6ee74f0a090e2d604914163588b --- components/slice-analysis-ms/.checkstyle | 16 +- components/slice-analysis-ms/pom.xml | 11 + .../org/onap/slice/analysis/ms/Application.java | 4 +- .../org/onap/slice/analysis/ms/MainThread.java | 58 +++++ .../onap/slice/analysis/ms/beans/ConfigPolicy.java | 72 ------ .../slice/analysis/ms/beans/Configuration.java | 242 ------------------- .../ms/configdb/ConfigDbInterfaceService.java | 127 ++++++++++ .../analysis/ms/configdb/IConfigDbService.java | 39 +++ .../analysis/ms/controller/ConfigFetchFromCbs.java | 4 +- .../onap/slice/analysis/ms/dmaap/DmaapClient.java | 45 ++-- .../ms/dmaap/IntelligentSlicingCallback.java | 69 ++++++ .../slice/analysis/ms/dmaap/NewPmNotification.java | 8 +- .../analysis/ms/dmaap/NotificationCallback.java | 2 +- .../analysis/ms/dmaap/PmNotificationCallback.java | 2 +- .../slice/analysis/ms/dmaap/PolicyDmaapClient.java | 2 +- .../ms/dmaap/PolicyNotificationCallback.java | 6 +- .../org/onap/slice/analysis/ms/models/CUModel.java | 101 ++++++++ .../onap/slice/analysis/ms/models/CellCUList.java | 80 +++++++ .../onap/slice/analysis/ms/models/ConfigData.java | 94 ++++++++ .../slice/analysis/ms/models/ConfigPolicy.java | 72 ++++++ .../slice/analysis/ms/models/Configuration.java | 265 +++++++++++++++++++++ .../slice/analysis/ms/models/MLOutputModel.java | 82 +++++++ .../analysis/ms/models/MeasurementObject.java | 96 ++++++++ .../onap/slice/analysis/ms/models/SubCounter.java | 76 ++++++ .../analysis/ms/models/configdb/CellsModel.java | 51 ++++ .../ms/models/configdb/NetworkFunctionModel.java | 52 ++++ .../models/pmnotification/CommonEventHeader.java | 138 +++++++++++ .../analysis/ms/models/pmnotification/Event.java | 47 ++++ .../models/pmnotification/MeasDataCollection.java | 77 ++++++ .../ms/models/pmnotification/MeasInfoId.java | 39 +++ .../ms/models/pmnotification/MeasInfoList.java | 59 +++++ .../ms/models/pmnotification/MeasResult.java | 48 ++++ .../ms/models/pmnotification/MeasTypes.java | 41 ++++ .../ms/models/pmnotification/MeasValuesList.java | 58 +++++ .../ms/models/pmnotification/Perf3gppFields.java | 48 ++++ .../ms/models/pmnotification/PmNotification.java | 39 +++ .../onap/slice/analysis/ms/models/policy/AAI.java | 61 +++++ .../ms/models/policy/AdditionalProperties.java | 75 ++++++ .../analysis/ms/models/policy/OnsetMessage.java | 136 +++++++++++ .../slice/analysis/ms/models/policy/Payload.java | 95 ++++++++ .../ms/restclients/ConfigDbRestClient.java | 64 +++++ .../slice/analysis/ms/restclients/RestClient.java | 80 +++++++ .../analysis/ms/service/AverageCalculator.java | 94 ++++++++ .../slice/analysis/ms/service/ConsumerThread.java | 72 ++++++ .../analysis/ms/service/IPmEventProcessor.java | 35 +++ .../analysis/ms/service/MLMessageProcessor.java | 73 ++++++ .../slice/analysis/ms/service/PmDataQueue.java | 96 ++++++++ .../analysis/ms/service/PmEventProcessor.java | 105 ++++++++ .../onap/slice/analysis/ms/service/PmThread.java | 92 +++++++ .../slice/analysis/ms/service/PolicyService.java | 111 +++++++++ .../ms/service/SnssaiSamplesProcessor.java | 190 +++++++++++++++ .../onap/slice/analysis/ms/utils/DmaapUtils.java | 2 +- .../slice/analysis/ms/beans/ConfigPolicyTest.java | 43 ---- .../slice/analysis/ms/beans/ConfigurationTest.java | 73 ------ .../ms/configdb/ConfigDbInterfaceServiceTest.java | 127 ++++++++++ .../slice/analysis/ms/dmaap/DmaapClientTest.java | 51 ++-- .../ms/dmaap/NotificationConsumerTest.java | 10 +- .../analysis/ms/dmaap/PolicyDmaapClientTest.java | 10 +- .../slice/analysis/ms/models/ConfigPolicyTest.java | 43 ++++ .../analysis/ms/models/ConfigurationTest.java | 73 ++++++ .../onap/slice/analysis/ms/models/ModelsTest.java | 92 +++++++ .../ms/models/pmnotification/PmModelsTest.java | 106 +++++++++ .../ms/models/policy/PolicyModelsTest.java | 69 ++++++ .../analysis/ms/restclients/RestClientTest.java | 120 ++++++++++ .../analysis/ms/service/AverageCalculatorTest.java | 117 +++++++++ .../ms/service/MLMessageProcessorTest.java | 93 ++++++++ .../slice/analysis/ms/service/PmDataQueueTest.java | 152 ++++++++++++ .../analysis/ms/service/PmEventProcessorTest.java | 65 +++++ .../analysis/ms/service/PolicyServiceTest.java | 84 +++++++ .../ms/service/SnssaiSamplesProcessorTest.java | 193 +++++++++++++++ .../src/test/resources/MLOutputModel.json | 49 ++++ .../src/test/resources/MLOutputModel1.json | 47 ++++ .../src/test/resources/appendData.json | 63 +++++ .../src/test/resources/average.json | 20 ++ .../src/test/resources/config_all.json | 4 + .../src/test/resources/event.json | 209 ++++++++++++++++ .../src/test/resources/eventProcessorOutput.json | 41 ++++ .../src/test/resources/getResponse.json | 21 ++ .../src/test/resources/measurementObjectList.json | 42 ++++ .../src/test/resources/onsetMessage.json | 46 ++++ .../src/test/resources/ricConfiguration.json | 10 + .../src/test/resources/ricToCellMapping.json | 4 + .../src/test/resources/ricToPrbMap.json | 10 + .../src/test/resources/ricToPrbOutput.json | 8 + .../resources/ricToThroughputMappingOutput.json | 10 + .../src/test/resources/serviceDetails.json | 12 + .../src/test/resources/sliceMeasurementList.json | 39 +++ 87 files changed, 5301 insertions(+), 506 deletions(-) create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/MainThread.java delete mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/beans/ConfigPolicy.java delete mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/beans/Configuration.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceService.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/IConfigDbService.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/IntelligentSlicingCallback.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/CUModel.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/CellCUList.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/ConfigData.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/ConfigPolicy.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/Configuration.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/MLOutputModel.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/MeasurementObject.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/SubCounter.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/configdb/CellsModel.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/configdb/NetworkFunctionModel.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/CommonEventHeader.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/Event.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasDataCollection.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasInfoId.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasInfoList.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasResult.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasTypes.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasValuesList.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/Perf3gppFields.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/PmNotification.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/AAI.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/AdditionalProperties.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/OnsetMessage.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/Payload.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/restclients/ConfigDbRestClient.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/restclients/RestClient.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/AverageCalculator.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ConsumerThread.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/IPmEventProcessor.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/MLMessageProcessor.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmDataQueue.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmEventProcessor.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmThread.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PolicyService.java create mode 100644 components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/SnssaiSamplesProcessor.java delete mode 100644 components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/beans/ConfigPolicyTest.java delete mode 100644 components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/beans/ConfigurationTest.java create mode 100644 components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceServiceTest.java create mode 100644 components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigPolicyTest.java create mode 100644 components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigurationTest.java create mode 100644 components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ModelsTest.java create mode 100644 components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/pmnotification/PmModelsTest.java create mode 100644 components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/policy/PolicyModelsTest.java create mode 100644 components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/restclients/RestClientTest.java create mode 100644 components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/AverageCalculatorTest.java create mode 100644 components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/MLMessageProcessorTest.java create mode 100644 components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/PmDataQueueTest.java create mode 100644 components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/PmEventProcessorTest.java create mode 100644 components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/PolicyServiceTest.java create mode 100644 components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/service/SnssaiSamplesProcessorTest.java create mode 100644 components/slice-analysis-ms/src/test/resources/MLOutputModel.json create mode 100644 components/slice-analysis-ms/src/test/resources/MLOutputModel1.json create mode 100644 components/slice-analysis-ms/src/test/resources/appendData.json create mode 100644 components/slice-analysis-ms/src/test/resources/average.json create mode 100644 components/slice-analysis-ms/src/test/resources/event.json create mode 100644 components/slice-analysis-ms/src/test/resources/eventProcessorOutput.json create mode 100644 components/slice-analysis-ms/src/test/resources/getResponse.json create mode 100644 components/slice-analysis-ms/src/test/resources/measurementObjectList.json create mode 100644 components/slice-analysis-ms/src/test/resources/onsetMessage.json create mode 100644 components/slice-analysis-ms/src/test/resources/ricConfiguration.json create mode 100644 components/slice-analysis-ms/src/test/resources/ricToCellMapping.json create mode 100644 components/slice-analysis-ms/src/test/resources/ricToPrbMap.json create mode 100644 components/slice-analysis-ms/src/test/resources/ricToPrbOutput.json create mode 100644 components/slice-analysis-ms/src/test/resources/ricToThroughputMappingOutput.json create mode 100644 components/slice-analysis-ms/src/test/resources/serviceDetails.json create mode 100644 components/slice-analysis-ms/src/test/resources/sliceMeasurementList.json diff --git a/components/slice-analysis-ms/.checkstyle b/components/slice-analysis-ms/.checkstyle index 97b553d8..93d1ba04 100644 --- a/components/slice-analysis-ms/.checkstyle +++ b/components/slice-analysis-ms/.checkstyle @@ -1,21 +1,21 @@ - - + + - - + + - - + + - - + + diff --git a/components/slice-analysis-ms/pom.xml b/components/slice-analysis-ms/pom.xml index f8eb7fa6..08028404 100644 --- a/components/slice-analysis-ms/pom.xml +++ b/components/slice-analysis-ms/pom.xml @@ -139,6 +139,12 @@ jackson-core 2.11.0 + + net.javacrumbs.json-unit + json-unit-assertj + 2.14.0 + test + com.fasterxml.jackson.core jackson-databind @@ -192,6 +198,11 @@ 2.21.0 test + + com.openpojo + openpojo + 0.8.10 + junit junit diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/Application.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/Application.java index f522e008..f04e86d8 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/Application.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/Application.java @@ -37,9 +37,9 @@ import java.util.Map; import javax.sql.DataSource; -import org.onap.slice.analysis.ms.beans.ConfigPolicy; -import org.onap.slice.analysis.ms.beans.Configuration; import org.onap.slice.analysis.ms.controller.ConfigFetchFromCbs; +import org.onap.slice.analysis.ms.models.ConfigPolicy; +import org.onap.slice.analysis.ms.models.Configuration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.jdbc.DataSourceBuilder; diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/MainThread.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/MainThread.java new file mode 100644 index 00000000..925a196f --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/MainThread.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * son-handler + * ================================================================================ + * Copyright (C) 2019-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; + +import javax.annotation.PostConstruct; + +import org.onap.slice.analysis.ms.dmaap.NewPmNotification; +import org.onap.slice.analysis.ms.service.ConsumerThread; +import org.onap.slice.analysis.ms.service.PmThread; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * This class starts the pm thread and consumer thread + */ +@Component +public class MainThread { + + private static Logger log = LoggerFactory.getLogger(MainThread.class); + + @Autowired + private NewPmNotification newPmNotification; + + + /** + * main thread initialization. + */ + @PostConstruct + public void init() { + log.debug("initializing main thread"); + Thread pmThread = new Thread(new PmThread(newPmNotification)); + pmThread.start(); + Thread consumerThread = new Thread(new ConsumerThread()); + consumerThread.start(); + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/beans/ConfigPolicy.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/beans/ConfigPolicy.java deleted file mode 100644 index d4cd53b8..00000000 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/beans/ConfigPolicy.java +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************* - * ============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.beans; - -import java.util.Map; - -/** - * - * Model class for configuration policy - * - */ - -public class ConfigPolicy { - - private static ConfigPolicy instance = null; - private Map config; - - protected ConfigPolicy() { - - } - - /** - * Get instance of class. - */ - public static ConfigPolicy getInstance() { - if (instance == null) { - instance = new ConfigPolicy(); - } - return instance; - } - - /** - * Get config param of ConfigPolicy - */ - public Map getConfig() { - return config; - } - - /** - * set config param of ConfigPolicy - */ - public void setConfig(Map config) { - this.config = config; - } - - /** - * Return ConfigPolicy instance as String - */ - @Override - public String toString() { - return "ConfigPolicy [config=" + config + "]"; - } -} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/beans/Configuration.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/beans/Configuration.java deleted file mode 100644 index c7072343..00000000 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/beans/Configuration.java +++ /dev/null @@ -1,242 +0,0 @@ -/******************************************************************************* - * ============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.beans; - -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.reflect.TypeToken; - -import java.lang.reflect.Type; -import java.util.List; -import java.util.Map; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Model class for the application Configuration - */ -public class Configuration { - private static Logger log = LoggerFactory.getLogger(Configuration.class); - - private static Configuration instance = null; - private String pgHost; - private int pgPort; - private String pgUsername; - private String pgPassword; - private List dmaapServers; - private String configDbService; - private String cg; - private String cid; - private int pollingInterval; - private int pollingTimeout; - private String aafUsername; - private String aafPassword; - private Map streamsSubscribes; - private Map streamsPublishes; - - /** - * Check if topic is secure. - */ - public boolean isSecured() { - return (aafUsername != null); - - } - - public String getAafUsername() { - return aafUsername; - } - - public void setAafUsername(String aafUsername) { - this.aafUsername = aafUsername; - } - - public String getAafPassword() { - return aafPassword; - } - - public void setAafPassword(String aafPassword) { - this.aafPassword = aafPassword; - } - - public Map getStreamsSubscribes() { - return streamsSubscribes; - } - - public void setStreamsSubscribes(Map streamsSubscribes) { - this.streamsSubscribes = streamsSubscribes; - } - - public Map getStreamsPublishes() { - return streamsPublishes; - } - - public void setStreamsPublishes(Map streamsPublishes) { - this.streamsPublishes = streamsPublishes; - } - - protected Configuration() { - - } - - /** - * Get instance of class. - */ - public static Configuration getInstance() { - if (instance == null) { - instance = new Configuration(); - } - return instance; - } - - public String getCg() { - return cg; - } - - public void setCg(String cg) { - this.cg = cg; - } - - public String getCid() { - return cid; - } - - public void setCid(String cid) { - this.cid = cid; - } - - public int getPollingInterval() { - return pollingInterval; - } - - public void setPollingInterval(int pollingInterval) { - this.pollingInterval = pollingInterval; - } - - public int getPollingTimeout() { - return pollingTimeout; - } - - public void setPollingTimeout(int pollingTimeout) { - this.pollingTimeout = pollingTimeout; - } - - public String getPgHost() { - return pgHost; - } - - public void setPgHost(String pgHost) { - this.pgHost = pgHost; - } - - public int getPgPort() { - return pgPort; - } - - public void setPgPort(int pgPort) { - this.pgPort = pgPort; - } - - public String getPgUsername() { - return pgUsername; - } - - public void setPgUsername(String pgUsername) { - this.pgUsername = pgUsername; - } - - public String getPgPassword() { - return pgPassword; - } - - public void setPgPassword(String pgPassword) { - this.pgPassword = pgPassword; - } - - public List getDmaapServers() { - return dmaapServers; - } - - public void setDmaapServers(List dmaapServers) { - this.dmaapServers = dmaapServers; - } - - public String getConfigDbService() { - return configDbService; - } - - public void setConfigDbService(String configDbService) { - this.configDbService = configDbService; - } - - - - @Override - public String toString() { - return "Configuration [pgHost=" + pgHost + ", pgPort=" + pgPort + ", pgUsername=" + pgUsername + ", pgPassword=" - + pgPassword + ", dmaapServers=" + dmaapServers + ", configDbService=" + configDbService + ", cg=" + cg - + ", cid=" + cid + ", pollingInterval=" + pollingInterval + ", pollingTimeout=" + pollingTimeout - + ", aafUsername=" + aafUsername + ", aafPassword=" + aafPassword + ", streamsSubscribes=" - + streamsSubscribes + ", streamsPublishes=" + streamsPublishes + "]"; - } - - /** - * updates application configuration. - */ - public void updateConfigurationFromJsonObject(JsonObject jsonObject) { - - log.info("Updating configuration from CBS"); - - Type mapType = new TypeToken>() { - }.getType(); - - JsonObject subscribes = jsonObject.getAsJsonObject("streams_subscribes"); - streamsSubscribes = new Gson().fromJson(subscribes, mapType); - - JsonObject publishes = jsonObject.getAsJsonObject("streams_publishes"); - streamsPublishes = new Gson().fromJson(publishes, mapType); - - pgPort = jsonObject.get("postgres.port").getAsInt(); - pollingInterval = jsonObject.get("sliceanalysisms.pollingInterval").getAsInt(); - pgPassword = jsonObject.get("postgres.password").getAsString(); - pgUsername = jsonObject.get("postgres.username").getAsString(); - pgHost = jsonObject.get("postgres.host").getAsString(); - - JsonArray servers = jsonObject.getAsJsonArray("sliceanalysisms.dmaap.server"); - Type listType = new TypeToken>() { - }.getType(); - dmaapServers = new Gson().fromJson(servers, listType); - - cg = jsonObject.get("sliceanalysisms.cg").getAsString(); - cid = jsonObject.get("sliceanalysisms.cid").getAsString(); - configDbService = jsonObject.get("sliceanalysisms.configDb.service").getAsString(); - - pollingTimeout = jsonObject.get("sliceanalysisms.pollingInterval").getAsInt(); - - log.info("configuration from CBS {}", this); - - } - - - -} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceService.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceService.java new file mode 100644 index 00000000..488aca81 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/ConfigDbInterfaceService.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 java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.annotation.PostConstruct; + +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.ConfigDbRestClient; +import org.onap.slice.analysis.ms.utils.BeanUtil; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; + +/** + * + * Service for config db interfaces + * + */ +@Service +public class ConfigDbInterfaceService implements IConfigDbService { + + private ConfigDbRestClient restclient; + private String configDbBaseUrl = Configuration.getInstance().getConfigDbService(); + + @PostConstruct + public void init() { + this.restclient = BeanUtil.getBean(ConfigDbRestClient.class); + } + + /** + * Fetches the current configuration of an S-NSSAI from config DB + */ + public Map fetchCurrentConfigurationOfSlice(String snssai){ + Map responseMap = null; + String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/profile-config/"+snssai; + + ResponseEntity> response=restclient.sendGetRequest(reqUrl,new ParameterizedTypeReference>() { + }); + responseMap=response.getBody(); + return responseMap; + } + + /** + * Fetches the current configuration of RIC from config DB + */ + public Map> fetchCurrentConfigurationOfRIC(String snssai){ + String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/slice-config/"+snssai; + ResponseEntity>> response=restclient.sendGetRequest(reqUrl, new ParameterizedTypeReference>>() { + }); + return response.getBody(); + } + + /** + * Fetches all the network functions of an S-NSSAI from config DB + */ + public List fetchNetworkFunctionsOfSnssai(String snssai){ + List responseList=new ArrayList<>(); + String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/du-list/"+snssai; + ResponseEntity> response=restclient.sendGetRequest(reqUrl, new ParameterizedTypeReference>() { + }); + for(NetworkFunctionModel networkFn:response.getBody()) { + responseList.add(networkFn.getgNBDUId()); + } + return responseList; + } + + /** + * Fetches the RICS of an S-NSSAI from config DB + */ + public Map> fetchRICsOfSnssai(String snssai){ + + Map> responseMap=new HashMap<>(); + + String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/du-cell-list/"+snssai; + + ResponseEntity>> response=restclient.sendGetRequest(reqUrl, new ParameterizedTypeReference>>() { + }); + + + for (Map.Entry> entry : response.getBody().entrySet()) { + List cellslist=new ArrayList<>(); + for(CellsModel cellmodel:entry.getValue()) { + + cellslist.add(cellmodel.getCellLocalId()); + } + responseMap.put(entry.getKey(), cellslist); + } + + return responseMap; + } + + /** + * Fetches the details of a service + */ + public Map fetchServiceDetails(String snssai){ + String reqUrl=configDbBaseUrl+"/api/sdnc-config-db/v4/subscriber-details/"+snssai; + ResponseEntity> response=restclient.sendGetRequest(reqUrl, new ParameterizedTypeReference>() { + }); + return response.getBody(); + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/IConfigDbService.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/IConfigDbService.java new file mode 100644 index 00000000..3c8a9f8a --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/configdb/IConfigDbService.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * ============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 java.util.List; +import java.util.Map; + +/** + * + * Interface for config db service + * + */ +public interface IConfigDbService { + + public Map> fetchRICsOfSnssai(String snssai); + public List fetchNetworkFunctionsOfSnssai(String snssai); + public Map fetchCurrentConfigurationOfSlice(String snssai); + public Map> fetchCurrentConfigurationOfRIC(String snssai); + public Map fetchServiceDetails(String snssai); +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/controller/ConfigFetchFromCbs.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/controller/ConfigFetchFromCbs.java index e8e4e11b..ea148f25 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/controller/ConfigFetchFromCbs.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/controller/ConfigFetchFromCbs.java @@ -34,8 +34,8 @@ import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsRequests; import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.CbsRequest; import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.EnvProperties; import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext; -import org.onap.slice.analysis.ms.beans.ConfigPolicy; -import org.onap.slice.analysis.ms.beans.Configuration; +import org.onap.slice.analysis.ms.models.ConfigPolicy; +import org.onap.slice.analysis.ms.models.Configuration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/DmaapClient.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/DmaapClient.java index 6e0ea401..08a89541 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/DmaapClient.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/DmaapClient.java @@ -30,7 +30,7 @@ import java.util.concurrent.TimeUnit; import javax.annotation.PostConstruct; -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.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -69,23 +69,29 @@ public class DmaapClient { @SuppressWarnings("unchecked") public synchronized void startClient() { - Map streamSubscribes = Configuration.getInstance().getStreamsSubscribes(); + Map streamSubscribes = configuration.getStreamsSubscribes(); String pmTopicUrl = ((Map) ((Map) streamSubscribes .get("performance_management_topic")).get("dmaap_info")).get("topic_url"); String[] pmTopicSplit = pmTopicUrl.split("\\/"); String pmTopic = pmTopicSplit[pmTopicSplit.length - 1]; log.debug("pm topic : {}", pmTopic); + String policyResponseTopicUrl = ((Map) ((Map) streamSubscribes .get("dcae_cl_response_topic")).get("dmaap_info")).get("topic_url"); String[] policyResponseTopicUrlSplit = policyResponseTopicUrl.split("\\/"); String policyResponseTopic = policyResponseTopicUrlSplit[policyResponseTopicUrlSplit.length - 1]; log.debug("policyResponse Topic : {}", policyResponseTopic); - CambriaConsumer pmNotifCambriaConsumer = null; - CambriaConsumer policyResponseCambriaConsumer = null; - - pmNotifCambriaConsumer = dmaapUtils.buildConsumer(configuration, pmTopic); - policyResponseCambriaConsumer = dmaapUtils.buildConsumer(configuration, policyResponseTopic); + + String intelligentSlicingTopicUrl = ((Map) ((Map) streamSubscribes + .get("intelligent_slicing_topic")).get("dmaap_info")).get("topic_url"); + String[] intelligentSlicingTopicSplit = intelligentSlicingTopicUrl.split("\\/"); + String intelligentSlicingTopic = intelligentSlicingTopicSplit[intelligentSlicingTopicSplit.length - 1]; + log.debug("intelligent slicing topic : {}", pmTopic); + + CambriaConsumer pmNotifCambriaConsumer = dmaapUtils.buildConsumer(configuration, pmTopic); + CambriaConsumer policyResponseCambriaConsumer = dmaapUtils.buildConsumer(configuration, policyResponseTopic); + CambriaConsumer intelligentSlicingCambriaConsumer = dmaapUtils.buildConsumer(configuration, intelligentSlicingTopic); ScheduledExecutorService executorPool; @@ -97,16 +103,21 @@ public class DmaapClient { executorPool.scheduleAtFixedRate(pmNotificationConsumer, 0, configuration.getPollingInterval(), TimeUnit.SECONDS); - // create notification consumers for Policy - NotificationConsumer policyNotificationConsumer = new NotificationConsumer(policyResponseCambriaConsumer, - new PolicyNotificationCallback()); - // start policy notification consumer threads - executorPool = Executors.newScheduledThreadPool(10); - executorPool.scheduleAtFixedRate(policyNotificationConsumer, 0, configuration.getPollingInterval(), - TimeUnit.SECONDS); - - - + // create notification consumers for Policy + NotificationConsumer policyNotificationConsumer = new NotificationConsumer(policyResponseCambriaConsumer, + new PolicyNotificationCallback()); + // start policy notification consumer threads + executorPool = Executors.newScheduledThreadPool(10); + executorPool.scheduleAtFixedRate(policyNotificationConsumer, 0, configuration.getPollingInterval(), + TimeUnit.SECONDS); + + // create notification consumers for ML MS + NotificationConsumer intelligentSlicingConsumer = new NotificationConsumer(intelligentSlicingCambriaConsumer, + new IntelligentSlicingCallback()); + // start intelligent Slicing notification consumer threads + executorPool = Executors.newScheduledThreadPool(10); + executorPool.scheduleAtFixedRate(intelligentSlicingConsumer, 0, configuration.getPollingInterval(), + TimeUnit.SECONDS); } } diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/IntelligentSlicingCallback.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/IntelligentSlicingCallback.java new file mode 100644 index 00000000..dd6760ba --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/IntelligentSlicingCallback.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.dmaap; + +import java.io.IOException; + +import org.onap.slice.analysis.ms.models.MLOutputModel; +import org.onap.slice.analysis.ms.service.MLMessageProcessor; +import org.onap.slice.analysis.ms.utils.BeanUtil; +import org.slf4j.Logger; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +/** + * Handles Notification on dmaap for ML ms events + */ +public class IntelligentSlicingCallback implements NotificationCallback { + private static final Logger log = org.slf4j.LoggerFactory.getLogger(IntelligentSlicingCallback.class); + private MLMessageProcessor mlMsMessageProcessor; + + public IntelligentSlicingCallback() { + mlMsMessageProcessor = BeanUtil.getBean(MLMessageProcessor.class); + } + + /** + * Trigger on Notification from ML ms + */ + @Override + public void activateCallBack(String msg) { + handlePolicyNotification(msg); + } + + /** + * Parse and take actions on reception of Notification from ML ms + * @param msg + */ + private void handlePolicyNotification(String msg) { + log.info("Message received from ML ms: {}" ,msg); + ObjectMapper obj = new ObjectMapper(); + MLOutputModel output = null; + try { + output = obj.readValue(msg, new TypeReference(){}); + mlMsMessageProcessor.processMLMsg(output); + } + catch (IOException e) { + log.error("Error converting ML msg to object, {}",e.getMessage()); + } + } +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NewPmNotification.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NewPmNotification.java index 5c1f496b..66c3f706 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NewPmNotification.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NewPmNotification.java @@ -32,7 +32,7 @@ import org.springframework.stereotype.Component; @Component public class NewPmNotification { - private Boolean newNotif; + private boolean newNotif; /** * Initialize new pm Notification flag @@ -42,15 +42,15 @@ public class NewPmNotification { newNotif = false; } - public Boolean getNewNotif() { + public boolean getNewNotif() { return newNotif; } - public void setNewNotif(Boolean newNotif) { + public void setNewNotif(boolean newNotif) { this.newNotif = newNotif; } - public NewPmNotification(Boolean newNotif) { + public NewPmNotification(boolean newNotif) { super(); this.newNotif = newNotif; } diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NotificationCallback.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NotificationCallback.java index 427b4048..ce1ebd6f 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NotificationCallback.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/NotificationCallback.java @@ -21,7 +21,7 @@ package org.onap.slice.analysis.ms.dmaap; -public abstract class NotificationCallback { +public interface NotificationCallback { public abstract void activateCallBack(String msg); diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PmNotificationCallback.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PmNotificationCallback.java index 17e50aca..963165d2 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PmNotificationCallback.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PmNotificationCallback.java @@ -30,7 +30,7 @@ import org.slf4j.LoggerFactory; /** * Handles Notification on dmaap for Performance events */ -public class PmNotificationCallback extends NotificationCallback { +public class PmNotificationCallback implements NotificationCallback { private static Logger log = LoggerFactory.getLogger(PmNotificationCallback.class); diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PolicyDmaapClient.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PolicyDmaapClient.java index 81ca9ef1..06604040 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PolicyDmaapClient.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PolicyDmaapClient.java @@ -25,7 +25,7 @@ import com.att.nsa.cambria.client.CambriaBatchingPublisher; import java.io.IOException; import java.util.Map; -import org.onap.slice.analysis.ms.beans.Configuration; +import org.onap.slice.analysis.ms.models.Configuration; import org.onap.slice.analysis.ms.utils.DmaapUtils; /** diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PolicyNotificationCallback.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PolicyNotificationCallback.java index 57aadd18..146b60a9 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PolicyNotificationCallback.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/dmaap/PolicyNotificationCallback.java @@ -26,7 +26,7 @@ import org.slf4j.Logger; /** * Handles Notification on dmaap for Policy events */ -public class PolicyNotificationCallback extends NotificationCallback { +public class PolicyNotificationCallback implements NotificationCallback { private static final Logger log = org.slf4j.LoggerFactory.getLogger(PolicyNotificationCallback.class); @@ -43,7 +43,7 @@ public class PolicyNotificationCallback extends NotificationCallback { * @param msg */ private void handlePolicyNotification(String msg) { - log.info("Message received from policy: " +msg); - //TBD - actions to perform on reception of notification from policy + log.info("Message received from policy: " +msg); + //TBD - actions to perform on reception of notification from policy } } diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/CUModel.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/CUModel.java new file mode 100644 index 00000000..6473ab23 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/CUModel.java @@ -0,0 +1,101 @@ +/******************************************************************************* + * ============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 java.util.List; + +/** + * Model class for CU model + */ +public class CUModel { + + private String gNBCUName; + private String nearRTRICId; + private List cellCUList; + + public String getgNBCUName() { + return gNBCUName; + } + + public void setgNBCUName(String gNBCUName) { + this.gNBCUName = gNBCUName; + } + + public String getNearRTRICId() { + return nearRTRICId; + } + + public void setNearRTRICId(String nearRTRICId) { + this.nearRTRICId = nearRTRICId; + } + + public List getCellCUList() { + return cellCUList; + } + + public void setCellCUList(List cellCUList) { + this.cellCUList = cellCUList; + } + + @Override + public String toString() { + return "CUModel [gNBCUName=" + gNBCUName + ", nearRTRICId=" + nearRTRICId + ", cellCUList=" + cellCUList + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((cellCUList == null) ? 0 : cellCUList.hashCode()); + result = prime * result + ((gNBCUName == null) ? 0 : gNBCUName.hashCode()); + result = prime * result + ((nearRTRICId == null) ? 0 : nearRTRICId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CUModel other = (CUModel) obj; + if (cellCUList == null) { + if (other.cellCUList != null) + return false; + } else if (!cellCUList.equals(other.cellCUList)) + return false; + if (gNBCUName == null) { + if (other.gNBCUName != null) + return false; + } else if (!gNBCUName.equals(other.gNBCUName)) + return false; + if (nearRTRICId == null) { + if (other.nearRTRICId != null) + return false; + } else if (!nearRTRICId.equals(other.nearRTRICId)) + return false; + return true; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/CellCUList.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/CellCUList.java new file mode 100644 index 00000000..cd566778 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/CellCUList.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * ============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; + +/** + * Model class for cell information + */ +public class CellCUList { + + private Integer cellLocalId; + private ConfigData configData; + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((cellLocalId == null) ? 0 : cellLocalId.hashCode()); + result = prime * result + ((configData == null) ? 0 : configData.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CellCUList other = (CellCUList) obj; + if (cellLocalId == null) { + if (other.cellLocalId != null) + return false; + } else if (!cellLocalId.equals(other.cellLocalId)) + return false; + if (configData == null) { + if (other.configData != null) + return false; + } else if (!configData.equals(other.configData)) + return false; + return true; + } + + public Integer getCellLocalId() { + return cellLocalId; + } + + public void setCellLocalId(Integer cellLocalId) { + this.cellLocalId = cellLocalId; + } + + public ConfigData getConfigData() { + return configData; + } + + public void setConfigData(ConfigData configData) { + this.configData = configData; + } + + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/ConfigData.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/ConfigData.java new file mode 100644 index 00000000..f8711154 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/ConfigData.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * ============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; + +/** + * Model class for the config data + */ +public class ConfigData { + + private String maxNumberofConns; + private String predictedMaxNumberofConns; + private String lastUpdatedTS; + + public String getMaxNumberofConns() { + return maxNumberofConns; + } + + public void setMaxNumberofConns(String maxNumberofConns) { + this.maxNumberofConns = maxNumberofConns; + } + + public String getPredictedMaxNumberofConns() { + return predictedMaxNumberofConns; + } + + public void setPredictedMaxNumberofConns(String predictedMaxNumberofConns) { + this.predictedMaxNumberofConns = predictedMaxNumberofConns; + } + + public String getLastUpdatedTS() { + return lastUpdatedTS; + } + + public void setLastUpdatedTS(String lastUpdatedTS) { + this.lastUpdatedTS = lastUpdatedTS; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((lastUpdatedTS == null) ? 0 : lastUpdatedTS.hashCode()); + result = prime * result + ((maxNumberofConns == null) ? 0 : maxNumberofConns.hashCode()); + result = prime * result + ((predictedMaxNumberofConns == null) ? 0 : predictedMaxNumberofConns.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ConfigData other = (ConfigData) obj; + if (lastUpdatedTS == null) { + if (other.lastUpdatedTS != null) + return false; + } else if (!lastUpdatedTS.equals(other.lastUpdatedTS)) + return false; + if (maxNumberofConns == null) { + if (other.maxNumberofConns != null) + return false; + } else if (!maxNumberofConns.equals(other.maxNumberofConns)) + return false; + if (predictedMaxNumberofConns == null) { + if (other.predictedMaxNumberofConns != null) + return false; + } else if (!predictedMaxNumberofConns.equals(other.predictedMaxNumberofConns)) + return false; + return true; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/ConfigPolicy.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/ConfigPolicy.java new file mode 100644 index 00000000..6f2b4ec6 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/ConfigPolicy.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * ============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 java.util.Map; + +/** + * + * Model class for configuration policy + * + */ + +public class ConfigPolicy { + + private static ConfigPolicy instance = null; + private Map config; + + protected ConfigPolicy() { + + } + + /** + * Get instance of class. + */ + public static ConfigPolicy getInstance() { + if (instance == null) { + instance = new ConfigPolicy(); + } + return instance; + } + + /** + * Get config param of ConfigPolicy + */ + public Map getConfig() { + return config; + } + + /** + * set config param of ConfigPolicy + */ + public void setConfig(Map config) { + this.config = config; + } + + /** + * Return ConfigPolicy instance as String + */ + @Override + public String toString() { + return "ConfigPolicy [config=" + config + "]"; + } +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/Configuration.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/Configuration.java new file mode 100644 index 00000000..25a80463 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/Configuration.java @@ -0,0 +1,265 @@ +/******************************************************************************* + * ============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 java.lang.reflect.Type; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.google.gson.reflect.TypeToken; + +/** + * Model class for the application Configuration + */ +public class Configuration { + private static Logger log = LoggerFactory.getLogger(Configuration.class); + + private static Configuration instance = null; + private String pgHost; + private int pgPort; + private String pgUsername; + private String pgPassword; + private List dmaapServers; + private String configDbService; + private String cg; + private String cid; + private int pollingInterval; + private int pollingTimeout; + private String aafUsername; + private String aafPassword; + private Map streamsSubscribes; + private Map streamsPublishes; + private int samples; + private int minPercentageChange; + private long initialDelaySeconds; + /** + * Check if topic is secure. + */ + public boolean isSecured() { + return (aafUsername != null); + + } + + public String getAafUsername() { + return aafUsername; + } + + public void setAafUsername(String aafUsername) { + this.aafUsername = aafUsername; + } + + public String getAafPassword() { + return aafPassword; + } + + public void setAafPassword(String aafPassword) { + this.aafPassword = aafPassword; + } + + public Map getStreamsSubscribes() { + return streamsSubscribes; + } + + public void setStreamsSubscribes(Map streamsSubscribes) { + this.streamsSubscribes = streamsSubscribes; + } + + public Map getStreamsPublishes() { + return streamsPublishes; + } + + public void setStreamsPublishes(Map streamsPublishes) { + this.streamsPublishes = streamsPublishes; + } + + protected Configuration() { + + } + + /** + * Get instance of class. + */ + public static Configuration getInstance() { + if (instance == null) { + instance = new Configuration(); + } + return instance; + } + + public String getCg() { + return cg; + } + + public void setCg(String cg) { + this.cg = cg; + } + + public String getCid() { + return cid; + } + + public void setCid(String cid) { + this.cid = cid; + } + + public int getPollingInterval() { + return pollingInterval; + } + + public void setPollingInterval(int pollingInterval) { + this.pollingInterval = pollingInterval; + } + + public int getPollingTimeout() { + return pollingTimeout; + } + + public void setPollingTimeout(int pollingTimeout) { + this.pollingTimeout = pollingTimeout; + } + + public String getPgHost() { + return pgHost; + } + + public void setPgHost(String pgHost) { + this.pgHost = pgHost; + } + + public int getPgPort() { + return pgPort; + } + + public void setPgPort(int pgPort) { + this.pgPort = pgPort; + } + + public String getPgUsername() { + return pgUsername; + } + + public void setPgUsername(String pgUsername) { + this.pgUsername = pgUsername; + } + + public String getPgPassword() { + return pgPassword; + } + + public void setPgPassword(String pgPassword) { + this.pgPassword = pgPassword; + } + + public List getDmaapServers() { + return dmaapServers; + } + + public void setDmaapServers(List dmaapServers) { + this.dmaapServers = dmaapServers; + } + + public String getConfigDbService() { + return configDbService; + } + + public void setConfigDbService(String configDbService) { + this.configDbService = configDbService; + } + + public int getSamples() { + return samples; + } + + public void setSamples(int samples) { + this.samples = samples; + } + + public int getMinPercentageChange() { + return minPercentageChange; + } + + public void setMinPercentageChange(int minPercentageChange) { + this.minPercentageChange = minPercentageChange; + } + + public long getInitialDelaySeconds() { + return initialDelaySeconds; + } + + public void setInitialDelaySeconds(long initialDelaySeconds) { + this.initialDelaySeconds = initialDelaySeconds; + } + + @Override + public String toString() { + return "Configuration [pgHost=" + pgHost + ", pgPort=" + pgPort + ", pgUsername=" + pgUsername + ", pgPassword=" + + pgPassword + ", dmaapServers=" + dmaapServers + ", configDbService=" + configDbService + ", cg=" + cg + + ", cid=" + cid + ", pollingInterval=" + pollingInterval + ", pollingTimeout=" + pollingTimeout + + ", aafUsername=" + aafUsername + ", aafPassword=" + aafPassword + ", streamsSubscribes=" + + streamsSubscribes + ", streamsPublishes=" + streamsPublishes + ", samples=" + samples + + ", minPercentageChange=" + minPercentageChange + ", initialDelaySeconds=" + initialDelaySeconds + "]"; + } + + /** + * updates application configuration. + */ + public void updateConfigurationFromJsonObject(JsonObject jsonObject) { + + log.info("Updating configuration from CBS"); + + Type mapType = new TypeToken>() { + }.getType(); + + JsonObject subscribes = jsonObject.getAsJsonObject("streams_subscribes"); + streamsSubscribes = new Gson().fromJson(subscribes, mapType); + + JsonObject publishes = jsonObject.getAsJsonObject("streams_publishes"); + streamsPublishes = new Gson().fromJson(publishes, mapType); + + pgPort = jsonObject.get("postgres.port").getAsInt(); + pollingInterval = jsonObject.get("sliceanalysisms.pollingInterval").getAsInt(); + pgPassword = jsonObject.get("postgres.password").getAsString(); + pgUsername = jsonObject.get("postgres.username").getAsString(); + pgHost = jsonObject.get("postgres.host").getAsString(); + + JsonArray servers = jsonObject.getAsJsonArray("sliceanalysisms.dmaap.server"); + Type listType = new TypeToken>() {}.getType(); + dmaapServers = new Gson().fromJson(servers, listType); + + cg = jsonObject.get("sliceanalysisms.cg").getAsString(); + cid = jsonObject.get("sliceanalysisms.cid").getAsString(); + configDbService = jsonObject.get("sliceanalysisms.configDb.service").getAsString(); + + pollingTimeout = jsonObject.get("sliceanalysisms.pollingTimeout").getAsInt(); + samples = jsonObject.get("sliceanalysisms.samples").getAsInt(); + minPercentageChange = jsonObject.get("sliceanalysisms.minPercentageChange").getAsInt(); + initialDelaySeconds = jsonObject.get("sliceanalysisms.initialDelaySeconds").getAsLong(); + + log.info("configuration from CBS {}", this); + } +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/MLOutputModel.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/MLOutputModel.java new file mode 100644 index 00000000..7533d215 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/MLOutputModel.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * ============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 java.util.List; + +/** + * Model class for ML output object + */ +public class MLOutputModel { + private String snssai; + private List data; + public String getSnssai() { + return snssai; + } + public void setSnssai(String snssai) { + this.snssai = snssai; + } + public List getData() { + return data; + } + public void setData(List data) { + this.data = data; + } + + @Override + public String toString() { + return "MLOutputModel [snssai=" + snssai + ", data=" + data + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((data == null) ? 0 : data.hashCode()); + result = prime * result + ((snssai == null) ? 0 : snssai.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + MLOutputModel other = (MLOutputModel) obj; + if (data == null) { + if (other.data != null) + return false; + } else if (!data.equals(other.data)) + return false; + if (snssai == null) { + if (other.snssai != null) + return false; + } else if (!snssai.equals(other.snssai)) + return false; + return true; + } + + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/MeasurementObject.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/MeasurementObject.java new file mode 100644 index 00000000..047c9856 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/MeasurementObject.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * ============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 java.util.Map; + +/** + * Model class for the Measurement Object + */ +public class MeasurementObject { + private String measurementObjectId; + private Map pmData; + + public String getMeasurementObjectId() { + return measurementObjectId; + } + + public void setMeasurementObjectId(String measurementObjectId) { + this.measurementObjectId = measurementObjectId; + } + + public Map getPmData() { + return pmData; + } + + public void setPmData(Map pmData) { + this.pmData = pmData; + } + + public MeasurementObject(String measurementObjectId, Map pmData) { + super(); + this.measurementObjectId = measurementObjectId; + this.pmData = pmData; + } + + public MeasurementObject(String measurementObjectId) { + super(); + this.measurementObjectId = measurementObjectId; + } + + public MeasurementObject() { + + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((measurementObjectId == null) ? 0 : measurementObjectId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + MeasurementObject other = (MeasurementObject) obj; + if (measurementObjectId == null) { + if (other.measurementObjectId != null) + return false; + } else if (!measurementObjectId.equals(other.measurementObjectId)) + return false; + return true; + } + + @Override + public String toString() { + return "MeasurementObject [measurementObjectId=" + measurementObjectId + ", pmData=" + pmData + "]"; + } + + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/SubCounter.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/SubCounter.java new file mode 100644 index 00000000..2990d365 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/SubCounter.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * ============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; + +/** + * Model class for the SubCounter Object which servers as key for PM data Queue + */ +public final class SubCounter { + final String networkFunction; + final String measuredObject; + + public SubCounter(String networkFunction, String measuredObject) { + super(); + this.networkFunction = networkFunction; + this.measuredObject = measuredObject; + } + + public String getNetworkFunction() { + return networkFunction; + } + + public String getMeasuredObject() { + return measuredObject; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((networkFunction == null) ? 0 : networkFunction.hashCode()); + result = prime * result + ((measuredObject == null) ? 0 : measuredObject.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + SubCounter other = (SubCounter) obj; + if (networkFunction == null) { + if (other.networkFunction != null) + return false; + } else if (!networkFunction.equals(other.networkFunction)) + return false; + if (measuredObject == null) { + if (other.measuredObject != null) + return false; + } else if (!measuredObject.equals(other.measuredObject)) + return false; + return true; + } +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/configdb/CellsModel.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/configdb/CellsModel.java new file mode 100644 index 00000000..e024bf7c --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/configdb/CellsModel.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * ============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.configdb; + + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Model class for the CellsModel Object + */ + +@JsonIgnoreProperties(ignoreUnknown = true) +public class CellsModel { + + private String cellLocalId; + + + public String getCellLocalId() { + return cellLocalId; + } + + public void setCellLocalId(String cellLocalId) { + this.cellLocalId = cellLocalId; + } + + @Override + public String toString() { + return "CellsModel [cellLocalId=" + cellLocalId + "]"; + } + + + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/configdb/NetworkFunctionModel.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/configdb/NetworkFunctionModel.java new file mode 100644 index 00000000..46291d51 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/configdb/NetworkFunctionModel.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * ============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.configdb; + + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +/** + * Model class for the NetworkFunction Object + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class NetworkFunctionModel { + + private String gNBDUId; + + + public String getgNBDUId() { + return gNBDUId; + } + + public void setgNBDUId(String gNBDUId) { + this.gNBDUId = gNBDUId; + } + + @Override + public String toString() { + return "NetworkFunctionModel [gNBDUId=" + gNBDUId + "]"; + } + + + + + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/CommonEventHeader.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/CommonEventHeader.java new file mode 100644 index 00000000..08c2b983 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/CommonEventHeader.java @@ -0,0 +1,138 @@ +/******************************************************************************* + * ============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; + +/** + * Model class for the CommonEventHeader Object + */ +public class CommonEventHeader { + + private String domain; + private String eventId; + private long sequence; + private String eventName; + private String sourceName; + private String reportingEntityName; + private String priority; + private long startEpochMicrosec; + private long lastEpochMicrosec; + private String version; + private String vesEventListenerVersion; + private String timeZoneOffset; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getEventId() { + return eventId; + } + + public void setEventId(String eventId) { + this.eventId = eventId; + } + + public long getSequence() { + return sequence; + } + + public void setSequence(long sequence) { + this.sequence = sequence; + } + + public String getEventName() { + return eventName; + } + + public void setEventName(String eventName) { + this.eventName = eventName; + } + + public String getSourceName() { + return sourceName; + } + + public void setSourceName(String sourceName) { + this.sourceName = sourceName; + } + + public String getReportingEntityName() { + return reportingEntityName; + } + + public void setReportingEntityName(String reportingEntityName) { + this.reportingEntityName = reportingEntityName; + } + + public String getPriority() { + return priority; + } + + public void setPriority(String priority) { + this.priority = priority; + } + + public long getStartEpochMicrosec() { + return startEpochMicrosec; + } + + public void setStartEpochMicrosec(long startEpochMicrosec) { + this.startEpochMicrosec = startEpochMicrosec; + } + + public long getLastEpochMicrosec() { + return lastEpochMicrosec; + } + + public void setLastEpochMicrosec(long lastEpochMicrosec) { + this.lastEpochMicrosec = lastEpochMicrosec; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getVesEventListenerVersion() { + return vesEventListenerVersion; + } + + public void setVesEventListenerVersion(String vesEventListenerVersion) { + this.vesEventListenerVersion = vesEventListenerVersion; + } + + public String getTimeZoneOffset() { + return timeZoneOffset; + } + + public void setTimeZoneOffset(String timeZoneOffset) { + this.timeZoneOffset = timeZoneOffset; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/Event.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/Event.java new file mode 100644 index 00000000..4e41e261 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/Event.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * ============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; + +/** + * Model class for the Event Object + */ +public class Event { + + private CommonEventHeader commonEventHeader; + private Perf3gppFields perf3gppFields; + + public CommonEventHeader getCommonEventHeader() { + return commonEventHeader; + } + + public void setCommonEventHeader(CommonEventHeader commonEventHeader) { + this.commonEventHeader = commonEventHeader; + } + + public Perf3gppFields getPerf3gppFields() { + return perf3gppFields; + } + + public void setPerf3gppFields(Perf3gppFields perf3gppFields) { + this.perf3gppFields = perf3gppFields; + } +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasDataCollection.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasDataCollection.java new file mode 100644 index 00000000..f5e36c28 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasDataCollection.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * ============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 java.util.List; + +/** + * Model class for the MeasDataCollection Object + */ +public class MeasDataCollection { + + private long granularityPeriod; + private String measuredEntityUserName; + private String measuredEntityDn; + private String measuredEntitySoftwareVersion; + private List measInfoList; + + public long getGranularityPeriod() { + return granularityPeriod; + } + + public void setGranularityPeriod(long granularityPeriod) { + this.granularityPeriod = granularityPeriod; + } + + public String getMeasuredEntityUserName() { + return measuredEntityUserName; + } + + public void setMeasuredEntityUserName(String measuredEntityUserName) { + this.measuredEntityUserName = measuredEntityUserName; + } + + public String getMeasuredEntityDn() { + return measuredEntityDn; + } + + public void setMeasuredEntityDn(String measuredEntityDn) { + this.measuredEntityDn = measuredEntityDn; + } + + public String getMeasuredEntitySoftwareVersion() { + return measuredEntitySoftwareVersion; + } + + public void setMeasuredEntitySoftwareVersion(String measuredEntitySoftwareVersion) { + this.measuredEntitySoftwareVersion = measuredEntitySoftwareVersion; + } + + public List getMeasInfoList() { + return measInfoList; + } + + public void setMeasInfoList(List measInfoList) { + this.measInfoList = measInfoList; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasInfoId.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasInfoId.java new file mode 100644 index 00000000..5b8f6b31 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasInfoId.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * ============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; + +/** + * Model class for the MeasInfoId Object + */ +public class MeasInfoId { + + private String sMeasInfoId; + + public String getsMeasInfoId() { + return sMeasInfoId; + } + + public void setsMeasInfoId(String sMeasInfoId) { + this.sMeasInfoId = sMeasInfoId; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasInfoList.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasInfoList.java new file mode 100644 index 00000000..34283a7d --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasInfoList.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * ============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 java.util.List; + +/** + * Model class for the MeasInfoList Object + */ +public class MeasInfoList { + + private MeasInfoId measInfoId; + private MeasTypes measTypes; + private List measValuesList = null; + + public MeasInfoId getMeasInfoId() { + return measInfoId; + } + + public void setMeasInfoId(MeasInfoId measInfoId) { + this.measInfoId = measInfoId; + } + + public MeasTypes getMeasTypes() { + return measTypes; + } + + public void setMeasTypes(MeasTypes measTypes) { + this.measTypes = measTypes; + } + + public List getMeasValuesList() { + return measValuesList; + } + + public void setMeasValuesList(List measValuesList) { + this.measValuesList = measValuesList; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasResult.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasResult.java new file mode 100644 index 00000000..1e418001 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasResult.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * ============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; + +/** + * Model class for the MeasResult Object + */ +public class MeasResult { + + private int p; + private String sValue; + + public int getP() { + return p; + } + + public void setP(int p) { + this.p = p; + } + + public String getsValue() { + return sValue; + } + + public void setsValue(String sValue) { + this.sValue = sValue; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasTypes.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasTypes.java new file mode 100644 index 00000000..f441166d --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasTypes.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * ============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 java.util.List; + +/** + * Model class for the MeasTypes Object + */ +public class MeasTypes { + + private List sMeasTypesList; + + public List getsMeasTypesList() { + return sMeasTypesList; + } + + public void setsMeasTypesList(List sMeasTypesList) { + this.sMeasTypesList = sMeasTypesList; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasValuesList.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasValuesList.java new file mode 100644 index 00000000..38b7c23c --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/MeasValuesList.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * ============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 java.util.List; + +/** + * Model class for the MeasValuesList Object + */ +public class MeasValuesList { + + private String measObjInstId; + private String suspectFlag; + private List measResults = null; + + public String getMeasObjInstId() { + return measObjInstId; + } + + public void setMeasObjInstId(String measObjInstId) { + this.measObjInstId = measObjInstId; + } + + public String getSuspectFlag() { + return suspectFlag; + } + + public void setSuspectFlag(String suspectFlag) { + this.suspectFlag = suspectFlag; + } + + public List getMeasResults() { + return measResults; + } + + public void setMeasResults(List measResults) { + this.measResults = measResults; + } +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/Perf3gppFields.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/Perf3gppFields.java new file mode 100644 index 00000000..dfe9cbca --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/Perf3gppFields.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * ============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; + +/** + * Model class for the Perf3gppFields Object + */ +public class Perf3gppFields { + + private String perf3gppFieldsVersion; + private MeasDataCollection measDataCollection; + + public String getPerf3gppFieldsVersion() { + return perf3gppFieldsVersion; + } + + public void setPerf3gppFieldsVersion(String perf3gppFieldsVersion) { + this.perf3gppFieldsVersion = perf3gppFieldsVersion; + } + + public MeasDataCollection getMeasDataCollection() { + return measDataCollection; + } + + public void setMeasDataCollection(MeasDataCollection measDataCollection) { + this.measDataCollection = measDataCollection; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/PmNotification.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/PmNotification.java new file mode 100644 index 00000000..a2dc49e8 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/pmnotification/PmNotification.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * ============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; + +/** + * Model class for the PmNotification Object + */ +public class PmNotification { + + Event event; + + public Event getEvent() { + return event; + } + + public void setEvent(Event event) { + this.event = event; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/AAI.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/AAI.java new file mode 100644 index 00000000..73d94d75 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/AAI.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * ============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 com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Model class for the AAI Object + */ +public class AAI { + @JsonProperty("vserver.is-closed-loop-disabled") + private String vserverIsClosedLoopDisabled; + @JsonProperty("vserver.prov-status") + private String vserverProvStatus; + @JsonProperty("vserver.vserver-name") + private String vserverVserverName; + + public String getVserverIsClosedLoopDisabled() { + return vserverIsClosedLoopDisabled; + } + + public void setVserverIsClosedLoopDisabled(String vserverIsClosedLoopDisabled) { + this.vserverIsClosedLoopDisabled = vserverIsClosedLoopDisabled; + } + + public String getVserverProvStatus() { + return vserverProvStatus; + } + + public void setVserverProvStatus(String vserverProvStatus) { + this.vserverProvStatus = vserverProvStatus; + } + + public String getVserverVserverName() { + return vserverVserverName; + } + + public void setVserverVserverName(String vserverVserverName) { + this.vserverVserverName = vserverVserverName; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/AdditionalProperties.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/AdditionalProperties.java new file mode 100644 index 00000000..0d4e4bd8 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/AdditionalProperties.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * ============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 java.util.List; +import java.util.Map; + +/** + * Model class for the AdditionalProperties Object + */ +public class AdditionalProperties { + private String modifyAction; + private List snssaiList; + private String sliceProfileId; + private T resourceConfig; + private Map nsiInfo; + private String scriptName; + public String getModifyAction() { + return modifyAction; + } + public void setModifyAction(String modifyAction) { + this.modifyAction = modifyAction; + } + public List getSnssaiList() { + return snssaiList; + } + public void setSnssaiList(List snssaiList) { + this.snssaiList = snssaiList; + } + public String getSliceProfileId() { + return sliceProfileId; + } + public void setSliceProfileId(String sliceProfileId) { + this.sliceProfileId = sliceProfileId; + } + public T getResourceConfig() { + return resourceConfig; + } + public void setResourceConfig(T resourceConfig) { + this.resourceConfig = resourceConfig; + } + public Map getNsiInfo() { + return nsiInfo; + } + public void setNsiInfo(Map nsiInfo) { + this.nsiInfo = nsiInfo; + } + public String getScriptName() { + return scriptName; + } + public void setScriptName(String scriptName) { + this.scriptName = scriptName; + } + + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/OnsetMessage.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/OnsetMessage.java new file mode 100644 index 00000000..671a9561 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/OnsetMessage.java @@ -0,0 +1,136 @@ +/******************************************************************************* + * ============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 com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Model class for the OnsetMessage Object + */ +public class OnsetMessage { + + private String closedLoopControlName; + private Long closedLoopAlarmStart; + private String closedLoopEventClient; + private String closedLoopEventStatus; + private String requestID; + + @JsonProperty("target_type") + private String targetType; + + @JsonProperty("AAI") + private AAI aai; + + private String target; + private Payload payload; + private String from; + private String version; + + public String getClosedLoopControlName() { + return closedLoopControlName; + } + + public void setClosedLoopControlName(String closedLoopControlName) { + this.closedLoopControlName = closedLoopControlName; + } + + public Long getClosedLoopAlarmStart() { + return closedLoopAlarmStart; + } + + public void setClosedLoopAlarmStart(Long closedLoopAlarmStart) { + this.closedLoopAlarmStart = closedLoopAlarmStart; + } + + public String getClosedLoopEventClient() { + return closedLoopEventClient; + } + + public void setClosedLoopEventClient(String closedLoopEventClient) { + this.closedLoopEventClient = closedLoopEventClient; + } + + public String getClosedLoopEventStatus() { + return closedLoopEventStatus; + } + + public void setClosedLoopEventStatus(String closedLoopEventStatus) { + this.closedLoopEventStatus = closedLoopEventStatus; + } + + public String getRequestID() { + return requestID; + } + + public void setRequestID(String requestID) { + this.requestID = requestID; + } + + public String getTargetType() { + return targetType; + } + + public void setTargetType(String targetType) { + this.targetType = targetType; + } + + public String getTarget() { + return target; + } + + public void setTarget(String target) { + this.target = target; + } + + public AAI getAai() { + return aai; + } + + public void setAai(AAI aAI) { + this.aai = aAI; + } + + public Payload getPayload() { + return payload; + } + + public void setPayload(Payload payload) { + this.payload = payload; + } + + public String getFrom() { + return from; + } + + public void setFrom(String from) { + this.from = from; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/Payload.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/Payload.java new file mode 100644 index 00000000..57aab994 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/models/policy/Payload.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * ============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; + +/** + * Model class for the Paylaod Object + */ +public class Payload { + + private String name; + private String serviceInstanceID; + private String globalSubscriberId; + private String subscriptionServiceType; + private String networkType; + private AdditionalProperties additionalProperties; + + + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public String getServiceInstanceID() { + return serviceInstanceID; + } + + + public void setServiceInstanceID(String serviceInstanceId) { + this.serviceInstanceID = serviceInstanceId; + } + + + public String getGlobalSubscriberId() { + return globalSubscriberId; + } + + + public void setGlobalSubscriberId(String globalSubscriberId) { + this.globalSubscriberId = globalSubscriberId; + } + + + public String getSubscriptionServiceType() { + return subscriptionServiceType; + } + + + public void setSubscriptionServiceType(String subscriptionServiceType) { + this.subscriptionServiceType = subscriptionServiceType; + } + + + public String getNetworkType() { + return networkType; + } + + + public void setNetworkType(String networkType) { + this.networkType = networkType; + } + + + public AdditionalProperties getAdditionalProperties() { + return additionalProperties; + } + + + public void setAdditionalProperties(AdditionalProperties additionalProperties) { + this.additionalProperties = additionalProperties; + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/restclients/ConfigDbRestClient.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/restclients/ConfigDbRestClient.java new file mode 100644 index 00000000..dbc42912 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/restclients/ConfigDbRestClient.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * ============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 java.util.Collections; + +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; + +/** + * This class represents rest client for config db interfaces + */ +@Component +public class ConfigDbRestClient extends RestClient { + + public ConfigDbRestClient() { + super(); + } + + /** + * Send Post Request to Config DB. + */ + + public ResponseEntity sendPostRequest(String requestUrl, String requestBody, + ParameterizedTypeReference responseType) { + HttpHeaders headers = new HttpHeaders(); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + headers.setContentType(MediaType.APPLICATION_JSON); + return super.sendPostRequest(headers, requestUrl, requestBody, responseType); + } + + /** + * Send Get Request to Config DB. + */ + + public ResponseEntity sendGetRequest(String requestUrl, ParameterizedTypeReference responseType) { + HttpHeaders headers = new HttpHeaders(); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + headers.setContentType(MediaType.APPLICATION_JSON); + return super.sendGetRequest(headers, requestUrl, responseType); + } +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/restclients/RestClient.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/restclients/RestClient.java new file mode 100644 index 00000000..5946fd1d --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/restclients/RestClient.java @@ -0,0 +1,80 @@ +/******************************************************************************* + * ============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 org.onap.slice.analysis.ms.utils.BeanUtil; +import org.slf4j.Logger; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + +/** + * This class is for base rest client + */ +@Component +public class RestClient { + + private static final String EXCEPTION_MSG = "Exception caught during request {}"; + private static final Logger log = org.slf4j.LoggerFactory.getLogger(RestClient.class); + + protected RestClient() { + + } + + /** + * Post Request Template. + */ + + public ResponseEntity sendPostRequest(HttpHeaders headers, String requestUrl, String requestBody, + ParameterizedTypeReference responseType) { + HttpEntity requestEntity = new HttpEntity<>(requestBody, headers); + try { + RestTemplate restTemplate = BeanUtil.getBean(RestTemplate.class); + return restTemplate.exchange(requestUrl, HttpMethod.POST, requestEntity, responseType); + } catch (Exception e) { + log.debug(EXCEPTION_MSG, e.getMessage()); + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } + + /** + * Get Request Template. + */ + + public ResponseEntity sendGetRequest(HttpHeaders headers, String requestUrl, ParameterizedTypeReference responseType) { + HttpEntity requestEntity = new HttpEntity<>(headers); + try { + RestTemplate restTemplate = BeanUtil.getBean(RestTemplate.class); + return restTemplate.exchange(requestUrl, HttpMethod.GET, requestEntity, responseType); + } catch (Exception e) { + log.debug(EXCEPTION_MSG, e.getMessage()); + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } + + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/AverageCalculator.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/AverageCalculator.java new file mode 100644 index 00000000..a003e9c0 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/AverageCalculator.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * ============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.util.ArrayList; +import java.util.List; + +import javax.annotation.PostConstruct; + +import org.onap.slice.analysis.ms.models.MeasurementObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +/** + * This class has utility methods for calculating the average of samples + */ +@Component +public class AverageCalculator { + private static Logger log = LoggerFactory.getLogger(AverageCalculator.class); + private List pmNames; + + @PostConstruct + public void init() { + pmNames = new ArrayList<>(); + pmNames.add("PrbUsedDl"); + pmNames.add("PrbUsedUl"); + } + + /** + * Find average of samples + */ + public List findAverageOfSamples(List> samples) { + int numOfSamples = samples.size(); + List result = new ArrayList<>(); + samples.forEach(sample -> + sample.forEach(cellMeasObj -> { + int index = result.indexOf(cellMeasObj); + if(index != -1) { + result.set(index, findSum(result.get(index), cellMeasObj)); + } + else { + result.add(cellMeasObj); + } + }) + ); + return findAvg(result, numOfSamples); + } + + /** + * Calculate the sum + */ + public MeasurementObject findSum(MeasurementObject existing, MeasurementObject current) { + pmNames.forEach(pmName -> { + int newValue = current.getPmData().get(pmName) + existing.getPmData().get(pmName); + existing.getPmData().put(pmName, newValue); + }); + return existing; + } + + /** + * Calculate the average + */ + public List findAvg(List result, int numOfSamples) { + result.forEach(cellMeasObj -> + pmNames.forEach(pmName -> { + int value = (cellMeasObj.getPmData().get(pmName))/numOfSamples; + cellMeasObj.getPmData().put(pmName, value); + }) + ); + log.debug("Average of measurement data samples {}",result); + return result; + } +} + diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ConsumerThread.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ConsumerThread.java new file mode 100644 index 00000000..39235cd5 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/ConsumerThread.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * ============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 org.onap.slice.analysis.ms.configdb.IConfigDbService; +import org.onap.slice.analysis.ms.models.Configuration; +import org.onap.slice.analysis.ms.utils.BeanUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This Thread class consumes message from pm data queue and sends onset message to policy + */ +public class ConsumerThread extends Thread { + private static Logger log = LoggerFactory.getLogger(PmThread.class); + private PmDataQueue pmDataQueue; + private IConfigDbService configDbService; + private SnssaiSamplesProcessor snssaiSamplesProcessor; + private long initialDelaySec; + + /** + * Default constructor. + */ + public ConsumerThread() { + super(); + this.pmDataQueue = BeanUtil.getBean(PmDataQueue.class); + this.configDbService = BeanUtil.getBean(IConfigDbService.class); + this.snssaiSamplesProcessor = BeanUtil.getBean(SnssaiSamplesProcessor.class); + this.initialDelaySec = Configuration.getInstance().getInitialDelaySeconds(); + } + + /** + * Consumes data from PM data queue, process the data and sends onset message to policy if needed + */ + @Override + public void run() { + boolean done = false; + String snssai = ""; + while (!done) { + try { + Thread.sleep(initialDelaySec); + snssai = pmDataQueue.getSnnsaiFromQueue(); + if (!snssai.equals("")) { + log.info("Consumer thread started for s-nssai {}",snssai); + snssaiSamplesProcessor.processSamplesOfSnnsai(snssai, configDbService.fetchNetworkFunctionsOfSnssai(snssai)); + } + } catch (Exception e) { + log.error("Exception in Consumer Thread ", e); + done = true; + } + } + } +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/IPmEventProcessor.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/IPmEventProcessor.java new file mode 100644 index 00000000..0a67df81 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/IPmEventProcessor.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * ============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.util.List; +import java.util.Map; + +import org.onap.slice.analysis.ms.models.MeasurementObject; +import org.onap.slice.analysis.ms.models.pmnotification.Event; + +/** + * Interface for pm event processor + */ +public interface IPmEventProcessor { + public Map> processEvent(Event event); +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/MLMessageProcessor.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/MLMessageProcessor.java new file mode 100644 index 00000000..bee7b30e --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/MLMessageProcessor.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * ============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.util.List; +import java.util.Map; + +import javax.annotation.PostConstruct; + +import org.onap.slice.analysis.ms.configdb.IConfigDbService; +import org.onap.slice.analysis.ms.models.CUModel; +import org.onap.slice.analysis.ms.models.MLOutputModel; +import org.onap.slice.analysis.ms.models.policy.AdditionalProperties; +import org.onap.slice.analysis.ms.utils.BeanUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +/** + * Process the message sent by ML service and sends notification to policy + */ +@Component +@Scope("Prototype") +public class MLMessageProcessor { + private static Logger log = LoggerFactory.getLogger(MLMessageProcessor.class); + + private IConfigDbService configDbService; + private PolicyService policyService; + + + @PostConstruct + public void init() { + configDbService = BeanUtil.getBean(IConfigDbService.class); + } + + public void processMLMsg(MLOutputModel mlOutputMsg) { + String snssai = mlOutputMsg.getSnssai(); + List cuData = mlOutputMsg.getData(); + Map> ricToCellMapping = configDbService.fetchRICsOfSnssai(snssai); + log.debug("RIC to cell mapping of S-NSSAI {} is {}",snssai,ricToCellMapping); + for(CUModel cuModel: cuData) { + String cellId = String.valueOf(cuModel.getCellCUList().get(0).getCellLocalId()); + ricToCellMapping.forEach((ricId, cells) -> { + if(cells.contains(cellId)) { + cuModel.setNearRTRICId(ricId); + } + }); + } + AdditionalProperties addProps = new AdditionalProperties<>(); + addProps.setResourceConfig(mlOutputMsg); + policyService.sendOnsetMessageToPolicy(snssai, addProps, configDbService.fetchServiceDetails(snssai)); + } +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmDataQueue.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmDataQueue.java new file mode 100644 index 00000000..d907bfed --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmDataQueue.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * ============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.util.Collections; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Queue; +import java.util.concurrent.LinkedBlockingQueue; + +import org.onap.slice.analysis.ms.models.MeasurementObject; +import org.onap.slice.analysis.ms.models.SubCounter; +import org.springframework.stereotype.Component; + +/** + * This class represents the data structure for storing the pm events + */ +@Component +public class PmDataQueue { + private Map>> subCounterMap = Collections.synchronizedMap(new LinkedHashMap>>()); + private Queue snssaiList = new LinkedBlockingQueue<>(); + + /** + * put the measurement data for (an S-NSSAI from a network function) in the queue + */ + public void putDataToQueue(SubCounter subCounter, List measurementObjectData) { + Queue> measQueue; + if (subCounterMap.containsKey(subCounter)){ + subCounterMap.get(subCounter).add(measurementObjectData); + } + else { + measQueue = new LinkedBlockingQueue<>(); + measQueue.add(measurementObjectData); + subCounterMap.put(subCounter, measQueue); + } + } + + /** + * get the measurement data for (an S-NSSAI from a network function) from the queue + * returns the specified number of samples + */ + public List> getSamplesFromQueue(SubCounter subCounter, int samples) { + List> sampleList = new LinkedList<>(); + if (subCounterMap.containsKey(subCounter)){ + Queue> measQueue = subCounterMap.get(subCounter); + while(samples > 0) { + sampleList.add(measQueue.remove()); + samples --; + } + } + return sampleList; + } + + /** + * put S-NSSAI to the queue + */ + public void putSnssaiToQueue(String snssai) { + if (!snssaiList.contains(snssai)) + snssaiList.add(snssai); + } + + /** + * get S-NSSAI from the queue + */ + public String getSnnsaiFromQueue() { + String snssai = ""; + try { + snssai = snssaiList.remove(); + } + catch(Exception e) { + + } + return snssai; + } +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmEventProcessor.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmEventProcessor.java new file mode 100644 index 00000000..99c24c8a --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmEventProcessor.java @@ -0,0 +1,105 @@ +/******************************************************************************* + * ============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.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import org.onap.slice.analysis.ms.models.MeasurementObject; +import org.onap.slice.analysis.ms.models.pmnotification.Event; +import org.onap.slice.analysis.ms.models.pmnotification.MeasInfoList; +import org.onap.slice.analysis.ms.models.pmnotification.MeasResult; +import org.onap.slice.analysis.ms.models.pmnotification.MeasValuesList; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +/** + * This class is responsible for processing PmEvent + */ +@Component +@Scope("prototype") +public class PmEventProcessor implements IPmEventProcessor{ + protected Map> instanceMap = new HashMap<>(); + + + /** + * Process the PM event + */ + public Map> processEvent(Event event) { + List measurements = event.getPerf3gppFields().getMeasDataCollection().getMeasInfoList(); + measurements.forEach(measurement -> { + List collectedSubCounters = measurement.getMeasTypes().getsMeasTypesList(); + List subCounterMeasurements = measurement.getMeasValuesList(); + subCounterMeasurements.forEach(subCounterMeasurement -> processMeasurementObjectData(collectedSubCounters, subCounterMeasurement)); + }); + return instanceMap; + } + + /** + * Process the measurement data from every measurement object. eg cell + */ + public void processMeasurementObjectData(List collectedSubCounters, MeasValuesList subCounterMeasurement) { + List measResultList = subCounterMeasurement.getMeasResults(); + String measObjId = subCounterMeasurement.getMeasObjInstId(); + measResultList.forEach(measResult -> { + String pmName = collectedSubCounters.get(measResult.getP()-1); + Integer pmValue = Integer.valueOf(measResult.getsValue()); + Map pmMapping = getMapKey(pmName); + String snssai = pmMapping.get("snssai"); + String pm = pmMapping.get("pm"); + Map pmData = new HashMap<>(); + pmData.put(pm, pmValue); + if (instanceMap.containsKey(snssai)) { + int index = instanceMap.get(snssai).indexOf(new MeasurementObject(measObjId)); + if (index == -1) { + instanceMap.get(snssai).add(new MeasurementObject(measObjId,pmData)); + } + else { + instanceMap.get(snssai).get(index).getPmData().put(pmName, pmValue); + } + } + else { + List l = new LinkedList<>(); + l.add(new MeasurementObject(measObjId,pmData)); + instanceMap.put(snssai, l); + } + }); + } + + /** + * Fetch pm name and S-NSSAI + */ + public Map getMapKey(String pmName) { + String [] pmNameArr = pmName.split("\\."); + String snssai = ""; + String pm = pmNameArr[1]; + Map result = new HashMap<>(); + result.put("pm", pm); + if ((pm.equalsIgnoreCase("PrbUsedDl")) || (pm.equalsIgnoreCase("PrbUsedUl"))){ + snssai = pmNameArr[2]; + } + result.put("snssai", snssai); + return result; + } +} \ No newline at end of file diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmThread.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmThread.java new file mode 100644 index 00000000..d9091b3c --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PmThread.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.service; + +import java.util.List; +import java.util.Map; + +import org.onap.slice.analysis.ms.data.repository.PerformanceNotificationsRepository; +import org.onap.slice.analysis.ms.dmaap.NewPmNotification; +import org.onap.slice.analysis.ms.models.MeasurementObject; +import org.onap.slice.analysis.ms.models.SubCounter; +import org.onap.slice.analysis.ms.models.pmnotification.PmNotification; +import org.onap.slice.analysis.ms.utils.BeanUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.fasterxml.jackson.databind.ObjectMapper; + +/** + * This Thread class consumes pm message from database and puts it in the queue for further processing + */ +public class PmThread extends Thread { + private static Logger log = LoggerFactory.getLogger(PmThread.class); + private NewPmNotification newPmNotification; + private PerformanceNotificationsRepository performanceNotificationsRepository; + private IPmEventProcessor pmEventProcessor; + private PmDataQueue pmDataQueue; + + /** + * parameterized constructor. + */ + public PmThread(NewPmNotification newPmNotification) { + super(); + this.newPmNotification = newPmNotification; + this.performanceNotificationsRepository = BeanUtil.getBean(PerformanceNotificationsRepository.class); + this.pmEventProcessor = BeanUtil.getBean(IPmEventProcessor.class); + this.pmDataQueue = BeanUtil.getBean(PmDataQueue.class); + } + + /** + * check for new PM notification. Fetch notification from the database, process and put it in the pm data queue + */ + @Override + public void run() { + log.info("PM thread starting ..."); + boolean done = false; + PmNotification pmNotification; + Map> processedData; + while (!done) { + try { + Thread.sleep(1000); + if (newPmNotification.getNewNotif()) { + log.info("New PM notification from Dmaap"); + String pmNotificationString = performanceNotificationsRepository.getPerformanceNotificationFromQueue(); + if(pmNotificationString != null) { + ObjectMapper mapper = new ObjectMapper(); + pmNotification = mapper.readValue(pmNotificationString, PmNotification.class); + processedData = pmEventProcessor.processEvent(pmNotification.getEvent()); + String networkFunction = pmNotification.getEvent().getPerf3gppFields().getMeasDataCollection().getMeasuredEntityDn(); + processedData.forEach((key,value) -> { + SubCounter subCounter = new SubCounter(networkFunction, key); + pmDataQueue.putDataToQueue(subCounter, value); + pmDataQueue.putSnssaiToQueue(subCounter.getMeasuredObject()); + }); + } + } + } catch (Exception e) { + log.error("Exception in PM Thread ", e); + done = true; + } + } + } +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PolicyService.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PolicyService.java new file mode 100644 index 00000000..80063398 --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/PolicyService.java @@ -0,0 +1,111 @@ +/******************************************************************************* + * ============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.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import javax.annotation.PostConstruct; + +import org.onap.slice.analysis.ms.dmaap.PolicyDmaapClient; +import org.onap.slice.analysis.ms.models.Configuration; +import org.onap.slice.analysis.ms.models.policy.AAI; +import org.onap.slice.analysis.ms.models.policy.AdditionalProperties; +import org.onap.slice.analysis.ms.models.policy.OnsetMessage; +import org.onap.slice.analysis.ms.models.policy.Payload; +import org.onap.slice.analysis.ms.utils.DmaapUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.databind.ObjectMapper; + +@Component +public class PolicyService { + private PolicyDmaapClient policyDmaapClient; + private static Logger log = LoggerFactory.getLogger(PolicyService.class); + + @PostConstruct + public void init() { + Configuration configuration = Configuration.getInstance(); + policyDmaapClient = new PolicyDmaapClient(new DmaapUtils(), configuration); + } + + protected OnsetMessage formPolicyOnsetMessage(String snssai, AdditionalProperties addProps, Map serviceDetails) { + OnsetMessage onsetmsg = new OnsetMessage(); + Payload payload = new Payload(); + payload.setGlobalSubscriberId(serviceDetails.get("globalSubscriberId")); + payload.setSubscriptionServiceType(serviceDetails.get("subscriptionServiceType")); + payload.setNetworkType("AN"); + payload.setName(serviceDetails.get("ranNFNSSIId")); + payload.setServiceInstanceID(serviceDetails.get("ranNFNSSIId")); + + addProps.setModifyAction(""); + Map nsiInfo = new HashMap<>(); + nsiInfo.put("nsiId", UUID.randomUUID().toString()); + nsiInfo.put("nsiName", ""); + addProps.setNsiInfo(nsiInfo); + addProps.setScriptName("AN"); + addProps.setSliceProfileId(serviceDetails.get("sliceProfileId")); + addProps.setModifyAction("reconfigure"); + List snssaiList = new ArrayList<>(); + snssaiList.add(snssai); + addProps.setSnssaiList(snssaiList); + + payload.setAdditionalProperties(addProps); + onsetmsg.setPayload(payload); + + onsetmsg.setClosedLoopControlName("ControlLoop-Slicing-116d7b00-dbeb-4d03-8719-d0a658fa735b"); + onsetmsg.setClosedLoopAlarmStart(System.currentTimeMillis()); + onsetmsg.setClosedLoopEventClient("microservice.sliceAnalysisMS"); + onsetmsg.setClosedLoopEventStatus("ONSET"); + onsetmsg.setRequestID(UUID.randomUUID().toString()); + onsetmsg.setTarget("vserver.vserver-name"); + onsetmsg.setTargetType("VNF"); + onsetmsg.setFrom("DCAE"); + onsetmsg.setVersion("1.0.2"); + AAI aai = new AAI(); + aai.setVserverIsClosedLoopDisabled("false"); + aai.setVserverProvStatus("ACTIVE"); + aai.setVserverVserverName(serviceDetails.get("ranNFNSSIId")); + onsetmsg.setAai(aai); + return onsetmsg; + } + + protected void sendOnsetMessageToPolicy(String snssai, AdditionalProperties addProps, Map serviceDetails) { + OnsetMessage onsetMessage = formPolicyOnsetMessage(snssai, addProps, serviceDetails); + ObjectMapper obj = new ObjectMapper(); + String msg = ""; + try { + log.debug("Policy onset message for S-NSSAI: {} is {}", snssai, msg); + msg = obj.writeValueAsString(onsetMessage); + policyDmaapClient.sendNotificationToPolicy(msg); + } + catch (Exception e) { + log.error("Error sending notification to policy, {}",e.getMessage()); + } + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/SnssaiSamplesProcessor.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/SnssaiSamplesProcessor.java new file mode 100644 index 00000000..2e56190f --- /dev/null +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/service/SnssaiSamplesProcessor.java @@ -0,0 +1,190 @@ +/******************************************************************************* + * ============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.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.annotation.PostConstruct; + +import org.onap.slice.analysis.ms.configdb.IConfigDbService; +import org.onap.slice.analysis.ms.models.Configuration; +import org.onap.slice.analysis.ms.models.MeasurementObject; +import org.onap.slice.analysis.ms.models.SubCounter; +import org.onap.slice.analysis.ms.models.policy.AdditionalProperties; +import org.onap.slice.analysis.ms.utils.BeanUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +/** + * This class process the measurement data of an S-NSSAI + */ +@Component +@Scope("Prototype") +public class SnssaiSamplesProcessor { + private static Logger log = LoggerFactory.getLogger(SnssaiSamplesProcessor.class); + + private PolicyService policyService; + private IConfigDbService configDbService; + private PmDataQueue pmDataQueue; + private AverageCalculator averageCalculator; + private List snssaiMeasurementList = new ArrayList<>(); + private Map> ricToCellMapping = new HashMap<>(); + private Map> ricToPrbsMapping = new HashMap<>(); + private Map> ricToThroughputMapping = new HashMap<>(); + private int samples; + private List pmsToCompute; + private Map prbThroughputMapping = new HashMap<>(); + private int minPercentageChange; + + @PostConstruct + public void init() { + Configuration configuration = Configuration.getInstance(); + samples = configuration.getSamples(); + pmsToCompute = new ArrayList<>(); + pmsToCompute.add("PrbUsedDl"); + pmsToCompute.add("PrbUsedUl"); + prbThroughputMapping = new HashMap<>(); + prbThroughputMapping.put("PrbUsedDl", "dLThptPerSlice"); + prbThroughputMapping.put("PrbUsedUl", "uLThptPerSlice"); + minPercentageChange = configuration.getMinPercentageChange(); + policyService = BeanUtil.getBean(PolicyService.class); + configDbService = BeanUtil.getBean(IConfigDbService.class); + pmDataQueue = BeanUtil.getBean(PmDataQueue.class); + averageCalculator = BeanUtil.getBean(AverageCalculator.class); + } + + /** + * process the measurement data of an S-NSSAI + */ + public void processSamplesOfSnnsai(String snssai, List networkFunctions) { + networkFunctions.forEach(nf -> { + log.debug("Average of samples for {}:", snssai); + addToMeasurementList(averageCalculator.findAverageOfSamples(pmDataQueue.getSamplesFromQueue(new SubCounter(nf, snssai), samples))); + }); + ricToCellMapping = configDbService.fetchRICsOfSnssai(snssai); + log.debug("RIC to Cell Mapping for {} S-NSSAI: {}", snssai, ricToCellMapping); + Map> ricConfiguration = configDbService.fetchCurrentConfigurationOfRIC(snssai); + Map sliceConfiguration = configDbService.fetchCurrentConfigurationOfSlice(snssai); + log.debug("RIC Configuration: {}", ricConfiguration); + log.debug("Slice Configuration: {}", sliceConfiguration); + pmsToCompute.forEach(pm -> { + sumOfPrbsAcrossCells(pm); + int sum = computeSum(pm); + computeThroughput(sliceConfiguration, sum, pm); + calculatePercentageChange(ricConfiguration, pm); + }); + updateConfiguration(); + if(ricToThroughputMapping.size() > 0) { + AdditionalProperties>> addProps = new AdditionalProperties<>(); + addProps.setResourceConfig(ricToThroughputMapping); + policyService.sendOnsetMessageToPolicy(snssai, addProps, configDbService.fetchServiceDetails(snssai)); + } + + } + + /** + * process the measurement data of an S-NSSAI + */ + protected void updateConfiguration() { + Iterator>> it = ricToThroughputMapping.entrySet().iterator(); + Map.Entry> entry = null; + while(it.hasNext()) { + entry = it.next(); + if(entry.getValue().size() == 0) { + it.remove(); + } + } + } + + private void addToMeasurementList(List sample) { + snssaiMeasurementList.addAll(sample); + } + + /** + * Calculate the change in the configuration value and keep the configuration only if it is greater than a + * specific limit + */ + protected void calculatePercentageChange(Map> ricConfiguration, String pm) { + Iterator>> it = ricToThroughputMapping.entrySet().iterator(); + Map.Entry> entry = null; + float existing = 0; + float change = 0; + while(it.hasNext()) { + entry = it.next(); + existing = ricConfiguration.get(entry.getKey()).get(pm); + change = ((Math.abs(entry.getValue().get(pm) - existing))/existing)*100; + if (change <= minPercentageChange) { + ricToThroughputMapping.get(entry.getKey()).remove(pm); + } + } + } + + protected void sumOfPrbsAcrossCells(String pmName) { + ricToCellMapping.forEach((ric,cells) -> { + int sumOfPrbs = 0; + for(String cell : cells) { + int index = snssaiMeasurementList.indexOf(new MeasurementObject(cell)); + sumOfPrbs += snssaiMeasurementList.get(index).getPmData().get(pmName); + } + if(ricToPrbsMapping.containsKey(ric)) { + ricToPrbsMapping.get(ric).put(pmName, sumOfPrbs); + } + else { + Map pmToPrbMapping = new HashMap<>(); + pmToPrbMapping.put(pmName, sumOfPrbs); + ricToPrbsMapping.put(ric, pmToPrbMapping); + } + }); + } + + protected Integer computeSum(String pm) { + return ricToPrbsMapping.entrySet().stream().map(x -> x.getValue().get(pm)).reduce(0, Integer::sum); + } + + protected void computeThroughput(Map sliceConfiguration, int sum, String pm) { + Iterator>> it = ricToPrbsMapping.entrySet().iterator(); + Map.Entry> entry = null; + Map throughtputMap = null; + String ric = ""; + int value = 0; + while(it.hasNext()) { + entry = it.next(); + ric = entry.getKey(); + value = Math.round(((float)entry.getValue().get(pm)/sum)*(float)sliceConfiguration.get(prbThroughputMapping.get(pm))); + if(ricToThroughputMapping.containsKey(ric)) { + ricToThroughputMapping.get(ric).put(prbThroughputMapping.get(pm), value); + } + else { + throughtputMap = new HashMap<>(); + throughtputMap.put(prbThroughputMapping.get(pm), value); + ricToThroughputMapping.put(ric, throughtputMap); + } + } + + } + +} diff --git a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/utils/DmaapUtils.java b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/utils/DmaapUtils.java index 0952f754..7457533b 100644 --- a/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/utils/DmaapUtils.java +++ b/components/slice-analysis-ms/src/main/java/org/onap/slice/analysis/ms/utils/DmaapUtils.java @@ -33,7 +33,7 @@ import com.att.nsa.cambria.client.CambriaTopicManager; import java.net.MalformedURLException; import java.security.GeneralSecurityException; -import org.onap.slice.analysis.ms.beans.Configuration; +import org.onap.slice.analysis.ms.models.Configuration; /** * Utility class to perform actions related to Dmaap 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/beans/ConfigPolicyTest.java deleted file mode 100644 index 66f97d96..00000000 --- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/beans/ConfigPolicyTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * ============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.beans; - -import static org.junit.Assert.assertEquals; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; - - -public class ConfigPolicyTest { - - @Test - public void configPolicyTest() { - ConfigPolicy configPolicy = ConfigPolicy.getInstance(); - Map config = new HashMap(); - config.put("policyName", "pcims_policy"); - configPolicy.setConfig(config); - assertEquals(config, configPolicy.getConfig()); - } -} 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/beans/ConfigurationTest.java deleted file mode 100644 index a3487773..00000000 --- a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/beans/ConfigurationTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * ============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.beans; - -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; - - -public class ConfigurationTest { - Configuration configuration = Configuration.getInstance(); - - @Test - public void configurationTest() { - - List list = new ArrayList(); - list.add("server"); - Map subscribes = new HashMap<>(); - - configuration.setStreamsSubscribes(subscribes); - configuration.setStreamsPublishes(subscribes); - configuration.setDmaapServers(list); - configuration.setCg("cg"); - configuration.setCid("cid"); - configuration.setAafPassword("password"); - configuration.setAafUsername("user"); - configuration.setPgHost("pg"); - configuration.setPgPort(5432); - configuration.setPgPassword("password"); - configuration.setPgUsername("user"); - configuration.setPollingInterval(30); - configuration.setPollingTimeout(100); - configuration.setConfigDbService("sdnrService"); - - assertEquals("cg", configuration.getCg()); - assertEquals("cid", configuration.getCid()); - assertEquals("user", configuration.getAafUsername()); - assertEquals("password", configuration.getAafPassword()); - assertEquals("user", configuration.getPgUsername()); - assertEquals("password", configuration.getPgPassword()); - assertEquals("pg", configuration.getPgHost()); - assertEquals(5432, configuration.getPgPort()); - assertEquals(30, configuration.getPollingInterval()); - assertEquals(100, configuration.getPollingTimeout()); - assertEquals("sdnrService", configuration.getConfigDbService()); - assertEquals(list, configuration.getDmaapServers()); - } -} 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 responsemap=new HashMap<>(); + responsemap.put("dLThptPerSlice", 1); + responsemap.put("uLThptPerSlice", 2); + Mockito.when(restclient.sendGetRequest(Mockito.anyString(), Mockito.any())).thenReturn(new ResponseEntity(responsemap, HttpStatus.OK)); + assertEquals(responsemap, configdbservice.fetchCurrentConfigurationOfSlice("snssai")); + } + + @Test + public void fetchCurrentConfigurationOfRIC() { + Map map=new HashMap<>(); + Map> 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(responsemap, HttpStatus.OK)); + assertEquals(responsemap, configdbservice.fetchCurrentConfigurationOfSlice("snssai")); + + } + @Test + public void fetchRICsOfSnssai() { + Map> response=new HashMap<>(); + List cellslist=new ArrayList<>(); + List 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(response, HttpStatus.OK)); + List outputlist=new ArrayList<>(); + outputlist.add("1111"); + outputlist.add("2222"); + Map> output= configdbservice.fetchRICsOfSnssai("snssai"); + assertEquals(outputlist, output.get("1")); + + } + + @Test + public void fetchNetworkFunctionsOfSnssai() { + + List responsemap=new ArrayList<>(); + List networkfunctionslist=new ArrayList(); + 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(networkfunctionslist, HttpStatus.OK)); + responsemap=configdbservice.fetchNetworkFunctionsOfSnssai("snssai"); + assertEquals(3, responsemap.size()); + + } + public void fetchServiceProfile() { + Map responseMap=new HashMap(); + 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(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/models/ConfigPolicyTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigPolicyTest.java new file mode 100644 index 00000000..2b137e3a --- /dev/null +++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigPolicyTest.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * ============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 static org.junit.Assert.assertEquals; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; + + +public class ConfigPolicyTest { + + @Test + public void configPolicyTest() { + ConfigPolicy configPolicy = ConfigPolicy.getInstance(); + Map config = new HashMap(); + config.put("policyName", "pcims_policy"); + configPolicy.setConfig(config); + assertEquals(config, configPolicy.getConfig()); + } +} diff --git a/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigurationTest.java b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigurationTest.java new file mode 100644 index 00000000..eb492800 --- /dev/null +++ b/components/slice-analysis-ms/src/test/java/org/onap/slice/analysis/ms/models/ConfigurationTest.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * ============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 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; + + +public class ConfigurationTest { + Configuration configuration = Configuration.getInstance(); + + @Test + public void configurationTest() { + + List list = new ArrayList(); + list.add("server"); + Map subscribes = new HashMap<>(); + + configuration.setStreamsSubscribes(subscribes); + configuration.setStreamsPublishes(subscribes); + configuration.setDmaapServers(list); + configuration.setCg("cg"); + configuration.setCid("cid"); + configuration.setAafPassword("password"); + configuration.setAafUsername("user"); + configuration.setPgHost("pg"); + configuration.setPgPort(5432); + configuration.setPgPassword("password"); + configuration.setPgUsername("user"); + configuration.setPollingInterval(30); + configuration.setPollingTimeout(100); + configuration.setConfigDbService("sdnrService"); + + assertEquals("cg", configuration.getCg()); + assertEquals("cid", configuration.getCid()); + assertEquals("user", configuration.getAafUsername()); + assertEquals("password", configuration.getAafPassword()); + assertEquals("user", configuration.getPgUsername()); + assertEquals("password", configuration.getPgPassword()); + assertEquals("pg", configuration.getPgHost()); + assertEquals(5432, configuration.getPgPort()); + assertEquals(30, configuration.getPollingInterval()); + assertEquals(100, configuration.getPollingTimeout()); + assertEquals("sdnrService", configuration.getConfigDbService()); + assertEquals(list, configuration.getDmaapServers()); + } +} 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> responseType = null; + HttpHeaders headers = new HttpHeaders(); + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + headers.setContentType(MediaType.APPLICATION_JSON); + HttpEntity requestEntity = new HttpEntity<>( headers); + Map 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> 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 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 requestEntity = new HttpEntity<>(requestBody, headers); + PowerMockito.when(restTemplate.exchange(requestUrl, HttpMethod.POST,requestEntity,responseType)).thenReturn(new ResponseEntity(HttpStatus.OK)); + ResponseEntity resp = restclient.sendPostRequest(headers, requestUrl, requestBody,responseType); + assertEquals(resp.getStatusCode(), HttpStatus.OK); + } + + @Test + public void sendPostRequestTest2() { + ParameterizedTypeReference 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 requestEntity = new HttpEntity<>(requestBody, headers); + PowerMockito.when(restTemplate.exchange(requestUrl, HttpMethod.POST,requestEntity,responseType)).thenReturn(new ResponseEntity(HttpStatus.NOT_FOUND)); + ResponseEntity 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 pmNames = new ArrayList<>(); + pmNames.add("PrbUsedDl"); + pmNames.add("PrbUsedUl"); + ReflectionTestUtils.setField(averageCalculator, "pmNames", pmNames); + } + + @Test + public void findAverageOfSamplesTest() { + ObjectMapper obj = new ObjectMapper(); + List> input = null; + List output = null; + try { + input = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/measurementObjectList.json"))), new TypeReference>>(){}); + output = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/average.json"))), new TypeReference>(){}); + } + catch (IOException e) { + e.printStackTrace(); + } + + assertEquals(output, averageCalculator.findAverageOfSamples(input)); + } + + @Test + public void findAvgTest() { + List result = new ArrayList<>(); + Map 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 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 existingMap = new HashMap<>(); + existingMap.put("PrbUsedDl", 50); + existingMap.put("PrbUsedUl", 48); + + Map currentMap = new HashMap<>(); + currentMap.put("PrbUsedDl", 40); + currentMap.put("PrbUsedUl", 38); + + Map 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> ricToCellMapping = new HashMap<>(); + List myList = new ArrayList(); + myList.add("111"); + myList.add("112"); + ricToCellMapping.put("12", myList); + myList = new ArrayList(); + 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(){}); + mloutputExp = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/MLOutputModel.json"))), new TypeReference(){}); + } + catch (IOException e) { + e.printStackTrace(); + } + when(configDbService.fetchRICsOfSnssai("0001-0111")).thenReturn(ricToCellMapping); + AdditionalProperties 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> measList = null; + try { + measList = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/measurementObjectList.json"))), new TypeReference>>(){}); + } + catch (IOException e) { + e.printStackTrace(); + } + SubCounter sub1 = new SubCounter("nf1", "nssai1"); + Map>> subCounterMap = Collections.synchronizedMap(new LinkedHashMap>>()); + subCounterMap.put(sub1, measList); + ReflectionTestUtils.setField(pmDataQueue, "subCounterMap", subCounterMap); + + Queue 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>> subCounterMapExp = Collections.synchronizedMap(new LinkedHashMap>>()); + List measObj = null; + Queue> measObjExp = null; + try { + measObj = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/average.json"))), new TypeReference>(){}); + measObjExp = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/appendData.json"))), new TypeReference>>(){}); + + } + 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>> subCounterMapExp = Collections.synchronizedMap(new LinkedHashMap>>()); + List measObj = null; + Queue> measObjExp = null; + Queue> measObjExp1 = new LinkedBlockingQueue<>(); + try { + measObj = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/average.json"))), new TypeReference>(){}); + measObjExp = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/measurementObjectList.json"))), new TypeReference>>(){}); + } + 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>>) ReflectionTestUtils.getField(pmDataQueue, "subCounterMap")).get(sub)); + assertEquals(subCounterMapExp.get(sub1).contains(measObj), ((Map>>) ReflectionTestUtils.getField(pmDataQueue, "subCounterMap")).get(sub1).contains(measObj)); + } + + @Test + public void getSamplesFromQueueTest() { + SubCounter sub = new SubCounter("nf1", "nssai1"); + List> measObj = null; + try { + measObj = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/getResponse.json"))), new TypeReference>>(){}); + } + catch (IOException e) { + e.printStackTrace(); + } + assertEquals(measObj, pmDataQueue.getSamplesFromQueue(sub, 1)); + } + + @SuppressWarnings("unchecked") + @Test + public void putSnssaiToQueueTest() { + pmDataQueue.putSnssaiToQueue("nssai1"); + assertEquals(3, ((Queue)ReflectionTestUtils.getField(pmDataQueue, "snssaiList")).size()); + } + + @SuppressWarnings("unchecked") + @Test + public void putNewSnssaiToQueueTest() { + pmDataQueue.putSnssaiToQueue("nssai9"); + assertEquals(4, ((Queue)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> 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>>(){}); + } + 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 input = null; + OnsetMessage output = null; + String expected = ""; + String actual = ""; + Map> ricToThroughputMapping = new HashMap<>(); + Map ric1 = new HashMap<>(); + Map 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>(){}); + 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>> 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> ricToThroughputMapping = new HashMap<>(); + Map ric1 = new HashMap<>(); + Map 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> ricToPrbsMapping = null; + List sliceMeasList = null; + Map> ricToCellMapping = null; + Map 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>>(){}); + sliceMeasList = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/sliceMeasurementList.json"))), new TypeReference>(){}); + ricToCellMapping = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/ricToCellMapping.json"))), new TypeReference>>(){}); + } + 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> ricToThroughputMappingExp = new HashMap<>(); + Map ric1 = new HashMap<>(); + Map 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> ricToThroughputMappingExp = new HashMap<>(); + Map ric2 = new HashMap<>(); + ric2.put("dLThptPerSlice",50); + ric2.put("uLThptPerSlice",30); + ricToThroughputMappingExp.put("2", ric2); + + Map> ricToThroughputMapping = new HashMap<>(); + Map 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> ricConfiguration = null; + Map> exp = new HashMap<>(); + Map ric1 = new HashMap<>(); + Map 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>>(){}); + } + 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> ricToPrbsMapping = new HashMap<>(); + Map> 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>>(){}); + } + catch (IOException e) { + e.printStackTrace(); + } + snssaiSamplesProcessor.sumOfPrbsAcrossCells("PrbUsedDl"); + assertEquals(ricToPrbsMappingExp, ReflectionTestUtils.getField(snssaiSamplesProcessor, "ricToPrbsMapping")); + } + + @Test + public void computeThroughputTest() { + Map> ricToThroughputMapping = new HashMap<>(); + ReflectionTestUtils.setField(snssaiSamplesProcessor, "ricToThroughputMapping", ricToThroughputMapping); + + Map> ricToThroughputMappingExp = new HashMap<>(); + try { + ricToThroughputMappingExp = obj.readValue(new String(Files.readAllBytes(Paths.get("src/test/resources/ricToThroughputMappingOutput.json"))), new TypeReference>>(){}); + } + catch (IOException e) { + e.printStackTrace(); + } + Map sliceConfiguration = new HashMap(); + 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 -- cgit 1.2.3-korg