summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKalkere Ramesh, Sharan (sk720x) <sk720x@att.com>2018-12-10 16:17:44 -0500
committerKalkere Ramesh, Sharan (sk720x) <sk720x@att.com>2018-12-10 16:19:48 -0500
commit57f1d8052877d1114bd59b8e4383e4c86f41b4a6 (patch)
treeaeb97f5ccc3b80772e2e43c6c9d09d39438a6b16
parent533311a4934838b67ffd0ca49d7958f69059bccd (diff)
Added lookup of serviceType and sent to BPMN
Change-Id: I8da48da63211c5875a056f1d95cfc6bdf073a9fb Issue-ID: SO-1316 Signed-off-by: Kalkere Ramesh, Sharan (sk720x) <sk720x@att.com>
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java29
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java92
2 files changed, 119 insertions, 2 deletions
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 32693c356e..676dca101b 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
@@ -705,7 +705,6 @@ public class ServiceInstances {
String vnfType = msoRequest.getVnfType(sir,requestScope,action,requestVersion);
String networkType = msoRequest.getNetworkType(sir,requestScope);
String sdcServiceModelVersion = msoRequest.getSDCServiceModelVersion(sir);
- String serviceInstanceType = msoRequest.getServiceInstanceType(sir,requestScope);
String vfModuleType = msoRequest.getVfModuleType(sir,requestScope,action,requestVersion);
if(requestScope.equalsIgnoreCase(ModelType.vnf.name()) && vnfType != null){
@@ -732,7 +731,7 @@ public class ServiceInstances {
Boolean isBaseVfModule = false;
RecipeLookupResult recipeLookupResult = getServiceInstanceOrchestrationURI(sir, action, alaCarteFlag, currentActiveReq);
-
+ String serviceInstanceType = getServiceType(requestScope, sir, alaCarteFlag);
ModelType modelType;
ModelInfo modelInfo = sir.getRequestDetails().getModelInfo();
if (action == Action.applyUpdatedConfig || action == Action.inPlaceSoftwareUpdate) {
@@ -1857,4 +1856,30 @@ public class ServiceInstances {
}
}
}
+ protected String getServiceType(String requestScope, ServiceInstancesRequest sir, Boolean aLaCarteFlag){
+ String serviceType = null;
+ if(requestScope.equalsIgnoreCase(ModelType.service.toString())){
+ String defaultServiceModelName = getDefaultModel(sir);
+ org.onap.so.db.catalog.beans.Service serviceRecord;
+ if(aLaCarteFlag){
+ serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName);
+ if(serviceRecord != null){
+ serviceType = serviceRecord.getServiceType();
+ }
+ }else{
+ serviceRecord = catalogDbClient.getServiceByID(sir.getRequestDetails().getModelInfo().getModelVersionId());
+ if(serviceRecord != null){
+ serviceType = serviceRecord.getServiceType();
+ }else{
+ serviceRecord = catalogDbClient.getFirstByModelNameOrderByModelVersionDesc(defaultServiceModelName);
+ if(serviceRecord != null){
+ serviceType = serviceRecord.getServiceType();
+ }
+ }
+ }
+ }else{
+ serviceType = msoRequest.getServiceInstanceType(sir, requestScope);
+ }
+ return serviceType;
+ }
}
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 8d3649a65d..168df1903a 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
@@ -55,7 +55,9 @@ import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.logger.MsoLogger;
import org.onap.so.serviceinstancebeans.CloudConfiguration;
import org.onap.so.serviceinstancebeans.ModelInfo;
+import org.onap.so.serviceinstancebeans.RequestDetails;
import org.onap.so.serviceinstancebeans.RequestError;
+import org.onap.so.serviceinstancebeans.RequestInfo;
import org.onap.so.serviceinstancebeans.RequestParameters;
import org.onap.so.serviceinstancebeans.RequestReferences;
import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
@@ -70,6 +72,7 @@ import org.springframework.util.ResourceUtils;
import org.springframework.web.util.UriComponentsBuilder;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.tomakehurst.wiremock.http.Fault;
@@ -2582,4 +2585,93 @@ public class ServiceInstancesTest extends BaseTest{
ServiceInstancesResponse realResponse = mapper.readValue(response.getBody(), ServiceInstancesResponse.class);
assertThat(realResponse, sameBeanAs(expectedResponse).ignoring("requestReferences.requestId"));
}
+ @Test
+ public void setServiceTypeTestALaCarte() throws JsonProcessingException{
+ String requestScope = ModelType.service.toString();
+ Boolean aLaCarteFlag = true;
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ requestInfo.setSource("VID");
+ requestDetails.setRequestInfo(requestInfo);
+ sir.setRequestDetails(requestDetails);
+ Service defaultService = new Service();
+ defaultService.setServiceType("testServiceTypeALaCarte");
+
+ stubFor(get(urlMatching(".*/service/search/.*"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(defaultService))
+ .withStatus(HttpStatus.SC_OK)));
+
+ String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
+ assertEquals(serviceType, "testServiceTypeALaCarte");
+ }
+ @Test
+ public void setServiceTypeTest() throws JsonProcessingException{
+ String requestScope = ModelType.service.toString();
+ Boolean aLaCarteFlag = false;
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
+ requestInfo.setSource("VID");
+ requestDetails.setModelInfo(modelInfo);
+ requestDetails.setRequestInfo(requestInfo);
+ sir.setRequestDetails(requestDetails);
+ Service defaultService = new Service();
+ defaultService.setServiceType("testServiceType");
+
+ stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(defaultService))
+ .withStatus(HttpStatus.SC_OK)));
+
+ String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
+ assertEquals(serviceType, "testServiceType");
+ }
+ @Test
+ public void setServiceTypeTestDefault() throws JsonProcessingException{
+ String requestScope = ModelType.service.toString();
+ Boolean aLaCarteFlag = false;
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelVersionId("0dd91181-49da-446b-b839-cd959a96f04a");
+ requestInfo.setSource("VID");
+ requestDetails.setModelInfo(modelInfo);
+ requestDetails.setRequestInfo(requestInfo);
+ sir.setRequestDetails(requestDetails);
+ Service defaultService = new Service();
+ defaultService.setServiceType("testServiceType");
+
+ stubFor(get(urlMatching(".*/service/0dd91181-49da-446b-b839-cd959a96f04a"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withStatus(HttpStatus.SC_NOT_FOUND)));
+ stubFor(get(urlMatching(".*/service/search/.*"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(mapper.writeValueAsString(defaultService))
+ .withStatus(HttpStatus.SC_OK)));
+
+ String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
+ assertEquals(serviceType, "testServiceType");
+ }
+ @Test
+ public void setServiceTypeTestNetwork() throws JsonProcessingException{
+ String requestScope = ModelType.network.toString();
+ Boolean aLaCarteFlag = null;
+ ServiceInstancesRequest sir = new ServiceInstancesRequest();
+ RequestDetails requestDetails = new RequestDetails();
+ RequestInfo requestInfo = new RequestInfo();
+ ModelInfo modelInfo = new ModelInfo();
+ modelInfo.setModelName("networkModelName");
+ requestInfo.setSource("VID");
+ requestDetails.setModelInfo(modelInfo);
+ requestDetails.setRequestInfo(requestInfo);
+ sir.setRequestDetails(requestDetails);
+
+ String serviceType = servInstances.getServiceType(requestScope, sir, aLaCarteFlag);
+ assertEquals(serviceType, "networkModelName");
+ }
}