From be2ccf0d82ff31d910f60069985b8c82f450964a Mon Sep 17 00:00:00 2001 From: "Smokowski, Steve (ss835w)" Date: Thu, 9 Aug 2018 14:24:13 -0400 Subject: Groovy Compile Groovy was not compiling as the maven plugin was off. I had to move some files around, and add some import statements to make it compile again. I also had to rename some packages to onap.so. A few files were deleted that did not compile but were not in use. Issue-ID: SO-823 Change-Id: I99d04b4f25709c86d397d72700c237d81362d8b3 Signed-off-by: Smokowski, Steve (ss835w) --- .../CreateCustomE2EServiceInstanceTest.groovy | 84 - ...CreateGenericAlaCarteServiceInstanceTest.groovy | 235 -- .../scripts/CreateNetworkInstanceTest.groovy | 379 -- .../scripts/CreateVfModuleInfraTest.groovy | 96 - .../scripts/CreateVfModuleVolumeInfraV1Test.groovy | 208 - .../DeleteCustomE2EServiceInstanceTest.groovy | 148 - ...DeleteGenericAlaCarteServiceInstanceTest.groovy | 125 - .../scripts/DeleteNetworkInstanceTest.groovy | 418 -- .../scripts/DeleteVfModuleVolumeInfraV1Test.groovy | 167 - .../scripts/DoCreateE2EServiceInstanceTest.groovy | 103 - .../DoCreateNetworkInstanceRollbackTest.groovy | 369 -- .../scripts/DoCreateNetworkInstanceTest.groovy | 4324 -------------------- .../scripts/DoCreateServiceInstanceTest.groovy | 135 - .../DoCreateVFCNetworkServiceInstanceTest.groovy | 106 - .../scripts/DoCreateVfModuleRollbackTest.groovy | 202 - .../scripts/DoCreateVfModuleTest.groovy | 229 -- .../scripts/DoCreateVfModuleVolumeV2Test.groovy | 135 - .../infrastructure/scripts/DoCreateVnfTest.groovy | 106 - .../DoCustomDeleteE2EServiceInstanceTest.groovy | 169 - .../DoDeleteNetworkInstanceRollbackTest.groovy | 343 -- .../scripts/DoDeleteNetworkInstanceTest.groovy | 1948 --------- .../scripts/DoDeleteServiceInstanceTest.groovy | 127 - .../scripts/DoDeleteVfModuleFromVnfTest.groovy | 172 - .../scripts/DoDeleteVfModuleTest.groovy | 163 - .../scripts/DoDeleteVfModuleVolumeV2Test.groovy | 152 - .../scripts/DoDeleteVnfAndModulesTest.groovy | 162 - .../scripts/DoScaleE2EServiceInstanceTest.groovy | 110 - .../DoUpdateNetworkInstanceRollbackTest.groovy | 332 -- .../scripts/DoUpdateNetworkInstanceTest.groovy | 2762 ------------- .../scripts/DoUpdateVfModuleTest.groovy | 309 -- .../scripts/DoUpdateVnfAndModulesTest.groovy | 126 - .../ScaleCustomE2EServiceInstanceTest.groovy | 195 - .../scripts/UpdateNetworkInstanceTest.groovy | 358 -- .../scripts/UpdateVfModuleVolumeInfraV1Test.groovy | 134 - .../scripts/CreateVcpeResCustServiceTest.groovy | 1269 ------ .../scripts/DeleteVcpeResCustServiceTest.groovy | 773 ---- .../DoCreateAllottedResourceBRGRollbackTest.groovy | 654 --- .../scripts/DoCreateAllottedResourceBRGTest.groovy | 999 ----- .../DoCreateAllottedResourceTXCRollbackTest.groovy | 654 --- .../scripts/DoCreateAllottedResourceTXCTest.groovy | 957 ----- .../scripts/DoDeleteAllottedResourceBRGTest.groovy | 606 --- .../scripts/DoDeleteAllottedResourceTXCTest.groovy | 607 --- .../so/bpmn/vcpe/scripts/GroovyTestBase.groovy | 124 - .../org/onap/so/bpmn/vcpe/scripts/MapGetter.groovy | 49 - .../org/onap/so/bpmn/vcpe/scripts/MapSetter.groovy | 50 - 45 files changed, 21873 deletions(-) delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstanceTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericAlaCarteServiceInstanceTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfraTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstanceTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteGenericAlaCarteServiceInstanceTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstanceTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollbackTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstanceTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollbackTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstanceTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstanceTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModulesTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstanceTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateNetworkInstanceTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/GroovyTestBase.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapGetter.groovy delete mode 100644 bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapSetter.groovy (limited to 'bpmn/so-bpmn-infrastructure-flows/src/test') diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstanceTest.groovy deleted file mode 100644 index ae40e9d7c6..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstanceTest.groovy +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import com.github.tomakehurst.wiremock.junit.WireMockRule -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.junit.Before -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.Captor -import org.mockito.Mockito -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner - -import static org.junit.Assert.assertNotNull -import static org.mockito.Mockito.* - -@RunWith(MockitoJUnitRunner.class) -class CreateCustomE2EServiceInstanceTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(28090); - - @Before - public void init() throws IOException { - MockitoAnnotations.initMocks(this); - } - - @Captor - static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) - - @Test - public void testPrepareInitServiceOperationStatus (){ - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") - when(mockExecution.getVariable("mso.adapters.openecomp.db.endpoint")).thenReturn("http://localhost:28090/dbadapters/RequestsDbAdapter") - CreateCustomE2EServiceInstance obj = new CreateCustomE2EServiceInstance(); - obj.prepareInitServiceOperationStatus(mockExecution) - Mockito.verify(mockExecution, times(5)).setVariable(captor.capture(), captor.capture()) - def updateVolumeGroupRequest = captor.getValue() - assertNotNull(updateVolumeGroupRequest); - } - - private ExecutionEntity setupMock() { - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("CreateCustomE2EServiceInstance") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("CreateCustomE2EServiceInstance") - when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") - ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) - when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - when(mockExecution.getId()).thenReturn("100") - when(mockExecution.getProcessDefinitionId()).thenReturn("CreateCustomE2EServiceInstance") - when(mockExecution.getProcessInstanceId()).thenReturn("CreateCustomE2EServiceInstance") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - return mockExecution - } -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericAlaCarteServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericAlaCarteServiceInstanceTest.groovy deleted file mode 100644 index da0990910a..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateGenericAlaCarteServiceInstanceTest.groovy +++ /dev/null @@ -1,235 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.junit.Before -import org.junit.Rule -import org.junit.Test -import org.mockito.MockitoAnnotations -import org.onap.so.bpmn.common.scripts.MsoUtils -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.bpmn.common.scripts.VidUtils - -import static org.junit.Assert.*; -import static org.mockito.Mockito.* - -import com.github.tomakehurst.wiremock.junit.WireMockRule - -class CreateGenericAlaCarteServiceInstanceTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(8090); - - String Prefix="CRESI_" - def utils = new MsoUtils() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils() - - String createDBRequestError = -""" - - - - 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 falloutHandlerRequest = - """ - - b69c9054-da09-4a2c-adf5-51042b62bfac - CREATE - VID - - - Received error from SDN-C: No availability zone available. - 5300 - - """ - - String completeMsoProcessRequest = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - CREATE - VID - - Network has been created successfully. - BPMN Network action: CREATE -""" - - String jsonIncomingRequest = - """{ - "requestDetails": { - "modelInfo": { - "modelType": "service", - "modelInvariantId": "1de901ed-17af-4b03-bc1f-41659cfa27cb", - "modelVersionId": "ace39141-09ec-4068-b06d-ac6b23bdc6e0", - "modelName": "demoVLB", - "modelVersion": "1.0" - }, - "cloudConfiguration" : { - "lcpCloudRegionId": "RegionOne", - "tenantId": "onap" - }, - "subscriberInfo": { - "globalSubscriberId": "Demonstration", - "subscriberName": "Demonstration" - }, - "requestInfo": { - "instanceName": "sample-instance-2", - "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", - "source": "VID", - "requestorId":"1234", - "suppressRollback": "false" - }, - "requestParameters": { - "subscriptionServiceType": "vLB" - } - } - }""" - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - - } - - public void initializeVariables(DelegateExecution mockExecution) { - - //verify(mockExecution).setVariable(Prefix + "Success", false) - - //verify(mockExecution).setVariable(Prefix + "CompleteMsoProcessRequest", "") - //verify(mockExecution).setVariable(Prefix + "FalloutHandlerRequest", "") - //verify(mockExecution).setVariable(Prefix + "isSilentSuccess", false) - - } - - @Test - //@Ignore - public void preProcessRequest() { - - println "************ preProcessRequest() ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest) - try{ - - // preProcessRequest(DelegateExecution execution) - CreateGenericALaCarteServiceInstance createGenericALaCarteServiceInstance = new CreateGenericALaCarteServiceInstance() - createGenericALaCarteServiceInstance.preProcessRequest(mockExecution) - - //verify(mockExecution).getVariable("isDebugLogEnabled") - //verify(mockExecution).setVariable("prefix", Prefix) - - initializeVariables(mockExecution) - //verify(mockExecution).setVariable(Prefix + "Success", false) - }catch(Exception e){ - //ignore - } - } - - @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") - try{ - // preProcessRequest(DelegateExecution execution) - CreateGenericALaCarteServiceInstance createGenericALaCarteServiceInstance = new CreateGenericALaCarteServiceInstance() - createGenericALaCarteServiceInstance.sendSyncResponse(mockExecution) - - //verify(mockExecution).setVariable("prefix", Prefix) - //verify(mockExecution).setVariable("createServiceRestRequest", "202") - }catch(Exception e){ - //ignore - } - } - - @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") - try{ - CreateGenericALaCarteServiceInstance createGenericALaCarteServiceInstance = new CreateGenericALaCarteServiceInstance() - createGenericALaCarteServiceInstance.sendSyncError(mockExecution) - - //verify(mockExecution).setVariable("prefix", Prefix) - //verify(mockExecution).setVariable("createServiceRestRequest", "500") - }catch(Exception e){ - //ignore - } - } - - private ExecutionEntity setupMock() { - - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("CreateGenericALaCarteSeviceInstance") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("CreateGenericALaCarteSeviceInstance") - 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("CreateGenericALaCarteSeviceInstance") - when(mockExecution.getProcessInstanceId()).thenReturn("CreateGenericALaCarteSeviceInstance") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - } -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy deleted file mode 100644 index 4d5f506599..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy +++ /dev/null @@ -1,379 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.junit.Before -import org.junit.Rule -import org.junit.Test -import org.mockito.MockitoAnnotations -import org.onap.so.bpmn.common.scripts.MsoUtils -import org.onap.so.bpmn.core.WorkflowException - -import static org.junit.Assert.*; -import static org.mockito.Mockito.* - -import com.github.tomakehurst.wiremock.junit.WireMockRule - -class CreateNetworkInstanceTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(8090); - - String Prefix="CRENI_" - def utils = new MsoUtils() - - String createDBRequestError = -""" - - - - 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 falloutHandlerRequest = - """ - - b69c9054-da09-4a2c-adf5-51042b62bfac - CREATE - VID - - - Received error from SDN-C: No availability zone available. - 5300 - - """ - - String completeMsoProcessRequest = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - CREATE - VID - - Network has been created successfully. - BPMN Network action: CREATE -""" - - -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" - } - ] - } - }}""" - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - - public void initializeVariables(DelegateExecution mockExecution) { - - verify(mockExecution).setVariable(Prefix + "Success", false) - - verify(mockExecution).setVariable(Prefix + "CompleteMsoProcessRequest", "") - verify(mockExecution).setVariable(Prefix + "FalloutHandlerRequest", "") - verify(mockExecution).setVariable(Prefix + "isSilentSuccess", false) - - } - - @Test - //@Ignore - public void preProcessRequest() { - - println "************ preProcessRequest() ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest) - - - // preProcessRequest(DelegateExecution execution) - CreateNetworkInstance CreateNetworkInstance = new CreateNetworkInstance() - CreateNetworkInstance.preProcessRequest(mockExecution) - - //verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix) - - initializeVariables(mockExecution) - //verify(mockExecution).setVariable(Prefix + "Success", false) - - } - - - @Test - //@Ignore - public void getNetworkModelInfo() { - - println "************ getNetworkModelInfo() ************* " - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - - // preProcessRequest(DelegateExecution execution) - CreateNetworkInstance CreateNetworkInstance = new CreateNetworkInstance() - CreateNetworkInstance.getNetworkModelInfo(mockExecution) - - //verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix) - - } - - @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(DelegateExecution execution) - CreateNetworkInstance CreateNetworkInstance = new CreateNetworkInstance() - CreateNetworkInstance.sendSyncResponse(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable("CreateNetworkInstanceResponseCode", "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") - - CreateNetworkInstance CreateNetworkInstance = new CreateNetworkInstance() - CreateNetworkInstance.sendSyncError(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable("CreateNetworkInstanceResponseCode", "500") - - } - - @Test - //@Ignore - public void prepareDBRequestError() { - - println "************ prepareDBRequestError ************* " - - WorkflowException sndcWorkflowException = new WorkflowException("CreateNetworkInstance", 500, "Received error from SDN-C: No availability zone available") - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowException) - //when(mockExecution.getVariable("msoRequestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable(Prefix + "requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("networkId")).thenReturn("") - when(mockExecution.getVariable("networkName")).thenReturn("") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso.adapters.db.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(DelegateExecution execution) - CreateNetworkInstance CreateNetworkInstance = new CreateNetworkInstance() - CreateNetworkInstance.prepareDBRequestError(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "createDBRequest", createDBRequestError) - - } - - - @Test - //@Ignore - public void prepareCompletion() { - - println "************ postProcessResponse ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable(Prefix + "dbReturnCode")).thenReturn("200") - - // postProcessResponse(DelegateExecution execution) - CreateNetworkInstance CreateNetworkInstance = new CreateNetworkInstance() - CreateNetworkInstance.prepareCompletion(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "Success", true) - verify(mockExecution).setVariable(Prefix + "CompleteMsoProcessRequest", completeMsoProcessRequest) - - } - - @Test - //@Ignore - public void buildErrorResponse() { - - println "************ buildErrorResponse ************* " - - - WorkflowException sndcWorkflowException = new WorkflowException("CreateNetworkInstance", 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("mso-request-id")).thenReturn("b69c9054-da09-4a2c-adf5-51042b62bfac") - //when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowException) - when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowException) - - // buildErrorResponse(DelegateExecution execution) - CreateNetworkInstance CreateNetworkInstance = new CreateNetworkInstance() - CreateNetworkInstance.buildErrorResponse(mockExecution) - - verify(mockExecution, atLeast(1)).setVariable("prefix", "CRENI_") - verify(mockExecution).setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) - - //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() - //debugger.printInvocations(mockExecution) - - } - - @Test - //@Ignore - public void postProcessResponse() { - - println "************ postProcessResponse() ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("CMSO_ResponseCode")).thenReturn("200") - - // postProcessResponse(DelegateExecution execution) - CreateNetworkInstance CreateNetworkInstance = new CreateNetworkInstance() - CreateNetworkInstance.postProcessResponse(mockExecution) - - //verify(mockExecution).getVariable("isDebugLogEnabled") - //verify(mockExecution).setVariable("prefix", Prefix) - - verify(mockExecution).setVariable(Prefix + "Success", true) - - } - - @Test - //@Ignore - public void processRollbackData() { - - println "************ callDBCatalog() ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - - // preProcessRequest(DelegateExecution execution) - CreateNetworkInstance CreateNetworkInstance = new CreateNetworkInstance() - CreateNetworkInstance.processRollbackData(mockExecution) - -// verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix) - - } - - private ExecutionEntity setupMock() { - - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("CreateNetworkInstance") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("CreateNetworkInstance") - 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("CreateNetworkInstance") - when(mockExecution.getProcessInstanceId()).thenReturn("CreateNetworkInstance") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - } - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfraTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfraTest.groovy deleted file mode 100644 index 77220da94f..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleInfraTest.groovy +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import com.github.tomakehurst.wiremock.junit.WireMockRule -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.junit.Before -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.Captor -import org.mockito.Mockito -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner - -import static org.mockito.Mockito.mock -import static org.mockito.Mockito.when - -@RunWith(MockitoJUnitRunner.class) -class CreateVfModuleInfraTest { - - def prefix = "CVFMI_" - def requestInfo = "12345" - - @Rule - public WireMockRule wireMockRule = new WireMockRule(28090) - - @Captor - static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) - - @Before - void init() throws IOException { - MockitoAnnotations.initMocks(this); - } - - @Test - void testPrepareUpdateInfraRequest() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(prefix) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("12345") - when(mockExecution.getVariable(prefix + "requestInfo")).thenReturn(requestInfo) - when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("12345") - when(mockExecution.getVariable(prefix + "vfModuleName")).thenReturn("12345") - when(mockExecution.getVariable("mso.adapters.openecomp.db.endpoint")).thenReturn("http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter") - - CreateVfModuleInfra obj = new CreateVfModuleInfra() - obj.prepareUpdateInfraRequest(mockExecution) - Mockito.verify(mockExecution).setVariable(prefix + "dbAdapterEndpoint", "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter") - } - - - - private static ExecutionEntity setupMock() { - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("CreateVfModuleInfra") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("CreateVfModuleInfra") - 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("CreateVfModuleInfra") - when(mockExecution.getProcessInstanceId()).thenReturn("CreateVfModuleInfra") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - } -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy deleted file mode 100644 index 2b437d875e..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy +++ /dev/null @@ -1,208 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.junit.Before -import org.junit.Ignore -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.onap.so.bpmn.common.scripts.MsoGroovyTest - -import static org.junit.Assert.assertEquals -import static org.mockito.Mockito.* - -@RunWith(MockitoJUnitRunner.class) -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", - "modelInvariantUuid": "ff5256d1-5a33-55df-13ab-12abad84e7ff", - "modelUuid": "fe6478e4-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", - "modelInstanceName": "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 - @Ignore - 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') - when(mockExecution.getVariable("mso.rollback")).thenReturn('true') - - 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/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstanceTest.groovy deleted file mode 100644 index 95259e9ec0..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstanceTest.groovy +++ /dev/null @@ -1,148 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import com.github.tomakehurst.wiremock.junit.WireMockRule -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.junit.Before -import org.junit.BeforeClass -import org.junit.Rule -import org.junit.Test -import org.mockito.MockitoAnnotations -import org.onap.so.bpmn.mock.FileUtil -import org.onap.so.bpmn.vcpe.scripts.GroovyTestBase - -import static org.mockito.Mockito.verify -import static org.mockito.Mockito.when - -class DeleteCustomE2EServiceInstanceTest extends GroovyTestBase { - - private static String request - - @Rule - public WireMockRule wireMockRule = new WireMockRule(GroovyTestBase.PORT) - - String Prefix = "CVRCS_" - String RbType = "DCRENI_" - - @BeforeClass - public static void setUpBeforeClass() { - request = FileUtil.readResourceFile("__files/InfrastructureFlows/DeleteCustomE2EService.json") - } - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - - public DeleteCustomE2EServiceInstanceTest(){ - super("DeleteCustomE2EServiceInstance") - } - @Test - public void preProcessRequestTest () { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcess(mex) - DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance() - mex.setVariable("isDebugLogEnabled","true") - instance.preProcessRequest(mex); - - verify(mex).getVariable(GroovyTestBase.DBGFLAG) - - Map userParams = new HashMap<>() - userParams.put("someUserParam","someValue") - - verify(mex).setVariable("prefix", "DELSI_") - verify(mex).setVariable("msoRequestId", "mri") - verify(mex).setVariable("source", "CCD") - verify(mex).setVariable("operationType", "DELETE") - verify(mex).setVariable("globalSubscriberId", "38829939920000") - verify(mex).setVariable("serviceInputParams",userParams) - } - - @Test - public void sendSyncResponseTest() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcess(mex) - DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance() - instance.sendSyncResponse(mex) - verify(mex).setVariable("DeleteCustomE2EServiceInstanceWorkflowResponseSent", "true") - } - - @Test - public void prepareCompletionRequestTest(){ - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcess(mex) - DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance() - instance.prepareCompletionRequest(mex) - String msoComplitionRequest = FileUtil.readResourceFile("__files/GenericFlows/MsoCompletionRequest.xml") - //verify(mex).setVariable("completionRequest", msoComplitionRequest) - } - - @Test - public void sendSyncErrorTest(){ - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcess(mex) - DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance() - instance.sendSyncError(mex) - - } - - @Test - public void prepareFalloutRequest(){ - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcess(mex) - DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance() - instance.prepareFalloutRequest(mex) - String requestInfo = - """ - null - DELETE - null - """ - //verify(mex).setVariable("falloutRequest", requestInfo) - } - - @Test - public void processJavaExceptionTest(){ - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcess(mex) - DeleteCustomE2EServiceInstance instance = new DeleteCustomE2EServiceInstance() - instance.processJavaException() - } - - - private void initPreProcess(ExecutionEntity mex) { - when(mex.getVariable(GroovyTestBase.DBGFLAG)).thenReturn("true") - when(mex.getVariable("bpmnRequest")).thenReturn(request) - when(mex.getVariable("mso-request-id")).thenReturn("mri") - when(mex.getVariable("serviceType")).thenReturn("VoLTE") - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - when(mex.getVariable("requestAction")).thenReturn("ra") - when(mex.getVariable("operationId")).thenReturn("59960003992") - } -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteGenericAlaCarteServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteGenericAlaCarteServiceInstanceTest.groovy deleted file mode 100644 index b459710479..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteGenericAlaCarteServiceInstanceTest.groovy +++ /dev/null @@ -1,125 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.junit.Before -import org.junit.Rule -import org.junit.Test -import org.mockito.MockitoAnnotations -import org.onap.so.bpmn.common.scripts.MsoUtils -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.bpmn.common.scripts.VidUtils - -import static org.junit.Assert.*; -import static org.mockito.Mockito.* - -import com.github.tomakehurst.wiremock.junit.WireMockRule - -class DeleteGenericAlaCarteServiceInstanceTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(8090); - - String Prefix="DELSI_" - def utils = new MsoUtils() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils() - - String jsonIncomingRequest = - """{ - "requestDetails": { - "modelInfo": { - "modelType": "service", - "modelInvariantId": "1de901ed-17af-4b03-bc1f-41659cfa27cb", - "modelVersionId": "ace39141-09ec-4068-b06d-ac6b23bdc6e0", - "modelName": "demoVLB", - "modelVersion": "1.0" - }, - "cloudConfiguration" : { - "lcpCloudRegionId": "RegionOne", - "tenantId": "onap" - }, - "subscriberInfo": { - "globalSubscriberId": "Demonstration", - "subscriberName": "Demonstration" - }, - "requestInfo": { - "instanceName": "sample-instance-2", - "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", - "source": "VID", - "requestorId":"1234", - "suppressRollback": "false" - }, - "requestParameters": { - "subscriptionServiceType": "vLB" - } - } - }""" - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - - } - - public void initializeVariables(DelegateExecution mockExecution) { - - verify(mockExecution).setVariable(Prefix + "Success", false) - - verify(mockExecution).setVariable(Prefix + "CompleteMsoProcessRequest", "") - verify(mockExecution).setVariable(Prefix + "FalloutHandlerRequest", "") - verify(mockExecution).setVariable(Prefix + "isSilentSuccess", false) - - } - - @Test - //@Ignore - public void preProcessRequest() { - - println "************ preProcessRequest() ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest) - - try { - // preProcessRequest(DelegateExecution execution) - DeleteGenericALaCarteServiceInstance deleteGenericALaCarteServiceInstance = new DeleteGenericALaCarteServiceInstance() - deleteGenericALaCarteServiceInstance.preProcessRequest(mockExecution) - - verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix) - - initializeVariables(mockExecution) - //verify(mockExecution).setVariable(Prefix + "Success", false) - }catch(Exception e){ - //ignore - } - - } -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstanceTest.groovy deleted file mode 100644 index 9b7d7ee21f..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteNetworkInstanceTest.groovy +++ /dev/null @@ -1,418 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - - -import static org.mockito.Mockito.* - -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.delegate.DelegateExecution -import org.junit.Before -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.junit.WireMockRule - - -@RunWith(MockitoJUnitRunner.class) -class DeleteNetworkInstanceTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(8090); - - String Prefix="DELNI_" - def utils = new MsoUtils() - - String falloutHandlerRequest = - """ - - b69c9054-da09-4a2c-adf5-51042b62bfac - DELETE - PORTAL - - - Received error from SDN-C: No availability zone available - 5300 - 200 - - """ - - String falloutHandlerRequestObj = - """ - - b69c9054-da09-4a2c-adf5-51042b62bfac - DELETE - PORTAL - - - Received error from SDN-C: No availability zone available - 7000 - - """ - - String completeMsoProcessRequest = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - DELETE - VID - - Network has been deleted successfully. - BPMN Network action: DELETE -""" - -String deleteDBRequest = -""" - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - BPMN - Network successfully deleted. - - COMPLETED - 100 - <network-outputs xmlns="http://org.onap/so/infra/vnf-request/v1" xmlns:aetgt="http://org.onap/so/infra/vnf-request/v1" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"/> - - -""" - -String deleteDBRequestErrorObj = -""" - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - BPMN - Received error from SDN-C: No availability zone available - - FAILED - - <network-outputs xmlns="http://org.onap/so/infra/vnf-request/v1" xmlns:aetgt="http://org.onap/so/infra/vnf-request/v1" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"/> - - - """ - -String deleteDBRequestErrorString = -""" - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - BPMN - Received error from SDN-C: No availability zone available - - FAILED - - <network-outputs xmlns="http://org.onap/so/infra/vnf-request/v1" xmlns:aetgt="http://org.onap/so/infra/vnf-request/v1" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"/> - - - """ - - 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" - } - ] - } - }}""" - -// - - - - - - - - - - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - - @Test - //@Ignore - public void preProcessRequest() { - - println "************ preProcessRequest_Payload ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest) - - DeleteNetworkInstance DeleteNetworkInstance = new DeleteNetworkInstance() - DeleteNetworkInstance.preProcessRequest(mockExecution) - - verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix) - - //verify variable initialization - initializeVariables(mockExecution) - - - } - - public void initializeVariables (DelegateExecution mockExecution) { - - - verify(mockExecution).setVariable(Prefix + "Success", false) - - verify(mockExecution).setVariable(Prefix + "CompleteMsoProcessRequest", "") - verify(mockExecution).setVariable(Prefix + "FalloutHandlerRequest", "") - verify(mockExecution).setVariable(Prefix + "isSilentSuccess", false) - - } - - - @Test - //@Ignore - public void getNetworkModelInfo() { - - println "************ getNetworkModelInfo() ************* " - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - - // preProcessRequest(DelegateExecution execution) - DeleteNetworkInstance DeleteNetworkInstance = new DeleteNetworkInstance() - DeleteNetworkInstance.getNetworkModelInfo(mockExecution) - - verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix) - - } - - @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(DelegateExecution execution) - DeleteNetworkInstance DeleteNetworkInstance = new DeleteNetworkInstance() - DeleteNetworkInstance.sendSyncResponse(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable("DeleteNetworkInstanceResponseCode", "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") - - DeleteNetworkInstance DeleteNetworkInstance = new DeleteNetworkInstance() - DeleteNetworkInstance.sendSyncError(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable("DeleteNetworkInstanceResponseCode", "500") - - } - - - @Test - //@Ignore - public void prepareCompletion() { - - println "************ postProcessResponse ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable(Prefix + "source")).thenReturn("PORTAL") - when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - - // postProcessResponse(DelegateExecution execution) - DeleteNetworkInstance DeleteNetworkInstance = new DeleteNetworkInstance() - DeleteNetworkInstance.prepareCompletion(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "CompleteMsoProcessRequest", completeMsoProcessRequest) - - } - - - @Test - //@Ignore - public void prepareDBRequestError() { - - println "************ prepareDBRequestError ************* " - - WorkflowException sndcWorkflowExceptionObj = new WorkflowException("CreateNetworkV2", 500, "Received error from SDN-C: No availability zone available") - - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable(Prefix + "requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowExceptionObj) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso.adapters.db.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(DelegateExecution execution) - DeleteNetworkInstance DeleteNetworkInstance = new DeleteNetworkInstance() - DeleteNetworkInstance.prepareDBRequestError(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "deleteDBRequest", deleteDBRequestErrorObj) - - } - - - @Test - //@Ignore - public void postProcessResponse() { - - println "************ postProcessResponse ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("CMSO_ResponseCode")).thenReturn("200") - - // postProcessResponse(DelegateExecution execution) - DeleteNetworkInstance DeleteNetworkInstance = new DeleteNetworkInstance() - DeleteNetworkInstance.postProcessResponse(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "Success", true) - - - } - - - @Test - //@Ignore - public void buildErrorResponse_FalloutHandlerRequest() { - - println "************ buildErrorResponse ************* " - - WorkflowException sndcWorkflowExceptionObj = new WorkflowException("DeleteNetworkInstance", 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("mso-request-id")).thenReturn("b69c9054-da09-4a2c-adf5-51042b62bfac") - when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowExceptionObj) - when(mockExecution.getVariable(Prefix + "source")).thenReturn("PORTAL") - - // buildErrorResponse(DelegateExecution execution) - DeleteNetworkInstance DeleteNetworkInstance = new DeleteNetworkInstance() - DeleteNetworkInstance.buildErrorResponse(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "Success", false) - verify(mockExecution).setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequestObj) - - } - - - private ExecutionEntity setupMock() { - - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("DeleteNetworkInstance") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DeleteNetworkInstance") - 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("DeleteNetworkInstance") - when(mockExecution.getProcessInstanceId()).thenReturn("DeleteNetworkInstance") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - - } - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy deleted file mode 100644 index 0bce32716f..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy +++ /dev/null @@ -1,167 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -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.onap.so.bpmn.common.scripts.MsoGroovyTest -import org.onap.so.bpmn.core.WorkflowException - -import static org.mockito.Mockito.verify -import static org.mockito.Mockito.when - -@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("mso.workflow.message.endpoint")).thenReturn('http://localhost:28080/mso/WorkflowMessage') - when(mockExecution.getVariable("mso.use.qualified.host")).thenReturn('') - - DeleteVfModuleVolumeInfraV1 myproc = new DeleteVfModuleVolumeInfraV1() - myproc.prepareVnfAdapterDeleteRequest(mockExecution, 'true') - - verify(mockExecution).setVariable("DELVfModVol_deleteVnfARequest", deleteVnfAdapterRequestXml) - - } - - @Test - //@Ignore - public void testPrepareDbRequest() { - - ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1') - when(mockExecution.getVariable("DELVfModVol_requestId")).thenReturn('TEST-REQUEST-ID-0123') - when(mockExecution.getVariable("DELVfModVol_volumeOutputs")).thenReturn('') - when(mockExecution.getVariable("mso.adapters.db.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - 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/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceTest.groovy deleted file mode 100644 index 72f79c80d9..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceTest.groovy +++ /dev/null @@ -1,103 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import com.github.tomakehurst.wiremock.junit.WireMockRule -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.junit.Before -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.Captor -import org.mockito.Mockito -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.onap.so.bpmn.common.scripts.utils.XmlComparator - -import static org.mockito.Mockito.* -/** - * @author sushilma - * @since January 10, 2018 - */ -@RunWith(MockitoJUnitRunner.class) -class DoCreateE2EServiceInstanceTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(28090); - - @Before - public void init() throws IOException { - MockitoAnnotations.initMocks(this); - } - - @Captor - static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) - - String expectedServiceInstanceData = """ - 1234 - volte-service - voLTE type - voLTE role - Created - c1d4305f-cdbd-4bbe-9069-a2f4978fd89e - d4df5c27-98a1-4812-a8aa-c17f055b7a3f - """ - @Test - public void testPreProcessRequest(){ - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("globalSubscriberId")).thenReturn("12345") - when(mockExecution.getVariable("serviceType")).thenReturn("TRANSPORT") - when(mockExecution.getVariable("serviceInstanceId")).thenReturn("1234") - when(mockExecution.getVariable("serviceInstanceName")).thenReturn("volte-service") - when(mockExecution.getVariable("uuiRequest")).thenReturn("""{"service":{"serviceDefId":"c1d4305f-cdbd-4bbe-9069-a2f4978fd89e" , "templateId" : "d4df5c27-98a1-4812-a8aa-c17f055b7a3f"}}""") - when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("/mso/sdncadapter/") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") - when(mockExecution.getVariable("mso.workflow.default.aai.customer.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.customer.uri")).thenReturn('/aai/v8/business/customers/customer') - DoCreateE2EServiceInstance obj = new DoCreateE2EServiceInstance() - obj.preProcessRequest(mockExecution) - Mockito.verify(mockExecution, times(7)).setVariable(captor.capture(), captor.capture()) - XmlComparator.assertXMLEquals(expectedServiceInstanceData, captor.getValue()) - } - - private ExecutionEntity setupMock() { - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("DoCreateE2EServiceInstance") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoCreateE2EServiceInstance") - when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") - ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) - when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - when(mockExecution.getId()).thenReturn("100") - when(mockExecution.getProcessDefinitionId()).thenReturn("DoCreateE2EServiceInstance") - when(mockExecution.getProcessInstanceId()).thenReturn("DoCreateE2EServiceInstance") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - return mockExecution - } -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollbackTest.groovy deleted file mode 100644 index 5ee10bc931..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollbackTest.groovy +++ /dev/null @@ -1,369 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import static org.mockito.Mockito.* - -import org.camunda.bpm.engine.delegate.BpmnError -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.impl.pvm.process.ProcessDefinitionImpl -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.mockito.internal.debugging.MockitoDebuggerImpl -import org.onap.so.bpmn.common.scripts.MsoUtils -import org.onap.so.bpmn.core.WorkflowException -import org.junit.Before -import org.junit.Rule; -import org.junit.Test -import org.junit.Ignore -import org.junit.runner.RunWith - -import static org.onap.so.bpmn.mock.StubResponseNetworkAdapter.MockNetworkAdapterRestRollbackDelete; -import static org.junit.Assert.*; - -import com.github.tomakehurst.wiremock.client.WireMock; -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import org.apache.commons.lang3.* - - -@RunWith(MockitoJUnitRunner.class) -class DoCreateNetworkInstanceRollbackTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(28090); - - def utils = new MsoUtils() - String Prefix="CRENWKIR_" - - - String rollbackNetworkRequest = - """ - - 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 rollbackActivateSDNCRequest = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - rollback - network-topology-operation - sdncCallback - generic-resource - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - CreateNetworkInstance - 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 - - invariant-uuid - customization-uuid - uuid - version - CONTRAIL_EXTERNAL - - - - 8abc633a-810b-4ca5-8b3a-09511d13a2ce - CONTRAIL_EXTERNAL - MNS-25180-L-01-dmz_direct_net_1 - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - -""" - - String rollbackSDNCRequest = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - rollback - network-topology-operation - sdncCallback - generic-resource - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - CreateNetworkInstance - 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 - - invariant-uuid - customization-uuid - uuid - version - CONTRAIL_EXTERNAL - - - - 8abc633a-810b-4ca5-8b3a-09511d13a2ce - CONTRAIL_EXTERNAL - MNS-25180-L-01-dmz_direct_net_1 - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - -""" - -// - - - - - - - - - - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - - } - - public void initializeVariables (DelegateExecution mockExecution) { - - verify(mockExecution).setVariable(Prefix + "WorkflowException", null) - - verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", null) - verify(mockExecution).setVariable(Prefix + "rollbackNetworkResponse", "") - verify(mockExecution).setVariable(Prefix + "rollbackNetworkReturnCode", "") - - verify(mockExecution).setVariable(Prefix + "rollbackSDNCRequest", null) - verify(mockExecution).setVariable(Prefix + "rollbackSDNCResponse", "") - verify(mockExecution).setVariable(Prefix + "rollbackSDNCReturnCode", "") - - verify(mockExecution).setVariable(Prefix + "rollbackActivateSDNCRequest", null) - verify(mockExecution).setVariable(Prefix + "rollbackActivateSDNCResponse", "") - verify(mockExecution).setVariable(Prefix + "rollbackActivateSDNCReturnCode", "") - - verify(mockExecution).setVariable(Prefix + "Success", false) - verify(mockExecution).setVariable(Prefix + "fullRollback", false) - verify(mockExecution).setVariable(Prefix + "networkId", "") - verify(mockExecution).setVariable(Prefix + "urlRollbackPoNetwork", "") - - } - - @Test - //@Ignore - public void preProcessRequest() { - - println "************ preProcessRequest ************* " - - WorkflowException workflowException = new WorkflowException("DoCreateNetworkInstance", 2500, "Received error from Network Adapter: JBWEB000065: HTTP Status 500.") - Map rollbackData = new HashMap(); - rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) - rollbackData.put("rollbackActivateSDNCRequest", rollbackActivateSDNCRequest) - rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) - - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) - when(mockExecution.getVariable("rollbackData")).thenReturn(rollbackData) - when(mockExecution.getVariable("sdncVersion")).thenReturn("1702") - - when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - when(mockExecution.getVariable("mso.adapters.sdnc.endpoint")).thenReturn("http://localhost:28090/SDNCAdapter") - when(mockExecution.getVariable("mso.adapters.network.rest.endpoint")).thenReturn("http://localhost:28090/networks/NetworkAdapter") - when(mockExecution.getVariable("mso.adapters.sdnc.resource.endpoint")).thenReturn("http://localhost:28090/SDNCAdapterRpc") - - - // preProcessRequest(DelegateExecution execution) - DoCreateNetworkInstanceRollback DoCreateNetworkInstanceRollback = new DoCreateNetworkInstanceRollback() - DoCreateNetworkInstanceRollback.preProcessRequest(mockExecution) - -// verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix) - - //verify variable initialization - initializeVariables(mockExecution) - - } - - @Test - //@Ignore - public void callPONetworkAdapter() { - - MockNetworkAdapterRestRollbackDelete("deleteNetworkResponse_Success.xml","8abc633a-810b-4ca5-8b3a-09511d13a2ce"); - - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn( rollbackNetworkRequest) - when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn(rollbackSDNCRequest) - when(mockExecution.getVariable("mso.adapters.network.rest.endpoint")).thenReturn("http://localhost:28090/networks/NetworkAdapter") - - // preProcessRequest(DelegateExecution execution) - DoCreateNetworkInstanceRollback DoCreateNetworkInstanceRollback = new DoCreateNetworkInstanceRollback() - DoCreateNetworkInstanceRollback.callPONetworkAdapter(mockExecution) - - verify(mockExecution, atLeast(1)).setVariable(Prefix + "urlRollbackPoNetwork", "http://localhost:28090/networks/NetworkAdapter/8abc633a-810b-4ca5-8b3a-09511d13a2ce/rollback") - - } - - @Test - //@Ignore - public void validateRollbackResponses_Good() { - - WorkflowException workflowException = new WorkflowException("DoCreateNetworkInstanceRollback", 2500, "AAI Update Contrail Failed. Error 404.") - WorkflowException expectedWorkflowException = new WorkflowException("DoCreateNetworkInstanceRollback", 2500, "AAI Update Contrail Failed. Error 404. + SNDC activate rollback completed. + PO Network rollback completed. + SNDC assign rollback completed.") - - println "************ validateRollbackResponses_Good() ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackActivateSDNCRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackNetworkReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackNetworkResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "rollbackSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackSDNCResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "rollbackActivateSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackActivateSDNCResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "WorkflowException")).thenReturn(workflowException) - when(mockExecution.getVariable(Prefix + "fullRollback")).thenReturn(false) - - DoCreateNetworkInstanceRollback DoCreateNetworkInstanceRollback = new DoCreateNetworkInstanceRollback() - DoCreateNetworkInstanceRollback.validateRollbackResponses(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) - verify(mockExecution, atLeast(1)).setVariable("rolledBack", true) - verify(mockExecution, atLeast(1)).setVariable("wasDeleted", true) - verify(mockExecution).setVariable("WorkflowException", refEq(expectedWorkflowException, any(WorkflowException.class))) - //verify(mockExecution).setVariable("WorkflowException", expectedWorkflowException) - } - - @Test - //@Ignore - public void validateRollbackResponses_FullRollback() { - - Map rollbackData = new HashMap(); - rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) - rollbackData.put("rollbackActivateSDNCRequest", rollbackActivateSDNCRequest) - rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) - - println "************ validateRollbackResponses_FullRollback() ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackActivateSDNCRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackNetworkReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackNetworkResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "rollbackSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackSDNCResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "rollbackActivateSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackActivateSDNCResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "workflowException")).thenReturn(null) - when(mockExecution.getVariable(Prefix + "fullRollback")).thenReturn(true) - when(mockExecution.getVariable("rollbackData")).thenReturn(rollbackData) - - DoCreateNetworkInstanceRollback DoCreateNetworkInstanceRollback = new DoCreateNetworkInstanceRollback() - DoCreateNetworkInstanceRollback.validateRollbackResponses(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) - verify(mockExecution, atLeast(1)).setVariable("rollbackSuccessful", true) - verify(mockExecution, atLeast(1)).setVariable("rollbackError", false) - - } - - - private ExecutionEntity setupMock() { - - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("DoCreateNetworkInstanceRollback") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoCreateNetworkInstanceRollback") - 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("DoCreateNetworkInstanceRollback") - when(mockExecution.getProcessInstanceId()).thenReturn("DoCreateNetworkInstanceRollback") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - } - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy deleted file mode 100644 index 0a1f8f2859..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy +++ /dev/null @@ -1,4324 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - - -import static org.mockito.Mockito.* -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkByName; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkByName_404; -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 static org.onap.so.bpmn.mock.StubResponseAAI.MockPutNetworkIdWithDepth; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkPolicy; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkTableReference; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkVpnBinding; -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 DoCreateNetworkInstanceTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(8090); - - def utils = new MsoUtils() - String Prefix="CRENWKI_" - -// ---- Start XML Zone ---- - String xmlIncomingRequest = - """ - - - 1ef47428-cade-45bd-a103-0751e8b2deb0 - CREATE - PORTAL - - - bdc5efe8-404a-409b-85f6-0dcc9eebae30 - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - dvs-slcp3-01 - 3008 - MNS-25180-L-01-dmz_direct_net_1 - true - - - 1 - 0 - - - """ - - String expectedXMLNetworkRequest = -""" - - - 1ef47428-cade-45bd-a103-0751e8b2deb0 - CREATE - PORTAL - - - bdc5efe8-404a-409b-85f6-0dcc9eebae30 - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - dvs-slcp3-01 - 3008 - MNS-25180-L-01-dmz_direct_net_1 - true - - - 1 - 0 - - -""" - - String expectedXMLNetworkInputs = -""" - bdc5efe8-404a-409b-85f6-0dcc9eebae30 - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - dvs-slcp3-01 - 3008 - MNS-25180-L-01-dmz_direct_net_1 - true -""" - - String networkXMLOutputs = -"""""" - -// ---- End XML Zone ---- - -// ---- Start JSON Zone ---- - // JSON format Input - String jsonIncomingRequest = - """{ "requestDetails": { - "modelInfo": { - "modelType": "network", - "modelCustomizationId": "f21df226-8093-48c3-be7e-0408fcda0422", - "modelName": "CONTRAIL_EXTERNAL", - "modelVersion": "1.0" - }, - "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 expectedJSONNetworkRequest = - """ - - null - CREATE - VID - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - - - networkId - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - f21df226-8093-48c3-be7e-0408fcda0422 - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - false - 1610 - - - someValue1 - -""" - - String expectedJSONNetworkInputs = -""" - networkId - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - f21df226-8093-48c3-be7e-0408fcda0422 - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - false - 1610 -""" - - String networkJSONOutputs = -""" - networkId - MNS-25180-L-01-dmz_direct_net_1 - """ - -// ---- End JSON Zone ---- - -// ---- Start vPIR Zone ---- - // expectedNetworkRequest - String expectedvIPRNetworkRequest = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - CREATE - 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 - - - HNGW Protected OAM - 36a3a8ea-49a6-4ac8-b06c-89a54544b9b6 - fcc85cb0-ad74-45d7-a5a1-17c8744fdb71 - 1.0 - - - 1702 - - -""" - - String expectedvIPRNetworkInputs = -""" - 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 - - - HNGW Protected OAM - 36a3a8ea-49a6-4ac8-b06c-89a54544b9b6 - fcc85cb0-ad74-45d7-a5a1-17c8744fdb71 - 1.0 - - - 1702 -""" - - String networkvIPROutputs = -""" - networkId - MNS-25180-L-01-dmz_direct_net_1 - """ - -// ---- End vPIR Zone ---- - - String vnfRequestFakeRegion = - """ - - 1ef47428-cade-45bd-a103-0751e8b2deb0 - CREATE - PORTAL - - - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - MSO-dev-service-type - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - MDTWNJ21 - 7dd5365547234ee8937416c65507d266 - - - 1 - 0 - -""" - - // expectedNetworkRequest - String expectedNetworkRequest_Outputs = - """ - - 1ef47428-cade-45bd-a103-0751e8b2deb0 - CREATE - PORTAL - - - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - MSO-dev-service-type - 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 queryAAIResponse = - """ - - - - - - - - - - - - bdc5efe8-404a-409b-85f6-0dcc9eebae30 - HSL_direct_net_2 - CONTRAIL_EXTERNAL - dmz_direct - contrail - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - 0 - pending-create - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - 107.239.52.1 - 107.239.52.0 - 24 - 4 - pending-create - 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-create - networkName - false - true - false - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - 107.239.52.1 - 107.239.52.0 - 24 - 4 - pending-create - true - subnetName - ECOMP - true - - - string - 192.10.16.0/24 - 192.10.16.100/24 - ip-address - 1505857301954 - - - string - 192.110.17.0/24 - 192.110.17.110/24 - ip-address - 1505857301954 - - - - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - 107.239.52.1 - 107.239.52.0 - 24 - 4 - pending-create - true - subnetName - true - - - string - 192.10.16.0/24 - 192.10.16.100/24 - ip-address - 1505857301954 - - - - - - - 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 queryIdAIIResponse_AlaCarte = -""" - - - - - - - - - - - - 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-create - networkName - false - true - false - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - 107.239.52.1 - 107.239.52.0 - 24 - 4 - pending-create - true - subnetName - - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - 107.239.52.1 - 107.239.52.0 - 24 - 4 - pending-create - 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 queryIdAIIResponse_segmentation = -""" - - - - - - - - - - - - 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-create - networkName - false - true - false - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - 107.239.52.1 - 107.239.52.0 - 24 - 4 - pending-create - true - subnetName - - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - 107.239.52.1 - 107.239.52.0 - 24 - 4 - pending-create - true - subnetName - - - - - - 1 - 1498507569188 - - - - - 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 queryIdAIIResponse_Ipv4 = -""" - - - - - - - - - - - - 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-create - networkName - false - true - false - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - 107.239.52.1 - 107.239.52.0 - 24 - ipv4 - pending-create - true - subnetName - - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - 107.239.52.1 - 107.239.52.0 - 24 - ipv4 - pending-create - 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 queryIdAIIResponse_SRIOV = -""" - - 6cb1ae5a-d2db-4eb6-97bf-d52a506a53d8 - MSO_TEST_1702_A_HnportalProviderNetwork.HNPortalPROVIDERNETWORK.SR_IOV_Provider2_1_net_17 - SR_IOV_Provider2_1 - HnportalProviderNetwork.HNPortalPROVIDERNETWORK.SR_IOV_Provider2_1 - AIC_SR_IOV - false - - 1487336177672 - PendingCreate - f70d7a32-0ac8-4bd5-a0fb-3c9336540d78 - 1.0 - Physnet21 - true - false - false - - - 10437 - MSO_TEST_1702_A_HnportalProviderNetwork.HNPortalPROVIDERNETWORK.SR_IOV_Provider2_1_net_17_S0 - 192.168.6.1 - 192.168.6.0 - 26 - 4 - PendingCreate - true - 192.168.6.3 - 192.168.6.62 - 1487336177359 - - - - - tenant - https://aai-ext1.test.com:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn16/tenants/tenant/6accefef3cb442ff9e644d589fb04107 - - cloud-region.cloud-owner - att-aic - - - cloud-region.cloud-region-id - mtn16 - - - tenant.tenant-id - 6accefef3cb442ff9e644d589fb04107 - - - tenant.tenant-name - MSO_TEST_1702_A - - - - cloud-region - https://aai-ext1.test.com:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/mtn16 - - cloud-region.cloud-owner - att-aic - - - cloud-region.cloud-region-id - mtn16 - - - cloud-region.owner-defined-type - lcp - - - - service-instance - https://aai-ext1.test.com:8443/aai/v8/business/customers/customer/MSO_1610_ST/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/51d8336b-a993-4afe-a5fc-10b3afbd6560 - - customer.global-customer-id - MSO_1610_ST - - - service-subscription.service-type - MSO-dev-service-type - - - service-instance.service-instance-id - 51d8336b-a993-4afe-a5fc-10b3afbd6560 - - - service-instance.service-instance-name - HnportalProviderNetwork_17 - - - -""" - - 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-create - networkName - false - true - false - - - cb1a7b47-5428-44c9-89c2-8b17541c3228 - 108.239.40.1 - 108.239.40.0 - 28 - 4 - pending-create - 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-create - true - 2606:ae00:2e01:604:: - 2606:ae00:2e01:604:: - 1465398611 - subnetName - - - - - - 416 - 4132176 - - - - cloud-region - https://localhost: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://localhost: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://localhost: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 - 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 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-create - networkName - false - true - false - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - 107.239.52.1 - 107.239.52.0 - 24 - 4 - pending-create - 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-create - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - 107.239.52.1 - 107.239.52.0 - 24 - 4 - pending-create - 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 createDBRequestError01 = - """ - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - BPMN - Received error unexpectedly from SDN-C. - - FAILED - <network-id></network-id><network-name></network-names> - - - """ - - String createDBRequest_Outputs = - """ - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - BPMN - Network successfully created. - - COMPLETED - 100 - <network-id>networkId</network-id><network-name>MNS-25180-L-01-dmz_direct_net_1</network-names> - networkId - - -""" - - String createNetworkRequest = - """ - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - sn5256d1-5a33-55df-13ab-12abad84e222 - 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 - true - - 192.10.16.0/24 - 192.10.16.100/24 - - - 192.110.17.0/24 - 192.110.17.110/24 - - - - - - - - 107.239.52.0/24 - true - 107.239.52.1 - 4 - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - subnetName - true - - 192.10.16.0/24 - 192.10.16.100/24 - - - true - true - false - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - - messageId_generated - -""" - -String createNetworkRequest_Ipv4 = -""" - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - sn5256d1-5a33-55df-13ab-12abad84e222 - 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 - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - - messageId_generated - -""" - -String createNetworkRequestAlaCarte = -""" - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - f21df226-8093-48c3-be7e-0408fcda0422 - 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 - - someValue1 - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - - messageId_generated - -""" - -String createNetworkRequest_SRIOV = -""" - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - 6cb1ae5a-d2db-4eb6-97bf-d52a506a53d8 - MSO_TEST_1702_A_HnportalProviderNetwork.HNPortalPROVIDERNETWORK.SR_IOV_Provider2_1_net_17 - CONTRAIL_EXTERNAL - sn5256d1-5a33-55df-13ab-12abad84e222 - AIC_SR_IOV - - Physnet21 - - - - - 192.168.6.3 - 192.168.6.62 - - 192.168.6.0/26 - true - 192.168.6.1 - 4 - 10437 - MSO_TEST_1702_A_HnportalProviderNetwork.HNPortalPROVIDERNETWORK.SR_IOV_Provider2_1_net_17_S0 - - true - true - false - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - - messageId_generated - -""" - - String createNetworkRequest_noPhysicalName = - """ - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - 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 createNetworkResponseREST = - """ - 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 - - true - - - 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 createRollbackNetworkRequest = - """ - - 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 createNetworkResponse = - """ - 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 - Created - 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 - Created - true - ECOMP - 1505857301954 - subnetName - true - - - string - 192.10.16.0/24 - 192.10.16.100/24 - ip-address - 1505857301954 - - - string - 192.110.17.0/24 - 192.110.17.110/24 - ip-address - 1505857301954 - - - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 - 107.239.52.1 - 107.239.52.0 - 24 - 4 - Created - true - 1505857301954 - subnetName - true - - - string - 192.10.16.0/24 - 192.10.16.100/24 - ip-address - 1505857301954 - - - - - - 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 updateContrailAAIPayloadRequest_segmentation = -""" - 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 - Created - 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 - Created - true - subnetName - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 - 107.239.52.1 - 107.239.52.0 - 24 - 4 - Created - true - subnetName - - - - - 1 - 1498507569188 - - - - - 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 createNetworkErrorResponse = - """ - 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.onap.so/network", the namespace on the "createNetworkContrail" 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 assignSDNCRequest = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - assign - 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 - - - networkId - CONTRAIL_EXTERNAL - MNS-25180-L-01-dmz_direct_net_1 - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - -""" - -String assignSDNCRequest_decodeUrlLink = -""" - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - assign - network-topology-operation - sdncCallback - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - NetworkActivateRequest - VID - - - - - - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - VIRTUAL USP - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - MSO_1610_dev - - - networkId - CONTRAIL_EXTERNAL - MNS-25180-L-01-dmz_direct_net_1 - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - -""" - -String assignRpcSDNCRequest = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - assign - 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 - MSO_1610_dev - - - 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 activateSDNCRequest = -""" - - 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 - MSO_1610_dev - - - 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 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 sdncRpcRollbackRequest = -""" - - 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 - MSO_1610_dev - - - 8abc633a-810b-4ca5-8b3a-09511d13a2ce - 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 sdncActivateRollbackRequest = -""" - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - deactivate - 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 - MSO_1610_dev - - - 8abc633a-810b-4ca5-8b3a-09511d13a2ce - 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 - - <output xmlns="com:att: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 sdncAdapterWorkflowAssignResponse = -""" - - - 79ec9006-3695-4fcc-93a8-be6f9e248beb - 200 - OK - - - - - 79ec9006-3695-4fcc-93a8-be6f9e248beb - - f805ec2b-b4d8-473e-8325-67f110139e5d - - 200 - - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - restconf/config/GENERIC-RESOURCE-API:services/service/f805ec2b-b4d8-473e-8325-67f110139e5d/service-data/networks/network/f7e4db56-aab5-4065-8e65-cec1cd1de24f - - Y - - - -""" - - String rollbackNetworkRequest = -""" - - 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 rollbackActivateSDNCRequest = -""" - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - rollback - network-topology-operation - sdncCallback - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - CreateNetworkInstance - 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 - - invariant-uuid - customization-uuid - uuid - version - CONTRAIL_EXTERNAL - - - - 8abc633a-810b-4ca5-8b3a-09511d13a2ce - CONTRAIL_EXTERNAL - MNS-25180-L-01-dmz_direct_net_1 - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - -""" - - String rollbackSDNCRequest = -""" - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - rollback - network-topology-operation - sdncCallback - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - CreateNetworkInstance - 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 - - invariant-uuid - customization-uuid - uuid - version - CONTRAIL_EXTERNAL - - - - 8abc633a-810b-4ca5-8b3a-09511d13a2ce - CONTRAIL_EXTERNAL - MNS-25180-L-01-dmz_direct_net_1 - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - -""" - -// - - - - - - - - - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - - public void initializeVariables (DelegateExecution mockExecution) { - - verify(mockExecution).setVariable(Prefix + "networkRequest", "") - verify(mockExecution).setVariable(Prefix + "rollbackEnabled", null) - verify(mockExecution).setVariable(Prefix + "networkInputs", "") - //verify(mockExecution).setVariable(Prefix + "requestId", "") - verify(mockExecution).setVariable(Prefix + "messageId", "") - verify(mockExecution).setVariable(Prefix + "source", "") - verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "") - verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "") - verify(mockExecution).setVariable(Prefix + "serviceInstanceId","") - verify(mockExecution).setVariable("GENGS_type","") - verify(mockExecution).setVariable(Prefix + "rsrc_endpoint", null) - verify(mockExecution).setVariable(Prefix + "networkOutputs", "") - verify(mockExecution).setVariable(Prefix + "networkId","") - verify(mockExecution).setVariable(Prefix + "networkName","") - - // AAI query Name - verify(mockExecution).setVariable(Prefix + "queryNameAAIRequest","") - verify(mockExecution).setVariable(Prefix + "queryNameAAIResponse", "") - verify(mockExecution).setVariable(Prefix + "aaiNameReturnCode", "") - verify(mockExecution).setVariable(Prefix + "isAAIqueryNameGood", 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 + "isCloudRegionGood", false) - - // AAI query Id - verify(mockExecution).setVariable(Prefix + "queryIdAAIRequest","") - verify(mockExecution).setVariable(Prefix + "queryIdAAIResponse", "") - verify(mockExecution).setVariable(Prefix + "aaiIdReturnCode", "") - - // AAI query vpn binding - verify(mockExecution).setVariable(Prefix + "queryVpnBindingAAIRequest","") - verify(mockExecution).setVariable(Prefix + "queryVpnBindingAAIResponse", "") - verify(mockExecution).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "") - verify(mockExecution).setVariable(Prefix + "vpnBindings", null) - verify(mockExecution).setVariable(Prefix + "vpnCount", 0) - verify(mockExecution).setVariable(Prefix + "routeCollection", "") - - // AAI query network policy - verify(mockExecution).setVariable(Prefix + "queryNetworkPolicyAAIRequest","") - verify(mockExecution).setVariable(Prefix + "queryNetworkPolicyAAIResponse", "") - verify(mockExecution).setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "") - verify(mockExecution).setVariable(Prefix + "networkPolicyUriList", null) - verify(mockExecution).setVariable(Prefix + "networkPolicyCount", 0) - verify(mockExecution).setVariable(Prefix + "networkCollection", "") - - // AAI query route table reference - verify(mockExecution).setVariable(Prefix + "queryNetworkTableRefAAIRequest","") - verify(mockExecution).setVariable(Prefix + "queryNetworkTableRefAAIResponse", "") - verify(mockExecution).setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "") - verify(mockExecution).setVariable(Prefix + "networkTableRefUriList", null) - verify(mockExecution).setVariable(Prefix + "networkTableRefCount", 0) - verify(mockExecution).setVariable(Prefix + "tableRefCollection", "") - - // AAI requery Id - verify(mockExecution).setVariable(Prefix + "requeryIdAAIRequest","") - verify(mockExecution).setVariable(Prefix + "requeryIdAAIResponse", "") - verify(mockExecution).setVariable(Prefix + "aaiRequeryIdReturnCode", "") - - // AAI update contrail - verify(mockExecution).setVariable(Prefix + "updateContrailAAIUrlRequest","") - verify(mockExecution).setVariable(Prefix + "updateContrailAAIPayloadRequest","") - verify(mockExecution).setVariable(Prefix + "updateContrailAAIResponse", "") - verify(mockExecution).setVariable(Prefix + "aaiUpdateContrailReturnCode", "") - - verify(mockExecution).setVariable(Prefix + "createNetworkRequest", "") - verify(mockExecution).setVariable(Prefix + "createNetworkResponse", "") - verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", "") - //verify(mockExecution).setVariable(Prefix + "rollbackNetworkResponse", "") - verify(mockExecution).setVariable(Prefix + "networkReturnCode", "") - //verify(mockExecution).setVariable(Prefix + "rollbackNetworkReturnCode", "") - verify(mockExecution).setVariable(Prefix + "isNetworkRollbackNeeded", false) - - verify(mockExecution).setVariable(Prefix + "assignSDNCRequest", "") - verify(mockExecution).setVariable(Prefix + "assignSDNCResponse", "") - verify(mockExecution).setVariable(Prefix + "rollbackSDNCRequest", "") - //verify(mockExecution).setVariable(Prefix + "rollbackSDNCResponse", "") - verify(mockExecution).setVariable(Prefix + "sdncReturnCode", "") - //verify(mockExecution).setVariable(Prefix + "rollbackSDNCReturnCode", "") - verify(mockExecution).setVariable(Prefix + "isSdncRollbackNeeded", false) - verify(mockExecution).setVariable(Prefix + "sdncResponseSuccess", false) - - verify(mockExecution).setVariable(Prefix + "activateSDNCRequest", "") - verify(mockExecution).setVariable(Prefix + "activateSDNCResponse", "") - verify(mockExecution).setVariable(Prefix + "rollbackActivateSDNCRequest", "") - //verify(mockExecution).setVariable(Prefix + "rollbackActivateSDNCResponse", "") - verify(mockExecution).setVariable(Prefix + "sdncActivateReturnCode", "") - //verify(mockExecution).setVariable(Prefix + "rollbackActivateSDNCReturnCode", "") - verify(mockExecution).setVariable(Prefix + "isSdncActivateRollbackNeeded", false) - verify(mockExecution).setVariable(Prefix + "sdncActivateResponseSuccess", false) - - verify(mockExecution).setVariable(Prefix + "orchestrationStatus", "") - verify(mockExecution).setVariable(Prefix + "isVnfBindingPresent", false) - verify(mockExecution).setVariable(Prefix + "Success", false) - - verify(mockExecution).setVariable(Prefix + "isException", false) - - } - - @Test - //@Ignore - public void preProcessRequest_vIPR_NetworkRequest() { - - println "************ preProcessRequest_Payload ************* " - - 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() - - def serviceModelInfo = """{"modelUuid": "36a3a8ea-49a6-4ac8-b06c-89a54544b9b6", - "modelName": "HNGW Protected OAM", - "modelType": "service", - "modelVersion": "1.0", - "modelInvariantUuid": "fcc85cb0-ad74-45d7-a5a1-17c8744fdb71" - }""".trim() - - - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - - // Pre-defined value, testing Only - 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("networkId") // 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("serviceModelInfo")).thenReturn(serviceModelInfo) - when(mockExecution.getVariable("sdncVersion")).thenReturn("1702") - when(mockExecution.getVariable("action")).thenReturn("CREATE") - when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("MSO-dev-service-type") - when(mockExecution.getVariable("globalSubscriberId")).thenReturn("globalId_45678905678") - - when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - when(mockExecution.getVariable("mso.rollback")).thenReturn("true") - when(mockExecution.getVariable("mso.adapters.sdnc.endpoint")).thenReturn("http://localhost:8090/SDNCAdapter") - when(mockExecution.getVariable("mso.adapters.network.rest.endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") - when(mockExecution.getVariable("mso.adapters.sdnc.resource.endpoint")).thenReturn("http://localhost:8090/SDNCAdapterRpc") - - - // preProcessRequest(DelegateExecution execution) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.preProcessRequest(mockExecution) - -// verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix) - - //verify variable initialization - initializeVariables(mockExecution) - - verify(mockExecution).setVariable("action", "CREATE") - verify(mockExecution).setVariable(Prefix + "networkId","") - verify(mockExecution).setVariable(Prefix + "networkRequest", expectedvIPRNetworkRequest) - verify(mockExecution, atLeast(1)).setVariable(Prefix + "rollbackEnabled", false) - verify(mockExecution).setVariable(Prefix + "networkInputs", expectedvIPRNetworkInputs) - //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 + "messageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") - verify(mockExecution).setVariable(Prefix + "source", "VID") - verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") - verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") - verify(mockExecution).setVariable(Prefix + "serviceInstanceId","f70e927b-6087-4974-9ef8-c5e4d5847ca4") - verify(mockExecution, atLeast(1)).setVariable("GENGS_type", "service-instance") - //verify(mockExecution, atLeast(1)).setVariable("mso-request-id", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") - //verify(mockExecution, atLeast(1)).setVariable("msoRequestId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") - //verify(mockExecution).setVariable("mso-service-instance-id","88f65519-9a38-4c4b-8445-9eb4a5a5af56") - verify(mockExecution).setVariable(Prefix + "networkId","") - verify(mockExecution).setVariable(Prefix + "networkOutputs", networkvIPROutputs) - verify(mockExecution).setVariable(Prefix + "networkName","") - - } - - @Test - //@Ignore - public void preProcessRequest_JSON_NetworkRequest() { - - println "************ preProcessRequest_Payload ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - - // Pre-defined value, testing Only - when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - // Inputs: - // when(mockExecution.getVariable("requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") - when(mockExecution.getVariable("requestAction")).thenReturn("CREATE") - when(mockExecution.getVariable("networkId")).thenReturn("networkId") // optional - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest) // JSON format - when(mockExecution.getVariable("sdncVersion")).thenReturn("1610") // 1610 default - when(mockExecution.getVariable("disableRollback")).thenReturn(true) - - when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - when(mockExecution.getVariable("mso.rollback")).thenReturn("true") - when(mockExecution.getVariable("mso.adapters.sdnc.endpoint")).thenReturn("http://localhost:8090/SDNCAdapter") - when(mockExecution.getVariable("mso.adapters.network.rest.endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") - when(mockExecution.getVariable("mso.adapters.sdnc.resource.endpoint")).thenReturn("http://localhost:8090/SDNCAdapterRpc") - - // preProcessRequest(DelegateExecution execution) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.preProcessRequest(mockExecution) - -// verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix) - - //verify variable initialization - initializeVariables(mockExecution) - - verify(mockExecution).setVariable("action", "CREATE") - verify(mockExecution).setVariable(Prefix + "networkRequest", expectedJSONNetworkRequest) - verify(mockExecution).setVariable(Prefix + "rollbackEnabled", false) - verify(mockExecution).setVariable(Prefix + "networkInputs", expectedJSONNetworkInputs) - //verify(mockExecution).setVariable(Prefix + "requestId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") - //verify(mockExecution).setVariable(Prefix + "messageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") - verify(mockExecution).setVariable(Prefix + "source", "VID") - verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") - verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") - verify(mockExecution).setVariable(Prefix + "serviceInstanceId","f70e927b-6087-4974-9ef8-c5e4d5847ca4") - verify(mockExecution, atLeast(1)).setVariable("GENGS_type", "service-instance") - //verify(mockExecution, atLeast(1)).setVariable("msoRequestId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") - //verify(mockExecution).setVariable("mso-service-instance-id","88f65519-9a38-4c4b-8445-9eb4a5a5af56") - verify(mockExecution).setVariable(Prefix + "networkId","") - verify(mockExecution).setVariable(Prefix + "networkOutputs", networkJSONOutputs) - verify(mockExecution).setVariable(Prefix + "networkName","") - - - } - - @Test - //@Ignore - public void preProcessRequest_XML_NetworkRequest() { - - println "************ preProcessRequest_Payload ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - - // Pre-defined value, testing Only - when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - // Inputs: - // when(mockExecution.getVariable("msoRequestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("bpmnRequest")).thenReturn(xmlIncomingRequest) // XML format - - when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - when(mockExecution.getVariable("mso.rollback")).thenReturn("true") - when(mockExecution.getVariable("mso.adapters.sdnc.endpoint")).thenReturn("http://localhost:8090/SDNCAdapter") - when(mockExecution.getVariable("mso.adapters.network.rest.endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") - when(mockExecution.getVariable("mso.adapters.sdnc.resource.endpoint")).thenReturn("http://localhost:8090/SDNCAdapterRpc") - - // preProcessRequest(DelegateExecution execution) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.preProcessRequest(mockExecution) - -// verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix) - - //verify variable initialization - initializeVariables(mockExecution) - - verify(mockExecution).setVariable("action", "CREATE") - verify(mockExecution).setVariable(Prefix + "networkRequest", expectedXMLNetworkRequest) - verify(mockExecution).setVariable(Prefix + "rollbackEnabled", true) - verify(mockExecution).setVariable(Prefix + "networkInputs", expectedXMLNetworkInputs) - //verify(mockExecution).setVariable(Prefix + "requestId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") - verify(mockExecution).setVariable(Prefix + "messageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") - verify(mockExecution).setVariable(Prefix + "source", "PORTAL") - verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") - verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") - verify(mockExecution).setVariable(Prefix + "serviceInstanceId","MNS-25180-L-01-dmz_direct_net_1") - verify(mockExecution, atLeast(1)).setVariable("GENGS_type", "service-instance") - //verify(mockExecution).setVariable("mso-service-instance-id","88f65519-9a38-4c4b-8445-9eb4a5a5af56") - verify(mockExecution, atLeast(1)).setVariable(Prefix + "networkId","") - verify(mockExecution).setVariable(Prefix + "networkOutputs", networkXMLOutputs) - verify(mockExecution).setVariable(Prefix + "networkName","") - - } - - - - @Test - //@Ignore - public void prepareCreateNetworkRequest() { - - println "************ prepareNetworkRequest ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedvIPRNetworkRequest) - when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).thenReturn(queryIdAIIResponse) - when(mockExecution.getVariable(Prefix + "cloudRegionPo")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("messageId_generated") - when(mockExecution.getVariable(Prefix + "source")).thenReturn("VID") - //when(mockExecution.getVariable(Prefix + "queryVpnBindingAAIResponse")).thenReturn(queryVpnBindingAAIResponse) - when(mockExecution.getVariable(Prefix + "routeCollection")).thenReturn("13979:10575713979:105757") - when(mockExecution.getVariable(Prefix + "networkCollection")).thenReturn("GN_EVPN_Test") - when(mockExecution.getVariable(Prefix + "tableRefCollection")).thenReturn("refFQDN1refFQDN2") - when(mockExecution.getVariable(Prefix + "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(Prefix + "rollbackEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - - // preProcessRequest(DelegateExecution execution) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.prepareCreateNetworkRequest(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution).setVariable("prefix", Prefix) - - verify(mockExecution).setVariable(Prefix + "createNetworkRequest", createNetworkRequest) - - } - - - @Test - //@Ignore - public void prepareCreateNetworkRequest_Ipv4() { - - println "************ prepareNetworkRequest ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedvIPRNetworkRequest) - when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).thenReturn(queryIdAIIResponse_Ipv4) - when(mockExecution.getVariable(Prefix + "cloudRegionPo")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("messageId_generated") - when(mockExecution.getVariable(Prefix + "source")).thenReturn("VID") - //when(mockExecution.getVariable(Prefix + "queryVpnBindingAAIResponse")).thenReturn(queryVpnBindingAAIResponse) - when(mockExecution.getVariable(Prefix + "routeCollection")).thenReturn("13979:10575713979:105757") - when(mockExecution.getVariable(Prefix + "networkCollection")).thenReturn("GN_EVPN_Test") - when(mockExecution.getVariable(Prefix + "tableRefCollection")).thenReturn("refFQDN1refFQDN2") - when(mockExecution.getVariable(Prefix + "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(Prefix + "rollbackEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - - // preProcessRequest(DelegateExecution execution) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.prepareCreateNetworkRequest(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution).setVariable("prefix", Prefix) - - verify(mockExecution).setVariable(Prefix + "createNetworkRequest", createNetworkRequest_Ipv4) - - } - - @Test - //@Ignore - public void prepareCreateNetworkRequest_AlaCarte() { - - println "************ prepareNetworkRequest ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedJSONNetworkRequest) - when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).thenReturn(queryIdAIIResponse_AlaCarte) - when(mockExecution.getVariable(Prefix + "cloudRegionPo")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("messageId_generated") - when(mockExecution.getVariable(Prefix + "source")).thenReturn("VID") - //when(mockExecution.getVariable(Prefix + "queryVpnBindingAAIResponse")).thenReturn(queryVpnBindingAAIResponse) - when(mockExecution.getVariable(Prefix + "routeCollection")).thenReturn("13979:10575713979:105757") - when(mockExecution.getVariable(Prefix + "networkCollection")).thenReturn("GN_EVPN_Test") - when(mockExecution.getVariable(Prefix + "tableRefCollection")).thenReturn("refFQDN1refFQDN2") - when(mockExecution.getVariable(Prefix + "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(Prefix + "rollbackEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - - // preProcessRequest(DelegateExecution execution) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.prepareCreateNetworkRequest(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution).setVariable("prefix", Prefix) - - verify(mockExecution).setVariable(Prefix + "createNetworkRequest", createNetworkRequestAlaCarte) - - } - - @Test - //@Ignore - public void prepareCreateNetworkRequest_SRIOV() { - - println "************ prepareNetworkRequest ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedvIPRNetworkRequest) - when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).thenReturn(queryIdAIIResponse_SRIOV) - when(mockExecution.getVariable(Prefix + "cloudRegionPo")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("messageId_generated") - when(mockExecution.getVariable(Prefix + "source")).thenReturn("VID") - //when(mockExecution.getVariable(Prefix + "queryVpnBindingAAIResponse")).thenReturn(queryVpnBindingAAIResponse) - when(mockExecution.getVariable(Prefix + "routeCollection")).thenReturn("13979:10575713979:105757") - when(mockExecution.getVariable(Prefix + "networkCollection")).thenReturn("GN_EVPN_Test") - when(mockExecution.getVariable(Prefix + "tableRefCollection")).thenReturn("refFQDN1refFQDN2") - when(mockExecution.getVariable(Prefix + "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(Prefix + "rollbackEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - - // preProcessRequest(DelegateExecution execution) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.prepareCreateNetworkRequest(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution).setVariable("prefix", Prefix) - - verify(mockExecution).setVariable(Prefix + "createNetworkRequest", createNetworkRequest_SRIOV) - - } - - - @Test - //@Ignore - public void prepareSDNCRequest() { - - println "************ prepareSDNCRequest ************* " - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedvIPRNetworkRequest) - when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable(Prefix + "serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") - when(mockExecution.getVariable(Prefix + "networkId")).thenReturn("networkId") - 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("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/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(DelegateExecution execution) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.prepareSDNCRequest(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "assignSDNCRequest", assignSDNCRequest) - - } - - @Test - //@Ignore - public void prepareSDNCRequest_decodeUrlLink() { - - println "************ prepareSDNCRequest ************* " - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedvIPRNetworkRequest) - when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable(Prefix + "serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") - when(mockExecution.getVariable(Prefix + "networkId")).thenReturn("networkId") - 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("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/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/VIRTUAL%20USP/service-instances/service-instance/6d4eb22a-82f1-4257-9f80-4176262cfe69/") - - - // preProcessRequest(DelegateExecution execution) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.prepareSDNCRequest(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "assignSDNCRequest", assignSDNCRequest_decodeUrlLink) - - } - - @Test - //@Ignore - public void prepareRpcSDNCRequest() { - - println "************ prepareRpcSDNCRequest ************* " - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedvIPRNetworkRequest) - when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable(Prefix + "serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") - 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(Prefix + "networkId")).thenReturn("networkId") - when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/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(DelegateExecution execution) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.prepareRpcSDNCRequest(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "assignSDNCRequest", assignRpcSDNCRequest) - - } - - @Test - //@Ignore - public void prepareSDNCRollbackRequest() { - - println "************ prepareSDNCRollbackRequest ************* " - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedvIPRNetworkRequest) - when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable(Prefix + "serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") - when(mockExecution.getVariable(Prefix + "assignSDNCResponse")).thenReturn(assignResponse) - 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("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/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(DelegateExecution execution) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.prepareSDNCRollbackRequest(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "rollbackSDNCRequest", sdncRollbackRequest) - - } - - @Test - //@Ignore - public void prepareRpcSDNCActivateRequest() { - - println "************ prepareRpcSDNCActivateRequest ************* " - - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedvIPRNetworkRequest) - when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable(Prefix + "serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") - when(mockExecution.getVariable(Prefix + "networkId")).thenReturn("networkId") - 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("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(DelegateExecution execution) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.prepareRpcSDNCActivateRequest(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "activateSDNCRequest", activateSDNCRequest) - - } - - - @Test - //@Ignore - public void prepareRpcSDNCRollbackRequest() { - - println "************ prepareRpcSDNCRollbackRequest ************* " - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedvIPRNetworkRequest) - when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable(Prefix + "serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") - when(mockExecution.getVariable(Prefix + "assignSDNCResponse")).thenReturn(assignResponse) - 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("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") // test ONLY - when(mockExecution.getVariable("msoRequestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/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(DelegateExecution execution) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.prepareRpcSDNCRollbackRequest(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "rollbackSDNCRequest", sdncRpcRollbackRequest) - - } - - @Test - //@Ignore - public void prepareRpcSDNCActivateRollback() { - - println "************ prepareRpcSDNCActivateRollback ************* " - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedvIPRNetworkRequest) - when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable(Prefix + "serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") - when(mockExecution.getVariable(Prefix + "activateSDNCResponse")).thenReturn(assignResponse) - 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("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(DelegateExecution execution) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.prepareRpcSDNCActivateRollback(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 + "rollbackActivateSDNCRequest", sdncActivateRollbackRequest) - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkName_200() { - - println "************ callRESTQueryAAINetworkName ************* " - - WireMock.reset(); - MockGetNetworkByName("MNS-25180-L-01-dmz_direct_net_1", "CreateNetworkV2/createNetwork_queryName_AAIResponse_Success.xml"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(networkInputs) - 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.DoCreateNetworkInstance.aai.network.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") - when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.l3-network.uri")).thenReturn("/aai/v8/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") - - // preProcessRequest(DelegateExecution execution) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.callRESTQueryAAINetworkName(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "queryNameAAIRequest", "http://localhost:8090/aai/v8/network/l3-networks/l3-network?network-name=MNS-25180-L-01-dmz_direct_net_1") - - verify(mockExecution).setVariable(Prefix + "aaiNameReturnCode", "200") - verify(mockExecution).setVariable(Prefix + "orchestrationStatus", "PENDING-CREATE") - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkName_404() { - - println "************ callRESTQueryAAINetworkName ************* " - - WireMock.reset(); - MockGetNetworkByName_404("CreateNetworkV2/createNetwork_queryName_AAIResponse_Success.xml", "myOwn_Network"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(networkInputs_404) - 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.DoCreateNetworkInstance.aai.network.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") - when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.l3-network.uri")).thenReturn("/aai/v8/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") - - // preProcessRequest(DelegateExecution execution) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.callRESTQueryAAINetworkName(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "queryNameAAIRequest", "http://localhost:8090/aai/v8/network/l3-networks/l3-network?network-name=myOwn_Network") - verify(mockExecution).setVariable(Prefix + "aaiNameReturnCode", "404") - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkId_200() { - - println "************ callRESTQueryAAINetworkId ************* " - - WireMock.reset(); - MockGetNetworkByIdWithDepth("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_Success.xml", "all"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "assignSDNCResponse")).thenReturn(sdncAdapterWorkflowAssignResponse) - 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.DoCreateNetworkInstance.aai.network.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") - when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.l3-network.uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("sdncVersion")).thenReturn("1702") - 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) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.callRESTQueryAAINetworkId(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "queryIdAAIRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4"+"?depth=all") - verify(mockExecution).setVariable(Prefix + "aaiIdReturnCode", "200") - - } - - @Test - //@Ignore - public void callRESTQueryAAICloudRegion30_200() { - - println "************ callRESTQueryAAICloudRegion30_200 ************* " - - WireMock.reset(); - MockGetNetworkCloudRegion("CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml", "RDM2WAGPLCP"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(Prefix) - when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedvIPRNetworkRequest) - 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/att-aic") - 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/att-aic") - // - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - - // preProcessRequest(DelegateExecution execution) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) - verify(mockExecution, atLeast(2)).setVariable(Prefix + "queryCloudRegionReturnCode", "200") - verify(mockExecution).setVariable(Prefix + "isCloudRegionGood", true) - - } - - @Test - //@Ignore - public void callRESTQueryAAICloudRegion25_200() { - - println "************ callRESTQueryAAICloudRegion25_200 ************* " - - WireMock.reset(); - MockGetNetworkCloudRegion("CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml", "RDM2WAGPLCP"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(Prefix) - when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedvIPRNetworkRequest) - 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/att-aic") - 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/att-aic") - // - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - - // preProcessRequest(DelegateExecution execution) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) - verify(mockExecution, atLeast(2)).setVariable(Prefix + "queryCloudRegionReturnCode", "200") - verify(mockExecution).setVariable(Prefix + "isCloudRegionGood", true) - - } - - @Test - //@Ignore - public void callRESTQueryAAICloudRegion_NotFound() { - - println "************ callRESTQueryAAICloudRegionFake ************* " - - WireMock.reset(); - MockGetNetworkCloudRegion_404("MDTWNJ21") - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(Prefix) - when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(vnfRequestFakeRegion) - 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/att-aic") - 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/att-aic") - // - 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) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) - verify(mockExecution, atLeast(1)).setVariable(Prefix + "queryCloudRegionReturnCode", "404") - verify(mockExecution).setVariable(Prefix + "cloudRegionPo", "MDTWNJ21") - verify(mockExecution).setVariable(Prefix + "cloudRegionSdnc", "AAIAIC25") - verify(mockExecution).setVariable(Prefix + "isCloudRegionGood", true) - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkVpnBinding_200() { - - println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " - - WireMock.reset(); - MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); - MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "c980a6ef-3b88-49f0-9751-dbad8608d0a6"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).thenReturn(queryIdAIIResponse) // v6 - 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.vpn-binding.uri")).thenReturn("") - // old: when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.network.vpn-binding.uri")).thenReturn("") - when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.vpn-binding.uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") - 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) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "vpnCount", 2) - verify(mockExecution).setVariable(Prefix + "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(Prefix + "queryVpnBindingAAIRequest", "http://localhost:8090/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017?depth=all") - verify(mockExecution, atLeast(2)).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkVpnBindingList_200() { - - println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " - - WireMock.reset(); - MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBindingList_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); - MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBindingList_AAIResponse_Success.xml", "c980a6ef-3b88-49f0-9751-dbad8608d0a6"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).thenReturn(queryIdAIIResponse) // v6 - 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.DoCreateNetworkInstance.aai.vpn-binding.uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") - 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) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "vpnCount", 2) - verify(mockExecution).setVariable(Prefix + "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(Prefix + "queryVpnBindingAAIRequest", "http://localhost:8090/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017?depth=all") - verify(mockExecution, atLeast(2)).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkVpnBinding_TestScenario01_200() { - - println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " - - WireMock.reset(); - MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).thenReturn(queryIdAIIResponseTestScenario01) - 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.vpn-binding.uri")).thenReturn("") - // old: when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.network.vpn-binding.uri")).thenReturn("") - when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.vpn-binding.uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") - 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) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "vpnCount", 1) - verify(mockExecution).setVariable(Prefix + "vpnBindings", ['/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/']) - // the last vpnBinding value is saved. - verify(mockExecution).setVariable(Prefix + "queryVpnBindingAAIRequest", "http://localhost:8090/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017?depth=all") - verify(mockExecution).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkVpnBinding_200_URN_Uri() { - - println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " - - WireMock.reset(); - MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); - MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "c980a6ef-3b88-49f0-9751-dbad8608d0a6"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).thenReturn(queryIdAIIResponse) - 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.DoCreateNetworkInstance.aai.network.vpn-binding.uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") - //when(mockExecution.getVariable("mso.workflow.default.aai.network.vpn-binding.uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") - when(mockExecution.getVariable("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("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) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "vpnCount", 2) - verify(mockExecution).setVariable(Prefix + "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(Prefix + "queryVpnBindingAAIRequest", "http://localhost:8090/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017?depth=all") - verify(mockExecution, atLeast(2)).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkVpnBinding_NotPresent() { - - println "************ callRESTQueryAAINetworkVpnBinding_NotPresent ************* " - - WireMock.reset(); - MockGetNetworkVpnBinding("CreateNetworkV2/createNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); - - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - - when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).thenReturn(queryIdAIIResponseVpnNotPresent) - 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("/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/v8/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") - - // preProcessRequest(DelegateExecution execution) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") - verify(mockExecution).setVariable(Prefix + "vpnCount", 0) - verify(mockExecution).setVariable(Prefix + "queryVpnBindingAAIResponse", aaiVpnResponseStub) - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkPolicy_200() { - - println "************ callRESTQueryAAINetworkPolicy_200 ************* " - - WireMock.reset(); - MockGetNetworkPolicy("CreateNetworkV2/createNetwork_queryNetworkPolicy_AAIResponse_Success.xml", "cee6d136-e378-4678-a024-2cd15f0ee0cg"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).thenReturn(queryIdAIIResponse) - 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.DoCreateNetworkInstance.aai.network-policy.uri")).thenReturn("") - // old: when(mockExecution.getVariable("mso.workflow.default.aai.network-policy.uri")).thenReturn("/aai/v8/network/network-policies/network-policy") - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.network-policy.uri")).thenReturn("/aai/v8/network/network-policies/network-policy") - 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) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.callRESTQueryAAINetworkPolicy(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "networkPolicyCount", 1) - verify(mockExecution).setVariable(Prefix + "networkPolicyUriList", ['/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg']) - // the last vpnBinding value is saved. - verify(mockExecution).setVariable(Prefix + "queryNetworkPolicyAAIRequest", "http://localhost:8090/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg?depth=all") - verify(mockExecution).setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkTableRef_200() { - - println "************ callRESTQueryAAINetworkTableRef_200 ************* " - - WireMock.reset(); - MockGetNetworkTableReference("CreateNetworkV2/createNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", "refFQDN1"); - MockGetNetworkTableReference("CreateNetworkV2/createNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", "refFQDN2"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).thenReturn(queryIdAIIResponse) - 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-table-reference.uri")).thenReturn("") - // old: when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.network-table-reference.uri")).thenReturn("") - when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.route-table-reference.uri")).thenReturn("/aai/v8/network/route-table-references/route-table-reference") - 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) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.callRESTQueryAAINetworkTableRef(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "networkTableRefCount", 2) - verify(mockExecution).setVariable(Prefix + "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(Prefix + "queryNetworkTableRefAAIRequest", "http://localhost:8090/aai/v8/network/route-table-references/route-table-reference/refFQDN1?depth=all") - verify(mockExecution, atLeast(2)).setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") - - } - - @Test - //@Ignore - public void callRESTReQueryAAINetworkId_200() { - - println "************ callRESTReQueryAAINetworkId ************* " - - WireMock.reset(); - MockGetNetworkByIdWithDepth("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "CreateNetworkV2/createNetwork_queryNetworkId_AAIResponse_Success.xml", "all"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "networkId")).thenReturn("49c86598-f766-46f8-84f8-8d1c1b10f9b4") - 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.l3-network.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.l3-network.uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") - //old: when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.network.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("sdncVersion")).thenReturn("1702") - 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) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.callRESTReQueryAAINetworkId(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "requeryIdAAIRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4"+"?depth=all") - verify(mockExecution).setVariable(Prefix + "aaiRequeryIdReturnCode", "200") - - } - - @Test - //@Ignore - public void callRESTUpdateContrailAAINetworkREST_200() { - - println "************ callRESTUpdateContrailAAINetwork ************* " - - WireMock.reset(); - MockPutNetworkIdWithDepth("CreateNetworkV2/createNetwork_updateContrail_AAIResponse_Success.xml", "49c86598-f766-46f8-84f8-8d1c1b10f9b4", "all"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "networkId")).thenReturn("49c86598-f766-46f8-84f8-8d1c1b10f9b4") - when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - when(mockExecution.getVariable(Prefix + "createNetworkResponse")).thenReturn(createNetworkResponseREST) - 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.DoCreateNetworkInstance.aai.network.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") - when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.l3-network.uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable(Prefix + "rollbackEnabled")).thenReturn("false") - 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) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.callRESTUpdateContrailAAINetwork(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "updateContrailAAIUrlRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4"+"?depth=all") - verify(mockExecution).setVariable(Prefix + "updateContrailAAIPayloadRequest", updateContrailAAIPayloadRequest) - verify(mockExecution).setVariable(Prefix + "aaiUpdateContrailReturnCode", "200") - //verify(mockExecution).setVariable(Prefix + "updateContrailAAIResponse", updateContrailAAIResponse) - verify(mockExecution).setVariable(Prefix + "isPONR", true) - - } - - @Test - //@Ignore - public void callRESTUpdateContrailAAINetworkREST_200_segmentation() { - - println "************ callRESTUpdateContrailAAINetwork ************* " - - WireMock.reset(); - MockPutNetworkIdWithDepth("CreateNetworkV2/createNetwork_updateContrail_AAIResponse_Success.xml", "49c86598-f766-46f8-84f8-8d1c1b10f9b4", "all"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "networkId")).thenReturn("49c86598-f766-46f8-84f8-8d1c1b10f9b4") - when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse_segmentation) - when(mockExecution.getVariable(Prefix + "createNetworkResponse")).thenReturn(createNetworkResponseREST) - 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.DoCreateNetworkInstance.aai.network.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") - when(mockExecution.getVariable("mso.workflow.DoCreateNetworkInstance.aai.l3-network.uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable(Prefix + "rollbackEnabled")).thenReturn("false") - 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) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.callRESTUpdateContrailAAINetwork(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "updateContrailAAIUrlRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4"+"?depth=all") - verify(mockExecution).setVariable(Prefix + "updateContrailAAIPayloadRequest", updateContrailAAIPayloadRequest_segmentation) - verify(mockExecution).setVariable(Prefix + "aaiUpdateContrailReturnCode", "200") - //verify(mockExecution).setVariable(Prefix + "updateContrailAAIResponse", updateContrailAAIResponse) - verify(mockExecution).setVariable(Prefix + "isPONR", true) - - } - - - - @Test - //@Ignore - public void validateCreateNetworkResponseREST() { - - println "************ validateNetworkResponse ************* " - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable(Prefix + "createNetworkResponse")).thenReturn(createNetworkResponseREST) - when(mockExecution.getVariable(Prefix + "networkReturnCode")).thenReturn('200') - - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.validateCreateNetworkResponse(mockExecution) - - //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() - //debugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "createNetworkResponse", createNetworkResponseREST) - verify(mockExecution).setVariable(Prefix + "isNetworkRollbackNeeded", true) - verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", createRollbackNetworkRequest) - - } - - @Test - //@Ignore - public void validateCreateNetworkResponseREST_Error() { - - println "************ validateNetworkResponse ************* " - - WorkflowException workflowException = new WorkflowException("DoCreateNetworkInstance", 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(Prefix + "createNetworkResponse")).thenReturn(networkException500) - when(mockExecution.getVariable(Prefix + "networkReturnCode")).thenReturn('500') - - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - try { - DoCreateNetworkInstance.validateCreateNetworkResponse(mockExecution) - } catch (Exception ex) { - println " Test End - Handle catch-throw BpmnError()! " - } - - verify(mockExecution).setVariable("prefix", Prefix) - 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(Prefix + "assignSDNCResponse")).thenReturn(sdncAdapterWorkflowResponse) - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) - when(mockExecution.getVariable(Prefix + "sdncReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "isResponseGood")).thenReturn(true) - - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - try { - DoCreateNetworkInstance.validateSDNCResponse(mockExecution) - verify(mockExecution).setVariable(Prefix + "isSdncRollbackNeeded", 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 validateSDNCResponse_Error() { - - println "************ validateSDNCResponse ************* " - - WorkflowException workflowException = new WorkflowException("DoCreateNetworkInstance", 2500, "Received error from SNDC Adapter: HTTP Status 500.") - - //ExecutionEntity mockExecution = mock(ExecutionEntity.class) - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable(Prefix + "assignSDNCResponse")).thenReturn(sdncAdapterWorkflowResponse_Error) - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(false) - when(mockExecution.getVariable(Prefix + "sdncReturnCode")).thenReturn("200") - when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) - - - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - try { - DoCreateNetworkInstance.validateSDNCResponse(mockExecution) - } catch (Exception ex) { - println " Graceful Exit! - " + ex.getMessage() - } - //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() - //debugger.printInvocations(mockExecution) - - // verify set prefix = Prefix + "" - //verify(mockExecution).setVariable(Prefix + "sdncResponseSuccess", false) - - } - - @Test - //@Ignore - public void validateRpcSDNCActivateResponse() { - - println "************ validateRpcSDNCActivateResponse ************* " - - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable(Prefix + "activateSDNCResponse")).thenReturn(sdncAdapterWorkflowResponse) - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) - when(mockExecution.getVariable(Prefix + "sdncActivateReturnCode")).thenReturn("200") - - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - try { - DoCreateNetworkInstance.validateRpcSDNCActivateResponse(mockExecution) - verify(mockExecution).setVariable(Prefix + "isSdncActivateRollbackNeeded", 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 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 + "rollbackSDNCRequest")).thenReturn(rollbackSDNCRequest) - when(mockExecution.getVariable(Prefix + "rollbackActivateSDNCRequest")).thenReturn(rollbackActivateSDNCRequest) - when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn(rollbackNetworkRequest) - when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) - - // preProcessRequest(DelegateExecution execution) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.prepareRollbackData(mockExecution) - -// verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix) - - } - - @Test - public void postProcessResponse() { - - println "************ postProcessResponse() ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("testProcessKey")).thenReturn("DoCreateNetworkInstanceTest") - when(mockExecution.getVariable(Prefix + "isException")).thenReturn(false) - when(mockExecution.getVariable("sdncVersion")).thenReturn("1702") - when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn(sdncRpcRollbackRequest) - when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn(rollbackSDNCRequest) - when(mockExecution.getVariable(Prefix + "rollbackActivateSDNCRequest")).thenReturn(sdncActivateRollbackRequest) - - - // preProcessRequest(DelegateExecution execution) - DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() - DoCreateNetworkInstance.postProcessResponse(mockExecution) - -// verify(mockExecution,atLeastOnce()).getVariable("isDebugLogEnabled") - verify(mockExecution,atLeastOnce()).setVariable("prefix", Prefix) - verify(mockExecution,atLeastOnce()).setVariable(Prefix + "Success", true) - - } - - private ExecutionEntity setupMock() { - - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("DoCreateNetworkInstance") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoCreateNetworkInstance") - 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("DoCreateNetworkInstance") - when(mockExecution.getProcessInstanceId()).thenReturn("DoCreateNetworkInstance") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - } -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy deleted file mode 100644 index cc6f89865f..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateServiceInstanceTest.groovy +++ /dev/null @@ -1,135 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import com.github.tomakehurst.wiremock.junit.WireMockRule -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.junit.Assert -import org.junit.Before -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.Captor -import org.mockito.Mockito -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.core.domain.ModelInfo -import org.onap.so.bpmn.core.domain.ServiceDecomposition -import org.onap.so.bpmn.core.domain.ServiceInstance -import org.onap.so.bpmn.mock.StubResponseAAI - -import static org.mockito.Mockito.* - -@RunWith(MockitoJUnitRunner.class) -class DoCreateServiceInstanceTest { - def prefix = "DCRESI_" - - @Rule - public WireMockRule wireMockRule = new WireMockRule(28090) - - @Captor - static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) - - @Before - void init() throws IOException { - MockitoAnnotations.initMocks(this); - } - - @Test - void testPreProcessRequest() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(prefix) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("msoRequestId")).thenReturn("12345") - when(mockExecution.getVariable("serviceInstanceId")).thenReturn("MIS/1604/0026/SW_INTERNET") - when(mockExecution.getVariable("lcpCloudRegionId")).thenReturn("MDTWNJ21") - when(mockExecution.getVariable("mso-request-id")).thenReturn("testRequestId-1503410089303") - when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:28080/mso/SDNCAdapterCallbackService") - when(mockExecution.getVariable("globalSubscriberId")).thenReturn("MSO_dev") - when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("MSO-dev-service-type") - when(mockExecution.getVariable("productFamilyId")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable("sdnc.si.svc.types")).thenReturn("PORT-MIRROR,PPROBES") - - ServiceDecomposition decomposition = new ServiceDecomposition() - ModelInfo modelInfo = new ModelInfo() - ServiceInstance instance = new ServiceInstance() - instance.instanceId = "12345" - decomposition.modelInfo = modelInfo - decomposition.serviceInstance = instance - - when(mockExecution.getVariable("serviceDecomposition")).thenReturn(decomposition) - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") - when(mockExecution.getVariable("mso.workflow.default.aai.customer.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.customer.uri")).thenReturn('/aai/v8/business/customers/customer') - - - DoCreateServiceInstance obj = new DoCreateServiceInstance() - obj.preProcessRequest(mockExecution) - - verify(mockExecution).setVariable("prefix", prefix) - verify(mockExecution).setVariable("sdncCallbackUrl", "http://localhost:28080/mso/SDNCAdapterCallbackService") - } - - - - @Test - void testGetAAICustomerById() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(prefix) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("globalSubscriberId")).thenReturn("12345") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.customer.uri")).thenReturn("/aai/v9/business/customers/customer") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") - when(mockExecution.getVariable("mso.workflow.custom.DoCreateServiceInstance.aai.version")).thenReturn('8') - StubResponseAAI.MockGetCustomer("12345", "") - DoCreateServiceInstance obj = new DoCreateServiceInstance() - obj.getAAICustomerById(mockExecution) - - verify(mockExecution, times(1)).getVariable("aai.endpoint") - } - - private static ExecutionEntity setupMock() { - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("DoCreateServiceInstance") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoCreateServiceInstance") - 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("DoCreateServiceInstance") - when(mockExecution.getProcessInstanceId()).thenReturn("DoCreateServiceInstance") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - } -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstanceTest.groovy deleted file mode 100644 index 6d9d5e5356..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstanceTest.groovy +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import com.github.tomakehurst.wiremock.junit.WireMockRule -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.junit.Before -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.Captor -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse -import static com.github.tomakehurst.wiremock.client.WireMock.put -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.mockito.Mockito.mock -import static org.mockito.Mockito.times -import static org.mockito.Mockito.verify -import static org.mockito.Mockito.when - -/** - * @author sushilma - * @since January 10, 2018 - */ -@RunWith(MockitoJUnitRunner.class) -class DoCreateVFCNetworkServiceInstanceTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(28090) - @Before - public void init() throws IOException { - MockitoAnnotations.initMocks(this); - } - - @Captor - static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) - - @Test - public void testAddNSRelationship(){ - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("nsInstanceId")).thenReturn("NS12345") - when(mockExecution.getVariable("globalSubscriberId")).thenReturn("MSO_dev") - when(mockExecution.getVariable("serviceType")).thenReturn("MSO-dev-service-type") - when(mockExecution.getVariable("serviceId")).thenReturn("SER12345") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - MockPutServiceInstance("MSO_dev", "MSO-dev-service-type", "SER12345"); - DoCreateVFCNetworkServiceInstance DoCreateVFCNetworkServiceInstance = new DoCreateVFCNetworkServiceInstance() - DoCreateVFCNetworkServiceInstance.addNSRelationship(mockExecution); - verify(mockExecution, times(1)).getVariable("aai.endpoint") - verify(mockExecution, times(1)).getVariable("mso.msoKey") - verify(mockExecution, times(1)).getVariable("aai.auth") - } - - private ExecutionEntity setupMock() { - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("DoCreateVFCNetworkServiceInstance") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoCreateVFCNetworkServiceInstance") - when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") - ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) - when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - when(mockExecution.getId()).thenReturn("100") - when(mockExecution.getProcessDefinitionId()).thenReturn("DoCreateVFCNetworkServiceInstance") - when(mockExecution.getProcessInstanceId()).thenReturn("DoCreateVFCNetworkServiceInstance") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - return mockExecution - } - - public static void MockPutServiceInstance(String globalCustId, String subscriptionType, String serviceInstanceId) { - stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId+"/relationship-list/relationship")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml").withBody("") - )); - } -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy deleted file mode 100644 index c5c6187648..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleRollbackTest.groovy +++ /dev/null @@ -1,202 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import com.github.tomakehurst.wiremock.junit.WireMockRule -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.junit.Assert -import org.junit.Before -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.Captor -import org.mockito.Mockito -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.onap.so.bpmn.common.scripts.utils.XmlComparator -import org.onap.so.bpmn.core.RollbackData -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.mock.FileUtil - -import static com.github.tomakehurst.wiremock.client.WireMock.* -import static org.mockito.Mockito.* - -@RunWith(MockitoJUnitRunner.class) -class DoCreateVfModuleRollbackTest { - - def prefix = "DCVFMR_" - - @Rule - public WireMockRule wireMockRule = new WireMockRule(28090) - - @Captor - static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) - - @Before - void init() throws IOException { - MockitoAnnotations.initMocks(this); - } - - @Test - void testPrepSDNCAdapterRequest() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(prefix) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable(prefix + "serviceInstanceId")).thenReturn("12345") - when(mockExecution.getVariable("testReqId")).thenReturn("testReqId") - when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:28080/mso/SDNCAdapterCallbackService") - when(mockExecution.getVariable(prefix + "source")).thenReturn("VID") - when(mockExecution.getVariable(prefix + "tenantId")).thenReturn("fba1bd1e195a404cacb9ce17a9b2b421") - when(mockExecution.getVariable(prefix + "vnfType")).thenReturn("vRRaas") - when(mockExecution.getVariable(prefix + "vnfName")).thenReturn("skask-test") - when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") - when(mockExecution.getVariable(prefix + "vfModuleModelName")).thenReturn("PCRF::module-0-2") - when(mockExecution.getVariable(prefix + "requestId")).thenReturn("testRequestId") - when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("cb510af0-5b21-4bc7-86d9-323cb396ce32") - when(mockExecution.getVariable(prefix + "vfModuleName")).thenReturn("PCRF::module-0-2") - when(mockExecution.getVariable(prefix + "serviceId")).thenReturn("12345") - when(mockExecution.getVariable(prefix + "cloudSiteId")).thenReturn("RDM2WAGPLCP") - - when(mockExecution.getVariable(prefix + "rollbackSDNCRequestActivate")).thenReturn("true") - - - DoCreateVfModuleRollback obj = new DoCreateVfModuleRollback() - obj.prepSDNCAdapterRequest(mockExecution) - - Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture()) - String expectedValue = FileUtil.readResourceFile("__files/DoCreateVfModuleRollback/sdncAdapterWorkflowRequest.xml") - XmlComparator.assertXMLEquals(expectedValue, captor.getValue()) - } - - - - @Test - void testBuildSDNCRequest() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(prefix) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable(prefix + "serviceInstanceId")).thenReturn("12345") - when(mockExecution.getVariable("testReqId")).thenReturn("testReqId") - when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:28080/mso/SDNCAdapterCallbackService") - when(mockExecution.getVariable(prefix + "source")).thenReturn("VID") - when(mockExecution.getVariable(prefix + "vnfType")).thenReturn("vRRaas") - when(mockExecution.getVariable(prefix + "vnfName")).thenReturn("skask-test") - when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") - when(mockExecution.getVariable(prefix + "requestId")).thenReturn("testRequestId") - when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("cb510af0-5b21-4bc7-86d9-323cb396ce32") - when(mockExecution.getVariable(prefix + "vfModuleName")).thenReturn("PCRF::module-0-2") - when(mockExecution.getVariable(prefix + "serviceId")).thenReturn("12345") - - when(mockExecution.getVariable(prefix + "rollbackSDNCRequestActivate")).thenReturn("true") - - - DoCreateVfModuleRollback obj = new DoCreateVfModuleRollback() - String sdncRequest = obj.buildSDNCRequest(mockExecution, "svcInstId_test", "deactivate") - String expectedValue = FileUtil.readResourceFile("__files/DoCreateVfModuleRollback/deactivateSDNCRequest.xml") - XmlComparator.assertXMLEquals(expectedValue, sdncRequest) - } - - - - @Test - void testPrepVNFAdapterRequest() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(prefix) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable(prefix + "serviceInstanceId")).thenReturn("12345") - when(mockExecution.getVariable("testReqId")).thenReturn("testReqId") - when(mockExecution.getVariable("mso.use.qualified.host")).thenReturn("true") - when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") - when(mockExecution.getVariable(prefix + "requestId")).thenReturn("testRequestId") - when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("cb510af0-5b21-4bc7-86d9-323cb396ce32") - when(mockExecution.getVariable(prefix + "mso-request-id")).thenReturn("12345") - when(mockExecution.getVariable("mso.workflow.message.endpoint")).thenReturn('http://localhost:18080/mso/WorkflowMessage/') - - - DoCreateVfModuleRollback obj = new DoCreateVfModuleRollback() - String sdncRequest = obj.prepVNFAdapterRequest(mockExecution) - - Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture()) - String expectedValue = FileUtil.readResourceFile("__files/DoCreateVfModuleRollback/vnfAdapterRestV1Request.xml") - XmlComparator.assertXMLEquals(expectedValue, captor.getValue(), "messageId", "notificationUrl") - } - - @Test - void testDeleteNetworkPoliciesFromAAI() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(prefix) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("DCVFM_cloudSiteId")).thenReturn("12345") - when(mockExecution.getVariable("mso.workflow.DoCreateVfModuleRollback.aai.network-policy.uri")).thenReturn("/aai/v8/network/network-policies/network-policy") - when(mockExecution.getVariable("mso.workflow.custom.DoCreateVfModuleRollback.aai.version")).thenReturn("8") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") - when(mockExecution.getVariable("rollbackData")).thenReturn(new RollbackData()) - List fqdnList = new ArrayList() - fqdnList.add("test") - when(mockExecution.getVariable(prefix + "createdNetworkPolicyFqdnList")).thenReturn(fqdnList) - mockData() - DoCreateVfModuleRollback obj = new DoCreateVfModuleRollback() - obj.deleteNetworkPoliciesFromAAI(mockExecution) - - Mockito.verify(mockExecution).setVariable("prefix", prefix) - Mockito.verify(mockExecution).setVariable(prefix + "networkPolicyFqdnCount", 1) - Mockito.verify(mockExecution).setVariable(prefix + "aaiQueryNetworkPolicyByFqdnReturnCode", 200) - } - - - private static ExecutionEntity setupMock() { - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("DoCreateVfModuleRollback") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoCreateVfModuleRollback") - 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("DoCreateVfModuleRollback") - when(mockExecution.getProcessInstanceId()).thenReturn("DoCreateVfModuleRollback") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - } - - private static void mockData() { - stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy\\?network-policy-fqdn=.*")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml"))) - stubFor(delete(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*")) - .willReturn(aResponse() - .withStatus(200))); - - } -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleTest.groovy deleted file mode 100644 index 30e3779b53..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleTest.groovy +++ /dev/null @@ -1,229 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import com.github.tomakehurst.wiremock.junit.WireMockRule -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.junit.Assert -import org.junit.Before -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.Captor -import org.mockito.Mockito -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.onap.so.bpmn.common.scripts.utils.XmlComparator -import org.onap.so.bpmn.core.RollbackData -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.mock.FileUtil - -import static com.github.tomakehurst.wiremock.client.WireMock.* -import static org.mockito.Mockito.* - -@RunWith(MockitoJUnitRunner.class) -class DoCreateVfModuleTest { - def prefix = "DCVFM_" - - @Rule - public WireMockRule wireMockRule = new WireMockRule(28090) - - @Captor - static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) - - @Before - void init() throws IOException { - MockitoAnnotations.initMocks(this); - } - - @Test - void testQueryAAIVfModule() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(prefix) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("DCVFM_vnfId")).thenReturn("12345") - when(mockExecution.getVariable("mso.workflow.DoCreateVfModule.aai.generic-vnf.uri")).thenReturn("/aai/v9/network/generic-vnfs/generic-vnf") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") - - mockData() - DoCreateVfModule obj = new DoCreateVfModule() - obj.queryAAIVfModule(mockExecution) - Mockito.verify(mockExecution).setVariable("DCVFM_queryAAIVfModuleResponseCode", 200) - } - - - @Test - void testQueryAAIVfModuleForStatus() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(prefix) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("DCVFM_vnfId")).thenReturn("12345") - when(mockExecution.getVariable("DCVFM_vfModuleName")).thenReturn("module-0") - when(mockExecution.getVariable("mso.workflow.DoCreateVfModule.aai.generic-vnf.uri")).thenReturn("/aai/v9/network/generic-vnfs/generic-vnf") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") - - mockData() - DoCreateVfModule obj = new DoCreateVfModule() - obj.queryAAIVfModuleForStatus(mockExecution) - Mockito.verify(mockExecution).setVariable("DCVFM_orchestrationStatus", '') - Mockito.verify(mockExecution).setVariable("DCVFM_queryAAIVfModuleForStatusResponseCode", 200) - } - - - - @Test - void testPreProcessVNFAdapterRequest() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(prefix) - when(mockExecution.getVariable(prefix + "cloudSiteId")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("cb510af0-5b21-4bc7-86d9-323cb396ce32") - when(mockExecution.getVariable("volumeGroupStackId")).thenReturn("12345") - when(mockExecution.getVariable(prefix + "vfModuleName")).thenReturn("PCRF::module-0-2") - when(mockExecution.getVariable("lcpCloudRegionId")).thenReturn("MDTWNJ21") - when(mockExecution.getVariable(prefix + "tenantId")).thenReturn("fba1bd1e195a404cacb9ce17a9b2b421") - when(mockExecution.getVariable(prefix + "vnfType")).thenReturn("vRRaas") - when(mockExecution.getVariable(prefix + "vnfName")).thenReturn("skask-test") - when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") - when(mockExecution.getVariable(prefix + "vfModuleModelName")).thenReturn("PCRF::module-0-2") - when(mockExecution.getVariable(prefix + "vfModuleIndex")).thenReturn("index") - when(mockExecution.getVariable(prefix + "requestId")).thenReturn("testRequestId") - when(mockExecution.getVariable(prefix + "serviceId")).thenReturn("12345") - when(mockExecution.getVariable(prefix + "serviceInstanceId")).thenReturn("MIS/1604/0026/SW_INTERNET") - when(mockExecution.getVariable(prefix + "backoutOnFailure")).thenReturn("12345") - when(mockExecution.getVariable(prefix + "volumeGroupId")).thenReturn("12345") - when(mockExecution.getVariable(prefix + "asdcServiceModelVersion")).thenReturn("1.0") - when(mockExecution.getVariable(prefix + "modelCustomizationUuid")).thenReturn("cb510af0-5b21-4bc7-86d9-323cb396ced3") - when(mockExecution.getVariable("baseVfModuleId")).thenReturn("12345") - when(mockExecution.getVariable(prefix + "baseVfModuleHeatStackId")).thenReturn("12345") - String sdncGetResponse = FileUtil.readResourceFile("__files/DoCreateVfModule/sdncGetResponse.xml"); - when(mockExecution.getVariable(prefix + "getSDNCAdapterResponse")).thenReturn(sdncGetResponse) - Map map = new HashMap(); - map.put("vrr_image_name", "MDT17"); - map.put("availability_zone_0", "nova"); - map.put("vrr_flavor_name", "ns.c16r32d128.v1"); - when(mockExecution.getVariable("vnfParamsMap")).thenReturn(map) - when(mockExecution.getVariable("mso-request-id")).thenReturn("testRequestId-1503410089303") - when(mockExecution.getVariable("mso.use.qualified.host")).thenReturn("true") - when(mockExecution.getVariable("mso.workflow.message.endpoint")).thenReturn("http://localhost:28080/mso/WorkflowMesssage") - - mockData() - DoCreateVfModule obj = new DoCreateVfModule() - obj.preProcessVNFAdapterRequest(mockExecution) - - String createVnfARequest = FileUtil.readResourceFile("__files/DoCreateVfModule/createVnfARequest.xml") - Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture()) - XmlComparator.assertXMLEquals(createVnfARequest, captor.getValue(), "messageId", "notificationUrl") - } - - @Test - void testQueryCloudRegion() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(prefix) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("DCVFM_cloudSiteId")).thenReturn("12345") - when(mockExecution.getVariable("mso.workflow.DoCreateVfModule.aai.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") - - mockData() - DoCreateVfModule obj = new DoCreateVfModule() - obj.queryCloudRegion(mockExecution) - - Mockito.verify(mockExecution).setVariable("prefix", prefix) - Mockito.verify(mockExecution).setVariable(prefix + "queryCloudRegionRequest", "http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/12345") - Mockito.verify(mockExecution).setVariable(prefix + "queryCloudRegionReturnCode", "200") - } - - - - @Test - void testCreateNetworkPoliciesInAAI() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(prefix) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("DCVFM_cloudSiteId")).thenReturn("12345") - when(mockExecution.getVariable("mso.workflow.DoCreateVfModule.aai.network-policy.uri")).thenReturn("/aai/v8/network/network-policies/network-policy") - when(mockExecution.getVariable("mso.workflow.custom.DoCreateVfModule.aai.version")).thenReturn("8") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") - when(mockExecution.getVariable("rollbackData")).thenReturn(new RollbackData()) - List fqdnList = new ArrayList() - fqdnList.add("test") - when(mockExecution.getVariable("DCVFM_contrailNetworkPolicyFqdnList")).thenReturn(fqdnList) - - mockData() - DoCreateVfModule obj = new DoCreateVfModule() - obj.createNetworkPoliciesInAAI(mockExecution) - - Mockito.verify(mockExecution).setVariable("prefix", prefix) - Mockito.verify(mockExecution).setVariable(prefix + "networkPolicyFqdnCount", 1) - Mockito.verify(mockExecution).setVariable(prefix + "aaiQqueryNetworkPolicyByFqdnReturnCode", 200) - } - - - - private static ExecutionEntity setupMock() { - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("DoCreateVfModule") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoCreateVfModule") - 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("DoCreateVfModule") - when(mockExecution.getProcessInstanceId()).thenReturn("DoCreateVfModule") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - } - - private static void mockData() { - stubFor(get(urlMatching(".*/aai/v[0-9]+/network/generic-vnfs/generic-vnf/12345[?]depth=1")) - .willReturn(aResponse() - .withStatus(200).withHeader("Content-Type", "text/xml") - .withBodyFile("DoCreateVfModule/getGenericVnfResponse.xml"))) - stubFor(get(urlMatching(".*/aai/v[0-9]+/network/generic-vnfs/generic-vnf/12345/vf-modules/vf-module[?]vf-module-name=module-0")) - .willReturn(aResponse() - .withStatus(200).withHeader("Content-Type", "text/xml") - .withBodyFile("DoCreateVfModule/getGenericVnfResponse.xml"))) - stubFor(get(urlMatching(".*/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/12345")) - .willReturn(aResponse() - .withStatus(200).withHeader("Content-Type", "text/xml") - .withBodyFile("DoCreateVfModule/cloudRegion_AAIResponse_Success.xml"))) - stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy\\?network-policy-fqdn=.*")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml"))) - } -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy deleted file mode 100644 index 91e7086bd3..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2Test.groovy +++ /dev/null @@ -1,135 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -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.ArgumentCaptor -import org.mockito.Captor -import org.mockito.Mockito -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.onap.so.bpmn.common.scripts.MsoGroovyTest - -import static org.junit.Assert.assertEquals -import static org.junit.Assert.assertNotNull -import static org.mockito.Mockito.times -import static org.mockito.Mockito.when - - -@RunWith(MockitoJUnitRunner.class) -class DoCreateVfModuleVolumeV2Test extends MsoGroovyTest { - - @Captor - static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) - - def String volumeRollbackRequest = """ - - - 171907d6-cdf0-4e08-953d-81ee104005a7 - {{VOLUMEGROUPSTACKID}} - c2141e3fcae940fcb4797ec9115e5a7a - mtwnj1a - true - - 230fd6ac-2a39-4be4-9b1e-7b7e1cc039b5 - 88c871d6-be09-4982-8490-96b1d243fb34 - - 9a5a91e8-3b79-463c-81c3-874a78f5b567 - - true - http://localhost:8080/mso/WorkflowMessage/VNFAResponse/9a5a91e8-3b79-463c-81c3-874a78f5b567 - - """ - - def String volumeRollbackRequestWithStackId = """ - - - 171907d6-cdf0-4e08-953d-81ee104005a7 - mdt22avrr_volume01/0f1aaae8-efe3-45ce-83e1-bfad01db58d8 - c2141e3fcae940fcb4797ec9115e5a7a - mtwnj1a - true - - 230fd6ac-2a39-4be4-9b1e-7b7e1cc039b5 - 88c871d6-be09-4982-8490-96b1d243fb34 - - 9a5a91e8-3b79-463c-81c3-874a78f5b567 - - true - http://localhost:8080/mso/WorkflowMessage/VNFAResponse/9a5a91e8-3b79-463c-81c3-874a78f5b567 - - """ - - - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - - @Test - public void testBuildRollbackVolumeGroupRequestXml() { - DoCreateVfModuleVolumeV2 process = new DoCreateVfModuleVolumeV2() - String xml = process.buildRollbackVolumeGroupRequestXml( - "171907d6-cdf0-4e08-953d-81ee104005a7", // volumeGroupId - "mtwnj1a", // cloudSiteId - "c2141e3fcae940fcb4797ec9115e5a7a", // tenantId - "230fd6ac-2a39-4be4-9b1e-7b7e1cc039b5", // requestId - "88c871d6-be09-4982-8490-96b1d243fb34", // serviceInstanceId - "9a5a91e8-3b79-463c-81c3-874a78f5b567", // messageId - "http://localhost:8080/mso/WorkflowMessage/VNFAResponse/9a5a91e8-3b79-463c-81c3-874a78f5b567") // notificationUrl - - assertEquals(volumeRollbackRequest.replaceAll("\\s", ""), xml.replaceAll("\\s", "")) - } - - - @Test - public void testUpdateRollbackVolumeGroupRequestXml() { - DoCreateVfModuleVolumeV2 process = new DoCreateVfModuleVolumeV2() - String updatedXml = process.updateRollbackVolumeGroupRequestXml(volumeRollbackRequest, "mdt22avrr_volume01/0f1aaae8-efe3-45ce-83e1-bfad01db58d8") - assertEquals(volumeRollbackRequestWithStackId.replaceAll("\\s", ""), updatedXml.replaceAll("\\s", "")) - } - - @Test - public void testPrepareVnfAdapterCreateRequest (){ - ExecutionEntity mockExecution = setupMock('DoCreateVfModuleVolumeV2') - - when(mockExecution.getVariable("prefix")).thenReturn('DCVFMODVOLV2_') - when(mockExecution.getVariable("serviceInstanceId")).thenReturn('') - when(mockExecution.getVariable("vnfId")).thenReturn('test-vnf-id') - when(mockExecution.getVariable("mso-request-id")).thenReturn('1234') - when(mockExecution.getVariable("volumeGroupId")).thenReturn('1234') - when(mockExecution.getVariable("mso.use.qualified.host")).thenReturn("true") - when(mockExecution.getVariable("mso.workflow.message.endpoint")).thenReturn("http://localhost:28080/mso/WorkflowMesssage") - Map vfModuleInputParams = new HashMap() - vfModuleInputParams.put("param1","value1") - when(mockExecution.getVariable("vfModuleInputParams")).thenReturn(vfModuleInputParams) - DoCreateVfModuleVolumeV2 process = new DoCreateVfModuleVolumeV2() - process.prepareVnfAdapterCreateRequest(mockExecution,"true"); - Mockito.verify(mockExecution,times(2)).setVariable(captor.capture(), captor.capture()) - String DCVFMODVOLV2_createVnfARequest = captor.getValue(); - assertNotNull(DCVFMODVOLV2_createVnfARequest) - } -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfTest.groovy deleted file mode 100644 index 9b421d8b63..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnfTest.groovy +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import com.github.tomakehurst.wiremock.junit.WireMockRule -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.junit.Assert -import org.junit.Before -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.Captor -import org.mockito.Mockito -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.core.domain.VnfResource - -import static org.mockito.Mockito.* - -@RunWith(MockitoJUnitRunner.class) -class DoCreateVnfTest { - def prefix = "DoCVNF_" - - @Rule - public WireMockRule wireMockRule = new WireMockRule(28090) - - @Captor - static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) - - @Before - void init() throws IOException { - MockitoAnnotations.initMocks(this); - } - - @Test - void testPreProcessRequest() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(prefix) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("msoRequestId")).thenReturn("12345") - when(mockExecution.getVariable("serviceInstanceId")).thenReturn("MIS/1604/0026/SW_INTERNET") - when(mockExecution.getVariable("vnfType")).thenReturn("vRRaas") - when(mockExecution.getVariable("vnfName")).thenReturn("skask-test") - - when(mockExecution.getVariable("productFamilyId")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable("lcpCloudRegionId")).thenReturn("MDTWNJ21") - - when(mockExecution.getVariable("vnfResourceDecomposition")).thenReturn(new VnfResource()) - when(mockExecution.getVariable("mso-request-id")).thenReturn("testRequestId-1503410089303") - when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:28080/mso/SDNCAdapterCallbackService") - - - - DoCreateVnf obj = new DoCreateVnf() - obj.preProcessRequest(mockExecution) - - Mockito.verify(mockExecution, times(31)).setVariable(captor.capture(), captor.capture()) - List list = captor.getAllValues() - String str = list.get(51) - Assert.assertEquals("http://localhost:28080/mso/SDNCAdapterCallbackService", str) - } - - private static ExecutionEntity setupMock() { - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("DoCreateVnf") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoCreateVnf") - 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("DoCreateVnf") - when(mockExecution.getProcessInstanceId()).thenReturn("DoCreateVnf") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - } -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceTest.groovy deleted file mode 100644 index bbbb82b5aa..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceTest.groovy +++ /dev/null @@ -1,169 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import com.github.tomakehurst.wiremock.junit.WireMockRule -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.junit.Before -import org.junit.BeforeClass -import org.junit.Ignore -import org.junit.Rule -import org.junit.Test -import org.mockito.MockitoAnnotations -import org.onap.so.bpmn.infrastructure.scripts.DoCustomDeleteE2EServiceInstance -import org.onap.so.bpmn.mock.FileUtil -import org.onap.so.bpmn.vcpe.scripts.GroovyTestBase - -import static org.assertj.core.api.Assertions.assertThatThrownBy -import static org.mockito.Matchers.anyString -import static org.mockito.Mockito.verify -import static org.mockito.Mockito.when -import static org.mockito.Mockito.eq - -class DoCustomDeleteE2EServiceInstanceTest extends GroovyTestBase { - - private static String request - - @Rule - public WireMockRule wireMockRule = new WireMockRule(GroovyTestBase.PORT) - - String Prefix = "CVRCS_" - String RbType = "DCRENI_" - - @BeforeClass - public static void setUpBeforeClass() { - request = FileUtil.readResourceFile("__files/InfrastructureFlows/DeleteCustomE2EService.json") - } - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - public DoCustomDeleteE2EServiceInstanceTest(){ - super("DoCustomDeleteE2EServiceInstance") - } - - @Test - public void preProcessRequestTest(){ - - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcess(mex) - - DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance() - instance.preProcessRequest(mex) - verify(mex).setVariable("sdncCallbackUrl", "/mso/sdncadapter/") - verify(mex).setVariable("siParamsXml", "") - } - - @Test - public void postProcessAAIGETSuccessTest(){ - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcess(mex) - when(mex.getVariable("GENGS_SuccessIndicator")).thenReturn(true) - - String aaiGetResponse = FileUtil.readResourceFile("__files/GenericFlows/aaiGetResponse.xml") - when(mex.getVariable("GENGS_service")).thenReturn(aaiGetResponse) - DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance() - instance.postProcessAAIGET(mex) - - verify(mex).setVariable(eq("serviceRelationShip"), anyString()) - } - - @Test - public void postProcessAAIGETFailureTest(){ - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcess(mex) - when(mex.getVariable("GENGS_FoundIndicator")).thenReturn(false) - when(mex.getVariable("GENGS_SuccessIndicator")).thenReturn(false) - - DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance() - assertThatThrownBy { instance.postProcessAAIGET(mex) } isInstanceOf BpmnError.class - } - - @Test - public void preInitResourcesOperStatusTest(){ - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcess(mex) - when(mex.getVariable("serviceRelationShip")).thenReturn("[{\"resourceInstanceId\":\"3333\",\"resourceType\":\"overlay\"},{\"resourceInstanceId\":\"4444\",\"resourceType\":\"underlay\"},{\"resourceInstanceId\":\"1111\",\"resourceType\":\"vIMS\"},{\"resourceInstanceId\":\"222\",\"resourceType\":\"vEPC\"}]") - DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance() - instance.preInitResourcesOperStatus(mex) - - verify(mex).setVariable(eq("CVFMI_initResOperStatusRequest"), anyString()) - } - - @Test - public void preResourceDeleteTest() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcess(mex) - when(mex.getVariable("serviceRelationShip")).thenReturn("[{\"resourceInstanceId\":\"3333\",\"resourceType\":\"overlay\"},{\"resourceInstanceId\":\"4444\",\"resourceType\":\"underlay\"},{\"resourceInstanceId\":\"1111\",\"resourceType\":\"vIMS\"},{\"resourceInstanceId\":\"222\",\"resourceType\":\"vEPC\"}]") - DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance() - instance.preResourceDelete(mex,"overlay") - verify(mex).setVariable("resourceType", "overlay") - } - - @Test - public void postProcessSDNCDeleteTest(){ - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcess(mex) - when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn("true") - when(mex.getVariable("DDELSI_sdncResponseSuccess")).thenReturn("true") - when(mex.getVariable("prefix")).thenReturn("DDELSI_") - DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance() - String response = FileUtil.readResourceFile("__files/GenericFlows/SDNCDeleteResponse.xml") - String method = "deleteE2E"; - instance.postProcessSDNCDelete(mex, response, method) - // following method doesn't do anything currently -> nothing to check - } - - @Test - public void postProcessAAIDELTest() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcess(mex) - when(mex.getVariable("GENDS_SuccessIndicator")).thenReturn("true") - DoCustomDeleteE2EServiceInstance instance = new DoCustomDeleteE2EServiceInstance() - instance.postProcessAAIDEL(mex) - } - - private void initPreProcess(ExecutionEntity mex) { - when(mex.getVariable(GroovyTestBase.DBGFLAG)).thenReturn("true") - when(mex.getVariable("bpmnRequest")).thenReturn(request) - when(mex.getVariable("mso-request-id")).thenReturn("mri") - when(mex.getVariable("serviceType")).thenReturn("VoLTE") - when(mex.getVariable("serviceInstanceId")).thenReturn("e151059a-d924-4629-845f-264db19e50b4") - when(mex.getVariable("requestAction")).thenReturn("ra") - when(mex.getVariable("operationId")).thenReturn("59960003992") - when(mex.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("/mso/sdncadapter/") - when(mex.getVariable("GENGS_FoundIndicator")).thenReturn("true") - when(mex.getVariable("GENGS_siResourceLink")).thenReturn("/service-subscription/e2eserviceInstance/delete/service-instances/") - when(mex.getVariable("globalSubscriberId")).thenReturn("4993921112123") - when(mex.getVariable("GENGS_service")).thenReturn("test3434") - when(mex.getVariable("mso.adapters.openecomp.db.endpoint")).thenReturn("http://localhost:8080/mso") - } -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollbackTest.groovy deleted file mode 100644 index 5e264c0af4..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollbackTest.groovy +++ /dev/null @@ -1,343 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - - -import static org.mockito.Mockito.* - -import org.camunda.bpm.engine.delegate.BpmnError -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.impl.pvm.process.ProcessDefinitionImpl -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.mockito.internal.debugging.MockitoDebuggerImpl -import org.onap.so.bpmn.common.scripts.MsoUtils -import org.onap.so.bpmn.core.WorkflowException -import org.junit.Before -import org.junit.Rule; -import org.junit.Test -import org.junit.Ignore -import org.junit.runner.RunWith - -import static org.junit.Assert.*; - -import com.github.tomakehurst.wiremock.client.WireMock; -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.apache.commons.lang3.* - - -@RunWith(MockitoJUnitRunner.class) -class DoDeleteNetworkInstanceRollbackTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(8090); - - def utils = new MsoUtils() - String Prefix="DELNWKIR_" - - - String rollbackNetworkRequest = - """ - - 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 rollbackDeActivateSDNCRequest = - """ - - 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 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - MSO_1610_dev - - - 8abc633a-810b-4ca5-8b3a-09511d13a2ce - CONTRAIL_EXTERNAL - - invariant-uuid - customization-uuid - uuid - version - CONTRAIL_EXTERNAL - - - - 8abc633a-810b-4ca5-8b3a-09511d13a2ce - CONTRAIL_EXTERNAL - MNS-25180-L-01-dmz_direct_net_1 - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - -""" - - String rollbackSDNCRequest = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - rollback - network-topology-operation - sdncCallback - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - CreateNetworkInstance - 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 - - invariant-uuid - customization-uuid - uuid - version - CONTRAIL_EXTERNAL - - - - 8abc633a-810b-4ca5-8b3a-09511d13a2ce - CONTRAIL_EXTERNAL - MNS-25180-L-01-dmz_direct_net_1 - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - -""" - -// - - - - - - - - - - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - - public void initializeVariables (DelegateExecution mockExecution) { - - verify(mockExecution).setVariable(Prefix + "WorkflowException", null) - - verify(mockExecution).setVariable(Prefix + "rollbackDeactivateSDNCRequest", null) - verify(mockExecution).setVariable(Prefix + "rollbackDeactivateSDNCResponse", "") - verify(mockExecution).setVariable(Prefix + "rollbackDeactivateSDNCReturnCode", "") - - verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", null) - verify(mockExecution).setVariable(Prefix + "rollbackNetworkResponse", "") - verify(mockExecution).setVariable(Prefix + "rollbackNetworkReturnCode", "") - - verify(mockExecution).setVariable(Prefix + "Success", false) - verify(mockExecution).setVariable(Prefix + "fullRollback", false) - - } - - @Test - //@Ignore - public void preProcessRequest() { - - println "************ preProcessRequest ************* " - - WorkflowException workflowException = new WorkflowException("DoCreateNetworkInstance", 2500, "Received error from Network Adapter: JBWEB000065: HTTP Status 500.") - Map rollbackData = new HashMap(); - rollbackData.put("rollbackDeactivateSDNCRequest", rollbackDeActivateSDNCRequest) - rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) - rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) - - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) - when(mockExecution.getVariable("rollbackData")).thenReturn(rollbackData) - when(mockExecution.getVariable("sdncVersion")).thenReturn("1702") - - when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - when(mockExecution.getVariable("mso.adapters.sdnc.endpoint")).thenReturn("http://localhost:8090/SDNCAdapter") - when(mockExecution.getVariable("mso.adapters.network.rest.endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") - when(mockExecution.getVariable("mso.adapters.sdnc.resource.endpoint")).thenReturn("http://localhost:8090/SDNCAdapterRpc") - - - // preProcessRequest(DelegateExecution execution) - DoDeleteNetworkInstanceRollback DoDeleteNetworkInstanceRollback = new DoDeleteNetworkInstanceRollback() - DoDeleteNetworkInstanceRollback.preProcessRequest(mockExecution) - - //verify variable initialization - initializeVariables(mockExecution) - -// verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix) - - } - - - @Test - //@Ignore - public void validateRollbackResponses_Good() { - - WorkflowException workflowException = new WorkflowException("DoDeleteNetworkInstanceRollback", 2500, "AAI Update Contrail Failed. Error 404.") - WorkflowException expectedWorkflowException = new WorkflowException("DoDeleteNetworkInstanceRollback", 2500, "AAI Update Contrail Failed. Error 404. + SNDC deactivate rollback completed. + PO Network rollback completed. + SNDC unassign rollback completed.") - - println "************ validateRollbackResponses_Good() ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - - when(mockExecution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackDeactivateSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackDeactivateSDNCResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackNetworkReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackNetworkResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackSDNCResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "WorkflowException")).thenReturn(workflowException) - when(mockExecution.getVariable(Prefix + "fullRollback")).thenReturn(false) - - DoDeleteNetworkInstanceRollback DoDeleteNetworkInstanceRollback = new DoDeleteNetworkInstanceRollback() - DoDeleteNetworkInstanceRollback.validateRollbackResponses(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) - verify(mockExecution, atLeast(1)).setVariable("rolledBack", true) - verify(mockExecution, atLeast(1)).setVariable("wasDeleted", true) - verify(mockExecution).setVariable("WorkflowException", refEq(expectedWorkflowException, any(WorkflowException.class))) - //verify(mockExecution).setVariable("WorkflowException", expectedWorkflowException) - } - - @Test - //@Ignore - public void validateRollbackResponses_FullRollback() { - - Map rollbackData = new HashMap(); - rollbackData.put("rollbackDeactivateSDNCRequest", rollbackDeActivateSDNCRequest) - rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) - rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) - - println "************ validateRollbackResponses_FullRollback() ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - - when(mockExecution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackDeactivateSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackDeactivateSDNCResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackNetworkReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackNetworkResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackSDNCResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "WorkflowException")).thenReturn(null) - when(mockExecution.getVariable(Prefix + "fullRollback")).thenReturn(true) - when(mockExecution.getVariable("rollbackData")).thenReturn(rollbackData) - - DoDeleteNetworkInstanceRollback DoDeleteNetworkInstanceRollback = new DoDeleteNetworkInstanceRollback() - DoDeleteNetworkInstanceRollback.validateRollbackResponses(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) - verify(mockExecution, atLeast(1)).setVariable("rollbackSuccessful", true) - verify(mockExecution, atLeast(1)).setVariable("rollbackError", false) - - } - - - private ExecutionEntity setupMock() { - - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("DoDeleteNetworkInstanceRollback") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoDeleteNetworkInstanceRollback") - 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("DoDeleteNetworkInstanceRollback") - when(mockExecution.getProcessInstanceId()).thenReturn("DoDeleteNetworkInstanceRollback") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - } - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy deleted file mode 100644 index 1a2d16d9d0..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy +++ /dev/null @@ -1,1948 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.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/att-aic/RDM2WAGPLCP/ - - cloud-region.cloud-owner - att-aic - - - 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/att-aic") - 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/att-aic") - 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/att-aic") - 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/att-aic") - 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/att-aic") - 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/att-aic") - // - 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 - - } - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstanceTest.groovy deleted file mode 100644 index a8bdfb0633..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteServiceInstanceTest.groovy +++ /dev/null @@ -1,127 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import com.github.tomakehurst.wiremock.junit.WireMockRule -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.junit.Assert -import org.junit.Before -import org.junit.Ignore -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.Captor -import org.mockito.Mockito -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.mock.FileUtil -import org.onap.so.bpmn.vcpe.scripts.GroovyTestBase - -import static com.github.tomakehurst.wiremock.client.WireMock.* -import static org.mockito.Mockito.* - -@RunWith(MockitoJUnitRunner.class) -class DoDeleteServiceInstanceTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(28090) - - @Captor - static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) - - @Before - void init() throws IOException { - MockitoAnnotations.initMocks(this); - } - - @Test - public void preProcessRequestTest() { - - ExecutionEntity mex = setupMock() - when(mex.getVariable(GroovyTestBase.DBGFLAG)).thenReturn("true") - when(mex.getVariable("serviceInstanceId")).thenReturn("e151059a-d924-4629-845f-264db19e50b4") - when(mex.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("/mso/sdncadapter/") - when(mex.getVariable("globalSubscriberId")).thenReturn("4993921112123") - - DoDeleteServiceInstance instance = new DoDeleteServiceInstance() - instance.preProcessRequest(mex) - - Mockito.verify(mex).setVariable("sdncCallbackUrl", "/mso/sdncadapter/") - Mockito.verify(mex).setVariable("siParamsXml", "") - } - - - @Test - public void testPostProcessAAIGET() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true') - when(mockExecution.getVariable("aai.endpoint")).thenReturn('http://localhost:8090') - when(mockExecution.getVariable("GENGS_FoundIndicator")).thenReturn(true) - when(mockExecution.getVariable("sdnc.si.svc.types")).thenReturn("") - when(mockExecution.getVariable("globalSubscriberId")).thenReturn("globalSubscriberId_test") - when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("subscriptionServiceType_test") - - String aaiGetResponse = FileUtil.readResourceFile("__files/GenericFlows/aaiGetResponse.xml") - when(mockExecution.getVariable("GENGS_service")).thenReturn(aaiGetResponse) - when(mockExecution.getVariable("GENGS_siResourceLink")).thenReturn("/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/") - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8') - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - - mockData() - DoDeleteServiceInstance instance = new DoDeleteServiceInstance() - instance.postProcessAAIGET(mockExecution) - - Mockito.verify(mockExecution).setVariable("sendToSDNC", true) - } - - private static ExecutionEntity setupMock() { - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("DoDeleteServiceInstance") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoDeleteServiceInstance") - 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("DoDeleteServiceInstance") - when(mockExecution.getProcessInstanceId()).thenReturn("DoDeleteServiceInstance") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - } - - private void mockData() { - stubFor(get(urlMatching(".*/aai/v[0-9]+/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/.*")) - .willReturn(aResponse() - .withStatus(200).withHeader("Content-Type", "text/xml") - .withBodyFile(""))) - } -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy deleted file mode 100644 index fcb0fb0940..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnfTest.groovy +++ /dev/null @@ -1,172 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import com.github.tomakehurst.wiremock.junit.WireMockRule -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.junit.Assert -import org.junit.Before -import org.junit.Ignore -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.Captor -import org.mockito.Mockito -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.onap.so.bpmn.core.WorkflowException - -import static com.github.tomakehurst.wiremock.client.WireMock.* -import static org.mockito.Mockito.* - -@RunWith(MockitoJUnitRunner.class) -class DoDeleteVfModuleFromVnfTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(28090); - - @Captor - static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) - - @Before - public void init() throws IOException { - MockitoAnnotations.initMocks(this); - } - - @Test - public void testPreProcessRequest() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("msoRequestId")).thenReturn("12345") - when(mockExecution.getVariable("source")).thenReturn("VID") - when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") - when(mockExecution.getVariable("vnfId")).thenReturn("12345") - when(mockExecution.getVariable("tenantId")).thenReturn("19123c2924c648eb8e42a3c1f14b7682") - when(mockExecution.getVariable("vfModuleId")).thenReturn("12345") - when(mockExecution.getVariable("lcpCloudRegionId")).thenReturn("12345") - when(mockExecution.getVariable("sdncVersion")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") - - DoDeleteVfModuleFromVnf obj = new DoDeleteVfModuleFromVnf() - obj.preProcessRequest(mockExecution) - - Mockito.verify(mockExecution).setVariable("prefix", "DDVFMV_") - Mockito.verify(mockExecution).setVariable("DDVFMV_contrailNetworkPolicyFqdnList", null) - Mockito.verify(mockExecution).setVariable("mso-request-id", "12345") - Mockito.verify(mockExecution).setVariable("requestId", "12345") - Mockito.verify(mockExecution).setVariable("cloudSiteId", "12345") - Mockito.verify(mockExecution).setVariable("source", "VID") - Mockito.verify(mockExecution).setVariable("isVidRequest", "true") - Mockito.verify(mockExecution).setVariable("srvInstId", "") - Mockito.verify(mockExecution).setVariable("DDVFMV_serviceInstanceIdToSdnc", "12345") - Mockito.verify(mockExecution).setVariable("DDVFMV_sdncVersion", "8") - Mockito.verify(mockExecution).setVariable("sdncCallbackUrl", "http://localhost:8090/SDNCAdapterCallback") - } - - - - @Test - void testDeleteNetworkPoliciesFromAAI() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso.workflow.DoDeleteVfModuleFromVnf.aai.network-policy.uri")).thenReturn("/aai/v8/network/network-policies/network-policy") - when(mockExecution.getVariable("mso.workflow.custom.DoDeleteVfModuleFromVnf.aai.version")).thenReturn("8") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") - List fqdnList = new ArrayList() - fqdnList.add("test") - when(mockExecution.getVariable("DDVFMV_contrailNetworkPolicyFqdnList")).thenReturn(fqdnList) - mockData() - DoDeleteVfModuleFromVnf obj = new DoDeleteVfModuleFromVnf() - obj.deleteNetworkPoliciesFromAAI(mockExecution) - - Mockito.verify(mockExecution).setVariable("prefix", 'DDVFMV_') - Mockito.verify(mockExecution).setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", 200) - } - - - @Test - void testQueryAAIForVfModule() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("vnfId")).thenReturn("12345") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("mso.workflow.global.default.aai.namespace") - when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - - mockData() - DoDeleteVfModuleFromVnf obj = new DoDeleteVfModuleFromVnf() - obj.queryAAIForVfModule(mockExecution) - - Mockito.verify(mockExecution, atLeastOnce()).setVariable("DDVMFV_getVnfResponseCode", 200) - } - - - - private ExecutionEntity setupMock() { - - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("DoDeleteVfModuleFromVnf") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoDeleteVfModuleFromVnf") - 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("DoDeleteVfModuleFromVnf") - when(mockExecution.getProcessInstanceId()).thenReturn("DoDeleteVfModuleFromVnf") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - - } - - private static void mockData() { - stubFor(get(urlMatching(".*/aai/v[0-9]+/network/generic-vnfs/generic-vnf/12345[?]depth=1")) - .willReturn(aResponse() - .withStatus(200).withHeader("Content-Type", "text/xml") - .withBodyFile("VfModularity/GenerateVfModuleName_AAIResponse_Success.xml"))) - - stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy\\?network-policy-fqdn=.*")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml"))) - - stubFor(delete(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*")) - .willReturn(aResponse() - .withStatus(200))); - - } -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy deleted file mode 100644 index 3390b1a6f0..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleTest.groovy +++ /dev/null @@ -1,163 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import com.github.tomakehurst.wiremock.junit.WireMockRule -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.junit.Assert -import org.junit.Before -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.Captor -import org.mockito.Mockito -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.onap.so.bpmn.common.scripts.utils.XmlComparator -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.mock.FileUtil - -import static com.github.tomakehurst.wiremock.client.WireMock.* -import static org.mockito.Mockito.* - -@RunWith(MockitoJUnitRunner.class) -class DoDeleteVfModuleTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(28090); - - @Captor - static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) - - @Before - public void init() throws IOException { - MockitoAnnotations.initMocks(this); - } - - @Test - public void testPrepSDNCAdapterRequest() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("testReqId")).thenReturn("testReqId") - when(mockExecution.getVariable("requestId")).thenReturn("12345") - when(mockExecution.getVariable("source")).thenReturn("VID") - when(mockExecution.getVariable("serviceId")).thenReturn("12345") - when(mockExecution.getVariable("vnfId")).thenReturn("12345") - when(mockExecution.getVariable("tenantId")).thenReturn("19123c2924c648eb8e42a3c1f14b7682") - when(mockExecution.getVariable("vfModuleId")).thenReturn("12345") - when(mockExecution.getVariable("DoDVfMod_serviceInstanceIdToSdnc")).thenReturn("123456789") - when(mockExecution.getVariable("vfModuleName")).thenReturn("vfModuleName_test") - when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") - - DoDeleteVfModule obj = new DoDeleteVfModule() - obj.prepSDNCAdapterRequest(mockExecution, 'release') - - String expectedValue = FileUtil.readResourceFile("__files/DoDeleteVfModule/sdncAdapterWorkflowRequest.xml") - Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture()) - XmlComparator.assertXMLEquals(expectedValue, captor.getValue()) - } - - - @Test - void testDeleteNetworkPoliciesFromAAI() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso.workflow.DoDeleteVfModule.aai.network-policy.uri")).thenReturn("/aai/v8/network/network-policies/network-policy") - when(mockExecution.getVariable("mso.workflow.custom.DoDeleteVfModule.aai.version")).thenReturn("8") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") - List fqdnList = new ArrayList() - fqdnList.add("test") - when(mockExecution.getVariable("DoDVfMod_contrailNetworkPolicyFqdnList")).thenReturn(fqdnList) - mockData() - DoDeleteVfModule obj = new DoDeleteVfModule() - obj.deleteNetworkPoliciesFromAAI(mockExecution) - - Mockito.verify(mockExecution).setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", 200) - } - - - @Test - void testQueryAAIVfModuleForStatus() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("DCVFM_vnfId")).thenReturn("12345") - when(mockExecution.getVariable("DCVFM_vfModuleName")).thenReturn("module-0") - when(mockExecution.getVariable("mso.workflow.DoDeleteVfModule.aai.generic-vnf.uri")).thenReturn("/aai/v9/network/generic-vnfs/generic-vnf") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") - - mockData() - DoCreateVfModule obj = new DoCreateVfModule() - obj.queryAAIVfModuleForStatus(mockExecution) - - Mockito.verify(mockExecution).setVariable("DCVFM_queryAAIVfModuleForStatusResponseCode", 200) - } - - - - private ExecutionEntity setupMock() { - - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("DoDeleteVfModule") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoDeleteVfModule") - 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("DoDeleteVfModule") - when(mockExecution.getProcessInstanceId()).thenReturn("DoDeleteVfModule") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - - } - - private static void mockData() { - stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy\\?network-policy-fqdn=.*")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml"))) - - stubFor(delete(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*")) - .willReturn(aResponse() - .withStatus(200))) - - stubFor(get(urlMatching(".*/aai/v[0-9]+/network/generic-vnfs/generic-vnf/12345/vf-modules/vf-module[?]vf-module-name=module-0")) - .willReturn(aResponse() - .withStatus(200).withHeader("Content-Type", "text/xml") - .withBodyFile("DoDeleteVfModule/getGenericVnfResponse.xml"))) - - } -} - diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy deleted file mode 100644 index 730be14df0..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy +++ /dev/null @@ -1,152 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import com.github.tomakehurst.wiremock.junit.WireMockRule -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.junit.Assert -import org.junit.Before -import org.junit.Ignore -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.Captor -import org.mockito.Mockito -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.onap.so.bpmn.common.scripts.utils.XmlComparator -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.mock.FileUtil - -import static com.github.tomakehurst.wiremock.client.WireMock.* -import static org.mockito.Mockito.* - -@RunWith(MockitoJUnitRunner.class) -class DoDeleteVfModuleVolumeV2Test { - @Rule - public WireMockRule wireMockRule = new WireMockRule(28090); - - @Captor - static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) - - @Before - public void init() throws IOException { - MockitoAnnotations.initMocks(this); - } - - @Test - public void testCallRESTQueryAAICloudRegion() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn("DDVMV_") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("lcpCloudRegionId")).thenReturn("12345") - when(mockExecution.getVariable("mso.workflow.DoDeleteVfModuleVolumeV2.aai.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") - - mockData() - DoDeleteVfModuleVolumeV2 obj = new DoDeleteVfModuleVolumeV2() - obj.callRESTQueryAAICloudRegion(mockExecution, "true") - Mockito.verify(mockExecution).setVariable("DDVMV_queryCloudRegionReturnCode", "200") - Mockito.verify(mockExecution).setVariable("DDVMV_aicCloudRegion", "RDM2WAGPLCP") - } - - @Test - public void testCallRESTQueryAAICloudRegionAAiEndpointNull() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn("DDVMV_") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("lcpCloudRegionId")).thenReturn("12345") - when(mockExecution.getVariable("mso.workflow.DoDeleteVfModuleVolumeV2.aai.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region") - when(mockExecution.getVariable("aai.endpoint")).thenReturn(null) - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") - - mockData() - try { - DoDeleteVfModuleVolumeV2 obj = new DoDeleteVfModuleVolumeV2() - obj.callRESTQueryAAICloudRegion(mockExecution, "true") - - } catch (Exception ex) { - println " Test End - Handle catch-throw BpmnError()! " - } - Mockito.verify(mockExecution,atLeastOnce()).setVariable(captor.capture(),captor.capture()) - WorkflowException workflowException = captor.getValue() - Assert.assertEquals(9999, workflowException.getErrorCode()) - } - - @Test - public void testPrepareVnfAdapterDeleteRequest() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn("DDVMV_") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("aicCloudRegion")).thenReturn("RegionOne") - when(mockExecution.getVariable("tenantId")).thenReturn("12345") - when(mockExecution.getVariable("volumeGroupId")).thenReturn("12345") - when(mockExecution.getVariable("volumeGroupHeatStackId")).thenReturn("12345") - when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345") - when(mockExecution.getVariable("msoRequestId")).thenReturn("12345") - when(mockExecution.getVariable("mso.use.qualified.host")).thenReturn("true") - when(mockExecution.getVariable("mso.workflow.message.endpoint")).thenReturn("http://localhost:18080/mso/WorkflowMessage") - - DoDeleteVfModuleVolumeV2 obj = new DoDeleteVfModuleVolumeV2() - obj.prepareVnfAdapterDeleteRequest(mockExecution, "true") - - Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture()) - String str = FileUtil.readResourceFile("__files/DoCreateVfModuleVolumeV2/vnfAdapterDeleteRequest.xml") - XmlComparator.assertXMLEquals(str, captor.getValue(),"messageId","notificationUrl") - } - - - private ExecutionEntity setupMock() { - - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("DoDeleteVfModuleVolumeV2") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoDeleteVfModuleVolumeV2") - 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("DoDeleteVfModuleVolumeV2") - when(mockExecution.getProcessInstanceId()).thenReturn("DoDeleteVfModuleVolumeV2") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - - } - - private void mockData() { - stubFor(get(urlMatching(".*/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/12345")) - .willReturn(aResponse() - .withStatus(200).withHeader("Content-Type", "text/xml") - .withBodyFile("DoCreateVfModuleVolumeV2/cloudRegion_AAIResponse_Success.xml"))) - } -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy deleted file mode 100644 index 0b95ffc053..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVnfAndModulesTest.groovy +++ /dev/null @@ -1,162 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import com.github.tomakehurst.wiremock.junit.WireMockRule -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.junit.Assert -import org.junit.Before -import org.junit.Ignore -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.Captor -import org.mockito.Mockito -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.onap.so.bpmn.core.WorkflowException - -import static com.github.tomakehurst.wiremock.client.WireMock.* -import static org.mockito.Mockito.* - -@RunWith(MockitoJUnitRunner.class) -public class DoDeleteVnfAndModulesTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(28090); - - @Captor - static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) - - String cloudConfiguration = "{ " + - "\"lcpCloudRegionId\": \"mdt1\"," + - "\"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\"" + "}"; - - @Before - public void init() throws IOException { - MockitoAnnotations.initMocks(this); - } - - @Test - public void testPreProcessRequestTest() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("cloudConfiguration")).thenReturn(cloudConfiguration) - when(mockExecution.getVariable("msoRequestId")).thenReturn("12345") - when(mockExecution.getVariable("serviceInstanceId")).thenReturn("serviceInstanceId") - when(mockExecution.getVariable("sdncVersion")).thenReturn("1702") - when(mockExecution.getVariable("productFamilyId")).thenReturn("productFamilyId") - when(mockExecution.getVariable("lcpCloudRegionId")).thenReturn("mdt1") - when(mockExecution.getVariable("tenantId")).thenReturn("19123c2924c648eb8e42a3c1f14b7682") - when(mockExecution.getVariable("globalSubscriberId")).thenReturn("MSO_test") - when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") - - DoDeleteVnfAndModules obj = new DoDeleteVnfAndModules() - obj.preProcessRequest(mockExecution) - - Mockito.verify(mockExecution).setVariable("prefix", "DDVAM_") - Mockito.verify(mockExecution).setVariable("requestId", "12345") - Mockito.verify(mockExecution).setVariable("mso-request-id", "12345") - Mockito.verify(mockExecution).setVariable("DDVAM_source", "VID") - Mockito.verify(mockExecution).setVariable("DDVAM_isVidRequest", "true") - Mockito.verify(mockExecution).setVariable("DDVAM_sdncVersion", "1702") - Mockito.verify(mockExecution).setVariable("DDVAM_isVidRequest", "true") - Mockito.verify(mockExecution).setVariable("sdncCallbackUrl", "http://localhost:8090/SDNCAdapterCallback") - } - - - - @Test - public void testQueryAAIVfModuleNullEndPoint() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("vnfId")).thenReturn("12345") - when(mockExecution.getVariable("mso.workflow.DoDeleteVnfAndModules.aai.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") - when(mockExecution.getVariable("aai.endpoint")).thenReturn(null) - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") - - mockData() - try { - DoDeleteVnfAndModules obj = new DoDeleteVnfAndModules() - obj.queryAAIVfModule(mockExecution) - } catch (Exception ex) { - println " Test End - Handle catch-throw BpmnError()! " - } - - Mockito.verify(mockExecution,atLeastOnce()).setVariable(captor.capture(),captor.capture()) - WorkflowException workflowException = captor.getValue() - Assert.assertEquals("AAI GET Failed:null", workflowException.getErrorMessage()) - Assert.assertEquals(1002, workflowException.getErrorCode()) - } - - @Test - public void testQueryAAIVfModule() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("vnfId")).thenReturn("12345") - when(mockExecution.getVariable("mso.workflow.DoDeleteVnfAndModules.aai.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") - - mockData() - DoDeleteVnfAndModules obj = new DoDeleteVnfAndModules() - obj.queryAAIVfModule(mockExecution) - - Mockito.verify(mockExecution).setVariable("DCVFM_queryAAIVfModuleResponseCode", 200) - } - - private ExecutionEntity setupMock() { - - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("DoDeleteVnfAndModules") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoDeleteVnfAndModules") - 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("DoDeleteVnfAndModules") - when(mockExecution.getProcessInstanceId()).thenReturn("DoDeleteVnfAndModules") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - - } - - private void mockData() { - - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/12345[?]depth=1")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("GenericFlows/getGenericVnfResponse_hasRelationships.xml"))); - } -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstanceTest.groovy deleted file mode 100644 index 4e993525f9..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoScaleE2EServiceInstanceTest.groovy +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 CMCC 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 com.github.tomakehurst.wiremock.junit.WireMockRule -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.junit.Before -import org.junit.BeforeClass -import org.junit.Rule -import org.junit.Test -import org.mockito.MockitoAnnotations -import org.onap.so.bpmn.mock.FileUtil -import org.onap.so.bpmn.vcpe.scripts.GroovyTestBase - -import static org.mockito.Mockito.verify -import static org.mockito.Mockito.when - -class DoScaleE2EServiceInstanceTest extends GroovyTestBase { - - private static String request - - @Rule - public WireMockRule wireMockRule = new WireMockRule(GroovyTestBase.PORT) - - String Prefix = "CVRCS_" - - @BeforeClass - public static void setUpBeforeClass() { - request = FileUtil.readResourceFile("__files/InfrastructureFlows/DoScaleE2EServiceInstance.json") - } - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - public DoScaleE2EServiceInstanceTest(){ - super("DoScaleE2EServiceInstance") - } - - @Test - public void preProcessRequestTest(){ - - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcess(mex) - - DoScaleE2EServiceInstance instance = new DoScaleE2EServiceInstance() - instance.preProcessRequest(mex) - verify(mex).setVariable("resourceTemplateUUIDs", "ns111:ns333:") - } - - @Test - public void preInitResourcesOperStatusTest(){ - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcess(mex) - DoScaleE2EServiceInstance instance = new DoScaleE2EServiceInstance() - instance.preInitResourcesOperStatus(mex) - - verify(mex).setVariable("serviceInstanceId","e151059a-d924-4629-845f-264db19e50b4") - verify(mex).setVariable("operationId", "59960003992") - verify(mex).setVariable("operationType", "SCALE") - verify(mex).setVariable("URN_mso_openecomp_adapters_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter") - - String payload = - """ - - - - e151059a-d924-4629-845f-264db19e50b4 - 59960003992 - SCALE - ns111:ns333: - - -""" - verify(mex).setVariable("CVFMI_initResOperStatusRequest", payload) - } - - private void initPreProcess(ExecutionEntity mex) { - when(mex.getVariable(GroovyTestBase.DBGFLAG)).thenReturn("true") - when(mex.getVariable("bpmnRequest")).thenReturn(request) - when(mex.getVariable("msoRequestId")).thenReturn("mri") - when(mex.getVariable("serviceType")).thenReturn("VoLTE") - when(mex.getVariable("serviceInstanceId")).thenReturn("e151059a-d924-4629-845f-264db19e50b4") - when(mex.getVariable("serviceInstanceName")).thenReturn("ra") - when(mex.getVariable("operationId")).thenReturn("59960003992") - when(mex.getVariable("globalSubscriberId")).thenReturn("4993921112123") - when(mex.getVariable("resourceTemplateUUIDs")).thenReturn("ns111:ns333:") - } -} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy deleted file mode 100644 index 0189d065df..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy +++ /dev/null @@ -1,332 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import static org.mockito.Mockito.* - -import org.camunda.bpm.engine.delegate.BpmnError -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.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.onap.so.bpmn.common.scripts.MsoUtils -import org.onap.so.bpmn.core.WorkflowException -import org.junit.Before -import org.junit.Rule; -import org.junit.Test -import org.junit.Ignore -import org.junit.runner.RunWith - -import static org.junit.Assert.*; - -import com.github.tomakehurst.wiremock.client.WireMock; -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import org.apache.commons.lang3.* - - -@RunWith(MockitoJUnitRunner.class) -class DoUpdateNetworkInstanceRollbackTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(28090); - - def utils = new MsoUtils() - String Prefix="UPDNETIR_" - - - String rollbackNetworkRequest = - """ - - 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 rollbackActivateSDNCRequest = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - rollback - network-topology-operation - sdncCallback - generic-resource - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - CreateNetworkInstance - 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 - - invariant-uuid - customization-uuid - uuid - version - CONTRAIL_EXTERNAL - - - - 8abc633a-810b-4ca5-8b3a-09511d13a2ce - CONTRAIL_EXTERNAL - MNS-25180-L-01-dmz_direct_net_1 - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - -""" - - String rollbackSDNCRequest = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - rollback - network-topology-operation - sdncCallback - generic-resource - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - CreateNetworkInstance - 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 - - invariant-uuid - customization-uuid - uuid - version - CONTRAIL_EXTERNAL - - - - 8abc633a-810b-4ca5-8b3a-09511d13a2ce - CONTRAIL_EXTERNAL - MNS-25180-L-01-dmz_direct_net_1 - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - -""" - -// - - - - - - - - - - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - - public void initializeVariables (DelegateExecution mockExecution) { - - verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", null) - verify(mockExecution).setVariable(Prefix + "rollbackSDNCRequest", null) - verify(mockExecution).setVariable(Prefix + "WorkflowException", null) - - verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", "") - verify(mockExecution).setVariable(Prefix + "rollbackNetworkResponse", "") - verify(mockExecution).setVariable(Prefix + "rollbackNetworkReturnCode", "") - - verify(mockExecution).setVariable(Prefix + "rollbackSDNCRequest", "") - verify(mockExecution).setVariable(Prefix + "rollbackSDNCResponse", "") - verify(mockExecution).setVariable(Prefix + "rollbackSDNCReturnCode", "") - - verify(mockExecution).setVariable(Prefix + "Success", false) - verify(mockExecution).setVariable(Prefix + "fullRollback", false) - - - } - - @Test - //@Ignore - public void preProcessRequest() { - - println "************ preProcessRequest ************* " - - WorkflowException workflowException = new WorkflowException("DoUpdateNetworkInstanceRollback", 2500, "Received error from Network Adapter: JBWEB000065: HTTP Status 500.") - Map rollbackData = new HashMap(); - rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) - rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) - - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) - when(mockExecution.getVariable("rollbackData")).thenReturn(rollbackData) - when(mockExecution.getVariable("sdncVersion")).thenReturn("1610") - when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - when(mockExecution.getVariable("mso.adapters.sdnc.endpoint")).thenReturn("http://localhost:28090/SDNCAdapter") - when(mockExecution.getVariable("mso.adapters.network.rest.endpoint")).thenReturn("http://localhost:28090/networks/NetworkAdapter") - when(mockExecution.getVariable("mso.adapters.sdnc.resource.endpoint")).thenReturn("http://localhost:28090/SDNCAdapterRpc") - - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstanceRollback DoUpdateNetworkInstanceRollback = new DoUpdateNetworkInstanceRollback() - DoUpdateNetworkInstanceRollback.preProcessRequest(mockExecution) - -// verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix) - - //verify variable initialization - initializeVariables(mockExecution) - - } - - - @Test - @Ignore - public void validateRollbackResponses_Good() { - - WorkflowException workflowException = new WorkflowException("DoUpdateNetworkInstanceRollback", 2500, "AAI Update Contrail Failed. Error 404.") - WorkflowException expectedWorkflowException = new WorkflowException("DoUpdateNetworkInstanceRollback", 2500, "AAI Update Contrail Failed. Error 404. + SNDC activate rollback completed. + PO Network rollback completed. + SNDC assign rollback completed.") - - println "************ validateRollbackResponses_Good() ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackNetworkReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackNetworkResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "rollbackSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackSDNCResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "WorkflowException")).thenReturn(workflowException) - when(mockExecution.getVariable(Prefix + "fullRollback")).thenReturn(false) - - DoUpdateNetworkInstanceRollback DoUpdateNetworkInstanceRollback = new DoUpdateNetworkInstanceRollback() - DoUpdateNetworkInstanceRollback.validateRollbackResponses(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) - verify(mockExecution, atLeast(1)).setVariable("rolledBack", true) - verify(mockExecution, atLeast(1)).setVariable("wasDeleted", true) - verify(mockExecution).setVariable("WorkflowException", refEq(expectedWorkflowException, any(WorkflowException.class))) - //verify(mockExecution).setVariable("WorkflowException", expectedWorkflowException) - } - - @Test - //@Ignore - public void validateRollbackResponses_FullRollback() { - - Map rollbackData = new HashMap(); - rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) - rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) - - println "************ validateRollbackResponses_FullRollback() ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn(Prefix) - when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn("Good") - when(mockExecution.getVariable(Prefix + "rollbackNetworkReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackNetworkResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "rollbackSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "rollbackSDNCResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable(Prefix + "WorkflowException")).thenReturn(null) - when(mockExecution.getVariable(Prefix + "fullRollback")).thenReturn(true) - when(mockExecution.getVariable("rollbackData")).thenReturn(rollbackData) - - DoUpdateNetworkInstanceRollback DoUpdateNetworkInstanceRollback = new DoUpdateNetworkInstanceRollback() - DoUpdateNetworkInstanceRollback.validateRollbackResponses(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) - verify(mockExecution, atLeast(1)).setVariable("rollbackSuccessful", true) - verify(mockExecution, atLeast(1)).setVariable("rollbackError", false) - - } - - - private ExecutionEntity setupMock() { - - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("DoUpdateNetworkInstanceRollback") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoUpdateNetworkInstanceRollback") - 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("DoUpdateNetworkInstanceRollback") - when(mockExecution.getProcessInstanceId()).thenReturn("DoUpdateNetworkInstanceRollback") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - } - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy deleted file mode 100644 index de3db5b5a8..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy +++ /dev/null @@ -1,2762 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - - -import static org.mockito.Mockito.* -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 static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkVpnBinding; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkTableReference; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkPolicy; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutNetworkIdWithDepth; -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.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 DoUpdateNetworkInstanceTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(8090); - - def utils = new MsoUtils() - String Prefix="UPDNETI_" - - String jsonIncomingRequest = - """{ "requestDetails": { - "modelInfo": { - "modelType": "network", - "modelCustomizationId": "f21df226-8093-48c3-be7e-0408fcda0422", - "modelName": "CONTRAIL_EXTERNAL", - "modelVersion": "1.0" - }, - "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_MissingCloudRegion = - """{ "requestDetails": { - "modelInfo": { - "modelType": "network", - "modelCustomizationId": "f21df226-8093-48c3-be7e-0408fcda0422", - "modelName": "CONTRAIL_EXTERNAL", - "modelVersion": "1.0" - }, - "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 - f21df226-8093-48c3-be7e-0408fcda0422 - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - false - 1610 - - - someValue1 - -""" - - -String expectedNetworkRequestMissingCloudRegion = -""" - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - UPDATE - VID - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - - - networkId - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - f21df226-8093-48c3-be7e-0408fcda0422 - null - 7dd5365547234ee8937416c65507d266 - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - false - null - - -""" - -String expectedNetworkInputMissingCloudRegion = -""" - networkId - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - f21df226-8093-48c3-be7e-0408fcda0422 - null - 7dd5365547234ee8937416c65507d266 - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - false - null -""" - - String networkInputsMissingName = - """ - - CONTRAIL_EXTERNAL - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - RDM2WAGPLCP - e81d842d3e8b45c5a59f57cd76af3aaf - """ - -String networkInputsMissingCloudRegion = -""" - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - - e81d842d3e8b45c5a59f57cd76af3aaf -""" - - // expectedNetworkRequest - String expectedNetworkRequest = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - UPDATE - VID - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - - - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - f21df226-8093-48c3-be7e-0408fcda0422 - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - false - 1610 - - - someValue1 - -""" - -String expectedNetworkInputs = -""" - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - f21df226-8093-48c3-be7e-0408fcda0422 - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - false - 1610 -""" - -String expectedVperNetworkRequest = -""" - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - UPDATE - VID - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - - - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - 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 expectedVperNetworkInputs = -""" - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - 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 expectedNetworkInputsMissingNetworkId = -""" - - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - f21df226-8093-48c3-be7e-0408fcda0422 - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - false - 1610 -""" - - - 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 - -""" - - - 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 - 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 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-update - true - subnetName - ECOMP - true - - - 400d286b-7e44-4514-b9b3-f70f7360ff32 - 172.20.1.0/24 - 10.102.200.1 - ip-address - 1505857300987 - - - 6f038013-8b15-4eb8-914b-507489fbc8ee - 10.102.0.0/16 - 10.102.200.1 - ip-address - 1505857301151 - - - 8811c5f8-f1ed-4fa0-a505-e1be60396e28 - 192.168.2.0/25 - 10.102.200.1 - 1505857301954 - - - - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - 107.239.52.1 - 107.239.52.0 - 24 - 4 - pending-delete - true - subnetName - true - - - 400d286b-7e44-4514-b9b3-f70f7360ff32 - 172.20.1.0/24 - 10.102.200.1 - 1505857300987 - - - - - - - 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://localhost: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://localhost: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://localhost: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 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 - sn5256d1-5a33-55df-13ab-12abad84e222 - - 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 - true - - 172.20.1.0/24 - 10.102.200.1 - - - 10.102.0.0/16 - 10.102.200.1 - - - 192.168.2.0/25 - 10.102.200.1 - - - true - true - false - - 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 - true - - 172.20.1.0/24 - 10.102.200.1 - - - 10.102.0.0/16 - 10.102.200.1 - - - 192.168.2.0/25 - 10.102.200.1 - - - 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 - ECOMP - 1505857300987 - subnetName - true - - - 400d286b-7e44-4514-b9b3-f70f7360ff32 - 172.20.1.0/24 - 10.102.200.1 - ip-address - 1505857300987 - - - 6f038013-8b15-4eb8-914b-507489fbc8ee - 10.102.0.0/16 - 10.102.200.1 - ip-address - 1505857301151 - - - 8811c5f8-f1ed-4fa0-a505-e1be60396e28 - 192.168.2.0/25 - 10.102.200.1 - - 1505857301954 - - - - - - 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 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.onap.so/network", the namespace on the "updateNetworkContrail" element, is not a valid SOAP version.""" - - String aaiResponse = - """ - - - - - - - - - - - - bdc5efe8-404a-409b-85f6-0dcc9eebae30 - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - HSL_direct - contrail - 8bbd3edf-b835-4610-96a2-a5cafa029042 - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - active - MNS-25180-L-01-dmz_direct_net_1/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="com:att: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 rollbackSDNCRequest = -""" - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - rollback - network-topology-operation - sdncCallback - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - CreateNetworkInstance - 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 - - invariant-uuid - customization-uuid - uuid - version - CONTRAIL_EXTERNAL - - - - 8abc633a-810b-4ca5-8b3a-09511d13a2ce - CONTRAIL_EXTERNAL - MNS-25180-L-01-dmz_direct_net_1 - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - -""" - -String rollbackNetworkRequest = -""" - - 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 - - - -""" - -// - - - - - - - - - - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - - public void initializeVariables (DelegateExecution mockExecution) { - - verify(mockExecution).setVariable(Prefix + "messageId", "") - verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "") - verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "") - verify(mockExecution).setVariable(Prefix + "networkRequest", "") - verify(mockExecution).setVariable(Prefix + "networkInputs", "") - verify(mockExecution).setVariable(Prefix + "networkOutputs", "") - verify(mockExecution).setVariable(Prefix + "requestId", "") - verify(mockExecution).setVariable(Prefix + "source", "") - verify(mockExecution).setVariable(Prefix + "networkId", "") - - verify(mockExecution).setVariable(Prefix + "isPONR", 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 + "isCloudRegionGood", false) - - // AAI query Id - verify(mockExecution).setVariable(Prefix + "queryIdAAIRequest","") - verify(mockExecution).setVariable(Prefix + "queryIdAAIResponse", "") - verify(mockExecution).setVariable(Prefix + "aaiIdReturnCode", "") - - // AAI query vpn binding - verify(mockExecution).setVariable(Prefix + "queryVpnBindingAAIRequest","") - verify(mockExecution).setVariable(Prefix + "queryVpnBindingAAIResponse", "") - verify(mockExecution).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "") - verify(mockExecution).setVariable(Prefix + "vpnBindings", null) - verify(mockExecution).setVariable(Prefix + "vpnCount", 0) - verify(mockExecution).setVariable(Prefix + "routeCollection", "") - - // AAI query network policy - verify(mockExecution).setVariable(Prefix + "queryNetworkPolicyAAIRequest","") - verify(mockExecution).setVariable(Prefix + "queryNetworkPolicyAAIResponse", "") - verify(mockExecution).setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "") - verify(mockExecution).setVariable(Prefix + "networkPolicyUriList", null) - verify(mockExecution).setVariable(Prefix + "networkPolicyCount", 0) - verify(mockExecution).setVariable(Prefix + "networkCollection", "") - - // AAI query route table reference - verify(mockExecution).setVariable(Prefix + "queryNetworkTableRefAAIRequest","") - verify(mockExecution).setVariable(Prefix + "queryNetworkTableRefAAIResponse", "") - verify(mockExecution).setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "") - verify(mockExecution).setVariable(Prefix + "networkTableRefUriList", null) - verify(mockExecution).setVariable(Prefix + "networkTableRefCount", 0) - verify(mockExecution).setVariable(Prefix + "tableRefCollection", "") - - - // AAI requery Id - verify(mockExecution).setVariable(Prefix + "requeryIdAAIRequest","") - verify(mockExecution).setVariable(Prefix + "requeryIdAAIResponse", "") - verify(mockExecution).setVariable(Prefix + "aaiRequeryIdReturnCode", "") - - // AAI update contrail - verify(mockExecution).setVariable(Prefix + "updateContrailAAIUrlRequest","") - verify(mockExecution).setVariable(Prefix + "updateContrailAAIPayloadRequest","") - verify(mockExecution).setVariable(Prefix + "updateContrailAAIResponse", "") - verify(mockExecution).setVariable(Prefix + "aaiUpdateContrailReturnCode", "") - - verify(mockExecution).setVariable(Prefix + "updateNetworkRequest", "") - verify(mockExecution).setVariable(Prefix + "updateNetworkResponse", "") - verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", "") - //verify(mockExecution).setVariable(Prefix + "rollbackNetworkResponse", "") - verify(mockExecution).setVariable(Prefix + "networkReturnCode", "") - //verify(mockExecution).setVariable(Prefix + "rollbackNetworkReturnCode", "") - verify(mockExecution).setVariable(Prefix + "isNetworkRollbackNeeded", false) - - verify(mockExecution).setVariable(Prefix + "changeAssignSDNCRequest", "") - verify(mockExecution).setVariable(Prefix + "changeAssignSDNCResponse", "") - verify(mockExecution).setVariable(Prefix + "rollbackSDNCRequest", "") - //verify(mockExecution).setVariable(Prefix + "rollbackSDNCResponse", "") - verify(mockExecution).setVariable(Prefix + "sdncReturnCode", "") - //verify(mockExecution).setVariable(Prefix + "rollbackSDNCReturnCode", "") - verify(mockExecution).setVariable(Prefix + "isSdncRollbackNeeded", false) - verify(mockExecution).setVariable(Prefix + "sdncResponseSuccess", false) - - verify(mockExecution).setVariable(Prefix + "isVnfBindingPresent", false) - verify(mockExecution).setVariable(Prefix + "Success", false) - verify(mockExecution).setVariable(Prefix + "serviceInstanceId", "") - - verify(mockExecution).setVariable(Prefix + "isException", false) - - } - - @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("sdncVersion")).thenReturn("1610") - when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - 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("disableRollback")).thenReturn("true") - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.preProcessRequest(mockExecution) - -// verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix + "") - - //verify variable initialization - initializeVariables(mockExecution) - - // Authentications - verify(mockExecution).setVariable("action", "UPDATE") - verify(mockExecution).setVariable(Prefix + "networkRequest", expectedNetworkRequest) - verify(mockExecution).setVariable(Prefix + "rollbackEnabled", false) - verify(mockExecution).setVariable(Prefix + "networkInputs", expectedNetworkInputs) - verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") - verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") - verify(mockExecution).setVariable(Prefix + "networkOutputs", "") - - } - - @Test - //@Ignore - public void preProcessRequest_vPERNetworkRequest() { - - 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("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("49c86598-f766-46f8-84f8-8d1c1b10f9b4") // 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("UPDATE") - when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("MSO-dev-service-type") - when(mockExecution.getVariable("globalSubscriberId")).thenReturn("globalId_45678905678") - when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - - when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - when(mockExecution.getVariable("mso.rollback")).thenReturn("true") - when(mockExecution.getVariable("mso.adapters.sdnc.endpoint")).thenReturn("http://localhost:8090/SDNCAdapter") - when(mockExecution.getVariable("mso.adapters.network.rest.endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") - when(mockExecution.getVariable("mso.adapters.sdnc.resource.endpoint")).thenReturn("http://localhost:8090/SDNCAdapterRpc") - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.preProcessRequest(mockExecution) - -// verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix + "") - - //verify variable initialization - initializeVariables(mockExecution) - - // Authentications - verify(mockExecution).setVariable("action", "UPDATE") - verify(mockExecution).setVariable(Prefix + "networkRequest", expectedVperNetworkRequest) - verify(mockExecution).setVariable(Prefix + "rollbackEnabled", false) - verify(mockExecution).setVariable(Prefix + "networkInputs", expectedVperNetworkInputs) - verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") - verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") - verify(mockExecution).setVariable(Prefix + "networkOutputs", "") - - } - - @Test - //@Ignore - public void preProcessRequest_MissingNetworkId() { - - println "************ preProcessRequest_MissingName() ************* " - - WorkflowException missingNameWorkflowException = new WorkflowException("DoUpdateNetworkInstance", 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("sdncVersion")).thenReturn("1610") - - when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - 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("disableRollback")).thenReturn("true") - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - try { - DoUpdateNetworkInstance.preProcessRequest(mockExecution) - } catch (Exception ex) { - println " Test End - Handle catch-throw BpmnError()! " - } - - verify(mockExecution, atLeast(1)).getVariable("isDebugLogEnabled") - verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix + "") - - //verify variable initialization - initializeVariables(mockExecution) - - verify(mockExecution).setVariable("action", "UPDATE") - verify(mockExecution).setVariable(Prefix + "networkRequest", expectedNetworkRequestMissingNetworkId) - verify(mockExecution).setVariable(Prefix + "rollbackEnabled", false) - verify(mockExecution).setVariable(Prefix + "networkInputs", expectedNetworkInputsMissingNetworkId) - verify(mockExecution).setVariable(Prefix + "messageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") - verify(mockExecution).setVariable(Prefix + "source", "VID") - verify(mockExecution).setVariable(Prefix + "networkOutputs", "") - - verify(mockExecution).setVariable(eq("WorkflowException"), refEq(missingNameWorkflowException)) - - } - - @Test - //@Ignore - public void preProcessRequest_MissingCloudRegion() { - - println "************ preProcessRequest_MissingCloudRegion() ************* " - - WorkflowException missingCloudRegionWorkflowException = new WorkflowException("DoUpdateNetworkInstance", 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(Prefix + "messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - 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("disableRollback")).thenReturn("true") - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - try { - DoUpdateNetworkInstance.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", Prefix + "") - - //verify variable initialization - initializeVariables(mockExecution) - - verify(mockExecution).setVariable("action", "UPDATE") - verify(mockExecution).setVariable(Prefix + "networkRequest", expectedNetworkRequestMissingCloudRegion) - verify(mockExecution).setVariable(Prefix + "rollbackEnabled", false) - verify(mockExecution).setVariable(Prefix + "networkInputs", expectedNetworkInputMissingCloudRegion) - verify(mockExecution).setVariable(Prefix + "messageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") - verify(mockExecution).setVariable(Prefix + "source", "VID") - - verify(mockExecution).setVariable(eq("WorkflowException"), refEq(missingCloudRegionWorkflowException)) - - } - - @Test - //@Ignore - public void prepareUpdateNetworkRequest() { - - println "************ prepareNetworkRequest ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedVperNetworkRequest) - when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - when(mockExecution.getVariable(Prefix + "cloudRegionPo")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("messageId_generated") - when(mockExecution.getVariable(Prefix + "source")).thenReturn("VID") - //when(mockExecution.getVariable(Prefix + "queryVpnBindingAAIResponse")).thenReturn(queryVpnBindingAAIResponse) - when(mockExecution.getVariable(Prefix + "routeCollection")).thenReturn("13979:10575713979:105757") - when(mockExecution.getVariable(Prefix + "networkCollection")).thenReturn("GN_EVPN_Test") - when(mockExecution.getVariable(Prefix + "tableRefCollection")).thenReturn("refFQDN1refFQDN2") - when(mockExecution.getVariable(Prefix + "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(Prefix + "rollbackEnabled")).thenReturn("true") - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.prepareUpdateNetworkRequest(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution).setVariable("prefix", Prefix + "") - - verify(mockExecution).setVariable(Prefix + "updateNetworkRequest", updateNetworkRequest) - - } - - - @Test - //@Ignore - public void prepareUpdateNetworkRequest_NoPhysicalname() { - - println "************ prepareNetworkRequest ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(NetworkRequest_noPhysicalName) - when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - when(mockExecution.getVariable(Prefix + "cloudRegionPo")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("messageId_generated") - when(mockExecution.getVariable(Prefix + "source")).thenReturn("VID") - //when(mockExecution.getVariable(Prefix + "queryVpnBindingAAIResponse")).thenReturn(queryVpnBindingAAIResponse) - when(mockExecution.getVariable(Prefix + "routeCollection")).thenReturn("13979:10575713979:105757") - when(mockExecution.getVariable(Prefix + "networkCollection")).thenReturn("GN_EVPN_Test") - when(mockExecution.getVariable(Prefix + "tableRefCollection")).thenReturn("") - when(mockExecution.getVariable(Prefix + "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(Prefix + "rollbackEnabled")).thenReturn("true") - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.prepareUpdateNetworkRequest(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution).setVariable("prefix", Prefix + "") - - verify(mockExecution).setVariable(Prefix + "updateNetworkRequest", updateNetworkRequest_noPhysicalName) - - } - - @Test - //@Ignore - public void prepareSDNCRequest() { - - println "************ prepareSDNCRequest ************* " - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable(Prefix + "serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") - when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).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("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/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(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.prepareSDNCRequest(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution).setVariable("prefix", Prefix + "") - verify(mockExecution).setVariable(Prefix + "changeAssignSDNCRequest", changeAssignSDNCRequest) - - } - - @Test - //@Ignore - public void prepareSDNCRollbackRequest() { - - println "************ prepareSDNCRollbackRequest ************* " - - - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable(Prefix + "serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") - when(mockExecution.getVariable(Prefix + "changeAssignSDNCResponse")).thenReturn(assignResponse) - 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("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/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(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.prepareSDNCRollbackRequest(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution).setVariable("prefix", Prefix + "") - verify(mockExecution).setVariable(Prefix + "WorkflowException", null) - verify(mockExecution).setVariable(Prefix + "rollbackSDNCRequest", sdncRollbackRequest) - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkId_200() { - - println "************ callRESTQueryAAINetworkId ************* " - - WireMock.reset(); - MockGetNetworkByIdWithDepth("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", "all"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "networkRequest")).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.DoUpdateNetworkInstance.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") - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTQueryAAINetworkId(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix + "") - verify(mockExecution).setVariable(Prefix + "queryIdAAIRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4"+"?depth=all") - verify(mockExecution).setVariable(Prefix + "aaiIdReturnCode", "200") - - } - - @Test - //@Ignore - public void callRESTQueryAAICloudRegion30_200() { - - println "************ callRESTQueryAAICloudRegion30_200 ************* " - - WireMock.reset(); - MockGetNetworkCloudRegion("CreateNetworkV2/cloudRegion30_AAIResponse_Success.xml", "RDM2WAGPLCP"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") - 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/att-aic") - 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) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix + "") - verify(mockExecution, atLeast(2)).setVariable(Prefix + "queryCloudRegionReturnCode", "200") - verify(mockExecution).setVariable(Prefix + "isCloudRegionGood", true) - - } - - @Test - public void callRESTQueryAAICloudRegion25_200() { - - println "************ callRESTQueryAAICloudRegion25_200 ************* " - - WireMock.reset(); - MockGetNetworkCloudRegion("CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml", "RDM2WAGPLCP"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") - 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/att-aic") - 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) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix + "") - verify(mockExecution).setVariable(Prefix + "isCloudRegionGood", true) - - } - - @Test - //@Ignore - public void callRESTQueryAAICloudRegion_NotFound() { - - println "************ callRESTQueryAAICloudRegionFake ************* " - - WireMock.reset(); - MockGetNetworkCloudRegion_404("MDTWNJ21"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(vnfRequestFakeRegion) - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") - 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/att-aic") - 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) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix + "") - verify(mockExecution, atLeast(1)).setVariable(Prefix + "queryCloudRegionReturnCode", "404") - verify(mockExecution).setVariable(Prefix + "cloudRegionPo", "MDTWNJ21") - verify(mockExecution).setVariable(Prefix + "cloudRegionSdnc", "AAIAIC25") - verify(mockExecution).setVariable(Prefix + "isCloudRegionGood", true) - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkVpnBinding_200() { - - println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " - - WireMock.reset(); - MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); - MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", "c980a6ef-3b88-49f0-9751-dbad8608d0a6"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) // v6 - 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.global.default.aai.version")).thenReturn("8") - when(mockExecution.getVariable("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("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) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix + "") - verify(mockExecution).setVariable(Prefix + "vpnCount", 2) - verify(mockExecution).setVariable(Prefix + "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(Prefix + "queryVpnBindingAAIRequest", "http://localhost:8090/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017?depth=all") - verify(mockExecution, atLeast(2)).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkVpnBindingList_200() { - - println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " - - WireMock.reset(); - MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBindingList_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); - MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBindingList_AAIResponse_Success.xml", "c980a6ef-3b88-49f0-9751-dbad8608d0a6"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) // v6 - 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.global.default.aai.version")).thenReturn("8") - when(mockExecution.getVariable("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("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) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix + "") - verify(mockExecution).setVariable(Prefix + "vpnCount", 2) - verify(mockExecution).setVariable(Prefix + "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(Prefix + "queryVpnBindingAAIRequest", "http://localhost:8090/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017?depth=all") - verify(mockExecution, atLeast(2)).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") - - } - - - @Test - //@Ignore - public void callRESTQueryAAINetworkVpnBinding_TestScenario01_200() { - - println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " - - WireMock.reset(); - MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponseTestScenario01) - 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.global.default.aai.version")).thenReturn("8") - when(mockExecution.getVariable("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("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) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix + "") - verify(mockExecution).setVariable(Prefix + "vpnCount", 1) - verify(mockExecution).setVariable(Prefix + "vpnBindings", ['/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/']) - // the last vpnBinding value is saved. - verify(mockExecution).setVariable(Prefix + "queryVpnBindingAAIRequest", "http://localhost:8090/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017?depth=all") - verify(mockExecution).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkVpnBinding_200_URN_Uri() { - - println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " - - WireMock.reset(); - MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); - MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", "c980a6ef-3b88-49f0-9751-dbad8608d0a6"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - 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.global.default.aai.version")).thenReturn("8") - when(mockExecution.getVariable("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("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) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix + "") - verify(mockExecution).setVariable(Prefix + "vpnCount", 2) - verify(mockExecution).setVariable(Prefix + "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(Prefix + "queryVpnBindingAAIRequest", "http://localhost:8090/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017?depth=all") - verify(mockExecution, atLeast(2)).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkVpnBinding_NotPresent() { - - println "************ callRESTQueryAAINetworkVpnBinding_NotPresent ************* " - - WireMock.reset(); - MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); - - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - - when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponseVpnNotPresent) - 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.global.default.aai.version")).thenReturn("8") - when(mockExecution.getVariable("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("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) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix + "") - verify(mockExecution).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") - verify(mockExecution).setVariable(Prefix + "vpnCount", 0) - verify(mockExecution).setVariable(Prefix + "queryVpnBindingAAIResponse", aaiVpnResponseStub) - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkTableRef_200() { - - println "************ callRESTQueryAAINetworkTableRef_200 ************* " - - WireMock.reset(); - MockGetNetworkTableReference("UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", "refFQDN1"); - MockGetNetworkTableReference("UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", "refFQDN2"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - 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-table-reference.uri")).thenReturn("") - when(mockExecution.getVariable("mso.workflow.DoUpdateNetworkInstance.aai.route-table-reference.uri")).thenReturn("/aai/v8/network/route-table-references/route-table-reference") - 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) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTQueryAAINetworkTableRef(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix + "") - verify(mockExecution).setVariable(Prefix + "networkTableRefCount", 2) - verify(mockExecution).setVariable(Prefix + "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(Prefix + "queryNetworkTableRefAAIRequest", "http://localhost:8090/aai/v8/network/route-table-references/route-table-reference/refFQDN1?depth=all") - verify(mockExecution, atLeast(2)).setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkPolicy_200() { - - println "************ callRESTQueryAAINetworkPolicy_200 ************* " - - WireMock.reset(); - MockGetNetworkPolicy("UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", "cee6d136-e378-4678-a024-2cd15f0ee0cg"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - 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.global.default.aai.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.network-policy.uri")).thenReturn("/aai/v8/network/network-policies/network-policy") - 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) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTQueryAAINetworkPolicy(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix + "") - verify(mockExecution).setVariable(Prefix + "networkPolicyCount", 1) - verify(mockExecution).setVariable(Prefix + "networkPolicyUriList", ['/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg']) - // the last vpnBinding value is saved. - verify(mockExecution).setVariable(Prefix + "queryNetworkPolicyAAIRequest", "http://localhost:8090/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg?depth=all") - verify(mockExecution).setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") - - } - - - @Test - //@Ignore - public void callRESTReQueryAAINetworkId_200() { - - println "************ callRESTReQueryAAINetworkId ************* " - - WireMock.reset(); - MockGetNetworkByIdWithDepth("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", "all"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable(Prefix + "changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowFormattedResponse) - 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.DoUpdateNetworkInstance.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") - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTReQueryAAINetworkId(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix + "") - verify(mockExecution).setVariable(Prefix + "requeryIdAAIRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4"+"?depth=all") - verify(mockExecution).setVariable(Prefix + "aaiRequeryIdReturnCode", "200") - - } - - - @Test - //@Ignore - public void callRESTUpdateContrailAAINetworkREST_200() { - - println "************ callRESTUpdateContrailAAINetwork ************* " - - WireMock.reset(); - MockPutNetworkIdWithDepth("UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml", "49c86598-f766-46f8-84f8-8d1c1b10f9b4", "all"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable(Prefix + "changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowFormattedResponse) - when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - when(mockExecution.getVariable(Prefix + "updateNetworkResponse")).thenReturn(updateNetworkResponseREST) - 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.DoUpdateNetworkInstance.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") - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTUpdateContrailAAINetwork(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix + "") - verify(mockExecution).setVariable(Prefix + "updateContrailAAIUrlRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4"+"?depth=all") - verify(mockExecution).setVariable(Prefix + "updateContrailAAIPayloadRequest", updateContrailAAIPayloadRequest) - verify(mockExecution).setVariable(Prefix + "aaiUpdateContrailReturnCode", "200") - //verify(mockExecution).setVariable(Prefix + "updateContrailAAIResponse", updateContrailAAIResponse) - verify(mockExecution).setVariable(Prefix + "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(Prefix + "updateNetworkResponse")).thenReturn(updateNetworkResponseREST) - when(mockExecution.getVariable(Prefix + "networkReturnCode")).thenReturn('200') - - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.validateUpdateNetworkResponse(mockExecution) - - //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() - //debugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix + "") - verify(mockExecution).setVariable(Prefix + "updateNetworkResponse", updateNetworkResponseREST) - verify(mockExecution).setVariable(Prefix + "isNetworkRollbackNeeded", true) - verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", updateRollbackNetworkRequest) - - } - - @Test - //@Ignore - public void validateUpdateNetworkResponseREST_Error() { - - println "************ validateNetworkResponse ************* " - - WorkflowException workflowException = new WorkflowException("DoUpdateNetworkInstance", 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(Prefix + "updateNetworkResponse")).thenReturn(networkException500) - when(mockExecution.getVariable(Prefix + "networkReturnCode")).thenReturn('500') - - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - try { - DoUpdateNetworkInstance.validateUpdateNetworkResponse(mockExecution) - } catch (Exception ex) { - println " Test End - Handle catch-throw BpmnError()! " - } - - verify(mockExecution).setVariable("prefix", Prefix + "") - 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(Prefix + "changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowResponse) - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) - when(mockExecution.getVariable(Prefix + "sdncReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "isResponseGood")).thenReturn(true) - - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - try { - DoUpdateNetworkInstance.validateSDNCResponse(mockExecution) - verify(mockExecution).setVariable(Prefix + "isSdncRollbackNeeded", true) - verify(mockExecution).setVariable(Prefix + "rollbackSDNCRequest", "") - - } 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 validateSDNCResponse_Error() { - - println "************ validateSDNCResponse ************* " - //ExecutionEntity mockExecution = mock(ExecutionEntity.class) - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable(Prefix + "changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowResponse_Error) - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(false) - when(mockExecution.getVariable(Prefix + "sdncReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "isResponseGood")).thenReturn(true) - - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - try { - DoUpdateNetworkInstance.validateSDNCResponse(mockExecution) - } catch (Exception ex) { - println " Graceful Exit! - " + ex.getMessage() - } - //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() - //debugger.printInvocations(mockExecution) - - // verify set prefix = Prefix + "" - //verify(mockExecution).setVariable(Prefix + "sdncResponseSuccess", false) - - } - - @Test - //@Ignore - public void prepareRollbackData() { - - println "************ prepareRollbackData() ************* " - - - - WorkflowException workflowException = new WorkflowException("DoUpdateNetworkInstance", 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 + "rollbackSDNCRequest")).thenReturn(rollbackSDNCRequest) - when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn(rollbackNetworkRequest) - when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.prepareRollbackData(mockExecution) - -// verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix) - - } - - @Test - //@Ignore - public void postProcessResponse() { - - println "************ postProcessResponse() ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable(Prefix + "isException")).thenReturn(false) - when(mockExecution.getVariable("sdncVersion")).thenReturn("1610") - when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn(rollbackSDNCRequest) - when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn(rollbackSDNCRequest) - when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable("mso-request-id")).thenReturn("requestId") - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.postProcessResponse(mockExecution) - -// verify(mockExecution, atLeast(3)).getVariable("isDebugLogEnabled") - verify(mockExecution, atLeast(3)).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "Success", true) - - } - - private ExecutionEntity setupMock() { - - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("DoUpdateNetworkInstance") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoUpdateNetworkInstance") - 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("DoUpdateNetworkInstance") - when(mockExecution.getProcessInstanceId()).thenReturn("DoUpdateNetworkInstance") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - } - - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy deleted file mode 100644 index beaebceaf7..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVfModuleTest.groovy +++ /dev/null @@ -1,309 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import com.github.tomakehurst.wiremock.junit.WireMockRule -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.junit.Assert -import org.junit.Before -import org.junit.Ignore -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.Captor -import org.mockito.Mockito -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.onap.so.bpmn.common.scripts.VfModule -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.mock.FileUtil - -import static com.github.tomakehurst.wiremock.client.WireMock.* -import static org.mockito.Mockito.* -import org.onap.so.bpmn.common.scripts.utils.XmlComparator - -@RunWith(MockitoJUnitRunner.class) -class DoUpdateVfModuleTest { - - def prefix = "DOUPVfMod_" - String doUpdateVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/DoUpdateVfModuleRequest.xml"); - String sdncChangeAssignRequest = FileUtil.readResourceFile("__files/DoUpdateVfModule/sdncChangeAssignRequest.xml") - String sdncTopologyRequest = FileUtil.readResourceFile("__files/DoUpdateVfModule/sdncTopologyRequest.xml") - - @Captor - static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) - - @Rule - public WireMockRule wireMockRule = new WireMockRule(28090); - - @Before - public void init() { - MockitoAnnotations.initMocks(this) - } - - @Test - void testPreProcessRequest() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(prefix) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("DoUpdateVfModuleRequest")).thenReturn(doUpdateVfModuleRequest) - when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:28080/mso/SDNCAdapterCallbackService") - - DoUpdateVfModule obj = new DoUpdateVfModule() - obj.preProcessRequest(mockExecution) - - Mockito.verify(mockExecution, atLeastOnce()).getVariable("mso.workflow.sdncadapter.callback") - } - - - - @Test - void testPrepConfirmVolumeGroupTenant() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(prefix) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable(prefix + "aicCloudRegion")).thenReturn("att-aic") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region") - when(mockExecution.getVariable("mso.workflow.default.aai.cloud-region.version")).thenReturn("8") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") - - mockData() - DoUpdateVfModule obj = new DoUpdateVfModule() - obj.prepConfirmVolumeGroupTenant(mockExecution) - - Mockito.verify(mockExecution).setVariable(prefix + "queryCloudRegionRequest", "http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") - Mockito.verify(mockExecution).setVariable(prefix + "queryCloudRegionReturnCode", "200") - Mockito.verify(mockExecution).setVariable(prefix + "cloudRegionForVolume", "AAIAIC25") - Mockito.verify(mockExecution).setVariable(prefix + "isCloudRegionGood", true) - } - - - @Test - void testPrepSDNCTopologyChg() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(prefix) - when(mockExecution.getVariable(prefix + "requestId")).thenReturn("12345") - when(mockExecution.getVariable("testReqId")).thenReturn("testReqId") - - - when(mockExecution.getVariable(prefix + "cloudSiteId")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("cb510af0-5b21-4bc7-86d9-323cb396ce32") - when(mockExecution.getVariable("volumeGroupStackId")).thenReturn("12345") - when(mockExecution.getVariable(prefix + "vfModuleName")).thenReturn("PCRF::module-0-2") - when(mockExecution.getVariable(prefix + "aicCloudRegion")).thenReturn("MDTWNJ21") - when(mockExecution.getVariable(prefix + "usePreload")).thenReturn("Y") - when(mockExecution.getVariable(prefix + "vnfNameFromAAI")).thenReturn("skask-test") - - def node = new Node(null, 'vfModule') - new Node(node, 'vf-module-name', "abc") - VfModule vfModule = new VfModule(node, true); - when(mockExecution.getVariable(prefix + "vfModule")).thenReturn(vfModule) - - when(mockExecution.getVariable(prefix + "tenantId")).thenReturn("fba1bd1e195a404cacb9ce17a9b2b421") - when(mockExecution.getVariable(prefix + "vnfType")).thenReturn("vRRaas") - when(mockExecution.getVariable(prefix + "vnfName")).thenReturn("skask-test") - when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") - when(mockExecution.getVariable(prefix + "vfModuleModelName")).thenReturn("PCRF::module-0-2") - when(mockExecution.getVariable(prefix + "requestId")).thenReturn("testRequestId") - when(mockExecution.getVariable(prefix + "serviceId")).thenReturn("12345") - when(mockExecution.getVariable(prefix + "serviceInstanceId")).thenReturn("MIS/1604/0026/SW_INTERNET") - Map map = new HashMap(); - map.put("vrr_image_name", "MDT17"); - map.put("availability_zone_0", "nova"); - map.put("vrr_flavor_name", "ns.c16r32d128.v1"); - when(mockExecution.getVariable("vnfParamsMap")).thenReturn(map) - when(mockExecution.getVariable("mso-request-id")).thenReturn("testRequestId-1503410089303") - when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/SDNCAdapter") - - mockData() - DoUpdateVfModule obj = new DoUpdateVfModule() - obj.prepSDNCTopologyChg(mockExecution) - - Mockito.verify(mockExecution).setVariable(prefix + "vnfName", "skask-test") - - Mockito.verify(mockExecution, times(2)).setVariable(captor.capture(), captor.capture()) - XmlComparator.assertXMLEquals(sdncChangeAssignRequest, captor.getValue()) - } - - - - @Test - void testPrepSDNCTopologyQuery() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(prefix) - when(mockExecution.getVariable("testReqId")).thenReturn("testReqId") - when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("12345") - when(mockExecution.getVariable(prefix + "serviceId")).thenReturn("12345") - when(mockExecution.getVariable(prefix + "serviceInstanceId")).thenReturn("MIS/1604/0026/SW_INTERNET") - when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/SDNCAdapter") - - mockData() - DoUpdateVfModule obj = new DoUpdateVfModule() - obj.prepSDNCTopologyQuery(mockExecution) - - Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture()) - XmlComparator.assertXMLEquals(sdncTopologyRequest, captor.getValue()) - } - - - - @Test - void testPrepVnfAdapterRest() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(prefix) - when(mockExecution.getVariable(prefix + "aicCloudRegion")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("cb510af0-5b21-4bc7-86d9-323cb396ce32") - when(mockExecution.getVariable(prefix + "volumeGroupStackId")).thenReturn("12345") - when(mockExecution.getVariable(prefix + "vfModuleName")).thenReturn("PCRF::module-0-2") - when(mockExecution.getVariable(prefix + "tenantId")).thenReturn("fba1bd1e195a404cacb9ce17a9b2b421") - when(mockExecution.getVariable(prefix + "vnfType")).thenReturn("vRRaas") - when(mockExecution.getVariable(prefix + "vnfName")).thenReturn("skask-test") - when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") - when(mockExecution.getVariable(prefix + "vfModuleModelName")).thenReturn("PCRF::module-0-2") - when(mockExecution.getVariable(prefix + "vfModuleIndex")).thenReturn("index") - when(mockExecution.getVariable(prefix + "requestId")).thenReturn("testRequestId") - when(mockExecution.getVariable(prefix + "serviceId")).thenReturn("12345") - when(mockExecution.getVariable(prefix + "serviceInstanceId")).thenReturn("MIS/1604/0026/SW_INTERNET") - when(mockExecution.getVariable(prefix + "backoutOnFailure")).thenReturn("12345") - when(mockExecution.getVariable(prefix + "volumeGroupId")).thenReturn("12345") - when(mockExecution.getVariable(prefix + "asdcServiceModelVersion")).thenReturn("1.0") - when(mockExecution.getVariable(prefix + "modelCustomizationUuid")).thenReturn("cb510af0-5b21-4bc7-86d9-323cb396ced3") - when(mockExecution.getVariable(prefix + "baseVfModuleId")).thenReturn("12345") - when(mockExecution.getVariable(prefix + "baseVfModuleHeatStackId")).thenReturn("12345") - - def node = new Node(null, 'vfModule') - new Node(node, 'heat-stack-id', "abc") - VfModule vfModule = new VfModule(node, true); - when(mockExecution.getVariable(prefix + "vfModule")).thenReturn(vfModule) - - String sdncGetResponse = FileUtil.readResourceFile("__files/DoUpdateVfModule/sdncGetResponse.xml"); - when(mockExecution.getVariable(prefix + "sdncTopologyResponse")).thenReturn(sdncGetResponse) - Map map = new HashMap(); - map.put("vrr_image_name", "MDT17"); - map.put("availability_zone_0", "nova"); - map.put("vrr_flavor_name", "ns.c16r32d128.v1"); - when(mockExecution.getVariable(prefix + "vnfParamsMap")).thenReturn(map) - when(mockExecution.getVariable("mso-request-id")).thenReturn("testRequestId-1503410089303") - when(mockExecution.getVariable("mso.use.qualified.host")).thenReturn("true") - when(mockExecution.getVariable("mso.workflow.message.endpoint")).thenReturn("http://localhost:28080/mso/WorkflowMesssage") - - mockData() - DoUpdateVfModule obj = new DoUpdateVfModule() - obj.prepVnfAdapterRest(mockExecution) - - String createVnfARequest = FileUtil.readResourceFile("__files/DoUpdateVfModule/vnfAdapterRestRequest.xml") - Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture()) - XmlComparator.assertXMLEquals(createVnfARequest, captor.getValue(), "messageId", "notificationUrl") - } - - - - @Test - void testPrepSDNCTopologyAct() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(prefix) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable(prefix + "aicCloudRegion")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable("testReqId")).thenReturn("testReqId") - when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("cb510af0-5b21-4bc7-86d9-323cb396ce32") - when(mockExecution.getVariable(prefix + "tenantId")).thenReturn("fba1bd1e195a404cacb9ce17a9b2b421") - when(mockExecution.getVariable(prefix + "vnfType")).thenReturn("vRRaas") - when(mockExecution.getVariable(prefix + "vnfName")).thenReturn("skask-test") - when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask") - when(mockExecution.getVariable(prefix + "vfModuleModelName")).thenReturn("PCRF::module-0-2") - when(mockExecution.getVariable(prefix + "requestId")).thenReturn("testRequestId") - when(mockExecution.getVariable(prefix + "serviceId")).thenReturn("12345") - when(mockExecution.getVariable(prefix + "serviceInstanceId")).thenReturn("MIS/1604/0026/SW_INTERNET") - when(mockExecution.getVariable(prefix + "usePreload")).thenReturn("Y") - when(mockExecution.getVariable(prefix + "modelCustomizationUuid")).thenReturn("cb510af0-5b21-4bc7-86d9-323cb396ced3") - - def node = new Node(null, 'vfModule') - new Node(node, 'vf-module-name', "abc") - VfModule vfModule = new VfModule(node, true); - when(mockExecution.getVariable(prefix + "vfModule")).thenReturn(vfModule) - - when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/SDNCAdapter") - - mockData() - DoUpdateVfModule obj = new DoUpdateVfModule() - obj.prepSDNCTopologyAct(mockExecution) - - String createVnfARequest = FileUtil.readResourceFile("__files/DoUpdateVfModule/sdncActivateRequest.xml") - Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture()) - XmlComparator.assertXMLEquals(createVnfARequest, captor.getValue()) - } - - @Test - void testQueryAAIVfModule() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(prefix) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("12345") - when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") - - mockData() - DoUpdateVfModule obj = new DoUpdateVfModule() - obj.queryAAIVfModule(mockExecution) - Mockito.verify(mockExecution).setVariable(prefix + "queryAAIVfModuleResponseCode", 200) - } - - - private static ExecutionEntity setupMock() { - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("DoUpdateVfModule") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoUpdateVfModule") - 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("DoUpdateVfModule") - when(mockExecution.getProcessInstanceId()).thenReturn("DoUpdateVfModule") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - } - - private static void mockData() { - stubFor(get(urlMatching(".*/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic")) - .willReturn(aResponse() - .withStatus(200).withHeader("Content-Type", "text/xml") - .withBodyFile("DoUpdateVfModule/cloudRegion_AAIResponse_Success.xml"))) - - stubFor(get(urlMatching(".*/aai/v[0-9]+/network/generic-vnfs/generic-vnf/12345[?]depth=1")) - .willReturn(aResponse() - .withStatus(200).withHeader("Content-Type", "text/xml") - .withBodyFile("DoUpdateVfModule/getGenericVnfResponse.xml"))) - } -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModulesTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModulesTest.groovy deleted file mode 100644 index ba54787dc1..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateVnfAndModulesTest.groovy +++ /dev/null @@ -1,126 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import com.github.tomakehurst.wiremock.junit.WireMockRule -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.junit.Assert -import org.junit.Before -import org.junit.Ignore -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.Captor -import org.mockito.Mockito -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.onap.so.bpmn.core.WorkflowException - -import static com.github.tomakehurst.wiremock.client.WireMock.* -import static org.mockito.Mockito.* - -@RunWith(MockitoJUnitRunner.class) -class DoUpdateVnfAndModulesTest { - - @Captor - static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) - - @Rule - public WireMockRule wireMockRule = new WireMockRule(28090); - - @Before - public void init() { - MockitoAnnotations.initMocks(this) - } - - @Test - void testQueryAAIVfModule() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("vnfId")).thenReturn("12345") - when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") - - mockData() - DoUpdateVnfAndModules obj = new DoUpdateVnfAndModules() - obj.queryAAIVfModule(mockExecution) - Mockito.verify(mockExecution).setVariable("DUVAM_queryAAIVfModuleResponseCode", 200) - } - - @Test - @Ignore - void testQueryAAIVfModuleEndpointNull() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("vnfId")).thenReturn("12345") - when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf") - when(mockExecution.getVariable("aai.endpoint")).thenReturn(null) - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") - - mockData() - try { - DoUpdateVnfAndModules obj = new DoUpdateVnfAndModules() - obj.queryAAIVfModule(mockExecution) - } catch (Exception ex) { - println " Test End - Handle catch-throw BpmnError()! " - } - Mockito.verify(mockExecution, atLeastOnce()).setVariable(captor.capture(), captor.capture()) - WorkflowException workflowException = captor.getValue() - Assert.assertEquals(1002, workflowException.getErrorCode()) - Assert.assertEquals("AAI GET Failed:org.apache.http.client.ClientProtocolException", workflowException.getErrorMessage()) - } - - private static ExecutionEntity setupMock() { - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("DoUpdateVfModule") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoUpdateVfModule") - 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("DoUpdateVfModule") - when(mockExecution.getProcessInstanceId()).thenReturn("DoUpdateVfModule") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - } - - private static void mockData() { - stubFor(get(urlMatching(".*/aai/v[0-9]+/network/generic-vnfs/generic-vnf/12345[?]depth=1")) - .willReturn(aResponse() - .withStatus(200).withHeader("Content-Type", "text/xml") - .withBodyFile("DoUpdateVfModule/getGenericVnfResponse.xml"))) - } - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstanceTest.groovy deleted file mode 100644 index e196a62e1f..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstanceTest.groovy +++ /dev/null @@ -1,195 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 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 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.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.onap.so.bpmn.common.scripts.MsoUtils -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.common.scripts.ExceptionUtil - - -import com.github.tomakehurst.wiremock.junit.WireMockRule - -@RunWith(MockitoJUnitRunner.class) -class SacleCustomE2EServiceInstanceTest{ - @Rule - public WireMockRule wireMockRule = new WireMockRule(8090); - - String Prefix="CRESI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - String globalSubscriberId="test_custormer" - String requestDescription = "request description for test" - def utils = new MsoUtils() - - String jsonIncomingRequest = """{"service":{ - "serviceType":"example-service-type", - "globalSubscriberId":"test_custormer", - "resources":[ - { - "resourceInstanceId":"ns111", - "scaleType":"SCALE_NS", - "scaleNsData":{ - "scaleNsByStepsData":{ - "numberOfSteps":"4", - "aspectId":"TIC_EDGE_HW", - "scalingDirection":"UP" - } - } - }, - { - "resourceInstanceId":"ns333", - "scaleType":"SCALE_NS", - "scaleNsData":{ - "scaleNsByStepsData":{ - "numberOfSteps":"4", - "aspectId":"TIC_EDGE_HW", - "scalingDirection":"UP" - } - } - }], - "serviceInstanceName":"XXXX" - }, - "operationId":"0a5b1651-c56e-4263-8c26-c8f8a6ef72d8" - }""" - - String xmlMsoCompletionRequest = """ - - 56c881ad-6c9d-4b79-aacc-401e5640b47f - SCALE - null - - Service Instance was scaled successfully. - 56c881ad-6c9d-4b79-aacc-401e5640b47f - ScaleGenericALaCarteServiceInstance -""" - - String requestInfo = """ - 56c881ad-6c9d-4b79-aacc-401e5640b47f - SCALE - null - """ - - String payload =""" - - - - 56c881ad-6c9d-4b79-aacc-401e5640b47f - 0a5b1651-c56e-4263-8c26-c8f8a6ef72d8 - SCALE - - processing - Prepare service scaling - 0 - - - - """ - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - - @Test - public void preProcessRequestTest() { - println "************ preProcessRequest_Payload ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest) - - when(mockExecution.getVariable("mso-request-id")).thenReturn("56c881ad-6c9d-4b79-aacc-401e5640b47f") - when(mockExecution.getVariable("serviceInstanceId")).thenReturn("56c881ad-6c9d-4b79-aacc-401e5640b47f") - - ScaleCustomE2EServiceInstance scaleCustomE2EServiceInstance = new ScaleCustomE2EServiceInstance() - scaleCustomE2EServiceInstance.preProcessRequest(mockExecution) - - verify(mockExecution).setVariable("globalSubscriberId", globalSubscriberId) - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable("requestDescription", requestDescription) - } - - @Test - public void sendSyncResponseTest() { - println "************ sendSyncResponse ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("operationId")).thenReturn("3338b250-e995-4782-8936-081b66ba4dbf") - when(mockExecution.getVariable("serviceInstanceId")).thenReturn("56c881ad-6c9d-4b79-aacc-401e5640b47f") - - ScaleCustomE2EServiceInstance scaleCustomE2EServiceInstance = new ScaleCustomE2EServiceInstance() - scaleCustomE2EServiceInstance.sendSyncResponse(mockExecution) - - verify(mockExecution).setVariable("sentSyncResponse", true) - } - - @Test - public void prepareCompletionRequestTest() { - println "************ prepareCompletionRequest ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("msoRequestId")).thenReturn("56c881ad-6c9d-4b79-aacc-401e5640b47f") - when(mockExecution.getVariable("serviceInstanceId")).thenReturn("56c881ad-6c9d-4b79-aacc-401e5640b47f") - - ScaleCustomE2EServiceInstance scaleCustomE2EServiceInstance = new ScaleCustomE2EServiceInstance() - scaleCustomE2EServiceInstance.prepareCompletionRequest(mockExecution) - - verify(mockExecution).setVariable("CompleteMsoProcessRequest", xmlMsoCompletionRequest) - - } - - @Test - public void prepareInitServiceOperationStatusTest() { - println "************ prepareInitServiceOperationStatus ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - - when(mockExecution.getVariable("serviceInstanceId")).thenReturn("56c881ad-6c9d-4b79-aacc-401e5640b47f") - //when(mockExecution.getVariable("serviceInstanceName")).thenReturn("XXXX") - when(mockExecution.getVariable("operationId")).thenReturn("0a5b1651-c56e-4263-8c26-c8f8a6ef72d8") - - ScaleCustomE2EServiceInstance scaleCustomE2EServiceInstance = new ScaleCustomE2EServiceInstance() - scaleCustomE2EServiceInstance.prepareInitServiceOperationStatus(mockExecution) - - payload = utils.formatXml(payload) - verify(mockExecution).setVariable("CVFMI_updateServiceOperStatusRequest", payload) - } - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateNetworkInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateNetworkInstanceTest.groovy deleted file mode 100644 index fd3c1e352f..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateNetworkInstanceTest.groovy +++ /dev/null @@ -1,358 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - - -import static org.mockito.Mockito.* - -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.junit.WireMockRule -import org.apache.commons.lang3.* - - -@RunWith(MockitoJUnitRunner.class) -class UpdateNetworkInstanceTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(8090); - - String Prefix="UPDNI_" - def utils = new MsoUtils() - - String createDBRequestError = -""" - - - - 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 falloutHandlerRequest = - """ - - b69c9054-da09-4a2c-adf5-51042b62bfac - UPDATE - VID - - - Received error from SDN-C: No availability zone available. - 5300 - - """ - - String completeMsoProcessRequest = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - UPDATE - VID - - Network has been updated successfully. - BPMN Network action: UPDATE -""" - - -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" - } - ] - } - }}""" - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - - public void initializeVariables(DelegateExecution mockExecution) { - - verify(mockExecution).setVariable(Prefix + "source", "") - verify(mockExecution).setVariable(Prefix + "Success", false) - - verify(mockExecution).setVariable(Prefix + "CompleteMsoProcessRequest", "") - verify(mockExecution).setVariable(Prefix + "FalloutHandlerRequest", "") - - } - - @Test - //@Ignore - public void preProcessRequest() { - - println "************ preProcessRequest() ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest) - - when(mockExecution.getVariable("mso.adapters.db.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(DelegateExecution execution) - UpdateNetworkInstance UpdateNetworkInstance = new UpdateNetworkInstance() - UpdateNetworkInstance.preProcessRequest(mockExecution) - -// verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix) - - initializeVariables(mockExecution) - //verify(mockExecution).setVariable(Prefix + "Success", false) - - } - - - @Test - //@Ignore - public void getNetworkModelInfo() { - - println "************ getNetworkModelInfo() ************* " - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - - // preProcessRequest(DelegateExecution execution) - UpdateNetworkInstance UpdateNetworkInstance = new UpdateNetworkInstance() - UpdateNetworkInstance.getNetworkModelInfo(mockExecution) - -// verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix) - - } - - @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(DelegateExecution execution) - UpdateNetworkInstance UpdateNetworkInstance = new UpdateNetworkInstance() - UpdateNetworkInstance.sendSyncResponse(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable("UpdateNetworkInstanceResponseCode", "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") - - UpdateNetworkInstance UpdateNetworkInstance = new UpdateNetworkInstance() - UpdateNetworkInstance.sendSyncError(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable("UpdateNetworkInstanceResponseCode", "500") - - } - - @Test - //@Ignore - public void prepareCompletion() { - - println "************ postProcessResponse ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable(Prefix + "dbReturnCode")).thenReturn("200") - - // postProcessResponse(DelegateExecution execution) - UpdateNetworkInstance UpdateNetworkInstance = new UpdateNetworkInstance() - UpdateNetworkInstance.prepareCompletion(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "Success", true) - verify(mockExecution).setVariable(Prefix + "CompleteMsoProcessRequest", completeMsoProcessRequest) - - } - - @Test - //@Ignore - public void buildErrorResponse() { - - println "************ buildErrorResponse ************* " - - - WorkflowException sndcWorkflowException = new WorkflowException("UpdateNetworkInstance", 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("mso-request-id")).thenReturn("b69c9054-da09-4a2c-adf5-51042b62bfac") - //when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowException) - when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowException) - - // buildErrorResponse(DelegateExecution execution) - UpdateNetworkInstance UpdateNetworkInstance = new UpdateNetworkInstance() - UpdateNetworkInstance.buildErrorResponse(mockExecution) - - verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) - verify(mockExecution).setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) - - //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() - //debugger.printInvocations(mockExecution) - - } - - @Test - //@Ignore - public void postProcessResponse() { - - println "************ postProcessResponse() ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("CMSO_ResponseCode")).thenReturn("200") - - // postProcessResponse(DelegateExecution execution) - UpdateNetworkInstance UpdateNetworkInstance = new UpdateNetworkInstance() - UpdateNetworkInstance.postProcessResponse(mockExecution) - - //verify(mockExecution).getVariable("isDebugLogEnabled") - //verify(mockExecution).setVariable("prefix", Prefix) - - verify(mockExecution).setVariable(Prefix + "Success", true) - - } - - @Test - //@Ignore - public void processRollbackData() { - - println "************ callDBCatalog() ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - - // preProcessRequest(DelegateExecution execution) - UpdateNetworkInstance UpdateNetworkInstance = new UpdateNetworkInstance() - UpdateNetworkInstance.processRollbackData(mockExecution) - -// verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix) - - } - - private ExecutionEntity setupMock() { - - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("UpdateNetworkInstance") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("UpdateNetworkInstance") - 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("UpdateNetworkInstance") - when(mockExecution.getProcessInstanceId()).thenReturn("UpdateNetworkInstance") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - } - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy deleted file mode 100644 index 620b0b787d..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy +++ /dev/null @@ -1,134 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.infrastructure.scripts - -import com.github.tomakehurst.wiremock.junit.WireMockRule -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.junit.Assert -import org.junit.Before -import org.junit.Ignore -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.Captor -import org.mockito.Mockito -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.onap.so.bpmn.common.scripts.utils.XmlComparator -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.mock.FileUtil - -import static com.github.tomakehurst.wiremock.client.WireMock.* -import static org.mockito.Mockito.* - -@RunWith(MockitoJUnitRunner.class) -class UpdateVfModuleVolumeInfraV1Test { - - def prefix = "UPDVfModVol_" - @Captor - static ArgumentCaptor captor = ArgumentCaptor.forClass(ExecutionEntity.class) - - @Rule - public WireMockRule wireMockRule = new WireMockRule(28090); - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - - @Test - void testQueryAAIForVfModule() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(prefix) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("UPDVfModVol_relatedVfModuleLink")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf/12345/vf-modules/vf-module/12345") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - - mockData() - UpdateVfModuleVolumeInfraV1 obj = new UpdateVfModuleVolumeInfraV1() - obj.queryAAIForVfModule(mockExecution, "true") - - Mockito.verify(mockExecution, atLeastOnce()).setVariable("UPDVfModVol_personaModelId", "ff5256d2-5a33-55df-13ab-12abad84e7ff") - } - - @Test - void testPrepVnfAdapterRest() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(prefix) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable(prefix + "aicCloudRegion")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable(prefix + "tenantId")).thenReturn("") - when(mockExecution.getVariable(prefix + "aaiVolumeGroupResponse")).thenReturn(FileUtil.readResourceFile("__files/UpdateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml")) - when(mockExecution.getVariable(prefix + "vnfType")).thenReturn("vnf1") - when(mockExecution.getVariable(prefix + "vnfVersion")).thenReturn("1") - when(mockExecution.getVariable(prefix + "AAIQueryGenericVfnResponse")).thenReturn(FileUtil.readResourceFile("__files/GenericFlows/getGenericVnfByNameResponse.xml")) - when(mockExecution.getVariable(prefix + "requestId")).thenReturn("12345") - when(mockExecution.getVariable(prefix + "serviceId")).thenReturn("12345") - when(mockExecution.getVariable("mso-request-id")).thenReturn("12345") - when(mockExecution.getVariable("mso.workflow.message.endpoint")).thenReturn('http://localhost:28080/mso/WorkflowMessage') - when(mockExecution.getVariable("mso.use.qualified.host")).thenReturn("true") - - mockData() - UpdateVfModuleVolumeInfraV1 obj = new UpdateVfModuleVolumeInfraV1() - obj.prepVnfAdapterRest(mockExecution, "true") - - Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture()) - def updateVolumeGroupRequest = captor.getValue() - String expectedValue = FileUtil.readResourceFile("__files/UpdateVfModuleVolumeInfraV1/updateVolumeGroupRequest.xml") - XmlComparator.assertXMLEquals(expectedValue, updateVolumeGroupRequest, "messageId", "notificationUrl") - } - - - private static ExecutionEntity setupMock() { - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("UpdateVfModuleVolumeInfraV1") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("UpdateVfModuleVolumeInfraV1") - 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("UpdateVfModuleVolumeInfraV1") - when(mockExecution.getProcessInstanceId()).thenReturn("UpdateVfModuleVolumeInfraV1") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - } - - private static void mockData() { - stubFor(get(urlMatching(".*/aai/v[0-9]+/network/generic-vnfs/generic-vnf/12345/vf-modules/vf-module/.*")) - .willReturn(aResponse() - .withStatus(200).withHeader("Content-Type", "text/xml") - .withBodyFile("UpdateVfModuleVolumeInfraV1/vf_module_aai_response.xml"))) - } -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy deleted file mode 100644 index 523c791efc..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/CreateVcpeResCustServiceTest.groovy +++ /dev/null @@ -1,1269 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.so.bpmn.vcpe.scripts - - -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.junit.Before -import org.junit.BeforeClass -import org.junit.Rule -import org.junit.Test -import org.junit.Ignore -import org.mockito.MockitoAnnotations -import org.camunda.bpm.engine.delegate.BpmnError -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.core.domain.HomingSolution -import org.onap.so.bpmn.mock.FileUtil - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse -import static com.github.tomakehurst.wiremock.client.WireMock.get -import static com.github.tomakehurst.wiremock.client.WireMock.patch -import static com.github.tomakehurst.wiremock.client.WireMock.put -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.*; -import static org.mockito.Mockito.* -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource -import org.onap.so.bpmn.core.domain.ServiceDecomposition -import org.onap.so.bpmn.core.domain.VnfResource -import org.onap.so.bpmn.core.domain.AllottedResource -import org.onap.so.bpmn.core.domain.ModelInfo -import org.onap.so.bpmn.core.domain.HomingSolution -import org.onap.so.bpmn.core.RollbackData -import org.onap.so.bpmn.vcpe.scripts.MapGetter -import org.onap.so.bpmn.vcpe.scripts.MapSetter - -import com.github.tomakehurst.wiremock.junit.WireMockRule - -class CreateVcpeResCustServiceTest extends GroovyTestBase { - - private static String request - - @Rule - public WireMockRule wireMockRule = new WireMockRule(PORT) - - String Prefix = "CVRCS_" - String RbType = "DCRENI_" - - @BeforeClass - public static void setUpBeforeClass() { - request = FileUtil.readResourceFile("__files/VCPE/CreateVcpeResCustService/request.json") - } - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - - public CreateVcpeResCustServiceTest() { - super("CreateVcpeResCustService") - } - - - // ***** preProcessRequest ***** - - @Test - @Ignore // 1802 merge - public void preProcessRequest() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcess(mex) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.preProcessRequest(mex) - - verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("prefix", Prefix) - verify(mex).setVariable("aaiDistDelay", "aaidelay") - verify(mex).setVariable("createVcpeServiceRequest", request) - verify(mex).setVariable("msoRequestId", "mri") - assertEquals("sii", map.get("serviceInstanceId")) - verify(mex).setVariable("requestAction", "ra") - verify(mex).setVariable("source", "VID") - verify(mex).setVariable("globalSubscriberId", CUST) - verify(mex).setVariable("globalCustomerId", CUST) - verify(mex).setVariable("subscriptionServiceType", SVC) - verify(mex).setVariable("disableRollback", "false") - verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") - assertTrue(map.containsKey("subscriberInfo")) - - verify(mex).setVariable("brgWanMacAddress", "brgmac") - verify(mex).setVariable("customerLocation", ["customerLatitude":"32.897480", "customerLongitude":"-97.040443", "customerName":"some_company"]) - verify(mex).setVariable("homingService", "sniro") - assertTrue(map.containsKey("serviceInputParams")) - assertTrue(map.containsKey(Prefix+"requestInfo")) - - def reqinfo = map.get(Prefix+"requestInfo") - assertTrue(reqinfo.indexOf("mri= 0) - assertTrue(reqinfo.indexOf("VID= 0) - } - - @Test - // @Ignore - public void preProcessRequest_MissingAaiDistDelay() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcess(mex) - - when(mex.getVariable("URN_mso_workflow_aai_distribution_delay")).thenReturn(null) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - - assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.preProcessRequest(mex) })) - } - - @Test - @Ignore // 1802 merge - public void preProcessRequest_EmptyParts() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcess(mex) - - def req = request - .replace('"source"', '"sourceXXX"') - .replace('"BRG_WAN_MAC_Address"', '"BRG_WAN_MAC_AddressXXX"') - .replace('"Customer_Location"', '"Customer_LocationXXX"') - - when(mex.getVariable("bpmnRequest")).thenReturn(req) - when(mex.getVariable("serviceInstanceId")).thenReturn(null) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.preProcessRequest(mex) - - verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("prefix", Prefix) - verify(mex).setVariable("createVcpeServiceRequest", req) - verify(mex).setVariable("msoRequestId", "mri") - assertNotNull(map.get("serviceInstanceId")) - assertFalse(map.get("serviceInstanceId").isEmpty()) - verify(mex).setVariable("requestAction", "ra") - verify(mex).setVariable("source", "VID") - verify(mex).setVariable("globalSubscriberId", CUST) - verify(mex).setVariable("globalCustomerId", CUST) - verify(mex).setVariable("subscriptionServiceType", SVC) - verify(mex).setVariable("disableRollback", "false") - verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") - assertTrue(map.containsKey("subscriberInfo")) - - assertEquals("", map.get("brgWanMacAddress")) - assertEquals("", map.get("customerLocation")) - assertEquals("oof", map.get("homingService")) - assertTrue(map.containsKey("serviceInputParams")) - assertTrue(map.containsKey(Prefix+"requestInfo")) - - def reqinfo = map.get(Prefix+"requestInfo") - println reqinfo - assertTrue(reqinfo.indexOf("mri= 0) - assertTrue(reqinfo.indexOf("VID= 0) - } - - @Test - // @Ignore - public void preProcessRequest_MissingSubscriberId() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcess(mex) - - def req = request - .replace('"globalSubscriberId"', '"globalSubscriberIdXXX"') - - when(mex.getVariable("bpmnRequest")).thenReturn(req) - when(mex.getVariable("serviceInstanceId")).thenReturn(null) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - - assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.preProcessRequest(mex) })) - } - - @Test - // @Ignore - public void preProcessRequest_BpmnError() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - when(mex.getVariable("bpmnRequest")).thenThrow(new BpmnError("expected exception")) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - - assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.preProcessRequest(mex) })) - } - - @Test - // @Ignore - public void preProcessRequest_Ex() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - when(mex.getVariable("bpmnRequest")).thenThrow(new RuntimeException("expected exception")) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - - assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.preProcessRequest(mex) })) - } - - // ***** sendSyncResponse ***** - - @Test - // @Ignore - public void sendSyncResponse() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initSendSyncResponse(mex) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.sendSyncResponse(mex) - - verify(mex, times(2)).getVariable(DBGFLAG) - - verify(mex).setVariable(processName+"WorkflowResponseSent", "true") - - assertEquals("202", map.get(processName+"ResponseCode")) - assertEquals("Success", map.get(processName+"Status")) - - def resp = map.get(processName+"Response") - - assertTrue(resp.indexOf('"instanceId":"sii"') >= 0) - assertTrue(resp.indexOf('"requestId":"mri"') >= 0) - } - - @Test - // @Ignore - public void sendSyncResponse_Ex() { - ExecutionEntity mex = setupMock() - initSendSyncResponse(mex) - - when(mex.getVariable("serviceInstanceId")).thenThrow(new RuntimeException("expected exception")) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - - assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.sendSyncResponse(mex) })) - } - - - // ***** prepareDecomposeService ***** - - @Test - // @Ignore - public void prepareDecomposeService() { - ExecutionEntity mex = setupMock() - initPrepareDecomposeService(mex) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.prepareDecomposeService(mex) - - verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("serviceModelInfo", "mi") - } - - @Test - // @Ignore - public void prepareDecomposeService_Ex() { - ExecutionEntity mex = setupMock() - initPrepareDecomposeService(mex) - - when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception")) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - - assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareDecomposeService(mex) })) - } - - - // ***** prepareCreateServiceInstance ***** - - @Test - // @Ignore - public void prepareCreateServiceInstance() { - ExecutionEntity mex = setupMock() - initPrepareCreateServiceInstance(mex) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.prepareCreateServiceInstance(mex) - - verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("serviceInstanceName", "VCPE1") - verify(mex).setVariable("serviceDecompositionString", "mydecomp") - } - - @Test - // @Ignore - public void prepareCreateServiceInstance_Ex() { - ExecutionEntity mex = setupMock() - initPrepareCreateServiceInstance(mex) - - when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception")) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - - assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareCreateServiceInstance(mex) })) - } - - - // ***** postProcessServiceInstanceCreate ***** - - @Test - // @Ignore - public void postProcessServiceInstanceCreate() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPostProcessServiceInstanceCreate(mex) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.postProcessServiceInstanceCreate(mex) - - verify(mex).getVariable(DBGFLAG) - - def reqinfo = map.get(Prefix+"setUpdateDbInstancePayload") - - assertTrue(reqinfo.indexOf("mri= 0) - assertTrue(reqinfo.indexOf("sii= 0) - assertTrue(reqinfo.indexOf("sin= 0) - } - - @Test - // @Ignore - public void postProcessServiceInstanceCreate_BpmnError() { - ExecutionEntity mex = setupMock() - initPostProcessServiceInstanceCreate(mex) - - doThrow(new BpmnError("expected exception")).when(mex).setVariable(endsWith("setUpdateDbInstancePayload"), any()) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - - assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessServiceInstanceCreate(mex) })) - } - - @Test - // @Ignore - public void postProcessServiceInstanceCreate_Ex() { - ExecutionEntity mex = setupMock() - initPostProcessServiceInstanceCreate(mex) - - doThrow(new RuntimeException("expected exception")).when(mex).setVariable(endsWith("setUpdateDbInstancePayload"), any()) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - - assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessServiceInstanceCreate(mex) })) - } - - - // ***** processDecomposition ***** - - @Test - // @Ignore - public void processDecomposition() { - ExecutionEntity mex = setupMock() - def svcdecomp = initProcessDecomposition(mex) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.processDecomposition(mex) - - verify(mex).getVariable(DBGFLAG) - - verify(mex).setVariable("vnfList", svcdecomp.getVnfResources()) - verify(mex).setVariable("vnfListString", '[myvnf]') - verify(mex).setVariable(Prefix+"VNFsCount", 1) - - verify(mex).setVariable("vnfModelInfo", "mymodel") - verify(mex).setVariable("vnfModelInfoString", "mymodel") - } - - @Test - // @Ignore - public void processDecomposition_EmptyNet_EmptyVnf() { - ExecutionEntity mex = setupMock() - def svcdecomp = initProcessDecomposition(mex) - - when(svcdecomp.getVnfResources()).thenReturn(new LinkedList()) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.processDecomposition(mex) - - verify(mex).getVariable(DBGFLAG) - - verify(mex).setVariable("vnfList", svcdecomp.getVnfResources()) - verify(mex).setVariable("vnfListString", '[]') - verify(mex).setVariable(Prefix+"VNFsCount", 0) - - verify(mex).setVariable("vnfModelInfo", "") - verify(mex).setVariable("vnfModelInfoString", "") - } - - @Test - // @Ignore - public void processDecomposition_Ex() { - ExecutionEntity mex = setupMock() - def svcdecomp = initProcessDecomposition(mex) - - when(svcdecomp.getVnfResources()).thenThrow(new RuntimeException("expected exception")) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - - assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.processDecomposition(mex) })) - } - - - // ***** filterVnfs ***** - - @Test - // @Ignore - public void filterVnfs() { - ExecutionEntity mex = setupMock() - def svcdecomp = initFilterVnfs(mex) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.processDecomposition(mex) - - verify(mex).setVariable("vnfListString", '[myvnf3, myvnf5]') - } - - @Test - // @Ignore - public void filterVnfs_Null() { - ExecutionEntity mex = setupMock() - def svcdecomp = initFilterVnfs(mex) - - when(svcdecomp.getVnfResources()).thenReturn(null) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.processDecomposition(mex) - - // nothing more to check, as long as it didn't throw an exception - } - - - // ***** prepareCreateAllottedResourceTXC ***** - - @Test - // @Ignore - public void prepareCreateAllottedResourceTXC() { - ExecutionEntity mex = setupMock() - initPrepareCreateAllottedResourceTXC(mex) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.prepareCreateAllottedResourceTXC(mex) - - verify(mex).getVariable(DBGFLAG) - - verify(mex).setVariable("createTXCAR", true) - verify(mex).setVariable("allottedResourceModelInfoTXC", "modelB") - verify(mex).setVariable("allottedResourceRoleTXC", "TXCr") - verify(mex).setVariable("allottedResourceTypeTXC", "Tunnel XConn") - verify(mex).setVariable("parentServiceInstanceIdTXC", "homeB") - } - - @Test - // @Ignore - public void prepareCreateAllottedResourceTXC_NullArList() { - ExecutionEntity mex = setupMock() - def svcdecomp = initPrepareCreateAllottedResourceTXC(mex) - - when(svcdecomp.getAllottedResources()).thenReturn(null) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.prepareCreateAllottedResourceTXC(mex) - - verify(mex).getVariable(DBGFLAG) - - verify(mex, never()).setVariable("createTXCAR", true) - verify(mex, never()).setVariable("allottedResourceModelInfoTXC", "modelB") - verify(mex, never()).setVariable("allottedResourceRoleTXC", "TXCr") - verify(mex, never()).setVariable("allottedResourceTypeTXC", "Tunnel XConn") - verify(mex, never()).setVariable("parentServiceInstanceIdTXC", "homeB") - } - - @Test - // @Ignore - public void prepareCreateAllottedResourceTXC_Ex() { - ExecutionEntity mex = setupMock() - initPrepareCreateAllottedResourceTXC(mex) - - when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception")) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - - assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareCreateAllottedResourceTXC(mex) })) - } - - - // ***** prepareCreateAllottedResourceBRG ***** - - @Test - // @Ignore - public void prepareCreateAllottedResourceBRG() { - ExecutionEntity mex = setupMock() - initPrepareCreateAllottedResourceBRG(mex) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.prepareCreateAllottedResourceBRG(mex) - - verify(mex).getVariable(DBGFLAG) - - verify(mex).setVariable("createBRGAR", true) - verify(mex).setVariable("allottedResourceModelInfoBRG", "modelB") - verify(mex).setVariable("allottedResourceRoleBRG", "BRGr") - verify(mex).setVariable("allottedResourceTypeBRG", "BRG") - verify(mex).setVariable("parentServiceInstanceIdBRG", "homeB") - } - - @Test - // @Ignore - public void prepareCreateAllottedResourceBRG_NullArList() { - ExecutionEntity mex = setupMock() - def svcdecomp = initPrepareCreateAllottedResourceBRG(mex) - - when(svcdecomp.getAllottedResources()).thenReturn(null) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.prepareCreateAllottedResourceBRG(mex) - - verify(mex).getVariable(DBGFLAG) - - verify(mex, never()).setVariable("createBRGAR", true) - verify(mex, never()).setVariable("allottedResourceModelInfoBRG", "modelB") - verify(mex, never()).setVariable("allottedResourceRoleBRG", "BRGr") - verify(mex, never()).setVariable("allottedResourceTypeBRG", "BRG") - verify(mex, never()).setVariable("parentServiceInstanceIdBRG", "homeB") - } - - @Test - // @Ignore - public void prepareCreateAllottedResourceBRG_Ex() { - ExecutionEntity mex = setupMock() - initPrepareCreateAllottedResourceBRG(mex) - - when(mex.getVariable("createVcpeServiceRequest")).thenThrow(new RuntimeException("expected exception")) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - - assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareCreateAllottedResourceBRG(mex) })) - } - - - // ***** prepareVnfAndModulesCreate ***** - - @Test - // @Ignore - public void prepareVnfAndModulesCreate() { - ExecutionEntity mex = setupMock() - initPrepareVnfAndModulesCreate(mex) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.prepareVnfAndModulesCreate(mex) - - verify(mex).getVariable(DBGFLAG) - - verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") - verify(mex).setVariable("lcpCloudRegionId", "mdt1") - verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba") - } - - @Test - // @Ignore - public void prepareVnfAndModulesCreate_EmptyList() { - ExecutionEntity mex = setupMock() - initPrepareVnfAndModulesCreate(mex) - - when(mex.getVariable("vnfList")).thenReturn(new LinkedList()) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.prepareVnfAndModulesCreate(mex) - - verify(mex).getVariable(DBGFLAG) - - verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") - verify(mex).setVariable("lcpCloudRegionId", "mdt1") - verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba") - } - - @Test - // @Ignore - public void prepareVnfAndModulesCreate_NullList() { - ExecutionEntity mex = setupMock() - initPrepareVnfAndModulesCreate(mex) - - when(mex.getVariable("vnfList")).thenReturn(null) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.prepareVnfAndModulesCreate(mex) - - verify(mex).getVariable(DBGFLAG) - - verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") - verify(mex).setVariable("lcpCloudRegionId", "mdt1") - verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba") - } - - @Test - // @Ignore - public void prepareVnfAndModulesCreate_Ex() { - ExecutionEntity mex = setupMock() - initPrepareVnfAndModulesCreate(mex) - - when(mex.getVariable("vnfList")).thenThrow(new RuntimeException("expected exception")) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - - assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareVnfAndModulesCreate(mex) })) - } - - - // ***** validateVnfCreate ***** - - @Test - // @Ignore - public void validateVnfCreate() { - ExecutionEntity mex = setupMock() - initValidateVnfCreate(mex) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.validateVnfCreate(mex) - - verify(mex).getVariable(DBGFLAG) - - verify(mex).setVariable(Prefix+"VnfsCreatedCount", 3) - } - - @Test - // @Ignore - public void validateVnfCreate_Ex() { - ExecutionEntity mex = setupMock() - initValidateVnfCreate(mex) - - when(mex.getVariable(Prefix+"VnfsCreatedCount")).thenThrow(new RuntimeException("expected exception")) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - - assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.validateVnfCreate(mex) })) - } - - - // ***** postProcessResponse ***** - - @Test - // @Ignore - public void postProcessResponse() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPostProcessResponse(mex) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.postProcessResponse(mex) - - verify(mex).getVariable(DBGFLAG) - - verify(mex).setVariable(Prefix+"Success", true) - - def reqinfo = map.get(Prefix+"CompleteMsoProcessRequest") - - assertTrue(reqinfo.indexOf("request-id>mri= 0) - assertTrue(reqinfo.indexOf("source>mysrc= 0) - assertTrue(reqinfo.indexOf("serviceInstanceId>sii= 0) - } - - @Test - // @Ignore - public void postProcessResponse_BpmnError() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPostProcessResponse(mex) - - when(mex.getVariable("source")).thenThrow(new BpmnError("expected exception")) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - - assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessResponse(mex) })) - } - - @Test - // @Ignore - public void postProcessResponse_Ex() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPostProcessResponse(mex) - - when(mex.getVariable("source")).thenThrow(new RuntimeException("expected exception")) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - - assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessResponse(mex) })) - } - - - // ***** preProcessRollback ***** - - @Test - // @Ignore - public void preProcessRollback() { - ExecutionEntity mex = setupMock() - def wfe = initPreProcessRollback(mex) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.preProcessRollback(mex) - - verify(mex).getVariable(DBGFLAG) - - verify(mex).setVariable("prevWorkflowException", wfe) - } - - @Test - // @Ignore - public void preProcessRollback_NullWfe() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - def wfe = initPreProcessRollback(mex) - - when(mex.getVariable("WorkflowException")).thenReturn(null) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.preProcessRollback(mex) - - verify(mex).getVariable(DBGFLAG) - - assertFalse(map.containsKey("prevWorkflowException")) - } - - @Test - // @Ignore - public void preProcessRollback_BpmnError() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - def wfe = initPreProcessRollback(mex) - - when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.preProcessRollback(mex) - - verify(mex).getVariable(DBGFLAG) - - assertFalse(map.containsKey("prevWorkflowException")) - } - - @Test - // @Ignore - public void preProcessRollback_Ex() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - def wfe = initPreProcessRollback(mex) - - when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.preProcessRollback(mex) - - verify(mex).getVariable(DBGFLAG) - - assertFalse(map.containsKey("prevWorkflowException")) - } - - - // ***** postProcessRollback ***** - - @Test - // @Ignore - public void postProcessRollback() { - ExecutionEntity mex = setupMock() - def wfe = initPostProcessRollback(mex) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.postProcessRollback(mex) - - verify(mex).getVariable(DBGFLAG) - - verify(mex).setVariable("WorkflowException", wfe) - } - - @Test - // @Ignore - public void postProcessRollback_NullWfe() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - def wfe = initPostProcessRollback(mex) - - when(mex.getVariable("prevWorkflowException")).thenReturn(null) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.postProcessRollback(mex) - - verify(mex).getVariable(DBGFLAG) - - assertFalse(map.containsKey("WorkflowException")) - } - - @Test - // @Ignore - public void postProcessRollback_BpmnError() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - def wfe = initPostProcessRollback(mex) - - when(mex.getVariable("prevWorkflowException")).thenThrow(new BpmnError("expected exception")) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.postProcessRollback(mex) })) - } - - @Test - // @Ignore - public void postProcessRollback_Ex() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - def wfe = initPostProcessRollback(mex) - - when(mex.getVariable("prevWorkflowException")).thenThrow(new RuntimeException("expected exception")) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.postProcessRollback(mex) - - verify(mex).getVariable(DBGFLAG) - - assertFalse(map.containsKey("WorkflowException")) - } - - - // ***** prepareFalloutRequest ***** - - @Test - // @Ignore - public void prepareFalloutRequest() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPrepareFalloutRequest(mex) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.prepareFalloutRequest(mex) - - verify(mex, times(2)).getVariable(DBGFLAG) - - def fo = map.get(Prefix+"falloutRequest") - - assertTrue(fo.indexOf("world= 0) - assertTrue(fo.indexOf("ErrorMessage>mymsg= 0) - assertTrue(fo.indexOf("ErrorCode>999= 0) - } - - @Test - // @Ignore - public void prepareFalloutRequest_Ex() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPrepareFalloutRequest(mex) - - when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - - assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.prepareFalloutRequest(mex) })) - } - - // ***** sendSyncError ***** - - @Test - // @Ignore - public void sendSyncError() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initSendSyncError(mex) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.sendSyncError(mex) - - verify(mex, times(2)).getVariable(DBGFLAG) - - verify(mex).setVariable(processName+"WorkflowResponseSent", "true") - - assertEquals("500", map.get(processName+"ResponseCode")) - assertEquals("Fail", map.get(processName+"Status")) - - def resp = map.get(processName+"Response") - - assertTrue(resp.indexOf("ErrorMessage>mymsg= 0) - - verify(mex).setVariable("WorkflowResponse", resp) - } - - @Test - // @Ignore - public void sendSyncError_NotWfe() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initSendSyncError(mex) - - when(mex.getVariable("WorkflowException")).thenReturn("not a WFE") - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.sendSyncError(mex) - - verify(mex, times(2)).getVariable(DBGFLAG) - - verify(mex).setVariable(processName+"WorkflowResponseSent", "true") - - assertEquals("500", map.get(processName+"ResponseCode")) - assertEquals("Fail", map.get(processName+"Status")) - - def resp = map.get(processName+"Response") - - assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.= 0) - - verify(mex).setVariable("WorkflowResponse", resp) - } - - @Test - // @Ignore - public void sendSyncError_NullWfe() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initSendSyncError(mex) - - when(mex.getVariable("WorkflowException")).thenReturn(null) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - CreateVcpeResCustService.sendSyncError(mex) - - verify(mex, times(2)).getVariable(DBGFLAG) - - verify(mex).setVariable(processName+"WorkflowResponseSent", "true") - - assertEquals("500", map.get(processName+"ResponseCode")) - assertEquals("Fail", map.get(processName+"Status")) - - def resp = map.get(processName+"Response") - - assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.= 0) - - verify(mex).setVariable("WorkflowResponse", resp) - } - - @Test - // @Ignore - public void sendSyncError_Ex() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initSendSyncError(mex) - - when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - - CreateVcpeResCustService.sendSyncError(mex) - - assertFalse(map.containsKey(processName+"ResponseCode")) - } - - - // ***** processJavaException ***** - - @Test - // @Ignore - public void processJavaException() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initProcessJavaException(mex) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - - assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.processJavaException(mex) })) - - verify(mex, times(2)).getVariable(DBGFLAG) - - verify(mex).setVariable("prefix", Prefix) - - def wfe = map.get("WorkflowException") - - assertEquals("Caught a Java Lang Exception", wfe.getErrorMessage()) - } - - @Test - // @Ignore - public void processJavaException_BpmnError() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initProcessJavaException(mex) - - when(mex.getVariables()).thenThrow(new BpmnError("expected exception")) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - - assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.processJavaException(mex) })) - - assertFalse(map.containsKey("WorkflowException")) - } - - @Test - // @Ignore - public void processJavaException_Ex() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initProcessJavaException(mex) - - when(mex.getVariables()).thenThrow(new RuntimeException("expected exception")) - - CreateVcpeResCustService CreateVcpeResCustService = new CreateVcpeResCustService() - - assertTrue(doBpmnError( { _ -> CreateVcpeResCustService.processJavaException(mex) })) - - def wfe = map.get("WorkflowException") - - assertEquals("Exception in processJavaException method", wfe.getErrorMessage()) - } - - - private void initPreProcess(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("bpmnRequest")).thenReturn(request) - when(mex.getVariable("URN_mso_workflow_aai_distribution_delay")).thenReturn("aaidelay") - when(mex.getVariable("mso-request-id")).thenReturn("mri") - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - when(mex.getVariable("requestAction")).thenReturn("ra") - } - - private initSendSyncResponse(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("mso-request-id")).thenReturn("mri") - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - } - - private void initPrepareDecomposeService(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("createVcpeServiceRequest")).thenReturn('{"requestDetails":{"modelInfo":"mi"}}') - } - - private void initPrepareCreateServiceInstance(ExecutionEntity mex) { - ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class) - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request) - when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp) - - when(svcdecomp.toJsonStringNoRootName()).thenReturn("mydecomp") - } - - private void initPostProcessServiceInstanceCreate(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("mso-request-id")).thenReturn("mri") - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - when(mex.getVariable("serviceInstanceName")).thenReturn("sin") - } - - private ServiceDecomposition initProcessDecomposition(ExecutionEntity mex) { - List vnflst = new LinkedList<>() - vnflst.add(makeVnf("", "")) - vnflst.add(makeVnf("2", "BRG")) - vnflst.add(makeVnf("3", "BRG")) - - ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class) - when(svcdecomp.getVnfResources()).thenReturn(vnflst) - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp) - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - when(mex.getVariable("serviceInstanceName")).thenReturn("sin") - - return svcdecomp - } - - private ServiceDecomposition initFilterVnfs(ExecutionEntity mex) { - List vnflst = new LinkedList<>() - vnflst.add(makeVnf("", "BRG")) - vnflst.add(makeVnf("2", "Tunnel XConn")) - vnflst.add(makeVnf("3", "")) - vnflst.add(makeVnf("4", "BRG")) - vnflst.add(makeVnf("5", "other")) - - ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class) - when(svcdecomp.getVnfResources()).thenReturn(vnflst) - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp) - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - when(mex.getVariable("serviceInstanceName")).thenReturn("sin") - - return svcdecomp - } - - private initAwaitAaiDistribution(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - } - - private ServiceDecomposition initPrepareCreateAllottedResourceTXC(ExecutionEntity mex) { - ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class) - List arlst = new LinkedList<>() - - arlst.add(makeArBRG("A")) - arlst.add(makeArTXC("B")) - arlst.add(makeArBRG("C")) - - when(svcdecomp.getAllottedResources()).thenReturn(arlst) - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request) - when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp) - when(mex.getVariable("allottedResourceId")).thenReturn(ARID) - - return svcdecomp - } - - private ServiceDecomposition initPrepareCreateAllottedResourceBRG(ExecutionEntity mex) { - ServiceDecomposition svcdecomp = mock(ServiceDecomposition.class) - List arlst = new LinkedList<>() - - arlst.add(makeArTXC("A")) - arlst.add(makeArBRG("B")) - arlst.add(makeArTXC("C")) - - when(svcdecomp.getAllottedResources()).thenReturn(arlst) - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request) - when(mex.getVariable("serviceDecomposition")).thenReturn(svcdecomp) - when(mex.getVariable("allottedResourceId")).thenReturn(ARID) - - return svcdecomp - } - - private AllottedResource makeArTXC(String id) { - AllottedResource ar = mock(AllottedResource.class) - ModelInfo mod = mock(ModelInfo.class) - HomingSolution home = mock(HomingSolution.class) - - when(ar.toJsonStringNoRootName()).thenReturn("json"+id) - when(ar.getAllottedResourceType()).thenReturn("Tunnel XConn") - when(ar.getModelInfo()).thenReturn(mod) - when(ar.getAllottedResourceRole()).thenReturn("TXCr") - when(ar.getHomingSolution()).thenReturn(home) - - when(mod.toJsonStringNoRootName()).thenReturn("model"+id) - - when(home.getServiceInstanceId()).thenReturn("home"+id) - - return ar - } - - private AllottedResource makeArBRG(String id) { - AllottedResource ar = mock(AllottedResource.class) - ModelInfo mod = mock(ModelInfo.class) - HomingSolution home = mock(HomingSolution.class) - - when(ar.toJsonStringNoRootName()).thenReturn("json"+id) - when(ar.getAllottedResourceType()).thenReturn("BRG") - when(ar.getModelInfo()).thenReturn(mod) - when(ar.getAllottedResourceRole()).thenReturn("BRGr") - when(ar.getHomingSolution()).thenReturn(home) - - when(mod.toJsonStringNoRootName()).thenReturn("model"+id) - - when(home.getServiceInstanceId()).thenReturn("home"+id) - - return ar - } - - private initPrepareVnfAndModulesCreate(ExecutionEntity mex) { - - List vnflst = new LinkedList<>() - - vnflst.add(makeVnf("A", "BRG")) - vnflst.add(makeVnf("B", "")) - vnflst.add(makeVnf("C", "")) - vnflst.add(makeVnf("D", "Tunnel XConn")) - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("createVcpeServiceRequest")).thenReturn(request) - when(mex.getVariable("vnfList")).thenReturn(vnflst) - when(mex.getVariable(Prefix+"VnfsCreatedCount")).thenReturn(2) - when(mex.getVariable("vnfModelInfo")).thenReturn("nomodel") - when(mex.getVariable("sdncVersion")).thenReturn("myvers") - } - - private VnfResource makeVnf(String id, String role) { - ModelInfo mod = mock(ModelInfo.class) - VnfResource vnf = mock(VnfResource.class) - - when(mod.toString()).thenReturn('{"modelInfo":"mymodel'+id+'"}') - - when(vnf.toString()).thenReturn("myvnf"+id) - when(vnf.getModelInfo()).thenReturn(mod) - when(vnf.getNfRole()).thenReturn(role) - - return vnf - } - - private initValidateVnfCreate(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable(Prefix+"VnfsCreatedCount")).thenReturn(2) - } - - private initPostProcessResponse(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("source")).thenReturn("mysrc") - when(mex.getVariable("mso-request-id")).thenReturn("mri") - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - } - - private WorkflowException initPreProcessRollback(ExecutionEntity mex) { - WorkflowException wfe = mock(WorkflowException.class) - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("WorkflowException")).thenReturn(wfe) - - return wfe - } - - private WorkflowException initPostProcessRollback(ExecutionEntity mex) { - WorkflowException wfe = mock(WorkflowException.class) - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("prevWorkflowException")).thenReturn(wfe) - - return wfe - } - - private initPrepareFalloutRequest(ExecutionEntity mex) { - WorkflowException wfe = mock(WorkflowException.class) - - when(wfe.getErrorMessage()).thenReturn("mymsg") - when(wfe.getErrorCode()).thenReturn(999) - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("WorkflowException")).thenReturn(wfe) - when(mex.getVariable(Prefix+"requestInfo")).thenReturn("world") - - return wfe - } - - private initSendSyncError(ExecutionEntity mex) { - WorkflowException wfe = mock(WorkflowException.class) - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("mso-request-id")).thenReturn("mri") - when(mex.getVariable("WorkflowException")).thenReturn(wfe) - - when(wfe.getErrorMessage()).thenReturn("mymsg") - } - - private initProcessJavaException(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - } - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy deleted file mode 100644 index b7c754938a..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DeleteVcpeResCustServiceTest.groovy +++ /dev/null @@ -1,773 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.so.bpmn.vcpe.scripts - - -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.junit.Before -import org.junit.BeforeClass -import org.junit.Rule -import org.junit.Test -import org.junit.Ignore -import org.mockito.MockitoAnnotations -import org.camunda.bpm.engine.delegate.BpmnError -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.mock.FileUtil - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse -import static com.github.tomakehurst.wiremock.client.WireMock.get -import static com.github.tomakehurst.wiremock.client.WireMock.patch -import static com.github.tomakehurst.wiremock.client.WireMock.put -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.*; -import static org.mockito.Mockito.* -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource -import org.onap.so.bpmn.core.domain.ServiceDecomposition -import org.onap.so.bpmn.core.domain.VnfResource -import org.onap.so.bpmn.core.domain.AllottedResource -import org.onap.so.bpmn.core.domain.ModelInfo - -import org.onap.so.bpmn.core.RollbackData -import org.onap.so.bpmn.vcpe.scripts.MapGetter -import org.onap.so.bpmn.vcpe.scripts.MapSetter - -import com.github.tomakehurst.wiremock.junit.WireMockRule - -class DeleteVcpeResCustServiceTest extends GroovyTestBase { - - private static String request - - @Rule - public WireMockRule wireMockRule = new WireMockRule(PORT) - - String Prefix = "DVRCS_" - String RbType = "DCRENI_" - - @BeforeClass - public static void setUpBeforeClass() { - request = FileUtil.readResourceFile("__files/VCPE/DeleteVcpeResCustService/request.json") - } - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - - public DeleteVcpeResCustServiceTest() { - super("DeleteVcpeResCustService") - } - - - // ***** preProcessRequest ***** - - @Test -// @Ignore - public void preProcessRequest() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcess(mex) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - DeleteVcpeResCustService.preProcessRequest(mex) - - verify(mex).getVariable(DBGFLAG) - - assertEquals(Prefix, map.get("prefix")) - assertEquals(request, map.get("DeleteVcpeResCustServiceRequest")) - assertEquals("mri", map.get("msoRequestId")) - assertEquals("ra", map.get("requestAction")) - assertEquals("VID", map.get("source")) - assertEquals(CUST, map.get("globalSubscriberId")) - assertEquals(CUST, map.get("globalCustomerId")) - assertEquals("false", map.get("disableRollback")) - assertEquals("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", map.get("productFamilyId")) - assertEquals(SVC, map.get("subscriptionServiceType")) - - assertEquals("mdt1", map.get("lcpCloudRegionId")) - assertEquals("8b1df54faa3b49078e3416e21370a3ba", map.get("tenantId")) - assertEquals("1707", map.get("sdncVersion")) - assertEquals("service-instance", map.get("GENGS_type")) - assertEquals("""{"tenantId":"8b1df54faa3b49078e3416e21370a3ba","lcpCloudRegionId":"mdt1"}""", map.get("cloudConfiguration")) - assertTrue(map.containsKey(Prefix+"requestInfo")) - - def reqinfo = map.get(Prefix+"requestInfo") - assertTrue(reqinfo.indexOf("mri= 0) - assertTrue(reqinfo.indexOf("VID= 0) - } - - @Test -// @Ignore - public void preProcessRequest_EmptyParts() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcess(mex) - - def req = request - .replace('"source"', '"sourceXXX"') - - when(mex.getVariable("bpmnRequest")).thenReturn(req) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - DeleteVcpeResCustService.preProcessRequest(mex) - - verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("prefix", Prefix) - verify(mex).setVariable("DeleteVcpeResCustServiceRequest", req) - verify(mex).setVariable("msoRequestId", "mri") - verify(mex).setVariable("requestAction", "ra") - verify(mex).setVariable("source", "VID") - verify(mex).setVariable("globalSubscriberId", CUST) - verify(mex).setVariable("globalCustomerId", CUST) - verify(mex).setVariable("disableRollback", "false") - verify(mex).setVariable("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") - verify(mex).setVariable("subscriptionServiceType", SVC) - - verify(mex).setVariable("lcpCloudRegionId", "mdt1") - verify(mex).setVariable("tenantId", "8b1df54faa3b49078e3416e21370a3ba") - assertEquals("""{"tenantId":"8b1df54faa3b49078e3416e21370a3ba","lcpCloudRegionId":"mdt1"}""", map.get("cloudConfiguration")) - verify(mex).setVariable("sdncVersion", "1707") - verify(mex).setVariable("GENGS_type", "service-instance") - assertTrue(map.containsKey(Prefix+"requestInfo")) - - def reqinfo = map.get(Prefix+"requestInfo") - println reqinfo - assertTrue(reqinfo.indexOf("mri= 0) - assertTrue(reqinfo.indexOf("VID= 0) - } - - @Test -// @Ignore - public void preProcessRequest_MissingServiceInstanceId() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - when(mex.getVariable("serviceInstanceId")).thenReturn(null) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - - assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.preProcessRequest(mex) })) - } - - @Test -// @Ignore - public void preProcessRequest_BpmnError() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - when(mex.getVariable("bpmnRequest")).thenThrow(new BpmnError("expected exception")) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - - assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.preProcessRequest(mex) })) - } - - @Test -// @Ignore - public void preProcessRequest_Ex() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - when(mex.getVariable("bpmnRequest")).thenThrow(new RuntimeException("expected exception")) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - - assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.preProcessRequest(mex) })) - } - - private void initPreProcess(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("bpmnRequest")).thenReturn(request) - when(mex.getVariable("mso-request-id")).thenReturn("mri") - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - when(mex.getVariable("requestAction")).thenReturn("ra") - } - - // ***** sendSyncResponse ***** - - @Test -// @Ignore - public void sendSyncResponse() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initSendSyncResponse(mex) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - DeleteVcpeResCustService.sendSyncResponse(mex) - - verify(mex, times(2)).getVariable(DBGFLAG) - - verify(mex).setVariable(processName+"WorkflowResponseSent", "true") - - assertEquals("202", map.get(processName+"ResponseCode")) - assertEquals("Success", map.get(processName+"Status")) - - def resp = map.get(processName+"Response") - - assertTrue(resp.indexOf('"instanceId":"sii"') >= 0) - assertTrue(resp.indexOf('"requestId":"mri"') >= 0) - } - - @Test -// @Ignore - public void sendSyncResponse_Ex() { - ExecutionEntity mex = setupMock() - initSendSyncResponse(mex) - - when(mex.getVariable("serviceInstanceId")).thenThrow(new RuntimeException("expected exception")) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - - assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.sendSyncResponse(mex) })) - } - - private initSendSyncResponse(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("mso-request-id")).thenReturn("mri") - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - } - - // ***** prepareServiceDelete ***** - - @Test -// @Ignore - public void prepareServiceDelete() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPrepareServiceDelete(mex) - - myMockGetAr("/aai/v11/anytxc", 200, "arGetTXCById.xml"); - myMockGetAr("/aai/v11/anybrg", 200, "arGetBRGById.xml"); - myMockGetAr("/aai/v11/other", 200, "arGetOtherById.xml"); - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - DeleteVcpeResCustService.prepareServiceDelete(mex) - - verify(mex).setVariable(Prefix+"TunnelXConn", true) - assertEquals("ar-txcA", map.get("TXC_allottedResourceId")) - - verify(mex).setVariable(Prefix+"BRG", true) - assertEquals("ar-brgB", map.get("BRG_allottedResourceId")) - - verify(mex).setVariable(Prefix+"vnfsCount", 2) - assertNotNull(map.get(Prefix+"relatedVnfIdList")) - assertEquals("[vnfX, vnfY]", map.get(Prefix+"relatedVnfIdList").toString()) - - verify(mex, never()).setVariable(processName+"WorkflowResponseSent", "true") - } - - @Test -// @Ignore - public void prepareServiceDelete_NotFound() { - ExecutionEntity mex = setupMock() - initPrepareServiceDelete(mex) - - when(mex.getVariable("GENGS_FoundIndicator")).thenReturn(false) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - - assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.prepareServiceDelete(mex) })) - - verify(mex, never()).setVariable(processName+"WorkflowResponseSent", "true") - } - - @Test -// @Ignore - public void prepareServiceDelete_Empty() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPrepareServiceDelete(mex) - - when(mex.getVariable("GENGS_service")).thenReturn("") - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - DeleteVcpeResCustService.prepareServiceDelete(mex) - - verify(mex).getVariable(DBGFLAG) - - verify(mex).setVariable(Prefix+"TunnelXConn", false) - assertNull(map.get("TXC_allottedResourceId")) - - verify(mex).setVariable(Prefix+"BRG", false) - assertNull(map.get("BRG_allottedResourceId")) - - assertEquals(0, map.get(Prefix+"vnfsCount")) - assertFalse(map.containsKey(Prefix+"relatedVnfIdList")) - - verify(mex, never()).setVariable(processName+"WorkflowResponseSent", "true") - } - - @Test -// @Ignore - public void prepareServiceDelete_BpmnError() { - ExecutionEntity mex = setupMock() - initPrepareServiceDelete(mex) - - when(mex.getVariable("GENGS_FoundIndicator")).thenThrow(new BpmnError("expected exception")) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - - assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.prepareServiceDelete(mex) })) - - verify(mex, never()).setVariable(processName+"WorkflowResponseSent", "true") - } - - @Test -// @Ignore - public void prepareServiceDelete_Ex() { - ExecutionEntity mex = setupMock() - initPrepareServiceDelete(mex) - - when(mex.getVariable("GENGS_FoundIndicator")).thenThrow(new RuntimeException("expected exception")) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - - assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.prepareServiceDelete(mex) })) - - verify(mex).setVariable(processName+"WorkflowResponseSent", "true") - } - - private initPrepareServiceDelete(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - when(mex.getVariable("GENGS_FoundIndicator")).thenReturn(true) - when(mex.getVariable("mso-request-id")).thenReturn("mri") - when(mex.getVariable("DeleteVcpeResCustServiceRequest")).thenReturn(request) - when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx) - when(mex.getVariable("GENGS_service")).thenReturn(FileUtil.readResourceFile("__files/VCPE/DeleteVcpeResCustService/serviceToDelete.xml")) - } - - // ***** getAaiAr ***** - - @Test -// @Ignore - public void getAaiAr() { - myMockGetAr("/myurl/ar1", 200, "arGetBRGById.xml"); - - ExecutionEntity mex = setupMock() - initGetAaiAr(mex) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - def (type, id) = DeleteVcpeResCustService.getAaiAr(mex, "/myurl/ar1") - - assertEquals("BRG", type) - assertEquals("ar-brgB", id) - } - - @Test -// @Ignore - public void getAaiAr_401() { - myMockGetAr("/myurl/ar1", 401, "arGetBRGById.xml"); - - ExecutionEntity mex = setupMock() - initGetAaiAr(mex) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - def (type, id) = DeleteVcpeResCustService.getAaiAr(mex, "/myurl/ar1") - - assertEquals(null, type) - assertEquals(null, id) - } - - @Test -// @Ignore - public void getAaiAr_EmptyResponse() { - myMockGetAr("/myurl/ar1", 200, "empty.txt"); - - ExecutionEntity mex = setupMock() - initGetAaiAr(mex) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - def (type, id) = DeleteVcpeResCustService.getAaiAr(mex, "/myurl/ar1") - - assertEquals(null, type) - assertEquals(null, id) - } - - private void initGetAaiAr(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("URN_aai_endpoint")).thenReturn(aaiUriPfx) - } - - // ***** prepareVnfAndModulesDelete ***** - - @Test -// @Ignore - public void prepareVnfAndModulesDelete() { - ExecutionEntity mex = setupMock() - initPrepareVnfAndModulesDelete(mex) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - DeleteVcpeResCustService.prepareVnfAndModulesDelete(mex) - - verify(mex).getVariable(DBGFLAG) - - verify(mex).setVariable("vnfId", "vnfB") - } - - @Test -// @Ignore - public void prepareVnfAndModulesDelete_Empty() { - ExecutionEntity mex = setupMock() - initPrepareVnfAndModulesDelete(mex) - - when(mex.getVariable(Prefix+"relatedVnfIdList")).thenReturn(new LinkedList()) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - DeleteVcpeResCustService.prepareVnfAndModulesDelete(mex) - - verify(mex).getVariable(DBGFLAG) - - verify(mex).setVariable("vnfId", "") - } - - @Test -// @Ignore - public void prepareVnfAndModulesDelete_Ex() { - ExecutionEntity mex = setupMock() - initPrepareVnfAndModulesDelete(mex) - - when(mex.getVariable(Prefix+"relatedVnfIdList")).thenThrow(new RuntimeException("expected exception")) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - - assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.prepareVnfAndModulesDelete(mex) })) - } - - private initPrepareVnfAndModulesDelete(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable(Prefix+"relatedVnfIdList")).thenReturn(Arrays.asList("vnfA", "vnfB", "vnfC")) - when(mex.getVariable(Prefix+"vnfsDeletedCount")).thenReturn(1) - } - - // ***** validateVnfDelete ***** - - @Test -// @Ignore - public void validateVnfDelete() { - ExecutionEntity mex = setupMock() - initValidateVnfDelete(mex) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - DeleteVcpeResCustService.validateVnfDelete(mex) - - verify(mex).getVariable(DBGFLAG) - - verify(mex).setVariable(Prefix+"vnfsDeletedCount", 3) - } - - @Test -// @Ignore - public void validateVnfDelete_Ex() { - ExecutionEntity mex = setupMock() - initValidateVnfDelete(mex) - - when(mex.getVariable(Prefix+"vnfsDeletedCount")).thenThrow(new RuntimeException("expected exception")) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - - assertTrue(doBpmnError({ _ -> DeleteVcpeResCustService.validateVnfDelete(mex) })) - } - - private initValidateVnfDelete(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable(Prefix+"vnfsDeletedCount")).thenReturn(2) - } - - // ***** postProcessResponse ***** - - @Test -// @Ignore - public void postProcessResponse() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPostProcessResponse(mex) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - DeleteVcpeResCustService.postProcessResponse(mex) - - verify(mex).getVariable(DBGFLAG) - - assertEquals(true, map.get(Prefix+"Success")) - - def req = map.get(Prefix+"CompleteMsoProcessRequest") - - assertTrue(req.indexOf("mri= 0) - assertTrue(req.indexOf("mysrc= 0) - } - - @Test -// @Ignore - public void postProcessResponse_BpmnError() { - ExecutionEntity mex = setupMock() - initPostProcessResponse(mex) - - when(mex.getVariable("source")).thenThrow(new BpmnError("expected exception")) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - - assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.postProcessResponse(mex) })) - } - - @Test -// @Ignore - public void postProcessResponse_Ex() { - ExecutionEntity mex = setupMock() - initPostProcessResponse(mex) - - when(mex.getVariable("source")).thenThrow(new RuntimeException("expected exception")) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - - assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.postProcessResponse(mex) })) - } - - private initPostProcessResponse(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("source")).thenReturn("mysrc") - when(mex.getVariable("msoRequestId")).thenReturn("mri") - } - - - // ***** prepareFalloutRequest ***** - - @Test -// @Ignore - public void prepareFalloutRequest() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPrepareFalloutRequest(mex) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - DeleteVcpeResCustService.prepareFalloutRequest(mex) - - verify(mex, times(2)).getVariable(DBGFLAG) - - def fo = map.get(Prefix+"falloutRequest") - - assertTrue(fo.indexOf("world= 0) - assertTrue(fo.indexOf("ErrorMessage>mymsg= 0) - assertTrue(fo.indexOf("ErrorCode>999= 0) - } - - @Test -// @Ignore - public void prepareFalloutRequest_Ex() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPrepareFalloutRequest(mex) - - when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - - assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.prepareFalloutRequest(mex) })) - } - - private initPrepareFalloutRequest(ExecutionEntity mex) { - WorkflowException wfe = mock(WorkflowException.class) - - when(wfe.getErrorMessage()).thenReturn("mymsg") - when(wfe.getErrorCode()).thenReturn(999) - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("WorkflowException")).thenReturn(wfe) - when(mex.getVariable(Prefix+"requestInfo")).thenReturn("world") - - return wfe - } - - // ***** sendSyncError ***** - - @Test -// @Ignore - public void sendSyncError() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initSendSyncError(mex) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - DeleteVcpeResCustService.sendSyncError(mex) - - verify(mex, times(2)).getVariable(DBGFLAG) - - verify(mex).setVariable(processName+"WorkflowResponseSent", "true") - - assertEquals("500", map.get(processName+"ResponseCode")) - assertEquals("Fail", map.get(processName+"Status")) - - def resp = map.get(processName+"Response") - - assertTrue(resp.indexOf("ErrorMessage>mymsg= 0) - - verify(mex).setVariable("WorkflowResponse", resp) - } - - @Test -// @Ignore - public void sendSyncError_NotWfe() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initSendSyncError(mex) - - when(mex.getVariable("WorkflowException")).thenReturn("not a WFE") - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - DeleteVcpeResCustService.sendSyncError(mex) - - verify(mex, times(2)).getVariable(DBGFLAG) - - verify(mex).setVariable(processName+"WorkflowResponseSent", "true") - - assertEquals("500", map.get(processName+"ResponseCode")) - assertEquals("Fail", map.get(processName+"Status")) - - def resp = map.get(processName+"Response") - - assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.= 0) - - verify(mex).setVariable("WorkflowResponse", resp) - } - - @Test -// @Ignore - public void sendSyncError_NullWfe() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initSendSyncError(mex) - - when(mex.getVariable("WorkflowException")).thenReturn(null) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - DeleteVcpeResCustService.sendSyncError(mex) - - verify(mex, times(2)).getVariable(DBGFLAG) - - verify(mex).setVariable(processName+"WorkflowResponseSent", "true") - - assertEquals("500", map.get(processName+"ResponseCode")) - assertEquals("Fail", map.get(processName+"Status")) - - def resp = map.get(processName+"Response") - - assertTrue(resp.indexOf("ErrorMessage>Sending Sync Error.= 0) - - verify(mex).setVariable("WorkflowResponse", resp) - } - - @Test -// @Ignore - public void sendSyncError_Ex() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initSendSyncError(mex) - - when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - - DeleteVcpeResCustService.sendSyncError(mex) - - assertFalse(map.containsKey(processName+"ResponseCode")) - } - - private initSendSyncError(ExecutionEntity mex) { - WorkflowException wfe = mock(WorkflowException.class) - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("mso-request-id")).thenReturn("mri") - when(mex.getVariable("WorkflowException")).thenReturn(wfe) - - when(wfe.getErrorMessage()).thenReturn("mymsg") - } - - - // ***** processJavaException ***** - - @Test -// @Ignore - public void processJavaException() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initProcessJavaException(mex) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - - assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.processJavaException(mex) })) - - verify(mex, times(2)).getVariable(DBGFLAG) - - verify(mex).setVariable("prefix", Prefix) - - def wfe = map.get("WorkflowException") - - assertEquals("Caught a Java Lang Exception", wfe.getErrorMessage()) - } - - @Test -// @Ignore - public void processJavaException_BpmnError() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initProcessJavaException(mex) - - when(mex.getVariables()).thenThrow(new BpmnError("expected exception")) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - - assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.processJavaException(mex) })) - - assertFalse(map.containsKey("WorkflowException")) - } - - @Test -// @Ignore - public void processJavaException_Ex() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initProcessJavaException(mex) - - when(mex.getVariables()).thenThrow(new RuntimeException("expected exception")) - - DeleteVcpeResCustService DeleteVcpeResCustService = new DeleteVcpeResCustService() - - assertTrue(doBpmnError( { _ -> DeleteVcpeResCustService.processJavaException(mex) })) - - def wfe = map.get("WorkflowException") - - assertEquals("Exception in processJavaException method", wfe.getErrorMessage()) - } - - private initProcessJavaException(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - } - - private void myMockGetAr(String url, int status, String fileResp) { - stubFor(get(urlMatching(url)) - .willReturn(aResponse() - .withStatus(status) - .withHeader("Content-Type", "text/xml") - .withBodyFile("VCPE/DeleteVcpeResCustService/" + fileResp))); - } -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy deleted file mode 100644 index 1e8842e68f..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollbackTest.groovy +++ /dev/null @@ -1,654 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.vcpe.scripts - - -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.junit.Before -import org.junit.BeforeClass -import org.junit.Rule -import org.junit.Test -import org.junit.Ignore -import org.mockito.MockitoAnnotations -import org.camunda.bpm.engine.delegate.BpmnError -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.mock.FileUtil - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse -import static com.github.tomakehurst.wiremock.client.WireMock.get -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.*; -import static org.mockito.Mockito.* -import static org.onap.so.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource -import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource - -import org.onap.so.bpmn.core.RollbackData - -import com.github.tomakehurst.wiremock.junit.WireMockRule - -class DoCreateAllottedResourceBRGRollbackTest extends GroovyTestBase { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(PORT) - - String Prefix = "DCARBRGRB_" - String RbType = "DCARBRG_" - - @BeforeClass - public static void setUpBeforeClass() { - super.setUpBeforeClass() - } - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - - public DoCreateAllottedResourceBRGRollbackTest() { - super("DoCreateAllottedResourceBRGRollback") - } - - - // ***** preProcessRequest ***** - - @Test -// @Ignore - public void preProcessRequest() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) - - ////verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("prefix", Prefix) - verify(mex).setVariable("serviceInstanceId", "sii") - verify(mex).setVariable("parentServiceInstanceId", "psii") - verify(mex).setVariable("allottedResourceId", "myid") - verify(mex).setVariable("rollbackAAI", true) - verify(mex).setVariable("aaiARPath", "mypath") - verify(mex).setVariable("rollbackSDNC", true) - verify(mex).setVariable("deactivateSdnc", "myactivate") - verify(mex).setVariable("deleteSdnc", "mycreate") - verify(mex).setVariable("unassignSdnc", "true") - verify(mex).setVariable("sdncDeactivateRequest", "activatereq") - verify(mex).setVariable("sdncDeleteRequest", "createreq") - verify(mex).setVariable("sdncUnassignRequest", "assignreq") - - verify(mex, never()).setVariable("skipRollback", true) - } - - @Test -// @Ignore - public void preProcessRequest_RollbackDisabled() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - when(mex.getVariable("disableRollback")).thenReturn("true") - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) - - ////verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("prefix", Prefix) - verify(mex).setVariable("serviceInstanceId", "sii") - verify(mex).setVariable("parentServiceInstanceId", "psii") - verify(mex).setVariable("allottedResourceId", "myid") - verify(mex).setVariable("rollbackAAI", true) - verify(mex).setVariable("aaiARPath", "mypath") - verify(mex).setVariable("rollbackSDNC", true) - verify(mex).setVariable("deactivateSdnc", "myactivate") - verify(mex).setVariable("deleteSdnc", "mycreate") - verify(mex).setVariable("unassignSdnc", "true") - verify(mex).setVariable("sdncDeactivateRequest", "activatereq") - verify(mex).setVariable("sdncDeleteRequest", "createreq") - verify(mex).setVariable("sdncUnassignRequest", "assignreq") - - verify(mex).setVariable("skipRollback", true) - } - - @Test -// @Ignore - public void preProcessRequest_NoAAI() { - ExecutionEntity mex = setupMock() - def data = initPreProcess(mex) - - when(mex.getVariable("rollbackAAI")).thenReturn(false) - data.put(RbType, "rollbackAAI", "false") - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) - - //verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("prefix", Prefix) - verify(mex).setVariable("serviceInstanceId", "sii") - verify(mex).setVariable("parentServiceInstanceId", "psii") - verify(mex).setVariable("allottedResourceId", "myid") - verify(mex, never()).setVariable("rollbackAAI", true) - verify(mex, never()).setVariable("aaiARPath", "mypath") - verify(mex).setVariable("rollbackSDNC", true) - verify(mex).setVariable("deactivateSdnc", "myactivate") - verify(mex).setVariable("deleteSdnc", "mycreate") - verify(mex).setVariable("unassignSdnc", "true") - verify(mex).setVariable("sdncDeactivateRequest", "activatereq") - verify(mex).setVariable("sdncDeleteRequest", "createreq") - verify(mex).setVariable("sdncUnassignRequest", "assignreq") - - verify(mex, never()).setVariable("skipRollback", true) - } - - @Test -// @Ignore - public void preProcessRequest_NoAssign() { - ExecutionEntity mex = setupMock() - def data = initPreProcess(mex) - - when(mex.getVariable("rollbackSDNC")).thenReturn(false) - data.put(RbType, "rollbackSDNCassign", "false") - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) - - //verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("prefix", Prefix) - verify(mex).setVariable("serviceInstanceId", "sii") - verify(mex).setVariable("parentServiceInstanceId", "psii") - verify(mex).setVariable("allottedResourceId", "myid") - verify(mex).setVariable("rollbackAAI", true) - verify(mex).setVariable("aaiARPath", "mypath") - verify(mex, never()).setVariable("rollbackSDNC", true) - verify(mex, never()).setVariable("deactivateSdnc", "myactivate") - verify(mex, never()).setVariable("deleteSdnc", "mycreate") - verify(mex, never()).setVariable("unassignSdnc", "true") - verify(mex, never()).setVariable("sdncDeactivateRequest", "activatereq") - verify(mex, never()).setVariable("sdncDeleteRequest", "createreq") - verify(mex, never()).setVariable("sdncUnassignRequest", "assignreq") - - verify(mex, never()).setVariable("skipRollback", true) - } - - @Test -// @Ignore - public void preProcessRequest_NoAAI_NoAssign() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - when(mex.getVariable("rollbackAAI")).thenReturn(false) - when(mex.getVariable("rollbackSDNC")).thenReturn(false) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) - - verify(mex).setVariable("skipRollback", true) - } - - @Test -// @Ignore - public void preProcessRequest_NoRbStructure() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - when(mex.getVariable("rollbackData")).thenReturn(new RollbackData()) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) - - verify(mex).setVariable("skipRollback", true) - } - - @Test -// @Ignore - public void preProcessRequest_NullRb() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - when(mex.getVariable("rollbackData")).thenReturn(null) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) - - verify(mex).setVariable("skipRollback", true) - } - - @Test -// @Ignore - public void preProcessRequest_BpmnError() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) })) - } - - @Test -// @Ignore - public void preProcessRequest_Ex() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.preProcessRequest(mex) })) - } - - @Test - @Ignore - public void updateAaiAROrchStatus() { - ExecutionEntity mex = setupMock() - initUpdateAaiAROrchStatus(mex) - - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml") - MockPatchAllottedResource(CUST, SVC, INST, ARID) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - DoCreateAllottedResourceBRGRollback.updateAaiAROrchStatus(mex, "success") - } - - @Test -// @Ignore - public void updateAaiAROrchStatus_EmptyResponse() { - ExecutionEntity mex = setupMock() - initUpdateAaiAROrchStatus(mex) - - wireMockRule - .stubFor(get(urlMatching("/aai/v[0-9]+/.*")) - .willReturn(aResponse() - .withStatus(200))) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.updateAaiAROrchStatus(mex, "success") })) - } - - @Test -// @Ignore - public void updateAaiAROrchStatus_NoArPath() { - ExecutionEntity mex = setupMock() - initUpdateAaiAROrchStatus(mex) - - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml") - MockPatchAllottedResource(CUST, SVC, INST, ARID) - - when(mex.getVariable("aaiARPath")).thenReturn(null) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.updateAaiAROrchStatus(mex, "success") })) - } - - - // ***** validateSDNCResp ***** - - @Test -// @Ignore - public void validateSDNCResp() { - ExecutionEntity mex = setupMock() - initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - - when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - - DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create") - - verify(mex).getVariable("WorkflowException") - verify(mex).getVariable("SDNCA_SuccessIndicator") - } - - @Test -// @Ignore - public void validateSDNCResp_Unsuccessful() { - ExecutionEntity mex = setupMock() - initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - - when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(false) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create") })) - } - - @Test -// @Ignore - public void validateSDNCResp_BpmnError404() { - ExecutionEntity mex = setupMock() - initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) - - when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("404", "expected exception")) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - - DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create") - } - - @Test -// @Ignore - public void validateSDNCResp_BpmnError() { - ExecutionEntity mex = setupMock() - initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) - - when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create") })) - } - - @Test -// @Ignore - public void validateSDNCResp_Ex() { - ExecutionEntity mex = setupMock() - initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) - - when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.validateSDNCResp(mex, resp, "create") })) - } - - @Test - @Ignore - public void deleteAaiAR() { - ExecutionEntity mex = setupMock() - initDeleteAaiAR(mex) - - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml") - MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - DoCreateAllottedResourceBRGRollback.deleteAaiAR(mex) - } - - @Test -// @Ignore - public void deleteAaiAR_NoArPath() { - ExecutionEntity mex = setupMock() - initDeleteAaiAR(mex) - - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml") - MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) - - when(mex.getVariable("aaiARPath")).thenReturn("") - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.deleteAaiAR(mex) })) - } - - @Test -// @Ignore - public void deleteAaiAR_BpmnError() { - ExecutionEntity mex = setupMock() - initDeleteAaiAR(mex) - - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml") - MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) - - when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.deleteAaiAR(mex) })) - } - - @Test -// @Ignore - public void deleteAaiAR_Ex() { - ExecutionEntity mex = setupMock() - initDeleteAaiAR(mex) - - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRGRollback/arGetById.xml") - MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) - - when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRGRollback.deleteAaiAR(mex) })) - } - - @Test -// @Ignore - public void postProcessRequest() { - ExecutionEntity mex = setupMock() - initPostProcessRequest(mex) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - DoCreateAllottedResourceBRGRollback.postProcessRequest(mex) - - //verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("rollbackData", null) - verify(mex).setVariable("rolledBack", true) - } - - @Test -// @Ignore - public void postProcessRequest_RolledBack() { - ExecutionEntity mex = setupMock() - initPostProcessRequest(mex) - - when(mex.getVariable("skipRollback")).thenReturn(true) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - DoCreateAllottedResourceBRGRollback.postProcessRequest(mex) - - //verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("rollbackData", null) - verify(mex, never()).setVariable("rolledBack", true) - } - - @Test -// @Ignore - public void postProcessRequest_BpmnError() { - ExecutionEntity mex = setupMock() - initPostProcessRequest(mex) - - when(mex.getVariable("skipRollback")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - DoCreateAllottedResourceBRGRollback.postProcessRequest(mex) - - //verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("rollbackData", null) - verify(mex, never()).setVariable("rolledBack", true) - } - - @Test -// @Ignore - public void postProcessRequest_Ex() { - ExecutionEntity mex = setupMock() - initPostProcessRequest(mex) - - when(mex.getVariable("skipRollback")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - DoCreateAllottedResourceBRGRollback.postProcessRequest(mex) - - //verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("rollbackData", null) - verify(mex, never()).setVariable("rolledBack", true) - } - - @Test -// @Ignore - public void processRollbackException() { - ExecutionEntity mex = setupMock() - initProcessRollbackException(mex) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - DoCreateAllottedResourceBRGRollback.processRollbackException(mex) - - //verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("rollbackData", null) - verify(mex).setVariable("rolledBack", false) - verify(mex).setVariable("rollbackError", "Caught exception in AllottedResource Create Rollback") - verify(mex).setVariable("WorkflowException", null) - } - - @Test -// @Ignore - public void processRollbackException_BpmnError() { - ExecutionEntity mex = setupMock() - initProcessRollbackException(mex) - - doThrow(new BpmnError("expected exception")).when(mex).setVariable("rollbackData", null) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - DoCreateAllottedResourceBRGRollback.processRollbackException(mex) - } - - @Test -// @Ignore - public void processRollbackException_Ex() { - ExecutionEntity mex = setupMock() - initProcessRollbackException(mex) - - doThrow(new RuntimeException("expected exception")).when(mex).setVariable("rollbackData", null) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - DoCreateAllottedResourceBRGRollback.processRollbackException(mex) - } - - @Test -// @Ignore - public void processRollbackJavaException() { - ExecutionEntity mex = setupMock() - initProcessRollbackException(mex) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - DoCreateAllottedResourceBRGRollback.processRollbackJavaException(mex) - - //verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("rollbackData", null) - verify(mex).setVariable("rolledBack", false) - verify(mex).setVariable("rollbackError", "Caught Java exception in AllottedResource Create Rollback") - verify(mex, never()).setVariable("WorkflowException", null) - } - - @Test -// @Ignore - public void processRollbackJavaException_BpmnError() { - ExecutionEntity mex = setupMock() - initProcessRollbackException(mex) - - doThrow(new BpmnError("expected exception")).when(mex).setVariable("rollbackData", null) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - DoCreateAllottedResourceBRGRollback.processRollbackJavaException(mex) - } - - @Test -// @Ignore - public void processRollbackJavaException_Ex() { - ExecutionEntity mex = setupMock() - initProcessRollbackException(mex) - - doThrow(new RuntimeException("expected exception")).when(mex).setVariable("rollbackData", null) - - DoCreateAllottedResourceBRGRollback DoCreateAllottedResourceBRGRollback = new DoCreateAllottedResourceBRGRollback() - DoCreateAllottedResourceBRGRollback.processRollbackJavaException(mex) - } - - private RollbackData initPreProcess(ExecutionEntity mex) { - def data = new RollbackData() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("rollbackData")).thenReturn(data) - when(mex.getVariable("rollbackAAI")).thenReturn(true) - when(mex.getVariable("rollbackSDNC")).thenReturn(true) - when(mex.getVariable("disableRollback")).thenReturn("false") - - data.put("SERVICEINSTANCE", "allottedResourceId", "myid") - - data.put(RbType, "serviceInstanceId", "sii") - data.put(RbType, "parentServiceInstanceId", "psii") - - data.put(RbType, "rollbackAAI", "true") - data.put(RbType, "aaiARPath", "mypath") - - data.put(RbType, "rollbackSDNCassign", "true") - data.put(RbType, "rollbackSDNCactivate", "myactivate") - data.put(RbType, "rollbackSDNCcreate", "mycreate") - data.put(RbType, "sdncActivateRollbackReq", "activatereq") - data.put(RbType, "sdncCreateRollbackReq", "createreq") - data.put(RbType, "sdncAssignRollbackReq", "assignreq") - - return data - } - - private initUpdateAaiAROrchStatus(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) - when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) - } - - private initValidateSDNCResp(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("prefix")).thenReturn(Prefix) - when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) - } - - private String initValidateSDNCResp_Resp() { - return "<response-code>200</response-code>" - } - - private initDeleteAaiAR(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("aaiARResourceVersion")).thenReturn(VERS) - when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) - when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) - } - - private initPostProcessRequest(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("skipRollback")).thenReturn(false) - } - - private initProcessRollbackException(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - } - - private initProcessRollbackJavaException(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - } - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy deleted file mode 100644 index 543bb1db05..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGTest.groovy +++ /dev/null @@ -1,999 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.vcpe.scripts - - -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.junit.Before -import org.junit.BeforeClass -import org.junit.Rule -import org.junit.Test -import org.junit.Ignore -import org.mockito.MockitoAnnotations -import org.camunda.bpm.engine.delegate.BpmnError -import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.mock.FileUtil - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse -import static com.github.tomakehurst.wiremock.client.WireMock.put -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.*; -import static org.mockito.Mockito.* -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource -import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource -import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutAllottedResource -import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutAllottedResource_500 - -import org.onap.so.bpmn.core.RollbackData -import org.onap.so.bpmn.vcpe.scripts.MapSetter - -import com.github.tomakehurst.wiremock.junit.WireMockRule - -class DoCreateAllottedResourceBRGTest extends GroovyTestBase { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(PORT) - - String Prefix = "DCARBRG_" - - @BeforeClass - public static void setUpBeforeClass() { - super.setUpBeforeClass() - } - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - - public DoCreateAllottedResourceBRGTest() { - super("DoCreateAllottedResourceBRG") - } - - - // ***** preProcessRequest ***** - - @Test -// @Ignore - public void preProcessRequest() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.preProcessRequest(mex) - - //verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("prefix", Prefix) - - assertTrue(checkMissingPreProcessRequest("mso.workflow.sdncadapter.callback")) - assertTrue(checkMissingPreProcessRequest("mso.workflow.sdnc.replication.delay")) - assertTrue(checkMissingPreProcessRequest("serviceInstanceId")) - assertTrue(checkMissingPreProcessRequest("parentServiceInstanceId")) - assertTrue(checkMissingPreProcessRequest("allottedResourceModelInfo")) - assertTrue(checkMissingPreProcessRequest("vni")) - assertTrue(checkMissingPreProcessRequest("vgmuxBearerIP")) - assertTrue(checkMissingPreProcessRequest("brgWanMacAddress")) - assertTrue(checkMissingPreProcessRequest("allottedResourceRole")) - assertTrue(checkMissingPreProcessRequest("allottedResourceType")) - } - - - // ***** getAaiAR ***** - - @Test - @Ignore - public void getAaiAR() { - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml") - - ExecutionEntity mex = setupMock() - initGetAaiAR(mex) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.getAaiAR(mex) - - verify(mex).setVariable("foundActiveAR", true) - } - - @Test -// @Ignore - public void getAaiAR_Duplicate() { - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml") - - ExecutionEntity mex = setupMock() - initGetAaiAR(mex) - - // fail if duplicate - when(mex.getVariable("failExists")).thenReturn("true") - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRG.getAaiAR(mex) })) - } - - @Test -// @Ignore - public void getAaiAR_NotActive() { - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml") - - ExecutionEntity mex = setupMock() - initGetAaiAR(mex) - - // not active - when(mex.getVariable("aaiAROrchStatus")).thenReturn("not-active") - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceBRG.getAaiAR(mex) })) - } - - @Test - @Ignore - public void getAaiAR_NoStatus() { - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg.xml") - - ExecutionEntity mex = setupMock() - initGetAaiAR(mex) - - when(mex.getVariable("aaiAROrchStatus")).thenReturn(null) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.getAaiAR(mex) - - verify(mex, never()).setVariable("foundActiveAR", true) - } - - - // ***** createAaiAR ***** - - @Test - @Ignore - public void createAaiAR() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initCreateAaiAr(mex) - - MockPutAllottedResource(CUST, SVC, INST, ARID) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.createAaiAR(mex) - - def data = map.get("rollbackData") - assertNotNull(data) - assertTrue(data instanceof RollbackData) - - assertEquals("45", data.get(Prefix, "disableRollback")) - assertEquals("true", data.get(Prefix, "rollbackAAI")) - assertEquals(ARID, data.get(Prefix, "allottedResourceId")) - assertEquals("sii", data.get(Prefix, "serviceInstanceId")) - assertEquals("psii", data.get(Prefix, "parentServiceInstanceId")) - assertEquals(mex.getVariable("PSI_resourceLink")+"/allotted-resources/allotted-resource/"+ARID, data.get(Prefix, "aaiARPath")) - } - - @Test - @Ignore - public void createAaiAR_NoArid_NoModelUuids() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initCreateAaiAr(mex) - - // no allottedResourceId - will be generated - - when(mex.getVariable("allottedResourceId")).thenReturn(null) - - wireMockRule - .stubFor(put(urlMatching("/aai/.*/allotted-resource/.*")) - .willReturn(aResponse() - .withStatus(200))) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.createAaiAR(mex) - - def arid = map.get("allottedResourceId") - assertNotNull(arid) - assertFalse(arid.isEmpty()) - - def data = map.get("rollbackData") - assertNotNull(data) - assertTrue(data instanceof RollbackData) - - assertEquals(arid, data.get(Prefix, "allottedResourceId")) - } - - @Test -// @Ignore - public void createAaiAR_MissingPsiLink() { - ExecutionEntity mex = setupMock() - initCreateAaiAr(mex) - - when(mex.getVariable("PSI_resourceLink")).thenReturn(null) - - MockPutAllottedResource(CUST, SVC, INST, ARID) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) })) - } - - @Test -// @Ignore - public void createAaiAR_HttpFailed() { - ExecutionEntity mex = setupMock() - initCreateAaiAr(mex) - - MockPutAllottedResource_500(CUST, SVC, INST, ARID) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) })) - } - - @Test -// @Ignore - public void createAaiAR_BpmnError() { - ExecutionEntity mex = setupMock() - initCreateAaiAr(mex) - - when(mex.getVariable("aai.endpoint")).thenThrow(new BpmnError("expected exception")) - - MockPutAllottedResource(CUST, SVC, INST, ARID) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) })) - } - - @Test -// @Ignore - public void createAaiAR_Ex() { - ExecutionEntity mex = setupMock() - initCreateAaiAr(mex) - - when(mex.getVariable("aai.endpoint")).thenThrow(new RuntimeException("expected exception")) - - MockPutAllottedResource(CUST, SVC, INST, ARID) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.createAaiAR(mex) })) - } - - - // ***** buildSDNCRequest ***** - - @Test -// @Ignore - public void buildSDNCRequest() { - ExecutionEntity mex = setupMock() - initBuildSDNCRequest(mex) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - String result = DoCreateAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") - - assertTrue(result.indexOf("myreq= 0) - assertTrue(result.indexOf("myact= 0) - assertTrue(result.indexOf("ari= 0) - assertTrue(result.indexOf("sii= 0) - assertTrue(result.indexOf("sii= 0) - assertTrue(result.indexOf("psii= 0) - assertTrue(result.indexOf("sst= 0) - assertTrue(result.indexOf("gci= 0) - assertTrue(result.indexOf("scu= 0) - assertTrue(result.indexOf("mri= 0) - assertTrue(result.indexOf("bwma= 0) - assertTrue(result.indexOf("myvni= 0) - assertTrue(result.indexOf("vbi= 0) - assertTrue(result.indexOf("miu= 0) - assertTrue(result.indexOf("mu= 0) - assertTrue(result.indexOf("mcu= 0) - assertTrue(result.indexOf("mv= 0) - assertTrue(result.indexOf("mn= 0) - } - - @Test -// @Ignore - public void buildSDNCRequest_EmptyModelInfo() { - ExecutionEntity mex = setupMock() - initBuildSDNCRequest(mex) - - when(mex.getVariable("allottedResourceModelInfo")).thenReturn("{}") - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - String result = DoCreateAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") - - assertTrue(result.indexOf("myreq= 0) - assertTrue(result.indexOf("myact= 0) - assertTrue(result.indexOf("ari= 0) - assertTrue(result.indexOf("sii= 0) - assertTrue(result.indexOf("sii= 0) - assertTrue(result.indexOf("psii= 0) - assertTrue(result.indexOf("sst= 0) - assertTrue(result.indexOf("gci= 0) - assertTrue(result.indexOf("scu= 0) - assertTrue(result.indexOf("mri= 0) - assertTrue(result.indexOf("bwma= 0) - assertTrue(result.indexOf("myvni= 0) - assertTrue(result.indexOf("vbi= 0) - assertTrue(result.indexOf("") >= 0) - assertTrue(result.indexOf("") >= 0) - assertTrue(result.indexOf("") >= 0) - assertTrue(result.indexOf("") >= 0) - assertTrue(result.indexOf("") >= 0) - } - - @Test -// @Ignore - public void buildSDNCRequest_Ex() { - ExecutionEntity mex = setupMock() - initBuildSDNCRequest(mex) - - when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") })) - } - - - // ***** preProcessSDNCAssign ***** - - @Test -// @Ignore - public void preProcessSDNCAssign() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - def data = initPreProcessSDNC(mex) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.preProcessSDNCAssign(mex) - - def req = map.get("sdncAssignRequest") - assertNotNull(req) - - assertEquals(data, map.get("rollbackData")) - - def rbreq = data.get(Prefix, "sdncAssignRollbackReq") - - assertTrue(req.indexOf("assign= 0) - assertTrue(req.indexOf("CreateBRGInstance= 0) - assertTrue(req.indexOf("") >= 0) - - assertTrue(rbreq.indexOf("unassign= 0) - assertTrue(rbreq.indexOf("DeleteBRGInstance= 0) - assertTrue(rbreq.indexOf("") >= 0) - } - - @Test -// @Ignore - public void preProcessSDNCAssign_BpmnError() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCAssign(mex) })) - } - - @Test -// @Ignore - public void preProcessSDNCAssign_Ex() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCAssign(mex) })) - } - - - // ***** preProcessSDNCCreate ***** - - @Test -// @Ignore - public void preProcessSDNCCreate() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - def data = initPreProcessSDNC(mex) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.preProcessSDNCCreate(mex) - - def req = map.get("sdncCreateRequest") - assertNotNull(req) - - assertEquals(data, map.get("rollbackData")) - - def rbreq = data.get(Prefix, "sdncCreateRollbackReq") - - assertTrue(req.indexOf("create= 0) - assertTrue(req.indexOf("CreateBRGInstance= 0) - assertTrue(req.indexOf("") >= 0) - - assertTrue(rbreq.indexOf("delete= 0) - assertTrue(rbreq.indexOf("DeleteBRGInstance= 0) - assertTrue(rbreq.indexOf("") >= 0) - - } - - @Test -// @Ignore - public void preProcessSDNCCreate_BpmnError() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCCreate(mex) })) - } - - @Test -// @Ignore - public void preProcessSDNCCreate_Ex() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCCreate(mex) })) - } - - - // ***** preProcessSDNCActivate ***** - - @Test -// @Ignore - public void preProcessSDNCActivate() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - def data = initPreProcessSDNC(mex) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.preProcessSDNCActivate(mex) - - def req = map.get("sdncActivateRequest") - assertNotNull(req) - - assertEquals(data, map.get("rollbackData")) - - def rbreq = data.get(Prefix, "sdncActivateRollbackReq") - - assertTrue(req.indexOf("activate= 0) - assertTrue(req.indexOf("CreateBRGInstance= 0) - assertTrue(req.indexOf("") >= 0) - - assertTrue(rbreq.indexOf("deactivate= 0) - assertTrue(rbreq.indexOf("DeleteBRGInstance= 0) - assertTrue(rbreq.indexOf("") >= 0) - - } - - @Test -// @Ignore - public void preProcessSDNCActivate_BpmnError() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCActivate(mex) })) - } - - @Test -// @Ignore - public void preProcessSDNCActivate_Ex() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCActivate(mex) })) - } - - - // ***** validateSDNCResp ***** - - @Test -// @Ignore - public void validateSDNCResp() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - def data = initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - - when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") - - verify(mex).getVariable("WorkflowException") - verify(mex).getVariable("SDNCA_SuccessIndicator") - verify(mex).getVariable("rollbackData") - - assertEquals(data, map.get("rollbackData")) - - assertEquals("true", data.get(Prefix, "rollback" + "SDNCcreate")) - - } - - @Test -// @Ignore - public void validateSDNCResp_Get() { - ExecutionEntity mex = setupMock() - def data = initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - - when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "get") - - verify(mex).getVariable("WorkflowException") - verify(mex).getVariable("SDNCA_SuccessIndicator") - - verify(mex, never()).getVariable("rollbackData") - } - - @Test -// @Ignore - public void validateSDNCResp_Unsuccessful() { - ExecutionEntity mex = setupMock() - initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - - // unsuccessful - when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(false) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") })) - } - - @Test -// @Ignore - public void validateSDNCResp_BpmnError() { - ExecutionEntity mex = setupMock() - initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - - when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") })) - } - - @Test -// @Ignore - public void validateSDNCResp_Ex() { - ExecutionEntity mex = setupMock() - initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - - when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.validateSDNCResp(mex, resp, "create") })) - } - - - // ***** preProcessSDNCGet ***** - - @Test -// @Ignore - public void preProcessSDNCGet_FoundAR() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcessSDNCGet(mex) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.preProcessSDNCGet(mex) - - String req = map.get("sdncGetRequest") - - assertTrue(req.indexOf("") >= 0) - assertTrue(req.indexOf("sii= 0) - assertTrue(req.indexOf("arlink= 0) - assertTrue(req.indexOf("myurl= 0) - - } - - @Test -// @Ignore - public void preProcessSDNCGet_NotFoundAR() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcessSDNCGet(mex) - - when(mex.getVariable("foundActiveAR")).thenReturn(false) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.preProcessSDNCGet(mex) - - String req = map.get("sdncGetRequest") - - assertTrue(req.indexOf("") >= 0) - assertTrue(req.indexOf("sii= 0) - assertTrue(req.indexOf("assignlink= 0) - assertTrue(req.indexOf("myurl= 0) - - } - - @Test -// @Ignore - public void preProcessSDNCGet_Ex() { - ExecutionEntity mex = setupMock() - initPreProcessSDNCGet(mex) - - when(mex.getVariable("foundActiveAR")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.preProcessSDNCGet(mex) })) - } - - - // ***** updateAaiAROrchStatus ***** - - @Test - @Ignore - public void updateAaiAROrchStatus() { - MockPatchAllottedResource(CUST, SVC, INST, ARID) - - ExecutionEntity mex = setupMock() - initUpdateAaiAROrchStatus(mex) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.updateAaiAROrchStatus(mex, "success") - } - - - // ***** generateOutputs ***** - - @Test -// @Ignore - public void generateOutputs() { - ExecutionEntity mex = setupMock() - def brgtop = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/SDNCTopologyQueryCallback.xml") - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("enhancedCallbackRequestData")).thenReturn(brgtop) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.generateOutputs(mex) - - verify(mex).setVariable("allotedResourceName", "namefromrequest") - - } - - @Test -// @Ignore - public void generateOutputs_BadXml() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("enhancedCallbackRequestData")).thenReturn("invalid xml") - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.generateOutputs(mex) - - verify(mex, never()).setVariable(anyString(), anyString()) - - } - - @Test -// @Ignore - public void generateOutputs_BpmnError() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - DoCreateAllottedResourceBRG.generateOutputs(mex) - verify(mex, never()).setVariable(anyString(), anyString()) - - } - - @Test -// @Ignore - public void generateOutputs_Ex() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - DoCreateAllottedResourceBRG.generateOutputs(mex) - verify(mex, never()).setVariable(anyString(), anyString()) - - } - - - // ***** preProcessRollback ***** - - @Test -// @Ignore - public void preProcessRollback() { - ExecutionEntity mex = setupMock() - WorkflowException wfe = mock(WorkflowException.class) - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("WorkflowException")).thenReturn(wfe) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.preProcessRollback(mex) - - verify(mex).setVariable("prevWorkflowException", wfe) - - } - - @Test -// @Ignore - public void preProcessRollback_NotWFE() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("WorkflowException")).thenReturn("I'm not a WFE") - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.preProcessRollback(mex) - -// verify(mex, never()).setVariable("prevWorkflowException", any()) - - } - - @Test -// @Ignore - public void preProcessRollback_BpmnError() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - DoCreateAllottedResourceBRG.preProcessRollback(mex) - - } - - @Test -// @Ignore - public void preProcessRollback_Ex() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - DoCreateAllottedResourceBRG.preProcessRollback(mex) - - } - - - // ***** postProcessRollback ***** - - @Test -// @Ignore - public void postProcessRollback() { - ExecutionEntity mex = setupMock() - WorkflowException wfe = mock(WorkflowException.class) - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("prevWorkflowException")).thenReturn(wfe) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.postProcessRollback(mex) - - verify(mex).setVariable("WorkflowException", wfe) - verify(mex).setVariable("rollbackData", null) - - } - - @Test -// @Ignore - public void postProcessRollback_NotWFE() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("prevWorkflowException")).thenReturn("I'm not a WFE") - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - DoCreateAllottedResourceBRG.postProcessRollback(mex) - -// verify(mex, never()).setVariable("WorkflowException", any()) - verify(mex).setVariable("rollbackData", null) - - } - - @Test -// @Ignore - public void postProcessRollback_BpmnError() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("prevWorkflowException")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceBRG.postProcessRollback(mex) })) - verify(mex, never()).setVariable("rollbackData", null) - - } - - @Test -// @Ignore - public void postProcessRollback_Ex() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("prevWorkflowException")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - DoCreateAllottedResourceBRG.postProcessRollback(mex) - verify(mex, never()).setVariable("rollbackData", null) - - } - - private boolean checkMissingPreProcessRequest(String fieldnm) { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - DoCreateAllottedResourceBRG DoCreateAllottedResourceBRG = new DoCreateAllottedResourceBRG() - - when(mex.getVariable(fieldnm)).thenReturn("") - - return doBpmnError( { _ -> DoCreateAllottedResourceBRG.preProcessRequest(mex) }) - } - - private void initPreProcess(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("sdncurn") - when(mex.getVariable("mso.workflow.sdnc.replication.delay")).thenReturn("sdncdelay") - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") - when(mex.getVariable("allottedResourceModelInfo")).thenReturn("armi") - when(mex.getVariable("vni")).thenReturn("myvni") - when(mex.getVariable("vgmuxBearerIP")).thenReturn("vbi") - when(mex.getVariable("brgWanMacAddress")).thenReturn("bwma") - when(mex.getVariable("allottedResourceRole")).thenReturn("arr") - when(mex.getVariable("allottedResourceType")).thenReturn("art") - } - - private void initGetAaiAR(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("allottedResourceType")).thenReturn("BRGt") - when(mex.getVariable("allottedResourceRole")).thenReturn("BRGr") - when(mex.getVariable("CSI_service")).thenReturn(FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/getAR.xml")) - when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) - when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active") - } - - private initCreateAaiAr(ExecutionEntity mex) { - when(mex.getVariable("disableRollback")).thenReturn(45) - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("allottedResourceId")).thenReturn(ARID) - when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) - when(mex.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.namespace")) - when(mex.getVariable("PSI_resourceLink")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST) - when(mex.getVariable("allottedResourceType")).thenReturn("BRGt") - when(mex.getVariable("allottedResourceRole")).thenReturn("BRGr") - when(mex.getVariable("CSI_resourceLink")).thenReturn(aaiUriPfx+"/aai/v9/mycsi") - when(mex.getVariable("allottedResourceModelInfo")).thenReturn(""" - { - "modelInvariantUuid":"modelinvuuid", - "modelUuid":"modeluuid", - "modelCustomizationUuid":"modelcustuuid" - } - """) - } - - private initBuildSDNCRequest(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("allottedResourceId")).thenReturn("ari") - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") - when(mex.getVariable("subscriptionServiceType")).thenReturn("sst") - when(mex.getVariable("globalCustomerId")).thenReturn("gci") - when(mex.getVariable("sdncCallbackUrl")).thenReturn("scu") - when(mex.getVariable("msoRequestId")).thenReturn("mri") - when(mex.getVariable("brgWanMacAddress")).thenReturn("bwma") - when(mex.getVariable("vni")).thenReturn("myvni") - when(mex.getVariable("vgmuxBearerIP")).thenReturn("vbi") - when(mex.getVariable("allottedResourceModelInfo")).thenReturn(""" - { - "modelInvariantUuid":"miu", - "modelUuid":"mu", - "modelCustomizationUuid":"mcu", - "modelVersion":"mv", - "modelName":"mn" - } - """) - } - - private RollbackData initPreProcessSDNC(ExecutionEntity mex) { - def data = new RollbackData() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("rollbackData")).thenReturn(data) - - return data - } - - private initPreProcessSDNCGet(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl") - when(mex.getVariable("foundActiveAR")).thenReturn(true) - when(mex.getVariable("aaiARGetResponse")).thenReturn("arlink") - when(mex.getVariable("sdncAssignResponse")).thenReturn("<object-path>assignlink</object-path>") - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl") - } - - private RollbackData initValidateSDNCResp(ExecutionEntity mex) { - def data = new RollbackData() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("prefix")).thenReturn(Prefix) - when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) - when(mex.getVariable("rollbackData")).thenReturn(data) - - return data - } - - private String initValidateSDNCResp_Resp() { - return "<response-code>200</response-code>" - } - - private initUpdateAaiAROrchStatus(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) - } - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy deleted file mode 100644 index 66cfdb635d..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollbackTest.groovy +++ /dev/null @@ -1,654 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.vcpe.scripts - - -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.junit.Before -import org.junit.BeforeClass -import org.junit.Rule -import org.junit.Test -import org.junit.Ignore -import org.mockito.MockitoAnnotations -import org.camunda.bpm.engine.delegate.BpmnError -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.mock.FileUtil - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse -import static com.github.tomakehurst.wiremock.client.WireMock.get -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.*; -import static org.mockito.Mockito.* -import static org.onap.so.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource -import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource - -import org.onap.so.bpmn.core.RollbackData - -import com.github.tomakehurst.wiremock.junit.WireMockRule - -class DoCreateAllottedResourceTXCRollbackTest extends GroovyTestBase { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(PORT) - - String Prefix = "DCARTXCRB_" - String RbType = "DCARTXC_" - - @BeforeClass - public static void setUpBeforeClass() { - super.setUpBeforeClass() - } - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - - public DoCreateAllottedResourceTXCRollbackTest() { - super("DoCreateAllottedResourceTXCRollback") - } - - - // ***** preProcessRequest ***** - - @Test -// @Ignore - public void preProcessRequest() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) - - //verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("prefix", Prefix) - verify(mex).setVariable("serviceInstanceId", "sii") - verify(mex).setVariable("parentServiceInstanceId", "psii") - verify(mex).setVariable("allottedResourceId", "myid") - verify(mex).setVariable("rollbackAAI", true) - verify(mex).setVariable("aaiARPath", "mypath") - verify(mex).setVariable("rollbackSDNC", true) - verify(mex).setVariable("deactivateSdnc", "myactivate") - verify(mex).setVariable("deleteSdnc", "mycreate") - verify(mex).setVariable("unassignSdnc", "true") - verify(mex).setVariable("sdncDeactivateRequest", "activatereq") - verify(mex).setVariable("sdncDeleteRequest", "createreq") - verify(mex).setVariable("sdncUnassignRequest", "assignreq") - - verify(mex, never()).setVariable("skipRollback", true) - } - - @Test -// @Ignore - public void preProcessRequest_RollbackDisabled() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - when(mex.getVariable("disableRollback")).thenReturn("true") - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) - - //verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("prefix", Prefix) - verify(mex).setVariable("serviceInstanceId", "sii") - verify(mex).setVariable("parentServiceInstanceId", "psii") - verify(mex).setVariable("allottedResourceId", "myid") - verify(mex).setVariable("rollbackAAI", true) - verify(mex).setVariable("aaiARPath", "mypath") - verify(mex).setVariable("rollbackSDNC", true) - verify(mex).setVariable("deactivateSdnc", "myactivate") - verify(mex).setVariable("deleteSdnc", "mycreate") - verify(mex).setVariable("unassignSdnc", "true") - verify(mex).setVariable("sdncDeactivateRequest", "activatereq") - verify(mex).setVariable("sdncDeleteRequest", "createreq") - verify(mex).setVariable("sdncUnassignRequest", "assignreq") - - verify(mex).setVariable("skipRollback", true) - } - - @Test -// @Ignore - public void preProcessRequest_NoAAI() { - ExecutionEntity mex = setupMock() - def data = initPreProcess(mex) - - when(mex.getVariable("rollbackAAI")).thenReturn(false) - data.put(RbType, "rollbackAAI", "false") - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) - - //verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("prefix", Prefix) - verify(mex).setVariable("serviceInstanceId", "sii") - verify(mex).setVariable("parentServiceInstanceId", "psii") - verify(mex).setVariable("allottedResourceId", "myid") - verify(mex, never()).setVariable("rollbackAAI", true) - verify(mex, never()).setVariable("aaiARPath", "mypath") - verify(mex).setVariable("rollbackSDNC", true) - verify(mex).setVariable("deactivateSdnc", "myactivate") - verify(mex).setVariable("deleteSdnc", "mycreate") - verify(mex).setVariable("unassignSdnc", "true") - verify(mex).setVariable("sdncDeactivateRequest", "activatereq") - verify(mex).setVariable("sdncDeleteRequest", "createreq") - verify(mex).setVariable("sdncUnassignRequest", "assignreq") - - verify(mex, never()).setVariable("skipRollback", true) - } - - @Test -// @Ignore - public void preProcessRequest_NoAssign() { - ExecutionEntity mex = setupMock() - def data = initPreProcess(mex) - - when(mex.getVariable("rollbackSDNC")).thenReturn(false) - data.put(RbType, "rollbackSDNCassign", "false") - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) - - //verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("prefix", Prefix) - verify(mex).setVariable("serviceInstanceId", "sii") - verify(mex).setVariable("parentServiceInstanceId", "psii") - verify(mex).setVariable("allottedResourceId", "myid") - verify(mex).setVariable("rollbackAAI", true) - verify(mex).setVariable("aaiARPath", "mypath") - verify(mex, never()).setVariable("rollbackSDNC", true) - verify(mex, never()).setVariable("deactivateSdnc", "myactivate") - verify(mex, never()).setVariable("deleteSdnc", "mycreate") - verify(mex, never()).setVariable("unassignSdnc", "true") - verify(mex, never()).setVariable("sdncDeactivateRequest", "activatereq") - verify(mex, never()).setVariable("sdncDeleteRequest", "createreq") - verify(mex, never()).setVariable("sdncUnassignRequest", "assignreq") - - verify(mex, never()).setVariable("skipRollback", true) - } - - @Test -// @Ignore - public void preProcessRequest_NoAAI_NoAssign() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - when(mex.getVariable("rollbackAAI")).thenReturn(false) - when(mex.getVariable("rollbackSDNC")).thenReturn(false) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) - - verify(mex).setVariable("skipRollback", true) - } - - @Test -// @Ignore - public void preProcessRequest_NoRbStructure() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - when(mex.getVariable("rollbackData")).thenReturn(new RollbackData()) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) - - verify(mex).setVariable("skipRollback", true) - } - - @Test -// @Ignore - public void preProcessRequest_NullRb() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - when(mex.getVariable("rollbackData")).thenReturn(null) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) - - verify(mex).setVariable("skipRollback", true) - } - - @Test -// @Ignore - public void preProcessRequest_BpmnError() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) })) - } - - @Test -// @Ignore - public void preProcessRequest_Ex() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.preProcessRequest(mex) })) - } - - @Test - @Ignore - public void updateAaiAROrchStatus() { - ExecutionEntity mex = setupMock() - initUpdateAaiAROrchStatus(mex) - - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml") - MockPatchAllottedResource(CUST, SVC, INST, ARID) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - DoCreateAllottedResourceTXCRollback.updateAaiAROrchStatus(mex, "success") - } - - @Test -// @Ignore - public void updateAaiAROrchStatus_EmptyResponse() { - ExecutionEntity mex = setupMock() - initUpdateAaiAROrchStatus(mex) - - wireMockRule - .stubFor(get(urlMatching("/aai/v[0-9]+/.*")) - .willReturn(aResponse() - .withStatus(200))) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.updateAaiAROrchStatus(mex, "success") })) - } - - @Test -// @Ignore - public void updateAaiAROrchStatus_NoArPath() { - ExecutionEntity mex = setupMock() - initUpdateAaiAROrchStatus(mex) - - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml") - MockPatchAllottedResource(CUST, SVC, INST, ARID) - - when(mex.getVariable("aaiARPath")).thenReturn(null) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.updateAaiAROrchStatus(mex, "success") })) - } - - - // ***** validateSDNCResp ***** - - @Test -// @Ignore - public void validateSDNCResp() { - ExecutionEntity mex = setupMock() - initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - - when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - - DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create") - - verify(mex).getVariable("WorkflowException") - verify(mex).getVariable("SDNCA_SuccessIndicator") - } - - @Test -// @Ignore - public void validateSDNCResp_Unsuccessful() { - ExecutionEntity mex = setupMock() - initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - - when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(false) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create") })) - } - - @Test -// @Ignore - public void validateSDNCResp_BpmnError404() { - ExecutionEntity mex = setupMock() - initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) - - when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("404", "expected exception")) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - - DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create") - } - - @Test -// @Ignore - public void validateSDNCResp_BpmnError() { - ExecutionEntity mex = setupMock() - initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) - - when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create") })) - } - - @Test -// @Ignore - public void validateSDNCResp_Ex() { - ExecutionEntity mex = setupMock() - initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) - - when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.validateSDNCResp(mex, resp, "create") })) - } - - @Test - @Ignore - public void deleteAaiAR() { - ExecutionEntity mex = setupMock() - initDeleteAaiAR(mex) - - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml") - MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - DoCreateAllottedResourceTXCRollback.deleteAaiAR(mex) - } - - @Test -// @Ignore - public void deleteAaiAR_NoArPath() { - ExecutionEntity mex = setupMock() - initDeleteAaiAR(mex) - - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml") - MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) - - when(mex.getVariable("aaiARPath")).thenReturn("") - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.deleteAaiAR(mex) })) - } - - @Test -// @Ignore - public void deleteAaiAR_BpmnError() { - ExecutionEntity mex = setupMock() - initDeleteAaiAR(mex) - - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml") - MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) - - when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.deleteAaiAR(mex) })) - } - - @Test -// @Ignore - public void deleteAaiAR_Ex() { - ExecutionEntity mex = setupMock() - initDeleteAaiAR(mex) - - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXCRollback/arGetById.xml") - MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) - - when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXCRollback.deleteAaiAR(mex) })) - } - - @Test -// @Ignore - public void postProcessRequest() { - ExecutionEntity mex = setupMock() - initPostProcessRequest(mex) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - DoCreateAllottedResourceTXCRollback.postProcessRequest(mex) - - //verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("rollbackData", null) - verify(mex).setVariable("rolledBack", true) - } - - @Test -// @Ignore - public void postProcessRequest_RolledBack() { - ExecutionEntity mex = setupMock() - initPostProcessRequest(mex) - - when(mex.getVariable("skipRollback")).thenReturn(true) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - DoCreateAllottedResourceTXCRollback.postProcessRequest(mex) - - //verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("rollbackData", null) - verify(mex, never()).setVariable("rolledBack", true) - } - - @Test -// @Ignore - public void postProcessRequest_BpmnError() { - ExecutionEntity mex = setupMock() - initPostProcessRequest(mex) - - when(mex.getVariable("skipRollback")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - DoCreateAllottedResourceTXCRollback.postProcessRequest(mex) - - //verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("rollbackData", null) - verify(mex, never()).setVariable("rolledBack", true) - } - - @Test -// @Ignore - public void postProcessRequest_Ex() { - ExecutionEntity mex = setupMock() - initPostProcessRequest(mex) - - when(mex.getVariable("skipRollback")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - DoCreateAllottedResourceTXCRollback.postProcessRequest(mex) - - //verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("rollbackData", null) - verify(mex, never()).setVariable("rolledBack", true) - } - - @Test -// @Ignore - public void processRollbackException() { - ExecutionEntity mex = setupMock() - initProcessRollbackException(mex) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - DoCreateAllottedResourceTXCRollback.processRollbackException(mex) - - //verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("rollbackData", null) - verify(mex).setVariable("rolledBack", false) - verify(mex).setVariable("rollbackError", "Caught exception in AllottedResource Create Rollback") - verify(mex).setVariable("WorkflowException", null) - } - - @Test -// @Ignore - public void processRollbackException_BpmnError() { - ExecutionEntity mex = setupMock() - initProcessRollbackException(mex) - - doThrow(new BpmnError("expected exception")).when(mex).setVariable("rollbackData", null) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - DoCreateAllottedResourceTXCRollback.processRollbackException(mex) - } - - @Test -// @Ignore - public void processRollbackException_Ex() { - ExecutionEntity mex = setupMock() - initProcessRollbackException(mex) - - doThrow(new RuntimeException("expected exception")).when(mex).setVariable("rollbackData", null) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - DoCreateAllottedResourceTXCRollback.processRollbackException(mex) - } - - @Test -// @Ignore - public void processRollbackJavaException() { - ExecutionEntity mex = setupMock() - initProcessRollbackException(mex) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - DoCreateAllottedResourceTXCRollback.processRollbackJavaException(mex) - - //verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("rollbackData", null) - verify(mex).setVariable("rolledBack", false) - verify(mex).setVariable("rollbackError", "Caught Java exception in AllottedResource Create Rollback") - verify(mex, never()).setVariable("WorkflowException", null) - } - - @Test -// @Ignore - public void processRollbackJavaException_BpmnError() { - ExecutionEntity mex = setupMock() - initProcessRollbackException(mex) - - doThrow(new BpmnError("expected exception")).when(mex).setVariable("rollbackData", null) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - DoCreateAllottedResourceTXCRollback.processRollbackJavaException(mex) - } - - @Test -// @Ignore - public void processRollbackJavaException_Ex() { - ExecutionEntity mex = setupMock() - initProcessRollbackException(mex) - - doThrow(new RuntimeException("expected exception")).when(mex).setVariable("rollbackData", null) - - DoCreateAllottedResourceTXCRollback DoCreateAllottedResourceTXCRollback = new DoCreateAllottedResourceTXCRollback() - DoCreateAllottedResourceTXCRollback.processRollbackJavaException(mex) - } - - private RollbackData initPreProcess(ExecutionEntity mex) { - def data = new RollbackData() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("rollbackData")).thenReturn(data) - when(mex.getVariable("rollbackAAI")).thenReturn(true) - when(mex.getVariable("rollbackSDNC")).thenReturn(true) - when(mex.getVariable("disableRollback")).thenReturn("false") - - data.put("SERVICEINSTANCE", "allottedResourceId", "myid") - - data.put(RbType, "serviceInstanceId", "sii") - data.put(RbType, "parentServiceInstanceId", "psii") - - data.put(RbType, "rollbackAAI", "true") - data.put(RbType, "aaiARPath", "mypath") - - data.put(RbType, "rollbackSDNCassign", "true") - data.put(RbType, "rollbackSDNCactivate", "myactivate") - data.put(RbType, "rollbackSDNCcreate", "mycreate") - data.put(RbType, "sdncActivateRollbackReq", "activatereq") - data.put(RbType, "sdncCreateRollbackReq", "createreq") - data.put(RbType, "sdncAssignRollbackReq", "assignreq") - - return data - } - - private initUpdateAaiAROrchStatus(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) - when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) - } - - private initValidateSDNCResp(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("prefix")).thenReturn(Prefix) - when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) - } - - private String initValidateSDNCResp_Resp() { - return "<response-code>200</response-code>" - } - - private initDeleteAaiAR(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("aaiARResourceVersion")).thenReturn(VERS) - when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) - when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) - } - - private initPostProcessRequest(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("skipRollback")).thenReturn(false) - } - - private initProcessRollbackException(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - } - - private initProcessRollbackJavaException(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - } - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy deleted file mode 100644 index fa40c17e63..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCTest.groovy +++ /dev/null @@ -1,957 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.vcpe.scripts - - -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.junit.Before -import org.junit.BeforeClass -import org.junit.Rule -import org.junit.Test -import org.junit.Ignore -import org.mockito.MockitoAnnotations -import org.camunda.bpm.engine.delegate.BpmnError -import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.mock.FileUtil -import org.springframework.beans.factory.config.YamlPropertiesFactoryBean -import org.springframework.core.io.ClassPathResource -import org.springframework.core.io.FileSystemResource -import org.springframework.core.io.Resource - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse -import static com.github.tomakehurst.wiremock.client.WireMock.put -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.*; -import static org.mockito.Mockito.* -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource -import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource -import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutAllottedResource -import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutAllottedResource_500 - -import java.util.Map - -import org.onap.so.bpmn.core.RollbackData -import org.onap.so.bpmn.vcpe.scripts.MapSetter - -import com.github.tomakehurst.wiremock.junit.WireMockRule - -class DoCreateAllottedResourceTXCTest extends GroovyTestBase { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(PORT) - - String Prefix = "DCARTXC_" - - @BeforeClass - public static void setUpBeforeClass() { - aaiUriPfx = UrnPropertiesReader.getVariable("aai.endpoint") - } - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - - public DoCreateAllottedResourceTXCTest() { - super("DoCreateAllottedResourceTXC") - } - - - // ***** preProcessRequest ***** - - @Test - // @Ignore - public void preProcessRequest() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - DoCreateAllottedResourceTXC.preProcessRequest(mex) - - //verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("prefix", Prefix) - - assertTrue(checkMissingPreProcessRequest("mso.workflow.sdncadapter.callback")) - assertTrue(checkMissingPreProcessRequest("mso.workflow.sdnc.replication.delay")) - assertTrue(checkMissingPreProcessRequest("serviceInstanceId")) - assertTrue(checkMissingPreProcessRequest("parentServiceInstanceId")) - assertTrue(checkMissingPreProcessRequest("allottedResourceModelInfo")) - assertTrue(checkMissingPreProcessRequest("brgWanMacAddress")) - assertTrue(checkMissingPreProcessRequest("allottedResourceRole")) - assertTrue(checkMissingPreProcessRequest("allottedResourceType")) - } - - - // ***** getAaiAR ***** - - @Test - @Ignore - public void getAaiAR() { - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml") - - ExecutionEntity mex = setupMock() - initGetAaiAR(mex) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - DoCreateAllottedResourceTXC.getAaiAR(mex) - - verify(mex).setVariable("foundActiveAR", true) - } - - @Test - // @Ignore - public void getAaiAR_Duplicate() { - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml") - - ExecutionEntity mex = setupMock() - initGetAaiAR(mex) - - // fail if duplicate - when(mex.getVariable("failExists")).thenReturn("true") - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXC.getAaiAR(mex) })) - } - - @Test - // @Ignore - public void getAaiAR_NotActive() { - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml") - - ExecutionEntity mex = setupMock() - initGetAaiAR(mex) - - // not active - when(mex.getVariable("aaiAROrchStatus")).thenReturn("not-active") - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - assertTrue(doBpmnError( { _ -> DoCreateAllottedResourceTXC.getAaiAR(mex) })) - } - - @Test - @Ignore - public void getAaiAR_NoStatus() { - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceTXC/getArTxc.xml") - - ExecutionEntity mex = setupMock() - initGetAaiAR(mex) - - when(mex.getVariable("aaiAROrchStatus")).thenReturn(null) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - DoCreateAllottedResourceTXC.getAaiAR(mex) - - verify(mex, never()).setVariable("foundActiveAR", true) - } - - - // ***** createAaiAR ***** - - @Test - @Ignore - public void createAaiAR() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initCreateAaiAr(mex) - - MockPutAllottedResource(CUST, SVC, INST, ARID) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - DoCreateAllottedResourceTXC.createAaiAR(mex) - - def data = map.get("rollbackData") - assertNotNull(data) - assertTrue(data instanceof RollbackData) - - assertEquals("45", data.get(Prefix, "disableRollback")) - assertEquals("true", data.get(Prefix, "rollbackAAI")) - assertEquals(ARID, data.get(Prefix, "allottedResourceId")) - assertEquals("sii", data.get(Prefix, "serviceInstanceId")) - assertEquals("psii", data.get(Prefix, "parentServiceInstanceId")) - assertEquals(mex.getVariable("PSI_resourceLink")+"/allotted-resources/allotted-resource/"+ARID, data.get(Prefix, "aaiARPath")) - } - - @Test - @Ignore - public void createAaiAR_NoArid_NoModelUuids() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initCreateAaiAr(mex) - - // no allottedResourceId - will be generated - - when(mex.getVariable("allottedResourceId")).thenReturn(null) - - wireMockRule - .stubFor(put(urlMatching("/aai/.*/allotted-resource/.*")) - .willReturn(aResponse() - .withStatus(200))) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - DoCreateAllottedResourceTXC.createAaiAR(mex) - - def arid = map.get("allottedResourceId") - assertNotNull(arid) - assertFalse(arid.isEmpty()) - - def data = map.get("rollbackData") - assertNotNull(data) - assertTrue(data instanceof RollbackData) - - assertEquals(arid, data.get(Prefix, "allottedResourceId")) - } - - @Test - // @Ignore - public void createAaiAR_MissingPsiLink() { - ExecutionEntity mex = setupMock() - initCreateAaiAr(mex) - - when(mex.getVariable("PSI_resourceLink")).thenReturn(null) - - MockPutAllottedResource(CUST, SVC, INST, ARID) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.createAaiAR(mex) })) - } - - @Test - // @Ignore - public void createAaiAR_HttpFailed() { - ExecutionEntity mex = setupMock() - initCreateAaiAr(mex) - - MockPutAllottedResource_500(CUST, SVC, INST, ARID) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.createAaiAR(mex) })) - } - - @Test - // @Ignore - public void createAaiAR_BpmnError() { - ExecutionEntity mex = setupMock() - initCreateAaiAr(mex) - - when(mex.getVariable("aai.endpoint")).thenThrow(new BpmnError("expected exception")) - - MockPutAllottedResource(CUST, SVC, INST, ARID) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.createAaiAR(mex) })) - } - - @Test - // @Ignore - public void createAaiAR_Ex() { - ExecutionEntity mex = setupMock() - initCreateAaiAr(mex) - - when(mex.getVariable("aai.endpoint")).thenThrow(new RuntimeException("expected exception")) - - MockPutAllottedResource(CUST, SVC, INST, ARID) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.createAaiAR(mex) })) - } - - - // ***** buildSDNCRequest ***** - - @Test - // @Ignore - public void buildSDNCRequest() { - ExecutionEntity mex = setupMock() - initBuildSDNCRequest(mex) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - String result = DoCreateAllottedResourceTXC.buildSDNCRequest(mex, "myact", "myreq") - - assertTrue(result.indexOf("myreq= 0) - assertTrue(result.indexOf("myact= 0) - assertTrue(result.indexOf("ari= 0) - assertTrue(result.indexOf("sii= 0) - assertTrue(result.indexOf("sii= 0) - assertTrue(result.indexOf("psii= 0) - assertTrue(result.indexOf("sst= 0) - assertTrue(result.indexOf("gci= 0) - assertTrue(result.indexOf("scu= 0) - assertTrue(result.indexOf("mri= 0) - assertTrue(result.indexOf("") >= 0) - assertTrue(result.indexOf("") >= 0) - assertTrue(result.indexOf("") >= 0) - assertTrue(result.indexOf("") >= 0) - assertTrue(result.indexOf("") >= 0) - } - - @Test - // @Ignore - public void buildSDNCRequest_Ex() { - ExecutionEntity mex = setupMock() - initBuildSDNCRequest(mex) - - when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.buildSDNCRequest(mex, "myact", "myreq") })) - } - - - // ***** preProcessSDNCAssign ***** - - @Test - // @Ignore - public void preProcessSDNCAssign() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - def data = initPreProcessSDNC(mex) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - DoCreateAllottedResourceTXC.preProcessSDNCAssign(mex) - - def req = map.get("sdncAssignRequest") - assertNotNull(req) - - assertEquals(data, map.get("rollbackData")) - - def rbreq = data.get(Prefix, "sdncAssignRollbackReq") - - assertTrue(req.indexOf("assign= 0) - assertTrue(req.indexOf("CreateTunnelXConnInstance= 0) - assertTrue(req.indexOf("") >= 0) - - assertTrue(rbreq.indexOf("unassign= 0) - assertTrue(rbreq.indexOf("DeleteTunnelXConnInstance= 0) - assertTrue(rbreq.indexOf("") >= 0) - } - - @Test - // @Ignore - public void preProcessSDNCAssign_BpmnError() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCAssign(mex) })) - } - - @Test - // @Ignore - public void preProcessSDNCAssign_Ex() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCAssign(mex) })) - } - - - // ***** preProcessSDNCCreate ***** - - @Test - // @Ignore - public void preProcessSDNCCreate() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - def data = initPreProcessSDNC(mex) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - DoCreateAllottedResourceTXC.preProcessSDNCCreate(mex) - - def req = map.get("sdncCreateRequest") - assertNotNull(req) - - assertEquals(data, map.get("rollbackData")) - - def rbreq = data.get(Prefix, "sdncCreateRollbackReq") - - assertTrue(req.indexOf("create= 0) - assertTrue(req.indexOf("CreateTunnelXConnInstance= 0) - assertTrue(req.indexOf("") >= 0) - - assertTrue(rbreq.indexOf("delete= 0) - assertTrue(rbreq.indexOf("DeleteTunnelXConnInstance= 0) - assertTrue(rbreq.indexOf("") >= 0) - - } - - @Test - // @Ignore - public void preProcessSDNCCreate_BpmnError() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCCreate(mex) })) - } - - @Test - // @Ignore - public void preProcessSDNCCreate_Ex() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCCreate(mex) })) - } - - - // ***** preProcessSDNCActivate ***** - - @Test - // @Ignore - public void preProcessSDNCActivate() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - def data = initPreProcessSDNC(mex) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - DoCreateAllottedResourceTXC.preProcessSDNCActivate(mex) - - def req = map.get("sdncActivateRequest") - assertNotNull(req) - - assertEquals(data, map.get("rollbackData")) - - def rbreq = data.get(Prefix, "sdncActivateRollbackReq") - - assertTrue(req.indexOf("activate= 0) - assertTrue(req.indexOf("CreateTunnelXConnInstance= 0) - assertTrue(req.indexOf("") >= 0) - - assertTrue(rbreq.indexOf("deactivate= 0) - assertTrue(rbreq.indexOf("DeleteTunnelXConnInstance= 0) - assertTrue(rbreq.indexOf("") >= 0) - - } - - @Test - // @Ignore - public void preProcessSDNCActivate_BpmnError() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("rollbackData")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCActivate(mex) })) - } - - @Test - // @Ignore - public void preProcessSDNCActivate_Ex() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("rollbackData")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCActivate(mex) })) - } - - - // ***** validateSDNCResp ***** - - @Test - // @Ignore - public void validateSDNCResp() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - def data = initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - - when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "create") - - verify(mex).getVariable("WorkflowException") - verify(mex).getVariable("SDNCA_SuccessIndicator") - verify(mex).getVariable("rollbackData") - - assertEquals(data, map.get("rollbackData")) - - assertEquals("true", data.get(Prefix, "rollback" + "SDNCcreate")) - - } - - @Test - // @Ignore - public void validateSDNCResp_Get() { - ExecutionEntity mex = setupMock() - def data = initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - - when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "get") - - verify(mex).getVariable("WorkflowException") - verify(mex).getVariable("SDNCA_SuccessIndicator") - - verify(mex, never()).getVariable("rollbackData") - } - - @Test - // @Ignore - public void validateSDNCResp_Unsuccessful() { - ExecutionEntity mex = setupMock() - initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - - // unsuccessful - when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(false) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "create") })) - } - - @Test - // @Ignore - public void validateSDNCResp_BpmnError() { - ExecutionEntity mex = setupMock() - initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - - when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "create") })) - } - - @Test - // @Ignore - public void validateSDNCResp_Ex() { - ExecutionEntity mex = setupMock() - initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp() - - when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.validateSDNCResp(mex, resp, "create") })) - } - - - // ***** preProcessSDNCGet ***** - - @Test - // @Ignore - public void preProcessSDNCGet_FoundAR() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcessSDNCGet(mex) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - DoCreateAllottedResourceTXC.preProcessSDNCGet(mex) - - String req = map.get("sdncGetRequest") - - assertTrue(req.indexOf("") >= 0) - assertTrue(req.indexOf("sii= 0) - assertTrue(req.indexOf("arlink= 0) - assertTrue(req.indexOf("myurl= 0) - - } - - @Test - // @Ignore - public void preProcessSDNCGet_NotFoundAR() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcessSDNCGet(mex) - - when(mex.getVariable("foundActiveAR")).thenReturn(false) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - DoCreateAllottedResourceTXC.preProcessSDNCGet(mex) - - String req = map.get("sdncGetRequest") - - assertTrue(req.indexOf("") >= 0) - assertTrue(req.indexOf("sii= 0) - assertTrue(req.indexOf("assignlink= 0) - assertTrue(req.indexOf("myurl= 0) - - } - - @Test - // @Ignore - public void preProcessSDNCGet_Ex() { - ExecutionEntity mex = setupMock() - initPreProcessSDNCGet(mex) - - when(mex.getVariable("foundActiveAR")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.preProcessSDNCGet(mex) })) - } - - - // ***** updateAaiAROrchStatus ***** - - @Test - @Ignore - public void updateAaiAROrchStatus() { - MockPatchAllottedResource(CUST, SVC, INST, ARID) - - ExecutionEntity mex = setupMock() - initUpdateAaiAROrchStatus(mex) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - DoCreateAllottedResourceTXC.updateAaiAROrchStatus(mex, "success") - } - - - // ***** generateOutputs ***** - - @Test - // @Ignore - public void generateOutputs() { - ExecutionEntity mex = setupMock() - def txctop = FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXC/SDNCTopologyQueryCallback.xml") - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("enhancedCallbackRequestData")).thenReturn(txctop) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - DoCreateAllottedResourceTXC.generateOutputs(mex) - - verify(mex).setVariable("allotedResourceName", "namefromrequest") - verify(mex).setVariable("vni", "my-vni") - verify(mex).setVariable("vgmuxBearerIP", "my-bearer-ip") - verify(mex).setVariable("vgmuxLanIP", "my-lan-ip") - - } - - @Test - // @Ignore - public void generateOutputs_BadXml() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("enhancedCallbackRequestData")).thenReturn("invalid xml") - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - DoCreateAllottedResourceTXC.generateOutputs(mex) - - verify(mex, never()).setVariable(anyString(), anyString()) - - } - - @Test - // @Ignore - public void generateOutputs_BpmnError() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - DoCreateAllottedResourceTXC.generateOutputs(mex) - verify(mex, never()).setVariable(anyString(), anyString()) - - } - - @Test - // @Ignore - public void generateOutputs_Ex() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("enhancedCallbackRequestData")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - DoCreateAllottedResourceTXC.generateOutputs(mex) - verify(mex, never()).setVariable(anyString(), anyString()) - - } - - - // ***** preProcessRollback ***** - - @Test - // @Ignore - public void preProcessRollback() { - ExecutionEntity mex = setupMock() - WorkflowException wfe = mock(WorkflowException.class) - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("WorkflowException")).thenReturn(wfe) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - DoCreateAllottedResourceTXC.preProcessRollback(mex) - - verify(mex).setVariable("prevWorkflowException", wfe) - - } - - @Test - // @Ignore - public void preProcessRollback_NotWFE() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("WorkflowException")).thenReturn("I'm not a WFE") - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - DoCreateAllottedResourceTXC.preProcessRollback(mex) - -// verify(mex, never()).setVariable("prevWorkflowException", any()) - - } - - @Test - // @Ignore - public void preProcessRollback_BpmnError() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - DoCreateAllottedResourceTXC.preProcessRollback(mex) - - } - - @Test - // @Ignore - public void preProcessRollback_Ex() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - DoCreateAllottedResourceTXC.preProcessRollback(mex) - - } - - - // ***** postProcessRollback ***** - - @Test - // @Ignore - public void postProcessRollback() { - ExecutionEntity mex = setupMock() - WorkflowException wfe = mock(WorkflowException.class) - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("prevWorkflowException")).thenReturn(wfe) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - DoCreateAllottedResourceTXC.postProcessRollback(mex) - - verify(mex).setVariable("WorkflowException", wfe) - verify(mex).setVariable("rollbackData", null) - - } - - @Test - // @Ignore - public void postProcessRollback_NotWFE() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("prevWorkflowException")).thenReturn("I'm not a WFE") - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - DoCreateAllottedResourceTXC.postProcessRollback(mex) - -// verify(mex, never()).setVariable("WorkflowException", any()) - verify(mex).setVariable("rollbackData", null) - - } - - @Test - // @Ignore - public void postProcessRollback_BpmnError() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("prevWorkflowException")).thenThrow(new BpmnError("expected exception")) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoCreateAllottedResourceTXC.postProcessRollback(mex) })) - verify(mex, never()).setVariable("rollbackData", null) - - } - - @Test - // @Ignore - public void postProcessRollback_Ex() { - ExecutionEntity mex = setupMock() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("prevWorkflowException")).thenThrow(new RuntimeException("expected exception")) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - DoCreateAllottedResourceTXC.postProcessRollback(mex) - verify(mex, never()).setVariable("rollbackData", null) - - } - - private boolean checkMissingPreProcessRequest(String fieldnm) { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - DoCreateAllottedResourceTXC DoCreateAllottedResourceTXC = new DoCreateAllottedResourceTXC() - - when(mex.getVariable(fieldnm)).thenReturn("") - - return doBpmnError( { _ -> DoCreateAllottedResourceTXC.preProcessRequest(mex) }) - } - - private void initPreProcess(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("sdncurn") - when(mex.getVariable("mso.workflow.sdnc.replication.delay")).thenReturn("sdncdelay") - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") - when(mex.getVariable("allottedResourceModelInfo")).thenReturn("armi") - when(mex.getVariable("brgWanMacAddress")).thenReturn("bwma") - when(mex.getVariable("allottedResourceRole")).thenReturn("arr") - when(mex.getVariable("allottedResourceType")).thenReturn("art") - } - - private void initGetAaiAR(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("allottedResourceType")).thenReturn("TXCt") - when(mex.getVariable("allottedResourceRole")).thenReturn("TXCr") - when(mex.getVariable("CSI_service")).thenReturn(FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXC/getAR.xml")) - when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) - when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active") - } - - private initCreateAaiAr(ExecutionEntity mex) { - when(mex.getVariable("disableRollback")).thenReturn(45) - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("allottedResourceId")).thenReturn(ARID) - when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) - when(mex.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.namespace")) - when(mex.getVariable("PSI_resourceLink")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST) - when(mex.getVariable("allottedResourceType")).thenReturn("TXCt") - when(mex.getVariable("allottedResourceRole")).thenReturn("TXCr") - when(mex.getVariable("CSI_resourceLink")).thenReturn(aaiUriPfx+"/aai/v9/mycsi") - when(mex.getVariable("allottedResourceModelInfo")).thenReturn(""" - { - "modelInvariantUuid":"modelinvuuid", - "modelUuid":"modeluuid", - "modelCustomizationUuid":"modelcustuuid" - } - """) - } - - private initBuildSDNCRequest(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("allottedResourceId")).thenReturn("ari") - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") - when(mex.getVariable("subscriptionServiceType")).thenReturn("sst") - when(mex.getVariable("globalCustomerId")).thenReturn("gci") - when(mex.getVariable("sdncCallbackUrl")).thenReturn("scu") - when(mex.getVariable("msoRequestId")).thenReturn("mri") - } - - private RollbackData initPreProcessSDNC(ExecutionEntity mex) { - def data = new RollbackData() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("rollbackData")).thenReturn(data) - - return data - } - - private initPreProcessSDNCGet(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl") - when(mex.getVariable("foundActiveAR")).thenReturn(true) - when(mex.getVariable("aaiARGetResponse")).thenReturn("arlink") - when(mex.getVariable("sdncAssignResponse")).thenReturn("<object-path>assignlink</object-path>") - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - when(mex.getVariable("sdncCallbackUrl")).thenReturn("myurl") - } - - private RollbackData initValidateSDNCResp(ExecutionEntity mex) { - def data = new RollbackData() - - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("prefix")).thenReturn(Prefix) - when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) - when(mex.getVariable("rollbackData")).thenReturn(data) - - return data - } - - private String initValidateSDNCResp_Resp() { - return "<response-code>200</response-code>" - } - - private initUpdateAaiAROrchStatus(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) - } - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy deleted file mode 100644 index e8004d3d2b..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRGTest.groovy +++ /dev/null @@ -1,606 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.vcpe.scripts - - -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.junit.Before -import org.junit.BeforeClass -import org.junit.Rule -import org.junit.Test -import org.junit.Ignore -import org.mockito.MockitoAnnotations -import org.camunda.bpm.engine.delegate.BpmnError -import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.mock.FileUtil - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse -import static com.github.tomakehurst.wiremock.client.WireMock.delete -import static com.github.tomakehurst.wiremock.client.WireMock.get -import static com.github.tomakehurst.wiremock.client.WireMock.patch -import static com.github.tomakehurst.wiremock.client.WireMock.put -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.*; -import static org.mockito.Mockito.* -import static org.onap.so.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource -import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource -import static org.onap.so.bpmn.mock.StubResponseAAI.MockQueryAllottedResourceById - -import java.util.Map - -import org.onap.so.bpmn.core.RollbackData -import org.onap.so.bpmn.vcpe.scripts.MapSetter - -import com.github.tomakehurst.wiremock.junit.WireMockRule - -class DoDeleteAllottedResourceBRGTest extends GroovyTestBase { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(PORT) - - String Prefix = "DDARBRG_" - - @BeforeClass - public static void setUpBeforeClass() { - super.setUpBeforeClass() - } - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - - public DoDeleteAllottedResourceBRGTest() { - super("DoDeleteAllottedResourceBRG") - } - - - // ***** preProcessRequest ***** - - @Test -// @Ignore - public void preProcessRequest() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - DoDeleteAllottedResourceBRG.preProcessRequest(mex) - - //verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("prefix", Prefix) - verify(mex).setVariable("sdncCallbackUrl", "sdncurn") - - assertTrue(checkMissingPreProcessRequest("mso.workflow.sdncadapter.callback")) - assertTrue(checkMissingPreProcessRequest("serviceInstanceId")) - assertTrue(checkMissingPreProcessRequest("allottedResourceId")) - } - - @Test -// @Ignore - public void preProcessRequest_BpmnError() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - when(mex.getVariable("serviceInstanceId")).thenThrow(new BpmnError("expected exception")) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - - assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.preProcessRequest(mex) })) - } - - @Test -// @Ignore - public void preProcessRequest_Ex() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - when(mex.getVariable("serviceInstanceId")).thenThrow(new RuntimeException("expected exception")) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - - assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.preProcessRequest(mex) })) - } - - - // ***** getAaiAR ***** - - @Test - @Ignore - public void getAaiAR() { - MockQueryAllottedResourceById(ARID, "GenericFlows/getARUrlById.xml") - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml") - - ExecutionEntity mex = setupMock() - initGetAaiAR(mex) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - DoDeleteAllottedResourceBRG.getAaiAR(mex) - - verify(mex).setVariable("parentServiceInstanceId", INST) - } - - @Test -// @Ignore - public void getAaiAR_EmptyResponse() { - - // note: empty result-link - wireMockRule - .stubFor(get(urlMatching("/aai/.*/search/.*")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBody(""))) - - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml") - - ExecutionEntity mex = setupMock() - initGetAaiAR(mex) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - - assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.getAaiAR(mex) })) - } - - - // ***** updateAaiAROrchStatus ***** - - @Test - @Ignore - public void updateAaiAROrchStatus() { - ExecutionEntity mex = setupMock() - initUpdateAaiAROrchStatus(mex) - - MockPatchAllottedResource(CUST, SVC, INST, ARID) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - DoDeleteAllottedResourceBRG.updateAaiAROrchStatus(mex, "success") - } - - - // ***** buildSDNCRequest ***** - - @Test -// @Ignore - public void buildSDNCRequest() { - ExecutionEntity mex = setupMock() - initBuildSDNCRequest(mex) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - - String result = DoDeleteAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") - - assertTrue(result.indexOf("myreq= 0) - assertTrue(result.indexOf("myact= 0) - assertTrue(result.indexOf("ari= 0) - assertTrue(result.indexOf("sii= 0) - assertTrue(result.indexOf("sii= 0) - assertTrue(result.indexOf("psii= 0) - assertTrue(result.indexOf("sst= 0) - assertTrue(result.indexOf("gci= 0) - assertTrue(result.indexOf("scu= 0) - assertTrue(result.indexOf("mri= 0) - assertTrue(result.indexOf("") >= 0) - assertTrue(result.indexOf("") >= 0) - assertTrue(result.indexOf("") >= 0) - assertTrue(result.indexOf("") >= 0) - assertTrue(result.indexOf("") >= 0) - } - - @Test -// @Ignore - public void buildSDNCRequest_Ex() { - ExecutionEntity mex = setupMock() - initBuildSDNCRequest(mex) - - when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.buildSDNCRequest(mex, "myact", "myreq") })) - } - - - // ***** preProcessSDNCUnassign ***** - - @Test -// @Ignore - public void preProcessSDNCUnassign() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcessSDNC(mex) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - DoDeleteAllottedResourceBRG.preProcessSDNCUnassign(mex) - - def req = map.get("sdncUnassignRequest") - - assertTrue(req.indexOf("unassign= 0) - assertTrue(req.indexOf("DeleteBRGInstance= 0) - assertTrue(req.indexOf("") >= 0) - } - - @Test -// @Ignore - public void preProcessSDNCUnassign_BpmnError() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception")) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCUnassign(mex) })) - } - - @Test -// @Ignore - public void preProcessSDNCUnassign_Ex() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCUnassign(mex) })) - } - - - // ***** preProcessSDNCDelete ***** - - @Test -// @Ignore - public void preProcessSDNCDelete() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcessSDNC(mex) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - DoDeleteAllottedResourceBRG.preProcessSDNCDelete(mex) - - def req = map.get("sdncDeleteRequest") - - assertTrue(req.indexOf("delete= 0) - assertTrue(req.indexOf("DeleteBRGInstance= 0) - assertTrue(req.indexOf("") >= 0) - } - - @Test -// @Ignore - public void preProcessSDNCDelete_BpmnError() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception")) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDelete(mex) })) - } - - @Test -// @Ignore - public void preProcessSDNCDelete_Ex() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDelete(mex) })) - } - - - // ***** preProcessSDNCDeactivate ***** - - @Test -// @Ignore - public void preProcessSDNCDeactivate() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcessSDNC(mex) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - DoDeleteAllottedResourceBRG.preProcessSDNCDeactivate(mex) - - def req = map.get("sdncDeactivateRequest") - - assertTrue(req.indexOf("deactivate= 0) - assertTrue(req.indexOf("DeleteBRGInstance= 0) - assertTrue(req.indexOf("") >= 0) - } - - @Test -// @Ignore - public void preProcessSDNCDeactivate_BpmnError() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception")) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDeactivate(mex) })) - } - - @Test -// @Ignore - public void preProcessSDNCDeactivate_Ex() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.preProcessSDNCDeactivate(mex) })) - } - - - // ***** validateSDNCResp ***** - - @Test -// @Ignore - public void validateSDNCResp() { - ExecutionEntity mex = setupMock() - def data = initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp(200) - - when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - - DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create") - - verify(mex).getVariable("WorkflowException") - verify(mex).getVariable("SDNCA_SuccessIndicator") - verify(mex).getVariable(Prefix+"sdncResponseSuccess") - - verify(mex, never()).getVariable(Prefix + "sdncRequestDataResponseCode") - verify(mex, never()).setVariable("wasDeleted", false) - } - - @Test -// @Ignore - public void validateSDNCResp_Fail404_Deactivate_FailNotFound() { - ExecutionEntity mex = setupMock() - def data = initValidateSDNCResp(mex) - - def resp = initValidateSDNCResp_Resp(404) - when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404") - when(mex.getVariable("failNotFound")).thenReturn("true") - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - - assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "deactivate")})) - } - - @Test -// @Ignore - public void validateSDNCResp_Fail404_Deactivate() { - ExecutionEntity mex = setupMock() - def data = initValidateSDNCResp(mex) - - def resp = initValidateSDNCResp_Resp(404) - when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404") - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - - DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "deactivate") - - verify(mex).setVariable("ARNotFoundInSDNC", true) - verify(mex).setVariable("wasDeleted", false) - } - - @Test -// @Ignore - public void validateSDNCResp_Fail404() { - ExecutionEntity mex = setupMock() - def data = initValidateSDNCResp(mex) - - def resp = initValidateSDNCResp_Resp(404) - when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404") - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - - assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create")})) - } - - @Test -// @Ignore - public void validateSDNCResp_Deactivate() { - ExecutionEntity mex = setupMock() - def data = initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp(200) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - - assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "deactivate")})) - } - - @Test -// @Ignore - public void validateSDNCResp_BpmnError() { - ExecutionEntity mex = setupMock() - initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp(200) - - when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create") })) - } - - @Test -// @Ignore - public void validateSDNCResp_Ex() { - ExecutionEntity mex = setupMock() - initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp(200) - - when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - - assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceBRG.validateSDNCResp(mex, resp, "create") })) - } - - @Test - @Ignore - public void deleteAaiAR() { - ExecutionEntity mex = setupMock() - initDeleteAaiAR(mex) - - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml") - MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - DoDeleteAllottedResourceBRG.deleteAaiAR(mex) - } - - @Test -// @Ignore - public void deleteAaiAR_NoArPath() { - ExecutionEntity mex = setupMock() - initDeleteAaiAR(mex) - - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml") - MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) - - when(mex.getVariable("aaiARPath")).thenReturn("") - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - - assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.deleteAaiAR(mex) })) - } - - @Test -// @Ignore - public void deleteAaiAR_BpmnError() { - ExecutionEntity mex = setupMock() - initDeleteAaiAR(mex) - - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml") - MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) - - when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception")) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - - assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.deleteAaiAR(mex) })) - } - - @Test -// @Ignore - public void deleteAaiAR_Ex() { - ExecutionEntity mex = setupMock() - initDeleteAaiAR(mex) - - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceBRG/arGetById.xml") - MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) - - when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception")) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - - assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceBRG.deleteAaiAR(mex) })) - } - - private boolean checkMissingPreProcessRequest(String fieldnm) { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - DoDeleteAllottedResourceBRG DoDeleteAllottedResourceBRG = new DoDeleteAllottedResourceBRG() - - when(mex.getVariable(fieldnm)).thenReturn("") - - return doBpmnError( { _ -> DoDeleteAllottedResourceBRG.preProcessRequest(mex) }) - } - - private void initPreProcess(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("sdncurn") - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - when(mex.getVariable("allottedResourceId")).thenReturn("ari") - } - - private void initGetAaiAR(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("allottedResourceType")).thenReturn("BRG") - when(mex.getVariable("allottedResourceRole")).thenReturn("BRG") - when(mex.getVariable("allottedResourceId")).thenReturn(ARID) - when(mex.getVariable("CSI_service")).thenReturn(FileUtil.readResourceFile("__files/VCPE/DoDeleteAllottedResourceBRG/getAR.xml")) - when(mex.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.namespace")) - when(mex.getVariable("mso.workflow.global.default.aai.version")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.version")) - when(mex.getVariable("mso.workflow.default.aai.v8.nodes.query.uri")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.default.aai.v8.nodes-query.uri")) - when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) - when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) - when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active") - } - - private initUpdateAaiAROrchStatus(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) - } - - private initBuildSDNCRequest(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("allottedResourceId")).thenReturn("ari") - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") - when(mex.getVariable("subscriptionServiceType")).thenReturn("sst") - when(mex.getVariable("globalCustomerId")).thenReturn("gci") - when(mex.getVariable("sdncCallbackUrl")).thenReturn("scu") - when(mex.getVariable("msoRequestId")).thenReturn("mri") - } - - private initPreProcessSDNC(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - } - - private initValidateSDNCResp(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("prefix")).thenReturn(Prefix) - when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) - } - - private String initValidateSDNCResp_Resp(int code) { - return "<response-code>${code}</response-code>" - } - - private initDeleteAaiAR(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) - when(mex.getVariable("aaiARResourceVersion")).thenReturn("myvers") - when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) - } - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy deleted file mode 100644 index 6719be17a1..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXCTest.groovy +++ /dev/null @@ -1,607 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.vcpe.scripts - - -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.junit.Before -import org.junit.BeforeClass -import org.junit.Rule -import org.junit.Test -import org.junit.Ignore -import org.mockito.MockitoAnnotations -import org.camunda.bpm.engine.delegate.BpmnError -import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.mock.FileUtil - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse -import static com.github.tomakehurst.wiremock.client.WireMock.delete -import static com.github.tomakehurst.wiremock.client.WireMock.get -import static com.github.tomakehurst.wiremock.client.WireMock.patch -import static com.github.tomakehurst.wiremock.client.WireMock.put -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.*; -import static org.mockito.Mockito.* -import static org.onap.so.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource -import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource -import static org.onap.so.bpmn.mock.StubResponseAAI.MockQueryAllottedResourceById - - -import java.util.Map - -import org.onap.so.bpmn.core.RollbackData -import org.onap.so.bpmn.vcpe.scripts.MapSetter - -import com.github.tomakehurst.wiremock.junit.WireMockRule - -class DoDeleteAllottedResourceTXCTest extends GroovyTestBase { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(PORT) - - String Prefix = "DDARTXC_" - - @BeforeClass - public static void setUpBeforeClass() { - super.setUpBeforeClass() - } - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - - public DoDeleteAllottedResourceTXCTest() { - super("DoDeleteAllottedResourceTXC") - } - - - // ***** preProcessRequest ***** - - @Test -// @Ignore - public void preProcessRequest() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - DoDeleteAllottedResourceTXC.preProcessRequest(mex) - - //verify(mex).getVariable(DBGFLAG) - verify(mex).setVariable("prefix", Prefix) - verify(mex).setVariable("sdncCallbackUrl", "sdncurn") - - assertTrue(checkMissingPreProcessRequest("mso.workflow.sdncadapter.callback")) - assertTrue(checkMissingPreProcessRequest("serviceInstanceId")) - assertTrue(checkMissingPreProcessRequest("allottedResourceId")) - } - - @Test -// @Ignore - public void preProcessRequest_BpmnError() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - when(mex.getVariable("serviceInstanceId")).thenThrow(new BpmnError("expected exception")) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - - assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.preProcessRequest(mex) })) - } - - @Test -// @Ignore - public void preProcessRequest_Ex() { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - when(mex.getVariable("serviceInstanceId")).thenThrow(new RuntimeException("expected exception")) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - - assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.preProcessRequest(mex) })) - } - - - // ***** getAaiAR ***** - - @Test - @Ignore - public void getAaiAR() { - MockQueryAllottedResourceById(ARID, "GenericFlows/getARUrlById.xml") - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml") - - ExecutionEntity mex = setupMock() - initGetAaiAR(mex) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - DoDeleteAllottedResourceTXC.getAaiAR(mex) - - verify(mex).setVariable("parentServiceInstanceId", INST) - } - - @Test -// @Ignore - public void getAaiAR_EmptyResponse() { - - // note: empty result-link - wireMockRule - .stubFor(get(urlMatching("/aai/.*/search/.*")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBody(""))) - - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml") - - ExecutionEntity mex = setupMock() - initGetAaiAR(mex) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - - assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.getAaiAR(mex) })) - } - - - // ***** updateAaiAROrchStatus ***** - - @Test - @Ignore - public void updateAaiAROrchStatus() { - ExecutionEntity mex = setupMock() - initUpdateAaiAROrchStatus(mex) - - MockPatchAllottedResource(CUST, SVC, INST, ARID) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - DoDeleteAllottedResourceTXC.updateAaiAROrchStatus(mex, "success") - } - - - // ***** buildSDNCRequest ***** - - @Test -// @Ignore - public void buildSDNCRequest() { - ExecutionEntity mex = setupMock() - initBuildSDNCRequest(mex) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - - String result = DoDeleteAllottedResourceTXC.buildSDNCRequest(mex, "myact", "myreq") - - assertTrue(result.indexOf("myreq= 0) - assertTrue(result.indexOf("myact= 0) - assertTrue(result.indexOf("ari= 0) - assertTrue(result.indexOf("sii= 0) - assertTrue(result.indexOf("sii= 0) - assertTrue(result.indexOf("psii= 0) - assertTrue(result.indexOf("sst= 0) - assertTrue(result.indexOf("gci= 0) - assertTrue(result.indexOf("scu= 0) - assertTrue(result.indexOf("mri= 0) - assertTrue(result.indexOf("") >= 0) - assertTrue(result.indexOf("") >= 0) - assertTrue(result.indexOf("") >= 0) - assertTrue(result.indexOf("") >= 0) - assertTrue(result.indexOf("") >= 0) - } - - @Test -// @Ignore - public void buildSDNCRequest_Ex() { - ExecutionEntity mex = setupMock() - initBuildSDNCRequest(mex) - - when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.buildSDNCRequest(mex, "myact", "myreq") })) - } - - - // ***** preProcessSDNCUnassign ***** - - @Test -// @Ignore - public void preProcessSDNCUnassign() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcessSDNC(mex) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - DoDeleteAllottedResourceTXC.preProcessSDNCUnassign(mex) - - def req = map.get("sdncUnassignRequest") - - assertTrue(req.indexOf("unassign= 0) - assertTrue(req.indexOf("DeleteTunnelXConnInstance= 0) - assertTrue(req.indexOf("") >= 0) - } - - @Test -// @Ignore - public void preProcessSDNCUnassign_BpmnError() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception")) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCUnassign(mex) })) - } - - @Test -// @Ignore - public void preProcessSDNCUnassign_Ex() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCUnassign(mex) })) - } - - - // ***** preProcessSDNCDelete ***** - - @Test -// @Ignore - public void preProcessSDNCDelete() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcessSDNC(mex) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - DoDeleteAllottedResourceTXC.preProcessSDNCDelete(mex) - - def req = map.get("sdncDeleteRequest") - - assertTrue(req.indexOf("delete= 0) - assertTrue(req.indexOf("DeleteTunnelXConnInstance= 0) - assertTrue(req.indexOf("") >= 0) - } - - @Test -// @Ignore - public void preProcessSDNCDelete_BpmnError() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception")) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCDelete(mex) })) - } - - @Test -// @Ignore - public void preProcessSDNCDelete_Ex() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCDelete(mex) })) - } - - - // ***** preProcessSDNCDeactivate ***** - - @Test -// @Ignore - public void preProcessSDNCDeactivate() { - ExecutionEntity mex = setupMock() - def map = setupMap(mex) - initPreProcessSDNC(mex) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - DoDeleteAllottedResourceTXC.preProcessSDNCDeactivate(mex) - - def req = map.get("sdncDeactivateRequest") - - assertTrue(req.indexOf("deactivate= 0) - assertTrue(req.indexOf("DeleteTunnelXConnInstance= 0) - assertTrue(req.indexOf("") >= 0) - } - - @Test -// @Ignore - public void preProcessSDNCDeactivate_BpmnError() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("allottedResourceId")).thenThrow(new BpmnError("expected exception")) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCDeactivate(mex) })) - } - - @Test -// @Ignore - public void preProcessSDNCDeactivate_Ex() { - ExecutionEntity mex = setupMock() - initPreProcessSDNC(mex) - - when(mex.getVariable("allottedResourceId")).thenThrow(new RuntimeException("expected exception")) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.preProcessSDNCDeactivate(mex) })) - } - - - // ***** validateSDNCResp ***** - - @Test -// @Ignore - public void validateSDNCResp() { - ExecutionEntity mex = setupMock() - def data = initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp(200) - - when(mex.getVariable(Prefix+"sdncResponseSuccess")).thenReturn(true) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - - DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "create") - - verify(mex).getVariable("WorkflowException") - verify(mex).getVariable("SDNCA_SuccessIndicator") - verify(mex).getVariable(Prefix+"sdncResponseSuccess") - - verify(mex, never()).getVariable(Prefix + "sdncRequestDataResponseCode") - verify(mex, never()).setVariable("wasDeleted", false) - } - - @Test -// @Ignore - public void validateSDNCResp_Fail404_Deactivate_FailNotFound() { - ExecutionEntity mex = setupMock() - def data = initValidateSDNCResp(mex) - - def resp = initValidateSDNCResp_Resp(404) - when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404") - when(mex.getVariable("failNotFound")).thenReturn("true") - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - - assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "deactivate")})) - } - - @Test -// @Ignore - public void validateSDNCResp_Fail404_Deactivate() { - ExecutionEntity mex = setupMock() - def data = initValidateSDNCResp(mex) - - def resp = initValidateSDNCResp_Resp(404) - when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404") - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - - DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "deactivate") - - verify(mex).setVariable("ARNotFoundInSDNC", true) - verify(mex).setVariable("wasDeleted", false) - } - - @Test -// @Ignore - public void validateSDNCResp_Fail404() { - ExecutionEntity mex = setupMock() - def data = initValidateSDNCResp(mex) - - def resp = initValidateSDNCResp_Resp(404) - when(mex.getVariable(Prefix+"sdncRequestDataResponseCode")).thenReturn("404") - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - - assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "create")})) - } - - @Test -// @Ignore - public void validateSDNCResp_Deactivate() { - ExecutionEntity mex = setupMock() - def data = initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp(200) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - - assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "deactivate")})) - } - - @Test -// @Ignore - public void validateSDNCResp_BpmnError() { - ExecutionEntity mex = setupMock() - initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp(200) - - when(mex.getVariable("WorkflowException")).thenThrow(new BpmnError("expected exception")) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "create") })) - } - - @Test -// @Ignore - public void validateSDNCResp_Ex() { - ExecutionEntity mex = setupMock() - initValidateSDNCResp(mex) - def resp = initValidateSDNCResp_Resp(200) - - when(mex.getVariable("WorkflowException")).thenThrow(new RuntimeException("expected exception")) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - - assertTrue(doBpmnError({ _ -> DoDeleteAllottedResourceTXC.validateSDNCResp(mex, resp, "create") })) - } - - @Test - @Ignore - public void deleteAaiAR() { - ExecutionEntity mex = setupMock() - initDeleteAaiAR(mex) - - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml") - MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - DoDeleteAllottedResourceTXC.deleteAaiAR(mex) - } - - @Test -// @Ignore - public void deleteAaiAR_NoArPath() { - ExecutionEntity mex = setupMock() - initDeleteAaiAR(mex) - - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml") - MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) - - when(mex.getVariable("aaiARPath")).thenReturn("") - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - - assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.deleteAaiAR(mex) })) - } - - @Test -// @Ignore - public void deleteAaiAR_BpmnError() { - ExecutionEntity mex = setupMock() - initDeleteAaiAR(mex) - - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml") - MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) - - when(mex.getVariable("aaiARPath")).thenThrow(new BpmnError("expected exception")) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - - assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.deleteAaiAR(mex) })) - } - - @Test -// @Ignore - public void deleteAaiAR_Ex() { - ExecutionEntity mex = setupMock() - initDeleteAaiAR(mex) - - MockGetAllottedResource(CUST, SVC, INST, ARID, "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml") - MockDeleteAllottedResource(CUST, SVC, INST, ARID, VERS) - - when(mex.getVariable("aaiARPath")).thenThrow(new RuntimeException("expected exception")) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - - assertTrue(doBpmnError( { _ -> DoDeleteAllottedResourceTXC.deleteAaiAR(mex) })) - } - - private boolean checkMissingPreProcessRequest(String fieldnm) { - ExecutionEntity mex = setupMock() - initPreProcess(mex) - - DoDeleteAllottedResourceTXC DoDeleteAllottedResourceTXC = new DoDeleteAllottedResourceTXC() - - when(mex.getVariable(fieldnm)).thenReturn("") - - return doBpmnError( { _ -> DoDeleteAllottedResourceTXC.preProcessRequest(mex) }) - } - - private void initPreProcess(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("sdncurn") - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - when(mex.getVariable("allottedResourceId")).thenReturn("ari") - } - - private void initGetAaiAR(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("allottedResourceType")).thenReturn("TXC") - when(mex.getVariable("allottedResourceRole")).thenReturn("TXC") - when(mex.getVariable("allottedResourceId")).thenReturn(ARID) - when(mex.getVariable("CSI_service")).thenReturn(FileUtil.readResourceFile("__files/VCPE/DoDeleteAllottedResourceTXC/getAR.xml")) - when(mex.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.namespace")) - when(mex.getVariable("mso.workflow.global.default.aai.version")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.global.default.aai.version")) - when(mex.getVariable("mso.workflow.default.aai.v8.nodes.query.uri")).thenReturn(UrnPropertiesReader.getVariable("mso.workflow.default.aai.v8.nodes-query.uri")) - when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) - when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) - when(mex.getVariable("aaiAROrchStatus")).thenReturn("Active") - } - - private initUpdateAaiAROrchStatus(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) - } - - private initBuildSDNCRequest(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("allottedResourceId")).thenReturn("ari") - when(mex.getVariable("serviceInstanceId")).thenReturn("sii") - when(mex.getVariable("parentServiceInstanceId")).thenReturn("psii") - when(mex.getVariable("subscriptionServiceType")).thenReturn("sst") - when(mex.getVariable("globalCustomerId")).thenReturn("gci") - when(mex.getVariable("sdncCallbackUrl")).thenReturn("scu") - when(mex.getVariable("msoRequestId")).thenReturn("mri") - } - - private initPreProcessSDNC(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - } - - private initValidateSDNCResp(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("prefix")).thenReturn(Prefix) - when(mex.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) - } - - private String initValidateSDNCResp_Resp(int code) { - return "<response-code>${code}</response-code>" - } - - private initDeleteAaiAR(ExecutionEntity mex) { - when(mex.getVariable(DBGFLAG)).thenReturn("true") - when(mex.getVariable("aaiARPath")).thenReturn(aaiUriPfx + "/aai/v9/business/customers/customer/"+CUST+"/service-subscriptions/service-subscription/"+SVC+"/service-instances/service-instance/"+INST+"/allotted-resources/allotted-resource/"+ARID) - when(mex.getVariable("aaiARResourceVersion")).thenReturn("myvers") - when(mex.getVariable("aai.endpoint")).thenReturn(aaiUriPfx) - } - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/GroovyTestBase.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/GroovyTestBase.groovy deleted file mode 100644 index 764e6244d4..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/GroovyTestBase.groovy +++ /dev/null @@ -1,124 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.vcpe.scripts - - -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.junit.Before -import org.junit.BeforeClass -import org.junit.Rule -import org.junit.Test -import org.junit.Ignore -import org.mockito.MockitoAnnotations -import org.camunda.bpm.engine.delegate.BpmnError -import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.bpmn.core.WorkflowException -import org.onap.so.bpmn.mock.FileUtil -import org.springframework.beans.factory.config.YamlPropertiesFactoryBean -import org.springframework.core.io.ClassPathResource -import org.springframework.core.io.Resource - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse -import static com.github.tomakehurst.wiremock.client.WireMock.get -import static com.github.tomakehurst.wiremock.client.WireMock.patch -import static com.github.tomakehurst.wiremock.client.WireMock.put -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import static org.junit.Assert.*; -import static org.mockito.Mockito.* -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource -import org.onap.so.bpmn.core.RollbackData -import org.onap.so.bpmn.vcpe.scripts.MapSetter - -import com.github.tomakehurst.wiremock.junit.WireMockRule - -class GroovyTestBase { - - static final int PORT = 28090 - static final String LOCAL_URI = "http://localhost:" + PORT - - static final String CUST = "SDN-ETHERNET-INTERNET" - static final String SVC = "123456789" - static final String INST = "MIS%252F1604%252F0026%252FSW_INTERNET" - static final String ARID = "arId-1" - static final String VERS = "myvers" - - static final String DBGFLAG = "isDebugLogEnabled" - - static String aaiUriPfx - - String processName - - public static void setUpBeforeClass() { - aaiUriPfx = UrnPropertiesReader.getVariable("aai.endpoint") - } - - public GroovyTestBase(String processName) { - this.processName = processName - } - - public boolean doBpmnError(def func) { - - try { - func() - return false; - - } catch(BpmnError e) { - return true; - } - } - - public ExecutionEntity setupMock() { - - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn(processName) - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn(processName) - when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") - ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) - when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) - - ExecutionEntity mex = mock(ExecutionEntity.class) - - when(mex.getId()).thenReturn("100") - when(mex.getProcessDefinitionId()).thenReturn(processName) - when(mex.getProcessInstanceId()).thenReturn(processName) - when(mex.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mex.getProcessEngineServices().getRepositoryService().getProcessDefinition(mex.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - when(mex.getVariable("isAsyncProcess")).thenReturn("true") - when(mex.getVariable(processName+"WorkflowResponseSent")).thenReturn("false") - - return mex - } - - public Map setupMap(ExecutionEntity mex) { - MapSetter mapset = new MapSetter(); - doAnswer(mapset).when(mex).setVariable(any(), any()) - return mapset.getMap(); - } - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapGetter.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapGetter.groovy deleted file mode 100644 index fa5dcec4bc..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapGetter.groovy +++ /dev/null @@ -1,49 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.vcpe.scripts; - -import java.util.HashMap; -import java.util.Map; - -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - -class MapGetter implements Answer { - final Map map; - - public MapGetter() { - map = new HashMap<>(); - } - - public MapGetter(Map map) { - this.map = map; - } - - public Map getMap() { - return map; - } - - @Override - public Object answer(InvocationOnMock invocation) throws Throwable { - return map.get(invocation.getArgumentAt(0, String.class)); - } - -} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapSetter.groovy b/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapSetter.groovy deleted file mode 100644 index 7b50c616ea..0000000000 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/groovy/org/onap/so/bpmn/vcpe/scripts/MapSetter.groovy +++ /dev/null @@ -1,50 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.vcpe.scripts; - -import java.util.HashMap; -import java.util.Map; - -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - -class MapSetter implements Answer { - final Map map; - - public MapSetter() { - map = new HashMap<>(); - } - - public MapSetter(Map map) { - this.map = map; - } - - public Map getMap() { - return map; - } - - @Override - public Void answer(InvocationOnMock invocation) throws Throwable { - map.put(invocation.getArgumentAt(0, String.class), invocation.getArgumentAt(1, Object.class)); - return null; - } - -} -- cgit 1.2.3-korg