diff options
28 files changed, 626 insertions, 499 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java index 450ffd6d93..b249b58d48 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomization.java @@ -96,8 +96,8 @@ public class QueryAllottedResourceCustomization extends CatalogQuery { put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUuid()); put(valueMap, "MODEL_INSTANCE_NAME", o.getModelInstanceName()); put(valueMap, "TOSCA_NODE_TYPE", arNull ? null : o.getAllottedResource().getToscaNodeType()); - put(valueMap, "ALLOTTED_RESOURCE_TYPE", arNull ? null : o.getAllottedResource().getSubcategory()); - put(valueMap, "ALLOTTED_RESOURCE_ROLE", o.getTargetNetworkRole()); + put(valueMap, "ALLOTTED_RESOURCE_TYPE", o.getNfType()); + put(valueMap, "ALLOTTED_RESOURCE_ROLE", o.getNfRole()); put(valueMap, "NF_TYPE", o.getNfType()); put(valueMap, "NF_ROLE", o.getNfRole()); put(valueMap, "NF_FUNCTION", o.getNfFunction()); diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/OofHoming.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/OofHoming.groovy index f0f239b50f..d6576b7dce 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/OofHoming.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/OofHoming.groovy @@ -73,6 +73,8 @@ class OofHoming extends AbstractServiceTaskProcessor { utils.log("DEBUG", "Incoming Request Id is: " + requestId, isDebugEnabled) String serviceInstanceId = execution.getVariable("serviceInstanceId") utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) + String serviceInstanceName = execution.getVariable("serviceInstanceName") + utils.log("DEBUG", "Incoming Service Instance Name is: " + serviceInstanceName, isDebugEnabled) ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") utils.log("DEBUG", "Incoming Service Decomposition is: " + serviceDecomposition, isDebugEnabled) String subscriberInfo = execution.getVariable("subscriberInfo") @@ -86,21 +88,24 @@ class OofHoming extends AbstractServiceTaskProcessor { if (isBlank(requestId) || isBlank(serviceInstanceId) || + isBlank(serviceInstanceName) || isBlank(serviceDecomposition.toString()) || - isBlank(subscriberInfo) || - isBlank(customerLocation.toString()) || - isBlank(cloudOwner) || - isBlank(cloudRegionId)) { + isBlank(customerLocation.toString())) { exceptionUtil.buildAndThrowWorkflowException(execution, 4000, "A required input variable is missing or null") } else { - String subId = jsonUtil.getJsonValue(subscriberInfo, "globalSubscriberId") - String subName = jsonUtil.getJsonValue(subscriberInfo, "subscriberName") - String subCommonSiteId = "" - if (jsonUtil.jsonElementExist(subscriberInfo, "subscriberCommonSiteId")) { - subCommonSiteId = jsonUtil.getJsonValue(subscriberInfo, "subscriberCommonSiteId") + Subscriber subscriber = null + if (isBlank(subscriberInfo)) { + subscriber = new Subscriber("", "", "") + } else { + String subId = jsonUtil.getJsonValue(subscriberInfo, "globalSubscriberId") + String subName = jsonUtil.getJsonValue(subscriberInfo, "subscriberName") + String subCommonSiteId = "" + if (jsonUtil.jsonElementExist(subscriberInfo, "subscriberCommonSiteId")) { + subCommonSiteId = jsonUtil.getJsonValue(subscriberInfo, "subscriberCommonSiteId") + } + subscriber = new Subscriber(subId, subName, subCommonSiteId) } - Subscriber subscriber = new Subscriber(subId, subName, subCommonSiteId) //Authentication def authHeader = "" diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/OofUtils.groovy index f07a477bb3..b61739f32c 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/OofUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/OofUtils.groovy @@ -1,19 +1,21 @@ package org.openecomp.mso.bpmn.common.scripts -import org.apache.commons.lang3.StringUtils -import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.DelegateExecution import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil import org.openecomp.mso.bpmn.common.scripts.MsoUtils import org.openecomp.mso.bpmn.core.domain.HomingSolution import org.openecomp.mso.bpmn.core.domain.ModelInfo import org.openecomp.mso.bpmn.core.domain.Resource +import org.openecomp.mso.bpmn.core.domain.AllottedResource import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition import org.openecomp.mso.bpmn.core.domain.ServiceInstance import org.openecomp.mso.bpmn.core.domain.Subscriber import org.openecomp.mso.bpmn.core.domain.VnfResource import org.openecomp.mso.bpmn.core.json.JsonUtils +import java.lang.reflect.Array + import static org.openecomp.mso.bpmn.common.scripts.GenericUtils.* class OofUtils { @@ -47,7 +49,7 @@ class OofUtils { String buildRequest(DelegateExecution execution, String requestId, ServiceDecomposition decomposition, - Subscriber subscriber, + Subscriber subscriber = null, Map customerLocation, ArrayList existingCandidates = null, ArrayList excludedCandidates = null, @@ -82,9 +84,14 @@ class OofUtils { String modelName = model.getModelName() String modelVersion = model.getModelVersion() //Subscriber Info - String subscriberId = subscriber.getGlobalId() - String subscriberName = subscriber.getName() - String commonSiteId = subscriber.getCommonSiteId() + String subscriberId = "" + String subscriberName = "" + String commonSiteId = "" + if (subscriber != null){ + subscriberId = subscriber.getGlobalId() + subscriberName = subscriber.getName() + commonSiteId = subscriber.getCommonSiteId() + } //Determine RequestType //TODO Figure out better way to determine this @@ -100,27 +107,39 @@ class OofUtils { //Demands String placementDemands = "" StringBuilder sb = new StringBuilder() - List<Resource> resourceList = decomposition.getServiceAllottedResources() + List<AllottedResource> allottedResourceList = decomposition.getServiceAllottedResources() List<VnfResource> vnfResourceList = decomposition.getServiceVnfs() - if (resourceList.isEmpty() || resourceList == null) { + if (allottedResourceList.isEmpty() || allottedResourceList == null) { utils.log("DEBUG", "Allotted Resources List is empty - will try to get service VNFs instead.", isDebugEnabled) - resourceList = decomposition.getServiceVnfs() + allottedResourceList = decomposition.getServiceVnfs() } - if (resourceList.isEmpty() || resourceList == null) { + if (allottedResourceList.isEmpty() || allottedResourceList == null) { utils.log("DEBUG", "Resources List is Empty", isDebugEnabled) } else { - for (Resource resource : resourceList) { - ModelInfo resourceModelInfo = resource.getModelInfo() + for (AllottedResource resource : allottedResourceList) { + utils.log("DEBUG", "Allotted Resource: " + resource.toString(), + isDebugEnabled) def serviceResourceId = resource.getResourceId() - def resourceModuleName = resource.getResourceType() - def resouceModelInvariantId = resourceModelInfo.getModelInvariantUuid() - def resouceModelName = resourceModelInfo.getModelName() - def resouceModelVersion = resourceModelInfo.getModelVersion() - def resouceModelVersionId = resourceModelInfo.getModelUuid() - def resouceModelType = resourceModelInfo.getModelType() + def resourceModuleName = resource.getNfFunction() + utils.log("DEBUG", "resourceModuleName: " + resourceModuleName, + isDebugEnabled) + def resourceModelInvariantId = "no-resourceModelInvariantId" + def resourceModelVersionId = "no-resourceModelVersionId" + + List modelIdLst = execution.getVariable("homingModelIds") + utils.log("DEBUG", "Incoming modelIdLst is: " + modelIdLst.toString(), isDebugEnabled) + for (Map modelId : modelIdLst ) + if (resourceModuleName == modelId.resourceModuleName) { + resourceModelInvariantId = modelId.resourceModelInvariantId + resourceModelVersionId = modelId.resourceModelVersionId + } + + def resourceModelName = "" //Optional + def resourceModelVersion = "" //Optional + def resourceModelType = "" //Optional def tenantId = "" //Optional def requiredCandidatesJson = "" @@ -130,22 +149,56 @@ class OofUtils { requiredCandidates) String demand = - "{\n" + - "\"resourceModuleName\": \"${resourceModuleName}\",\n" + - "\"serviceResourceId\": \"${serviceResourceId}\",\n" + - "\"tenantId\": \"${tenantId}\",\n" + - "\"resourceModelInfo\": {\n" + - " \"modelInvariantId\": \"${resouceModelInvariantId}\",\n" + - " \"modelVersionId\": \"${resouceModelVersionId}\",\n" + - " \"modelName\": \"${resouceModelName}\",\n" + - " \"modelType\": \"${resouceModelType}\",\n" + - " \"modelVersion\": \"${resouceModelVersion}\",\n" + - " \"modelCustomizationName\": \"\"\n" + - " }" + requiredCandidatesJson + "\n" + - "}," + " {\n" + + " \"resourceModuleName\": \"${resourceModuleName}\",\n" + + " \"serviceResourceId\": \"${serviceResourceId}\",\n" + + " \"tenantId\": \"${tenantId}\",\n" + + " \"resourceModelInfo\": {\n" + + " \"modelInvariantId\": \"${resourceModelInvariantId}\",\n" + + " \"modelVersionId\": \"${resourceModelVersionId}\",\n" + + " \"modelName\": \"${resourceModelName}\",\n" + + " \"modelType\": \"${resourceModelType}\",\n" + + " \"modelVersion\": \"${resourceModelVersion}\",\n" + + " \"modelCustomizationName\": \"\"\n" + + " }" + requiredCandidatesJson + "\n" + + " }," placementDemands = sb.append(demand) } + for (VnfResource vnfResource : vnfResourceList) { + utils.log("DEBUG", "VNF Resource: " + vnfResource.toString(), + isDebugEnabled) + ModelInfo vnfResourceModelInfo = vnfResource.getModelInfo() + def serviceResourceId = vnfResource.getResourceId() + def resourceModuleName = vnfResource.getNfFunction() + utils.log("DEBUG", "resourceModuleName: " + resourceModuleName, + isDebugEnabled) + def resourceModelInvariantId = vnfResourceModelInfo.getModelInvariantUuid() + def resourceModelName = vnfResourceModelInfo.getModelName() + def resourceModelVersion = vnfResourceModelInfo.getModelVersion() + def resourceModelVersionId = vnfResourceModelInfo.getModelUuid() + def resourceModelType = vnfResourceModelInfo.getModelType() + def tenantId = "" //Optional + def requiredCandidatesJson = "" + + + String placementDemand = + " {\n" + + " \"resourceModuleName\": \"${resourceModuleName}\",\n" + + " \"serviceResourceId\": \"${serviceResourceId}\",\n" + + " \"tenantId\": \"${tenantId}\",\n" + + " \"resourceModelInfo\": {\n" + + " \"modelInvariantId\": \"${resourceModelInvariantId}\",\n" + + " \"modelVersionId\": \"${resourceModelVersionId}\",\n" + + " \"modelName\": \"${resourceModelName}\",\n" + + " \"modelType\": \"${resourceModelType}\",\n" + + " \"modelVersion\": \"${resourceModelVersion}\",\n" + + " \"modelCustomizationName\": \"\"\n" + + " }" + requiredCandidatesJson + "\n" + + " }," + + placementDemands = sb.append(placementDemand) + } placementDemands = placementDemands.substring(0, placementDemands.length() - 1) } @@ -271,11 +324,14 @@ class OofUtils { } else { return } - } else if (JsonUtils.jsonElementExist(response, "requestError") == true) { + } else if (response.contains("error") || response.contains("Error") ) { String errorMessage = "" if (response.contains("policyException")) { String text = jsonUtil.getJsonValue(response, "requestError.policyException.text") errorMessage = "OOF Async Callback Response contains a Request Error Policy Exception: " + text + } else if (response.contains("Unable to find any candidate for demand")) { + errorMessage = "OOF Async Callback Response contains error: Unable to find any candidate for " + + "demand *** Response: " + response.toString() } else if (response.contains("serviceException")) { String text = jsonUtil.getJsonValue(response, "requestError.serviceException.text") errorMessage = "OOF Async Callback Response contains a Request Error Service Exception: " + text diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/OofHomingTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/OofHomingTest.java index 283f3c6116..1f64fb55f8 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/OofHomingTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/OofHomingTest.java @@ -41,6 +41,7 @@ import org.openecomp.mso.bpmn.mock.FileUtil; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.UUID; @@ -97,7 +98,7 @@ public class OofHomingTest extends WorkflowTest { List<AllottedResource> arList = new ArrayList<AllottedResource>(); AllottedResource ar = new AllottedResource(); ar.setResourceId("testResourceIdAR"); - ar.setResourceInstanceName("testARInstanceName"); + ar.setNfFunction("testARFunctionName"); ModelInfo arModel = new ModelInfo(); arModel.setModelCustomizationUuid("testModelCustomizationUuidAR"); arModel.setModelInvariantUuid("testModelInvariantIdAR"); @@ -108,7 +109,7 @@ public class OofHomingTest extends WorkflowTest { ar.setModelInfo(arModel); AllottedResource ar2 = new AllottedResource(); ar2.setResourceId("testResourceIdAR2"); - ar2.setResourceInstanceName("testAR2InstanceName"); + ar2.setNfFunction("testAR2FunctionName"); ModelInfo arModel2 = new ModelInfo(); arModel2.setModelCustomizationUuid("testModelCustomizationUuidAR2"); arModel2.setModelInvariantUuid("testModelInvariantIdAR2"); @@ -123,7 +124,7 @@ public class OofHomingTest extends WorkflowTest { List<VnfResource> vnfList = new ArrayList<VnfResource>(); VnfResource vnf = new VnfResource(); vnf.setResourceId("testResourceIdVNF"); - vnf.setResourceInstanceName("testVnfInstanceName"); + vnf.setNfFunction("testVnfFunctionName"); ArrayList<CloudFlavor> flavors = new ArrayList<>(); CloudFlavor flavor1 = new CloudFlavor("flavorLabel1xxx", "vimFlavorxxx"); CloudFlavor flavor2 = new CloudFlavor("flavorLabel2xxx", "vimFlavorxxx"); @@ -478,9 +479,9 @@ public class OofHomingTest extends WorkflowTest { //Get Variables WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - - assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=No solution found " + - "for plan 08e1b8cf-144a-4bac-b293-d5e2eedc97e8]", workflowException.toString()); + Boolean errorMatch = workflowException.toString().contains("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback " + + "Response contains error: Unable to find any candidate for demand *** Response:"); + assert(errorMatch); } @Test @@ -546,7 +547,8 @@ public class OofHomingTest extends WorkflowTest { variables.put("customerLocation", customerLocation); variables.put("cloudOwner", "amazon"); variables.put("cloudRegionId", "TNZED"); - variables.put("isDebugLogEnabled", "true"); + variables.put("vgMuxInfraModelInvariantId", "testModelInvariantIdAR"); + variables.put("vgMuxInfraModelId", "testArModelUuid"); // variables.put("mso-request-id", "testRequestId"); variables.put("msoRequestId", "testRequestId"); variables.put("serviceInstanceId", "testServiceInstanceId123"); @@ -589,6 +591,8 @@ public class OofHomingTest extends WorkflowTest { variables.put("customerLocation", customerLocation); variables.put("cloudOwner", "amazon"); variables.put("cloudRegionId", "TNZED"); + variables.put("vgMuxInfraModelInvariantId", "testModelInvariantIdAR"); + variables.put("vgMuxInfraModelId", "testArModelUuid"); variables.put("isDebugLogEnabled", "true"); variables.put("msoRequestId", "testRequestId"); variables.put("serviceInstanceId", "testServiceInstanceId123"); @@ -609,6 +613,8 @@ public class OofHomingTest extends WorkflowTest { variables.put("customerLocation", customerLocation); variables.put("cloudOwner", "amazon"); variables.put("cloudRegionId", "TNZED"); + variables.put("vgMuxInfraModelInvariantId", "testModelInvariantIdAR"); + variables.put("vgMuxInfraModelId", "testArModelUuid"); variables.put("isDebugLogEnabled", "true"); // variables.put("mso-request-id", "testRequestId"); variables.put("msoRequestId", "testRequestId"); @@ -720,16 +726,20 @@ public class OofHomingTest extends WorkflowTest { "\"timeout\":600},\"placementInfo\":{\"requestParameters\":{\"customerLatitude\":" + "\"32.89748\",\"customerLongitude\":\"-97.040443\",\"customerName\":\"xyz\"},\"subscriberInfo\":" + "{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\"," + - "\"subscriberCommonSiteId\":\"\"},\"placementDemands\":[{\"resourceModuleName\":\"ALLOTTED_RESOURCE\"" + + "\"subscriberCommonSiteId\":\"\"},\"placementDemands\":[{\"resourceModuleName\":\"testARFunctionName\"" + ",\"serviceResourceId\":\"testResourceIdAR\",\"tenantId\":" + - "\"\",\"resourceModelInfo\":{\"modelInvariantId\":\"testModelInvariantIdAR\"," + - "\"modelVersionId\":\"testARModelUuid\",\"modelName\":\"testModelNameAR\",\"modelType\":" + - "\"testModelTypeAR\",\"modelVersion\":\"testModelVersionAR\",\"modelCustomizationName\":\"\"}}," + - "{\"resourceModuleName\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\"," + - "\"tenantId\":\"\",\"resourceModelInfo\":{\"modelInvariantId\":\"testModelInvariantIdAR2\"," + - "\"modelVersionId\":\"testAr2ModelUuid\",\"modelName\":\"testModelNameAR2\"," + - "\"modelType\":\"testModelTypeAR2\",\"modelVersion\":\"testModelVersionAR2\"," + - "\"modelCustomizationName\":\"\"}}]},\"serviceInfo\":" + + "\"\",\"resourceModelInfo\":{\"modelInvariantId\":\"no-resourceModelInvariantId\"," + + "\"modelVersionId\":\"no-resourceModelVersionId\",\"modelName\":\"\",\"modelType\":" + + "\"\",\"modelVersion\":\"\",\"modelCustomizationName\":\"\"}}," + + "{\"resourceModuleName\":\"testAR2FunctionName\",\"serviceResourceId\":\"testResourceIdAR2\"," + + "\"tenantId\":\"\",\"resourceModelInfo\":{\"modelInvariantId\":\"no-resourceModelInvariantId\"," + + "\"modelVersionId\":\"no-resourceModelVersionId\",\"modelName\":\"\"," + + "\"modelType\":\"\",\"modelVersion\":\"\"," + + "\"modelCustomizationName\":\"\"}},{\"resourceModuleName\":\"testVnfFunctionName\",\"serviceResourceId\":\"" + + "testResourceIdVNF\",\"tenantId\":\"\",\"resourceModelInfo\":{\"modelInvariantId\"" + + ":\"testModelInvariantIdVNF\",\"modelVersionId\":\"testVnfModelUuid\",\"modelName\":\"" + + "testModelNameVNF\",\"modelType\":\"testModelTypeVNF\",\"modelVersion\":\"testModelVersionVNF\"" + + ",\"modelCustomizationName\":\"\"}}]},\"serviceInfo\":" + "{\"serviceInstanceId\":\"testServiceInstanceId123\"," + "\"serviceName\":\"testServiceName\",\"modelInfo\":{\"modelType\":\"\",\"modelInvariantId\":" + "\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":\"testModelName\"," + diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallbackNoSolutionFound b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallbackNoSolutionFound index 8bb29f0c0a..2024df401b 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallbackNoSolutionFound +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/BuildingBlocks/oofCallbackNoSolutionFound @@ -1,10 +1,18 @@ { - "solutions": { - "placementSolutions": [], - "licenseSolutions": [] - }, - "transactionId": "08e1b8cf-144a-4bac-b293-d5e2eedc97e8", - "requestId": "02c2e322-5839-4c97-9d46-0a5fa6bb642e", - "requestStatus": "completed", - "statusMessage": "No solution found for plan 08e1b8cf-144a-4bac-b293-d5e2eedc97e8" + "plans":[ + { + "name":"356fdb73-cef2-4dda-8865-31fd6733d6e4", + "message":"Unable to find any candidate for demand vGW", + "links":[ + [ + { + "rel":"self", + "href":"http://172.17.0.6:8091/v1/plans/1c15e194-6df5-43fe-a5ff-42e6093b8ddd" + } + ] + ], + "id":"1c15e194-6df5-43fe-a5ff-42e6093b8ddd", + "status":"error" + } + ] }
\ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy index 0e4aea00ae..321741b721 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy @@ -95,12 +95,11 @@ public class DoScaleVFCNetworkServiceInstance extends AbstractServiceTaskProcess * scale NS task */ public void scaleNetworkService(DelegateExecution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") String saleNsRequest = execution.getVariable("reqBody") String[] nsReqStr = saleNsRequest.split("\\|") - def jobIdArray = ['jobId001', 'jobId002'] as String[] - for (int i = 0; i < nsReqStr.length; i++) { JSONObject reqBodyJsonObj = new JSONObject(nsReqStr[i]) String nsInstanceId = reqBodyJsonObj.getJSONObject("nsScaleParameters").getString("nsInstanceId") @@ -114,11 +113,11 @@ public class DoScaleVFCNetworkServiceInstance extends AbstractServiceTaskProcess String returnCode = apiResponse.getStatusCode() String aaiResponseAsString = apiResponse.getResponseBodyAsString() String jobId = ""; - if (returnCode == "200") { + if (returnCode == "200" || returnCode == "202") { jobId = jsonUtil.getJsonValue(aaiResponseAsString, "jobId") } - - execution.setVariable("jobId", jobIdArray[i]) + utils.log("INFO", "scaleNetworkService get a ns scale job Id:" + jobId, isDebugEnabled) + execution.setVariable("jobId", jobId) String isScaleFinished = "" diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy index ce117d3655..68f50e033c 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy @@ -76,6 +76,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { execution.setVariable("homingService", "") execution.setVariable("cloudOwner", "") execution.setVariable("cloudRegionId", "") + execution.setVariable("homingModelIds", "") //TODO execution.setVariable("sdncVersion", "1707") @@ -199,28 +200,47 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { def userParams = reqMap.requestDetails?.requestParameters?.userParams Map<String, String> inputMap = [:] - - if (userParams) { + if (userParams) { userParams.each { - userParam -> - if("BRG_WAN_MAC_Address".equals(userParam?.name)) { - execution.setVariable("brgWanMacAddress", userParam.value) - inputMap.put("BRG_WAN_MAC_Address", userParam.value) - } - if("Customer_Location".equals(userParam?.name)) { - execution.setVariable("customerLocation", userParam.value) - userParam.value.each { - customerLocParam -> - inputMap.put(customerLocParam.key, customerLocParam.value) + userParam -> + if ("Customer_Location".equals(userParam?.name)) { + execution.setVariable("customerLocation", userParam.value) + userParam.value.each { + param -> + inputMap.put(param.key, param.value) + } + } + if ("Homing_Model_Ids".equals(userParam?.name)) { + utils.log("DEBUG", "Homing_Model_Ids: " + userParam.value.toString() + " ---- Type is:" + + userParam.value.getClass() , isDebugEnabled) + def modelIdLst = [] + userParam.value.each { + param -> + def valueMap = [:] + param.each { + entry -> + valueMap.put(entry.key, entry.value) } - } - if("Homing_Solution".equals(userParam?.name)) { - execution.setVariable("homingService", userParam.value) - inputMap.put("Homing_Solution", userParam.value) - } else { - execution.setVariable("homingService", "oof") - } - } + modelIdLst.add(valueMap) + utils.log("DEBUG", "Param: " + param.toString() + " ---- Type is:" + + param.getClass() , isDebugEnabled) + } + execution.setVariable("homingModelIds", modelIdLst) + } + if ("BRG_WAN_MAC_Address".equals(userParam?.name)) { + execution.setVariable("brgWanMacAddress", userParam.value) + inputMap.put("BRG_WAN_MAC_Address", userParam.value) + } + if ("Homing_Solution".equals(userParam?.name)) { + execution.setVariable("homingService", userParam.value) + inputMap.put("Homing_Solution", userParam.value) + } + } + } + + if (execution.getVariable("homingService") == "") { + // Set Default Homing to OOF if not set + execution.setVariable("homingService", "oof") } utils.log("DEBUG", "User Input Parameters map: " + userParams.toString(), isDebugEnabled) @@ -422,7 +442,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { VnfResource vr = it.next() String role = vr.getNfRole() - if (role == "BRG" || role == "TunnelXConn") { + if (role == "BRG" || role == "TunnelXConn" || role == "Tunnel XConn") { it.remove() } } @@ -456,7 +476,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { utils.log("DEBUG", " getting model info for AllottedResource # :" + allottedResource.toJsonStringNoRootName(), isDebugEnabled) utils.log("DEBUG", " allottedResource.getAllottedResourceType() :" + allottedResource.getAllottedResourceType(), isDebugEnabled) - if ("TunnelXConn".equalsIgnoreCase(allottedResource.getAllottedResourceType())) { + if ("TunnelXConn".equalsIgnoreCase(allottedResource.getAllottedResourceType()) || "Tunnel XConn".equalsIgnoreCase(allottedResource.getAllottedResourceType())) { //set create flag to true execution.setVariable("createTXCAR", true) ModelInfo allottedResourceModelInfo = allottedResource.getModelInfo() diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy index aa16d3b280..08edb88c61 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy @@ -242,8 +242,8 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { if(isBlank(type) || isBlank(id)) {
- } else if(type == "TunnelXConn") {
- utils.log("DEBUG","TunnelXConn AR found", isDebugEnabled)
+ } else if(type == "TunnelXConn" || type == "Tunnel XConn") {
+ utils.log("DEBUG","Tunnel XConn AR found", isDebugEnabled)
TXC_found = true
TXC_id = id
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVcpeResCustService.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVcpeResCustService.bpmn index 9342e34f59..0a0c95af4c 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVcpeResCustService.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVcpeResCustService.bpmn @@ -452,6 +452,7 @@ CreateVcpeResCustService.prepareCreateAllottedResourceTXC(execution)]]></bpmn2:s <camunda:in source="cloudOwner" target="cloudOwner" /> <camunda:in source="cloudRegionId" target="cloudRegionId" /> <camunda:in source="serviceInstanceName" target="serviceInstanceName" /> + <camunda:in source="homingModelIds" target="homingModelIds" /> </bpmn2:extensionElements> <bpmn2:incoming>SequenceFlow_11efpvh</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_1jbuf1t</bpmn2:outgoing> diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy index a735121002..a8401d7a02 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy @@ -469,7 +469,7 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase { verify(mex).setVariable("createTXCAR", true) verify(mex).setVariable("allottedResourceModelInfoTXC", "modelB") verify(mex).setVariable("allottedResourceRoleTXC", "TXCr") - verify(mex).setVariable("allottedResourceTypeTXC", "TunnelXConn") + verify(mex).setVariable("allottedResourceTypeTXC", "Tunnel XConn") verify(mex).setVariable("parentServiceInstanceIdTXC", "homeB") } @@ -489,7 +489,7 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase { verify(mex, never()).setVariable("createTXCAR", true) verify(mex, never()).setVariable("allottedResourceModelInfoTXC", "modelB") verify(mex, never()).setVariable("allottedResourceRoleTXC", "TXCr") - verify(mex, never()).setVariable("allottedResourceTypeTXC", "TunnelXConn") + verify(mex, never()).setVariable("allottedResourceTypeTXC", "Tunnel XConn") verify(mex, never()).setVariable("parentServiceInstanceIdTXC", "homeB") } @@ -1087,7 +1087,7 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase { private ServiceDecomposition initFilterVnfs(ExecutionEntity mex) { List<VnfResource> vnflst = new LinkedList<>() vnflst.add(makeVnf("", "BRG")) - vnflst.add(makeVnf("2", "TunnelXConn")) + vnflst.add(makeVnf("2", "Tunnel XConn")) vnflst.add(makeVnf("3", "")) vnflst.add(makeVnf("4", "BRG")) vnflst.add(makeVnf("5", "other")) @@ -1149,7 +1149,7 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase { HomingSolution home = mock(HomingSolution.class) when(ar.toJsonStringNoRootName()).thenReturn("json"+id) - when(ar.getAllottedResourceType()).thenReturn("TunnelXConn") + when(ar.getAllottedResourceType()).thenReturn("Tunnel XConn") when(ar.getModelInfo()).thenReturn(mod) when(ar.getAllottedResourceRole()).thenReturn("TXCr") when(ar.getHomingSolution()).thenReturn(home) @@ -1186,7 +1186,7 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase { vnflst.add(makeVnf("A", "BRG")) vnflst.add(makeVnf("B", "")) vnflst.add(makeVnf("C", "")) - vnflst.add(makeVnf("D", "TunnelXConn")) + vnflst.add(makeVnf("D", "Tunnel XConn")) when(mex.getVariable(DBGFLAG)).thenReturn("true") when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request) diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/arGetById.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/arGetById.xml index bb7f4c20fd..f2063442d6 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/arGetById.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/arGetById.xml @@ -1,9 +1,9 @@ <allotted-resource xmlns="http://org.openecomp.aai.inventory/v9"> <id>ar-1</id> <orchestration-status>Active</orchestration-status> - <role>TunnelXConn</role> - <type>TunnelXConn</type> - <description>TunnelXConn</description> + <role>Tunnel XConn</role> + <type>Tunnel XConn</type> + <description>Tunnel XConn</description> <selflink/> <resource-version>1490627351232</resource-version> <relationship-list> diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json index 81fdcc76d0..e99dd9ccda 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json @@ -63,8 +63,8 @@ "modelInstanceName" : "Pri_IP_MUX_Demux 1" }, "toscaNodeType" : null, - "allottedResourceType" : "TunnelXConn", - "allottedResourceRole" : "TunnelXConn", + "allottedResourceType" : "Tunnel XConn", + "allottedResourceRole" : "Tunnel XConn", "providingServiceModelInvariantUuid" : null, "nfFunction" : null, "nfType" : null, diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/arGetTXCById.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/arGetTXCById.xml index 65cee9f662..97992fc00b 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/arGetTXCById.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/arGetTXCById.xml @@ -1,9 +1,9 @@ <allotted-resource xmlns="http://org.openecomp.aai.inventory/v9"> <id>ar-txcA</id> <orchestration-status>Active</orchestration-status> - <role>TunnelXConn</role> - <type>TunnelXConn</type> - <description>TunnelXConn</description> + <role>Tunnel XConn</role> + <type>Tunnel XConn</type> + <description>Tunnel XConn</description> <selflink/> <resource-version>1490627351232</resource-version> <relationship-list> diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml index bb7f4c20fd..f2063442d6 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml @@ -1,9 +1,9 @@ <allotted-resource xmlns="http://org.openecomp.aai.inventory/v9"> <id>ar-1</id> <orchestration-status>Active</orchestration-status> - <role>TunnelXConn</role> - <type>TunnelXConn</type> - <description>TunnelXConn</description> + <role>Tunnel XConn</role> + <type>Tunnel XConn</type> + <description>Tunnel XConn</description> <selflink/> <resource-version>1490627351232</resource-version> <relationship-list> diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoDeleteAllottedResourceTXC/arGetById.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoDeleteAllottedResourceTXC/arGetById.xml index bb7f4c20fd..f2063442d6 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoDeleteAllottedResourceTXC/arGetById.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoDeleteAllottedResourceTXC/arGetById.xml @@ -1,9 +1,9 @@ <allotted-resource xmlns="http://org.openecomp.aai.inventory/v9"> <id>ar-1</id> <orchestration-status>Active</orchestration-status> - <role>TunnelXConn</role> - <type>TunnelXConn</type> - <description>TunnelXConn</description> + <role>Tunnel XConn</role> + <type>Tunnel XConn</type> + <description>Tunnel XConn</description> <selflink/> <resource-version>1490627351232</resource-version> <relationship-list> diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaVIDRequest.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaVIDRequest.java index faa669133f..9f30e67897 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaVIDRequest.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/camundabeans/CamundaVIDRequest.java @@ -34,7 +34,7 @@ import com.fasterxml.jackson.annotation.JsonRootName; CommonConstants.REQUEST_ID_HEADER, CommonConstants.IS_BASE_VF_MODULE_VARIABLE, CommonConstants.RECIPE_TIMEOUT_VARIABLE, CommonConstants.REQUEST_ACTION_VARIABLE, CommonConstants.SERVICE_INSTANCE_ID_VARIABLE, - CommonConstants.VNF_ID_VARIABLE, CommonConstants.VF_MODULE_ID_VARIABLE, + CommonConstants.CORRELATION_ID, CommonConstants.VNF_ID_VARIABLE, CommonConstants.VF_MODULE_ID_VARIABLE, CommonConstants.VOLUME_GROUP_ID_VARIABLE, CommonConstants.NETWORK_ID_VARIABLE, CommonConstants.CONFIGURATION_ID_VARIABLE, CommonConstants.SERVICE_TYPE_VARIABLE, CommonConstants.VNF_TYPE_VARIABLE, CommonConstants.VF_MODULE_TYPE_VARIABLE, @@ -55,7 +55,6 @@ public class CamundaVIDRequest { @JsonProperty(CommonConstants.REQUEST_ID_HEADER) private CamundaInput msoRequestId; - @JsonProperty(CommonConstants.IS_BASE_VF_MODULE_VARIABLE) private CamundaBooleanInput isBaseVfModule; @@ -68,6 +67,9 @@ public class CamundaVIDRequest { @JsonProperty(CommonConstants.SERVICE_INSTANCE_ID_VARIABLE) private CamundaInput serviceInstanceId; + @JsonProperty(CommonConstants.CORRELATION_ID) + private CamundaInput correlationId; + @JsonProperty(CommonConstants.VNF_ID_VARIABLE) private CamundaInput vnfId; @@ -177,6 +179,16 @@ public class CamundaVIDRequest { this.serviceInstanceId = serviceInstanceId; } + @JsonProperty(CommonConstants.CORRELATION_ID) + public CamundaInput getCorrelationId() { + return correlationId; + } + + @JsonProperty(CommonConstants.CORRELATION_ID) + public void setCorrelationId(CamundaInput correlationId) { + this.correlationId = correlationId; + } + @JsonProperty(CommonConstants.VNF_ID_VARIABLE) public CamundaInput getVnfId() { return vnfId; diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/BPELRestClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/BPELRestClient.java index 1a086ac35c..85fe52f24c 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/BPELRestClient.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/BPELRestClient.java @@ -85,14 +85,10 @@ public class BPELRestClient extends RequestClient { } @Override - public HttpResponse post(String requestId, boolean isBaseVfModule, - int recipeTimeout, String requestAction, String serviceInstanceId, - String vnfId, String vfModuleId, String volumeGroupId, String networkId, String configurationId, - String serviceType, String vnfType, String vfModuleType, String networkType, - String requestDetails, String recipeParamXsd) { + public HttpResponse post(RequestClientParamater params) { return null; } - + @Override public HttpResponse get() { return null; diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java index 9cc89530c4..c0cfdf9bec 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaClient.java @@ -20,13 +20,12 @@ package org.openecomp.mso.apihandler.common; - import java.io.IOException; import javax.xml.bind.DatatypeConverter; +import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpResponse; -import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.openecomp.mso.apihandler.camundabeans.CamundaBooleanInput; @@ -51,8 +50,7 @@ public class CamundaClient extends RequestClient{ @Override public HttpResponse post(String camundaReqXML, String requestId, - String requestTimeout, String schemaVersion, String serviceInstanceId, String action) - throws ClientProtocolException, IOException{ + String requestTimeout, String schemaVersion, String serviceInstanceId, String action) throws IOException { HttpPost post = new HttpPost(url); msoLogger.debug(CAMUNDA_URL_MESAGE + url); String jsonReq = wrapRequest(camundaReqXML, requestId, serviceInstanceId, requestTimeout, schemaVersion); @@ -77,7 +75,7 @@ public class CamundaClient extends RequestClient{ } @Override - public HttpResponse post(String jsonReq) throws ClientProtocolException, IOException{ + public HttpResponse post(String jsonReq) throws IOException { HttpPost post = new HttpPost(url); msoLogger.debug(CAMUNDA_URL_MESAGE + url); @@ -102,21 +100,13 @@ public class CamundaClient extends RequestClient{ } @Override - public HttpResponse post(String requestId, boolean isBaseVfModule, - int recipeTimeout, String requestAction, String serviceInstanceId, - String vnfId, String vfModuleId, String volumeGroupId, String networkId, String configurationId, - String serviceType, String vnfType, String vfModuleType, String networkType, - String requestDetails, String recipeParamXsd) - throws ClientProtocolException, IOException{ + public HttpResponse post(RequestClientParamater params) throws IOException { HttpPost post = new HttpPost(url); msoLogger.debug(CAMUNDA_URL_MESAGE + url); - String jsonReq = wrapVIDRequest(requestId, isBaseVfModule, recipeTimeout, requestAction, - serviceInstanceId, vnfId, vfModuleId, volumeGroupId, networkId, configurationId, - serviceType, vnfType, vfModuleType, networkType, requestDetails, recipeParamXsd); + String jsonReq = wrapVIDRequest(params); StringEntity input = new StringEntity(jsonReq); input.setContentType(CommonConstants.CONTENT_TYPE_JSON); - String encryptedCredentials; if(props!=null){ encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH,null); @@ -128,12 +118,10 @@ public class CamundaClient extends RequestClient{ } } } - post.setEntity(input); - return client.execute(post); } - + @Override public HttpResponse get() { return null; @@ -150,8 +138,6 @@ public class CamundaClient extends RequestClient{ if(schemaVersion == null){ schemaVersion = ""; } - - try{ CamundaRequest camundaRequest = new CamundaRequest(); CamundaInput camundaInput = new CamundaInput(); @@ -183,52 +169,8 @@ public class CamundaClient extends RequestClient{ return jsonReq; } - private String wrapVIDRequest(String requestId, boolean isBaseVfModule, - int recipeTimeout, String requestAction, String serviceInstanceId, - String vnfId, String vfModuleId, String volumeGroupId, String networkId, String configurationId, - String serviceType, String vnfType, String vfModuleType, String networkType, - String requestDetails, String recipeParams){ + private String wrapVIDRequest(RequestClientParamater requestClientParamater) { String jsonReq = null; - if(requestId == null){ - requestId =""; - } - if(requestAction == null){ - requestAction =""; - } - if(serviceInstanceId == null){ - serviceInstanceId =""; - } - if(vnfId == null){ - vnfId =""; - } - if(vfModuleId == null){ - vfModuleId =""; - } - if(volumeGroupId == null){ - volumeGroupId =""; - } - if(networkId == null){ - networkId =""; - } - if(configurationId == null){ - configurationId =""; - } - if(serviceType == null){ - serviceType =""; - } - if(vnfType == null){ - vnfType =""; - } - if(vfModuleType == null){ - vfModuleType =""; - } - if(networkType == null){ - networkType =""; - } - if(requestDetails == null){ - requestDetails =""; - } - try{ CamundaVIDRequest camundaRequest = new CamundaVIDRequest(); CamundaInput serviceInput = new CamundaInput(); @@ -238,6 +180,7 @@ public class CamundaClient extends RequestClient{ CamundaIntegerInput recipeTimeoutInput = new CamundaIntegerInput(); CamundaInput requestActionInput = new CamundaInput(); CamundaInput serviceInstanceIdInput = new CamundaInput(); + CamundaInput correlationIdInput = new CamundaInput(); CamundaInput vnfIdInput = new CamundaInput(); CamundaInput vfModuleIdInput = new CamundaInput(); CamundaInput volumeGroupIdInput = new CamundaInput(); @@ -249,22 +192,23 @@ public class CamundaClient extends RequestClient{ CamundaInput networkTypeInput = new CamundaInput(); CamundaInput recipeParamsInput = new CamundaInput(); host.setValue(parseURL()); - requestIdInput.setValue(requestId); - isBaseVfModuleInput.setValue(isBaseVfModule); - recipeTimeoutInput.setValue(recipeTimeout); - requestActionInput.setValue(requestAction); - serviceInstanceIdInput.setValue(serviceInstanceId); - vnfIdInput.setValue(vnfId); - vfModuleIdInput.setValue(vfModuleId); - volumeGroupIdInput.setValue(volumeGroupId); - networkIdInput.setValue(networkId); - configurationIdInput.setValue(configurationId); - serviceTypeInput.setValue(serviceType); - vnfTypeInput.setValue(vnfType); - vfModuleTypeInput.setValue(vfModuleType); - networkTypeInput.setValue(networkType); - recipeParamsInput.setValue(recipeParams); - serviceInput.setValue(requestDetails); + requestIdInput.setValue(StringUtils.defaultString(requestClientParamater.getRequestId())); + isBaseVfModuleInput.setValue(requestClientParamater.isBaseVfModule()); + recipeTimeoutInput.setValue(requestClientParamater.getRecipeTimeout()); + requestActionInput.setValue(StringUtils.defaultString(requestClientParamater.getRequestAction())); + serviceInstanceIdInput.setValue(StringUtils.defaultString(requestClientParamater.getServiceInstanceId())); + correlationIdInput.setValue(StringUtils.defaultString(requestClientParamater.getCorrelationId())); + vnfIdInput.setValue(StringUtils.defaultString(requestClientParamater.getVnfId())); + vfModuleIdInput.setValue(StringUtils.defaultString(requestClientParamater.getVfModuleId())); + volumeGroupIdInput.setValue(StringUtils.defaultString(requestClientParamater.getVolumeGroupId())); + networkIdInput.setValue(StringUtils.defaultString(requestClientParamater.getNetworkId())); + configurationIdInput.setValue(StringUtils.defaultString(requestClientParamater.getConfigurationId())); + serviceTypeInput.setValue(StringUtils.defaultString(requestClientParamater.getServiceType())); + vnfTypeInput.setValue(StringUtils.defaultString(requestClientParamater.getVnfType())); + vfModuleTypeInput.setValue(StringUtils.defaultString(requestClientParamater.getVfModuleType())); + networkTypeInput.setValue(StringUtils.defaultString(requestClientParamater.getNetworkType())); + recipeParamsInput.setValue(requestClientParamater.getRecipeParamXsd()); + serviceInput.setValue(StringUtils.defaultString(requestClientParamater.getRequestDetails())); camundaRequest.setServiceInput(serviceInput); camundaRequest.setHost(host); camundaRequest.setRequestId(requestIdInput); @@ -273,6 +217,7 @@ public class CamundaClient extends RequestClient{ camundaRequest.setRecipeTimeout(recipeTimeoutInput); camundaRequest.setRequestAction(requestActionInput); camundaRequest.setServiceInstanceId(serviceInstanceIdInput); + camundaRequest.setCorrelationId(correlationIdInput); camundaRequest.setVnfId(vnfIdInput); camundaRequest.setVfModuleId(vfModuleIdInput); camundaRequest.setVolumeGroupId(volumeGroupIdInput); @@ -306,5 +251,4 @@ public class CamundaClient extends RequestClient{ return host; } - } diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java index 3941e1e5af..845b140348 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CamundaTaskClient.java @@ -25,7 +25,6 @@ import java.io.IOException; import javax.xml.bind.DatatypeConverter;
import org.apache.http.HttpResponse;
-import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
@@ -39,8 +38,7 @@ public class CamundaTaskClient extends RequestClient{ }
@Override
- public HttpResponse post(String jsonReq)
- throws ClientProtocolException, IOException{
+ public HttpResponse post(String jsonReq) throws IOException{
HttpPost post = new HttpPost(url);
msoLogger.debug("Camunda Task url is: "+ url);
@@ -65,25 +63,18 @@ public class CamundaTaskClient extends RequestClient{ @Override
public HttpResponse post(String camundaReqXML, String requestId,
- String requestTimeout, String schemaVersion, String serviceInstanceId, String action)
- throws ClientProtocolException, IOException{
+ String requestTimeout, String schemaVersion, String serviceInstanceId, String action) {
msoLogger.debug("Method not supported");
return null;
}
-
+
@Override
- public HttpResponse post(String requestId, boolean isBaseVfModule,
- int recipeTimeout, String requestAction, String serviceInstanceId,
- String vnfId, String vfModuleId, String volumeGroupId, String networkId, String configurationId,
- String serviceType, String vnfType, String vfModuleType, String networkType,
- String requestDetails, String recipeParamXsd)
- throws ClientProtocolException, IOException{
- msoLogger.debug("Method not supported");
+ public HttpResponse post(RequestClientParamater params) {
return null;
}
-
+
@Override
- public HttpResponse get() throws ClientProtocolException, IOException{
+ public HttpResponse get() throws IOException{
HttpGet get = new HttpGet(url);
msoLogger.debug("Camunda Task url is: "+ url);
String encryptedCredentials;
@@ -97,7 +88,6 @@ public class CamundaTaskClient extends RequestClient{ }
}
}
-
return client.execute(get);
}
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CommonConstants.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CommonConstants.java index 4dac998527..daa411a963 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CommonConstants.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/CommonConstants.java @@ -25,13 +25,11 @@ public final class CommonConstants { public static final String DEFAULT_BPEL_AUTH = "admin:admin"; public static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f"; - public static final String REQUEST_ID_HEADER = "mso-request-id"; public static final String REQUEST_TIMEOUT_HEADER = "mso-service-request-timeout"; public static final String SCHEMA_VERSION_HEADER = "mso-schema-version"; public static final String SERVICE_INSTANCE_ID_HEADER = "mso-service-instance-id"; public static final String ACTION_HEADER = "mso-action"; - public static final String CAMUNDA_SERVICE_INPUT = "bpmnRequest"; public static final String CAMUNDA_ROOT_INPUT = "variables"; public static final String CONTENT_TYPE_JSON= "application/json"; @@ -47,13 +45,12 @@ public final class CommonConstants { public static final int CAMUNDA = 1; public static final int CAMUNDATASK = 2; public static final String CAMUNDA_HOST = "host"; - public static final String SDNC_UUID_HEADER = "mso-sdnc-request-id"; - public static final String REQUEST_ID_VARIABLE = "requestId"; public static final String IS_BASE_VF_MODULE_VARIABLE = "isBaseVfModule"; public static final String RECIPE_TIMEOUT_VARIABLE = "recipeTimeout"; public static final String REQUEST_ACTION_VARIABLE = "requestAction"; public static final String SERVICE_INSTANCE_ID_VARIABLE = "serviceInstanceId"; + public static final String CORRELATION_ID = "correlationId"; public static final String VNF_ID_VARIABLE = "vnfId"; public static final String VF_MODULE_ID_VARIABLE = "vfModuleId"; public static final String VOLUME_GROUP_ID_VARIABLE = "volumeGroupId"; diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java index d702a63fda..ed5d076d8c 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClient.java @@ -67,17 +67,11 @@ public abstract class RequestClient { public abstract HttpResponse post(String request, String requestId, String requestTimeout, String schemaVersion, String serviceInstanceId, String action) throws ClientProtocolException, IOException; - public abstract HttpResponse post(String request) throws ClientProtocolException, IOException; - - public abstract HttpResponse post(String requestId, boolean isBaseVfModule, - int recipeTimeout, String requestAction, String serviceInstanceId, - String vnfId, String vfModuleId, String volumeGroupId, String networkId, String configurationId, - String serviceType, String vnfType, String vfModuleType, String networkType, - String requestDetails, String recipeParamXsd) - throws ClientProtocolException, IOException; + public abstract HttpResponse post(String request) throws IOException; + + public abstract HttpResponse post(RequestClientParamater params) throws IOException; - public abstract HttpResponse get() - throws ClientProtocolException, IOException; + public abstract HttpResponse get() throws IOException; protected String getEncryptedPropValue (String prop, String defaultValue, String encryptionKey) { try { diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClientParamater.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClientParamater.java new file mode 100644 index 0000000000..4db69199da --- /dev/null +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/openecomp/mso/apihandler/common/RequestClientParamater.java @@ -0,0 +1,242 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * 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.openecomp.mso.apihandler.common; + +public class RequestClientParamater { + + private String requestId; + private boolean isBaseVfModule; + private int recipeTimeout; + private String requestAction; + private String serviceInstanceId; + private String correlationId; + private String vnfId; + private String vfModuleId; + private String volumeGroupId; + private String networkId; + private String configurationId; + private String serviceType; + private String vnfType; + private String vfModuleType; + private String networkType; + private String requestDetails; + private String recipeParamXsd; + + private RequestClientParamater(Builder builder) { + requestId = builder.requestId; + isBaseVfModule = builder.isBaseVfModule; + recipeTimeout = builder.recipeTimeout; + requestAction = builder.requestAction; + serviceInstanceId = builder.serviceInstanceId; + correlationId = builder.correlationId; + vnfId = builder.vnfId; + vfModuleId = builder.vfModuleId; + volumeGroupId = builder.volumeGroupId; + networkId = builder.networkId; + configurationId = builder.configurationId; + serviceType = builder.serviceType; + vnfType = builder.vnfType; + vfModuleType = builder.vfModuleType; + networkType = builder.networkType; + requestDetails = builder.requestDetails; + recipeParamXsd = builder.recipeParamXsd; + } + + public String getRequestId() { + return requestId; + } + + public boolean isBaseVfModule() { + return isBaseVfModule; + } + + public int getRecipeTimeout() { + return recipeTimeout; + } + + public String getRequestAction() { + return requestAction; + } + + public String getServiceInstanceId() { + return serviceInstanceId; + } + + public String getCorrelationId() { + return correlationId; + } + + public String getVnfId() { + return vnfId; + } + + public String getVfModuleId() { + return vfModuleId; + } + + public String getVolumeGroupId() { + return volumeGroupId; + } + + public String getNetworkId() { + return networkId; + } + + public String getConfigurationId() { + return configurationId; + } + + public String getServiceType() { + return serviceType; + } + + public String getVnfType() { + return vnfType; + } + + public String getVfModuleType() { + return vfModuleType; + } + + public String getNetworkType() { + return networkType; + } + + public String getRequestDetails() { + return requestDetails; + } + + public String getRecipeParamXsd() { + return recipeParamXsd; + } + + public static class Builder { + private String requestId; + private boolean isBaseVfModule; + private int recipeTimeout; + private String requestAction; + private String serviceInstanceId; + private String correlationId; + private String vnfId; + private String vfModuleId; + private String volumeGroupId; + private String networkId; + private String configurationId; + private String serviceType; + private String vnfType; + private String vfModuleType; + private String networkType; + private String requestDetails; + private String recipeParamXsd; + + public Builder setRequestId(String requestId) { + this.requestId = requestId; + return this; + } + + public Builder setBaseVfModule(boolean baseVfModule) { + isBaseVfModule = baseVfModule; + return this; + } + + public Builder setRecipeTimeout(int recipeTimeout) { + this.recipeTimeout = recipeTimeout; + return this; + } + + public Builder setRequestAction(String requestAction) { + this.requestAction = requestAction; + return this; + } + + public Builder setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + return this; + } + + public Builder setCorrelationId(String correlationId) { + this.correlationId = correlationId; + return this; + } + + public Builder setVnfId(String vnfId) { + this.vnfId = vnfId; + return this; + } + + public Builder setVfModuleId(String vfModuleId) { + this.vfModuleId = vfModuleId; + return this; + } + + public Builder setVolumeGroupId(String volumeGroupId) { + this.volumeGroupId = volumeGroupId; + return this; + } + + public Builder setNetworkId(String networkId) { + this.networkId = networkId; + return this; + } + + public Builder setConfigurationId(String configurationId) { + this.configurationId = configurationId; + return this; + } + + public Builder setServiceType(String serviceType) { + this.serviceType = serviceType; + return this; + } + + public Builder setVnfType(String vnfType) { + this.vnfType = vnfType; + return this; + } + + public Builder setVfModuleType(String vfModuleType) { + this.vfModuleType = vfModuleType; + return this; + } + + public Builder setNetworkType(String networkType) { + this.networkType = networkType; + return this; + } + + public Builder setRequestDetails(String requestDetails) { + this.requestDetails = requestDetails; + return this; + } + + public Builder setRecipeParamXsd(String recipeParamXsd) { + this.recipeParamXsd = recipeParamXsd; + return this; + } + + public RequestClientParamater build(){ + return new RequestClientParamater(this); + } + } + + +} diff --git a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaClientTest.java b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaClientTest.java index 8bfc4ced76..69927e2126 100644 --- a/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaClientTest.java +++ b/mso-api-handlers/mso-api-handler-common/src/test/java/org/openecomp/mso/camunda/tests/CamundaClientTest.java @@ -24,7 +24,6 @@ package org.openecomp.mso.camunda.tests; import static org.junit.Assert.assertEquals; import java.io.IOException; -import java.util.UUID; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; @@ -42,12 +41,9 @@ import org.mockito.MockitoAnnotations; import org.openecomp.mso.apihandler.common.CommonConstants; import org.openecomp.mso.apihandler.common.RequestClient; import org.openecomp.mso.apihandler.common.RequestClientFactory; +import org.openecomp.mso.apihandler.common.RequestClientParamater; import org.openecomp.mso.properties.MsoJavaProperties; -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.databind.JsonMappingException; - - /** * This class implements test methods of Camunda Beans. * @@ -66,8 +62,7 @@ public class CamundaClientTest { } @Test - public void tesCamundaPost() throws JsonGenerationException, - JsonMappingException, IOException { + public void tesCamundaPost() throws IOException { String responseBody ="{\"links\":[{\"method\":\"GET\",\"href\":\"http://localhost:9080/engine-rest/process-instance/2047c658-37ae-11e5-9505-7a1020524153\",\"rel\":\"self\"}],\"id\":\"2047c658-37ae-11e5-9505-7a1020524153\",\"definitionId\":\"dummy:10:73298961-37ad-11e5-9505-7a1020524153\",\"businessKey\":null,\"caseInstanceId\":null,\"ended\":true,\"suspended\":false}"; HttpResponse mockResponse = createResponse(200, responseBody); @@ -106,8 +101,6 @@ public class CamundaClientTest { mockHttpClient = Mockito.mock(HttpClient.class); Mockito.when(mockHttpClient.execute(Mockito.any(HttpPost.class))) .thenReturn(mockResponse); - - String reqXML = "<xml>test</xml>"; String orchestrationURI = "/engine-rest/process-definition/key/dummy/start"; MsoJavaProperties props = new MsoJavaProperties(); @@ -115,9 +108,7 @@ public class CamundaClientTest { RequestClient requestClient = RequestClientFactory.getRequestClient(orchestrationURI, props); requestClient.setClient(mockHttpClient); - HttpResponse response = requestClient.post("mso-req-id", false, 180, - "createInstance", "svc-inst-id", "vnf-id", "vf-module-id", "vg-id", "nw-id", "conf-id", "svc-type", - "vnf-type", "vf-module-type", "nw-type", "", ""); + HttpResponse response = requestClient.post(createParams()); assertEquals(requestClient.getType(), CommonConstants.CAMUNDA); assertEquals(response.getStatusLine().getStatusCode(), HttpStatus.SC_OK); } @@ -137,6 +128,15 @@ public class CamundaClientTest { return response; } + private RequestClientParamater createParams(){ + return new RequestClientParamater.Builder().setRequestId("mso-req-id").setBaseVfModule(false). + setRecipeTimeout(180).setRequestAction("createInstance").setServiceInstanceId("svc-inst-id"). + setVnfId("vnf-id").setVfModuleId("vf-module-id").setVolumeGroupId("vg-id").setNetworkId("nw-id"). + setConfigurationId("conf-id").setServiceType("svc-type").setVnfType("vnf-type"). + setVfModuleType("vf-module-type").setNetworkType("nw-type").setRequestDetails(""). + setRecipeParamXsd("").build(); + } + diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java index 23adafd08e..5a612dbdc5 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java @@ -43,6 +43,7 @@ import org.json.JSONObject; import org.openecomp.mso.apihandler.common.ErrorNumbers; import org.openecomp.mso.apihandler.common.RequestClient; import org.openecomp.mso.apihandler.common.RequestClientFactory; +import org.openecomp.mso.apihandler.common.RequestClientParamater; import org.openecomp.mso.apihandler.common.ResponseHandler; import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.CompareModelsRequest; import org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans.E2EServiceInstanceDeleteRequest; @@ -82,8 +83,6 @@ public class E2EServiceInstances { private ServiceInstancesRequest sir = null; public static final String END_OF_THE_TRANSACTION = "End of the transaction, the final response is: "; - public static final String EXCEPTION_CREATING_DB_RECORD = "Exception while creating record in DB"; - public static final String EXCEPTION_COMMUNICATE_BPMN_ENGINE = "Exception while communicate with BPMN engine"; /** * POST Requests for E2E Service create Instance on a version provided @@ -228,7 +227,6 @@ public class E2EServiceInstances { // Define RecipeLookupResult info here instead of query DB for efficiency String workflowUrl = "/mso/async/services/CompareModelofE2EServiceInstance"; - int recipeTimeout = 180; RequestClient requestClient = null; HttpResponse response = null; @@ -239,14 +237,15 @@ public class E2EServiceInstances { requestClient = RequestClientFactory.getRequestClient(workflowUrl, MsoPropertiesUtils.loadMsoProperties()); JSONObject jjo = new JSONObject(requestJSON); - String bpmnRequest = jjo.toString(); // Capture audit event msoLogger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl()); - String serviceId = instanceIdMap.get("serviceId"); - String serviceType = e2eCompareModelReq.getServiceType(); - response = requestClient.post(requestId, false, recipeTimeout, action.name(), serviceId, null, null, null, - null, null, serviceType, null, null, null, bpmnRequest, null); + RequestClientParamater requestClientParamater = new RequestClientParamater.Builder().setRequestId(requestId). + setBaseVfModule(false).setRecipeTimeout(180).setRequestAction(action.name()). + setServiceInstanceId(instanceIdMap.get("serviceId")).setServiceType(e2eCompareModelReq.getServiceType()). + setRequestDetails(jjo.toString()).build(); + + response = requestClient.post(requestClientParamater); msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", workflowUrl, null); @@ -440,8 +439,6 @@ public class E2EServiceInstances { HttpResponse response = null; long subStartTime = System.currentTimeMillis(); - // String sirRequestJson = mapReqJsonToSvcInstReq(e2eSir, requestJSON); - try { requestClient = RequestClientFactory.getRequestClient( recipeLookupResult.getOrchestrationURI(), @@ -449,19 +446,17 @@ public class E2EServiceInstances { JSONObject jjo = new JSONObject(requestJSON); jjo.put("operationId", UUIDChecker.generateUUID(msoLogger)); - - String bpmnRequest = jjo.toString(); - // Capture audit event msoLogger .debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl()); - String serviceId = instanceIdMap.get("serviceId"); - String serviceInstanceType = e2eDelReq.getServiceType(); - response = requestClient.post(requestId, false, - recipeLookupResult.getRecipeTimeout(), action.name(), - serviceId, null, null, null, null, null, serviceInstanceType, - null, null, null, bpmnRequest, recipeLookupResult.getRecipeParamXsd()); + + RequestClientParamater requestClientParamater = new RequestClientParamater.Builder().setRequestId(requestId). + setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()). + setRequestAction(action.name()).setServiceInstanceId(instanceIdMap.get("serviceId")). + setServiceType(e2eDelReq.getServiceType()).setRequestDetails(jjo.toString()). + setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build(); + response = requestClient.post(requestClientParamater); msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, @@ -564,12 +559,6 @@ public class E2EServiceInstances { return response; } - //check for the current operation status -// Response resp = checkE2ESvcInstStatus(action, serviceId, startTime, msoRequest); -// if(resp != null && resp.getStatus() != 200) { -// return resp; -// } - CatalogDatabase db = null; RecipeLookupResult recipeLookupResult = null; try { @@ -615,18 +604,19 @@ public class E2EServiceInstances { HttpResponse response = null; long subStartTime = System.currentTimeMillis(); - String sirRequestJson = mapReqJsonToSvcInstReq(e2eSir, requestJSON); - try { requestClient = RequestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI(), MsoPropertiesUtils.loadMsoProperties()); // Capture audit event msoLogger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl()); + RequestClientParamater requestClientParamater = new RequestClientParamater.Builder().setRequestId(requestId). + setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.name()). + setServiceInstanceId(serviceId).setServiceType(serviceInstanceType). + setRequestDetails(mapReqJsonToSvcInstReq(e2eSir, requestJSON)). + setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build(); - response = requestClient.post(requestId, false, recipeLookupResult.getRecipeTimeout(), action.name(), - serviceId, null, null, null, null, null, serviceInstanceType, null, null, null, sirRequestJson, - recipeLookupResult.getRecipeParamXsd()); + response = requestClient.post(requestClientParamater); msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", recipeLookupResult.getOrchestrationURI(), @@ -752,25 +742,23 @@ public class E2EServiceInstances { return response; } - String serviceInstanceType = e2eSir.getService().getServiceType(); - - String serviceId = ""; RequestClient requestClient = null; HttpResponse response = null; long subStartTime = System.currentTimeMillis(); - String sirRequestJson = mapReqJsonToSvcInstReq(e2eSir, requestJSON); - try { requestClient = RequestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI(), MsoPropertiesUtils.loadMsoProperties()); // Capture audit event msoLogger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl()); + RequestClientParamater requestClientParamater = new RequestClientParamater.Builder().setRequestId(requestId). + setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.name()). + setServiceInstanceId("").setServiceType(e2eSir.getService().getServiceType()). + setRequestDetails(mapReqJsonToSvcInstReq(e2eSir, requestJSON)). + setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build(); - response = requestClient.post(requestId, false, recipeLookupResult.getRecipeTimeout(), action.name(), - serviceId, null, null, null, null, null, serviceInstanceType, null, null, null, sirRequestJson, - recipeLookupResult.getRecipeParamXsd()); + response = requestClient.post(requestClientParamater); msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", recipeLookupResult.getOrchestrationURI(), @@ -897,8 +885,6 @@ public class E2EServiceInstances { HttpResponse response = null; long subStartTime = System.currentTimeMillis(); - // String sirRequestJson = mapReqJsonToSvcInstReq(e2eSir, requestJSON); - try { requestClient = RequestClientFactory.getRequestClient( recipeLookupResult.getOrchestrationURI(), @@ -907,18 +893,18 @@ public class E2EServiceInstances { JSONObject jjo = new JSONObject(requestJSON); jjo.put("operationId", UUIDChecker.generateUUID(msoLogger)); - String bpmnRequest = jjo.toString(); - // Capture audit event msoLogger .debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl()); - String serviceId = instanceIdMap.get("serviceId"); - String serviceInstanceType = e2eScaleReq.getService().getServiceType(); - response = requestClient.post(requestId, false, - recipeLookupResult.getRecipeTimeout(), action.name(), - serviceId, null, null, null, null, null, serviceInstanceType, - null, null, null, bpmnRequest, recipeLookupResult.getRecipeParamXsd()); + RequestClientParamater requestClientParamater = new RequestClientParamater.Builder().setRequestId(requestId). + setBaseVfModule(false).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()).setRequestAction(action.name()). + setServiceInstanceId(instanceIdMap.get("serviceId")). + setServiceType(e2eScaleReq.getService().getServiceType()). + setRequestDetails(jjo.toString()). + setRecipeParamXsd(recipeLookupResult.getRecipeParamXsd()).build(); + + response = requestClient.post(requestClientParamater); msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java index 2f2ef313f4..3f6cc35432 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/MsoRequest.java @@ -85,7 +85,6 @@ public class MsoRequest { private String requestId; private String requestXML; - private String requestJSON; private String requestUri; private VnfRequest vnfReq; private RequestInfo requestInfo; @@ -118,8 +117,6 @@ public class MsoRequest { private OwningEntity owningEntity; private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH); - private static final String NOT_PROVIDED = "not provided"; - protected AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager (); MsoRequest (String requestId) { @@ -1153,7 +1150,7 @@ public class MsoRequest { mapper.setSerializationInclusion(Include.NON_NULL); //mapper.configure(Feature.WRAP_ROOT_VALUE, true); msoLogger.debug ("building sir from object " + sir); - requestJSON = mapper.writeValueAsString(sir); + String requestJSON = mapper.writeValueAsString(sir); // Perform mapping from VID-style modelInfo fields to ASDC-style modelInfo fields diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java index e16963db3b..581ad34939 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/ServiceInstances.java @@ -20,6 +20,7 @@ */ package org.openecomp.mso.apihandlerinfra; +import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -42,6 +43,7 @@ import org.openecomp.mso.apihandler.common.CommonConstants; import org.openecomp.mso.apihandler.common.ErrorNumbers; import org.openecomp.mso.apihandler.common.RequestClient; import org.openecomp.mso.apihandler.common.RequestClientFactory; +import org.openecomp.mso.apihandler.common.RequestClientParamater; import org.openecomp.mso.apihandler.common.ResponseHandler; import org.openecomp.mso.apihandler.common.ValidationException; import org.openecomp.mso.serviceinstancebeans.ModelInfo; @@ -690,37 +692,7 @@ public class ServiceInstances { } db.close(); - - String serviceInstanceId = ""; - String vnfId = ""; - String vfModuleId = ""; - String volumeGroupId = ""; - String networkId = ""; - ServiceInstancesRequest siReq = msoRequest.getServiceInstancesRequest(); - - if(siReq.getServiceInstanceId () != null){ - serviceInstanceId = siReq.getServiceInstanceId (); - } - - if(siReq.getVnfInstanceId () != null){ - vnfId = siReq.getVnfInstanceId (); - } - - if(siReq.getVfModuleInstanceId () != null){ - vfModuleId = siReq.getVfModuleInstanceId (); - } - - if(siReq.getVolumeGroupInstanceId () != null){ - volumeGroupId = siReq.getVolumeGroupInstanceId (); - } - - if(siReq.getNetworkInstanceId () != null){ - networkId = siReq.getNetworkInstanceId (); - } - - - requestId = msoRequest.getRequestId (); - msoLogger.debug ("requestId is: " + requestId); + msoLogger.debug ("requestId is: " + msoRequest.getRequestId()); msoLogger.debug ("About to insert a record"); try { @@ -736,15 +708,32 @@ public class ServiceInstances { return response; } - return postBPELRequest(action, requestId, startTime, msoRequest, recipeLookupResult.getOrchestrationURI(), recipeLookupResult.getRecipeTimeout(), - isBaseVfModule, serviceInstanceId, vnfId, vfModuleId, volumeGroupId, networkId, null, - msoRequest.getServiceInstanceType(), msoRequest.getVnfType(), msoRequest.getVfModuleType(), msoRequest.getNetworkType()); + return postBPELRequest(action, startTime, msoRequest, recipeLookupResult.getOrchestrationURI(), + recipeLookupResult.getRecipeTimeout(), isBaseVfModule); } - private Response postBPELRequest(Action action, String requestId, long startTime, MsoRequest msoRequest, - String orchestrationUri, int timeOut, Boolean isBaseVfModule, - String serviceInstanceId, String vnfId, String vfModuleId, String volumeGroupId, String networkId, - String configurationId, String serviceInstanceType, String vnfType, String vfModuleType, String networkType) { + private RequestClientParamater buildRequestClientParameter(MsoRequest msoRequest, boolean isBaseVfModule, + int timeOut, String requestAction) throws IOException { + return new RequestClientParamater.Builder(). + setRequestId(msoRequest.getRequestId()). + setBaseVfModule(isBaseVfModule).setRecipeTimeout(timeOut). + setRequestAction(requestAction). + setServiceInstanceId(msoRequest.getServiceInstancesRequest().getServiceInstanceId()). + setCorrelationId(msoRequest.getServiceInstancesRequest().getCorrelationId()). + setVnfId(msoRequest.getServiceInstancesRequest().getVnfInstanceId()). + setVfModuleId(msoRequest.getServiceInstancesRequest().getVfModuleInstanceId()). + setVolumeGroupId(msoRequest.getServiceInstancesRequest().getVolumeGroupInstanceId()). + setNetworkId(msoRequest.getServiceInstancesRequest().getNetworkInstanceId()). + setConfigurationId(msoRequest.getServiceInstancesRequest().getConfigurationId()). + setServiceType(msoRequest.getServiceInstanceType()). + setVnfType(msoRequest.getVnfType()). + setVfModuleType(msoRequest.getVfModuleType()). + setNetworkType(msoRequest.getNetworkType()). + setRequestDetails(msoRequest.getRequestJSON()).build(); + } + + private Response postBPELRequest(Action action, long startTime, MsoRequest msoRequest, + String orchestrationUri, int timeOut, Boolean isBaseVfModule) { RequestClient requestClient = null; HttpResponse response = null; long subStartTime = System.currentTimeMillis(); @@ -754,12 +743,7 @@ public class ServiceInstances { System.out.println("URL : " + requestClient.getUrl ()); - response = requestClient.post(requestId, isBaseVfModule, timeOut, action.name (), - serviceInstanceId, vnfId, vfModuleId, volumeGroupId, networkId, configurationId, - msoRequest.getServiceInstanceType (), - msoRequest.getVnfType (), msoRequest.getVfModuleType (), - msoRequest.getNetworkType (), msoRequest.getRequestJSON(), null); - + response = requestClient.post(buildRequestClientParameter(msoRequest, isBaseVfModule, timeOut, action.name())); msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from BPMN engine", "BPMN", orchestrationUri, null); } catch (Exception e) { msoLogger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN", orchestrationUri, null); @@ -1191,7 +1175,6 @@ public class ServiceInstances { return new RecipeLookupResult (vnfRecipe.getOrchestrationUri(), vnfRecipe.getRecipeTimeout()); } - private RecipeLookupResult getNetworkUri (CatalogDatabase db, MsoRequest msoRequest, Action action) throws Exception { String defaultNetworkType = msoRequest.getRequestInfo().getSource() + "_DEFAULT"; @@ -1299,18 +1282,6 @@ public class ServiceInstances { return response; } - - String serviceInstanceId = ""; - String configurationId = ""; - ServiceInstancesRequest siReq = msoRequest.getServiceInstancesRequest(); - - if(siReq.getServiceInstanceId () != null){ - serviceInstanceId = siReq.getServiceInstanceId (); - } - - if(siReq.getConfigurationId() != null){ - configurationId = siReq.getConfigurationId(); - } requestId = msoRequest.getRequestId (); msoLogger.debug ("requestId is: " + requestId); @@ -1328,7 +1299,6 @@ public class ServiceInstances { return response; } - return postBPELRequest(action, requestId, startTime, msoRequest, orchestrationUri, Integer.parseInt(timeOut), false, - serviceInstanceId, null, null, null, null, configurationId, null, null, null, null); + return postBPELRequest(action, startTime, msoRequest, orchestrationUri, Integer.parseInt(timeOut), false); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java index 60ac6b98c9..901e03fc17 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java @@ -40,12 +40,12 @@ import org.junit.Test; import org.openecomp.mso.apihandler.common.CamundaClient; import org.openecomp.mso.apihandler.common.RequestClient; import org.openecomp.mso.apihandler.common.RequestClientFactory; +import org.openecomp.mso.apihandler.common.RequestClientParamater; import org.openecomp.mso.apihandler.common.ValidationException; import org.openecomp.mso.db.AbstractSessionFactoryManager; import org.openecomp.mso.db.catalog.CatalogDatabase; import org.openecomp.mso.db.catalog.beans.Service; import org.openecomp.mso.db.catalog.beans.ServiceRecipe; -import org.openecomp.mso.properties.MsoDatabaseException; import org.openecomp.mso.properties.MsoJavaProperties; import org.openecomp.mso.properties.MsoPropertiesFactory; import org.openecomp.mso.requestsdb.OperationStatus; @@ -194,12 +194,7 @@ public class E2EServiceInstancesTest { new MockUp<CamundaClient>() { @Mock - public HttpResponse post(String requestId, boolean isBaseVfModule, - int recipeTimeout, String requestAction, - String serviceInstanceId, String vnfId, String vfModuleId, - String volumeGroupId, String networkId, String configurationId, String serviceType, - String vnfType, String vfModuleType, String networkType, - String requestDetails, String recipeParamXsd) { + public HttpResponse post(RequestClientParamater requestClientParamater) { ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1); HttpResponse resp = new BasicHttpResponse(pv, 202, "test response"); @@ -258,12 +253,7 @@ public class E2EServiceInstancesTest { new MockUp<CamundaClient>() { @Mock - public HttpResponse post(String requestId, boolean isBaseVfModule, - int recipeTimeout, String requestAction, - String serviceInstanceId, String vnfId, String vfModuleId, - String volumeGroupId, String networkId, String configurationId, String serviceType, - String vnfType, String vfModuleType, String networkType, - String requestDetails, String recipeParamXsd) { + public HttpResponse post(RequestClientParamater requestClientParamater) { ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1); HttpResponse resp = new BasicHttpResponse(pv, 500, "test response"); @@ -323,12 +313,7 @@ public class E2EServiceInstancesTest { new MockUp<CamundaClient>() { @Mock - public HttpResponse post(String requestId, boolean isBaseVfModule, - int recipeTimeout, String requestAction, - String serviceInstanceId, String vnfId, String vfModuleId, - String volumeGroupId, String networkId, String configurationId, String serviceType, - String vnfType, String vfModuleType, String networkType, - String requestDetails, String recipeParamXsd) { + public HttpResponse post(RequestClientParamater requestClientParamater) { ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1); HttpResponse resp = new BasicHttpResponse(pv, 500, "test response"); @@ -388,12 +373,7 @@ public class E2EServiceInstancesTest { new MockUp<CamundaClient>() { @Mock - public HttpResponse post(String requestId, boolean isBaseVfModule, - int recipeTimeout, String requestAction, - String serviceInstanceId, String vnfId, String vfModuleId, - String volumeGroupId, String networkId, String configurationId, String serviceType, - String vnfType, String vfModuleType, String networkType, - String requestDetails, String recipeParamXsd) { + public HttpResponse post(RequestClientParamater requestClientParamater) { HttpResponse resp = null; return resp; } @@ -625,12 +605,7 @@ public class E2EServiceInstancesTest { final MockUp<CamundaClient> mockCmaundaClient = new MockUp<CamundaClient>() { @Mock - public HttpResponse post(String requestId, boolean isBaseVfModule, - int recipeTimeout, String requestAction, String serviceInstanceId, - String vnfId, String vfModuleId, String volumeGroupId, String networkId, String configurationId, - String serviceType, String vnfType, String vfModuleType, String networkType, - String requestDetails, String recipeParamXsd) - throws ClientProtocolException, IOException { + public HttpResponse post(RequestClientParamater requestClientParamater) { ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1); HttpResponse resp = new BasicHttpResponse(pv, 200, "test response"); BasicHttpEntity entity = new BasicHttpEntity(); @@ -822,12 +797,7 @@ public class E2EServiceInstancesTest { new MockUp<CamundaClient>() { @Mock - public HttpResponse post(String requestId, boolean isBaseVfModule, - int recipeTimeout, String requestAction, - String serviceInstanceId, String vnfId, String vfModuleId, - String volumeGroupId, String networkId, String configurationId, String serviceType, - String vnfType, String vfModuleType, String networkType, - String requestDetails, String recipeParamXsd) { + public HttpResponse post(RequestClientParamater requestClientParamater) { ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1); HttpResponse resp = new BasicHttpResponse(pv, 202, "test response"); @@ -888,12 +858,7 @@ public class E2EServiceInstancesTest { new MockUp<CamundaClient>() { @Mock - public HttpResponse post(String requestId, boolean isBaseVfModule, - int recipeTimeout, String requestAction, - String serviceInstanceId, String vnfId, String vfModuleId, - String volumeGroupId, String networkId, String configurationId, String serviceType, - String vnfType, String vfModuleType, String networkType, - String requestDetails, String recipeParamXsd) { + public HttpResponse post(RequestClientParamater requestClientParamater) { ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1); HttpResponse resp = new BasicHttpResponse(pv, 202, "test response"); @@ -955,12 +920,7 @@ public class E2EServiceInstancesTest { new MockUp<CamundaClient>() { @Mock - public HttpResponse post(String requestId, boolean isBaseVfModule, - int recipeTimeout, String requestAction, - String serviceInstanceId, String vnfId, String vfModuleId, - String volumeGroupId, String networkId, String configurationId, String serviceType, - String vnfType, String vfModuleType, String networkType, - String requestDetails, String recipeParamXsd) { + public HttpResponse post(RequestClientParamater requestClientParamater) { ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1); HttpResponse resp = new BasicHttpResponse(pv, 202, "test response"); @@ -1027,12 +987,7 @@ public class E2EServiceInstancesTest { new MockUp<CamundaClient>() { @Mock - public HttpResponse post(String requestId, boolean isBaseVfModule, - int recipeTimeout, String requestAction, - String serviceInstanceId, String vnfId, String vfModuleId, - String volumeGroupId, String networkId, String configurationId, String serviceType, - String vnfType, String vfModuleType, String networkType, - String requestDetails, String recipeParamXsd) { + public HttpResponse post(RequestClientParamater requestClientParamater) { ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1); HttpResponse resp = new BasicHttpResponse(pv, 202, "test response"); @@ -1093,12 +1048,7 @@ public class E2EServiceInstancesTest { new MockUp<CamundaClient>() { @Mock - public HttpResponse post(String requestId, boolean isBaseVfModule, - int recipeTimeout, String requestAction, - String serviceInstanceId, String vnfId, String vfModuleId, - String volumeGroupId, String networkId, String configurationId, String serviceType, - String vnfType, String vfModuleType, String networkType, - String requestDetails, String recipeParamXsd) { + public HttpResponse post(RequestClientParamater requestClientParamater) { ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1); HttpResponse resp = new BasicHttpResponse(pv, 202, "test response"); @@ -1160,12 +1110,7 @@ public class E2EServiceInstancesTest { MockUp<CamundaClient> client = new MockUp<CamundaClient>() { @Mock - public HttpResponse post(String requestId, boolean isBaseVfModule, - int recipeTimeout, String requestAction, - String serviceInstanceId, String vnfId, String vfModuleId, - String volumeGroupId, String networkId, String configurationId, String serviceType, - String vnfType, String vfModuleType, String networkType, - String requestDetails, String recipeParamXsd) throws Exception { + public HttpResponse post(RequestClientParamater requestClientParamater) throws Exception { throw new Exception(); } }; @@ -1192,13 +1137,7 @@ public class E2EServiceInstancesTest { new MockUp<CamundaClient>() { @Mock - public HttpResponse post(String requestId, boolean isBaseVfModule, - int recipeTimeout, String requestAction, String serviceInstanceId, - String vnfId, String vfModuleId, String volumeGroupId, String networkId, String configurationId, - String serviceType, String vnfType, String vfModuleType, String networkType, - String requestDetails, String recipeParamXsd) - throws ClientProtocolException, IOException { - + public HttpResponse post(RequestClientParamater requestClientParamater) throws IOException { throw new ClientProtocolException(); } }; @@ -1216,13 +1155,7 @@ public class E2EServiceInstancesTest { new MockUp<CamundaClient>() { @Mock - public HttpResponse post(String requestId, boolean isBaseVfModule, - int recipeTimeout, String requestAction, String serviceInstanceId, - String vnfId, String vfModuleId, String volumeGroupId, String networkId, String configurationId, - String serviceType, String vnfType, String vfModuleType, String networkType, - String requestDetails, String recipeParamXsd) - throws ClientProtocolException, IOException { - + public HttpResponse post(RequestClientParamater requestClientParamater) { ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1); HttpResponse resp = new BasicHttpResponse(pv, 202, "compareModelwithTargetVersion, test response"); @@ -1291,12 +1224,7 @@ public class E2EServiceInstancesTest { final MockUp<CamundaClient> mockCamundaClient = new MockUp<CamundaClient>() { @Mock - public HttpResponse post(String requestId, boolean isBaseVfModule, - int recipeTimeout, String requestAction, - String serviceInstanceId, String vnfId, String vfModuleId, - String volumeGroupId, String networkId, String configurationId, String serviceType, - String vnfType, String vfModuleType, String networkType, - String requestDetails, String recipeParamXsd) { + public HttpResponse post(RequestClientParamater requestClientParamater) { ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1); HttpResponse resp = new BasicHttpResponse(pv, 202, "test response"); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstanceTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstanceTest.java index 50f00ef6a4..938a1038a4 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstanceTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstanceTest.java @@ -21,6 +21,16 @@ package org.openecomp.mso.apihandlerinfra;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import javax.ws.rs.core.Response;
+import mockit.Mock;
+import mockit.MockUp;
import org.apache.http.HttpResponse;
import org.apache.http.ProtocolVersion;
import org.apache.http.entity.BasicHttpEntity;
@@ -30,33 +40,23 @@ import org.hibernate.criterion.Order; import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
-
-import javax.ws.rs.core.Response;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-
import org.openecomp.mso.apihandler.common.CamundaClient;
import org.openecomp.mso.apihandler.common.RequestClient;
import org.openecomp.mso.apihandler.common.RequestClientFactory;
+import org.openecomp.mso.apihandler.common.RequestClientParamater;
import org.openecomp.mso.db.catalog.CatalogDatabase;
-import org.openecomp.mso.db.catalog.beans.*;
+import org.openecomp.mso.db.catalog.beans.Service;
+import org.openecomp.mso.db.catalog.beans.ServiceRecipe;
+import org.openecomp.mso.db.catalog.beans.VfModule;
+import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
+import org.openecomp.mso.db.catalog.beans.VnfComponentsRecipe;
+import org.openecomp.mso.db.catalog.beans.VnfRecipe;
+import org.openecomp.mso.db.catalog.beans.VnfResource;
import org.openecomp.mso.properties.MsoJavaProperties;
-import org.openecomp.mso.properties.MsoPropertiesException;
import org.openecomp.mso.properties.MsoPropertiesFactory;
import org.openecomp.mso.requestsdb.InfraActiveRequests;
import org.openecomp.mso.requestsdb.RequestsDatabase;
-import mockit.Mock;
-import mockit.MockUp;
-
public class ServiceInstanceTest {
/*** Create Service Instance Test Cases ***/
@@ -225,11 +225,7 @@ public class ServiceInstanceTest { new MockUp<CamundaClient>() {
@Mock
- public HttpResponse post(String requestId, boolean isBaseVfModule,
- int recipeTimeout, String requestAction, String serviceInstanceId,
- String vnfId, String vfModuleId, String volumeGroupId, String networkId, String configurationId,
- String serviceType, String vnfType, String vfModuleType, String networkType,
- String requestDetails, String recipeParamXsd){
+ public HttpResponse post(RequestClientParamater requestClientParamater) {
ProtocolVersion pv = new ProtocolVersion("HTTP",1,1);
HttpResponse resp = new BasicHttpResponse(pv,200, "test response");
BasicHttpEntity entity = new BasicHttpEntity();
@@ -295,11 +291,7 @@ public class ServiceInstanceTest { new MockUp<CamundaClient>() {
@Mock
- public HttpResponse post(String requestId, boolean isBaseVfModule,
- int recipeTimeout, String requestAction, String serviceInstanceId,
- String vnfId, String vfModuleId, String volumeGroupId, String networkId, String configurationId,
- String serviceType, String vnfType, String vfModuleType, String networkType,
- String requestDetails, String recipeParamXsd){
+ public HttpResponse post(RequestClientParamater requestClientParamater) {
ProtocolVersion pv = new ProtocolVersion("HTTP",1,1);
HttpResponse resp = new BasicHttpResponse(pv,500, "test response");
BasicHttpEntity entity = new BasicHttpEntity();
@@ -366,11 +358,7 @@ public class ServiceInstanceTest { new MockUp<CamundaClient>() {
@Mock
- public HttpResponse post(String requestId, boolean isBaseVfModule,
- int recipeTimeout, String requestAction, String serviceInstanceId,
- String vnfId, String vfModuleId, String volumeGroupId, String networkId, String configurationId,
- String serviceType, String vnfType, String vfModuleType, String networkType,
- String requestDetails, String recipeParamXsd){
+ public HttpResponse post(RequestClientParamater requestClientParamater) {
ProtocolVersion pv = new ProtocolVersion("HTTP",1,1);
HttpResponse resp = new BasicHttpResponse(pv,500, "test response");
BasicHttpEntity entity = new BasicHttpEntity();
@@ -437,11 +425,7 @@ public class ServiceInstanceTest { new MockUp<CamundaClient>() {
@Mock
- public HttpResponse post(String requestId, boolean isBaseVfModule,
- int recipeTimeout, String requestAction, String serviceInstanceId,
- String vnfId, String vfModuleId, String volumeGroupId, String networkId, String configurationId,
- String serviceType, String vnfType, String vfModuleType, String networkType,
- String requestDetails, String recipeParamXsd){
+ public HttpResponse post(RequestClientParamater requestClientParamater){
return null;
}
};
@@ -923,11 +907,7 @@ public class ServiceInstanceTest { new MockUp<CamundaClient>() {
@Mock
- public HttpResponse post(String requestId, boolean isBaseVfModule,
- int recipeTimeout, String requestAction, String serviceInstanceId,
- String vnfId, String vfModuleId, String volumeGroupId, String networkId, String configurationId,
- String serviceType, String vnfType, String vfModuleType, String networkType,
- String requestDetails, String recipeParamXsd){
+ public HttpResponse post(RequestClientParamater requestClientParamater) {
ProtocolVersion pv = new ProtocolVersion("HTTP",1,1);
HttpResponse resp = new BasicHttpResponse(pv,200, "test response");
BasicHttpEntity entity = new BasicHttpEntity();
@@ -1092,11 +1072,7 @@ public class ServiceInstanceTest { new MockUp<CamundaClient>() {
@Mock
- public HttpResponse post(String requestId, boolean isBaseVfModule,
- int recipeTimeout, String requestAction, String serviceInstanceId,
- String vnfId, String vfModuleId, String volumeGroupId, String networkId, String configurationId,
- String serviceType, String vnfType, String vfModuleType, String networkType,
- String requestDetails, String recipeParamXsd){
+ public HttpResponse post(RequestClientParamater requestClientParamater){
ProtocolVersion pv = new ProtocolVersion("HTTP",1,1);
HttpResponse resp = new BasicHttpResponse(pv,200, "test response");
BasicHttpEntity entity = new BasicHttpEntity();
@@ -1143,11 +1119,7 @@ public class ServiceInstanceTest { new MockUp<CamundaClient>() {
@Mock
- public HttpResponse post(String requestId, boolean isBaseVfModule,
- int recipeTimeout, String requestAction, String serviceInstanceId,
- String vnfId, String vfModuleId, String volumeGroupId, String networkId, String configurationId,
- String serviceType, String vnfType, String vfModuleType, String networkType,
- String requestDetails, String recipeParamXsd){
+ public HttpResponse post(RequestClientParamater requestClientParamater) {
ProtocolVersion pv = new ProtocolVersion("HTTP",1,1);
HttpResponse resp = new BasicHttpResponse(pv,200, "test response");
BasicHttpEntity entity = new BasicHttpEntity();
|