summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/QueryJobStatus.groovy141
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/QueryJobStatus.bpmn141
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstances.java35
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/QuerySubnetCapability.java16
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/resources/subnetCapability.json25
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/Onap3gppServiceInstancesTest.java17
6 files changed, 363 insertions, 12 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/QueryJobStatus.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/QueryJobStatus.groovy
new file mode 100644
index 0000000000..5cdf540173
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/QueryJobStatus.groovy
@@ -0,0 +1,141 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2020 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.so.bpmn.infrastructure.scripts
+
+import groovy.json.JsonSlurper
+import org.json.JSONObject
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import org.onap.so.bpmn.core.UrnPropertiesReader
+
+public class QueryJobStatus extends AbstractServiceTaskProcessor{
+ private static final Logger logger = LoggerFactory.getLogger(QueryJobStatus.class)
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ JsonUtils jsonUtil = new JsonUtils()
+
+ public void preProcessRequest(DelegateExecution execution) {
+ logger.debug("Start preProcessRequest")
+
+ try{
+ String requestId = execution.getVariable("msoRequestId")
+ logger.debug("RequestId :" + requestId)
+ String responseId = execution.getVariable("responseId")
+ String jobId = execution.getVariable("jobId")
+ def jsonSlurper = new JsonSlurper()
+
+ HashMap<String,?> esrInfo=jsonSlurper.parseText(execution.getVariable("esrInfo"))
+ logger.debug("esrInfo" + esrInfo.toString())
+
+ HashMap<String,?> serviceInfo=jsonSlurper.parseText(execution.getVariable("serviceInfo"))
+ logger.debug("serviceInfo" + serviceInfo.toString())
+
+ execution.setVariable("esrInfo", esrInfo)
+ execution.setVariable("serviceInfo", serviceInfo)
+
+ String nssmfEndpoint = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint",execution)
+ String endPoint = String.format("/api/rest/provMns/v1/NSS/jobs/%s", jobId)
+ String url = nssmfEndpoint + endPoint
+ execution.setVariable("NSSMF_AdapterEndpoint", url)
+
+ String payload = """
+ {
+ "responseId": "${responseId}",
+ "esrInfo": ${execution.getVariable("esrInfo") as JSONObject},
+ "serviceInfo": ${execution.getVariable("serviceInfo") as JSONObject}
+ }
+ """
+
+ execution.setVariable("NSSMF_AdapterRequest", payload.replaceAll("\\s+", ""))
+ execution.setVariable("startTime", System.currentTimeMillis())
+ logger.debug("Outgoing NSSMF_AdapterRequest: \n" + payload)
+ }catch(Exception e){
+ String msg = "Exception in QueryJobStatus.preProcessRequest " + ex.getMessage()
+ logger.error(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.debug("exit preProcessRequest")
+ }
+
+ public void checkJobStatus(DelegateExecution execution) {
+ logger.debug(" *** checkJobStatus *** ")
+ def NSSMF_ResponseCode = execution.getVariable("NSSMF_ResponseCode") as Integer
+ logger.debug("NSSMF_ResponseCode:" + NSSMF_ResponseCode)
+ def NSSMF_Response = execution.getVariable("NSSMF_Response") as String
+ def status = jsonUtil.getJsonValue(NSSMF_Response, "responseDescriptor.status")
+ logger.debug("NSSMF_Response" + NSSMF_Response)
+
+ Long startTime = execution.getVariable("startTime") as Long
+ Long timeout = execution.getVariable("timeout") as Long
+ timeout = timeout == null ? 600000 : timeout * 60000
+
+ if(NSSMF_Response != null) {
+ if (status.equalsIgnoreCase("processing") && (System.currentTimeMillis() - startTime) > timeout) {
+ handleTimeOut(execution)
+ }
+ else if(status.equalsIgnoreCase("finished") || status.equalsIgnoreCase("failed")) {
+ execution.setVariable("JobStatusCompleted", "TRUE")
+ } else {
+ execution.setVariable("JobStatusCompleted", "FALSE")
+ }
+ } else {
+ Map<String, ?> responseDescriptorMap = new HashMap<>()
+ responseDescriptorMap.put("status","failed")
+ responseDescriptorMap.put("statusDescription","Exception while querying job status")
+ String responseDescriptor = """
+ {
+ "responseDescriptor": "${responseDescriptorMap}",
+ }
+ """
+ execution.setVariable("JobStatusCompleted", "TRUE")
+ execution.setVariable("NSSMF_Response",responseDescriptor.replaceAll("\\s+", ""))
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Received a Bad Response from NSSMF.")
+ }
+ logger.debug("exit checkJobStatus")
+ }
+
+ private handleTimeOut(DelegateExecution execution) {
+ Map<String, ?> responseDescriptorMap = new HashMap<>()
+ responseDescriptorMap.put("status","failed")
+ responseDescriptorMap.put("statusDescription","timeout")
+ String responseDescriptor = """
+ {
+ "responseDescriptor": "${responseDescriptorMap}",
+ }
+ """
+ execution.setVariable("JobStatusCompleted", "TRUE")
+ execution.setVariable("NSSMF_Response",responseDescriptor.replaceAll("\\s+", ""))
+ }
+
+ public void updateJobStatusDetails(DelegateExecution execution)
+ {
+ logger.debug("**updateJobStatusDetails**")
+ def NSSMF_Response = execution.getVariable("NSSMF_Response") as String
+ def responseDescriptor = jsonUtil.getJsonValue(NSSMF_Response, "responseDescriptor")
+ execution.setVariable("responseDescriptor",responseDescriptor)
+ logger.debug("**exit updateJobStatusDetails")
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/QueryJobStatus.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/QueryJobStatus.bpmn
new file mode 100644
index 0000000000..b2b6c031f9
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/QueryJobStatus.bpmn
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0le3oyh" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.2">
+ <bpmn:process id="QueryJobStatus" name="QueryJobStatus" isExecutable="true">
+ <bpmn:startEvent id="StartEvent_1" name="Start">
+ <bpmn:outgoing>Flow_16nxw2f</bpmn:outgoing>
+ </bpmn:startEvent>
+ <bpmn:scriptTask id="Activity_0cd23fy" name="Preprocess Request" scriptFormat="groovy">
+ <bpmn:incoming>Flow_16nxw2f</bpmn:incoming>
+ <bpmn:outgoing>Flow_0qhl0m8</bpmn:outgoing>
+ <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
+def qjs= new QueryJobStatus()
+qjs.preProcessRequest(execution)</bpmn:script>
+ </bpmn:scriptTask>
+ <bpmn:serviceTask id="Activity_1aivult" name="Query Job Status">
+ <bpmn:extensionElements>
+ <camunda:connector>
+ <camunda:inputOutput>
+ <camunda:inputParameter name="url">${NSSMF_AdapterEndpoint}</camunda:inputParameter>
+ <camunda:inputParameter name="headers">
+ <camunda:map>
+ <camunda:entry key="content-type">application/json</camunda:entry>
+ <camunda:entry key="Authorization">Basic YnBlbDpwYXNzd29yZDEk</camunda:entry>
+ </camunda:map>
+ </camunda:inputParameter>
+ <camunda:inputParameter name="payload">${NSSMF_AdapterRequest}</camunda:inputParameter>
+ <camunda:inputParameter name="method">POST</camunda:inputParameter>
+ <camunda:outputParameter name="NSSMF_ResponseCode">${statusCode}</camunda:outputParameter>
+ <camunda:outputParameter name="NSSMF_Response">${response}</camunda:outputParameter>
+ </camunda:inputOutput>
+ <camunda:connectorId>http-connector</camunda:connectorId>
+ </camunda:connector>
+ </bpmn:extensionElements>
+ <bpmn:incoming>Flow_0qhl0m8</bpmn:incoming>
+ <bpmn:incoming>Flow_1qqqckj</bpmn:incoming>
+ <bpmn:outgoing>Flow_18di8yy</bpmn:outgoing>
+ </bpmn:serviceTask>
+ <bpmn:sequenceFlow id="Flow_16nxw2f" sourceRef="StartEvent_1" targetRef="Activity_0cd23fy" />
+ <bpmn:sequenceFlow id="Flow_0qhl0m8" sourceRef="Activity_0cd23fy" targetRef="Activity_1aivult" />
+ <bpmn:scriptTask id="Activity_16hyg49" name="Check Job Status" scriptFormat="groovy">
+ <bpmn:incoming>Flow_18di8yy</bpmn:incoming>
+ <bpmn:outgoing>Flow_0ct1kfw</bpmn:outgoing>
+ <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
+def qjs= new QueryJobStatus()
+qjs.checkJobStatus(execution)</bpmn:script>
+ </bpmn:scriptTask>
+ <bpmn:exclusiveGateway id="Gateway_1ruy0j9" name="Is Completed?">
+ <bpmn:incoming>Flow_0ct1kfw</bpmn:incoming>
+ <bpmn:outgoing>Flow_1x9fug6</bpmn:outgoing>
+ <bpmn:outgoing>Flow_1qqqckj</bpmn:outgoing>
+ </bpmn:exclusiveGateway>
+ <bpmn:sequenceFlow id="Flow_18di8yy" sourceRef="Activity_1aivult" targetRef="Activity_16hyg49" />
+ <bpmn:sequenceFlow id="Flow_0ct1kfw" sourceRef="Activity_16hyg49" targetRef="Gateway_1ruy0j9" />
+ <bpmn:scriptTask id="Activity_0rtwx97" name="Update JobStatus details" scriptFormat="groovy">
+ <bpmn:incoming>Flow_1x9fug6</bpmn:incoming>
+ <bpmn:outgoing>Flow_0qqltc9</bpmn:outgoing>
+ <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.*
+def qjs= new QueryJobStatus()
+qjs.updateJobStatusDetails(execution)</bpmn:script>
+ </bpmn:scriptTask>
+ <bpmn:sequenceFlow id="Flow_1x9fug6" name="yes" sourceRef="Gateway_1ruy0j9" targetRef="Activity_0rtwx97">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("JobStatusCompleted") == "TRUE"}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ <bpmn:endEvent id="Event_0p00z2s" name="End">
+ <bpmn:incoming>Flow_0qqltc9</bpmn:incoming>
+ </bpmn:endEvent>
+ <bpmn:sequenceFlow id="Flow_0qqltc9" sourceRef="Activity_0rtwx97" targetRef="Event_0p00z2s" />
+ <bpmn:sequenceFlow id="Flow_1qqqckj" name="No" sourceRef="Gateway_1ruy0j9" targetRef="Activity_1aivult">
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">#{execution.getVariable("JobStatusCompleted") == "FALSE"}</bpmn:conditionExpression>
+ </bpmn:sequenceFlow>
+ </bpmn:process>
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="QueryJobStatus">
+ <bpmndi:BPMNEdge id="Flow_1qqqckj_di" bpmnElement="Flow_1qqqckj">
+ <di:waypoint x="880" y="152" />
+ <di:waypoint x="880" y="280" />
+ <di:waypoint x="550" y="280" />
+ <di:waypoint x="550" y="167" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="892" y="163" width="15" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0qqltc9_di" bpmnElement="Flow_0qqltc9">
+ <di:waypoint x="1100" y="127" />
+ <di:waypoint x="1152" y="127" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_1x9fug6_di" bpmnElement="Flow_1x9fug6">
+ <di:waypoint x="905" y="127" />
+ <di:waypoint x="1000" y="127" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="944" y="109" width="17" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0ct1kfw_di" bpmnElement="Flow_0ct1kfw">
+ <di:waypoint x="780" y="127" />
+ <di:waypoint x="855" y="127" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_18di8yy_di" bpmnElement="Flow_18di8yy">
+ <di:waypoint x="600" y="127" />
+ <di:waypoint x="680" y="127" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_0qhl0m8_di" bpmnElement="Flow_0qhl0m8">
+ <di:waypoint x="410" y="127" />
+ <di:waypoint x="500" y="127" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="Flow_16nxw2f_di" bpmnElement="Flow_16nxw2f">
+ <di:waypoint x="215" y="127" />
+ <di:waypoint x="310" y="127" />
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
+ <dc:Bounds x="179" y="109" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="186" y="152" width="25" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_0cd23fy_di" bpmnElement="Activity_0cd23fy">
+ <dc:Bounds x="310" y="87" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_1aivult_di" bpmnElement="Activity_1aivult">
+ <dc:Bounds x="500" y="87" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_16hyg49_di" bpmnElement="Activity_16hyg49">
+ <dc:Bounds x="680" y="87" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Gateway_1ruy0j9_di" bpmnElement="Gateway_1ruy0j9" isMarkerVisible="true">
+ <dc:Bounds x="855" y="102" width="50" height="50" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="844" y="83" width="72" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Activity_0rtwx97_di" bpmnElement="Activity_0rtwx97">
+ <dc:Bounds x="1000" y="87" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="Event_0p00z2s_di" bpmnElement="Event_0p00z2s">
+ <dc:Bounds x="1152" y="109" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="1160" y="152" width="20" height="14" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ </bpmndi:BPMNPlane>
+ </bpmndi:BPMNDiagram>
+</bpmn:definitions>
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 e7b96b16a9..3f05c79dad 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
@@ -23,6 +23,11 @@ package org.onap.so.apihandlerinfra;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.UUID;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.function.Function;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -54,6 +59,7 @@ import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.Allocate3gppServ
import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.DeAllocate3gppService;
import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.Modify3gppService;
import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.QuerySubnetCapability;
+import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.SubnetTypes;
import org.onap.so.constants.Status;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.ServiceRecipe;
@@ -70,6 +76,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.core.type.TypeReference;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.info.Info;
@@ -238,8 +245,8 @@ public class Onap3gppServiceInstances {
public Response getSliceSubnetCapabilities(QuerySubnetCapability request, @PathParam("version") String version)
throws ApiException {
logger.debug("Request received {}", request);
- String subnetType = null;
- return getSubnetCapabilities(subnetType, version);
+ List<SubnetTypes> subnetTypes = request.getSubnetTypes();
+ return getSubnetCapabilities(subnetTypes, version);
}
/**
@@ -577,8 +584,28 @@ public class Onap3gppServiceInstances {
}
// To be implemented for fetching Subnet capabilities
- private Response getSubnetCapabilities(String subnetType, String version) throws ApiException {
- return null;
+ private Response getSubnetCapabilities(List<SubnetTypes> subnetTypes, String version) throws ApiException {
+ 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<>();
+ for (SubnetTypes value : subnetTypes) {
+ if (subnetCapability.containsKey(value.toString())) {
+ responseMap.put(value.toString(), subnetCapability.get(value.toString()));
+ }
+ }
+ String response = null;
+ try {
+ response = oMapper.writeValueAsString(responseMap);
+ } catch (JsonProcessingException e) {
+ logger.debug("Exception while converting subnet capability object to String {}", e);
+ }
+ return builder.buildResponse(HttpStatus.SC_OK, null, response, version);
}
/**
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/QuerySubnetCapability.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/QuerySubnetCapability.java
index 2e479e1ecb..c66b053609 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/QuerySubnetCapability.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/onap3gppserviceinstancebeans/QuerySubnetCapability.java
@@ -22,26 +22,26 @@ package org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans;
import java.util.List;
+import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Model class for slice subnet capability query
*/
public class QuerySubnetCapability {
- private SubnetTypes subnetType;
+ @JsonProperty("subnetTypes")
+ private List<SubnetTypes> subnetTypes;
- public SubnetTypes getSubnetType() {
- return subnetType;
+ public List<SubnetTypes> getSubnetTypes() {
+ return subnetTypes;
}
- public void setSubnetType(SubnetTypes subnetType) {
- this.subnetType = subnetType;
+ public void setSubnetTypes(List<SubnetTypes> subnetTypes) {
+ this.subnetTypes = subnetTypes;
}
@Override
public String toString() {
- return "QuerySubnetCapability [subnetType=" + subnetType + "]";
+ return "QuerySubnetCapability [subnetType=" + subnetTypes + "]";
}
-
}
-
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/resources/subnetCapability.json b/mso-api-handlers/mso-api-handler-infra/src/main/resources/subnetCapability.json
new file mode 100644
index 0000000000..0d5acef64a
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/subnetCapability.json
@@ -0,0 +1,25 @@
+{
+ "AN": {
+ "latency": "5",
+ "maxNumberofUEs": "100",
+ "maxThroughput": "150",
+ "terminalDensity": "50"
+ },
+ "CN": {
+ "latency": "10",
+ "maxThroughput": "50",
+ "maxNumberofConns": "100"
+ },
+ "TN_FH": {
+ "latency": "10",
+ "maxThroughput": "100"
+ },
+ "TN_MH": {
+ "latency": "5",
+ "maxThroughput": "50"
+ },
+ "TN_BH": {
+ "latency": "10",
+ "maxThroughput": "100"
+ }
+}
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 503af1bdcb..c3c92be013 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
@@ -49,6 +49,9 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.util.UriComponentsBuilder;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.so.apihandlerinfra.exceptions.ApiException;
+import org.onap.so.apihandlerinfra.onap3gppserviceinstancebeans.QuerySubnetCapability;
+import org.springframework.beans.factory.annotation.Autowired;
public class Onap3gppServiceInstancesTest extends BaseTest {
@@ -56,6 +59,9 @@ public class Onap3gppServiceInstancesTest extends BaseTest {
private final ObjectMapper mapper = new ObjectMapper();
+ @Autowired
+ private Onap3gppServiceInstances objUnderTest;
+
@Before
public void init() throws JsonProcessingException {
@@ -176,6 +182,17 @@ public class Onap3gppServiceInstancesTest extends BaseTest {
assertEquals(expectedResponse, actualResponse);
}
+ @Test
+ public void getSliceSubnetCapabilitiesTest() throws IOException, ApiException {
+ String request = "{\"subnetTypes\":[\"AN\"]}";
+ QuerySubnetCapability subnetCapabilityRequest = mapper.readValue(request, QuerySubnetCapability.class);
+ String expectedResponse =
+ "{\"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());
+ assertEquals(expectedResponse, actualResponse);
+ }
}