From b6b7bef8bdcad15af01ac88a038dd763ce59f68f Mon Sep 17 00:00:00 2001 From: xg353y Date: Tue, 11 Apr 2017 13:30:42 +0200 Subject: [MSO-8] Update the maven dependency Update the maven depenency for sdc-distribution-client to cooperate with the sdc changes. Change-Id: I2da936e5c40cb68c7181bb78307192dd5655b5dc Signed-off-by: xg353y --- .../scripts/CreateVfModuleVolumeInfraV1Test.groovy | 209 ++ .../scripts/DeleteVfModuleVolumeInfraV1Test.groovy | 166 ++ .../scripts/DoCreateVfModuleVolumeV1Test.groovy | 218 ++ .../scripts/UpdateNetworkInstanceInfraTest.groovy | 3094 ++++++++++++++++++++ .../scripts/UpdateVfModuleVolumeInfraV1Test.groovy | 93 + 5 files changed, 3780 insertions(+) create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1Test.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceInfraTest.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy (limited to 'bpmn/MSOInfrastructureBPMN/src/test/groovy/org') diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy new file mode 100644 index 0000000000..4f5375719f --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy @@ -0,0 +1,209 @@ +/*- + * ============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.scripts; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.* + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.mockito.ArgumentCaptor +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.openecomp.mso.bpmn.common.scripts.MsoGroovyTest; + + +@RunWith(MockitoJUnitRunner.class) +import org.apache.commons.lang3.* + + +class CreateVfModuleVolumeInfraV1Test extends MsoGroovyTest { + + def jsonRequest = """ +{ + "requestDetails": { + "modelInfo": { + "modelType": "volumeGroup", + "modelId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", + "modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12::base::module-0", + "modelVersion": "1" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "mdt1", + "tenantId": "88a6ca3ee0394ade9403f075db23167e" + }, + "requestInfo": { + "instanceName": "MSOTESTVOL101a-vSAMP12_base_vol_module-0", + "source": "VID", + "suppressRollback": false + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "{service-instance-id}", + "modelInfo": { + "modelType": "service", + "modelId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", + "modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelName": "Test", + "modelVersion": "2.0" + } + } + }, { + "relatedInstance": { + "instanceId": "{vnf-instance-id}", + "modelInfo": { + "modelType": "vnf", + "modelId": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", + "modelName": "vSAMP12", + "modelVersion": "1", + "modelCustomizationName": "vSAMP12" + } + } + } + ], + "requestParameters": { + "serviceId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "userParams": [ + {"name": "vnfName", "value": "STMTN5MMSC20" }, + {"name": "vnfName2", "value": "US1117MTSNJVBR0246" }, + {"name": "vnfNmInformation", "value": "" }, + {"name": "vnfType", "value": "pcrf-capacity" }, + {"name": "vnfId", "value": "skask" }, + {"name": "vnfStackId", "value": "slowburn" }, + {"name": "vnfStatus", "value": "created" }, + {"name": "aicCloudRegion", "value": "MDTWNJ21" }, + {"name": "availabilityZone", "value": "slcp3-esx-az01" }, + {"name": "oamNetworkName", "value": "VLAN-OAM-1323" }, + {"name": "vmName", "value": "slcp34246vbc246ceb" }, + {"name": "ipagNetworkId", "value": "970cd2b9-7f09-4a12-af47-182ea38ba1f0" }, + {"name": "vpeNetworkId", "value": "545cc2c3-1930-4100-b534-5d82d0e12bb6" } + ] + } + } +} +""" + + def volumeRequestXml = """ + + CREATE_VF_MODULE_VOL + VID + + + + + MSOTESTVOL101a-vSAMP12_base_vol_module-0 + Test/vSAMP12 + vSAMP12::base::module-0 + 2.0 + mdt1 + 88a6ca3ee0394ade9403f075db23167e + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + true + + + + STMTN5MMSC20 + US1117MTSNJVBR0246 + + pcrf-capacity + skask + slowburn + created + MDTWNJ21 + slcp3-esx-az01 + VLAN-OAM-1323 + slcp34246vbc246ceb + 970cd2b9-7f09-4a12-af47-182ea38ba1f0 + 545cc2c3-1930-4100-b534-5d82d0e12bb6 + +""" + + def completeMsoRequestXml = """ + + 1234 + CREATE + VID + + Volume Group has been created successfully. + BPMN VF Module Volume action: CREATE +""" + + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + + @Test + public void testPreProcessRequest() { + + ExecutionEntity mockExecution = setupMock('CreateVfModuleVolumeInfraV1') + + when(mockExecution.getVariable("prefix")).thenReturn('CVMVINFRAV1_') + when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonRequest) + when(mockExecution.getVariable("serviceInstanceId")).thenReturn('') + when(mockExecution.getVariable("vnfId")).thenReturn('test-vnf-id') + when(mockExecution.getVariable("mso-request-id")).thenReturn('1234') + + CreateVfModuleVolumeInfraV1 createVfModuleVolumeInfraV1 = new CreateVfModuleVolumeInfraV1() + createVfModuleVolumeInfraV1.preProcessRequest(mockExecution, 'true') + + // Capture the arguments to setVariable + ArgumentCaptor captor1 = ArgumentCaptor.forClass(String.class); + ArgumentCaptor captor2 = ArgumentCaptor.forClass(String.class); + + verify(mockExecution, times(15)).setVariable(captor1.capture(), captor2.capture()) + + List arg2List = captor2.getAllValues() + String volumeRequestActual = arg2List.get(6) + String isVidRequestActual = arg2List.get(8) + + assertEquals(volumeRequestXml, volumeRequestActual.trim()) + assertEquals('true', isVidRequestActual) + } + + @Test + public void testPostProcessResponse() { + + ExecutionEntity mockExecution = setupMock('CreateVfModuleVolumeInfraV1') + when(mockExecution.getVariable("dbReturnCode")).thenReturn('000') + when(mockExecution.getVariable("CVMVINFRAV1_createDBResponse")).thenReturn('') + when(mockExecution.getVariable("mso-request-id")).thenReturn('1234') + when(mockExecution.getVariable("CVMVINFRAV1_source")).thenReturn('VID') + + CreateVfModuleVolumeInfraV1 createVfModuleVolumeInfraV1 = new CreateVfModuleVolumeInfraV1() + createVfModuleVolumeInfraV1.postProcessResponse(mockExecution, 'true') + + verify(mockExecution).setVariable('CVMVINFRAV1_Success', true) + verify(mockExecution).setVariable('CVMVINFRAV1_CompleteMsoProcessRequest', completeMsoRequestXml) + } + + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy new file mode 100644 index 0000000000..2e6b35eaba --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy @@ -0,0 +1,166 @@ +/*- + * ============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.scripts; + +import static org.junit.Assert.* +import static org.mockito.Mockito.* + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.openecomp.mso.bpmn.common.scripts.MsoGroovyTest +import org.openecomp.mso.bpmn.core.WorkflowException + + +@RunWith(MockitoJUnitRunner.class) +class DeleteVfModuleVolumeInfraV1Test extends MsoGroovyTest { + + def deleteVnfAdapterRequestXml = """ + RDM2WAGPLCP + fba1bd1e195a404cacb9ce17a9b2b421 + 78987 + + true + + TEST-REQUEST-ID-0123 + 1234 + + ebb9ef7b-a6a5-40e6-953e-f868f1767677 + http://localhost:28080/mso/WorkflowMessage/VNFAResponse/ebb9ef7b-a6a5-40e6-953e-f868f1767677 +""" + + def dbRequestXml = """ + + + + TEST-REQUEST-ID-0123 + BPMN + VolumeGroup successfully deleted + COMPLETE + 100 + + + +""" + + def completionRequestXml = """ + + TEST-REQUEST-ID-0123 + DELETE + VID + + Volume Group has been deleted successfully. + BPMN VF Module Volume action: DELETE +""" + + def falloutHandlerRequestXml = """ + + TEST-REQUEST-ID-0123 + DELETE + VID + + + Unexpected Error + 5000 + +""" + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + } + + + @Test + public void testPrepareVnfAdapterDeleteRequest() { + + ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1') + when(mockExecution.getVariable("DELVfModVol_cloudRegion")).thenReturn('RDM2WAGPLCP') + when(mockExecution.getVariable("DELVfModVol_tenantId")).thenReturn('fba1bd1e195a404cacb9ce17a9b2b421') + when(mockExecution.getVariable("DELVfModVol_volumeGroupId")).thenReturn('78987') + when(mockExecution.getVariable("DELVfModVol_volumeGroupHeatStackId")).thenReturn('') + when(mockExecution.getVariable("DELVfModVol_requestId")).thenReturn('TEST-REQUEST-ID-0123') + when(mockExecution.getVariable("DELVfModVol_serviceId")).thenReturn('1234') + when(mockExecution.getVariable("DELVfModVol_messageId")).thenReturn('ebb9ef7b-a6a5-40e6-953e-f868f1767677') + when(mockExecution.getVariable("URN_mso_workflow_message_endpoint")).thenReturn('http://localhost:28080/mso/WorkflowMessage') + when(mockExecution.getVariable("URN_mso_use_qualified_host")).thenReturn('') + + DeleteVfModuleVolumeInfraV1 myproc = new DeleteVfModuleVolumeInfraV1() + myproc.prepareVnfAdapterDeleteRequest(mockExecution, 'true') + + verify(mockExecution).setVariable("DELVfModVol_deleteVnfARequest", deleteVnfAdapterRequestXml) + + } + + @Test + public void testPrepareDbRequest() { + + ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1') + when(mockExecution.getVariable("DELVfModVol_requestId")).thenReturn('TEST-REQUEST-ID-0123') + when(mockExecution.getVariable("DELVfModVol_volumeOutputs")).thenReturn('') + + DeleteVfModuleVolumeInfraV1 myproc = new DeleteVfModuleVolumeInfraV1() + myproc.prepareDBRequest(mockExecution, 'true') + + verify(mockExecution).setVariable("DELVfModVol_updateInfraRequest", dbRequestXml) + } + + @Test + public void testPrepareCompletionHandlerRequest() { + + ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1') + when(mockExecution.getVariable("mso-request-id")).thenReturn('TEST-REQUEST-ID-0123') + when(mockExecution.getVariable("DELVfModVol_source")).thenReturn('VID') + + DeleteVfModuleVolumeInfraV1 myproc = new DeleteVfModuleVolumeInfraV1() + myproc.prepareCompletionHandlerRequest(mockExecution, 'true') + + verify(mockExecution).setVariable("DELVfModVol_CompleteMsoProcessRequest", completionRequestXml) + } + + @Test + public void testPrepareFalloutHandler() { + + WorkflowException workflowException = new WorkflowException('DeleteVfModuleVolumeInfraV1', 5000, 'Unexpected Error') + + ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1') + + when(mockExecution.getVariable("DELVfModVol_requestId")).thenReturn('TEST-REQUEST-ID-0123') + when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) + when(mockExecution.getVariable("DELVfModVol_source")).thenReturn('VID') + + DeleteVfModuleVolumeInfraV1 myproc = new DeleteVfModuleVolumeInfraV1() + myproc.prepareFalloutHandler(mockExecution, 'true') + + verify(mockExecution).setVariable("DELVfModVol_Success", false) + verify(mockExecution).setVariable("DELVfModVol_FalloutHandlerRequest", falloutHandlerRequestXml) + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1Test.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1Test.groovy new file mode 100644 index 0000000000..cf95ed3085 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1Test.groovy @@ -0,0 +1,218 @@ +/*- + * ============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.scripts; + +import static org.junit.Assert.* +import static org.mockito.Mockito.* + +import org.apache.commons.lang3.* +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.junit.Assert +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.openecomp.mso.bpmn.common.scripts.MsoGroovyTest + + +@RunWith(MockitoJUnitRunner.class) +class DoCreateVfModuleVolumeV1Test extends MsoGroovyTest { + + def volumeRequest = +""" + + 123abc + d8d4fcfa-fd7e-4413-b19d-c95aa67291b8 + CREATE_VF_MODULE_VOL + SoapUI-bns-create-base-vol-1001-1 + + + Test/vSAMP12 + vSAMP12::base::module-0 + true + 2.0 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MDTWNJ21 + 897deadc2b954a6bac6d3c197fb3525e + MSOTESTVOL101a-vSAMP12_base_vol_module-0 + + + + value1" + value2" + value3" + +""" + + def genericVnfResponseXml = """ + + TEST-VNF-ID-0123 + STMTN5MMSC20 + pcrf-capacity + SDN-MOBILITY + vPCRF + pending-create + false + false + introvert + 2.0 + 0000020 + + + lukewarm + PCRF::module-0-0 + introvert + 2.0 + true + fastburn + pending-create + 0000074 + + + supercool + PCRF::module-1-0 + extrovert + 2.0 + false + slowburn + pending-create + 0000075 + + + + + + +""" + def String expectedCreateVnfRequestXml = """ + MDTWNJ21 + 897deadc2b954a6bac6d3c197fb3525e + TEST-VNF-ID-0123 + STMTN5MMSC20 + test-vol-group-id-123 + MSOTESTVOL101a-vSAMP12_base_vol_module-0 + Test/vSAMP12 + 2.0 + vSAMP12::base::module-0 + + + + vnf_id + TEST-VNF-ID-0123 + + + vnf_name + STMTN5MMSC20 + + + vf_module_id + test-vol-group-id-123 + + + vf_module_name + MSOTESTVOL101a-vSAMP12_base_vol_module-0 + + + param1 + value1 + + + param2 + value2 + + + param3 + value3 + + + true + true + true + + d8d4fcfa-fd7e-4413-b19d-c95aa67291b8 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + + 111 + http://localhost:28080/mso/WorkflowMessage/12345678 + +""" + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + + } + + @Test + public void TestPreProcessRequest() { + + ExecutionEntity mockExecution = setupMock('DoCreateVfModuleVolumeV1') + + when(mockExecution.getVariable("DoCreateVfModuleVolumeV1Request")).thenReturn(volumeRequest) + when(mockExecution.getVariable("vnf-id")).thenReturn('test-vnf-id-123') + when(mockExecution.getVariable("volume-group-id")).thenReturn('test-volume-group-id-123') + when(mockExecution.getVariable("mso-request-id")).thenReturn('test-request-id-123') + + DoCreateVfModuleVolumeV1 myprocess = new DoCreateVfModuleVolumeV1() + myprocess.preProcessRequest(mockExecution, 'true') + + verify(mockExecution).setVariable('DCVFMODVOLV1_serviceId', 'a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb') + verify(mockExecution).setVariable('DCVFMODVOLV1_source', 'SoapUI-bns-create-base-vol-1001-1') + verify(mockExecution, times(7)).setVariable(anyString(), anyString()) + } + + @Test + public void TestPrepareVnfAdapterCreateRequest() { + + ExecutionEntity mockExecution = setupMock('DoCreateVfModuleVolumeV1') + + when(mockExecution.getVariable("DCVFMODVOLV1_Request")).thenReturn(volumeRequest) + when(mockExecution.getVariable("DCVFMODVOLV1_requestId")).thenReturn('d8d4fcfa-fd7e-4413-b19d-c95aa67291b8') + when(mockExecution.getVariable("DCVFMODVOLV1_serviceId")).thenReturn('a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb') + when(mockExecution.getVariable("DCVFMODVOLV1_AAIQueryGenericVfnResponse")).thenReturn(genericVnfResponseXml) + when(mockExecution.getVariable("DCVFMODVOLV1_rollbackEnabled")).thenReturn(true) + when(mockExecution.getVariable("volume-group-id")).thenReturn('test-vol-group-id-123') + when(mockExecution.getVariable("URN_mso_workflow_message_endpoint")).thenReturn('http://localhost:28080/mso/WorkflowMessage') + when(mockExecution.getVariable("URN_mso_use_qualified_host")).thenReturn(true) + + DoCreateVfModuleVolumeV1 myprocess = new DoCreateVfModuleVolumeV1() + myprocess.prepareVnfAdapterCreateRequest(mockExecution, 'true') + + // Capture the arguments to setVariable + ArgumentCaptor captor1 = ArgumentCaptor.forClass(String.class); + ArgumentCaptor captor2 = ArgumentCaptor.forClass(String.class); + + verify(mockExecution, times(2)).setVariable(captor1.capture(), captor2.capture()) + + List arg2List = captor2.getAllValues() + String createVnfRequestXml = arg2List.get(0) + + //replace messageID value because it is random generated + createVnfRequestXml = createVnfRequestXml.replaceAll("(.+?)", "111") + .replaceAll("(.+?)", "http://localhost:28080/mso/WorkflowMessage/12345678") + + Assert.assertEquals(expectedCreateVnfRequestXml.trim(), createVnfRequestXml.trim()) + } + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceInfraTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceInfraTest.groovy new file mode 100644 index 0000000000..d19081c766 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceInfraTest.groovy @@ -0,0 +1,3094 @@ +/*- + * ============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.scripts; + +import static org.junit.Assert.* +import static org.mockito.Mockito.* +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.MockPutNetwork +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 org.apache.commons.lang3.* +import org.camunda.bpm.engine.ProcessEngineServices +import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity +import org.camunda.bpm.engine.repository.ProcessDefinition +import org.camunda.bpm.engine.runtime.Execution +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.mockito.ArgumentCaptor +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.openecomp.mso.bpmn.common.scripts.MsoUtils +import org.openecomp.mso.bpmn.core.WorkflowException + +import com.github.tomakehurst.wiremock.client.WireMock +import com.github.tomakehurst.wiremock.junit.WireMockRule + + +@RunWith(MockitoJUnitRunner.class) +class UpdateNetworkInstanceInfraTest { + + @Rule + public WireMockRule wireMockRule = new WireMockRule(28090); + + def utils = new MsoUtils() + + String jsonIncomingRequest = + """{ "requestDetails": { + "modelInfo": { + "modelType": "networkTyp", + "modelId": "modelId", + "modelNameVersionId": "modelNameVersionId", + "modelName": "CONTRAIL_EXTERNAL", + "modelVersion": "1" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "RDM2WAGPLCP", + "tenantId": "7dd5365547234ee8937416c65507d266" + }, + "requestInfo": { + "instanceName": "MNS-25180-L-01-dmz_direct_net_1", + "source": "VID", + "callbackUrl": "", + "suppressRollback": true, + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "f70e927b-6087-4974-9ef8-c5e4d5847ca4", + "modelInfo": { + "modelType": "serviceT", + "modelId": "modelI", + "modelNameVersionId": "modelNameVersionI", + "modelName": "modleNam", + "modelVersion": "1" + } + } + } + ], + "requestParameters": { + "userParams": [ + { + "name": "someUserParam1", + "value": "someValue1" + } + ] + } + }}""" + + String jsonIncomingRequest_Missingname = + """{ "requestDetails": { + "modelInfo": { + "modelType": "networkTyp", + "modelId": "modelId", + "modelNameVersionId": "modelNameVersionId", + "modelName": "CONTRAIL_EXTERNAL", + "modelVersion": "1" + }, + "cloudConfiguration": { + "lcpCloudRegionId": "RDM2WAGPLCP", + "tenantId": "7dd5365547234ee8937416c65507d266" + }, + "requestInfo": { + "source": "VID", + "callbackUrl": "", + "suppressRollback": true, + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "f70e927b-6087-4974-9ef8-c5e4d5847ca4", + "modelInfo": { + "modelType": "serviceT", + "modelId": "modelI", + "modelNameVersionId": "modelNameVersionI", + "modelName": "modleNam", + "modelVersion": "1" + } + } + } + ], + "requestParameters": { + "userParams": [] + } + }}""" + + String jsonIncomingRequest_MissingCloudRegion = + """{ "requestDetails": { + "modelInfo": { + "modelType": "networkTyp", + "modelId": "modelId", + "modelNameVersionId": "modelNameVersionId", + "modelName": "CONTRAIL_EXTERNAL", + "modelVersion": "1" + }, + "cloudConfiguration": { + "tenantId": "7dd5365547234ee8937416c65507d266" + }, + "requestInfo": { + "instanceName": "MNS-25180-L-01-dmz_direct_net_1", + "source": "VID", + "callbackUrl": "", + "suppressRollback": true, + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "f70e927b-6087-4974-9ef8-c5e4d5847ca4", + "modelInfo": { + "modelType": "serviceT", + "modelId": "modelI", + "modelNameVersionId": "modelNameVersionI", + "modelName": "modleNam", + "modelVersion": "1" + } + } + } + ], + "requestParameters": { + "userParams": [] + } + }}""" + + + + String expectedNetworkRequestMissingNetworkId = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + UPDATE + VID + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + + + + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + true + + + someValue1 + + +""" + + +String expectedNetworkRequestMissingCloudRegion = +""" + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + UPDATE + PORTAL + + + HSL_direct_net_2 + CONTRAIL_EXTERNAL + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + + e81d842d3e8b45c5a59f57cd76af3aaf + + + 1 + +""" + + // vnfRESTRequest + String networkRESTRequest = +""" + + + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + UPDATE + PORTAL + + + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + dvs-slcp3-01 + 3008 + + + 1 + 0 + + + + """ + + String networkInputsMissingName = + """ + + CONTRAIL_EXTERNAL + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + RDM2WAGPLCP + e81d842d3e8b45c5a59f57cd76af3aaf + """ + +String networkInputsMissingCloudRegion = +""" + HSL_direct_net_2 + CONTRAIL_EXTERNAL + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + + e81d842d3e8b45c5a59f57cd76af3aaf +""" + + String expectedUpdateNetworkInstanceInfraRequest = + """ + + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + UPDATE + PORTAL + + + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + dvs-slcp3-01 + 3008 + + + 1 + 0 + + +""" + + String expectedUpdateNetworkInstanceInfraRequest_Output = + """ + + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + UPDATE + PORTAL + + + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + + + MNS-25180-L-01-dmz_direct_net_1 + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + + + 1 + 0 + + +""" + + // expectedNetworkRequest + String expectedNetworkRequest = + """ + + UPDATE + VID + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + true + + + true + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + true + true + 10.10.125.1 + +""" + +String expectedNetworkInputs = +""" + + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + true +""" + + + String NetworkRequest_noPhysicalName = + """ + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + UPDATE + PORTAL + + + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + 3008 + + + + true + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + true + true + 10.10.125.1 + + +""" + + String vnfRequestFakeRegion = + """ + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + UPDATE + PORTAL + + + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MDTWNJ21 + 7dd5365547234ee8937416c65507d266 + + + 1 + 0 + +""" + + // expectedNetworkRequest + String expectedNetworkRequest_Outputs = + """ + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + UPDATE + PORTAL + + + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + + + MNS-25180-L-01-dmz_direct_net_1 + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + + + 1 + 0 + +""" + + + // expectedNetworkRequest + String networkInputs_404 = + """ + myOwn_Network + CONTRAIL_EXTERNAL + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + RDM2WAGPLCP + e81d842d3e8b45c5a59f57cd76af3aaf + """ + + String networkInputs = + """ + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + RDM2WAGPLCP + e81d842d3e8b45c5a59f57cd76af3aaf +""" + + String networkOutputs = + """ + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + """ + + String queryAAIResponse = + """ + + + + + + + + + + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + HSL_direct_net_2 + CONTRAIL_EXTERNAL + dmz_direct + contrail + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + pending-delete + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-delete + true + + + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ + + vpn-binding.vpn-id + 85f015d0-2e32-4c30-96d2-87a1a27f8017 + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ + + vpn-binding.vpn-id + c980a6ef-3b88-49f0-9751-dbad8608d0a6 + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ + + tenant.tenant-id + 7dd5365547234ee8937416c65507d266 + + + + + +""" + + String queryIdAIIResponse = + """ + + + + + + + + + + + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + dmz_direct + contrail + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + l3-version + pending-delete + ST_2Bindings_6006/55288ef0-595c-47d3-819e-cf93aaac6326 + networkName + false + true + false + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-delete + true + subnetName + + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-delete + true + subnetName + + + + + 414 + 4132176 + + + 415 + 4132176 + + + + inner + ctag-version + + + tenant + https://aai-ext1.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/897deadc2b954a6bac6d3c197fb3525e/ + + tenant.tenant-id + 897deadc2b954a6bac6d3c197fb3525e + + + tenant.tenant-name + MSOTest1 + + + + vpn-binding + https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/a290b841-f672-44dd-b9cd-6f8c20d7d8c8/ + + vpn-binding.vpn-id + a290b841-f672-44dd-b9cd-6f8c20d7d8c8 + + + vpn-binding.vpn-name + oam_protected_net_6_MTN5_msotest2 + + + + vpn-binding + https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/24a4b507-853a-4a38-99aa-05fcc54be24d/ + + vpn-binding.vpn-id + 24a4b507-853a-4a38-99aa-05fcc54be24d + + + vpn-binding.vpn-name + oam_protected_net_6_MTN5_msotest1 + + + + + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ + + vpn-binding.vpn-id + 85f015d0-2e32-4c30-96d2-87a1a27f8017 + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ + + vpn-binding.vpn-id + c980a6ef-3b88-49f0-9751-dbad8608d0a6 + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ + + tenant.tenant-id + 7dd5365547234ee8937416c65507d266 + + + + network-policy + https://aai-app-e2e.test.com:8443/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg + + network-policy.network-policy-id + cee6d136-e378-4678-a024-2cd15f0ee0cg + + + + route-table-reference + https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN1 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + + route-table-reference + https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN2 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + + + +""" + + String queryIdAIIResponseTestScenario01 = + """ + + 4da55fe4-7a9e-478c-a434-8a98d62265ab + GN_EVPN_direct_net_0_ST1 + CONTRAIL30_BASIC + GN_EVPN_direct + contrail + false + 9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + 1465398611 + pending-delete + networkName + false + true + false + + + cb1a7b47-5428-44c9-89c2-8b17541c3228 + 108.239.40.1 + 108.239.40.0 + 28 + 4 + pending-delete + true + 108.239.40.0 + 108.239.40.0 + 1465398611 + subnetName + + + + e2cc7c14-90f0-4205-840d-b4e07f04e621 + 2606:ae00:2e01:604::1 + 2606:ae00:2e01:604:: + 64 + 6 + pending-delete + true + 2606:ae00:2e01:604:: + 2606:ae00:2e01:604:: + 1465398611 + subnetName + + + + + + 416 + 4132176 + + + + cloud-region + https://mtanjv9aaas03.aic.cip.com:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/ + + + cloud-region.cloud-region-id + AAIAIC25 + + + cloud-region.cloud-owner + att-aic + + + cloud-region.owner-defined-type + + + + + tenant + https://mtanjv9aaas03.aic.cip.com:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/4ae1d3446a4c48b2bec44b6cfba06d68/ + + tenant.tenant-id + 4ae1d3446a4c48b2bec44b6cfba06d68 + + + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + AAIAIC25 + + + tenant.tenant-name + Ruchira Contrail 3.0 test + + + + vpn-binding + https://mtanjv9aaas03.aic.cip.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ + + vpn-binding.vpn-id + 9a7b327d9-287aa00-82c4b0-100001 + + + vpn-binding.vpn-name + GN_EVPN_direct_net_0_ST1 + + + + route-table-reference + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + +""" + + String queryIdAIIResponseVpnNotPresent = + """ + + + + + + + + + + + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + dmz_direct + contrail + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + pending-delete + networkName + false + true + false + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-delete + true + subnetName + + + + + + +""" + + String queryNameAIIResponse = + """ + + + + + + + + + + + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + dmz_direct + contrail + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + pending-delete + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-delete + true + + + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ + + vpn-binding.vpn-id + 85f015d0-2e32-4c30-96d2-87a1a27f8017 + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ + + vpn-binding.vpn-id + c980a6ef-3b88-49f0-9751-dbad8608d0a6 + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ + + tenant.tenant-id + 7dd5365547234ee8937416c65507d266 + + + + + + """ + + String queryNameAIIResponseVpnNotPresent = + """ + + + + + + + + + + + + + + +""" + + String queryVpnBindingAAIResponse = + """ + + + + + + + + + + + + 9a7b327d9-287aa00-82c4b0-105757 + GN_EVPN_Test + 13979:105757 + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/689ec39e-c5fc-4462-8db2-4f760763ad28/ + + l3-network.network-id + 689ec39e-c5fc-4462-8db2-4f760763ad28 + + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/1a49396b-19b3-40a4-8792-aa2fbd0f0704/ + + l3-network.network-id + 1a49396b-19b3-40a4-8792-aa2fbd0f0704 + + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/774f3329-3c83-4771-86c7-9e6207cd50fd/ + + l3-network.network-id + 774f3329-3c83-4771-86c7-9e6207cd50fd + + + + + +""" + + String updateDBRequest_Active = + """ + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + BPMN + Network MNS-25180-L-01-dmz_direct_net_1 already exists. Silent success. + + COMPLETED + 100 + <network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id><network-name>MNS-25180-L-01-dmz_direct_net_1</network-names> + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + + +""" + + String updateDBRequest = + """ + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + BPMN + Network successfully updated. + + COMPLETED + 100 + <network-id></network-id><network-name></network-names> + + + +""" + + String updateDBRequestError = + """ + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + BPMN + Received error from SDN-C: No availability zone available + + FAILED + <network-id></network-id><network-name></network-names> + + + """ + + String updateDBRequestError01 = + """ + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + BPMN + Received error unexpectedly from SDN-C. + + FAILED + <network-id></network-id><network-name></network-names> + + + """ + + String updateDBRequest_Outputs = + """ + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + BPMN + Network successfully updated. + + COMPLETED + 100 + <network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id><network-name>MNS-25180-L-01-dmz_direct_net_1</network-names> + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + + +""" + + String updateNetworkRequest = + """ + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + ST_2Bindings_6006/55288ef0-595c-47d3-819e-cf93aaac6326 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + + CONTRAIL + + networkName + 414,415 + + + true + false + 13979:105757 + 13979:105757 + GN_EVPN_Test + refFQDN1 + refFQDN2 + + + + + + + 107.239.52.0/24 + true + 107.239.52.1 + 4 + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + subnetName + + + + + + + 107.239.52.0/24 + true + 107.239.52.1 + 4 + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + subnetName + + true + true + false + + true + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + true + true + 10.10.125.1 + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + + messageId_generated + +""" + + + String updateNetworkRequest_noPhysicalName = + """ + RDM2WAGPLCP + 7dd5365547234ee8937416c65507d266 + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + ST_2Bindings_6006/55288ef0-595c-47d3-819e-cf93aaac6326 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + + CONTRAIL + + networkName + 414,415 + + + true + false + 13979:105757 + 13979:105757 + GN_EVPN_Test + + + + + + + 107.239.52.0/24 + true + 107.239.52.1 + 4 + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + subnetName + + + + + + + 107.239.52.0/24 + true + 107.239.52.1 + 4 + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + subnetName + + true + true + false + + true + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + true + true + 10.10.125.1 + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + null + + messageId_generated + +""" + + String updateNetworkResponseREST = + """ + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + default-domain:MSOTest:GN_EVPN_direct_net_0_ST1 + + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 + + + + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + + CONTRAIL_EXTERNAL + true + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + + + + messageId_generated +""" + + String updateRollbackNetworkRequest = + """ + + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + + CONTRAIL_EXTERNAL + true + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + + + +""" + + String updateNetworkResponse = + """ + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + default-domain:MSOTest:GN_EVPN_direct_net_0_ST1 + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 + + + + RDM2WAGPLCP + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + + + true + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + CONTRAIL_EXTERNAL + false + c4f4e878-cde0-4b15-ae9a-bda857759cea + 7dd5365547234ee8937416c65507d266 + +""" + + String updateContrailAAIPayloadRequest = + """ + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + dmz_direct + contrail + c4f4e878-cde0-4b15-ae9a-bda857759cea + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + l3-version + active + ST_2Bindings_6006/55288ef0-595c-47d3-819e-cf93aaac6326 + default-domain:MSOTest:GN_EVPN_direct_net_0_ST1 + networkName + false + true + false + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 + 107.239.52.1 + 107.239.52.0 + 24 + 4 + active + true + subnetName + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 + 107.239.52.1 + 107.239.52.0 + 24 + 4 + active + true + subnetName + + + + 414 + + + 415 + + + + inner + ctag-version + + + tenant + https://aai-ext1.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/897deadc2b954a6bac6d3c197fb3525e/ + + tenant.tenant-id + 897deadc2b954a6bac6d3c197fb3525e + + + tenant.tenant-name + MSOTest1 + + + + vpn-binding + https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/a290b841-f672-44dd-b9cd-6f8c20d7d8c8/ + + vpn-binding.vpn-id + a290b841-f672-44dd-b9cd-6f8c20d7d8c8 + + + vpn-binding.vpn-name + oam_protected_net_6_MTN5_msotest2 + + + + vpn-binding + https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/24a4b507-853a-4a38-99aa-05fcc54be24d/ + + vpn-binding.vpn-id + 24a4b507-853a-4a38-99aa-05fcc54be24d + + + vpn-binding.vpn-name + oam_protected_net_6_MTN5_msotest1 + + + + + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ + + vpn-binding.vpn-id + 85f015d0-2e32-4c30-96d2-87a1a27f8017 + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ + + vpn-binding.vpn-id + c980a6ef-3b88-49f0-9751-dbad8608d0a6 + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ + + tenant.tenant-id + 7dd5365547234ee8937416c65507d266 + + + + network-policy + https://aai-app-e2e.test.com:8443/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg + + network-policy.network-policy-id + cee6d136-e378-4678-a024-2cd15f0ee0cg + + + + route-table-reference + https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN1 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + + route-table-reference + https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN2 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + +""" + + String updateContrailAAIResponse = + """ + + + + + + + + +""" + + String updateNetworkErrorResponse = + """ + 680bd458-5ec1-4a16-b77c-509022e53450INTERNAL + 400 Bad Request: The server could not comply with the request since it is either malformed or otherwise incorrect., error.type=StackValidationFailed, error.message=Property error: : resources.network.properties: : Unknown Property network_ipam_refs_data + true + """ + + + String networkException500 = + """soap:VersionMismatch"http://org.openecomp.mso/network", the namespace on the "updateNetworkContrail" element, is not a valid SOAP version.""" + + String aaiResponse = + """ + + + + + + + + + + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + HSL_direct_net_2 + CONTRAIL_BASIC + HSL_direct + contrail + 8bbd3edf-b835-4610-96a2-a5cafa029042 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + active + HSL_direct_net_2/57594a56-1c92-4a38-9caa-641c1fa3d4b6 + + + ea5f2a2c-604f-47ff-a9c5-253ee4f0ef0a + 5a77fdc2-7789-4649-a1b9-6eaf1db1813a + 172.16.34.1 + 172.16.34.0 + 28 + 4 + active + true + + + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v3/cloud-infrastructure/tenants/tenant/e81d842d3e8b45c5a59f57cd76af3aaf/ + + tenant.tenant-id + e81d842d3e8b45c5a59f57cd76af3aaf + + + + + + """ + + String changeAssignSDNCRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + changeassign + network-topology-operation + sdncCallback + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + NetworkActivateRequest + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + MSO_1610_dev + + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + CONTRAIL_EXTERNAL + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + +""" + +String assignResponse = +""" 006927ca-f5a3-47fd-880c-dfcbcd81a093 200 OK 200006927ca-f5a3-47fd-880c-dfcbcd81a093Ynotsurewecarea9a77d5a-123e-4ca2-9eb9-0b015d2ee0fbGN_EVPN_direct_net_0_ST_noGW8abc633a-810b-4ca5-8b3a-09511d13a2ce """ + + String sdncRollbackRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + rollback + network-topology-operation + sdncCallback + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + NetworkActivateRequest + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + MSO_1610_dev + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + +""" + + String sdncAdapterWorkflowResponse = + """ + + + 745b1b50-e39e-4685-9cc8-c71f0bde8bf0 + 200 + OK + + <output xmlns="org:openecomp:sdnctl:vnf"><svc-request-id>00703dc8-71ff-442d-a4a8-3adc5beef6a9</svc-request-id><response-code>200</response-code><ack-final-indicator>Y</ack-final-indicator><network-information><network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id></network-information><service-information><service-type>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-type><service-instance-id>MNS-25180-L-01-dmz_direct_net_1</service-instance-id><subscriber-name>notsurewecare</subscriber-name></service-information></output> + +""" + + + String sdncAdapterWorkflowResponse_Error = + """ + + + + 400 + Error writing to l3-netework + Y + c79240d8-34b5-4853-af69-2021928dba00 + + + +""" + + String expected_sdncAdapterWorkflowResponse_Error = + """ + + + + 400 + Error writing to l3-netework + Y + c79240d8-34b5-4853-af69-2021928dba00 + + + +""" + + String sdncAdapterWorkflowFormattedResponse = + """ + + + 00703dc8-71ff-442d-a4a8-3adc5beef6a9 + 200 + Y + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + notsurewecare + + + +""" + + String falloutHandlerRequest = + """ + + b69c9054-da09-4a2c-adf5-51042b62bfac + UPDATE + PORTAL + + + Received error from SDN-C: No availability zone available. + 5300 + + """ + + String falloutHandlerRequestObject = + """ + + b69c9054-da09-4a2c-adf5-51042b62bfac + UPDATE + VID + + + Received error from SDN-C: No availability zone available + 7000 + + """ + + + String falloutHandlerRequest_Scenario01 = + """ + + b69c9054-da09-4a2c-adf5-51042b62bfac + UPDATE + VID + + + Unexpected Response from AAI - 400 + 7020 + + """ + + String completeMsoProcessRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + UPDATE + PORTAL + + BPMN Network action: UPDATE +""" + +// - - - - - - - - + + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + + } + + public void initializeVariables (Execution mockExecution) { + + verify(mockExecution).setVariable("UPDNETI_messageId", "") + verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "") + verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "") + verify(mockExecution).setVariable("UPDNETI_UpdateNetworkInstanceInfraJsonRequest", "") + verify(mockExecution).setVariable("UPDNETI_networkRequest", "") + verify(mockExecution).setVariable("UPDNETI_networkInputs", "") + verify(mockExecution).setVariable("UPDNETI_networkOutputs", "") + verify(mockExecution).setVariable("UPDNETI_requestId", "") + verify(mockExecution).setVariable("UPDNETI_source", "") + verify(mockExecution).setVariable("UPDNETI_networkId", "") + + verify(mockExecution).setVariable("UPDNETI_CompleteMsoProcessRequest", "") + verify(mockExecution).setVariable("UPDNETI_FalloutHandlerRequest", "") + verify(mockExecution).setVariable("UPDNETI_isSilentSuccess", false) + verify(mockExecution).setVariable("UPDNETI_isPONR", false) + + // AAI query Cloud Region + verify(mockExecution).setVariable("UPDNETI_queryCloudRegionRequest","") + verify(mockExecution).setVariable("UPDNETI_queryCloudRegionReturnCode","") + verify(mockExecution).setVariable("UPDNETI_queryCloudRegionResponse","") + verify(mockExecution).setVariable("UPDNETI_cloudRegionPo","") + verify(mockExecution).setVariable("UPDNETI_cloudRegionSdnc","") + verify(mockExecution).setVariable("UPDNETI_isCloudRegionGood", false) + + // AAI query Id + verify(mockExecution).setVariable("UPDNETI_queryIdAAIRequest","") + verify(mockExecution).setVariable("UPDNETI_queryIdAAIResponse", "") + verify(mockExecution).setVariable("UPDNETI_aaiIdReturnCode", "") + + // AAI query vpn binding + verify(mockExecution).setVariable("UPDNETI_queryVpnBindingAAIRequest","") + verify(mockExecution).setVariable("UPDNETI_queryVpnBindingAAIResponse", "") + verify(mockExecution).setVariable("UPDNETI_aaiQqueryVpnBindingReturnCode", "") + verify(mockExecution).setVariable("UPDNETI_vpnBindings", null) + verify(mockExecution).setVariable("UPDNETI_vpnCount", 0) + verify(mockExecution).setVariable("UPDNETI_routeCollection", "") + + // AAI query network policy + verify(mockExecution).setVariable("UPDNETI_queryNetworkPolicyAAIRequest","") + verify(mockExecution).setVariable("UPDNETI_queryNetworkPolicyAAIResponse", "") + verify(mockExecution).setVariable("UPDNETI_aaiQqueryNetworkPolicyReturnCode", "") + verify(mockExecution).setVariable("UPDNETI_networkPolicyUriList", null) + verify(mockExecution).setVariable("UPDNETI_networkPolicyCount", 0) + verify(mockExecution).setVariable("UPDNETI_networkCollection", "") + + // AAI query route table reference + verify(mockExecution).setVariable("UPDNETI_queryNetworkTableRefAAIRequest","") + verify(mockExecution).setVariable("UPDNETI_queryNetworkTableRefAAIResponse", "") + verify(mockExecution).setVariable("UPDNETI_aaiQqueryNetworkTableRefReturnCode", "") + verify(mockExecution).setVariable("UPDNETI_networkTableRefUriList", null) + verify(mockExecution).setVariable("UPDNETI_networkTableRefCount", 0) + verify(mockExecution).setVariable("UPDNETI_tableRefCollection", "") + + + // AAI requery Id + verify(mockExecution).setVariable("UPDNETI_requeryIdAAIRequest","") + verify(mockExecution).setVariable("UPDNETI_requeryIdAAIResponse", "") + verify(mockExecution).setVariable("UPDNETI_aaiRequeryIdReturnCode", "") + + // AAI update contrail + verify(mockExecution).setVariable("UPDNETI_updateContrailAAIUrlRequest","") + verify(mockExecution).setVariable("UPDNETI_updateContrailAAIPayloadRequest","") + verify(mockExecution).setVariable("UPDNETI_updateContrailAAIResponse", "") + verify(mockExecution).setVariable("UPDNETI_aaiUpdateContrailReturnCode", "") + + verify(mockExecution).setVariable("UPDNETI_updateNetworkRequest", "") + verify(mockExecution).setVariable("UPDNETI_updateNetworkResponse", "") + verify(mockExecution).setVariable("UPDNETI_rollbackNetworkRequest", "") + verify(mockExecution).setVariable("UPDNETI_rollbackNetworkResponse", "") + verify(mockExecution).setVariable("UPDNETI_networkReturnCode", "") + verify(mockExecution).setVariable("UPDNETI_rollbackNetworkReturnCode", "") + verify(mockExecution).setVariable("UPDNETI_isNetworkRollbackNeeded", false) + + verify(mockExecution).setVariable("UPDNETI_changeAssignSDNCRequest", "") + verify(mockExecution).setVariable("UPDNETI_changeAssignSDNCResponse", "") + verify(mockExecution).setVariable("UPDNETI_rollbackSDNCRequest", "") + verify(mockExecution).setVariable("UPDNETI_rollbackSDNCResponse", "") + verify(mockExecution).setVariable("UPDNETI_sdncReturnCode", "") + verify(mockExecution).setVariable("UPDNETI_rollbackSDNCReturnCode", "") + verify(mockExecution).setVariable("UPDNETI_isSdncRollbackNeeded", false) + verify(mockExecution).setVariable("UPDNETI_sdncResponseSuccess", false) + + verify(mockExecution).setVariable("UPDNETI_updateDBRequest", "") + verify(mockExecution).setVariable("UPDNETI_updateDBResponse", "") + verify(mockExecution).setVariable("UPDNETI_dbReturnCode", "") + + verify(mockExecution).setVariable("UPDNETI_isVnfBindingPresent", false) + verify(mockExecution).setVariable("UPDNETI_Success", false) + verify(mockExecution).setVariable("UPDNETI_serviceInstanceId", "") + verify(mockExecution).setVariable("GENGS_type", "service-instance") // Setting for Generic Sub Flow use + + + } + + @Test + //@Ignore + public void preProcessRequest_NetworkRequest() { + + println "************ preProcessRequest_Payload ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("isBaseVfModule")).thenReturn(true) + when(mockExecution.getVariable("recipeTimeout")).thenReturn(0) + when(mockExecution.getVariable("requestAction")).thenReturn("UPDATE") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("vnfId")).thenReturn("") + when(mockExecution.getVariable("volumeGroupId")).thenReturn("") + when(mockExecution.getVariable("networkId")).thenReturn("49c86598-f766-46f8-84f8-8d1c1b10f9b4") + when(mockExecution.getVariable("serviceType")).thenReturn("MOG") + when(mockExecution.getVariable("networkType")).thenReturn("modelName") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest) + + when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.preProcessRequest(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", "UPDNETI_") + + //verify variable initialization + initializeVariables(mockExecution) + + // Authentications + verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") + verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") + + verify(mockExecution).setVariable("UPDNETI_UpdateNetworkInstanceInfraJsonRequest", jsonIncomingRequest) + //verify(mockExecution).setVariable("UPDNETI_networkRequest", expectedNetworkRequest) + //verify(mockExecution).setVariable("UPDNETI_networkInputs", expectedNetworkInputs) + //verify(mockExecution, atLeast(3)).setVariable("UPDNETI_networkOutputs", "") + + //verify(mockExecution).setVariable("UPDNETI_requestId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + //verify(mockExecution).setVariable("UPDNETI_source", "VID") + //verify(mockExecution).setVariable("UPDNETI_messageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + //verify(mockExecution, atLeast(1)).setVariable("GENGS_type", "service-instance") + + } + + + @Test + //@Ignore + public void preProcessRequest_MissingNetworkId() { + + println "************ preProcessRequest_MissingName() ************* " + + WorkflowException missingNameWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 2500, "Variable 'network-id' value/element is missing.") + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("isBaseVfModule")).thenReturn(true) + when(mockExecution.getVariable("recipeTimeout")).thenReturn(0) + when(mockExecution.getVariable("requestAction")).thenReturn("UPDATE") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("vnfId")).thenReturn("") + when(mockExecution.getVariable("volumeGroupId")).thenReturn("") + //when(mockExecution.getVariable("networkId")).thenReturn("49c86598-f766-46f8-84f8-8d1c1b10f9b4") + when(mockExecution.getVariable("serviceType")).thenReturn("MOG") + when(mockExecution.getVariable("networkType")).thenReturn("modelName") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest) + + when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + try { + UpdateNetworkInstanceInfra.preProcessRequest(mockExecution) + } catch (Exception ex) { + println " Test End - Handle catch-throw BpmnError()! " + } + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution, atLeast(1)).getVariable("isDebugLogEnabled") + verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") + + //verify variable initialization + initializeVariables(mockExecution) + + // Authentications + verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") + verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") + + verify(mockExecution).setVariable("UPDNETI_UpdateNetworkInstanceInfraJsonRequest", jsonIncomingRequest) + //verify(mockExecution, atLeast(1)).setVariable("UPDNETI_networkOutputs", networkOutputs) + //verify(mockExecution).setVariable("UPDNETI_networkRequest", expectedNetworkRequestMissingNetworkId) + //verify(mockExecution).setVariable("UPDNETI_networkInputs", expectedNetworkInputs) + + //verify(mockExecution).setVariable("UPDNETI_requestId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + //verify(mockExecution).setVariable("UPDNETI_source", "VID") + //verify(mockExecution).setVariable("UPDNETI_messageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + + verify(mockExecution).setVariable(eq("WorkflowException"), refEq(missingNameWorkflowException)) + + } + + @Test + //@Ignore + public void preProcessRequest_MissingCloudRegion() { + + println "************ preProcessRequest_MissingCloudRegion() ************* " + + WorkflowException missingCloudRegionWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 2500, "requestDetails has missing 'aic-cloud-region' value/element.") + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("isBaseVfModule")).thenReturn(true) + when(mockExecution.getVariable("recipeTimeout")).thenReturn(0) + when(mockExecution.getVariable("requestAction")).thenReturn("UPDATE") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("vnfId")).thenReturn("") + when(mockExecution.getVariable("volumeGroupId")).thenReturn("") + when(mockExecution.getVariable("networkId")).thenReturn("networkId") + when(mockExecution.getVariable("serviceType")).thenReturn("MOG") + when(mockExecution.getVariable("networkType")).thenReturn("modelName") + + when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest_MissingCloudRegion) + when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") + + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + try { + UpdateNetworkInstanceInfra.preProcessRequest(mockExecution) + } catch (Exception ex) { + println " Test End - Handle catch-throw BpmnError()! " + } + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution, atLeast(1)).getVariable("isDebugLogEnabled") + verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") + + //verify variable initialization + initializeVariables(mockExecution) + + verify(mockExecution).setVariable("UPDNETI_messageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + // Authentications + verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") + verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") + + verify(mockExecution).setVariable("UPDNETI_UpdateNetworkInstanceInfraJsonRequest", jsonIncomingRequest_MissingCloudRegion) + //verify(mockExecution).setVariable("UPDNETI_networkRequest", "") + //verify(mockExecution).setVariable("UPDNETI_networkInputs", "") + //verify(mockExecution, atLeast(1)).setVariable("UPDNETI_networkOutputs", "") + + //verify(mockExecution).setVariable("UPDNETI_requestId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + //verify(mockExecution).setVariable("UPDNETI_source", "VID") + + verify(mockExecution).setVariable(eq("WorkflowException"), refEq(missingCloudRegionWorkflowException)) + + } + + @Test + //@Ignore + public void sendSyncResponse() { + + println "************ sendSyncResponse ************* " + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("isAsyncProcess")).thenReturn(true) + when(mockExecution.getVariable("mso-request-id")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + //when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.sendSyncResponse(mockExecution) + + verify(mockExecution).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UpdateNetworkInstanceInfraResponseCode", "202") + + + } + + @Test + //@Ignore + public void sendSyncError() { + + println "************ sendSyncError ************* " + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("isAsyncProcess")).thenReturn(true) + when(mockExecution.getVariable("mso-request-id")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + //when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.sendSyncError(mockExecution) + + verify(mockExecution).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UpdateNetworkInstanceInfraResponseCode", "500") + + } + + + @Test + //@Ignore + public void prepareDBRequest() { + + println "************ prepareDBRequest ************* " + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("UPDNETI_networkOutputs")).thenReturn("") + when(mockExecution.getVariable("UPDNETI_requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("UPDNETI_orchestrationStatus")).thenReturn("") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.prepareDBRequest(mockExecution) + + verify(mockExecution).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UPDNETI_updateDBRequest", updateDBRequest) + + } + + @Test + //@Ignore + public void prepareDBRequestErro_ExceptionObject() { + + println "************ prepareDBRequest ************* " + + WorkflowException sndcWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 500, "Received error from SDN-C: No availability zone available") + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("UPDNETI_networkOutputs")).thenReturn("") + when(mockExecution.getVariable("UPDNETI_requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("UPDNETI_networkOutputs")).thenReturn("") + when(mockExecution.getVariable("UPDNETI_orchestrationStatus")).thenReturn("") + when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowException) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.prepareDBRequestError(mockExecution) + + verify(mockExecution).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UPDNETI_updateDBRequest", updateDBRequestError) + + } + + @Test + //@Ignore + public void prepareDBRequest_Outputs() { + + println "************ prepareDBRequest ************* " + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("UPDNETI_networkOutputs")).thenReturn(networkOutputs) + when(mockExecution.getVariable("UPDNETI_requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("UPDNETI_orchestrationStatus")).thenReturn("") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.prepareDBRequest(mockExecution) + + verify(mockExecution).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UPDNETI_updateDBRequest", updateDBRequest_Outputs) + + } + + @Test + //@Ignore + public void prepareUpdateNetworkRequest() { + + println "************ prepareNetworkRequest ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("UPDNETI_networkRequest")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) + when(mockExecution.getVariable("UPDNETI_cloudRegionPo")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("messageId_generated") + when(mockExecution.getVariable("UPDNETI_source")).thenReturn("VID") + //when(mockExecution.getVariable("UPDNETI_queryVpnBindingAAIResponse")).thenReturn(queryVpnBindingAAIResponse) + when(mockExecution.getVariable("UPDNETI_routeCollection")).thenReturn("13979:10575713979:105757") + when(mockExecution.getVariable("UPDNETI_networkCollection")).thenReturn("GN_EVPN_Test") + when(mockExecution.getVariable("UPDNETI_tableRefCollection")).thenReturn("refFQDN1refFQDN2") + when(mockExecution.getVariable("UPDNETI_requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + //when(mockExecution.getVariable("URN_?????")).thenReturn("") // notificationUrl, //TODO - is this coming from URN? What variable/value to use? + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("UPDNETI_rollbackEnabled")).thenReturn("true") + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.prepareUpdateNetworkRequest(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + // verify set prefix = "UPDNETI_" + verify(mockExecution).setVariable("prefix", "UPDNETI_") + + verify(mockExecution).setVariable("UPDNETI_updateNetworkRequest", updateNetworkRequest) + + } + + + @Test + //@Ignore + public void prepareUpdateNetworkRequest_NoPhysicalname() { + + println "************ prepareNetworkRequest ************* " + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("UPDNETI_networkRequest")).thenReturn(NetworkRequest_noPhysicalName) + when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) + when(mockExecution.getVariable("UPDNETI_cloudRegionPo")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("messageId_generated") + when(mockExecution.getVariable("UPDNETI_source")).thenReturn("VID") + //when(mockExecution.getVariable("UPDNETI_queryVpnBindingAAIResponse")).thenReturn(queryVpnBindingAAIResponse) + when(mockExecution.getVariable("UPDNETI_routeCollection")).thenReturn("13979:10575713979:105757") + when(mockExecution.getVariable("UPDNETI_networkCollection")).thenReturn("GN_EVPN_Test") + when(mockExecution.getVariable("UPDNETI_tableRefCollection")).thenReturn("") + when(mockExecution.getVariable("UPDNETI_requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + //when(mockExecution.getVariable("URN_?????")).thenReturn("") // notificationUrl, //TODO - is this coming from URN? What variable/value to use? + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("UPDNETI_rollbackEnabled")).thenReturn("true") + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.prepareUpdateNetworkRequest(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + // verify set prefix = "UPDNETI_" + verify(mockExecution).setVariable("prefix", "UPDNETI_") + + verify(mockExecution).setVariable("UPDNETI_updateNetworkRequest", updateNetworkRequest_noPhysicalName) + + } + + @Test + //@Ignore + public void prepareSDNCRequest() { + + println "************ prepareSDNCRequest ************* " + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("UPDNETI_networkRequest")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable("UPDNETI_cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable("UPDNETI_serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("openecomp-mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("http://localhost:28090/SDNCAdapterCallback") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("GENGSI_siResourceLink")).thenReturn("https://aai-int1.test.com:8443/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/6d4eb22a-82f1-4257-9f80-4176262cfe69/") + + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.prepareSDNCRequest(mockExecution) + + // verify set prefix = "UPDNETI_" + verify(mockExecution).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UPDNETI_changeAssignSDNCRequest", changeAssignSDNCRequest) + + } + + @Test + //@Ignore + public void prepareSDNCRollbackRequest() { + + println "************ prepareSDNCRollbackRequest ************* " + + + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("UPDNETI_networkRequest")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable("UPDNETI_cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable("UPDNETI_serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("UPDNETI_changeAssignSDNCResponse")).thenReturn(assignResponse) + when(mockExecution.getVariable("openecomp-mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("http://localhost:28090/SDNCAdapterCallback") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("GENGSI_siResourceLink")).thenReturn("https://aai-int1.test.com:8443/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/6d4eb22a-82f1-4257-9f80-4176262cfe69/") + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.prepareSDNCRollbackRequest(mockExecution) + + // verify set prefix = "UPDNETI_" + verify(mockExecution).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UPDNETI_rollbackSDNCRequest", sdncRollbackRequest) + + } + + @Test + //@Ignore + public void callRESTQueryAAINetworkId_200() { + + println "************ callRESTQueryAAINetworkId ************* " + + WireMock.reset(); + + MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("UPDNETI_networkRequest")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.callRESTQueryAAINetworkId(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UPDNETI_queryIdAAIRequest", "http://localhost:28090/aai/v8/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4") + verify(mockExecution).setVariable("UPDNETI_aaiIdReturnCode", "200") + + } + + @Test + //@Ignore + public void callRESTQueryAAICloudRegion30_200() { + + println "************ callRESTQueryAAICloudRegion30_200 ************* " + + WireMock.reset(); + MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion30_AAIResponse_Success.xml") + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") + when(mockExecution.getVariable("UPDNETI_networkInputs")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.callRESTQueryAAICloudRegion(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UPDNETI_queryCloudRegionRequest", "http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/RDM2WAGPLCP") + verify(mockExecution, atLeast(2)).setVariable("UPDNETI_queryCloudRegionReturnCode", "200") + verify(mockExecution).setVariable("UPDNETI_isCloudRegionGood", true) + + } + + @Test + //@Ignore + public void callRESTQueryAAICloudRegion25_200() { + + println "************ callRESTQueryAAICloudRegion25_200 ************* " + + WireMock.reset(); + MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml") + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") + when(mockExecution.getVariable("UPDNETI_networkInputs")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.callRESTQueryAAICloudRegion(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UPDNETI_queryCloudRegionRequest", "http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/RDM2WAGPLCP") + verify(mockExecution, atLeast(2)).setVariable("UPDNETI_queryCloudRegionReturnCode", "200") + verify(mockExecution).setVariable("UPDNETI_isCloudRegionGood", true) + + } + + @Test + //@Ignore + public void callRESTQueryAAICloudRegion_NotFound() { + + println "************ callRESTQueryAAICloudRegionFake ************* " + + WireMock.reset(); + MockGetCloudRegion("MDTWNJ21", 404, "") + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") + when(mockExecution.getVariable("UPDNETI_networkInputs")).thenReturn(vnfRequestFakeRegion) + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.callRESTQueryAAICloudRegion(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UPDNETI_queryCloudRegionRequest", "http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/MDTWNJ21") + verify(mockExecution, atLeast(1)).setVariable("UPDNETI_queryCloudRegionReturnCode", "404") + verify(mockExecution).setVariable("UPDNETI_cloudRegionPo", "MDTWNJ21") + verify(mockExecution).setVariable("UPDNETI_cloudRegionSdnc", "AAIAIC25") + verify(mockExecution).setVariable("UPDNETI_isCloudRegionGood", true) + + } + + @Test + //@Ignore + public void callRESTQueryAAINetworkVpnBinding_200() { + + println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " + + WireMock.reset(); + 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); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) // v6 + when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") +// when(mockExecution.getVariable("URN_mso_workflow_UpdateNetworkInstanceInfra_aai_network_vpn-binding_uri")).thenReturn("") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.callRESTQueryAAINetworkVpnBinding(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UPDNETI_vpnCount", 2) + verify(mockExecution).setVariable("UPDNETI_vpnBindings", ['/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/', '/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/']) + // the last vpnBinding value is saved. + verify(mockExecution).setVariable("UPDNETI_queryVpnBindingAAIRequest", "http://localhost:28090/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017") + verify(mockExecution, atLeast(2)).setVariable("UPDNETI_aaiQqueryVpnBindingReturnCode", "200") + + } + + @Test + //@Ignore + public void callRESTQueryAAINetworkVpnBinding_TestScenario01_200() { + + println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " + + WireMock.reset(); + MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200) + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponseTestScenario01) + when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") +// when(mockExecution.getVariable("URN_mso_workflow_UpdateNetworkInstanceInfra_aai_network_vpn-binding_uri")).thenReturn("") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.callRESTQueryAAINetworkVpnBinding(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UPDNETI_vpnCount", 1) + verify(mockExecution).setVariable("UPDNETI_vpnBindings", ['/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/']) + // the last vpnBinding value is saved. + verify(mockExecution).setVariable("UPDNETI_queryVpnBindingAAIRequest", "http://localhost:28090/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017") + verify(mockExecution).setVariable("UPDNETI_aaiQqueryVpnBindingReturnCode", "200") + + } + + @Test + //@Ignore + public void callRESTQueryAAINetworkVpnBinding_200_URN_Uri() { + + println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " + + WireMock.reset(); + 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); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) + when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.callRESTQueryAAINetworkVpnBinding(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UPDNETI_vpnCount", 2) + verify(mockExecution).setVariable("UPDNETI_vpnBindings", ['/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/', '/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/']) + // the last vpnBinding value is saved. + verify(mockExecution).setVariable("UPDNETI_queryVpnBindingAAIRequest", "http://localhost:28090/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017") + verify(mockExecution, atLeast(2)).setVariable("UPDNETI_aaiQqueryVpnBindingReturnCode", "200") + + } + + @Test + //@Ignore + public void callRESTQueryAAINetworkVpnBinding_NotPresent() { + + println "************ callRESTQueryAAINetworkVpnBinding_NotPresent ************* " + + WireMock.reset(); + MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200) + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + + when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponseVpnNotPresent) + when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.callRESTQueryAAINetworkVpnBinding(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UPDNETI_aaiQqueryVpnBindingReturnCode", "200") + verify(mockExecution).setVariable("UPDNETI_vpnCount", 0) + verify(mockExecution).setVariable("UPDNETI_queryVpnBindingAAIResponse", aaiVpnResponseStub) + + } + + @Test + //@Ignore + public void callRESTQueryAAINetworkTableRef_200() { + + println "************ callRESTQueryAAINetworkTableRef_200 ************* " + + WireMock.reset(); + MockGetNetworkRouteTable("refFQDN1", "CreateNetworkV2/createNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200) + MockGetNetworkRouteTable("refFQDN2", "CreateNetworkV2/createNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200) + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) + when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_route_table_reference_uri")).thenReturn("/aai/v8/network/route-table-references/route-table-reference") +// when(mockExecution.getVariable("URN_mso_workflow_CreateNetworkInstanceInfra_aai_network_table_reference_uri")).thenReturn("") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.callRESTQueryAAINetworkTableRef(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UPDNETI_networkTableRefCount", 2) + verify(mockExecution).setVariable("UPDNETI_networkTableRefUriList", ['/aai/v8/network/route-table-references/route-table-reference/refFQDN1','/aai/v8/network/route-table-references/route-table-reference/refFQDN2']) + // the last vpnBinding value is saved. + verify(mockExecution).setVariable("UPDNETI_queryNetworkTableRefAAIRequest", "http://localhost:28090/aai/v8/network/route-table-references/route-table-reference/refFQDN1") + verify(mockExecution, atLeast(2)).setVariable("UPDNETI_aaiQqueryNetworkTableRefReturnCode", "200") + + } + + @Test + //@Ignore + public void callRESTQueryAAINetworkPolicy_200() { + + println "************ callRESTQueryAAINetworkPolicy_200 ************* " + + WireMock.reset(); + MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200) + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) + when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_network_policy_uri")).thenReturn("/aai/v8/network/network-policies/network-policy") +// when(mockExecution.getVariable("URN_mso_workflow_UpdateNetworkInstanceInfra_aai_network_policy_uri")).thenReturn("") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.callRESTQueryAAINetworkPolicy(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UPDNETI_networkPolicyCount", 1) + verify(mockExecution).setVariable("UPDNETI_networkPolicyUriList", ['/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg']) + // the last vpnBinding value is saved. + verify(mockExecution).setVariable("UPDNETI_queryNetworkPolicyAAIRequest", "http://localhost:28090/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg") + verify(mockExecution).setVariable("UPDNETI_aaiQqueryNetworkPolicyReturnCode", "200") + + } + + + @Test + //@Ignore + public void callRESTReQueryAAINetworkId_200() { + + println "************ callRESTReQueryAAINetworkId ************* " + + WireMock.reset(); + MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200) + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("UPDNETI_changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowFormattedResponse) + when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.callRESTReQueryAAINetworkId(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UPDNETI_requeryIdAAIRequest", "http://localhost:28090/aai/v8/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4") + verify(mockExecution).setVariable("UPDNETI_aaiRequeryIdReturnCode", "200") + + } + + + @Test + //@Ignore + public void callRESTUpdateContrailAAINetworkREST_200() { + + println "************ callRESTUpdateContrailAAINetwork ************* " + + WireMock.reset(); + MockPutNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", 200, "UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml") + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("UPDNETI_changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowFormattedResponse) + when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) + when(mockExecution.getVariable("UPDNETI_updateNetworkResponse")).thenReturn(updateNetworkResponseREST) + when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + // preProcessRequest(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.callRESTUpdateContrailAAINetwork(mockExecution) + + // Capture the arguments to setVariable + ArgumentCaptor captor1 = ArgumentCaptor.forClass(String.class); + ArgumentCaptor captor2 = ArgumentCaptor.forClass(String.class); + + verify(mockExecution, times(6)).setVariable(captor1.capture(), captor2.capture()) + List arg2List = captor2.getAllValues() + String payloadResponseActual = arg2List.get(4) + + assertEquals(updateContrailAAIResponse.replaceAll("\\s+", ""), payloadResponseActual.replaceAll("\\s+", "")) + + verify(mockExecution).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UPDNETI_updateContrailAAIUrlRequest", "http://localhost:28090/aai/v8/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4") + verify(mockExecution).setVariable("UPDNETI_updateContrailAAIPayloadRequest", updateContrailAAIPayloadRequest) + verify(mockExecution).setVariable("UPDNETI_aaiUpdateContrailReturnCode", "200") + verify(mockExecution).setVariable("UPDNETI_isPONR", true) + + } + + + + @Test + //@Ignore + public void validateUpdateNetworkResponseREST() { + + println "************ validateNetworkResponse ************* " + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("UPDNETI_updateNetworkResponse")).thenReturn(updateNetworkResponseREST) + when(mockExecution.getVariable("UPDNETI_networkReturnCode")).thenReturn('200') + + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.validateUpdateNetworkResponse(mockExecution) + + //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() + //debugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UPDNETI_updateNetworkResponse", updateNetworkResponseREST) + verify(mockExecution).setVariable("UPDNETI_isNetworkRollbackNeeded", true) + verify(mockExecution).setVariable("UPDNETI_rollbackNetworkRequest", updateRollbackNetworkRequest) + + } + + @Test + //@Ignore + public void validateUpdateNetworkResponseREST_Error() { + + println "************ validateNetworkResponse ************* " + + WorkflowException workflowException = new WorkflowException("UpdateNetworkInstanceInfra", 2500, "Received error from Network Adapter: JBWEB000065: HTTP Status 500.") + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("UPDNETI_updateNetworkResponse")).thenReturn(networkException500) + when(mockExecution.getVariable("UPDNETI_networkReturnCode")).thenReturn('500') + + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + try { + UpdateNetworkInstanceInfra.validateUpdateNetworkResponse(mockExecution) + } catch (Exception ex) { + println " Test End - Handle catch-throw BpmnError()! " + } + + verify(mockExecution).setVariable("prefix", "UPDNETI_") + verify(mockExecution, atLeast(1)).setVariable("WorkflowException", refEq(workflowException, any(WorkflowException.class))) + + } + + @Test + //@Ignore + public void validateSDNCResponse() { + + println "************ validateSDNCResponse ************* " + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("UPDNETI_changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowResponse) + when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") + when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) + when(mockExecution.getVariable("UPDNETI_sdncReturnCode")).thenReturn("200") + when(mockExecution.getVariable("UPDNETI_isResponseGood")).thenReturn(true) + + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + try { + UpdateNetworkInstanceInfra.validateSDNCResponse(mockExecution) + verify(mockExecution).setVariable("UPDNETI_isSdncRollbackNeeded", true) + verify(mockExecution).setVariable("UPDNETI_rollbackSDNCRequest", "") + + } catch (Exception ex) { + println " Graceful Exit - " + ex.getMessage() + } + //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() + //debugger.printInvocations(mockExecution) + + //verify(mockExecution).setVariable("UPDNETI_isSdncRollbackNeeded", true) + + } + + @Test + //@Ignore + public void validateSDNCResponse_Error() { + + println "************ validateSDNCResponse ************* " + //ExecutionEntity mockExecution = mock(ExecutionEntity.class) + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("UPDNETI_changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowResponse_Error) + when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") + when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(false) + when(mockExecution.getVariable("UPDNETI_sdncReturnCode")).thenReturn("200") + when(mockExecution.getVariable("UPDNETI_isResponseGood")).thenReturn(true) + + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + try { + UpdateNetworkInstanceInfra.validateSDNCResponse(mockExecution) + } catch (Exception ex) { + println " Graceful Exit! - " + ex.getMessage() + } + //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() + //debugger.printInvocations(mockExecution) + + // verify set prefix = "UPDNETI_" + //verify(mockExecution).setVariable("UPDNETI_sdncResponseSuccess", false) + + } + + + + @Test + //@Ignore + public void postProcessResponse() { + + println "************ postProcessResponse ************* " + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("UPDNETI_source")).thenReturn("PORTAL") + when(mockExecution.getVariable("UPDNETI_requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("UPDNETI_dbReturnCode")).thenReturn("200") + + // postProcessResponse(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.postProcessResponse(mockExecution) + + // check the sequence of variable invocation + //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() + //preDebugger.printInvocations(mockExecution) + + verify(mockExecution).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UPDNETI_Success", true) + verify(mockExecution).setVariable("UPDNETI_CompleteMsoProcessRequest", completeMsoProcessRequest) + + } + + @Test + //@Ignore + public void validateRollbackResponses_Good() { + + WorkflowException workflowException = new WorkflowException("UpdateNetworkInstanceInfra", 2500, "AAI Update Contrail Failed. Error 404.") + WorkflowException expectedWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 2500, "AAI Update Contrail Failed. Error 404. + PO Network rollback is not supported for Update. Submit another Update to restore/rollback. + SNDC rollback completed.") + + println "************ validateRollbackResponses_Good() ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") + + when(mockExecution.getVariable("UPDNETI_isNetworkRollbackNeeded")).thenReturn(true) + when(mockExecution.getVariable("UPDNETI_rollbackNetworkReturnCode")).thenReturn("200") + when(mockExecution.getVariable("UPDNETI_rollbackNetworkResponse")).thenReturn("GoodResponse") + when(mockExecution.getVariable("UPDNETI_isSdncRollbackNeeded")).thenReturn(true) + when(mockExecution.getVariable("UPDNETI_rollbackSDNCReturnCode")).thenReturn("200") + when(mockExecution.getVariable("UPDNETI_rollbackSDNCResponse")).thenReturn("GoodResponse") + when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) + + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.validateRollbackResponses(mockExecution) + + // verify set prefix = "UPDNETI_" + verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("WorkflowException", refEq(expectedWorkflowException, any(WorkflowException.class))) + + } + + @Test + //@Ignore + public void validateRollbackResponses_Failed() { + + WorkflowException workflowException = new WorkflowException("UpdateNetworkInstanceInfra", 7020, "AAI Update Contrail Failed. Error 404.") + WorkflowException expectedWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 7020, "AAI Update Contrail Failed. Error 404. + PO Network rollback is not supported for Update. Submit another Update to restore/rollback. + SDNC rollback failed. ") + + println "************ validateRollbackResponses_Failed() ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") + + when(mockExecution.getVariable("UPDNETI_isNetworkRollbackNeeded")).thenReturn(true) + when(mockExecution.getVariable("UPDNETI_rollbackNetworkReturnCode")).thenReturn("404") + when(mockExecution.getVariable("UPDNETI_rollbackNetworkResponse")).thenReturn("BadResponse") + when(mockExecution.getVariable("UPDNETI_isSdncRollbackNeeded")).thenReturn(true) + when(mockExecution.getVariable("UPDNETI_rollbackSDNCReturnCode")).thenReturn("500") + when(mockExecution.getVariable("UPDNETI_rollbackSDNCResponse")).thenReturn("BadResponse") + when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) + + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.validateRollbackResponses(mockExecution) + + // verify set prefix = "UPDNETI_" + verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") + verify(mockExecution, atLeast(1)).setVariable("WorkflowException", refEq(expectedWorkflowException, any(WorkflowException.class))) + + } + + @Test + //@Ignore + public void validateRollbackResponses_NetworkFailed() { + + WorkflowException workflowException = new WorkflowException("UpdateNetworkInstanceInfra", 7020, "AAI Update Contrail Failed. Error 404.") + WorkflowException expectedWorkflowExceptionFailed = new WorkflowException("UpdateNetworkInstanceInfra", 7020, "AAI Update Contrail Failed. Error 404. + PO Network rollback is not supported for Update. Submit another Update to restore/rollback. + SNDC rollback completed.") + + println "************ validateRollbackResponses_NetworkFailed() ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") + + when(mockExecution.getVariable("UPDNETI_isNetworkRollbackNeeded")).thenReturn(true) + when(mockExecution.getVariable("UPDNETI_rollbackNetworkReturnCode")).thenReturn("404") + when(mockExecution.getVariable("UPDNETI_rollbackNetworkResponse")).thenReturn("BadResponse") + when(mockExecution.getVariable("UPDNETI_isSdncRollbackNeeded")).thenReturn(true) + when(mockExecution.getVariable("UPDNETI_rollbackSDNCReturnCode")).thenReturn("200") + when(mockExecution.getVariable("UPDNETI_rollbackSDNCResponse")).thenReturn("GoodResponse") + when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) + + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.validateRollbackResponses(mockExecution) + + // verify set prefix = "UPDNETI_" + verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") + verify(mockExecution, atLeast(1)).setVariable("WorkflowException", refEq(expectedWorkflowExceptionFailed , any(WorkflowException.class))) + + } + + @Test + //@Ignore + public void validateRollbackResponses_SdncFailed() { + + WorkflowException workflowException = new WorkflowException("UpdateNetworkInstanceInfra", 7020, "AAI Update Contrail Failed. Error 404.") + WorkflowException expectedWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 7020, "AAI Update Contrail Failed. Error 404. + PO Network rollback is not supported for Update. Submit another Update to restore/rollback. + SDNC rollback failed. ") + + println "************ validateRollbackResponses_SdncFailed() ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") + + when(mockExecution.getVariable("UPDNETI_isNetworkRollbackNeeded")).thenReturn(true) + when(mockExecution.getVariable("UPDNETI_rollbackNetworkReturnCode")).thenReturn("200") + when(mockExecution.getVariable("UPDNETI_rollbackNetworkResponse")).thenReturn("GoodResponse") + when(mockExecution.getVariable("UPDNETI_isSdncRollbackNeeded")).thenReturn(true) + when(mockExecution.getVariable("UPDNETI_rollbackSDNCReturnCode")).thenReturn("200") + when(mockExecution.getVariable("UPDNETI_rollbackSDNCResponse")).thenReturn("400") + when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) + + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.validateRollbackResponses(mockExecution) + + // verify set prefix = "UPDNETI_" + verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("WorkflowException", refEq(expectedWorkflowException , any(WorkflowException.class))) + + } + + @Test + //@Ignore + public void validateRollbackResponses_NoRollbacks() { + + WorkflowException workflowException = new WorkflowException("UpdateNetworkInstanceInfra", 2500, " AAI Update Contrail Failed. Error 404") + WorkflowException expectedWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 2500, " AAI Update Contrail Failed. Error 404") + + println "************ validateRollbackResponses_NoRollbacks() ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") + + when(mockExecution.getVariable("UPDNETI_isNetworkRollbackNeeded")).thenReturn(false) + when(mockExecution.getVariable("UPDNETI_rollbackNetworkReturnCode")).thenReturn("200") + when(mockExecution.getVariable("UPDNETI_rollbackNetworkResponse")).thenReturn("GoodResponse") + when(mockExecution.getVariable("UPDNETI_isSdncRollbackNeeded")).thenReturn(false) + when(mockExecution.getVariable("UPDNETI_rollbackSDNCReturnCode")).thenReturn("200") + when(mockExecution.getVariable("UPDNETI_rollbackSDNCResponse")).thenReturn("GoodResponse") + when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) + + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.validateRollbackResponses(mockExecution) + + // verify set prefix = "UPDNETI_" + verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") + //verify(mockExecution, atLeast(1)).setVariable("WorkflowException", any(expectedWorkflowException)) + verify(mockExecution, atLeast(1)).setVariable("WorkflowException", refEq(expectedWorkflowException, any(WorkflowException.class))) + + } + + + @Test + //@Ignore + public void buildErrorResponse() { + + println "************ buildErrorResponse ************* " + + + WorkflowException sndcWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 5300, "Received error from SDN-C: No availability zone available.") + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("UPDNETI_requestId")).thenReturn("b69c9054-da09-4a2c-adf5-51042b62bfac") + when(mockExecution.getVariable("UPDNETI_source")).thenReturn("PORTAL") + when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowException) + + // buildErrorResponse(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.buildErrorResponse(mockExecution) + + // verify set prefix = "UPDNETI_" + verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UPDNETI_Success", false) + verify(mockExecution).setVariable("UPDNETI_FalloutHandlerRequest", falloutHandlerRequest) + + //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() + //debugger.printInvocations(mockExecution) + + } + + @Test + //@Ignore + public void buildErrorResponse_WorkflowExceptionObject() { + + println "************ buildErrorResponse ************* " + + WorkflowException sndcWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 7000, "Received error from SDN-C: No availability zone available") + + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("UPDNETI_requestId")).thenReturn("b69c9054-da09-4a2c-adf5-51042b62bfac") + when(mockExecution.getVariable("UPDNETI_source")).thenReturn("VID") + when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowException) + + // buildErrorResponse(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.buildErrorResponse(mockExecution) + + // verify set prefix = "UPDNETI_" + verify(mockExecution).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UPDNETI_Success", false) + verify(mockExecution).setVariable("UPDNETI_FalloutHandlerRequest", falloutHandlerRequestObject) + + //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() + //debugger.printInvocations(mockExecution) + + } + + @Test + //@Ignore + public void buildErrorResponse_Scenario01() { + + WorkflowException aaiWorkflowException_Secnario01 = new WorkflowException("UpdateNetworkInstanceInfra", 7020, "Unexpected Response from AAI - 400") + + println "************ buildErrorResponse ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("UPDNETI_requestId")).thenReturn("b69c9054-da09-4a2c-adf5-51042b62bfac") + when(mockExecution.getVariable("UPDNETI_source")).thenReturn("VID") + when(mockExecution.getVariable("WorkflowException")).thenReturn(aaiWorkflowException_Secnario01) + when(mockExecution.getVariable("UPDNETI_dbReturnCode")).thenReturn("200") + when(mockExecution.getVariable("UPDNETI_updateDBResponse")).thenReturn("") + + when(mockExecution.getVariable("UPDNETI_aaiRequeryIdReturnCode")).thenReturn("400") + + // buildErrorResponse(Execution execution) + UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() + UpdateNetworkInstanceInfra.buildErrorResponse(mockExecution) + + // verify set prefix = "UPDNETI_" + verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") + verify(mockExecution).setVariable("UPDNETI_Success", false) + verify(mockExecution).setVariable("UPDNETI_FalloutHandlerRequest", falloutHandlerRequest_Scenario01) + + //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() + //debugger.printInvocations(mockExecution) + + } + + + private ExecutionEntity setupMock() { + + ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) + when(mockProcessDefinition.getKey()).thenReturn("UpdateNetworkInstanceInfra") + RepositoryService mockRepositoryService = mock(RepositoryService.class) + when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) + when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("UpdateNetworkInstanceInfra") + when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") + ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) + when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + + when(mockExecution.getId()).thenReturn("100") + when(mockExecution.getProcessDefinitionId()).thenReturn("UpdateNetworkInstanceInfra") + when(mockExecution.getProcessInstanceId()).thenReturn("UpdateNetworkInstanceInfra") + when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) + when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) + + return mockExecution + } + + +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy new file mode 100644 index 0000000000..2e9efad215 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy @@ -0,0 +1,93 @@ +/*- + * ============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.scripts; + +import static org.junit.Assert.* +import static org.mockito.Mockito.* + +import org.junit.Before +import org.junit.Ignore +import org.junit.Rule +import org.junit.runner.RunWith +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner + +import com.github.tomakehurst.wiremock.junit.WireMockRule + +@RunWith(MockitoJUnitRunner.class) +@Ignore // No Junits exists in this class to run +class UpdateVfModuleVolumeInfraV1Test { + + String xml = """ + + + tenant + https://aai-ext1.test.com:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mdt1/tenants/tenant/fba1bd1e195a404cacb9ce17a9b2b421/ + + tenant.tenant-id + fba1bd1e195a404cacb9ce17a9b2b421 + + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + mdt1 + + + tenant.tenant-name + ECOMP_MDT1 + + + + vf-module + https://aai-ext1.test.com:8443/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mdt1/tenants/tenant/fba1bd1e195a404cacb9ce17a9b2b421/ + + vf-module.vf-module-ids + fba1bd1e195a404cacb9ce17a9b2b421 + + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + mdt1 + + + vf-module.vf-module-name + ECOMP_MDT1 + + + +""" + + @Rule + public WireMockRule wireMockRule = new WireMockRule(28090); + + @Before + public void init() + { + MockitoAnnotations.initMocks(this) + + } +} -- cgit 1.2.3-korg