summaryrefslogtreecommitdiffstats
path: root/adapters/mso-nssmf-adapter/src
diff options
context:
space:
mode:
authorzm330 <zhangminyj@chinamobile.com>2020-11-10 15:51:39 +0800
committerzm330 <zhangminyj@chinamobile.com>2020-11-10 15:51:49 +0800
commit7737166117a3d41b8c1297531d2e68829bf7fbc8 (patch)
tree4db9947dceadef882767e1e89bb650e4dfe27e6a /adapters/mso-nssmf-adapter/src
parentdb17dd3511b757cb4d5b0a63cfdcda3bb60b51a0 (diff)
Update query subnet capability
Issue-ID: SO-2963 Signed-off-by: zm330 <zhangminyj@chinamobile.com> Change-Id: I695cb9b6842c85c2f0a99cf95f12bbf3b6a04a6d
Diffstat (limited to 'adapters/mso-nssmf-adapter/src')
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java2
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java48
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java2
-rw-r--r--adapters/mso-nssmf-adapter/src/main/resources/subnetCapability.json19
-rw-r--r--adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java5
5 files changed, 67 insertions, 9 deletions
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java
index 789f4f239d..acaa3945bd 100644
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java
@@ -193,7 +193,7 @@ public abstract class BaseNssmfManager implements NssmfManager {
return doQuerySubnetCapability(nbiRequest.getSubnetCapabilityQuery());
}
- protected abstract <T> RestResponse doQuerySubnetCapability(T req) throws ApplicationException;
+ protected abstract <T> RestResponse doQuerySubnetCapability(QuerySubnetCapability req) throws ApplicationException;
/**
* send request to nssmf
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java
index 72d1b53781..9dcd2d4cfb 100644
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java
@@ -20,7 +20,11 @@
package org.onap.so.adapters.nssmf.manager.impl;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.http.Header;
+import org.apache.http.HttpStatus;
import org.apache.http.message.BasicHeader;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.so.adapters.nssmf.entity.NssmfInfo;
@@ -31,14 +35,23 @@ import org.onap.so.adapters.nssmf.exceptions.ApplicationException;
import org.onap.so.adapters.nssmf.util.NssmfAdapterUtil;
import org.onap.so.beans.nsmf.*;
import org.onap.so.db.request.beans.ResourceOperationStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import static java.lang.String.valueOf;
import static org.onap.so.adapters.nssmf.enums.JobStatus.*;
-import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.*;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.QUERY_JOB_STATUS_FAILED;
+import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.StatusDesc.QUERY_JOB_STATUS_SUCCESS;
import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal;
public abstract class ExternalNssmfManager extends BaseNssmfManager {
+ private static final Logger logger = LoggerFactory.getLogger(ExternalNssmfManager.class);
+
@Override
protected String wrapAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
return doWrapExtAllocateReqBody(nbiRequest);
@@ -167,11 +180,34 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager {
}
@Override
- protected <T> RestResponse doQuerySubnetCapability(T req) throws ApplicationException {
- RestResponse response = new RestResponse();
- response.setStatus(200);
- response.setResponseContent(null);
- return response;
+ protected <T> RestResponse doQuerySubnetCapability(QuerySubnetCapability req) throws ApplicationException {
+
+ ObjectMapper oMapper = new ObjectMapper();
+ InputStream inputStream = TypeReference.class.getResourceAsStream("/subnetCapability.json");
+ Map<String, Object> subnetCapability = new HashMap<>();
+ try {
+ subnetCapability = oMapper.readValue(inputStream, Map.class);
+ } catch (Exception e) {
+ logger.debug("Exception while reading subnet capability value from json", e);
+ }
+ Map<String, Object> responseMap = new HashMap<>();
+ List<String> subnetTypes = req.getSubnetTypes();
+ for (String value : subnetTypes) {
+ if (subnetCapability.containsKey(value)) {
+ responseMap.put(value, subnetCapability.get(value));
+ }
+ }
+ String response = null;
+ try {
+ response = oMapper.writeValueAsString(responseMap);
+ } catch (JsonProcessingException e) {
+ logger.debug("Exception while converting subnet capability object to String {}", e);
+ }
+
+ RestResponse rsp = new RestResponse();
+ rsp.setStatus(HttpStatus.SC_OK);
+ rsp.setResponseContent(response);
+ return rsp;
}
/**
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java
index 88b5071371..296c30c1d8 100644
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/InternalNssmfManager.java
@@ -122,7 +122,7 @@ public abstract class InternalNssmfManager extends BaseNssmfManager {
protected abstract String doWrapModifyReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException;
@Override
- protected <T> RestResponse doQuerySubnetCapability(T req) throws ApplicationException {
+ protected <T> RestResponse doQuerySubnetCapability(QuerySubnetCapability req) throws ApplicationException {
// handler
return sendRequest(marshal(req));
}
diff --git a/adapters/mso-nssmf-adapter/src/main/resources/subnetCapability.json b/adapters/mso-nssmf-adapter/src/main/resources/subnetCapability.json
new file mode 100644
index 0000000000..8db52168ae
--- /dev/null
+++ b/adapters/mso-nssmf-adapter/src/main/resources/subnetCapability.json
@@ -0,0 +1,19 @@
+{
+ "AN": {
+ "latency": "5",
+ "maxNumberofUEs": "100"
+ },
+ "CN": {
+ "latency": "10",
+ "maxNumberofConns": "100"
+ },
+ "TN_FH": {
+ "latency": "10"
+ },
+ "TN_MH": {
+ "latency": "5"
+ },
+ "TN_BH": {
+ "latency": "10"
+ }
+}
diff --git a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java
index 4a659e1ca3..0d86056821 100644
--- a/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java
+++ b/adapters/mso-nssmf-adapter/src/test/java/org/onap/so/adapters/nssmf/service/impl/NssmfManagerServiceImplTest.java
@@ -38,6 +38,7 @@ import org.onap.so.adapters.nssmf.entity.TokenResponse;
import org.onap.so.adapters.nssmf.enums.HttpMethod;
import org.onap.so.adapters.nssmf.util.RestUtil;
import org.onap.so.beans.nsmf.*;
+import org.onap.so.beans.nsmf.oof.SubnetCapability;
import org.onap.so.db.request.beans.ResourceOperationStatus;
import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository;
import org.springframework.http.ResponseEntity;
@@ -429,7 +430,9 @@ public class NssmfManagerServiceImplTest {
public void querySubnetCapability() {
NssmfAdapterNBIRequest nbiRequest = createNbiRequest();
- String subnetCapabilityQuery = "\"subnetTypes\": [\"TN-FH\",\"TN-MH\",\"TN-BH\"]";
+ QuerySubnetCapability subnetCapabilityQuery = new QuerySubnetCapability();
+ List<String> subnetTypes = Arrays.asList("TN-FH", "TN-MH", "TN-BH");
+ subnetCapabilityQuery.setSubnetTypes(subnetTypes);
nbiRequest.setSubnetCapabilityQuery(subnetCapabilityQuery);
ResponseEntity res = nssiManagerService.queryNSSISelectionCapability(nbiRequest);
assertNotNull(res);