diff options
Diffstat (limited to 'bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe')
9 files changed, 0 insertions, 2332 deletions
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 deleted file mode 100644 index e7b80f12ab..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/AbstractTestBase.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * ============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 deleted file mode 100644 index d9534f325f..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/CreateVcpeResCustServiceTest.java +++ /dev/null @@ -1,382 +0,0 @@ -/* - * ============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 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.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; - -import java.io.IOException; -import java.util.HashMap; -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.BPMNUtil; -import org.openecomp.mso.bpmn.mock.FileUtil; - -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/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 - @Ignore // 1802 merge - @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 { - - System.out.println("starting: testCreateVcpeResCustService_Success\n"); - 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<String, Object> 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); - - 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.contains("request-id>testRequestId<")); - assertTrue(completionReq.contains("action>CREATE<")); - assertTrue(completionReq.contains("source>VID<")); - - assertEquals("1", BPMNUtil.getVariable(processEngineRule, PROCNAME, Prefix+"VnfsCreatedCount")); - } - - @Test - @Ignore // 1802 merge - @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_NoParts() throws Exception { - - System.out.println("starting: testCreateVcpeResCustService_NoParts\n" ); - 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"); - - // 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<String, Object> variables = setupVariables(); - - String businessKey = UUID.randomUUID().toString(); - invokeAsyncProcess(PROCNAME, "v1", businessKey, request, variables); - - // for SI - injectSDNCCallbacks(callbacks, "assign"); - - 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.contains("request-id>testRequestId<")); - assertTrue(completionReq.contains("action>CREATE<")); - assertTrue(completionReq.contains("source>VID<")); - - assertEquals("0", BPMNUtil.getVariable(processEngineRule, PROCNAME, Prefix+"VnfsCreatedCount")); - } - - @Test - @Ignore // 1802 merge - @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 { - - System.out.println("starting: testCreateVcpeResCustService_Fault_NoRollback\n"); - 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<String, Object> 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); - - 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 - @Ignore // 1802 merge - @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"}) - - public void testCreateVcpeResCustService_Fault_Rollback() throws Exception { - - System.out.println("starting: testCreateVcpeResCustService_Fault_Rollback\n"); - 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<String, Object> 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<String, Object> setupVariables() { - Map<String, Object> variables = new HashMap<>(); - variables.put("requestId", "testRequestId"); - variables.put("request-id", "testRequestId"); - variables.put("serviceInstanceId", DEC_INST); - variables.put("allottedResourceId", ARID); - return variables; - - } -} 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 deleted file mode 100644 index d026b7a949..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DeleteVcpeResCustServiceTest.java +++ /dev/null @@ -1,297 +0,0 @@ -/* - * ============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<String, Object> 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.contains("<request-id>testRequestId<")); - assertTrue(completionReq.contains("<action>DELETE<")); - assertTrue(completionReq.contains("<source>VID<")); - - 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<String, Object> 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.contains("<request-id>testRequestId<")); - assertTrue(completionReq.contains("<action>DELETE<")); - assertTrue(completionReq.contains("<source>VID<")); - - 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<String, Object> 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<String, Object> setupVariables() throws UnsupportedEncodingException { - Map<String, Object> 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 deleted file mode 100644 index 0407e172e2..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoCreateAllottedResourceBRGRollbackTest.java +++ /dev/null @@ -1,345 +0,0 @@ -/* - * ============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 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; -import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; -import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; - -import java.io.IOException; -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.core.RollbackData; -import org.openecomp.mso.bpmn.mock.FileUtil; - - -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/VfModularity/SDNCTopologyDeactivateCallback.xml")); - callbacks.put("delete", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeleteCallback.xml")); - callbacks.put("unassign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyUnassignCallback.xml")); - } - - @Test - @Deployment(resources = { - "subprocess/SDNCAdapterV1.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/DoCreateAllottedResourceBRGRollback.bpmn"}) - public void testDoCreateAllottedResourceBRGRollback_Success() 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<String, Object> variables = new HashMap<>(); - setVariablesSuccess(variables, "testRequestId1"); - - invokeSubProcess(PROCNAME, businessKey, variables); - - injectSDNCCallbacks(callbacks, "deactivate"); - 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_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<String, Object> variables = new HashMap<>(); - RollbackData rollbackData = setVariablesSuccess(variables, "testRequestId1"); - - rollbackData.put(RbType, "rollbackAAI", "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(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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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); - - variables.put("serviceInstanceId", DEC_INST); - variables.put("parentServiceInstanceId", DEC_PARENT_INST); - - RollbackData rollbackData = new RollbackData(); - - 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/"+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 deleted file mode 100644 index 0373266ce1..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoCreateAllottedResourceBRGTest.java +++ /dev/null @@ -1,296 +0,0 @@ -/* - * ============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 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; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutAllottedResource; -import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; -import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; - -import java.io.IOException; -import java.util.HashMap; -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.mock.FileUtil; - - -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/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")); - } - - @Test - @Deployment(resources = { - "subprocess/GenericGetService.bpmn", - "subprocess/SDNCAdapterV1.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/DoCreateAllottedResourceBRG.bpmn", - "subprocess/DoCreateAllottedResourceBRGRollback.bpmn"}) - 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"); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - setVariablesSuccess(variables, "testRequestId123"); - - invokeSubProcess(PROCNAME, businessKey, variables); - - injectSDNCCallbacks(callbacks, "assign"); - injectSDNCCallbacks(callbacks, "create"); - injectSDNCCallbacks(callbacks, "activate"); - 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_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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> variables, String requestId) { - variables.put("isDebugLogEnabled", "true"); - variables.put("failExists", "true"); - variables.put("disableRollback", "true"); - variables.put("msoRequestId", requestId); - variables.put("mso-request-id", "requestId"); - variables.put("sourceNetworkId", "snId"); - variables.put("sourceNetworkRole", "snRole"); - variables.put("allottedResourceRole", "txc"); - variables.put("allottedResourceType", "BRG"); - variables.put("allottedResourceId", ARID); - variables.put("vni", "BRG"); - variables.put("vgmuxBearerIP", "bearerip"); - variables.put("brgWanMacAddress", "wanmac"); - - variables.put("serviceInstanceId", DEC_INST); - variables.put("parentServiceInstanceId", DEC_PARENT_INST); - - variables.put("serviceChainServiceInstanceId", "scsiId"); - - String arModelInfo = "{ "+ "\"modelType\": \"allotted-resource\"," + - "\"modelInvariantUuid\": \"ff5256d2-5a33-55df-13ab-12abad84e7ff\"," + - "\"modelUuid\": \"fe6478e5-ea33-3346-ac12-ab121484a3fe\"," + - "\"modelName\": \"vSAMP12\"," + - "\"modelVersion\": \"1.0\"," + - "\"modelCustomizationUuid\": \"MODEL-ID-1234\"," + - "}"; - variables.put("allottedResourceModelInfo", arModelInfo); - } - -} 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 deleted file mode 100644 index cdce56ee63..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoCreateAllottedResourceTXCRollbackTest.java +++ /dev/null @@ -1,345 +0,0 @@ -/* - * ============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 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; -import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; -import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; - -import java.io.IOException; -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.core.RollbackData; -import org.openecomp.mso.bpmn.mock.FileUtil; - - -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/VfModularity/SDNCTopologyDeactivateCallback.xml")); - callbacks.put("delete", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyDeleteCallback.xml")); - callbacks.put("unassign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyUnassignCallback.xml")); - } - - @Test - @Deployment(resources = { - "subprocess/SDNCAdapterV1.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/DoCreateAllottedResourceTXCRollback.bpmn"}) - public void testDoCreateAllottedResourceTXCRollback_Success() 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<String, Object> variables = new HashMap<>(); - setVariablesSuccess(variables, "testRequestId1"); - - invokeSubProcess(PROCNAME, businessKey, variables); - - injectSDNCCallbacks(callbacks, "deactivate"); - 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_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<String, Object> variables = new HashMap<>(); - RollbackData rollbackData = setVariablesSuccess(variables, "testRequestId1"); - - rollbackData.put(RbType, "rollbackAAI", "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(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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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); - - variables.put("serviceInstanceId", DEC_INST); - variables.put("parentServiceInstanceId", DEC_PARENT_INST); - - RollbackData rollbackData = new RollbackData(); - - 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/"+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 deleted file mode 100644 index 9cf059c24c..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoCreateAllottedResourceTXCTest.java +++ /dev/null @@ -1,302 +0,0 @@ -/* - * ============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 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; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutAllottedResource; -import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; -import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; - -import java.io.IOException; -import java.util.HashMap; -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.mock.FileUtil; - - -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/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")); - } - - @Test - @Deployment(resources = { - "subprocess/GenericGetService.bpmn", - "subprocess/SDNCAdapterV1.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/DoCreateAllottedResourceTXC.bpmn", - "subprocess/DoCreateAllottedResourceTXCRollback.bpmn"}) - 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<String, Object> variables = new HashMap<>(); - setVariablesSuccess(variables, "testRequestId123"); - - invokeSubProcess(PROCNAME, businessKey, variables); - - injectSDNCCallbacks(callbacks, "assign"); - injectSDNCCallbacks(callbacks, "create"); - injectSDNCCallbacks(callbacks, "activate"); - 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")); - 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<String, Object> 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<String, Object> 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")); - 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<String, Object> 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<String, Object> 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<String, Object> variables, String requestId) { - // TODO: need all of these? - variables.put("isDebugLogEnabled", "true"); - variables.put("failExists", "true"); - variables.put("disableRollback", "true"); - variables.put("msoRequestId", requestId); - variables.put("mso-request-id", "requestId"); - variables.put("sourceNetworkId", "snId"); - variables.put("sourceNetworkRole", "snRole"); - variables.put("allottedResourceRole", "brg"); - variables.put("allottedResourceType", "TXC"); - variables.put("allottedResourceId", ARID); - variables.put("brgWanMacAddress", "wanmac"); - - variables.put("serviceInstanceId", DEC_INST); - variables.put("parentServiceInstanceId", DEC_PARENT_INST); - - variables.put("serviceChainServiceInstanceId", "scsiId"); - - String arModelInfo = "{ "+ "\"modelType\": \"allotted-resource\"," + - "\"modelInvariantUuid\": \"ff5256d2-5a33-55df-13ab-12abad84e7ff\"," + - "\"modelUuid\": \"fe6478e5-ea33-3346-ac12-ab121484a3fe\"," + - "\"modelName\": \"vSAMP12\"," + - "\"modelVersion\": \"1.0\"," + - "\"modelCustomizationUuid\": \"MODEL-ID-1234\"," + - "}"; - variables.put("allottedResourceModelInfo", arModelInfo); - } - -} 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 deleted file mode 100644 index 03972da789..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoDeleteAllottedResourceBRGTest.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * ============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 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; -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.util.HashMap; -import java.util.Map; -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.mock.FileUtil; - - -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/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 - @Deployment(resources = { - "subprocess/SDNCAdapterV1.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/DoDeleteAllottedResourceBRG.bpmn"}) - public void testDoDeleteAllottedResourceBRG_Success() 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<String, Object> variables = new HashMap<>(); - setVariablesSuccess(variables, "testRequestId1"); - - invokeSubProcess(PROCNAME, businessKey, variables); - - injectSDNCCallbacks(callbacks, "deactivate"); - injectSDNCCallbacks(callbacks, "delete"); - injectSDNCCallbacks(callbacks, "unassign"); - - waitForProcessEnd(businessKey, 10000); - - Assert.assertTrue(isProcessEnded(businessKey)); - 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<String, Object> 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<String, Object> 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<String, Object> 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); - - 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 deleted file mode 100644 index 2b0364c3c9..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/vcpe/DoDeleteAllottedResourceTXCTest.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * ============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 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; -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.util.HashMap; -import java.util.Map; -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.mock.FileUtil; - - -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/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 - @Deployment(resources = { - "subprocess/SDNCAdapterV1.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/DoDeleteAllottedResourceTXC.bpmn"}) - public void testDoDeleteAllottedResourceTXC_Success() 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<String, Object> variables = new HashMap<>(); - setVariablesSuccess(variables, "testRequestId1"); - - invokeSubProcess(PROCNAME, businessKey, variables); - - injectSDNCCallbacks(callbacks, "deactivate"); - injectSDNCCallbacks(callbacks, "delete"); - injectSDNCCallbacks(callbacks, "unassign"); - - waitForProcessEnd(businessKey, 10000); - - Assert.assertTrue(isProcessEnded(businessKey)); - 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<String, Object> 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<String, Object> 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<String, Object> 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); - - variables.put("serviceInstanceId", DEC_INST); - variables.put("parentServiceInstanceId", DEC_PARENT_INST); - } - -} |