/*- * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= */ package org.onap.so.bpmn.infrastructure.scripts import static org.mockito.Mockito.* import static org.onap.so.bpmn.mock.StubResponseNetworkAdapter.MockNetworkAdapter; import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkByIdWithDepth; import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkCloudRegion; import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkCloudRegion_404; 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.delegate.DelegateExecution import org.junit.Before import org.junit.Ignore import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.mockito.MockitoAnnotations import org.mockito.runners.MockitoJUnitRunner import org.onap.so.bpmn.common.scripts.MsoUtils import org.onap.so.bpmn.core.WorkflowException import com.github.tomakehurst.wiremock.client.WireMock import com.github.tomakehurst.wiremock.junit.WireMockRule import org.apache.commons.lang3.* @RunWith(MockitoJUnitRunner.class) class DoDeleteNetworkInstanceTest { @Rule public WireMockRule wireMockRule = new WireMockRule(8090); def utils = new MsoUtils() String Prefix="DELNWKI_" String incomingJsonRequest = """{ "requestDetails": { "modelInfo": { "modelType": "network", "modelCustomizationId": "f21df226-8093-48c3-be7e-0408fcda0422", "modelName": "CONTRAIL_EXTERNAL", "modelVersion": "1.0" }, "cloudConfiguration": { "lcpCloudRegionId": "RDM2WAGPLCP", "tenantId": "7dd5365547234ee8937416c65507d266" }, "requestInfo": { "instanceName": "HSL_direct_net_2", "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 expectedDoDeleteNetworkInstanceRequest = """{ "requestDetails": { "modelInfo": { "modelType": "networkTyp", "modelId": "modelId", "modelNameVersionId": "modelNameVersionId", "modelName": "CONTRAIL_EXTERNAL", "modelVersion": "1" }, "cloudConfiguration": { "lcpCloudRegionId": "RDM2WAGPLCP", "tenantId": "7dd5365547234ee8937416c65507d266" }, "requestInfo": { "instanceName": "HSL_direct_net_2", "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": [] } }""" // expectedVnfRequest String expectedNetworkRequest = """ 88f65519-9a38-4c4b-8445-9eb4a5a5af56 DELETE VID f70e927b-6087-4974-9ef8-c5e4d5847ca4 bdc5efe8-404a-409b-85f6-0dcc9eebae30 HSL_direct_net_2 CONTRAIL_EXTERNAL f21df226-8093-48c3-be7e-0408fcda0422 RDM2WAGPLCP 7dd5365547234ee8937416c65507d266 a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb false 1610 """ String expectedVperNetworkRequest = """ 88f65519-9a38-4c4b-8445-9eb4a5a5af56 DELETE VID f70e927b-6087-4974-9ef8-c5e4d5847ca4 bdc5efe8-404a-409b-85f6-0dcc9eebae30 MNS-25180-L-01-dmz_direct_net_1 CONTRAIL_EXTERNAL MSO-dev-service-type globalId_45678905678 RDM2WAGPLCP 7dd5365547234ee8937416c65507d266 a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb false false CONTRAIL_EXTERNAL sn5256d1-5a33-55df-13ab-12abad84e111 sn5256d1-5a33-55df-13ab-12abad84e764 1 sn5256d1-5a33-55df-13ab-12abad84e222 1702 """ String expected_networkInput = """ bdc5efe8-404a-409b-85f6-0dcc9eebae30 HSL_direct_net_2 CONTRAIL_EXTERNAL f21df226-8093-48c3-be7e-0408fcda0422 RDM2WAGPLCP 7dd5365547234ee8937416c65507d266 a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb false 1610 """ String expectedVper_networkInput = """ bdc5efe8-404a-409b-85f6-0dcc9eebae30 MNS-25180-L-01-dmz_direct_net_1 CONTRAIL_EXTERNAL MSO-dev-service-type globalId_45678905678 RDM2WAGPLCP 7dd5365547234ee8937416c65507d266 a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb false false CONTRAIL_EXTERNAL sn5256d1-5a33-55df-13ab-12abad84e111 sn5256d1-5a33-55df-13ab-12abad84e764 1 sn5256d1-5a33-55df-13ab-12abad84e222 1702 """ // emptyRegionVnfRequest String emptyRegionVnfRequest = """ 88f65519-9a38-4c4b-8445-9eb4a5a5af56 DELETE PORTAL bdc5efe8-404a-409b-85f6-0dcc9eebae30 HSL_direct_net_2 CONTRAIL_BASIC a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb e81d842d3e8b45c5a59f57cd76af3aaf 0 """ String vnfRequestCloudRegionNotFound = """ 88f65519-9a38-4c4b-8445-9eb4a5a5af56 DELETE PORTAL bdc5efe8-404a-409b-85f6-0dcc9eebae30 HSL_direct_net_2 CONTRAIL_BASIC a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb MDTWNJ21 e81d842d3e8b45c5a59f57cd76af3aaf 0 """ String vnfPayload = """ 88f65519-9a38-4c4b-8445-9eb4a5a5af56 DELETE PORTAL bdc5efe8-404a-409b-85f6-0dcc9eebae30 HSL_direct_net_2 CONTRAIL_BASIC a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb RDM2WAGPLCP e81d842d3e8b45c5a59f57cd76af3aaf 0 """ String vnfPayload_MissingId = """ 88f65519-9a38-4c4b-8445-9eb4a5a5af56 DELETE PORTAL bdc5efe8-404a-409b-85f6-0dcc9eebae30 CONTRAIL_BASIC a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb RDM2WAGPLCP e81d842d3e8b45c5a59f57cd76af3aaf 0 """ String vnfRequestRESTPayload = """ 88f65519-9a38-4c4b-8445-9eb4a5a5af56 DELETE PORTAL bdc5efe8-404a-409b-85f6-0dcc9eebae30 HSL_direct_net_2 CONTRAIL_BASIC a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb RDM2WAGPLCP e81d842d3e8b45c5a59f57cd76af3aaf id name 0 """ String incomingRequestMissingCloudRegion = """{ "requestDetails": { "modelInfo": { "modelType": "network", "modelCustomizationId": "f21df226-8093-48c3-be7e-0408fcda0422", "modelName": "CONTRAIL_EXTERNAL", "modelVersion": "1.0" }, "cloudConfiguration": { "tenantId": "7dd5365547234ee8937416c65507d266" }, "requestInfo": { "instanceName": "HSL_direct_net_2", "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 expectedNetworkRequestMissingId = """ 88f65519-9a38-4c4b-8445-9eb4a5a5af56 DELETE VID f70e927b-6087-4974-9ef8-c5e4d5847ca4 HSL_direct_net_2 CONTRAIL_EXTERNAL f21df226-8093-48c3-be7e-0408fcda0422 RDM2WAGPLCP 7dd5365547234ee8937416c65507d266 a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb false 1610 """ String expectedNetworkRequestMissingCloudRegion = """ 88f65519-9a38-4c4b-8445-9eb4a5a5af56 DELETE VID f70e927b-6087-4974-9ef8-c5e4d5847ca4 bdc5efe8-404a-409b-85f6-0dcc9eebae30 HSL_direct_net_2 CONTRAIL_EXTERNAL f21df226-8093-48c3-be7e-0408fcda0422 null 7dd5365547234ee8937416c65507d266 a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb false 1610 """ // vnfRESTRequest String vnfRESTRequest = """ DELETE VID f70e927b-6087-4974-9ef8-c5e4d5847ca4 bdc5efe8-404a-409b-85f6-0dcc9eebae30 HSL_direct_net_2 CONTRAIL_EXTERNAL RDM2WAGPLCP 7dd5365547234ee8937416c65507d266 a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb true """ String networkInputs = """ bdc5efe8-404a-409b-85f6-0dcc9eebae30 HSL_direct_net_2 CONTRAIL_BASIC a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb RDM2WAGPLCP e81d842d3e8b45c5a59f57cd76af3aaf """ String networkInputsNoType = """ a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb RDM2WAGPLCP e81d842d3e8b45c5a59f57cd76af3aaf """ String networkInputsMissingId = """ HSL_direct_net_2 CONTRAIL_EXTERNAL f21df226-8093-48c3-be7e-0408fcda0422 RDM2WAGPLCP 7dd5365547234ee8937416c65507d266 a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb false 1610 """ String networkInputsMissingCloudRegion = """ bdc5efe8-404a-409b-85f6-0dcc9eebae30 HSL_direct_net_2 CONTRAIL_EXTERNAL f21df226-8093-48c3-be7e-0408fcda0422 null 7dd5365547234ee8937416c65507d266 a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb false 1610 """ String MissingIdFault = "Invalid value or missing network-id element" String MissingRegionFault = "Invalid value or missing 'aic-cloud-region' element" String invalidWorkflowException = """ Invalid value of network-id element 2500 """ String queryAAIResponse = """ 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 deleteNetworkRequest = """ RDM2WAGPLCP e81d842d3e8b45c5a59f57cd76af3aaf CONTRAIL_BASIC HSL_direct_net_2/57594a56-1c92-4a38-9caa-641c1fa3d4b6 88f65519-9a38-4c4b-8445-9eb4a5a5af56 0 """ String deleteNetworkRESTRequest = """ RDM2WAGPLCP e81d842d3e8b45c5a59f57cd76af3aaf bdc5efe8-404a-409b-85f6-0dcc9eebae30 HSL_direct_net_2/57594a56-1c92-4a38-9caa-641c1fa3d4b6 CONTRAIL_BASIC sn5256d1-5a33-55df-13ab-12abad84e222 true 88f65519-9a38-4c4b-8445-9eb4a5a5af56 f70e927b-6087-4974-9ef8-c5e4d5847ca4 messageId_value """ String deleteNetworkRESTRequestAlaCarte = """ RDM2WAGPLCP e81d842d3e8b45c5a59f57cd76af3aaf bdc5efe8-404a-409b-85f6-0dcc9eebae30 HSL_direct_net_2/57594a56-1c92-4a38-9caa-641c1fa3d4b6 CONTRAIL_BASIC f21df226-8093-48c3-be7e-0408fcda0422 true 88f65519-9a38-4c4b-8445-9eb4a5a5af56 f70e927b-6087-4974-9ef8-c5e4d5847ca4 messageId_value """ String deleteNetworkResponse_noRollback = """ true """ String deleteNetworkResponse = """ true 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 deleteRollbackNetworkRequest = """ 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 deleteNetworkResponseFalseCompletion = """ false """ String deleteNetworkErrorResponse = """ 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 deleteNetworkWorkflowException = """ Received error from Network Adapter: 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 7020 """ String aaiWorkflowException = """ Bpmn error encountered in DoDeleteNetworkInstance flow. Unexpected Response from AAI Adapter - org.apache.http.conn.HttpHostConnectException: Connect to localhost:8090 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect 2500 """ 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/v8/cloud-infrastructure/tenants/tenant/e81d842d3e8b45c5a59f57cd76af3aaf/ tenant.tenant-id e81d842d3e8b45c5a59f57cd76af3aaf cloud-region cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RDM2WAGPLCP/ cloud-region.cloud-owner CloudOwner cloud-region.cloud-region-id RDM2WAGPLCP """ String aaiResponseWithRelationship = """ 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/v8/cloud-infrastructure/tenants/tenant/e81d842d3e8b45c5a59f57cd76af3aaf/ tenant.tenant-id e81d842d3e8b45c5a59f57cd76af3aaf vf-module https://aai-app-e2e.ecomp.cci.com:8443/aai/v8/network/generic-vnfs/generic-vnf/105df7e5-0b3b-49f7-a837-4864b62827c4/vf-modules/vf-module/d9217058-95a0-49ee-b9a9-949259e89349/ generic-vnf.vnf-id 105df7e5-0b3b-49f7-a837-4864b62827c4 vf-module.vf-module-id d9217058-95a0-49ee-b9a9-949259e89349 generic-vnf https://aai-app-e2e.test.com:8443/aai/v8/network/generic-vnfs/generic-vnf/45f822d9-73ca-4255-9844-7cef401bbf47/ generic-vnf.vnf-id 45f822d9-73ca-4255-9844-7cef401bbf47 generic-vnf.vnf-name zrdm1scpx05 """ String deleteSDNCRequest = """ 88f65519-9a38-4c4b-8445-9eb4a5a5af56 f70e927b-6087-4974-9ef8-c5e4d5847ca4 delete network-topology-operation sdncCallback 88f65519-9a38-4c4b-8445-9eb4a5a5af56 DisconnectNetworkRequest VID a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb f70e927b-6087-4974-9ef8-c5e4d5847ca4 bdc5efe8-404a-409b-85f6-0dcc9eebae30 CONTRAIL_BASIC HSL_direct_net_2 7dd5365547234ee8937416c65507d266 RDM2WAGPLCP """ String deleteRpcSDNCRequest = """ 88f65519-9a38-4c4b-8445-9eb4a5a5af56 f70e927b-6087-4974-9ef8-c5e4d5847ca4 unassign network-topology-operation sdncCallback generic-resource 88f65519-9a38-4c4b-8445-9eb4a5a5af56 DeleteNetworkInstance VID a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb MSO-dev-service-type fcc85cb0-ad74-45d7-a5a1-17c8744fdb71 36a3a8ea-49a6-4ac8-b06c-89a54544b9b6 1.0 HNGW Protected OAM f70e927b-6087-4974-9ef8-c5e4d5847ca4 globalId_45678905678 networkId CONTRAIL_EXTERNAL sn5256d1-5a33-55df-13ab-12abad84e764 sn5256d1-5a33-55df-13ab-12abad84e222 sn5256d1-5a33-55df-13ab-12abad84e111 1 CONTRAIL_EXTERNAL MNS-25180-L-01-dmz_direct_net_1 7dd5365547234ee8937416c65507d266 RDM2WAGPLCP """ String sdncAdapaterDeactivateRollback = """ 88f65519-9a38-4c4b-8445-9eb4a5a5af56 f70e927b-6087-4974-9ef8-c5e4d5847ca4 activate network-topology-operation sdncCallback generic-resource 88f65519-9a38-4c4b-8445-9eb4a5a5af56 CreateNetworkInstance VID a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb MSO-dev-service-type fcc85cb0-ad74-45d7-a5a1-17c8744fdb71 36a3a8ea-49a6-4ac8-b06c-89a54544b9b6 1.0 HNGW Protected OAM f70e927b-6087-4974-9ef8-c5e4d5847ca4 globalId_45678905678 bdc5efe8-404a-409b-85f6-0dcc9eebae30 CONTRAIL_EXTERNAL sn5256d1-5a33-55df-13ab-12abad84e764 sn5256d1-5a33-55df-13ab-12abad84e222 sn5256d1-5a33-55df-13ab-12abad84e111 1 CONTRAIL_EXTERNAL MNS-25180-L-01-dmz_direct_net_1 7dd5365547234ee8937416c65507d266 RDM2WAGPLCP """ String sdncAdapterWorkflowResponse = """ 745b1b50-e39e-4685-9cc8-c71f0bde8bf0 200 OK <?xml version="1.0" encoding="UTF-8"?><output xmlns="com:att:sdnctl:vnf"><svc-request-id>19174929-3809-49ca-89eb-17f84a035389</svc-request-id><response-code>200</response-code><ack-final-indicator>Y</ack-final-indicator><network-information><network-id>bdc5efe8-404a-409b-85f6-0dcc9eebae30</network-id></network-information><service-information><service-type>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-type><service-instance-id>HSL_direct_net_2</service-instance-id><subscriber-name>notsurewecare</subscriber-name></service-information></output> """ String sdncAdapterWorkflowResponse_404 = """ <?xml version="1.0" encoding="UTF-8"?><output xmlns="com:att:sdnctl:vnf"><svc-request-id>00703dc8-71ff-442d-a4a8-3adc5beef6a9</svc-request-id><response-code>404</response-code><response-message>Service instance not found in config tree</response-message><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 expected_sdncAdapterWorkflowFormattedResponse_404 = """ 00703dc8-71ff-442d-a4a8-3adc5beef6a9 404 Service instance not found in config tree Y 49c86598-f766-46f8-84f8-8d1c1b10f9b4 a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb MNS-25180-L-01-dmz_direct_net_1 notsurewecare """ String sdncAdapterWorkflowFormattedResponse = """ 19174929-3809-49ca-89eb-17f84a035389 200 Y bdc5efe8-404a-409b-85f6-0dcc9eebae30 a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb HSL_direct_net_2 notsurewecare """ String sdncAdapterWorkflowFormattedResponse_404 = """ 00703dc8-71ff-442d-a4a8-3adc5beef6a9 404 Service instance not found in config tree Y 49c86598-f766-46f8-84f8-8d1c1b10f9b4 a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb MNS-25180-L-01-dmz_direct_net_1 notsurewecare """ String invalidRequest = "Invalid value of network-id element" String sndcWorkflowException = """ Received error from SDN-C: No availability zone available 5300 200 """ String sndcWorkflowErrorResponse = """ Received error from SDN-C: <?xml version="1.0" encoding="UTF-8"?><output xmlns="com:att:sdnctl:vnf"><svc-request-id>00703dc8-71ff-442d-a4a8-3adc5beef6a9</svc-request-id><response-code>404</response-code><response-message>Service instance not found in config tree</response-message><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> 5300 """ String unexpectedErrorEncountered = """ bpel error deleting network 5300 """ // expectedVnfRequest String inputViprSDC_NetworkRequest = """ 88f65519-9a38-4c4b-8445-9eb4a5a5af56 DELETE VID f70e927b-6087-4974-9ef8-c5e4d5847ca4 networkId MNS-25180-L-01-dmz_direct_net_1 CONTRAIL_EXTERNAL MSO-dev-service-type globalId_45678905678 RDM2WAGPLCP 7dd5365547234ee8937416c65507d266 a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb false false CONTRAIL_EXTERNAL sn5256d1-5a33-55df-13ab-12abad84e111 sn5256d1-5a33-55df-13ab-12abad84e764 1 sn5256d1-5a33-55df-13ab-12abad84e222 CONTRAIL_EXTERNAL HNGW Protected OAM 36a3a8ea-49a6-4ac8-b06c-89a54544b9b6 fcc85cb0-ad74-45d7-a5a1-17c8744fdb71 1.0 service 1702 """ // - - - - - - - - @Before public void init() { MockitoAnnotations.initMocks(this) } @Test //@Ignore public void preProcessRequest_Json() { 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("DELETE") when(mockExecution.getVariable("networkId")).thenReturn("bdc5efe8-404a-409b-85f6-0dcc9eebae30") 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("") when(mockExecution.getVariable("serviceType")).thenReturn("MOG") when(mockExecution.getVariable("networkType")).thenReturn("modelName") when(mockExecution.getVariable("bpmnRequest")).thenReturn(incomingJsonRequest) when(mockExecution.getVariable("disableRollback")).thenReturn(true) when(mockExecution.getVariable("testMessageId")).thenReturn("7df689f9-7b93-430b-9b9e-28140d70cc7ad") when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") when(mockExecution.getVariable("mso-service-instance-id")).thenReturn("FH/VLXM/003717//SW_INTERNET") when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("mso.rollback")).thenReturn("true") when(mockExecution.getVariable("sdncVersion")).thenReturn("1610") DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() DoDeleteNetworkInstance.preProcessRequest(mockExecution) // check the sequence of variable invocation //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() //preDebugger.printInvocations(mockExecution) // verify(mockExecution).getVariable("isDebugLogEnabled") verify(mockExecution).setVariable("prefix", Prefix) //verify variable initialization initializeVariables(mockExecution) verify(mockExecution).setVariable("action", "DELETE") verify(mockExecution).setVariable(Prefix + "networkRequest", expectedNetworkRequest) verify(mockExecution).setVariable(Prefix + "rollbackEnabled", false) verify(mockExecution).setVariable(Prefix + "networkInputs", expected_networkInput) verify(mockExecution).setVariable(Prefix + "messageId", "7df689f9-7b93-430b-9b9e-28140d70cc7ad") verify(mockExecution).setVariable(Prefix + "source", "VID") // Authentications verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") } @Test //@Ignore public void preProcessRequest_vPER() { def networkModelInfo = """{"modelUuid": "sn5256d1-5a33-55df-13ab-12abad84e111", "modelName": "CONTRAIL_EXTERNAL", "modelType": "CONTRAIL_EXTERNAL", "modelVersion": "1", "modelCustomizationUuid": "sn5256d1-5a33-55df-13ab-12abad84e222", "modelInvariantUuid": "sn5256d1-5a33-55df-13ab-12abad84e764" }""".trim() println "************ preProcessRequest_Payload ************* " ExecutionEntity mockExecution = setupMock() // Initialize prerequisite variables when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") // Inputs: when(mockExecution.getVariable("msoRequestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") when(mockExecution.getVariable("disableRollback")).thenReturn("true") when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") when(mockExecution.getVariable("networkId")).thenReturn("bdc5efe8-404a-409b-85f6-0dcc9eebae30") // optional when(mockExecution.getVariable("networkName")).thenReturn("MNS-25180-L-01-dmz_direct_net_1") // optional when(mockExecution.getVariable("productFamilyId")).thenReturn("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") when(mockExecution.getVariable("networkModelInfo")).thenReturn("CONTRAIL_EXTERNAL") when(mockExecution.getVariable("lcpCloudRegionId")).thenReturn("RDM2WAGPLCP") when(mockExecution.getVariable("tenantId")).thenReturn("7dd5365547234ee8937416c65507d266") when(mockExecution.getVariable("failIfExists")).thenReturn("false") when(mockExecution.getVariable("networkModelInfo")).thenReturn(networkModelInfo) when(mockExecution.getVariable("sdncVersion")).thenReturn("1702") when(mockExecution.getVariable("action")).thenReturn("DELETE") when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("MSO-dev-service-type") when(mockExecution.getVariable("globalSubscriberId")).thenReturn("globalId_45678905678") when(mockExecution.getVariable("testMessageId")).thenReturn("7df689f9-7b93-430b-9b9e-28140d70cc7ad") when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() DoDeleteNetworkInstance.preProcessRequest(mockExecution) // check the sequence of variable invocation //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() //preDebugger.printInvocations(mockExecution) // verify(mockExecution).getVariable("isDebugLogEnabled") verify(mockExecution).setVariable("prefix", Prefix) //verify variable initialization initializeVariables(mockExecution) verify(mockExecution).setVariable("action", "DELETE") verify(mockExecution).setVariable(Prefix + "networkRequest", expectedVperNetworkRequest) verify(mockExecution).setVariable(Prefix + "rollbackEnabled", false) verify(mockExecution).setVariable(Prefix + "networkInputs", expectedVper_networkInput) verify(mockExecution).setVariable(Prefix + "messageId", "7df689f9-7b93-430b-9b9e-28140d70cc7ad") verify(mockExecution).setVariable(Prefix + "source", "VID") // Authentications verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") } public void initializeVariables (DelegateExecution mockExecution) { verify(mockExecution).setVariable(Prefix + "networkRequest", "") verify(mockExecution).setVariable(Prefix + "isSilentSuccess", false) verify(mockExecution).setVariable(Prefix + "Success", false) verify(mockExecution).setVariable(Prefix + "requestId", "") verify(mockExecution).setVariable(Prefix + "source", "") verify(mockExecution).setVariable(Prefix + "lcpCloudRegion", "") verify(mockExecution).setVariable(Prefix + "networkInputs", "") verify(mockExecution).setVariable(Prefix + "tenantId", "") verify(mockExecution).setVariable(Prefix + "queryAAIRequest","") verify(mockExecution).setVariable(Prefix + "queryAAIResponse", "") verify(mockExecution).setVariable(Prefix + "aaiReturnCode", "") verify(mockExecution).setVariable(Prefix + "isAAIGood", false) verify(mockExecution).setVariable(Prefix + "isVfRelationshipExist", false) // AAI query Cloud Region verify(mockExecution).setVariable(Prefix + "queryCloudRegionRequest","") verify(mockExecution).setVariable(Prefix + "queryCloudRegionReturnCode","") verify(mockExecution).setVariable(Prefix + "queryCloudRegionResponse","") verify(mockExecution).setVariable(Prefix + "cloudRegionPo","") verify(mockExecution).setVariable(Prefix + "cloudRegionSdnc","") verify(mockExecution).setVariable(Prefix + "deleteNetworkRequest", "") verify(mockExecution).setVariable(Prefix + "deleteNetworkResponse", "") verify(mockExecution).setVariable(Prefix + "networkReturnCode", "") verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", "") verify(mockExecution).setVariable(Prefix + "deleteSDNCRequest", "") verify(mockExecution).setVariable(Prefix + "deleteSDNCResponse", "") verify(mockExecution).setVariable(Prefix + "sdncReturnCode", "") verify(mockExecution).setVariable(Prefix + "sdncResponseSuccess", false) verify(mockExecution).setVariable(Prefix + "deactivateSDNCRequest", "") verify(mockExecution).setVariable(Prefix + "deactivateSDNCResponse", "") verify(mockExecution).setVariable(Prefix + "deactivateSdncReturnCode", "") verify(mockExecution).setVariable(Prefix + "isSdncDeactivateRollbackNeeded", "") verify(mockExecution).setVariable(Prefix + "rollbackDeactivateSDNCRequest", "") verify(mockExecution).setVariable(Prefix + "isException", false) } @Test //@Ignore public void preProcessRequest_Json_MissingId() { println "************ preProcessRequest_MissingId() ************* " 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("DELETE") //when(mockExecution.getVariable("networkId")).thenReturn("") // missing Id 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("") when(mockExecution.getVariable("serviceType")).thenReturn("MOG") when(mockExecution.getVariable("networkType")).thenReturn("modelName") when(mockExecution.getVariable("bpmnRequest")).thenReturn(incomingJsonRequest) when(mockExecution.getVariable("disableRollback")).thenReturn(true) when(mockExecution.getVariable("testMessageId")).thenReturn("7df689f9-7b93-430b-9b9e-28140d70cc7ad") when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") when(mockExecution.getVariable("mso-service-instance-id")).thenReturn("FH/VLXM/003717//SW_INTERNET") when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("mso.rollback")).thenReturn("true") when(mockExecution.getVariable("sdncVersion")).thenReturn("1610") // preProcessRequest(DelegateExecution execution) DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() try { DoDeleteNetworkInstance.preProcessRequest(mockExecution) } catch (Exception ex) { println " Test End - Handle catch-throw BpmnError()! " } //verify(mockExecution).getVariable("isDebugLogEnabled") verify(mockExecution).setVariable("prefix", Prefix) //verify variable initialization initializeVariables(mockExecution) verify(mockExecution).setVariable("action", "DELETE") verify(mockExecution).setVariable(Prefix + "networkRequest", expectedNetworkRequestMissingId) verify(mockExecution).setVariable(Prefix + "rollbackEnabled", false) verify(mockExecution).setVariable(Prefix + "networkInputs", networkInputsMissingId) verify(mockExecution).setVariable(Prefix + "messageId", "7df689f9-7b93-430b-9b9e-28140d70cc7ad") verify(mockExecution).setVariable(Prefix + "source", "VID") } @Test //@Ignore public void preProcessRequest_Json_MissingCloudRegion() { def networkModelInfo = """{"modelVersionId": "sn5256d1-5a33-55df-13ab-12abad84e111", "modelName": "CONTRAIL_EXTERNAL", "modelType": "CONTRAIL_EXTERNAL", "modelVersion": "1", "modelCustomizationId": "sn5256d1-5a33-55df-13ab-12abad84e222", "modelInvariantId": "sn5256d1-5a33-55df-13ab-12abad84e764" }""".trim() println "************ preProcessRequest_MissingCloudRegion() ************* " ExecutionEntity mockExecution = setupMock() // Initialize prerequisite variables when(mockExecution.getVariable("networkModelInfo")).thenReturn(networkModelInfo) 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("DELETE") when(mockExecution.getVariable("networkId")).thenReturn("bdc5efe8-404a-409b-85f6-0dcc9eebae30") 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("") when(mockExecution.getVariable("serviceType")).thenReturn("MOG") when(mockExecution.getVariable("networkType")).thenReturn("modelName") when(mockExecution.getVariable("bpmnRequest")).thenReturn(incomingRequestMissingCloudRegion) when(mockExecution.getVariable("disableRollback")).thenReturn(true) when(mockExecution.getVariable("testMessageId")).thenReturn("7df689f9-7b93-430b-9b9e-28140d70cc7ad") when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") when(mockExecution.getVariable("mso-service-instance-id")).thenReturn("FH/VLXM/003717//SW_INTERNET") when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("mso.rollback")).thenReturn("true") when(mockExecution.getVariable("sdncVersion")).thenReturn("1610") // preProcessRequest(DelegateExecution execution) DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() DoDeleteNetworkInstance.preProcessRequest(mockExecution) //verify(mockExecution).getVariable("isDebugLogEnabled") verify(mockExecution).setVariable("prefix", Prefix) //verify variable initialization initializeVariables(mockExecution) verify(mockExecution).setVariable("action", "DELETE") verify(mockExecution).setVariable(Prefix + "networkRequest", expectedNetworkRequestMissingCloudRegion) verify(mockExecution).setVariable(Prefix + "rollbackEnabled", false) verify(mockExecution).setVariable(Prefix + "networkInputs", networkInputsMissingCloudRegion) verify(mockExecution).setVariable(Prefix + "messageId", "7df689f9-7b93-430b-9b9e-28140d70cc7ad") verify(mockExecution).setVariable(Prefix + "lcpCloudRegion", null) verify(mockExecution).setVariable("BasicAuthHeaderValuePO","Basic cGFzc3dvcmQ=") verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") } @Test //@Ignore public void prepareNetworkRequest() { println "************ prepareNetworkRequest ************* " ExecutionEntity mockExecution = setupMock() // Initialize prerequisite variables when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedVperNetworkRequest) when(mockExecution.getVariable(Prefix + "queryAAIResponse")).thenReturn(queryAAIResponse) when(mockExecution.getVariable(Prefix + "cloudRegionPo")).thenReturn("RDM2WAGPLCP") when(mockExecution.getVariable(Prefix + "tenantId")).thenReturn("e81d842d3e8b45c5a59f57cd76af3aaf") when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") when(mockExecution.getVariable("mso.adapters.network.rest.endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") when(mockExecution.getVariable("msoRequestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("messageId_value") //when(mockExecution.getVariable("URN_?????")).thenReturn("") // notificationUrl, //TODO - is this coming from URN? What variable/value to use? when(mockExecution.getVariable(Prefix + "rollbackEnabled")).thenReturn("true") when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() DoDeleteNetworkInstance.prepareNetworkRequest(mockExecution) verify(mockExecution).setVariable("prefix", Prefix) verify(mockExecution).setVariable("mso.adapters.network.rest.endpoint", "http://localhost:8090/networks/NetworkAdapter/bdc5efe8-404a-409b-85f6-0dcc9eebae30") //verify(mockExecution).setVariable(Prefix + "deleteNetworkRequest", deleteNetworkRequest) verify(mockExecution).setVariable(Prefix + "deleteNetworkRequest", deleteNetworkRESTRequest) } @Test //@Ignore public void prepareNetworkRequest_AlaCarte() { println "************ prepareNetworkRequest ************* " ExecutionEntity mockExecution = setupMock() // Initialize prerequisite variables when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) when(mockExecution.getVariable(Prefix + "queryAAIResponse")).thenReturn(queryAAIResponse) when(mockExecution.getVariable(Prefix + "cloudRegionPo")).thenReturn("RDM2WAGPLCP") when(mockExecution.getVariable(Prefix + "tenantId")).thenReturn("e81d842d3e8b45c5a59f57cd76af3aaf") when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") when(mockExecution.getVariable("mso.adapters.network.rest.endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") when(mockExecution.getVariable("msoRequestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("messageId_value") //when(mockExecution.getVariable("URN_?????")).thenReturn("") // notificationUrl, //TODO - is this coming from URN? What variable/value to use? when(mockExecution.getVariable(Prefix + "rollbackEnabled")).thenReturn("true") when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() DoDeleteNetworkInstance.prepareNetworkRequest(mockExecution) verify(mockExecution).setVariable("prefix", Prefix) verify(mockExecution).setVariable("mso.adapters.network.rest.endpoint", "http://localhost:8090/networks/NetworkAdapter/bdc5efe8-404a-409b-85f6-0dcc9eebae30") //verify(mockExecution).setVariable(Prefix + "deleteNetworkRequest", deleteNetworkRequest) verify(mockExecution).setVariable("mso-request-id", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") verify(mockExecution).setVariable(Prefix + "deleteNetworkRequest", deleteNetworkRESTRequestAlaCarte) } @Test //@Ignore public void sendRequestToVnfAdapter() { println "************ sendRequestToVnfAdapter ************* " WireMock.reset(); MockNetworkAdapter("bdc5efe8-404a-409b-85f6-0dcc9eebae30", 200, "deleteNetworkResponse_Success.xml"); ExecutionEntity mockExecution = setupMock() when(mockExecution.getVariable(Prefix + "deleteNetworkRequest")).thenReturn(deleteNetworkRESTRequest) when(mockExecution.getVariable("mso.adapters.network.rest.endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter/bdc5efe8-404a-409b-85f6-0dcc9eebae30") when(mockExecution.getVariable("BasicAuthHeaderValuePO")).thenReturn("3141634BF7E070AA289CF2892C986C0B") when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() DoDeleteNetworkInstance.sendRequestToVnfAdapter(mockExecution) verify(mockExecution).setVariable(Prefix + "networkReturnCode", 200) //verify(mockExecution).setVariable(Prefix + "deleteNetworkResponse", deleteNetworkResponse_noRollback) } @Test //@Ignore public void prepareSDNCRequest() { println "************ prepareSDNCRequest ************* " ExecutionEntity mockExecution = setupMock() // Initialize prerequisite variables when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") when(mockExecution.getVariable(Prefix + "queryAAIResponse")).thenReturn(aaiResponse) when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() DoDeleteNetworkInstance.prepareSDNCRequest(mockExecution) verify(mockExecution).setVariable("prefix", Prefix) verify(mockExecution).setVariable(Prefix + "deleteSDNCRequest", deleteSDNCRequest) } @Test //@Ignore public void prepareRpcSDNCRequest() { println "************ prepareRpcSDNCRequest ************* " ExecutionEntity mockExecution = setupMock() // Initialize prerequisite variables when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(inputViprSDC_NetworkRequest) when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") when(mockExecution.getVariable("msoRequestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") // test ONLY when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() DoDeleteNetworkInstance.prepareRpcSDNCRequest(mockExecution) verify(mockExecution).setVariable("prefix", Prefix) verify(mockExecution).setVariable(Prefix + "deleteSDNCRequest", deleteRpcSDNCRequest) } @Test //@Ignore public void prepareRpcSDNCActivateRollback() { println "************ prepareRpcSDNCActivateRollback ************* " ExecutionEntity mockExecution = mock(ExecutionEntity.class) // Initialize prerequisite variables when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(inputViprSDC_NetworkRequest) when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") when(mockExecution.getVariable(Prefix + "serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") when(mockExecution.getVariable(Prefix + "networkId")).thenReturn("8abc633a-810b-4ca5-8b3a-09511d13a2ce") when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") when(mockExecution.getVariable("msoRequestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") // test ONLY when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("GENGSI_siResourceLink")).thenReturn(null) when(mockExecution.getVariable(Prefix + "deactivateSDNCResponse")).thenReturn(sdncAdapterWorkflowFormattedResponse) // preProcessRequest(DelegateExecution execution) DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() DoDeleteNetworkInstance.prepareRpcSDNCDeactivateRollback(mockExecution) // verify set prefix = Prefix + "" verify(mockExecution).setVariable("prefix", Prefix) //verify(mockExecution).setVariable("mso-request-id", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") //verify(mockExecution).setVariable(Prefix + "requestId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") //verify(mockExecution).setVariable("mso-service-instance-id", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") verify(mockExecution).setVariable(Prefix + "rollbackDeactivateSDNCRequest", sdncAdapaterDeactivateRollback) } @Test //@Ignore public void callRESTQueryAAI_200() { println "************ callRESTQueryAAI ************* " WireMock.reset(); MockGetNetworkByIdWithDepth("bdc5efe8-404a-409b-85f6-0dcc9eebae30", "DeleteNetworkV2/deleteNetworkAAIResponse_Success.xml", "all"); ExecutionEntity mockExecution = setupMock() when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") when(mockExecution.getVariable("mso.workflow.default.aai.network.l3-network.uri")).thenReturn("") // old: when(mockExecution.getVariable("mso.workflow.DoDeleteNetworkInstance.aai.network.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") when(mockExecution.getVariable("mso.workflow.DoDeleteNetworkInstance.aai.l3-network.uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() DoDeleteNetworkInstance.callRESTQueryAAI(mockExecution) verify(mockExecution).setVariable("prefix", Prefix) verify(mockExecution).setVariable(Prefix + "queryAAIRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/bdc5efe8-404a-409b-85f6-0dcc9eebae30"+"?depth=all") verify(mockExecution).setVariable(Prefix + "aaiReturnCode", "200") //verify(mockExecution).setVariable(Prefix + "queryAAIResponse", aaiResponse) verify(mockExecution).setVariable(Prefix + "isAAIGood", true) verify(mockExecution).setVariable(Prefix + "isVfRelationshipExist", false) } @Test //@Ignore public void callRESTQueryAAI_withRelationship_200() { println "************ callRESTQueryAAI ************* " WireMock.reset(); MockGetNetworkByIdWithDepth("bdc5efe8-404a-409b-85f6-0dcc9eebae30", "DeleteNetworkV2/deleteNetworkAAIResponse_withRelationship_Success.xml", "all"); ExecutionEntity mockExecution = setupMock() when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") when(mockExecution.getVariable("mso.workflow.default.aai.network.l3-network.uri")).thenReturn("") // old: when(mockExecution.getVariable("mso.workflow.DoDeleteNetworkInstance.aai.network.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") when(mockExecution.getVariable("mso.workflow.DoDeleteNetworkInstance.aai.l3-network.uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() DoDeleteNetworkInstance.callRESTQueryAAI(mockExecution) verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) verify(mockExecution).setVariable(Prefix + "queryAAIRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/bdc5efe8-404a-409b-85f6-0dcc9eebae30"+"?depth=all") verify(mockExecution).setVariable(Prefix + "aaiReturnCode", "200") //verify(mockExecution).setVariable(Prefix + "queryAAIResponse", aaiResponseWithRelationship) verify(mockExecution).setVariable(Prefix + "isAAIGood", true) verify(mockExecution).setVariable(Prefix + "isVfRelationshipExist", true) } @Test //@Ignore public void callRESTQueryAAI_200_DefaultUri() { println "************ callRESTQueryAAI ************* " WireMock.reset(); MockGetNetworkByIdWithDepth("bdc5efe8-404a-409b-85f6-0dcc9eebae30", "DeleteNetworkV2/deleteNetworkAAIResponse_Success.xml", "all"); ExecutionEntity mockExecution = setupMock() when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") // old: when(mockExecution.getVariable("mso.workflow.default.aai.network.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") when(mockExecution.getVariable("mso.workflow.default.aai.v8.l3-network.uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() DoDeleteNetworkInstance.callRESTQueryAAI(mockExecution) verify(mockExecution).setVariable("prefix", Prefix) verify(mockExecution).setVariable(Prefix + "queryAAIRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/bdc5efe8-404a-409b-85f6-0dcc9eebae30"+ "?depth=all") verify(mockExecution).setVariable(Prefix + "aaiReturnCode", "200") //verify(mockExecution).setVariable(Prefix + "queryAAIResponse", aaiResponse) verify(mockExecution).setVariable(Prefix + "isAAIGood", true) } @Test //@Ignore public void callRESTQueryAAICloudRegion30_200() { println "************ callRESTQueryAAICloudRegion30_200 ************* " WireMock.reset(); MockGetNetworkCloudRegion("DeleteNetworkV2/cloudRegion30_AAIResponse_Success.xml", "RDM2WAGPLCP"); ExecutionEntity mockExecution = setupMock() when(mockExecution.getVariable("prefix")).thenReturn(Prefix) when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) when(mockExecution.getVariable(Prefix + "lcpCloudRegion")).thenReturn("RDM2WAGPLCP") when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") // old: when(mockExecution.getVariable("mso.workflow.default.aai.cloud-infrastructure.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner") when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner") when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() DoDeleteNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) verify(mockExecution, atLeast(2)).setVariable(Prefix + "queryCloudRegionReturnCode", "200") } @Test //@Ignore public void callRESTQueryAAICloudRegion_NotFound() { println "************ callRESTQueryAAICloudRegion_NotFound ************* " WireMock.reset(); MockGetNetworkCloudRegion_404("MDTWNJ21"); ExecutionEntity mockExecution = setupMock() when(mockExecution.getVariable("prefix")).thenReturn(Prefix) when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(vnfRequestCloudRegionNotFound) when(mockExecution.getVariable(Prefix + "lcpCloudRegion")).thenReturn("MDTWNJ21") when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") // old: when(mockExecution.getVariable("mso.workflow.default.aai.cloud-infrastructure.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner") when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner") when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") // preProcessRequest(DelegateExecution execution) DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() DoDeleteNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) verify(mockExecution).setVariable(Prefix + "cloudRegionPo", "MDTWNJ21") verify(mockExecution).setVariable(Prefix + "cloudRegionSdnc", "AAIAIC25") } @Test //@Ignore public void callRESTQueryAAICloudRegion25_200() { println "************ callRESTQueryAAICloudRegion25_200 ************* " WireMock.reset(); MockGetNetworkCloudRegion("DeleteNetworkV2/cloudRegion25_AAIResponse_Success.xml", "RDM2WAGPLCP"); ExecutionEntity mockExecution = setupMock() when(mockExecution.getVariable("prefix")).thenReturn(Prefix) when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) when(mockExecution.getVariable(Prefix + "lcpCloudRegion")).thenReturn("RDM2WAGPLCP") when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") // old: when(mockExecution.getVariable("mso.workflow.default.aai.cloud-infrastructure.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner") when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner") // when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") // preProcessRequest(DelegateExecution execution) DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() DoDeleteNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) verify(mockExecution, atLeast(2)).setVariable(Prefix + "queryCloudRegionReturnCode", "200") } @Test //@Ignore public void validateNetworkResponse() { println "************ validateNetworkResponse ************* " ExecutionEntity mockExecution = setupMock() // Initialize prerequisite variables when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable(Prefix + "deleteNetworkResponse")).thenReturn(deleteNetworkResponse) when(mockExecution.getVariable(Prefix + "networkReturnCode")).thenReturn('200') DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() DoDeleteNetworkInstance.validateNetworkResponse(mockExecution) verify(mockExecution).setVariable("prefix", Prefix) //verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", null) } @Test //@Ignore public void validateSDNCResponse_200() { println "************ validateSDNCResponse ************* " ExecutionEntity mockExecution = setupMock() // Initialize prerequisite variables when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable(Prefix + "sdncReturnCode")).thenReturn("200") when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() try { DoDeleteNetworkInstance.validateSDNCResponse(mockExecution, sdncAdapterWorkflowResponse) } catch (Exception ex) { println " Graceful Exit - " + ex.getMessage() } } @Test //@Ignore public void validateSDNCResponse_404() { println "************ validateSDNCResponse ************* " WorkflowException workflowException = new WorkflowException("DoCreateNetworkInstance", 2500, "Received error from SNDC Adapter: HTTP Status 404.") ExecutionEntity mockExecution = setupMock() // Initialize prerequisite variables when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable(Prefix + "sdncReturnCode")).thenReturn("404") when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(false) when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() try { DoDeleteNetworkInstance.validateSDNCResponse(mockExecution) } catch (Exception ex) { println " Graceful Exit - " + ex.getMessage() } } @Test //@Ignore public void validateRpcSDNCDeactivateResponse() { println "************ validateRpcSDNCDeactivateResponse ************* " ExecutionEntity mockExecution = setupMock() // Initialize prerequisite variables when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable(Prefix + "deactivateSDNCResponse")).thenReturn(sdncAdapterWorkflowResponse) when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) when(mockExecution.getVariable(Prefix + "deactivateSDNCReturnCode")).thenReturn("200") DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() try { DoDeleteNetworkInstance.validateRpcSDNCDeactivateResponse(mockExecution) verify(mockExecution).setVariable(Prefix + "isSdncDeactivateRollbackNeeded", true) } catch (Exception ex) { println " Graceful Exit - " + ex.getMessage() } //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() //debugger.printInvocations(mockExecution) //verify(mockExecution).setVariable(Prefix + "isSdncRollbackNeeded", true) } @Test @Ignore public void postProcessResponse() { println "************ postProcessResponse ************* " ExecutionEntity mockExecution = setupMock() // Initialize prerequisite variables when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable(Prefix + "source")).thenReturn("PORTAL") when(mockExecution.getVariable(Prefix + "isException")).thenReturn(false) // postProcessResponse(DelegateExecution execution) DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() DoDeleteNetworkInstance.postProcessResponse(mockExecution) verify(mockExecution).setVariable("prefix", Prefix) verify(mockExecution).setVariable(Prefix + "Success", true) } @Test //@Ignore public void prepareRollbackData() { println "************ prepareRollbackData() ************* " WorkflowException workflowException = new WorkflowException("DoCreateNetworkInstance", 2500, "Received error from Network Adapter: JBWEB000065: HTTP Status 500.") ExecutionEntity mockExecution = mock(ExecutionEntity.class) // Initialize prerequisite variables when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn(deleteRollbackNetworkRequest) //when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn(null) //when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn("") when(mockExecution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")).thenReturn(sdncAdapaterDeactivateRollback) when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) // preProcessRequest(DelegateExecution execution) DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() DoDeleteNetworkInstance.prepareRollbackData(mockExecution) // verify(mockExecution).getVariable("isDebugLogEnabled") verify(mockExecution).setVariable("prefix", Prefix) } private ExecutionEntity setupMock() { ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) when(mockProcessDefinition.getKey()).thenReturn("DoDeleteNetworkInstance") RepositoryService mockRepositoryService = mock(RepositoryService.class) when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoDeleteNetworkInstance") 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("DoDeleteNetworkInstance") when(mockExecution.getProcessInstanceId()).thenReturn("DoDeleteNetworkInstance") when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) return mockExecution } }