From: Jim Hahn Date: Wed, 11 Oct 2017 15:49:51 +0000 (-0400) Subject: Add junit test coverage and fix bugs in VCPE X-Git-Tag: v1.1.0~158^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=015b92c3d96fb42f80b018fdf8f639f1cf3298c3;p=so.git Add junit test coverage and fix bugs in VCPE Added additional junit tests for VCPE and fixed bugs that were found while testing. Change-Id: Icb6a0c936a16b775ff553c11cb07a4348bd9ebfc Issue-ID: SO-210 Signed-off-by: Jim Hahn --- diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java index 9057904da3..f60d984a6d 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java @@ -21,6 +21,9 @@ package org.openecomp.mso.bpmn.common; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Matchers.any; import static org.mockito.Mockito.doAnswer; @@ -77,7 +80,18 @@ public class BPMNUtil { .getValue(); return (T) responseData; } + + + public static void assertAnyProcessInstanceFinished(ProcessEngineServices processEngineServices, String processDefinitionID) { + String pID = getProcessInstanceId(processEngineServices, + processDefinitionID); + assertNotNull(pID); + assertTrue(processEngineServices.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(pID).finished().count() > 0); + } + public static void assertNoProcessInstance(ProcessEngineServices processEngineServices, String processDefinitionID) { + assertNull(getProcessInstanceId(processEngineServices, processDefinitionID)); + } public static void assertProcessInstanceFinished(ProcessEngineServices processEngineServices, String pid) { assertEquals(1, processEngineServices.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(pid).finished().count()); diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/CreateVcpeResCustService.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy similarity index 68% rename from bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/CreateVcpeResCustService.groovy rename to bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy index 3b24ebf544..87cf6fbd0f 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/CreateVcpeResCustService.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy @@ -1,5 +1,21 @@ /* - * © 2016 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.vcpe.scripts; @@ -33,6 +49,8 @@ import org.springframework.web.util.UriUtils; */ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { + private static final String DebugFlag = "isDebugLogEnabled" + String Prefix="CVRCS_" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() @@ -50,8 +68,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { execution.setVariable("globalSubscriberId", "") execution.setVariable("serviceInstanceName", "") execution.setVariable("msoRequestId", "") - execution.setVariable("CVRCS_NetworksCreatedCount", 0) - execution.setVariable("CVRCS_VnfsCreatedCount", 0) + execution.setVariable(Prefix+"VnfsCreatedCount", 0) execution.setVariable("productFamilyId", "") execution.setVariable("brgWanMacAddress", "") @@ -67,7 +84,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { * @param execution */ public void preProcessRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) execution.setVariable("prefix",Prefix) utils.log("DEBUG", " ***** Inside preProcessRequest CreateVcpeResCustService Request ***** ", isDebugEnabled) @@ -105,10 +122,9 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { String source = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.source") if ((source == null) || (source.isEmpty())) { - execution.setVariable("source", "VID") - } else { - execution.setVariable("source", source) + source = "VID" } + execution.setVariable("source", source) // extract globalSubscriberId String globalSubscriberId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.subscriberInfo.globalSubscriberId") @@ -173,7 +189,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { ${source} """ - execution.setVariable("CVRCS_requestInfo", requestInfo) + execution.setVariable(Prefix+"requestInfo", requestInfo) utils.log("DEBUG", " ***** Completed preProcessRequest CreateVcpeResCustService Request ***** ", isDebugEnabled) @@ -186,8 +202,8 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { } } - public void sendSyncResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + public void sendSyncResponse(Execution execution) { + def isDebugEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG", " ***** Inside sendSyncResponse of CreateVcpeResCustService ***** ", isDebugEnabled) @@ -211,7 +227,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { // // ******************************* public void prepareDecomposeService(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) try { utils.log("DEBUG", " ***** Inside prepareDecomposeService of CreateVcpeResCustService ***** ", isDebugEnabled) @@ -234,7 +250,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { // // ******************************* public void prepareCreateServiceInstance(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) try { utils.log("DEBUG", " ***** Inside prepareCreateServiceInstance of CreateVcpeResCustService ***** ", isDebugEnabled) @@ -266,10 +282,9 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { public void postProcessServiceInstanceCreate (Execution execution){ def method = getClass().getSimpleName() + '.postProcessServiceInstanceCreate(' +'execution=' + execution.getId() +')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + def isDebugLogEnabled = execution.getVariable(DebugFlag) logDebug('Entered ' + method, isDebugLogEnabled) - String source = execution.getVariable("source") String requestId = execution.getVariable("mso-request-id") String serviceInstanceId = execution.getVariable("serviceInstanceId") String serviceInstanceName = execution.getVariable("serviceInstanceName") @@ -289,8 +304,8 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { """ - execution.setVariable("CVRCS_setUpdateDbInstancePayload", payload) - utils.logAudit("CVRCS_setUpdateDbInstancePayload: " + payload) + execution.setVariable(Prefix+"setUpdateDbInstancePayload", payload) + utils.logAudit(Prefix+"setUpdateDbInstancePayload: " + payload) logDebug('Exited ' + method, isDebugLogEnabled) } catch (BpmnError e) { @@ -303,28 +318,13 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { public void processDecomposition (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) - utils.log("DEBUG", " ***** Inside getDataFromDecomposition() of CreateVcpeResCustService ***** ", isDebugEnabled) + utils.log("DEBUG", " ***** Inside processDecomposition() of CreateVcpeResCustService ***** ", isDebugEnabled) try { ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - List networkList = serviceDecomposition.getServiceNetworks() - - - execution.setVariable("networkList", networkList) - execution.setVariable("networkListString", networkList.toString()) - - utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled) - - if (networkList != null && networkList.size() > 0) { - execution.setVariable("CVRCS_NetworksCount", networkList.size()) - utils.log("DEBUG", "networks to create: "+ networkList.size(), isDebugEnabled) - } else { - execution.setVariable("CVRCS_NetworksCount", 0) - utils.log("DEBUG", "no networks to create based upon serviceDecomposition content", isDebugEnabled) - } // VNFs List vnfList = serviceDecomposition.getServiceVnfs() @@ -333,7 +333,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { String vnfModelInfoString = "" if (vnfList != null && vnfList.size() > 0) { - execution.setVariable("CVRCS_VNFsCount", vnfList.size()) + execution.setVariable(Prefix+"VNFsCount", vnfList.size()) utils.log("DEBUG", "vnfs to create: "+ vnfList.size(), isDebugEnabled) ModelInfo vnfModelInfo = vnfList[0].getModelInfo() @@ -341,7 +341,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { String vnfModelInfoWithRoot = vnfModelInfo.toString() vnfModelInfoString = jsonUtil.getJsonValue(vnfModelInfoWithRoot, "modelInfo") } else { - execution.setVariable("CVRCS_VNFsCount", 0) + execution.setVariable(Prefix+"VNFsCount", 0) utils.log("DEBUG", "no vnfs to create based upon serviceDecomposition content", isDebugEnabled) } @@ -349,111 +349,18 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { execution.setVariable("vnfModelInfoString", vnfModelInfoString) utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled) - utils.log("DEBUG", " ***** Completed getDataFromDecomposition() of CreateVcpeResCustService ***** ", isDebugEnabled) + utils.log("DEBUG", " ***** Completed processDecomposition() of CreateVcpeResCustService ***** ", isDebugEnabled) } catch (Exception ex) { sendSyncError(execution) - String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. getDataFromDecomposition() - " + ex.getMessage() + String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. processDecomposition() - " + ex.getMessage() utils.log("DEBUG", exceptionMessage, isDebugEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) } } - // ******************************* - // Generate Network request Section - // ******************************* - public void prepareNetworkCreate (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside preparenNetworkCreate of CreateVcpeResCustService ***** ", isDebugEnabled) - - - String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest") - - List networkList = execution.getVariable("networkList") - utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled) - - Integer networksCreatedCount = execution.getVariable("CVRCS_NetworksCreatedCount") - String networkModelInfoString = "" - - if (networkList != null) { - utils.log("DEBUG", " getting model info for network # :" + networksCreatedCount, isDebugEnabled) - ModelInfo networkModelInfo = networkList[networksCreatedCount.intValue()].getModelInfo() - //Currently use String representation in JSON format as an input - //execution.setVariable("networkModelInfo", networkModelInfo) - networkModelInfoString = networkModelInfo.toJsonStringNoRootName() - } else { - String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected number of networks to create - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - - //Currently use String representation in JSON format as an input - execution.setVariable("networkModelInfo", networkModelInfoString) - utils.log("DEBUG", " networkModelInfoString :" + networkModelInfoString, isDebugEnabled) - - // extract cloud configuration - String lcpCloudRegionId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId") - execution.setVariable("lcpCloudRegionId", lcpCloudRegionId) - utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled) - String tenantId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.cloudConfiguration.tenantId") - execution.setVariable("tenantId", tenantId) - utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled) - - String sdncVersion = execution.getVariable("sdncVersion") - utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled) - -// List vnfList = execution.getVariable("vnfList") -// utils.log("DEBUG", "vnfList: "+ vnfList.toString(), isDebugEnabled) -// -// String vnfModelInfo = execution.getVariable("vnfModelInfo") -// utils.log("DEBUG", "vnfModelInfo: "+ vnfModelInfo, isDebugEnabled) - - utils.log("DEBUG", " ***** Completed preparenNetworkCreate of CreateVcpeResCustService ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method prepareNetworkCreate() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Validate Network request Section -> increment count - // ******************************* - public void validateNetworkCreate (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside validateNetworkCreate of CreateVcpeResCustService ***** ", isDebugEnabled) - - Integer networksCreatedCount = execution.getVariable("CVRCS_NetworksCreatedCount") - networksCreatedCount++ - execution.setVariable("CVRCS_NetworksCreatedCount", networksCreatedCount) - - execution.setVariable("DCRENI_rollbackData"+networksCreatedCount, execution.getVariable("DCRENI_rollbackData")) - - utils.log("DEBUG", "networksCreatedCount: "+ networksCreatedCount, isDebugEnabled) - utils.log("DEBUG", "DCRENI_rollbackData N : "+ execution.getVariable("DCRENI_rollbackData"+networksCreatedCount), isDebugEnabled) - -// JSONArray vnfList = execution.getVariable("vnfList") -// utils.log("DEBUG", "vnfList: "+ vnfList, isDebugEnabled) - - String vnfModelInfo = execution.getVariable("vnfModelInfo") - utils.log("DEBUG", "vnfModelInfo: "+ vnfModelInfo, isDebugEnabled) - - List networkList = execution.getVariable("networkList") - utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled) - - utils.log("DEBUG", " ***** Completed validateNetworkCreate of CreateVcpeResCustService ***** "+" network # "+networksCreatedCount, isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method validateNetworkCreate() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - public void prepareCreateAllottedResourceTXC(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) try { utils.log("DEBUG", " ***** Inside prepareCreateAllottedResourceTXC of CreateVcpeResCustService ***** ", isDebugEnabled) @@ -467,13 +374,6 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest") ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - //parentServiceInstanceId - //The parentServiceInstanceId will be a Landing Network service. This value will have been provided to the calling flow by SNIRO query (homing solution). - //serviceDecomposition.getServiceNetworks() - - //For 1707, the vIPR Tenant OAM flow will use the BRG allotted resource parent service ID (since it is known that the security zone also comes from the vIPR FW). - //Beyond 1707, this would need to be captured somehow in TOSCA model and also provided by SNIRO. - //allottedResourceModelInfo //allottedResourceRole //The model Info parameters are a JSON structure as defined in the Service Instantiation API. @@ -486,34 +386,20 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { utils.log("DEBUG", " getting model info for AllottedResource # :" + allottedResource.toJsonString(), isDebugEnabled) utils.log("DEBUG", " allottedResource.getAllottedResourceType() :" + allottedResource.getAllottedResourceType(), isDebugEnabled) - if(allottedResource.getAllottedResourceType() != null && allottedResource.getAllottedResourceType().equalsIgnoreCase("TunnelXConn")){ + if("TunnelXConn".equalsIgnoreCase(allottedResource.getAllottedResourceType())){ //set create flag to true execution.setVariable("createTXCAR", true) ModelInfo allottedResourceModelInfo = allottedResource.getModelInfo() execution.setVariable("allottedResourceModelInfoTXC", allottedResourceModelInfo.toJsonString()) execution.setVariable("allottedResourceRoleTXC", allottedResource.getAllottedResourceRole()) execution.setVariable("allottedResourceTypeTXC", allottedResource.getAllottedResourceType()) - - //from Homing Solution. This is the infraServiceInstanceId in the BRG Allotted Resource decomposition structure. + //After decomposition and homing BBs, there should be an allotted resource object in the decomposition that represents the TXC, + //and in its homingSolution section should be found the infraServiceInstanceId (i.e. infraServiceInstanceId in TXC Allotted Resource structure) (which the Homing BB would have populated). execution.setVariable("parentServiceInstanceIdTXC", allottedResource.getHomingSolution().getServiceInstanceId()) } } } - //Populate with the A&AI network ID (l3-network object) for the Tenant OAM network that was created in prior step - //String sourceNetworkId = execution.getVariable("networkId") - //execution.setVariable("sourceNetworkId", sourceNetworkId) - //Populate with the network-role (from A&AI l3-network object) for the Tenant OAM network from prior step - - //List networkResources = serviceDecomposition.getServiceNetworks() - //if (networkResources != null) { - //Iterator iter = networkResources.iterator(); - //while (iter.hasNext()){ - //NetworkResource networkResource = (NetworkResource)iter.next(); - //execution.setVariable("sourceNetworkRole", networkResource.getNetworkRole()) - //} - //} - //unit test only String allottedResourceId = execution.getVariable("allottedResourceId") execution.setVariable("allottedResourceIdTXC", allottedResourceId) @@ -527,7 +413,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { } } public void prepareCreateAllottedResourceBRG(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) try { utils.log("DEBUG", " ***** Inside prepareCreateAllottedResourceBRG of CreateVcpeResCustService ***** ", isDebugEnabled) @@ -541,13 +427,6 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest") ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - //parentServiceInstanceId - //The parentServiceInstanceId will be a Landing Network service. This value will have been provided to the calling flow by SNIRO query (homing solution). - //serviceDecomposition.getServiceNetworks() - - //For 1707, the vIPR Tenant OAM flow will use the BRG allotted resource parent service ID (since it is known that the security zone also comes from the vIPR FW). - //Beyond 1707, this would need to be captured somehow in TOSCA model and also provided by SNIRO. - //allottedResourceModelInfo //allottedResourceRole //The model Info parameters are a JSON structure as defined in the Service Instantiation API. @@ -560,38 +439,20 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { utils.log("DEBUG", " getting model info for AllottedResource # :" + allottedResource.toJsonString(), isDebugEnabled) utils.log("DEBUG", " allottedResource.getAllottedResourceType() :" + allottedResource.getAllottedResourceType(), isDebugEnabled) - if (allottedResource.getAllottedResourceType() != null && allottedResource.getAllottedResourceType().equalsIgnoreCase("BRG")) { + if("BRG".equalsIgnoreCase(allottedResource.getAllottedResourceType())){ //set create flag to true execution.setVariable("createBRGAR", true) ModelInfo allottedResourceModelInfo = allottedResource.getModelInfo() execution.setVariable("allottedResourceModelInfoBRG", allottedResourceModelInfo.toJsonString()) execution.setVariable("allottedResourceRoleBRG", allottedResource.getAllottedResourceRole()) execution.setVariable("allottedResourceTypeBRG", allottedResource.getAllottedResourceType()) - //For 1707, the vIPR Tenant OAM flow will use the BRG allotted resource parent service ID (since it is known that the security zone also comes from the vIPR FW). - //This Id should be taken from the homing solution for the BRG resource. - //After decomposition and homing BBs, there should be an allotted resource object in the decomposition that represents the BRG, + //After decomposition and homing BBs, there should be an allotted resource object in the decomposition that represents the BRG, //and in its homingSolution section should be found the infraServiceInstanceId (i.e. infraServiceInstanceId in BRG Allotted Resource structure) (which the Homing BB would have populated). - - //from Homing Solution. This is the infraServiceInstanceId in the BRG Allotted Resource decomposition structure. execution.setVariable("parentServiceInstanceIdBRG", allottedResource.getHomingSolution().getServiceInstanceId()) } } } - //Populate with the A&AI network ID (l3-network object) for the Tenant OAM network that was created in prior step - //String sourceNetworkId = execution.getVariable("networkId") - //execution.setVariable("sourceNetworkId", sourceNetworkId) - //Populate with the network-role (from A&AI l3-network object) for the Tenant OAM network from prior step - - //List networkResources = serviceDecomposition.getServiceNetworks() - //if (networkResources != null) { - //Iterator iter = networkResources.iterator(); - //while (iter.hasNext()){ - //NetworkResource networkResource = (NetworkResource)iter.next(); - //execution.setVariable("sourceNetworkRole", networkResource.getNetworkRole()) - //} - //} - //unit test only String allottedResourceId = execution.getVariable("allottedResourceId") execution.setVariable("allottedResourceIdBRG", allottedResourceId) @@ -611,7 +472,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { // Generate Network request Section // ******************************* public void prepareVnfAndModulesCreate (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) try { utils.log("DEBUG", " ***** Inside prepareVnfAndModulesCreate of CreateVcpeResCustService ***** ", isDebugEnabled) @@ -634,7 +495,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { List vnfList = execution.getVariable("vnfList") - Integer vnfsCreatedCount = execution.getVariable("CVRCS_VnfsCreatedCount") + Integer vnfsCreatedCount = execution.getVariable(Prefix+"VnfsCreatedCount") String vnfModelInfoString = null; if (vnfList != null && vnfList.size() > 0 ) { @@ -673,15 +534,15 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { // Validate Vnf request Section -> increment count // ******************************* public void validateVnfCreate (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) try { utils.log("DEBUG", " ***** Inside validateVnfCreate of CreateVcpeResCustService ***** ", isDebugEnabled) - Integer vnfsCreatedCount = execution.getVariable("CVRCS_VnfsCreatedCount") + Integer vnfsCreatedCount = execution.getVariable(Prefix+"VnfsCreatedCount") vnfsCreatedCount++ - execution.setVariable("CVRCS_VnfsCreatedCount", vnfsCreatedCount) + execution.setVariable(Prefix+"VnfsCreatedCount", vnfsCreatedCount) utils.log("DEBUG", " ***** Completed validateVnfCreate of CreateVcpeResCustService ***** "+" vnf # "+vnfsCreatedCount, isDebugEnabled) } catch (Exception ex) { @@ -691,38 +552,11 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { } } - // ******************************* - // Validate Network request Section -> decrement count - // ******************************* - public void validateNetworkRollback (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside validateNetworkRollback of CreateVcpeResCustService ***** ", isDebugEnabled) - - Integer networksCreatedCount = execution.getVariable("CVRCS_NetworksCreatedCount") - networksCreatedCount-- - - execution.setVariable("CVRCS_NetworksCreatedCount", networksCreatedCount) - - execution.setVariable("DCRENI_rollbackData", execution.getVariable("DCRENI_rollbackData"+networksCreatedCount)) - - utils.log("DEBUG", " ***** Completed validateNetworkRollback of CreateVcpeResCustService ***** "+" network # "+networksCreatedCount, isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method validateNetworkRollback() - " + ex.getMessage() - //exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - execution.setVariable("CVRCS_NetworksCreatedCount", 0) - utils.log("ERROR", exceptionMessage, true) - } - } - // ***************************************** // Prepare Completion request Section // ***************************************** public void postProcessResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG", " ***** Inside postProcessResponse of CreateVcpeResCustService ***** ", isDebugEnabled) @@ -748,8 +582,8 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) utils.logAudit(xmlMsoCompletionRequest) - execution.setVariable("CVRCS_Success", true) - execution.setVariable("CVRCS_CompleteMsoProcessRequest", xmlMsoCompletionRequest) + execution.setVariable(Prefix+"Success", true) + execution.setVariable(Prefix+"CompleteMsoProcessRequest", xmlMsoCompletionRequest) utils.log("DEBUG", " SUCCESS flow, going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) } catch (BpmnError e) { throw e; @@ -761,7 +595,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { } public void preProcessRollback (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG"," ***** preProcessRollback of CreateVcpeResCustService ***** ", isDebugEnabled) try { @@ -782,7 +616,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { } public void postProcessRollback (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG"," ***** postProcessRollback of CreateVcpeResCustService ***** ", isDebugEnabled) String msg = "" try { @@ -802,19 +636,19 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { } public void prepareFalloutRequest(Execution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG", " *** STARTED CreateVcpeResCustService prepareFalloutRequest Process *** ", isDebugEnabled) try { WorkflowException wfex = execution.getVariable("WorkflowException") utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled) - String requestInfo = execution.getVariable("CVRCS_requestInfo") + String requestInfo = execution.getVariable(Prefix+"requestInfo") utils.log("DEBUG", " Incoming Request Info: " + requestInfo, isDebugEnabled) //TODO. hmmm. there is no way to UPDATE error message. // String errorMessage = wfex.getErrorMessage() -// boolean successIndicator = execution.getVariable("DCRESI_rollbackSuccessful") +// boolean successIndicator = execution.getVariable("DCRESI_rolledBack") // if (successIndicator){ // errorMessage = errorMessage + ". Rollback successful." // } else { @@ -823,7 +657,7 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) - execution.setVariable("CVRCS_falloutRequest", falloutRequest) + execution.setVariable(Prefix+"falloutRequest", falloutRequest) } catch (Exception ex) { utils.log("DEBUG", "Error Occured in CreateVcpeResCustService prepareFalloutRequest Process " + ex.getMessage(), isDebugEnabled) @@ -834,15 +668,15 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { public void sendSyncError (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) execution.setVariable("prefix", Prefix) utils.log("DEBUG", " ***** Inside sendSyncError() of CreateVcpeResCustService ***** ", isDebugEnabled) try { String errorMessage = "" - if (execution.getVariable("WorkflowException") instanceof WorkflowException) { - WorkflowException wfe = execution.getVariable("WorkflowException") + def wfe = execution.getVariable("WorkflowException") + if (wfe instanceof WorkflowException) { errorMessage = wfe.getErrorMessage() } else { errorMessage = "Sending Sync Error." @@ -862,20 +696,20 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { } public void processJavaException(Execution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) execution.setVariable("prefix",Prefix) try{ utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled) utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled) - execution.setVariable("CRESI_unexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated + execution.setVariable(Prefix+"unexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Caught a Java Lang Exception") }catch(BpmnError b){ utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugEnabled) throw b }catch(Exception e){ utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) - execution.setVariable("CRESI_unexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated + execution.setVariable(Prefix+"unexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception in processJavaException method") } utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled) diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/DeleteVcpeResCustService.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy similarity index 68% rename from bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/DeleteVcpeResCustService.groovy rename to bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy index 960bb5cc7f..04eb4c7d7e 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/DeleteVcpeResCustService.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy @@ -1,5 +1,21 @@ /* - * © 2016 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.vcpe.scripts @@ -33,7 +49,9 @@ import org.springframework.web.util.UriUtils; */ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { - String Prefix="DELVAS_" + private static final String DebugFlag = "isDebugLogEnabled" + + String Prefix = "DVRCS_" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() VidUtils vidUtils = new VidUtils() @@ -49,10 +67,8 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { execution.setVariable("DeleteVcpeResCustServiceRequest", "") execution.setVariable("msoRequestId", "") - execution.setVariable("DELVAS_vnfsDeletedCount", 0) - execution.setVariable("DELVAS_vnfsCount", 0) - execution.setVariable("DELVAS_networksCount", 0) - execution.setVariable("DELVAS_networksDeletedCount", 0) + execution.setVariable(Prefix+"vnfsDeletedCount", 0) + execution.setVariable(Prefix+"vnfsCount", 0) } // ************************************************** @@ -63,7 +79,7 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { * @param execution */ public void preProcessRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) execution.setVariable("prefix",Prefix) utils.log("DEBUG", " ***** Inside preProcessRequest DeleteVcpeResCustService Request ***** ", isDebugEnabled) @@ -93,10 +109,9 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { String source = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.requestInfo.source") if ((source == null) || (source.isEmpty())) { - execution.setVariable("source", "VID") - } else { - execution.setVariable("source", source) + source = "VID" } + execution.setVariable("source", source) // extract globalSubscriberId String globalSubscriberId = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.subscriberInfo.globalSubscriberId") @@ -139,7 +154,7 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { ${source} """ - execution.setVariable("DELVAS_requestInfo", requestInfo) + execution.setVariable(Prefix+"requestInfo", requestInfo) //Setting for Generic Sub Flows execution.setVariable("GENGS_type", "service-instance") @@ -154,8 +169,8 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { } } - public void sendSyncResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + public void sendSyncResponse(Execution execution) { + def isDebugEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG", " ***** Inside sendSyncResponse of DeleteVcpeResCustService ***** ", isDebugEnabled) @@ -169,13 +184,13 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { utils.log("DEBUG", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled) sendWorkflowResponse(execution, 202, syncResponse) } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Unexpected from method preProcessRequest() - " + ex.getMessage()^M + String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Unexpected from method preProcessRequest() - " + ex.getMessage() exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) } } - public void prepareServiceDelete (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + public void prepareServiceDelete(Execution execution) { + def isDebugEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG", " ***** Inside prepareServiceInstanceDelete() of DeleteVcpeResCustService ***** ", isDebugEnabled) try { @@ -198,8 +213,8 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { utils.log("DEBUG", "serviceInstanceAaiRecord: "+serviceInstanceAaiRecord, isDebugEnabled) // determine if AR needs to be deleted - boolean DELVAS_TunnelXConn = false - boolean DELVAS_BRG = false + boolean DVRCS_TunnelXConn = false + boolean DVRCS_BRG = false String TXC_allottedResourceId String BRG_allottedResourceId XmlParser xmlParser = new XmlParser() @@ -208,32 +223,31 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { if (arList != null) { def groovy.util.NodeList ars = utils.getIdenticalChildren(arList, 'allotted-resource') for (groovy.util.Node ar in ars) { - def groovy.util.Node type = utils.getChildNode(ar, 'type') - if ((type != null) && (type.text().equals('TunnelXConn'))) { + def type = utils.getChildNodeText(ar, 'type') + if ("TunnelXConn".equals(type)) { utils.log("DEBUG","TunnelXConn AR found", isDebugEnabled) - def groovy.util.Node id = utils.getChildNode(ar, 'id') + def id = utils.getChildNodeText(ar, 'id') if (id != null){ - DELVAS_TunnelXConn = true + DVRCS_TunnelXConn = true TXC_allottedResourceId = id } - } - if ((type != null) && (type.text().equals('BRG'))) { + } else if ("BRG".equals(type)) { utils.log("DEBUG","FW AR found", isDebugEnabled) - def groovy.util.Node id = utils.getChildNode(ar, 'id') + def id = utils.getChildNodeText(ar, 'id') if (id != null){ - DELVAS_BRG = true + DVRCS_BRG = true BRG_allottedResourceId = id } } } } - execution.setVariable("DELVAS_TunnelXConn", DELVAS_TunnelXConn) - utils.log("DEBUG", "DELVAS_TunnelXConn : " + DELVAS_TunnelXConn, isDebugEnabled) + execution.setVariable(Prefix+"TunnelXConn", DVRCS_TunnelXConn) + utils.log("DEBUG", Prefix+"TunnelXConn : " + DVRCS_TunnelXConn, isDebugEnabled) execution.setVariable("TXC_allottedResourceId", TXC_allottedResourceId) utils.log("DEBUG", "TXC_allottedResourceId : " + TXC_allottedResourceId, isDebugEnabled) - execution.setVariable("DELVAS_BRG", DELVAS_BRG) - utils.log("DEBUG", "DELVAS_BRG : " + DELVAS_BRG, isDebugEnabled) + execution.setVariable(Prefix+"BRG", DVRCS_BRG) + utils.log("DEBUG", Prefix+"BRG : " + DVRCS_BRG, isDebugEnabled) execution.setVariable("BRG_allottedResourceId", BRG_allottedResourceId) utils.log("DEBUG", "BRG_allottedResourceId : " + BRG_allottedResourceId, isDebugEnabled) @@ -246,7 +260,6 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { utils.log("DEBUG", " relationship string - " + relationship, isDebugEnabled) int vnfsCount = 0 - int networksCount = 0 if (relationship != null && relationship.length() > 0){ relationship = relationship.trim().replace("tag0:","").replace(":tag0","") @@ -254,29 +267,20 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { // Check if Network TableREf is present, then build a List of network policy List relatedVnfIdList = networkUtils.getRelatedVnfIdList(relationship) vnfsCount = relatedVnfIdList.size() - execution.setVariable("DELVAS_vnfsCount", vnfsCount) - utils.log("DEBUG", " DELVAS_vnfsCount : " + vnfsCount, isDebugEnabled) - execution.setVariable("DELVAS_relatedVnfIdList", relatedVnfIdList) - - // Check if Network TableREf is present, then build a List of network policy - List relatedNetworkIdList = networkUtils.getRelatedNetworkIdList(relationship) - networksCount = relatedNetworkIdList.size() - execution.setVariable("DELVAS_networksCount", networksCount) - utils.log("DEBUG", " DELVAS_networksCount : " + networksCount, isDebugEnabled) - execution.setVariable("DELVAS_relatedNetworkIdList", relatedNetworkIdList) + execution.setVariable(Prefix+"vnfsCount", vnfsCount) + utils.log("DEBUG", " "+Prefix+"vnfsCount : " + vnfsCount, isDebugEnabled) + execution.setVariable(Prefix+"relatedVnfIdList", relatedVnfIdList) } else { - execution.setVariable("DELVAS_vnfsCount", 0) - utils.log("DEBUG", " DELVAS_vnfsCount : " + vnfsCount, isDebugEnabled) - execution.setVariable("DELVAS_networksCount", 0) - utils.log("DEBUG", " DELVAS_networksCount : " + networksCount, isDebugEnabled) + execution.setVariable(Prefix+"vnfsCount", 0) + utils.log("DEBUG", " "+Prefix+"vnfsCount : " + vnfsCount, isDebugEnabled) } - utils.log("DEBUG", " ***** Completed prepareServiceInstanceDelete() of DeleteVcpeCusRestService ***** ", isDebugEnabled) + utils.log("DEBUG", " ***** Completed prepareServiceInstanceDelete() of DeleteVcpeResCustService ***** ", isDebugEnabled) } catch (BpmnError e){ throw e; } catch (Exception ex) { sendSyncError(execution) - String exceptionMessage = "Bpmn error encountered in DeleteVcpeCusRestService flow. prepareServiceInstanceDelete() - " + ex.getMessage() + String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. prepareServiceInstanceDelete() - " + ex.getMessage() utils.log("DEBUG", exceptionMessage, isDebugEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) } @@ -287,13 +291,12 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { // // ******************************* public void prepareVnfAndModulesDelete (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) + utils.log("DEBUG", " ***** Inside prepareVnfAndModulesDelete of DeleteVcpeResCustService ***** ", isDebugEnabled) try { - utils.log("DEBUG", " ***** Inside prepareVnfAndModulesDelete of DeleteServiceInstanceMacro ***** ", isDebugEnabled) - - List vnfList = execution.getVariable("DELVAS_relatedVnfIdList") - Integer vnfsDeletedCount = execution.getVariable("DELVAS_vnfsDeletedCount") + List vnfList = execution.getVariable(Prefix+"relatedVnfIdList") + int vnfsDeletedCount = execution.getVariable(Prefix+"vnfsDeletedCount") String vnfModelInfoString = "" String vnfId = "" if (vnfList.size() > 0 ) { @@ -303,10 +306,10 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { execution.setVariable("vnfId", vnfId) utils.log("DEBUG", "need to delete vnfId:" + vnfId, isDebugEnabled) - utils.log("DEBUG", " ***** Completed prepareVnfAndModulesDelete of DeleteServiceInstanceMacro ***** ", isDebugEnabled) + utils.log("DEBUG", " ***** Completed prepareVnfAndModulesDelete of DeleteVcpeResCustService ***** ", isDebugEnabled) } catch (Exception ex) { // try error in method block - String exceptionMessage = "Bpmn error encountered in DeleteServiceInstanceMacro flow. Unexpected Error from method prepareVnfAndModulesDelete() - " + ex.getMessage() + String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Unexpected Error from method prepareVnfAndModulesDelete() - " + ex.getMessage() exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) } } @@ -315,70 +318,19 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { // Validate Vnf request Section -> increment count // ******************************* public void validateVnfDelete (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) + utils.log("DEBUG", " ***** Inside validateVnfDelete of DeleteVcpeResCustService ***** ", isDebugEnabled) try { - utils.log("DEBUG", " ***** Inside validateVnfDelete of DeleteVcpeCusRestService ***** ", isDebugEnabled) - - String vnfsDeletedCount = execution.getVariable("DELVAS_vnfsDeletedCount") + int vnfsDeletedCount = execution.getVariable(Prefix+"vnfsDeletedCount") vnfsDeletedCount++ - execution.setVariable("DELVAS_vnfsDeletedCount", vnfsDeletedCount) - - utils.log("DEBUG", " ***** Completed validateVnfDelete of DeleteVcpeCusRestService ***** "+" vnf # "+vnfsDeletedCount, isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in DeleteVcpeCusRestService flow. Unexpected Error from method validateVnfDelete() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Generate Network request Section - // ******************************* - public void prepareNetworkDelete (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside prepareNetworkDelete of DeleteVcpeCusRestService ***** ", isDebugEnabled) - - List networkList = execution.getVariable("DELVAS_relatedNetworkIdList") - Integer networksDeletedCount = execution.getVariable("DELVAS_networksDeletedCount") - - String networkId = "" - if (networkList.size() > 0) { - networkId = networkList.get(networksDeletedCount.intValue()) - } - - execution.setVariable("networkId", networkId) - utils.log("DEBUG", "need to delete networkId:" + networkId, isDebugEnabled) - - utils.log("DEBUG", " ***** Completed prepareNetworkDelete of DeleteVcpeCusRestService ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = q"Bpmn error encountered in DeleteVcpeCusRestService flow. Unexpected Error from method prepareNetworkDelete() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Validate Network request Section - // ******************************* - public void validateNetworkDelete (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside validateNetworkDelete of DeleteVcpeCusRestService ***** ", isDebugEnabled) - - Integer networksDeletedCount = execution.getVariable("DELVAS_networksDeletedCount") - networksDeletedCount++ - - execution.setVariable("DELVAS_networksDeletedCount", networksDeletedCount) + execution.setVariable(Prefix+"vnfsDeletedCount", vnfsDeletedCount) - utils.log("DEBUG", " ***** Completed validateNetworkDelete of DeleteVcpeCusRestService ***** ", isDebugEnabled) + utils.log("DEBUG", " ***** Completed validateVnfDelete of DeleteVcpeResCustService ***** "+" vnf # "+vnfsDeletedCount, isDebugEnabled) } catch (Exception ex) { // try error in method block - String exceptionMessage = "Bpmn error encountered in DeleteVcpeCusRestService flow. Unexpected Error from method validateNetworkDelete() - " + ex.getMessage() + String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Unexpected Error from method validateVnfDelete() - " + ex.getMessage() exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) } } @@ -388,8 +340,8 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { // Prepare Completion request Section // ***************************************** public void postProcessResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " ***** Inside postProcessResponse of DeleteVcpeCusRestService ***** ", isDebugEnabled) + def isDebugEnabled=execution.getVariable(DebugFlag) + utils.log("DEBUG", " ***** Inside postProcessResponse of DeleteVcpeResCustService ***** ", isDebugEnabled) try { String source = execution.getVariable("source") @@ -411,8 +363,8 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) utils.logAudit(xmlMsoCompletionRequest) - execution.setVariable("DELVAS_Success", true) - execution.setVariable("DELVAS_CompleteMsoProcessRequest", xmlMsoCompletionRequest) + execution.setVariable(Prefix+"Success", true) + execution.setVariable(Prefix+"CompleteMsoProcessRequest", xmlMsoCompletionRequest) utils.log("DEBUG", " SUCCESS flow, going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) } catch (BpmnError e) { throw e; @@ -425,29 +377,29 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { } public void prepareFalloutRequest(Execution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** STARTED DeleteVcpeCusRestService prepareFalloutRequest Process *** ", isDebugEnabled) + def isDebugEnabled=execution.getVariable(DebugFlag) + utils.log("DEBUG", " *** STARTED DeleteVcpeResCustService prepareFalloutRequest Process *** ", isDebugEnabled) try { WorkflowException wfex = execution.getVariable("WorkflowException") utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled) - String requestInfo = execution.getVariable("DELVAS_requestInfo") + String requestInfo = execution.getVariable(Prefix+"requestInfo") utils.log("DEBUG", " Incoming Request Info: " + requestInfo, isDebugEnabled) String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) - execution.setVariable("DELVAS_falloutRequest", falloutRequest) + execution.setVariable(Prefix+"falloutRequest", falloutRequest) } catch (Exception ex) { - utils.log("DEBUG", "Error Occured in DeleteVcpeCusRestService prepareFalloutRequest Process " + ex.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DeleteVcpeCusRestService prepareFalloutRequest Process") + utils.log("DEBUG", "Error Occured in DeleteVcpeResCustService prepareFalloutRequest Process " + ex.getMessage(), isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DeleteVcpeResCustService prepareFalloutRequest Process") } - utils.log("DEBUG", "*** COMPLETED DeleteVcpeCusRestService prepareFalloutRequest Process ***", isDebugEnabled) + utils.log("DEBUG", "*** COMPLETED DeleteVcpeResCustService prepareFalloutRequest Process ***", isDebugEnabled) } public void sendSyncError (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " ***** Inside sendSyncError() of DeleteServiceInstanceInfra ***** ", isDebugEnabled) + def isDebugEnabled=execution.getVariable(DebugFlag) + utils.log("DEBUG", " ***** Inside sendSyncError() of DeleteVcpeResCustService ***** ", isDebugEnabled) try { String errorMessage = "" @@ -472,20 +424,20 @@ public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor { } public void processJavaException(Execution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) execution.setVariable("prefix",Prefix) try{ utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled) utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled) - execution.setVariable("DELVAS_unexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated + execution.setVariable(Prefix+"unexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Caught a Java Lang Exception") }catch(BpmnError b){ utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugEnabled) throw b }catch(Exception e){ utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) - execution.setVariable("DELVAS_unexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated + execution.setVariable(Prefix+"unexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception in processJavaException method") } utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled) diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/DoCreateAllottedResourceBRG.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy similarity index 93% rename from bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/DoCreateAllottedResourceBRG.groovy rename to bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy index 528a804b6f..9ddfa1e31c 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/DoCreateAllottedResourceBRG.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy @@ -1,5 +1,21 @@ /* - * © 2016 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.vcpe.scripts; @@ -48,13 +64,15 @@ import static org.apache.commons.lang3.StringUtils.* */ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ + private static final String DebugFlag = "isDebugLogEnabled" + String Prefix="DCARBRG_" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() public void preProcessRequest (Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = "" utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled) @@ -125,7 +143,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ public void getAaiAR (Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) utils.log("DEBUG"," ***** getAaiAR ***** ", isDebugEnabled) String arType = execution.getVariable("allottedResourceType") @@ -163,7 +181,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ public void createAaiAR(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG"," ***** createAaiAR ***** ", isDebugEnabled) String msg = "" @@ -285,7 +303,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ public String buildSDNCRequest(Execution execution, String action, String sdncRequestId) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = "" utils.log("DEBUG"," ***** buildSDNCRequest *****", isDebugEnabled) String sdncReq = null @@ -387,7 +405,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ public void preProcessSDNCAssign(Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = "" utils.log("DEBUG"," ***** preProcessSDNCAssign *****", isDebugEnabled) @@ -417,7 +435,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ public void preProcessSDNCCreate(Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = "" utils.log("DEBUG"," ***** preProcessSDNCCreate *****", isDebugEnabled) @@ -447,7 +465,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ public void preProcessSDNCActivate(Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = "" utils.log("DEBUG"," ***** preProcessSDNCActivate *****", isDebugEnabled) @@ -477,7 +495,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ public void validateSDNCResp(Execution execution, String response, String method){ - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugLogEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG", " *** ValidateSDNCResponse Process*** ", isDebugLogEnabled) String msg = "" @@ -516,7 +534,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ } public void preProcessSDNCGet(Execution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugLogEnabled = execution.getVariable(DebugFlag) utils.log("DEBUG", "*** preProcessSDNCGet *** ", isDebugLogEnabled) try{ @@ -576,7 +594,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ } public void updateAaiAROrchStatus(Execution execution, String status){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) utils.log("DEBUG", " *** updateAaiAROrchStatus *** ", isDebugEnabled) String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) or create AllottedResourceUtils arUtils = new AllottedResourceUtils(this) @@ -586,7 +604,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ public void generateOutputs(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG"," ***** generateOutputs ***** ", isDebugEnabled) try { String sdncGetResponse = execution.getVariable("enhancedCallbackRequestData") //unescaped @@ -608,7 +626,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ } public void preProcessRollback (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG"," ***** preProcessRollback ***** ", isDebugEnabled) try { @@ -629,7 +647,7 @@ public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ } public void postProcessRollback (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG"," ***** postProcessRollback ***** ", isDebugEnabled) String msg = "" try { diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy similarity index 86% rename from bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy rename to bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy index 0e0f5c2035..c26b14e57c 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy @@ -1,5 +1,21 @@ /* - * © 2016 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.vcpe.scripts; @@ -37,12 +53,14 @@ import static org.apache.commons.lang3.StringUtils.* */ public class DoCreateAllottedResourceBRGRollback extends AbstractServiceTaskProcessor{ + private static final String DebugFlag = "isDebugLogEnabled" + String Prefix="DCARBRGRB_" ExceptionUtil exceptionUtil = new ExceptionUtil() public void preProcessRequest (Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = "" utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled) execution.setVariable("prefix", Prefix) @@ -114,7 +132,7 @@ public class DoCreateAllottedResourceBRGRollback extends AbstractServiceTaskProc // aaiARPath set during query (existing AR) public void updateAaiAROrchStatus(Execution execution, String status){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = null; utils.log("DEBUG", " *** updateAaiAROrchStatus ***", isDebugEnabled) AllottedResourceUtils arUtils = new AllottedResourceUtils(this) @@ -137,7 +155,7 @@ public class DoCreateAllottedResourceBRGRollback extends AbstractServiceTaskProc public void validateSDNCResp(Execution execution, String response, String method){ - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugLogEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG", " *** ValidateSDNCResponse Process*** ", isDebugLogEnabled) String msg = "" @@ -160,24 +178,24 @@ public class DoCreateAllottedResourceBRGRollback extends AbstractServiceTaskProc throw new BpmnError("MSOWorkflowException") } } catch (BpmnError e) { - if (e.getErrorCode() == 404) + if ("404".contentEquals(e.getErrorCode())) { msg = "SDNC rollback " + method + " returned a 404. Proceding with rollback" - utils.log("DEBUG", msg, isDebugEnabled) + utils.log("DEBUG", msg, isDebugLogEnabled) } else { throw e; } } catch(Exception ex) { msg = "Exception in validateSDNCResp. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) + utils.log("DEBUG", msg, isDebugLogEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } logDebug(" *** Exit ValidateSDNCResp Process*** ", isDebugLogEnabled) } public void deleteAaiAR(Execution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugLogEnabled = execution.getVariable(DebugFlag) try{ utils.log("DEBUG", " *** deleteAaiAR *** ", isDebugLogEnabled) AllottedResourceUtils arUtils = new AllottedResourceUtils(this) @@ -198,7 +216,7 @@ public class DoCreateAllottedResourceBRGRollback extends AbstractServiceTaskProc } public void postProcessRequest(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG"," ***** postProcessRequest ***** ", isDebugEnabled) String msg = "" try { @@ -222,7 +240,7 @@ public class DoCreateAllottedResourceBRGRollback extends AbstractServiceTaskProc } public void processRollbackException(Execution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG"," ***** processRollbackException ***** ", isDebugEnabled) try{ utils.log("DEBUG", "Caught an Exception in DoCreateAllottedResourceRollback", isDebugEnabled) @@ -241,7 +259,7 @@ public class DoCreateAllottedResourceBRGRollback extends AbstractServiceTaskProc } public void processRollbackJavaException(Execution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG"," ***** processRollbackJavaException ***** ", isDebugEnabled) try{ execution.setVariable("rollbackData", null) diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/DoCreateAllottedResourceTXC.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy similarity index 92% rename from bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/DoCreateAllottedResourceTXC.groovy rename to bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy index 28f3d6a771..8774effff9 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/DoCreateAllottedResourceTXC.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy @@ -1,5 +1,21 @@ /* - * © 2016 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.vcpe.scripts; @@ -49,13 +65,15 @@ import static org.apache.commons.lang3.StringUtils.* */ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{ + private static final String DebugFlag = "isDebugLogEnabled" + String Prefix="DCARTXC_" ExceptionUtil exceptionUtil = new ExceptionUtil() JsonUtils jsonUtil = new JsonUtils() public void preProcessRequest (Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = "" utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled) @@ -116,7 +134,7 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{ public void getAaiAR (Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) utils.log("DEBUG"," ***** getAaiAR ***** ", isDebugEnabled) String arType = execution.getVariable("allottedResourceType") @@ -154,7 +172,7 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{ public void createAaiAR(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG"," ***** createAaiAR ***** ", isDebugEnabled) String msg = "" @@ -276,7 +294,7 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{ public String buildSDNCRequest(Execution execution, String action, String sdncRequestId) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = "" utils.log("DEBUG"," ***** buildSDNCRequest *****", isDebugEnabled) String sdncReq = null @@ -375,7 +393,7 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{ public void preProcessSDNCAssign(Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = "" utils.log("DEBUG"," ***** preProcessSDNCAssign *****", isDebugEnabled) @@ -405,7 +423,7 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{ public void preProcessSDNCCreate(Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = "" utils.log("DEBUG"," ***** preProcessSDNCCreate *****", isDebugEnabled) @@ -435,7 +453,7 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{ public void preProcessSDNCActivate(Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = "" utils.log("DEBUG"," ***** preProcessSDNCActivate *****", isDebugEnabled) @@ -465,7 +483,7 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{ public void validateSDNCResp(Execution execution, String response, String method){ - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugLogEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG", " *** ValidateSDNCResponse Process*** ", isDebugLogEnabled) String msg = "" @@ -497,14 +515,14 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{ throw e; } catch(Exception ex) { msg = "Exception in validateSDNCResp. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) + utils.log("DEBUG", msg, isDebugLogEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } logDebug(" *** Exit ValidateSDNCResp Process*** ", isDebugLogEnabled) } public void preProcessSDNCGet(Execution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugLogEnabled = execution.getVariable(DebugFlag) utils.log("DEBUG", "*** preProcessSDNCGet *** ", isDebugLogEnabled) try{ @@ -564,7 +582,7 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{ } public void updateAaiAROrchStatus(Execution execution, String status){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) utils.log("DEBUG", " *** updateAaiAROrchStatus *** ", isDebugEnabled) String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) or create AllottedResourceUtils arUtils = new AllottedResourceUtils(this) @@ -574,7 +592,7 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{ public void generateOutputs(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG"," ***** generateOutputs ***** ", isDebugEnabled) try { String sdncGetResponse = execution.getVariable("enhancedCallbackRequestData") //unescaped @@ -583,11 +601,12 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{ arData = utils.removeXmlNamespaces(arData) String txca = utils.getNodeXml(arData, "tunnelxconn-assignments") + execution.setVariable("vni", utils.getNodeText1(txca, "vni")) + execution.setVariable("vgmuxBearerIP", utils.getNodeText1(txca, "vgmux_bearer_ip")) + execution.setVariable("vgmuxLanIP", utils.getNodeText1(txca, "vgmux_lan_ip")) + String ari = utils.getNodeXml(arData, "allotted-resource-identifiers") execution.setVariable("allotedResourceName", utils.getNodeText1(ari, "allotted-resource-name")) - execution.setVariable("vni", utils.getNodeText1(ari, "vni")) - execution.setVariable("vgmuxBearerIp", utils.getNodeText1(ari, "vgmux_bearer_ip")) - execution.setVariable("vgmuxLanIP", utils.getNodeText1(ari, "vgmux_lan_ip")) } catch (BpmnError e) { utils.log("DEBUG", "BPMN Error in generateOutputs ", isDebugEnabled) } catch(Exception ex) { @@ -599,7 +618,7 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{ } public void preProcessRollback (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG"," ***** preProcessRollback ***** ", isDebugEnabled) try { @@ -620,7 +639,7 @@ public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{ } public void postProcessRollback (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG"," ***** postProcessRollback ***** ", isDebugEnabled) String msg = "" try { diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy similarity index 86% rename from bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy rename to bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy index 142ddde6b5..ff621e5954 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy @@ -1,5 +1,21 @@ /* - * © 2016 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.vcpe.scripts; @@ -37,12 +53,14 @@ import static org.apache.commons.lang3.StringUtils.* */ public class DoCreateAllottedResourceTXCRollback extends AbstractServiceTaskProcessor{ + private static final String DebugFlag = "isDebugLogEnabled" + String Prefix="DCARTXCRB_" ExceptionUtil exceptionUtil = new ExceptionUtil() public void preProcessRequest (Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = "" utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled) execution.setVariable("prefix", Prefix) @@ -114,7 +132,7 @@ public class DoCreateAllottedResourceTXCRollback extends AbstractServiceTaskProc // aaiARPath set during query (existing AR) public void updateAaiAROrchStatus(Execution execution, String status){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = null; utils.log("DEBUG", " *** updateAaiAROrchStatus ***", isDebugEnabled) AllottedResourceUtils arUtils = new AllottedResourceUtils(this) @@ -137,7 +155,7 @@ public class DoCreateAllottedResourceTXCRollback extends AbstractServiceTaskProc public void validateSDNCResp(Execution execution, String response, String method){ - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugLogEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG", " *** ValidateSDNCResponse Process*** ", isDebugLogEnabled) String msg = "" @@ -160,24 +178,24 @@ public class DoCreateAllottedResourceTXCRollback extends AbstractServiceTaskProc throw new BpmnError("MSOWorkflowException") } } catch (BpmnError e) { - if (e.getErrorCode() == 404) + if ("404".contentEquals(e.getErrorCode())) { msg = "SDNC rollback " + method + " returned a 404. Proceding with rollback" - utils.log("DEBUG", msg, isDebugEnabled) + utils.log("DEBUG", msg, isDebugLogEnabled) } else { throw e; } } catch(Exception ex) { msg = "Exception in validateSDNCResp. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) + utils.log("DEBUG", msg, isDebugLogEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } logDebug(" *** Exit ValidateSDNCResp Process*** ", isDebugLogEnabled) } public void deleteAaiAR(Execution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugLogEnabled = execution.getVariable(DebugFlag) try{ utils.log("DEBUG", " *** deleteAaiAR *** ", isDebugLogEnabled) AllottedResourceUtils arUtils = new AllottedResourceUtils(this) @@ -198,7 +216,7 @@ public class DoCreateAllottedResourceTXCRollback extends AbstractServiceTaskProc } public void postProcessRequest(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG"," ***** postProcessRequest ***** ", isDebugEnabled) String msg = "" try { @@ -222,7 +240,7 @@ public class DoCreateAllottedResourceTXCRollback extends AbstractServiceTaskProc } public void processRollbackException(Execution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG"," ***** processRollbackException ***** ", isDebugEnabled) try{ utils.log("DEBUG", "Caught an Exception in DoCreateAllottedResourceRollback", isDebugEnabled) @@ -241,7 +259,7 @@ public class DoCreateAllottedResourceTXCRollback extends AbstractServiceTaskProc } public void processRollbackJavaException(Execution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG"," ***** processRollbackJavaException ***** ", isDebugEnabled) try{ execution.setVariable("rollbackData", null) diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy similarity index 88% rename from bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy rename to bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy index 9dbca8664b..bfdccc80a1 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy @@ -1,5 +1,21 @@ /* - * © 2016 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.vcpe.scripts; @@ -41,12 +57,14 @@ import static org.apache.commons.lang3.StringUtils.* */ public class DoDeleteAllottedResourceBRG extends AbstractServiceTaskProcessor{ + private static final String DebugFlag = "isDebugLogEnabled" + String Prefix="DDARBRG_" ExceptionUtil exceptionUtil = new ExceptionUtil() public void preProcessRequest (Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = "" utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled) @@ -88,7 +106,7 @@ public class DoDeleteAllottedResourceBRG extends AbstractServiceTaskProcessor{ public void getAaiAR (Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) utils.log("DEBUG"," ***** getAaiAR ***** ", isDebugEnabled) String allottedResourceId = execution.getVariable("allottedResourceId") @@ -117,7 +135,7 @@ public class DoDeleteAllottedResourceBRG extends AbstractServiceTaskProcessor{ // aaiARPath set during query (existing AR) public void updateAaiAROrchStatus(Execution execution, String status){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) utils.log("DEBUG", " *** updateAaiAROrchStatus *** ", isDebugEnabled) AllottedResourceUtils arUtils = new AllottedResourceUtils(this) String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) @@ -127,7 +145,7 @@ public class DoDeleteAllottedResourceBRG extends AbstractServiceTaskProcessor{ public String buildSDNCRequest(Execution execution, String action, String sdncRequestId) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = "" utils.log("DEBUG"," ***** buildSDNCRequest *****", isDebugEnabled) String sdncReq = null @@ -213,7 +231,7 @@ public class DoDeleteAllottedResourceBRG extends AbstractServiceTaskProcessor{ public void preProcessSDNCUnassign(Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = "" utils.log("DEBUG"," ***** preProcessSDNCUnassign *****", isDebugEnabled) @@ -234,7 +252,7 @@ public class DoDeleteAllottedResourceBRG extends AbstractServiceTaskProcessor{ public void preProcessSDNCDelete(Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = "" utils.log("DEBUG"," ***** preProcessSDNCDelete *****", isDebugEnabled) @@ -255,7 +273,7 @@ public class DoDeleteAllottedResourceBRG extends AbstractServiceTaskProcessor{ public void preProcessSDNCDeactivate(Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = "" utils.log("DEBUG"," ***** preProcessSDNCDeactivate *****", isDebugEnabled) @@ -276,7 +294,7 @@ public class DoDeleteAllottedResourceBRG extends AbstractServiceTaskProcessor{ public void validateSDNCResp(Execution execution, String response, String method){ - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugLogEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG", " *** ValidateSDNCResponse Process*** ", isDebugLogEnabled) String msg = "" @@ -302,7 +320,7 @@ public class DoDeleteAllottedResourceBRG extends AbstractServiceTaskProcessor{ if ("true".equals(execution.getVariable("failNotFound"))) { msg = "Allotted Resource Not found in SDNC" - utils.log("DEBUG", msg, isDebugEnabled) + utils.log("DEBUG", msg, isDebugLogEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } else @@ -319,14 +337,14 @@ public class DoDeleteAllottedResourceBRG extends AbstractServiceTaskProcessor{ throw e; } catch(Exception ex) { msg = "Exception in validateSDNCResp. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) + utils.log("DEBUG", msg, isDebugLogEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } logDebug(" *** Exit ValidateSDNCResp Process*** ", isDebugLogEnabled) } public void deleteAaiAR(Execution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugLogEnabled = execution.getVariable(DebugFlag) try{ utils.log("DEBUG", " *** deleteAaiAR *** ", isDebugLogEnabled) AllottedResourceUtils arUtils = new AllottedResourceUtils(this) diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy similarity index 88% rename from bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy rename to bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy index a66e88852b..1f729ac05d 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy @@ -1,5 +1,21 @@ /* - * © 2016 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.vcpe.scripts; @@ -41,12 +57,14 @@ import static org.apache.commons.lang3.StringUtils.* */ public class DoDeleteAllottedResourceTXC extends AbstractServiceTaskProcessor{ + private static final String DebugFlag = "isDebugLogEnabled" + String Prefix="DDARTXC_" ExceptionUtil exceptionUtil = new ExceptionUtil() public void preProcessRequest (Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = "" utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled) @@ -88,7 +106,7 @@ public class DoDeleteAllottedResourceTXC extends AbstractServiceTaskProcessor{ public void getAaiAR (Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) utils.log("DEBUG"," ***** getAaiAR ***** ", isDebugEnabled) String allottedResourceId = execution.getVariable("allottedResourceId") @@ -117,7 +135,7 @@ public class DoDeleteAllottedResourceTXC extends AbstractServiceTaskProcessor{ // aaiARPath set during query (existing AR) public void updateAaiAROrchStatus(Execution execution, String status){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) utils.log("DEBUG", " *** updateAaiAROrchStatus *** ", isDebugEnabled) AllottedResourceUtils arUtils = new AllottedResourceUtils(this) String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) @@ -127,7 +145,7 @@ public class DoDeleteAllottedResourceTXC extends AbstractServiceTaskProcessor{ public String buildSDNCRequest(Execution execution, String action, String sdncRequestId) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = "" utils.log("DEBUG"," ***** buildSDNCRequest *****", isDebugEnabled) String sdncReq = null @@ -213,7 +231,7 @@ public class DoDeleteAllottedResourceTXC extends AbstractServiceTaskProcessor{ public void preProcessSDNCUnassign(Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = "" utils.log("DEBUG"," ***** preProcessSDNCUnassign *****", isDebugEnabled) @@ -234,7 +252,7 @@ public class DoDeleteAllottedResourceTXC extends AbstractServiceTaskProcessor{ public void preProcessSDNCDelete(Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = "" utils.log("DEBUG"," ***** preProcessSDNCDelete *****", isDebugEnabled) @@ -255,7 +273,7 @@ public class DoDeleteAllottedResourceTXC extends AbstractServiceTaskProcessor{ public void preProcessSDNCDeactivate(Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugEnabled = execution.getVariable(DebugFlag) String msg = "" utils.log("DEBUG"," ***** preProcessSDNCDeactivate *****", isDebugEnabled) @@ -276,7 +294,7 @@ public class DoDeleteAllottedResourceTXC extends AbstractServiceTaskProcessor{ public void validateSDNCResp(Execution execution, String response, String method){ - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") + def isDebugLogEnabled=execution.getVariable(DebugFlag) utils.log("DEBUG", " *** ValidateSDNCResponse Process*** ", isDebugLogEnabled) String msg = "" @@ -302,7 +320,7 @@ public class DoDeleteAllottedResourceTXC extends AbstractServiceTaskProcessor{ if ("true".equals(execution.getVariable("failNotFound"))) { msg = "Allotted Resource Not found in SDNC" - utils.log("DEBUG", msg, isDebugEnabled) + utils.log("DEBUG", msg, isDebugLogEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } else @@ -319,14 +337,14 @@ public class DoDeleteAllottedResourceTXC extends AbstractServiceTaskProcessor{ throw e; } catch(Exception ex) { msg = "Exception in validateSDNCResp. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) + utils.log("DEBUG", msg, isDebugLogEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } logDebug(" *** Exit ValidateSDNCResp Process*** ", isDebugLogEnabled) } public void deleteAaiAR(Execution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + def isDebugLogEnabled = execution.getVariable(DebugFlag) try{ utils.log("DEBUG", " *** deleteAaiAR *** ", isDebugLogEnabled) AllottedResourceUtils arUtils = new AllottedResourceUtils(this) diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/vcpe/workflow/WorkflowAsyncVcpeResource.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/vcpe/workflow/WorkflowAsyncVcpeResource.java index b11a1d022d..f1224da30c 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/vcpe/workflow/WorkflowAsyncVcpeResource.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/vcpe/workflow/WorkflowAsyncVcpeResource.java @@ -1,4 +1,4 @@ -/*- +/* * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.mso.bpmn.vcpe.workflow; import javax.ws.rs.Path; @@ -39,9 +38,8 @@ import org.openecomp.mso.bpmn.common.workflow.service.WorkflowAsyncResource; */ @Path("/async") public class WorkflowAsyncVcpeResource extends WorkflowAsyncResource { - - @Override + protected ProcessEngineServices getProcessEngineServices() { - return pes4junit.orElse(ProcessEngines.getProcessEngine("vcpe")); + return pes4junit.orElse(ProcessEngines.getProcessEngine("vcpe")); } } diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVcpeResCustService.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVcpeResCustService.bpmn index c893690f79..02f7f4815a 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVcpeResCustService.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVcpeResCustService.bpmn @@ -164,7 +164,7 @@ CreateVcpeResCustService.prepareFalloutRequest(execution)]]> - + @@ -221,8 +221,8 @@ CreateVcpeResCustService.postProcessRollback(execution)]]> - - + + SequenceFlow_0orpdrl SequenceFlow_1t3cnnx @@ -254,7 +254,7 @@ CreateVcpeResCustService.postProcessRollback(execution)]]> SequenceFlow_0dr2fem - + @@ -263,7 +263,7 @@ CreateVcpeResCustService.postProcessRollback(execution)]]> SequenceFlow_1mbymcu - + @@ -291,8 +291,8 @@ CreateVcpeResCustService.postProcessRollback(execution)]]> - - + + SequenceFlow_1sl79hn SequenceFlow_0ne9n0g @@ -300,7 +300,7 @@ CreateVcpeResCustService.postProcessRollback(execution)]]> - + SequenceFlow_0ne9n0g SequenceFlow_00by7l7 SequenceFlow_17cz98f @@ -311,13 +311,13 @@ CreateVcpeResCustService.postProcessRollback(execution)]]> - + - + @@ -369,7 +369,7 @@ CreateVcpeResCustService.prepareCreateServiceInstance(execution)]]>SequenceFlow_13uceka - + SequenceFlow_1ky2sv9 SequenceFlow_0vj46ej - SequenceFlow_17g05fd + SequenceFlow_11efpvh SequenceFlow_1jbuf1t - + SequenceFlow_15vce9o @@ -542,7 +542,7 @@ CreateVcpeResCustService.prepareCreateAllottedResourceBRG(execution)]]> SequenceFlow_0p75l97 SequenceFlow_0ws7fjn - @@ -560,12 +560,12 @@ CreateVcpeResCustService.prepareVnfAndModulesCreate(execution)]]> SequenceFlow_13iuk3s - SequenceFlow_1mkdhw9 SequenceFlow_13iuk3s + SequenceFlow_0k5vcuu SequenceFlow_1ufio7c - + in 1702 scope only one VNF will be created @@ -600,6 +600,22 @@ CreateVcpeResCustService.prepareVnfAndModulesCreate(execution)]]> SequenceFlow_1cgpklo + + SequenceFlow_17g05fd + SequenceFlow_11efpvh + + + + + SequenceFlow_1mkdhw9 + SequenceFlow_0k5vcuu + + + @@ -730,82 +746,82 @@ CreateVcpeResCustService.prepareVnfAndModulesCreate(execution)]]> - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - - - + + + - + - - - - + + + + - + - - + + - + - - - - + + + + - + @@ -830,41 +846,41 @@ CreateVcpeResCustService.prepareVnfAndModulesCreate(execution)]]> - + - + - + - - + + - + - - - + + + - + - - + + - + - - + + - + @@ -881,17 +897,17 @@ CreateVcpeResCustService.prepareVnfAndModulesCreate(execution)]]> - + - + - - - + + + - + @@ -922,31 +938,31 @@ CreateVcpeResCustService.prepareVnfAndModulesCreate(execution)]]> - + - - - - + + + + - + - + - + - + - - + + - + @@ -986,42 +1002,42 @@ CreateVcpeResCustService.prepareVnfAndModulesCreate(execution)]]> - + - + - + - + - + - - - + + + - + - - + + - + - - - - + + + + - + @@ -1061,63 +1077,63 @@ CreateVcpeResCustService.prepareVnfAndModulesCreate(execution)]]> - + - + - + - + - - + + - + - + - + - - + + - + - - - + + + - + - + - + - - + + - + - - + + - + @@ -1140,85 +1156,85 @@ CreateVcpeResCustService.prepareVnfAndModulesCreate(execution)]]> - + - + - + - + - + - + - + - - + + - + - - + + - + - + - + - - - + + + - + - - + + - + - - - - + + + + - + - - + + - + - - - + + + - + @@ -1313,10 +1329,10 @@ CreateVcpeResCustService.prepareVnfAndModulesCreate(execution)]]> - + - + @@ -1343,28 +1359,25 @@ CreateVcpeResCustService.prepareVnfAndModulesCreate(execution)]]> - - - - + + - + - - - + + - + - + - + @@ -1391,69 +1404,68 @@ CreateVcpeResCustService.prepareVnfAndModulesCreate(execution)]]> - + - - - - + + + + - + - + - + - - + + - + - - + + - + - - - + + + - + - - - + + - + - + - - + + - + - - - + + + - + @@ -1467,6 +1479,27 @@ CreateVcpeResCustService.prepareVnfAndModulesCreate(execution)]]> + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteVcpeResCustService.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteVcpeResCustService.bpmn index 39fcd66c60..38e1d43910 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteVcpeResCustService.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteVcpeResCustService.bpmn @@ -22,9 +22,9 @@ DeleteVcpeResCustService.preProcessRequest(execution) ]]> - + SequenceFlow_10o22u2 - + SequenceFlow_12ilko1 @@ -38,7 +38,7 @@ DeleteVcpeResCustService.postProcessResponse(execution)]]> - + @@ -73,8 +73,8 @@ execution.setVariable("DeleteVcpeResCustServiceSuccessIndicator", true)]]>SequenceFlow_2 SequenceFlow_5 +def DeleteVcpeResCustService = new DeleteVcpeResCustService() +DeleteVcpeResCustService.processJavaException(execution)]]> @@ -108,7 +108,7 @@ DeleteServiceInstanceInfra.processJavaException(execution)]]> - + @@ -185,9 +185,9 @@ DeleteVcpeResCustService.prepareServiceDelete(execution)]]> SequenceFlow_05cjs89 SequenceFlow_0snq0kw - + SequenceFlow_0zaircn - + SequenceFlow_09i2jj0 @@ -214,7 +214,7 @@ DeleteVcpeResCustService.prepareServiceDelete(execution)]]> SequenceFlow_0zaircn - + @@ -223,7 +223,7 @@ DeleteVcpeResCustService.prepareServiceDelete(execution)]]> - + @@ -261,9 +261,9 @@ DeleteVcpeResCustService.prepareServiceDelete(execution)]]> SequenceFlow_1yamcyn SequenceFlow_19cxgtm SequenceFlow_128485i - + SequenceFlow_1lfph6u @@ -286,9 +286,9 @@ DeleteGenericMacroServiceNetworkVnf.prepareVnfAndModulesDelete(execution)]]> SequenceFlow_04fys47 SequenceFlow_1o5cutr - + SequenceFlow_1o5cutr @@ -298,10 +298,10 @@ DeleteGenericMacroServiceNetworkVnf.validateVnfDelete(execution)]]> - 0}]]> + 0}]]> - + @@ -748,7 +748,7 @@ DeleteGenericMacroServiceNetworkVnf.validateVnfDelete(execution)]]> - + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateAllottedResourceBRG.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateAllottedResourceBRG.bpmn index c1cb102e47..a35371e97c 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateAllottedResourceBRG.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateAllottedResourceBRG.bpmn @@ -16,7 +16,7 @@ dcar.preProcessRequest(execution)]]> notFound SequenceFlow_6 - @@ -207,7 +207,7 @@ dcar.validateSDNCResp(execution, response, "activate" )]]> SequenceFlow_0f7u5pu SequenceFlow_16o7col - - + SequenceFlow_1 @@ -55,7 +55,6 @@ rbk.validateSDNCResp(execution, response, "deactivate" )]]> SequenceFlow_0eb41vb - SequenceFlow_149adfw SequenceFlow_0sh1u69 SequenceFlow_1s7yieq - SequenceFlow_041l824 SequenceFlow_00i7x43 SequenceFlow_00i7x43 SequenceFlow_13mhe5h + SequenceFlow_0m483td SequenceFlow_03bkrg4 SequenceFlow_0c5h00o + SequenceFlow_0dzz8fp SequenceFlow_0m483rd SequenceFlow_0m483st @@ -143,7 +143,7 @@ rbk.updateAaiAROrchStatus(execution, "PendingDelete")]]> - + @@ -175,6 +175,7 @@ rbk.postProcessRequest(execution)]]> SequenceFlow_0sh1u69 + SequenceFlow_0m483st SequenceFlow_04hdt5s SequenceFlow_0m483td @@ -195,11 +196,7 @@ rbk.postProcessRequest(execution)]]> SequenceFlow_0xm9g9s - - SequenceFlow_0m483td - - - + SequenceFlow_13mhe5h @@ -222,25 +219,7 @@ rbk.postProcessRequest(execution)]]> - - - SequenceFlow_0dzz8fp - - - - SequenceFlow_0m483st - - - - SequenceFlow_149adfw - - - - SequenceFlow_041l824 - - - - + @@ -413,11 +392,12 @@ rbk.postProcessRequest(execution)]]> - - - + + + + - + @@ -522,17 +502,13 @@ rbk.postProcessRequest(execution)]]> - - - - - - - + + + - + @@ -587,47 +563,11 @@ rbk.postProcessRequest(execution)]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateAllottedResourceTXC.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateAllottedResourceTXC.bpmn index 7978ea6220..178534f797 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateAllottedResourceTXC.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateAllottedResourceTXC.bpmn @@ -16,7 +16,7 @@ dcar.preProcessRequest(execution)]]> notFound SequenceFlow_6 - @@ -207,7 +207,7 @@ dcar.validateSDNCResp(execution, response, "activate" )]]> SequenceFlow_0f7u5pu SequenceFlow_16o7col - - + SequenceFlow_1 @@ -55,7 +55,6 @@ rbk.validateSDNCResp(execution, response, "deactivate" )]]> SequenceFlow_0eb41vb - SequenceFlow_149adfw SequenceFlow_0sh1u69 SequenceFlow_1s7yieq - SequenceFlow_041l824 SequenceFlow_00i7x43 SequenceFlow_00i7x43 SequenceFlow_13mhe5h + SequenceFlow_0m483td SequenceFlow_03bkrg4 SequenceFlow_0c5h00o + SequenceFlow_0dzz8fp SequenceFlow_0m483rd SequenceFlow_0m483st @@ -143,7 +143,7 @@ rbk.updateAaiAROrchStatus(execution, "PendingDelete")]]> - + @@ -175,6 +175,7 @@ rbk.postProcessRequest(execution)]]> SequenceFlow_0sh1u69 + SequenceFlow_0m483st SequenceFlow_04hdt5s SequenceFlow_0m483td @@ -195,11 +196,7 @@ rbk.postProcessRequest(execution)]]> SequenceFlow_0xm9g9s - - SequenceFlow_0m483td - - - + SequenceFlow_13mhe5h @@ -222,25 +219,7 @@ rbk.postProcessRequest(execution)]]> - - - SequenceFlow_0dzz8fp - - - - SequenceFlow_0m483st - - - - SequenceFlow_149adfw - - - - SequenceFlow_041l824 - - - - + @@ -413,11 +392,12 @@ rbk.postProcessRequest(execution)]]> - - - + + + + - + @@ -522,17 +502,13 @@ rbk.postProcessRequest(execution)]]> - - - - - - - + + + - + @@ -587,47 +563,11 @@ rbk.postProcessRequest(execution)]]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - + 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 new file mode 100644 index 0000000000..c5eff73084 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy @@ -0,0 +1,1198 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.vcpe.scripts + + +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution +import org.junit.Before +import org.junit.BeforeClass +import org.junit.Rule +import org.junit.Test +import org.junit.Ignore +import org.mockito.MockitoAnnotations +import org.camunda.bpm.engine.delegate.BpmnError +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.mock.FileUtil + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse +import static com.github.tomakehurst.wiremock.client.WireMock.get +import static com.github.tomakehurst.wiremock.client.WireMock.patch +import static com.github.tomakehurst.wiremock.client.WireMock.put +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching +import static org.junit.Assert.*; +import static org.mockito.Mockito.* +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource +import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition +import org.openecomp.mso.bpmn.core.domain.VnfResource +import org.openecomp.mso.bpmn.core.domain.AllottedResource +import org.openecomp.mso.bpmn.core.domain.ModelInfo +import org.openecomp.mso.bpmn.core.domain.HomingSolution +import org.openecomp.mso.bpmn.core.RollbackData +import org.openecomp.mso.bpmn.vcpe.scripts.MapGetter +import org.openecomp.mso.bpmn.vcpe.scripts.MapSetter + +import com.github.tomakehurst.wiremock.junit.WireMockRule + +class CreateVcpeResCustServiceTest extends GroovyTestBase { + + private static String request + + @Rule + public WireMockRule wireMockRule = new WireMockRule(PORT) + + String Prefix = "CVRCS_" + String RbType = "DCRENI_" + + @BeforeClass + public static void setUpBeforeClass() { + super.setUpBeforeClass() + request = FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/request.json") + } + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + public CreateVcpeResCustServiceTest() { + super("CreateVcpeResCustService") + } + + + // ***** preProcessRequest ***** + + @Test +// @Ignore + public void preProcessRequest() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("createVcpeServiceRequest", request) + verify(mex).setVariable("msoRequestId", "mri") + assertEquals("sii", map.get("serviceInstanceId")) + verify(mex).setVariable("requestAction", "ra") + verify(mex).setVariable("source", "VID") + verify(mex).setVariable("globalSubscriberId", CUST) + verify(mex).setVariable("globalCustomerId", CUST) + verify(mex).setVariable("subscriptionServiceType", SVC) + verify(mex).setVariable("disableRollback", "false") + verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") + assertTrue(map.containsKey("subscriberInfo")) + + verify(mex).setVariable("brgWanMacAddress", "brgmac") + assertTrue(map.containsKey("serviceInputParams")) + assertTrue(map.containsKey(Prefix+"requestInfo")) + + def reqinfo = map.get(Prefix+"requestInfo") + assertTrue(reqinfo.indexOf("mri= 0) + assertTrue(reqinfo.indexOf("VID= 0) + } + + @Test +// @Ignore + public void preProcessRequest_EmptyParts() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + + def req = request + .replace('"source"', '"sourceXXX"') + .replace('"BRG_WAN_MAC_Address"', '"BRG_WAN_MAC_AddressXXX"') + + when(mex.getVariable("bpmnRequest")).thenReturn(req) + when(mex.getVariable("serviceInstanceId")).thenReturn(null) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("createVcpeServiceRequest", req) + verify(mex).setVariable("msoRequestId", "mri") + assertNotNull(map.get("serviceInstanceId")) + assertFalse(map.get("serviceInstanceId").isEmpty()) + verify(mex).setVariable("requestAction", "ra") + verify(mex).setVariable("source", "VID") + verify(mex).setVariable("globalSubscriberId", CUST) + verify(mex).setVariable("globalCustomerId", CUST) + verify(mex).setVariable("subscriptionServiceType", SVC) + verify(mex).setVariable("disableRollback", "false") + verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") + assertTrue(map.containsKey("subscriberInfo")) + + assertEquals("", map.get("brgWanMacAddress")) + assertTrue(map.containsKey("serviceInputParams")) + assertTrue(map.containsKey(Prefix+"requestInfo")) + + def reqinfo = map.get(Prefix+"requestInfo") + println reqinfo + assertTrue(reqinfo.indexOf("mri= 0) + assertTrue(reqinfo.indexOf("VID= 0) + } + + @Test +// @Ignore + public void preProcessRequest_MissingSubscriberId() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + + def req = request + .replace('"globalSubscriberId"', '"globalSubscriberIdXXX"') + + when(mex.getVariable("bpmnRequest")).thenReturn(req) + when(mex.getVariable("serviceInstanceId")).thenReturn(null) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.preProcessRequest(mex) })) + } + + @Test +// @Ignore + public void preProcessRequest_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("bpmnRequest")).thenThrow(new BpmnError("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.preProcessRequest(mex) })) + } + + @Test +// @Ignore + public void preProcessRequest_Ex() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("bpmnRequest")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.preProcessRequest(mex) })) + } + + // ***** sendSyncResponse ***** + + @Test +// @Ignore + public void sendSyncResponse() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initSendSyncResponse(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.sendSyncResponse(mex) + + verify(mex, times(2)).getVariable(DBGFLAG) + + verify(mex).setVariable(processName+"WorkflowResponseSent", "true") + + assertEquals("202", map.get(processName+"ResponseCode")) + assertEquals("Success", map.get(processName+"Status")) + + def resp = map.get(processName+"Response") + + assertTrue(resp.indexOf('"instanceId":"sii"') >= 0) + assertTrue(resp.indexOf('"requestId":"mri"') >= 0) + } + + @Test +// @Ignore + public void sendSyncResponse_Ex() { + ExecutionEntity mex = setupMock() + initSendSyncResponse(mex) + + when(mex.getVariable("serviceInstanceId")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.sendSyncResponse(mex) })) + } + + + // ***** prepareDecomposeService ***** + + @Test +// @Ignore + public void prepareDecomposeService() { + ExecutionEntity mex = setupMock() + initPrepareDecomposeService(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.prepareDecomposeService(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("serviceModelInfo", "mi") + } + + @Test +// @Ignore + public void prepareDecomposeService_Ex() { + ExecutionEntity mex = setupMock() + initPrepareDecomposeService(mex) + + when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareDecomposeService(mex) })) + } + + + // ***** prepareCreateServiceInstance ***** + + @Test +// @Ignore + public void prepareCreateServiceInstance() { + ExecutionEntity mex = setupMock() + initPrepareCreateServiceInstance(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.prepareCreateServiceInstance(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("serviceInstanceName", "VCPE1") + verify(mex).setVariable("serviceDecompositionString", "mydecomp") + } + + @Test +// @Ignore + public void prepareCreateServiceInstance_Ex() { + ExecutionEntity mex = setupMock() + initPrepareCreateServiceInstance(mex) + + when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareCreateServiceInstance(mex) })) + } + + + // ***** postProcessServiceInstanceCreate ***** + + @Test +// @Ignore + public void postProcessServiceInstanceCreate() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPostProcessServiceInstanceCreate(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.postProcessServiceInstanceCreate(mex) + + verify(mex).getVariable(DBGFLAG) + + def reqinfo = map.get(Prefix+"setUpdateDbInstancePayload") + + assertTrue(reqinfo.indexOf("mri= 0) + assertTrue(reqinfo.indexOf("sii= 0) + assertTrue(reqinfo.indexOf("sin= 0) + } + + @Test +// @Ignore + public void postProcessServiceInstanceCreate_BpmnError() { + ExecutionEntity mex = setupMock() + initPostProcessServiceInstanceCreate(mex) + + doThrow(new BpmnError("expected exception")).when(mex).setVariable(endsWith("setUpdateDbInstancePayload"), any()) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessServiceInstanceCreate(mex) })) + } + + @Test +// @Ignore + public void postProcessServiceInstanceCreate_Ex() { + ExecutionEntity mex = setupMock() + initPostProcessServiceInstanceCreate(mex) + + doThrow(new RuntimeException("expected exception")).when(mex).setVariable(endsWith("setUpdateDbInstancePayload"), any()) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessServiceInstanceCreate(mex) })) + } + + + // ***** processDecomposition ***** + + @Test +// @Ignore + public void processDecomposition() { + ExecutionEntity mex = setupMock() + def svcdecomp = initProcessDecomposition(mex, true, true) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.processDecomposition(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable("vnfList", svcdecomp.getServiceVnfs()) + verify(mex).setVariable("vnfListString", '[myvnf, myvnf2, myvnf3]') + verify(mex).setVariable(Prefix+"VNFsCount", 3) + + verify(mex).setVariable("vnfModelInfo", "mymodel") + verify(mex).setVariable("vnfModelInfoString", "mymodel") + } + + @Test +// @Ignore + public void processDecomposition_EmptyNet_EmptyVnf() { + ExecutionEntity mex = setupMock() + def svcdecomp = initProcessDecomposition(mex, true, true) + + when(svcdecomp.getServiceVnfs()).thenReturn(new LinkedList()) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.processDecomposition(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable("vnfList", svcdecomp.getServiceVnfs()) + verify(mex).setVariable("vnfListString", '[]') + verify(mex).setVariable(Prefix+"VNFsCount", 0) + + verify(mex).setVariable("vnfModelInfo", "") + verify(mex).setVariable("vnfModelInfoString", "") + } + + @Test +// @Ignore + public void processDecomposition_Ex() { + ExecutionEntity mex = setupMock() + def svcdecomp = initProcessDecomposition(mex, true, true) + + when(svcdecomp.getServiceVnfs()).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.processDecomposition(mex) })) + } + + + // ***** prepareCreateAllottedResourceTXC ***** + + @Test +// @Ignore + public void prepareCreateAllottedResourceTXC() { + ExecutionEntity mex = setupMock() + initPrepareCreateAllottedResourceTXC(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.prepareCreateAllottedResourceTXC(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable("createTXCAR", true) + verify(mex).setVariable("allottedResourceModelInfoTXC", "modelB") + verify(mex).setVariable("allottedResourceRoleTXC", "TXCr") + verify(mex).setVariable("allottedResourceTypeTXC", "TunnelXConn") + verify(mex).setVariable("parentServiceInstanceIdTXC", "homeB") + } + + @Test +// @Ignore + public void prepareCreateAllottedResourceTXC_NullArList() { + ExecutionEntity mex = setupMock() + def svcdecomp = initPrepareCreateAllottedResourceTXC(mex) + + when(svcdecomp.getServiceAllottedResources()).thenReturn(null) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.prepareCreateAllottedResourceTXC(mex) + + verify(mex).getVariable(DBGFLAG) + + 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("parentServiceInstanceIdTXC", "homeB") + } + + @Test +// @Ignore + public void prepareCreateAllottedResourceTXC_Ex() { + ExecutionEntity mex = setupMock() + initPrepareCreateAllottedResourceTXC(mex) + + when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareCreateAllottedResourceTXC(mex) })) + } + + + // ***** prepareCreateAllottedResourceBRG ***** + + @Test +// @Ignore + public void prepareCreateAllottedResourceBRG() { + ExecutionEntity mex = setupMock() + initPrepareCreateAllottedResourceBRG(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.prepareCreateAllottedResourceBRG(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable("createBRGAR", true) + verify(mex).setVariable("allottedResourceModelInfoBRG", "modelB") + verify(mex).setVariable("allottedResourceRoleBRG", "BRGr") + verify(mex).setVariable("allottedResourceTypeBRG", "BRG") + verify(mex).setVariable("parentServiceInstanceIdBRG", "homeB") + } + + @Test +// @Ignore + public void prepareCreateAllottedResourceBRG_NullArList() { + ExecutionEntity mex = setupMock() + def svcdecomp = initPrepareCreateAllottedResourceBRG(mex) + + when(svcdecomp.getServiceAllottedResources()).thenReturn(null) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.prepareCreateAllottedResourceBRG(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex, never()).setVariable("createBRGAR", true) + verify(mex, never()).setVariable("allottedResourceModelInfoBRG", "modelB") + verify(mex, never()).setVariable("allottedResourceRoleBRG", "BRGr") + verify(mex, never()).setVariable("allottedResourceTypeBRG", "BRG") + verify(mex, never()).setVariable("parentServiceInstanceIdBRG", "homeB") + } + + @Test +// @Ignore + public void prepareCreateAllottedResourceBRG_Ex() { + ExecutionEntity mex = setupMock() + initPrepareCreateAllottedResourceBRG(mex) + + when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareCreateAllottedResourceBRG(mex) })) + } + + + // ***** prepareVnfAndModulesCreate ***** + + @Test +// @Ignore + public void prepareVnfAndModulesCreate() { + ExecutionEntity mex = setupMock() + initPrepareVnfAndModulesCreate(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.prepareVnfAndModulesCreate(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") + verify(mex).setVariable("lcpCloudRegionId", "mdt1") + verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba") + } + + @Test +// @Ignore + public void prepareVnfAndModulesCreate_EmptyList() { + ExecutionEntity mex = setupMock() + initPrepareVnfAndModulesCreate(mex) + + when(mex.getVariable("vnfList")).thenReturn(new LinkedList()) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.prepareVnfAndModulesCreate(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") + verify(mex).setVariable("lcpCloudRegionId", "mdt1") + verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba") + } + + @Test +// @Ignore + public void prepareVnfAndModulesCreate_NullList() { + ExecutionEntity mex = setupMock() + initPrepareVnfAndModulesCreate(mex) + + when(mex.getVariable("vnfList")).thenReturn(null) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.prepareVnfAndModulesCreate(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") + verify(mex).setVariable("lcpCloudRegionId", "mdt1") + verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba") + } + + @Test +// @Ignore + public void prepareVnfAndModulesCreate_Ex() { + ExecutionEntity mex = setupMock() + initPrepareVnfAndModulesCreate(mex) + + when(mex.getVariable("vnfList")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareVnfAndModulesCreate(mex) })) + } + + + // ***** validateVnfCreate ***** + + @Test +// @Ignore + public void validateVnfCreate() { + ExecutionEntity mex = setupMock() + initValidateVnfCreate(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.validateVnfCreate(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable(Prefix+"VnfsCreatedCount", 3) + } + + @Test +// @Ignore + public void validateVnfCreate_Ex() { + ExecutionEntity mex = setupMock() + initValidateVnfCreate(mex) + + when(mex.getVariable(Prefix+"VnfsCreatedCount")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.validateVnfCreate(mex) })) + } + + + // ***** postProcessResponse ***** + + @Test +// @Ignore + public void postProcessResponse() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPostProcessResponse(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.postProcessResponse(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable(Prefix+"Success", true) + + def reqinfo = map.get(Prefix+"CompleteMsoProcessRequest") + + assertTrue(reqinfo.indexOf("request-id>mri= 0) + assertTrue(reqinfo.indexOf("source>mysrc= 0) + assertTrue(reqinfo.indexOf("serviceInstanceId>sii= 0) + } + + @Test +// @Ignore + public void postProcessResponse_BpmnError() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPostProcessResponse(mex) + + when(mex.getVariable("source")).thenThrow(new BpmnError("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessResponse(mex) })) + } + + @Test +// @Ignore + public void postProcessResponse_Ex() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPostProcessResponse(mex) + + when(mex.getVariable("source")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessResponse(mex) })) + } + + + // ***** preProcessRollback ***** + + @Test +// @Ignore + public void preProcessRollback() { + ExecutionEntity mex = setupMock() + def wfe = initPreProcessRollback(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.preProcessRollback(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable("prevWorkflowException", wfe) + } + + @Test +// @Ignore + public void preProcessRollback_NullWfe() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def wfe = initPreProcessRollback(mex) + + when(mex.getVariable("WorkflowException")).thenReturn(null) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.preProcessRollback(mex) + + verify(mex).getVariable(DBGFLAG) + + assertFalse(map.containsKey("prevWorkflowException")) + } + + @Test +// @Ignore + public void preProcessRollback_BpmnError() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def wfe = initPreProcessRollback(mex) + + when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.preProcessRollback(mex) + + verify(mex).getVariable(DBGFLAG) + + assertFalse(map.containsKey("prevWorkflowException")) + } + + @Test +// @Ignore + public void preProcessRollback_Ex() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def wfe = initPreProcessRollback(mex) + + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.preProcessRollback(mex) + + verify(mex).getVariable(DBGFLAG) + + assertFalse(map.containsKey("prevWorkflowException")) + } + + + // ***** postProcessRollback ***** + + @Test +// @Ignore + public void postProcessRollback() { + ExecutionEntity mex = setupMock() + def wfe = initPostProcessRollback(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.postProcessRollback(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable("WorkflowException", wfe) + } + + @Test +// @Ignore + public void postProcessRollback_NullWfe() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def wfe = initPostProcessRollback(mex) + + when(mex.getVariable("prevWorkflowException")).thenReturn(null) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.postProcessRollback(mex) + + verify(mex).getVariable(DBGFLAG) + + assertFalse(map.containsKey("WorkflowException")) + } + + @Test +// @Ignore + public void postProcessRollback_BpmnError() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def wfe = initPostProcessRollback(mex) + + when(mex.getVariable("prevWorkflowException")).thenThrow(new BpmnError("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessRollback(mex) })) + } + + @Test +// @Ignore + public void postProcessRollback_Ex() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def wfe = initPostProcessRollback(mex) + + when(mex.getVariable("prevWorkflowException")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.postProcessRollback(mex) + + verify(mex).getVariable(DBGFLAG) + + assertFalse(map.containsKey("WorkflowException")) + } + + + // ***** prepareFalloutRequest ***** + + @Test +// @Ignore + public void prepareFalloutRequest() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPrepareFalloutRequest(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.prepareFalloutRequest(mex) + + verify(mex, times(2)).getVariable(DBGFLAG) + + def fo = map.get(Prefix+"falloutRequest") + + assertTrue(fo.indexOf("world= 0) + assertTrue(fo.indexOf("ErrorMessage>mymsg= 0) + assertTrue(fo.indexOf("ErrorCode>999= 0) + } + + @Test +// @Ignore + public void prepareFalloutRequest_Ex() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPrepareFalloutRequest(mex) + + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareFalloutRequest(mex) })) + } + + // ***** sendSyncError ***** + + @Test +// @Ignore + public void sendSyncError() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initSendSyncError(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.sendSyncError(mex) + + verify(mex, times(2)).getVariable(DBGFLAG) + + verify(mex).setVariable(processName+"WorkflowResponseSent", "true") + + assertEquals("500", map.get(processName+"ResponseCode")) + assertEquals("Fail", map.get(processName+"Status")) + + def resp = map.get(processName+"Response") + + assertTrue(resp.indexOf("ErrorMessage>mymsg= 0) + + verify(mex).setVariable("WorkflowResponse", resp) + } + + @Test +// @Ignore + public void sendSyncError_NotWfe() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initSendSyncError(mex) + + when(mex.getVariable("WorkflowException")).thenReturn("not a WFE") + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.sendSyncError(mex) + + verify(mex, times(2)).getVariable(DBGFLAG) + + verify(mex).setVariable(processName+"WorkflowResponseSent", "true") + + assertEquals("500", map.get(processName+"ResponseCode")) + assertEquals("Fail", map.get(processName+"Status")) + + def resp = map.get(processName+"Response") + + assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.= 0) + + verify(mex).setVariable("WorkflowResponse", resp) + } + + @Test +// @Ignore + public void sendSyncError_NullWfe() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initSendSyncError(mex) + + when(mex.getVariable("WorkflowException")).thenReturn(null) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + CreateVcpeResCustService.sendSyncError(mex) + + verify(mex, times(2)).getVariable(DBGFLAG) + + verify(mex).setVariable(processName+"WorkflowResponseSent", "true") + + assertEquals("500", map.get(processName+"ResponseCode")) + assertEquals("Fail", map.get(processName+"Status")) + + def resp = map.get(processName+"Response") + + assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.= 0) + + verify(mex).setVariable("WorkflowResponse", resp) + } + + @Test +// @Ignore + public void sendSyncError_Ex() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initSendSyncError(mex) + + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + CreateVcpeResCustService.sendSyncError(mex) + + assertFalse(map.containsKey(processName+"ResponseCode")) + } + + + // ***** processJavaException ***** + + @Test +// @Ignore + public void processJavaException() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initProcessJavaException(mex) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.processJavaException(mex) })) + + verify(mex, times(2)).getVariable(DBGFLAG) + + verify(mex).setVariable("prefix", Prefix) + + def wfe = map.get("WorkflowException") + + assertEquals("Caught a Java Lang Exception", wfe.getErrorMessage()) + } + + @Test +// @Ignore + public void processJavaException_BpmnError() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initProcessJavaException(mex) + + when(mex.getVariables()).thenThrow(new BpmnError("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.processJavaException(mex) })) + + assertFalse(map.containsKey("WorkflowException")) + } + + @Test +// @Ignore + public void processJavaException_Ex() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initProcessJavaException(mex) + + when(mex.getVariables()).thenThrow(new RuntimeException("expected exception")) + + CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() + + assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.processJavaException(mex) })) + + def wfe = map.get("WorkflowException") + + assertEquals("Exception in processJavaException method", wfe.getErrorMessage()) + } + + + private void initPreProcess(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("bpmnRequest")).thenReturn(request) + when(mex.getVariable("mso-request-id")).thenReturn("mri") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("requestAction")).thenReturn("ra") + } + + private initSendSyncResponse(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("mso-request-id")).thenReturn("mri") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + } + + private void initPrepareDecomposeService(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("createVcpeServiceRequest")).thenReturn('{"requestDetails":{"modelInfo":"mi"}}') + } + + private void initPrepareCreateServiceInstance(ExecutionEntity mex) { + ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request) + when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp) + + when(svcdecomp.toJsonString()).thenReturn("mydecomp") + } + + private void initPostProcessServiceInstanceCreate(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("mso-request-id")).thenReturn("mri") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("serviceInstanceName")).thenReturn("sin") + } + + private ServiceDecomposition initProcessDecomposition(ExecutionEntity mex, boolean haveNet, boolean haveVnf) { + List vnflst = new LinkedList<>() + if(haveVnf) { + vnflst.add(makeVnf("")) + vnflst.add(makeVnf("2")) + vnflst.add(makeVnf("3")) + } + + ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class) + when(svcdecomp.getServiceVnfs()).thenReturn(vnflst) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp) + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("serviceInstanceName")).thenReturn("sin") + + return svcdecomp + } + + private ServiceDecomposition initPrepareCreateAllottedResourceTXC(ExecutionEntity mex) { + ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class) + List arlst = new LinkedList<>() + + arlst.add(makeArBRG("A")) + arlst.add(makeArTXC("B")) + arlst.add(makeArBRG("C")) + + when(svcdecomp.getServiceAllottedResources()).thenReturn(arlst) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request) + when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp) + when(mex.getVariable("allottedResourceId")).thenReturn(ARID) + + return svcdecomp + } + + private ServiceDecomposition initPrepareCreateAllottedResourceBRG(ExecutionEntity mex) { + ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class) + List arlst = new LinkedList<>() + + arlst.add(makeArTXC("A")) + arlst.add(makeArBRG("B")) + arlst.add(makeArTXC("C")) + + when(svcdecomp.getServiceAllottedResources()).thenReturn(arlst) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request) + when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp) + when(mex.getVariable("allottedResourceId")).thenReturn(ARID) + + return svcdecomp + } + + private AllottedResource makeArTXC(String id) { + AllottedResource ar = mock(AllottedResource.class) + ModelInfo mod = mock(ModelInfo.class) + HomingSolution home = mock(HomingSolution.class) + + when(ar.toJsonString()).thenReturn("json"+id) + when(ar.getAllottedResourceType()).thenReturn("TunnelXConn") + when(ar.getModelInfo()).thenReturn(mod) + when(ar.getAllottedResourceRole()).thenReturn("TXCr") + when(ar.getHomingSolution()).thenReturn(home) + + when(mod.toJsonString()).thenReturn("model"+id) + + when(home.getServiceInstanceId()).thenReturn("home"+id) + + return ar + } + + private AllottedResource makeArBRG(String id) { + AllottedResource ar = mock(AllottedResource.class) + ModelInfo mod = mock(ModelInfo.class) + HomingSolution home = mock(HomingSolution.class) + + when(ar.toJsonString()).thenReturn("json"+id) + when(ar.getAllottedResourceType()).thenReturn("BRG") + when(ar.getModelInfo()).thenReturn(mod) + when(ar.getAllottedResourceRole()).thenReturn("BRGr") + when(ar.getHomingSolution()).thenReturn(home) + + when(mod.toJsonString()).thenReturn("model"+id) + + when(home.getServiceInstanceId()).thenReturn("home"+id) + + return ar + } + + private initPrepareVnfAndModulesCreate(ExecutionEntity mex) { + + List vnflst = new LinkedList<>() + + vnflst.add(makeVnf("A")) + vnflst.add(makeVnf("B")) + vnflst.add(makeVnf("C")) + vnflst.add(makeVnf("D")) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request) + when(mex.getVariable("vnfList")).thenReturn(vnflst) + when(mex.getVariable(Prefix+"VnfsCreatedCount")).thenReturn(2) + when(mex.getVariable("vnfModelInfo")).thenReturn("nomodel") + when(mex.getVariable("sdncVersion")).thenReturn("myvers") + } + + private VnfResource makeVnf(String id) { + ModelInfo mod = mock(ModelInfo.class) + VnfResource vnf = mock(VnfResource.class) + + when(mod.toString()).thenReturn('{"modelInfo":"mymodel'+id+'"}') + + when(vnf.toString()).thenReturn("myvnf"+id) + when(vnf.getModelInfo()).thenReturn(mod) + + return vnf + } + + private initValidateVnfCreate(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable(Prefix+"VnfsCreatedCount")).thenReturn(2) + } + + private initPostProcessResponse(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("source")).thenReturn("mysrc") + when(mex.getVariable("mso-request-id")).thenReturn("mri") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + } + + private WorkflowException initPreProcessRollback(ExecutionEntity mex) { + WorkflowException wfe = mock(WorkflowException.class) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("WorkflowException")).thenReturn(wfe) + + return wfe + } + + private WorkflowException initPostProcessRollback(ExecutionEntity mex) { + WorkflowException wfe = mock(WorkflowException.class) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prevWorkflowException")).thenReturn(wfe) + + return wfe + } + + private initPrepareFalloutRequest(ExecutionEntity mex) { + WorkflowException wfe = mock(WorkflowException.class) + + when(wfe.getErrorMessage()).thenReturn("mymsg") + when(wfe.getErrorCode()).thenReturn(999) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("WorkflowException")).thenReturn(wfe) + when(mex.getVariable(Prefix+"requestInfo")).thenReturn("world") + + return wfe + } + + private initSendSyncError(ExecutionEntity mex) { + WorkflowException wfe = mock(WorkflowException.class) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("mso-request-id")).thenReturn("mri") + when(mex.getVariable("WorkflowException")).thenReturn(wfe) + + when(wfe.getErrorMessage()).thenReturn("mymsg") + } + + private initProcessJavaException(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy new file mode 100644 index 0000000000..df7c0cff97 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy @@ -0,0 +1,709 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.vcpe.scripts + + +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution +import org.junit.Before +import org.junit.BeforeClass +import org.junit.Rule +import org.junit.Test +import org.junit.Ignore +import org.mockito.MockitoAnnotations +import org.camunda.bpm.engine.delegate.BpmnError +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.mock.FileUtil + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse +import static com.github.tomakehurst.wiremock.client.WireMock.get +import static com.github.tomakehurst.wiremock.client.WireMock.patch +import static com.github.tomakehurst.wiremock.client.WireMock.put +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching +import static org.junit.Assert.*; +import static org.mockito.Mockito.* +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource +import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition +import org.openecomp.mso.bpmn.core.domain.VnfResource +import org.openecomp.mso.bpmn.core.domain.AllottedResource +import org.openecomp.mso.bpmn.core.domain.ModelInfo +import org.openecomp.mso.bpmn.core.domain.HomingSolution +import org.openecomp.mso.bpmn.core.RollbackData +import org.openecomp.mso.bpmn.vcpe.scripts.MapGetter +import org.openecomp.mso.bpmn.vcpe.scripts.MapSetter + +import com.github.tomakehurst.wiremock.junit.WireMockRule + +class DeleteVcpeResCustServiceTest extends GroovyTestBase { + + private static String request + + @Rule + public WireMockRule wireMockRule = new WireMockRule(PORT) + + String Prefix = "DVRCS_" + String RbType = "DCRENI_" + + @BeforeClass + public static void setUpBeforeClass() { + super.setUpBeforeClass() + request = FileUtil.readResourceFile("__files/VCPE/DeleteVcpeResCustService/request.json") + } + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + public DeleteVcpeResCustServiceTest() { + super("DeleteVcpeResCustService") + } + + + // ***** preProcessRequest ***** + + @Test +// @Ignore + public void preProcessRequest() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("DeleteVcpeResCustServiceRequest", request) + verify(mex).setVariable("msoRequestId", "mri") + verify(mex).setVariable("requestAction", "ra") + verify(mex).setVariable("source", "VID") + verify(mex).setVariable("globalSubscriberId", CUST) + verify(mex).setVariable("globalCustomerId", CUST) + verify(mex).setVariable("disableRollback", "false") + verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") + verify(mex).setVariable("subscriptionServiceType", SVC) + + verify(mex).setVariable("lcpCloudRegionId", "mdt1") + verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba") + verify(mex).setVariable("sdncVersion", "1702") + verify(mex).setVariable("GENGS_type", "service-instance") + assertTrue(map.containsKey(Prefix+"requestInfo")) + + def reqinfo = map.get(Prefix+"requestInfo") + assertTrue(reqinfo.indexOf("mri= 0) + assertTrue(reqinfo.indexOf("VID= 0) + } + + @Test +// @Ignore + public void preProcessRequest_EmptyParts() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcess(mex) + + def req = request + .replace('"source"', '"sourceXXX"') + + when(mex.getVariable("bpmnRequest")).thenReturn(req) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("DeleteVcpeResCustServiceRequest", req) + verify(mex).setVariable("msoRequestId", "mri") + verify(mex).setVariable("requestAction", "ra") + verify(mex).setVariable("source", "VID") + verify(mex).setVariable("globalSubscriberId", CUST) + verify(mex).setVariable("globalCustomerId", CUST) + verify(mex).setVariable("disableRollback", "false") + verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") + verify(mex).setVariable("subscriptionServiceType", SVC) + + verify(mex).setVariable("lcpCloudRegionId", "mdt1") + verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba") + verify(mex).setVariable("sdncVersion", "1702") + verify(mex).setVariable("GENGS_type", "service-instance") + assertTrue(map.containsKey(Prefix+"requestInfo")) + + def reqinfo = map.get(Prefix+"requestInfo") + println reqinfo + assertTrue(reqinfo.indexOf("mri= 0) + assertTrue(reqinfo.indexOf("VID= 0) + } + + @Test +// @Ignore + public void preProcessRequest_MissingServiceInstanceId() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("serviceInstanceId")).thenReturn(null) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.preProcessRequest(mex) })) + } + + @Test +// @Ignore + public void preProcessRequest_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("bpmnRequest")).thenThrow(new BpmnError("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.preProcessRequest(mex) })) + } + + @Test +// @Ignore + public void preProcessRequest_Ex() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("bpmnRequest")).thenThrow(new RuntimeException("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.preProcessRequest(mex) })) + } + + private void initPreProcess(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("bpmnRequest")).thenReturn(request) + when(mex.getVariable("mso-request-id")).thenReturn("mri") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("requestAction")).thenReturn("ra") + } + + // ***** sendSyncResponse ***** + + @Test +// @Ignore + public void sendSyncResponse() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initSendSyncResponse(mex) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.sendSyncResponse(mex) + + verify(mex, times(2)).getVariable(DBGFLAG) + + verify(mex).setVariable(processName+"WorkflowResponseSent", "true") + + assertEquals("202", map.get(processName+"ResponseCode")) + assertEquals("Success", map.get(processName+"Status")) + + def resp = map.get(processName+"Response") + + assertTrue(resp.indexOf('"instanceId":"sii"') >= 0) + assertTrue(resp.indexOf('"requestId":"mri"') >= 0) + } + + @Test +// @Ignore + public void sendSyncResponse_Ex() { + ExecutionEntity mex = setupMock() + initSendSyncResponse(mex) + + when(mex.getVariable("serviceInstanceId")).thenThrow(new RuntimeException("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.sendSyncResponse(mex) })) + } + + private initSendSyncResponse(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("mso-request-id")).thenReturn("mri") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + } + + // ***** prepareServiceDelete ***** + + @Test +// @Ignore + public void prepareServiceDelete() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPrepareServiceDelete(mex) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.prepareServiceDelete(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable(Prefix+"TunnelXConn", true) + assertEquals("txcA", map.get("TXC_allottedResourceId")) + + verify(mex).setVariable(Prefix+"BRG", true) + assertEquals("brgB", map.get("BRG_allottedResourceId")) + + verify(mex).setVariable(Prefix+"vnfsCount", 2) + assertNotNull(map.get(Prefix+"relatedVnfIdList")) + assertEquals("[vnfX, vnfY]", map.get(Prefix+"relatedVnfIdList").toString()) + + verify(mex, never()).setVariable(processName+"WorkflowResponseSent", "true") + } + + @Test +// @Ignore + public void prepareServiceDelete_NotFound() { + ExecutionEntity mex = setupMock() + initPrepareServiceDelete(mex) + + when(mex.getVariable("GENGS_FoundIndicator")).thenReturn(false) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.prepareServiceDelete(mex) })) + + verify(mex, never()).setVariable(processName+"WorkflowResponseSent", "true") + } + + @Test +// @Ignore + public void prepareServiceDelete_Empty() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPrepareServiceDelete(mex) + + when(mex.getVariable("GENGS_service")).thenReturn("") + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.prepareServiceDelete(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable(Prefix+"TunnelXConn", false) + assertNull(map.get("TXC_allottedResourceId")) + + verify(mex).setVariable(Prefix+"BRG", false) + assertNull(map.get("BRG_allottedResourceId")) + + assertEquals(0, map.get(Prefix+"vnfsCount")) + assertFalse(map.containsKey(Prefix+"relatedVnfIdList")) + + verify(mex, never()).setVariable(processName+"WorkflowResponseSent", "true") + } + + @Test +// @Ignore + public void prepareServiceDelete_BpmnError() { + ExecutionEntity mex = setupMock() + initPrepareServiceDelete(mex) + + when(mex.getVariable("GENGS_FoundIndicator")).thenThrow(new BpmnError("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.prepareServiceDelete(mex) })) + + verify(mex, never()).setVariable(processName+"WorkflowResponseSent", "true") + } + + @Test +// @Ignore + public void prepareServiceDelete_Ex() { + ExecutionEntity mex = setupMock() + initPrepareServiceDelete(mex) + + when(mex.getVariable("GENGS_FoundIndicator")).thenThrow(new RuntimeException("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.prepareServiceDelete(mex) })) + + verify(mex).setVariable(processName+"WorkflowResponseSent", "true") + } + + private initPrepareServiceDelete(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("GENGS_FoundIndicator")).thenReturn(true) + when(mex.getVariable("mso-request-id")).thenReturn("mri") + when(mex.getVariable("DeleteVcpeResCustServiceRequest")).thenReturn(request) + when(mex.getVariable("GENGS_service")).thenReturn(FileUtil.readResourceFile("__files/VCPE/DeleteVcpeResCustService/serviceToDelete.xml")) + } + + // ***** prepareVnfAndModulesDelete ***** + + @Test +// @Ignore + public void prepareVnfAndModulesDelete() { + ExecutionEntity mex = setupMock() + initPrepareVnfAndModulesDelete(mex) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.prepareVnfAndModulesDelete(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable("vnfId", "vnfB") + } + + @Test +// @Ignore + public void prepareVnfAndModulesDelete_Empty() { + ExecutionEntity mex = setupMock() + initPrepareVnfAndModulesDelete(mex) + + when(mex.getVariable(Prefix+"relatedVnfIdList")).thenReturn(new LinkedList()) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.prepareVnfAndModulesDelete(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable("vnfId", "") + } + + @Test +// @Ignore + public void prepareVnfAndModulesDelete_Ex() { + ExecutionEntity mex = setupMock() + initPrepareVnfAndModulesDelete(mex) + + when(mex.getVariable(Prefix+"relatedVnfIdList")).thenThrow(new RuntimeException("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.prepareVnfAndModulesDelete(mex) })) + } + + private initPrepareVnfAndModulesDelete(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable(Prefix+"relatedVnfIdList")).thenReturn(Arrays.asList("vnfA", "vnfB", "vnfC")) + when(mex.getVariable(Prefix+"vnfsDeletedCount")).thenReturn(1) + } + + // ***** validateVnfDelete ***** + + @Test +// @Ignore + public void validateVnfDelete() { + ExecutionEntity mex = setupMock() + initValidateVnfDelete(mex) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.validateVnfDelete(mex) + + verify(mex).getVariable(DBGFLAG) + + verify(mex).setVariable(Prefix+"vnfsDeletedCount", 3) + } + + @Test +// @Ignore + public void validateVnfDelete_Ex() { + ExecutionEntity mex = setupMock() + initValidateVnfDelete(mex) + + when(mex.getVariable(Prefix+"vnfsDeletedCount")).thenThrow(new RuntimeException("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.validateVnfDelete(mex) })) + } + + private initValidateVnfDelete(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable(Prefix+"vnfsDeletedCount")).thenReturn(2) + } + + // ***** postProcessResponse ***** + + @Test +// @Ignore + public void postProcessResponse() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPostProcessResponse(mex) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.postProcessResponse(mex) + + verify(mex).getVariable(DBGFLAG) + + assertEquals(true, map.get(Prefix+"Success")) + + def req = map.get(Prefix+"CompleteMsoProcessRequest") + + assertTrue(req.indexOf("mri= 0) + assertTrue(req.indexOf("mysrc= 0) + } + + @Test +// @Ignore + public void postProcessResponse_BpmnError() { + ExecutionEntity mex = setupMock() + initPostProcessResponse(mex) + + when(mex.getVariable("source")).thenThrow(new BpmnError("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.postProcessResponse(mex) })) + } + + @Test +// @Ignore + public void postProcessResponse_Ex() { + ExecutionEntity mex = setupMock() + initPostProcessResponse(mex) + + when(mex.getVariable("source")).thenThrow(new RuntimeException("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.postProcessResponse(mex) })) + } + + private initPostProcessResponse(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("source")).thenReturn("mysrc") + when(mex.getVariable("msoRequestId")).thenReturn("mri") + } + + + // ***** prepareFalloutRequest ***** + + @Test +// @Ignore + public void prepareFalloutRequest() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPrepareFalloutRequest(mex) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.prepareFalloutRequest(mex) + + verify(mex, times(2)).getVariable(DBGFLAG) + + def fo = map.get(Prefix+"falloutRequest") + + assertTrue(fo.indexOf("world= 0) + assertTrue(fo.indexOf("ErrorMessage>mymsg= 0) + assertTrue(fo.indexOf("ErrorCode>999= 0) + } + + @Test +// @Ignore + public void prepareFalloutRequest_Ex() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPrepareFalloutRequest(mex) + + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.prepareFalloutRequest(mex) })) + } + + private initPrepareFalloutRequest(ExecutionEntity mex) { + WorkflowException wfe = mock(WorkflowException.class) + + when(wfe.getErrorMessage()).thenReturn("mymsg") + when(wfe.getErrorCode()).thenReturn(999) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("WorkflowException")).thenReturn(wfe) + when(mex.getVariable(Prefix+"requestInfo")).thenReturn("world") + + return wfe + } + + // ***** sendSyncError ***** + + @Test +// @Ignore + public void sendSyncError() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initSendSyncError(mex) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.sendSyncError(mex) + + verify(mex, times(2)).getVariable(DBGFLAG) + + verify(mex).setVariable(processName+"WorkflowResponseSent", "true") + + assertEquals("500", map.get(processName+"ResponseCode")) + assertEquals("Fail", map.get(processName+"Status")) + + def resp = map.get(processName+"Response") + + assertTrue(resp.indexOf("ErrorMessage>mymsg= 0) + + verify(mex).setVariable("WorkflowResponse", resp) + } + + @Test +// @Ignore + public void sendSyncError_NotWfe() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initSendSyncError(mex) + + when(mex.getVariable("WorkflowException")).thenReturn("not a WFE") + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.sendSyncError(mex) + + verify(mex, times(2)).getVariable(DBGFLAG) + + verify(mex).setVariable(processName+"WorkflowResponseSent", "true") + + assertEquals("500", map.get(processName+"ResponseCode")) + assertEquals("Fail", map.get(processName+"Status")) + + def resp = map.get(processName+"Response") + + assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.= 0) + + verify(mex).setVariable("WorkflowResponse", resp) + } + + @Test +// @Ignore + public void sendSyncError_NullWfe() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initSendSyncError(mex) + + when(mex.getVariable("WorkflowException")).thenReturn(null) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + DeleteVcpeResCustService.sendSyncError(mex) + + verify(mex, times(2)).getVariable(DBGFLAG) + + verify(mex).setVariable(processName+"WorkflowResponseSent", "true") + + assertEquals("500", map.get(processName+"ResponseCode")) + assertEquals("Fail", map.get(processName+"Status")) + + def resp = map.get(processName+"Response") + + assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.= 0) + + verify(mex).setVariable("WorkflowResponse", resp) + } + + @Test +// @Ignore + public void sendSyncError_Ex() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initSendSyncError(mex) + + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + DeleteVcpeResCustService.sendSyncError(mex) + + assertFalse(map.containsKey(processName+"ResponseCode")) + } + + private initSendSyncError(ExecutionEntity mex) { + WorkflowException wfe = mock(WorkflowException.class) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("mso-request-id")).thenReturn("mri") + when(mex.getVariable("WorkflowException")).thenReturn(wfe) + + when(wfe.getErrorMessage()).thenReturn("mymsg") + } + + + // ***** processJavaException ***** + + @Test +// @Ignore + public void processJavaException() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initProcessJavaException(mex) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.processJavaException(mex) })) + + verify(mex, times(2)).getVariable(DBGFLAG) + + verify(mex).setVariable("prefix", Prefix) + + def wfe = map.get("WorkflowException") + + assertEquals("Caught a Java Lang Exception", wfe.getErrorMessage()) + } + + @Test +// @Ignore + public void processJavaException_BpmnError() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initProcessJavaException(mex) + + when(mex.getVariables()).thenThrow(new BpmnError("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.processJavaException(mex) })) + + assertFalse(map.containsKey("WorkflowException")) + } + + @Test +// @Ignore + public void processJavaException_Ex() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initProcessJavaException(mex) + + when(mex.getVariables()).thenThrow(new RuntimeException("expected exception")) + + DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() + + assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.processJavaException(mex) })) + + def wfe = map.get("WorkflowException") + + assertEquals("Exception in processJavaException method", wfe.getErrorMessage()) + } + + private initProcessJavaException(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy new file mode 100644 index 0000000000..af532e733c --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy @@ -0,0 +1,653 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.vcpe.scripts + + +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution +import org.junit.Before +import org.junit.BeforeClass +import org.junit.Rule +import org.junit.Test +import org.junit.Ignore +import org.mockito.MockitoAnnotations +import org.camunda.bpm.engine.delegate.BpmnError +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.mock.FileUtil + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse +import static com.github.tomakehurst.wiremock.client.WireMock.get +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching +import static org.junit.Assert.*; +import static org.mockito.Mockito.* +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchAllottedResource + +import org.openecomp.mso.bpmn.core.RollbackData + +import com.github.tomakehurst.wiremock.junit.WireMockRule + +class DoCreateAllottedResourceBRGRollbackTest extends GroovyTestBase { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(PORT) + + String Prefix = "DCARBRGRB_" + String RbType = "DCARBRG_" + + @BeforeClass + public static void setUpBeforeClass() { + super.setUpBeforeClass() + } + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + public DoCreateAllottedResourceBRGRollbackTest() { + super("DoCreateAllottedResourceBRGRollback") + } + + + // ***** preProcessRequest ***** + + @Test +// @Ignore + public void preProcessRequest() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("serviceInstanceId", "sii") + verify(mex).setVariable("parentServiceInstanceId", "psii") + verify(mex).setVariable("allottedResourceId", "myid") + verify(mex).setVariable("rollbackAAI", true) + verify(mex).setVariable("aaiARPath", "mypath") + verify(mex).setVariable("rollbackSDNC", true) + verify(mex).setVariable("deactivateSdnc", "myactivate") + verify(mex).setVariable("deleteSdnc", "mycreate") + verify(mex).setVariable("unassignSdnc", "true") + verify(mex).setVariable("sdncDeactivateRequest", "activatereq") + verify(mex).setVariable("sdncDeleteRequest", "createreq") + verify(mex).setVariable("sdncUnassignRequest", "assignreq") + + verify(mex, never()).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_RollbackDisabled() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("disableRollback")).thenReturn("true") + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("serviceInstanceId", "sii") + verify(mex).setVariable("parentServiceInstanceId", "psii") + verify(mex).setVariable("allottedResourceId", "myid") + verify(mex).setVariable("rollbackAAI", true) + verify(mex).setVariable("aaiARPath", "mypath") + verify(mex).setVariable("rollbackSDNC", true) + verify(mex).setVariable("deactivateSdnc", "myactivate") + verify(mex).setVariable("deleteSdnc", "mycreate") + verify(mex).setVariable("unassignSdnc", "true") + verify(mex).setVariable("sdncDeactivateRequest", "activatereq") + verify(mex).setVariable("sdncDeleteRequest", "createreq") + verify(mex).setVariable("sdncUnassignRequest", "assignreq") + + verify(mex).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_NoAAI() { + ExecutionEntity mex = setupMock() + def data = initPreProcess(mex) + + when(mex.getVariable("rollbackAAI")).thenReturn(false) + data.put(RbType, "rollbackAAI", "false") + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("serviceInstanceId", "sii") + verify(mex).setVariable("parentServiceInstanceId", "psii") + verify(mex).setVariable("allottedResourceId", "myid") + verify(mex, never()).setVariable("rollbackAAI", true) + verify(mex, never()).setVariable("aaiARPath", "mypath") + verify(mex).setVariable("rollbackSDNC", true) + verify(mex).setVariable("deactivateSdnc", "myactivate") + verify(mex).setVariable("deleteSdnc", "mycreate") + verify(mex).setVariable("unassignSdnc", "true") + verify(mex).setVariable("sdncDeactivateRequest", "activatereq") + verify(mex).setVariable("sdncDeleteRequest", "createreq") + verify(mex).setVariable("sdncUnassignRequest", "assignreq") + + verify(mex, never()).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_NoAssign() { + ExecutionEntity mex = setupMock() + def data = initPreProcess(mex) + + when(mex.getVariable("rollbackSDNC")).thenReturn(false) + data.put(RbType, "rollbackSDNCassign", "false") + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("serviceInstanceId", "sii") + verify(mex).setVariable("parentServiceInstanceId", "psii") + verify(mex).setVariable("allottedResourceId", "myid") + verify(mex).setVariable("rollbackAAI", true) + verify(mex).setVariable("aaiARPath", "mypath") + verify(mex, never()).setVariable("rollbackSDNC", true) + verify(mex, never()).setVariable("deactivateSdnc", "myactivate") + verify(mex, never()).setVariable("deleteSdnc", "mycreate") + verify(mex, never()).setVariable("unassignSdnc", "true") + verify(mex, never()).setVariable("sdncDeactivateRequest", "activatereq") + verify(mex, never()).setVariable("sdncDeleteRequest", "createreq") + verify(mex, never()).setVariable("sdncUnassignRequest", "assignreq") + + verify(mex, never()).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_NoAAI_NoAssign() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("rollbackAAI")).thenReturn(false) + when(mex.getVariable("rollbackSDNC")).thenReturn(false) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) + + verify(mex).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_NoRbStructure() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("rollbackData")).thenReturn(new RollbackData()) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) + + verify(mex).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_NullRb() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("rollbackData")).thenReturn(null) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) + + verify(mex).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) })) + } + + @Test +// @Ignore + public void preProcessRequest_Ex() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) })) + } + + @Test +// @Ignore + public void updateAaiAROrchStatus() { + ExecutionEntity mex = setupMock() + initUpdateAaiAROrchStatus(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml") + MockPatchAllottedResource(CUST, SVC, INST, ARID) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.updateAaiAROrchStatus(mex, "success") + } + + @Test +// @Ignore + public void updateAaiAROrchStatus_EmptyResponse() { + ExecutionEntity mex = setupMock() + initUpdateAaiAROrchStatus(mex) + + wireMockRule + .stubFor(get(urlMatching("/aai/v[0-9]+/.*")) + .willReturn(aResponse() + .withStatus(200))) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.updateAaiAROrchStatus(mex, "success") })) + } + + @Test +// @Ignore + public void updateAaiAROrchStatus_NoArPath() { + ExecutionEntity mex = setupMock() + initUpdateAaiAROrchStatus(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml") + MockPatchAllottedResource(CUST, SVC, INST, ARID) + + when(mex.getVariable("aaiARPath")).thenReturn(null) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.updateAaiAROrchStatus(mex, "success") })) + } + + + // ***** validateSDNCResp ***** + + @Test +// @Ignore + public void validateSDNCResp() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create") + + verify(mex).getVariable("WorkflowException") + verify(mex).getVariable("SDNCA_SuccessIndicator") + } + + @Test +// @Ignore + public void validateSDNCResp_Unsuccessful() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(false) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create") })) + } + + @Test +// @Ignore + public void validateSDNCResp_BpmnError404() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("404", "expected exception")) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create") + } + + @Test +// @Ignore + public void validateSDNCResp_BpmnError() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create") })) + } + + @Test +// @Ignore + public void validateSDNCResp_Ex() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create") })) + } + + @Test +// @Ignore + public void deleteAaiAR() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.deleteAaiAR(mex) + } + + @Test +// @Ignore + public void deleteAaiAR_NoArPath() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenReturn("") + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.deleteAaiAR(mex) })) + } + + @Test +// @Ignore + public void deleteAaiAR_BpmnError() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.deleteAaiAR(mex) })) + } + + @Test +// @Ignore + public void deleteAaiAR_Ex() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.deleteAaiAR(mex) })) + } + + @Test +// @Ignore + public void postProcessRequest() { + ExecutionEntity mex = setupMock() + initPostProcessRequest(mex) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.postProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex).setVariable("rolledBack", true) + } + + @Test +// @Ignore + public void postProcessRequest_RolledBack() { + ExecutionEntity mex = setupMock() + initPostProcessRequest(mex) + + when(mex.getVariable("skipRollback")).thenReturn(true) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.postProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex, never()).setVariable("rolledBack", true) + } + + @Test +// @Ignore + public void postProcessRequest_BpmnError() { + ExecutionEntity mex = setupMock() + initPostProcessRequest(mex) + + when(mex.getVariable("skipRollback")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.postProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex, never()).setVariable("rolledBack", true) + } + + @Test +// @Ignore + public void postProcessRequest_Ex() { + ExecutionEntity mex = setupMock() + initPostProcessRequest(mex) + + when(mex.getVariable("skipRollback")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.postProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex, never()).setVariable("rolledBack", true) + } + + @Test +// @Ignore + public void processRollbackException() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.processRollbackException(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex).setVariable("rolledBack", false) + verify(mex).setVariable("rollbackError", "Caught exception in AllottedResource Create Rollback") + verify(mex).setVariable("WorkflowException", null) + } + + @Test +// @Ignore + public void processRollbackException_BpmnError() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + doThrow(new BpmnError("expected exception")).when(mex).setVariable("rollbackData", null) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.processRollbackException(mex) + } + + @Test +// @Ignore + public void processRollbackException_Ex() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + doThrow(new RuntimeException("expected exception")).when(mex).setVariable("rollbackData", null) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.processRollbackException(mex) + } + + @Test +// @Ignore + public void processRollbackJavaException() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.processRollbackJavaException(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex).setVariable("rolledBack", false) + verify(mex).setVariable("rollbackError", "Caught Java exception in AllottedResource Create Rollback") + verify(mex, never()).setVariable("WorkflowException", null) + } + + @Test +// @Ignore + public void processRollbackJavaException_BpmnError() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + doThrow(new BpmnError("expected exception")).when(mex).setVariable("rollbackData", null) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.processRollbackJavaException(mex) + } + + @Test +// @Ignore + public void processRollbackJavaException_Ex() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + doThrow(new RuntimeException("expected exception")).when(mex).setVariable("rollbackData", null) + + DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() + DoCreateAllottedResourceBRGRollback.processRollbackJavaException(mex) + } + + private RollbackData initPreProcess(ExecutionEntity mex) { + def data = new RollbackData() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("rollbackData")).thenReturn(data) + when(mex.getVariable("rollbackAAI")).thenReturn(true) + when(mex.getVariable("rollbackSDNC")).thenReturn(true) + when(mex.getVariable("disableRollback")).thenReturn("false") + + data.put("SERVICEINSTANCE", "allottedResourceId", "myid") + + data.put(RbType, "serviceInstanceId", "sii") + data.put(RbType, "parentServiceInstanceId", "psii") + + data.put(RbType, "rollbackAAI", "true") + data.put(RbType, "aaiARPath", "mypath") + + data.put(RbType, "rollbackSDNCassign", "true") + data.put(RbType, "rollbackSDNCactivate", "myactivate") + data.put(RbType, "rollbackSDNCcreate", "mycreate") + data.put(RbType, "sdncActivateRollbackReq", "activatereq") + data.put(RbType, "sdncCreateRollbackReq", "createreq") + data.put(RbType, "sdncAssignRollbackReq", "assignreq") + + return data + } + + private initUpdateAaiAROrchStatus(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx) + } + + private initValidateSDNCResp(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prefix")).thenReturn(Prefix) + when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) + } + + private String initValidateSDNCResp_Resp() { + return "<response-code>200</response-code>" + } + + private initDeleteAaiAR(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("aaiARResourceVersion")).thenReturn(VERS) + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx) + } + + private initPostProcessRequest(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("skipRollback")).thenReturn(false) + } + + private initProcessRollbackException(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + } + + private initProcessRollbackJavaException(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy index f34f84a5fd..1d4d3ea5a3 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy @@ -1,3 +1,22 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.vcpe.scripts @@ -12,1120 +31,960 @@ import org.junit.Rule import org.junit.Test import org.junit.Ignore import org.mockito.MockitoAnnotations -import org.mockito.ArgumentCaptor import org.camunda.bpm.engine.delegate.BpmnError -import org.openecomp.mso.bpmn.common.scripts.MsoUtils import org.openecomp.mso.bpmn.core.WorkflowException import org.openecomp.mso.bpmn.mock.FileUtil import static com.github.tomakehurst.wiremock.client.WireMock.aResponse -import static com.github.tomakehurst.wiremock.client.WireMock.get -import static com.github.tomakehurst.wiremock.client.WireMock.patch import static com.github.tomakehurst.wiremock.client.WireMock.put import static com.github.tomakehurst.wiremock.client.WireMock.stubFor import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching import static org.junit.Assert.*; import static org.mockito.Mockito.* import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchAllottedResource +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutAllottedResource +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutAllottedResource_500 + import org.openecomp.mso.bpmn.core.RollbackData +import org.openecomp.mso.bpmn.vcpe.scripts.MapSetter import com.github.tomakehurst.wiremock.junit.WireMockRule -class DoCreateAllottedResourceBRGTest { +class DoCreateAllottedResourceBRGTest extends GroovyTestBase { @Rule - public WireMockRule wireMockRule = new WireMockRule(28090) - - static def urnProps = new Properties() - static def aaiUriPfx - - String Prefix="DCARBRG_" - def utils = new MsoUtils() + public WireMockRule wireMockRule = new WireMockRule(PORT) + + String Prefix = "DCARBRG_" - @BeforeClass - public static void setUpBeforeClass() { - def fr = new FileReader("src/test/resources/mso.bpmn.urn.properties") - urnProps.load(fr) - fr.close() - - aaiUriPfx = urnProps.get("aai.endpoint") - } - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - - - // ***** preProcessRequest ***** - - @Test -// @Ignore - public void preProcessRequest() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) + @BeforeClass + public static void setUpBeforeClass() { + super.setUpBeforeClass() + } + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + public DoCreateAllottedResourceBRGTest() { + super("DoCreateAllottedResourceBRG") + } + + + // ***** preProcessRequest ***** - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.preProcessRequest(mex) + @Test +// @Ignore + public void preProcessRequest() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.preProcessRequest(mex) - verify(mex).getVariable("isDebugLogEnabled") - verify(mex).setVariable("prefix", Prefix) - - assertTrue(checkMissingPreProcessRequest("URN_mso_workflow_sdncadapter_callback")) - assertTrue(checkMissingPreProcessRequest("serviceInstanceId")) - assertTrue(checkMissingPreProcessRequest("parentServiceInstanceId")) - assertTrue(checkMissingPreProcessRequest("allottedResourceModelInfo")) - assertTrue(checkMissingPreProcessRequest("vni")) - assertTrue(checkMissingPreProcessRequest("vgmuxBearerIP")) - assertTrue(checkMissingPreProcessRequest("brgWanMacAddress")) - assertTrue(checkMissingPreProcessRequest("allottedResourceRole")) - assertTrue(checkMissingPreProcessRequest("allottedResourceType")) - } - - - // ***** getAaiAR ***** - - @Test -// @Ignore - public void getAaiAR() { - def arData = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/getAR.xml") - def arBrg = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/getArBrg.xml") - - wireMockRule - .stubFor(get(urlMatching("/aai/v[0-9]+/mylink")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("VCPE/DoCreateAllottedResourceBRG/getArBrg.xml"))) - - ExecutionEntity mex = setupMock() - - when(mex.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mex.getVariable("allottedResourceType")).thenReturn("BRGt") - when(mex.getVariable("allottedResourceRole")).thenReturn("BRGr") - when(mex.getVariable("CSI_service")).thenReturn(arData) - when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx) - when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active") - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.getAaiAR(mex) - - verify(mex).setVariable("foundActiveAR", true) - } - - @Test -// @Ignore - public void getAaiAR_Duplicate() { - def arData = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/getAR.xml") - def arBrg = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/getArBrg.xml") - - wireMockRule - .stubFor(get(urlMatching("/aai/v[0-9]+/mylink")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("VCPE/DoCreateAllottedResourceBRG/getArBrg.xml"))) - - ExecutionEntity mex = setupMock() - - when(mex.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mex.getVariable("allottedResourceType")).thenReturn("BRGt") - when(mex.getVariable("allottedResourceRole")).thenReturn("BRGr") - when(mex.getVariable("CSI_service")).thenReturn(arData) - when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx) - when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active") - - // fail if duplicate - when(mex.getVariable("failExists")).thenReturn("true") - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRG.getAaiAR(mex) })) - } - - @Test -// @Ignore - public void getAaiAR_NotActive() { - def arData = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/getAR.xml") - def arBrg = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/getArBrg.xml") - - wireMockRule - .stubFor(get(urlMatching("/aai/v[0-9]+/mylink")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("VCPE/DoCreateAllottedResourceBRG/getArBrg.xml"))) - - ExecutionEntity mex = setupMock() - - when(mex.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mex.getVariable("allottedResourceType")).thenReturn("BRGt") - when(mex.getVariable("allottedResourceRole")).thenReturn("BRGr") - when(mex.getVariable("CSI_service")).thenReturn(arData) - when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx) - - // not active - when(mex.getVariable("aaiAROrchStatus")).thenReturn("not-active") - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRG.getAaiAR(mex) })) - } - - @Test -// @Ignore - public void getAaiAR_NoStatus() { - def arData = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/getAR.xml") - def arBrg = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/getArBrg.xml") - - wireMockRule - .stubFor(get(urlMatching("/aai/v[0-9]+/mylink")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("VCPE/DoCreateAllottedResourceBRG/getArBrg.xml"))) - - ExecutionEntity mex = setupMock() - - when(mex.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mex.getVariable("allottedResourceType")).thenReturn("BRGt") - when(mex.getVariable("allottedResourceRole")).thenReturn("BRGr") - when(mex.getVariable("CSI_service")).thenReturn(arData) - when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx) - - when(mex.getVariable("aaiAROrchStatus")).thenReturn(null) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.getAaiAR(mex) - - verify(mex, never()).setVariable("foundActiveAR", true) - } + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + + assertTrue(checkMissingPreProcessRequest("URN_mso_workflow_sdncadapter_callback")) + assertTrue(checkMissingPreProcessRequest("serviceInstanceId")) + assertTrue(checkMissingPreProcessRequest("parentServiceInstanceId")) + assertTrue(checkMissingPreProcessRequest("allottedResourceModelInfo")) + assertTrue(checkMissingPreProcessRequest("vni")) + assertTrue(checkMissingPreProcessRequest("vgmuxBearerIP")) + assertTrue(checkMissingPreProcessRequest("brgWanMacAddress")) + assertTrue(checkMissingPreProcessRequest("allottedResourceRole")) + assertTrue(checkMissingPreProcessRequest("allottedResourceType")) + } + + + // ***** getAaiAR ***** + + @Test +// @Ignore + public void getAaiAR() { + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml") + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.getAaiAR(mex) - // ***** createAaiAR ***** + verify(mex).setVariable("foundActiveAR", true) + } + + @Test +// @Ignore + public void getAaiAR_Duplicate() { + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml") - @Test -// @Ignore - public void createAaiAR() { - ExecutionEntity mex = setupMock() - initCreateAaiAr(mex) - - wireMockRule - .stubFor(put(urlMatching("/aai/v[0-9]+/mypsi/allotted-resources/allotted-resource/myid")) - .willReturn(aResponse() - .withStatus(200))) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.createAaiAR(mex) - - ArgumentCaptor keycap = ArgumentCaptor.forClass(String.class) - ArgumentCaptor valcap = ArgumentCaptor.forClass(Object.class) - - verify(mex, times(3)).setVariable(keycap.capture(), valcap.capture()) - - assertFalse(keycap.getAllValues().isEmpty()) - assertEquals("rollbackData", keycap.getAllValues().get(keycap.getAllValues().size()-1)) - - def data = valcap.getAllValues().get(valcap.getAllValues().size()-1) - assertNotNull(data) - assertTrue(data instanceof RollbackData) - - assertEquals("45", data.get(Prefix, "disableRollback")) - assertEquals("true", data.get(Prefix, "rollbackAAI")) - assertEquals("myid", data.get(Prefix, "allottedResourceId")) - assertEquals("sii", data.get(Prefix, "serviceInstanceId")) - assertEquals("psii", data.get(Prefix, "parentServiceInstanceId")) - assertEquals(aaiUriPfx+"/aai/v9/mypsi/allotted-resources/allotted-resource/myid", data.get(Prefix, "aaiARPath")) - } - - @Test -// @Ignore - public void createAaiAR_NoArid_NoModelUuids() { - ExecutionEntity mex = setupMock() - initCreateAaiAr(mex) - - // no allottedResourceId - will be generated - - when(mex.getVariable("allottedResourceId")).thenReturn(null) - - wireMockRule - .stubFor(put(urlMatching("/aai/v[0-9]+/mypsi/allotted-resources/allotted-resource/.*")) - .willReturn(aResponse() - .withStatus(200))) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.createAaiAR(mex) - - ArgumentCaptor keycap = ArgumentCaptor.forClass(String.class) - ArgumentCaptor valcap = ArgumentCaptor.forClass(Object.class) - - verify(mex, times(4)).setVariable(keycap.capture(), valcap.capture()) - - assertFalse(keycap.getAllValues().isEmpty()) - assertEquals("allottedResourceId", keycap.getAllValues().get(0)) - assertEquals("rollbackData", keycap.getAllValues().get(keycap.getAllValues().size()-1)) - - def arid = valcap.getAllValues().get(0) - assertNotNull(arid) - assertFalse(arid.isEmpty()) - - def data = valcap.getAllValues().get(valcap.getAllValues().size()-1) - assertNotNull(data) - assertTrue(data instanceof RollbackData) - - assertEquals(arid, data.get(Prefix, "allottedResourceId")) - } - - @Test -// @Ignore - public void createAaiAR_MissingPsiLink() { - ExecutionEntity mex = setupMock() - initCreateAaiAr(mex) - - when(mex.getVariable("PSI_resourceLink")).thenReturn(null) - - wireMockRule - .stubFor(put(urlMatching("/aai/v[0-9]+/mypsi/allotted-resources/allotted-resource/myid")) - .willReturn(aResponse() - .withStatus(200))) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) })) - } - - @Test -// @Ignore - public void createAaiAR_HttpFailed() { - ExecutionEntity mex = setupMock() - initCreateAaiAr(mex) - - // return 500 status - wireMockRule - .stubFor(put(urlMatching("/aai/v[0-9]+/mypsi/allotted-resources/allotted-resource/myid")) - .willReturn(aResponse() - .withStatus(500))) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) })) - } - - @Test -// @Ignore - public void createAaiAR_BpmnError() { - ExecutionEntity mex = setupMock() - initCreateAaiAr(mex) - - when(mex.getVariable("URN_aai_endpoint")).thenThrow(new BpmnError("expected exception")) - - wireMockRule - .stubFor(put(urlMatching("/aai/v[0-9]+/mypsi/allotted-resources/allotted-resource/myid")) - .willReturn(aResponse() - .withStatus(200))) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) })) - } - - @Test -// @Ignore - public void createAaiAR_Ex() { - ExecutionEntity mex = setupMock() - initCreateAaiAr(mex) - - when(mex.getVariable("URN_aai_endpoint")).thenThrow(new RuntimeException("expected exception")) - - wireMockRule - .stubFor(put(urlMatching("/aai/v[0-9]+/mypsi/allotted-resources/allotted-resource/myid")) - .willReturn(aResponse() - .withStatus(200))) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) })) - } + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) + // fail if duplicate + when(mex.getVariable("failExists")).thenReturn("true") - // ***** buildSDNCRequest ***** + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - @Test -// @Ignore - public void buildSDNCRequest() { - ExecutionEntity mex = setupMock() - initBuildSDNCRequest(mex) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - String result = DoCreateAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") - - assertTrue(result.indexOf("myreq= 0) - assertTrue(result.indexOf("myact= 0) - assertTrue(result.indexOf("ari= 0) - assertTrue(result.indexOf("sii= 0) - assertTrue(result.indexOf("psii= 0) - assertTrue(result.indexOf("psii= 0) - assertTrue(result.indexOf("scu= 0) - assertTrue(result.indexOf("mri= 0) - assertTrue(result.indexOf("bwma= 0) - assertTrue(result.indexOf("myvni= 0) - assertTrue(result.indexOf("vbi= 0) - assertTrue(result.indexOf("miu= 0) - assertTrue(result.indexOf("mu= 0) - assertTrue(result.indexOf("mcu= 0) - assertTrue(result.indexOf("mv= 0) - assertTrue(result.indexOf("mn= 0) - } - - @Test -// @Ignore - public void buildSDNCRequest_EmptyModelInfo() { - ExecutionEntity mex = setupMock() - initBuildSDNCRequest(mex) - - when(mex.getVariable("allottedResourceModelInfo")).thenReturn("{}") - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - String result = DoCreateAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") - - assertTrue(result.indexOf("myreq= 0) - assertTrue(result.indexOf("myact= 0) - assertTrue(result.indexOf("ari= 0) - assertTrue(result.indexOf("sii= 0) - assertTrue(result.indexOf("psii= 0) - assertTrue(result.indexOf("psii= 0) - assertTrue(result.indexOf("scu= 0) - assertTrue(result.indexOf("mri= 0) - assertTrue(result.indexOf("bwma= 0) - assertTrue(result.indexOf("myvni= 0) - assertTrue(result.indexOf("vbi= 0) - assertTrue(result.indexOf("") >= 0) - assertTrue(result.indexOf("") >= 0) - assertTrue(result.indexOf("") >= 0) - assertTrue(result.indexOf("") >= 0) - assertTrue(result.indexOf("") >= 0) - } - - @Test -// @Ignore - public void buildSDNCRequest_Ex() { - ExecutionEntity mex = setupMock() - initBuildSDNCRequest(mex) - - when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") })) - } + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRG.getAaiAR(mex) })) + } + + @Test +// @Ignore + public void getAaiAR_NotActive() { + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml") + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) - // ***** preProcessSDNCAssign ***** + // not active + when(mex.getVariable("aaiAROrchStatus")).thenReturn("not-active") - @Test -// @Ignore - public void preProcessSDNCAssign() { - ExecutionEntity mex = setupMock() - def data = initPreProcessSDNC(mex) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.preProcessSDNCAssign(mex) - - ArgumentCaptor keycap = ArgumentCaptor.forClass(String.class) - ArgumentCaptor valcap = ArgumentCaptor.forClass(Object.class) - - verify(mex, times(2)).setVariable(keycap.capture(), valcap.capture()) - - assertFalse(keycap.getAllValues().isEmpty()) - assertEquals("sdncAssignRequest", keycap.getAllValues().get(0)) - assertEquals("rollbackData", keycap.getAllValues().get(keycap.getAllValues().size()-1)) - - def req = valcap.getAllValues().get(0) - assertNotNull(req) - - assertEquals(data, valcap.getAllValues().get(valcap.getAllValues().size()-1)) - - def rbreq = data.get(Prefix, "sdncAssignRollbackReq") - - assertTrue(req.indexOf("assign= 0) - assertTrue(req.indexOf("CreateBRGInstance= 0) - assertTrue(req.indexOf("") >= 0) - - assertTrue(rbreq.indexOf("unassign= 0) - assertTrue(rbreq.indexOf("DeleteBRGInstance= 0) - assertTrue(rbreq.indexOf("") >= 0) - } - - @Test -// @Ignore - public void preProcessSDNCAssign_BpmnError() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCAssign(mex) })) - } - - @Test -// @Ignore - public void preProcessSDNCAssign_Ex() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCAssign(mex) })) - } + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRG.getAaiAR(mex) })) + } + + @Test +// @Ignore + public void getAaiAR_NoStatus() { + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml") - // ***** preProcessSDNCCreate ***** + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) - @Test -// @Ignore - public void preProcessSDNCCreate() { - ExecutionEntity mex = setupMock() - def data = initPreProcessSDNC(mex) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.preProcessSDNCCreate(mex) - - ArgumentCaptor keycap = ArgumentCaptor.forClass(String.class) - ArgumentCaptor valcap = ArgumentCaptor.forClass(Object.class) - - verify(mex, times(2)).setVariable(keycap.capture(), valcap.capture()) - - assertFalse(keycap.getAllValues().isEmpty()) - assertEquals("sdncCreateRequest", keycap.getAllValues().get(0)) - assertEquals("rollbackData", keycap.getAllValues().get(keycap.getAllValues().size()-1)) - - def req = valcap.getAllValues().get(0) - assertNotNull(req) - - assertEquals(data, valcap.getAllValues().get(valcap.getAllValues().size()-1)) - - def rbreq = data.get(Prefix, "sdncCreateRollbackReq") - - assertTrue(req.indexOf("create= 0) - assertTrue(req.indexOf("CreateBRGInstance= 0) - assertTrue(req.indexOf("") >= 0) - - assertTrue(rbreq.indexOf("delete= 0) - assertTrue(rbreq.indexOf("DeleteBRGInstance= 0) - assertTrue(rbreq.indexOf("") >= 0) - - } + when(mex.getVariable("aaiAROrchStatus")).thenReturn(null) - @Test -// @Ignore - public void preProcessSDNCCreate_BpmnError() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCCreate(mex) })) - } - - @Test -// @Ignore - public void preProcessSDNCCreate_Ex() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.getAaiAR(mex) + + verify(mex, never()).setVariable("foundActiveAR", true) + } + + + // ***** createAaiAR ***** + + @Test +// @Ignore + public void createAaiAR() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initCreateAaiAr(mex) + + MockPutAllottedResource(CUST, SVC, INST, ARID) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.createAaiAR(mex) + + def data = map.get("rollbackData") + assertNotNull(data) + assertTrue(data instanceof RollbackData) + + assertEquals("45", data.get(Prefix, "disableRollback")) + assertEquals("true", data.get(Prefix, "rollbackAAI")) + assertEquals(ARID, data.get(Prefix, "allottedResourceId")) + assertEquals("sii", data.get(Prefix, "serviceInstanceId")) + assertEquals("psii", data.get(Prefix, "parentServiceInstanceId")) + assertEquals(mex.getVariable("PSI_resourceLink")+"/allotted-resources/allotted-resource/"+ARID, data.get(Prefix, "aaiARPath")) + } + + @Test +// @Ignore + public void createAaiAR_NoArid_NoModelUuids() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initCreateAaiAr(mex) - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCCreate(mex) })) - } + // no allottedResourceId - will be generated + when(mex.getVariable("allottedResourceId")).thenReturn(null) - // ***** preProcessSDNCActivate ***** + wireMockRule + .stubFor(put(urlMatching("/aai/.*/allotted-resource/.*")) + .willReturn(aResponse() + .withStatus(200))) - @Test -// @Ignore - public void preProcessSDNCActivate() { - ExecutionEntity mex = setupMock() - def data = initPreProcessSDNC(mex) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.preProcessSDNCActivate(mex) - - ArgumentCaptor keycap = ArgumentCaptor.forClass(String.class) - ArgumentCaptor valcap = ArgumentCaptor.forClass(Object.class) - - verify(mex, times(2)).setVariable(keycap.capture(), valcap.capture()) - - assertFalse(keycap.getAllValues().isEmpty()) - assertEquals("sdncActivateRequest", keycap.getAllValues().get(0)) - assertEquals("rollbackData", keycap.getAllValues().get(keycap.getAllValues().size()-1)) - - def req = valcap.getAllValues().get(0) - assertNotNull(req) - - assertEquals(data, valcap.getAllValues().get(valcap.getAllValues().size()-1)) - - def rbreq = data.get(Prefix, "sdncActivateRollbackReq") - - assertTrue(req.indexOf("activate= 0) - assertTrue(req.indexOf("CreateBRGInstance= 0) - assertTrue(req.indexOf("") >= 0) - - assertTrue(rbreq.indexOf("deactivate= 0) - assertTrue(rbreq.indexOf("DeleteBRGInstance= 0) - assertTrue(rbreq.indexOf("") >= 0) - - } + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.createAaiAR(mex) - @Test -// @Ignore - public void preProcessSDNCActivate_BpmnError() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCActivate(mex) })) - } - - @Test -// @Ignore - public void preProcessSDNCActivate_Ex() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCActivate(mex) })) - } + def arid = map.get("allottedResourceId") + assertNotNull(arid) + assertFalse(arid.isEmpty()) + def data = map.get("rollbackData") + assertNotNull(data) + assertTrue(data instanceof RollbackData) - // ***** validateSDNCResp ***** + assertEquals(arid, data.get(Prefix, "allottedResourceId")) + } + + @Test +// @Ignore + public void createAaiAR_MissingPsiLink() { + ExecutionEntity mex = setupMock() + initCreateAaiAr(mex) - @Test -// @Ignore - public void validateSDNCResp() { - ExecutionEntity mex = setupMock() - def data = initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - - when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") - - verify(mex).getVariable("WorkflowException") - verify(mex).getVariable("SDNCA_SuccessIndicator") - verify(mex).getVariable("rollbackData") - - ArgumentCaptor keycap = ArgumentCaptor.forClass(String.class) - ArgumentCaptor valcap = ArgumentCaptor.forClass(Object.class) - - verify(mex, times(4)).setVariable(keycap.capture(), valcap.capture()) - - assertFalse(keycap.getAllValues().isEmpty()) - assertEquals("rollbackData", keycap.getAllValues().get(keycap.getAllValues().size()-1)) - - assertEquals(data, valcap.getAllValues().get(valcap.getAllValues().size()-1)) - - assertEquals("true", data.get(Prefix, "rollback" + "SDNCcreate")) - - } - - @Test -// @Ignore - public void validateSDNCResp_Get() { - ExecutionEntity mex = setupMock() - def data = initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - - when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "get") - - verify(mex).getVariable("WorkflowException") - verify(mex).getVariable("SDNCA_SuccessIndicator") - - verify(mex, never()).getVariable("rollbackData") - } - - @Test -// @Ignore - public void validateSDNCResp_Unsuccessful() { - ExecutionEntity mex = setupMock() - initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - - // unsuccessful - when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(false) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") })) - } - - @Test -// @Ignore - public void validateSDNCResp_BpmnError() { - ExecutionEntity mex = setupMock() - initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - - when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") })) - } - - @Test -// @Ignore - public void validateSDNCResp_Ex() { - ExecutionEntity mex = setupMock() - initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - - when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") })) - } + when(mex.getVariable("PSI_resourceLink")).thenReturn(null) + MockPutAllottedResource(CUST, SVC, INST, ARID) - // ***** preProcessSDNCGet ***** + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - @Test -// @Ignore - public void preProcessSDNCGet_FoundAR() { - ExecutionEntity mex = setupMock() - initPreProcessSDNCGet(mex) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.preProcessSDNCGet(mex) - - ArgumentCaptor keycap = ArgumentCaptor.forClass(String.class) - ArgumentCaptor valcap = ArgumentCaptor.forClass(Object.class) - - verify(mex, times(1)).setVariable(keycap.capture(), valcap.capture()) - - assertFalse(keycap.getAllValues().isEmpty()) - assertEquals("sdncGetRequest", keycap.getAllValues().get(keycap.getAllValues().size()-1)) - - String req = valcap.getAllValues().get(valcap.getAllValues().size()-1) - - assertTrue(req.indexOf("") >= 0) - assertTrue(req.indexOf("sii= 0) - assertTrue(req.indexOf("arlink= 0) - assertTrue(req.indexOf("myurl= 0) - - } + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) })) + } + + @Test +// @Ignore + public void createAaiAR_HttpFailed() { + ExecutionEntity mex = setupMock() + initCreateAaiAr(mex) - @Test -// @Ignore - public void preProcessSDNCGet_NotFoundAR() { - ExecutionEntity mex = setupMock() - initPreProcessSDNCGet(mex) - - when(mex.getVariable("foundActiveAR")).thenReturn(false) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.preProcessSDNCGet(mex) - - ArgumentCaptor keycap = ArgumentCaptor.forClass(String.class) - ArgumentCaptor valcap = ArgumentCaptor.forClass(Object.class) - - verify(mex, times(1)).setVariable(keycap.capture(), valcap.capture()) - - assertFalse(keycap.getAllValues().isEmpty()) - assertEquals("sdncGetRequest", keycap.getAllValues().get(keycap.getAllValues().size()-1)) - - String req = valcap.getAllValues().get(valcap.getAllValues().size()-1) - - assertTrue(req.indexOf("") >= 0) - assertTrue(req.indexOf("sii= 0) - assertTrue(req.indexOf("assignlink= 0) - assertTrue(req.indexOf("myurl= 0) - - } + MockPutAllottedResource_500(CUST, SVC, INST, ARID) - @Test -// @Ignore - public void preProcessSDNCGet_Ex() { - ExecutionEntity mex = setupMock() - initPreProcessSDNCGet(mex) - - when(mex.getVariable("foundActiveAR")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCGet(mex) })) - } + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) })) + } + + @Test +// @Ignore + public void createAaiAR_BpmnError() { + ExecutionEntity mex = setupMock() + initCreateAaiAr(mex) - // ***** updateAaiAROrchStatus ***** + when(mex.getVariable("URN_aai_endpoint")).thenThrow(new BpmnError("expected exception")) - @Test -// @Ignore - public void updateAaiAROrchStatus() { - ExecutionEntity mex = setupMock() - initUpdateAaiAROrchStatus(mex) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.updateAaiAROrchStatus(mex, "success") - } + MockPutAllottedResource(CUST, SVC, INST, ARID) + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - // ***** generateOutputs ***** + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) })) + } + + @Test +// @Ignore + public void createAaiAR_Ex() { + ExecutionEntity mex = setupMock() + initCreateAaiAr(mex) - @Test -// @Ignore - public void generateOutputs() { - ExecutionEntity mex = setupMock() - def brgtop = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/SDNCTopologyQueryCallback.xml") - - when(mex.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mex.getVariable("enhancedCallbackRequestData")).thenReturn(brgtop) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.generateOutputs(mex) - - verify(mex).setVariable("allotedResourceName", "namefromrequest") - - } + when(mex.getVariable("URN_aai_endpoint")).thenThrow(new RuntimeException("expected exception")) - @Test -// @Ignore - public void generateOutputs_BadXml() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mex.getVariable("enhancedCallbackRequestData")).thenReturn("invalid xml") - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.generateOutputs(mex) - - verify(mex, never()).setVariable(anyString(), anyString()) - - } + MockPutAllottedResource(CUST, SVC, INST, ARID) - @Test -// @Ignore - public void generateOutputs_BpmnError() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - DoCreateAllottedResourceBRG.generateOutputs(mex) - verify(mex, never()).setVariable(anyString(), anyString()) - - } + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - @Test -// @Ignore - public void generateOutputs_Ex() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - DoCreateAllottedResourceBRG.generateOutputs(mex) - verify(mex, never()).setVariable(anyString(), anyString()) - - } + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) })) + } + + + // ***** buildSDNCRequest ***** + + @Test +// @Ignore + public void buildSDNCRequest() { + ExecutionEntity mex = setupMock() + initBuildSDNCRequest(mex) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + String result = DoCreateAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") + + assertTrue(result.indexOf("myreq= 0) + assertTrue(result.indexOf("myact= 0) + assertTrue(result.indexOf("ari= 0) + assertTrue(result.indexOf("sii= 0) + assertTrue(result.indexOf("psii= 0) + assertTrue(result.indexOf("psii= 0) + assertTrue(result.indexOf("scu= 0) + assertTrue(result.indexOf("mri= 0) + assertTrue(result.indexOf("bwma= 0) + assertTrue(result.indexOf("myvni= 0) + assertTrue(result.indexOf("vbi= 0) + assertTrue(result.indexOf("miu= 0) + assertTrue(result.indexOf("mu= 0) + assertTrue(result.indexOf("mcu= 0) + assertTrue(result.indexOf("mv= 0) + assertTrue(result.indexOf("mn= 0) + } + + @Test +// @Ignore + public void buildSDNCRequest_EmptyModelInfo() { + ExecutionEntity mex = setupMock() + initBuildSDNCRequest(mex) + + when(mex.getVariable("allottedResourceModelInfo")).thenReturn("{}") + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + String result = DoCreateAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") + + assertTrue(result.indexOf("myreq= 0) + assertTrue(result.indexOf("myact= 0) + assertTrue(result.indexOf("ari= 0) + assertTrue(result.indexOf("sii= 0) + assertTrue(result.indexOf("psii= 0) + assertTrue(result.indexOf("psii= 0) + assertTrue(result.indexOf("scu= 0) + assertTrue(result.indexOf("mri= 0) + assertTrue(result.indexOf("bwma= 0) + assertTrue(result.indexOf("myvni= 0) + assertTrue(result.indexOf("vbi= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + } + + @Test +// @Ignore + public void buildSDNCRequest_Ex() { + ExecutionEntity mex = setupMock() + initBuildSDNCRequest(mex) + when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) - // ***** preProcessRollback ***** + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - @Test -// @Ignore - public void preProcessRollback() { - ExecutionEntity mex = setupMock() - WorkflowException wfe = mock(WorkflowException.class) - - when(mex.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mex.getVariable("WorkflowException")).thenReturn(wfe) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.preProcessRollback(mex) - - verify(mex).setVariable("prevWorkflowException", wfe) - - } + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") })) + } + + + // ***** preProcessSDNCAssign ***** + + @Test +// @Ignore + public void preProcessSDNCAssign() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def data = initPreProcessSDNC(mex) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.preProcessSDNCAssign(mex) + + def req = map.get("sdncAssignRequest") + assertNotNull(req) + + assertEquals(data, map.get("rollbackData")) + + def rbreq = data.get(Prefix, "sdncAssignRollbackReq") + + assertTrue(req.indexOf("assign= 0) + assertTrue(req.indexOf("CreateBRGInstance= 0) + assertTrue(req.indexOf("") >= 0) + + assertTrue(rbreq.indexOf("unassign= 0) + assertTrue(rbreq.indexOf("DeleteBRGInstance= 0) + assertTrue(rbreq.indexOf("") >= 0) + } + + @Test +// @Ignore + public void preProcessSDNCAssign_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCAssign(mex) })) + } + + @Test +// @Ignore + public void preProcessSDNCAssign_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCAssign(mex) })) + } + + + // ***** preProcessSDNCCreate ***** + + @Test +// @Ignore + public void preProcessSDNCCreate() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def data = initPreProcessSDNC(mex) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.preProcessSDNCCreate(mex) + + def req = map.get("sdncCreateRequest") + assertNotNull(req) + + assertEquals(data, map.get("rollbackData")) + + def rbreq = data.get(Prefix, "sdncCreateRollbackReq") + + assertTrue(req.indexOf("create= 0) + assertTrue(req.indexOf("CreateBRGInstance= 0) + assertTrue(req.indexOf("") >= 0) + + assertTrue(rbreq.indexOf("delete= 0) + assertTrue(rbreq.indexOf("DeleteBRGInstance= 0) + assertTrue(rbreq.indexOf("") >= 0) + + } + + @Test +// @Ignore + public void preProcessSDNCCreate_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCCreate(mex) })) + } + + @Test +// @Ignore + public void preProcessSDNCCreate_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCCreate(mex) })) + } + + + // ***** preProcessSDNCActivate ***** + + @Test +// @Ignore + public void preProcessSDNCActivate() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def data = initPreProcessSDNC(mex) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.preProcessSDNCActivate(mex) + + def req = map.get("sdncActivateRequest") + assertNotNull(req) + + assertEquals(data, map.get("rollbackData")) + + def rbreq = data.get(Prefix, "sdncActivateRollbackReq") + + assertTrue(req.indexOf("activate= 0) + assertTrue(req.indexOf("CreateBRGInstance= 0) + assertTrue(req.indexOf("") >= 0) + + assertTrue(rbreq.indexOf("deactivate= 0) + assertTrue(rbreq.indexOf("DeleteBRGInstance= 0) + assertTrue(rbreq.indexOf("") >= 0) + + } + + @Test +// @Ignore + public void preProcessSDNCActivate_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCActivate(mex) })) + } + + @Test +// @Ignore + public void preProcessSDNCActivate_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCActivate(mex) })) + } + + + // ***** validateSDNCResp ***** + + @Test +// @Ignore + public void validateSDNCResp() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def data = initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") + + verify(mex).getVariable("WorkflowException") + verify(mex).getVariable("SDNCA_SuccessIndicator") + verify(mex).getVariable("rollbackData") + + assertEquals(data, map.get("rollbackData")) + + assertEquals("true", data.get(Prefix, "rollback" + "SDNCcreate")) + + } + + @Test +// @Ignore + public void validateSDNCResp_Get() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "get") + + verify(mex).getVariable("WorkflowException") + verify(mex).getVariable("SDNCA_SuccessIndicator") + + verify(mex, never()).getVariable("rollbackData") + } + + @Test +// @Ignore + public void validateSDNCResp_Unsuccessful() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + // unsuccessful + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(false) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") })) + } + + @Test +// @Ignore + public void validateSDNCResp_BpmnError() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") })) + } + + @Test +// @Ignore + public void validateSDNCResp_Ex() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") })) + } + + + // ***** preProcessSDNCGet ***** + + @Test +// @Ignore + public void preProcessSDNCGet_FoundAR() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcessSDNCGet(mex) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.preProcessSDNCGet(mex) + + String req = map.get("sdncGetRequest") + + assertTrue(req.indexOf("") >= 0) + assertTrue(req.indexOf("sii= 0) + assertTrue(req.indexOf("arlink= 0) + assertTrue(req.indexOf("myurl= 0) + + } + + @Test +// @Ignore + public void preProcessSDNCGet_NotFoundAR() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcessSDNCGet(mex) + + when(mex.getVariable("foundActiveAR")).thenReturn(false) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.preProcessSDNCGet(mex) + + String req = map.get("sdncGetRequest") + + assertTrue(req.indexOf("") >= 0) + assertTrue(req.indexOf("sii= 0) + assertTrue(req.indexOf("assignlink= 0) + assertTrue(req.indexOf("myurl= 0) + + } + + @Test +// @Ignore + public void preProcessSDNCGet_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNCGet(mex) + + when(mex.getVariable("foundActiveAR")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCGet(mex) })) + } + + + // ***** updateAaiAROrchStatus ***** + + @Test +// @Ignore + public void updateAaiAROrchStatus() { + MockPatchAllottedResource(CUST, SVC, INST, ARID) + + ExecutionEntity mex = setupMock() + initUpdateAaiAROrchStatus(mex) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.updateAaiAROrchStatus(mex, "success") + } + + + // ***** generateOutputs ***** + + @Test +// @Ignore + public void generateOutputs() { + ExecutionEntity mex = setupMock() + def brgtop = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/SDNCTopologyQueryCallback.xml") + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("enhancedCallbackRequestData")).thenReturn(brgtop) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.generateOutputs(mex) + + verify(mex).setVariable("allotedResourceName", "namefromrequest") + + } + + @Test +// @Ignore + public void generateOutputs_BadXml() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("enhancedCallbackRequestData")).thenReturn("invalid xml") + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.generateOutputs(mex) + + verify(mex, never()).setVariable(anyString(), anyString()) + + } + + @Test +// @Ignore + public void generateOutputs_BpmnError() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + DoCreateAllottedResourceBRG.generateOutputs(mex) + verify(mex, never()).setVariable(anyString(), anyString()) + + } + + @Test +// @Ignore + public void generateOutputs_Ex() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + DoCreateAllottedResourceBRG.generateOutputs(mex) + verify(mex, never()).setVariable(anyString(), anyString()) + + } + + + // ***** preProcessRollback ***** + + @Test +// @Ignore + public void preProcessRollback() { + ExecutionEntity mex = setupMock() + WorkflowException wfe = mock(WorkflowException.class) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("WorkflowException")).thenReturn(wfe) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.preProcessRollback(mex) + + verify(mex).setVariable("prevWorkflowException", wfe) + + } + + @Test +// @Ignore + public void preProcessRollback_NotWFE() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("WorkflowException")).thenReturn("I'm not a WFE") + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.preProcessRollback(mex) - @Test -// @Ignore - public void preProcessRollback_NotWFE() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mex.getVariable("WorkflowException")).thenReturn("I'm not a WFE") - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.preProcessRollback(mex) - // verify(mex, never()).setVariable("prevWorkflowException", any()) - - } - @Test -// @Ignore - public void preProcessRollback_BpmnError() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - DoCreateAllottedResourceBRG.preProcessRollback(mex) - - } + } + + @Test +// @Ignore + public void preProcessRollback_BpmnError() { + ExecutionEntity mex = setupMock() - @Test -// @Ignore - public void preProcessRollback_Ex() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - DoCreateAllottedResourceBRG.preProcessRollback(mex) - - } + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - // ***** postProcessRollback ***** + DoCreateAllottedResourceBRG.preProcessRollback(mex) - @Test -// @Ignore - public void postProcessRollback() { - ExecutionEntity mex = setupMock() - WorkflowException wfe = mock(WorkflowException.class) - - when(mex.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mex.getVariable("prevWorkflowException")).thenReturn(wfe) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.postProcessRollback(mex) - - verify(mex).setVariable("WorkflowException", wfe) - verify(mex).setVariable("rollbackData", null) - - } + } + + @Test +// @Ignore + public void preProcessRollback_Ex() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + DoCreateAllottedResourceBRG.preProcessRollback(mex) + + } + + + // ***** postProcessRollback ***** + + @Test +// @Ignore + public void postProcessRollback() { + ExecutionEntity mex = setupMock() + WorkflowException wfe = mock(WorkflowException.class) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prevWorkflowException")).thenReturn(wfe) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.postProcessRollback(mex) + + verify(mex).setVariable("WorkflowException", wfe) + verify(mex).setVariable("rollbackData", null) + + } + + @Test +// @Ignore + public void postProcessRollback_NotWFE() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prevWorkflowException")).thenReturn("I'm not a WFE") + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + DoCreateAllottedResourceBRG.postProcessRollback(mex) - @Test -// @Ignore - public void postProcessRollback_NotWFE() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mex.getVariable("prevWorkflowException")).thenReturn("I'm not a WFE") - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.postProcessRollback(mex) - // verify(mex, never()).setVariable("WorkflowException", any()) - verify(mex).setVariable("rollbackData", null) - - } + verify(mex).setVariable("rollbackData", null) - @Test -// @Ignore - public void postProcessRollback_BpmnError() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mex.getVariable("prevWorkflowException")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.postProcessRollback(mex) })) - verify(mex, never()).setVariable("rollbackData", null) - - } + } + + @Test +// @Ignore + public void postProcessRollback_BpmnError() { + ExecutionEntity mex = setupMock() - @Test -// @Ignore - public void postProcessRollback_Ex() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mex.getVariable("prevWorkflowException")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - DoCreateAllottedResourceBRG.postProcessRollback(mex) - verify(mex, never()).setVariable("rollbackData", null) - - } + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prevWorkflowException")).thenThrow(new BpmnError("expected exception")) - private boolean checkMissingPreProcessRequest(String fieldnm) { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - when(mex.getVariable(fieldnm)).thenReturn("") - - return doBpmnError( { _ -> DoCreateAllottedResourceBRG.preProcessRequest(mex) }) - } + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - private boolean doBpmnError(def func) { - - try { - func() - return false; - - } catch(BpmnError e) { - return true; - } - } - - private void initPreProcess(ExecutionEntity mex) { - when(mex.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mex.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("sdncurn") - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") - when(mex.getVariable("allottedResourceModelInfo")).thenReturn("armi") - when(mex.getVariable("vni")).thenReturn("myvni") - when(mex.getVariable("vgmuxBearerIP")).thenReturn("vbi") - when(mex.getVariable("brgWanMacAddress")).thenReturn("bwma") - when(mex.getVariable("allottedResourceRole")).thenReturn("arr") - when(mex.getVariable("allottedResourceType")).thenReturn("art") - } - - private initCreateAaiAr(ExecutionEntity mex) { - when(mex.getVariable("disableRollback")).thenReturn(45) - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") - when(mex.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mex.getVariable("allottedResourceId")).thenReturn("myid") - when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx) - when(mex.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn(urnProps.get("mso.workflow.global.default.aai.namespace")) - when(mex.getVariable("PSI_resourceLink")).thenReturn(aaiUriPfx+"/aai/v9/mypsi") - when(mex.getVariable("allottedResourceType")).thenReturn("BRGt") - when(mex.getVariable("allottedResourceRole")).thenReturn("BRGr") - when(mex.getVariable("CSI_resourceLink")).thenReturn(aaiUriPfx+"/aai/v9/mycsi") - when(mex.getVariable("allottedResourceModelInfo")).thenReturn(""" - { - "modelInvariantUuid":"modelinvuuid", - "modelUuid":"modeluuid", - "modelCustomizationUuid":"modelcustuuid" - } - """) - } - - private initBuildSDNCRequest(ExecutionEntity mex) { - when(mex.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mex.getVariable("allottedResourceId")).thenReturn("ari") - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") - when(mex.getVariable("sdncCallbackUrl")).thenReturn("scu") - when(mex.getVariable("msoRequestId")).thenReturn("mri") - when(mex.getVariable("brgWanMacAddress")).thenReturn("bwma") - when(mex.getVariable("vni")).thenReturn("myvni") - when(mex.getVariable("vgmuxBearerIP")).thenReturn("vbi") - when(mex.getVariable("allottedResourceModelInfo")).thenReturn(""" - { - "modelInvariantUuid":"miu", - "modelUuid":"mu", - "modelCustomizationUuid":"mcu", - "modelVersion":"mv", - "modelName":"mn" - } - """) - } - - private RollbackData initPreProcessSDNC(ExecutionEntity mex) { - def data = new RollbackData() - - when(mex.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mex.getVariable("rollbackData")).thenReturn(data) - - return data - } - - private initPreProcessSDNCGet(ExecutionEntity mex) { - when(mex.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl") - when(mex.getVariable("foundActiveAR")).thenReturn(true) - when(mex.getVariable("aaiARGetResponse")).thenReturn("arlink") - when(mex.getVariable("sdncAssignResponse")).thenReturn("<object-path>assignlink</object-path>") - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - when(mex.getVariable("junitSleepMs")).thenReturn("5") - when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl") - } - - private RollbackData initValidateSDNCResp(ExecutionEntity mex) { - def data = new RollbackData() - - when(mex.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mex.getVariable("prefix")).thenReturn(Prefix) - when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) - when(mex.getVariable("rollbackData")).thenReturn(data) - - return data - } + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.postProcessRollback(mex) })) + verify(mex, never()).setVariable("rollbackData", null) + + } + + @Test +// @Ignore + public void postProcessRollback_Ex() { + ExecutionEntity mex = setupMock() - private String initValidateSDNCResp_Resp() { - return "<response-code>200</response-code>" - } + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prevWorkflowException")).thenThrow(new RuntimeException("expected exception")) - private initUpdateAaiAROrchStatus(ExecutionEntity mex) { - when(mex.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx+"/aai/v9/myurl") - - wireMockRule - .stubFor(patch(urlMatching("/aai/v[0-9]+/myurl")) - .willReturn(aResponse() - .withStatus(200))) - } - - private ExecutionEntity setupMock() { - - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("DoCreateAllottedResourceBRG") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoCreateAllottedResourceBRG") - when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") - ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) - when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) - - ExecutionEntity mex = mock(ExecutionEntity.class) - - when(mex.getId()).thenReturn("100") - when(mex.getProcessDefinitionId()).thenReturn("DoCreateAllottedResourceBRG") - when(mex.getProcessInstanceId()).thenReturn("DoCreateAllottedResourceBRG") - when(mex.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mex.getProcessEngineServices().getRepositoryService().getProcessDefinition(mex.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mex - } + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + DoCreateAllottedResourceBRG.postProcessRollback(mex) + verify(mex, never()).setVariable("rollbackData", null) + + } + + private boolean checkMissingPreProcessRequest(String fieldnm) { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() + + when(mex.getVariable(fieldnm)).thenReturn("") + + return doBpmnError( { _ -> DoCreateAllottedResourceBRG.preProcessRequest(mex) }) + } + + private void initPreProcess(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("sdncurn") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") + when(mex.getVariable("allottedResourceModelInfo")).thenReturn("armi") + when(mex.getVariable("vni")).thenReturn("myvni") + when(mex.getVariable("vgmuxBearerIP")).thenReturn("vbi") + when(mex.getVariable("brgWanMacAddress")).thenReturn("bwma") + when(mex.getVariable("allottedResourceRole")).thenReturn("arr") + when(mex.getVariable("allottedResourceType")).thenReturn("art") + } + + private void initGetAaiAR(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("allottedResourceType")).thenReturn("BRGt") + when(mex.getVariable("allottedResourceRole")).thenReturn("BRGr") + when(mex.getVariable("CSI_service")).thenReturn(FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/getAR.xml")) + when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx) + when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active") + } + + private initCreateAaiAr(ExecutionEntity mex) { + when(mex.getVariable("disableRollback")).thenReturn(45) + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("allottedResourceId")).thenReturn(ARID) + when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx) + when(mex.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn(urnProps.get("mso.workflow.global.default.aai.namespace")) + when(mex.getVariable("PSI_resourceLink")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST) + when(mex.getVariable("allottedResourceType")).thenReturn("BRGt") + when(mex.getVariable("allottedResourceRole")).thenReturn("BRGr") + when(mex.getVariable("CSI_resourceLink")).thenReturn(aaiUriPfx+"/aai/v9/mycsi") + when(mex.getVariable("allottedResourceModelInfo")).thenReturn(""" + { + "modelInvariantUuid":"modelinvuuid", + "modelUuid":"modeluuid", + "modelCustomizationUuid":"modelcustuuid" + } + """) + } + + private initBuildSDNCRequest(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("allottedResourceId")).thenReturn("ari") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") + when(mex.getVariable("sdncCallbackUrl")).thenReturn("scu") + when(mex.getVariable("msoRequestId")).thenReturn("mri") + when(mex.getVariable("brgWanMacAddress")).thenReturn("bwma") + when(mex.getVariable("vni")).thenReturn("myvni") + when(mex.getVariable("vgmuxBearerIP")).thenReturn("vbi") + when(mex.getVariable("allottedResourceModelInfo")).thenReturn(""" + { + "modelInvariantUuid":"miu", + "modelUuid":"mu", + "modelCustomizationUuid":"mcu", + "modelVersion":"mv", + "modelName":"mn" + } + """) + } + + private RollbackData initPreProcessSDNC(ExecutionEntity mex) { + def data = new RollbackData() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("rollbackData")).thenReturn(data) + + return data + } + + private initPreProcessSDNCGet(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl") + when(mex.getVariable("foundActiveAR")).thenReturn(true) + when(mex.getVariable("aaiARGetResponse")).thenReturn("arlink") + when(mex.getVariable("sdncAssignResponse")).thenReturn("<object-path>assignlink</object-path>") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("junitSleepMs")).thenReturn("5") + when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl") + } + + private RollbackData initValidateSDNCResp(ExecutionEntity mex) { + def data = new RollbackData() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prefix")).thenReturn(Prefix) + when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) + when(mex.getVariable("rollbackData")).thenReturn(data) + + return data + } + + private String initValidateSDNCResp_Resp() { + return "<response-code>200</response-code>" + } + + private initUpdateAaiAROrchStatus(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + } } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy new file mode 100644 index 0000000000..e5635deba7 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy @@ -0,0 +1,653 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.vcpe.scripts + + +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution +import org.junit.Before +import org.junit.BeforeClass +import org.junit.Rule +import org.junit.Test +import org.junit.Ignore +import org.mockito.MockitoAnnotations +import org.camunda.bpm.engine.delegate.BpmnError +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.mock.FileUtil + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse +import static com.github.tomakehurst.wiremock.client.WireMock.get +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching +import static org.junit.Assert.*; +import static org.mockito.Mockito.* +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchAllottedResource + +import org.openecomp.mso.bpmn.core.RollbackData + +import com.github.tomakehurst.wiremock.junit.WireMockRule + +class DoCreateAllottedResourceTXCRollbackTest extends GroovyTestBase { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(PORT) + + String Prefix = "DCARTXCRB_" + String RbType = "DCARTXC_" + + @BeforeClass + public static void setUpBeforeClass() { + super.setUpBeforeClass() + } + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + public DoCreateAllottedResourceTXCRollbackTest() { + super("DoCreateAllottedResourceTXCRollback") + } + + + // ***** preProcessRequest ***** + + @Test +// @Ignore + public void preProcessRequest() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("serviceInstanceId", "sii") + verify(mex).setVariable("parentServiceInstanceId", "psii") + verify(mex).setVariable("allottedResourceId", "myid") + verify(mex).setVariable("rollbackAAI", true) + verify(mex).setVariable("aaiARPath", "mypath") + verify(mex).setVariable("rollbackSDNC", true) + verify(mex).setVariable("deactivateSdnc", "myactivate") + verify(mex).setVariable("deleteSdnc", "mycreate") + verify(mex).setVariable("unassignSdnc", "true") + verify(mex).setVariable("sdncDeactivateRequest", "activatereq") + verify(mex).setVariable("sdncDeleteRequest", "createreq") + verify(mex).setVariable("sdncUnassignRequest", "assignreq") + + verify(mex, never()).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_RollbackDisabled() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("disableRollback")).thenReturn("true") + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("serviceInstanceId", "sii") + verify(mex).setVariable("parentServiceInstanceId", "psii") + verify(mex).setVariable("allottedResourceId", "myid") + verify(mex).setVariable("rollbackAAI", true) + verify(mex).setVariable("aaiARPath", "mypath") + verify(mex).setVariable("rollbackSDNC", true) + verify(mex).setVariable("deactivateSdnc", "myactivate") + verify(mex).setVariable("deleteSdnc", "mycreate") + verify(mex).setVariable("unassignSdnc", "true") + verify(mex).setVariable("sdncDeactivateRequest", "activatereq") + verify(mex).setVariable("sdncDeleteRequest", "createreq") + verify(mex).setVariable("sdncUnassignRequest", "assignreq") + + verify(mex).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_NoAAI() { + ExecutionEntity mex = setupMock() + def data = initPreProcess(mex) + + when(mex.getVariable("rollbackAAI")).thenReturn(false) + data.put(RbType, "rollbackAAI", "false") + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("serviceInstanceId", "sii") + verify(mex).setVariable("parentServiceInstanceId", "psii") + verify(mex).setVariable("allottedResourceId", "myid") + verify(mex, never()).setVariable("rollbackAAI", true) + verify(mex, never()).setVariable("aaiARPath", "mypath") + verify(mex).setVariable("rollbackSDNC", true) + verify(mex).setVariable("deactivateSdnc", "myactivate") + verify(mex).setVariable("deleteSdnc", "mycreate") + verify(mex).setVariable("unassignSdnc", "true") + verify(mex).setVariable("sdncDeactivateRequest", "activatereq") + verify(mex).setVariable("sdncDeleteRequest", "createreq") + verify(mex).setVariable("sdncUnassignRequest", "assignreq") + + verify(mex, never()).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_NoAssign() { + ExecutionEntity mex = setupMock() + def data = initPreProcess(mex) + + when(mex.getVariable("rollbackSDNC")).thenReturn(false) + data.put(RbType, "rollbackSDNCassign", "false") + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("serviceInstanceId", "sii") + verify(mex).setVariable("parentServiceInstanceId", "psii") + verify(mex).setVariable("allottedResourceId", "myid") + verify(mex).setVariable("rollbackAAI", true) + verify(mex).setVariable("aaiARPath", "mypath") + verify(mex, never()).setVariable("rollbackSDNC", true) + verify(mex, never()).setVariable("deactivateSdnc", "myactivate") + verify(mex, never()).setVariable("deleteSdnc", "mycreate") + verify(mex, never()).setVariable("unassignSdnc", "true") + verify(mex, never()).setVariable("sdncDeactivateRequest", "activatereq") + verify(mex, never()).setVariable("sdncDeleteRequest", "createreq") + verify(mex, never()).setVariable("sdncUnassignRequest", "assignreq") + + verify(mex, never()).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_NoAAI_NoAssign() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("rollbackAAI")).thenReturn(false) + when(mex.getVariable("rollbackSDNC")).thenReturn(false) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) + + verify(mex).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_NoRbStructure() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("rollbackData")).thenReturn(new RollbackData()) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) + + verify(mex).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_NullRb() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("rollbackData")).thenReturn(null) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) + + verify(mex).setVariable("skipRollback", true) + } + + @Test +// @Ignore + public void preProcessRequest_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) })) + } + + @Test +// @Ignore + public void preProcessRequest_Ex() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) })) + } + + @Test +// @Ignore + public void updateAaiAROrchStatus() { + ExecutionEntity mex = setupMock() + initUpdateAaiAROrchStatus(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml") + MockPatchAllottedResource(CUST, SVC, INST, ARID) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.updateAaiAROrchStatus(mex, "success") + } + + @Test +// @Ignore + public void updateAaiAROrchStatus_EmptyResponse() { + ExecutionEntity mex = setupMock() + initUpdateAaiAROrchStatus(mex) + + wireMockRule + .stubFor(get(urlMatching("/aai/v[0-9]+/.*")) + .willReturn(aResponse() + .withStatus(200))) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.updateAaiAROrchStatus(mex, "success") })) + } + + @Test +// @Ignore + public void updateAaiAROrchStatus_NoArPath() { + ExecutionEntity mex = setupMock() + initUpdateAaiAROrchStatus(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml") + MockPatchAllottedResource(CUST, SVC, INST, ARID) + + when(mex.getVariable("aaiARPath")).thenReturn(null) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.updateAaiAROrchStatus(mex, "success") })) + } + + + // ***** validateSDNCResp ***** + + @Test +// @Ignore + public void validateSDNCResp() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create") + + verify(mex).getVariable("WorkflowException") + verify(mex).getVariable("SDNCA_SuccessIndicator") + } + + @Test +// @Ignore + public void validateSDNCResp_Unsuccessful() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(false) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create") })) + } + + @Test +// @Ignore + public void validateSDNCResp_BpmnError404() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("404", "expected exception")) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create") + } + + @Test +// @Ignore + public void validateSDNCResp_BpmnError() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create") })) + } + + @Test +// @Ignore + public void validateSDNCResp_Ex() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create") })) + } + + @Test +// @Ignore + public void deleteAaiAR() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.deleteAaiAR(mex) + } + + @Test +// @Ignore + public void deleteAaiAR_NoArPath() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenReturn("") + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.deleteAaiAR(mex) })) + } + + @Test +// @Ignore + public void deleteAaiAR_BpmnError() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.deleteAaiAR(mex) })) + } + + @Test +// @Ignore + public void deleteAaiAR_Ex() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.deleteAaiAR(mex) })) + } + + @Test +// @Ignore + public void postProcessRequest() { + ExecutionEntity mex = setupMock() + initPostProcessRequest(mex) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.postProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex).setVariable("rolledBack", true) + } + + @Test +// @Ignore + public void postProcessRequest_RolledBack() { + ExecutionEntity mex = setupMock() + initPostProcessRequest(mex) + + when(mex.getVariable("skipRollback")).thenReturn(true) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.postProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex, never()).setVariable("rolledBack", true) + } + + @Test +// @Ignore + public void postProcessRequest_BpmnError() { + ExecutionEntity mex = setupMock() + initPostProcessRequest(mex) + + when(mex.getVariable("skipRollback")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.postProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex, never()).setVariable("rolledBack", true) + } + + @Test +// @Ignore + public void postProcessRequest_Ex() { + ExecutionEntity mex = setupMock() + initPostProcessRequest(mex) + + when(mex.getVariable("skipRollback")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.postProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex, never()).setVariable("rolledBack", true) + } + + @Test +// @Ignore + public void processRollbackException() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.processRollbackException(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex).setVariable("rolledBack", false) + verify(mex).setVariable("rollbackError", "Caught exception in AllottedResource Create Rollback") + verify(mex).setVariable("WorkflowException", null) + } + + @Test +// @Ignore + public void processRollbackException_BpmnError() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + doThrow(new BpmnError("expected exception")).when(mex).setVariable("rollbackData", null) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.processRollbackException(mex) + } + + @Test +// @Ignore + public void processRollbackException_Ex() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + doThrow(new RuntimeException("expected exception")).when(mex).setVariable("rollbackData", null) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.processRollbackException(mex) + } + + @Test +// @Ignore + public void processRollbackJavaException() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.processRollbackJavaException(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("rollbackData", null) + verify(mex).setVariable("rolledBack", false) + verify(mex).setVariable("rollbackError", "Caught Java exception in AllottedResource Create Rollback") + verify(mex, never()).setVariable("WorkflowException", null) + } + + @Test +// @Ignore + public void processRollbackJavaException_BpmnError() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + doThrow(new BpmnError("expected exception")).when(mex).setVariable("rollbackData", null) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.processRollbackJavaException(mex) + } + + @Test +// @Ignore + public void processRollbackJavaException_Ex() { + ExecutionEntity mex = setupMock() + initProcessRollbackException(mex) + + doThrow(new RuntimeException("expected exception")).when(mex).setVariable("rollbackData", null) + + DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() + DoCreateAllottedResourceTXCRollback.processRollbackJavaException(mex) + } + + private RollbackData initPreProcess(ExecutionEntity mex) { + def data = new RollbackData() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("rollbackData")).thenReturn(data) + when(mex.getVariable("rollbackAAI")).thenReturn(true) + when(mex.getVariable("rollbackSDNC")).thenReturn(true) + when(mex.getVariable("disableRollback")).thenReturn("false") + + data.put("SERVICEINSTANCE", "allottedResourceId", "myid") + + data.put(RbType, "serviceInstanceId", "sii") + data.put(RbType, "parentServiceInstanceId", "psii") + + data.put(RbType, "rollbackAAI", "true") + data.put(RbType, "aaiARPath", "mypath") + + data.put(RbType, "rollbackSDNCassign", "true") + data.put(RbType, "rollbackSDNCactivate", "myactivate") + data.put(RbType, "rollbackSDNCcreate", "mycreate") + data.put(RbType, "sdncActivateRollbackReq", "activatereq") + data.put(RbType, "sdncCreateRollbackReq", "createreq") + data.put(RbType, "sdncAssignRollbackReq", "assignreq") + + return data + } + + private initUpdateAaiAROrchStatus(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx) + } + + private initValidateSDNCResp(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prefix")).thenReturn(Prefix) + when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) + } + + private String initValidateSDNCResp_Resp() { + return "<response-code>200</response-code>" + } + + private initDeleteAaiAR(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("aaiARResourceVersion")).thenReturn(VERS) + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx) + } + + private initPostProcessRequest(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("skipRollback")).thenReturn(false) + } + + private initProcessRollbackException(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + } + + private initProcessRollbackJavaException(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy new file mode 100644 index 0000000000..2b6d4ba6a0 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy @@ -0,0 +1,950 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.vcpe.scripts + + +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution +import org.junit.Before +import org.junit.BeforeClass +import org.junit.Rule +import org.junit.Test +import org.junit.Ignore +import org.mockito.MockitoAnnotations +import org.camunda.bpm.engine.delegate.BpmnError +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.mock.FileUtil + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse +import static com.github.tomakehurst.wiremock.client.WireMock.put +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching +import static org.junit.Assert.*; +import static org.mockito.Mockito.* +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchAllottedResource +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutAllottedResource +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutAllottedResource_500 + +import java.util.Map + +import org.openecomp.mso.bpmn.core.RollbackData +import org.openecomp.mso.bpmn.vcpe.scripts.MapSetter + +import com.github.tomakehurst.wiremock.junit.WireMockRule + +class DoCreateAllottedResourceTXCTest extends GroovyTestBase { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(PORT) + + String Prefix = "DCARTXC_" + + @BeforeClass + public static void setUpBeforeClass() { + def fr = new FileReader("src/test/resources/mso.bpmn.urn.properties") + urnProps.load(fr) + fr.close() + + aaiUriPfx = urnProps.get("aai.endpoint") + } + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + public DoCreateAllottedResourceTXCTest() { + super("DoCreateAllottedResourceTXC") + } + + + // ***** preProcessRequest ***** + + @Test +// @Ignore + public void preProcessRequest() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + + assertTrue(checkMissingPreProcessRequest("URN_mso_workflow_sdncadapter_callback")) + assertTrue(checkMissingPreProcessRequest("serviceInstanceId")) + assertTrue(checkMissingPreProcessRequest("parentServiceInstanceId")) + assertTrue(checkMissingPreProcessRequest("allottedResourceModelInfo")) + assertTrue(checkMissingPreProcessRequest("brgWanMacAddress")) + assertTrue(checkMissingPreProcessRequest("allottedResourceRole")) + assertTrue(checkMissingPreProcessRequest("allottedResourceType")) + } + + + // ***** getAaiAR ***** + + @Test +// @Ignore + public void getAaiAR() { + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml") + + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.getAaiAR(mex) + + verify(mex).setVariable("foundActiveAR", true) + } + + @Test +// @Ignore + public void getAaiAR_Duplicate() { + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml") + + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) + + // fail if duplicate + when(mex.getVariable("failExists")).thenReturn("true") + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXC.getAaiAR(mex) })) + } + + @Test +// @Ignore + public void getAaiAR_NotActive() { + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml") + + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) + + // not active + when(mex.getVariable("aaiAROrchStatus")).thenReturn("not-active") + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXC.getAaiAR(mex) })) + } + + @Test +// @Ignore + public void getAaiAR_NoStatus() { + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml") + + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) + + when(mex.getVariable("aaiAROrchStatus")).thenReturn(null) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.getAaiAR(mex) + + verify(mex, never()).setVariable("foundActiveAR", true) + } + + + // ***** createAaiAR ***** + + @Test +// @Ignore + public void createAaiAR() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initCreateAaiAr(mex) + + MockPutAllottedResource(CUST, SVC, INST, ARID) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.createAaiAR(mex) + + def data = map.get("rollbackData") + assertNotNull(data) + assertTrue(data instanceof RollbackData) + + assertEquals("45", data.get(Prefix, "disableRollback")) + assertEquals("true", data.get(Prefix, "rollbackAAI")) + assertEquals(ARID, data.get(Prefix, "allottedResourceId")) + assertEquals("sii", data.get(Prefix, "serviceInstanceId")) + assertEquals("psii", data.get(Prefix, "parentServiceInstanceId")) + assertEquals(mex.getVariable("PSI_resourceLink")+"/allotted-resources/allotted-resource/"+ARID, data.get(Prefix, "aaiARPath")) + } + + @Test +// @Ignore + public void createAaiAR_NoArid_NoModelUuids() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initCreateAaiAr(mex) + + // no allottedResourceId - will be generated + + when(mex.getVariable("allottedResourceId")).thenReturn(null) + + wireMockRule + .stubFor(put(urlMatching("/aai/.*/allotted-resource/.*")) + .willReturn(aResponse() + .withStatus(200))) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.createAaiAR(mex) + + def arid = map.get("allottedResourceId") + assertNotNull(arid) + assertFalse(arid.isEmpty()) + + def data = map.get("rollbackData") + assertNotNull(data) + assertTrue(data instanceof RollbackData) + + assertEquals(arid, data.get(Prefix, "allottedResourceId")) + } + + @Test +// @Ignore + public void createAaiAR_MissingPsiLink() { + ExecutionEntity mex = setupMock() + initCreateAaiAr(mex) + + when(mex.getVariable("PSI_resourceLink")).thenReturn(null) + + MockPutAllottedResource(CUST, SVC, INST, ARID) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.createAaiAR(mex) })) + } + + @Test +// @Ignore + public void createAaiAR_HttpFailed() { + ExecutionEntity mex = setupMock() + initCreateAaiAr(mex) + + MockPutAllottedResource_500(CUST, SVC, INST, ARID) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.createAaiAR(mex) })) + } + + @Test +// @Ignore + public void createAaiAR_BpmnError() { + ExecutionEntity mex = setupMock() + initCreateAaiAr(mex) + + when(mex.getVariable("URN_aai_endpoint")).thenThrow(new BpmnError("expected exception")) + + MockPutAllottedResource(CUST, SVC, INST, ARID) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.createAaiAR(mex) })) + } + + @Test +// @Ignore + public void createAaiAR_Ex() { + ExecutionEntity mex = setupMock() + initCreateAaiAr(mex) + + when(mex.getVariable("URN_aai_endpoint")).thenThrow(new RuntimeException("expected exception")) + + MockPutAllottedResource(CUST, SVC, INST, ARID) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.createAaiAR(mex) })) + } + + + // ***** buildSDNCRequest ***** + + @Test +// @Ignore + public void buildSDNCRequest() { + ExecutionEntity mex = setupMock() + initBuildSDNCRequest(mex) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + String result = DoCreateAllottedResourceTXC.buildSDNCRequest(mex, "myact", "myreq") + + assertTrue(result.indexOf("myreq= 0) + assertTrue(result.indexOf("myact= 0) + assertTrue(result.indexOf("ari= 0) + assertTrue(result.indexOf("sii= 0) + assertTrue(result.indexOf("psii= 0) + assertTrue(result.indexOf("psii= 0) + assertTrue(result.indexOf("scu= 0) + assertTrue(result.indexOf("mri= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + } + + @Test +// @Ignore + public void buildSDNCRequest_Ex() { + ExecutionEntity mex = setupMock() + initBuildSDNCRequest(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.buildSDNCRequest(mex, "myact", "myreq") })) + } + + + // ***** preProcessSDNCAssign ***** + + @Test +// @Ignore + public void preProcessSDNCAssign() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def data = initPreProcessSDNC(mex) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.preProcessSDNCAssign(mex) + + def req = map.get("sdncAssignRequest") + assertNotNull(req) + + assertEquals(data, map.get("rollbackData")) + + def rbreq = data.get(Prefix, "sdncAssignRollbackReq") + + assertTrue(req.indexOf("assign= 0) + assertTrue(req.indexOf("CreateTunnelXConnInstance= 0) + assertTrue(req.indexOf("") >= 0) + + assertTrue(rbreq.indexOf("unassign= 0) + assertTrue(rbreq.indexOf("DeleteTunnelXConnInstance= 0) + assertTrue(rbreq.indexOf("") >= 0) + } + + @Test +// @Ignore + public void preProcessSDNCAssign_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCAssign(mex) })) + } + + @Test +// @Ignore + public void preProcessSDNCAssign_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCAssign(mex) })) + } + + + // ***** preProcessSDNCCreate ***** + + @Test +// @Ignore + public void preProcessSDNCCreate() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def data = initPreProcessSDNC(mex) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.preProcessSDNCCreate(mex) + + def req = map.get("sdncCreateRequest") + assertNotNull(req) + + assertEquals(data, map.get("rollbackData")) + + def rbreq = data.get(Prefix, "sdncCreateRollbackReq") + + assertTrue(req.indexOf("create= 0) + assertTrue(req.indexOf("CreateTunnelXConnInstance= 0) + assertTrue(req.indexOf("") >= 0) + + assertTrue(rbreq.indexOf("delete= 0) + assertTrue(rbreq.indexOf("DeleteTunnelXConnInstance= 0) + assertTrue(rbreq.indexOf("") >= 0) + + } + + @Test +// @Ignore + public void preProcessSDNCCreate_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCCreate(mex) })) + } + + @Test +// @Ignore + public void preProcessSDNCCreate_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCCreate(mex) })) + } + + + // ***** preProcessSDNCActivate ***** + + @Test +// @Ignore + public void preProcessSDNCActivate() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def data = initPreProcessSDNC(mex) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.preProcessSDNCActivate(mex) + + def req = map.get("sdncActivateRequest") + assertNotNull(req) + + assertEquals(data, map.get("rollbackData")) + + def rbreq = data.get(Prefix, "sdncActivateRollbackReq") + + assertTrue(req.indexOf("activate= 0) + assertTrue(req.indexOf("CreateTunnelXConnInstance= 0) + assertTrue(req.indexOf("") >= 0) + + assertTrue(rbreq.indexOf("deactivate= 0) + assertTrue(rbreq.indexOf("DeleteTunnelXConnInstance= 0) + assertTrue(rbreq.indexOf("") >= 0) + + } + + @Test +// @Ignore + public void preProcessSDNCActivate_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCActivate(mex) })) + } + + @Test +// @Ignore + public void preProcessSDNCActivate_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCActivate(mex) })) + } + + + // ***** validateSDNCResp ***** + + @Test +// @Ignore + public void validateSDNCResp() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + def data = initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "create") + + verify(mex).getVariable("WorkflowException") + verify(mex).getVariable("SDNCA_SuccessIndicator") + verify(mex).getVariable("rollbackData") + + assertEquals(data, map.get("rollbackData")) + + assertEquals("true", data.get(Prefix, "rollback" + "SDNCcreate")) + + } + + @Test +// @Ignore + public void validateSDNCResp_Get() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "get") + + verify(mex).getVariable("WorkflowException") + verify(mex).getVariable("SDNCA_SuccessIndicator") + + verify(mex, never()).getVariable("rollbackData") + } + + @Test +// @Ignore + public void validateSDNCResp_Unsuccessful() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + // unsuccessful + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(false) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "create") })) + } + + @Test +// @Ignore + public void validateSDNCResp_BpmnError() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "create") })) + } + + @Test +// @Ignore + public void validateSDNCResp_Ex() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp() + + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "create") })) + } + + + // ***** preProcessSDNCGet ***** + + @Test +// @Ignore + public void preProcessSDNCGet_FoundAR() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcessSDNCGet(mex) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.preProcessSDNCGet(mex) + + String req = map.get("sdncGetRequest") + + assertTrue(req.indexOf("") >= 0) + assertTrue(req.indexOf("sii= 0) + assertTrue(req.indexOf("arlink= 0) + assertTrue(req.indexOf("myurl= 0) + + } + + @Test +// @Ignore + public void preProcessSDNCGet_NotFoundAR() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcessSDNCGet(mex) + + when(mex.getVariable("foundActiveAR")).thenReturn(false) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.preProcessSDNCGet(mex) + + String req = map.get("sdncGetRequest") + + assertTrue(req.indexOf("") >= 0) + assertTrue(req.indexOf("sii= 0) + assertTrue(req.indexOf("assignlink= 0) + assertTrue(req.indexOf("myurl= 0) + + } + + @Test +// @Ignore + public void preProcessSDNCGet_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNCGet(mex) + + when(mex.getVariable("foundActiveAR")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCGet(mex) })) + } + + + // ***** updateAaiAROrchStatus ***** + + @Test +// @Ignore + public void updateAaiAROrchStatus() { + MockPatchAllottedResource(CUST, SVC, INST, ARID) + + ExecutionEntity mex = setupMock() + initUpdateAaiAROrchStatus(mex) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.updateAaiAROrchStatus(mex, "success") + } + + + // ***** generateOutputs ***** + + @Test +// @Ignore + public void generateOutputs() { + ExecutionEntity mex = setupMock() + def txctop = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXC/SDNCTopologyQueryCallback.xml") + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("enhancedCallbackRequestData")).thenReturn(txctop) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.generateOutputs(mex) + + verify(mex).setVariable("allotedResourceName", "namefromrequest") + verify(mex).setVariable("vni", "my-vni") + verify(mex).setVariable("vgmuxBearerIP", "my-bearer-ip") + verify(mex).setVariable("vgmuxLanIP", "my-lan-ip") + + } + + @Test +// @Ignore + public void generateOutputs_BadXml() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("enhancedCallbackRequestData")).thenReturn("invalid xml") + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.generateOutputs(mex) + + verify(mex, never()).setVariable(anyString(), anyString()) + + } + + @Test +// @Ignore + public void generateOutputs_BpmnError() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + DoCreateAllottedResourceTXC.generateOutputs(mex) + verify(mex, never()).setVariable(anyString(), anyString()) + + } + + @Test +// @Ignore + public void generateOutputs_Ex() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + DoCreateAllottedResourceTXC.generateOutputs(mex) + verify(mex, never()).setVariable(anyString(), anyString()) + + } + + + // ***** preProcessRollback ***** + + @Test +// @Ignore + public void preProcessRollback() { + ExecutionEntity mex = setupMock() + WorkflowException wfe = mock(WorkflowException.class) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("WorkflowException")).thenReturn(wfe) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.preProcessRollback(mex) + + verify(mex).setVariable("prevWorkflowException", wfe) + + } + + @Test +// @Ignore + public void preProcessRollback_NotWFE() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("WorkflowException")).thenReturn("I'm not a WFE") + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.preProcessRollback(mex) + +// verify(mex, never()).setVariable("prevWorkflowException", any()) + + } + + @Test +// @Ignore + public void preProcessRollback_BpmnError() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + DoCreateAllottedResourceTXC.preProcessRollback(mex) + + } + + @Test +// @Ignore + public void preProcessRollback_Ex() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + DoCreateAllottedResourceTXC.preProcessRollback(mex) + + } + + + // ***** postProcessRollback ***** + + @Test +// @Ignore + public void postProcessRollback() { + ExecutionEntity mex = setupMock() + WorkflowException wfe = mock(WorkflowException.class) + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prevWorkflowException")).thenReturn(wfe) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.postProcessRollback(mex) + + verify(mex).setVariable("WorkflowException", wfe) + verify(mex).setVariable("rollbackData", null) + + } + + @Test +// @Ignore + public void postProcessRollback_NotWFE() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prevWorkflowException")).thenReturn("I'm not a WFE") + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + DoCreateAllottedResourceTXC.postProcessRollback(mex) + +// verify(mex, never()).setVariable("WorkflowException", any()) + verify(mex).setVariable("rollbackData", null) + + } + + @Test +// @Ignore + public void postProcessRollback_BpmnError() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prevWorkflowException")).thenThrow(new BpmnError("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.postProcessRollback(mex) })) + verify(mex, never()).setVariable("rollbackData", null) + + } + + @Test +// @Ignore + public void postProcessRollback_Ex() { + ExecutionEntity mex = setupMock() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prevWorkflowException")).thenThrow(new RuntimeException("expected exception")) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + DoCreateAllottedResourceTXC.postProcessRollback(mex) + verify(mex, never()).setVariable("rollbackData", null) + + } + + private boolean checkMissingPreProcessRequest(String fieldnm) { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() + + when(mex.getVariable(fieldnm)).thenReturn("") + + return doBpmnError( { _ -> DoCreateAllottedResourceTXC.preProcessRequest(mex) }) + } + + private void initPreProcess(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("sdncurn") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") + when(mex.getVariable("allottedResourceModelInfo")).thenReturn("armi") + when(mex.getVariable("brgWanMacAddress")).thenReturn("bwma") + when(mex.getVariable("allottedResourceRole")).thenReturn("arr") + when(mex.getVariable("allottedResourceType")).thenReturn("art") + } + + private void initGetAaiAR(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("allottedResourceType")).thenReturn("TXCt") + when(mex.getVariable("allottedResourceRole")).thenReturn("TXCr") + when(mex.getVariable("CSI_service")).thenReturn(FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXC/getAR.xml")) + when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx) + when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active") + } + + private initCreateAaiAr(ExecutionEntity mex) { + when(mex.getVariable("disableRollback")).thenReturn(45) + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("allottedResourceId")).thenReturn(ARID) + when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx) + when(mex.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn(urnProps.get("mso.workflow.global.default.aai.namespace")) + when(mex.getVariable("PSI_resourceLink")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST) + when(mex.getVariable("allottedResourceType")).thenReturn("TXCt") + when(mex.getVariable("allottedResourceRole")).thenReturn("TXCr") + when(mex.getVariable("CSI_resourceLink")).thenReturn(aaiUriPfx+"/aai/v9/mycsi") + when(mex.getVariable("allottedResourceModelInfo")).thenReturn(""" + { + "modelInvariantUuid":"modelinvuuid", + "modelUuid":"modeluuid", + "modelCustomizationUuid":"modelcustuuid" + } + """) + } + + private initBuildSDNCRequest(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("allottedResourceId")).thenReturn("ari") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") + when(mex.getVariable("sdncCallbackUrl")).thenReturn("scu") + when(mex.getVariable("msoRequestId")).thenReturn("mri") + } + + private RollbackData initPreProcessSDNC(ExecutionEntity mex) { + def data = new RollbackData() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("rollbackData")).thenReturn(data) + + return data + } + + private initPreProcessSDNCGet(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl") + when(mex.getVariable("foundActiveAR")).thenReturn(true) + when(mex.getVariable("aaiARGetResponse")).thenReturn("arlink") + when(mex.getVariable("sdncAssignResponse")).thenReturn("<object-path>assignlink</object-path>") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("junitSleepMs")).thenReturn("5") + when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl") + } + + private RollbackData initValidateSDNCResp(ExecutionEntity mex) { + def data = new RollbackData() + + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prefix")).thenReturn(Prefix) + when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) + when(mex.getVariable("rollbackData")).thenReturn(data) + + return data + } + + private String initValidateSDNCResp_Resp() { + return "<response-code>200</response-code>" + } + + private initUpdateAaiAROrchStatus(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy new file mode 100644 index 0000000000..f91a39c856 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy @@ -0,0 +1,600 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.vcpe.scripts + + +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution +import org.junit.Before +import org.junit.BeforeClass +import org.junit.Rule +import org.junit.Test +import org.junit.Ignore +import org.mockito.MockitoAnnotations +import org.camunda.bpm.engine.delegate.BpmnError +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.mock.FileUtil + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse +import static com.github.tomakehurst.wiremock.client.WireMock.delete +import static com.github.tomakehurst.wiremock.client.WireMock.get +import static com.github.tomakehurst.wiremock.client.WireMock.patch +import static com.github.tomakehurst.wiremock.client.WireMock.put +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching +import static org.junit.Assert.*; +import static org.mockito.Mockito.* +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchAllottedResource +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockQueryAllottedResourceById + +import java.util.Map + +import org.openecomp.mso.bpmn.core.RollbackData +import org.openecomp.mso.bpmn.vcpe.scripts.MapSetter + +import com.github.tomakehurst.wiremock.junit.WireMockRule + +class DoDeleteAllottedResourceBRGTest extends GroovyTestBase { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(PORT) + + String Prefix = "DDARBRG_" + + @BeforeClass + public static void setUpBeforeClass() { + super.setUpBeforeClass() + } + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + public DoDeleteAllottedResourceBRGTest() { + super("DoDeleteAllottedResourceBRG") + } + + + // ***** preProcessRequest ***** + + @Test +// @Ignore + public void preProcessRequest() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + DoDeleteAllottedResourceBRG.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("sdncCallbackUrl", "sdncurn") + + assertTrue(checkMissingPreProcessRequest("URN_mso_workflow_sdncadapter_callback")) + assertTrue(checkMissingPreProcessRequest("serviceInstanceId")) + assertTrue(checkMissingPreProcessRequest("allottedResourceId")) + } + + @Test +// @Ignore + public void preProcessRequest_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("serviceInstanceId")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.preProcessRequest(mex) })) + } + + @Test +// @Ignore + public void preProcessRequest_Ex() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("serviceInstanceId")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.preProcessRequest(mex) })) + } + + + // ***** getAaiAR ***** + + @Test +// @Ignore + public void getAaiAR() { + MockQueryAllottedResourceById(ARID, "GenericFlows/getARUrlById.xml") + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml") + + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + DoDeleteAllottedResourceBRG.getAaiAR(mex) + + verify(mex).setVariable("parentServiceInstanceId", INST) + } + + @Test +// @Ignore + public void getAaiAR_EmptyResponse() { + + // note: empty result-link + wireMockRule + .stubFor(get(urlMatching("/aai/.*/search/.*")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBody(""))) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml") + + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.getAaiAR(mex) })) + } + + + // ***** updateAaiAROrchStatus ***** + + @Test +// @Ignore + public void updateAaiAROrchStatus() { + ExecutionEntity mex = setupMock() + initUpdateAaiAROrchStatus(mex) + + MockPatchAllottedResource(CUST, SVC, INST, ARID) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + DoDeleteAllottedResourceBRG.updateAaiAROrchStatus(mex, "success") + } + + + // ***** buildSDNCRequest ***** + + @Test +// @Ignore + public void buildSDNCRequest() { + ExecutionEntity mex = setupMock() + initBuildSDNCRequest(mex) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + String result = DoDeleteAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") + + assertTrue(result.indexOf("myreq= 0) + assertTrue(result.indexOf("myact= 0) + assertTrue(result.indexOf("ari= 0) + assertTrue(result.indexOf("sii= 0) + assertTrue(result.indexOf("psii= 0) + assertTrue(result.indexOf("psii= 0) + assertTrue(result.indexOf("scu= 0) + assertTrue(result.indexOf("mri= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + } + + @Test +// @Ignore + public void buildSDNCRequest_Ex() { + ExecutionEntity mex = setupMock() + initBuildSDNCRequest(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") })) + } + + + // ***** preProcessSDNCUnassign ***** + + @Test +// @Ignore + public void preProcessSDNCUnassign() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcessSDNC(mex) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + DoDeleteAllottedResourceBRG.preProcessSDNCUnassign(mex) + + def req = map.get("sdncUnassignRequest") + + assertTrue(req.indexOf("unassign= 0) + assertTrue(req.indexOf("DeleteBRGInstance= 0) + assertTrue(req.indexOf("") >= 0) + } + + @Test +// @Ignore + public void preProcessSDNCUnassign_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCUnassign(mex) })) + } + + @Test +// @Ignore + public void preProcessSDNCUnassign_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCUnassign(mex) })) + } + + + // ***** preProcessSDNCDelete ***** + + @Test +// @Ignore + public void preProcessSDNCDelete() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcessSDNC(mex) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + DoDeleteAllottedResourceBRG.preProcessSDNCDelete(mex) + + def req = map.get("sdncDeleteRequest") + + assertTrue(req.indexOf("delete= 0) + assertTrue(req.indexOf("DeleteBRGInstance= 0) + assertTrue(req.indexOf("") >= 0) + } + + @Test +// @Ignore + public void preProcessSDNCDelete_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDelete(mex) })) + } + + @Test +// @Ignore + public void preProcessSDNCDelete_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDelete(mex) })) + } + + + // ***** preProcessSDNCDeactivate ***** + + @Test +// @Ignore + public void preProcessSDNCDeactivate() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcessSDNC(mex) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + DoDeleteAllottedResourceBRG.preProcessSDNCDeactivate(mex) + + def req = map.get("sdncDeactivateRequest") + + assertTrue(req.indexOf("deactivate= 0) + assertTrue(req.indexOf("DeleteBRGInstance= 0) + assertTrue(req.indexOf("") >= 0) + } + + @Test +// @Ignore + public void preProcessSDNCDeactivate_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDeactivate(mex) })) + } + + @Test +// @Ignore + public void preProcessSDNCDeactivate_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDeactivate(mex) })) + } + + + // ***** validateSDNCResp ***** + + @Test +// @Ignore + public void validateSDNCResp() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp(200) + + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create") + + verify(mex).getVariable("WorkflowException") + verify(mex).getVariable("SDNCA_SuccessIndicator") + verify(mex).getVariable(Prefix+"sdncResponseSuccess") + + verify(mex, never()).getVariable(Prefix + "sdncRequestDataResponseCode") + verify(mex, never()).setVariable("wasDeleted", false) + } + + @Test +// @Ignore + public void validateSDNCResp_Fail404_Deactivate_FailNotFound() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + + def resp = initValidateSDNCResp_Resp(404) + when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404") + when(mex.getVariable("failNotFound")).thenReturn("true") + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "deactivate")})) + } + + @Test +// @Ignore + public void validateSDNCResp_Fail404_Deactivate() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + + def resp = initValidateSDNCResp_Resp(404) + when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404") + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "deactivate") + + verify(mex).setVariable("ARNotFoundInSDNC", true) + verify(mex).setVariable("wasDeleted", false) + } + + @Test +// @Ignore + public void validateSDNCResp_Fail404() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + + def resp = initValidateSDNCResp_Resp(404) + when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404") + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create")})) + } + + @Test +// @Ignore + public void validateSDNCResp_Deactivate() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp(200) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "deactivate")})) + } + + @Test +// @Ignore + public void validateSDNCResp_BpmnError() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp(200) + + when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create") })) + } + + @Test +// @Ignore + public void validateSDNCResp_Ex() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp(200) + + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create") })) + } + + @Test +// @Ignore + public void deleteAaiAR() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + DoDeleteAllottedResourceBRG.deleteAaiAR(mex) + } + + @Test +// @Ignore + public void deleteAaiAR_NoArPath() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenReturn("") + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.deleteAaiAR(mex) })) + } + + @Test +// @Ignore + public void deleteAaiAR_BpmnError() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.deleteAaiAR(mex) })) + } + + @Test +// @Ignore + public void deleteAaiAR_Ex() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.deleteAaiAR(mex) })) + } + + private boolean checkMissingPreProcessRequest(String fieldnm) { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() + + when(mex.getVariable(fieldnm)).thenReturn("") + + return doBpmnError( { _ -> DoDeleteAllottedResourceBRG.preProcessRequest(mex) }) + } + + private void initPreProcess(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("sdncurn") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("allottedResourceId")).thenReturn("ari") + } + + private void initGetAaiAR(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("allottedResourceType")).thenReturn("BRG") + when(mex.getVariable("allottedResourceRole")).thenReturn("BRG") + when(mex.getVariable("allottedResourceId")).thenReturn(ARID) + when(mex.getVariable("CSI_service")).thenReturn(FileUtil.readResourceFile("__files/VCPE/DoDeleteAllottedResourceBRG/getAR.xml")) + when(mex.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn(urnProps.get("mso.workflow.global.default.aai.namespace")) + when(mex.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn(urnProps.get("mso.workflow.global.default.aai.version")) + when(mex.getVariable("URN_mso_workflow_default_aai_v8_nodes_query_uri")).thenReturn(urnProps.get("mso.workflow.default.aai.v8.nodes-query.uri")) + when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx) + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active") + } + + private initUpdateAaiAROrchStatus(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + } + + private initBuildSDNCRequest(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("allottedResourceId")).thenReturn("ari") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") + when(mex.getVariable("sdncCallbackUrl")).thenReturn("scu") + when(mex.getVariable("msoRequestId")).thenReturn("mri") + } + + private initPreProcessSDNC(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + } + + private initValidateSDNCResp(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prefix")).thenReturn(Prefix) + when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) + } + + private String initValidateSDNCResp_Resp(int code) { + return "<response-code>${code}</response-code>" + } + + private initDeleteAaiAR(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + when(mex.getVariable("aaiARResourceVersion")).thenReturn("myvers") + when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx) + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy new file mode 100644 index 0000000000..97f714d98d --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy @@ -0,0 +1,600 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.vcpe.scripts + + +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution +import org.junit.Before +import org.junit.BeforeClass +import org.junit.Rule +import org.junit.Test +import org.junit.Ignore +import org.mockito.MockitoAnnotations +import org.camunda.bpm.engine.delegate.BpmnError +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.mock.FileUtil + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse +import static com.github.tomakehurst.wiremock.client.WireMock.delete +import static com.github.tomakehurst.wiremock.client.WireMock.get +import static com.github.tomakehurst.wiremock.client.WireMock.patch +import static com.github.tomakehurst.wiremock.client.WireMock.put +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching +import static org.junit.Assert.*; +import static org.mockito.Mockito.* +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchAllottedResource +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockQueryAllottedResourceById + +import java.util.Map + +import org.openecomp.mso.bpmn.core.RollbackData +import org.openecomp.mso.bpmn.vcpe.scripts.MapSetter + +import com.github.tomakehurst.wiremock.junit.WireMockRule + +class DoDeleteAllottedResourceTXCTest extends GroovyTestBase { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(PORT) + + String Prefix = "DDARTXC_" + + @BeforeClass + public static void setUpBeforeClass() { + super.setUpBeforeClass() + } + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + public DoDeleteAllottedResourceTXCTest() { + super("DoDeleteAllottedResourceTXC") + } + + + // ***** preProcessRequest ***** + + @Test +// @Ignore + public void preProcessRequest() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + DoDeleteAllottedResourceTXC.preProcessRequest(mex) + + verify(mex).getVariable(DBGFLAG) + verify(mex).setVariable("prefix", Prefix) + verify(mex).setVariable("sdncCallbackUrl", "sdncurn") + + assertTrue(checkMissingPreProcessRequest("URN_mso_workflow_sdncadapter_callback")) + assertTrue(checkMissingPreProcessRequest("serviceInstanceId")) + assertTrue(checkMissingPreProcessRequest("allottedResourceId")) + } + + @Test +// @Ignore + public void preProcessRequest_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("serviceInstanceId")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.preProcessRequest(mex) })) + } + + @Test +// @Ignore + public void preProcessRequest_Ex() { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + when(mex.getVariable("serviceInstanceId")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.preProcessRequest(mex) })) + } + + + // ***** getAaiAR ***** + + @Test +// @Ignore + public void getAaiAR() { + MockQueryAllottedResourceById(ARID, "GenericFlows/getARUrlById.xml") + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml") + + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + DoDeleteAllottedResourceTXC.getAaiAR(mex) + + verify(mex).setVariable("parentServiceInstanceId", INST) + } + + @Test +// @Ignore + public void getAaiAR_EmptyResponse() { + + // note: empty result-link + wireMockRule + .stubFor(get(urlMatching("/aai/.*/search/.*")) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBody(""))) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml") + + ExecutionEntity mex = setupMock() + initGetAaiAR(mex) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.getAaiAR(mex) })) + } + + + // ***** updateAaiAROrchStatus ***** + + @Test +// @Ignore + public void updateAaiAROrchStatus() { + ExecutionEntity mex = setupMock() + initUpdateAaiAROrchStatus(mex) + + MockPatchAllottedResource(CUST, SVC, INST, ARID) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + DoDeleteAllottedResourceTXC.updateAaiAROrchStatus(mex, "success") + } + + + // ***** buildSDNCRequest ***** + + @Test +// @Ignore + public void buildSDNCRequest() { + ExecutionEntity mex = setupMock() + initBuildSDNCRequest(mex) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + String result = DoDeleteAllottedResourceTXC.buildSDNCRequest(mex, "myact", "myreq") + + assertTrue(result.indexOf("myreq= 0) + assertTrue(result.indexOf("myact= 0) + assertTrue(result.indexOf("ari= 0) + assertTrue(result.indexOf("sii= 0) + assertTrue(result.indexOf("psii= 0) + assertTrue(result.indexOf("psii= 0) + assertTrue(result.indexOf("scu= 0) + assertTrue(result.indexOf("mri= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + assertTrue(result.indexOf("") >= 0) + } + + @Test +// @Ignore + public void buildSDNCRequest_Ex() { + ExecutionEntity mex = setupMock() + initBuildSDNCRequest(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.buildSDNCRequest(mex, "myact", "myreq") })) + } + + + // ***** preProcessSDNCUnassign ***** + + @Test +// @Ignore + public void preProcessSDNCUnassign() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcessSDNC(mex) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + DoDeleteAllottedResourceTXC.preProcessSDNCUnassign(mex) + + def req = map.get("sdncUnassignRequest") + + assertTrue(req.indexOf("unassign= 0) + assertTrue(req.indexOf("DeleteTunnelXConnInstance= 0) + assertTrue(req.indexOf("") >= 0) + } + + @Test +// @Ignore + public void preProcessSDNCUnassign_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCUnassign(mex) })) + } + + @Test +// @Ignore + public void preProcessSDNCUnassign_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCUnassign(mex) })) + } + + + // ***** preProcessSDNCDelete ***** + + @Test +// @Ignore + public void preProcessSDNCDelete() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcessSDNC(mex) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + DoDeleteAllottedResourceTXC.preProcessSDNCDelete(mex) + + def req = map.get("sdncDeleteRequest") + + assertTrue(req.indexOf("delete= 0) + assertTrue(req.indexOf("DeleteTunnelXConnInstance= 0) + assertTrue(req.indexOf("") >= 0) + } + + @Test +// @Ignore + public void preProcessSDNCDelete_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCDelete(mex) })) + } + + @Test +// @Ignore + public void preProcessSDNCDelete_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCDelete(mex) })) + } + + + // ***** preProcessSDNCDeactivate ***** + + @Test +// @Ignore + public void preProcessSDNCDeactivate() { + ExecutionEntity mex = setupMock() + def map = setupMap(mex) + initPreProcessSDNC(mex) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + DoDeleteAllottedResourceTXC.preProcessSDNCDeactivate(mex) + + def req = map.get("sdncDeactivateRequest") + + assertTrue(req.indexOf("deactivate= 0) + assertTrue(req.indexOf("DeleteTunnelXConnInstance= 0) + assertTrue(req.indexOf("") >= 0) + } + + @Test +// @Ignore + public void preProcessSDNCDeactivate_BpmnError() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCDeactivate(mex) })) + } + + @Test +// @Ignore + public void preProcessSDNCDeactivate_Ex() { + ExecutionEntity mex = setupMock() + initPreProcessSDNC(mex) + + when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCDeactivate(mex) })) + } + + + // ***** validateSDNCResp ***** + + @Test +// @Ignore + public void validateSDNCResp() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp(200) + + when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "create") + + verify(mex).getVariable("WorkflowException") + verify(mex).getVariable("SDNCA_SuccessIndicator") + verify(mex).getVariable(Prefix+"sdncResponseSuccess") + + verify(mex, never()).getVariable(Prefix + "sdncRequestDataResponseCode") + verify(mex, never()).setVariable("wasDeleted", false) + } + + @Test +// @Ignore + public void validateSDNCResp_Fail404_Deactivate_FailNotFound() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + + def resp = initValidateSDNCResp_Resp(404) + when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404") + when(mex.getVariable("failNotFound")).thenReturn("true") + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "deactivate")})) + } + + @Test +// @Ignore + public void validateSDNCResp_Fail404_Deactivate() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + + def resp = initValidateSDNCResp_Resp(404) + when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404") + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "deactivate") + + verify(mex).setVariable("ARNotFoundInSDNC", true) + verify(mex).setVariable("wasDeleted", false) + } + + @Test +// @Ignore + public void validateSDNCResp_Fail404() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + + def resp = initValidateSDNCResp_Resp(404) + when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404") + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "create")})) + } + + @Test +// @Ignore + public void validateSDNCResp_Deactivate() { + ExecutionEntity mex = setupMock() + def data = initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp(200) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "deactivate")})) + } + + @Test +// @Ignore + public void validateSDNCResp_BpmnError() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp(200) + + when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "create") })) + } + + @Test +// @Ignore + public void validateSDNCResp_Ex() { + ExecutionEntity mex = setupMock() + initValidateSDNCResp(mex) + def resp = initValidateSDNCResp_Resp(200) + + when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "create") })) + } + + @Test +// @Ignore + public void deleteAaiAR() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + DoDeleteAllottedResourceTXC.deleteAaiAR(mex) + } + + @Test +// @Ignore + public void deleteAaiAR_NoArPath() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenReturn("") + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.deleteAaiAR(mex) })) + } + + @Test +// @Ignore + public void deleteAaiAR_BpmnError() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.deleteAaiAR(mex) })) + } + + @Test +// @Ignore + public void deleteAaiAR_Ex() { + ExecutionEntity mex = setupMock() + initDeleteAaiAR(mex) + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml") + MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) + + when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception")) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.deleteAaiAR(mex) })) + } + + private boolean checkMissingPreProcessRequest(String fieldnm) { + ExecutionEntity mex = setupMock() + initPreProcess(mex) + + DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() + + when(mex.getVariable(fieldnm)).thenReturn("") + + return doBpmnError( { _ -> DoDeleteAllottedResourceTXC.preProcessRequest(mex) }) + } + + private void initPreProcess(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("sdncurn") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("allottedResourceId")).thenReturn("ari") + } + + private void initGetAaiAR(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("allottedResourceType")).thenReturn("TXC") + when(mex.getVariable("allottedResourceRole")).thenReturn("TXC") + when(mex.getVariable("allottedResourceId")).thenReturn(ARID) + when(mex.getVariable("CSI_service")).thenReturn(FileUtil.readResourceFile("__files/VCPE/DoDeleteAllottedResourceTXC/getAR.xml")) + when(mex.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn(urnProps.get("mso.workflow.global.default.aai.namespace")) + when(mex.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn(urnProps.get("mso.workflow.global.default.aai.version")) + when(mex.getVariable("URN_mso_workflow_default_aai_v8_nodes_query_uri")).thenReturn(urnProps.get("mso.workflow.default.aai.v8.nodes-query.uri")) + when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx) + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active") + } + + private initUpdateAaiAROrchStatus(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + } + + private initBuildSDNCRequest(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("allottedResourceId")).thenReturn("ari") + when(mex.getVariable("serviceInstanceId")).thenReturn("sii") + when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") + when(mex.getVariable("sdncCallbackUrl")).thenReturn("scu") + when(mex.getVariable("msoRequestId")).thenReturn("mri") + } + + private initPreProcessSDNC(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + } + + private initValidateSDNCResp(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("prefix")).thenReturn(Prefix) + when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) + } + + private String initValidateSDNCResp_Resp(int code) { + return "<response-code>${code}</response-code>" + } + + private initDeleteAaiAR(ExecutionEntity mex) { + when(mex.getVariable(DBGFLAG)).thenReturn("true") + when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) + when(mex.getVariable("aaiARResourceVersion")).thenReturn("myvers") + when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx) + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/GroovyTestBase.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/GroovyTestBase.groovy new file mode 100644 index 0000000000..121583ec10 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/GroovyTestBase.groovy @@ -0,0 +1,124 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.vcpe.scripts + + +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution +import org.junit.Before +import org.junit.BeforeClass +import org.junit.Rule +import org.junit.Test +import org.junit.Ignore +import org.mockito.MockitoAnnotations +import org.camunda.bpm.engine.delegate.BpmnError +import org.openecomp.mso.bpmn.core.WorkflowException +import org.openecomp.mso.bpmn.mock.FileUtil + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse +import static com.github.tomakehurst.wiremock.client.WireMock.get +import static com.github.tomakehurst.wiremock.client.WireMock.patch +import static com.github.tomakehurst.wiremock.client.WireMock.put +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching +import static org.junit.Assert.*; +import static org.mockito.Mockito.* +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource +import org.openecomp.mso.bpmn.core.RollbackData +import org.openecomp.mso.bpmn.vcpe.scripts.MapSetter + +import com.github.tomakehurst.wiremock.junit.WireMockRule + +class GroovyTestBase { + + static final int PORT = 28090 + static final String LOCAL_URI = "http://localhost:" + PORT + + static final String CUST = "SDN-ETHERNET-INTERNET" + static final String SVC = "123456789" + static final String INST = "MIS%252F1604%252F0026%252FSW_INTERNET" + static final String ARID = "arId-1" + static final String VERS = "myvers" + + static final String DBGFLAG = "isDebugLogEnabled" + + static Properties urnProps = new Properties() + static String aaiUriPfx + + String processName + + public static void setUpBeforeClass() { + def fr = new FileReader("src/test/resources/mso.bpmn.urn.properties") + urnProps.load(fr) + fr.close() + + aaiUriPfx = urnProps.get("aai.endpoint") + } + + public GroovyTestBase(String processName) { + this.processName = processName + } + + public boolean doBpmnError(def func) { + + try { + func() + return false; + + } catch(BpmnError e) { + return true; + } + } + + public ExecutionEntity setupMock() { + + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn(processName) + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn(processName) + when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") + ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) + when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) + + ExecutionEntity mex = mock(ExecutionEntity.class) + + when(mex.getId()).thenReturn("100") + when(mex.getProcessDefinitionId()).thenReturn(processName) + when(mex.getProcessInstanceId()).thenReturn(processName) + when(mex.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mex.getProcessEngineServices().getRepositoryService().getProcessDefinition(mex.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + when(mex.getVariable("isAsyncProcess")).thenReturn("true") + when(mex.getVariable(processName+"WorkflowResponseSent")).thenReturn("false") + + return mex + } + + public Map setupMap(ExecutionEntity mex) { + MapSetter mapset = new MapSetter(); + doAnswer(mapset).when(mex).setVariable(any(), any()) + return mapset.getMap(); + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/MapGetter.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/MapGetter.groovy new file mode 100644 index 0000000000..062cc0697e --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/MapGetter.groovy @@ -0,0 +1,48 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.vcpe.scripts; + +import java.util.HashMap; +import java.util.Map; + +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; + +class MapGetter implements Answer { + final Map map; + + public MapGetter() { + map = new HashMap<>(); + } + + public MapGetter(Map map) { + this.map = map; + } + + public Map getMap() { + return map; + } + + @Override + public Object answer(InvocationOnMock invocation) throws Throwable { + return map.get(invocation.getArgumentAt(0, String.class)); + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/MapSetter.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/MapSetter.groovy new file mode 100644 index 0000000000..e3395323d7 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/MapSetter.groovy @@ -0,0 +1,49 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.vcpe.scripts; + +import java.util.HashMap; +import java.util.Map; + +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; + +class MapSetter implements Answer { + final Map map; + + public MapSetter() { + map = new HashMap<>(); + } + + public MapSetter(Map map) { + this.map = map; + } + + public Map getMap() { + return map; + } + + @Override + public Void answer(InvocationOnMock invocation) throws Throwable { + map.put(invocation.getArgumentAt(0, String.class), invocation.getArgumentAt(1, Object.class)); + return null; + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/AbstractTestBase.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/AbstractTestBase.java new file mode 100644 index 0000000000..e7b80f12ab --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/AbstractTestBase.java @@ -0,0 +1,41 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.vcpe; + +import org.openecomp.mso.bpmn.common.WorkflowTest; + +public class AbstractTestBase extends WorkflowTest { + + + public static final String CUST = "SDN-ETHERNET-INTERNET"; + public static final String SVC = "123456789"; + public static final String INST = "MIS%252F1604%252F0026%252FSW_INTERNET"; + public static final String PARENT_INST = "MIS%252F1604%252F0027%252FSW_INTERNET"; + public static final String ARID = "arId-1"; + public static final String ARVERS = "1490627351232"; + + public static final String DEC_INST = "MIS%2F1604%2F0026%2FSW_INTERNET"; + public static final String DEC_PARENT_INST = "MIS%2F1604%2F0027%2FSW_INTERNET"; + + public static final String VAR_SUCCESS_IND = "SuccessIndicator"; + public static final String VAR_WFEX = "SavedWorkflowException1"; + public static final String VAR_RESP_CODE = "CMSO_ResponseCode"; + public static final String VAR_COMP_REQ = "CompleteMsoProcessRequest"; +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/CreateVcpeResCustServiceTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/CreateVcpeResCustServiceTest.java index a94dc85d06..8f94187f48 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/CreateVcpeResCustServiceTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/CreateVcpeResCustServiceTest.java @@ -1,4 +1,4 @@ -/*- +/* * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ @@ -7,9 +7,9 @@ * 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. @@ -17,24 +17,22 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.mso.bpmn.vcpe; -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetCustomer; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchAllottedResource; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutAllottedResource; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutServiceInstance; import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogData; import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; -// TODO: uncomment when Homing BB is merged -// import static org.openecomp.mso.bpmn.mock.StubResponseSNIRO.mockSNIRO; import java.io.IOException; import java.util.HashMap; @@ -42,569 +40,335 @@ import java.util.Map; import java.util.UUID; import org.camunda.bpm.engine.test.Deployment; -import org.junit.Ignore; import org.junit.Test; -import org.openecomp.mso.bpmn.common.WorkflowTest; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; +import org.openecomp.mso.bpmn.common.BPMNUtil; import org.openecomp.mso.bpmn.mock.FileUtil; -public class CreateVcpeResCustServiceTest extends WorkflowTest { +public class CreateVcpeResCustServiceTest extends AbstractTestBase { + private static final String PROCNAME = "CreateVcpeResCustService"; + private static final String Prefix = "CVRCS_"; + private final CallbackSet callbacks = new CallbackSet(); private final String request; public CreateVcpeResCustServiceTest() throws IOException { - callbacks.put("assign", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyAssignCallback.xml")); - callbacks.put("query", FileUtil.readResourceFile("__files/VCPE/SDNCTopologyQueryCallbackNetworkInstance.xml")); - callbacks.put("activate", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyActivateCallback.xml")); - callbacks.put("vnfCreate", FileUtil.readResourceFile("__files/VCPE/VfModularity/VNFAdapterRestCreateCallback.xml")); - callbacks.put("create", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyCreateCallback.xml")); - callbacks.put("queryTXC", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXC/SDNCTopologyQueryCallback.xml")); - callbacks.put("queryBRG", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/SDNCTopologyQueryCallback.xml")); - - callbacks.put("sniro", JSON, "SNIROResponse", FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallback2AR1Vnf")); - callbacks.put("sniro2", JSON, "SNIROResponse", FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallback2AR1Vnf2Net")); - callbacks.put("sniroNoSol", JSON, "SNIROResponse", FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackNoSolutionFound")); - callbacks.put("sniroPolicyEx", JSON, "SNIROResponse", FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackPolicyException")); - callbacks.put("sniroServiceEx", JSON, "SNIROResponse", FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackServiceException")); - - request = FileUtil.readResourceFile("__files/VCPE/request.json"); + callbacks.put("assign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyAssignCallback.xml")); + callbacks.put("create", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyCreateCallback.xml")); + callbacks.put("activate", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyActivateCallback.xml")); + callbacks.put("queryTXC", FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryTXCCallback.xml")); + callbacks.put("queryBRG", FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryBRGCallback.xml")); + callbacks.put("deactivate", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallback.xml")); + callbacks.put("delete", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeleteCallback.xml")); + callbacks.put("unassign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyUnassignCallback.xml")); + + request = FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/requestNoSIName.json"); } + + @Test + @Deployment(resources = { + "process/CreateVcpeResCustService.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/GenericPutService.bpmn", + "subprocess/BuildingBlock/DecomposeService.bpmn", + "subprocess/DoCreateServiceInstance.bpmn", + "subprocess/DoCreateAllottedResourceTXC.bpmn", + "subprocess/DoCreateAllottedResourceBRG.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + + // stubs + "VCPE/stubprocess/Homing.bpmn", + "VCPE/stubprocess/DoCreateVnfAndModules.bpmn"}) + + public void testCreateVcpeResCustService_Success() throws Exception { + + MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef", "2", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json"); + MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json"); + MockGetCustomer(CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml"); + + // TODO: the SI should NOT have to be URL-encoded yet again! + MockPutServiceInstance(CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml"); + MockGetServiceInstance(CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml"); + + MockNodeQueryServiceInstanceById(INST, "GenericFlows/getSIUrlById.xml"); + MockNodeQueryServiceInstanceById(PARENT_INST, "GenericFlows/getParentSIUrlById.xml"); + MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml"); + MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml"); + MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID); + MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID); + + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + Map variables = setupVariables(); + String businessKey = UUID.randomUUID().toString(); + invokeAsyncProcess(PROCNAME, "v1", businessKey, request, variables); + + // for SI + injectSDNCCallbacks(callbacks, "assign"); + + // for TXC + injectSDNCCallbacks(callbacks, "assign"); + injectSDNCCallbacks(callbacks, "create"); + injectSDNCCallbacks(callbacks, "activate"); + injectSDNCCallbacks(callbacks, "queryTXC"); + + // for BRG + injectSDNCCallbacks(callbacks, "assign"); + injectSDNCCallbacks(callbacks, "create"); + injectSDNCCallbacks(callbacks, "activate"); + injectSDNCCallbacks(callbacks, "queryBRG"); + + waitForProcessEnd(businessKey, 10000); -// /** -// * End-to-End flow - Unit test for CreateVcpeResCustService.bpmn -// * - String input & String response -// */ -// -// @Test -// @Ignore -// @Deployment(resources = {"process/CreateVcpeResCustService.bpmn", -// "subprocess/DoCreateServiceInstance.bpmn", -// "subprocess/DoCreateServiceInstanceRollback.bpmn", -// "subprocess/DoCreateNetworkInstance.bpmn", -// "subprocess/DoCreateNetworkInstanceRollback.bpmn", -// "subprocess/DoCreateVnfAndModules.bpmn", -// "subprocess/DoCreateAllottedResourceTXC.bpmn", -// "subprocess/DoCreateAllottedResourceTXCRollback.bpmn", -// "subprocess/DoCreateAllottedResourceBRG.bpmn", -// "subprocess/DoCreateAllottedResourceBRGRollback.bpmn", -// "subprocess/BuildingBlock/DecomposeService.bpmn", -// "subprocess/BuildingBlock/Homing.bpmn", -// "subprocess/GenericGetService.bpmn", -// "subprocess/GenericPutService.bpmn", -// "subprocess/SDNCAdapterV1.bpmn", -// "subprocess/DoCreateVnf.bpmn", -// "subprocess/GenericGetVnf.bpmn", -// "subprocess/GenericPutVnf.bpmn", -// "subprocess/FalloutHandler.bpmn", -// "subprocess/GenericDeleteService.bpmn", -// "subprocess/ReceiveWorkflowMessage.bpmn", -// "subprocess/CompleteMsoProcess.bpmn"}) -// -// public void invokeCreateServiceInstanceInfra_Success() throws Exception { -// -// logStart(); -// -// // setup simulators -// //MockGetCustomer_VCPE(); -// MockGetCustomer("MCBH-1610", "VCPE/getCustomer.xml"); -// //MockGetNetworkCatalogData_VCPE(); -// MockGetNetworkCatalogData("uuid-miu-svc-011-abcdef", "2", "VCPE/getCatalogNetworkData.json"); -// //MockGetVnfCatalogData_VCPE(); -// MockGetVnfCatalogData("uuid-miu-svc-011-abcdef", "2", "VCPE/getCatalogVnfData.json"); -// //MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef", "VCPE/getCatalogServiceResourcesData.json"); -// MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef", "VCPE/getCatalogServiceResourcesDataNoNetworkVnf.json"); -// MockGetServiceInstanceById_VCPE(); -// MockPutServiceInstance_VCPE(); -// -// //SDNC Adapter Mocks -// mockSDNCAdapterRest(); -// mockSDNCAdapter(); -// -// //from CreateNetworkInstanceTest -// sdncAdapterNetworkTopologySimulator_CreateNetworkV2(); -// MockNetworkAdapterResponse_CreateSuccessV2(); -// MockAAIResponse_queryName_CreateNetwork_404V2(); // 'network-name' not in AAI , Ok to Create. -// MockAAIResponse_cloudRegion25_Success(); -// MockAAIResponse_queryId_CreateNetwork_SuccessV2(); -// MockAAIResponse_queryVpnBinding_CreateNetwork_SuccessV2(); -// MockAAIResponse_queryVpnBinding2_CreateNetwork_SuccessV2(); -// MockAAIResponse_queryNetworkPolicy_CreateNetwork_SuccessV2(); -// MockAAIResponse_queryNetworkTableRef_CreateNetwork_SuccessV2(); -// MockAAIResponse_updateContrail_CreateNetwork_SuccessV2(); -// MockDBUpdate_Success(); -// MocksAAIResponse_queryNetworkInstance_CreateNetwork_Success(); -// -// //network AAI Mocks -// MockGetNetworkById("680b7453-0ec4-4d96-b355-280d981d418f", "VCPE/getNetwork.xml"); -// MockGetNetworkById("444a701a-6419-45b2-aa52-b45a1b719cf6", "VCPE/getNetwork.xml"); -// MockGetNetworkById("cf82a73f-de7f-4f84-8dfc-16a487c63a36", "VCPE/getNetwork.xml"); -// MockPutNetwork("680b7453-0ec4-4d96-b355-280d981d418f"); -// MockPutNetwork("cf82a73f-de7f-4f84-8dfc-16a487c63a36"); -// -// MockPutGenericVnf("9c61db87-345c-49ae-ac80-472211df5deb"); -// -// mockSNIRO(); -// -// String businessKey = UUID.randomUUID().toString(); -//// String createVfModuleRequest = -//// FileUtil.readResourceFile("__files/VCPE/CreateVfModule_VID_request.json"); -// -// Map variables = setupVariablesObjectMap(); -// -// TestAsyncResponse asyncResponse = invokeAsyncProcess("CreateVcpeResCustService", -// "v1", businessKey, getRequest(), variables); -// -// WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000); -// -// String responseBody = response.getResponse(); -// System.out.println("Workflow (Synch) Response:\n" + responseBody); -// -// injectSDNCCallbacks(callbacks, "assign, query"); -// injectSDNCCallbacks(callbacks, "activate"); -// -// // TODO add appropriate assertions -// -// waitForProcessEnd(businessKey, 10000); -// checkVariable(businessKey, "CreateVcpeResCustServiceSuccessIndicator", true); -// -// logEnd(); -// } + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + + String completionReq = BPMNUtil.getVariable(processEngineRule, PROCNAME, Prefix+VAR_COMP_REQ); + System.out.println("completionReq:\n" + completionReq); + + assertEquals("true", BPMNUtil.getVariable(processEngineRule, PROCNAME, PROCNAME+VAR_SUCCESS_IND)); + assertEquals("200", BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_RESP_CODE)); + assertEquals(null, workflowException); + assertTrue(completionReq.indexOf("request-id>testRequestId<") >= 0); + assertTrue(completionReq.indexOf("action>CREATE<") >= 0); + assertTrue(completionReq.indexOf("source>VID<") >= 0); + + assertEquals("1", BPMNUtil.getVariable(processEngineRule, PROCNAME, Prefix+"VnfsCreatedCount")); + } + @Test + @Deployment(resources = { + "process/CreateVcpeResCustService.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/GenericPutService.bpmn", + "subprocess/BuildingBlock/DecomposeService.bpmn", + "subprocess/DoCreateServiceInstance.bpmn", + "subprocess/DoCreateAllottedResourceTXC.bpmn", + "subprocess/DoCreateAllottedResourceBRG.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + + // stubs + "VCPE/stubprocess/Homing.bpmn", + "VCPE/stubprocess/DoCreateVnfAndModules.bpmn"}) - /** - * TEST Decompose + Homing - Unit test for CreateVcpeResCustService.bpmn - * - String input & String response - */ + public void testCreateVcpeResCustService_NoParts() throws Exception { - @Test -// TODO: run this test when Homing BB is merged - @Ignore - @Deployment(resources = {"process/CreateVcpeResCustService.bpmn", - "subprocess/DoCreateServiceInstance.bpmn", - "subprocess/DoCreateServiceInstanceRollback.bpmn", - "subprocess/DoCreateNetworkInstance.bpmn", - "subprocess/DoCreateNetworkInstanceRollback.bpmn", - "subprocess/BuildingBlock/DecomposeService.bpmn", - "subprocess/BuildingBlock/Homing.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/GenericPutService.bpmn", - "subprocess/SDNCAdapterV1.bpmn", - "subprocess/DoCreateVnf.bpmn", - "subprocess/GenericGetVnf.bpmn", - "subprocess/GenericPutVnf.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/GenericDeleteService.bpmn", - "subprocess/DoCreateAllottedResourceBRG.bpmn", - "subprocess/DoCreateAllottedResourceBRGRollback.bpmn", - "subprocess/DoCreateAllottedResourceTXC.bpmn", - "subprocess/DoCreateAllottedResourceTXCRollback.bpmn", - "subprocess/CompleteMsoProcess.bpmn"}) - - public void invokeDecompositionHomingCreateServiceInstanceNetwork() throws Exception { - - logStart(); - - // setup simulators - MockGetCustomer("MCBH-1610", "VCPE/getCustomer.xml"); - - MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef", "2", "VCPE/getCatalogVcpe.json"); - -// MockPutServiceInstance_VCPE(); - -// MockGetNetworkByIdWithDepth("680b7453-0ec4-4d96-b355-280d981d418f", "VCPE/CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_Success.xml", "1"); -// MockGetNetworkByIdWithDepth("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "VCPE/CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_Success.xml", "1"); - - MockPutGenericVnf("39ae1b77-4edd-4e94-846a-d087a35a2260"); - - // stuff to satisfy TXC & BRG subflows - MockNodeQueryServiceInstanceById("MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getSIUrlById.xml"); - MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); - MockNodeQueryServiceInstanceById("MIS%252F1604%252F0027%252FSW_INTERNET", "GenericFlows/getParentSIUrlById.xml"); - MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0027%252FSW_INTERNET", "GenericFlows/getParentServiceInstance.xml"); - MockPutAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0027%252FSW_INTERNET", "arId-1"); - MockPatchAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0027%252FSW_INTERNET", "arId-1"); + MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef", "2", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesNoData.json"); + MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesNoData.json"); + MockGetCustomer(CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml"); - mockSDNCAdapter(200); + // TODO: the SI should NOT have to be URL-encoded yet again! + MockPutServiceInstance(CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml"); + MockGetServiceInstance(CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml"); + + MockNodeQueryServiceInstanceById(INST, "GenericFlows/getSIUrlById.xml"); + MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml"); + MockNodeQueryServiceInstanceById(PARENT_INST, "GenericFlows/getParentSIUrlById.xml"); + MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml"); + + // TODO: should these really be PARENT_INST, or should they be INST? + MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID); + MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID); + mockSDNCAdapter(200); mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + Map variables = setupVariables(); -// TODO: uncomment when Homing BB is merged -// mockSNIRO(); + String businessKey = UUID.randomUUID().toString(); + invokeAsyncProcess(PROCNAME, "v1", businessKey, request, variables); + + // for SI + injectSDNCCallbacks(callbacks, "assign"); + + waitForProcessEnd(businessKey, 10000); - //Below works for Homing/Sniro + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + + String completionReq = BPMNUtil.getVariable(processEngineRule, PROCNAME, Prefix+VAR_COMP_REQ); + System.out.println("completionReq:\n" + completionReq); - Map variables = setupVariablesObjectMap(); + assertEquals("true", BPMNUtil.getVariable(processEngineRule, PROCNAME, PROCNAME+VAR_SUCCESS_IND)); + assertEquals("200", BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_RESP_CODE)); + assertEquals(null, workflowException); + assertTrue(completionReq.indexOf("request-id>testRequestId<") >= 0); + assertTrue(completionReq.indexOf("action>CREATE<") >= 0); + assertTrue(completionReq.indexOf("source>VID<") >= 0); - String businessKey = UUID.randomUUID().toString(); - TestAsyncResponse asyncResponse = invokeAsyncProcess("CreateVcpeResCustService", - "v1", businessKey, request, variables); - - WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000); + assertEquals("0", BPMNUtil.getVariable(processEngineRule, PROCNAME, Prefix+"VnfsCreatedCount")); + } + + @Test + @Deployment(resources = { + "process/CreateVcpeResCustService.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/GenericPutService.bpmn", + "subprocess/BuildingBlock/DecomposeService.bpmn", + "subprocess/DoCreateServiceInstance.bpmn", + "subprocess/DoCreateAllottedResourceBRG.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + + // this stub will trigger a fault + "VCPE/stubprocess/DoCreateAllottedResourceTXC.bpmn", + + // stubs + "VCPE/stubprocess/Homing.bpmn", + "VCPE/stubprocess/DoCreateVnfAndModules.bpmn"}) + + public void testCreateVcpeResCustService_Fault_NoRollback() throws Exception { + + MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef", "2", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json"); + MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json"); + MockGetCustomer(CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml"); + + // TODO: the SI should NOT have to be URL-encoded yet again! + MockPutServiceInstance(CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml"); + MockGetServiceInstance(CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml"); - String responseBody = response.getResponse(); - System.out.println("Workflow (Synch) Response:\n" + responseBody); + MockNodeQueryServiceInstanceById(INST, "GenericFlows/getSIUrlById.xml"); + MockNodeQueryServiceInstanceById(PARENT_INST, "GenericFlows/getParentSIUrlById.xml"); + MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml"); + MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml"); + MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID); + MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID); - injectWorkflowMessages(callbacks, "sniro"); - injectSDNCCallbacks(callbacks, "assign, create, activate, queryTXC"); - injectSDNCCallbacks(callbacks, "assign, create, activate, queryBRG"); + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + Map variables = setupVariables(); + String req = FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/requestNoSINameNoRollback.json"); + + String businessKey = UUID.randomUUID().toString(); + invokeAsyncProcess(PROCNAME, "v1", businessKey, req, variables); + + // for SI + injectSDNCCallbacks(callbacks, "assign"); + waitForProcessEnd(businessKey, 10000); - checkVariable(businessKey, "CreateVcpeResCustServiceSuccessIndicator", true); - logEnd(); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + + String completionReq = BPMNUtil.getVariable(processEngineRule, PROCNAME, Prefix+VAR_COMP_REQ); + System.out.println("completionReq:\n" + completionReq); + + assertEquals(null, BPMNUtil.getVariable(processEngineRule, PROCNAME, PROCNAME+VAR_SUCCESS_IND)); + assertEquals(null, BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_RESP_CODE)); + assertNotNull(workflowException); + + BPMNUtil.assertNoProcessInstance(processEngineRule, "DoCreateAllottedResourceBRGRollback"); + BPMNUtil.assertNoProcessInstance(processEngineRule, "DoCreateVnfAndModulesRollback"); + BPMNUtil.assertNoProcessInstance(processEngineRule, "DoCreateAllottedResourceTXCRollback"); } + @Test + @Deployment(resources = { + "process/CreateVcpeResCustService.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/GenericPutService.bpmn", + "subprocess/BuildingBlock/DecomposeService.bpmn", + "subprocess/DoCreateServiceInstance.bpmn", + "subprocess/DoCreateAllottedResourceTXC.bpmn", + "subprocess/DoCreateAllottedResourceTXCRollback.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + + // this stub will trigger a fault + "VCPE/stubprocess/DoCreateAllottedResourceBRG.bpmn", + + // stubs + "VCPE/stubprocess/DoCreateAllottedResourceBRGRollback.bpmn", + "VCPE/stubprocess/DoCreateVnfAndModulesRollback.bpmn", + "VCPE/stubprocess/DoCreateServiceInstanceRollback.bpmn", + "VCPE/stubprocess/Homing.bpmn", + "VCPE/stubprocess/DoCreateVnfAndModules.bpmn"}) - /** - * TEST Decompose + Homing - Unit test for CreateVcpeResCustService.bpmn - * - String input & String response - */ - -// @Test -// @Deployment(resources = {"process/CreateVcpeResCustService.bpmn", -// "subprocess/DoCreateServiceInstance.bpmn", -// "subprocess/DoCreateServiceInstanceRollback.bpmn", -// "subprocess/DoCreateNetworkInstance.bpmn", -// "subprocess/DoCreateNetworkInstanceRollback.bpmn", -// "subprocess/BuildingBlock/DecomposeService.bpmn", -// "subprocess/BuildingBlock/Homing.bpmn", -// "subprocess/DoCreateAllottedResourceTXC.bpmn", -// "subprocess/DoCreateAllottedResourceTXCRollback.bpmn", -// "subprocess/DoCreateAllottedResourceBRG.bpmn", -// "subprocess/DoCreateAllottedResourceBRGRollback.bpmn", -// "subprocess/GenericGetService.bpmn", -// "subprocess/GenericPutService.bpmn", -// "subprocess/SDNCAdapterV1.bpmn", -// "subprocess/DoCreateVnf.bpmn", -// "subprocess/GenericGetVnf.bpmn", -// "subprocess/GenericPutVnf.bpmn", -// "subprocess/FalloutHandler.bpmn", -// "subprocess/GenericDeleteService.bpmn", -// "subprocess/ReceiveWorkflowMessage.bpmn", -// "subprocess/CompleteMsoProcess.bpmn"}) -// -// public void invokeDecompositionHomingCreateServiceInstanceARs() throws Exception { -// -// logStart(); -// -// // setup simulators -// MockGetCustomer("MCBH-1610", "VCPE/getCustomer.xml"); -// -// MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef", "VCPE/getCatalogServiceResourcesDataServiceAllotted.json"); -// -// MockPutServiceInstance_VCPE(); -// //network AAI Mocks -// MockGetNetworkById("cf82a73f-de7f-4f84-8dfc-16a487c63a36", "VCPE/getNetwork.xml"); -// MockPutNetwork("cf82a73f-de7f-4f84-8dfc-16a487c63a36"); -// -// MockNodeQueryServiceInstanceById("c763d462-dfe4-4577-9706-fa3a9db640be", "VCPE/getSIUrlById.xml"); -// -// mockSDNCAdapter(); -// -// MockNodeQueryServiceInstanceById("MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getSIUrlById.xml"); -// MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET"); -// MockPutAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "arId-1"); -// MockPutAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET_in-use", "arId-1"); -// MockPatchAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET_in-use", "arId-1"); -// -// -// MockDBUpdateVfModule(); -// -// mockSNIRO(); -// -// String businessKey = UUID.randomUUID().toString(); -// -// //Below works for Homing/Sniro -// -// Map variables = setupVariablesObjectMap(); -// TestAsyncResponse asyncResponse = invokeAsyncProcess("CreateVcpeResCustService", "v1", businessKey, getRequest(), variables); -// WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000); -// String responseBody = response.getResponse(); -// System.out.println("Workflow (Synch) Response:\n" + responseBody); -// -// //Below is from CreateVcpeResCustService -//// Map variables = setupVariables(); -//// WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "CreateVcpeResCustService", variables); -//// waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); -//// String workflowResp = BPMNUtil.getVariable(processEngineRule, "CreateVcpeResCustService", "WorkflowResponse"); -// -// injectWorkflowMessages(callbacks, "sniro"); -// // TODO add appropriate assertions -// injectSDNCCallbacks(callbacks, "assign, query, create, activate, queryTXC, assign, create, activate, queryBRG"); -// waitForProcessEnd(businessKey, 10000); -// -//// checkVariable(businessKey, "CreateVcpeResCustServiceSuccessIndicator", true); -// -// logEnd(); -// } -// -// -// /** -// * TEST Decompose + Homing - Unit test for CreateVcpeResCustService.bpmn -// * - String input & String response -// */ -// -// @Test -// //@Ignore -// @Deployment(resources = {"process/CreateVcpeResCustService.bpmn", -// "subprocess/DoCreateServiceInstance.bpmn", -// "subprocess/DoCreateServiceInstanceRollback.bpmn", -// "subprocess/DoCreateNetworkInstance.bpmn", -// "subprocess/DoCreateNetworkInstanceRollback.bpmn", -// "subprocess/BuildingBlock/DecomposeService.bpmn", -// "subprocess/BuildingBlock/Homing.bpmn", -// "subprocess/DoCreateVnfAndModules.bpmn", -// "subprocess/DoCreateVnfAndModulesRollback.bpmn", -// "subprocess/DoCreateAllottedResourceTXC.bpmn", -// "subprocess/DoCreateAllottedResourceTXCRollback.bpmn", -// "subprocess/DoCreateAllottedResourceBRG.bpmn", -// "subprocess/DoCreateAllottedResourceBRGRollback.bpmn", -// "subprocess/GenericGetService.bpmn", -// "subprocess/GenericPutService.bpmn", -// "subprocess/SDNCAdapterV1.bpmn", -// "subprocess/DoCreateVnf.bpmn", -// "subprocess/GenericGetVnf.bpmn", -// "subprocess/GenericPutVnf.bpmn", -// "subprocess/FalloutHandler.bpmn", -// "subprocess/GenericDeleteService.bpmn", -// "subprocess/ReceiveWorkflowMessage.bpmn", -// "subprocess/CompleteMsoProcess.bpmn"}) -// -// public void invokeDecompositionHomingCreateServiceVnf() throws Exception { -// -// logStart(); -// -// // setup simulators -// MockGetCustomer("MCBH-1610", "VCPE/getCustomer.xml"); -// -// MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef", "VCPE/getCatalogServiceResourcesServiceVnf.json"); -// -// MockPutServiceInstance_VCPE(); -// //network AAI Mocks -// MockGetNetworkById("cf82a73f-de7f-4f84-8dfc-16a487c63a36", "VCPE/getNetwork.xml"); -// MockPutNetwork("cf82a73f-de7f-4f84-8dfc-16a487c63a36"); -// -// MockNodeQueryServiceInstanceById("c763d462-dfe4-4577-9706-fa3a9db640be", "VCPE/getSIUrlById.xml"); -// -// -// MockNodeQueryServiceInstanceById("MIS%2F1604%2F0026%2FSW_INTERNET", "GenericFlows/getSIUrlByIdVcpe.xml"); -// MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET"); -// MockGetGenericVnfById_404("testVnfId"); -// MockPutGenericVnf(".*"); -// MockAAIVfModule(); -// MockPatchGenericVnf("skask"); -// MockPatchVfModuleId("skask", ".*"); -// MockSDNCAdapterVfModule(); -// MockVNFAdapterRestVfModule(); -// MockDBUpdateVfModule(); -// -// -// mockSDNCAdapter(); -// //mockSDNCAdapterRest(); -// -// //MockSDNCAdapterServiceInstanceModule(); -// -// //mockSDNCAdapterTopology("CreateNetworkV2mock/sdncCreateNetworkTopologyRsrcAssignResponse.xml", "SvcAction>assign"); -// -// MockDBUpdateVfModule(); -// -// mockSNIRO(); -// -// String businessKey = UUID.randomUUID().toString(); -// -// //Below works for Homing/Sniro -// -// Map variables = setupVariablesObjectMap(); -// TestAsyncResponse asyncResponse = invokeAsyncProcess("CreateVcpeResCustService", "v1", businessKey, getRequest(), variables); -// WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000); -// String responseBody = response.getResponse(); -// System.out.println("Workflow (Synch) Response:\n" + responseBody); -// -// //Below is from CreateVcpeResCustService -//// Map variables = setupVariables(); -//// WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "CreateVcpeResCustService", variables); -//// waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); -//// String workflowResp = BPMNUtil.getVariable(processEngineRule, "CreateVcpeResCustService", "WorkflowResponse"); -// -// injectWorkflowMessages(callbacks, "sniro"); -// // TODO add appropriate assertions -// injectSDNCCallbacks(callbacks, "assign, query"); -// waitForProcessEnd(businessKey, 10000); -// -//// checkVariable(businessKey, "CreateVcpeResCustServiceSuccessIndicator", true); -// -// logEnd(); -// } -// -// -// /** -// * TEST Decompose + Homing - Unit test for CreateVcpeResCustService.bpmn -// * - String input & String response -// */ -// -// @Test -// //@Ignore -// @Deployment(resources = {"process/CreateVcpeResCustService.bpmn", -// "subprocess/DoCreateServiceInstance.bpmn", -// "subprocess/DoCreateServiceInstanceRollback.bpmn", -// "subprocess/DoCreateNetworkInstance.bpmn", -// "subprocess/DoCreateNetworkInstanceRollback.bpmn", -// "subprocess/BuildingBlock/DecomposeService.bpmn", -// "subprocess/BuildingBlock/Homing.bpmn", -// "subprocess/DoCreateVnfAndModules.bpmn", -// "subprocess/DoCreateVnfAndModulesRollback.bpmn", -// "subprocess/DoCreateAllottedResourceTXC.bpmn", -// "subprocess/DoCreateAllottedResourceTXCRollback.bpmn", -// "subprocess/DoCreateAllottedResourceBRG.bpmn", -// "subprocess/DoCreateAllottedResourceBRGRollback.bpmn", -// "subprocess/GenericGetService.bpmn", -// "subprocess/GenericPutService.bpmn", -// "subprocess/SDNCAdapterV1.bpmn", -// "subprocess/DoCreateVnf.bpmn", -// "subprocess/GenericGetVnf.bpmn", -// "subprocess/GenericPutVnf.bpmn", -// "subprocess/FalloutHandler.bpmn", -// "subprocess/GenericDeleteService.bpmn", -// "subprocess/ReceiveWorkflowMessage.bpmn", -// "subprocess/CompleteMsoProcess.bpmn"}) -// -// public void invokeCreateAll() throws Exception { -// -// logStart(); -// -// // setup simulators -// MockGetCustomer("MCBH-1610", "VCPE/getCustomer.xml"); -// -// MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef", "VCPE/getCatalogServiceResourcesData.json"); -// -// MockPutServiceInstance_VCPE(); -// //network AAI Mocks -// MockGetNetworkById("cf82a73f-de7f-4f84-8dfc-16a487c63a36", "VCPE/getNetwork.xml"); -// MockPutNetwork("cf82a73f-de7f-4f84-8dfc-16a487c63a36"); -// -// MockNodeQueryServiceInstanceById("c763d462-dfe4-4577-9706-fa3a9db640be", "VCPE/getSIUrlById.xml"); -// -// MockGetNetworkByIdWithDepth("680b7453-0ec4-4d96-b355-280d981d418f", "VCPE/CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_Success.xml", "1"); -// MockGetNetworkByIdWithDepth("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "VCPE/CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_Success.xml", "1"); -// MockNetworkAdapterPost("CreateNetworkV2/createNetworkResponse_Success.xml", "VCPE/createNetworkRequest"); -// MockGetNetworkVpnBindingWithDepth("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017", "all"); -// MockGetNetworkVpnBindingWithDepth("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "c980a6ef-3b88-49f0-9751-dbad8608d0a6", "all"); -// MockGetNetworkPolicyWithDepth("CreateNetworkV2/createNetwork_queryNetworkPolicy_AAIResponse_Success.xml", "cee6d136-e378-4678-a024-2cd15f0ee0cg", "all"); -// MockGetNetworkTableReferenceWithDepth("CreateNetworkV2/createNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", "refFQDN1", "all"); -// MockGetNetworkTableReferenceWithDepth("CreateNetworkV2/createNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", "refFQDN2", "all"); -// MockPutNetworkIdWithDepth("CreateNetworkV2/createNetwork_updateContrail_AAIResponse_Success.xml", "680b7453-0ec4-4d96-b355-280d981d418f", "1"); -// MockPutNetworkIdWithDepth("CreateNetworkV2/createNetwork_updateContrail_AAIResponse_Success.xml", "49c86598-f766-46f8-84f8-8d1c1b10f9b4", "1"); -// -// -// MockNodeQueryServiceInstanceById("MIS%2F1604%2F0026%2FSW_INTERNET", "GenericFlows/getSIUrlByIdVcpe.xml"); -// MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET"); -// MockGetGenericVnfById_404("testVnfId"); -// MockPutGenericVnf(".*"); -// MockAAIVfModule(); -// MockPatchGenericVnf("skask"); -// MockPatchVfModuleId("skask", ".*"); -// MockSDNCAdapterVfModule(); -// MockVNFAdapterRestVfModule(); -// MockDBUpdateVfModule(); -// -// -// mockSDNCAdapter(); -// //mockSDNCAdapterRest(); -// -// //MockSDNCAdapterServiceInstanceModule(); -// -// //mockSDNCAdapterTopology("CreateNetworkV2mock/sdncCreateNetworkTopologyRsrcAssignResponse.xml", "SvcAction>assign"); -// -// MockDBUpdateVfModule(); -// -// mockSNIRO(); -// -// String businessKey = UUID.randomUUID().toString(); -// -// //Below works for Homing/Sniro -// -// Map variables = setupVariablesObjectMap(); -// TestAsyncResponse asyncResponse = invokeAsyncProcess("CreateVcpeResCustService", "v1", businessKey, getRequest(), variables); -// WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000); -// String responseBody = response.getResponse(); -// System.out.println("Workflow (Synch) Response:\n" + responseBody); -// -// //Below is from CreateVcpeResCustService -//// Map variables = setupVariables(); -//// WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "CreateVcpeResCustService", variables); -//// waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); -//// String workflowResp = BPMNUtil.getVariable(processEngineRule, "CreateVcpeResCustService", "WorkflowResponse"); -// -// injectWorkflowMessages(callbacks, "sniro"); -// // TODO add appropriate assertions -// injectSDNCCallbacks(callbacks, "assign, query"); -// waitForProcessEnd(businessKey, 10000); -// -//// checkVariable(businessKey, "CreateVcpeResCustServiceSuccessIndicator", true); -// -// logEnd(); -// } + public void testCreateVcpeResCustService_Fault_Rollback() throws Exception { + + MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef", "2", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json"); + MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef", "VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json"); + MockGetCustomer(CUST, "VCPE/CreateVcpeResCustService/getCustomer.xml"); + + // TODO: the SI should NOT have to be URL-encoded yet again! + MockPutServiceInstance(CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml"); + MockGetServiceInstance(CUST, SVC, INST.replace("%", "%25"), "GenericFlows/getServiceInstance.xml"); + + MockNodeQueryServiceInstanceById(INST, "GenericFlows/getSIUrlById.xml"); + MockNodeQueryServiceInstanceById(PARENT_INST, "GenericFlows/getParentSIUrlById.xml"); + MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml"); + MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml"); + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/CreateVcpeResCustService/arGetById.xml"); + MockGetAllottedResource(CUST, SVC, PARENT_INST, ARID, "VCPE/CreateVcpeResCustService/arGetById.xml"); + MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID); + MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID); + MockDeleteAllottedResource(CUST, SVC, PARENT_INST, ARID, ARVERS); + + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + Map variables = setupVariables(); + + String businessKey = UUID.randomUUID().toString(); + invokeAsyncProcess(PROCNAME, "v1", businessKey, request, variables); + + // for SI + injectSDNCCallbacks(callbacks, "assign"); + + // for TXC + injectSDNCCallbacks(callbacks, "assign"); + injectSDNCCallbacks(callbacks, "create"); + injectSDNCCallbacks(callbacks, "activate"); + injectSDNCCallbacks(callbacks, "queryTXC"); + + // BRG is a stub so don't need SDNC callbacks + + // for TXC rollback + injectSDNCCallbacks(callbacks, "deactivate"); + injectSDNCCallbacks(callbacks, "delete"); + injectSDNCCallbacks(callbacks, "unassign"); + + waitForProcessEnd(businessKey, 10000); + + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + + String completionReq = BPMNUtil.getVariable(processEngineRule, PROCNAME, Prefix+VAR_COMP_REQ); + System.out.println("completionReq:\n" + completionReq); + + assertEquals(null, BPMNUtil.getVariable(processEngineRule, PROCNAME, PROCNAME+VAR_SUCCESS_IND)); + assertEquals(null, BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_RESP_CODE)); + assertEquals(null, completionReq); + assertNotNull(workflowException); + + BPMNUtil.assertAnyProcessInstanceFinished(processEngineRule, "DoCreateAllottedResourceBRGRollback"); + BPMNUtil.assertAnyProcessInstanceFinished(processEngineRule, "DoCreateVnfAndModulesRollback"); + BPMNUtil.assertAnyProcessInstanceFinished(processEngineRule, "DoCreateAllottedResourceTXCRollback"); + } // ***************** // Utility Section // ***************** // Success Scenario - private Map setupVariablesObjectMap() { + private Map setupVariables() { Map variables = new HashMap<>(); variables.put("requestId", "testRequestId"); variables.put("request-id", "testRequestId"); - variables.put("CREVAS_testServiceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); // assigned for testing - variables.put("serviceInstanceId", "c763d462-dfe4-4577-9706-fa3a9db640be");// unit test - variables.put("sourceNetworkId", "c763d462-dfe4-4577-9706-fa3a9db640be");// unit test - variables.put("networkId", "c763d462-dfe4-4577-9706-fa3a9db640be");// unit test - variables.put("sourceNetworkRole", "whoknows");// unit test - variables.put("allottedResourceId", "arId-1"); + variables.put("serviceInstanceId", DEC_INST); + variables.put("allottedResourceId", ARID); variables.put("junitSleepMs", "5"); return variables; } - -// private Map setupVariables() { -// Map variables = new HashMap(); -// variables.put("bpmnRequest", getRequest()); -// variables.put("mso-request-id", "testRequestId"); -// variables.put("CREVAS_testServiceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); // assigned for testing -// variables.put("serviceInstanceId", "c763d462-dfe4-4577-9706-fa3a9db640be");// unit test -// variables.put("sourceNetworkId", "c763d462-dfe4-4577-9706-fa3a9db640be");// unit test -// variables.put("sourceNetworkRole", "whoknows");// unit test -// variables.put("allottedResourceId", "arId-1"); -// variables.put("junitSleepMs", "5"); -// return variables; -// -// } - - // start of mocks used locally and by other VF Module unit tests - public static void MockSDNCAdapterVfModule() { - // simplified the implementation to return "success" for all requests - stubFor(post(urlEqualTo("/SDNCAdapter")) -// .withRequestBody(containing("SvcInstanceId><")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("VfModularity/StandardSDNCSynchResponse.xml"))); -// stubFor(post(urlEqualTo("/SDNCAdapter")) -// .withRequestBody(containing("vnf-type>STMTN")) -// .willReturn(aResponse() -// .withStatus(200) -// .withHeader("Content-Type", "text/xml") -// .withBodyFile("VfModularity/StandardSDNCSynchResponse.xml"))); -// stubFor(post(urlEqualTo("/SDNCAdapter")) -// .withRequestBody(containing("SvcAction>query")) -// .willReturn(aResponse() -// .withStatus(200) -// .withHeader("Content-Type", "text/xml") -// .withBodyFile("VfModularity/StandardSDNCSynchResponse.xml"))); - } - - - - } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DeleteVcpeResCustServiceTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DeleteVcpeResCustServiceTest.java new file mode 100644 index 0000000000..88b6464de0 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DeleteVcpeResCustServiceTest.java @@ -0,0 +1,297 @@ +/* + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. 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.bpmn.vcpe; + +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchAllottedResource; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockQueryAllottedResourceById; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; +import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.BPMNUtil; +import org.openecomp.mso.bpmn.mock.FileUtil; + +import com.github.tomakehurst.wiremock.stubbing.Scenario; + +public class DeleteVcpeResCustServiceTest extends AbstractTestBase { + + private static final String PROCNAME = "DeleteVcpeResCustService"; + private static final String Prefix = "DVRCS_"; + private static final String AR_BRG_ID = "ar-brgB"; + private static final String AR_TXC_ID = "ar-txcA"; + + private final CallbackSet callbacks = new CallbackSet(); + private final String request; + + public DeleteVcpeResCustServiceTest() throws IOException { + callbacks.put("deactivate", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallback.xml")); + callbacks.put("delete", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeleteCallback.xml")); + callbacks.put("unassign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyUnassignCallback.xml")); + + request = FileUtil.readResourceFile("__files/VCPE/DeleteVcpeResCustService/request.json"); + } + + @Test + @Deployment(resources = { + "process/DeleteVcpeResCustService.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/GenericDeleteService.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoDeleteServiceInstance.bpmn", + "subprocess/DoDeleteAllottedResourceBRG.bpmn", + "subprocess/DoDeleteAllottedResourceTXC.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + + // stubs + "VCPE/stubprocess/DoDeleteVnfAndModules.bpmn"}) + + public void testDeleteVcpeResCustService_Success() throws Exception { + + MockNodeQueryServiceInstanceById(INST, "GenericFlows/getSIUrlById.xml"); + + // TODO: use INST instead of DEC_INST + /* + * Seems to be a bug in GenericDeleteService (or its subflows) as they + * fail to URL-encode the SI id before performing the query so we'll + * add a stub for that case, too. + */ + MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getSIUrlById.xml"); + + /* + * cannot use MockGetServiceInstance(), because we need to return + * different responses as we traverse through the flow + */ + + // initially, the SI includes the ARs + stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST)) + .inScenario("SI retrieval") + .whenScenarioStateIs(Scenario.STARTED) + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("VCPE/DeleteVcpeResCustService/getSI.xml")) + .willSetStateTo("ARs Deleted")); + + // once the ARs have been deleted, the SI should be empty + stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + CUST + "/service-subscriptions/service-subscription/" + SVC + "/service-instances/service-instance/" + INST)) + .inScenario("SI retrieval") + .whenScenarioStateIs("ARs Deleted") + .willReturn(aResponse() + .withStatus(200) + .withHeader("Content-Type", "text/xml") + .withBodyFile("VCPE/DeleteVcpeResCustService/getSIAfterDelArs.xml"))); + + // for BRG + MockQueryAllottedResourceById(AR_BRG_ID, "VCPE/DeleteVcpeResCustService/getBRGArUrlById.xml"); + MockGetAllottedResource(CUST, SVC, INST, AR_BRG_ID, "VCPE/DeleteVcpeResCustService/arGetBRGById.xml"); + MockPatchAllottedResource(CUST, SVC, INST, AR_BRG_ID); + MockDeleteAllottedResource(CUST, SVC, INST, AR_BRG_ID, ARVERS); + + // for TXC + MockQueryAllottedResourceById(AR_TXC_ID, "VCPE/DeleteVcpeResCustService/getTXCArUrlById.xml"); + MockGetAllottedResource(CUST, SVC, INST, AR_TXC_ID, "VCPE/DeleteVcpeResCustService/arGetTXCById.xml"); + MockPatchAllottedResource(CUST, SVC, INST, AR_TXC_ID); + MockDeleteAllottedResource(CUST, SVC, INST, AR_TXC_ID, ARVERS); + + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + Map variables = setupVariables(); + + String businessKey = UUID.randomUUID().toString(); + invokeAsyncProcess(PROCNAME, "v1", businessKey, request, variables); + + // for BRG + injectSDNCCallbacks(callbacks, "deactivate"); + injectSDNCCallbacks(callbacks, "delete"); + injectSDNCCallbacks(callbacks, "unassign"); + + // for TXC + injectSDNCCallbacks(callbacks, "deactivate"); + injectSDNCCallbacks(callbacks, "delete"); + injectSDNCCallbacks(callbacks, "unassign"); + + // for SI + injectSDNCCallbacks(callbacks, "deactivate"); + injectSDNCCallbacks(callbacks, "delete"); + + waitForProcessEnd(businessKey, 10000); + + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + + String completionReq = BPMNUtil.getVariable(processEngineRule, PROCNAME, Prefix+VAR_COMP_REQ); + System.out.println("completionReq:\n" + completionReq); + + assertEquals("true", BPMNUtil.getVariable(processEngineRule, PROCNAME, PROCNAME+VAR_SUCCESS_IND)); + assertEquals("200", BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_RESP_CODE)); + assertEquals(null, workflowException); + assertTrue(completionReq.indexOf("testRequestId<") >= 0); + assertTrue(completionReq.indexOf("DELETE<") >= 0); + assertTrue(completionReq.indexOf("VID<") >= 0); + + assertEquals("2", BPMNUtil.getVariable(processEngineRule, PROCNAME, Prefix+"vnfsDeletedCount")); + + BPMNUtil.assertAnyProcessInstanceFinished(processEngineRule, "DoDeleteVnfAndModules"); + } + + @Test + @Deployment(resources = { + "process/DeleteVcpeResCustService.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/GenericDeleteService.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoDeleteServiceInstance.bpmn", + "subprocess/DoDeleteAllottedResourceBRG.bpmn", + "subprocess/DoDeleteAllottedResourceTXC.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + + // stubs + "VCPE/stubprocess/DoDeleteVnfAndModules.bpmn"}) + + public void testDeleteVcpeResCustService_NoBRG_NoTXC_NoVNF() throws Exception { + + MockNodeQueryServiceInstanceById(INST, "GenericFlows/getSIUrlById.xml"); + + // TODO: use INST instead of DEC_INST + /* + * Seems to be a bug in GenericDeleteService (or its subflows) as they + * fail to URL-encode the SI id before performing the query so we'll + * add a stub for that case, too. + */ + MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getSIUrlById.xml"); + + MockGetServiceInstance(CUST, SVC, INST, "VCPE/DeleteVcpeResCustService/getSIAfterDelArs.xml"); + + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + Map variables = setupVariables(); + + String businessKey = UUID.randomUUID().toString(); + invokeAsyncProcess(PROCNAME, "v1", businessKey, request, variables); + + // for SI + injectSDNCCallbacks(callbacks, "deactivate"); + injectSDNCCallbacks(callbacks, "delete"); + + waitForProcessEnd(businessKey, 10000); + + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + + String completionReq = BPMNUtil.getVariable(processEngineRule, PROCNAME, Prefix+VAR_COMP_REQ); + System.out.println("completionReq:\n" + completionReq); + + assertEquals("true", BPMNUtil.getVariable(processEngineRule, PROCNAME, PROCNAME+VAR_SUCCESS_IND)); + assertEquals("200", BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_RESP_CODE)); + assertEquals(null, workflowException); + assertTrue(completionReq.indexOf("testRequestId<") >= 0); + assertTrue(completionReq.indexOf("DELETE<") >= 0); + assertTrue(completionReq.indexOf("VID<") >= 0); + + assertEquals("0", BPMNUtil.getVariable(processEngineRule, PROCNAME, Prefix+"vnfsDeletedCount")); + + BPMNUtil.assertNoProcessInstance(processEngineRule, "DoDeleteVnfAndModules"); + } + + @Test + @Deployment(resources = { + "process/DeleteVcpeResCustService.bpmn", + "subprocess/GenericGetService.bpmn", + "subprocess/GenericDeleteService.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoDeleteServiceInstance.bpmn", + "subprocess/DoDeleteAllottedResourceBRG.bpmn", + "subprocess/DoDeleteAllottedResourceTXC.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + + // stubs + "VCPE/stubprocess/DoDeleteVnfAndModules.bpmn"}) + + public void testDeleteVcpeResCustService_Fault() throws Exception { + + MockNodeQueryServiceInstanceById(INST, "GenericFlows/getSIUrlById.xml"); + + // TODO: use INST instead of DEC_INST + /* + * Seems to be a bug in GenericDeleteService (or its subflows) as they + * fail to URL-encode the SI id before performing the query so we'll + * add a stub for that case, too. + */ + MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getSIUrlById.xml"); + + MockGetServiceInstance(CUST, SVC, INST, "VCPE/DeleteVcpeResCustService/getSIAfterDelArs.xml"); + + // generate failure + mockSDNCAdapter(404); + + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + Map variables = setupVariables(); + + String businessKey = UUID.randomUUID().toString(); + invokeAsyncProcess(PROCNAME, "v1", businessKey, request, variables); + + waitForProcessEnd(businessKey, 10000); + + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + + String completionReq = BPMNUtil.getVariable(processEngineRule, PROCNAME, Prefix+VAR_COMP_REQ); + System.out.println("completionReq:\n" + completionReq); + + assertEquals(null, BPMNUtil.getVariable(processEngineRule, PROCNAME, PROCNAME+VAR_SUCCESS_IND)); + assertEquals(null, BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_RESP_CODE)); + assertNotNull(workflowException); + } + + private Map setupVariables() throws UnsupportedEncodingException { + Map variables = new HashMap<>(); + variables.put("isDebugLogEnabled", "true"); + variables.put("requestId", "testRequestId"); + variables.put("serviceInstanceId", DEC_INST); + variables.put("sdncVersion", "1802"); + variables.put("serviceInstanceName", "some-junk-name"); + return variables; + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoCreateAllottedResourceBRGRollbackTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoCreateAllottedResourceBRGRollbackTest.java index f5c3775273..0407e172e2 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoCreateAllottedResourceBRGRollbackTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoCreateAllottedResourceBRGRollbackTest.java @@ -1,4 +1,4 @@ -/*- +/* * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ @@ -7,9 +7,9 @@ * 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. @@ -17,13 +17,12 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - -/* - * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. - */ package org.openecomp.mso.bpmn.vcpe; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchAllottedResource; @@ -36,23 +35,22 @@ import java.util.Map; import java.util.UUID; import org.camunda.bpm.engine.test.Deployment; -import org.junit.Assert; import org.junit.Test; import org.openecomp.mso.bpmn.common.BPMNUtil; -import org.openecomp.mso.bpmn.common.WorkflowTest; import org.openecomp.mso.bpmn.core.RollbackData; import org.openecomp.mso.bpmn.mock.FileUtil; -public class DoCreateAllottedResourceBRGRollbackTest extends WorkflowTest { +public class DoCreateAllottedResourceBRGRollbackTest extends AbstractTestBase { + private static final String PROCNAME = "DoCreateAllottedResourceBRGRollback"; private static final String RbType = "DCARBRG_"; private final CallbackSet callbacks = new CallbackSet(); public DoCreateAllottedResourceBRGRollbackTest() throws IOException { - callbacks.put("deactivate", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyDeactivateCallback.xml")); - callbacks.put("delete", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyDeleteCallback.xml")); - callbacks.put("unassign", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyUnassignCallback.xml")); + callbacks.put("deactivate", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallback.xml")); + callbacks.put("delete", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeleteCallback.xml")); + callbacks.put("unassign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyUnassignCallback.xml")); } @Test @@ -60,11 +58,11 @@ public class DoCreateAllottedResourceBRGRollbackTest extends WorkflowTest { "subprocess/SDNCAdapterV1.bpmn", "subprocess/FalloutHandler.bpmn", "subprocess/DoCreateAllottedResourceBRGRollback.bpmn"}) - public void testDoCreateAllottedResourceBRGRollback_success() throws Exception { + public void testDoCreateAllottedResourceBRGRollback_Success() throws Exception { - MockGetAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "arId-1", "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml"); - MockPatchAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "arId-1"); - MockDeleteAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "arId-1", "1490627351232"); + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml"); + MockPatchAllottedResource(CUST, SVC, INST, ARID); + MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS); mockSDNCAdapter(200); mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); @@ -72,7 +70,7 @@ public class DoCreateAllottedResourceBRGRollbackTest extends WorkflowTest { Map variables = new HashMap<>(); setVariablesSuccess(variables, "testRequestId1"); - invokeSubProcess("DoCreateAllottedResourceBRGRollback", businessKey, variables); + invokeSubProcess(PROCNAME, businessKey, variables); injectSDNCCallbacks(callbacks, "deactivate"); injectSDNCCallbacks(callbacks, "delete"); @@ -80,37 +78,268 @@ public class DoCreateAllottedResourceBRGRollbackTest extends WorkflowTest { waitForProcessEnd(businessKey, 10000); - Assert.assertTrue(isProcessEnded(businessKey)); - String workflowException = BPMNUtil.getVariable(processEngineRule, "DoCreateAllottedResourceBRGRollback", "WorkflowException"); + assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); System.out.println("workflowException:\n" + workflowException); assertEquals(null, workflowException); + assertEquals("true", BPMNUtil.getVariable(processEngineRule, PROCNAME, "rolledBack")); + assertNull(BPMNUtil.getVariable(processEngineRule, PROCNAME, "rollbackError")); } + + @Test + @Deployment(resources = { + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoCreateAllottedResourceBRGRollback.bpmn"}) + public void testDoCreateAllottedResourceBRGRollback_skipRollback() throws Exception { + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml"); + MockPatchAllottedResource(CUST, SVC, INST, ARID); + MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS); + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + RollbackData rollbackData = setVariablesSuccess(variables, "testRequestId1"); + + rollbackData.put(RbType, "rollbackAAI", "false"); + rollbackData.put(RbType, "rollbackSDNCassign", "false"); + + invokeSubProcess(PROCNAME, businessKey, variables); - private void setVariablesSuccess(Map variables, String requestId) { + waitForProcessEnd(businessKey, 10000); + + assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + assertEquals(null, workflowException); + assertEquals(null, BPMNUtil.getVariable(processEngineRule, PROCNAME, "rolledBack")); + assertNull(BPMNUtil.getVariable(processEngineRule, PROCNAME, "rollbackError")); + } + + @Test + @Deployment(resources = { + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoCreateAllottedResourceBRGRollback.bpmn"}) + public void testDoCreateAllottedResourceBRGRollback_DoNotRollBack() throws Exception { + + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + RollbackData rollbackData = setVariablesSuccess(variables, "testRequestId1"); + + // this will cause "rollbackSDNC" to be set to false + rollbackData.put(RbType, "rollbackSDNCassign", "false"); + + invokeSubProcess(PROCNAME, businessKey, variables); + + waitForProcessEnd(businessKey, 10000); + + assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + assertEquals(null, workflowException); + assertEquals("true", BPMNUtil.getVariable(processEngineRule, PROCNAME, "rolledBack")); + assertNull(BPMNUtil.getVariable(processEngineRule, PROCNAME, "rollbackError")); + } + + @Test + @Deployment(resources = { + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoCreateAllottedResourceBRGRollback.bpmn"}) + public void testDoCreateAllottedResourceBRGRollback_NoDeactivate() throws Exception { + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml"); + MockPatchAllottedResource(CUST, SVC, INST, ARID); + MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS); + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + RollbackData rollbackData = setVariablesSuccess(variables, "testRequestId1"); + + rollbackData.put(RbType, "rollbackSDNCactivate", "false"); + + invokeSubProcess(PROCNAME, businessKey, variables); + + injectSDNCCallbacks(callbacks, "delete"); + injectSDNCCallbacks(callbacks, "unassign"); + + waitForProcessEnd(businessKey, 10000); + + assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + assertEquals(null, workflowException); + assertEquals("true", BPMNUtil.getVariable(processEngineRule, PROCNAME, "rolledBack")); + assertNull(BPMNUtil.getVariable(processEngineRule, PROCNAME, "rollbackError")); + } + + @Test + @Deployment(resources = { + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoCreateAllottedResourceBRGRollback.bpmn"}) + public void testDoCreateAllottedResourceBRGRollback_NoDelete() throws Exception { + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml"); + MockPatchAllottedResource(CUST, SVC, INST, ARID); + MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS); + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + RollbackData rollbackData = setVariablesSuccess(variables, "testRequestId1"); + + rollbackData.put(RbType, "rollbackSDNCcreate", "false"); + + invokeSubProcess(PROCNAME, businessKey, variables); + + injectSDNCCallbacks(callbacks, "deactivate"); + injectSDNCCallbacks(callbacks, "unassign"); + + waitForProcessEnd(businessKey, 10000); + + assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + assertEquals(null, workflowException); + assertEquals("true", BPMNUtil.getVariable(processEngineRule, PROCNAME, "rolledBack")); + assertNull(BPMNUtil.getVariable(processEngineRule, PROCNAME, "rollbackError")); + } + + @Test + @Deployment(resources = { + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoCreateAllottedResourceBRGRollback.bpmn"}) + public void testDoCreateAllottedResourceBRGRollback_NoUnassign() throws Exception { + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml"); + MockPatchAllottedResource(CUST, SVC, INST, ARID); + MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS); + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + RollbackData rollbackData = setVariablesSuccess(variables, "testRequestId1"); + + rollbackData.put(RbType, "rollbackSDNCassign", "false"); + + /* + * Note: if assign == false then the flow/script will set + * "skipRollback" to false, which will cause ALL of the SDNC steps + * to be skipped, not just the unassign step. + */ + + invokeSubProcess(PROCNAME, businessKey, variables); + + waitForProcessEnd(businessKey, 10000); + + assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + assertEquals(null, workflowException); + assertEquals("true", BPMNUtil.getVariable(processEngineRule, PROCNAME, "rolledBack")); + assertNull(BPMNUtil.getVariable(processEngineRule, PROCNAME, "rollbackError")); + } + + @Test + @Deployment(resources = { + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoCreateAllottedResourceBRGRollback.bpmn"}) + public void testDoCreateAllottedResourceBRGRollback_SubProcessError() throws Exception { + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml"); + MockPatchAllottedResource(CUST, SVC, INST, ARID); + MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + mockSDNCAdapter(404); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariablesSuccess(variables, "testRequestId1"); + + invokeSubProcess(PROCNAME, businessKey, variables); + + waitForProcessEnd(businessKey, 10000); + + assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + assertEquals(null, workflowException); + assertEquals("false", BPMNUtil.getVariable(processEngineRule, PROCNAME, "rolledBack")); + assertNotNull(BPMNUtil.getVariable(processEngineRule, PROCNAME, "rollbackError")); + } + + @Test + @Deployment(resources = { + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoCreateAllottedResourceBRGRollback.bpmn"}) + public void testDoCreateAllottedResourceBRGRollback_JavaException() throws Exception { + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml"); + MockPatchAllottedResource(CUST, SVC, INST, ARID); + MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS); + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariablesSuccess(variables, "testRequestId1"); + + variables.put("rollbackData", "string instead of rollback data"); + + invokeSubProcess(PROCNAME, businessKey, variables); + + waitForProcessEnd(businessKey, 10000); + + assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + assertEquals(null, workflowException); + assertEquals("false", BPMNUtil.getVariable(processEngineRule, PROCNAME, "rolledBack")); + assertNotNull(BPMNUtil.getVariable(processEngineRule, PROCNAME, "rollbackError")); + } + + private RollbackData setVariablesSuccess(Map variables, String requestId) { variables.put("isDebugLogEnabled", "true"); variables.put("failNotFound", "true"); variables.put("msoRequestId", requestId); variables.put("mso-request-id", "requestId"); - variables.put("allottedResourceId", "arId-1"); + variables.put("allottedResourceId", ARID); + + variables.put("serviceInstanceId", DEC_INST); + variables.put("parentServiceInstanceId", DEC_PARENT_INST); - variables.put("serviceInstanceId", "MIS%252F1604%252F0026%252FSW_INTERNET"); - variables.put("parentServiceInstanceId","MIS%252F1604%252F0026%252FSW_INTERNET"); RollbackData rollbackData = new RollbackData(); - rollbackData.put(RbType, "serviceInstanceId", "MIS%252F1604%252F0026%252FSW_INTERNET"); - rollbackData.put(RbType, "serviceSubscriptionType", "123456789"); + rollbackData.put(RbType, "serviceInstanceId", DEC_INST); + rollbackData.put(RbType, "serviceSubscriptionType", SVC); rollbackData.put(RbType, "disablerollback", "false"); rollbackData.put(RbType, "rollbackAAI", "true"); rollbackData.put(RbType, "rollbackSDNCassign", "true"); rollbackData.put(RbType, "rollbackSDNCactivate", "true"); rollbackData.put(RbType, "rollbackSDNCcreate", "true"); - rollbackData.put(RbType, "aaiARPath", "http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1"); + rollbackData.put(RbType, "aaiARPath", "http://localhost:28090/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID); rollbackData.put(RbType, "sdncActivateRollbackReq", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncActivateRollbackReq.xml")); rollbackData.put(RbType, "sdncCreateRollbackReq", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncCreateRollbackReq.xml")); rollbackData.put(RbType, "sdncAssignRollbackReq", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncAssignRollbackReq.xml")); variables.put("rollbackData",rollbackData); + + return rollbackData; } } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoCreateAllottedResourceBRGTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoCreateAllottedResourceBRGTest.java index 4f7b32b340..5b6f74fc7d 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoCreateAllottedResourceBRGTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoCreateAllottedResourceBRGTest.java @@ -1,4 +1,4 @@ -/*- +/* * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ @@ -7,9 +7,9 @@ * 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. @@ -17,13 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - -/* - * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. - */ package org.openecomp.mso.bpmn.vcpe; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchAllottedResource; @@ -40,18 +38,18 @@ import org.camunda.bpm.engine.test.Deployment; import org.junit.Assert; import org.junit.Test; import org.openecomp.mso.bpmn.common.BPMNUtil; -import org.openecomp.mso.bpmn.common.WorkflowTest; import org.openecomp.mso.bpmn.mock.FileUtil; -public class DoCreateAllottedResourceBRGTest extends WorkflowTest { +public class DoCreateAllottedResourceBRGTest extends AbstractTestBase { + private static final String PROCNAME = "DoCreateAllottedResourceBRG"; private final CallbackSet callbacks = new CallbackSet(); public DoCreateAllottedResourceBRGTest() throws IOException { - callbacks.put("assign", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyAssignCallback.xml")); - callbacks.put("create", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyCreateCallback.xml")); - callbacks.put("activate", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyActivateCallback.xml")); + callbacks.put("assign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyAssignCallback.xml")); + callbacks.put("create", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyCreateCallback.xml")); + callbacks.put("activate", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyActivateCallback.xml")); callbacks.put("query", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/SDNCTopologyQueryCallback.xml")); } @@ -62,14 +60,21 @@ public class DoCreateAllottedResourceBRGTest extends WorkflowTest { "subprocess/FalloutHandler.bpmn", "subprocess/DoCreateAllottedResourceBRG.bpmn", "subprocess/DoCreateAllottedResourceBRGRollback.bpmn"}) - public void testDoCreateAllottedResourceBRG_success() throws Exception{ - - MockNodeQueryServiceInstanceById("MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getSIUrlById.xml"); - MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); - MockNodeQueryServiceInstanceById("MIS%252F1604%252F0027%252FSW_INTERNET", "GenericFlows/getParentSIUrlById.xml"); - MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0027%252FSW_INTERNET", "GenericFlows/getParentServiceInstance.xml"); - MockPutAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0027%252FSW_INTERNET", "arId-1"); - MockPatchAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0027%252FSW_INTERNET", "arId-1"); + public void testDoCreateAllottedResourceBRG_Success() throws Exception{ + + // TODO: use INST instead of DEC_INST + /* + * should be INST instead of DEC_INST, but AAI utilities appear to + * have a bug in that they don't URL-encode the SI id before using + * it in the query + */ + MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getSIUrlById.xml"); + MockNodeQueryServiceInstanceById(DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml"); + + MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml"); + MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml"); + MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID); + MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID); mockSDNCAdapter(200); mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); @@ -77,7 +82,7 @@ public class DoCreateAllottedResourceBRGTest extends WorkflowTest { Map variables = new HashMap<>(); setVariablesSuccess(variables, "testRequestId123"); - invokeSubProcess("DoCreateAllottedResourceBRG", businessKey, variables); + invokeSubProcess(PROCNAME, businessKey, variables); injectSDNCCallbacks(callbacks, "assign"); injectSDNCCallbacks(callbacks, "create"); @@ -87,14 +92,178 @@ public class DoCreateAllottedResourceBRGTest extends WorkflowTest { waitForProcessEnd(businessKey, 10000); Assert.assertTrue(isProcessEnded(businessKey)); - String allotedResourceName = BPMNUtil.getVariable(processEngineRule, "DoCreateAllottedResourceBRG", "allotedResourceName"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "DoCreateAllottedResourceBRG", "WorkflowException"); - assertEquals("namefromrequest", allotedResourceName); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); assertEquals(null, workflowException); + + assertEquals("namefromrequest", BPMNUtil.getVariable(processEngineRule, PROCNAME, "allotedResourceName")); + } + + @Test + @Deployment(resources = { + "subprocess/GenericGetService.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoCreateAllottedResourceBRG.bpmn", + "subprocess/DoCreateAllottedResourceBRGRollback.bpmn"}) + public void testDoCreateAllottedResourceBRG_NoSI() throws Exception{ + + // TODO: use INST instead of DEC_INST + /* + * should be INST instead of DEC_INST, but AAI utilities appear to + * have a bug in that they don't URL-encode the SI id before using + * it in the query + */ + MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getNotFound.xml"); + MockNodeQueryServiceInstanceById(DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml"); + + MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml"); + MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml"); + MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID); + MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID); + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariablesSuccess(variables, "testRequestId123"); + + invokeSubProcess(PROCNAME, businessKey, variables); + + waitForProcessEnd(businessKey, 10000); + + Assert.assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + assertNotNull(workflowException); + + assertEquals(null, BPMNUtil.getVariable(processEngineRule, PROCNAME, "allotedResourceName")); + } + + @Test + @Deployment(resources = { + "subprocess/GenericGetService.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoCreateAllottedResourceBRG.bpmn", + "subprocess/DoCreateAllottedResourceBRGRollback.bpmn"}) + public void testDoCreateAllottedResourceBRG_ActiveAr() throws Exception{ + + // TODO: use INST instead of DEC_INST + /* + * should be INST instead of DEC_INST, but AAI utilities appear to + * have a bug in that they don't URL-encode the SI id before using + * it in the query + */ + MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getSIUrlById.xml"); + MockNodeQueryServiceInstanceById(DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml"); + + MockGetServiceInstance(CUST, SVC, INST, "VCPE/DoCreateAllottedResourceBRG/getSIandAR.xml"); + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg2.xml"); + MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml"); + MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID); + MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID); + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariablesSuccess(variables, "testRequestId123"); + + variables.put("failExists", "false"); + + invokeSubProcess(PROCNAME, businessKey, variables); + + injectSDNCCallbacks(callbacks, "query"); + + waitForProcessEnd(businessKey, 10000); + + Assert.assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + assertEquals(null, workflowException); + + assertEquals("namefromrequest", BPMNUtil.getVariable(processEngineRule, PROCNAME, "allotedResourceName")); + } + + @Test + @Deployment(resources = { + "subprocess/GenericGetService.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoCreateAllottedResourceBRG.bpmn", + "subprocess/DoCreateAllottedResourceBRGRollback.bpmn"}) + public void testDoCreateAllottedResourceBRG_NoParentSI() throws Exception{ + + // TODO: use INST instead of DEC_INST + /* + * should be INST instead of DEC_INST, but AAI utilities appear to + * have a bug in that they don't URL-encode the SI id before using + * it in the query + */ + MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getSIUrlById.xml"); + MockNodeQueryServiceInstanceById(DEC_PARENT_INST, "GenericFlows/getNotFound.xml"); + + MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml"); + MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml"); + MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID); + MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID); + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariablesSuccess(variables, "testRequestId123"); + + invokeSubProcess(PROCNAME, businessKey, variables); + + waitForProcessEnd(businessKey, 10000); + + Assert.assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + assertNotNull(workflowException); + + assertEquals(null, BPMNUtil.getVariable(processEngineRule, PROCNAME, "allotedResourceName")); + } + + @Test + @Deployment(resources = { + "subprocess/GenericGetService.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoCreateAllottedResourceBRG.bpmn", + "subprocess/DoCreateAllottedResourceBRGRollback.bpmn"}) + public void testDoCreateAllottedResourceBRG_SubProcessError() throws Exception{ + + // TODO: use INST instead of DEC_INST + /* + * should be INST instead of DEC_INST, but AAI utilities appear to + * have a bug in that they don't URL-encode the SI id before using + * it in the query + */ + MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getSIUrlById.xml"); + MockNodeQueryServiceInstanceById(DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml"); + + MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml"); + MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml"); + MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID); + MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID); + mockSDNCAdapter(404); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariablesSuccess(variables, "testRequestId123"); + + invokeSubProcess(PROCNAME, businessKey, variables); + + waitForProcessEnd(businessKey, 10000); + + Assert.assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + assertNotNull(workflowException); + + assertEquals(null, BPMNUtil.getVariable(processEngineRule, PROCNAME, "allotedResourceName")); } private void setVariablesSuccess(Map variables, String requestId) { - // TODO: need all of these? variables.put("isDebugLogEnabled", "true"); variables.put("failExists", "true"); variables.put("disableRollback", "true"); @@ -104,14 +273,15 @@ public class DoCreateAllottedResourceBRGTest extends WorkflowTest { variables.put("sourceNetworkRole", "snRole"); variables.put("allottedResourceRole", "txc"); variables.put("allottedResourceType", "BRG"); - variables.put("allottedResourceId", "arId-1"); + variables.put("allottedResourceId", ARID); variables.put("vni", "BRG"); variables.put("vgmuxBearerIP", "bearerip"); variables.put("brgWanMacAddress", "wanmac"); variables.put("junitSleepMs", "5"); + + variables.put("serviceInstanceId", DEC_INST); + variables.put("parentServiceInstanceId", DEC_PARENT_INST); - variables.put("serviceInstanceId", "MIS%252F1604%252F0026%252FSW_INTERNET"); - variables.put("parentServiceInstanceId","MIS%252F1604%252F0027%252FSW_INTERNET"); variables.put("serviceChainServiceInstanceId", "scsiId"); String arModelInfo = "{ "+ "\"modelType\": \"allotted-resource\"," + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoCreateAllottedResourceTXCRollbackTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoCreateAllottedResourceTXCRollbackTest.java index a887f72db0..cdce56ee63 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoCreateAllottedResourceTXCRollbackTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoCreateAllottedResourceTXCRollbackTest.java @@ -1,4 +1,4 @@ -/*- +/* * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ @@ -7,9 +7,9 @@ * 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. @@ -17,13 +17,12 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - -/* - * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. - */ package org.openecomp.mso.bpmn.vcpe; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchAllottedResource; @@ -36,23 +35,22 @@ import java.util.Map; import java.util.UUID; import org.camunda.bpm.engine.test.Deployment; -import org.junit.Assert; import org.junit.Test; import org.openecomp.mso.bpmn.common.BPMNUtil; -import org.openecomp.mso.bpmn.common.WorkflowTest; import org.openecomp.mso.bpmn.core.RollbackData; import org.openecomp.mso.bpmn.mock.FileUtil; -public class DoCreateAllottedResourceTXCRollbackTest extends WorkflowTest { +public class DoCreateAllottedResourceTXCRollbackTest extends AbstractTestBase { + private static final String PROCNAME = "DoCreateAllottedResourceTXCRollback"; private static final String RbType = "DCARTXC_"; private final CallbackSet callbacks = new CallbackSet(); public DoCreateAllottedResourceTXCRollbackTest() throws IOException { - callbacks.put("deactivate", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyDeactivateCallback.xml")); - callbacks.put("delete", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyDeleteCallback.xml")); - callbacks.put("unassign", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyUnassignCallback.xml")); + callbacks.put("deactivate", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallback.xml")); + callbacks.put("delete", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeleteCallback.xml")); + callbacks.put("unassign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyUnassignCallback.xml")); } @Test @@ -60,11 +58,11 @@ public class DoCreateAllottedResourceTXCRollbackTest extends WorkflowTest { "subprocess/SDNCAdapterV1.bpmn", "subprocess/FalloutHandler.bpmn", "subprocess/DoCreateAllottedResourceTXCRollback.bpmn"}) - public void testDoCreateAllottedResourceTXCRollback_success() throws Exception{ + public void testDoCreateAllottedResourceTXCRollback_Success() throws Exception { - MockGetAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "arId-1", "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml"); - MockPatchAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "arId-1"); - MockDeleteAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "arId-1", "1490627351232"); + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml"); + MockPatchAllottedResource(CUST, SVC, INST, ARID); + MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS); mockSDNCAdapter(200); mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); @@ -72,7 +70,7 @@ public class DoCreateAllottedResourceTXCRollbackTest extends WorkflowTest { Map variables = new HashMap<>(); setVariablesSuccess(variables, "testRequestId1"); - invokeSubProcess("DoCreateAllottedResourceTXCRollback", businessKey, variables); + invokeSubProcess(PROCNAME, businessKey, variables); injectSDNCCallbacks(callbacks, "deactivate"); injectSDNCCallbacks(callbacks, "delete"); @@ -80,37 +78,268 @@ public class DoCreateAllottedResourceTXCRollbackTest extends WorkflowTest { waitForProcessEnd(businessKey, 10000); - Assert.assertTrue(isProcessEnded(businessKey)); - String workflowException = BPMNUtil.getVariable(processEngineRule, "DoCreateAllottedResourceTXCRollback", "WorkflowException"); + assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); System.out.println("workflowException:\n" + workflowException); assertEquals(null, workflowException); + assertEquals("true", BPMNUtil.getVariable(processEngineRule, PROCNAME, "rolledBack")); + assertNull(BPMNUtil.getVariable(processEngineRule, PROCNAME, "rollbackError")); } + + @Test + @Deployment(resources = { + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoCreateAllottedResourceTXCRollback.bpmn"}) + public void testDoCreateAllottedResourceTXCRollback_skipRollback() throws Exception { + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml"); + MockPatchAllottedResource(CUST, SVC, INST, ARID); + MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS); + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + RollbackData rollbackData = setVariablesSuccess(variables, "testRequestId1"); + + rollbackData.put(RbType, "rollbackAAI", "false"); + rollbackData.put(RbType, "rollbackSDNCassign", "false"); + + invokeSubProcess(PROCNAME, businessKey, variables); - private void setVariablesSuccess(Map variables, String requestId) { + waitForProcessEnd(businessKey, 10000); + + assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + assertEquals(null, workflowException); + assertEquals(null, BPMNUtil.getVariable(processEngineRule, PROCNAME, "rolledBack")); + assertNull(BPMNUtil.getVariable(processEngineRule, PROCNAME, "rollbackError")); + } + + @Test + @Deployment(resources = { + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoCreateAllottedResourceTXCRollback.bpmn"}) + public void testDoCreateAllottedResourceTXCRollback_DoNotRollBack() throws Exception { + + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + RollbackData rollbackData = setVariablesSuccess(variables, "testRequestId1"); + + // this will cause "rollbackSDNC" to be set to false + rollbackData.put(RbType, "rollbackSDNCassign", "false"); + + invokeSubProcess(PROCNAME, businessKey, variables); + + waitForProcessEnd(businessKey, 10000); + + assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + assertEquals(null, workflowException); + assertEquals("true", BPMNUtil.getVariable(processEngineRule, PROCNAME, "rolledBack")); + assertNull(BPMNUtil.getVariable(processEngineRule, PROCNAME, "rollbackError")); + } + + @Test + @Deployment(resources = { + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoCreateAllottedResourceTXCRollback.bpmn"}) + public void testDoCreateAllottedResourceTXCRollback_NoDeactivate() throws Exception { + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml"); + MockPatchAllottedResource(CUST, SVC, INST, ARID); + MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS); + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + RollbackData rollbackData = setVariablesSuccess(variables, "testRequestId1"); + + rollbackData.put(RbType, "rollbackSDNCactivate", "false"); + + invokeSubProcess(PROCNAME, businessKey, variables); + + injectSDNCCallbacks(callbacks, "delete"); + injectSDNCCallbacks(callbacks, "unassign"); + + waitForProcessEnd(businessKey, 10000); + + assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + assertEquals(null, workflowException); + assertEquals("true", BPMNUtil.getVariable(processEngineRule, PROCNAME, "rolledBack")); + assertNull(BPMNUtil.getVariable(processEngineRule, PROCNAME, "rollbackError")); + } + + @Test + @Deployment(resources = { + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoCreateAllottedResourceTXCRollback.bpmn"}) + public void testDoCreateAllottedResourceTXCRollback_NoDelete() throws Exception { + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml"); + MockPatchAllottedResource(CUST, SVC, INST, ARID); + MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS); + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + RollbackData rollbackData = setVariablesSuccess(variables, "testRequestId1"); + + rollbackData.put(RbType, "rollbackSDNCcreate", "false"); + + invokeSubProcess(PROCNAME, businessKey, variables); + + injectSDNCCallbacks(callbacks, "deactivate"); + injectSDNCCallbacks(callbacks, "unassign"); + + waitForProcessEnd(businessKey, 10000); + + assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + assertEquals(null, workflowException); + assertEquals("true", BPMNUtil.getVariable(processEngineRule, PROCNAME, "rolledBack")); + assertNull(BPMNUtil.getVariable(processEngineRule, PROCNAME, "rollbackError")); + } + + @Test + @Deployment(resources = { + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoCreateAllottedResourceTXCRollback.bpmn"}) + public void testDoCreateAllottedResourceTXCRollback_NoUnassign() throws Exception { + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml"); + MockPatchAllottedResource(CUST, SVC, INST, ARID); + MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS); + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + RollbackData rollbackData = setVariablesSuccess(variables, "testRequestId1"); + + rollbackData.put(RbType, "rollbackSDNCassign", "false"); + + /* + * Note: if assign == false then the flow/script will set + * "skipRollback" to false, which will cause ALL of the SDNC steps + * to be skipped, not just the unassign step. + */ + + invokeSubProcess(PROCNAME, businessKey, variables); + + waitForProcessEnd(businessKey, 10000); + + assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + assertEquals(null, workflowException); + assertEquals("true", BPMNUtil.getVariable(processEngineRule, PROCNAME, "rolledBack")); + assertNull(BPMNUtil.getVariable(processEngineRule, PROCNAME, "rollbackError")); + } + + @Test + @Deployment(resources = { + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoCreateAllottedResourceTXCRollback.bpmn"}) + public void testDoCreateAllottedResourceTXCRollback_SubProcessError() throws Exception { + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml"); + MockPatchAllottedResource(CUST, SVC, INST, ARID); + MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + mockSDNCAdapter(404); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariablesSuccess(variables, "testRequestId1"); + + invokeSubProcess(PROCNAME, businessKey, variables); + + waitForProcessEnd(businessKey, 10000); + + assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + assertEquals(null, workflowException); + assertEquals("false", BPMNUtil.getVariable(processEngineRule, PROCNAME, "rolledBack")); + assertNotNull(BPMNUtil.getVariable(processEngineRule, PROCNAME, "rollbackError")); + } + + @Test + @Deployment(resources = { + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoCreateAllottedResourceTXCRollback.bpmn"}) + public void testDoCreateAllottedResourceTXCRollback_JavaException() throws Exception { + + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml"); + MockPatchAllottedResource(CUST, SVC, INST, ARID); + MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS); + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariablesSuccess(variables, "testRequestId1"); + + variables.put("rollbackData", "string instead of rollback data"); + + invokeSubProcess(PROCNAME, businessKey, variables); + + waitForProcessEnd(businessKey, 10000); + + assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + assertEquals(null, workflowException); + assertEquals("false", BPMNUtil.getVariable(processEngineRule, PROCNAME, "rolledBack")); + assertNotNull(BPMNUtil.getVariable(processEngineRule, PROCNAME, "rollbackError")); + } + + private RollbackData setVariablesSuccess(Map variables, String requestId) { variables.put("isDebugLogEnabled", "true"); variables.put("failNotFound", "true"); variables.put("msoRequestId", requestId); variables.put("mso-request-id", "requestId"); - variables.put("allottedResourceId", "arId-1"); + variables.put("allottedResourceId", ARID); + + variables.put("serviceInstanceId", DEC_INST); + variables.put("parentServiceInstanceId", DEC_PARENT_INST); - variables.put("serviceInstanceId", "MIS%252F1604%252F0026%252FSW_INTERNET"); - variables.put("parentServiceInstanceId","MIS%252F1604%252F0026%252FSW_INTERNET"); RollbackData rollbackData = new RollbackData(); - rollbackData.put(RbType, "serviceInstanceId", "MIS%252F1604%252F0026%252FSW_INTERNET"); - rollbackData.put(RbType, "serviceSubscriptionType", "123456789"); + rollbackData.put(RbType, "serviceInstanceId", DEC_INST); + rollbackData.put(RbType, "serviceSubscriptionType", SVC); rollbackData.put(RbType, "disablerollback", "false"); rollbackData.put(RbType, "rollbackAAI", "true"); rollbackData.put(RbType, "rollbackSDNCassign", "true"); rollbackData.put(RbType, "rollbackSDNCactivate", "true"); rollbackData.put(RbType, "rollbackSDNCcreate", "true"); - rollbackData.put(RbType, "aaiARPath", "http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1"); + rollbackData.put(RbType, "aaiARPath", "http://localhost:28090/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID); rollbackData.put(RbType, "sdncActivateRollbackReq", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXCRollback/sdncActivateRollbackReq.xml")); rollbackData.put(RbType, "sdncCreateRollbackReq", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXCRollback/sdncCreateRollbackReq.xml")); rollbackData.put(RbType, "sdncAssignRollbackReq", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXCRollback/sdncAssignRollbackReq.xml")); variables.put("rollbackData",rollbackData); + + return rollbackData; } } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoCreateAllottedResourceTXCTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoCreateAllottedResourceTXCTest.java index 42704bfe97..4323ccae1a 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoCreateAllottedResourceTXCTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoCreateAllottedResourceTXCTest.java @@ -1,4 +1,4 @@ -/*- +/* * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ @@ -7,9 +7,9 @@ * 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. @@ -17,13 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - -/* - * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. - */ package org.openecomp.mso.bpmn.vcpe; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchAllottedResource; @@ -40,18 +38,18 @@ import org.camunda.bpm.engine.test.Deployment; import org.junit.Assert; import org.junit.Test; import org.openecomp.mso.bpmn.common.BPMNUtil; -import org.openecomp.mso.bpmn.common.WorkflowTest; import org.openecomp.mso.bpmn.mock.FileUtil; -public class DoCreateAllottedResourceTXCTest extends WorkflowTest { +public class DoCreateAllottedResourceTXCTest extends AbstractTestBase { + private static final String PROCNAME = "DoCreateAllottedResourceTXC"; private final CallbackSet callbacks = new CallbackSet(); public DoCreateAllottedResourceTXCTest() throws IOException { - callbacks.put("assign", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyAssignCallback.xml")); - callbacks.put("create", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyCreateCallback.xml")); - callbacks.put("activate", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyActivateCallback.xml")); + callbacks.put("assign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyAssignCallback.xml")); + callbacks.put("create", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyCreateCallback.xml")); + callbacks.put("activate", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyActivateCallback.xml")); callbacks.put("query", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXC/SDNCTopologyQueryCallback.xml")); } @@ -62,22 +60,29 @@ public class DoCreateAllottedResourceTXCTest extends WorkflowTest { "subprocess/FalloutHandler.bpmn", "subprocess/DoCreateAllottedResourceTXC.bpmn", "subprocess/DoCreateAllottedResourceTXCRollback.bpmn"}) - public void testDoCreateAllottedResourceTXC_success() throws Exception{ - - MockNodeQueryServiceInstanceById("MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getSIUrlById.xml"); - MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); - MockNodeQueryServiceInstanceById("MIS%252F1604%252F0027%252FSW_INTERNET", "GenericFlows/getParentSIUrlById.xml"); - MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0027%252FSW_INTERNET", "GenericFlows/getParentServiceInstance.xml"); - MockPutAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0027%252FSW_INTERNET", "arId-1"); - MockPatchAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0027%252FSW_INTERNET", "arId-1"); + public void testDoCreateAllottedResourceTXC_Success() throws Exception{ + + // TODO: use INST instead of DEC_INST + /* + * should be INST instead of DEC_INST, but AAI utilities appear to + * have a bug in that they don't URL-encode the SI id before using + * it in the query + */ + MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getSIUrlById.xml"); + MockNodeQueryServiceInstanceById(DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml"); + + MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml"); + MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml"); + MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID); + MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID); mockSDNCAdapter(200); mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); String businessKey = UUID.randomUUID().toString(); - Map variables = new HashMap(); + Map variables = new HashMap<>(); setVariablesSuccess(variables, "testRequestId123"); - invokeSubProcess("DoCreateAllottedResourceTXC", businessKey, variables); + invokeSubProcess(PROCNAME, businessKey, variables); injectSDNCCallbacks(callbacks, "assign"); injectSDNCCallbacks(callbacks, "create"); @@ -87,13 +92,186 @@ public class DoCreateAllottedResourceTXCTest extends WorkflowTest { waitForProcessEnd(businessKey, 10000); Assert.assertTrue(isProcessEnded(businessKey)); - String workflowException = BPMNUtil.getVariable(processEngineRule, "DoCreateAllottedResourceTXC", "WorkflowException"); - System.out.println("workflowException:\n" + workflowException); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + assertEquals(null, workflowException); + + assertEquals("namefromrequest", BPMNUtil.getVariable(processEngineRule, PROCNAME, "allotedResourceName")); + assertEquals("my-vni", BPMNUtil.getVariable(processEngineRule, PROCNAME, "vni")); + assertEquals("my-bearer-ip", BPMNUtil.getVariable(processEngineRule, PROCNAME, "vgmuxBearerIP")); + assertEquals("my-lan-ip", BPMNUtil.getVariable(processEngineRule, PROCNAME, "vgmuxLanIP")); + } + + @Test + @Deployment(resources = { + "subprocess/GenericGetService.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoCreateAllottedResourceTXC.bpmn", + "subprocess/DoCreateAllottedResourceTXCRollback.bpmn"}) + public void testDoCreateAllottedResourceTXC_NoSI() throws Exception{ + + // TODO: use INST instead of DEC_INST + /* + * should be INST instead of DEC_INST, but AAI utilities appear to + * have a bug in that they don't URL-encode the SI id before using + * it in the query + */ + MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getNotFound.xml"); + MockNodeQueryServiceInstanceById(DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml"); + + MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml"); + MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml"); + MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID); + MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID); + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariablesSuccess(variables, "testRequestId123"); + + invokeSubProcess(PROCNAME, businessKey, variables); + + waitForProcessEnd(businessKey, 10000); + + Assert.assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + assertNotNull(workflowException); + + assertEquals(null, BPMNUtil.getVariable(processEngineRule, PROCNAME, "allotedResourceName")); + } + + @Test + @Deployment(resources = { + "subprocess/GenericGetService.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoCreateAllottedResourceTXC.bpmn", + "subprocess/DoCreateAllottedResourceTXCRollback.bpmn"}) + public void testDoCreateAllottedResourceTXC_ActiveAr() throws Exception{ + + // TODO: use INST instead of DEC_INST + /* + * should be INST instead of DEC_INST, but AAI utilities appear to + * have a bug in that they don't URL-encode the SI id before using + * it in the query + */ + MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getSIUrlById.xml"); + MockNodeQueryServiceInstanceById(DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml"); + + MockGetServiceInstance(CUST, SVC, INST, "VCPE/DoCreateAllottedResourceTXC/getSIandAR.xml"); + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc2.xml"); + MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml"); + MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID); + MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID); + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariablesSuccess(variables, "testRequestId123"); + + variables.put("failExists", "false"); + + invokeSubProcess(PROCNAME, businessKey, variables); + + injectSDNCCallbacks(callbacks, "query"); + + waitForProcessEnd(businessKey, 10000); + + Assert.assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); assertEquals(null, workflowException); - logEnd(); + + assertEquals("namefromrequest", BPMNUtil.getVariable(processEngineRule, PROCNAME, "allotedResourceName")); + assertEquals("my-vni", BPMNUtil.getVariable(processEngineRule, PROCNAME, "vni")); + assertEquals("my-bearer-ip", BPMNUtil.getVariable(processEngineRule, PROCNAME, "vgmuxBearerIP")); + assertEquals("my-lan-ip", BPMNUtil.getVariable(processEngineRule, PROCNAME, "vgmuxLanIP")); + } + + @Test + @Deployment(resources = { + "subprocess/GenericGetService.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoCreateAllottedResourceTXC.bpmn", + "subprocess/DoCreateAllottedResourceTXCRollback.bpmn"}) + public void testDoCreateAllottedResourceTXC_NoParentSI() throws Exception{ + + // TODO: use INST instead of DEC_INST + /* + * should be INST instead of DEC_INST, but AAI utilities appear to + * have a bug in that they don't URL-encode the SI id before using + * it in the query + */ + MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getSIUrlById.xml"); + + MockNodeQueryServiceInstanceById(DEC_PARENT_INST, "GenericFlows/getNotFound.xml"); + + MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml"); + MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml"); + MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID); + MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID); + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariablesSuccess(variables, "testRequestId123"); + + invokeSubProcess(PROCNAME, businessKey, variables); + + waitForProcessEnd(businessKey, 10000); + + Assert.assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + assertNotNull(workflowException); + + assertEquals(null, BPMNUtil.getVariable(processEngineRule, PROCNAME, "allotedResourceName")); + } + + @Test + @Deployment(resources = { + "subprocess/GenericGetService.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoCreateAllottedResourceTXC.bpmn", + "subprocess/DoCreateAllottedResourceTXCRollback.bpmn"}) + public void testDoCreateAllottedResourceTXC_SubProcessError() throws Exception{ + + // TODO: use INST instead of DEC_INST + /* + * should be INST instead of DEC_INST, but AAI utilities appear to + * have a bug in that they don't URL-encode the SI id before using + * it in the query + */ + MockNodeQueryServiceInstanceById(DEC_INST, "GenericFlows/getSIUrlById.xml"); + MockNodeQueryServiceInstanceById(DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml"); + + MockGetServiceInstance(CUST, SVC, INST, "GenericFlows/getServiceInstance.xml"); + MockGetServiceInstance(CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml"); + MockPutAllottedResource(CUST, SVC, PARENT_INST, ARID); + MockPatchAllottedResource(CUST, SVC, PARENT_INST, ARID); + mockSDNCAdapter(404); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariablesSuccess(variables, "testRequestId123"); + + invokeSubProcess(PROCNAME, businessKey, variables); + + waitForProcessEnd(businessKey, 10000); + + Assert.assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + assertNotNull(workflowException); + + assertEquals(null, BPMNUtil.getVariable(processEngineRule, PROCNAME, "allotedResourceName")); } private void setVariablesSuccess(Map variables, String requestId) { + // TODO: need all of these? variables.put("isDebugLogEnabled", "true"); variables.put("failExists", "true"); variables.put("disableRollback", "true"); @@ -101,14 +279,15 @@ public class DoCreateAllottedResourceTXCTest extends WorkflowTest { variables.put("mso-request-id", "requestId"); variables.put("sourceNetworkId", "snId"); variables.put("sourceNetworkRole", "snRole"); - variables.put("allottedResourceRole", "txc"); - variables.put("allottedResourceType", "TunnelXConn"); - variables.put("allottedResourceId", "arId-1"); + variables.put("allottedResourceRole", "brg"); + variables.put("allottedResourceType", "TXC"); + variables.put("allottedResourceId", ARID); variables.put("brgWanMacAddress", "wanmac"); variables.put("junitSleepMs", "5"); + + variables.put("serviceInstanceId", DEC_INST); + variables.put("parentServiceInstanceId", DEC_PARENT_INST); - variables.put("serviceInstanceId", "MIS%252F1604%252F0026%252FSW_INTERNET"); - variables.put("parentServiceInstanceId","MIS%252F1604%252F0027%252FSW_INTERNET"); variables.put("serviceChainServiceInstanceId", "scsiId"); String arModelInfo = "{ "+ "\"modelType\": \"allotted-resource\"," + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoDeleteAllottedResourceBRGTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoDeleteAllottedResourceBRGTest.java index 46f5da46b3..03972da789 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoDeleteAllottedResourceBRGTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoDeleteAllottedResourceBRGTest.java @@ -1,4 +1,4 @@ -/*- +/* * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ @@ -7,9 +7,9 @@ * 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. @@ -17,13 +17,10 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - -/* - * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. - */ package org.openecomp.mso.bpmn.vcpe; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchAllottedResource; @@ -38,20 +35,22 @@ import java.util.UUID; import org.camunda.bpm.engine.test.Deployment; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; import org.openecomp.mso.bpmn.common.BPMNUtil; -import org.openecomp.mso.bpmn.common.WorkflowTest; import org.openecomp.mso.bpmn.mock.FileUtil; -public class DoDeleteAllottedResourceBRGTest extends WorkflowTest { +public class DoDeleteAllottedResourceBRGTest extends AbstractTestBase { + private static final String PROCNAME = "DoDeleteAllottedResourceBRG"; private final CallbackSet callbacks = new CallbackSet(); public DoDeleteAllottedResourceBRGTest() throws IOException { - callbacks.put("deactivate", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyDeactivateCallback.xml")); - callbacks.put("delete", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyDeleteCallback.xml")); - callbacks.put("unassign", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyUnassignCallback.xml")); + callbacks.put("deactivate", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallback.xml")); + callbacks.put("deactivateNF", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallbackNotFound.xml")); + callbacks.put("delete", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeleteCallback.xml")); + callbacks.put("unassign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyUnassignCallback.xml")); } @Test @@ -59,12 +58,12 @@ public class DoDeleteAllottedResourceBRGTest extends WorkflowTest { "subprocess/SDNCAdapterV1.bpmn", "subprocess/FalloutHandler.bpmn", "subprocess/DoDeleteAllottedResourceBRG.bpmn"}) - public void testDoDeleteAllottedResourceBRG_success() throws Exception { + public void testDoDeleteAllottedResourceBRG_Success() throws Exception { - MockQueryAllottedResourceById("arId-1", "GenericFlows/getARUrlById.xml"); - MockGetAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "arId-1", "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml"); - MockPatchAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "arId-1"); - MockDeleteAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "arId-1", "1490627351232"); + MockQueryAllottedResourceById(ARID, "GenericFlows/getARUrlById.xml"); + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml"); + MockPatchAllottedResource(CUST, SVC, INST, ARID); + MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS); mockSDNCAdapter(200); mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); @@ -72,7 +71,7 @@ public class DoDeleteAllottedResourceBRGTest extends WorkflowTest { Map variables = new HashMap<>(); setVariablesSuccess(variables, "testRequestId1"); - invokeSubProcess("DoDeleteAllottedResourceBRG", businessKey, variables); + invokeSubProcess(PROCNAME, businessKey, variables); injectSDNCCallbacks(callbacks, "deactivate"); injectSDNCCallbacks(callbacks, "delete"); @@ -81,20 +80,83 @@ public class DoDeleteAllottedResourceBRGTest extends WorkflowTest { waitForProcessEnd(businessKey, 10000); Assert.assertTrue(isProcessEnded(businessKey)); - String workflowException = BPMNUtil.getVariable(processEngineRule, "DoDeleteAllottedResourceBRG", "WorkflowException"); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); System.out.println("workflowException:\n" + workflowException); assertEquals(null, workflowException); } + + @Test + @Deployment(resources = { + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoDeleteAllottedResourceBRG.bpmn"}) + public void testDoDeleteAllottedResourceBRG_ARNotInSDNC() throws Exception { + + MockQueryAllottedResourceById(ARID, "GenericFlows/getARUrlById.xml"); + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml"); + MockPatchAllottedResource(CUST, SVC, INST, ARID); + MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS); + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariablesSuccess(variables, "testRequestId1"); + + variables.put("failNotFound", "false"); + + invokeSubProcess(PROCNAME, businessKey, variables); + + injectSDNCCallbacks(callbacks, "deactivateNF"); + + waitForProcessEnd(businessKey, 10000); + + Assert.assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + assertEquals(null, workflowException); + } + + // TODO - exception is not caught + @Test + @Ignore + @Deployment(resources = { + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoDeleteAllottedResourceBRG.bpmn"}) + public void testDoDeleteAllottedResourceBRG_SubProcessError() throws Exception { + + MockQueryAllottedResourceById(ARID, "GenericFlows/getARUrlById.xml"); + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml"); + MockPatchAllottedResource(CUST, SVC, INST, ARID); + MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + mockSDNCAdapter(500); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariablesSuccess(variables, "testRequestId1"); + + invokeSubProcess(PROCNAME, businessKey, variables); + + waitForProcessEnd(businessKey, 10000); + + Assert.assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + assertNotNull(workflowException); + } private void setVariablesSuccess(Map variables, String requestId) { variables.put("isDebugLogEnabled", "true"); variables.put("failNotFound", "true"); variables.put("msoRequestId", requestId); variables.put("mso-request-id", "requestId"); - variables.put("allottedResourceId", "arId-1"); + variables.put("allottedResourceId", ARID); - variables.put("serviceInstanceId", "MIS%252F1604%252F0026%252FSW_INTERNET"); - variables.put("parentServiceInstanceId","MIS%252F1604%252F0026%252FSW_INTERNET"); + variables.put("serviceInstanceId", DEC_INST); + variables.put("parentServiceInstanceId", DEC_PARENT_INST); } } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoDeleteAllottedResourceTXCTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoDeleteAllottedResourceTXCTest.java index 48e1349633..2b0364c3c9 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoDeleteAllottedResourceTXCTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoDeleteAllottedResourceTXCTest.java @@ -1,4 +1,4 @@ -/*- +/* * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ @@ -7,9 +7,9 @@ * 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. @@ -17,13 +17,10 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - -/* - * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. - */ package org.openecomp.mso.bpmn.vcpe; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchAllottedResource; @@ -38,20 +35,22 @@ import java.util.UUID; import org.camunda.bpm.engine.test.Deployment; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; import org.openecomp.mso.bpmn.common.BPMNUtil; -import org.openecomp.mso.bpmn.common.WorkflowTest; import org.openecomp.mso.bpmn.mock.FileUtil; -public class DoDeleteAllottedResourceTXCTest extends WorkflowTest { +public class DoDeleteAllottedResourceTXCTest extends AbstractTestBase { + private static final String PROCNAME = "DoDeleteAllottedResourceTXC"; private final CallbackSet callbacks = new CallbackSet(); public DoDeleteAllottedResourceTXCTest() throws IOException { - callbacks.put("deactivate", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyDeactivateCallback.xml")); - callbacks.put("delete", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyDeleteCallback.xml")); - callbacks.put("unassign", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyUnassignCallback.xml")); + callbacks.put("deactivate", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallback.xml")); + callbacks.put("deactivateNF", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeactivateCallbackNotFound.xml")); + callbacks.put("delete", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeleteCallback.xml")); + callbacks.put("unassign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyUnassignCallback.xml")); } @Test @@ -59,12 +58,12 @@ public class DoDeleteAllottedResourceTXCTest extends WorkflowTest { "subprocess/SDNCAdapterV1.bpmn", "subprocess/FalloutHandler.bpmn", "subprocess/DoDeleteAllottedResourceTXC.bpmn"}) - public void testDoDeleteAllottedResourceTXC_success() throws Exception { + public void testDoDeleteAllottedResourceTXC_Success() throws Exception { - MockQueryAllottedResourceById("arId-1", "GenericFlows/getARUrlById.xml"); - MockGetAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "arId-1", "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml"); - MockPatchAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "arId-1"); - MockDeleteAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "arId-1", "1490627351232"); + MockQueryAllottedResourceById(ARID, "GenericFlows/getARUrlById.xml"); + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml"); + MockPatchAllottedResource(CUST, SVC, INST, ARID); + MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS); mockSDNCAdapter(200); mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); @@ -72,7 +71,7 @@ public class DoDeleteAllottedResourceTXCTest extends WorkflowTest { Map variables = new HashMap<>(); setVariablesSuccess(variables, "testRequestId1"); - invokeSubProcess("DoDeleteAllottedResourceTXC", businessKey, variables); + invokeSubProcess(PROCNAME, businessKey, variables); injectSDNCCallbacks(callbacks, "deactivate"); injectSDNCCallbacks(callbacks, "delete"); @@ -81,20 +80,83 @@ public class DoDeleteAllottedResourceTXCTest extends WorkflowTest { waitForProcessEnd(businessKey, 10000); Assert.assertTrue(isProcessEnded(businessKey)); - String workflowException = BPMNUtil.getVariable(processEngineRule, "DoDeleteAllottedResourceTXC", "WorkflowException"); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); System.out.println("workflowException:\n" + workflowException); assertEquals(null, workflowException); } + + @Test + @Deployment(resources = { + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoDeleteAllottedResourceTXC.bpmn"}) + public void testDoDeleteAllottedResourceTXC_ARNotInSDNC() throws Exception { + + MockQueryAllottedResourceById(ARID, "GenericFlows/getARUrlById.xml"); + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml"); + MockPatchAllottedResource(CUST, SVC, INST, ARID); + MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS); + mockSDNCAdapter(200); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariablesSuccess(variables, "testRequestId1"); + + variables.put("failNotFound", "false"); + + invokeSubProcess(PROCNAME, businessKey, variables); + + injectSDNCCallbacks(callbacks, "deactivateNF"); + + waitForProcessEnd(businessKey, 10000); + + Assert.assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + assertEquals(null, workflowException); + } + + // TODO - exception is not caught + @Test + @Ignore + @Deployment(resources = { + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/FalloutHandler.bpmn", + "subprocess/DoDeleteAllottedResourceTXC.bpmn"}) + public void testDoDeleteAllottedResourceTXC_SubProcessError() throws Exception { + + MockQueryAllottedResourceById(ARID, "GenericFlows/getARUrlById.xml"); + MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml"); + MockPatchAllottedResource(CUST, SVC, INST, ARID); + MockDeleteAllottedResource(CUST, SVC, INST, ARID, ARVERS); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + mockSDNCAdapter(500); + + String businessKey = UUID.randomUUID().toString(); + Map variables = new HashMap<>(); + setVariablesSuccess(variables, "testRequestId1"); + + invokeSubProcess(PROCNAME, businessKey, variables); + + waitForProcessEnd(businessKey, 10000); + + Assert.assertTrue(isProcessEnded(businessKey)); + String workflowException = BPMNUtil.getVariable(processEngineRule, PROCNAME, VAR_WFEX); + System.out.println("workflowException:\n" + workflowException); + assertNotNull(workflowException); + } private void setVariablesSuccess(Map variables, String requestId) { variables.put("isDebugLogEnabled", "true"); variables.put("failNotFound", "true"); variables.put("msoRequestId", requestId); variables.put("mso-request-id", "requestId"); - variables.put("allottedResourceId", "arId-1"); + variables.put("allottedResourceId", ARID); - variables.put("serviceInstanceId", "MIS%252F1604%252F0026%252FSW_INTERNET"); - variables.put("parentServiceInstanceId","MIS%252F1604%252F0026%252FSW_INTERNET"); + variables.put("serviceInstanceId", DEC_INST); + variables.put("parentServiceInstanceId", DEC_PARENT_INST); } } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRG.bpmn b/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRG.bpmn new file mode 100644 index 0000000000..b33aad7443 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRG.bpmn @@ -0,0 +1,54 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_1v2f9n5 + + + + SequenceFlow_1v2f9n5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRGRollback.bpmn b/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRGRollback.bpmn new file mode 100644 index 0000000000..807efae1af --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRGRollback.bpmn @@ -0,0 +1,55 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1epm19d + + + SequenceFlow_1 + SequenceFlow_1epm19d + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceTXC.bpmn b/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceTXC.bpmn new file mode 100644 index 0000000000..b2f280d7e9 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceTXC.bpmn @@ -0,0 +1,38 @@ + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateServiceInstanceRollback.bpmn b/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateServiceInstanceRollback.bpmn new file mode 100644 index 0000000000..532ca867bb --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateServiceInstanceRollback.bpmn @@ -0,0 +1,53 @@ + + + + + SequenceFlow_1ipu8um + + + SequenceFlow_1l4c4k0 + + + SequenceFlow_1ipu8um + SequenceFlow_1l4c4k0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModules.bpmn b/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModules.bpmn new file mode 100644 index 0000000000..5e4400e9bd --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModules.bpmn @@ -0,0 +1,53 @@ + + + + + SequenceFlow_11sp3s9 + + + + SequenceFlow_11sp3s9 + SequenceFlow_0q1lfmf + + + + + SequenceFlow_0q1lfmf + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModulesRollback.bpmn b/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModulesRollback.bpmn new file mode 100644 index 0000000000..2867a671b6 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModulesRollback.bpmn @@ -0,0 +1,53 @@ + + + + + SequenceFlow_1537b7m + + + SequenceFlow_1mz2mgf + + + + SequenceFlow_1537b7m + SequenceFlow_1mz2mgf + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoDeleteVnfAndModules.bpmn b/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoDeleteVnfAndModules.bpmn new file mode 100644 index 0000000000..517df36c74 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoDeleteVnfAndModules.bpmn @@ -0,0 +1,37 @@ + + + + + SequenceFlow_0qi7pl3 + + + + SequenceFlow_0qi7pl3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/Homing.bpmn b/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/Homing.bpmn new file mode 100644 index 0000000000..ad4c3c816d --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/Homing.bpmn @@ -0,0 +1,35 @@ + + + + + SequenceFlow_0tyavm9 + + + SequenceFlow_0tyavm9 + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/GenericFlows/getNotFound.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/GenericFlows/getNotFound.xml new file mode 100644 index 0000000000..f66c9c4fb8 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/GenericFlows/getNotFound.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateServiceInstance/createServiceInstance_AAIResponse_success.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateServiceInstance/createServiceInstance_AAIResponse_success.xml deleted file mode 100644 index 5f810bab4c..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateServiceInstance/createServiceInstance_AAIResponse_success.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryBRGCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryBRGCallback.xml new file mode 100644 index 0000000000..410ba05e5f --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryBRGCallback.xml @@ -0,0 +1,37 @@ + + + + 36e20198-c67a-464b-96d0-aaa99eb2639e + 5b9b15d0-5dd7-47dc-95b9-0440c340a3ba + 1.0 + BRGmodelname + 013bd784-9bca-4919-ae2f-ae57af27bad9 + + + parent-service-instance-id + consuming-service-instance-id + namefromrequest + brg + allottedresourceidfromrequest + + + fq-name + + d1 + drole + + vlan-tag + + s2 + srole + + txc-id + + 1 + 123 + a.b.c.d + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryTXCCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryTXCCallback.xml new file mode 100644 index 0000000000..ac85be4e97 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryTXCCallback.xml @@ -0,0 +1,24 @@ + + + + 36e20198-c67a-464b-96d0-aaa99eb2639e + 5b9b15d0-5dd7-47dc-95b9-0440c340a3ba + 1.0 + TXCmodelname + 013bd784-9bca-4919-ae2f-ae57af27bad9 + + + parent-service-instance-id + consuming-service-instance-id + namefromrequest + tunnelxconn + allottedresourceidfromrequest + + + my-vni + my-bearer-ip + my-lan-ip + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/arGetById.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/arGetById.xml new file mode 100644 index 0000000000..bb7f4c20fd --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/arGetById.xml @@ -0,0 +1,31 @@ + + ar-1 + Active + TunnelXConn + TunnelXConn + TunnelXConn + + 1490627351232 + + + service-instance + http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + customer.global-customer-id + SDN-ETHERNET-INTERNET + + + service-subscription.service-type + 123456789 + + + service-instance.service-instance-id + 88819355-9a71-4ddc-9e22-373f0644b40b + + + service-instance.service-instance-name + vcpe-1702-m010904-name4 + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesData.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json similarity index 67% rename from bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesData.json rename to bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json index be0dfc8954..81fdcc76d0 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesData.json +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json @@ -63,13 +63,30 @@ "modelInstanceName" : "Pri_IP_MUX_Demux 1" }, "toscaNodeType" : null, - "allottedResourceType" : "ContrailRoute", - "allottedResourceRole" : null, + "allottedResourceType" : "TunnelXConn", + "allottedResourceRole" : "TunnelXConn", "providingServiceModelInvariantUuid" : null, "nfFunction" : null, "nfType" : null, "nfRole" : null, - "nfNamingCode" : null + "nfNamingCode" : null, + "homingSolution": { + "inventoryType": "service", + "serviceInstanceId": "MIS%252F1604%252F0027%252FSW_INTERNET", + "vnfHostname": "MDTNJ01", + "cloudOwner": "aic", + "cloudRegionId": "dfwtx", + "aicClli": "KDTNJ01", + "aicVersion": "3.0", + "entitlementPoolList": [ + "f1d563e8-e714-4393-8f99-cc480144a05e", + "j1d563e8-e714-4393-8f99-cc480144a05e" + ], + "licenseKeyGroupList": [ + "s1d563e8-e714-4393-8f99-cc480144a05e", + "b1d563e8-e714-4393-8f99-cc480144a05e" + ] + } }, { "modelInfo" : { @@ -81,13 +98,30 @@ "modelInstanceName" : "Pri_Service_Admin 5" }, "toscaNodeType" : null, - "allottedResourceType" : "SecurityZone", - "allottedResourceRole" : null, + "allottedResourceType" : "BRG", + "allottedResourceRole" : "BRG", "providingServiceModelInvariantUuid" : null, "nfFunction" : null, "nfType" : null, "nfRole" : null, - "nfNamingCode" : null + "nfNamingCode" : null, + "homingSolution": { + "inventoryType": "service", + "serviceInstanceId": "MIS%252F1604%252F0027%252FSW_INTERNET", + "vnfHostname": "MDTNJ01", + "cloudOwner": "aic", + "cloudRegionId": "dfwtx", + "aicClli": "KDTNJ01", + "aicVersion": "3.0", + "entitlementPoolList": [ + "f1d563e8-e714-4393-8f99-cc480144a05e", + "j1d563e8-e714-4393-8f99-cc480144a05e" + ], + "licenseKeyGroupList": [ + "s1d563e8-e714-4393-8f99-cc480144a05e", + "b1d563e8-e714-4393-8f99-cc480144a05e" + ] + } } ] }} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesDataServiceInstanceOnly.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesNoData.json similarity index 66% rename from bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesDataServiceInstanceOnly.json rename to bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesNoData.json index 56af494d49..80692b27f5 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesDataServiceInstanceOnly.json +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesNoData.json @@ -1,13 +1,11 @@ -{ - "serviceResources": { +{ "serviceResources" : { "modelInfo" : { "modelName" : "MSO Test Network", "modelUuid" : "aed5a5b7-20d3-44f7-90a3-ddbd16f14d1e", "modelInvariantUuid" : "52b49b5d-3086-4ffd-b5e6-1b1e5e7e062f", "modelVersion" : null }, - "serviceVnfs": [], - "serviceNetworks": [], - "serviceAllottedResources": [] - } -} \ No newline at end of file + "serviceVnfs": [], + "serviceNetworks": [], + "serviceAllottedResources": [] + }} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCustomer.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCustomer.xml new file mode 100644 index 0000000000..b9d88d15db --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCustomer.xml @@ -0,0 +1,7 @@ + + SDN-ETHERNET-INTERNET + SDN-ETHERNET-INTERNET + 1490627351232 + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/request.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/request.json similarity index 88% rename from bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/request.json rename to bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/request.json index 9141d5074a..dc4669e8d9 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/request.json +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/request.json @@ -11,7 +11,7 @@ }, "subscriberInfo": { - "globalSubscriberId":"MCBH-1610", + "globalSubscriberId":"SDN-ETHERNET-INTERNET", "subscriberName":"Kaneohe" }, "requestInfo": @@ -28,7 +28,7 @@ }, "requestParameters": { - "subscriptionServiceType":"vcpesvc", + "subscriptionServiceType":"123456789", "aLaCarte":"false", "userParams": { diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSIName.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSIName.json new file mode 100644 index 0000000000..dc9ac49a4e --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSIName.json @@ -0,0 +1,39 @@ +{ + "requestDetails": + { + "modelInfo": + { + "modelType":"service", + "modelInvariantUuid":"uuid-miu-svc-011-abcdef", + "modelVersionId":"ASDC_TOSCA_UUID", + "modelName":"SIModelName1", + "modelVersion":"2" + }, + "subscriberInfo": + { + "globalSubscriberId":"SDN-ETHERNET-INTERNET", + "subscriberName":"Kaneohe" + }, + "requestInfo": + { + "source":"VID", + "suppressRollback":"false", + "productFamilyId":"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" + }, + "cloudConfiguration": + { + "lcpCloudRegionId":"mdt1", + "tenantId":"8b1df54faa3b49078e3416e21370a3ba" + }, + "requestParameters": + { + "subscriptionServiceType":"123456789", + "aLaCarte":"false", + "userParams": + { + "BRG_WAN_MAC_Address" : "brgmac" + } + } + + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSINameNoRollback.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSINameNoRollback.json new file mode 100644 index 0000000000..d5b0713d9f --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSINameNoRollback.json @@ -0,0 +1,39 @@ +{ + "requestDetails": + { + "modelInfo": + { + "modelType":"service", + "modelInvariantUuid":"uuid-miu-svc-011-abcdef", + "modelVersionId":"ASDC_TOSCA_UUID", + "modelName":"SIModelName1", + "modelVersion":"2" + }, + "subscriberInfo": + { + "globalSubscriberId":"SDN-ETHERNET-INTERNET", + "subscriberName":"Kaneohe" + }, + "requestInfo": + { + "source":"VID", + "suppressRollback":"true", + "productFamilyId":"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" + }, + "cloudConfiguration": + { + "lcpCloudRegionId":"mdt1", + "tenantId":"8b1df54faa3b49078e3416e21370a3ba" + }, + "requestParameters": + { + "subscriptionServiceType":"123456789", + "aLaCarte":"false", + "userParams": + { + "BRG_WAN_MAC_Address" : "brgmac" + } + } + + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/arGetBRGById.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/arGetBRGById.xml new file mode 100644 index 0000000000..3cb31464d5 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/arGetBRGById.xml @@ -0,0 +1,31 @@ + + ar-brgB + Active + BRG + BRG + BRG + + 1490627351232 + + + service-instance + http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + customer.global-customer-id + SDN-ETHERNET-INTERNET + + + service-subscription.service-type + 123456789 + + + service-instance.service-instance-id + 88819355-9a71-4ddc-9e22-373f0644b40b + + + service-instance.service-instance-name + vcpe-1702-m010904-name4 + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/arGetTXCById.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/arGetTXCById.xml new file mode 100644 index 0000000000..65cee9f662 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/arGetTXCById.xml @@ -0,0 +1,31 @@ + + ar-txcA + Active + TunnelXConn + TunnelXConn + TunnelXConn + + 1490627351232 + + + service-instance + http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + customer.global-customer-id + SDN-ETHERNET-INTERNET + + + service-subscription.service-type + 123456789 + + + service-instance.service-instance-id + 88819355-9a71-4ddc-9e22-373f0644b40b + + + service-instance.service-instance-name + vcpe-1702-m010904-name4 + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getARUrlById.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getBRGArUrlById.xml similarity index 87% rename from bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getARUrlById.xml rename to bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getBRGArUrlById.xml index e178583a34..932dbfb2ca 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getARUrlById.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getBRGArUrlById.xml @@ -1,6 +1,6 @@ allotted-resource - https://aai-ext1.test.com:8443/aai/v7/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + https://aai-ext1.test.com:8443/aai/v7/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/ar-brgB \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getSI.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getSI.xml new file mode 100644 index 0000000000..4f95ed2f19 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getSI.xml @@ -0,0 +1,43 @@ + + + MIS/1604/0026/SW_INTERNET + 123456789 + + + + TunnelXConn + ar-txcA + + + BRG + ar-brgB + + + other + ar-otherC + + + + + + generic-vnf + https://aai-ext1.test.com:8443/aai/v7/generic-vnf/vnfX + + + l3-network + https://aai-ext1.test.com:8443/aai/v7/l3-network/netA + + + generic-vnf + https://aai-ext1.test.com:8443/aai/v7/generic-vnf/vnfY + + + l3-network + https://aai-ext1.test.com:8443/aai/v7/l3-network/netB + + + l3-network + https://aai-ext1.test.com:8443/aai/v7/l3-network/netC + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getSIAfterDelArs.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getSIAfterDelArs.xml new file mode 100644 index 0000000000..feb535c238 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getSIAfterDelArs.xml @@ -0,0 +1,8 @@ + + MIS/1604/0026/SW_INTERNET + SDN-MOBILITY + 123456789 + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getParentSIUrlById.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getTXCArUrlById.xml similarity index 61% rename from bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getParentSIUrlById.xml rename to bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getTXCArUrlById.xml index c29133e539..1c4f13d642 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getParentSIUrlById.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getTXCArUrlById.xml @@ -1,6 +1,6 @@ - service-instance - https://aai-ext1.test.com:8443/aai/v7/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0027%252FSW_INTERNET + allotted-resource + https://aai-ext1.test.com:8443/aai/v7/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/ar-txcA \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/request.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/request.json new file mode 100644 index 0000000000..dc4669e8d9 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/request.json @@ -0,0 +1,40 @@ +{ + "requestDetails": + { + "modelInfo": + { + "modelType":"service", + "modelInvariantUuid":"uuid-miu-svc-011-abcdef", + "modelVersionId":"ASDC_TOSCA_UUID", + "modelName":"SIModelName1", + "modelVersion":"2" + }, + "subscriberInfo": + { + "globalSubscriberId":"SDN-ETHERNET-INTERNET", + "subscriberName":"Kaneohe" + }, + "requestInfo": + { + "instanceName":"VCPE1", + "source":"VID", + "suppressRollback":"false", + "productFamilyId":"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" + }, + "cloudConfiguration": + { + "lcpCloudRegionId":"mdt1", + "tenantId":"8b1df54faa3b49078e3416e21370a3ba" + }, + "requestParameters": + { + "subscriptionServiceType":"123456789", + "aLaCarte":"false", + "userParams": + { + "BRG_WAN_MAC_Address" : "brgmac" + } + } + + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/serviceToDelete.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/serviceToDelete.xml new file mode 100644 index 0000000000..6071c51b2d --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/serviceToDelete.xml @@ -0,0 +1,38 @@ + + + + TunnelXConn + txcA + + + BRG + brgB + + + other + otherC + + + + + generic-vnf + https://aai-ext1.test.com:8443/aai/v7/generic-vnf/vnfX + + + l3-network + https://aai-ext1.test.com:8443/aai/v7/l3-network/netA + + + generic-vnf + https://aai-ext1.test.com:8443/aai/v7/generic-vnf/vnfY + + + l3-network + https://aai-ext1.test.com:8443/aai/v7/l3-network/netB + + + l3-network + https://aai-ext1.test.com:8443/aai/v7/l3-network/netC + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getAR.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getAR.xml index b6da551d23..e352ff8f1f 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getAR.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getAR.xml @@ -2,7 +2,7 @@ allotted-resource - http://localhost:28090/aai/v9/mylink + https://aai-ext1.test.com:8443/aai/v7/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getArBrg.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getArBrg.xml index 361d44032b..8c3976b828 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getArBrg.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getArBrg.xml @@ -12,11 +12,11 @@ http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 customer.global-customer-id - MCBH-1610 + SDN-ETHERNET-INTERNET service-subscription.service-type - vcpesvc + 123456789 service-instance.service-instance-id diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getArBrg2.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getArBrg2.xml new file mode 100644 index 0000000000..650d608fb0 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getArBrg2.xml @@ -0,0 +1,31 @@ + + ar-1 + Active + txc + BRG + BRG + + 1490627351232 + + + service-instance + http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + customer.global-customer-id + SDN-ETHERNET-INTERNET + + + service-subscription.service-type + 123456789 + + + service-instance.service-instance-id + 88819355-9a71-4ddc-9e22-373f0644b40b + + + service-instance.service-instance-name + vcpe-1702-m010904-name4 + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getParentServiceInstance.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getSIandAR.xml similarity index 61% rename from bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getParentServiceInstance.xml rename to bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getSIandAR.xml index bc810c6014..14c7410995 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getParentServiceInstance.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getSIandAR.xml @@ -1,7 +1,15 @@ - MIS/1604/0027/SW_INTERNET - 123456789 - + MIS/1604/0026/SW_INTERNET + 123456789 + + Active + + + + allotted-resource + https://aai-ext1.test.com:8443/aai/v7/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + cvlan-tag https://aai-ext1.test.com:8443/aai/v2/network/vces/vce/832bace2-3fb0-49e0-a6a4-07c47223c535/port-groups/port-group/slcp1447vbc.ipag/cvlan-tags/cvlan-tag/2003/ @@ -20,11 +28,11 @@ vce - https://aai-ext1.test.com:8443/aai/v2/network/vces/vce/832bace2-3fb0-49e0-a6a4-07c47223c535/ + https://aai-ext1.test.com:8443/aai/v2/network/vces/vce/832bace2-3fb0-49e0-a6a4-07c47223c535/ vce.vnf-id 832bace2-3fb0-49e0-a6a4-07c47223c535 - + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml index 6a35247b09..8ed991608a 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml @@ -12,11 +12,11 @@ http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 customer.global-customer-id - MCBH-1610 + SDN-ETHERNET-INTERNET service-subscription.service-type - vcpesvc + 123456789 service-instance.service-instance-id diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getAR.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getAR.xml new file mode 100644 index 0000000000..e352ff8f1f --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getAR.xml @@ -0,0 +1,8 @@ + + + + allotted-resource + https://aai-ext1.test.com:8443/aai/v7/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getArTxc.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getArTxc.xml new file mode 100644 index 0000000000..dfb7d46a68 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getArTxc.xml @@ -0,0 +1,31 @@ + + ar-1 + Active + TXCr + TXCt + TXC + + 1490627351232 + + + service-instance + http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + customer.global-customer-id + SDN-ETHERNET-INTERNET + + + service-subscription.service-type + 123456789 + + + service-instance.service-instance-id + 88819355-9a71-4ddc-9e22-373f0644b40b + + + service-instance.service-instance-name + vcpe-1702-m010904-name4 + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getArTxc2.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getArTxc2.xml new file mode 100644 index 0000000000..59c503036a --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getArTxc2.xml @@ -0,0 +1,31 @@ + + ar-1 + Active + brg + TXC + TXC + + 1490627351232 + + + service-instance + http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + customer.global-customer-id + SDN-ETHERNET-INTERNET + + + service-subscription.service-type + 123456789 + + + service-instance.service-instance-id + 88819355-9a71-4ddc-9e22-373f0644b40b + + + service-instance.service-instance-name + vcpe-1702-m010904-name4 + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getSIandAR.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getSIandAR.xml new file mode 100644 index 0000000000..14c7410995 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getSIandAR.xml @@ -0,0 +1,38 @@ + + MIS/1604/0026/SW_INTERNET + 123456789 + + Active + + + + allotted-resource + https://aai-ext1.test.com:8443/aai/v7/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 + + + + cvlan-tag + https://aai-ext1.test.com:8443/aai/v2/network/vces/vce/832bace2-3fb0-49e0-a6a4-07c47223c535/port-groups/port-group/slcp1447vbc.ipag/cvlan-tags/cvlan-tag/2003/ + + cvlan-tag.cvlan-tag + 2003 + + + port-group.interface-id + slcp1447vbc.ipag + + + vce.vnf-id + 832bace2-3fb0-49e0-a6a4-07c47223c535 + + + + vce + https://aai-ext1.test.com:8443/aai/v2/network/vces/vce/832bace2-3fb0-49e0-a6a4-07c47223c535/ + + vce.vnf-id + 832bace2-3fb0-49e0-a6a4-07c47223c535 + + + + 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 713ef56b50..bb7f4c20fd 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml @@ -12,11 +12,11 @@ http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 customer.global-customer-id - MCBH-1610 + SDN-ETHERNET-INTERNET service-subscription.service-type - vcpesvc + 123456789 service-instance.service-instance-id diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoDeleteAllottedResourceBRG/arGetById.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoDeleteAllottedResourceBRG/arGetById.xml index 6a35247b09..8ed991608a 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoDeleteAllottedResourceBRG/arGetById.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoDeleteAllottedResourceBRG/arGetById.xml @@ -12,11 +12,11 @@ http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 customer.global-customer-id - MCBH-1610 + SDN-ETHERNET-INTERNET service-subscription.service-type - vcpesvc + 123456789 service-instance.service-instance-id 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 713ef56b50..bb7f4c20fd 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoDeleteAllottedResourceTXC/arGetById.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoDeleteAllottedResourceTXC/arGetById.xml @@ -12,11 +12,11 @@ http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1 customer.global-customer-id - MCBH-1610 + SDN-ETHERNET-INTERNET service-subscription.service-type - vcpesvc + 123456789 service-instance.service-instance-id diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/VNFAdapterRestCreateCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/VNFAdapterRestCreateCallback.xml deleted file mode 100644 index 49ecd0bf3f..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/VNFAdapterRestCreateCallback.xml +++ /dev/null @@ -1,55 +0,0 @@ - - skask - supercool - slowburn - true - - - key1 - value1 - - - key2 - value2 - - -server1_private_ip -192.168.28.3 - - -contrail-service-instance-fqdn -default-domain:MSOTest:MsoNW-RA - - -policyKey1_contrail_network_policy_fqdn -MSOTest:DefaultPolicyFQDN1 - - -policyKey2_contrail_network_policy_fqdn -MSOTest:DefaultPolicyFQDN2 - - -oam_management_v6_address -2000:abc:bce:1111 - - -oam_management_v4_address -127.0.0.1 - - - - skask - supercool - slowburn - true - tenantId - cloudSiteId - - requestId - serviceInstanceId - - {{MESSAGE-ID}} - - {{MESSAGE-ID}} - - diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/createServiceInstance_genericQueryByInstance_AAIResponse_200.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/createServiceInstance_genericQueryByInstance_AAIResponse_200.xml deleted file mode 100644 index 2f38a4f535..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/createServiceInstance_genericQueryByInstance_AAIResponse_200.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - gg0e927b-6087-5574-9ef8-c5e4d5847db5 - V1.0 - vMOG-AKRON-1234 - 1462561835 - - - - - diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogNetworkData.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogNetworkData.json deleted file mode 100644 index cab2637955..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogNetworkData.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "serviceNetworks": [ - { - "version": null, - "modelCustomizationUuid": "93a5f915-403f-487d-89e4-7107359635b0", - "modelName": "VIPR_TENANT_OAM_NET", - "modelInstanceName": "VIPR_TENANT_OAM_NET 1", - "modelUuid": "6524c8ad-dc17-44c0-ad24-08c4d2df52e6", - "modelVersion": "1.0", - "modelInvariantUuid": "b2667e06-1ec1-4a2a-a916-991b5510b603", - "networkResourceId": 100, - "created": 1484943975000, - "networkResource": { - "version": "1", - "id": 100, - "networkType": "VIPR_TENANT_OAM_NET", - "orchestrationMode": "HEAT", - "description": "manual record pointing to existing CONTRAIL30_BASIC template", - "templateId": 1, - "neutronNetworkType": "BASIC", - "aicVersionMin": "3.0", - "aicVersionMax": null, - "created": 1484936027000 - }, - "networkType": "VIPR_TENANT_OAM_NET" - } - ] -} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesDataNoNetwork.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesDataNoNetwork.json deleted file mode 100644 index 2003acf9ea..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesDataNoNetwork.json +++ /dev/null @@ -1,62 +0,0 @@ -{ "serviceResources" : { - "modelName" : "CMW_Service", - "modelUuid" : "Cmw_123", - "modelInvariantUuid" : "cmw-123-456-789", - "modelVersion" : null, - "serviceVnfs": [ - { "vnf" : { - "modelName" : "MANUAL RECORD", - "modelUuid" : null, - "modelInvariantUuid" : "miu-vnf-15190", - "modelVersion" : "1.0", - "modelCustomizationUuid" : "123456-789012-cmwabd", - "modelInstanceName" : null, - "vfModules": [ - { "vfModule" : { - "modelName" : "vSAMP12::base::module-0", - "modelUuid" : null, - "modelInvariantUuid" : "miu-1001", - "modelVersion" : "1", - "modelCustomizationUuid" : "1001", - "vfModuleType" : "Test/vSAMP12::vSAMP12::base::module-0", - "isBase" : true, - "vfModuleLabel" : "base", - "initialCount" : 1 - }}, - { "vfModule" : { - "modelName" : "base::module-0", - "modelUuid" : null, - "modelInvariantUuid" : "miu-1002", - "modelVersion" : "1", - "modelCustomizationUuid" : "1002", - "vfModuleType" : "Test/vSAMP12::base::module-0", - "isBase" : true, - "vfModuleLabel" : "module-0", - "initialCount" : 1 - }}, - { "vfModule" : { - "modelName" : "vSAMP12DEV::base::module-0", - "modelUuid" : null, - "modelInvariantUuid" : "miu-1003", - "modelVersion" : "1", - "modelCustomizationUuid" : "f86e8800-7629-427f-b284-3dbfd04db01f", - "vfModuleType" : "Test/vSAMP12::vSAMP12DEV::base::module-0", - "isBase" : true, - "vfModuleLabel" : "base", - "initialCount" : 0 - }} - ] - }} - ], - "serviceNetworks": [], - "serviceAllottedResources": [ - { "allottedResource" : { - "modelName" : "Bruce Wayne", - "modelUuid" : "123-123", - "modelInvariantUuid" : "not yet implemented", - "modelVersion" : "1.0", - "modelCustomizationUuid" : "ar-mod-custid-456-456", - "modelInstanceName" : "Clark Kent" - }} - ] - }} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesDataNoNetworkVnf.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesDataNoNetworkVnf.json deleted file mode 100644 index 4364eaf594..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesDataNoNetworkVnf.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "serviceResources": { - "modelName": "CMW_Service", - "modelUuid": "Cmw_123", - "modelInvariantUuid": "cmw-123-456-789", - "modelVersion": null, - "serviceVnfs": [], - "serviceNetworks": [], - "serviceAllottedResources": [ - { - "allottedResource": { - "modelName": "Bruce Wayne", - "modelUuid": "123-123", - "modelInvariantUuid": "not yet implemented", - "modelVersion": "1.0", - "modelCustomizationUuid": "ar-mod-custid-456-456", - "modelInstanceName": "Clark Kent", - "toscaModelType": "undefined", - "allottedResourceType": "ContrailRoute", - "allottedResourceRole": "ALLOTTED_RESROUCE_ROLE", - "providingServiceModelInvariantUuid": "PROVIDING_SERVICE_MODEL_INVARIANT_UUID" - } - } - ] - } -} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesDataServiceAllotted.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesDataServiceAllotted.json deleted file mode 100644 index e865210713..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesDataServiceAllotted.json +++ /dev/null @@ -1,84 +0,0 @@ -{ - "serviceResources": { - "modelInfo": { - "modelName": "SD-WAN", - "modelUuid": "ee9807ef-9814-4067-b997-5eee54c9e719", - "modelInvariantUuid": "7b0fafc1-83df-4590-9460-b5a8d9f9f277", - "modelVersion": null - }, - "serviceVnfs": [], - "serviceNetworks": [], - "serviceAllottedResources": [ - { - "modelInfo": { - "modelName": "IP_MUX_Demux", - "modelUuid": "64a1a718-556b-48ce-b3b7-ed3237ccc94f", - "modelInvariantUuid": "f110ef53-a0a6-4d72-ab91-fd88a835e8c4", - "modelVersion": "2.0", - "modelCustomizationUuid": "4bab0880-2f06-4aeb-87cb-3734c8e8bf93", - "modelInstanceName": "Pri_IP_MUX_Demux 1" - }, - "toscaNodeType": null, - "allottedResourceType": "ContrailRoute", - "allottedResourceRole": "ContrailRoute", - "providingServiceModelInvariantUuid": null, - "nfFunction": null, - "nfType": null, - "nfRole": null, - "nfNamingCode": null, - "homingSolution": { - "inventoryType": "service", - "serviceInstanceId": "c763d462-dfe4-4577-9706-fa3a9db640be", - "vnfHostname": "MDTNJ01", - "cloudOwner": "aic", - "cloudRegionId": "dfwtx", - "aicClli": "KDTNJ01", - "aicVersion": "3.0", - "entitlementPoolList": [ - "f1d563e8-e714-4393-8f99-cc480144a05e", - "j1d563e8-e714-4393-8f99-cc480144a05e" - ], - "licenseKeyGroupList": [ - "s1d563e8-e714-4393-8f99-cc480144a05e", - "b1d563e8-e714-4393-8f99-cc480144a05e" - ] - } - }, - { - "modelInfo": { - "modelName": "Service_Admin", - "modelUuid": "73501e03-ee76-4509-a8ce-96d2a9f33ee9", - "modelInvariantUuid": "462edf71-1a3c-487b-bf55-497460ab7de3", - "modelVersion": "2.0", - "modelCustomizationUuid": "a896ffad-c8f9-404e-a527-7a8d0cc99ce6", - "modelInstanceName": "Pri_Service_Admin 5" - }, - "toscaNodeType": null, - "allottedResourceType": "SecurityZone", - "allottedResourceRole": "SecurityZone", - "providingServiceModelInvariantUuid": null, - "nfFunction": null, - "nfType": null, - "nfRole": null, - "nfNamingCode": null, - "homingSolution": { - "inventoryType": "service", - "serviceInstanceId": "c763d462-dfe4-4577-9706-fa3a9db640be", - "vnfHostname": "MDTNJ01", - "cloudOwner": "aic", - "cloudRegionId": "dfwtx", - "aicClli": "KDTNJ01", - "aicVersion": "3.0", - "entitlementPoolList": [ - "f1d563e8-e714-4393-8f99-cc480144a05e", - "j1d563e8-e714-4393-8f99-cc480144a05e" - ], - "licenseKeyGroupList": [ - "s1d563e8-e714-4393-8f99-cc480144a05e", - "b1d563e8-e714-4393-8f99-cc480144a05e" - ] - } - } - ] - } -} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesServiceNetwork.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesServiceNetwork.json deleted file mode 100644 index 821bd04c19..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesServiceNetwork.json +++ /dev/null @@ -1,27 +0,0 @@ -{ "serviceResources" : { - "modelInfo" : { - "modelName" : "MSO Test Network", - "modelUuid" : "aed5a5b7-20d3-44f7-90a3-ddbd16f14d1e", - "modelInvariantUuid" : "52b49b5d-3086-4ffd-b5e6-1b1e5e7e062f", - "modelVersion" : null - }, - "serviceVnfs": [], - "serviceNetworks": [ - { - "modelInfo" : { - "modelName" : "CONTRAIL_BASIC", - "modelUuid" : "fe5be3a6-dbe0-46d6-bcac-44dc841a7edc", - "modelInvariantUuid" : "ab07fbd8-185a-45ac-be45-db3eb02e98d5", - "modelVersion" : null, - "modelCustomizationUuid" : "0cb9b26a-9820-48a7-86e5-16c510e993d9", - "modelInstanceName" : "CONTRAIL_BASIC 5" - }, - "toscaNodeType" : null, - "networkType" : null, - "networkTechnology" : null, - "networkRole" : null, - "networkScope" : null - } - ], - "serviceAllottedResources": [] - }} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesServiceVnf.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesServiceVnf.json deleted file mode 100644 index 7893aff693..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesServiceVnf.json +++ /dev/null @@ -1,40 +0,0 @@ -{ "serviceResources" : { - "modelInfo" : { - "modelName" : "MSO Test Network", - "modelUuid" : "aed5a5b7-20d3-44f7-90a3-ddbd16f14d1e", - "modelInvariantUuid" : "52b49b5d-3086-4ffd-b5e6-1b1e5e7e062f", - "modelVersion" : null - }, - "serviceVnfs": [ - { "modelInfo" : { - "modelName" : "vHNF for DHV Test", - "modelUuid" : "7097d8bb-f6ad-4cf7-866e-6a04c8f1b332", - "modelInvariantUuid" : "6ea0b528-e303-4686-aa77-aa2fcbdccb96", - "modelVersion" : "2.0", - "modelCustomizationUuid" : "da86dd87-43c5-458c-b226-5315b7be9ad5", - "modelInstanceName" : "vHNF for DHV Test 17" - }, - "toscaNodeType" : null, - "nfFunction" : null, - "nfType" : null, - "nfRole" : null, - "nfNamingCode" : null, - "vfModules": [ - { - "modelInfo" : { - "modelName" : "VhnfForDhvTest..base_TEST..module-0", - "modelUuid" : "ebc3d18c-3e62-4c24-bcd6-961e98701a0a", - "modelInvariantUuid" : "f5696ec0-ec71-4916-bf3b-93a654efcba4", - "modelVersion" : "1", - "modelCustomizationUuid" : "1740536a-742e-40f5-b9c8-83918849a787" - }, "isBase" : true, - "vfModuleLabel" : "base_TEST", - "initialCount" : 1, - "hasVolumeGroup" : true - } - ] - } - ], - "serviceNetworks": [], - "serviceAllottedResources": [] - }} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogVcpe.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogVcpe.json deleted file mode 100644 index b95e45ac46..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogVcpe.json +++ /dev/null @@ -1,76 +0,0 @@ -{ "serviceResources" : { - "modelInfo" : { - "modelName" : "MSO Test Network", - "modelUuid" : "aed5a5b7-20d3-44f7-90a3-ddbd16f14d1e", - "modelInvariantUuid" : "52b49b5d-3086-4ffd-b5e6-1b1e5e7e062f", - "modelVersion" : null - }, - "serviceVnfs": [ - { "modelInfo" : { - "modelName" : "vHNF for DHV Test", - "modelUuid" : "7097d8bb-f6ad-4cf7-866e-6a04c8f1b332", - "modelInvariantUuid" : "6ea0b528-e303-4686-aa77-aa2fcbdccb96", - "modelVersion" : "2.0", - "modelCustomizationUuid" : "da86dd87-43c5-458c-b226-5315b7be9ad5", - "modelInstanceName" : "vHNF for DHV Test 17" - }, - "toscaNodeType" : null, - "nfFunction" : null, - "nfType" : null, - "nfRole" : null, - "nfNamingCode" : null, - "vfModules": [ - { - "modelInfo" : { - "modelName" : "VhnfForDhvTest..base_TEST..module-0", - "modelUuid" : "ebc3d18c-3e62-4c24-bcd6-961e98701a0a", - "modelInvariantUuid" : "f5696ec0-ec71-4916-bf3b-93a654efcba4", - "modelVersion" : "1", - "modelCustomizationUuid" : "1740536a-742e-40f5-b9c8-83918849a787" - }, "isBase" : true, - "vfModuleLabel" : "base_TEST", - "initialCount" : 1, - "hasVolumeGroup" : true - } - ] - } - ], - "serviceAllottedResources": [ - { - "modelInfo" : { - "modelName" : "IP_MUX_Demux", - "modelUuid" : "64a1a718-556b-48ce-b3b7-ed3237ccc94f", - "modelInvariantUuid" : "f110ef53-a0a6-4d72-ab91-fd88a835e8c4", - "modelVersion" : "2.0", - "modelCustomizationUuid" : "4bab0880-2f06-4aeb-87cb-3734c8e8bf93", - "modelInstanceName" : "Pri_IP_MUX_Demux 1" - }, - "toscaNodeType" : null, - "allottedResourceType" : "TunnelXConn", - "allottedResourceRole" : null, - "providingServiceModelInvariantUuid" : null, - "nfFunction" : null, - "nfType" : null, - "nfRole" : null, - "nfNamingCode" : null - }, - { - "modelInfo" : { - "modelName" : "Service_Admin", - "modelUuid" : "73501e03-ee76-4509-a8ce-96d2a9f33ee9", - "modelInvariantUuid" : "462edf71-1a3c-487b-bf55-497460ab7de3", - "modelVersion" : "2.0", - "modelCustomizationUuid" : "a896ffad-c8f9-404e-a527-7a8d0cc99ce6", - "modelInstanceName" : "Pri_Service_Admin 5" - }, - "toscaNodeType" : null, - "allottedResourceType" : "BRG", - "allottedResourceRole" : null, - "providingServiceModelInvariantUuid" : null, - "nfFunction" : null, - "nfType" : null, - "nfRole" : null, - "nfNamingCode" : null - } - ] - }} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogVnfData.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogVnfData.json deleted file mode 100644 index d95b313583..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogVnfData.json +++ /dev/null @@ -1 +0,0 @@ -{"serviceVnfs":[]} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCustomer.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCustomer.xml deleted file mode 100644 index 6e35f24205..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCustomer.xml +++ /dev/null @@ -1,7 +0,0 @@ - - MCBH-1610 - MCBH-1610 - 1465943440 - - - diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getNetwork.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getNetwork.xml deleted file mode 100644 index 32a01b6973..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getNetwork.xml +++ /dev/null @@ -1,92 +0,0 @@ - - cf82a73f-de7f-4f84-8dfc-16a487c63a36 - Dev_NoBinding-2001 - CONTRAIL30_BASIC - GN_EVPN_direct - contrail - 968a47e3-e238-4158-af87-6be7f508a6c0 - false - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - 0 - 1476384388 - active - Dev_NoBinding-2001/11c429ac-eab3-4566-a9d3-d8ca6fb4e803 - default-domain:IST_Automation_AAI_updated:Dev_NoBinding-2001 - - false - false - false - - - 5c559cd8-1ef2-45a8-b342-b4c9307d33ff - - 48267a65-2209-4e10-ad44-fc30d4fcb508 - 218.210.11.1 - 218.210.11.0 - 24 - 4 - pending-update - true - 218.210.11.3 - 218.210.11.64 - 1476384386 - - - - - tenant - https://aai-int1.test.openecomp.com:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn6/tenants/tenant/fe4400a8e96e4caa85ccdca8a850255b - - cloud-region.cloud-owner - att-aic - - - cloud-region.cloud-region-id - mtn6 - - - tenant.tenant-id - fe4400a8e96e4caa85ccdca8a850255b - - - tenant.tenant-name - IST_Automation_AAI_updated - - - - cloud-region - https://aai-int1.test.openecomp.com:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn6 - - cloud-region.cloud-owner - att-aic - - - cloud-region.cloud-region-id - mtn6 - - - cloud-region.owner-defined-type - - - - service-instance - https://aai-int1.test.openecomp.com:8443/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/ffdfebef-9cf0-4be4-ab29-0380f0da0341 - - customer.global-customer-id - MSO_1610_dev - - - service-subscription.service-type - MSO-dev-service-type - - - service-instance.service-instance-id - ffdfebef-9cf0-4be4-ab29-0380f0da0341 - - - service-instance.service-instance-name - dm4251_SERVICE1 - - - - diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/serviceDecompositionATMFW.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/serviceDecompositionATMFW.json deleted file mode 100644 index bc54c557e1..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/serviceDecompositionATMFW.json +++ /dev/null @@ -1,110 +0,0 @@ -{ -"serviceResources" : { - "modelInfo" : { - "modelName" : "CMW_Service", - "modelUuid" : "", - "modelInvariantId" : "cmw-123-456-789", - "modelVersion" : "", - "modelCustomizationUuid" : "", - "modelInstanceName" : "", - "modelCustomizationName" : "", - "modelVersionId" : "Cmw_123", - "modelType" : "" - }, - "serviceInstanceData" : { - "instanceId" : "ff5256d2-5a33-55df-13ab-12abad84e7ff" - }, - "serviceNetworks" : [ { - "modelInfo" : { - "modelName" : "CONTRAIL30_BASIC", - "modelUuid" : "", - "modelInvariantId" : "not yet implemented", - "modelVersion" : "1.0", - "modelCustomizationUuid" : "z_network_123", - "modelInstanceName" : "", - "modelCustomizationName" : "", - "modelVersionId" : "mod-inst-uuid-123", - "modelType" : "network" - }, - "instanceData" : { }, - "networkType" : "CONTRAIL30_BASIC" - } ], - "serviceVnfs" : [ { - "modelInfo" : { - "modelName" : "vSAMP12", - "modelUuid" : "", - "modelInvariantId" : "ff5256d2-5a33-55df-13ab-12abad84e7ff", - "modelVersion" : "1.0", - "modelCustomizationUuid" : "ff5256d2-5a33-55df-13ab-12abad84e7ff", - "modelInstanceName" : "", - "modelCustomizationName" : "", - "modelVersionId" : "fe6478e5-ea33-3346-ac12-ab121484a3fe", - "modelType" : "vnf" - }, - "instanceData" : { }, - "vfModules" : [ { - "modelInfo" : { - "modelName" : "vSAMP12::base::module-0", - "modelUuid" : "", - "modelInvariantId" : "miu-1001", - "modelVersion" : "1", - "modelCustomizationUuid" : "1001", - "modelInstanceName" : "", - "modelCustomizationName" : "", - "modelVersionId" : "", - "modelType" : "vfModule" - }, - "instanceData" : { }, - "hasVolumeGroup" : false, - "isBase" : true, - "initialCount" : 1 - }, { - "modelInfo" : { - "modelName" : "base::module-0", - "modelUuid" : "", - "modelInvariantId" : "miu-1002", - "modelVersion" : "1", - "modelCustomizationUuid" : "1002", - "modelInstanceName" : "", - "modelCustomizationName" : "", - "modelVersionId" : "", - "modelType" : "vfModule" - }, - "instanceData" : { }, - "hasVolumeGroup" : false, - "isBase" : true, - "initialCount" : 1 - }, { - "modelInfo" : { - "modelName" : "vSAMP12DEV::base::module-0", - "modelUuid" : "", - "modelInvariantId" : "miu-1003", - "modelVersion" : "1", - "modelCustomizationUuid" : "f86e8800-7629-427f-b284-3dbfd04db01f", - "modelInstanceName" : "", - "modelCustomizationName" : "", - "modelVersionId" : "", - "modelType" : "vfModule" - }, - "instanceData" : { }, - "hasVolumeGroup" : false, - "isBase" : true, - "initialCount" : 0 - } ] - } ], - "serviceAllottedResources" : [ { - "modelInfo" : { - "modelName" : "Bruce Wayne", - "modelUuid" : "", - "modelInvariantId" : "not yet implemented", - "modelVersion" : "1.0", - "modelCustomizationUuid" : "ar-mod-custid-456-456", - "modelInstanceName" : "Clark Kent", - "modelCustomizationName" : "", - "modelVersionId" : "123-123", - "modelType" : "allottedResource" - }, - "instanceData" : { } - } ] - } -} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/SDNCTopologyCreateCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyCreateCallback.xml similarity index 100% rename from bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/SDNCTopologyCreateCallback.xml rename to bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyCreateCallback.xml diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/SDNCTopologyDeactivateCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyDeactivateCallback.xml similarity index 100% rename from bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/SDNCTopologyDeactivateCallback.xml rename to bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyDeactivateCallback.xml diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyDeactivateCallbackNotFound.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyDeactivateCallbackNotFound.xml new file mode 100644 index 0000000000..bf2b3c0882 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyDeactivateCallbackNotFound.xml @@ -0,0 +1,8 @@ + + + skask + + 404 + {{REQUEST-ID}} + Y + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/SDNCTopologyDeleteCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyDeleteCallback.xml similarity index 100% rename from bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/SDNCTopologyDeleteCallback.xml rename to bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyDeleteCallback.xml diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/SDNCTopologyUnassignCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyUnassignCallback.xml similarity index 100% rename from bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/SDNCTopologyUnassignCallback.xml rename to bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyUnassignCallback.xml