aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java23
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java1
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstancesTest.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java12
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/Onap3gppServiceInstancesTest/subnetCapability.json (renamed from mso-api-handlers/mso-api-handler-infra/src/main/resources/subnetCapability.json)16
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml5
8 files changed, 50 insertions, 17 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java
index b1486c9686..a25a140334 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java
@@ -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);
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
index 7924ca304a..9a4d0a45df 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
@@ -26,6 +26,7 @@ package org.onap.so.apihandlerinfra;
import java.io.IOException;
import java.util.HashMap;
import java.util.Optional;
+import java.util.stream.Collectors;
import javax.transaction.Transactional;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml
index b46690f2a7..6064f73e23 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml
@@ -83,3 +83,7 @@ org:
adapters:
network:
encryptionKey: aa3871669d893c7fb8abbcda31b88b4f
+
+subnetCapability:
+ config:
+ file: /app/subnetCapability.json
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java
index f4ff19f53d..fb923faf78 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java
@@ -104,8 +104,8 @@ public class ManualTasksTest extends BaseTest {
RequestError expectedResponse = new RequestError();
ServiceException se = new ServiceException();
se.setMessageId("SVC0002");
- se.setText("Mapping of request to JSON object failed: Unrecognized token \'test\': "
- + "was expecting \'null\', \'true\', \'false\' or NaN\n at [Source: (String)\"test\"; line: 1, column: 9]");
+ se.setText(
+ "Mapping of request to JSON object failed: Unrecognized token \u0027test\u0027: was expecting (JSON String, Number, Array, Object or token \u0027null\u0027, \u0027true\u0027 or \u0027false\u0027)\n at [Source: (String)\"test\"; line: 1, column: 5]");
expectedResponse.setServiceException(se);
HttpHeaders headers = new HttpHeaders();
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstancesTest.java
index 95f00c3a39..14a87bf915 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstancesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstancesTest.java
@@ -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());
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
index d43bbb6ea0..b358f26cb2 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
@@ -2453,7 +2453,7 @@ public class ServiceInstancesTest extends BaseTest {
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
assertEquals(
- "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
+ "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error: [no body]",
realResponse.getServiceException().getText());
}
@@ -2498,7 +2498,7 @@ public class ServiceInstancesTest extends BaseTest {
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
assertEquals(
- "Unable to get process-instance history from Camunda for requestId: f0a35706-efc4-4e27-80ea-a995d7a2a40f due to error: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
+ "Unable to get process-instance history from Camunda for requestId: f0a35706-efc4-4e27-80ea-a995d7a2a40f due to error: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error: [no body]",
realResponse.getServiceException().getText());
}
@@ -2515,7 +2515,7 @@ public class ServiceInstancesTest extends BaseTest {
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
assertEquals(
- "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
+ "Unable to check for duplicate instance due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error: [no body]",
realResponse.getServiceException().getText());
}
@@ -2547,7 +2547,7 @@ public class ServiceInstancesTest extends BaseTest {
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
assertEquals(
- "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
+ "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error: [no body]",
realResponse.getServiceException().getText());
}
@@ -2567,7 +2567,7 @@ public class ServiceInstancesTest extends BaseTest {
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
assertEquals(
- "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
+ "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error: [no body]",
realResponse.getServiceException().getText());
}
@@ -2584,7 +2584,7 @@ public class ServiceInstancesTest extends BaseTest {
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value());
RequestError realResponse = mapper.readValue(response.getBody(), RequestError.class);
assertEquals(
- "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error",
+ "Unable to save instance to db due to error contacting requestDb: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Server Error: [no body]",
realResponse.getServiceException().getText());
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/resources/subnetCapability.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Onap3gppServiceInstancesTest/subnetCapability.json
index 0d5acef64a..55b3831502 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/resources/subnetCapability.json
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Onap3gppServiceInstancesTest/subnetCapability.json
@@ -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"
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml b/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml
index 1429ac9b52..bcd36b8643 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml
@@ -140,3 +140,8 @@ org:
adapters:
network:
encryptionKey: aa3871669d893c7fb8abbcda31b88b4f
+
+subnetCapability:
+ config:
+ file: src/test/resources/Onap3gppServiceInstancesTest/subnetCapability.json
+