From 015b92c3d96fb42f80b018fdf8f639f1cf3298c3 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Wed, 11 Oct 2017 11:49:51 -0400 Subject: 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 --- .../scripts/CreateVcpeResCustServiceTest.groovy | 1198 ++++++++++++ .../scripts/DeleteVcpeResCustServiceTest.groovy | 709 +++++++ .../DoCreateAllottedResourceBRGRollbackTest.groovy | 653 +++++++ .../scripts/DoCreateAllottedResourceBRGTest.groovy | 1943 +++++++++----------- .../DoCreateAllottedResourceTXCRollbackTest.groovy | 653 +++++++ .../scripts/DoCreateAllottedResourceTXCTest.groovy | 950 ++++++++++ .../scripts/DoDeleteAllottedResourceBRGTest.groovy | 600 ++++++ .../scripts/DoDeleteAllottedResourceTXCTest.groovy | 600 ++++++ .../mso/bpmn/vcpe/scripts/GroovyTestBase.groovy | 124 ++ .../mso/bpmn/vcpe/scripts/MapGetter.groovy | 48 + .../mso/bpmn/vcpe/scripts/MapSetter.groovy | 49 + .../openecomp/mso/bpmn/vcpe/AbstractTestBase.java | 41 + .../bpmn/vcpe/CreateVcpeResCustServiceTest.java | 832 +++------ .../bpmn/vcpe/DeleteVcpeResCustServiceTest.java | 297 +++ .../DoCreateAllottedResourceBRGRollbackTest.java | 283 ++- .../bpmn/vcpe/DoCreateAllottedResourceBRGTest.java | 226 ++- .../DoCreateAllottedResourceTXCRollbackTest.java | 283 ++- .../bpmn/vcpe/DoCreateAllottedResourceTXCTest.java | 239 ++- .../bpmn/vcpe/DoDeleteAllottedResourceBRGTest.java | 106 +- .../bpmn/vcpe/DoDeleteAllottedResourceTXCTest.java | 106 +- .../stubprocess/DoCreateAllottedResourceBRG.bpmn | 54 + .../DoCreateAllottedResourceBRGRollback.bpmn | 55 + .../stubprocess/DoCreateAllottedResourceTXC.bpmn | 38 + .../DoCreateServiceInstanceRollback.bpmn | 53 + .../VCPE/stubprocess/DoCreateVnfAndModules.bpmn | 53 + .../stubprocess/DoCreateVnfAndModulesRollback.bpmn | 53 + .../VCPE/stubprocess/DoDeleteVnfAndModules.bpmn | 37 + .../test/resources/VCPE/stubprocess/Homing.bpmn | 35 + .../resources/__files/GenericFlows/getNotFound.xml | 2 + .../createServiceInstance_AAIResponse_success.xml | 11 - .../SDNCTopologyQueryBRGCallback.xml | 37 + .../SDNCTopologyQueryTXCCallback.xml | 24 + .../VCPE/CreateVcpeResCustService/arGetById.xml | 31 + .../getCatalogServiceResourcesData.json | 127 ++ .../getCatalogServiceResourcesNoData.json | 11 + .../VCPE/CreateVcpeResCustService/getCustomer.xml | 7 + .../VCPE/CreateVcpeResCustService/request.json | 40 + .../CreateVcpeResCustService/requestNoSIName.json | 39 + .../requestNoSINameNoRollback.json | 39 + .../VCPE/DeleteVcpeResCustService/arGetBRGById.xml | 31 + .../VCPE/DeleteVcpeResCustService/arGetTXCById.xml | 31 + .../DeleteVcpeResCustService/getBRGArUrlById.xml | 6 + .../VCPE/DeleteVcpeResCustService/getSI.xml | 43 + .../DeleteVcpeResCustService/getSIAfterDelArs.xml | 8 + .../DeleteVcpeResCustService/getTXCArUrlById.xml | 6 + .../VCPE/DeleteVcpeResCustService/request.json | 40 + .../DeleteVcpeResCustService/serviceToDelete.xml | 38 + .../VCPE/DoCreateAllottedResourceBRG/getAR.xml | 2 +- .../VCPE/DoCreateAllottedResourceBRG/getArBrg.xml | 4 +- .../VCPE/DoCreateAllottedResourceBRG/getArBrg2.xml | 31 + .../DoCreateAllottedResourceBRG/getSIandAR.xml | 38 + .../arGetById.xml | 4 +- .../VCPE/DoCreateAllottedResourceTXC/getAR.xml | 8 + .../VCPE/DoCreateAllottedResourceTXC/getArTxc.xml | 31 + .../VCPE/DoCreateAllottedResourceTXC/getArTxc2.xml | 31 + .../DoCreateAllottedResourceTXC/getSIandAR.xml | 38 + .../arGetById.xml | 4 +- .../VCPE/DoDeleteAllottedResourceBRG/arGetById.xml | 4 +- .../VCPE/DoDeleteAllottedResourceTXC/arGetById.xml | 4 +- .../__files/VCPE/SDNCTopologyCreateCallback.xml | 16 - .../VCPE/SDNCTopologyDeactivateCallback.xml | 13 - .../__files/VCPE/SDNCTopologyDeleteCallback.xml | 16 - .../__files/VCPE/SDNCTopologyUnassignCallback.xml | 16 - .../__files/VCPE/VNFAdapterRestCreateCallback.xml | 55 - ...ance_genericQueryByInstance_AAIResponse_200.xml | 13 - .../test/resources/__files/VCPE/getARUrlById.xml | 6 - .../__files/VCPE/getCatalogNetworkData.json | 28 - .../VCPE/getCatalogServiceResourcesData.json | 93 - .../getCatalogServiceResourcesDataNoNetwork.json | 62 - ...getCatalogServiceResourcesDataNoNetworkVnf.json | 26 - ...CatalogServiceResourcesDataServiceAllotted.json | 84 - ...logServiceResourcesDataServiceInstanceOnly.json | 13 - .../getCatalogServiceResourcesServiceNetwork.json | 27 - .../VCPE/getCatalogServiceResourcesServiceVnf.json | 40 - .../resources/__files/VCPE/getCatalogVcpe.json | 76 - .../resources/__files/VCPE/getCatalogVnfData.json | 1 - .../test/resources/__files/VCPE/getCustomer.xml | 7 - .../src/test/resources/__files/VCPE/getNetwork.xml | 92 - .../resources/__files/VCPE/getParentSIUrlById.xml | 6 - .../__files/VCPE/getParentServiceInstance.xml | 30 - .../src/test/resources/__files/VCPE/request.json | 40 - .../__files/VCPE/serviceDecompositionATMFW.json | 110 -- .../VfModularity/SDNCTopologyCreateCallback.xml | 16 + .../SDNCTopologyDeactivateCallback.xml | 13 + .../SDNCTopologyDeactivateCallbackNotFound.xml | 8 + .../VfModularity/SDNCTopologyDeleteCallback.xml | 16 + .../VfModularity/SDNCTopologyUnassignCallback.xml | 16 + 87 files changed, 9403 insertions(+), 2624 deletions(-) create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/GroovyTestBase.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/MapGetter.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/vcpe/scripts/MapSetter.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/AbstractTestBase.java create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DeleteVcpeResCustServiceTest.java create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRG.bpmn create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceBRGRollback.bpmn create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateAllottedResourceTXC.bpmn create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateServiceInstanceRollback.bpmn create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModules.bpmn create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoCreateVnfAndModulesRollback.bpmn create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/DoDeleteVnfAndModules.bpmn create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/VCPE/stubprocess/Homing.bpmn create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/GenericFlows/getNotFound.xml delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateServiceInstance/createServiceInstance_AAIResponse_success.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryBRGCallback.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/SDNCTopologyQueryTXCCallback.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/arGetById.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesNoData.json create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCustomer.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/request.json create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSIName.json create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/requestNoSINameNoRollback.json create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/arGetBRGById.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/arGetTXCById.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getBRGArUrlById.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getSI.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getSIAfterDelArs.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getTXCArUrlById.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/request.json create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/serviceToDelete.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getArBrg2.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getSIandAR.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getAR.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getArTxc.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getArTxc2.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceTXC/getSIandAR.xml delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/SDNCTopologyCreateCallback.xml delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/SDNCTopologyDeactivateCallback.xml delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/SDNCTopologyDeleteCallback.xml delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/SDNCTopologyUnassignCallback.xml delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/VNFAdapterRestCreateCallback.xml delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/createServiceInstance_genericQueryByInstance_AAIResponse_200.xml delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getARUrlById.xml delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogNetworkData.json delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesData.json delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesDataNoNetwork.json delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesDataNoNetworkVnf.json delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesDataServiceAllotted.json delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesDataServiceInstanceOnly.json delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesServiceNetwork.json delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesServiceVnf.json delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogVcpe.json delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogVnfData.json delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCustomer.xml delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getNetwork.xml delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getParentSIUrlById.xml delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getParentServiceInstance.xml delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/request.json delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/serviceDecompositionATMFW.json create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyCreateCallback.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyDeactivateCallback.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyDeactivateCallbackNotFound.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyDeleteCallback.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyUnassignCallback.xml (limited to 'bpmn/MSOInfrastructureBPMN/src/test') 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/CreateVcpeResCustService/getCatalogServiceResourcesData.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json new file mode 100644 index 0000000000..81fdcc76d0 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesData.json @@ -0,0 +1,127 @@ +{ "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": [ + { + "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": [ + { + "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" : "TunnelXConn", + "providingServiceModelInvariantUuid" : null, + "nfFunction" : null, + "nfType" : null, + "nfRole" : 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" : { + "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" : "BRG", + "providingServiceModelInvariantUuid" : null, + "nfFunction" : null, + "nfType" : null, + "nfRole" : 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/CreateVcpeResCustService/getCatalogServiceResourcesNoData.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesNoData.json new file mode 100644 index 0000000000..80692b27f5 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/getCatalogServiceResourcesNoData.json @@ -0,0 +1,11 @@ +{ "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 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/CreateVcpeResCustService/request.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/request.json new file mode 100644 index 0000000000..dc4669e8d9 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/CreateVcpeResCustService/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/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/DeleteVcpeResCustService/getBRGArUrlById.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getBRGArUrlById.xml new file mode 100644 index 0000000000..932dbfb2ca --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getBRGArUrlById.xml @@ -0,0 +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/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/DeleteVcpeResCustService/getTXCArUrlById.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getTXCArUrlById.xml new file mode 100644 index 0000000000..1c4f13d642 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DeleteVcpeResCustService/getTXCArUrlById.xml @@ -0,0 +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/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/DoCreateAllottedResourceBRG/getSIandAR.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/getSIandAR.xml new file mode 100644 index 0000000000..14c7410995 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/DoCreateAllottedResourceBRG/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/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/SDNCTopologyCreateCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/SDNCTopologyCreateCallback.xml deleted file mode 100644 index 11022f6aec..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/SDNCTopologyCreateCallback.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - skask - - 200 - {{REQUEST-ID}} - Y - - dontcare - 0 - SDN-MOBILITY - - - restconf/SDNCObjectPath - - \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/SDNCTopologyDeactivateCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/SDNCTopologyDeactivateCallback.xml deleted file mode 100644 index acea1459bc..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/SDNCTopologyDeactivateCallback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - skask - - 200 - {{REQUEST-ID}} - Y - - dontcare - 0 - SDN-MOBILITY - - \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/SDNCTopologyDeleteCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/SDNCTopologyDeleteCallback.xml deleted file mode 100644 index 11022f6aec..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/SDNCTopologyDeleteCallback.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - skask - - 200 - {{REQUEST-ID}} - Y - - dontcare - 0 - SDN-MOBILITY - - - restconf/SDNCObjectPath - - \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/SDNCTopologyUnassignCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/SDNCTopologyUnassignCallback.xml deleted file mode 100644 index 11022f6aec..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/SDNCTopologyUnassignCallback.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - skask - - 200 - {{REQUEST-ID}} - Y - - dontcare - 0 - SDN-MOBILITY - - - restconf/SDNCObjectPath - - \ No newline at end of file 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/getARUrlById.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getARUrlById.xml deleted file mode 100644 index e178583a34..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getARUrlById.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - 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 - - \ No newline at end of file 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/getCatalogServiceResourcesData.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesData.json deleted file mode 100644 index be0dfc8954..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesData.json +++ /dev/null @@ -1,93 +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": [ - { - "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": [ - { - "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" : 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" : "SecurityZone", - "allottedResourceRole" : null, - "providingServiceModelInvariantUuid" : null, - "nfFunction" : null, - "nfType" : null, - "nfRole" : null, - "nfNamingCode" : null - } - ] - }} \ 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/getCatalogServiceResourcesDataServiceInstanceOnly.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesDataServiceInstanceOnly.json deleted file mode 100644 index 56af494d49..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getCatalogServiceResourcesDataServiceInstanceOnly.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "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 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/getParentSIUrlById.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getParentSIUrlById.xml deleted file mode 100644 index c29133e539..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getParentSIUrlById.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - 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 - - \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getParentServiceInstance.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getParentServiceInstance.xml deleted file mode 100644 index bc810c6014..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/getParentServiceInstance.xml +++ /dev/null @@ -1,30 +0,0 @@ - - MIS/1604/0027/SW_INTERNET - 123456789 - - - 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/request.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/request.json deleted file mode 100644 index 9141d5074a..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VCPE/request.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "requestDetails": - { - "modelInfo": - { - "modelType":"service", - "modelInvariantUuid":"uuid-miu-svc-011-abcdef", - "modelVersionId":"ASDC_TOSCA_UUID", - "modelName":"SIModelName1", - "modelVersion":"2" - }, - "subscriberInfo": - { - "globalSubscriberId":"MCBH-1610", - "subscriberName":"Kaneohe" - }, - "requestInfo": - { - "instanceName":"VCPE1", - "source":"VID", - "suppressRollback":"false", - "productFamilyId":"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" - }, - "cloudConfiguration": - { - "lcpCloudRegionId":"mdt1", - "tenantId":"8b1df54faa3b49078e3416e21370a3ba" - }, - "requestParameters": - { - "subscriptionServiceType":"vcpesvc", - "aLaCarte":"false", - "userParams": - { - "BRG_WAN_MAC_Address" : "brgmac" - } - } - - } -} 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/VfModularity/SDNCTopologyCreateCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyCreateCallback.xml new file mode 100644 index 0000000000..11022f6aec --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyCreateCallback.xml @@ -0,0 +1,16 @@ + + + skask + + 200 + {{REQUEST-ID}} + Y + + dontcare + 0 + SDN-MOBILITY + + + restconf/SDNCObjectPath + + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyDeactivateCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyDeactivateCallback.xml new file mode 100644 index 0000000000..acea1459bc --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyDeactivateCallback.xml @@ -0,0 +1,13 @@ + + + skask + + 200 + {{REQUEST-ID}} + Y + + dontcare + 0 + SDN-MOBILITY + + \ No newline at end of file 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/VfModularity/SDNCTopologyDeleteCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyDeleteCallback.xml new file mode 100644 index 0000000000..11022f6aec --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyDeleteCallback.xml @@ -0,0 +1,16 @@ + + + skask + + 200 + {{REQUEST-ID}} + Y + + dontcare + 0 + SDN-MOBILITY + + + restconf/SDNCObjectPath + + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyUnassignCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyUnassignCallback.xml new file mode 100644 index 0000000000..11022f6aec --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyUnassignCallback.xml @@ -0,0 +1,16 @@ + + + skask + + 200 + {{REQUEST-ID}} + Y + + dontcare + 0 + SDN-MOBILITY + + + restconf/SDNCObjectPath + + \ No newline at end of file -- cgit 1.2.3-korg