From 62cd6aaaf74aa91ee0037c0e155c8e7284f07567 Mon Sep 17 00:00:00 2001 From: Arthur Martella Date: Fri, 8 Sep 2017 13:27:46 -0400 Subject: 1710 Rebase - Second Attempt This commit rebases changes from openecomp-mso/internal-staging-1710 up to and including this codecloud commit: 54483fc6606ddb1591a2e9da61bff8712325f924 Wed Sep 6 18:12:56 2017 -0400 Rebasing was done on a branch on top of this commit in so/master in ONAP: 93fbdfbe46104f8859d4754040f979cb7997c157 Thu Sep 7 16:42:59 2017 +0000 Change-Id: I4ad9abf40da32bf5bdca43e868b8fa2dbcd9dc59 Issue-id: SO-107 Signed-off-by: Arthur Martella --- .../scripts/CreateNetworkInstanceTest.groovy | 360 ++ .../scripts/CreateVfModuleVolumeInfraV1Test.groovy | 11 +- .../scripts/DeleteNetworkInstanceTest.groovy | 397 ++ .../scripts/DeleteVfModuleVolumeInfraV1Test.groovy | 4 + .../DoCreateNetworkInstanceRollbackTest.groovy | 349 ++ .../scripts/DoCreateNetworkInstanceTest.groovy | 3988 ++++++++++++++++++++ .../scripts/DoCreateVfModuleVolumeV1Test.groovy | 218 -- .../DoDeleteNetworkInstanceRollbackTest.groovy | 323 ++ .../scripts/DoDeleteNetworkInstanceTest.groovy | 1929 ++++++++++ .../DoUpdateNetworkInstanceRollbackTest.groovy | 315 ++ .../scripts/DoUpdateNetworkInstanceTest.groovy | 2625 +++++++++++++ .../scripts/UpdateNetworkInstanceTest.groovy | 368 ++ 12 files changed, 10665 insertions(+), 222 deletions(-) create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteNetworkInstanceTest.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollbackTest.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1Test.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollbackTest.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceTest.groovy (limited to 'bpmn/MSOInfrastructureBPMN/src/test/groovy/org') diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy new file mode 100644 index 0000000000..13e107e8ad --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateNetworkInstanceTest.groovy @@ -0,0 +1,360 @@ +package org.openecomp.mso.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.runtime.Execution +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.mockito.MockitoAnnotations +import org.openecomp.mso.bpmn.common.scripts.MsoUtils +import org.openecomp.mso.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(Execution 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(Execution 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(Execution 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(Execution 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("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + // preProcessRequest(Execution 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(Execution 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(Execution 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(Execution 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(Execution 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 + } + +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy index 4f5375719f..0cf97922ae 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1Test.groovy @@ -27,10 +27,11 @@ import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity import org.mockito.ArgumentCaptor import org.mockito.MockitoAnnotations import org.mockito.runners.MockitoJUnitRunner +import org.openecomp.mso.bpmn.common.scripts.MsoGroovyTest import org.junit.Before +import org.junit.Ignore; import org.junit.Test import org.junit.runner.RunWith -import org.openecomp.mso.bpmn.common.scripts.MsoGroovyTest; @RunWith(MockitoJUnitRunner.class) @@ -64,8 +65,8 @@ class CreateVfModuleVolumeInfraV1Test extends MsoGroovyTest { "instanceId": "{service-instance-id}", "modelInfo": { "modelType": "service", - "modelId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", - "modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", + "modelInvariantUuid": "ff5256d1-5a33-55df-13ab-12abad84e7ff", + "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe", "modelName": "Test", "modelVersion": "2.0" } @@ -79,7 +80,7 @@ class CreateVfModuleVolumeInfraV1Test extends MsoGroovyTest { "modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", "modelName": "vSAMP12", "modelVersion": "1", - "modelCustomizationName": "vSAMP12" + "modelInstanceName": "vSAMP12" } } } @@ -162,6 +163,7 @@ class CreateVfModuleVolumeInfraV1Test extends MsoGroovyTest { @Test + @Ignore public void testPreProcessRequest() { ExecutionEntity mockExecution = setupMock('CreateVfModuleVolumeInfraV1') @@ -171,6 +173,7 @@ class CreateVfModuleVolumeInfraV1Test extends MsoGroovyTest { when(mockExecution.getVariable("serviceInstanceId")).thenReturn('') when(mockExecution.getVariable("vnfId")).thenReturn('test-vnf-id') when(mockExecution.getVariable("mso-request-id")).thenReturn('1234') + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn('true') CreateVfModuleVolumeInfraV1 createVfModuleVolumeInfraV1 = new CreateVfModuleVolumeInfraV1() createVfModuleVolumeInfraV1.preProcessRequest(mockExecution, 'true') diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteNetworkInstanceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteNetworkInstanceTest.groovy new file mode 100644 index 0000000000..304697891f --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteNetworkInstanceTest.groovy @@ -0,0 +1,397 @@ +package org.openecomp.mso.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.openecomp.mso.bpmn.common.scripts.MsoUtils +import org.openecomp.mso.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.openecomp/mso/infra/vnf-request/v1" xmlns:aetgt="http://org.openecomp/mso/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.openecomp/mso/infra/vnf-request/v1" xmlns:aetgt="http://org.openecomp/mso/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.openecomp/mso/infra/vnf-request/v1" xmlns:aetgt="http://org.openecomp/mso/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 (Execution 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(Execution 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(Execution 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(Execution 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("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + // preProcessRequest(Execution 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(Execution 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(Execution 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 + + } + +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy index 2e6b35eaba..fac156e86d 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1Test.groovy @@ -26,6 +26,7 @@ import static org.mockito.Mockito.* import org.apache.commons.lang3.* import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity import org.junit.Before +import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith import org.mockito.MockitoAnnotations @@ -121,11 +122,14 @@ class DeleteVfModuleVolumeInfraV1Test extends MsoGroovyTest { } @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("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") DeleteVfModuleVolumeInfraV1 myproc = new DeleteVfModuleVolumeInfraV1() myproc.prepareDBRequest(mockExecution, 'true') diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollbackTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollbackTest.groovy new file mode 100644 index 0000000000..2bb88632db --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollbackTest.groovy @@ -0,0 +1,349 @@ +package org.openecomp.mso.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.runtime.Execution; +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.mockito.internal.debugging.MockitoDebuggerImpl +import org.openecomp.mso.bpmn.common.scripts.MsoUtils +import org.openecomp.mso.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.openecomp.mso.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 (Execution 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("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + when(mockExecution.getVariable("URN_mso_adapters_sdnc_endpoint")).thenReturn("http://localhost:28090/SDNCAdapter") + when(mockExecution.getVariable("URN_mso_adapters_network_rest_endpoint")).thenReturn("http://localhost:28090/networks/NetworkAdapter") + when(mockExecution.getVariable("URN_mso_adapters_sdnc_resource_endpoint")).thenReturn("http://localhost:28090/SDNCAdapterRpc") + + + // preProcessRequest(Execution 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("URN_mso_adapters_network_rest_endpoint")).thenReturn("http://localhost:28090/networks/NetworkAdapter") + + // preProcessRequest(Execution 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/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy new file mode 100644 index 0000000000..d0b87b3737 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstanceTest.groovy @@ -0,0 +1,3988 @@ +package org.openecomp.mso.bpmn.infrastructure.scripts + +import static org.mockito.Mockito.* +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkByName; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkByName_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkByIdWithDepth; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkCloudRegion; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkCloudRegion_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutNetworkIdWithDepth; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkPolicy; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkTableReference; +import static org.openecomp.mso.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.runtime.Execution +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.openecomp.mso.bpmn.common.scripts.MsoUtils +import org.openecomp.mso.bpmn.core.WorkflowException + +import com.github.tomakehurst.wiremock.client.WireMock +import com.github.tomakehurst.wiremock.junit.WireMockRule +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 + + + + 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://mtanjv9aaas03.aic.cip.com:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/ + + + cloud-region.cloud-region-id + AAIAIC25 + + + cloud-region.cloud-owner + att-aic + + + cloud-region.owner-defined-type + + + + + tenant + https://mtanjv9aaas03.aic.cip.com:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/4ae1d3446a4c48b2bec44b6cfba06d68/ + + tenant.tenant-id + 4ae1d3446a4c48b2bec44b6cfba06d68 + + + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + AAIAIC25 + + + tenant.tenant-name + Ruchira Contrail 3.0 test + + + + vpn-binding + https://mtanjv9aaas03.aic.cip.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ + + vpn-binding.vpn-id + 9a7b327d9-287aa00-82c4b0-100001 + + + vpn-binding.vpn-name + GN_EVPN_direct_net_0_ST1 + + + + route-table-reference + 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 + + + + + + + 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 + subnetName + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 + 107.239.52.1 + 107.239.52.0 + 24 + 4 + Created + 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 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.openecomp.mso/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 (Execution 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("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_adapters_sdnc_endpoint")).thenReturn("http://localhost:8090/SDNCAdapter") + when(mockExecution.getVariable("URN_mso_adapters_network_rest_endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") + when(mockExecution.getVariable("URN_mso_adapters_sdnc_resource_endpoint")).thenReturn("http://localhost:8090/SDNCAdapterRpc") + + + // preProcessRequest(Execution 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("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_adapters_sdnc_endpoint")).thenReturn("http://localhost:8090/SDNCAdapter") + when(mockExecution.getVariable("URN_mso_adapters_network_rest_endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") + when(mockExecution.getVariable("URN_mso_adapters_sdnc_resource_endpoint")).thenReturn("http://localhost:8090/SDNCAdapterRpc") + + // preProcessRequest(Execution 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("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_adapters_sdnc_endpoint")).thenReturn("http://localhost:8090/SDNCAdapter") + when(mockExecution.getVariable("URN_mso_adapters_network_rest_endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") + when(mockExecution.getVariable("URN_mso_adapters_sdnc_resource_endpoint")).thenReturn("http://localhost:8090/SDNCAdapterRpc") + + // preProcessRequest(Execution 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(Prefix + "networkRequest", expectedXMLNetworkRequest) + verify(mockExecution).setVariable("action", "CREATE") + 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(Execution 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(Execution 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_AlaCarte() { + + println "************ prepareNetworkRequest ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedJSONNetworkRequest) + 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(Execution 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(Execution 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("URN_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(Execution 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("URN_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(Execution 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("URN_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(Execution 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("URN_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(Execution 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("URN_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(Execution 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("URN_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(Execution 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("URN_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(Execution 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_network_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_network_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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", "1"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "assignSDNCResponse")).thenReturn(sdncAdapterWorkflowAssignResponse) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_network_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("URN_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("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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=1") + 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_default_aai_cloud_infrastructure_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + // + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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).setVariable(Prefix + "queryCloudRegionRequest", "http://localhost:8090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/RDM2WAGPLCP") + 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_default_aai_cloud_infrastructure_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + // + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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).setVariable(Prefix + "queryCloudRegionRequest", "http://localhost:8090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/RDM2WAGPLCP") + 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + //old: when(mockExecution.getVariable("URN_mso_workflow_default_aai_cloud_infrastructure_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + // + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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).setVariable(Prefix + "queryCloudRegionRequest", "http://localhost:8090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/MDTWNJ21") + 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_default_aai_network_vpn-binding_uri")).thenReturn("") + // old: when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_network_vpn-binding_uri")).thenReturn("") + when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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_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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_default_aai_network_vpn-binding_uri")).thenReturn("") + // old: when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_network_vpn-binding_uri")).thenReturn("") + when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + //when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_network_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + //when(mockExecution.getVariable("URN_mso_workflow_default_aai_network_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + //when(mockExecution.getVariable("URN_mso_workflow_default_aai_network_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + //when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_network_policy_uri")).thenReturn("") + // old: when(mockExecution.getVariable("URN_mso_workflow_default_aai_network_policy_uri")).thenReturn("/aai/v8/network/network-policies/network-policy") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_network_policy_uri")).thenReturn("/aai/v8/network/network-policies/network-policy") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_network_table_reference_uri")).thenReturn("") + // old: when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_network_table_reference_uri")).thenReturn("") + when(mockExecution.getVariable("URN_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("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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", "1"); + + 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + //when(mockExecution.getVariable("URN_mso_workflow_default_aai_l3_network_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_l3_network_uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + //old: when(mockExecution.getVariable("URN_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("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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=1") + 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", "1"); + + 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_network_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("URN_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("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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=1") + 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", "1"); + + 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_DoCreateNetworkInstance_aai_network_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("URN_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("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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=1") + 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(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.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("1702") + when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn(sdncRpcRollbackRequest) + when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn(rollbackSDNCRequest) + when(mockExecution.getVariable(Prefix + "rollbackActivateSDNCRequest")).thenReturn(sdncActivateRollbackRequest) + + + // preProcessRequest(Execution execution) + DoCreateNetworkInstance DoCreateNetworkInstance = new DoCreateNetworkInstance() + DoCreateNetworkInstance.postProcessResponse(mockExecution) + + verify(mockExecution).getVariable("isDebugLogEnabled") + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).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 + } +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1Test.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1Test.groovy deleted file mode 100644 index e9c27b040a..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1Test.groovy +++ /dev/null @@ -1,218 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.bpmn.infrastructure.scripts; - -import static org.junit.Assert.* -import static org.mockito.Mockito.* - -import org.apache.commons.lang3.* -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.junit.Assert -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.openecomp.mso.bpmn.common.scripts.MsoGroovyTest - - -@RunWith(MockitoJUnitRunner.class) -class DoCreateVfModuleVolumeV1Test extends MsoGroovyTest { - - def volumeRequest = -""" - - 123abc - d8d4fcfa-fd7e-4413-b19d-c95aa67291b8 - CREATE_VF_MODULE_VOL - SoapUI-bns-create-base-vol-1001-1 - - - Test/vSAMP12 - vSAMP12::base::module-0 - true - 2.0 - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - MDTWNJ21 - 897deadc2b954a6bac6d3c197fb3525e - MSOTESTVOL101a-vSAMP12_base_vol_module-0 - - - - value1" - value2" - value3" - -""" - - def genericVnfResponseXml = """ - - TEST-VNF-ID-0123 - STMTN5MMSC20 - pcrf-capacity - SDN-MOBILITY - vPCRF - pending-create - false - false - introvert - 2.0 - 0000020 - - - lukewarm - PCRF::module-0-0 - introvert - 2.0 - true - fastburn - pending-create - 0000074 - - - supercool - PCRF::module-1-0 - extrovert - 2.0 - false - slowburn - pending-create - 0000075 - - - - - - -""" - def String expectedCreateVnfRequestXml = """ - MDTWNJ21 - 897deadc2b954a6bac6d3c197fb3525e - TEST-VNF-ID-0123 - STMTN5MMSC20 - test-vol-group-id-123 - MSOTESTVOL101a-vSAMP12_base_vol_module-0 - Test/vSAMP12 - 2.0 - vSAMP12::base::module-0 - - - - vnf_id - TEST-VNF-ID-0123 - - - vnf_name - STMTN5MMSC20 - - - vf_module_id - test-vol-group-id-123 - - - vf_module_name - MSOTESTVOL101a-vSAMP12_base_vol_module-0 - - - param1 - value1 - - - param2 - value2 - - - param3 - value3 - - - true - true - true - - d8d4fcfa-fd7e-4413-b19d-c95aa67291b8 - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - - 111 - http://localhost:28080/mso/WorkflowMessage/12345678 - -""" - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - - } - - @Test - public void TestPreProcessRequest() { - - ExecutionEntity mockExecution = setupMock('DoCreateVfModuleVolumeV1') - - when(mockExecution.getVariable("DoCreateVfModuleVolumeV1Request")).thenReturn(volumeRequest) - when(mockExecution.getVariable("vnf-id")).thenReturn('test-vnf-id-123') - when(mockExecution.getVariable("volume-group-id")).thenReturn('test-volume-group-id-123') - when(mockExecution.getVariable("mso-request-id")).thenReturn('test-request-id-123') - - DoCreateVfModuleVolumeV1 myprocess = new DoCreateVfModuleVolumeV1() - myprocess.preProcessRequest(mockExecution, 'true') - - verify(mockExecution).setVariable('DCVFMODVOLV1_serviceId', 'a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb') - verify(mockExecution).setVariable('DCVFMODVOLV1_source', 'SoapUI-bns-create-base-vol-1001-1') - verify(mockExecution, times(7)).setVariable(anyString(), anyString()) - } - - @Test - public void TestPrepareVnfAdapterCreateRequest() { - - ExecutionEntity mockExecution = setupMock('DoCreateVfModuleVolumeV1') - - when(mockExecution.getVariable("DCVFMODVOLV1_Request")).thenReturn(volumeRequest) - when(mockExecution.getVariable("DCVFMODVOLV1_requestId")).thenReturn('d8d4fcfa-fd7e-4413-b19d-c95aa67291b8') - when(mockExecution.getVariable("DCVFMODVOLV1_serviceId")).thenReturn('a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb') - when(mockExecution.getVariable("DCVFMODVOLV1_AAIQueryGenericVfnResponse")).thenReturn(genericVnfResponseXml) - when(mockExecution.getVariable("DCVFMODVOLV1_rollbackEnabled")).thenReturn(true) - when(mockExecution.getVariable("volume-group-id")).thenReturn('test-vol-group-id-123') - when(mockExecution.getVariable("URN_mso_workflow_message_endpoint")).thenReturn('http://localhost:28080/mso/WorkflowMessage') - when(mockExecution.getVariable("URN_mso_use_qualified_host")).thenReturn(true) - - DoCreateVfModuleVolumeV1 myprocess = new DoCreateVfModuleVolumeV1() - myprocess.prepareVnfAdapterCreateRequest(mockExecution, 'true') - - // Capture the arguments to setVariable - ArgumentCaptor captor1 = ArgumentCaptor.forClass(String.class); - ArgumentCaptor captor2 = ArgumentCaptor.forClass(String.class); - - verify(mockExecution, times(2)).setVariable(captor1.capture(), captor2.capture()) - - List arg2List = captor2.getAllValues() - String createVnfRequestXml = arg2List.get(0) - - //replace messageID value because it is random generated - createVnfRequestXml = createVnfRequestXml.replaceAll("(.+?)", "111") - .replaceAll("(.+?)", "http://localhost:28080/mso/WorkflowMessage/12345678") - - Assert.assertEquals(expectedCreateVnfRequestXml.trim(), createVnfRequestXml.trim()) - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollbackTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollbackTest.groovy new file mode 100644 index 0000000000..96a84deb26 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollbackTest.groovy @@ -0,0 +1,323 @@ +package org.openecomp.mso.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.runtime.Execution; +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.mockito.internal.debugging.MockitoDebuggerImpl +import org.openecomp.mso.bpmn.common.scripts.MsoUtils +import org.openecomp.mso.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 (Execution 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("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + when(mockExecution.getVariable("URN_mso_adapters_sdnc_endpoint")).thenReturn("http://localhost:8090/SDNCAdapter") + when(mockExecution.getVariable("URN_mso_adapters_network_rest_endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") + when(mockExecution.getVariable("URN_mso_adapters_sdnc_resource_endpoint")).thenReturn("http://localhost:8090/SDNCAdapterRpc") + + + // preProcessRequest(Execution 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/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy new file mode 100644 index 0000000000..0f87b6400e --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceTest.groovy @@ -0,0 +1,1929 @@ +package org.openecomp.mso.bpmn.infrastructure.scripts + +import static org.mockito.Mockito.* + +import static org.openecomp.mso.bpmn.mock.StubResponseNetworkAdapter.MockNetworkAdapter; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkByIdWithDepth; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkCloudRegion; +import static org.openecomp.mso.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.runtime.Execution +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.openecomp.mso.bpmn.common.scripts.MsoUtils +import org.openecomp.mso.bpmn.core.WorkflowException + +import com.github.tomakehurst.wiremock.client.WireMock +import com.github.tomakehurst.wiremock.junit.WireMockRule +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("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_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("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_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 (Execution 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("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") + when(mockExecution.getVariable("sdncVersion")).thenReturn("1610") + + // preProcessRequest(Execution 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("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") + when(mockExecution.getVariable("sdncVersion")).thenReturn("1610") + + // preProcessRequest(Execution 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("URN_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("URN_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("URN_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("URN_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("URN_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("URN_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("URN_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("URN_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(Execution 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", "1"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_network_l3_network_uri")).thenReturn("") + // old: when(mockExecution.getVariable("URN_mso_workflow_DoDeleteNetworkInstance_aai_network_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("URN_mso_workflow_DoDeleteNetworkInstance_aai_l3_network_uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_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=1") + + 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", "1"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_network_l3_network_uri")).thenReturn("") + // old: when(mockExecution.getVariable("URN_mso_workflow_DoDeleteNetworkInstance_aai_network_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("URN_mso_workflow_DoDeleteNetworkInstance_aai_l3_network_uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_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=1") + + 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", "1"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_default_aai_network_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_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=1") + + 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_default_aai_cloud_infrastructure_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + DoDeleteNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) + + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "queryCloudRegionRequest", "http://localhost:8090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/RDM2WAGPLCP") + 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_default_aai_cloud_infrastructure_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + // old: when(mockExecution.getVariable("URN_mso_workflow_default_aai_cloud_infrastructure_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + // + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution execution) + DoDeleteNetworkInstance DoDeleteNetworkInstance = new DoDeleteNetworkInstance() + DoDeleteNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) + + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "queryCloudRegionRequest", "http://localhost:8090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/RDM2WAGPLCP") + 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(Execution 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(Execution 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 + + } + +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy new file mode 100644 index 0000000000..c97bedbac1 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollbackTest.groovy @@ -0,0 +1,315 @@ +package org.openecomp.mso.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.runtime.Execution; +import org.mockito.MockitoAnnotations +import org.mockito.runners.MockitoJUnitRunner +import org.mockito.internal.debugging.MockitoDebuggerImpl +import org.openecomp.mso.bpmn.common.scripts.MsoUtils +import org.openecomp.mso.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 (Execution 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("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + when(mockExecution.getVariable("URN_mso_adapters_sdnc_endpoint")).thenReturn("http://localhost:28090/SDNCAdapter") + when(mockExecution.getVariable("URN_mso_adapters_network_rest_endpoint")).thenReturn("http://localhost:28090/networks/NetworkAdapter") + when(mockExecution.getVariable("URN_mso_adapters_sdnc_resource_endpoint")).thenReturn("http://localhost:28090/SDNCAdapterRpc") + + + // preProcessRequest(Execution 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 + } + +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy new file mode 100644 index 0000000000..fb44067b68 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy @@ -0,0 +1,2625 @@ +package org.openecomp.mso.bpmn.infrastructure.scripts + +import static org.mockito.Mockito.* +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkByIdWithDepth; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkCloudRegion; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkCloudRegion_404; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkVpnBinding; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkTableReference; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkPolicy; +import static org.openecomp.mso.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.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.openecomp.mso.bpmn.common.scripts.MsoUtils +import org.openecomp.mso.bpmn.core.WorkflowException + +import com.github.tomakehurst.wiremock.client.WireMock +import com.github.tomakehurst.wiremock.junit.WireMockRule +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 = +""" + HSL_direct_net_2 + 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 + HSL_direct_net_2 + CONTRAIL_EXTERNAL + dmz_direct + contrail + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + pending-delete + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-delete + true + + + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ + + vpn-binding.vpn-id + 85f015d0-2e32-4c30-96d2-87a1a27f8017 + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ + + vpn-binding.vpn-id + c980a6ef-3b88-49f0-9751-dbad8608d0a6 + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ + + tenant.tenant-id + 7dd5365547234ee8937416c65507d266 + + + + + +""" + + String queryIdAIIResponse = + """ + + + + + + + + + + + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + dmz_direct + contrail + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + l3-version + pending-delete + ST_2Bindings_6006/55288ef0-595c-47d3-819e-cf93aaac6326 + networkName + false + true + false + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-update + true + subnetName + + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-delete + true + subnetName + + + + + 414 + 4132176 + + + 415 + 4132176 + + + + inner + ctag-version + + + tenant + https://aai-ext1.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/897deadc2b954a6bac6d3c197fb3525e/ + + tenant.tenant-id + 897deadc2b954a6bac6d3c197fb3525e + + + tenant.tenant-name + MSOTest1 + + + + vpn-binding + https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/a290b841-f672-44dd-b9cd-6f8c20d7d8c8/ + + vpn-binding.vpn-id + a290b841-f672-44dd-b9cd-6f8c20d7d8c8 + + + vpn-binding.vpn-name + oam_protected_net_6_MTN5_msotest2 + + + + vpn-binding + https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/24a4b507-853a-4a38-99aa-05fcc54be24d/ + + vpn-binding.vpn-id + 24a4b507-853a-4a38-99aa-05fcc54be24d + + + vpn-binding.vpn-name + oam_protected_net_6_MTN5_msotest1 + + + + + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ + + vpn-binding.vpn-id + 85f015d0-2e32-4c30-96d2-87a1a27f8017 + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ + + vpn-binding.vpn-id + c980a6ef-3b88-49f0-9751-dbad8608d0a6 + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ + + tenant.tenant-id + 7dd5365547234ee8937416c65507d266 + + + + network-policy + https://aai-app-e2e.test.com:8443/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg + + network-policy.network-policy-id + cee6d136-e378-4678-a024-2cd15f0ee0cg + + + + route-table-reference + https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN1 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + + route-table-reference + https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN2 + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + + + +""" + + String queryIdAIIResponseTestScenario01 = + """ + + 4da55fe4-7a9e-478c-a434-8a98d62265ab + GN_EVPN_direct_net_0_ST1 + CONTRAIL30_BASIC + GN_EVPN_direct + contrail + false + 9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + 1465398611 + pending-delete + networkName + false + true + false + + + cb1a7b47-5428-44c9-89c2-8b17541c3228 + 108.239.40.1 + 108.239.40.0 + 28 + 4 + pending-delete + true + 108.239.40.0 + 108.239.40.0 + 1465398611 + subnetName + + + + e2cc7c14-90f0-4205-840d-b4e07f04e621 + 2606:ae00:2e01:604::1 + 2606:ae00:2e01:604:: + 64 + 6 + pending-delete + true + 2606:ae00:2e01:604:: + 2606:ae00:2e01:604:: + 1465398611 + subnetName + + + + + + 416 + 4132176 + + + + cloud-region + https://mtanjv9aaas03.aic.cip.com:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/ + + + cloud-region.cloud-region-id + AAIAIC25 + + + cloud-region.cloud-owner + att-aic + + + cloud-region.owner-defined-type + + + + + tenant + https://mtanjv9aaas03.aic.cip.com:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/4ae1d3446a4c48b2bec44b6cfba06d68/ + + tenant.tenant-id + 4ae1d3446a4c48b2bec44b6cfba06d68 + + + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + AAIAIC25 + + + tenant.tenant-name + Ruchira Contrail 3.0 test + + + + vpn-binding + https://mtanjv9aaas03.aic.cip.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ + + vpn-binding.vpn-id + 9a7b327d9-287aa00-82c4b0-100001 + + + vpn-binding.vpn-name + GN_EVPN_direct_net_0_ST1 + + + + route-table-reference + + route-table-reference.route-table-reference-id + cee6d136-e378-4678-a024-2cd15f0ee0hi + + + +""" + + String queryIdAIIResponseVpnNotPresent = + """ + + + + + + + + + + + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + dmz_direct + contrail + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + pending-delete + networkName + false + true + false + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-delete + true + subnetName + + + + + + +""" + + String queryNameAIIResponse = + """ + + + + + + + + + + + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + dmz_direct + contrail + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + pending-delete + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + 107.239.52.1 + 107.239.52.0 + 24 + 4 + pending-delete + true + + + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ + + vpn-binding.vpn-id + 85f015d0-2e32-4c30-96d2-87a1a27f8017 + + + + vpn-binding + https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ + + vpn-binding.vpn-id + c980a6ef-3b88-49f0-9751-dbad8608d0a6 + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ + + tenant.tenant-id + 7dd5365547234ee8937416c65507d266 + + + + + + """ + + String queryNameAIIResponseVpnNotPresent = + """ + + + + + + + + + + + + + + +""" + + String queryVpnBindingAAIResponse = + """ + + + + + + + + + + + + 9a7b327d9-287aa00-82c4b0-105757 + GN_EVPN_Test + 13979:105757 + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/689ec39e-c5fc-4462-8db2-4f760763ad28/ + + l3-network.network-id + 689ec39e-c5fc-4462-8db2-4f760763ad28 + + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/1a49396b-19b3-40a4-8792-aa2fbd0f0704/ + + l3-network.network-id + 1a49396b-19b3-40a4-8792-aa2fbd0f0704 + + + + l3-network + https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/774f3329-3c83-4771-86c7-9e6207cd50fd/ + + l3-network.network-id + 774f3329-3c83-4771-86c7-9e6207cd50fd + + + + + +""" + + + String 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 + 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 + true + false + + true + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + true + true + 10.10.125.1 + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + null + + messageId_generated + +""" + + String updateNetworkResponseREST = + """ + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + default-domain:MSOTest:GN_EVPN_direct_net_0_ST1 + + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 + + + + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + + CONTRAIL_EXTERNAL + true + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + + + + messageId_generated +""" + + String updateRollbackNetworkRequest = + """ + + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + + CONTRAIL_EXTERNAL + true + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + + + +""" + + String updateNetworkResponse = + """ + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + c4f4e878-cde0-4b15-ae9a-bda857759cea + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + default-domain:MSOTest:GN_EVPN_direct_net_0_ST1 + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 + + + + RDM2WAGPLCP + + 1ef47428-cade-45bd-a103-0751e8b2deb0 + + + true + MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 + CONTRAIL_EXTERNAL + false + c4f4e878-cde0-4b15-ae9a-bda857759cea + 7dd5365547234ee8937416c65507d266 + +""" + + String updateContrailAAIPayloadRequest = + """ + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + MNS-25180-L-01-dmz_direct_net_1 + CONTRAIL_EXTERNAL + dmz_direct + contrail + c4f4e878-cde0-4b15-ae9a-bda857759cea + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + 0 + l3-version + Active + ST_2Bindings_6006/55288ef0-595c-47d3-819e-cf93aaac6326 + default-domain:MSOTest:GN_EVPN_direct_net_0_ST1 + networkName + false + true + false + + + 57e9a1ff-d14f-4071-a828-b19ae98eb2fc + bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 + 107.239.52.1 + 107.239.52.0 + 24 + 4 + Active + true + subnetName + + + + 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.openecomp.mso/network", the namespace on the "updateNetworkContrail" element, is not a valid SOAP version.""" + + String aaiResponse = + """ + + + + + + + + + + + + bdc5efe8-404a-409b-85f6-0dcc9eebae30 + HSL_direct_net_2 + CONTRAIL_BASIC + HSL_direct + contrail + 8bbd3edf-b835-4610-96a2-a5cafa029042 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + active + HSL_direct_net_2/57594a56-1c92-4a38-9caa-641c1fa3d4b6 + + + ea5f2a2c-604f-47ff-a9c5-253ee4f0ef0a + 5a77fdc2-7789-4649-a1b9-6eaf1db1813a + 172.16.34.1 + 172.16.34.0 + 28 + 4 + active + true + + + + + + tenant + https://aai-app-e2e.test.com:8443/aai/v3/cloud-infrastructure/tenants/tenant/e81d842d3e8b45c5a59f57cd76af3aaf/ + + tenant.tenant-id + e81d842d3e8b45c5a59f57cd76af3aaf + + + + + + """ + + String changeAssignSDNCRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + changeassign + network-topology-operation + sdncCallback + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + NetworkActivateRequest + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + MSO_1610_dev + + + 49c86598-f766-46f8-84f8-8d1c1b10f9b4 + CONTRAIL_EXTERNAL + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + +""" + +String assignResponse = +""" 006927ca-f5a3-47fd-880c-dfcbcd81a093 200 OK 200006927ca-f5a3-47fd-880c-dfcbcd81a093Ynotsurewecarea9a77d5a-123e-4ca2-9eb9-0b015d2ee0fbGN_EVPN_direct_net_0_ST_noGW8abc633a-810b-4ca5-8b3a-09511d13a2ce """ + + String sdncRollbackRequest = + """ + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + rollback + network-topology-operation + sdncCallback + + + + 88f65519-9a38-4c4b-8445-9eb4a5a5af56 + NetworkActivateRequest + VID + + + + + + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + MSO-dev-service-type + f70e927b-6087-4974-9ef8-c5e4d5847ca4 + MSO_1610_dev + + + 8abc633a-810b-4ca5-8b3a-09511d13a2ce + CONTRAIL_EXTERNAL + MNS-25180-L-01-dmz_direct_net_1 + 7dd5365547234ee8937416c65507d266 + RDM2WAGPLCP + + +""" + + String sdncAdapterWorkflowResponse = + """ + + + 745b1b50-e39e-4685-9cc8-c71f0bde8bf0 + 200 + OK + + <output xmlns="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 (Execution 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("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") + when(mockExecution.getVariable("disableRollback")).thenReturn("true") + + // preProcessRequest(Execution 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("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_adapters_sdnc_endpoint")).thenReturn("http://localhost:8090/SDNCAdapter") + when(mockExecution.getVariable("URN_mso_adapters_network_rest_endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") + when(mockExecution.getVariable("URN_mso_adapters_sdnc_resource_endpoint")).thenReturn("http://localhost:8090/SDNCAdapterRpc") + + // preProcessRequest(Execution 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("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") + when(mockExecution.getVariable("disableRollback")).thenReturn("true") + + // preProcessRequest(Execution 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("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") + when(mockExecution.getVariable("disableRollback")).thenReturn("true") + + // preProcessRequest(Execution 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(Execution 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(Execution 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("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("URN_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(Execution 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("URN_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(Execution execution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.prepareSDNCRollbackRequest(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution).setVariable("prefix", Prefix + "") + 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", "1"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_DoUpdateNetworkInstance_aai_l3_network_uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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=1") + 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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 + "queryCloudRegionRequest", "http://localhost:8090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/RDM2WAGPLCP") + 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(expectedNetworkRequest) + when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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 + "queryCloudRegionRequest", "http://localhost:8090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/RDM2WAGPLCP") + 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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 + "queryCloudRegionRequest", "http://localhost:8090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/MDTWNJ21") + 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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_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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_network_table_reference_uri")).thenReturn("") + when(mockExecution.getVariable("URN_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("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") + when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_network_policy_uri")).thenReturn("/aai/v8/network/network-policies/network-policy") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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", "1"); + + 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_DoUpdateNetworkInstance_aai_l3_network_uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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=1") + 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", "1"); + + 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("URN_aai_endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("URN_mso_workflow_DoUpdateNetworkInstance_aai_l3_network_uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + // preProcessRequest(Execution 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=1") + 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(Execution 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(Execution 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/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceTest.groovy new file mode 100644 index 0000000000..e987d59805 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceTest.groovy @@ -0,0 +1,368 @@ +package org.openecomp.mso.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.runtime.Execution +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.openecomp.mso.bpmn.common.scripts.MsoUtils +import org.openecomp.mso.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(Execution 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("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + // preProcessRequest(Execution 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(Execution 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(Execution 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 prepareDBRequestError() { + + println "************ prepareDBRequestError ************* " + + WorkflowException sndcWorkflowException = new WorkflowException("UpdateNetworkInstance", 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("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + // preProcessRequest(Execution execution) + UpdateNetworkInstance UpdateNetworkInstance = new UpdateNetworkInstance() + UpdateNetworkInstance.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(Execution 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(Execution 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(Execution 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(Execution 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 + } + +} \ No newline at end of file -- cgit 1.2.3-korg