diff options
author | k.kazak <k.kazak@samsung.com> | 2019-04-03 13:51:40 +0200 |
---|---|---|
committer | k.kazak <k.kazak@samsung.com> | 2019-04-03 13:51:40 +0200 |
commit | 5856da6ee75f25b5e370edaa7259d9130a33aa75 (patch) | |
tree | 94dff81be087405601609a16a44276533df2a59b /bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap | |
parent | 3690db02a3035306d6be5fae7529a2f27b90ee71 (diff) |
Fix runtime bugs in bpmn groovy
DoDeleteVfModuleV2: non-existing variable uri (was renamed to resourceUri)
DoUpdateNetworkInstance: queryIdResponse type is expected to be L3Network
UpdateVfModuleVolumeInfraV1: non-existing variable cloudOwner
Include tests for those fixes to build
Change-Id: Icaea91260fbf6603f134df893a64ec1ca5ac40ab
Issue-ID: SO-1649
Signed-off-by: k.kazak <k.kazak@samsung.com>
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap')
3 files changed, 690 insertions, 1745 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy index eab1b89e10..2885d6919e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2Test.groovy @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * 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 @@ -26,21 +28,25 @@ import org.camunda.bpm.engine.RepositoryService import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity import org.camunda.bpm.engine.repository.ProcessDefinition +import org.junit.After +import org.junit.AfterClass import org.junit.Assert import org.junit.Before -import org.junit.Ignore +import org.junit.BeforeClass import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.mockito.ArgumentCaptor import org.mockito.Captor +import org.mockito.Mock import org.mockito.Mockito import org.mockito.MockitoAnnotations import org.mockito.Spy -import org.mockito.runners.MockitoJUnitRunner +import org.mockito.junit.MockitoJUnitRunner import org.onap.aai.domain.yang.VolumeGroup import org.onap.so.bpmn.common.scripts.MsoGroovyTest import org.onap.so.bpmn.common.scripts.utils.XmlComparator +import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException import org.onap.so.bpmn.mock.FileUtil import org.onap.so.client.aai.AAIObjectType @@ -48,73 +54,111 @@ import org.onap.so.client.aai.entities.AAIResultWrapper import org.onap.so.client.aai.entities.uri.AAIResourceUri import org.onap.so.client.aai.entities.uri.AAIUriFactory import org.onap.so.client.graphinventory.exceptions.GraphInventoryUriComputationException +import org.springframework.core.env.Environment +import org.springframework.mock.env.MockEnvironment import javax.ws.rs.NotFoundException import static com.github.tomakehurst.wiremock.client.WireMock.* import static org.mockito.Mockito.* -@RunWith(MockitoJUnitRunner.class) +@RunWith(MockitoJUnitRunner.Silent.class) class DoDeleteVfModuleVolumeV2Test extends MsoGroovyTest{ + @Rule + public WireMockRule wireMockRule = new WireMockRule(8090) + @Captor static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) @Spy - DoDeleteVfModuleVolumeV2 deleteVfModuleVolumeV2; + DoDeleteVfModuleVolumeV2 deleteVfModuleVolumeV2 + + @Mock + Environment mockEnvironment + + private String Prefix = "DDVMV_" + private RepositoryService mockRepositoryService + + + @After + void cleanupEnv() { + UrnPropertiesReader urnPropertiesReader = new UrnPropertiesReader() + urnPropertiesReader.setEnvironment(null) + } @Before public void init() throws IOException { super.init("DoDeleteVfModuleVolumeV2") MockitoAnnotations.initMocks(this); when(deleteVfModuleVolumeV2.getAAIClient()).thenReturn(client) - + when(mockEnvironment.getProperty("mso.workflow.global.default.aai.version")).thenReturn("14") + when(mockEnvironment.getProperty("mso.workflow.global.default.aai.namespace")).thenReturn("defaultTestNamespace") + when(mockEnvironment.getProperty("aai.endpoint")).thenReturn("http://localhost:8090") + UrnPropertiesReader urnPropertiesReader = new UrnPropertiesReader() + urnPropertiesReader.setEnvironment(mockEnvironment) } @Test public void testCallRESTQueryAAICloudRegion() { ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn("DDVMV_") + when(mockExecution.getVariable("prefix")).thenReturn(Prefix) when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("lcpCloudRegionId")).thenReturn("12345") - when(mockExecution.getVariable("mso.workflow.DoDeleteVfModuleVolumeV2.aai.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") + mockSuccessfulCloudData() - mockData() DoDeleteVfModuleVolumeV2 obj = new DoDeleteVfModuleVolumeV2() obj.callRESTQueryAAICloudRegion(mockExecution, "true") Mockito.verify(mockExecution).setVariable("DDVMV_queryCloudRegionReturnCode", "200") Mockito.verify(mockExecution).setVariable("DDVMV_aicCloudRegion", "RDM2WAGPLCP") } - @Test + @Test(expected = GroovyRuntimeException.class) public void testCallRESTQueryAAICloudRegionAAiEndpointNull() { ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn("DDVMV_") + when(mockExecution.getVariable("prefix")).thenReturn(Prefix) when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("lcpCloudRegionId")).thenReturn("12345") - when(mockExecution.getVariable("mso.workflow.DoDeleteVfModuleVolumeV2.aai.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region") - when(mockExecution.getVariable("aai.endpoint")).thenReturn(null) - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/") + when(mockEnvironment.getProperty("aai.endpoint")).thenReturn(null) - mockData() + mockSuccessfulCloudData() try { DoDeleteVfModuleVolumeV2 obj = new DoDeleteVfModuleVolumeV2() obj.callRESTQueryAAICloudRegion(mockExecution, "true") } catch (Exception ex) { - println " Test End - Handle catch-throw BpmnError()! " + println " Test End - Handle catch-throw Exception! " + Mockito.verify(mockExecution).getVariable(eq("lcpCloudRegionId")) + Assert.assertEquals(GroovyRuntimeException.class, ex.class) + throw ex } - Mockito.verify(mockExecution,atLeastOnce()).setVariable(captor.capture(),captor.capture()) - WorkflowException workflowException = captor.getValue() - Assert.assertEquals(9999, workflowException.getErrorCode()) + } + + @Test + public void testCallRESTQueryAAICloudRegionNotFound() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(Prefix) + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("lcpCloudRegionId")).thenReturn("12345") + when(mockExecution.getVariable(Prefix + "queryCloudRegionReturnCode")).thenReturn("404") + + wireMockRule.stubFor( + get(urlMatching(".*/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/12345")) + .willReturn(aResponse() + .withStatus(404))) + + DoDeleteVfModuleVolumeV2 obj = new DoDeleteVfModuleVolumeV2() + obj.callRESTQueryAAICloudRegion(mockExecution, "true") + + Mockito.verify(mockExecution).getVariable(eq("lcpCloudRegionId")) + Mockito.verify(mockExecution).setVariable(eq(Prefix + "queryCloudRegionReturnCode"), eq("404")) + Mockito.verify(mockExecution).setVariable(eq(Prefix + "aicCloudRegion"), eq("AAIAIC25")) } @Test public void testPrepareVnfAdapterDeleteRequest() { ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn("DDVMV_") + when(mockExecution.getVariable("prefix")).thenReturn(Prefix) when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") when(mockExecution.getVariable("aicCloudRegion")).thenReturn("RegionOne") when(mockExecution.getVariable("tenantId")).thenReturn("12345") @@ -139,8 +183,10 @@ class DoDeleteVfModuleVolumeV2Test extends MsoGroovyTest{ when(mockExecution.getVariable("volumeGroupId")).thenReturn("VolumeGroup123") when(mockExecution.getVariable("DDVMV_aicCloudRegion")).thenReturn("Region1") AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "Region1","VolumeGroup123") - Optional<VolumeGroup> volumeGroup = getAAIObjectFromJson(VolumeGroup.class,"__files/aai/VolumeGroupWithTenant.json"); + Optional<VolumeGroup> volumeGroup = getAAIObjectFromJson(VolumeGroup.class,"__files/AAI/VolumeGroupWithTenant.json"); when(client.get(VolumeGroup.class,resourceUri)).thenReturn(volumeGroup) + when(client.get(resourceUri)).thenReturn( + new AAIResultWrapper(FileUtil.readResourceFile("__files/AAI/VolumeGroupWithTenant.json"))) deleteVfModuleVolumeV2.callRESTQueryAAIForVolumeGroup(mockExecution,"true") Mockito.verify(mockExecution).setVariable("DDVMV_queryAAIVolGrpResponse", volumeGroup.get()) Mockito.verify(mockExecution).setVariable("DDVMV_volumeGroupHeatStackId", volumeGroup.get().getHeatStackId()) @@ -167,7 +213,7 @@ class DoDeleteVfModuleVolumeV2Test extends MsoGroovyTest{ when(mockExecution.getVariable("volumeGroupId")).thenReturn("VolumeGroup123") when(mockExecution.getVariable("DDVMV_aicCloudRegion")).thenReturn("Region1") AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VOLUME_GROUP,CLOUD_OWNER, "Region1","VolumeGroup123") - Optional<VolumeGroup> volumeGroup = getAAIObjectFromJson(VolumeGroup.class,"__files/aai/VolumeGroupWithTenant.json"); + Optional<VolumeGroup> volumeGroup = getAAIObjectFromJson(VolumeGroup.class,"__files/AAI/VolumeGroupWithTenant.json"); when(client.get(VolumeGroup.class,resourceUri)).thenReturn(volumeGroup) try { deleteVfModuleVolumeV2.callRESTQueryAAIForVolumeGroup(mockExecution, "true") @@ -248,30 +294,20 @@ class DoDeleteVfModuleVolumeV2Test extends MsoGroovyTest{ private ExecutionEntity setupMock() { - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("DoDeleteVfModuleVolumeV2") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoDeleteVfModuleVolumeV2") - when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") + mockRepositoryService = mock(RepositoryService.class) ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) - when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) + when(mockProcessEngineServices.getRepositoryService()).thenReturn(this.mockRepositoryService) ExecutionEntity mockExecution = mock(ExecutionEntity.class) // Initialize prerequisite variables - - when(mockExecution.getId()).thenReturn("100") - when(mockExecution.getProcessDefinitionId()).thenReturn("DoDeleteVfModuleVolumeV2") - when(mockExecution.getProcessInstanceId()).thenReturn("DoDeleteVfModuleVolumeV2") when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) return mockExecution } - private void mockData() { - stubFor(get(urlMatching(".*/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/12345")) + private void mockSuccessfulCloudData() { + wireMockRule.stubFor(get(urlMatching(".*/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/12345")) .willReturn(aResponse() .withStatus(200).withHeader("Content-Type", "text/xml") .withBodyFile("DoCreateVfModuleVolumeV2/cloudRegion_AAIResponse_Success.xml"))) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy index 68a9ed659e..19bb7c86b4 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceTest.groovy @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * 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 @@ -20,33 +22,34 @@ package org.onap.so.bpmn.infrastructure.scripts - -import static org.mockito.Mockito.* -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkByIdWithDepth; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkCloudRegion; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkCloudRegion_404; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkVpnBinding; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkTableReference; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetNetworkPolicy; -import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutNetworkIdWithDepth; +import com.github.tomakehurst.wiremock.client.WireMock +import com.github.tomakehurst.wiremock.junit.WireMockRule import org.camunda.bpm.engine.ProcessEngineServices import org.camunda.bpm.engine.RepositoryService +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity import org.camunda.bpm.engine.repository.ProcessDefinition -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.junit.Before -import org.junit.Rule -import org.junit.Test +import org.junit.* import org.junit.runner.RunWith import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner +import org.mockito.junit.MockitoJUnitRunner +import org.onap.aai.domain.yang.* import org.onap.so.bpmn.common.scripts.MsoUtils +import org.onap.so.bpmn.core.UrnPropertiesReader import org.onap.so.bpmn.core.WorkflowException - -import com.github.tomakehurst.wiremock.client.WireMock -import com.github.tomakehurst.wiremock.junit.WireMockRule -import org.apache.commons.lang3.* - +import org.onap.so.bpmn.mock.FileUtil +import org.onap.so.client.aai.entities.AAIResultWrapper +import org.springframework.mock.env.MockEnvironment + +import static org.mockito.ArgumentMatchers.eq +import static org.mockito.ArgumentMatchers.isA +import static org.mockito.ArgumentMatchers.refEq +import static org.mockito.Mockito.atLeast +import static org.mockito.Mockito.mock +import static org.mockito.Mockito.verify +import static org.mockito.Mockito.when +import static org.onap.so.bpmn.mock.StubResponseAAI.* @RunWith(MockitoJUnitRunner.class) class DoUpdateNetworkInstanceTest { @@ -200,24 +203,6 @@ String expectedNetworkInputMissingCloudRegion = <sdncVersion>null</sdncVersion> </network-inputs>""" - String networkInputsMissingName = - """<network-inputs xmlns="http://org.onap/so/infra/vnf-request/v1"> - <network-name/> - <network-type>CONTRAIL_EXTERNAL</network-type> - <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> - <aic-cloud-region>RDM2WAGPLCP</aic-cloud-region> - <tenant-id>e81d842d3e8b45c5a59f57cd76af3aaf</tenant-id> - </network-inputs>""" - -String networkInputsMissingCloudRegion = -"""<network-inputs xmlns="http://org.onap/so/infra/vnf-request/v1"> - <network-name>MNS-25180-L-01-dmz_direct_net_1</network-name> - <network-type>CONTRAIL_EXTERNAL</network-type> - <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> - <aic-cloud-region/> - <tenant-id>e81d842d3e8b45c5a59f57cd76af3aaf</tenant-id> -</network-inputs>""" - // expectedNetworkRequest String expectedNetworkRequest = """<network-request xmlns="http://www.w3.org/2001/XMLSchema"> @@ -384,619 +369,6 @@ String expectedNetworkInputsMissingNetworkId = </vnfreq:network-params> </vnfreq:network-request>""" - // expectedNetworkRequest - String expectedNetworkRequest_Outputs = - """<vnfreq:network-request xmlns:vnfreq="http://org.onap/so/infra/vnf-request/v1"> - <vnfreq:request-info> - <vnfreq:request-id>1ef47428-cade-45bd-a103-0751e8b2deb0</vnfreq:request-id> - <vnfreq:action>UPDATE</vnfreq:action> - <vnfreq:source>PORTAL</vnfreq:source> - </vnfreq:request-info> - <vnfreq:network-inputs> - <vnfreq:network-name>MNS-25180-L-01-dmz_direct_net_1</vnfreq:network-name> - <vnfreq:network-type>CONTRAIL_EXTERNAL</vnfreq:network-type> - <vnfreq:service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</vnfreq:service-id> - <vnfreq:aic-cloud-region>RDM2WAGPLCP</vnfreq:aic-cloud-region> - <vnfreq:tenant-id>7dd5365547234ee8937416c65507d266</vnfreq:tenant-id> - </vnfreq:network-inputs> - <vnfreq:network-outputs> - <vnfreq:network-name>MNS-25180-L-01-dmz_direct_net_1</vnfreq:network-name> - <vnfreq:network-id>bdc5efe8-404a-409b-85f6-0dcc9eebae30</vnfreq:network-id> - </vnfreq:network-outputs> - <vnfreq:network-params> - <param name="shared">1</param> - <param name="external">0</param> - </vnfreq:network-params> -</vnfreq:network-request>""" - - - String networkInputs = - """<network-inputs xmlns="http://org.onap/so/infra/vnf-request/v1"> - <network-id>bdc5efe8-404a-409b-85f6-0dcc9eebae30</network-id> - <network-name>MNS-25180-L-01-dmz_direct_net_1</network-name> - <network-type>CONTRAIL_EXTERNAL</network-type> - <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> - <aic-cloud-region>RDM2WAGPLCP</aic-cloud-region> - <tenant-id>e81d842d3e8b45c5a59f57cd76af3aaf</tenant-id> -</network-inputs>""" - - String networkOutputs = - """<network-outputs> - <network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id> - <network-name>MNS-25180-L-01-dmz_direct_net_1</network-name> - </network-outputs>""" - - String queryAAIResponse = - """<rest:RESTResponse xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd" - statusCode="200"> - <rest:headers> - <rest:header name="Transfer-Encoding" value="chunked"/> - <rest:header name="Date" value="Thu,10 Mar 2016 00:01:18 GMT"/> - <rest:header name="Expires" value="Thu,01 Jan 1970 00:00:00 UTC"/> - <rest:header name="X-AAI-TXID" value="mtcnjv9aaas03-20160310-00:01:18:502-132671"/> - <rest:header name="Content-Type" value="application/xml"/> - <rest:header name="Server" value="Apache-Coyote/1.1"/> - <rest:header name="Cache-Control" value="private"/> - </rest:headers> - <rest:payload contentType="text/xml"> - <l3-network xmlns="http://org.openecomp.aai.inventory/v3"> - <network-id>bdc5efe8-404a-409b-85f6-0dcc9eebae30</network-id> - <network-name>MNS-25180-L-01-dmz_direct_net_1</network-name> - <network-type>CONTRAIL_EXTERNAL</network-type> - <network-role>dmz_direct</network-role> - <network-technology>contrail</network-technology> - <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> - <network-role-instance>0</network-role-instance> - <orchestration-status>pending-delete</orchestration-status> - <subnets> - <subnet> - <subnet-id>57e9a1ff-d14f-4071-a828-b19ae98eb2fc</subnet-id> - <gateway-address>107.239.52.1</gateway-address> - <network-start-address>107.239.52.0</network-start-address> - <cidr-mask>24</cidr-mask> - <ip-version>4</ip-version> - <orchestration-status>pending-delete</orchestration-status> - <dhcp-enabled>true</dhcp-enabled> - <relationship-list/> - </subnet> - </subnets> - <relationship-list> - <relationship> - <related-to>vpn-binding</related-to> - <related-link>https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/</related-link> - <relationship-data> - <relationship-key>vpn-binding.vpn-id</relationship-key> - <relationship-value>85f015d0-2e32-4c30-96d2-87a1a27f8017</relationship-value> - </relationship-data> - </relationship> - <relationship> - <related-to>vpn-binding</related-to> - <related-link>https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/</related-link> - <relationship-data> - <relationship-key>vpn-binding.vpn-id</relationship-key> - <relationship-value>c980a6ef-3b88-49f0-9751-dbad8608d0a6</relationship-value> - </relationship-data> - </relationship> - <relationship> - <related-to>tenant</related-to> - <related-link>https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/</related-link> - <relationship-data> - <relationship-key>tenant.tenant-id</relationship-key> - <relationship-value>7dd5365547234ee8937416c65507d266</relationship-value> - </relationship-data> - </relationship> - </relationship-list> - </l3-network> - </rest:payload> -</rest:RESTResponse>""" - - String queryIdAIIResponse = - """<rest:RESTResponse xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd" - statusCode="200"> - <rest:headers> - <rest:header name="Transfer-Encoding" value="chunked"/> - <rest:header name="Date" value="Thu,10 Mar 2016 00:01:18 GMT"/> - <rest:header name="Expires" value="Thu,01 Jan 1970 00:00:00 UTC"/> - <rest:header name="X-AAI-TXID" value="mtcnjv9aaas03-20160310-00:01:18:502-132671"/> - <rest:header name="Content-Type" value="application/xml"/> - <rest:header name="Server" value="Apache-Coyote/1.1"/> - <rest:header name="Cache-Control" value="private"/> - </rest:headers> - <rest:payload contentType="text/xml"> - <l3-network xmlns="http://org.openecomp.aai.inventory/v6"> - <network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id> - <network-name>MNS-25180-L-01-dmz_direct_net_1</network-name> - <network-type>CONTRAIL_EXTERNAL</network-type> - <network-role>dmz_direct</network-role> - <network-technology>contrail</network-technology> - <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> - <network-role-instance>0</network-role-instance> - <resource-version>l3-version</resource-version> - <orchestration-status>pending-delete</orchestration-status> - <heat-stack-id>ST_2Bindings_6006/55288ef0-595c-47d3-819e-cf93aaac6326</heat-stack-id> - <physical-network-name>networkName</physical-network-name> - <is-provider-network>false</is-provider-network> - <is-shared-network>true</is-shared-network> - <is-external-network>false</is-external-network> - <subnets> - <subnet> - <subnet-id>57e9a1ff-d14f-4071-a828-b19ae98eb2fc</subnet-id> - <gateway-address>107.239.52.1</gateway-address> - <network-start-address>107.239.52.0</network-start-address> - <cidr-mask>24</cidr-mask> - <ip-version>4</ip-version> - <orchestration-status>pending-update</orchestration-status> - <dhcp-enabled>true</dhcp-enabled> - <subnet-name>subnetName</subnet-name> - <subnet-role>ECOMP</subnet-role> - <ip-assignment-direction>true</ip-assignment-direction> - <host-routes> - <host-route> - <host-route-id>400d286b-7e44-4514-b9b3-f70f7360ff32</host-route-id> - <route-prefix>172.20.1.0/24</route-prefix> - <next-hop>10.102.200.1</next-hop> - <next-hop-type>ip-address</next-hop-type> - <resource-version>1505857300987</resource-version> - </host-route> - <host-route> - <host-route-id>6f038013-8b15-4eb8-914b-507489fbc8ee</host-route-id> - <route-prefix>10.102.0.0/16</route-prefix> - <next-hop>10.102.200.1</next-hop> - <next-hop-type>ip-address</next-hop-type> - <resource-version>1505857301151</resource-version> - </host-route> - <host-route> - <host-route-id>8811c5f8-f1ed-4fa0-a505-e1be60396e28</host-route-id> - <route-prefix>192.168.2.0/25</route-prefix> - <next-hop>10.102.200.1</next-hop> - <resource-version>1505857301954</resource-version> - </host-route> - </host-routes> - <relationship-list/> - </subnet> - <subnet> - <subnet-id>57e9a1ff-d14f-4071-a828-b19ae98eb2fc</subnet-id> - <gateway-address>107.239.52.1</gateway-address> - <network-start-address>107.239.52.0</network-start-address> - <cidr-mask>24</cidr-mask> - <ip-version>4</ip-version> - <orchestration-status>pending-delete</orchestration-status> - <dhcp-enabled>true</dhcp-enabled> - <subnet-name>subnetName</subnet-name> - <ip-assignment-direction>true</ip-assignment-direction> - <host-routes> - <host-route> - <host-route-id>400d286b-7e44-4514-b9b3-f70f7360ff32</host-route-id> - <route-prefix>172.20.1.0/24</route-prefix> - <next-hop>10.102.200.1</next-hop> - <resource-version>1505857300987</resource-version> - </host-route> - </host-routes> - <relationship-list/> - </subnet> - </subnets> - <segmentation-assignments> - <segmentation-id>414</segmentation-id> - <resource-version>4132176</resource-version> - </segmentation-assignments> - <segmentation-assignments> - <segmentation-id>415</segmentation-id> - <resource-version>4132176</resource-version> - </segmentation-assignments> - <ctag-assignments> - <ctag-assignment> - <vlan-id-inner>inner</vlan-id-inner> - <resource-version>ctag-version</resource-version> - <relationship-list> - <relationship> - <related-to>tenant</related-to> - <related-link>https://aai-ext1.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/897deadc2b954a6bac6d3c197fb3525e/</related-link> - <relationship-data> - <relationship-key>tenant.tenant-id</relationship-key> - <relationship-value>897deadc2b954a6bac6d3c197fb3525e</relationship-value> - </relationship-data> - <related-to-property> - <property-key>tenant.tenant-name</property-key> - <property-value>MSOTest1</property-value> - </related-to-property> - </relationship> - <relationship> - <related-to>vpn-binding</related-to> - <related-link>https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/a290b841-f672-44dd-b9cd-6f8c20d7d8c8/</related-link> - <relationship-data> - <relationship-key>vpn-binding.vpn-id</relationship-key> - <relationship-value>a290b841-f672-44dd-b9cd-6f8c20d7d8c8</relationship-value> - </relationship-data> - <related-to-property> - <property-key>vpn-binding.vpn-name</property-key> - <property-value>oam_protected_net_6_MTN5_msotest2</property-value> - </related-to-property> - </relationship> - <relationship> - <related-to>vpn-binding</related-to> - <related-link>https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/24a4b507-853a-4a38-99aa-05fcc54be24d/</related-link> - <relationship-data> - <relationship-key>vpn-binding.vpn-id</relationship-key> - <relationship-value>24a4b507-853a-4a38-99aa-05fcc54be24d</relationship-value> - </relationship-data> - <related-to-property> - <property-key>vpn-binding.vpn-name</property-key> - <property-value>oam_protected_net_6_MTN5_msotest1</property-value> - </related-to-property> - </relationship> - </relationship-list> - </ctag-assignment> - </ctag-assignments> - <relationship-list> - <relationship> - <related-to>vpn-binding</related-to> - <related-link>https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/</related-link> - <relationship-data> - <relationship-key>vpn-binding.vpn-id</relationship-key> - <relationship-value>85f015d0-2e32-4c30-96d2-87a1a27f8017</relationship-value> - </relationship-data> - </relationship> - <relationship> - <related-to>vpn-binding</related-to> - <related-link>https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/</related-link> - <relationship-data> - <relationship-key>vpn-binding.vpn-id</relationship-key> - <relationship-value>c980a6ef-3b88-49f0-9751-dbad8608d0a6</relationship-value> - </relationship-data> - </relationship> - <relationship> - <related-to>tenant</related-to> - <related-link>https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/</related-link> - <relationship-data> - <relationship-key>tenant.tenant-id</relationship-key> - <relationship-value>7dd5365547234ee8937416c65507d266</relationship-value> - </relationship-data> - </relationship> - <relationship> - <related-to>network-policy</related-to> - <related-link>https://aai-app-e2e.test.com:8443/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg</related-link> - <relationship-data> - <relationship-key>network-policy.network-policy-id</relationship-key> - <relationship-value>cee6d136-e378-4678-a024-2cd15f0ee0cg</relationship-value> - </relationship-data> - </relationship> - <relationship> - <related-to>route-table-reference</related-to> - <related-link>https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN1</related-link> - <relationship-data> - <relationship-key>route-table-reference.route-table-reference-id</relationship-key> - <relationship-value>cee6d136-e378-4678-a024-2cd15f0ee0hi</relationship-value> - </relationship-data> - </relationship> - <relationship> - <related-to>route-table-reference</related-to> - <related-link>https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN2</related-link> - <relationship-data> - <relationship-key>route-table-reference.route-table-reference-id</relationship-key> - <relationship-value>cee6d136-e378-4678-a024-2cd15f0ee0hi</relationship-value> - </relationship-data> - </relationship> - </relationship-list> - </l3-network> - </rest:payload> -</rest:RESTResponse>""" - - String queryIdAIIResponseTestScenario01 = - """<?xml version="1.0" encoding="UTF-8"?> -<l3-network xmlns="http://org.openecomp.aai.inventory/v7"> - <network-id>4da55fe4-7a9e-478c-a434-8a98d62265ab</network-id> - <network-name>GN_EVPN_direct_net_0_ST1</network-name> - <network-type>CONTRAIL30_BASIC</network-type> - <network-role>GN_EVPN_direct</network-role> - <network-technology>contrail</network-technology> - <is-bound-to-vpn>false</is-bound-to-vpn> - <service-id>9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> - <network-role-instance>0</network-role-instance> - <resource-version>1465398611</resource-version> - <orchestration-status>pending-delete</orchestration-status> - <physical-network-name>networkName</physical-network-name> - <is-provider-network>false</is-provider-network> - <is-shared-network>true</is-shared-network> - <is-external-network>false</is-external-network> - <subnets> - <subnet> - <subnet-id>cb1a7b47-5428-44c9-89c2-8b17541c3228</subnet-id> - <gateway-address>108.239.40.1</gateway-address> - <network-start-address>108.239.40.0</network-start-address> - <cidr-mask>28</cidr-mask> - <ip-version>4</ip-version> - <orchestration-status>pending-delete</orchestration-status> - <dhcp-enabled>true</dhcp-enabled> - <dhcp-start>108.239.40.0</dhcp-start> - <dhcp-end>108.239.40.0</dhcp-end> - <resource-version>1465398611</resource-version> - <subnet-name>subnetName</subnet-name> - <relationship-list /> - </subnet> - <subnet> - <subnet-id>e2cc7c14-90f0-4205-840d-b4e07f04e621</subnet-id> - <gateway-address>2606:ae00:2e01:604::1</gateway-address> - <network-start-address>2606:ae00:2e01:604::</network-start-address> - <cidr-mask>64</cidr-mask> - <ip-version>6</ip-version> - <orchestration-status>pending-delete</orchestration-status> - <dhcp-enabled>true</dhcp-enabled> - <dhcp-start>2606:ae00:2e01:604::</dhcp-start> - <dhcp-end>2606:ae00:2e01:604::</dhcp-end> - <resource-version>1465398611</resource-version> - <subnet-name>subnetName</subnet-name> - <relationship-list /> - </subnet> - </subnets> - <ctag-assignments /> - <segmentation-assignments> - <segmentation-id>416</segmentation-id> - <resource-version>4132176</resource-version> - </segmentation-assignments> - <relationship-list> - <relationship> - <related-to>cloud-region</related-to> - <related-link>https://localhost:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/AAIAIC25/ - </related-link> - <relationship-data> - <relationship-key>cloud-region.cloud-region-id</relationship-key> - <relationship-value>AAIAIC25</relationship-value> - </relationship-data> - <relationship-data> - <relationship-key>cloud-region.cloud-owner</relationship-key> - <relationship-value>CloudOwner</relationship-value> - </relationship-data> - <related-to-property> - <property-key>cloud-region.owner-defined-type</property-key> - <property-value></property-value> - </related-to-property> - </relationship> - <relationship> - <related-to>tenant</related-to> - <related-link>https://localhost:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/AAIAIC25/tenants/tenant/4ae1d3446a4c48b2bec44b6cfba06d68/</related-link> - <relationship-data> - <relationship-key>tenant.tenant-id</relationship-key> - <relationship-value>4ae1d3446a4c48b2bec44b6cfba06d68 - </relationship-value> - </relationship-data> - <relationship-data> - <relationship-key>cloud-region.cloud-owner</relationship-key> - <relationship-value>CloudOwner</relationship-value> - </relationship-data> - <relationship-data> - <relationship-key>cloud-region.cloud-region-id</relationship-key> - <relationship-value>AAIAIC25</relationship-value> - </relationship-data> - <related-to-property> - <property-key>tenant.tenant-name</property-key> - <property-value>Ruchira Contrail 3.0 test</property-value> - </related-to-property> - </relationship> - <relationship> - <related-to>vpn-binding</related-to> - <related-link>https://localhost:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/</related-link> - <relationship-data> - <relationship-key>vpn-binding.vpn-id</relationship-key> - <relationship-value>9a7b327d9-287aa00-82c4b0-100001</relationship-value> - </relationship-data> - <related-to-property> - <property-key>vpn-binding.vpn-name</property-key> - <property-value>GN_EVPN_direct_net_0_ST1</property-value> - </related-to-property> - </relationship> - <relationship> - <related-to>route-table-reference</related-to> - <relationship-data> - <relationship-key>route-table-reference.route-table-reference-id</relationship-key> - <relationship-value>cee6d136-e378-4678-a024-2cd15f0ee0hi</relationship-value> - </relationship-data> - </relationship> - </relationship-list> -</l3-network>""" - - String queryIdAIIResponseVpnNotPresent = - """<rest:RESTResponse xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd" - statusCode="200"> - <rest:headers> - <rest:header name="Transfer-Encoding" value="chunked"/> - <rest:header name="Date" value="Thu,10 Mar 2016 00:01:18 GMT"/> - <rest:header name="Expires" value="Thu,01 Jan 1970 00:00:00 UTC"/> - <rest:header name="X-AAI-TXID" value="mtcnjv9aaas03-20160310-00:01:18:502-132671"/> - <rest:header name="Content-Type" value="application/xml"/> - <rest:header name="Server" value="Apache-Coyote/1.1"/> - <rest:header name="Cache-Control" value="private"/> - </rest:headers> - <rest:payload contentType="text/xml"> - <l3-network xmlns="http://org.openecomp.aai.inventory/v6"> - <network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id> - <network-name>MNS-25180-L-01-dmz_direct_net_1</network-name> - <network-type>CONTRAIL_EXTERNAL</network-type> - <network-role>dmz_direct</network-role> - <network-technology>contrail</network-technology> - <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> - <network-role-instance>0</network-role-instance> - <orchestration-status>pending-delete</orchestration-status> - <physical-network-name>networkName</physical-network-name> - <is-provider-network>false</is-provider-network> - <is-shared-network>true</is-shared-network> - <is-external-network>false</is-external-network> - <subnets> - <subnet> - <subnet-id>57e9a1ff-d14f-4071-a828-b19ae98eb2fc</subnet-id> - <gateway-address>107.239.52.1</gateway-address> - <network-start-address>107.239.52.0</network-start-address> - <cidr-mask>24</cidr-mask> - <ip-version>4</ip-version> - <orchestration-status>pending-delete</orchestration-status> - <dhcp-enabled>true</dhcp-enabled> - <subnet-name>subnetName</subnet-name> - <relationship-list/> - </subnet> - </subnets> - <relationship-list/> - </l3-network> - </rest:payload> -</rest:RESTResponse>""" - - String queryNameAIIResponse = - """<rest:RESTResponse xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd" - statusCode="200"> - <rest:headers> - <rest:header name="Transfer-Encoding" value="chunked"/> - <rest:header name="Date" value="Thu,10 Mar 2016 00:01:18 GMT"/> - <rest:header name="Expires" value="Thu,01 Jan 1970 00:00:00 UTC"/> - <rest:header name="X-AAI-TXID" value="mtcnjv9aaas03-20160310-00:01:18:502-132671"/> - <rest:header name="Content-Type" value="application/xml"/> - <rest:header name="Server" value="Apache-Coyote/1.1"/> - <rest:header name="Cache-Control" value="private"/> - </rest:headers> - <rest:payload contentType="text/xml"> - <l3-network xmlns="http://org.openecomp.aai.inventory/v6"> - <network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id> - <network-name>MNS-25180-L-01-dmz_direct_net_1</network-name> - <network-type>CONTRAIL_EXTERNAL</network-type> - <network-role>dmz_direct</network-role> - <network-technology>contrail</network-technology> - <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> - <network-role-instance>0</network-role-instance> - <orchestration-status>pending-delete</orchestration-status> - <subnets> - <subnet> - <subnet-id>57e9a1ff-d14f-4071-a828-b19ae98eb2fc</subnet-id> - <gateway-address>107.239.52.1</gateway-address> - <network-start-address>107.239.52.0</network-start-address> - <cidr-mask>24</cidr-mask> - <ip-version>4</ip-version> - <orchestration-status>pending-delete</orchestration-status> - <dhcp-enabled>true</dhcp-enabled> - <relationship-list/> - </subnet> - </subnets> - <relationship-list> - <relationship> - <related-to>vpn-binding</related-to> - <related-link>https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/</related-link> - <relationship-data> - <relationship-key>vpn-binding.vpn-id</relationship-key> - <relationship-value>85f015d0-2e32-4c30-96d2-87a1a27f8017</relationship-value> - </relationship-data> - </relationship> - <relationship> - <related-to>vpn-binding</related-to> - <related-link>https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/</related-link> - <relationship-data> - <relationship-key>vpn-binding.vpn-id</relationship-key> - <relationship-value>c980a6ef-3b88-49f0-9751-dbad8608d0a6</relationship-value> - </relationship-data> - </relationship> - <relationship> - <related-to>tenant</related-to> - <related-link>https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/</related-link> - <relationship-data> - <relationship-key>tenant.tenant-id</relationship-key> - <relationship-value>7dd5365547234ee8937416c65507d266</relationship-value> - </relationship-data> - </relationship> - </relationship-list> - </l3-network> - </rest:payload> - </rest:RESTResponse>""" - - String queryNameAIIResponseVpnNotPresent = - """<rest:RESTResponse xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd" - statusCode="200"> - <rest:headers> - <rest:header name="Transfer-Encoding" value="chunked"/> - <rest:header name="Date" value="Thu,10 Mar 2016 00:01:18 GMT"/> - <rest:header name="Expires" value="Thu,01 Jan 1970 00:00:00 UTC"/> - <rest:header name="X-AAI-TXID" value="mtcnjv9aaas03-20160310-00:01:18:502-132671"/> - <rest:header name="Content-Type" value="application/xml"/> - <rest:header name="Server" value="Apache-Coyote/1.1"/> - <rest:header name="Cache-Control" value="private"/> - </rest:headers> - <rest:payload contentType="text/xml"> - <l3-network xmlns="http://org.openecomp.aai.inventory/v6> - <network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id> - <network-name>MNS-25180-L-01-dmz_direct_net_1</network-name> - <network-type>CONTRAIL_EXTERNAL</network-type> - <network-role>dmz_direct</network-role> - <network-technology>contrail</network-technology> - <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> - <network-role-instance>0</network-role-instance> - <orchestration-status>pending-delete</orchestration-status> - <subnets> - <subnet> - <subnet-id>57e9a1ff-d14f-4071-a828-b19ae98eb2fc</subnet-id> - <gateway-address>107.239.52.1</gateway-address> - <network-start-address>107.239.52.0</network-start-address> - <cidr-mask>24</cidr-mask> - <ip-version>4</ip-version> - <orchestration-status>pending-delete</orchestration-status> - <dhcp-enabled>true</dhcp-enabled> - <relationship-list/> - </subnet> - </subnets> - </l3-network> - </rest:payload> - </rest:RESTResponse>""" - - String aaiVpnResponseStub = - """<rest:payload xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd" - xmlns="http://org.openecomp.aai.inventory/v8" - contentType="text/xml"> - <vpn-binding> - <global-route-target/> - </vpn-binding> -</rest:payload>""" - - String queryVpnBindingAAIResponse = - """<rest:RESTResponse xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd" - statusCode="200"> - <rest:headers> - <rest:header name="Transfer-Encoding" value="chunked"/> - <rest:header name="Date" value="Mon,14 Mar 2016 20:53:33 GMT"/> - <rest:header name="Expires" value="Thu,01 Jan 1970 00:00:00 UTC"/> - <rest:header name="X-AAI-TXID" - value="localhost-20160314-20:53:33:487-134392"/> - <rest:header name="Content-Type" value="application/xml"/> - <rest:header name="Server" value="Apache-Coyote/1.1"/> - <rest:header name="Cache-Control" value="private"/> - </rest:headers> - <rest:payload contentType="text/xml"> - <vpn-binding xmlns="http://org.openecomp.aai.inventory/v6"> - <vpn-id>9a7b327d9-287aa00-82c4b0-105757</vpn-id> - <vpn-name>GN_EVPN_Test</vpn-name> - <global-route-target>13979:105757</global-route-target> - <relationship-list> - <relationship> - <related-to>l3-network</related-to> - <related-link>https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/689ec39e-c5fc-4462-8db2-4f760763ad28/</related-link> - <relationship-data> - <relationship-key>l3-network.network-id</relationship-key> - <relationship-value>689ec39e-c5fc-4462-8db2-4f760763ad28</relationship-value> - </relationship-data> - </relationship> - <relationship> - <related-to>l3-network</related-to> - <related-link>https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/1a49396b-19b3-40a4-8792-aa2fbd0f0704/</related-link> - <relationship-data> - <relationship-key>l3-network.network-id</relationship-key> - <relationship-value>1a49396b-19b3-40a4-8792-aa2fbd0f0704</relationship-value> - </relationship-data> - </relationship> - <relationship> - <related-to>l3-network</related-to> - <related-link>https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/774f3329-3c83-4771-86c7-9e6207cd50fd/</related-link> - <relationship-data> - <relationship-key>l3-network.network-id</relationship-key> - <relationship-value>774f3329-3c83-4771-86c7-9e6207cd50fd</relationship-value> - </relationship-data> - </relationship> - </relationship-list> - </vpn-binding> - </rest:payload> -</rest:RESTResponse>""" - String updateNetworkRequest = """<updateNetworkRequest> @@ -1172,271 +544,10 @@ String updateNetworkRequest_noPhysicalName = </networkRollback> </rollbackNetworkRequest>""" - String updateNetworkResponse = - """<ns2:updateNetworkContrailResponse xmlns:ns2="http://org.onap.so/network" - xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> - <networkId>MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641</networkId> - <neutronNetworkId>c4f4e878-cde0-4b15-ae9a-bda857759cea</neutronNetworkId> - <networkStackId>MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641</networkStackId> - <networkFqdn>default-domain:MSOTest:GN_EVPN_direct_net_0_ST1</networkFqdn> - <subnetIdMap> - <entry> - <key>57e9a1ff-d14f-4071-a828-b19ae98eb2fc</key> - <value>bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73</value> - </entry> - </subnetIdMap> - <rollback> - <cloudId>RDM2WAGPLCP</cloudId> - <msoRequest> - <requestId>1ef47428-cade-45bd-a103-0751e8b2deb0</requestId> - <serviceInstanceId/> - </msoRequest> - <networkUpdated>true</networkUpdated> - <networkId>MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641</networkId> - <networkType>CONTRAIL_EXTERNAL</networkType> - <networkUpdated>false</networkUpdated> - <neutronNetworkId>c4f4e878-cde0-4b15-ae9a-bda857759cea</neutronNetworkId> - <tenantId>7dd5365547234ee8937416c65507d266</tenantId> - </rollback> -</ns2:updateNetworkContrailResponse>""" - - String updateContrailAAIPayloadRequest = - """<l3-network xmlns="http://org.openecomp.aai.inventory/v9"> - <network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id> - <network-name>MNS-25180-L-01-dmz_direct_net_1</network-name> - <network-type>CONTRAIL_EXTERNAL</network-type> - <network-role>dmz_direct</network-role> - <network-technology>contrail</network-technology> - <neutron-network-id>c4f4e878-cde0-4b15-ae9a-bda857759cea</neutron-network-id> - <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> - <network-role-instance>0</network-role-instance> - <resource-version>l3-version</resource-version> - <orchestration-status>Active</orchestration-status> - <heat-stack-id>ST_2Bindings_6006/55288ef0-595c-47d3-819e-cf93aaac6326</heat-stack-id> - <contrail-network-fqdn>default-domain:MSOTest:GN_EVPN_direct_net_0_ST1</contrail-network-fqdn> - <physical-network-name>networkName</physical-network-name> - <is-provider-network>false</is-provider-network> - <is-shared-network>true</is-shared-network> - <is-external-network>false</is-external-network> - <subnets> - <subnet> - <subnet-id>57e9a1ff-d14f-4071-a828-b19ae98eb2fc</subnet-id> - <neutron-subnet-id>bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73</neutron-subnet-id> - <gateway-address>107.239.52.1</gateway-address> - <network-start-address>107.239.52.0</network-start-address> - <cidr-mask>24</cidr-mask> - <ip-version>4</ip-version> - <orchestration-status>Active</orchestration-status> - <dhcp-enabled>true</dhcp-enabled> - <subnet-role>ECOMP</subnet-role> - <resource-version>1505857300987</resource-version> - <subnet-name>subnetName</subnet-name> - <ip-assignment-direction>true</ip-assignment-direction> - <host-routes> - <host-route> - <host-route-id>400d286b-7e44-4514-b9b3-f70f7360ff32</host-route-id> - <route-prefix>172.20.1.0/24</route-prefix> - <next-hop>10.102.200.1</next-hop> - <next-hop-type>ip-address</next-hop-type> - <resource-version>1505857300987</resource-version> - </host-route> - <host-route> - <host-route-id>6f038013-8b15-4eb8-914b-507489fbc8ee</host-route-id> - <route-prefix>10.102.0.0/16</route-prefix> - <next-hop>10.102.200.1</next-hop> - <next-hop-type>ip-address</next-hop-type> - <resource-version>1505857301151</resource-version> - </host-route> - <host-route> - <host-route-id>8811c5f8-f1ed-4fa0-a505-e1be60396e28</host-route-id> - <route-prefix>192.168.2.0/25</route-prefix> - <next-hop>10.102.200.1</next-hop> - <next-hop-type/> - <resource-version>1505857301954</resource-version> - </host-route> - </host-routes> - </subnet> - </subnets> - <segmentation-assignments> - <segmentation-id>414</segmentation-id> - <resource-version>4132176</resource-version> - </segmentation-assignments> - <segmentation-assignments> - <segmentation-id>415</segmentation-id> - <resource-version>4132176</resource-version> - </segmentation-assignments> - <ctag-assignments> - <ctag-assignment> - <vlan-id-inner>inner</vlan-id-inner> - <resource-version>ctag-version</resource-version> - <relationship-list> - <relationship> - <related-to>tenant</related-to> - <related-link>https://aai-ext1.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/897deadc2b954a6bac6d3c197fb3525e/</related-link> - <relationship-data> - <relationship-key>tenant.tenant-id</relationship-key> - <relationship-value>897deadc2b954a6bac6d3c197fb3525e</relationship-value> - </relationship-data> - <related-to-property> - <property-key>tenant.tenant-name</property-key> - <property-value>MSOTest1</property-value> - </related-to-property> - </relationship> - <relationship> - <related-to>vpn-binding</related-to> - <related-link>https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/a290b841-f672-44dd-b9cd-6f8c20d7d8c8/</related-link> - <relationship-data> - <relationship-key>vpn-binding.vpn-id</relationship-key> - <relationship-value>a290b841-f672-44dd-b9cd-6f8c20d7d8c8</relationship-value> - </relationship-data> - <related-to-property> - <property-key>vpn-binding.vpn-name</property-key> - <property-value>oam_protected_net_6_MTN5_msotest2</property-value> - </related-to-property> - </relationship> - <relationship> - <related-to>vpn-binding</related-to> - <related-link>https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/24a4b507-853a-4a38-99aa-05fcc54be24d/</related-link> - <relationship-data> - <relationship-key>vpn-binding.vpn-id</relationship-key> - <relationship-value>24a4b507-853a-4a38-99aa-05fcc54be24d</relationship-value> - </relationship-data> - <related-to-property> - <property-key>vpn-binding.vpn-name</property-key> - <property-value>oam_protected_net_6_MTN5_msotest1</property-value> - </related-to-property> - </relationship> - </relationship-list> - </ctag-assignment> - </ctag-assignments> - <relationship-list> - <relationship> - <related-to>vpn-binding</related-to> - <related-link>https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/</related-link> - <relationship-data> - <relationship-key>vpn-binding.vpn-id</relationship-key> - <relationship-value>85f015d0-2e32-4c30-96d2-87a1a27f8017</relationship-value> - </relationship-data> - </relationship> - <relationship> - <related-to>vpn-binding</related-to> - <related-link>https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/</related-link> - <relationship-data> - <relationship-key>vpn-binding.vpn-id</relationship-key> - <relationship-value>c980a6ef-3b88-49f0-9751-dbad8608d0a6</relationship-value> - </relationship-data> - </relationship> - <relationship> - <related-to>tenant</related-to> - <related-link>https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/</related-link> - <relationship-data> - <relationship-key>tenant.tenant-id</relationship-key> - <relationship-value>7dd5365547234ee8937416c65507d266</relationship-value> - </relationship-data> - </relationship> - <relationship> - <related-to>network-policy</related-to> - <related-link>https://aai-app-e2e.test.com:8443/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg</related-link> - <relationship-data> - <relationship-key>network-policy.network-policy-id</relationship-key> - <relationship-value>cee6d136-e378-4678-a024-2cd15f0ee0cg</relationship-value> - </relationship-data> - </relationship> - <relationship> - <related-to>route-table-reference</related-to> - <related-link>https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN1</related-link> - <relationship-data> - <relationship-key>route-table-reference.route-table-reference-id</relationship-key> - <relationship-value>cee6d136-e378-4678-a024-2cd15f0ee0hi</relationship-value> - </relationship-data> - </relationship> - <relationship> - <related-to>route-table-reference</related-to> - <related-link>https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN2</related-link> - <relationship-data> - <relationship-key>route-table-reference.route-table-reference-id</relationship-key> - <relationship-value>cee6d136-e378-4678-a024-2cd15f0ee0hi</relationship-value> - </relationship-data> - </relationship> - </relationship-list> -</l3-network>""" - - - String updateContrailAAIResponse = - """<rest:RESTResponse xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd" - statusCode="200"> - <rest:headers> - <rest:header name="Date" value="Thu,10 Mar 2016 00:01:18 GMT"/> - <rest:header name="Content-Length" value="0"/> - <rest:header name="Expires" value="Thu,01 Jan 1970 00:00:00 UTC"/> - <rest:header name="X-AAI-TXID" value="mtcnjv9aaas03-20160310-00:01:18:551-132672"/> - <rest:header name="Server" value="Apache-Coyote/1.1"/> - <rest:header name="Cache-Control" value="private"/> - </rest:headers> -</rest:RESTResponse>""" - - String updateNetworkErrorResponse = - """<updateNetworkError> - <messageId>680bd458-5ec1-4a16-b77c-509022e53450</messageId><category>INTERNAL</category> - <message>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</message> - <rolledBack>true</rolledBack> - </updateNetworkError>""" - String networkException500 = """<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:VersionMismatch</faultcode><faultstring>"http://org.onap.so/network", the namespace on the "updateNetworkContrail" element, is not a valid SOAP version.</faultstring></soap:Fault></soap:Body></soap:Envelope>""" - String aaiResponse = - """<rest:RESTResponse xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd" - statusCode="200"> - <rest:headers> - <rest:header name="Transfer-Encoding" value="chunked"/> - <rest:header name="Date" value="Sat,30 Jan 2016 20:09:24 GMT"/> - <rest:header name="Expires" value="Thu,01 Jan 1970 00:00:00 UTC"/> - <rest:header name="X-AAI-TXID" - value="localhost-20160130-20:09:24:814-165843"/> - <rest:header name="Content-Type" value="application/xml"/> - <rest:header name="Server" value="Apache-Coyote/1.1"/> - <rest:header name="Cache-Control" value="private"/> - </rest:headers> - <rest:payload contentType="text/xml"> - <l3-network xmlns="http://org.openecomp.aai.inventory/v3"> - <network-id>bdc5efe8-404a-409b-85f6-0dcc9eebae30</network-id> - <network-name>MNS-25180-L-01-dmz_direct_net_1</network-name> - <network-type>CONTRAIL_EXTERNAL</network-type> - <network-role>HSL_direct</network-role> - <network-technology>contrail</network-technology> - <neutron-network-id>8bbd3edf-b835-4610-96a2-a5cafa029042</neutron-network-id> - <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id> - <orchestration-status>active</orchestration-status> - <heat-stack-id>MNS-25180-L-01-dmz_direct_net_1/57594a56-1c92-4a38-9caa-641c1fa3d4b6</heat-stack-id> - <subnets> - <subnet> - <subnet-id>ea5f2a2c-604f-47ff-a9c5-253ee4f0ef0a</subnet-id> - <neutron-subnet-id>5a77fdc2-7789-4649-a1b9-6eaf1db1813a</neutron-subnet-id> - <gateway-address>172.16.34.1</gateway-address> - <network-start-address>172.16.34.0</network-start-address> - <cidr-mask>28</cidr-mask> - <ip-version>4</ip-version> - <orchestration-status>active</orchestration-status> - <dhcp-enabled>true</dhcp-enabled> - <relationship-list/> - </subnet> - </subnets> - <relationship-list> - <relationship> - <related-to>tenant</related-to> - <related-link>https://aai-app-e2e.test.com:8443/aai/v3/cloud-infrastructure/tenants/tenant/e81d842d3e8b45c5a59f57cd76af3aaf/</related-link> - <relationship-data> - <relationship-key>tenant.tenant-id</relationship-key> - <relationship-value>e81d842d3e8b45c5a59f57cd76af3aaf</relationship-value> - </relationship-data> - </relationship> - </relationship-list> - </l3-network> - </rest:payload> - </rest:RESTResponse>""" - String changeAssignSDNCRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" xmlns:ns5="http://org.onap/so/request/types/v1" @@ -1465,8 +576,8 @@ String updateNetworkRequest_noPhysicalName = </service-information> <network-request-information> <network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id> - <network-type>CONTRAIL_EXTERNAL</network-type> - <network-name>MNS-25180-L-01-dmz_direct_net_1</network-name> + <network-type>CONTRAIL30_BASIC</network-type> + <network-name>vprobes_pktinternal_net_4_1806</network-name> <tenant>7dd5365547234ee8937416c65507d266</tenant> <aic-cloud-region>RDM2WAGPLCP</aic-cloud-region> </network-request-information> @@ -1545,42 +656,6 @@ String assignResponse = </sdncadapterworkflow:response-data> </sdncadapterworkflow:SDNCAdapterWorkflowResponse>""" - String expected_sdncAdapterWorkflowResponse_Error = - """<sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns="com:att:sdnctl:vnf" - xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1" - xmlns:tag0="http://org.onap.so/workflow/sdnc/adapter/schema/v1" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <sdncadapterworkflow:response-data> - <tag0:RequestData xsi:type="xs:string"> - <output> - <response-code>400</response-code> - <response-message>Error writing to l3-netework</response-message> - <ack-final-indicator>Y</ack-final-indicator> - <svc-request-id>c79240d8-34b5-4853-af69-2021928dba00</svc-request-id> - </output> - </tag0:RequestData> - </sdncadapterworkflow:response-data> -</sdncadapterworkflow:SDNCAdapterWorkflowResponse>""" - - String sdncAdapterWorkflowFormattedResponse = - """<aetgt:SDNCAdapterWorkflowResponse xmlns:aetgt="http://org.onap/so/workflow/schema/v1" - xmlns="com:att:sdnctl:vnf"> - <aetgt:response-data> - <output> - <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>f70e927b-6087-4974-9ef8-c5e4d5847ca4</service-instance-id> - <subscriber-name>notsurewecare</subscriber-name> - </service-information> - </output> - </aetgt:response-data> -</aetgt:SDNCAdapterWorkflowResponse>""" String rollbackSDNCRequest = """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1" @@ -1649,6 +724,22 @@ String rollbackNetworkRequest = // - - - - - - - - + @BeforeClass + static void initEnv() { + MockEnvironment mockEnvironment = mock(MockEnvironment.class) + when(mockEnvironment.getProperty("mso.workflow.global.default.aai.version")).thenReturn("14") + when(mockEnvironment.getProperty("mso.workflow.global.default.aai.namespace")).thenReturn("defaultTestNamespace") + when(mockEnvironment.getProperty("aai.endpoint")).thenReturn("http://localhost:8090") + UrnPropertiesReader urnPropertiesReader = new UrnPropertiesReader() + urnPropertiesReader.setEnvironment(mockEnvironment) + } + + @AfterClass + static void cleanupEnv() { + UrnPropertiesReader urnPropertiesReader = new UrnPropertiesReader() + urnPropertiesReader.setEnvironment(null) + } + @Before public void init() { @@ -1743,117 +834,126 @@ String rollbackNetworkRequest = } - @Test - //@Ignore - public void preProcessRequest_NetworkRequest() { - - println "************ preProcessRequest_Payload ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("isBaseVfModule")).thenReturn(true) - when(mockExecution.getVariable("recipeTimeout")).thenReturn(0) - when(mockExecution.getVariable("requestAction")).thenReturn("UPDATE") - when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") - when(mockExecution.getVariable("vnfId")).thenReturn("") - when(mockExecution.getVariable("volumeGroupId")).thenReturn("") - when(mockExecution.getVariable("networkId")).thenReturn("49c86598-f766-46f8-84f8-8d1c1b10f9b4") - when(mockExecution.getVariable("serviceType")).thenReturn("MOG") - when(mockExecution.getVariable("networkType")).thenReturn("modelName") - when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest) - when(mockExecution.getVariable("sdncVersion")).thenReturn("1610") - when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso.rollback")).thenReturn("true") - when(mockExecution.getVariable("disableRollback")).thenReturn("true") - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.preProcessRequest(mockExecution) - -// verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix + "") - - //verify variable initialization - initializeVariables(mockExecution) - - // Authentications - verify(mockExecution).setVariable("action", "UPDATE") - verify(mockExecution).setVariable(Prefix + "networkRequest", expectedNetworkRequest) - verify(mockExecution).setVariable(Prefix + "rollbackEnabled", false) - verify(mockExecution).setVariable(Prefix + "networkInputs", expectedNetworkInputs) - verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") - verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") - verify(mockExecution).setVariable(Prefix + "networkOutputs", "") - - } - - @Test - //@Ignore - public void preProcessRequest_vPERNetworkRequest() { - - String networkModelInfo = """{"modelUuid": "sn5256d1-5a33-55df-13ab-12abad84e111", + @Test + public void preProcessRequest_NetworkRequest() { + + println "************ preProcessRequest_Payload ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable("requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("requestAction")).thenReturn("UPDATE") + when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable("networkId")).thenReturn("49c86598-f766-46f8-84f8-8d1c1b10f9b4") + when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest) + when(mockExecution.getVariable("sdncVersion")).thenReturn("1610") + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("mso.adapters.po.auth")). + thenReturn("5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.preProcessRequest(mockExecution) + + 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(Prefix + "messageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + verify(mockExecution).setVariable(Prefix + "source", "VID") + verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic dGVzdDp0ZXN0") + verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic dGVzdDp0ZXN0") + verify(mockExecution).setVariable(Prefix + "serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4") + verify(mockExecution).setVariable(Prefix + "networkOutputs", """<network-outputs> +\t <network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id> +\t <network-name>MNS-25180-L-01-dmz_direct_net_1</network-name> +\t </network-outputs>""") + verify(mockExecution).setVariable(Prefix + "networkId", "49c86598-f766-46f8-84f8-8d1c1b10f9b4") + verify(mockExecution).setVariable(Prefix + "networkName", "MNS-25180-L-01-dmz_direct_net_1") + } + + @Test + public void preProcessRequest_vPERNetworkRequest() { + + String networkModelInfo = """{"modelUuid": "sn5256d1-5a33-55df-13ab-12abad84e111", "modelName": "CONTRAIL_EXTERNAL", - "modelType": "CONTRAIL_EXTERNAL", - "modelVersion": "1", - "modelCustomizationUuid": "sn5256d1-5a33-55df-13ab-12abad84e222", - "modelInvariantUuid": "sn5256d1-5a33-55df-13ab-12abad84e764" - }""".trim() - - println "************ preProcessRequest_Payload ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("msoRequestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("disableRollback")).thenReturn("true") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") - when(mockExecution.getVariable("networkId")).thenReturn("49c86598-f766-46f8-84f8-8d1c1b10f9b4") // optional - when(mockExecution.getVariable("networkName")).thenReturn("MNS-25180-L-01-dmz_direct_net_1") // optional - when(mockExecution.getVariable("productFamilyId")).thenReturn("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb") - when(mockExecution.getVariable("networkModelInfo")).thenReturn("CONTRAIL_EXTERNAL") - when(mockExecution.getVariable("lcpCloudRegionId")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable("tenantId")).thenReturn("7dd5365547234ee8937416c65507d266") - when(mockExecution.getVariable("failIfExists")).thenReturn("false") - when(mockExecution.getVariable("networkModelInfo")).thenReturn(networkModelInfo) - when(mockExecution.getVariable("sdncVersion")).thenReturn("1702") - when(mockExecution.getVariable("action")).thenReturn("UPDATE") - when(mockExecution.getVariable("subscriptionServiceType")).thenReturn("MSO-dev-service-type") - when(mockExecution.getVariable("globalSubscriberId")).thenReturn("globalId_45678905678") - when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - - when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - when(mockExecution.getVariable("mso.rollback")).thenReturn("true") - when(mockExecution.getVariable("mso.adapters.sdnc.endpoint")).thenReturn("http://localhost:8090/SDNCAdapter") - when(mockExecution.getVariable("mso.adapters.network.rest.endpoint")).thenReturn("http://localhost:8090/networks/NetworkAdapter") - when(mockExecution.getVariable("mso.adapters.sdnc.resource.endpoint")).thenReturn("http://localhost:8090/SDNCAdapterRpc") - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.preProcessRequest(mockExecution) - -// verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix + "") - - //verify variable initialization - initializeVariables(mockExecution) - - // Authentications - verify(mockExecution).setVariable("action", "UPDATE") - verify(mockExecution).setVariable(Prefix + "networkRequest", expectedVperNetworkRequest) - verify(mockExecution).setVariable(Prefix + "rollbackEnabled", false) - verify(mockExecution).setVariable(Prefix + "networkInputs", expectedVperNetworkInputs) - verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") - verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") - verify(mockExecution).setVariable(Prefix + "networkOutputs", "") - - } - - @Test + "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("action")).thenReturn("UPDATE") + + 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("subscriptionServiceType")).thenReturn("MSO-dev-service-type") + when(mockExecution.getVariable("globalSubscriberId")).thenReturn("globalId_45678905678") + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + + when(mockExecution.getVariable("mso.adapters.po.auth")). + thenReturn("5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C") + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + + when(mockExecution.getVariable("mso.rollback")).thenReturn("true") + when(mockExecution.getVariable("mso.adapters.sdnc.endpoint")). + thenReturn("http://localhost:8090/SDNCAdapter") + when(mockExecution.getVariable("mso.adapters.network.rest.endpoint")). + thenReturn("http://localhost:8090/networks/NetworkAdapter") + when(mockExecution.getVariable("mso.adapters.sdnc.resource.endpoint")). + thenReturn("http://localhost:8090/SDNCAdapterRpc") + + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.preProcessRequest(mockExecution) + + 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(Prefix + "messageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") + verify(mockExecution).setVariable(Prefix + "source", "VID") + verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic dGVzdDp0ZXN0") + verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic dGVzdDp0ZXN0") + verify(mockExecution).setVariable(Prefix + "serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4") + verify(mockExecution).setVariable(eq(Prefix + "networkOutputs"), eq("""<network-outputs> +\t <network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id> +\t <network-name>MNS-25180-L-01-dmz_direct_net_1</network-name> +\t </network-outputs>""")) + + verify(mockExecution).setVariable(Prefix + "networkId", "49c86598-f766-46f8-84f8-8d1c1b10f9b4") + verify(mockExecution).setVariable(Prefix + "networkName", "MNS-25180-L-01-dmz_direct_net_1") + } + + @Test //@Ignore public void preProcessRequest_MissingNetworkId() { @@ -1968,107 +1068,88 @@ String rollbackNetworkRequest = } - @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("<routeTargets>13979:105757</routeTargets><routeTargets>13979:105757</routeTargets>") - when(mockExecution.getVariable(Prefix + "networkCollection")).thenReturn("<policyFqdns>GN_EVPN_Test</policyFqdns>") - when(mockExecution.getVariable(Prefix + "tableRefCollection")).thenReturn("<routeTableFqdns>refFQDN1</routeTableFqdns><routeTableFqdns>refFQDN2</routeTableFqdns>") - when(mockExecution.getVariable(Prefix + "requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - //when(mockExecution.getVariable("URN_?????")).thenReturn("") // notificationUrl, //TODO - is this coming from URN? What variable/value to use? - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable(Prefix + "rollbackEnabled")).thenReturn("true") - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.prepareUpdateNetworkRequest(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution).setVariable("prefix", Prefix + "") - - verify(mockExecution).setVariable(Prefix + "updateNetworkRequest", updateNetworkRequest) - - } - - - @Test - //@Ignore - public void prepareUpdateNetworkRequest_NoPhysicalname() { - - println "************ prepareNetworkRequest ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(NetworkRequest_noPhysicalName) - when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - when(mockExecution.getVariable(Prefix + "cloudRegionPo")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("messageId_generated") - when(mockExecution.getVariable(Prefix + "source")).thenReturn("VID") - //when(mockExecution.getVariable(Prefix + "queryVpnBindingAAIResponse")).thenReturn(queryVpnBindingAAIResponse) - when(mockExecution.getVariable(Prefix + "routeCollection")).thenReturn("<routeTargets>13979:105757</routeTargets><routeTargets>13979:105757</routeTargets>") - when(mockExecution.getVariable(Prefix + "networkCollection")).thenReturn("<policyFqdns>GN_EVPN_Test</policyFqdns>") - when(mockExecution.getVariable(Prefix + "tableRefCollection")).thenReturn("") - when(mockExecution.getVariable(Prefix + "requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - //when(mockExecution.getVariable("URN_?????")).thenReturn("") // notificationUrl, //TODO - is this coming from URN? What variable/value to use? - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable(Prefix + "rollbackEnabled")).thenReturn("true") - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.prepareUpdateNetworkRequest(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution).setVariable("prefix", Prefix + "") - - verify(mockExecution).setVariable(Prefix + "updateNetworkRequest", updateNetworkRequest_noPhysicalName) - - } - - @Test - //@Ignore - public void prepareSDNCRequest() { - - println "************ prepareSDNCRequest ************* " - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable(Prefix + "serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") - when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).thenReturn(aaiResponse) - when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("GENGSI_siResourceLink")).thenReturn("https://aai-int1.test.com:8443/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/6d4eb22a-82f1-4257-9f80-4176262cfe69/") - - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.prepareSDNCRequest(mockExecution) - - // verify set prefix = Prefix + "" - verify(mockExecution).setVariable("prefix", Prefix + "") - verify(mockExecution).setVariable(Prefix + "changeAssignSDNCRequest", changeAssignSDNCRequest) - - } + @Test + public void prepareUpdateNetworkRequest() { + + println "************ prepareNetworkRequest ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedVperNetworkRequest) + when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(getContrailL3Network()) + 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 + "routeCollection")). + thenReturn("<routeTargets>13979:105757</routeTargets><routeTargets>13979:105757</routeTargets>") + when(mockExecution.getVariable(Prefix + "networkCollection")). + thenReturn("<policyFqdns>GN_EVPN_Test</policyFqdns>") + when(mockExecution.getVariable(Prefix + "tableRefCollection")). + thenReturn("<routeTableFqdns>refFQDN1</routeTableFqdns><routeTableFqdns>refFQDN2</routeTableFqdns>") + when(mockExecution.getVariable(Prefix + "requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable(Prefix + "rollbackEnabled")).thenReturn("true") + + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.prepareUpdateNetworkRequest(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "updateNetworkRequest", updateNetworkRequest) + } + + + @Test + public void prepareUpdateNetworkRequest_NoPhysicalname() { + + println "************ prepareNetworkRequest ************* " + ExecutionEntity mockExecution = setupMock() + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("messageId_generated") + when(mockExecution.getVariable(Prefix + "source")).thenReturn("VID") + + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(NetworkRequest_noPhysicalName) + when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")). + thenReturn(getContrailL3Network()) + when(mockExecution.getVariable(Prefix + "cloudRegionPo")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(Prefix + "rollbackEnabled")).thenReturn("true") + + when(mockExecution.getVariable(Prefix + "routeCollection")).thenReturn("<routeTargets>13979:105757</routeTargets><routeTargets>13979:105757</routeTargets>") + when(mockExecution.getVariable(Prefix + "networkCollection")).thenReturn("<policyFqdns>GN_EVPN_Test</policyFqdns>") + when(mockExecution.getVariable(Prefix + "tableRefCollection")).thenReturn("") + + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.prepareUpdateNetworkRequest(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "updateNetworkRequest", updateNetworkRequest_noPhysicalName) + } + + @Test + public void prepareSDNCRequest() { + + println "************ prepareSDNCRequest ************* " + + ExecutionEntity mockExecution = mock(ExecutionEntity.class) + // Initialize prerequisite variables + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable(Prefix + "cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") + when(mockExecution.getVariable(Prefix + "serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") + when(mockExecution.getVariable(Prefix + "queryIdAAIResponse")).thenReturn( + new AAIResultWrapper(FileUtil.readResourceFile("__files/BuildingBlocks/Network/queryAAINetworkTestResponse.json"))) + when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("testMessageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") + when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://localhost:8090/SDNCAdapterCallback") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("GENGSI_siResourceLink")).thenReturn( + "https://aai-int1.test.com:8443/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/6d4eb22a-82f1-4257-9f80-4176262cfe69/") + + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.prepareSDNCRequest(mockExecution) + + // verify set prefix = Prefix + "" + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "changeAssignSDNCRequest", changeAssignSDNCRequest) + } @Test //@Ignore @@ -2101,614 +1182,412 @@ String rollbackNetworkRequest = } - @Test - //@Ignore - public void callRESTQueryAAINetworkId_200() { + @Test + public void callRESTQueryAAINetworkId_200() { + + println "************ callRESTQueryAAINetworkId ************* " + + WireMock.reset(); + MockGetNetworkByIdWithDepth(wireMockRule, "49c86598-f766-46f8-84f8-8d1c1b10f9b4", + "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", "1"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) + + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTQueryAAINetworkId(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "aaiIdReturnCode", "200") + verify(mockExecution).setVariable(eq(Prefix + "queryIdAAIResponse"), isA(AAIResultWrapper.class)) + } + + @Test + public void callRESTQueryAAICloudRegion30_200() { + + println "************ callRESTQueryAAICloudRegion30_200 ************* " + + WireMock.reset(); + MockGetNetworkCloudRegion(wireMockRule, "CreateNetworkV2/cloudRegion30_AAIResponse_Success.xml", "RDM2WAGPLCP"); + + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") + when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")). + thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) + + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix + "") + verify(mockExecution, atLeast(2)).setVariable(Prefix + "queryCloudRegionReturnCode", "200") + verify(mockExecution).setVariable(Prefix + "isCloudRegionGood", true) + } + + @Test + public void callRESTQueryAAICloudRegion25_200() { - println "************ callRESTQueryAAINetworkId ************* " + println "************ callRESTQueryAAICloudRegion25_200 ************* " - WireMock.reset(); - MockGetNetworkByIdWithDepth("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", "all"); + WireMock.reset(); + MockGetNetworkCloudRegion(wireMockRule, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml", "RDM2WAGPLCP"); - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") - when(mockExecution.getVariable("mso.workflow.DoUpdateNetworkInstance.aai.l3-network.uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTQueryAAINetworkId(mockExecution) + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") + when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")). + thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) - verify(mockExecution).setVariable("prefix", Prefix + "") - verify(mockExecution).setVariable(Prefix + "queryIdAAIRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4"+"?depth=all") - verify(mockExecution).setVariable(Prefix + "aaiIdReturnCode", "200") + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "isCloudRegionGood", true) + } - } + @Test + public void callRESTQueryAAICloudRegion_NotFound() { - @Test - //@Ignore - public void callRESTQueryAAICloudRegion30_200() { + println "************ callRESTQueryAAICloudRegionFake ************* " - println "************ callRESTQueryAAICloudRegion30_200 ************* " + WireMock.reset(); + MockGetNetworkCloudRegion_404(wireMockRule, "MDTWNJ21"); - WireMock.reset(); - MockGetNetworkCloudRegion("CreateNetworkV2/cloudRegion30_AAIResponse_Success.xml", "RDM2WAGPLCP"); + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") + when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(vnfRequestFakeRegion) + when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") + when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") + when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")). + thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner") + when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") + when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') + when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") + when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) + verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix + "") + verify(mockExecution, atLeast(1)).setVariable(Prefix + "queryCloudRegionReturnCode", "404") + verify(mockExecution).setVariable(Prefix + "cloudRegionPo", "MDTWNJ21") + verify(mockExecution).setVariable(Prefix + "cloudRegionSdnc", "AAIAIC25") + verify(mockExecution).setVariable(Prefix + "isCloudRegionGood", true) + } - verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix + "") - verify(mockExecution, atLeast(2)).setVariable(Prefix + "queryCloudRegionReturnCode", "200") - verify(mockExecution).setVariable(Prefix + "isCloudRegionGood", true) + @Test + public void callRESTQueryAAINetworkVpnBinding_200() { - } + println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " - @Test - public void callRESTQueryAAICloudRegion25_200() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn( + new AAIResultWrapper(FileUtil.readResourceFile("__files/BuildingBlocks/Network/queryAAIResponseEmptyUri.json"))) - println "************ callRESTQueryAAICloudRegion25_200 ************* " + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") + verify(mockExecution).setVariable(Prefix + "queryVpnBindingAAIResponse", + """<rest:payload xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd" + xmlns="defaultTestNamespacev14"\n contentType="text/xml">\n <vpn-binding> + <global-route-target/>\n </vpn-binding>\n</rest:payload>""") + verify(mockExecution).setVariable(Prefix + "routeCollection", "<routeTargets/>") + } + + @Test + public void callRESTQueryAAINetworkVpnBindingList_200() { + + println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " - WireMock.reset(); - MockGetNetworkCloudRegion("CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml", "RDM2WAGPLCP"); + WireMock.reset(); - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix + "") - verify(mockExecution).setVariable(Prefix + "isCloudRegionGood", true) - - } - - @Test - //@Ignore - public void callRESTQueryAAICloudRegion_NotFound() { - - println "************ callRESTQueryAAICloudRegionFake ************* " - - WireMock.reset(); - MockGetNetworkCloudRegion_404("MDTWNJ21"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - when(mockExecution.getVariable(Prefix + "networkInputs")).thenReturn(vnfRequestFakeRegion) - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTQueryAAICloudRegion(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution, atLeast(1)).setVariable("prefix", Prefix + "") - verify(mockExecution, atLeast(1)).setVariable(Prefix + "queryCloudRegionReturnCode", "404") - verify(mockExecution).setVariable(Prefix + "cloudRegionPo", "MDTWNJ21") - verify(mockExecution).setVariable(Prefix + "cloudRegionSdnc", "AAIAIC25") - verify(mockExecution).setVariable(Prefix + "isCloudRegionGood", true) - - } + MockGetNetworkVpnBindingWithDepth(wireMockRule, + "BuildingBlocks/Network/queryAAIVpnBindingTestResponseWithRoutes.json", + "13e94b71-3ce1-4988-ab0e-61208fc91f1c", "2") - @Test - //@Ignore - public void callRESTQueryAAINetworkVpnBinding_200() { + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn( + new AAIResultWrapper(FileUtil.readResourceFile("__files/BuildingBlocks/Network/queryAAINetworkTestResponse.json"))) - println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) - 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"); + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "routeCollection", """<routeTargets> + <routeTarget>2001:051111</routeTarget>\n <routeTargetRole>EXPORT</routeTargetRole>\n</routeTargets> +<routeTargets>\n <routeTarget>1000:051113</routeTarget>\n <routeTargetRole>IMPORT</routeTargetRole>\n</routeTargets>\n""") + } - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) // v6 - when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.vpn-binding.uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) + @Test + public void callRESTQueryAAINetworkVpnBinding_200_URN_Uri() { - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) + println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " - 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") + WireMock.reset(); + MockGetNetworkVpnBindingWithDepth(wireMockRule, + "BuildingBlocks/Network/queryAAIVpnBindingTestResponseWithRoutes.json", + "13e94b71-3ce1-4988-ab0e-61208fc91f1c", "2"); - } + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn( + new AAIResultWrapper(FileUtil.readResourceFile("__files/BuildingBlocks/Network/queryAAINetworkTestResponse.json"))) - @Test - //@Ignore - public void callRESTQueryAAINetworkVpnBindingList_200() { + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) - println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "routeCollection", + """<routeTargets>\n <routeTarget>2001:051111</routeTarget>\n <routeTargetRole>EXPORT</routeTargetRole> +</routeTargets>\n<routeTargets>\n <routeTarget>1000:051113</routeTarget>\n <routeTargetRole>IMPORT</routeTargetRole> +</routeTargets>\n""") + } - WireMock.reset(); - MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBindingList_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); - MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBindingList_AAIResponse_Success.xml", "c980a6ef-3b88-49f0-9751-dbad8608d0a6"); + @Test + public void callRESTQueryAAINetworkVpnBinding_NotPresent() { - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) // v6 - when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.vpn-binding.uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + println "************ callRESTQueryAAINetworkVpnBinding_NotPresent ************* " - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) + WireMock.reset(); - 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") + MockGetNetworkVpnBindingWithDepth(wireMockRule, + "BuildingBlocks/Network/queryAAIVpnBindingTestResponse.json", + "13e94b71-3ce1-4988-ab0e-61208fc91f1c", "2") - } + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn( + new AAIResultWrapper(FileUtil.readResourceFile("__files/BuildingBlocks/Network/queryAAINetworkTestResponse.json"))) - - @Test - //@Ignore - public void callRESTQueryAAINetworkVpnBinding_TestScenario01_200() { + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) - println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "routeCollection", "") + } - WireMock.reset(); - MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponseTestScenario01) - when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.vpn-binding.uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) + @Test + public void callRESTQueryAAINetworkTableRef_200() { - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) + println "************ callRESTQueryAAINetworkTableRef_200 ************* " + WireMock.reset(); - 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") + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn( + new AAIResultWrapper(FileUtil.readResourceFile("__files/BuildingBlocks/Network/queryAAINetworkTestResponse.json"))) - } + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTQueryAAINetworkTableRef(mockExecution) - @Test - //@Ignore - public void callRESTQueryAAINetworkVpnBinding_200_URN_Uri() { + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "networkTableRefCount", 0) + verify(mockExecution).setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") + verify(mockExecution).setVariable(Prefix + "queryNetworkTableRefAAIResponse", + """<rest:payload xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd" + xmlns="defaultTestNamespacev14"\n contentType="text/xml">\n <route-table-references> + <route-table-reference-fqdn/>\n </route-table-references>\n</rest:payload>""") + verify(mockExecution).setVariable(Prefix + "tableRefCollection", "<routeTableFqdns/>") + } - println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " + @Test + public void callRESTQueryAAINetworkPolicy_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"); + println "************ callRESTQueryAAINetworkPolicy_200 ************* " - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.vpn-binding.uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + WireMock.reset(); - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn( + new AAIResultWrapper(FileUtil.readResourceFile("__files/BuildingBlocks/Network/queryAAINetworkTestResponse.json"))) - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTQueryAAINetworkPolicy(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") + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "networkPolicyCount", 0) + verify(mockExecution).setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") + verify(mockExecution).setVariable(Prefix + "queryNetworkPolicyAAIResponse", + """<rest:payload xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd" + xmlns="defaultTestNamespacev14"\n contentType="text/xml">\n <network-policy> + <network-policy-fqdn/>\n </network-policy>\n</rest:payload>""") + verify(mockExecution).setVariable(Prefix + "networkCollection", "<policyFqdns/>") + } - } - @Test - //@Ignore - public void callRESTQueryAAINetworkVpnBinding_NotPresent() { + @Test + public void callRESTReQueryAAINetworkId_200() { - println "************ callRESTQueryAAINetworkVpnBinding_NotPresent ************* " + println "************ callRESTReQueryAAINetworkId ************* " - WireMock.reset(); - MockGetNetworkVpnBinding("UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", "85f015d0-2e32-4c30-96d2-87a1a27f8017"); + WireMock.reset(); + MockGetNetworkByIdWithDepth(wireMockRule, "49c86598-f766-46f8-84f8-8d1c1b10f9b4", + "BuildingBlocks/Network/queryAAINetworkTestResponse.json", "1"); - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponseVpnNotPresent) - when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.l3-network.uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTReQueryAAINetworkId(mockExecution) - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTQueryAAINetworkVpnBinding(mockExecution) + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "aaiRequeryIdReturnCode", "200") + verify(mockExecution).setVariable(eq(Prefix + "requeryIdAAIResponse"), isA(AAIResultWrapper.class)) + verify(mockExecution).setVariable(Prefix + "networkOutputs", """<network-outputs> + <network-id>467e3349-bec1-4922-bcb1-d0bb041bce30</network-id> + <network-name>vprobes_pktinternal_net_4_1806</network-name> + </network-outputs>""") + } - // 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 + public void callRESTUpdateContrailAAINetworkREST_200() { - } + println "************ callRESTUpdateContrailAAINetwork ************* " - @Test - //@Ignore - public void callRESTQueryAAINetworkTableRef_200() { + WireMock.reset(); + MockPostNetwork(wireMockRule, "49c86598-f766-46f8-84f8-8d1c1b10f9b4") + MockPostNetworkSubnet(wireMockRule, "49c86598-f766-46f8-84f8-8d1c1b10f9b4", "209f62cf-cf0c-42f8-b13c-f038b92ef108") + MockPostNetworkSubnet(wireMockRule, "49c86598-f766-46f8-84f8-8d1c1b10f9b4", "971bc608-1aff-47c0-923d-92e43b699f01") - println "************ callRESTQueryAAINetworkTableRef_200 ************* " + ExecutionEntity mockExecution = setupMock() + when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) + when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn( + new AAIResultWrapper(FileUtil.readResourceFile("__files/BuildingBlocks/Network/queryAAIResponseEmptyUri.json"))) + when(mockExecution.getVariable(Prefix + "updateNetworkResponse")).thenReturn(updateNetworkResponseREST) + + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.callRESTUpdateContrailAAINetwork(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "isPONR", true) + } - WireMock.reset(); - MockGetNetworkTableReference("UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", "refFQDN1"); - MockGetNetworkTableReference("UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", "refFQDN2"); - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") - when(mockExecution.getVariable("mso.workflow.default.aai.network-table-reference.uri")).thenReturn("") - when(mockExecution.getVariable("mso.workflow.DoUpdateNetworkInstance.aai.route-table-reference.uri")).thenReturn("/aai/v8/network/route-table-references/route-table-reference") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + @Test + public void validateUpdateNetworkResponseREST() { - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTQueryAAINetworkTableRef(mockExecution) + 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) + + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution).setVariable(Prefix + "updateNetworkResponse", updateNetworkResponseREST) + verify(mockExecution).setVariable(Prefix + "isNetworkRollbackNeeded", true) + verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", updateRollbackNetworkRequest) + } - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) + @Test + public void validateUpdateNetworkResponseREST_Error() { - 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") + println "************ validateNetworkResponse ************* " - } + WorkflowException workflowException = new WorkflowException("DoUpdateNetworkInstance", 2500, "Received error from Network Adapter: JBWEB000065: HTTP Status 500.") - @Test - //@Ignore - public void callRESTQueryAAINetworkPolicy_200() { + 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') - println "************ callRESTQueryAAINetworkPolicy_200 ************* " + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + try { + DoUpdateNetworkInstance.validateUpdateNetworkResponse(mockExecution) + } catch (Exception ex) { + println " Test End - Handle catch-throw BpmnError()! " + } - WireMock.reset(); - MockGetNetworkPolicy("UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", "cee6d136-e378-4678-a024-2cd15f0ee0cg"); + verify(mockExecution).setVariable("prefix", Prefix + "") + verify(mockExecution, atLeast(1)).setVariable(eq("WorkflowException"), refEq(workflowException)) - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") - when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("8") - when(mockExecution.getVariable("mso.workflow.default.aai.v8.network-policy.uri")).thenReturn("/aai/v8/network/network-policies/network-policy") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") + } - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTQueryAAINetworkPolicy(mockExecution) + @Test + public void validateSDNCResponse() { - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) + println "************ validateSDNCResponse ************* " - 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") + 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 + "sdncResponseSuccess")).thenReturn(true) - } + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.validateSDNCResponse(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + verify(mockExecution).setVariable(Prefix + "sdncResponseSuccess", false) + verify(mockExecution).setVariable(Prefix + "sdncRequestDataResponseCode", "200") + verify(mockExecution).setVariable(Prefix + "sdncResponseSuccess", true) + verify(mockExecution).setVariable(Prefix + "changeAssignSDNCResponse", sdncAdapterWorkflowResponse) + verify(mockExecution).setVariable(Prefix + "isSdncRollbackNeeded", true) + } + + @Test(expected = BpmnError.class) + public void validateSDNCResponse_Error() { - - @Test - //@Ignore - public void callRESTReQueryAAINetworkId_200() { - - println "************ callRESTReQueryAAINetworkId ************* " - - WireMock.reset(); - MockGetNetworkByIdWithDepth("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", "all"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable(Prefix + "changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowFormattedResponse) - when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") - when(mockExecution.getVariable("mso.workflow.DoUpdateNetworkInstance.aai.l3-network.uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTReQueryAAINetworkId(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix + "") - verify(mockExecution).setVariable(Prefix + "requeryIdAAIRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4"+"?depth=all") - verify(mockExecution).setVariable(Prefix + "aaiRequeryIdReturnCode", "200") - - } - - - @Test - //@Ignore - public void callRESTUpdateContrailAAINetworkREST_200() { - - println "************ callRESTUpdateContrailAAINetwork ************* " - - WireMock.reset(); - MockPutNetworkIdWithDepth("UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml", "49c86598-f766-46f8-84f8-8d1c1b10f9b4", "all"); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable(Prefix + "networkRequest")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable(Prefix + "changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowFormattedResponse) - when(mockExecution.getVariable(Prefix + "requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - when(mockExecution.getVariable(Prefix + "updateNetworkResponse")).thenReturn(updateNetworkResponseREST) - when(mockExecution.getVariable(Prefix + "messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090") - when(mockExecution.getVariable("mso.workflow.DoUpdateNetworkInstance.aai.l3-network.uri")).thenReturn("/aai/v9/network/l3-networks/l3-network") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/') - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.callRESTUpdateContrailAAINetwork(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix + "") - verify(mockExecution).setVariable(Prefix + "updateContrailAAIUrlRequest", "http://localhost:8090/aai/v9/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4"+"?depth=all") - verify(mockExecution).setVariable(Prefix + "updateContrailAAIPayloadRequest", updateContrailAAIPayloadRequest) - verify(mockExecution).setVariable(Prefix + "aaiUpdateContrailReturnCode", "200") - //verify(mockExecution).setVariable(Prefix + "updateContrailAAIResponse", updateContrailAAIResponse) - verify(mockExecution).setVariable(Prefix + "isPONR", true) - - } - - - - @Test - //@Ignore - public void validateUpdateNetworkResponseREST() { - - println "************ validateNetworkResponse ************* " - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable(Prefix + "updateNetworkResponse")).thenReturn(updateNetworkResponseREST) - when(mockExecution.getVariable(Prefix + "networkReturnCode")).thenReturn('200') - - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.validateUpdateNetworkResponse(mockExecution) - - //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() - //debugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", Prefix + "") - verify(mockExecution).setVariable(Prefix + "updateNetworkResponse", updateNetworkResponseREST) - verify(mockExecution).setVariable(Prefix + "isNetworkRollbackNeeded", true) - verify(mockExecution).setVariable(Prefix + "rollbackNetworkRequest", updateRollbackNetworkRequest) - - } - - @Test - //@Ignore - public void validateUpdateNetworkResponseREST_Error() { - - println "************ validateNetworkResponse ************* " - - WorkflowException workflowException = new WorkflowException("DoUpdateNetworkInstance", 2500, "Received error from Network Adapter: JBWEB000065: HTTP Status 500.") - - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable(Prefix + "updateNetworkResponse")).thenReturn(networkException500) - when(mockExecution.getVariable(Prefix + "networkReturnCode")).thenReturn('500') - - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - try { - DoUpdateNetworkInstance.validateUpdateNetworkResponse(mockExecution) - } catch (Exception ex) { - println " Test End - Handle catch-throw BpmnError()! " - } - - verify(mockExecution).setVariable("prefix", Prefix + "") - verify(mockExecution, atLeast(1)).setVariable("WorkflowException", refEq(workflowException, any(WorkflowException.class))) - - } - - @Test - //@Ignore - public void validateSDNCResponse() { - - println "************ validateSDNCResponse ************* " - - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable(Prefix + "changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowResponse) - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) - when(mockExecution.getVariable(Prefix + "sdncReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "isResponseGood")).thenReturn(true) - - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - try { - DoUpdateNetworkInstance.validateSDNCResponse(mockExecution) - verify(mockExecution).setVariable(Prefix + "isSdncRollbackNeeded", true) - verify(mockExecution).setVariable(Prefix + "rollbackSDNCRequest", "") - - } catch (Exception ex) { - println " Graceful Exit - " + ex.getMessage() - } - //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() - //debugger.printInvocations(mockExecution) - - //verify(mockExecution).setVariable(Prefix + "isSdncRollbackNeeded", true) - - } - - @Test - //@Ignore - public void validateSDNCResponse_Error() { - - println "************ validateSDNCResponse ************* " - //ExecutionEntity mockExecution = mock(ExecutionEntity.class) - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable(Prefix + "changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowResponse_Error) - when(mockExecution.getVariable("prefix")).thenReturn(Prefix + "") - when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(false) - when(mockExecution.getVariable(Prefix + "sdncReturnCode")).thenReturn("200") - when(mockExecution.getVariable(Prefix + "isResponseGood")).thenReturn(true) - - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - try { - DoUpdateNetworkInstance.validateSDNCResponse(mockExecution) - } catch (Exception ex) { - println " Graceful Exit! - " + ex.getMessage() - } - //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() - //debugger.printInvocations(mockExecution) - - // verify set prefix = Prefix + "" - //verify(mockExecution).setVariable(Prefix + "sdncResponseSuccess", false) - - } - - @Test - //@Ignore - public void prepareRollbackData() { - - println "************ prepareRollbackData() ************* " - - - - WorkflowException workflowException = new WorkflowException("DoUpdateNetworkInstance", 2500, "Received error from Network Adapter: JBWEB000065: HTTP Status 500.") - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable(Prefix + "rollbackSDNCRequest")).thenReturn(rollbackSDNCRequest) - when(mockExecution.getVariable(Prefix + "rollbackNetworkRequest")).thenReturn(rollbackNetworkRequest) - when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) - - // preProcessRequest(DelegateExecution execution) - DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() - DoUpdateNetworkInstance.prepareRollbackData(mockExecution) - -// verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", Prefix) - - } + println "************ validateSDNCResponse ************* " + 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 (BpmnError ex) { + verify(mockExecution).setVariable(Prefix + "sdncResponseSuccess", false) + println " Graceful Exit! - " + ex.getMessage() + throw ex + } + } + + @Test + 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) + + DoUpdateNetworkInstance DoUpdateNetworkInstance = new DoUpdateNetworkInstance() + DoUpdateNetworkInstance.prepareRollbackData(mockExecution) + + verify(mockExecution).setVariable("prefix", Prefix) + } @Test //@Ignore @@ -2735,6 +1614,37 @@ String rollbackNetworkRequest = } + private static L3Network getContrailL3Network() { + + HostRoutes routes1 = new HostRoutes() + routes1.getHostRoute().add(new HostRoute(routePrefix: "172.20.1.0/24", nextHop: "10.102.200.1")) + routes1.getHostRoute().add(new HostRoute(routePrefix: "10.102.0.0/16", nextHop: "10.102.200.1")) + routes1.getHostRoute().add(new HostRoute(routePrefix: "192.168.2.0/25", nextHop: "10.102.200.1")) + + Subnet subnet1 = new Subnet(networkStartAddress: "107.239.52.0", cidrMask: "24", dhcpEnabled: true, + gatewayAddress: "107.239.52.1", ipVersion: "4", subnetId: "57e9a1ff-d14f-4071-a828-b19ae98eb2fc", + subnetName: "subnetName", ipAssignmentDirection: "true", hostRoutes: routes1) + Subnets subnets = new Subnets() + subnets.getSubnet().add(subnet1) + + SegmentationAssignments segments = new SegmentationAssignments() + segments.getSegmentationAssignment().add(new SegmentationAssignment(segmentationId: "414")) + segments.getSegmentationAssignment().add(new SegmentationAssignment(segmentationId: "415")) + + return new L3Network( + networkName: "MNS-25180-L-01-dmz_direct_net_1", + networkType: "CONTRAIL_EXTERNAL", + networkTechnology: "Contrail", + networkId: "49c86598-f766-46f8-84f8-8d1c1b10f9b4", + orchestrationStatus: "pending-create", + physicalNetworkName: "networkName", + heatStackId: "ST_2Bindings_6006/55288ef0-595c-47d3-819e-cf93aaac6326", + isSharedNetwork: true, + subnets: subnets, + segmentationAssignments: segments + ) + } + private ExecutionEntity setupMock() { ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) @@ -2742,16 +1652,13 @@ String rollbackNetworkRequest = 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) diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy index 8af15de75b..80e2c863e8 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1Test.groovy @@ -4,7 +4,9 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ + * 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 * @@ -32,7 +34,7 @@ import org.junit.runner.RunWith import org.mockito.ArgumentCaptor import org.mockito.Captor import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner +import org.mockito.junit.MockitoJUnitRunner import org.onap.aai.domain.yang.GenericVnf import org.onap.aai.domain.yang.VfModule import org.onap.aai.domain.yang.VolumeGroup @@ -48,23 +50,23 @@ import javax.ws.rs.core.UriBuilder import static org.mockito.Mockito.* -@RunWith(MockitoJUnitRunner.class) +@RunWith(MockitoJUnitRunner.Silent.class) class UpdateVfModuleVolumeInfraV1Test extends MsoGroovyTest{ - + def prefix = "UPDVfModVol_" @Captor static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class) @Rule public ExpectedException thrown = ExpectedException.none() - - @Before - public void init(){ + + @Before + public void init() { super.init("UpdateVfModuleVolumeInfraV1") - MockitoAnnotations.initMocks(this) + MockitoAnnotations.initMocks(this) } - + @Test void testQueryAAIForVfModule() { ExecutionEntity mockExecution = setupMock() |