From eeafff5620de42cf115b2694d5eb67a7ddc48165 Mon Sep 17 00:00:00 2001 From: malar Date: Thu, 1 Sep 2022 11:00:01 +0000 Subject: Modify payload for ANR closedloop to align with A1 based action Issue-ID: DCAEGEN2-3148 Signed-off-by: Malarvizhi Paramasivam Change-Id: I41264a68b3dd40306c59a1c39fc1fd47213a3b13 --- Changelog.md | 5 +- pom.xml | 2 +- src/main/docker/config/sonhms/config_all.json | 4 +- .../dcaegen2/services/sonhms/Configuration.java | 13 +- .../services/sonhms/PmNotificationHandler.java | 105 ++----- .../services/sonhms/child/ChildThreadUtils.java | 24 +- .../dcaegen2/services/sonhms/model/ANRPayload.java | 115 ++++++++ .../dcaegen2/services/sonhms/model/Action.java | 32 +++ .../dcaegen2/services/sonhms/model/Neighbours.java | 94 ++++++ .../dcaegen2/services/sonhms/model/PolicyData.java | 89 ++++++ .../services/sonhms/model/PolicyNotification.java | 12 +- .../sonhms/restclient/ConfigInterface.java | 6 +- .../services/sonhms/restclient/CpsClient.java | 20 +- .../sonhms/child/TestChildThreadUtils.java | 315 ++++++++++----------- .../services/sonhms/restclient/CpsClientTest.java | 22 ++ src/test/resources/policy_notification.json | 4 +- version.properties | 2 +- 17 files changed, 601 insertions(+), 263 deletions(-) create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/ANRPayload.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/Action.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/Neighbours.java create mode 100644 src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyData.java diff --git a/Changelog.md b/Changelog.md index 5943e70..770d5b2 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,10 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [2.1.9] - 2022/09/01 + - [DCAEGEN2-3148](https://jira.onap.org/browse/DCAEGEN2-3148) - Modify payload for ANR closedloop to align with A1 based action + ## [2.1.8] - 2022/08/31 - [DCAEGEN2-3222](https://jira.onap.org/browse/DCAEGEN2-3222) - dcaegen2-services-son-handler vulnerability updates -## [2.1.7] - 2021/05/11 +## [2.1.7] - 2022/05/11 - [DCAEGEN2-3150](https://jira.onap.org/browse/DCAEGEN2-3150) - Fix bug in handling FM notification ## [2.1.6] - 2022/02/07 diff --git a/pom.xml b/pom.xml index f67a68c..601d19b 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ org.onap.dcaegen2.services.son-handler son-handler dcaegen2-services-son-handler - 2.1.8-SNAPSHOT + 2.1.9-SNAPSHOT diff --git a/src/main/docker/config/sonhms/config_all.json b/src/main/docker/config/sonhms/config_all.json index b6cb345..aae0704 100644 --- a/src/main/docker/config/sonhms/config_all.json +++ b/src/main/docker/config/sonhms/config_all.json @@ -117,8 +117,8 @@ "PCI_SDNR_TARGET_NAME": "SDNR", "PCI_OPTMIZATION_ALGO_CATEGORY_IN_OOF": "OOF-PCI-OPTIMIZATION", "PCI_NEIGHBOR_CHANGE_CLUSTER_TIMEOUT_IN_SECS": 60, - "PCI_MODCONFIGANR_POLICY_NAME": "ControlLoop-vSONH-7d4baf04-8875-4d1f-946d-06b874048b61", - "PCI_MODCONFIG_POLICY_NAME": "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459" + "PCI_MODCONFIGANR_POLICY_NAME": "ControlLoop-SONA1-7d4baf04-8875-4d1f-946d-06b874048b61", + "PCI_MODCONFIG_POLICY_NAME": "ControlLoop-SONO1-fb41f388-a5f2-11e8-98d0-529269fb1459" }, "type_version": "1.0.0", "version": "1.0.0", diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java b/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java index 1824e92..ce8e016 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/Configuration.java @@ -52,6 +52,7 @@ public class Configuration { private String getNbrListUrl; private String getPciUrl; private String getPnfUrl; + private String getRicIdUrl; private String oofService; private String oofEndpoint; private String cg; @@ -404,7 +405,7 @@ public class Configuration { public void setPolicyFixedPciTimeInterval(long policyFixedPciTimeInterval) { this.policyFixedPciTimeInterval = policyFixedPciTimeInterval; } - + public String getNfNamingCode() { return nfNamingCode; } @@ -461,6 +462,14 @@ public class Configuration { this.getPnfUrl = getPnfUrl; } + public void setGetRicIdUrl(String getRicIdUrl) { + this.getRicIdUrl = getRicIdUrl; + } + + public String getGetRicIdUrl() { + return getRicIdUrl; + } + public static void setInstance(Configuration instance) { Configuration.instance = instance; } @@ -470,7 +479,7 @@ public class Configuration { return "Configuration [pgHost=" + pgHost + ", pgPort=" + pgPort + ", pgUsername=" + pgUsername + ", pgPassword=" + pgPassword + ", dmaapServers=" + dmaapServers + ", configDbService=" + configDbService + ", cpsServiceUrl=" + cpsServiceUrl + ", CpsUsername=" + CpsUsername + ",CpsPassword=" + CpsPassword + ",ConfigClientType=" + ConfigClientType + ", getCellDataUrl=" + getCellDataUrl + ", getNbrListUrl=" - + getNbrListUrl + ", getPciUrl=" + getPciUrl + ", getPnfUrl=" + getPnfUrl + ", oofService=" + oofService + ", oofEndpoint=" + oofEndpoint + ", cg=" + cg + ", cid=" + cid + + getNbrListUrl + ", getPciUrl=" + getPciUrl + ", getPnfUrl=" + getPnfUrl + ", getRicIdUrl=" + getRicIdUrl + ",oofService=" + oofService + ", oofEndpoint=" + oofEndpoint + ", cg=" + cg + ", cid=" + cid + ", pollingInterval=" + pollingInterval + ", pollingTimeout=" + pollingTimeout + ", minCollision=" + minCollision + ", minConfusion=" + minConfusion + ", sourceId=" + sourceId + ", callbackUrl=" + callbackUrl + ", pciOptimizer=" + pciOptimizer + ", pciAnrOptimizer=" + pciAnrOptimizer diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/PmNotificationHandler.java b/src/main/java/org/onap/dcaegen2/services/sonhms/PmNotificationHandler.java index 5b7a58f..a1127fe 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/PmNotificationHandler.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/PmNotificationHandler.java @@ -2,21 +2,21 @@ * ============LICENSE_START======================================================= * son-handler * ================================================================================ - * Copyright (C) 2019 Wipro Limited. + * Copyright (C) 2019-2022 Wipro Limited. * ============================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * + * 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.dcaegen2.services.sonhms; @@ -38,6 +38,7 @@ import org.onap.dcaegen2.services.sonhms.dao.HandOverMetricsRepository; import org.onap.dcaegen2.services.sonhms.dmaap.PolicyDmaapClient; import org.onap.dcaegen2.services.sonhms.entity.HandOverMetrics; import org.onap.dcaegen2.services.sonhms.model.AdditionalMeasurements; +import org.onap.dcaegen2.services.sonhms.model.ANRPayload; import org.onap.dcaegen2.services.sonhms.model.CellConfig; import org.onap.dcaegen2.services.sonhms.model.Common; import org.onap.dcaegen2.services.sonhms.model.Configurations; @@ -48,11 +49,15 @@ import org.onap.dcaegen2.services.sonhms.model.HoDetails; import org.onap.dcaegen2.services.sonhms.model.Lte; import org.onap.dcaegen2.services.sonhms.model.LteCell; import org.onap.dcaegen2.services.sonhms.model.NeighborListInUse; +import org.onap.dcaegen2.services.sonhms.model.Neighbours; import org.onap.dcaegen2.services.sonhms.model.Payload; import org.onap.dcaegen2.services.sonhms.model.PmNotification; +import org.onap.dcaegen2.services.sonhms.model.PolicyData; import org.onap.dcaegen2.services.sonhms.model.Ran; import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; import org.onap.dcaegen2.services.sonhms.utils.DmaapUtils; +import org.onap.dcaegen2.services.sonhms.restclient.ConfigurationClient; +import org.onap.dcaegen2.services.sonhms.restclient.CpsClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -78,7 +83,7 @@ public class PmNotificationHandler { Boolean newEntryFlag = false; try { List hoDetailsList = new ArrayList<>(); - List lteCellList = new ArrayList<>(); + List neighbourList = new ArrayList<>(); String srcCellId = pmNotification.getEvent().getCommonEventHeader().getSourceName(); /* * check whether entry already exists if yes : read the hometrics and update it @@ -103,66 +108,16 @@ public class PmNotificationHandler { .getAdditionalMeasurements()) { int attemptsCount = Integer.parseInt(additionalMeasurements.getHashMap().get("InterEnbOutAtt_X2HO")); int successCount = Integer.parseInt(additionalMeasurements.getHashMap().get("InterEnbOutSucc_X2HO")); - float successRate = ((float) successCount / attemptsCount) * 100; - - if (successRate >= badThreshold && successRate <= poorThreshold) { // poor neighbor - HoDetails hoDetails = new HoDetails(); - hoDetails.setDstCellId(additionalMeasurements.getName()); - hoDetails.setAttemptsCount(attemptsCount); - hoDetails.setSuccessCount(successCount); - hoDetails.setSuccessRate(successRate); - int pc = 1; - int bc = 0; - if (dstCellIdPcPair.containsKey(additionalMeasurements.getName())) { - pc = dstCellIdPcPair.get(additionalMeasurements.getName()) + 1; - } - hoDetails.setBadCount(bc); - hoDetails.setPoorCount(pc); - hoDetailsList.add(hoDetails); - log.info("poor neighbor {}", additionalMeasurements.getName()); - } else if (successRate < badThreshold) { // bad neighbor - log.info(" bad neighbor {}", additionalMeasurements.getName()); - HoDetails hoDetails = new HoDetails(); - hoDetails.setDstCellId(additionalMeasurements.getName()); - hoDetails.setAttemptsCount(attemptsCount); - hoDetails.setSuccessCount(successCount); - hoDetails.setSuccessRate(successRate); - int bc = 1; - int pc = 0; - if (dstCellIdBcPair.containsKey(additionalMeasurements.getName())) { - bc = dstCellIdBcPair.get(additionalMeasurements.getName()) + 1; - } - if (dstCellIdPcPair.containsKey(additionalMeasurements.getName())) { - pc = dstCellIdPcPair.get(additionalMeasurements.getName()); - } - hoDetails.setBadCount(bc); - hoDetails.setPoorCount(pc); - hoDetailsList.add(hoDetails); - if (bc >= badCountThreshold) { - LteCell lteCell = new LteCell(); - lteCell.setBlacklisted("true"); - lteCell.setCid(additionalMeasurements.getName()); - lteCell.setPlmnId(additionalMeasurements.getHashMap().get("networkId")); - lteCell.setPnfName(pmNotification.getEvent().getCommonEventHeader().getReportingEntityName()); - lteCellList.add(lteCell); - hoDetailsList.remove(hoDetails); - } - - } else if (successRate > poorThreshold) { // good neighbor - HoDetails hoDetails = new HoDetails(); - hoDetails.setDstCellId(additionalMeasurements.getName()); - hoDetails.setAttemptsCount(attemptsCount); - hoDetails.setSuccessCount(successCount); - hoDetails.setSuccessRate(successRate); - int pc = 0; - int bc = 0; - hoDetails.setBadCount(bc); - hoDetails.setPoorCount(pc); - hoDetailsList.add(hoDetails); - log.info("good neighbor {}", additionalMeasurements.getName()); - } + int successRate = (int)((float) successCount / attemptsCount) * 100; + + Neighbours neighbourCell = new Neighbours(); + neighbourCell.setHoKpi(successRate); + neighbourCell.setCellId(additionalMeasurements.getName()); + neighbourCell.setPlmnId(additionalMeasurements.getHashMap().get("networkId")); + neighbourCell.setPnfName(pmNotification.getEvent().getCommonEventHeader().getReportingEntityName()); + neighbourList.add(neighbourCell); } - if (!lteCellList.isEmpty()) { + if (!neighbourList.isEmpty()) { log.info("triggering policy to remove bad neighbors"); Flag policyTriggerFlag = BeanUtil.getBean(Flag.class); @@ -171,7 +126,7 @@ public class PmNotificationHandler { } policyTriggerFlag.setHolder("PM"); - result = sendAnrUpdateToPolicy(pmNotification, lteCellList); + result = sendAnrUpdateToPolicy(pmNotification, neighbourList); log.info("Sent ANR update to policy {}", result); policyTriggerFlag.setHolder("NONE"); } @@ -199,19 +154,17 @@ public class PmNotificationHandler { } - private Boolean sendAnrUpdateToPolicy(PmNotification pmNotification, List lteCellList) { + private Boolean sendAnrUpdateToPolicy(PmNotification pmNotification, List neighbourList) { ObjectMapper mapper = new ObjectMapper(); try { mapper.setSerializationInclusion(Include.NON_NULL); - ArrayList configurations = new ArrayList<>(); String cellId = pmNotification.getEvent().getCommonEventHeader().getSourceName(); - Configurations configuration = new Configurations( - new Data(new FapService(cellId, null, - new CellConfig(new Lte(new Ran(new Common(cellId), - new NeighborListInUse(null, lteCellList, String.valueOf(lteCellList.size()))))))), - null); - configurations.add(configuration); - Payload payload = new Payload(configurations); + String pnfName = pmNotification.getEvent().getCommonEventHeader().getReportingEntityName(); + String plmnId = pmNotification.getEvent().getMeasurementFields() + .getAdditionalMeasurements().get(0).getHashMap().get("networkId"); + String ric_id = CpsClient.getRicId(cellId); + ANRPayload payload = new ANRPayload("CreatePolicy",1,1,ric_id, + (new PolicyData(pnfName,plmnId,cellId,neighbourList))); log.info("payload : {}", payload); String anrUpdateString = mapper.writeValueAsString(payload); ChildThreadUtils childUtils = new ChildThreadUtils(ConfigPolicy.getInstance(), new PnfUtils(), @@ -219,7 +172,7 @@ public class PmNotificationHandler { String requestId = UUID.randomUUID().toString(); String notification = childUtils.getNotificationString( pmNotification.getEvent().getCommonEventHeader().getReportingEntityName(), requestId, - anrUpdateString, System.currentTimeMillis(), "ModifyConfigANR"); + anrUpdateString, System.currentTimeMillis(), "ModifyA1Policy"); log.info("Policy Notification: {}", notification); Boolean result = policyDmaapClient.sendNotificationToPolicy(notification); log.info("send notification to policy result {} ", result); diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java index 6b60992..61653cf 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/child/ChildThreadUtils.java @@ -2,21 +2,21 @@ * ============LICENSE_START======================================================= * son-handler * ================================================================================ - * Copyright (C) 2019-2021 Wipro Limited. + * Copyright (C) 2019-2022 Wipro Limited. * ============================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= - * + * *******************************************************************************/ package org.onap.dcaegen2.services.sonhms.child; @@ -124,8 +124,10 @@ public class ChildThreadUtils { String action) { String closedLoopControlName = ""; - if (action.equals("ModifyConfig")) { - closedLoopControlName = "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459"; + String policyName = ""; + if (action.equals("ModifyO1Config")) { + closedLoopControlName = "ControlLoop-SONO1-fb41f388-a5f2-11e8-98d0-529269fb1459"; + policyName = "SONO1"; try { closedLoopControlName = (String) configPolicy.getConfig().get("PCI_MODCONFIG_POLICY_NAME"); } catch (NullPointerException e) { @@ -133,7 +135,8 @@ public class ChildThreadUtils { } } else { - closedLoopControlName = "ControlLoop-vSONH-7d4baf04-8875-4d1f-946d-06b874048b61"; + closedLoopControlName = "ControlLoop-SONA1-7d4baf04-8875-4d1f-946d-06b874048b61"; + policyName = "SONA1"; try { closedLoopControlName = (String) configPolicy.getConfig().get("PCI_MODCONFIGANR_POLICY_NAME"); } catch (NullPointerException e) { @@ -142,10 +145,11 @@ public class ChildThreadUtils { } PolicyNotification policyNotification = new PolicyNotification(closedLoopControlName, requestId, alarmStartTime, - pnfName, action); + pnfName, action, policyName); policyNotification.setClosedLoopControlName(closedLoopControlName); policyNotification.setPayload(payloadString); + policyNotification.setPolicyName(policyName); ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(Include.NON_NULL); @@ -200,7 +204,7 @@ public class ChildThreadUtils { String requestId = UUID.randomUUID().toString(); String notification = getNotificationString(pnfName, requestId, payloadString, - System.currentTimeMillis(), "ModifyConfig"); + System.currentTimeMillis(), "ModifyO1Config"); log.info("Policy Notification: {}", notification); boolean status = policyDmaapClient.sendNotificationToPolicy(notification); log.debug("sent Message: {}", status); @@ -271,7 +275,7 @@ public class ChildThreadUtils { } String requestId = UUID.randomUUID().toString(); String notification = getNotificationString(pnfName, requestId, payloadString, - System.currentTimeMillis(), "ModifyConfigANR"); + System.currentTimeMillis(), "ModifyA1Policy"); log.info("Policy Notification: {}", notification); Boolean result = policyDmaapClient.sendNotificationToPolicy(notification); log.info("send notification to policy result {} ", result); diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/ANRPayload.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/ANRPayload.java new file mode 100644 index 0000000..c8ff5e4 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/ANRPayload.java @@ -0,0 +1,115 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * son-handler + * ================================================================================ + * Copyright (C) 2022 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.dcaegen2.services.sonhms.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +/** + * Model class for payload for A1 based control loop + */ + +public class ANRPayload { + + @JsonProperty("action") + private String action; + + @JsonProperty("policy_id") + private int policy_id; + + @JsonProperty("policy_type_id") + private int policy_type_id; + + @JsonProperty("ric_id") + private String ric_id; + + @JsonProperty("policy_data") + private PolicyData policy_data; + + /** + * Constructor + */ + + public ANRPayload() { + + } + + /** + * Constructor + */ + + public ANRPayload(String action, int policy_id, int policy_type_id, String ric_id, PolicyData policy_data) { + super(); + this.action = action; + this.policy_id = policy_id; + this.policy_type_id = policy_type_id; + this.ric_id = ric_id; + this.policy_data=policy_data; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public int getPolicyId(){ + return policy_id; + } + public void setPolicyId(int policy_id){ + this.policy_id = policy_id; + } + + public int getPolicyTypeId(){ + return policy_type_id; + } + + public void setPolicyTypeId(int policy_type_id){ + this.policy_type_id = policy_type_id; + } + + public String getRicId(){ + return ric_id; + } + + public void setRicId(String ric_id){ + this.ric_id = ric_id; + } + + public PolicyData getPolicyData(){ + return policy_data; + } + + public void setPolicyData(PolicyData policy_data){ + this.policy_data = policy_data; + } + + @Override + public String toString() { + return "Payload [=" + action + "]"; + + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Action.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Action.java new file mode 100644 index 0000000..72bf6a8 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Action.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * son-handler + * ================================================================================ + * Copyright (C) 2022 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.dcaegen2.services.sonhms.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public enum Action { + + CreatePolicy, + DeletePolicy, + GetPolicyStatus + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/Neighbours.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Neighbours.java new file mode 100644 index 0000000..73c3cd5 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/Neighbours.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * son-handler + * ================================================================================ + * Copyright (C) 2022 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.dcaegen2.services.sonhms.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +/** + * Model class for neighbour details within the payload + * for A1 based control loop + */ + +public class Neighbours { + + @JsonProperty("PNFName") + private String pnfName; + + @JsonProperty("PLMNID") + private String plmnId; + + @JsonProperty("CellID") + private String cellId; + + @JsonProperty("ho-kpi1") + private int hoKpi; + + public Neighbours() { + + } + + /** + * Parameterized Constructor. + */ + public Neighbours(String pnfName, String plmnId, String cellId, int hoKpi) { + super(); + this.pnfName = pnfName; + this.plmnId = plmnId; + this.cellId = cellId; + this.hoKpi = hoKpi; + } + + public String getPnfName() { + return pnfName; + } + + public void setPnfName(String pnfName) { + this.pnfName = pnfName; + } + + public String getPlmnId() { + return plmnId; + } + + public void setPlmnId(String plmnId) { + this.plmnId = plmnId; + } + + public String getCellId() { + return cellId; + } + + public void setCellId(String cellId) { + this.cellId = cellId; + } + + public int getHoKpi() { + return hoKpi; + } + + public void setHoKpi(int hoKpi) { + this.hoKpi = hoKpi; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyData.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyData.java new file mode 100644 index 0000000..ff5b48e --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyData.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * ============LICENSE_START======================================================= + * son-handler + * ================================================================================ + * Copyright (C) 2022 Wipro Limited. + * ============================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + *******************************************************************************/ + +package org.onap.dcaegen2.services.sonhms.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +public class PolicyData { + + @JsonProperty("PNFName") + private String pnfName; + + @JsonProperty("PLMNID") + private String plmnId; + + @JsonProperty("CellID") + private String cellId; + + @JsonProperty("neighbours") + private List neighbours; + + public PolicyData() { + + } + + /** + * Parameterized Constructor. + */ + public PolicyData(String pnfName, String plmnId, String cellId, List neighbours) { + super(); + this.pnfName = pnfName; + this.plmnId = plmnId; + this.cellId = cellId; + this.neighbours = neighbours; + } + + public String getPnfName() { + return pnfName; + } + + public void setPnfName(String pnfName) { + this.pnfName = pnfName; + } + + public String getPlmnId() { + return plmnId; + } + + public void setPlmnId(String plmnId) { + this.plmnId = plmnId; + } + + public String getCellId() { + return cellId; + } + + public void setCellId(String cellId) { + this.cellId = cellId; + } + + public List getNeighbours() { + return neighbours; + } + + public void setNeighbours(List neighbours) { + this.neighbours=neighbours; + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotification.java b/src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotification.java index 8766dff..74afb10 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotification.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/model/PolicyNotification.java @@ -2,21 +2,21 @@ * ============LICENSE_START======================================================= * son-handler * ================================================================================ - * Copyright (C) 2019-2020 Wipro Limited. + * Copyright (C) 2019-2022 Wipro Limited. * ============================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= - * + * *******************************************************************************/ package org.onap.dcaegen2.services.sonhms.model; @@ -65,7 +65,7 @@ public class PolicyNotification { * Constructor. */ public PolicyNotification(String closedLoopControlName, String requestId, Long alarmStartTime, String pnfName, - String action) { + String action, String policyName) { this.closedLoopControlName = closedLoopControlName; this.requestId = requestId; this.closedLoopEventClient = "microservice.PCI"; @@ -80,7 +80,7 @@ public class PolicyNotification { aai.put("generic-vnf.is-closed-loop-disabled", "false"); aai.put("generic-vnf.prov-status", "ACTIVE"); aai.put("pnf.pnf-name", pnfName); - this.policyName = "PCI"; + this.policyName = policyName; this.policyVersion = "1.0.2"; } diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/ConfigInterface.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/ConfigInterface.java index ff34cbf..79753b7 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/ConfigInterface.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/ConfigInterface.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * son-handler * ================================================================================ - * Copyright (C) 2021 Wipro Limited. + * Copyright (C) 2021-2022 Wipro Limited. * ============================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,7 +53,7 @@ public abstract class ConfigInterface */ public abstract int getPci(String cellId) throws ConfigDbNotFoundException, CpsNotFoundException; - /** + /** * Abstract method to get PNF name from SDNR or CPS based on the client mentioned. * * @throws ConfigDbNotFoundException,CpsNotFoundException @@ -70,4 +70,4 @@ public abstract class ConfigInterface * @see org.onap.dcaegen2.services.sonhms.Configuration */ public abstract JSONObject getCellData(String cellId) throws ConfigDbNotFoundException, CpsNotFoundException; -} \ No newline at end of file +} diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CpsClient.java b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CpsClient.java index 461d901..caf94f1 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CpsClient.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CpsClient.java @@ -131,6 +131,24 @@ public class CpsClient extends ConfigInterface { return responseObject; } + /* + * Method to get NearRTRIC ID from CPS. + * + * @throws CpsNotFoundException when request to CPS fails + */ + + public static String getRicId(String cellId) throws CpsNotFoundException { + Configuration configuration = Configuration.getInstance(); + String requestUrl = configuration.getCpsServiceUrl() + "/" + configuration.getGetRicIdUrl(); + JSONObject inputparam = new JSONObject(); + JSONObject reqbody = new JSONObject(); + inputparam.put("cellId", cellId); + reqbody.put("inputParameters", inputparam); + String response = sendRequest(requestUrl, reqbody); + JSONObject responseObject = new JSONObject(response); + return responseObject.getString("idNearRTRIC"); + } + /** * Method to get CellData name from CPS. * @@ -151,7 +169,7 @@ public class CpsClient extends ConfigInterface { return responseObject; } - private String sendRequest(String url, JSONObject reqbody) throws CpsNotFoundException { + private static String sendRequest(String url, JSONObject reqbody) throws CpsNotFoundException { ResponseEntity response = SonHandlerRestTemplate.sendPostRequest(url, reqbody.toString(), new ParameterizedTypeReference() { }); diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java b/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java index ba3d4c0..aff431b 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/child/TestChildThreadUtils.java @@ -2,21 +2,21 @@ * ============LICENSE_START======================================================= * son-handler * ================================================================================ - * Copyright (C) 2019-2021 Wipro Limited. + * Copyright (C) 2019-2022 Wipro Limited. * ============================================================================== * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= - * + * *******************************************************************************/ package org.onap.dcaegen2.services.sonhms.child; @@ -80,179 +80,178 @@ import org.springframework.test.context.junit4.SpringRunner; @SpringBootTest(classes = TestChildThreadUtils.class) public class TestChildThreadUtils { - ChildThreadUtils childThreadUtils; - @Mock - private SonRequestsRepository repository; + ChildThreadUtils childThreadUtils; + @Mock + private SonRequestsRepository repository; - @Mock - private PnfUtils pnfUtils; - @Mock - private PolicyDmaapClient policyDmaapClient; - - @Mock - private HandOverMetricsRepository hoMetricRepository; - - @Mock - private HoMetricsComponent hoMetricsComponent; - - @InjectMocks - private ChildThreadUtils childThreadUtils2; + @Mock + private PnfUtils pnfUtils; + @Mock + private PolicyDmaapClient policyDmaapClient; + + @Mock + private HandOverMetricsRepository hoMetricRepository; + + @Mock + private HoMetricsComponent hoMetricsComponent; + + @InjectMocks + private ChildThreadUtils childThreadUtils2; - @Before - public void setup() { + @Before + public void setup() { - ConfigPolicy configPolicy = ConfigPolicy.getInstance(); - Configuration config = Configuration.getInstance(); - config.setConfigClientType("ConfigDB"); - config.setMinCollision(5); - config.setMinConfusion(5); - Map configPolicyMap = new HashMap<>(); - configPolicyMap.put("PCI_MODCONFIG_POLICY_NAME", "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459"); - configPolicy.setConfig(configPolicyMap); - childThreadUtils = new ChildThreadUtils(configPolicy, pnfUtils, policyDmaapClient, hoMetricsComponent); - MockitoAnnotations.initMocks(this); - - } + ConfigPolicy configPolicy = ConfigPolicy.getInstance(); + Configuration config = Configuration.getInstance(); + config.setConfigClientType("ConfigDB"); + config.setMinCollision(5); + config.setMinConfusion(5); + Map configPolicyMap = new HashMap<>(); + configPolicyMap.put("PCI_MODCONFIG_POLICY_NAME", "ControlLoop-SONO1-fb41f388-a5f2-11e8-98d0-529269fb1459"); + configPolicy.setConfig(configPolicyMap); + childThreadUtils = new ChildThreadUtils(configPolicy, pnfUtils, policyDmaapClient, hoMetricsComponent); + MockitoAnnotations.initMocks(this); + + } - @Test - public void savePciRequestTest() { - SonRequests sonRequest = new SonRequests(); - sonRequest.setTransactionId("transactionId"); - sonRequest.setChildThreadId(1L); - PowerMockito.mockStatic(BeanUtil.class); - PowerMockito.when(BeanUtil.getBean(SonRequestsRepository.class)) - .thenReturn(repository); - when(repository.save(sonRequest)).thenReturn(sonRequest); - childThreadUtils2.saveRequest("transactionId",1L);; - assertEquals(sonRequest, repository.save(sonRequest)); - } + @Test + public void savePciRequestTest() { + SonRequests sonRequest = new SonRequests(); + sonRequest.setTransactionId("transactionId"); + sonRequest.setChildThreadId(1L); + PowerMockito.mockStatic(BeanUtil.class); + PowerMockito.when(BeanUtil.getBean(SonRequestsRepository.class)) + .thenReturn(repository); + when(repository.save(sonRequest)).thenReturn(sonRequest); + childThreadUtils2.saveRequest("transactionId",1L);; + assertEquals(sonRequest, repository.save(sonRequest)); + } - @Test - public void triggerOrWaitTest() { - Map> collisionConfusionResult = new HashMap>(); - ArrayList list = new ArrayList(); - list.add(6); - list.add(7); - collisionConfusionResult.put("cellId", list); + @Test + public void triggerOrWaitTest() { + Map> collisionConfusionResult = new HashMap>(); + ArrayList list = new ArrayList(); + list.add(6); + list.add(7); + collisionConfusionResult.put("cellId", list); - Boolean result = childThreadUtils.triggerOrWait(collisionConfusionResult); - assertTrue(result); - Map> collisionConfusionResult1 = new HashMap>(); + Boolean result = childThreadUtils.triggerOrWait(collisionConfusionResult); + assertTrue(result); + Map> collisionConfusionResult1 = new HashMap>(); - ArrayList list1 = new ArrayList(); - list1.add(1); - list1.add(2); - collisionConfusionResult1.put("cell1", list1); - result = childThreadUtils.triggerOrWait(collisionConfusionResult1); - assertFalse(result); + ArrayList list1 = new ArrayList(); + list1.add(1); + list1.add(2); + collisionConfusionResult1.put("cell1", list1); + result = childThreadUtils.triggerOrWait(collisionConfusionResult1); + assertFalse(result); - } + } - @Test - public void getNotificationStringTest() { + @Test + public void getNotificationStringTest() { - String policy_notif = readFromFile("/policy_notification.json"); - PolicyNotification expected = new PolicyNotification(); - ObjectMapper mapper = new ObjectMapper(); + String policy_notif = readFromFile("/policy_notification.json"); + PolicyNotification expected = new PolicyNotification(); + ObjectMapper mapper = new ObjectMapper(); - try { - expected = mapper.readValue(policy_notif, PolicyNotification.class); - } catch (IOException e) { - e.printStackTrace(); - } + try { + expected = mapper.readValue(policy_notif, PolicyNotification.class); + } catch (IOException e) { + e.printStackTrace(); + } - String pnfName = "ncserver23"; - List cellPciPairs = new ArrayList<>(); + String pnfName = "ncserver23"; + List cellPciPairs = new ArrayList<>(); - cellPciPairs.add(new CellPciPair("Chn0330", 6)); - cellPciPairs.add(new CellPciPair("Chn0331", 7)); - String requestId = "a4130fd5-2291-4a83-8992-04e4c9f32731"; - Long alarmStart = Long.parseLong("1542445563201"); + cellPciPairs.add(new CellPciPair("Chn0330", 6)); + cellPciPairs.add(new CellPciPair("Chn0331", 7)); + String requestId = "a4130fd5-2291-4a83-8992-04e4c9f32731"; + Long alarmStart = Long.parseLong("1542445563201"); - String result = childThreadUtils.getNotificationString(pnfName, requestId, "payloadString", alarmStart, "ModifyConfig"); - PolicyNotification actual = new PolicyNotification(); - try { - actual = mapper.readValue(result, PolicyNotification.class); - } catch (IOException e) { - e.printStackTrace(); - } - System.out.println("actual :; "+result+"\nexp "+policy_notif); - Assert.assertEquals(expected.hashCode(), actual.hashCode()); - } - - @Test - public void sendToPolicyTest() throws Exception { - - PowerMockito.mockStatic(SdnrRestClient.class); - PowerMockito.mockStatic(BeanUtil.class); - PowerMockito.mockStatic(SdnrRestClient.class); - PowerMockito.mockStatic(ConfigurationClient.class); + String result = childThreadUtils.getNotificationString(pnfName, requestId, "payloadString", alarmStart, "ModifyO1Config"); + PolicyNotification actual = new PolicyNotification(); + try { + actual = mapper.readValue(result, PolicyNotification.class); + } catch (IOException e) { + e.printStackTrace(); + } + System.out.println("actual :; "+result+"\nexp "+policy_notif); + Assert.assertEquals(expected.hashCode(), actual.hashCode()); + } + + @Test + public void sendToPolicyTest() throws Exception { - SdnrRestClient sdnr = PowerMockito.spy(new SdnrRestClient()); - Configuration config = Configuration.getInstance(); + PowerMockito.mockStatic(SdnrRestClient.class); + PowerMockito.mockStatic(BeanUtil.class); + PowerMockito.mockStatic(SdnrRestClient.class); + PowerMockito.mockStatic(ConfigurationClient.class); - String asyncRspBodyString = readFromFile("/AsyncRespBody.json"); - ObjectMapper mapper = new ObjectMapper(); - AsyncResponseBody async = new AsyncResponseBody(); - try { + SdnrRestClient sdnr = PowerMockito.spy(new SdnrRestClient()); + Configuration config = Configuration.getInstance(); + + String asyncRspBodyString = readFromFile("/AsyncRespBody.json"); + ObjectMapper mapper = new ObjectMapper(); + AsyncResponseBody async = new AsyncResponseBody(); + try { async = mapper.readValue(asyncRspBodyString, AsyncResponseBody.class); - } catch (Exception e) { + } catch (Exception e) { e.printStackTrace(); - } + } - PowerMockito.whenNew(SdnrRestClient.class).withAnyArguments().thenReturn(sdnr); - PowerMockito.when(config.getConfigurationClient()).thenReturn(sdnr); - PowerMockito.doReturn(3).when(sdnr, "getPci", Mockito.anyString()); - PowerMockito.doReturn("pnfName").when(sdnr, "getPnfName", Mockito.anyString()); - when(policyDmaapClient.sendNotificationToPolicy(Mockito.anyString())).thenReturn(true); - Map> pnfsMap = new HashMap>(); - CellPciPair cell1 = new CellPciPair("cell0", 1); - CellPciPair cell2 = new CellPciPair("cell1", 2); - CellPciPair cell3 = new CellPciPair("cell2", 3); - List pciPairList = new ArrayList<>(); - pciPairList.add(cell1); - pciPairList.add(cell2); - pciPairList.add(cell3); - pnfsMap.put("pnf1", pciPairList); - when(policyDmaapClient.handlePolicyResponse(Mockito.anyString())).thenReturn(true); - when(pnfUtils.getPnfs(async.getSolutions())).thenReturn(pnfsMap); - List remNeighbors = new ArrayList<>(); - remNeighbors.add("EXP006"); - Map> cellRemNeighborsPair = new HashMap<>(); - cellRemNeighborsPair.put("EXP003", remNeighbors); - List>> list = new ArrayList<>(); - list.add(cellRemNeighborsPair); - Map>>> expected = new HashMap<>(); - expected.put("pnfName", list); - when(pnfUtils.getPnfsForAnrSolutions(async.getSolutions().getAnrSolutions())).thenReturn(expected); - HoDetails hoDetails = new HoDetails(); - hoDetails.setDstCellId("EXP006"); - List hoDetailsList = new ArrayList<>(); - hoDetailsList.add(hoDetails); - Either, Integer> hoMetrics = Either.left(hoDetailsList); - when(hoMetricsComponent.getHoMetrics(Mockito.anyString())).thenReturn(hoMetrics); - when(hoMetricsComponent.update(Mockito.anyString(), Mockito.anyString())).thenReturn(true); - assertTrue(childThreadUtils2.sendToPolicy(async)); - - } + PowerMockito.whenNew(SdnrRestClient.class).withAnyArguments().thenReturn(sdnr); + PowerMockito.when(config.getConfigurationClient()).thenReturn(sdnr); + PowerMockito.doReturn(3).when(sdnr, "getPci", Mockito.anyString()); + PowerMockito.doReturn("pnfName").when(sdnr, "getPnfName", Mockito.anyString()); + when(policyDmaapClient.sendNotificationToPolicy(Mockito.anyString())).thenReturn(true); + Map> pnfsMap = new HashMap>(); + CellPciPair cell1 = new CellPciPair("cell0", 1); + CellPciPair cell2 = new CellPciPair("cell1", 2); + CellPciPair cell3 = new CellPciPair("cell2", 3); + List pciPairList = new ArrayList<>(); + pciPairList.add(cell1); + pciPairList.add(cell2); + pciPairList.add(cell3); + pnfsMap.put("pnf1", pciPairList); + when(policyDmaapClient.handlePolicyResponse(Mockito.anyString())).thenReturn(true); + when(pnfUtils.getPnfs(async.getSolutions())).thenReturn(pnfsMap); + List remNeighbors = new ArrayList<>(); + remNeighbors.add("EXP006"); + Map> cellRemNeighborsPair = new HashMap<>(); + cellRemNeighborsPair.put("EXP003", remNeighbors); + List>> list = new ArrayList<>(); + list.add(cellRemNeighborsPair); + Map>>> expected = new HashMap<>(); + expected.put("pnfName", list); + when(pnfUtils.getPnfsForAnrSolutions(async.getSolutions().getAnrSolutions())).thenReturn(expected); + HoDetails hoDetails = new HoDetails(); + hoDetails.setDstCellId("EXP006"); + List hoDetailsList = new ArrayList<>(); + hoDetailsList.add(hoDetails); + Either, Integer> hoMetrics = Either.left(hoDetailsList); + when(hoMetricsComponent.getHoMetrics(Mockito.anyString())).thenReturn(hoMetrics); + when(hoMetricsComponent.update(Mockito.anyString(), Mockito.anyString())).thenReturn(true); + assertTrue(childThreadUtils2.sendToPolicy(async)); + } - private static String readFromFile(String file) { - String content = new String(); - try { + private static String readFromFile(String file) { + String content = new String(); + try { - InputStream is = ClusterUtilsTest.class.getResourceAsStream(file); - BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is)); - content = bufferedReader.readLine(); - String temp; - while ((temp = bufferedReader.readLine()) != null) { - content = content.concat(temp); - } - content = content.trim(); - bufferedReader.close(); - } catch (Exception e) { - e.printStackTrace(); - content = null; - } - return content; - } + InputStream is = ClusterUtilsTest.class.getResourceAsStream(file); + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is)); + content = bufferedReader.readLine(); + String temp; + while ((temp = bufferedReader.readLine()) != null) { + content = content.concat(temp); + } + content = content.trim(); + bufferedReader.close(); + } catch (Exception e) { + e.printStackTrace(); + content = null; + } + return content; + } } diff --git a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/CpsClientTest.java b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/CpsClientTest.java index 5b7050a..4d8713a 100644 --- a/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/CpsClientTest.java +++ b/src/test/java/org/onap/dcaegen2/services/sonhms/restclient/CpsClientTest.java @@ -151,6 +151,28 @@ public class CpsClientTest { } } + @Test + public void getRicIdTest() { + String responseBody = "{\"idNearRTRIC\":\"22\"}"; + PowerMockito.mockStatic(SonHandlerRestTemplate.class); + PowerMockito.mockStatic(Configuration.class); + PowerMockito.when(Configuration.getInstance()).thenReturn(configuration); + PowerMockito + .when(SonHandlerRestTemplate.sendPostRequest(Mockito.anyString(), Mockito.anyString(), + Matchers.>any())) + .thenReturn(ResponseEntity.ok(responseBody)); + try { + String result = cps.getRicId("1"); + String response = ResponseEntity.ok(responseBody).getBody(); + JSONObject respObj = new JSONObject(response); + assertEquals(respObj.get("idNearRTRIC"), result); + } catch (CpsNotFoundException e) { + log.debug("CpsNotFoundException {}", e.toString()); + } + } + + + @Test public void getCellData() { String responseBody = "{\"networkId\":\"netw1000\"}"; diff --git a/src/test/resources/policy_notification.json b/src/test/resources/policy_notification.json index 289afeb..b8906f3 100644 --- a/src/test/resources/policy_notification.json +++ b/src/test/resources/policy_notification.json @@ -1,5 +1,5 @@ { - "closedLoopControlName": "ControlLoop-vPCI-fb41f388-a5f2-11e8-98d0-529269fb1459", + "closedLoopControlName": "ControlLoop-SONO1-fb41f388-a5f2-11e8-98d0-529269fb1459", "closedLoopAlarmStart": 1542445563201, "closedLoopEventClient": "microservice.PCI", "closedLoopEventStatus": "ONSET", @@ -14,5 +14,5 @@ "generic-vnf.is-closed-loop-disabled": "false", "pnf.pnf-name": "ncserver23" }, - "Action": "ModifyConfig" + "Action": "ModifyO1Config" } diff --git a/version.properties b/version.properties index 3f0f450..27dd1a8 100644 --- a/version.properties +++ b/version.properties @@ -20,7 +20,7 @@ ############################################################################### major=2 minor=1 -patch=8 +patch=9 base_version=${major}.${minor}.${patch} release_version=${base_version} snapshot_version=${base_version}-SNAPSHOT -- cgit 1.2.3-korg