aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
authorMarcus G K Williams <marcus.williams@intel.com>2018-10-25 07:49:31 -0700
committerMarcus G K Williams <marcus.williams@intel.com>2018-10-29 13:29:13 -0700
commit649c4e85cc991ffe9c13fd3fab4cc3a303faa656 (patch)
tree7122a2cb3f58cdcb2f79fd59fabdb266b4f5c627 /bpmn
parent6c2c8a66fade016f74b51bdfea3ba04494530b97 (diff)
Fix Error, Check that vimID is present
Issue-ID: SO-1156 Change-Id: I14445f0e6dbed00b37a189f3a7c05923c6d4e5ab Signed-off-by: Marcus G K Williams <marcus.williams@intel.com>
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy63
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy88
2 files changed, 133 insertions, 18 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy
index beac679691..1a47ef88e2 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy
@@ -176,17 +176,30 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor {
execution.setVariable("subscriberInfo", subscriberInfo)
msoLogger.debug("Incoming subscriberInfo is: " + subscriberInfo)
- // extract cloud configuration, split vid_ID into cloudOwner and cloudRegionId
+ // extract cloud configuration - if underscore "_" is present treat as vimId else it's a cloudRegion
String vimId = jsonUtil.getJsonValue(createVcpeServiceRequest,
"requestDetails.cloudConfiguration.lcpCloudRegionId")
- def cloudRegion = vimId.split("_")
- def cloudOwner = cloudRegion[0].toString()
- def cloudRegionId = cloudRegion[1].toString()
- execution.setVariable("cloudOwner", cloudOwner)
- utils.log("DEBUG","cloudOwner: " + cloudOwner, isDebugEnabled)
- execution.setVariable("cloudRegionId", cloudRegionId)
- utils.log("DEBUG","cloudRegionId: " + cloudRegionId, isDebugEnabled)
-
+ if (vimId.contains("_") && vimId.split("_").length == 2 ) {
+ def cloudRegion = vimId.split("_")
+ def cloudOwner = cloudRegion[0]
+ def cloudRegionId = cloudRegion[1]
+ execution.setVariable("cloudOwner", cloudOwner)
+ msoLogger.debug("cloudOwner: " + cloudOwner)
+ execution.setVariable("cloudRegionId", cloudRegionId)
+ msoLogger.debug("cloudRegionId: " + cloudRegionId)
+ } else {
+ msoLogger.debug("vimId is not present - setting cloudRegion/cloudOwner from request.")
+ String cloudOwner = jsonUtil.getJsonValue(createVcpeServiceRequest,
+ "requestDetails.cloudConfiguration.cloudOwner")
+ if (!cloudOwner?.empty && cloudOwner != "")
+ {
+ execution.setVariable("cloudOwner", cloudOwner)
+ msoLogger.debug("cloudOwner: " + cloudOwner)
+ }
+ def cloudRegionId = vimId
+ execution.setVariable("cloudRegionId", cloudRegionId)
+ msoLogger.debug("cloudRegionId: " + cloudRegionId)
+ }
/*
* Extracting User Parameters from incoming Request and converting into a Map
*/
@@ -592,16 +605,32 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor {
msoLogger.debug(" vnfModelInfoString :" + vnfModelInfoString)
- // extract cloud configuration
+ // extract cloud configuration - if underscore "_" is present treat as vimId else it's a cloudRegion
String vimId = jsonUtil.getJsonValue(createVcpeServiceRequest,
"requestDetails.cloudConfiguration.lcpCloudRegionId")
- def cloudRegion = vimId.split("_")
- execution.setVariable("cloudOwner", cloudRegion[0])
- msoLogger.debug("cloudOwner: "+ cloudRegion[0])
- execution.setVariable("cloudRegionId", cloudRegion[1])
- msoLogger.debug("cloudRegionId: "+ cloudRegion[1])
- execution.setVariable("lcpCloudRegionId", cloudRegion[1])
- msoLogger.debug("lcpCloudRegionId: "+ cloudRegion[1])
+ if (vimId.contains("_") && vimId.split("_").length == 2 ) {
+ def cloudRegion = vimId.split("_")
+ execution.setVariable("cloudOwner", cloudRegion[0])
+ msoLogger.debug("cloudOwner: " + cloudRegion[0])
+ execution.setVariable("cloudRegionId", cloudRegion[1])
+ msoLogger.debug("cloudRegionId: " + cloudRegion[1])
+ execution.setVariable("lcpCloudRegionId", cloudRegion[1])
+ msoLogger.debug("lcpCloudRegionId: " + cloudRegion[1])
+ } else {
+ msoLogger.debug("vimId is not present - setting cloudRegion/cloudOwner from request.")
+ String cloudOwner = jsonUtil.getJsonValue(createVcpeServiceRequest,
+ "requestDetails.cloudConfiguration.cloudOwner")
+ if (!cloudOwner?.empty && cloudOwner != "")
+ {
+ execution.setVariable("cloudOwner", cloudOwner)
+ msoLogger.debug("cloudOwner: " + cloudOwner)
+ }
+ execution.setVariable("cloudRegionId", vimId)
+ msoLogger.debug("cloudRegionId: " + vimId)
+ execution.setVariable("lcpCloudRegionId", vimId)
+ msoLogger.debug("lcpCloudRegionId: " + vimId)
+ }
+
String tenantId = jsonUtil.getJsonValue(createVcpeServiceRequest,
"requestDetails.cloudConfiguration.tenantId")
execution.setVariable("tenantId", tenantId)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy
index 84da045450..d0ded39146 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy
@@ -31,6 +31,7 @@ import org.junit.Test
import org.junit.Ignore
import org.mockito.MockitoAnnotations
import org.camunda.bpm.engine.delegate.BpmnError
+import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
import org.onap.so.bpmn.core.domain.HomingSolution
import org.onap.so.bpmn.mock.FileUtil
@@ -195,7 +196,53 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase {
assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.preProcessRequest(mex) }))
}
-
+
+ @Test
+ @Ignore
+ public void preProcessRequest_vimId() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPreProcess(mex)
+ UrnPropertiesReader
+
+ def req = request
+ .replace('"mdt1"', '"CloudOwner_CloudRegion1"')
+
+ when(mex.getVariable("bpmnRequest")).thenReturn(req)
+ when(mex.getVariable("URN_mso_workflow_aai_distribution_delay")).thenReturn("PT5S")
+ when(mex.getVariable("aai.workflowAaiDistributionDelay")).thenReturn("PT5S")
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.preProcessRequest(mex)
+
+ verify(mex).setVariable("cloudRegionId", "CloudRegion1")
+ verify(mex).setVariable("cloudOwner", "CloudOwner")
+ }
+
+ @Test
+ @Ignore
+ public void preProcessRequest_noVimId() {
+ ExecutionEntity mex = setupMock()
+ def map = setupMap(mex)
+ initPreProcess(mex)
+
+ def req = request
+ .replace('"mdt1"', '"CloudRegion1_"')
+
+ when(mex.getVariable("bpmnRequest")).thenReturn(req)
+ when(mex.getVariable("URN_mso_workflow_aai_distribution_delay")).thenReturn(60)
+ when(mex.getVariable("URN_mso_workflow_aai_distribution_delay")).thenReturn("PT5S")
+ when(mex.getVariable("aai.workflowAaiDistributionDelay")).thenReturn("PT5S")
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.preProcessRequest(mex)
+
+ verify(mex).setVariable("cloudRegionId", "CloudRegion1_")
+ verify(mex).setVariable("cloudOwner", "my-cloud-owner")
+
+ }
+
+
@Test
// @Ignore
public void preProcessRequest_BpmnError() {
@@ -579,6 +626,45 @@ class CreateVcpeResCustServiceTest extends GroovyTestBase {
verify(mex).setVariable("cloudOwner", "my-cloud-owner")
verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba")
}
+
+ @Test
+ public void prepareVnfAndModulesCreate_noVimId() {
+ ExecutionEntity mex = setupMock()
+ initPrepareVnfAndModulesCreate(mex)
+
+ def req = request
+ .replace('"mdt1"', '"CloudRegion1_"')
+
+ when(mex.getVariable("createVcpeServiceRequest")).thenReturn(req)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.prepareVnfAndModulesCreate(mex)
+
+ verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
+ verify(mex).setVariable("cloudRegionId", "CloudRegion1_")
+ verify(mex).setVariable("lcpCloudRegionId", "CloudRegion1_")
+ verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba")
+ }
+
+ @Test
+ public void prepareVnfAndModulesCreate_vimId() {
+ ExecutionEntity mex = setupMock()
+ initPrepareVnfAndModulesCreate(mex)
+
+ def req = request
+ .replace('"mdt1"', '"CloudOwner_CloudRegion1"')
+
+ when(mex.getVariable("createVcpeServiceRequest")).thenReturn(req)
+
+ CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService()
+ CreateVcpeResCustService.prepareVnfAndModulesCreate(mex)
+
+ verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb")
+ verify(mex).setVariable("cloudOwner", "CloudOwner")
+ verify(mex).setVariable("cloudRegionId", "CloudRegion1")
+ verify(mex).setVariable("lcpCloudRegionId", "CloudRegion1")
+ verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba")
+ }
@Test
// @Ignore