From b1e5734ef566af5d49ba17d05ca0ab7b56d6666d Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 9 May 2017 03:55:30 -0700 Subject: [MSO-8] Additional fixes for the second rebase DB fixes + BPMN flows and groovy fixes + Fix issue with CloudConfig file not reloaded properly when it's wrong (JSON error or model hierarchy mistake) at MSO startup Change-Id: I2853030b78499e2a761706b643ea210955e72de3 Signed-off-by: Determe, Sebastien (sd378r) [MSO-8] Restore files removed in patch set 2 Those groovy files must be there Change-Id: I9a47ac3d9c8fc06774a1b8f518491b1b0b00af04 Signed-off-by: Determe, Sebastien (sd378r) --- .../infrastructure/CreateVfModuleInfraTest.java | 122 ++- .../UpdateNetworkInstanceInfraTest.java | 840 --------------------- .../UpdateVfModuleVolumeInfraV1Test.java | 284 +++---- 3 files changed, 225 insertions(+), 1021 deletions(-) delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateNetworkInstanceInfraTest.java (limited to 'bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso') diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleInfraTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleInfraTest.java index 4f987f0d48..dd7497c279 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleInfraTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleInfraTest.java @@ -20,26 +20,18 @@ package org.openecomp.mso.bpmn.infrastructure; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetCloudRegion; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkPolicyfqdn; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchGenericVnf; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchVfModuleId; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutNetwork; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutVfModuleIdNoResponse; -import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; -import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; -import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVNFPost; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModule; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockSDNCAdapterVfModule; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockVNFAdapterRestVfModule; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDBUpdateVfModule; import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.UUID; - +import org.junit.Ignore; import org.camunda.bpm.engine.test.Deployment; import org.junit.Test; import org.openecomp.mso.bpmn.common.WorkflowTest; @@ -66,7 +58,7 @@ public class CreateVfModuleInfraTest extends WorkflowTest { /** - * Sunny day VID scenario. + * Sunny day VID scenario with preloads. * * @throws Exception */ @@ -74,7 +66,9 @@ public class CreateVfModuleInfraTest extends WorkflowTest { @Deployment(resources = { "process/CreateVfModuleInfra.bpmn", "subprocess/DoCreateVfModule.bpmn", + "subprocess/GenericGetVnf.bpmn", "subprocess/SDNCAdapterV1.bpmn", + "subprocess/GenericNotificationService.bpmn", "subprocess/VnfAdapterRestV1.bpmn", "subprocess/ConfirmVolumeGroupTenant.bpmn", "subprocess/ConfirmVolumeGroupName.bpmn", @@ -84,28 +78,80 @@ public class CreateVfModuleInfraTest extends WorkflowTest { "subprocess/CompleteMsoProcess.bpmn", "subprocess/FalloutHandler.bpmn" }) - public void sunnyDayVID() throws Exception { + public void sunnyDayVIDWithPreloads() throws Exception { logStart(); - MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); - MockGetGenericVnfByIdWithPriority("skask", ".*", 200, "VfModularity/VfModule-new.xml", 5); - MockGetGenericVnfById("skask", "VfModularity/GenericVnf.xml", 200); - MockPutVfModuleIdNoResponse("skask", "PCRF", ".*"); - MockPutNetwork(".*", "VfModularity/AddNetworkPolicy_AAIResponse_Success.xml", 200); - MockPutGenericVnf("skask"); - mockVNFPost("", 202, "skask"); - mockSDNCAdapter("/SDNCAdapter", "vnf-type>STMTN", 200, "VfModularity/StandardSDNCSynchResponse.xml"); - mockSDNCAdapter("/SDNCAdapter", "SvcAction>query", 200, "VfModularity/StandardSDNCSynchResponse.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + MockAAIVfModule(); MockPatchGenericVnf("skask"); MockPatchVfModuleId("skask", ".*"); + MockSDNCAdapterVfModule(); + MockVNFAdapterRestVfModule(); + MockDBUpdateVfModule(); String businessKey = UUID.randomUUID().toString(); String createVfModuleRequest = FileUtil.readResourceFile("__files/CreateVfModule_VID_request.json"); - Map variables = setupVariablesSunnyDayVID(); + Map variables = setupVariablesSunnyDayVID(); + + TestAsyncResponse asyncResponse = invokeAsyncProcess("CreateVfModuleInfra", + "v1", businessKey, createVfModuleRequest, variables); + + WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000); + + String responseBody = response.getResponse(); + System.out.println("Workflow (Synch) Response:\n" + responseBody); + + injectSDNCCallbacks(callbacks, "assign, query"); + injectVNFRestCallbacks(callbacks, "vnfCreate"); + injectSDNCCallbacks(callbacks, "activate"); + + // TODO add appropriate assertions + + waitForProcessEnd(businessKey, 10000); + checkVariable(businessKey, "CreateVfModuleSuccessIndicator", true); + + logEnd(); + } + + /** + * Sunny day VID scenario with no preloads. + * + * @throws Exception + */ + @Test + @Deployment(resources = { + "process/CreateVfModuleInfra.bpmn", + "subprocess/DoCreateVfModule.bpmn", + "subprocess/GenericGetVnf.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/VnfAdapterRestV1.bpmn", + "subprocess/ConfirmVolumeGroupTenant.bpmn", + "subprocess/GenericNotificationService.bpmn", + "subprocess/ConfirmVolumeGroupName.bpmn", + "subprocess/CreateAAIVfModule.bpmn", + "subprocess/UpdateAAIVfModule.bpmn", + "subprocess/UpdateAAIGenericVnf.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/FalloutHandler.bpmn" + }) + public void sunnyDayVIDNoPreloads() throws Exception { + + logStart(); + + MockAAIVfModule(); + MockPatchGenericVnf("skask"); + MockPatchVfModuleId("skask", ".*"); + MockSDNCAdapterVfModule(); + MockVNFAdapterRestVfModule(); + MockDBUpdateVfModule(); + + String businessKey = UUID.randomUUID().toString(); + String createVfModuleRequest = + FileUtil.readResourceFile("__files/CreateVfModule_VID_request_noPreloads.json"); + + Map variables = setupVariablesSunnyDayVID(); TestAsyncResponse asyncResponse = invokeAsyncProcess("CreateVfModuleInfra", "v1", businessKey, createVfModuleRequest, variables); @@ -131,7 +177,7 @@ public class CreateVfModuleInfraTest extends WorkflowTest { private Map setupVariablesSunnyDayVID() { Map variables = new HashMap(); //try { - // variables.put("bpmnRequest", FileUtil.readResourceFile("__files/CreateVfModule_VID_request.json")); + //variables.put("bpmnRequest", FileUtil.readResourceFile("__files/CreateVfModule_VID_request.json")); //} //catch (Exception e) { @@ -159,39 +205,35 @@ public class CreateVfModuleInfraTest extends WorkflowTest { * @throws Exception */ @Test + @Ignore @Deployment(resources = { "process/CreateVfModuleInfra.bpmn", "subprocess/DoCreateVfModule.bpmn", + "subprocess/GenericGetVnf.bpmn", "subprocess/SDNCAdapterV1.bpmn", "subprocess/VnfAdapterRestV1.bpmn", "subprocess/ConfirmVolumeGroupTenant.bpmn", "subprocess/ConfirmVolumeGroupName.bpmn", "subprocess/CreateAAIVfModule.bpmn", "subprocess/CreateAAIVfModuleVolumeGroup.bpmn", + "subprocess/GenericNotificationService.bpmn", "subprocess/UpdateAAIVfModule.bpmn", "subprocess/UpdateAAIGenericVnf.bpmn", "subprocess/CompleteMsoProcess.bpmn", "subprocess/FalloutHandler.bpmn" }) + public void sunnyDayVIDWithVolumeGroupAttach() throws Exception { logStart(); - MockGetVolumeGroupById("AAIAIC25", "78987", "VfModularity/VolumeGroup.xml"); - MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); - MockGetCloudRegion("MDTWNJ21", 200, "CreateNetworkV2/cloudRegion30_AAIResponse_Success.xml"); - MockGetVolumeGroupById("RDM2WAGPLCP", "78987", "DeleteVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml"); - MockPutVfModuleIdNoResponse("skask", "PCRF", ".*"); - mockVNFPost("", 202, "skask"); - MockGetNetworkPolicyfqdn(".*", "VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml", 200); - MockPutGenericVnf("skask"); - MockGetGenericVnfByIdWithPriority("skask", ".*", 200, "VfModularity/VfModule-new.xml", 5); - mockSDNCAdapter("/SDNCAdapter", "vnf-type>STMTN", 200, "VfModularity/StandardSDNCSynchResponse.xml"); - mockSDNCAdapter("/SDNCAdapter", "SvcAction>query", 200, "VfModularity/StandardSDNCSynchResponse.xml"); - mockVNFPost("", 202, "skask"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + MockAAIVfModule(); MockPatchGenericVnf("skask"); MockPatchVfModuleId("skask", ".*"); + MockSDNCAdapterVfModule(); + MockVNFAdapterRestVfModule(); + MockDBUpdateVfModule(); String businessKey = UUID.randomUUID().toString(); String createVfModuleRequest = diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateNetworkInstanceInfraTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateNetworkInstanceInfraTest.java deleted file mode 100644 index 9ef4c94cce..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateNetworkInstanceInfraTest.java +++ /dev/null @@ -1,840 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.infrastructure; - -import static org.junit.Assert.assertEquals; -import static org.openecomp.mso.bpmn.common.BPMNUtil.executeAsyncWorkflow; -import static org.openecomp.mso.bpmn.common.BPMNUtil.getVariable; -import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetCloudRegion; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetwork; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkPolicy; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkRouteTable; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkVpnBinding; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutNetwork; -import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; -import static org.openecomp.mso.bpmn.mock.StubResponseNetworkAdapter.MockPutNetworkAdapter; -import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; -import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapterTopology; - -import java.util.HashMap; -import java.util.Map; - -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.openecomp.mso.bpmn.common.BPMNUtil; -import org.openecomp.mso.bpmn.common.SDNCAdapterCallbackRule; -import org.openecomp.mso.bpmn.common.WorkflowTest; -import org.openecomp.mso.bpmn.common.WorkflowTestTransformer; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; -import org.openecomp.mso.bpmn.mock.SDNCAdapterNetworkTopologyMockTransformer; - -import com.github.tomakehurst.wiremock.extension.ResponseTransformer; - -/** - * Unit test cases for UpdateNetworkInstanceInfra.bpmn - * - */ -public class UpdateNetworkInstanceInfraTest extends WorkflowTest { - @WorkflowTestTransformer - public static final ResponseTransformer sdncAdapterMockTransformer = - new SDNCAdapterNetworkTopologyMockTransformer(); - - @Rule - public final SDNCAdapterCallbackRule sdncAdapterCallbackRule = - new SDNCAdapterCallbackRule(processEngineRule); - - /** - * End-to-End flow - Unit test for UpdateNetworkInstanceInfra.bpmn - * - String input & String response - */ - - @Test - //@Ignore - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_Success1() throws Exception { - - System.out.println("----------------------------------------------------------"); - System.out.println(" Success1 - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("----------------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); // - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 200, "UpdateNetworkV2/updateNetworkResponse_Success.xml"); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN1", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - MockPutNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", 200, "UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables1(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - System.out.println("----------------------------------------------------------"); - System.out.println("- got workflow response -"); - System.out.println("----------------------------------------------------------"); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("true", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_CompleteMsoProcessRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_CompleteMsoProcessRequest")); - - String workflowResp = BPMNUtil.getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "WorkflowResponse"); - Assert.assertNotNull(workflowResp); - - System.out.println("----------------------------------------------------------"); - System.out.println(" Success1 - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("----------------------------------------------------------"); - - } - - @Test - //@Ignore - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_Success2() throws Exception { - - System.out.println("----------------------------------------------------------"); - System.out.println(" Success2 - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("----------------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 200, "UpdateNetworkV2/updateNetworkResponse_Success.xml"); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN1", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - MockPutNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", 200, "UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables2(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("true", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_CompleteMsoProcessRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_CompleteMsoProcessRequest")); - - String completeMsoProcessRequest = - "" + '\n' - + " " + '\n' - + " testRequestId" + '\n' - + " UPDATE" + '\n' - + " VID" + '\n' - + " " + '\n' - + " BPMN Network action: UPDATE" + '\n' - + ""; - - Assert.assertEquals(completeMsoProcessRequest, getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_CompleteMsoProcessRequest")); - - System.out.println("----------------------------------------------------------"); - System.out.println(" Success2 - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("----------------------------------------------------------"); - - } - - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_MissingNetworkId() throws Exception { - - System.out.println("--------------------------------------------------------------------"); - System.out.println(" Missing networkId - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("--------------------------------------------------------------------"); - - // setup simulators - - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariablesMissingNetworkId(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - String falloutHandlerActual = getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest"); - String falloutHandlerExpected = -"" + "\n" + -" " + "\n" + -" 88f65519-9a38-4c4b-8445-9eb4a5a5af56" + "\n" + -" UPDATE" + "\n" + -" VID" + "\n" + -" " + "\n" + -" " + "\n" + -" Variable 'network-id' value/element is missing." + "\n" + -" 2500" + "\n" + -" " + "\n" + -" "; - - assertEquals("Response", falloutHandlerExpected, falloutHandlerActual); - - System.out.println("------------------------------------------------------------------"); - System.out.println(" Missing networkId - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("------------------------------------------------------------------"); - - } - - /* NOT NEEDED - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_SDNCRollback1() throws Exception { - - System.out.println("----------------------------------------------------------"); - System.out.println(" SDNCRollback1 - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("----------------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>rollback"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 200, "UpdateNetworkV2/updateNetworkResponse_Success.xml"); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockAAIResponse_queryId_UpdateNetwork_404V2(); // failure in queryId in AAI - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariablesSDNCRollback(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - System.out.println("----------------------------------------------------------"); - System.out.println(" SDNCRollback1 - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("----------------------------------------------------------"); - - } */ - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_SDNCRollback_Scenario01() throws Exception { - - System.out.println("----------------------------------------------------------"); - System.out.println(" SDNCRollback - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("----------------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); // - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>rollback"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 200, "UpdateNetworkV2/updateNetworkResponse_Success.xml"); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_NoPayload_Success.xml", 200); // no 'payload' response from NetworkAdapter, version 2 - //MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); // let it fail (404) to see SDNC compensation - //MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); // let it fail (404) to see SDNC compensation - //MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariablesSDNCRollback(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - System.out.println("----------------------------------------------------------"); - System.out.println(" SDNCRollback - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("----------------------------------------------------------"); - - } - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_Network_SDNC_Rollback() throws Exception { - - System.out.println("---------------------------------------------------------------"); - System.out.println(" Network and SDNC Rollback - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("---------------------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); // - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>rollback"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 200, "UpdateNetworkV2/updateNetworkResponse_Success.xml"); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN1", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - //MockAAIResponse_updateContrail_CreateNetwork_SuccessV2(); // designed to fail in AAI Update - //mockUpdateRequestDB(500, "Database/DBUpdateResponse.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables1(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - System.out.println("---------------------------------------------------------------------"); - System.out.println(" Network and SCNC Rollback - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("---------------------------------------------------------------------"); - - } - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_Network_SDNC_Rollback_Failed() throws Exception { - - System.out.println("---------------------------------------------------------------"); - System.out.println(" Network and SDNC Rollback - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("---------------------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); // - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySim500Response.xml", "SvcAction>rollback"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 200, "UpdateNetworkV2/updateNetworkResponse_Success.xml"); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN1", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - //MockAAIResponse_updateContrail_CreateNetwork_SuccessV2(); // designed to fail in AAI Update - //mockUpdateRequestDB(500, "Database/DBUpdateResponse.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables1(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - System.out.println("---------------------------------------------------------------------"); - System.out.println(" Network and SCNC Rollback - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("---------------------------------------------------------------------"); - - } - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_SDNCRollback2() throws Exception { - - System.out.println("----------------------------------------------------"); - System.out.println(" SDNCRollback2 - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("----------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>rollback"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 500, "UpdateNetworkV2/updateNetworkResponse_500.xml"); // failure 500 in NetworkAdapter - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN1", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - //MockPutNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", 200, "UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables1(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - System.out.println("------------------------------------------------------------"); - System.out.println(" SDNCRollback2 - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("------------------------------------------------------------"); - - } - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_SDNCRollback3() throws Exception { - - System.out.println("----------------------------------------------------"); - System.out.println(" SDNCRollback3 - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("----------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>rollback"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 400, "UpdateNetworkV2/updateNetworkResponse_400.xml"); // failure 400 in NetworkAdapter - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN1", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - //MockPutNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", 200, "UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables1(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - System.out.println("------------------------------------------------------------"); - System.out.println(" SDNCRollback3 - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("------------------------------------------------------------"); - - } - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_PONR() throws Exception { - - System.out.println("--------------------------------------------------------------------"); - System.out.println(" PONR (Point-of-no-Return) - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("--------------------------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); // - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>rollback"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 200, "UpdateNetworkV2/updateNetworkResponse_Success.xml"); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN1", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - MockPutNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", 200, "UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml"); - mockUpdateRequestDB(500, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables1(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - String falloutHandlerRequest = - "" + '\n' - + " " + '\n' - + " testRequestId" + '\n' - + " CREATE" + '\n' - + " VID" + '\n' - + " " + '\n' - + " " + '\n' - + " DB Update failed, code: 500" + '\n' - + " 2500" + '\n' - + " " + '\n' - + " "; - - System.out.println("Display UPDNETI_FalloutHandlerRequest - " + getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - //Assert.assertEquals(falloutHandlerRequest, getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - System.out.println("--------------------------------------------------------------------"); - System.out.println(" PONR (Point-of-no-Return) - UpdateNetworkInstanceInfra flow Completed! "); - System.out.println("--------------------------------------------------------------------"); - - - } - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_sdncFailure() throws Exception { - - System.out.println("----------------------------------------------------------"); - System.out.println(" SNDC Failure - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("----------------------------------------------------------"); - - // setup simulators - - //MockSDNCAdapterBadAsynchronousResponse(); // 404 - mockSDNCAdapter("/SDNCAdapter", "SvcAction>query", 500, ""); // 500 - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables2(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_CompleteMsoProcessRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_CompleteMsoProcessRequest")); - - System.out.println("----------------------------------------------------------"); - System.out.println(" SNDC Failure - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("----------------------------------------------------------"); - - } - - // ***************** - // Utility Section - // ***************** - - // Success Scenario - private Map setupVariables1() { - Map variables = new HashMap(); - variables.put("bpmnRequest", getCreateNetworkRequest1()); - variables.put("mso-request-id", "testRequestId"); - variables.put("requestId", "testRequestId"); - variables.put("isBaseVfModule", "true"); - variables.put("recipeTimeout", "0"); - variables.put("requestAction", "CREATE"); - variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); - variables.put("vnfId", ""); - variables.put("vfModuleId", ""); - variables.put("volumeGroupId", ""); - variables.put("networkId", "49c86598-f766-46f8-84f8-8d1c1b10f9b4"); - variables.put("serviceType", "vMOG"); - variables.put("vfModuleType", ""); - variables.put("networkType", "modelName"); - return variables; - - } - - public String getCreateNetworkRequest1() { - - String request = - "{ \"requestDetails\": { " + '\n' + - " \"modelInfo\": { " + '\n' + - " \"modelType\": \"modelType\", " + '\n' + - " \"modelId\": \"modelId\", " + '\n' + - " \"modelNameVersionId\": \"modelNameVersionId\", " + '\n' + - " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + - " \"modelVersion\": \"1\" " + '\n' + - " }, " + '\n' + - " \"cloudConfiguration\": { " + '\n' + - " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + - " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + - " }, " + '\n' + - " \"requestInfo\": { " + '\n' + - " \"instanceName\": \"MNS-25180-L-01-dmz_direct_net_1\", " + '\n' + - " \"source\": \"VID\", " + '\n' + - " \"callbackUrl\": \"\", " + '\n' + - " \"suppressRollback\": \"true\" ," + '\n' + - " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\" " + '\n' + - " }, " + '\n' + - " \"requestParameters\": { " + '\n' + - " \"backoutOnFailure\": true, " + '\n' + - " \"serviceId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\", " + '\n' + - " \"userParams\": [] " + '\n' + - " } " + '\n' + - " } " + '\n' + - "}"; - - return request; - } - - // Success Scenario 2 - private Map setupVariables2() { - Map variables = new HashMap(); - variables.put("bpmnRequest", getCreateNetworkRequest2()); - variables.put("mso-request-id", "testRequestId"); - variables.put("requestId", "testRequestId"); - variables.put("isBaseVfModule", "true"); - variables.put("recipeTimeout", "0"); - variables.put("requestAction", "UPDATE"); - variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); - variables.put("vnfId", ""); - variables.put("vfModuleId", ""); - variables.put("volumeGroupId", ""); - variables.put("networkId", "49c86598-f766-46f8-84f8-8d1c1b10f9b4"); - variables.put("serviceType", "vMOG"); - variables.put("vfModuleType", ""); - variables.put("networkType", "modelName"); - return variables; - - } - - public String getCreateNetworkRequest2() { - - String request = - "{ \"requestDetails\": { " + '\n' + - " \"modelInfo\": { " + '\n' + - " \"modelType\": \"modelType\", " + '\n' + - " \"modelId\": \"modelId\", " + '\n' + - " \"modelNameVersionId\": \"modelNameVersionId\", " + '\n' + - " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + - " \"modelVersion\": \"1\" " + '\n' + - " }, " + '\n' + - " \"cloudConfiguration\": { " + '\n' + - " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + - " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + - " }, " + '\n' + - " \"requestInfo\": { " + '\n' + - " \"instanceName\": \"myOwn_Network\", " + '\n' + - " \"source\": \"VID\", " + '\n' + - " \"callbackUrl\": \"\", " + '\n' + - " \"suppressRollback\": \"true\" ," + '\n' + - " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\" " + '\n' + - " }, " + '\n' + - " \"requestParameters\": { " + '\n' + - " \"backoutOnFailure\": true, " + '\n' + - " \"serviceId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\", " + '\n' + - " \"userParams\": [] " + '\n' + - " } " + '\n' + - " } " + '\n' + - "}"; - - return request; - - } - - /* Active Scenario - private Map setupVariablesActive() { - Map variables = new HashMap(); - variables.put("mso-request-id", "testRequestId"); - variables.put("bpmnRequest", getCreateNetworkRequestActive()); - variables.put("requestId", "testRequestId"); - variables.put("isBaseVfModule", "true"); - variables.put("recipeTimeout", "0"); - variables.put("requestAction", "UPDATE"); - variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); - variables.put("vnfId", ""); - variables.put("vfModuleId", ""); - variables.put("volumeGroupId", ""); - variables.put("networkId", "49c86598-f766-46f8-84f8-8d1c1b10f9b4"); - variables.put("serviceType", "vMOG"); - variables.put("vfModuleType", ""); - variables.put("networkType", "modelName"); - return variables; - - } - - public String getCreateNetworkRequestActive() { - - String request = - "{ \"requestDetails\": { " + '\n' + - " \"modelInfo\": { " + '\n' + - " \"modelType\": \"modelType\", " + '\n' + - " \"modelId\": \"modelId\", " + '\n' + - " \"modelNameVersionId\": \"modelNameVersionId\", " + '\n' + - " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + - " \"modelVersion\": \"1\" " + '\n' + - " }, " + '\n' + - " \"cloudConfiguration\": { " + '\n' + - " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + - " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + - " }, " + '\n' + - " \"requestInfo\": { " + '\n' + - " \"instanceName\": \"MNS-25180-L-01-dmz_direct_net_2\", " + '\n' + - " \"source\": \"VID\", " + '\n' + - " \"callbackUrl\": \"\", " + '\n' + - " \"suppressRollback\": \"true\" ," + '\n' + - " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\" " + '\n' + - " }, " + '\n' + - " \"requestParameters\": { " + '\n' + - " \"userParams\": [] " + '\n' + - " } " + '\n' + - " } " + '\n' + - "}"; - - return request; - - } */ - - // Missing Name Scenario - private Map setupVariablesMissingNetworkId() { - Map variables = new HashMap(); - variables.put("mso-request-id", "88f65519-9a38-4c4b-8445-9eb4a5a5af56"); - variables.put("bpmnRequest", getCreateNetworkRequestNetworkId()); - variables.put("requestId", "testRequestId"); - variables.put("isBaseVfModule", "true"); - variables.put("recipeTimeout", "0"); - variables.put("requestAction", "UPDATE"); - variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); - variables.put("vnfId", ""); - variables.put("vfModuleId", ""); - variables.put("volumeGroupId", ""); - //variables.put("networkId", "49c86598-f766-46f8-84f8-8d1c1b10f9b4"); // missing, ok - variables.put("serviceType", "vMOG"); - variables.put("vfModuleType", ""); - variables.put("networkType", "modelName"); - - return variables; - - } - - public String getCreateNetworkRequestNetworkId() { - - String request = - "{ \"requestDetails\": { " + '\n' + - " \"modelInfo\": { " + '\n' + - " \"modelType\": \"modelType\", " + '\n' + - " \"modelId\": \"modelId\", " + '\n' + - " \"modelNameVersionId\": \"modelNameVersionId\", " + '\n' + - " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + - " \"modelVersion\": \"1\" " + '\n' + - " }, " + '\n' + - " \"cloudConfiguration\": { " + '\n' + - " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + - " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + - " }, " + '\n' + - " \"requestInfo\": { " + '\n' + - " \"source\": \"VID\", " + '\n' + - " \"callbackUrl\": \"\", " + '\n' + - " \"suppressRollback\": \"true\" ," + '\n' + - " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\" " + '\n' + - " }, " + '\n' + - " \"requestParameters\": { " + '\n' + - " \"userParams\": [] " + '\n' + - " } " + '\n' + - " } " + '\n' + - "}"; - - return request; - - } - - // SDNC Rollback Scenario - private Map setupVariablesSDNCRollback() { - Map variables = new HashMap(); - variables.put("mso-request-id", "testRequestId"); - variables.put("bpmnRequest", getCreateNetworkRequestSDNCRollback()); - variables.put("requestId", "testRequestId"); - variables.put("isBaseVfModule", "true"); - variables.put("recipeTimeout", "0"); - variables.put("requestAction", "UPDATE"); - variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); - variables.put("vnfId", ""); - variables.put("vfModuleId", ""); - variables.put("volumeGroupId", ""); - variables.put("networkId", "49c86598-f766-46f8-84f8-8d1c1b10f9b4"); - variables.put("serviceType", "vMOG"); - variables.put("vfModuleType", ""); - variables.put("networkType", "modelName"); - return variables; - - } - - public String getCreateNetworkRequestSDNCRollback() { - - String request = - "{ \"requestDetails\": { " + '\n' + - " \"modelInfo\": { " + '\n' + - " \"modelType\": \"modelType\", " + '\n' + - " \"modelId\": \"modelId\", " + '\n' + - " \"modelNameVersionId\": \"modelNameVersionId\", " + '\n' + - " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + - " \"modelVersion\": \"1\" " + '\n' + - " }, " + '\n' + - " \"cloudConfiguration\": { " + '\n' + - " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + - " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + - " }, " + '\n' + - " \"requestInfo\": { " + '\n' + - " \"instanceName\": \"MNS-25180-L-01-dmz_direct_net_3\", " + '\n' + - " \"source\": \"VID\", " + '\n' + - " \"callbackUrl\": \"\", " + '\n' + - " \"suppressRollback\": \"true\" ," + '\n' + - " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\" " + '\n' + - " }, " + '\n' + - " \"requestParameters\": { " + '\n' + - " \"userParams\": [] " + '\n' + - " } " + '\n' + - " } " + '\n' + - "}"; - - - return request; - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleVolumeInfraV1Test.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleVolumeInfraV1Test.java index 34c0af43c4..6a5e241dc2 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleVolumeInfraV1Test.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleVolumeInfraV1Test.java @@ -1,141 +1,143 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.infrastructure; - -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVfModuleId; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById; -import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; -import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockPutVNFVolumeGroup; - -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.WorkflowTest; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; -import org.openecomp.mso.bpmn.mock.FileUtil; - -/** - * Unit test cases for UpdateVfModuleVolume.bpmn - */ -public class UpdateVfModuleVolumeInfraV1Test extends WorkflowTest { - - private final CallbackSet callbacks = new CallbackSet(); - - public UpdateVfModuleVolumeInfraV1Test() throws IOException { - callbacks.put("volumeGroupUpdate", FileUtil.readResourceFile( - "__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml")); - } - - /** - * Happy path scenario. - * - * @throws Exception - */ - @Test - @Deployment(resources = { - "process/UpdateVfModuleVolumeInfraV1.bpmn", - "subprocess/VnfAdapterRestV1.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/FalloutHandler.bpmn" - }) - public void happyPath() throws Exception { - - logStart(); - - MockGetGenericVnfById("/TEST-VNF-ID-0123", "CreateVfModuleVolumeInfraV1/GenericVnf.xml", 200); - MockGetVolumeGroupById("mdt1", "78987", "UpdateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml"); - MockGetVfModuleId("9e48f6ea-f786-46de-800a-d480e5ccc846", "6a1dc898-b590-47b9-bbf0-34424a7a2ec3/", "UpdateVfModuleVolumeInfraV1/vf_module_aai_response.xml", 200); - mockPutVNFVolumeGroup("78987", 202); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - - String businessKey = UUID.randomUUID().toString(); - String updaetVfModuleVolRequest = - FileUtil.readResourceFile("__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request.json"); - - Map testVariables = new HashMap(); - testVariables.put("requestId", "TEST-REQUEST-ID-0123"); - testVariables.put("serviceInstanceId", "test-service-instance-id"); - testVariables.put("volumeGroupId", "78987"); - testVariables.put("vnfId", "TEST-VNF-ID-0123"); - TestAsyncResponse asyncResponse = invokeAsyncProcess("UpdateVfModuleVolumeInfraV1", "v1", businessKey, updaetVfModuleVolRequest, testVariables); - WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000); - - String responseBody = response.getResponse(); - System.out.println("Workflow (Synch) Response:\n" + responseBody); - - injectVNFRestCallbacks(callbacks, "volumeGroupUpdate"); - - waitForProcessEnd(businessKey, 10000); - checkVariable(businessKey, "UpdateVfModuleVolumeSuccessIndicator", true); - - logEnd(); - } - - /** - * VF Module Personal model id does not match request model invariant id - * @throws Exception - */ - @Test - //@Ignore - @Deployment(resources = { - "process/UpdateVfModuleVolumeInfraV1.bpmn", - "subprocess/VnfAdapterRestV1.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/FalloutHandler.bpmn" - }) - public void testPersonaModelIdNotMatch() throws Exception { - - logStart(); - - MockGetVolumeGroupById("mdt1", "78987", "UpdateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml"); - MockGetGenericVnfById("/TEST-VNF-ID-0123", "CreateVfModuleVolumeInfraV1/GenericVnf.xml", 200); - MockGetVfModuleId("9e48f6ea-f786-46de-800a-d480e5ccc846", "6a1dc898-b590-47b9-bbf0-34424a7a2ec3/", "UpdateVfModuleVolumeInfraV1/vf_module_aai_response.xml", 200); - mockPutVNFVolumeGroup("78987", 202); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - - String businessKey = UUID.randomUUID().toString(); - String updaetVfModuleVolRequest = - FileUtil.readResourceFile("__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request_2.json"); - - Map testVariables = new HashMap(); - testVariables.put("requestId", "TEST-REQUEST-ID-0123"); - testVariables.put("serviceInstanceId", "test-service-instance-id"); - testVariables.put("volumeGroupId", "78987"); - testVariables.put("vnfId", "TEST-VNF-ID-0123"); - TestAsyncResponse asyncResponse = invokeAsyncProcess("UpdateVfModuleVolumeInfraV1", "v1", businessKey, updaetVfModuleVolRequest, testVariables); - WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000); - - String responseBody = response.getResponse(); - System.out.println("Workflow (Synch) Response:\n" + responseBody); - - injectVNFRestCallbacks(callbacks, "volumeGroupUpdate"); - - waitForProcessEnd(businessKey, 10000); - checkVariable(businessKey, "UpdateVfModuleVolumeSuccessIndicator", true); - - logEnd(); - } -} +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.infrastructure; + +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVfModuleId; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; +import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockPutVNFVolumeGroup; + +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.WorkflowTest; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; +import org.openecomp.mso.bpmn.mock.FileUtil; + +/** + * Unit test cases for UpdateVfModuleVolume.bpmn + */ +public class UpdateVfModuleVolumeInfraV1Test extends WorkflowTest { + + private final CallbackSet callbacks = new CallbackSet(); + + public UpdateVfModuleVolumeInfraV1Test() throws IOException { + callbacks.put("volumeGroupUpdate", FileUtil.readResourceFile( + "__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml")); + } + + /** + * Happy path scenario. + * + * @throws Exception + */ + @Test + @Deployment(resources = { + "process/UpdateVfModuleVolumeInfraV1.bpmn", + "subprocess/VnfAdapterRestV1.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/GenericNotificationService.bpmn", + "subprocess/FalloutHandler.bpmn" + }) + public void happyPath() throws Exception { + + logStart(); + + MockGetGenericVnfById("/TEST-VNF-ID-0123", "CreateVfModuleVolumeInfraV1/GenericVnf.xml", 200); + MockGetVolumeGroupById("mdt1", "78987", "UpdateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml"); + MockGetVfModuleId("9e48f6ea-f786-46de-800a-d480e5ccc846", "6a1dc898-b590-47b9-bbf0-34424a7a2ec3/", "UpdateVfModuleVolumeInfraV1/vf_module_aai_response.xml", 200); + mockPutVNFVolumeGroup("78987", 202); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + String updaetVfModuleVolRequest = + FileUtil.readResourceFile("__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request.json"); + + Map testVariables = new HashMap(); + testVariables.put("requestId", "TEST-REQUEST-ID-0123"); + testVariables.put("serviceInstanceId", "test-service-instance-id"); + testVariables.put("volumeGroupId", "78987"); + testVariables.put("vnfId", "TEST-VNF-ID-0123"); + TestAsyncResponse asyncResponse = invokeAsyncProcess("UpdateVfModuleVolumeInfraV1", "v1", businessKey, updaetVfModuleVolRequest, testVariables); + WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000); + + String responseBody = response.getResponse(); + System.out.println("Workflow (Synch) Response:\n" + responseBody); + + injectVNFRestCallbacks(callbacks, "volumeGroupUpdate"); + + waitForProcessEnd(businessKey, 10000); + checkVariable(businessKey, "UpdateVfModuleVolumeSuccessIndicator", true); + + logEnd(); + } + + /** + * VF Module Personal model id does not match request model invariant id + * @throws Exception + */ + @Test + //@Ignore + @Deployment(resources = { + "process/UpdateVfModuleVolumeInfraV1.bpmn", + "subprocess/VnfAdapterRestV1.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/GenericNotificationService.bpmn", + "subprocess/FalloutHandler.bpmn" + }) + public void testPersonaModelIdNotMatch() throws Exception { + + logStart(); + + MockGetVolumeGroupById("mdt1", "78987", "UpdateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml"); + MockGetGenericVnfById("/TEST-VNF-ID-0123", "CreateVfModuleVolumeInfraV1/GenericVnf.xml", 200); + MockGetVfModuleId("9e48f6ea-f786-46de-800a-d480e5ccc846", "6a1dc898-b590-47b9-bbf0-34424a7a2ec3/", "UpdateVfModuleVolumeInfraV1/vf_module_aai_response.xml", 200); + mockPutVNFVolumeGroup("78987", 202); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + String updaetVfModuleVolRequest = + FileUtil.readResourceFile("__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request_2.json"); + + Map testVariables = new HashMap(); + testVariables.put("requestId", "TEST-REQUEST-ID-0123"); + testVariables.put("serviceInstanceId", "test-service-instance-id"); + testVariables.put("volumeGroupId", "78987"); + testVariables.put("vnfId", "TEST-VNF-ID-0123"); + TestAsyncResponse asyncResponse = invokeAsyncProcess("UpdateVfModuleVolumeInfraV1", "v1", businessKey, updaetVfModuleVolRequest, testVariables); + WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000); + + String responseBody = response.getResponse(); + System.out.println("Workflow (Synch) Response:\n" + responseBody); + + injectVNFRestCallbacks(callbacks, "volumeGroupUpdate"); + + waitForProcessEnd(businessKey, 10000); + checkVariable(businessKey, "UpdateVfModuleVolumeSuccessIndicator", true); + + logEnd(); + } +} -- cgit 1.2.3-korg