Read subnetCapabilities configuration file from SO pod 35/114735/1
authordeepikasatheesh <deepika.s84@wipro.com>
Tue, 10 Nov 2020 12:27:55 +0000 (04:27 -0800)
committerdeepikasatheesh <deepika.s84@wipro.com>
Tue, 10 Nov 2020 12:27:55 +0000 (04:27 -0800)
Issue-ID: SO-3372
Signed-off-by: deepikasatheesh <deepika.s84@wipro.com>
Change-Id: I1055ec23b572d4f8b19ba326615248153c895227

mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java
mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml
mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstancesTest.java
mso-api-handlers/mso-api-handler-infra/src/test/resources/Onap3gppServiceInstancesTest/subnetCapability.json [moved from mso-api-handlers/mso-api-handler-infra/src/main/resources/subnetCapability.json with 59% similarity]
mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml

index b1486c9..a25a140 100644 (file)
@@ -20,6 +20,9 @@
 
 package org.onap.so.apihandlerinfra;
 
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
 import java.sql.Timestamp;
 import java.util.HashMap;
 import java.util.UUID;
@@ -72,6 +75,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.MDC;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Component;
 import com.fasterxml.jackson.core.JsonProcessingException;
@@ -124,6 +128,9 @@ public class Onap3gppServiceInstances {
     @Autowired
     private ResponseHandler responseHandler;
 
+    @Value("${subnetCapability.config.file}")
+    private String subnetCapabilityConfigFile;
+
     /**
      * POST Requests for 3GPP Service create Instance on a version provided
      *
@@ -583,13 +590,23 @@ public class Onap3gppServiceInstances {
         }
     }
 
-    // To be implemented for fetching Subnet capabilities
     private Response getSubnetCapabilities(List<SubnetTypes> subnetTypes, String version) throws ApiException {
         ObjectMapper oMapper = new ObjectMapper();
-        InputStream inputStream = TypeReference.class.getResourceAsStream("/subnetCapability.json");
+        String inputFileString = "";
         Map<String, Object> subnetCapability = new HashMap<>();
+        BufferedReader br = null;
         try {
-            subnetCapability = oMapper.readValue(inputStream, Map.class);
+            logger.debug("Reading SubnetCapability file");
+            br = new BufferedReader(new FileReader(new File(subnetCapabilityConfigFile)));
+            StringBuilder sb = new StringBuilder();
+            String line = br.readLine();
+            while (line != null) {
+                sb.append(line);
+                sb.append("\n");
+                line = br.readLine();
+            }
+            inputFileString = sb.toString();
+            subnetCapability = oMapper.readValue(inputFileString, Map.class);
         } catch (Exception e) {
             logger.debug("Exception while reading subnet capability value from json", e);
         }
index b46690f..6064f73 100644 (file)
@@ -83,3 +83,7 @@ org:
       adapters:
         network:
           encryptionKey: aa3871669d893c7fb8abbcda31b88b4f
+
+subnetCapability:
+  config:
+      file: /app/subnetCapability.json
index 95f00c3..14a87bf 100644 (file)
@@ -187,7 +187,7 @@ public class Onap3gppServiceInstancesTest extends BaseTest {
         String request = "{\"subnetTypes\":[\"AN\"]}";
         QuerySubnetCapability subnetCapabilityRequest = MAPPER.readValue(request, QuerySubnetCapability.class);
         String expectedResponse =
-                "{\"AN\":{\"latency\":\"5\",\"maxNumberofUEs\":\"100\",\"maxThroughput\":\"150\",\"terminalDensity\":\"50\"}}";
+                "{\"AN\":{\"latency\":5,\"maxNumberofUEs\":\"100\",\"maxThroughput\":\"150\",\"terminalDensity\":\"50\"}}";
         Response response = objUnderTest.getSliceSubnetCapabilities(subnetCapabilityRequest, "v1");
         String actualResponse = (String) response.getEntity();
         assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
@@ -1,25 +1,31 @@
 {
   "AN": {
-    "latency": "5",
+    "latency": 5,
     "maxNumberofUEs": "100",
     "maxThroughput": "150",
     "terminalDensity": "50"
   },
   "CN": {
-    "latency": "10",
+    "latency": 10,
     "maxThroughput": "50",
     "maxNumberofConns": "100"
   },
   "TN_FH": {
-    "latency": "10",
+    "latency": 10,
     "maxThroughput": "100"
   },
   "TN_MH": {
-    "latency": "5",
+    "latency": 5,
     "maxThroughput": "50"
   },
   "TN_BH": {
-    "latency": "10",
+    "latency": 10,
     "maxThroughput": "100"
+  },
+  "AN_NF": {
+    "latency": 5,
+    "maxNumberofUEs": "100",
+    "maxThroughput": "150",
+    "terminalDensity": "50"
   }
 }
index 1429ac9..bcd36b8 100644 (file)
@@ -140,3 +140,8 @@ org:
       adapters:
         network:
           encryptionKey: aa3871669d893c7fb8abbcda31b88b4f
+
+subnetCapability:
+  config:
+      file: src/test/resources/Onap3gppServiceInstancesTest/subnetCapability.json
+