Fix bug in handling FM notification 61/129161/2 2.1.7-son-handler
authormalar <malarvizhi.44@wipro.com>
Fri, 6 May 2022 12:46:52 +0000 (12:46 +0000)
committermalar <malarvizhi.44@wipro.com>
Wed, 11 May 2022 08:29:25 +0000 (08:29 +0000)
Issue-ID: DCAEGEN2-3150
Signed-off-by: Malarvizhi Paramasivam <malarvizhi.44@wipro.com>
Change-Id: I89f346ba5d369e7070e3181784513ffc4487360c

Changelog.md
pom.xml
src/main/java/org/onap/dcaegen2/services/sonhms/restclient/CpsClient.java
src/test/java/org/onap/dcaegen2/services/sonhms/restclient/CpsClientTest.java
version.properties

index 6a3731b..9ff9d6b 100644 (file)
@@ -4,6 +4,8 @@ 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.7] - 2021/05/11
+         - [DCAEGEN2-3150](https://jira.onap.org/browse/DCAEGEN2-3150) - Fix bug in handling FM notification
 
 ## [2.1.6] - 2022/02/07
          - [DCAEGEN2-3057](https://jira.onap.org/browse/DCAEGEN2-3057) - Fix bug in triggering control loop for PCI collision/confusion - by replacing Config DB with CPS
diff --git a/pom.xml b/pom.xml
index 205692c..5365a15 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -27,7 +27,7 @@
         <groupId>org.onap.dcaegen2.services.son-handler</groupId>
         <artifactId>son-handler</artifactId>
         <name>dcaegen2-services-son-handler</name>
-        <version>2.1.6-SNAPSHOT</version>
+        <version>2.1.7-SNAPSHOT</version>
 
        <!--parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId>
                 <version>2.0.4.RELEASE</version> </parent -->
index 282fe91..461d901 100644 (file)
@@ -90,6 +90,7 @@ public class CpsClient extends ConfigInterface {
     public int getPci(String cellId) throws CpsNotFoundException {
 
         Configuration configuration = Configuration.getInstance();
+        int responseObject = 0;
         String requestUrl = configuration.getCpsServiceUrl() + "/" + configuration.getGetPciUrl();
         JSONObject inputparam = new JSONObject();
         JSONObject reqbody = new JSONObject();
@@ -97,10 +98,13 @@ public class CpsClient extends ConfigInterface {
         reqbody.put("inputParameters", inputparam);
         String response = sendRequest(requestUrl, reqbody);
         log.info("Response from CPS is : " + response);
-        JSONObject respObj = new JSONObject(response);
-        int obj = respObj.getInt("nRPCI");
-        log.info("The nRPCI value is " + obj );
-        return respObj.getInt("nRPCI");
+        JSONArray requestArray = new JSONArray(response);
+        for (int i=0;i<requestArray.length();i++) {
+            int pciValue = requestArray.getJSONObject(i).getInt("nRPCI");
+            responseObject = pciValue;
+            log.info("The nRPCI value is : " + responseObject);
+        }
+        return responseObject;
     }
 
     /**
@@ -121,7 +125,7 @@ public class CpsClient extends ConfigInterface {
         log.info("Response from CPS is : " + response);
         JSONArray requestArray = new JSONArray(response);
         for (int i=0;i<requestArray.length();i++) {
-            String pnfName = requestArray.getJSONObject(i).optString("idGNBCUCPFunction");
+            String pnfName = requestArray.getJSONObject(i).optString("idGNBDUFunction");
             responseObject = pnfName;
         }
         return responseObject;
index e43a635..5b7050a 100644 (file)
@@ -103,7 +103,7 @@ public class CpsClientTest {
     @Test
     public void getPciTest() {
 
-        String responseBody = "{\n" + "  \"nRPCI\": \"11\",\n" + "  \"value\": 0\n" + "}";
+        String responseBody = "[{\n" + "  \"nRPCI\": \"11\",\n" + "  \"value\": 0\n" + "}]";
         PowerMockito.mockStatic(SonHandlerRestTemplate.class);
         PowerMockito.mockStatic(Configuration.class);
         PowerMockito.when(Configuration.getInstance()).thenReturn(configuration);
@@ -115,8 +115,10 @@ public class CpsClientTest {
         try {
             int result = cps.getPci("1");
             String response = ResponseEntity.ok(responseBody).getBody();
-            JSONObject respObj = new JSONObject(response);
-            assertEquals(respObj.getInt("nRPCI"), result);
+            JSONArray requestArray = new JSONArray(response);
+            for (int i=0;i<requestArray.length();i++) {
+               assertEquals(requestArray.getJSONObject(i).getInt("nRPCI"), result);
+            }
         } catch (CpsNotFoundException e) {
             log.debug("CpsNotFoundException {}", e.toString());
             ;
@@ -127,7 +129,7 @@ public class CpsClientTest {
     @Test
     public void getPnfNameTest() {
 
-        String responseBody = "[{\n" + "  \"idGNBCUCPFunction\": \"cucpserver1\",\n" + "  \"value\": \"string\"\n" + "}]";
+        String responseBody = "[{\n" + "  \"idGNBDUFunction\": \"110\",\n" + "  \"value\": \"string\"\n" + "}]";
         PowerMockito.mockStatic(SonHandlerRestTemplate.class);
         PowerMockito.mockStatic(Configuration.class);
         PowerMockito.when(Configuration.getInstance()).thenReturn(configuration);
@@ -136,12 +138,12 @@ public class CpsClientTest {
                         Matchers.<ParameterizedTypeReference<String>>any()))
                 .thenReturn(ResponseEntity.ok(responseBody));
         try {
-            String result = cps.getPnfName("cucpserver1");
+            String result = cps.getPnfName("110");
             String response = ResponseEntity.ok(responseBody).getBody();
             
             JSONArray requestArray = new JSONArray(response);
             for (int i=0;i<requestArray.length();i++) {
-                assertEquals(requestArray.getJSONObject(i).getString("idGNBCUCPFunction"), result);
+                assertEquals(requestArray.getJSONObject(i).getString("idGNBDUFunction"), result);
             }
         } catch (CpsNotFoundException e) {
             log.debug("CpsNotFoundException {}", e.toString());
index 01f80e6..13675c4 100644 (file)
@@ -20,7 +20,7 @@
 ###############################################################################
 major=2
 minor=1
-patch=6
+patch=7
 base_version=${major}.${minor}.${patch}
 release_version=${base_version}
 snapshot_version=${base_version}-SNAPSHOT