summaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/test/groovy/org/onap
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-07-30 15:56:09 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2018-07-31 11:09:25 -0400
commit5a6a6de6f1a26a1897e4917a0df613e25a24eb70 (patch)
tree59a968f27b4b603aacc9d5e7b51fb598aeec5321 /bpmn/MSOCommonBPMN/src/test/groovy/org/onap
parentb6dc38501f3b746426b42d9de4cc883d894149e8 (diff)
Containerization feature of SO
Change-Id: I95381232eeefcd247a66a5cec370a8ce1c288e18 Issue-ID: SO-670 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/test/groovy/org/onap')
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AaiUtilTest.groovy471
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessorTest.groovy182
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsTest.groovy98
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy170
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy130
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenantTest.groovy125
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CustomE2EGetServiceTest.groovy104
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CustomE2EPutServiceTest.groovy72
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModuleTest.groovy218
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtilTest.groovy98
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/FalloutHandlerTest.groovy312
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleNameTest.groovy125
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenericGetServiceTest.groovy124
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenericGetVnfTest.groovy180
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenericPutServiceTest.groovy235
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy72
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoUtilsTest.groovy291
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/NetworkUtilsTest.groovy101
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModuleTest.groovy171
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1Test.groovy151
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2Test.groovy151
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterTest.groovy951
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtilsTest.groovy191
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1Test.groovy196
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/TrinityExceptionUtilTest.groovy201
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnfTest.groovy172
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy175
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VidUtilsTest.groovy969
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1Test.groovy118
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/utils/IgnoreNamedElementsDifferenceListener.groovy51
-rw-r--r--bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/utils/XmlComparator.groovy41
31 files changed, 6646 insertions, 0 deletions
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AaiUtilTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AaiUtilTest.groovy
new file mode 100644
index 0000000000..79caf5b9ac
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AaiUtilTest.groovy
@@ -0,0 +1,471 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*
+
+import org.onap.so.rest.HttpHeader
+import org.mockito.MockitoAnnotations
+import org.mockito.runners.MockitoJUnitRunner
+import org.mockito.internal.debugging.MockitoDebuggerImpl
+import org.junit.Before
+import org.onap.so.bpmn.common.scripts.AaiUtil;
+import org.junit.Rule;
+import org.junit.Test
+import org.junit.rules.ExpectedException
+import org.junit.Ignore
+import org.junit.runner.RunWith
+import org.junit.Before;
+import org.junit.Test;
+import org.camunda.bpm.engine.ProcessEngineServices
+import org.camunda.bpm.engine.RepositoryService
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl
+import org.camunda.bpm.engine.repository.ProcessDefinition
+
+@RunWith(MockitoJUnitRunner.class)
+@Ignore
+class AaiUtilTest extends MsoGroovyTest {
+
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(8090);
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none
+
+
+ def aaiPaylod = "<allotted-resource xmlns=\"http://org.openecomp.aai.inventory/v9\">\n" +
+ "\t\t\t\t<id>allottedResourceId</id>\n" +
+ "\t\t\t\t<description></description>\n" +
+ "\t\t\t\t<type>allottedResourceType</type>\n" +
+ "\t\t\t\t<role>allottedResourceRole</role>\n" +
+ "\t\t\t\t<selflink></selflink>\n" +
+ "\t\t\t\t<model-invariant-id></model-invariant-id>\n" +
+ "\t\t\t\t<model-version-id></model-version-id>\n" +
+ "\t\t\t\t<model-customization-id></model-customization-id>\n" +
+ "\t\t\t\t<orchestration-status>PendingCreate</orchestration-status>\n" +
+ "\t\t\t\t<operation-status></operation-status>\n" +
+ "\t\t\t\t<relationship-list>\n" +
+ "\t\t\t\t\t<relationship>\n" +
+ " \t\t\t<related-to>service-instance</related-to>\n" +
+ " \t\t\t<related-link>CSI_resourceLink</related-link>\n" +
+ "\t\t\t\t\t</relationship>\n" +
+ "\t\t\t\t</relationship-list>\n" +
+ "\t\t\t</allotted-resource>";
+
+ @Test
+ public void testGetVersionDefault() {
+ ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule')
+ assertEquals('8', version)
+ }
+
+ @Test
+ public void testGetVersionResourceSpecific() {
+ ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.workflow.default.aai.l3-network.version")).thenReturn('7')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule')
+ assertEquals('7', version)
+ }
+
+ @Test
+ public void testGetVersionFlowSpecific() {
+ ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.workflow.custom.CreateAAIVfModule.aai.version")).thenReturn('6')
+ when(mockExecution.getVariable("mso.workflow.default.aai.l3-network.version")).thenReturn('7')
+
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule')
+ assertEquals('6', version)
+ }
+
+ @Test
+ public void testGetVersionNotDefined() {
+ thrown.expect(Exception.class)
+ ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("")
+
+ def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule')
+
+ }
+
+ @Test
+ public void testGetUriDefaultVersion() {
+ ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.l3-network.uri")).thenReturn('/aai/v8/network/l3-networks/l3-network')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def uri = aaiUtil.getUri(mockExecution, 'l3-network')
+ assertEquals('/aai/v8/network/l3-networks/l3-network', uri)
+ }
+
+ @Test
+ public void testGetUriFlowAndResourceSpecific() {
+ ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.workflow.CreateAAIVfModule.aai.l3-network.uri")).thenReturn('/aai/v6/network/l3-networks/l3-network')
+
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.l3-network.uri")).thenReturn('/aai/v8/network/l3-networks/l3-network')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def uri = aaiUtil.getUri(mockExecution, 'l3-network')
+ assertEquals('/aai/v6/network/l3-networks/l3-network', uri)
+ }
+
+ @Test
+ public void testGetNetworkGenericVnfEndpoint() {
+ ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf')
+
+ when(mockExecution.getVariable('aai.endpoint')).thenReturn('http://localhost:28090')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+
+ when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn('8')
+
+
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def endpoint = aaiUtil.getNetworkGenericVnfEndpoint(mockExecution)
+ assertEquals('http://localhost:28090/aai/v8/network/generic-vnfs/generic-vnf', endpoint)
+ }
+
+ @Test
+ public void testGetNetworkGenericVnfUri() {
+ ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf')
+
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+
+ when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn('8')
+
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def uri = aaiUtil.getNetworkGenericVnfUri(mockExecution)
+ assertEquals('/aai/v8/network/generic-vnfs/generic-vnf', uri)
+ }
+
+ @Test
+ public void testGetNetworkVpnBindingUri() {
+ ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ 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("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def uri = aaiUtil.getNetworkVpnBindingUri(mockExecution)
+ assertEquals('/aai/v8/network/vpn-bindings/vpn-binding', uri)
+ }
+
+ @Test
+ public void testGetNetworkPolicyUri() {
+ ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ 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("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def uri = aaiUtil.getNetworkPolicyUri(mockExecution)
+ assertEquals('/aai/v8/network/network-policies/network-policy', uri)
+ }
+
+ @Test
+ public void testGetNetworkTableReferencesUri() {
+ ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.route-table-reference.uri")).thenReturn('/aai/v8/network/route-table-references/route-table-reference')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def uri = aaiUtil.getNetworkTableReferencesUri(mockExecution)
+ assertEquals('/aai/v8/network/route-table-references/route-table-reference', uri)
+ }
+
+ @Test
+ public void testGetNetworkVceUri() {
+ ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.vce.uri")).thenReturn('/aai/v8/network/vces/vce')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def uri = aaiUtil.getNetworkVceUri(mockExecution)
+ assertEquals('/aai/v8/network/vces/vce', uri)
+ }
+
+ @Test
+ public void testGetNetworkL3NetworkUri() {
+ ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ 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("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution)
+ assertEquals('/aai/v8/network/l3-networks/l3-network', uri)
+ }
+
+ @Test
+ public void testGetBusinessCustomerUri() {
+ ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.customer.uri")).thenReturn('/aai/v8/business/customers/customer')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def uri = aaiUtil.getBusinessCustomerUri(mockExecution)
+ assertEquals('/aai/v8/business/customers/customer', uri)
+ }
+
+ @Test
+ public void testGetCloudInfrastructureCloudRegionEndpoint() {
+ ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic')
+
+ when(mockExecution.getVariable('aai.endpoint')).thenReturn('http://localhost:28090')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def uri = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(mockExecution)
+ assertEquals('http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic', uri)
+ }
+
+ @Test
+ public void testGetCloudInfrastructureCloudRegionUri() {
+ ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic')
+
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+
+
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def uri = aaiUtil.getCloudInfrastructureCloudRegionUri(mockExecution)
+ assertEquals('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic', uri)
+ }
+
+ @Test
+ public void testGetCloudInfrastructureTenantUri() {
+ ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.tenant.uri")).thenReturn('/aai/v8/cloud-infrastructure/tenants/tenant')
+
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def uri = aaiUtil.getCloudInfrastructureTenantUri(mockExecution)
+ assertEquals('/aai/v8/cloud-infrastructure/tenants/tenant', uri)
+ }
+
+ @Test
+ public void testGetSearchNodesQueryUri() {
+ ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.nodes-query.uri")).thenReturn('/aai/v8/search/nodes-query')
+
+ when(mockExecution.getVariable('aai.endpoint')).thenReturn('http://localhost:28090')
+
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+
+
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def uri = aaiUtil.getSearchNodesQueryUri(mockExecution)
+ assertEquals('/aai/v8/search/nodes-query', uri)
+ }
+
+ @Test
+ public void testGetSearchNodesQueryEndpoint() {
+ ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.nodes-query.uri")).thenReturn('/aai/v8/search/nodes-query')
+
+ when(mockExecution.getVariable('aai.endpoint')).thenReturn('http://localhost:28090')
+
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def uri = aaiUtil.getSearchNodesQueryEndpoint(mockExecution)
+ assertEquals('http://localhost:28090/aai/v8/search/nodes-query', uri)
+ }
+
+ @Test
+ public void testGetSearchGenericQueryUri() {
+ ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-query.uri")).thenReturn('/aai/v8/search/generic-query')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+
+
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def uri = aaiUtil.getSearchGenericQueryUri(mockExecution)
+ assertEquals('/aai/v8/search/generic-query', uri)
+ }
+
+ @Test
+ public void testGetNamespaceFromUri() {
+ ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('6')
+ when(mockExecution.getVariable("mso.workflow.default.aai.v6.l3-network.uri")).thenReturn('/aai/v6/network/l3-networks/l3-network')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) // Required to populate the namespace in the class
+ def ns = aaiUtil.getNamespaceFromUri('/aai/v6/search/generic-query')
+ assertEquals('http://org.openecomp.aai.inventory/v6', ns)
+ }
+
+ @Test
+ public void testExecuteAAIGetCall() {
+ ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("aai.auth")).thenReturn("9B2278E8B8E95F256A560719055F4DF3")
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("aa3871669d893c7fb8abbcda31b88b4f")
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def uri = aaiUtil.executeAAIGetCall(mockExecution,"http://localhost:8090/aai/v9/business/customers/customer/CUST/service-subscriptions/service-subscription/SVC/service-instances/service-instance/NST/allotted-resources/allotted-resource/allottedResourceId")
+ }
+
+
+ @Test
+ public void testExecuteAAIPutCall() {
+ ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("aai.auth")).thenReturn("9B2278E8B8E95F256A560719055F4DF3")
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("aa3871669d893c7fb8abbcda31b88b4f")
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def uri = aaiUtil.executeAAIPutCall(mockExecution,"http://localhost:8090/aai/v9/business/customers/customer/CUST/service-subscriptions/service-subscription/SVC/service-instances/service-instance/NST/allotted-resources/allotted-resource/allottedResourceId",aaiPaylod)
+ }
+
+ @Test
+ public void testGetNamespaceFromUri2() {
+ ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1')
+ //
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('10')
+ when(mockExecution.getVariable("mso.workflow.default.aai.v10.l3-network.uri")).thenReturn('/aai/v10/network/l3-networks/l3-network')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+ //
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) // Required to populate the namespace in the class
+ def ns = aaiUtil.getNamespaceFromUri('/aai/v10/search/generic-query')
+ assertEquals('http://org.openecomp.aai.inventory/v10', ns)
+ }
+
+ @Test
+ public void testGetNamespaceFromUri3() {
+ ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1')
+ //
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('100')
+ when(mockExecution.getVariable("mso.workflow.default.aai.v100.l3-network.uri")).thenReturn('/aai/v100/network/l3-networks/l3-network')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+ //
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) // Required to populate the namespace in the class
+ def ns = aaiUtil.getNamespaceFromUri('/aai/v100/search/generic-query')
+ assertEquals('http://org.openecomp.aai.inventory/v100', ns)
+ }
+
+ @Test
+ public void testGetNamespaceFromUri_twoArguments() { // (execution, uri)
+ ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1')
+ //
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('10')
+ when(mockExecution.getVariable("mso.workflow.default.aai.v10.l3-network.uri")).thenReturn('/aai/v10/network/l3-networks/l3-network')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+ //
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ CreateAAIVfModule myproc = new CreateAAIVfModule()
+ AaiUtil aaiUtil = new AaiUtil(myproc)
+ def ns = aaiUtil.getNamespaceFromUri(mockExecution, '/aai/v10/search/generic-query')
+ assertEquals('http://org.openecomp.aai.inventory/v10', ns)
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessorTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessorTest.groovy
new file mode 100644
index 0000000000..86a175d811
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessorTest.groovy
@@ -0,0 +1,182 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.junit.Assert
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.onap.so.bpmn.core.WorkflowException;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*
+
+import org.onap.so.rest.HttpHeader
+import org.mockito.MockitoAnnotations
+import org.mockito.runners.MockitoJUnitRunner
+import org.mockito.internal.debugging.MockitoDebuggerImpl
+import org.junit.Before
+import org.onap.so.bpmn.common.scripts.AaiUtil;
+import org.junit.Rule;
+import org.junit.Test
+import org.junit.Ignore
+import org.junit.runner.RunWith
+import org.junit.Before;
+import org.junit.Test;
+import org.camunda.bpm.engine.ProcessEngineServices
+import org.camunda.bpm.engine.RepositoryService
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl
+import org.camunda.bpm.engine.repository.ProcessDefinition
+
+
+
+class AbstractServiceTaskProcessorImpl extends AbstractServiceTaskProcessor{
+
+ @Override
+ void preProcessRequest(DelegateExecution execution) {
+
+ }
+}
+
+@RunWith(MockitoJUnitRunner.class)
+public class AbstractServiceTaskProcessorTest extends MsoGroovyTest {
+
+ @Captor
+ ArgumentCaptor<ExecutionEntity> captor= ArgumentCaptor.forClass(ExecutionEntity.class);
+
+ @Test
+ public void testCreateCallbackURL_Success() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("mso.workflow.message.endpoint")).thenReturn('http://localhost:18080/mso/WorkflowMessage/')
+ AbstractServiceTaskProcessorImpl serviceTaskProcessor = new AbstractServiceTaskProcessorImpl();
+ def endpoint = serviceTaskProcessor.createCallbackURL(mockExecution, 'testMessageType', 'testCorrelator')
+ assertEquals('http://localhost:18080/mso/WorkflowMessage/testMessageType/testCorrelator', endpoint)
+ }
+
+ @Test
+ public void testCreateCallbackURL_NullEndpoint() {
+
+ ExecutionEntity mockExecution = setupMock()
+ try {
+
+ when(mockExecution.getVariable("mso.workflow.message.endpoint")).thenReturn("")
+ AbstractServiceTaskProcessorImpl serviceTaskProcessor = new AbstractServiceTaskProcessorImpl();
+ def endpoint = serviceTaskProcessor.createCallbackURL(mockExecution, 'testMessageType', 'testCorrelator')
+ }
+ catch(Exception ex){
+ }
+ Mockito.verify(mockExecution,times(1)).setVariable(captor.capture(),captor.capture())
+ WorkflowException workflowException = captor.getValue()
+ Assert.assertEquals("mso:workflow:message:endpoint URN mapping is not set",workflowException.getErrorMessage())
+ Assert.assertEquals(2000,workflowException.getErrorCode())
+ }
+
+ @Test
+ public void testCreateWorkflowMessageAdapterCallbackURL_Success() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("mso.adapters.workflow.message.endpoint")).thenReturn('http://localhost:18080/workflows/messages/message/')
+
+ AbstractServiceTaskProcessorImpl serviceTaskProcessor = new AbstractServiceTaskProcessorImpl();
+ def endpoint = serviceTaskProcessor.createWorkflowMessageAdapterCallbackURL(mockExecution, 'testMessageType', 'testCorrelator')
+ assertEquals('http://localhost:18080/workflows/messages/message/testMessageType/testCorrelator', endpoint)
+ }
+
+ @Test
+ public void testCreateWorkflowMessageAdapterCallbackURL_NullEndpoint() {
+
+ ExecutionEntity mockExecution = setupMock()
+ try {
+
+ when(mockExecution.getVariable("mso.adapters.workflow.message.endpoint")).thenReturn("")
+
+ AbstractServiceTaskProcessorImpl serviceTaskProcessor = new AbstractServiceTaskProcessorImpl();
+ def endpoint = serviceTaskProcessor.createWorkflowMessageAdapterCallbackURL(mockExecution, 'testMessageType', 'testCorrelator')
+ }
+ catch(Exception ex){
+ }
+ Mockito.verify(mockExecution,times(1)).setVariable(captor.capture(),captor.capture())
+ WorkflowException workflowException = captor.getValue()
+ Assert.assertEquals("mso:adapters:workflow:message:endpoint URN mapping is not set",workflowException.getErrorMessage())
+ Assert.assertEquals(2000,workflowException.getErrorCode())
+ }
+
+ @Test
+ public void testSetRollbackEnabledNullOrEmptyDisableRollback() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("prefix")).thenReturn('TEST_PREFIX')
+ when(mockExecution.getVariable("disableRollback")).thenReturn(null)
+ when(mockExecution.getVariable("mso.rollback")).thenReturn("")
+
+ AbstractServiceTaskProcessorImpl serviceTaskProcessor = new AbstractServiceTaskProcessorImpl();
+ serviceTaskProcessor.setRollbackEnabled(mockExecution, "true")
+ assertEquals(null, mockExecution.getVariable('TEST_PREFIXbackoutOnFailure'))
+ }
+
+ @Test
+ public void testSetRollbackEnabledDisableRollback() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("prefix")).thenReturn('TEST_PREFIX')
+ when(mockExecution.getVariable("disableRollback")).thenReturn(true)
+ when(mockExecution.getVariable("mso.rollback")).thenReturn("true")
+
+ AbstractServiceTaskProcessorImpl serviceTaskProcessor = new AbstractServiceTaskProcessorImpl();
+ serviceTaskProcessor.setRollbackEnabled(mockExecution, "true")
+ verify(mockExecution).setVariable("TEST_PREFIXbackoutOnFailure",false)
+ }
+
+ @Test
+ public void testSetRollbackEnabledRollback() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("prefix")).thenReturn('TEST_PREFIX')
+ when(mockExecution.getVariable("disableRollback")).thenReturn(false)
+ when(mockExecution.getVariable("mso.rollback")).thenReturn("true")
+
+ AbstractServiceTaskProcessorImpl serviceTaskProcessor = new AbstractServiceTaskProcessorImpl();
+ serviceTaskProcessor.setRollbackEnabled(mockExecution, "true")
+ verify(mockExecution).setVariable("TEST_PREFIXbackoutOnFailure",true)
+ }
+
+ @Test
+ public void testSetRollbackEnabledDefaultRollback() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("prefix")).thenReturn('TEST_PREFIX')
+ when(mockExecution.getVariable("disableRollback")).thenReturn("test")
+ when(mockExecution.getVariable("mso.rollback")).thenReturn("true")
+
+ AbstractServiceTaskProcessorImpl serviceTaskProcessor = new AbstractServiceTaskProcessorImpl();
+ serviceTaskProcessor.setRollbackEnabled(mockExecution, "true")
+ verify(mockExecution).setVariable("TEST_PREFIXbackoutOnFailure",true)
+ }
+
+ @Test
+ public void testSetBasicDBAuthHeader_Success() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("mso.adapters.db.auth")).thenReturn('9B2278E8B8E95F256A560719055F4DF3')
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn('aa3871669d893c7fb8abbcda31b88b4f')
+
+ AbstractServiceTaskProcessorImpl serviceTaskProcessor = new AbstractServiceTaskProcessorImpl();
+ serviceTaskProcessor.setBasicDBAuthHeader(mockExecution, "true")
+ verify(mockExecution).setVariable("BasicAuthHeaderValueDB",'Basic dXAyMTE4OnVwMjExOA==')
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsTest.groovy
new file mode 100644
index 0000000000..39064caa28
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CatalogDbUtilsTest.groovy
@@ -0,0 +1,98 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule
+import org.camunda.bpm.engine.ProcessEngineServices
+import org.camunda.bpm.engine.RepositoryService
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.camunda.bpm.engine.repository.ProcessDefinition
+import org.junit.Assert
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.Mockito
+import org.mockito.runners.MockitoJUnitRunner
+import org.onap.so.bpmn.mock.FileUtil
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse
+import static com.github.tomakehurst.wiremock.client.WireMock.get
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor
+import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching
+import static org.mockito.Mockito.mock
+import static org.mockito.Mockito.mock
+import static org.mockito.Mockito.mock
+import static org.mockito.Mockito.mock
+import static org.mockito.Mockito.when
+import static org.mockito.Mockito.when
+import static org.mockito.Mockito.when
+import static org.mockito.Mockito.when
+import static org.mockito.Mockito.when
+import static org.mockito.Mockito.when
+import static org.mockito.Mockito.when
+
+@RunWith(MockitoJUnitRunner.class)
+class CatalogDbUtilsTest {
+
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(8090)
+
+ @Test
+ public void testGetResponseFromCatalogDb() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("mso.catalog.db.endpoint")).thenReturn('http://localhost:8090')
+ when(mockExecution.getVariable("mso.adapters.db.auth")).thenReturn('757A94191D685FD2092AC1490730A4FC')
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn('07a7159d3bf51a0e53be7a8f89699be7')
+
+ stubFor(get(urlMatching(".*/serviceNetworks[?]serviceModelUuid=12345"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withBodyFile("catalogDbFiles/DoCreateServiceInstance_request.json")))
+
+ CatalogDbUtils obj = new CatalogDbUtils()
+ String str = obj.getResponseFromCatalogDb(mockExecution, "/serviceNetworks?serviceModelUuid=12345")
+ String expectedValue =
+ FileUtil.readResourceFile("__files/catalogDbFiles/DoCreateServiceInstance_request.json");
+ Assert.assertEquals(expectedValue, str)
+
+ }
+
+ private ExecutionEntity setupMock() {
+
+ ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
+ when(mockProcessDefinition.getKey()).thenReturn("GenericGetService")
+ RepositoryService mockRepositoryService = mock(RepositoryService.class)
+ when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
+ when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("GenericGetService")
+ when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100")
+ ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)
+ when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getId()).thenReturn("100")
+ when(mockExecution.getProcessDefinitionId()).thenReturn("GenericGetService")
+ when(mockExecution.getProcessInstanceId()).thenReturn("GenericGetService")
+ when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
+ when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition)
+ return mockExecution
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy
new file mode 100644
index 0000000000..9aa8425a50
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CompleteMsoProcessTest.groovy
@@ -0,0 +1,170 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.ArgumentCaptor
+import org.mockito.MockitoAnnotations
+import org.mockito.runners.MockitoJUnitRunner
+import org.onap.so.bpmn.core.WorkflowException
+
+import static org.assertj.core.api.Assertions.assertThat
+import static org.assertj.core.api.Assertions.assertThatThrownBy
+import static org.mockito.Matchers.eq
+import static org.mockito.Mockito.*
+
+@RunWith(MockitoJUnitRunner.class)
+class CompleteMsoProcessTest {
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this)
+ }
+
+ private String completeMsoProcessRequest = """
+ <sdncadapterworkflow:MsoCompletionRequest xmlns:ns="http://org.onap/so/request/types/v1" xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1">
+ <ns:request-information>
+ <ns:request-id>uCPE1020_STUW105_5002</ns:request-id>
+ <ns:request-action>Layer3ServiceActivateRequest</ns:request-action>
+ <ns:request-sub-action>COMPLETE</ns:request-sub-action>
+ <ns:source>OMX</ns:source>
+ <ns:notification-url>http://localhost:28090/CCD/StatusNotification</ns:notification-url>
+ <ns:order-number>10205000</ns:order-number>
+ <ns:order-version>1</ns:order-version>
+ </ns:request-information>
+ <sdncadapterworkflow:mso-bpel-name>UCPELayer3ServiceActivateV1</sdncadapterworkflow:mso-bpel-name>
+ </sdncadapterworkflow:MsoCompletionRequest>
+ """
+
+ @Test
+ public void testPreProcessRequest() {
+
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("CompleteMsoProcessRequest")).thenReturn(completeMsoProcessRequest)
+ when(mockExecution.getVariable("mso.adapters.db.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC");
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7");
+
+ CompleteMsoProcess completeMsoProcess = new CompleteMsoProcess()
+ completeMsoProcess.preProcessRequest(mockExecution)
+
+ /* Initialize all the process request variables in this block */
+ verify(mockExecution).setVariable("prefix","CMSO_")
+ //verify(mockExecution).setVariable("getLayer3ServiceDetailsV1Response","")
+ verify(mockExecution).setVariable("CMSO_request_id","")
+ verify(mockExecution).setVariable("CMSO_notification-url","")
+ verify(mockExecution).setVariable("CMSO_mso-bpel-name","")
+ verify(mockExecution).setVariable("CMSO_request_action","")
+
+ verify(mockExecution).setVariable("CMSO_notification-url-Ok", false)
+ verify(mockExecution).setVariable("CMSO_request_id-Ok", false)
+
+ //updateRequest Adapter process variables
+ verify(mockExecution).setVariable("CMSO_updateRequestResponse", "")
+ verify(mockExecution).setVariable("CMSO_updateRequestResponseCode", "")
+ verify(mockExecution).setVariable("CMSO_updateFinalNotifyAckStatusFailedPayload", "")
+
+ //Set DB adapter variables here
+ verify(mockExecution).setVariable("CMSO_updateDBStatusToSuccessPayload", "")
+ verify(mockExecution).setVariable("CMSO_updateInfraRequestDBPayload", "")
+ verify(mockExecution).setVariable("CMSO_setUpdateDBstatustoSuccessPayload", "")
+
+ //Auth variables
+ verify(mockExecution).setVariable("BasicAuthHeaderValue","")
+
+ //Response variables
+ verify(mockExecution).setVariable("CompletionHandlerResponse","")
+ verify(mockExecution).setVariable("CMSO_ErrorResponse", null)
+ verify(mockExecution).setVariable("CMSO_ResponseCode", "")
+
+ verify(mockExecution).setVariable("CMSO_notification-url-Ok",true)
+ verify(mockExecution).setVariable("CMSO_request_id-Ok",true)
+ verify(mockExecution).setVariable("CMSO_notification-url","http://localhost:28090/CCD/StatusNotification")
+ verify(mockExecution).setVariable("CMSO_request_id","uCPE1020_STUW105_5002")
+ verify(mockExecution).setVariable("CMSO_request_action","Layer3ServiceActivateRequest")
+ verify(mockExecution).setVariable("CMSO_source","OMX")
+
+ }
+
+ private String setUpdateDBstatustoSuccessPayload = """
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.onap.so/requestsdb">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <req:updateInfraRequest>
+ <requestId>testReqId</requestId>
+ <lastModifiedBy>BPEL</lastModifiedBy>
+ <statusMessage>Resource Completed Successfully</statusMessage>
+ <requestStatus>COMPLETE</requestStatus>
+ <progress>100</progress>
+
+ </req:updateInfraRequest>
+ </soapenv:Body>
+ </soapenv:Envelope>"""
+
+ @Test
+ public void testsetUpdateDBstatustoSuccessPayload(){
+
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("CMSO_request_id")).thenReturn("testReqId")
+ when(mockExecution.getVariable("CMSO_mso-bpel-name")).thenReturn("BPEL")
+ when(mockExecution.getVariable("mso.adapters.db.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC");
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7");
+
+ CompleteMsoProcess completeMsoProcess = new CompleteMsoProcess()
+ completeMsoProcess.setUpdateDBstatustoSuccessPayload(mockExecution)
+
+ verify(mockExecution).setVariable("CMSO_setUpdateDBstatustoSuccessPayload",setUpdateDBstatustoSuccessPayload)
+ }
+
+ private String msoCompletionResponse = """onse xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1">
+ <sdncadapterworkflow:out>BPEL BPEL-NAME FAILED</sdncadapterworkflow:out>
+</sdncadapterworkflow:MsoCompletionResponse>"""
+
+/*
+ private String msoCompletionResponse = """<sdncadapterworkflow:MsoCompletionResponse xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1">
+ <sdncadapterworkflow:out>BPEL BPEL-NAME FAILED</sdncadapterworkflow:out>
+</sdncadapterworkflow:MsoCompletionResponse>"""
+*/
+ @Test
+ void testBuildDataError() {
+ // given
+ def message = "Some-Message"
+
+ def mockExecution = mock ExecutionEntity.class
+ when mockExecution.getVariable("CMSO_mso-bpel-name") thenReturn "BPEL-NAME"
+ when mockExecution.getVariable("testProcessKey") thenReturn "CompleteMsoProcess"
+
+ def completeMsoProcess = new CompleteMsoProcess()
+ // when
+ assertThatThrownBy { completeMsoProcess.buildDataError(mockExecution, message) } isInstanceOf BpmnError
+ // then
+ verify mockExecution setVariable("CompleteMsoProcessResponse", msoCompletionResponse)
+ def argumentCaptor = ArgumentCaptor.forClass WorkflowException.class
+ verify mockExecution setVariable(eq("WorkflowException"), argumentCaptor.capture())
+ def capturedException = argumentCaptor.value
+
+ assertThat capturedException.processKey isEqualTo "CompleteMsoProcess"
+ assertThat capturedException.errorCode isEqualTo 500
+ assertThat capturedException.errorMessage isEqualTo message
+ }
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy
new file mode 100644
index 0000000000..9b3b8c2fb0
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupNameTest.groovy
@@ -0,0 +1,130 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*
+
+import org.onap.so.rest.HttpHeader
+import org.mockito.MockitoAnnotations
+import org.mockito.runners.MockitoJUnitRunner
+import org.mockito.internal.debugging.MockitoDebuggerImpl
+import org.junit.Before
+import org.onap.so.bpmn.common.scripts.AaiUtil;
+import org.junit.Rule;
+import org.junit.Test
+import org.junit.Ignore
+import org.junit.runner.RunWith
+import org.junit.Before;
+import org.junit.Test;
+import org.camunda.bpm.engine.ProcessEngineServices
+import org.camunda.bpm.engine.RepositoryService
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl
+import org.camunda.bpm.engine.repository.ProcessDefinition
+import org.junit.Assert
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.mockito.runners.MockitoJUnitRunner
+import org.onap.so.bpmn.common.scripts.ConfirmVolumeGroupName
+import org.onap.so.bpmn.core.WorkflowException
+
+import static com.github.tomakehurst.wiremock.client.WireMock.*
+import static org.mockito.Mockito.*
+
+@RunWith(MockitoJUnitRunner.class)
+@Ignore
+class ConfirmVolumeGroupNameTest extends MsoGroovyTest {
+
+ @Captor
+ ArgumentCaptor<ExecutionEntity> captor= ArgumentCaptor.forClass(ExecutionEntity.class);
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(8090);
+
+ @Test
+ public void testQueryAAIForVolumeGroupId() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn('http://localhost:8090')
+ when(mockExecution.getVariable("CVGN_volumeGroupGetEndpoint")).thenReturn('/aai/test/volume-groups/volume-group/testVolumeGroup')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+
+ mockData()
+
+ ConfirmVolumeGroupName confirmVolumeGroupName = new ConfirmVolumeGroupName()
+ confirmVolumeGroupName.queryAAIForVolumeGroupId(mockExecution)
+ verify(mockExecution).setVariable("CVGN_queryVolumeGroupResponseCode",200)
+ verify(mockExecution).setVariable("CVGN_queryVolumeGroupResponse","")
+ }
+
+ @Test
+ public void testQueryAAIForVolumeGroupId_404() {
+
+ ExecutionEntity mockExecution = setupMock()
+ try {
+ when(mockExecution.getVariable("CVGN_volumeGroupGetEndpoint")).thenReturn('/aai/test/volume-groups/volume-group/testVolumeGroup')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+
+ mockData()
+
+ ConfirmVolumeGroupName confirmVolumeGroupName = new ConfirmVolumeGroupName()
+ confirmVolumeGroupName.queryAAIForVolumeGroupId(mockExecution)
+ }
+ catch(Exception ex){
+
+ }
+ Mockito.verify(mockExecution,times(4)).setVariable(captor.capture(),captor.capture())
+ WorkflowException workflowException = captor.getValue()
+ Assert.assertEquals("AAI GET Failed",workflowException.getErrorMessage())
+ Assert.assertEquals(500,workflowException.getErrorCode())
+ }
+ private void mockData() {
+ stubFor(get(urlMatching("/aai/test/volume-groups/volume-group/testVolumeGroup"))
+ .willReturn(aResponse()
+ .withStatus(200)))
+ }
+
+ private ExecutionEntity setupMock() {
+
+ ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
+ when(mockProcessDefinition.getKey()).thenReturn("ConfirmVolumeGroupName")
+ RepositoryService mockRepositoryService = mock(RepositoryService.class)
+ when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
+ when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("ConfirmVolumeGroupName")
+ when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100")
+ ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)
+ when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getId()).thenReturn("100")
+ when(mockExecution.getProcessDefinitionId()).thenReturn("ConfirmVolumeGroupName")
+ when(mockExecution.getProcessInstanceId()).thenReturn("ConfirmVolumeGroupName")
+ when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
+ when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition)
+ return mockExecution
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenantTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenantTest.groovy
new file mode 100644
index 0000000000..1b76f5cb3f
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ConfirmVolumeGroupTenantTest.groovy
@@ -0,0 +1,125 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*
+
+import org.onap.so.rest.HttpHeader
+import org.mockito.MockitoAnnotations
+import org.mockito.runners.MockitoJUnitRunner
+import org.mockito.internal.debugging.MockitoDebuggerImpl
+import org.junit.Before
+import org.onap.so.bpmn.common.scripts.AaiUtil;
+import org.junit.Rule;
+import org.junit.Test
+import org.junit.Ignore
+import org.junit.runner.RunWith
+import org.junit.Before;
+import org.junit.Test;
+import org.camunda.bpm.engine.ProcessEngineServices
+import org.camunda.bpm.engine.RepositoryService
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl
+import org.camunda.bpm.engine.repository.ProcessDefinition
+import org.junit.Assert
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.mockito.runners.MockitoJUnitRunner
+import org.onap.so.bpmn.common.scripts.ConfirmVolumeGroupTenant
+import org.onap.so.bpmn.core.WorkflowException
+
+import static com.github.tomakehurst.wiremock.client.WireMock.*
+import static org.mockito.Mockito.*
+
+@RunWith(MockitoJUnitRunner.class)
+@Ignore
+class ConfirmVolumeGroupTenantTest extends MsoGroovyTest {
+
+ @Captor
+ ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class);
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(8090);
+
+ @Test
+ public void testpreProcessRequest() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn('http://localhost:8090')
+ when(mockExecution.getVariable("volumeGroupId")).thenReturn('testVolumeGroupId')
+ when(mockExecution.getVariable("volumeGroupName")).thenReturn('testVolumeGroupName')
+ when(mockExecution.getVariable("tenantId")).thenReturn('tenantId')
+ when(mockExecution.getVariable("aicCloudRegion")).thenReturn('aicCloudRegion')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+
+
+ mockData()
+
+
+ ConfirmVolumeGroupTenant confirmVolumeGroupTenant = new ConfirmVolumeGroupTenant()
+ confirmVolumeGroupTenant.preProcessRequest(mockExecution)
+ /* Mockito.verify(mockExecution, times(5)).setVariable(captor.capture(), captor.capture())*/
+ verify(mockExecution).setVariable("prefix", "CVGT_")
+ verify(mockExecution).setVariable("queryVolumeGroupResponseCode", 200)
+ verify(mockExecution).setVariable("queryAAIVolumeGroupResponse", "<volume-group xmlns=\"http://org.openecomp.aai.inventory/v10\"><volume-group-id>17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c</volume-group-id><volume-group-name>MSOTESTVOL103a-vSAMP12_base_module-0_vol</volume-group-name><heat-stack-id>9d1f53e3-3158-44f8-8032-a6bf40bbc9db</heat-stack-id><vnf-type>pcrf-capacity</vnf-type><orchestration-status>Active</orchestration-status><resource-version>0000020</resource-version><relationship-list><relationship><related-to>tenant</related-to><relationship-data><relationship-key>cloud-region.cloud-owner</relationship-key><relationship-value>att-aic</relationship-value></relationship-data><relationship-data><relationship-key>cloud-region.cloud-region-id</relationship-key><relationship-value>RegionOne</relationship-value></relationship-data><relationship-data><relationship-key>tenant.tenant-id</relationship-key><relationship-value>22eb191dd41a4f3c9be370fc638322f4</relationship-value></relationship-data></relationship></relationship-list></volume-group>")
+ verify(mockExecution).setVariable("tenantIdsMatch", false)
+ verify(mockExecution).setVariable("groupNamesMatch", false)
+ }
+
+
+ private void mockData() {
+ stubFor(get(urlMatching("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/aicCloudRegion/volume-groups/volume-group/testVolumeGroupId"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withBody("<volume-group xmlns=\"http://org.openecomp.aai.inventory/v10\"><volume-group-id>17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c</volume-group-id><volume-group-name>MSOTESTVOL103a-vSAMP12_base_module-0_vol</volume-group-name><heat-stack-id>9d1f53e3-3158-44f8-8032-a6bf40bbc9db</heat-stack-id><vnf-type>pcrf-capacity</vnf-type><orchestration-status>Active</orchestration-status><resource-version>0000020</resource-version><relationship-list><relationship><related-to>tenant</related-to><relationship-data><relationship-key>cloud-region.cloud-owner</relationship-key><relationship-value>att-aic</relationship-value></relationship-data><relationship-data><relationship-key>cloud-region.cloud-region-id</relationship-key><relationship-value>RegionOne</relationship-value></relationship-data><relationship-data><relationship-key>tenant.tenant-id</relationship-key><relationship-value>22eb191dd41a4f3c9be370fc638322f4</relationship-value></relationship-data></relationship></relationship-list></volume-group>")))
+ }
+
+ private ExecutionEntity setupMock() {
+
+ ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
+ when(mockProcessDefinition.getKey()).thenReturn("ConfirmVolumeGroupTenant")
+ RepositoryService mockRepositoryService = mock(RepositoryService.class)
+ when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
+ when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("ConfirmVolumeGroupTenant")
+ when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100")
+ ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)
+ when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)
+
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getId()).thenReturn("100")
+ when(mockExecution.getProcessDefinitionId()).thenReturn("ConfirmVolumeGroupTenant")
+ when(mockExecution.getProcessInstanceId()).thenReturn("ConfirmVolumeGroupTenant")
+ when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
+ when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition)
+
+ return mockExecution
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CustomE2EGetServiceTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CustomE2EGetServiceTest.groovy
new file mode 100644
index 0000000000..a8c10b1e81
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CustomE2EGetServiceTest.groovy
@@ -0,0 +1,104 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.junit.Assert
+import org.junit.Before
+import org.junit.Ignore
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.mockito.runners.MockitoJUnitRunner
+
+import static org.mockito.Mockito.times
+import static org.mockito.Mockito.when
+import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetServiceInstance
+import static org.onap.so.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById
+import static org.onap.so.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName
+
+/**
+ * @author sushilma
+ * @since January 10, 2018
+ */
+@RunWith(MockitoJUnitRunner.class)
+@Ignore
+class CustomE2EGetServiceTest extends MsoGroovyTest {
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(28090)
+
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+ @Test
+ public void testObtainServiceInstanceUrlById (){
+ ExecutionEntity mockExecution = setupMockWithPrefix('CustomE2EGetService','GENGS_')
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.nodes-query.uri")).thenReturn('/aai/v8/search/nodes-query')
+ when(mockExecution.getVariable("GENGS_type")).thenReturn('service-instance')
+ when(mockExecution.getVariable("GENGS_serviceInstanceId")).thenReturn("MIS%2F1604%2F0026%2FSW_INTERNET")
+ MockNodeQueryServiceInstanceById("MIS%2F1604%2F0026%2FSW_INTERNET", "GenericFlows/getSIUrlById.xml");
+ CustomE2EGetService customE2EGetService = new CustomE2EGetService();
+ customE2EGetService.obtainServiceInstanceUrlById(mockExecution)
+ Mockito.verify(mockExecution, times(9)).setVariable(captor.capture(), captor.capture())
+ Assert.assertEquals(200, captor.getAllValues().get(5))
+ }
+
+ @Test
+ public void testObtainServiceInstanceUrlByName (){
+ ExecutionEntity mockExecution = setupMockWithPrefix('CustomE2EGetService','GENGS_')
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.nodes-query.uri")).thenReturn('/aai/v8/search/nodes-query')
+ when(mockExecution.getVariable("GENGS_type")).thenReturn('service-instance')
+ when(mockExecution.getVariable("GENGS_serviceInstanceName")).thenReturn("1604-MVM-26")
+ MockNodeQueryServiceInstanceByName("1604-MVM-26", "GenericFlows/getSIUrlByName.xml");
+ CustomE2EGetService customE2EGetService = new CustomE2EGetService();
+ customE2EGetService.obtainServiceInstanceUrlByName(mockExecution)
+ Mockito.verify(mockExecution, times(8)).setVariable(captor.capture(), captor.capture())
+ Assert.assertEquals(200, captor.getAllValues().get(5))
+ }
+
+ @Test
+ public void testServiceObject (){
+ ExecutionEntity mockExecution = setupMockWithPrefix('CustomE2EGetService','GENGS_')
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.nodes-query.uri")).thenReturn('/aai/v8/search/nodes-query')
+ when(mockExecution.getVariable("GENGS_type")).thenReturn('service-instance')
+ when(mockExecution.getVariable("GENGS_serviceInstanceId")).thenReturn("MIS%2F1604%2F0026%2FSW_INTERNET")
+ when(mockExecution.getVariable("GENGS_resourceLink")).thenReturn("/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/1234453")
+ MockGetServiceInstance("MSO_1610_dev", "MSO-dev-service-type", "1234453", "GenericFlows/getServiceInstance.xml");
+ CustomE2EGetService customE2EGetService = new CustomE2EGetService();
+ customE2EGetService.getServiceObject(mockExecution)
+ Mockito.verify(mockExecution, times(7)).setVariable(captor.capture(), captor.capture())
+ Assert.assertEquals(200, captor.getAllValues().get(5))
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CustomE2EPutServiceTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CustomE2EPutServiceTest.groovy
new file mode 100644
index 0000000000..879ef7ab4f
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/CustomE2EPutServiceTest.groovy
@@ -0,0 +1,72 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.junit.Assert
+import org.junit.Before
+import org.junit.Ignore
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.mockito.runners.MockitoJUnitRunner
+
+import static org.mockito.Mockito.times
+import static org.mockito.Mockito.when
+import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutServiceInstance
+
+/**
+ * @author sushilma
+ * @since January 10, 2018
+ */
+@RunWith(MockitoJUnitRunner.class)
+@Ignore
+class CustomE2EPutServiceTest extends MsoGroovyTest {
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(28090)
+
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+ @Test
+ public void testPutServiceInstance(){
+ ExecutionEntity mockExecution = setupMockWithPrefix('CustomE2EPutService','GENPS_')
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.customer.uri")).thenReturn('/aai/v8/business/customers/customer')
+ when(mockExecution.getVariable("GENPS_type")).thenReturn('service-instance')
+ when(mockExecution.getVariable("GENPS_payload")).thenReturn('')
+ when(mockExecution.getVariable("GENPS_globalSubscriberId")).thenReturn("1604-MVM-26")
+ when(mockExecution.getVariable("GENPS_serviceType")).thenReturn("SDN-ETHERNET-INTERNET")
+ when(mockExecution.getVariable("GENPS_serviceInstanceId")).thenReturn( "1234")
+ MockPutServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234", "GenericFlows/getServiceInstance.xml");
+
+ CustomE2EPutService customE2EPutService = new CustomE2EPutService()
+ customE2EPutService.putServiceInstance(mockExecution);
+ Mockito.verify(mockExecution, times(6)).setVariable(captor.capture(), captor.capture())
+ Assert.assertEquals(200, captor.getAllValues().get(7))
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModuleTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModuleTest.groovy
new file mode 100644
index 0000000000..025bea5325
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/DeleteAAIVfModuleTest.groovy
@@ -0,0 +1,218 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule
+import org.camunda.bpm.engine.ProcessEngineServices
+import org.camunda.bpm.engine.RepositoryService
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.camunda.bpm.engine.repository.ProcessDefinition
+import org.junit.Assert
+import org.junit.Before
+import org.junit.Ignore
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mock
+import org.mockito.Mockito
+import org.mockito.MockitoAnnotations
+import org.mockito.runners.MockitoJUnitRunner
+import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.bpmn.mock.StubResponseAAI
+
+import static com.github.tomakehurst.wiremock.client.WireMock.*
+import static org.mockito.Mockito.*
+
+@RunWith(MockitoJUnitRunner.class)
+@Ignore
+class DeleteAAIVfModuleTest {
+
+ def prefix = "DAAIVfMod_"
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(28090)
+
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+ @Before
+ void init() throws IOException {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ void testQueryAAIForGenericVnf() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("prefix")).thenReturn(prefix)
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable(prefix + "genericVnfEndpoint")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf/skask")
+ when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
+ when(mockExecution.getVariable("aai.auth")).thenReturn("9B2278E8B8E95F256A560719055F4DF3")
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("aa3871669d893c7fb8abbcda31b88b4f")
+
+ StubResponseAAI.MockAAIVfModule()
+ DeleteAAIVfModule obj = new DeleteAAIVfModule()
+ obj.queryAAIForGenericVnf(mockExecution)
+
+ Mockito.verify(mockExecution).setVariable(prefix + "queryGenericVnfResponseCode", 200)
+ }
+
+ @Test
+ void testQueryAAIForGenericVnfEndpointNull() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable(prefix + "genericVnfEndpoint")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf/skask")
+ when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn(null)
+ when(mockExecution.getVariable("aai.auth")).thenReturn("9B2278E8B8E95F256A560719055F4DF3")
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("aa3871669d893c7fb8abbcda31b88b4f")
+
+ StubResponseAAI.MockAAIVfModule()
+ try {
+ DeleteAAIVfModule obj = new DeleteAAIVfModule()
+ obj.queryAAIForGenericVnf(mockExecution)
+ } catch (Exception ex) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+
+ Mockito.verify(mockExecution, times(2)).setVariable(captor.capture(), captor.capture())
+ WorkflowException workflowException = captor.getValue()
+ Assert.assertEquals(5000, workflowException.getErrorCode())
+ Assert.assertEquals("Internal Error - Occured during queryAAIForGenericVnf", workflowException.getErrorMessage())
+ }
+
+ @Test
+ void testDeleteGenericVnf() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable(prefix + "genericVnfEndpoint")).thenReturn("/aai/v9/cloud-infrastructure/volume-groups/volume-group/78987")
+ when(mockExecution.getVariable(prefix + "genVnfRsrcVer")).thenReturn("0000020")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
+ when(mockExecution.getVariable("aai.auth")).thenReturn("9B2278E8B8E95F256A560719055F4DF3")
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("aa3871669d893c7fb8abbcda31b88b4f")
+
+ stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group/78987/[?]resource-version=0000020"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("")))
+
+ StubResponseAAI.MockAAIVfModule()
+ DeleteAAIVfModule obj = new DeleteAAIVfModule()
+ obj.deleteGenericVnf(mockExecution)
+
+ Mockito.verify(mockExecution).setVariable(prefix + "deleteGenericVnfResponseCode", 200)
+ }
+
+ @Test
+ void testDeleteGenericVnfEndpointNull() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable(prefix + "genericVnfEndpoint")).thenReturn("/aai/v9/cloud-infrastructure/volume-groups/volume-group/78987")
+ when(mockExecution.getVariable(prefix + "genVnfRsrcVer")).thenReturn("0000020")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn(null)
+ when(mockExecution.getVariable("aai.auth")).thenReturn("9B2278E8B8E95F256A560719055F4DF3")
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("aa3871669d893c7fb8abbcda31b88b4f")
+
+ StubResponseAAI.MockAAIVfModule()
+ try {
+ DeleteAAIVfModule obj = new DeleteAAIVfModule()
+ obj.deleteGenericVnf(mockExecution)
+ } catch (Exception ex) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+
+ Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture())
+ WorkflowException workflowException = captor.getValue()
+ Assert.assertEquals(5000, workflowException.getErrorCode())
+ Assert.assertEquals("Internal Error - Occured during deleteGenericVnf", workflowException.getErrorMessage())
+ }
+
+ @Test
+ void testDeleteVfModule() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable(prefix + "vfModuleEndpoint")).thenReturn("/aai/v9/cloud-infrastructure/volume-groups/volume-group/78987")
+ when(mockExecution.getVariable(prefix + "vfModRsrcVer")).thenReturn("0000020")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
+ when(mockExecution.getVariable("aai.auth")).thenReturn("9B2278E8B8E95F256A560719055F4DF3")
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("aa3871669d893c7fb8abbcda31b88b4f")
+
+ stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group/78987/[?]resource-version=0000020"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withHeader("Content-Type", "text/xml")
+ .withBodyFile("")))
+
+ DeleteAAIVfModule obj = new DeleteAAIVfModule()
+ obj.deleteVfModule(mockExecution)
+
+ Mockito.verify(mockExecution).setVariable(prefix + "deleteVfModuleResponseCode", 200)
+ }
+
+ @Test
+ void testDeleteVfModuleEndpointNull() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable(prefix + "vfModuleEndpoint")).thenReturn("/aai/v9/cloud-infrastructure/volume-groups/volume-group/78987")
+ when(mockExecution.getVariable(prefix + "vfModRsrcVer")).thenReturn("0000020")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn(null)
+ when(mockExecution.getVariable("aai.auth")).thenReturn("9B2278E8B8E95F256A560719055F4DF3")
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("aa3871669d893c7fb8abbcda31b88b4f")
+
+ StubResponseAAI.MockAAIVfModule()
+ try {
+ DeleteAAIVfModule obj = new DeleteAAIVfModule()
+ obj.deleteVfModule(mockExecution)
+ } catch (Exception ex) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+
+ Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture())
+ WorkflowException workflowException = captor.getValue()
+ Assert.assertEquals(5000, workflowException.getErrorCode())
+ Assert.assertEquals("Internal Error - Occured during deleteVfModule", workflowException.getErrorMessage())
+ }
+
+ private static ExecutionEntity setupMock() {
+ ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
+ when(mockProcessDefinition.getKey()).thenReturn("DeleteAAIVfModule")
+ RepositoryService mockRepositoryService = mock(RepositoryService.class)
+ when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
+ when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DeleteAAIVfModule")
+ 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("DeleteAAIVfModule")
+ when(mockExecution.getProcessInstanceId()).thenReturn("DeleteAAIVfModule")
+ when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
+ when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition)
+
+ return mockExecution
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtilTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtilTest.groovy
new file mode 100644
index 0000000000..c7015cda50
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/ExceptionUtilTest.groovy
@@ -0,0 +1,98 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import org.junit.Assert
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+
+
+import org.junit.Ignore;
+
+import static org.mockito.Mockito.*
+
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.junit.Before
+import org.junit.runner.RunWith
+import org.mockito.MockitoAnnotations
+import org.mockito.internal.debugging.MockitoDebuggerImpl
+import org.mockito.runners.MockitoJUnitRunner
+import org.onap.so.bpmn.common.scripts.ExceptionUtil;
+import org.onap.so.bpmn.core.WorkflowException
+@RunWith(MockitoJUnitRunner.class)
+import org.junit.Test
+
+
+
+class ExceptionUtilTest {
+
+
+ @Before
+ public void init()
+ {
+ MockitoAnnotations.initMocks(this)
+ }
+
+ @Test
+ public void testMapErrorCode5010(){
+ String msg = "Connect to njcdtl20ew2988:8070 failed: Connection refused: connect"
+ ExceptionUtil util = new ExceptionUtil()
+ Assert.assertEquals("5010",util.MapErrorCode(msg))
+ }
+
+ @Test
+ public void testMapErrorCode5020(){
+ String msg = "Connection timed out"
+ ExceptionUtil util = new ExceptionUtil()
+ Assert.assertEquals("5020",util.MapErrorCode(msg))
+ }
+
+ @Test
+ public void testGetErrorCode() {
+ ExceptionUtil eUtil = new ExceptionUtil()
+ WorkflowException we = new WorkflowException("CreateVCEV2", 400, "SDNC Test Error")
+ int errCd = eUtil.getErrorCode(we)
+ Assert.assertEquals(400, errCd)
+ }
+
+ @Test
+ public void testGetErrorCodeWithNullWfe() {
+ ExceptionUtil eUtil = new ExceptionUtil()
+ int errCd = eUtil.getErrorCode(null)
+ Assert.assertEquals(2500, errCd)
+ }
+
+ @Test
+ public void testGetErrorMessage() {
+ ExceptionUtil eUtil = new ExceptionUtil()
+ WorkflowException we = new WorkflowException("CreateVCEV2", 400, "SDNC Test Error")
+ String errMsg = eUtil.getErrorMessage(we, "CreateVCEV2")
+ Assert.assertEquals("SDNC Test Error", errMsg)
+ }
+
+ @Test
+ public void testGetErrorMessageWithNullWfe() {
+ ExceptionUtil eUtil = new ExceptionUtil()
+ String errMsg = eUtil.getErrorMessage(null, "CreateVCEV2")
+ Assert.assertEquals("Unexpected error encountered in CreateVCEV2", errMsg)
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/FalloutHandlerTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/FalloutHandlerTest.groovy
new file mode 100644
index 0000000000..016d968a12
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/FalloutHandlerTest.groovy
@@ -0,0 +1,312 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import org.junit.runner.RunWith;
+import static org.mockito.Mockito.*
+import static org.junit.Assert.*;
+
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.ArgumentCaptor;
+import org.mockito.MockitoAnnotations
+import org.mockito.runners.MockitoJUnitRunner
+import org.onap.so.bpmn.common.scripts.MsoUtils;
+import org.onap.so.bpmn.common.scripts.FalloutHandler;
+
+@RunWith(MockitoJUnitRunner.class)
+class FalloutHandlerTest {
+
+ public MsoUtils utils = new MsoUtils()
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this)
+ }
+
+ private String falloutHandlerRequest = """
+ <sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1" xmlns:ns7="http://org.onap/so/request/types/v1">
+ <ns7:request-information>
+ <ns7:request-id>uCPE1020_STUW105_5002</ns7:request-id>
+ <ns7:request-action>Layer3ServiceActivateRequest</ns7:request-action>
+ <ns7:request-sub-action>CANCEL</ns7:request-sub-action>
+ <ns7:source>OMX</ns7:source>
+ <ns7:order-number>10205000</ns7:order-number>
+ <ns7:order-version>1</ns7:order-version>
+ </ns7:request-information>
+ <sdncadapterworkflow:WorkflowException>
+ <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>
+ <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>
+ <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>
+ </sdncadapterworkflow:WorkflowException>
+ </sdncadapterworkflow:FalloutHandlerRequest>
+ """
+
+ private String falloutHandlerResponse = """<workflow:FalloutHandlerResponse xmlns:workflow="http://org.onap/so/workflow/schema/v1">
+ <workflow:out>Fallout Handler Failed</workflow:out>
+</workflow:FalloutHandlerResponse>"""
+
+ @Test
+ public void testPreProcessRequest() {
+
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+
+ when(mockExecution.getVariable("FalloutHandlerRequest")).thenReturn(falloutHandlerRequest)
+ when(mockExecution.getVariable("mso.adapters.db.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC");
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7");
+
+ FalloutHandler falloutHandler = new FalloutHandler()
+ falloutHandler.preProcessRequest(mockExecution)
+
+ /* Initialize all the process request variables in this block */
+ verify(mockExecution).setVariable("prefix","FH_")
+ //verify(mockExecution).setVariable("getLayer3ServiceDetailsV1Response","")
+
+ //These variables are form the input Message to the BPMN
+ verify(mockExecution).setVariable("FH_request_id","")
+ verify(mockExecution).setVariable("FH_request_action","")
+ verify(mockExecution).setVariable("FH_notification-url","")
+ verify(mockExecution).setVariable("FH_mso-bpel-name","")
+ verify(mockExecution).setVariable("FH_ErrorCode", "")
+ verify(mockExecution).setVariable("FH_ErrorMessage", "")
+
+ verify(mockExecution).setVariable("FH_notification-url-Ok", false)
+ verify(mockExecution).setVariable("FH_request_id-Ok", false)
+
+ //These variables are for Get Mso Aai Password Adapter
+ verify(mockExecution).setVariable("FH_deliveryStatus", true)
+
+ //update Response Status to pending ...Adapter variables
+ verify(mockExecution).setVariable("FH_updateResponseStatusPayload", null)
+ verify(mockExecution).setVariable("FH_updateResponseStatusResponse", null)
+
+ //update Request Gamma ...Adapter variables
+ verify(mockExecution).setVariable("FH_updateRequestGammaPayload", "")
+ verify(mockExecution).setVariable("FH_updateRequestGammaResponse", null)
+ verify(mockExecution).setVariable("FH_updateRequestGammaResponseCode", null)
+
+ //update Request Infra ...Adapter variables
+ verify(mockExecution).setVariable("FH_updateRequestInfraPayload", "")
+ verify(mockExecution).setVariable("FH_updateRequestInfraResponse", null)
+ verify(mockExecution).setVariable("FH_updateRequestInfraResponseCode", null)
+
+ //assign False to success variable
+ verify(mockExecution).setVariable("FH_success", true)
+
+ //Set notify status to Failed variable
+ verify(mockExecution).setVariable("FH_NOTIFY_STATUS", "SUCCESS")
+
+ //Set DB update variable
+ verify(mockExecution).setVariable("FH_updateRequestPayload", "")
+ verify(mockExecution).setVariable("FH_updateRequestResponse", null)
+ verify(mockExecution).setVariable("FH_updateRequestResponseCode", null)
+
+ //Auth variables
+ verify(mockExecution).setVariable("BasicAuthHeaderValue","")
+
+ //Response variables
+ verify(mockExecution).setVariable("FalloutHandlerResponse","")
+ verify(mockExecution).setVariable("FH_ErrorResponse", null)
+ verify(mockExecution).setVariable("FH_ResponseCode", "")
+
+ verify(mockExecution).setVariable("FH_request_id-Ok",true)
+ verify(mockExecution).setVariable("FH_request_id","uCPE1020_STUW105_5002")
+ verify(mockExecution).setVariable("FH_request_action","Layer3ServiceActivateRequest")
+ verify(mockExecution).setVariable("FH_source","OMX")
+ verify(mockExecution).setVariable("FH_ErrorCode","Some Error Code - Fallout Handler")
+ verify(mockExecution).setVariable("FH_ErrorMessage","Some Error Message - Fallout Handler")
+
+ }
+
+ @Test
+ public void testpostProcessResponse(){
+
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("FH_success")).thenReturn(false)
+
+ FalloutHandler falloutHandler = new FalloutHandler()
+ falloutHandler.postProcessResponse(mockExecution)
+
+ // Capture the arguments to setVariable
+ ArgumentCaptor<String> captor1 = ArgumentCaptor.forClass(String.class);
+ ArgumentCaptor<String> captor2 = ArgumentCaptor.forClass(String.class);
+
+ verify(mockExecution, times(4)).setVariable(captor1.capture(), captor2.capture())
+ List<String> arg2List = captor2.getAllValues()
+ String payloadResponseActual = arg2List.get(1)
+
+ assertEquals(falloutHandlerResponse.replaceAll("\\s+", ""), payloadResponseActual.replaceAll("\\s+", ""))
+
+ verify(mockExecution).setVariable("FH_ResponseCode","500")
+ }
+
+ private String updateRequestPayload = """
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.onap.so/requestsdb">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <req:updateRequest>
+ <requestId>testReqId</requestId>
+ <lastModifiedBy>BPEL</lastModifiedBy>
+ <finalErrorMessage>ErrorMessage</finalErrorMessage>
+ <finalErrorCode>ErrorCode</finalErrorCode>
+ <status>FAILED</status>
+ <responseStatus>NotifyStatus</responseStatus>
+ </req:updateRequest>
+ </soapenv:Body>
+ </soapenv:Envelope>
+ """
+
+ @Test
+ public void testupdateRequestPayload(){
+
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("FH_request_id")).thenReturn("testReqId")
+ when(mockExecution.getVariable("FH_ErrorMessage")).thenReturn("ErrorMessage")
+ when(mockExecution.getVariable("FH_ErrorCode")).thenReturn("ErrorCode")
+ when(mockExecution.getVariable("FH_NOTIFY_STATUS")).thenReturn("NotifyStatus")
+
+ FalloutHandler falloutHandler = new FalloutHandler()
+ falloutHandler.updateRequestPayload(mockExecution)
+
+ // Capture the arguments to setVariable
+ ArgumentCaptor<String> captor1 = ArgumentCaptor.forClass(String.class);
+ ArgumentCaptor<String> captor2 = ArgumentCaptor.forClass(String.class);
+
+ verify(mockExecution, times(1)).setVariable(captor1.capture(), captor2.capture())
+ List<String> arg2List = captor2.getAllValues()
+ String payloadRequestActual = arg2List.get(0)
+
+ assertEquals(updateRequestPayload.replaceAll("\\s+", ""), payloadRequestActual.replaceAll("\\s+", ""))
+ }
+
+ private String updateRequestInfraPayload = """
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.onap.so/requestsdb">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <req:updateInfraRequest>
+ <requestId>testReqId</requestId>
+ <lastModifiedBy>BPEL</lastModifiedBy>
+ <statusMessage>ErrorMessage</statusMessage>
+ <requestStatus>FAILED</requestStatus>
+ <progress>100</progress>
+ </req:updateInfraRequest>
+ </soapenv:Body>
+ </soapenv:Envelope>
+ """
+
+ @Test
+ public void testupdateRequestInfraPayload(){
+
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("FH_request_id")).thenReturn("testReqId")
+ when(mockExecution.getVariable("FH_ErrorMessage")).thenReturn("ErrorMessage")
+
+ FalloutHandler falloutHandler = new FalloutHandler()
+ falloutHandler.updateRequestInfraPayload(mockExecution)
+
+ // Capture the arguments to setVariable
+ ArgumentCaptor<String> captor1 = ArgumentCaptor.forClass(String.class);
+ ArgumentCaptor<String> captor2 = ArgumentCaptor.forClass(String.class);
+
+ verify(mockExecution, times(1)).setVariable(captor1.capture(), captor2.capture())
+ List<String> arg2List = captor2.getAllValues()
+ String payloadRequestActual = arg2List.get(0)
+
+ assertEquals(updateRequestInfraPayload.replaceAll("\\s+", ""), payloadRequestActual.replaceAll("\\s+", ""))
+ }
+
+ private String updateRequestGammaPayload = """
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.onap.so/requestsdb">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <req:updateRequest>
+ <requestId>testReqId</requestId>
+ <lastModifiedBy>BPEL</lastModifiedBy>
+ <finalErrorMessage>ErrorMessage</finalErrorMessage>
+ <finalErrorCode>ErrorCode</finalErrorCode>
+ <status>FAILED</status>
+ </req:updateRequest>
+ </soapenv:Body>
+ </soapenv:Envelope>
+ """
+
+ @Test
+ public void testupdateRequestGammaPayload(){
+
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("FH_request_id")).thenReturn("testReqId")
+ when(mockExecution.getVariable("FH_ErrorMessage")).thenReturn("ErrorMessage")
+ when(mockExecution.getVariable("FH_ErrorCode")).thenReturn("ErrorCode")
+ when(mockExecution.getVariable("mso.default.adapter.namespace")).thenReturn("http://org.onap.so");
+
+ FalloutHandler falloutHandler = new FalloutHandler()
+ falloutHandler.updateRequestGammaPayload(mockExecution)
+
+ // Capture the arguments to setVariable
+ ArgumentCaptor<String> captor1 = ArgumentCaptor.forClass(String.class);
+ ArgumentCaptor<String> captor2 = ArgumentCaptor.forClass(String.class);
+
+ verify(mockExecution, times(1)).setVariable(captor1.capture(), captor2.capture())
+ List<String> arg2List = captor2.getAllValues()
+ String payloadRequestActual = arg2List.get(0)
+
+ assertEquals(updateRequestGammaPayload.replaceAll("\\s+", ""), payloadRequestActual.replaceAll("\\s+", ""))
+ }
+
+
+ String updateResponseStatusPayload = """
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.onap.so/requestsdb">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <req:updateResponseStatus>
+ <requestId>testReqId</requestId>
+ <lastModifiedBy>BPEL</lastModifiedBy>
+ <responseStatus>SENDING_FINAL_NOTIFY</responseStatus>
+ </req:updateResponseStatus>
+ </soapenv:Body>
+ </soapenv:Envelope>
+ """
+
+ @Test
+ public void testupdateResponseStatusPayload(){
+
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("FH_request_id")).thenReturn("testReqId")
+
+ FalloutHandler falloutHandler = new FalloutHandler()
+ falloutHandler.updateResponseStatusPayload(mockExecution)
+
+ // Capture the arguments to setVariable
+ ArgumentCaptor<String> captor1 = ArgumentCaptor.forClass(String.class);
+ ArgumentCaptor<String> captor2 = ArgumentCaptor.forClass(String.class);
+
+ verify(mockExecution, times(1)).setVariable(captor1.capture(), captor2.capture())
+ List<String> arg2List = captor2.getAllValues()
+ String payloadResponseActual = arg2List.get(0)
+
+ assertEquals(updateResponseStatusPayload.replaceAll("\\s+", ""), payloadResponseActual.replaceAll("\\s+", ""))
+ }
+
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleNameTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleNameTest.groovy
new file mode 100644
index 0000000000..c5baf8cc6c
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenerateVfModuleNameTest.groovy
@@ -0,0 +1,125 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule
+import org.camunda.bpm.engine.ProcessEngineServices
+import org.camunda.bpm.engine.RepositoryService
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.camunda.bpm.engine.repository.ProcessDefinition
+import org.junit.Assert
+import org.junit.Before
+import org.junit.Ignore
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.mockito.runners.MockitoJUnitRunner
+import org.onap.so.bpmn.core.WorkflowException
+
+import static com.github.tomakehurst.wiremock.client.WireMock.*
+import static org.mockito.Mockito.*
+
+@RunWith(MockitoJUnitRunner.class)
+@Ignore
+class GenerateVfModuleNameTest {
+
+ @Captor
+ ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class);
+
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(8090);
+
+ @Test
+ public void testQueryAAI() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn('http://localhost:8090')
+ when(mockExecution.getVariable("vnfId")).thenReturn('skask')
+ when(mockExecution.getVariable("personaModelId")).thenReturn('personaModelId_test')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+ when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn('8')
+
+ mockData()
+ GenerateVfModuleName obj = new GenerateVfModuleName()
+ obj.queryAAI(mockExecution)
+
+ Mockito.verify(mockExecution).setVariable("GVFMN_queryAAIVfModuleResponseCode", 200)
+ }
+
+ @Test
+ public void testQueryAAIEndpointNull() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn(null)
+ when(mockExecution.getVariable("vnfId")).thenReturn('skask')
+ when(mockExecution.getVariable("personaModelId")).thenReturn('personaModelId_test')
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+ when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn('8')
+
+ mockData()
+ try {
+ GenerateVfModuleName obj = new GenerateVfModuleName()
+ obj.queryAAI(mockExecution)
+ } catch (Exception ex) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+
+ Mockito.verify(mockExecution, times(1)).setVariable(captor.capture(), captor.capture())
+ WorkflowException workflowException = captor.getValue()
+ Assert.assertEquals(1002, workflowException.getErrorCode())
+ Assert.assertEquals("AAI GET Failed:org.apache.http.client.ClientProtocolException", workflowException.getErrorMessage())
+ }
+
+
+ private void mockData() {
+ stubFor(get(urlMatching(".*/aai/v[0-9]+/network/generic-vnfs/generic-vnf.*"))
+ .willReturn(aResponse()
+ .withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("GenericFlows/getGenericVnfResponse.xml")))
+ }
+
+ private ExecutionEntity setupMock() {
+
+ ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
+ when(mockProcessDefinition.getKey()).thenReturn("GenerateVfModuleName")
+ RepositoryService mockRepositoryService = mock(RepositoryService.class)
+ when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
+ when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("GenerateVfModuleName")
+ when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100")
+ ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)
+ when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getId()).thenReturn("100")
+ when(mockExecution.getProcessDefinitionId()).thenReturn("GenerateVfModuleName")
+ when(mockExecution.getProcessInstanceId()).thenReturn("GenerateVfModuleName")
+ when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
+ when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition)
+ return mockExecution
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenericGetServiceTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenericGetServiceTest.groovy
new file mode 100644
index 0000000000..49edd813f7
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenericGetServiceTest.groovy
@@ -0,0 +1,124 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule
+import org.camunda.bpm.engine.ProcessEngineServices
+import org.camunda.bpm.engine.RepositoryService
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.camunda.bpm.engine.repository.ProcessDefinition
+import org.junit.Assert
+import org.junit.Before
+import org.junit.Ignore
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.mockito.runners.MockitoJUnitRunner
+import org.onap.so.bpmn.core.WorkflowException
+
+import static com.github.tomakehurst.wiremock.client.WireMock.*
+import static org.mockito.Mockito.*
+
+@RunWith(MockitoJUnitRunner.class)
+@Ignore
+class GenericGetServiceTest {
+
+ def prefix = "GENGS_"
+ @Captor
+ ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class);
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(8090);
+
+ @Test
+ public void testGetServiceObject() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn('http://localhost:8090')
+ when(mockExecution.getVariable(prefix + "type")).thenReturn('service-instance')
+ when(mockExecution.getVariable(prefix + "serviceInstanceId")).thenReturn('12345')
+ when(mockExecution.getVariable(prefix + "resourceLink")).thenReturn("/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+
+ mockData()
+ GenericGetService obj = new GenericGetService()
+ obj.getServiceObject(mockExecution)
+
+ Mockito.verify(mockExecution).setVariable("prefix", prefix)
+ Mockito.verify(mockExecution).setVariable(prefix + "getServiceUrl", "http://localhost:8090/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/")
+ Mockito.verify(mockExecution).setVariable(prefix + "getServiceResponseCode", 200)
+ }
+
+ @Test
+ public void testGetServiceObjectEndpointNull() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn(null)
+ when(mockExecution.getVariable(prefix + "type")).thenReturn('service-instance')
+ when(mockExecution.getVariable(prefix + "serviceInstanceId")).thenReturn('12345')
+ when(mockExecution.getVariable(prefix + "resourceLink")).thenReturn("/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+
+ mockData()
+ try {
+ GenericGetService obj = new GenericGetService()
+ obj.getServiceObject(mockExecution)
+ } catch (Exception ex) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+
+ Mockito.verify(mockExecution, times(3)).setVariable(captor.capture(), captor.capture())
+ WorkflowException workflowException = captor.getValue()
+ Assert.assertEquals(9999, workflowException.getErrorCode())
+ Assert.assertEquals("org.apache.http.client.ClientProtocolException", workflowException.getErrorMessage())
+ }
+
+ private void mockData() {
+ stubFor(get(urlMatching(".*/aai/v[0-9]+/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/.*"))
+ .willReturn(aResponse()
+ .withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("")))
+ }
+
+ private ExecutionEntity setupMock() {
+
+ ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
+ when(mockProcessDefinition.getKey()).thenReturn("GenericGetService")
+ RepositoryService mockRepositoryService = mock(RepositoryService.class)
+ when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
+ when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("GenericGetService")
+ when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100")
+ ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)
+ when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getId()).thenReturn("100")
+ when(mockExecution.getProcessDefinitionId()).thenReturn("GenericGetService")
+ when(mockExecution.getProcessInstanceId()).thenReturn("GenericGetService")
+ when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
+ when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition)
+ return mockExecution
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenericGetVnfTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenericGetVnfTest.groovy
new file mode 100644
index 0000000000..1aef78f0d5
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenericGetVnfTest.groovy
@@ -0,0 +1,180 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule
+import org.camunda.bpm.engine.ProcessEngineServices
+import org.camunda.bpm.engine.RepositoryService
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.camunda.bpm.engine.repository.ProcessDefinition
+import org.junit.Assert
+import org.junit.Before
+import org.junit.Ignore
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.mockito.MockitoAnnotations
+import org.mockito.runners.MockitoJUnitRunner
+import org.onap.so.bpmn.core.WorkflowException
+
+import static com.github.tomakehurst.wiremock.client.WireMock.*
+import static org.mockito.Mockito.mock
+import static org.mockito.Mockito.times
+import static org.mockito.Mockito.when
+
+@RunWith(MockitoJUnitRunner.class)
+@Ignore
+class GenericGetVnfTest {
+
+ def prefix = "GENGV_"
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(28090)
+
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+
+ @Before
+ public void init()
+ {
+ MockitoAnnotations.initMocks(this)
+ }
+
+ @Test
+ public void testGetVnfByName() {
+
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
+ when(mockExecution.getVariable(prefix+"vnfName")).thenReturn("genricVnf_test")
+ when(mockExecution.getVariable(prefix+"type")).thenReturn("generic-vnf")
+ when(mockExecution.getVariable("mso.workflow.DoCreateVfModule.aai.generic-vnf.uri")).thenReturn("/aai/v9/network/generic-vnfs/generic-vnf")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+
+ mockData()
+ GenericGetVnf obj = new GenericGetVnf()
+ obj.getVnfByName(mockExecution)
+
+ Mockito.verify(mockExecution).setVariable("prefix","GENGV_")
+ Mockito.verify(mockExecution).setVariable(prefix+"getVnfPath","http://localhost:28090/aai/v9/network/generic-vnfs/generic-vnf?vnf-name=genricVnf_test&depth=1")
+ }
+
+ @Test
+ public void testGetVnfByNameEndpointNull() {
+
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn(null)
+ when(mockExecution.getVariable(prefix+"vnfName")).thenReturn("genricVnf_test")
+ when(mockExecution.getVariable(prefix+"type")).thenReturn("generic-vnf")
+ when(mockExecution.getVariable("mso.workflow.DoCreateVfModule.aai.generic-vnf.uri")).thenReturn("/aai/v9/network/generic-vnfs/generic-vnf")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+
+ mockData()
+ try{
+ GenericGetVnf obj = new GenericGetVnf()
+ obj.getVnfByName(mockExecution)
+ }catch (Exception ex) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+
+ Mockito.verify(mockExecution, times(3)).setVariable(captor.capture(), captor.capture())
+ WorkflowException workflowException = captor.getValue()
+ Assert.assertEquals(9999, workflowException.getErrorCode())
+ Assert.assertEquals("org.apache.http.client.ClientProtocolException", workflowException.getErrorMessage())
+ }
+
+ @Test
+ public void testGetVnfById() {
+
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
+ when(mockExecution.getVariable(prefix+"vnfId")).thenReturn("genricVnf_test")
+ when(mockExecution.getVariable(prefix+"type")).thenReturn("generic-vnf")
+ when(mockExecution.getVariable("mso.workflow.DoCreateVfModule.aai.generic-vnf.uri")).thenReturn("/aai/v9/network/generic-vnfs/generic-vnf")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+
+ mockData()
+ GenericGetVnf obj = new GenericGetVnf()
+ obj.getVnfById(mockExecution)
+
+ Mockito.verify(mockExecution).setVariable("prefix","GENGV_")
+ Mockito.verify(mockExecution).setVariable(prefix+"getVnfPath","http://localhost:28090/aai/v9/network/generic-vnfs/generic-vnf/genricVnf_test?depth=1")
+ }
+
+ @Test
+ public void testGetVnfByIdEndpointNull() {
+
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn(null)
+ when(mockExecution.getVariable(prefix+"vnfId")).thenReturn("genricVnf_test")
+ when(mockExecution.getVariable(prefix+"type")).thenReturn("generic-vnf")
+ when(mockExecution.getVariable("mso.workflow.DoCreateVfModule.aai.generic-vnf.uri")).thenReturn("/aai/v9/network/generic-vnfs/generic-vnf")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+
+ mockData()
+ try{
+ GenericGetVnf obj = new GenericGetVnf()
+ obj.getVnfById(mockExecution)
+ }catch (Exception ex) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+
+ Mockito.verify(mockExecution, times(3)).setVariable(captor.capture(), captor.capture())
+ WorkflowException workflowException = captor.getValue()
+ Assert.assertEquals(9999, workflowException.getErrorCode())
+ Assert.assertEquals("org.apache.http.client.ClientProtocolException", workflowException.getErrorMessage())
+ }
+
+ private static ExecutionEntity setupMock() {
+ ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
+ when(mockProcessDefinition.getKey()).thenReturn("DoCreateVfModule")
+ RepositoryService mockRepositoryService = mock(RepositoryService.class)
+ when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
+ when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("DoCreateVfModule")
+ when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100")
+ ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)
+ when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)
+
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ // Initialize prerequisite variables
+ when(mockExecution.getId()).thenReturn("100")
+ when(mockExecution.getProcessDefinitionId()).thenReturn("DoCreateVfModule")
+ when(mockExecution.getProcessInstanceId()).thenReturn("DoCreateVfModule")
+ when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
+ when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition)
+
+ return mockExecution
+ }
+
+ private static void mockData() {
+ stubFor(get(urlMatching(".*/aai/v[0-9]+/network/generic-vnfs/generic-vnf.*"))
+ .willReturn(aResponse()
+ .withStatus(200).withHeader("Content-Type", "text/xml")
+ .withBodyFile("GenericFlows/getGenericVnfResponse.xml")))
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenericPutServiceTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenericPutServiceTest.groovy
new file mode 100644
index 0000000000..d4ea8ce71f
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/GenericPutServiceTest.groovy
@@ -0,0 +1,235 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import static org.mockito.Mockito.*
+import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutServiceInstance;
+
+import org.camunda.bpm.engine.ProcessEngineServices
+import org.camunda.bpm.engine.RepositoryService
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.camunda.bpm.engine.repository.ProcessDefinition
+import org.junit.Before
+import org.junit.Ignore
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.MockitoAnnotations
+import org.mockito.internal.debugging.MockitoDebuggerImpl
+import org.mockito.runners.MockitoJUnitRunner
+
+import com.github.tomakehurst.wiremock.client.WireMock
+import com.github.tomakehurst.wiremock.junit.WireMockRule
+import org.apache.commons.lang3.*
+
+@RunWith(MockitoJUnitRunner.class)
+@Ignore
+class GenericPutServiceTest {
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(8090);
+
+ @Before
+ public void init()
+ {
+ MockitoAnnotations.initMocks(this)
+
+ }
+
+ @Test
+ public void preProcessRequest() {
+
+
+ println "************ preProcessRequest ************* "
+
+ ExecutionEntity mockExecution = setupMock()
+
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("GENPS_globalSubscriberId")).thenReturn("1604-MVM-26")
+ when(mockExecution.getVariable("GENPS_serviceInstanceId")).thenReturn("MIS%2F1604%2F0026%2FSW_INTERNET")
+ when(mockExecution.getVariable("GENPS_serviceType")).thenReturn("SDN-ETHERNET-INTERNET")
+ when(mockExecution.getVariable("GENPS_serviceInstanceData")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4")
+ when(mockExecution.getVariable("GENPS_type")).thenReturn("service-instance")
+
+ GenericPutService putServiceInstance= new GenericPutService()
+ putServiceInstance.preProcessRequest(mockExecution)
+
+ // check the sequence of variable invocation
+ //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl()
+ //preDebugger.printInvocations(mockExecution)
+
+ verify(mockExecution, atLeast(1)).getVariable("isDebugLogEnabled")
+ verify(mockExecution).setVariable("prefix", "GENPS_")
+
+ // execution.getVariable("isDebugLogEnabled")
+
+ verify(mockExecution).setVariable("GENPS_SuccessIndicator", false)
+ // verify(mockExecution).setVariable("globalSubscriberId", "1604-MVM-26")
+ // verify(mockExecution).setVariable("serviceInstanceId", "MIS%2F1604%2F0026%2FSW_INTERNET")
+ // verify(mockExecution).setVariable("serviceType", "SDN-ETHERNET-INTERNET")
+ // verify(mockExecution).setVariable("ServiceInstanceData", "f70e927b-6087-4974-9ef8-c5e4d5847ca4")
+
+
+ }
+
+
+ @Test
+ @Ignore
+ public void putServiceInstance() {
+ println "************ putServiceInstance ************* "
+
+ WireMock.reset();
+
+ MockPutServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericPutServiceInstance/GenericPutServiceInstance_PutServiceInstance_AAIResponse_Success.xml");
+ ExecutionEntity mockExecution = setupMock()
+
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("GENPS_globalSubscriberId")).thenReturn("1604-MVM-26")
+ when(mockExecution.getVariable("GENPS_serviceInstanceId")).thenReturn("MIS%2F1604%2F0026%2FSW_INTERNET")
+ when(mockExecution.getVariable("GENPS_serviceType")).thenReturn("SDN-ETHERNET-INTERNET")
+ when(mockExecution.getVariable("GENPS_serviceInstanceData")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090")
+ when(mockExecution.getVariable("mso.workflow.PutServiceInstance.aai.business.customer.uri")).thenReturn("/aai/v7/business/customers/customer")
+ when(mockExecution.getVariable("GENPS_serviceInstanceData")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4")
+ when(mockExecution.getVariable("GENPS_type")).thenReturn("service-instance")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("7")
+ when(mockExecution.getVariable("mso.workflow.default.aai.v7.customer.uri")).thenReturn("/aai/v7/business/customers/customer")
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
+ when(mockExecution.getVariable("aai.auth")).thenReturn("757A94191D685FD2092AC1490730A4FC")
+
+ GenericPutService serviceInstance= new GenericPutService()
+ serviceInstance.putServiceInstance(mockExecution)
+
+ // check the sequence of variable invocation
+ MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl()
+ preDebugger.printInvocations(mockExecution)
+
+ verify(mockExecution, atLeast(1)).getVariable("isDebugLogEnabled")
+ verify(mockExecution).setVariable("prefix", "GENPS_")
+
+ // execution.getVariable("isDebugLogEnabled")
+ // verify(mockExecution).setVariable("GENPSI_serviceInstanceData","f70e927b-6087-4974-9ef8-c5e4d5847ca4")
+
+ String servicePayload = """<service-instance xmlns="http://org.openecomp.aai.inventory/v7">f70e927b-6087-4974-9ef8-c5e4d5847ca4</service-instance>""" as String
+ verify(mockExecution).setVariable("GENPS_serviceInstancePayload",servicePayload)
+
+ String serviceAaiPath = "http://localhost:28090/aai/v7/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET"
+ verify(mockExecution).setVariable("GENPS_putServiceInstanceAaiPath", serviceAaiPath)
+
+ int responseCode = 200
+ verify(mockExecution).setVariable("GENPS_putServiceInstanceResponseCode", responseCode)
+
+ String aaiResponse = """<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>"""
+
+ verify(mockExecution).setVariable("GENPS_putServiceInstanceResponse", aaiResponse)
+
+ verify(mockExecution).setVariable("GENPS_SuccessIndicator", true)
+ }
+
+ @Test
+ @Ignore
+ public void putServiceInstance_404() {
+
+
+ println "************ putServiceInstance ************* "
+
+ WireMock.reset();
+
+ ExecutionEntity mockExecution = setupMock()
+
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("GENPS_globalSubscriberId")).thenReturn("1604-MVM-26")
+ when(mockExecution.getVariable("GENPS_serviceInstanceId")).thenReturn("MIS%2F1604%2F0026%2FSW_INTERNET")
+ when(mockExecution.getVariable("GENPS_serviceType")).thenReturn("SDN-ETHERNET-INTERNET")
+ when(mockExecution.getVariable("GENPS_ServiceInstanceData")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:8090")
+ when(mockExecution.getVariable("mso.workflow.PutServiceInstance.aai.business.customer_uri")).thenReturn("/aai/v7/business/customers/customer")
+ when(mockExecution.getVariable("GENPS_ServiceInstanceData")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4")
+
+ GenericPutService serviceInstance= new GenericPutService()
+ serviceInstance.putServiceInstance(mockExecution)
+
+ // check the sequence of variable invocation
+ MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl()
+ preDebugger.printInvocations(mockExecution)
+
+ verify(mockExecution, atLeast(1)).getVariable("isDebugLogEnabled")
+ verify(mockExecution).setVariable("prefix", "GENPS_")
+
+ // execution.getVariable("isDebugLogEnabled")
+
+
+ verify(mockExecution).setVariable("GENPS_serviceInstanceData","f70e927b-6087-4974-9ef8-c5e4d5847ca4")
+
+ String serviceInstancepayload = """<service-instance xmlns="http://org.onap.so.aai.inventory/v7">f70e927b-6087-4974-9ef8-c5e4d5847ca4
+ </service-instance>""" as String
+ verify(mockExecution).setVariable("GENPS_serviceInstancePayload",serviceInstancepayload)
+
+ String serviceInstanceAaiPath = "http://localhost:8090/aai/v7/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET"
+ verify(mockExecution).setVariable("GENPS_putServiceInstanceAaiPath", serviceInstanceAaiPath)
+
+ int responseCode = 404
+ verify(mockExecution).setVariable("GENPS_putServiceInstanceResponseCode", responseCode)
+
+ String aaiResponse = ""
+ verify(mockExecution).setVariable("GENPS_putServiceInstanceResponse", aaiResponse)
+
+ verify(mockExecution).setVariable("GENPS_SuccessIndicator", false)
+
+
+ }
+
+
+ private ExecutionEntity setupMock() {
+
+ ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
+ when(mockProcessDefinition.getKey()).thenReturn("PutServiceInstance")
+ RepositoryService mockRepositoryService = mock(RepositoryService.class)
+ when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
+ when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("PutServiceInstance")
+ 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("PutServiceInstance")
+ when(mockExecution.getProcessInstanceId()).thenReturn("PutServiceInstance")
+ when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
+ when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition)
+
+ return mockExecution
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy
new file mode 100644
index 0000000000..cd95a3a733
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoGroovyTest.groovy
@@ -0,0 +1,72 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import static org.mockito.Mockito.*
+
+import org.mockito.MockitoAnnotations
+import org.mockito.runners.MockitoJUnitRunner
+import org.mockito.internal.debugging.MockitoDebuggerImpl
+import org.camunda.bpm.engine.ProcessEngineServices
+import org.camunda.bpm.engine.RepositoryService
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl
+import org.camunda.bpm.engine.repository.ProcessDefinition
+
+abstract class MsoGroovyTest {
+
+ protected ExecutionEntity setupMock(String procName) {
+ ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
+ when(mockProcessDefinition.getKey()).thenReturn(procName)
+
+ RepositoryService mockRepositoryService = mock(RepositoryService.class)
+ when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
+ when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn(procName)
+ when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100")
+
+ ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class)
+ when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService)
+
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
+
+ return mockExecution
+ }
+
+ protected ExecutionEntity setupMockWithPrefix(String procName, String prefix) {
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+
+ when(mockExecution.getVariable("prefix")).thenReturn(prefix)
+
+ ProcessEngineServices processEngineServices = mock(ProcessEngineServices.class)
+ RepositoryService repositoryService = mock(RepositoryService.class)
+ ProcessDefinition processDefinition = mock(ProcessDefinition.class)
+
+ when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices)
+ when(processEngineServices.getRepositoryService()).thenReturn(repositoryService)
+ when(repositoryService.getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(processDefinition)
+ when(processDefinition.getKey()).thenReturn(procName)
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ return mockExecution
+ }
+
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoUtilsTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoUtilsTest.groovy
new file mode 100644
index 0000000000..dfcf69a931
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/MsoUtilsTest.groovy
@@ -0,0 +1,291 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+// JUnit 4
+import org.junit.Test
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+
+import static groovy.test.GroovyAssert.shouldFail
+
+import groovy.util.slurpersupport.NodeChild
+
+import static groovy.test.GroovyAssert.assertTrue
+import static groovy.test.GroovyAssert.assertEquals
+import static groovy.test.GroovyAssert.assertNotNull;
+
+import org.onap.so.bpmn.common.scripts.MsoUtils;
+import org.apache.commons.lang3.*
+
+
+class MsoUtilsTest {
+
+ def utils = new MsoUtils()
+ def origXmlResponse = null
+ // Expected rebuilds
+ def expected_buildElements = "<tns2:internet-service-change-details><tns2:internet-evc-speed-value>10</tns2:internet-evc-speed-value><tns2:internet-evc-speed-units>Kbps</tns2:internet-evc-speed-units><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v4-next-hop-address>192.168.1.15</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.15</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>2</tns2:request-index><tns2:v4-next-hop-address>192.168.1.16</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.16</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes></tns2:internet-service-change-details>"
+ def expected_rebuildDhcp = "<tns2:dhcp><tns2:v4-dhcp-server-enabled>Y</tns2:v4-dhcp-server-enabled><tns2:v6-dhcp-server-enabled>N</tns2:v6-dhcp-server-enabled><tns2:use-v4-default-pool>Y</tns2:use-v4-default-pool><tns2:excluded-v4-dhcp-addresses-from-default-pool><tns2:excluded-v4-address>192.168.1.7</tns2:excluded-v4-address></tns2:excluded-v4-dhcp-addresses-from-default-pool><tns2:excluded-v4-dhcp-addresses-from-default-pool><tns2:excluded-v4-address>192.168.1.8</tns2:excluded-v4-address></tns2:excluded-v4-dhcp-addresses-from-default-pool><tns2:v4-dhcp-pools><tns2:v4-dhcp-pool-prefix>192.155.2.3</tns2:v4-dhcp-pool-prefix><tns2:v4-dhcp-pool-prefix-length>28</tns2:v4-dhcp-pool-prefix-length><tns2:excluded-v4-addresses><tns2:excluded-v4-address>192.168.1.5</tns2:excluded-v4-address></tns2:excluded-v4-addresses><tns2:excluded-v4-addresses><tns2:excluded-v4-address>192.168.1.6</tns2:excluded-v4-address></tns2:excluded-v4-addresses><tns2:v4-dhcp-relay-gateway-address>2.2.2.1</tns2:v4-dhcp-relay-gateway-address><tns2:v4-dhcp-relay-next-hop-address>1.1.1.1</tns2:v4-dhcp-relay-next-hop-address></tns2:v4-dhcp-pools><tns2:v4-dhcp-pools><tns2:v4-dhcp-pool-prefix>192.155.2.4</tns2:v4-dhcp-pool-prefix><tns2:v4-dhcp-pool-prefix-length>28</tns2:v4-dhcp-pool-prefix-length><tns2:excluded-v4-addresses><tns2:excluded-v4-address>192.168.1.6</tns2:excluded-v4-address></tns2:excluded-v4-addresses><tns2:excluded-v4-addresses><tns2:excluded-v4-address>192.168.1.7</tns2:excluded-v4-address></tns2:excluded-v4-addresses><tns2:v4-dhcp-relay-gateway-address>2.2.2.2</tns2:v4-dhcp-relay-gateway-address><tns2:v4-dhcp-relay-next-hop-address>1.1.1.2</tns2:v4-dhcp-relay-next-hop-address></tns2:v4-dhcp-pools><tns2:use-v6-default-pool>N</tns2:use-v6-default-pool><tns2:excluded-v6-dhcp-addresses-from-default-pool><tns2:excluded-v6-address>1:5</tns2:excluded-v6-address></tns2:excluded-v6-dhcp-addresses-from-default-pool><tns2:excluded-v6-dhcp-addresses-from-default-pool><tns2:excluded-v6-address>1:6</tns2:excluded-v6-address></tns2:excluded-v6-dhcp-addresses-from-default-pool><tns2:v6-dhcp-pools><tns2:v6-dhcp-pool-prefix>0:0</tns2:v6-dhcp-pool-prefix><tns2:v6-dhcp-pool-prefix-length>28</tns2:v6-dhcp-pool-prefix-length><tns2:excluded-v6-addresses><tns2:excluded-v6-address>1:1</tns2:excluded-v6-address></tns2:excluded-v6-addresses><tns2:excluded-v6-addresses><tns2:excluded-v6-address>2:2</tns2:excluded-v6-address></tns2:excluded-v6-addresses><tns2:v6-dhcp-relay-gateway-address>3:3</tns2:v6-dhcp-relay-gateway-address><tns2:v6-dhcp-relay-next-hop-address>4:4</tns2:v6-dhcp-relay-next-hop-address></tns2:v6-dhcp-pools><tns2:v6-dhcp-pools><tns2:v6-dhcp-pool-prefix>0:0</tns2:v6-dhcp-pool-prefix><tns2:v6-dhcp-pool-prefix-length>28</tns2:v6-dhcp-pool-prefix-length><tns2:excluded-v6-addresses><tns2:excluded-v6-address>1:1</tns2:excluded-v6-address></tns2:excluded-v6-addresses><tns2:excluded-v6-addresses><tns2:excluded-v6-address>2:2</tns2:excluded-v6-address></tns2:excluded-v6-addresses><tns2:v6-dhcp-relay-gateway-address>3:3</tns2:v6-dhcp-relay-gateway-address><tns2:v6-dhcp-relay-next-hop-address>4:4</tns2:v6-dhcp-relay-next-hop-address></tns2:v6-dhcp-pools></tns2:dhcp>"
+ def expected_rebuildFirewallLite = "<tns2:firewall-lite><tns2:stateful-firewall-lite-v4-enabled>Y</tns2:stateful-firewall-lite-v4-enabled><tns2:stateful-firewall-lite-v6-enabled>N</tns2:stateful-firewall-lite-v6-enabled><tns2:v4-firewall-packet-filters><tns2:v4-firewall-prefix>0.0.0.1</tns2:v4-firewall-prefix><tns2:v4-firewall-prefix-length>1</tns2:v4-firewall-prefix-length><tns2:allow-icmp-ping>Y</tns2:allow-icmp-ping><tns2:udp-ports><tns2:port-number>1</tns2:port-number></tns2:udp-ports><tns2:tcp-ports><tns2:port-number>1</tns2:port-number></tns2:tcp-ports></tns2:v4-firewall-packet-filters><tns2:v4-firewall-packet-filters><tns2:v4-firewall-prefix>0.0.0.2</tns2:v4-firewall-prefix><tns2:v4-firewall-prefix-length>2</tns2:v4-firewall-prefix-length><tns2:allow-icmp-ping>Y</tns2:allow-icmp-ping><tns2:udp-ports><tns2:port-number>2</tns2:port-number></tns2:udp-ports><tns2:tcp-ports><tns2:port-number>2</tns2:port-number></tns2:tcp-ports></tns2:v4-firewall-packet-filters><tns2:v6-firewall-packet-filters><tns2:v6-firewall-prefix>:</tns2:v6-firewall-prefix><tns2:v6-firewall-prefix-length>0</tns2:v6-firewall-prefix-length><tns2:allow-icmp-ping>Y</tns2:allow-icmp-ping><tns2:udp-ports><tns2:port-number>3</tns2:port-number></tns2:udp-ports><tns2:tcp-ports><tns2:port-number>3</tns2:port-number></tns2:tcp-ports></tns2:v6-firewall-packet-filters><tns2:v6-firewall-packet-filters><tns2:v6-firewall-prefix>:</tns2:v6-firewall-prefix><tns2:v6-firewall-prefix-length>1</tns2:v6-firewall-prefix-length><tns2:allow-icmp-ping>Y</tns2:allow-icmp-ping><tns2:udp-ports><tns2:port-number>4</tns2:port-number></tns2:udp-ports><tns2:tcp-ports><tns2:port-number>4</tns2:port-number></tns2:tcp-ports></tns2:v6-firewall-packet-filters></tns2:firewall-lite>"
+ def expected_rebuildInternetEvcAccess = "<tns2:internet-evc-access-information><tns2:internet-evc-speed-value>8</tns2:internet-evc-speed-value><tns2:internet-evc-speed-units>Mbps</tns2:internet-evc-speed-units><tns2:ip-version>ds</tns2:ip-version></tns2:internet-evc-access-information>"
+ def expected_rebuildInternetServiceChangeDetails = "<tns:internet-service-change-details><tns2:internet-evc-speed-value>10</tns2:internet-evc-speed-value><tns2:internet-evc-speed-units>Kbps</tns2:internet-evc-speed-units><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v4-next-hop-address>192.168.1.15</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.15</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>2</tns2:request-index><tns2:v4-next-hop-address>192.168.1.16</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.16</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes><tns2:t-provided-v6-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address><tns2:v6-lan-public-prefix>2001:1890:12e3:2da::</tns2:v6-lan-public-prefix><tns2:v6-lan-public-prefix-length>28</tns2:v6-lan-public-prefix-length></tns2:t-provided-v6-lan-public-prefixes><tns2:t-provided-v6-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address><tns2:v6-lan-public-prefix>2001:1890:12e3:2da::</tns2:v6-lan-public-prefix><tns2:v6-lan-public-prefix-length>28</tns2:v6-lan-public-prefix-length></tns2:t-provided-v6-lan-public-prefixes></tns:internet-service-change-details>"
+ def expected_rebuildInternetServiceChangeDetailsWithVrLanParams = "<tns:internet-service-change-details><tns2:internet-evc-speed-value>10</tns2:internet-evc-speed-value><tns2:internet-evc-speed-units>Kbps</tns2:internet-evc-speed-units><tns2:v4-vr-lan-address>10.10.7.14</tns2:v4-vr-lan-address><tns2:v4-vr-lan-prefix-length>10</tns2:v4-vr-lan-prefix-length><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v4-next-hop-address>192.168.1.15</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.15</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>2</tns2:request-index><tns2:v4-next-hop-address>192.168.1.16</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.16</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes><tns2:t-provided-v6-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address><tns2:v6-lan-public-prefix>2001:1890:12e3:2da::</tns2:v6-lan-public-prefix><tns2:v6-lan-public-prefix-length>28</tns2:v6-lan-public-prefix-length></tns2:t-provided-v6-lan-public-prefixes><tns2:t-provided-v6-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address><tns2:v6-lan-public-prefix>2001:1890:12e3:2da::</tns2:v6-lan-public-prefix><tns2:v6-lan-public-prefix-length>28</tns2:v6-lan-public-prefix-length></tns2:t-provided-v6-lan-public-prefixes></tns:internet-service-change-details>"
+ def expected_rebuildL2Home = "<tns2:l2-homing-information><tns2:evc-name>AS/VLXM/003717//SW</tns2:evc-name><tns2:topology>MultiPoint</tns2:topology><tns2:preferred-aic-clli>MTSNJA4LCP1</tns2:preferred-aic-clli></tns2:l2-homing-information>"
+ def expected_rebuildL2HomeFor_aic_clli = "<tns2:l2-homing-information><tns2:evc-name>AS/VLXM/003717//SW</tns2:evc-name><tns2:topology>MultiPoint</tns2:topology><tns2:preferred-aic-clli>MTSNJA4LCP1</tns2:preferred-aic-clli><tns2:aic-version>2.5</tns2:aic-version></tns2:l2-homing-information>"
+ def expected_rebuildNat = "<tns2:nat><tns2:v4-nat-enabled>Y</tns2:v4-nat-enabled><tns2:v4-nat-mapping-entries><tns2:v4-nat-internal>0.0.0.0</tns2:v4-nat-internal><tns2:v4-nat-next-hop-address>0.0.0.0</tns2:v4-nat-next-hop-address><tns2:v4-nat-external>0.0.0.0</tns2:v4-nat-external></tns2:v4-nat-mapping-entries><tns2:v4-nat-mapping-entries><tns2:v4-nat-internal>0.0.0.1</tns2:v4-nat-internal><tns2:v4-nat-next-hop-address>0.0.0.1</tns2:v4-nat-next-hop-address><tns2:v4-nat-external>0.0.0.1</tns2:v4-nat-external></tns2:v4-nat-mapping-entries></tns2:nat>"
+ def expected_rebuildPat = "<tns2:pat><tns2:v4-pat-enabled>N</tns2:v4-pat-enabled><tns2:use-v4-default-pool>Y</tns2:use-v4-default-pool><tns2:v4-pat-pools><tns2:v4-pat-pool-prefix>192.168.1.44</tns2:v4-pat-pool-prefix><tns2:v4-pat-pool-prefix-length>0</tns2:v4-pat-pool-prefix-length><tns2:v4-pat-pool-next-hop-address>192.168.1.5</tns2:v4-pat-pool-next-hop-address></tns2:v4-pat-pools><tns2:v4-pat-pools><tns2:v4-pat-pool-prefix>192.168.1.45</tns2:v4-pat-pool-prefix><tns2:v4-pat-pool-prefix-length>28</tns2:v4-pat-pool-prefix-length><tns2:v4-pat-pool-next-hop-address>192.168.1.6</tns2:v4-pat-pool-next-hop-address></tns2:v4-pat-pools></tns2:pat>"
+ def expected_rebuildStaticRoutes = "<tns2:static-routes><tns2:v4-static-routes><tns2:v4-static-route-prefix>255.255.252.1</tns2:v4-static-route-prefix><tns2:v4-static-route-prefix-length>28</tns2:v4-static-route-prefix-length><tns2:v4-next-hop-address>192.168.1.15</tns2:v4-next-hop-address></tns2:v4-static-routes><tns2:v4-static-routes><tns2:v4-static-route-prefix>255.255.252.2</tns2:v4-static-route-prefix><tns2:v4-static-route-prefix-length>28</tns2:v4-static-route-prefix-length><tns2:v4-next-hop-address>192.168.1.15</tns2:v4-next-hop-address></tns2:v4-static-routes><tns2:v4-static-routes><tns2:v4-static-route-prefix>255.255.252.3</tns2:v4-static-route-prefix><tns2:v4-static-route-prefix-length>28</tns2:v4-static-route-prefix-length><tns2:v4-next-hop-address>192.168.1.15</tns2:v4-next-hop-address></tns2:v4-static-routes><tns2:v6-static-routes><tns2:v6-static-route-prefix>2001:1890:12e3:2da::</tns2:v6-static-route-prefix><tns2:v6-static-route-prefix-length>28</tns2:v6-static-route-prefix-length><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address></tns2:v6-static-routes><tns2:v6-static-routes><tns2:v6-static-route-prefix>2001:1890:12e3:2da::</tns2:v6-static-route-prefix><tns2:v6-static-route-prefix-length>28</tns2:v6-static-route-prefix-length><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address></tns2:v6-static-routes></tns2:static-routes>"
+ def expected_rebuildUcpeVmsServiceInformation = "<tns2:ucpe-vms-service-information><tns2:transport-service-information><tns2:transport-service-type>AVPN</tns2:transport-service-type><tns2:access-circuit-info><tns2:access-circuit-id>1</tns2:access-circuit-id><tns2:dual-mode>Active</tns2:dual-mode></tns2:access-circuit-info><tns2:access-circuit-info><tns2:access-circuit-id>2</tns2:access-circuit-id><tns2:dual-mode>Standby</tns2:dual-mode></tns2:access-circuit-info></tns2:transport-service-information><tns2:ucpe-information><tns2:ucpe-host-name>hostname</tns2:ucpe-host-name><tns2:ucpe-activation-code>activecode</tns2:ucpe-activation-code><tns2:out-of-band-management-modem>OOB</tns2:out-of-band-management-modem></tns2:ucpe-information><tns2:vnf-list><tns2:vnf-information><tns2:vnf-instance-id>1</tns2:vnf-instance-id><tns2:vnf-sequence-number>1</tns2:vnf-sequence-number><tns2:vnf-type>ZZ</tns2:vnf-type><tns2:vnf-vendor>JUNIPER</tns2:vnf-vendor><tns2:vnf-model>MODEL1</tns2:vnf-model><tns2:vnf-id>1</tns2:vnf-id><tns2:prov-status>1</tns2:prov-status><tns2:operational-state>1</tns2:operational-state><tns2:orchestration-status>1</tns2:orchestration-status><tns2:equipment-role>1</tns2:equipment-role></tns2:vnf-information><tns2:vnf-information><tns2:vnf-instance-id>2</tns2:vnf-instance-id><tns2:vnf-sequence-number>2</tns2:vnf-sequence-number><tns2:vnf-type>HY</tns2:vnf-type><tns2:vnf-vendor>JUNIPER</tns2:vnf-vendor><tns2:vnf-model>MODEL2</tns2:vnf-model><tns2:vnf-id>2</tns2:vnf-id><tns2:prov-status>2</tns2:prov-status><tns2:operational-state>2</tns2:operational-state><tns2:orchestration-status>2</tns2:orchestration-status><tns2:equipment-role>2</tns2:equipment-role></tns2:vnf-information></tns2:vnf-list></tns2:ucpe-vms-service-information>"
+ def expected_rebuildVrLan = "<tns2:vr-lan><tns2:routing-protocol>none</tns2:routing-protocol><tns2:vr-lan-interface><tns2:vr-designation>primary</tns2:vr-designation><tns2:v4-vr-lan-prefix>10.192.27.254</tns2:v4-vr-lan-prefix><tns2:v4-vr-lan-prefix-length>24</tns2:v4-vr-lan-prefix-length><tns2:v6-vr-lan-prefix>2620:0:10d0:f:ffff:ffff:ffff:fffe</tns2:v6-vr-lan-prefix><tns2:v6-vr-lan-prefix-length>64</tns2:v6-vr-lan-prefix-length><tns2:v4-vce-loopback-address>162.200.3.144</tns2:v4-vce-loopback-address><tns2:v6-vce-wan-address>2001:1890:12e3:2da::</tns2:v6-vce-wan-address><tns2:v4-public-lan-prefixes><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v4-next-hop-address>192.168.1.2</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.1</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v4-next-hop-address>192.168.1.72</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.71</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v4-next-hop-address>192.168.1.68</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.67</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes></tns2:v4-public-lan-prefixes><tns2:v6-public-lan-prefixes><tns2:t-provided-v6-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address><tns2:v6-lan-public-prefix>2001:1890:12e3:2da::</tns2:v6-lan-public-prefix><tns2:v6-lan-public-prefix-length>28</tns2:v6-lan-public-prefix-length></tns2:t-provided-v6-lan-public-prefixes><tns2:t-provided-v6-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address><tns2:v6-lan-public-prefix>2001:1890:12e3:3da::</tns2:v6-lan-public-prefix><tns2:v6-lan-public-prefix-length>28</tns2:v6-lan-public-prefix-length></tns2:t-provided-v6-lan-public-prefixes><tns2:t-provided-v6-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address><tns2:v6-lan-public-prefix>2001:1890:12e3:4da::</tns2:v6-lan-public-prefix><tns2:v6-lan-public-prefix-length>28</tns2:v6-lan-public-prefix-length></tns2:t-provided-v6-lan-public-prefixes></tns2:v6-public-lan-prefixes><tns2:dhcp><tns2:v4-dhcp-server-enabled>Y</tns2:v4-dhcp-server-enabled><tns2:v6-dhcp-server-enabled>N</tns2:v6-dhcp-server-enabled><tns2:use-v4-default-pool>Y</tns2:use-v4-default-pool><tns2:excluded-v4-dhcp-addresses-from-default-pool><tns2:excluded-v4-address>192.168.1.7</tns2:excluded-v4-address></tns2:excluded-v4-dhcp-addresses-from-default-pool><tns2:excluded-v4-dhcp-addresses-from-default-pool><tns2:excluded-v4-address>192.168.1.8</tns2:excluded-v4-address></tns2:excluded-v4-dhcp-addresses-from-default-pool><tns2:v4-dhcp-pools><tns2:v4-dhcp-pool-prefix>192.155.2.3</tns2:v4-dhcp-pool-prefix><tns2:v4-dhcp-pool-prefix-length>28</tns2:v4-dhcp-pool-prefix-length><tns2:excluded-v4-addresses><tns2:excluded-v4-address>192.168.1.5</tns2:excluded-v4-address></tns2:excluded-v4-addresses><tns2:excluded-v4-addresses><tns2:excluded-v4-address>192.168.1.6</tns2:excluded-v4-address></tns2:excluded-v4-addresses><tns2:v4-dhcp-relay-gateway-address>2.2.2.1</tns2:v4-dhcp-relay-gateway-address><tns2:v4-dhcp-relay-next-hop-address>1.1.1.1</tns2:v4-dhcp-relay-next-hop-address></tns2:v4-dhcp-pools><tns2:v4-dhcp-pools><tns2:v4-dhcp-pool-prefix>192.155.2.4</tns2:v4-dhcp-pool-prefix><tns2:v4-dhcp-pool-prefix-length>28</tns2:v4-dhcp-pool-prefix-length><tns2:excluded-v4-addresses><tns2:excluded-v4-address>192.168.1.6</tns2:excluded-v4-address></tns2:excluded-v4-addresses><tns2:excluded-v4-addresses><tns2:excluded-v4-address>192.168.1.7</tns2:excluded-v4-address></tns2:excluded-v4-addresses><tns2:v4-dhcp-relay-gateway-address>2.2.2.2</tns2:v4-dhcp-relay-gateway-address><tns2:v4-dhcp-relay-next-hop-address>1.1.1.2</tns2:v4-dhcp-relay-next-hop-address></tns2:v4-dhcp-pools><tns2:use-v6-default-pool>N</tns2:use-v6-default-pool><tns2:excluded-v6-dhcp-addresses-from-default-pool><tns2:excluded-v6-address>1:5</tns2:excluded-v6-address></tns2:excluded-v6-dhcp-addresses-from-default-pool><tns2:excluded-v6-dhcp-addresses-from-default-pool><tns2:excluded-v6-address>1:6</tns2:excluded-v6-address></tns2:excluded-v6-dhcp-addresses-from-default-pool><tns2:v6-dhcp-pools><tns2:v6-dhcp-pool-prefix>0:0</tns2:v6-dhcp-pool-prefix><tns2:v6-dhcp-pool-prefix-length>28</tns2:v6-dhcp-pool-prefix-length><tns2:excluded-v6-addresses><tns2:excluded-v6-address>1:1</tns2:excluded-v6-address></tns2:excluded-v6-addresses><tns2:excluded-v6-addresses><tns2:excluded-v6-address>2:2</tns2:excluded-v6-address></tns2:excluded-v6-addresses><tns2:v6-dhcp-relay-gateway-address>3:3</tns2:v6-dhcp-relay-gateway-address><tns2:v6-dhcp-relay-next-hop-address>4:4</tns2:v6-dhcp-relay-next-hop-address></tns2:v6-dhcp-pools><tns2:v6-dhcp-pools><tns2:v6-dhcp-pool-prefix>0:0</tns2:v6-dhcp-pool-prefix><tns2:v6-dhcp-pool-prefix-length>28</tns2:v6-dhcp-pool-prefix-length><tns2:excluded-v6-addresses><tns2:excluded-v6-address>1:1</tns2:excluded-v6-address></tns2:excluded-v6-addresses><tns2:excluded-v6-addresses><tns2:excluded-v6-address>2:2</tns2:excluded-v6-address></tns2:excluded-v6-addresses><tns2:v6-dhcp-relay-gateway-address>3:3</tns2:v6-dhcp-relay-gateway-address><tns2:v6-dhcp-relay-next-hop-address>4:4</tns2:v6-dhcp-relay-next-hop-address></tns2:v6-dhcp-pools></tns2:dhcp><tns2:pat><tns2:v4-pat-enabled>N</tns2:v4-pat-enabled><tns2:use-v4-default-pool>Y</tns2:use-v4-default-pool><tns2:v4-pat-pools><tns2:v4-pat-pool-prefix>192.168.1.44</tns2:v4-pat-pool-prefix><tns2:v4-pat-pool-prefix-length>0</tns2:v4-pat-pool-prefix-length><tns2:v4-pat-pool-next-hop-address>192.168.1.5</tns2:v4-pat-pool-next-hop-address></tns2:v4-pat-pools><tns2:v4-pat-pools><tns2:v4-pat-pool-prefix>192.168.1.45</tns2:v4-pat-pool-prefix><tns2:v4-pat-pool-prefix-length>28</tns2:v4-pat-pool-prefix-length><tns2:v4-pat-pool-next-hop-address>192.168.1.6</tns2:v4-pat-pool-next-hop-address></tns2:v4-pat-pools></tns2:pat><tns2:nat><tns2:v4-nat-enabled>Y</tns2:v4-nat-enabled><tns2:v4-nat-mapping-entries><tns2:v4-nat-internal>0.0.0.0</tns2:v4-nat-internal><tns2:v4-nat-next-hop-address>0.0.0.0</tns2:v4-nat-next-hop-address><tns2:v4-nat-external>0.0.0.0</tns2:v4-nat-external></tns2:v4-nat-mapping-entries><tns2:v4-nat-mapping-entries><tns2:v4-nat-internal>0.0.0.1</tns2:v4-nat-internal><tns2:v4-nat-next-hop-address>0.0.0.1</tns2:v4-nat-next-hop-address><tns2:v4-nat-external>0.0.0.1</tns2:v4-nat-external></tns2:v4-nat-mapping-entries></tns2:nat><tns2:firewall-lite><tns2:stateful-firewall-lite-v4-enabled>Y</tns2:stateful-firewall-lite-v4-enabled><tns2:stateful-firewall-lite-v6-enabled>N</tns2:stateful-firewall-lite-v6-enabled><tns2:v4-firewall-packet-filters><tns2:v4-firewall-prefix>0.0.0.1</tns2:v4-firewall-prefix><tns2:v4-firewall-prefix-length>1</tns2:v4-firewall-prefix-length><tns2:allow-icmp-ping>Y</tns2:allow-icmp-ping><tns2:udp-ports><tns2:port-number>1</tns2:port-number></tns2:udp-ports><tns2:tcp-ports><tns2:port-number>1</tns2:port-number></tns2:tcp-ports></tns2:v4-firewall-packet-filters><tns2:v4-firewall-packet-filters><tns2:v4-firewall-prefix>0.0.0.2</tns2:v4-firewall-prefix><tns2:v4-firewall-prefix-length>2</tns2:v4-firewall-prefix-length><tns2:allow-icmp-ping>Y</tns2:allow-icmp-ping><tns2:udp-ports><tns2:port-number>2</tns2:port-number></tns2:udp-ports><tns2:tcp-ports><tns2:port-number>2</tns2:port-number></tns2:tcp-ports></tns2:v4-firewall-packet-filters><tns2:v6-firewall-packet-filters><tns2:v6-firewall-prefix>:</tns2:v6-firewall-prefix><tns2:v6-firewall-prefix-length>0</tns2:v6-firewall-prefix-length><tns2:allow-icmp-ping>Y</tns2:allow-icmp-ping><tns2:udp-ports><tns2:port-number>3</tns2:port-number></tns2:udp-ports><tns2:tcp-ports><tns2:port-number>3</tns2:port-number></tns2:tcp-ports></tns2:v6-firewall-packet-filters><tns2:v6-firewall-packet-filters><tns2:v6-firewall-prefix>:</tns2:v6-firewall-prefix><tns2:v6-firewall-prefix-length>1</tns2:v6-firewall-prefix-length><tns2:allow-icmp-ping>Y</tns2:allow-icmp-ping><tns2:udp-ports><tns2:port-number>4</tns2:port-number></tns2:udp-ports><tns2:tcp-ports><tns2:port-number>4</tns2:port-number></tns2:tcp-ports></tns2:v6-firewall-packet-filters></tns2:firewall-lite><tns2:static-routes><tns2:v4-static-routes><tns2:v4-static-route-prefix>255.255.252.1</tns2:v4-static-route-prefix><tns2:v4-static-route-prefix-length>28</tns2:v4-static-route-prefix-length><tns2:v4-next-hop-address>192.168.1.15</tns2:v4-next-hop-address></tns2:v4-static-routes><tns2:v4-static-routes><tns2:v4-static-route-prefix>255.255.252.2</tns2:v4-static-route-prefix><tns2:v4-static-route-prefix-length>28</tns2:v4-static-route-prefix-length><tns2:v4-next-hop-address>192.168.1.15</tns2:v4-next-hop-address></tns2:v4-static-routes><tns2:v4-static-routes><tns2:v4-static-route-prefix>255.255.252.3</tns2:v4-static-route-prefix><tns2:v4-static-route-prefix-length>28</tns2:v4-static-route-prefix-length><tns2:v4-next-hop-address>192.168.1.15</tns2:v4-next-hop-address></tns2:v4-static-routes><tns2:v6-static-routes><tns2:v6-static-route-prefix>2001:1890:12e3:2da::</tns2:v6-static-route-prefix><tns2:v6-static-route-prefix-length>28</tns2:v6-static-route-prefix-length><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address></tns2:v6-static-routes><tns2:v6-static-routes><tns2:v6-static-route-prefix>2001:1890:12e3:2da::</tns2:v6-static-route-prefix><tns2:v6-static-route-prefix-length>28</tns2:v6-static-route-prefix-length><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address></tns2:v6-static-routes></tns2:static-routes></tns2:vr-lan-interface></tns2:vr-lan>"
+ def expected_rebuildVrLanInterfacePartial = "<tns2:vr-designation>primary</tns2:vr-designation><tns2:v4-vr-lan-prefix>10.192.27.254</tns2:v4-vr-lan-prefix><tns2:v4-vr-lan-prefix-length>24</tns2:v4-vr-lan-prefix-length><tns2:v6-vr-lan-prefix>2620:0:10d0:f:ffff:ffff:ffff:fffe</tns2:v6-vr-lan-prefix><tns2:v6-vr-lan-prefix-length>64</tns2:v6-vr-lan-prefix-length><tns2:v4-vce-loopback-address>162.200.3.144</tns2:v4-vce-loopback-address><tns2:v6-vce-wan-address>2001:1890:12e3:2da::</tns2:v6-vce-wan-address><tns2:v4-public-lan-prefixes><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v4-next-hop-address>192.168.1.2</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.1</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v4-next-hop-address>192.168.1.72</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.71</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v4-next-hop-address>192.168.1.68</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.67</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v4-next-hop-address>192.168.1.15</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.15</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes><tns2:t-provided-v4-lan-public-prefixes><tns2:request-index>2</tns2:request-index><tns2:v4-next-hop-address>192.168.1.16</tns2:v4-next-hop-address><tns2:v4-lan-public-prefix>192.168.1.16</tns2:v4-lan-public-prefix><tns2:v4-lan-public-prefix-length>28</tns2:v4-lan-public-prefix-length></tns2:t-provided-v4-lan-public-prefixes></tns2:v4-public-lan-prefixes><tns2:v6-public-lan-prefixes><tns2:t-provided-v6-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address><tns2:v6-lan-public-prefix>2001:1890:12e3:2da::</tns2:v6-lan-public-prefix><tns2:v6-lan-public-prefix-length>28</tns2:v6-lan-public-prefix-length></tns2:t-provided-v6-lan-public-prefixes><tns2:t-provided-v6-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address><tns2:v6-lan-public-prefix>2001:1890:12e3:3da::</tns2:v6-lan-public-prefix><tns2:v6-lan-public-prefix-length>28</tns2:v6-lan-public-prefix-length></tns2:t-provided-v6-lan-public-prefixes><tns2:t-provided-v6-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address><tns2:v6-lan-public-prefix>2001:1890:12e3:4da::</tns2:v6-lan-public-prefix><tns2:v6-lan-public-prefix-length>28</tns2:v6-lan-public-prefix-length></tns2:t-provided-v6-lan-public-prefixes><tns2:t-provided-v6-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address><tns2:v6-lan-public-prefix>2001:1890:12e3:2da::</tns2:v6-lan-public-prefix><tns2:v6-lan-public-prefix-length>28</tns2:v6-lan-public-prefix-length></tns2:t-provided-v6-lan-public-prefixes><tns2:t-provided-v6-lan-public-prefixes><tns2:request-index>1</tns2:request-index><tns2:v6-next-hop-address>2001:1890:12e3:2da::</tns2:v6-next-hop-address><tns2:v6-lan-public-prefix>2001:1890:12e3:2da::</tns2:v6-lan-public-prefix><tns2:v6-lan-public-prefix-length>28</tns2:v6-lan-public-prefix-length></tns2:t-provided-v6-lan-public-prefixes></tns2:v6-public-lan-prefixes>"
+
+ @Before
+ public void setUp() {
+ def responseAsString = getFile("sdncadaptercallbackrequest.xml")
+ def varrequestData=utils.getNodeText(responseAsString,"RequestData")
+ origXmlResponse = utils.getNodeXml(varrequestData, "layer3-service-list").drop(38).trim()
+
+ }
+
+ @Test
+ public void testBuildL2Home() {
+ def rebuildL2Home = utils.buildL2HomingInformation(origXmlResponse)
+ println " rebuildL2Home: "
+ println " actual - " + rebuildL2Home
+ println " expected - " + expected_rebuildL2Home
+ assertEquals("rebuildL2Home - expected vs actual", expected_rebuildL2Home, rebuildL2Home)
+ }
+
+ @Test
+ public void testBuildInternetEvcAccess() {
+ def rebuildInternetEvcAccess = utils.buildInternetEvcAccessInformation(origXmlResponse)
+ println " rebuildInternetEvcAccess: "
+ println " actual - " + rebuildInternetEvcAccess
+ println " expected - " + expected_rebuildInternetEvcAccess
+ assertEquals("rebuildInternetEvcAccess - expected vs actual", expected_rebuildInternetEvcAccess, rebuildInternetEvcAccess)
+ }
+
+ @Test
+ public void testBuildInternetServiceChangeDetails() {
+ def rebuildInternetServiceChangeDetails = utils.buildInternetServiceChangeDetails(origXmlResponse)
+ println " rebuildInternetServiceChangeDetails: "
+ println " actual - " + rebuildInternetServiceChangeDetails
+ println " expected - " + expected_rebuildInternetServiceChangeDetails
+ assertEquals("rebuildInternetServiceChangeDetails - expected vs actual", expected_rebuildInternetServiceChangeDetails, rebuildInternetServiceChangeDetails)
+ }
+
+ @Test
+ public void testBuildInternetServiceChangeDetailsWithVrLanParams() {
+ def responseAsString = getFile("sdncadaptercallbackrequest_with_aic_version.xml")
+ def varrequestData=utils.getNodeText(responseAsString,"RequestData")
+ def xmlResponse = utils.getNodeXml(varrequestData, "layer3-service-list").drop(38).trim()
+ def rebuildInternetServiceChangeDetails = utils.buildInternetServiceChangeDetails(xmlResponse)
+ println " rebuildInternetServiceChangeDetails: "
+ println " actual - " + rebuildInternetServiceChangeDetails
+ println " expected - " + expected_rebuildInternetServiceChangeDetails
+ assertEquals("rebuildInternetServiceChangeDetails - expected vs actual", expected_rebuildInternetServiceChangeDetailsWithVrLanParams, rebuildInternetServiceChangeDetails)
+ }
+
+ // Coming v100
+ @Test
+ @Ignore
+ public void testBuildUcpeVmsServiceInformation() {
+ def rebuildUcpeVmsServiceInformation = utils.buildUcpeVmsServiceInformation(origXmlResponse)
+ println " rebuildUcpeVmsServiceInformation: "
+ println " actual - " + rebuildUcpeVmsServiceInformation
+ println " expected - " + expected_rebuildUcpeVmsServiceInformation
+ assertEquals("rebuildUcpeVmsServiceInformation - expected vs actual", expected_rebuildUcpeVmsServiceInformation, rebuildUcpeVmsServiceInformation)
+ }
+
+ @Test
+ public void testBuildElements() {
+ // testing utility codes: buildElements() & buildElementsUnblunded()
+ def internetServiceChangeDetails = utils.getNodeXml(origXmlResponse, "internet-service-change-details").drop(38).trim()
+ def buildElements = ''
+ buildElements = "<tns2:internet-service-change-details>"
+ buildElements += utils.buildElements(internetServiceChangeDetails, ["internet-evc-speed-value"], "")
+ buildElements += utils.buildElements(internetServiceChangeDetails, ["internet-evc-speed-units"], "")
+ def tProvidedV4LanPublicPrefixesChangesList = ["request-index", "v4-next-hop-address", "v4-lan-public-prefix", "v4-lan-public-prefix-length"]
+ buildElements += utils.buildElementsUnbounded(internetServiceChangeDetails, tProvidedV4LanPublicPrefixesChangesList, "t-provided-v4-lan-public-prefixes")
+ buildElements += "</tns2:internet-service-change-details>"
+ println " buildElements: "
+ println " actual - " + buildElements
+ println " expected - " + expected_buildElements
+ assertEquals("buildElements - expected vs actual", expected_buildElements, buildElements)
+ }
+
+ @Test
+ public void testBuildVrLan() {
+ def rebuildVrLan = utils.buildVrLan(origXmlResponse)
+ println " rebuildVrLans: "
+ println " actual - " + rebuildVrLan
+ println " expected - " + expected_rebuildVrLan
+ assertEquals("rebuildVrLan - expected vs actual", expected_rebuildVrLan, rebuildVrLan)
+ }
+
+ @Test
+ public void testBuildVrLanInterfacePartial() {
+ def rebuildVrLanInterfacePartial = utils.buildVrLanInterfacePartial(origXmlResponse)
+ println " rebuildVrLanInterfacePartial: "
+ println " actual - " + rebuildVrLanInterfacePartial
+ println " expected - " + expected_rebuildVrLanInterfacePartial
+ assertEquals("rebuildVrLanInterfacePartial - expected vs actual", expected_rebuildVrLanInterfacePartial, rebuildVrLanInterfacePartial)
+ }
+
+ @Test
+ public void testBuildDhcp() {
+ def rebuildDhcp = utils.buildDhcp(origXmlResponse)
+ println " rebuildDhcp: "
+ println " actual - " + rebuildDhcp
+ println " expected - " + expected_rebuildDhcp
+ assertEquals("rebuildDhcp - expected vs actual", expected_rebuildDhcp, rebuildDhcp)
+ }
+
+ @Test
+ public void testBuildPat() {
+ def rebuildPat = utils.buildPat(origXmlResponse)
+ println " rebuildPat: "
+ println " actual - " + rebuildPat
+ println " expected - " + expected_rebuildPat
+ assertEquals("rebuildPat - expected vs actual", expected_rebuildPat, rebuildPat)
+ }
+
+ @Test
+ public void testBuildNat() {
+ def rebuildNat = utils.buildNat(origXmlResponse)
+ println " rebuildNat: "
+ println " actual - " + rebuildNat
+ println " expected - " + expected_rebuildNat
+ assertEquals("rebuildNat - expected vs actual", expected_rebuildNat, rebuildNat)
+ }
+
+ @Test
+ public void testBuildFirewallLite() {
+ def rebuildFirewallLite = utils.buildFirewallLite(origXmlResponse)
+ println " rebuildFirewallLite: "
+ println " actual - " + rebuildFirewallLite
+ println " expected - " + expected_rebuildFirewallLite
+ assertEquals("rebuildFirewallLite - expected vs actual", expected_rebuildFirewallLite, rebuildFirewallLite)
+ }
+
+ @Test
+ public void testBuildStaticRoutes() {
+ def rebuildStaticRoutes = utils.buildStaticRoutes(origXmlResponse)
+ println " rebuildStaticRoutes: "
+ println " actual - " + rebuildStaticRoutes
+ println " expected - " + expected_rebuildStaticRoutes
+ assertEquals("rebuildStaticRoutes - expected vs actual", expected_rebuildStaticRoutes, rebuildStaticRoutes)
+ }
+
+ @Test
+ public void testGetBasicAuth(){
+ def encodedAuth = utils.getBasicAuth("3E3CFA7BE2F6107AAD4AAA65F8976690","07a7159d3bf51a0e53be7a8f89699be7")
+ assertEquals("Basic bXlTdHJpbmc=", encodedAuth)
+ }
+
+ @Test
+ public void testEncrypt(){
+ def encrypted = utils.encrypt("myString","07a7159d3bf51a0e53be7a8f89699be7")
+ assertEquals("3E3CFA7BE2F6107AAD4AAA65F8976690", encrypted)
+
+ //use to get value for urn properties
+ //println(utils.encrypt("password"))
+ }
+
+ @Test
+ public void testDecrypt(){
+ def decrypted = utils.decrypt("3E3CFA7BE2F6107AAD4AAA65F8976690", "07a7159d3bf51a0e53be7a8f89699be7")
+ assertEquals("myString", decrypted)
+ }
+
+ @Test
+ public void testGetPBGFList(){
+ def responseAsString = getFile("sdncDeleteResponse.xml")
+ def nodes = utils.getPBGFList("true", responseAsString)
+ //assertEquals(2, nodes.size())
+ while(!nodes.empty){
+ def myBGFXML = nodes.remove(0)
+ def myBGF= new XmlSlurper().parseText(myBGFXML)
+ println "borderElmtId: " + myBGF.'border-element-id'
+ println "vlanid: " + myBGF.'vlan-id' +"\n"
+ }
+ }
+
+ @Test
+ public void testBuildL2HomingInformation_with_aic_clli() {
+
+ def responseAsString = getFile("sdncadaptercallbackrequest_with_aic_version.xml")
+ def varrequestData=utils.getNodeText(responseAsString,"RequestData")
+ def xmlResponse = utils.getNodeXml(varrequestData, "layer3-service-list").drop(38).trim()
+ def rebuildL2Home = utils.buildL2HomingInformation(xmlResponse)
+ println " rebuildL2Home: "
+ println " actual - " + rebuildL2Home
+ println " expected - " + expected_rebuildL2Home
+ assertEquals("rebuildL2Home - expected vs actual", expected_rebuildL2HomeFor_aic_clli, rebuildL2Home)
+ }
+
+ @Test
+ public void testUnescapeNodeContents() {
+ String output = "<a><b>AT&amp;T</b></a>"
+ String noChangeInput = "<a><b>AT&amp;T</b></a>"
+ String decodeWithNamespacesNodeInput = '<top xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema"><a xsi:type="xs:string">&lt;b&gt;AT&amp;amp;T&lt;/b&gt;</a></top>'
+ String decodeWithNamespacesInput = '<a xsi:type="xs:string">&lt;b&gt;AT&amp;amp;T&lt;/b&gt;</a>'
+ String decodeWithNamespacesOutput = '<a xsi:type="xs:string"><b>AT&amp;T</b></a>'
+ String decodeWithoutNamespacesInput = '<a type="string">&lt;b&gt;AT&amp;amp;T&lt;/b&gt;</a>'
+ String decodeWithoutNamespacesOutput = '<a type="string"><b>AT&amp;T</b></a>'
+ String normalString = "<a>AT&amp;T</a>"
+ NodeChild noChangeInputNode = new XmlSlurper().parseText(noChangeInput).'**'.find {it.name() == 'a'}
+ NodeChild decodeWithNamespacesInputNode = new XmlSlurper().parseText(decodeWithNamespacesNodeInput).'**'.find {it.name() == 'a'}
+ NodeChild decodeWithoutNamespacesInputNode = new XmlSlurper().parseText(decodeWithoutNamespacesInput).'**'.find {it.name() == 'a'}
+ NodeChild normalStringNode = new XmlSlurper().parseText(normalString).'**'.find {it.name() == 'a'}
+
+ assertEquals("no change", output, utils.unescapeNodeContents(noChangeInputNode, noChangeInput))
+ assertEquals("single unescape", decodeWithNamespacesOutput, utils.unescapeNodeContents(decodeWithNamespacesInputNode, decodeWithNamespacesInput))
+ assertEquals("single unescape", decodeWithoutNamespacesOutput, utils.unescapeNodeContents(decodeWithoutNamespacesInputNode, decodeWithoutNamespacesInput))
+ assertEquals("unescape normal string", "AT&T", utils.unescapeNodeContents(normalStringNode, "AT&amp;T"))
+ }
+
+ @Test
+ public void testXmlEncode() {
+
+ String expected = "&amp;amp;";
+
+ assertEquals("is double encoded", expected, MsoUtils.xmlEscape("&amp;"))
+
+ }
+ public String getFile(String fileName) {
+ def SLASH = File.separator
+ def pathBase = ' '
+ def fileAsString = ''
+ try {
+ pathBase = new File(".").getCanonicalPath()
+ //println "pathBase " + pathBase + "${SLASH}src${SLASH}test${SLASH}resources${SLASH}${fileName}"
+ fileAsString = new File(pathBase, "${SLASH}src${SLASH}test${SLASH}resources${SLASH}${fileName}").getText()
+ } catch (Exception ex) {
+ println " *** getFile error: " + ex.getStackTrace()
+ } finally {
+ return fileAsString
+ }
+ }
+
+
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/NetworkUtilsTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/NetworkUtilsTest.groovy
new file mode 100644
index 0000000000..510dcf665c
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/NetworkUtilsTest.groovy
@@ -0,0 +1,101 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import org.junit.Before
+import org.mockito.MockitoAnnotations
+
+import static org.mockito.Mockito.*
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+class NetworkUtilsTest {
+
+ def volumeRequestXml = """<volume-request xmlns="http://www.w3.org/2001/XMLSchema">
+ <request-info>
+ <action>CREATE_VF_MODULE_VOL</action>
+ <source>VID</source>
+ <service-instance-id/>
+ </request-info>
+ <volume-inputs>
+ <volume-group-id/>
+ <volume-group-name>MSOTESTVOL101a-vSAMP12_base_vol_module-0</volume-group-name>
+ <vnf-type>Test/vSAMP12</vnf-type>
+ <vf-module-model-name>vSAMP12::base::module-0</vf-module-model-name>
+ <asdc-service-model-version>2.0</asdc-service-model-version>
+ <aic-cloud-region>mdt1</aic-cloud-region>
+ <tenant-id>88a6ca3ee0394ade9403f075db23167e</tenant-id>
+ <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id>
+ <backout-on-failure></backout-on-failure>
+ </volume-inputs>
+ <volume-params>
+ <param name="vnf_name">STMTN5MMSC20</param>
+ <param name="vnf_name2">US1117MTSNJVBR0246</param>
+ </volume-params>
+</volume-request>"""
+
+
+ @Test
+ public void testIsRollbackEnabled() {
+
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.rollback")).thenReturn(true)
+
+ NetworkUtils networkUtils = new NetworkUtils()
+ def rollbackEnabled = networkUtils.isRollbackEnabled(mockExecution, volumeRequestXml)
+
+ assertEquals(true, rollbackEnabled)
+
+ }
+
+ @Test
+ public void testIsRollbackEnabled2() {
+
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
+ when(mockExecution.getVariable("mso.rollback")).thenReturn(false)
+
+ NetworkUtils networkUtils = new NetworkUtils()
+ def rollbackEnabled = networkUtils.isRollbackEnabled(mockExecution, volumeRequestXml)
+
+ assertEquals(false, rollbackEnabled)
+
+ }
+
+ @Test
+ public void testGetIpvVersion() {
+
+ NetworkUtils networkUtils = new NetworkUtils()
+ println "test: ipv4"
+ String version4 = networkUtils.getIpvVersion("ipv4")
+ assertEquals("4", version4)
+ println "test: ipv6"
+ String version6 = networkUtils.getIpvVersion("ipv6")
+ assertEquals("6", version6)
+ println "test: 4"
+ String versionDigit4 = networkUtils.getIpvVersion("4")
+ assertEquals("4", versionDigit4)
+
+ }
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModuleTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModuleTest.groovy
new file mode 100644
index 0000000000..c5b8fab9eb
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModuleTest.groovy
@@ -0,0 +1,171 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule
+import org.camunda.bpm.engine.ProcessEngineServices
+import org.camunda.bpm.engine.RepositoryService
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.camunda.bpm.engine.repository.ProcessDefinition
+import org.junit.Before
+import org.junit.Ignore
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.MockitoAnnotations
+import org.mockito.runners.MockitoJUnitRunner
+import org.onap.so.bpmn.mock.StubResponseAAI
+
+import static org.mockito.Mockito.*
+
+@RunWith(MockitoJUnitRunner.class)
+@Ignore
+class PrepareUpdateAAIVfModuleTest {
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(28090)
+
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+ @Before
+ void init() throws IOException {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ void testGetGenericVnf() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("PUAAIVfMod_vnfId")).thenReturn("skask")
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+ when(mockExecution.getVariable("mso.workflow.custom.PrepareUpdateAAIVfModule.aai.version")).thenReturn('8')
+
+ StubResponseAAI.MockAAIVfModule()
+
+ PrepareUpdateAAIVfModule obj = new PrepareUpdateAAIVfModule()
+ obj.getGenericVnf(mockExecution)
+
+ verify(mockExecution).setVariable("PUAAIVfMod_getVnfResponseCode", 200)
+ }
+
+ @Test
+ void testGetGenericVnfEndpointNull() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("PUAAIVfMod_vnfId")).thenReturn("skask")
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn(null)
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+ when(mockExecution.getVariable("mso.workflow.custom.PrepareUpdateAAIVfModule.aai.version")).thenReturn('8')
+
+ StubResponseAAI.MockAAIVfModule()
+ try {
+ PrepareUpdateAAIVfModule obj = new PrepareUpdateAAIVfModule()
+ obj.getGenericVnf(mockExecution)
+ } catch (Exception ex) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+
+ verify(mockExecution).setVariable("PUAAIVfMod_getVnfResponseCode", 500)
+ verify(mockExecution).setVariable("PUAAIVfMod_getVnfResponse", "AAI GET Failed:org.apache.http.client.ClientProtocolException")
+ }
+
+ @Test
+ void testUpdateVfModule() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("PUAAIVfMod_vnfId")).thenReturn("skask")
+ when(mockExecution.getVariable("PUAAIVfMod_vfModuleId")).thenReturn("supercool")
+
+ def node = new Node(null, 'vfModule')
+ new Node(node, 'vf-module-name', "abc")
+ VfModule vfModule = new VfModule(node, true)
+
+ when(mockExecution.getVariable("PUAAIVfMod_vfModule")).thenReturn(vfModule)
+ when(mockExecution.getVariable("PUAAIVfMod_orchestrationStatus")).thenReturn("created")
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+ when(mockExecution.getVariable("mso.workflow.custom.PrepareUpdateAAIVfModule.aai.version")).thenReturn('8')
+
+ StubResponseAAI.MockAAIVfModule()
+ PrepareUpdateAAIVfModule obj = new PrepareUpdateAAIVfModule()
+ obj.updateVfModule(mockExecution)
+
+ verify(mockExecution).setVariable("PUAAIVfMod_updateVfModuleResponseCode", 200)
+ verify(mockExecution).setVariable("PUAAIVfMod_updateVfModuleResponse", "")
+ }
+
+ @Test
+ void testUpdateVfModuleEndpointNull() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("PUAAIVfMod_vnfId")).thenReturn("skask")
+ when(mockExecution.getVariable("PUAAIVfMod_vfModuleId")).thenReturn("supercool")
+
+ def node = new Node(null, 'vfModule')
+ new Node(node, 'vf-module-name', "abc")
+ VfModule vfModule = new VfModule(node, true)
+
+ when(mockExecution.getVariable("PUAAIVfMod_vfModule")).thenReturn(vfModule)
+ when(mockExecution.getVariable("PUAAIVfMod_orchestrationStatus")).thenReturn("created")
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn(null)
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+ when(mockExecution.getVariable("mso.workflow.custom.PrepareUpdateAAIVfModule.aai.version")).thenReturn('8')
+
+ StubResponseAAI.MockAAIVfModule()
+ try {
+ PrepareUpdateAAIVfModule obj = new PrepareUpdateAAIVfModule()
+ obj.updateVfModule(mockExecution)
+ } catch (Exception ex) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+
+ verify(mockExecution).setVariable("PUAAIVfMod_updateVfModuleResponseCode", 500)
+ verify(mockExecution).setVariable("PUAAIVfMod_updateVfModuleResponse", "AAI PATCH Failed:org.apache.http.client.ClientProtocolException")
+ }
+
+ private static ExecutionEntity setupMock() {
+ ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
+ when(mockProcessDefinition.getKey()).thenReturn("PrepareUpdateAAIVfModule")
+ RepositoryService mockRepositoryService = mock(RepositoryService.class)
+ when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
+ when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("PrepareUpdateAAIVfModule")
+ 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("PrepareUpdateAAIVfModule")
+ when(mockExecution.getProcessInstanceId()).thenReturn("PrepareUpdateAAIVfModule")
+ when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
+ when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition)
+
+ return mockExecution
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1Test.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1Test.groovy
new file mode 100644
index 0000000000..1079bb48b3
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1Test.groovy
@@ -0,0 +1,151 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.junit.Before
+import org.junit.Ignore
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.MockitoAnnotations
+import org.mockito.internal.debugging.MockitoDebuggerImpl
+import org.mockito.runners.MockitoJUnitRunner
+import org.onap.so.bpmn.mock.FileUtil
+import org.onap.so.bpmn.core.json.JsonUtils
+
+import static org.mockito.Mockito.*
+
+@RunWith(MockitoJUnitRunner.class)
+public class SDNCAdapterRestV1Test {
+
+ @Before
+ public void init()
+ {
+ MockitoAnnotations.initMocks(this)
+ }
+
+ @Test
+ public void testPreProcessRequest() {
+ // bpTimeout is empty and "mso.adapters.sdnc.timeout" is defined
+
+ String sdncAdapterWorkflowRequest = FileUtil.readResourceFile("__files/SDN-ETHERNET-INTERNET/SDNCAdapterRestV1/sdnc_request.json");
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("prefix")).thenReturn("SDNCREST_")
+ when(mockExecution.getVariable("mso-request-id")).thenReturn("testMsoRequestId")
+ when(mockExecution.getVariable("SDNCREST_Request")).thenReturn(sdncAdapterWorkflowRequest)
+ when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B")
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
+
+ when(mockExecution.getVariable("mso.adapters.sdnc.rest.endpoint")).thenReturn("http://localhost:18080/adapters/rest/v1/sdnc/")
+
+ when(mockExecution.getVariable("mso.adapters.sdnc.timeout")).thenReturn("PT5M")
+
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("testProcessKey")).thenReturn("testProcessKey")
+
+
+ SDNCAdapterRestV1 sdncAdapterRestV1 = new SDNCAdapterRestV1()
+ sdncAdapterRestV1.preProcessRequest(mockExecution)
+
+ MockitoDebuggerImpl debugger = new MockitoDebuggerImpl()
+ //debugger.printInvocations(mockExecution)
+
+
+ verify(mockExecution).setVariable("prefix","SDNCREST_")
+
+ verify(mockExecution).setVariable("SDNCREST_SuccessIndicator",false)
+ verify(mockExecution).setVariable("SDNCREST_requestType","SDNCServiceRequest")
+ verify(mockExecution).setVariable("SDNCAResponse_CORRELATOR","0d883b7f-dd34-4e1b-9ed5-341d33052360-1511808197479")
+ verify(mockExecution).setVariable("SDNCREST_sdncAdapterMethod","POST")
+ verify(mockExecution).setVariable("SDNCREST_timeout","PT5M")
+ }
+
+ @Test
+ public void testPreProcessRequestGoodTimeout() {
+ // bpTimeout is valid and "mso.adapters.sdnc.timeout" is undefined
+
+ String sdncAdapterWorkflowRequest = FileUtil.readResourceFile("__files/SDN-ETHERNET-INTERNET/SDNCAdapterRestV1/sdnc_request.json");
+ sdncAdapterWorkflowRequest = JsonUtils.addJsonValue(sdncAdapterWorkflowRequest, "SDNCServiceRequest.bpTimeout", "PT20S")
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("prefix")).thenReturn("SDNCREST_")
+ when(mockExecution.getVariable("mso-request-id")).thenReturn("testMsoRequestId")
+ when(mockExecution.getVariable("SDNCREST_Request")).thenReturn(sdncAdapterWorkflowRequest)
+ when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B")
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
+
+ when(mockExecution.getVariable("mso.adapters.sdnc.rest.endpoint")).thenReturn("http://localhost:18080/adapters/rest/v1/sdnc/")
+
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("testProcessKey")).thenReturn("testProcessKey")
+
+
+ SDNCAdapterRestV1 sdncAdapterRestV1 = new SDNCAdapterRestV1()
+ sdncAdapterRestV1.preProcessRequest(mockExecution)
+
+ MockitoDebuggerImpl debugger = new MockitoDebuggerImpl()
+ //debugger.printInvocations(mockExecution)
+
+
+ verify(mockExecution).setVariable("prefix","SDNCREST_")
+
+ verify(mockExecution).setVariable("SDNCREST_SuccessIndicator",false)
+ verify(mockExecution).setVariable("SDNCREST_requestType","SDNCServiceRequest")
+ verify(mockExecution).setVariable("SDNCAResponse_CORRELATOR","0d883b7f-dd34-4e1b-9ed5-341d33052360-1511808197479")
+ verify(mockExecution).setVariable("SDNCREST_sdncAdapterMethod","POST")
+ verify(mockExecution).setVariable("SDNCREST_timeout","PT20S")
+ }
+
+ @Test
+ @Ignore
+ public void testPreProcessRequestBadTimeout() {
+ // bpTimeout is invalid and "mso.adapters.sdnc.timeout" is undefined
+
+ String sdncAdapterWorkflowRequest = FileUtil.readResourceFile("__files/SDN-ETHERNET-INTERNET/SDNCAdapterRestV1/sdnc_request.json");
+ sdncAdapterWorkflowRequest = JsonUtils.addJsonValue(sdncAdapterWorkflowRequest, "SDNCServiceRequest.bpTimeout", "badTimeout")
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("prefix")).thenReturn("SDNCREST_")
+ when(mockExecution.getVariable("mso-request-id")).thenReturn("testMsoRequestId")
+ when(mockExecution.getVariable("SDNCREST_Request")).thenReturn(sdncAdapterWorkflowRequest)
+ when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B")
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
+
+ when(mockExecution.getVariable("mso.adapters.sdnc.rest.endpoint")).thenReturn("http://localhost:18080/adapters/rest/v1/sdnc/")
+
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("testProcessKey")).thenReturn("testProcessKey")
+
+
+ SDNCAdapterRestV1 sdncAdapterRestV1 = new SDNCAdapterRestV1()
+ sdncAdapterRestV1.preProcessRequest(mockExecution)
+
+ MockitoDebuggerImpl debugger = new MockitoDebuggerImpl()
+ //debugger.printInvocations(mockExecution)
+
+
+ verify(mockExecution).setVariable("prefix","SDNCREST_")
+
+ verify(mockExecution).setVariable("SDNCREST_SuccessIndicator",false)
+ verify(mockExecution).setVariable("SDNCREST_requestType","SDNCServiceRequest")
+ verify(mockExecution).setVariable("SDNCAResponse_CORRELATOR","0d883b7f-dd34-4e1b-9ed5-341d33052360-1511808197479")
+ verify(mockExecution).setVariable("SDNCREST_sdncAdapterMethod","POST")
+ verify(mockExecution).setVariable("SDNCREST_timeout","PT10S")
+ }
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2Test.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2Test.groovy
new file mode 100644
index 0000000000..d7fe0ee208
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV2Test.groovy
@@ -0,0 +1,151 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.junit.Before
+import org.junit.Ignore
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.MockitoAnnotations
+import org.mockito.internal.debugging.MockitoDebuggerImpl
+import org.mockito.runners.MockitoJUnitRunner
+import org.onap.so.bpmn.mock.FileUtil
+import org.onap.so.bpmn.core.json.JsonUtils
+
+import static org.mockito.Mockito.*
+
+@RunWith(MockitoJUnitRunner.class)
+public class SDNCAdapterRestV2Test {
+
+ @Before
+ public void init()
+ {
+ MockitoAnnotations.initMocks(this)
+ }
+
+ @Test
+ public void testPreProcessRequest() {
+ // bpTimeout is empty and "mso.adapters.sdnc.timeout" is defined
+
+ String sdncAdapterWorkflowRequest = FileUtil.readResourceFile("__files/SDN-ETHERNET-INTERNET/SDNCAdapterRestV1/sdnc_request.json");
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("prefix")).thenReturn("SDNCREST_")
+ when(mockExecution.getVariable("mso-request-id")).thenReturn("testMsoRequestId")
+ when(mockExecution.getVariable("SDNCREST_Request")).thenReturn(sdncAdapterWorkflowRequest)
+ when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B")
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
+
+ when(mockExecution.getVariable("mso.adapters.sdnc.rest.endpoint")).thenReturn("http://localhost:18080/adapters/rest/v1/sdnc/")
+
+ when(mockExecution.getVariable("mso.adapters.sdnc.timeout")).thenReturn("PT5M")
+
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("testProcessKey")).thenReturn("testProcessKey")
+
+
+ SDNCAdapterRestV2 sdncAdapterRestV2 = new SDNCAdapterRestV2()
+ sdncAdapterRestV2.preProcessRequest(mockExecution)
+
+ MockitoDebuggerImpl debugger = new MockitoDebuggerImpl()
+ //debugger.printInvocations(mockExecution)
+
+
+ verify(mockExecution).setVariable("prefix","SDNCREST_")
+
+ verify(mockExecution).setVariable("SDNCREST_SuccessIndicator",false)
+ verify(mockExecution).setVariable("SDNCREST_requestType","SDNCServiceRequest")
+ verify(mockExecution).setVariable("SDNCAResponse_CORRELATOR","0d883b7f-dd34-4e1b-9ed5-341d33052360-1511808197479")
+ verify(mockExecution).setVariable("SDNCREST_sdncAdapterMethod","POST")
+ verify(mockExecution).setVariable("SDNCREST_timeout","PT5M")
+ }
+
+ @Test
+ public void testPreProcessRequestGoodTimeout() {
+ // bpTimeout is valid and "mso.adapters.sdnc.timeout" is undefined
+
+ String sdncAdapterWorkflowRequest = FileUtil.readResourceFile("__files/SDN-ETHERNET-INTERNET/SDNCAdapterRestV1/sdnc_request.json");
+ sdncAdapterWorkflowRequest = JsonUtils.addJsonValue(sdncAdapterWorkflowRequest, "SDNCServiceRequest.bpTimeout", "PT20S")
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("prefix")).thenReturn("SDNCREST_")
+ when(mockExecution.getVariable("mso-request-id")).thenReturn("testMsoRequestId")
+ when(mockExecution.getVariable("SDNCREST_Request")).thenReturn(sdncAdapterWorkflowRequest)
+ when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B")
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
+
+ when(mockExecution.getVariable("mso.adapters.sdnc.rest.endpoint")).thenReturn("http://localhost:18080/adapters/rest/v1/sdnc/")
+
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("testProcessKey")).thenReturn("testProcessKey")
+
+
+ SDNCAdapterRestV2 sdncAdapterRestV2 = new SDNCAdapterRestV2()
+ sdncAdapterRestV2.preProcessRequest(mockExecution)
+
+ MockitoDebuggerImpl debugger = new MockitoDebuggerImpl()
+ //debugger.printInvocations(mockExecution)
+
+
+ verify(mockExecution).setVariable("prefix","SDNCREST_")
+
+ verify(mockExecution).setVariable("SDNCREST_SuccessIndicator",false)
+ verify(mockExecution).setVariable("SDNCREST_requestType","SDNCServiceRequest")
+ verify(mockExecution).setVariable("SDNCAResponse_CORRELATOR","0d883b7f-dd34-4e1b-9ed5-341d33052360-1511808197479")
+ verify(mockExecution).setVariable("SDNCREST_sdncAdapterMethod","POST")
+ verify(mockExecution).setVariable("SDNCREST_timeout","PT20S")
+ }
+
+ @Ignore
+ @Test
+ public void testPreProcessRequestBadTimeout() {
+ // bpTimeout is invalid and "mso.adapters.sdnc.timeout" is undefined
+
+ String sdncAdapterWorkflowRequest = FileUtil.readResourceFile("__files/SDN-ETHERNET-INTERNET/SDNCAdapterRestV1/sdnc_request.json");
+ sdncAdapterWorkflowRequest = JsonUtils.addJsonValue(sdncAdapterWorkflowRequest, "SDNCServiceRequest.bpTimeout", "badTimeout")
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("prefix")).thenReturn("SDNCREST_")
+ when(mockExecution.getVariable("mso-request-id")).thenReturn("testMsoRequestId")
+ when(mockExecution.getVariable("SDNCREST_Request")).thenReturn(sdncAdapterWorkflowRequest)
+ when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B")
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
+
+ when(mockExecution.getVariable("mso.adapters.sdnc.rest.endpoint")).thenReturn("http://localhost:18080/adapters/rest/v1/sdnc/")
+
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("testProcessKey")).thenReturn("testProcessKey")
+
+
+ SDNCAdapterRestV2 sdncAdapterRestV2 = new SDNCAdapterRestV2()
+ sdncAdapterRestV2.preProcessRequest(mockExecution)
+
+ MockitoDebuggerImpl debugger = new MockitoDebuggerImpl()
+ //debugger.printInvocations(mockExecution)
+
+
+ verify(mockExecution).setVariable("prefix","SDNCREST_")
+
+ verify(mockExecution).setVariable("SDNCREST_SuccessIndicator",false)
+ verify(mockExecution).setVariable("SDNCREST_requestType","SDNCServiceRequest")
+ verify(mockExecution).setVariable("SDNCAResponse_CORRELATOR","0d883b7f-dd34-4e1b-9ed5-341d33052360-1511808197479")
+ verify(mockExecution).setVariable("SDNCREST_sdncAdapterMethod","POST")
+ verify(mockExecution).setVariable("SDNCREST_timeout","PT10S")
+ }
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterTest.groovy
new file mode 100644
index 0000000000..18d65d00d8
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterTest.groovy
@@ -0,0 +1,951 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+
+import static org.mockito.Mockito.*
+
+import org.camunda.bpm.engine.ProcessEngineServices
+import org.camunda.bpm.engine.RepositoryService
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.camunda.bpm.engine.repository.ProcessDefinition
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.MockitoAnnotations
+import org.mockito.runners.MockitoJUnitRunner
+import org.mockito.internal.debugging.MockitoDebuggerImpl
+import org.onap.so.bpmn.common.scripts.SDNCAdapter;
+
+import org.onap.so.bpmn.mock.FileUtil
+
+@RunWith(MockitoJUnitRunner.class)
+public class SDNCAdapterTest {
+
+ @Before
+ public void init()
+ {
+ MockitoAnnotations.initMocks(this)
+ System.setProperty("jboss.qualified.host.name","myhost.com")
+ }
+
+
+ String workflowResponse = """<sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
+ xmlns:tag0="http://org.onap/workflow/sdnc/adapter/schema/v1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="com:att:sdnctl:l3api">
+ <sdncadapterworkflow:response-data>
+ <tag0:CallbackHeader>
+ <tag0:RequestId>testRequestId</tag0:RequestId>
+ <tag0:ResponseCode>200</tag0:ResponseCode>
+ <tag0:ResponseMessage>OK</tag0:ResponseMessage>
+ </tag0:CallbackHeader>
+ <tag0:RequestData xsi:type="xs:string">
+ <layer3-service-list>
+ <service-instance-id>FK/VLXM/003717//SW_INTERNET</service-instance-id>
+ <service-status>
+ <rpc-name>service-configuration-operation</rpc-name>
+ <rpc-action>activate</rpc-action>
+ <request-status>synccomplete</request-status>
+ <final-indicator>N</final-indicator>
+ <l3sdn-action>Layer3ServiceActivateRequest</l3sdn-action>
+ <l3sdn-subaction>SUPP</l3sdn-subaction>
+ <response-timestamp>2015-04-28T21:32:11.386Z</response-timestamp>
+ </service-status>
+ <service-data>
+ <internet-evc-access-information>
+ <ip-version>ds</ip-version>
+ <internet-evc-speed-value>8</internet-evc-speed-value>
+ <internet-evc-speed-units>Mbps</internet-evc-speed-units>
+ </internet-evc-access-information>
+ <vr-lan>
+ <vr-lan-interface>
+ <static-routes>
+ <v6-static-routes>
+ <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address>
+ <v6-static-route-prefix>2001:1890:12e3:2da::</v6-static-route-prefix>
+ <v6-static-route-prefix-length>28</v6-static-route-prefix-length>
+ </v6-static-routes>
+ <v4-static-routes>
+ <v4-static-route-prefix>255.255.252.1</v4-static-route-prefix>
+ <v4-next-hop-address>192.168.1.15</v4-next-hop-address>
+ <v4-static-route-prefix-length>28</v4-static-route-prefix-length>
+ </v4-static-routes>
+ <v6-static-routes>
+ <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address>
+ <v6-static-route-prefix>2001:1890:12e3:2da::</v6-static-route-prefix>
+ <v6-static-route-prefix-length>28</v6-static-route-prefix-length>
+ </v6-static-routes>
+ <v4-static-routes>
+ <v4-static-route-prefix>255.255.252.2</v4-static-route-prefix>
+ <v4-next-hop-address>192.168.1.15</v4-next-hop-address>
+ <v4-static-route-prefix-length>28</v4-static-route-prefix-length>
+ </v4-static-routes>
+ <v4-static-routes>
+ <v4-static-route-prefix>255.255.252.3</v4-static-route-prefix>
+ <v4-next-hop-address>192.168.1.15</v4-next-hop-address>
+ <v4-static-route-prefix-length>28</v4-static-route-prefix-length>
+ </v4-static-routes>
+ </static-routes>
+ <dhcp>
+ <v6-dhcp-server-enabled>N</v6-dhcp-server-enabled>
+ <v4-dhcp-server-enabled>Y</v4-dhcp-server-enabled>
+ <use-v6-default-pool>N</use-v6-default-pool>
+ <excluded-v4-dhcp-addresses-from-default-pool>
+ <excluded-v4-address>192.168.1.7</excluded-v4-address>
+ </excluded-v4-dhcp-addresses-from-default-pool>
+ <excluded-v4-dhcp-addresses-from-default-pool>
+ <excluded-v4-address>192.168.1.8</excluded-v4-address>
+ </excluded-v4-dhcp-addresses-from-default-pool>
+ <v4-dhcp-pools>
+ <v4-dhcp-relay-next-hop-address>1.1.1.1</v4-dhcp-relay-next-hop-address>
+ <v4-dhcp-pool-prefix-length>28</v4-dhcp-pool-prefix-length>
+ <excluded-v4-addresses>
+ <excluded-v4-address>192.168.1.5</excluded-v4-address>
+ </excluded-v4-addresses>
+ <v4-dhcp-relay-gateway-address>2.2.2.1</v4-dhcp-relay-gateway-address>
+ <excluded-v4-addresses>
+ <excluded-v4-address>192.168.1.6</excluded-v4-address>
+ </excluded-v4-addresses>
+ <v4-dhcp-pool-prefix>192.155.2.3</v4-dhcp-pool-prefix>
+ </v4-dhcp-pools>
+ <v4-dhcp-pools>
+ <v4-dhcp-relay-next-hop-address>1.1.1.2</v4-dhcp-relay-next-hop-address>
+ <v4-dhcp-pool-prefix-length>28</v4-dhcp-pool-prefix-length>
+ <excluded-v4-addresses>
+ <excluded-v4-address>192.168.1.6</excluded-v4-address>
+ </excluded-v4-addresses>
+ <v4-dhcp-relay-gateway-address>2.2.2.2</v4-dhcp-relay-gateway-address>
+ <excluded-v4-addresses>
+ <excluded-v4-address>192.168.1.7</excluded-v4-address>
+ </excluded-v4-addresses>
+ <v4-dhcp-pool-prefix>192.155.2.4</v4-dhcp-pool-prefix>
+ </v4-dhcp-pools>
+ <use-v4-default-pool>Y</use-v4-default-pool>
+ <excluded-v6-dhcp-addresses-from-default-pool>
+ <excluded-v6-address>1:5</excluded-v6-address>
+ </excluded-v6-dhcp-addresses-from-default-pool>
+ <excluded-v6-dhcp-addresses-from-default-pool>
+ <excluded-v6-address>1:6</excluded-v6-address>
+ </excluded-v6-dhcp-addresses-from-default-pool>
+ <v6-dhcp-pools>
+ <v6-dhcp-relay-next-hop-address>4:4</v6-dhcp-relay-next-hop-address>
+ <v6-dhcp-pool-prefix-length>28</v6-dhcp-pool-prefix-length>
+ <excluded-v6-addresses>
+ <excluded-v6-address>1:1</excluded-v6-address>
+ </excluded-v6-addresses>
+ <v6-dhcp-relay-gateway-address>3:3</v6-dhcp-relay-gateway-address>
+ <excluded-v6-addresses>
+ <excluded-v6-address>2:2</excluded-v6-address>
+ </excluded-v6-addresses>
+ <v6-dhcp-pool-prefix>0:0</v6-dhcp-pool-prefix>
+ </v6-dhcp-pools>
+ <v6-dhcp-pools>
+ <v6-dhcp-relay-next-hop-address>4:4</v6-dhcp-relay-next-hop-address>
+ <v6-dhcp-pool-prefix-length>28</v6-dhcp-pool-prefix-length>
+ <excluded-v6-addresses>
+ <excluded-v6-address>1:1</excluded-v6-address>
+ </excluded-v6-addresses>
+ <v6-dhcp-relay-gateway-address>3:3</v6-dhcp-relay-gateway-address>
+ <excluded-v6-addresses>
+ <excluded-v6-address>2:2</excluded-v6-address>
+ </excluded-v6-addresses>
+ <v6-dhcp-pool-prefix>0:0</v6-dhcp-pool-prefix>
+ </v6-dhcp-pools>
+ </dhcp>
+ <firewall-lite>
+ <stateful-firewall-lite-v6-enabled>N</stateful-firewall-lite-v6-enabled>
+ <stateful-firewall-lite-v4-enabled>Y</stateful-firewall-lite-v4-enabled>
+ <v4-firewall-packet-filters>
+ <v4-firewall-prefix>0.0.0.1</v4-firewall-prefix>
+ <v4-firewall-prefix-length>1</v4-firewall-prefix-length>
+ <allow-icmp-ping>Y</allow-icmp-ping>
+ <udp-ports>
+ <port-number>1</port-number>
+ </udp-ports>
+ <tcp-ports>
+ <port-number>1</port-number>
+ </tcp-ports>
+ </v4-firewall-packet-filters>
+ <v4-firewall-packet-filters>
+ <v4-firewall-prefix>0.0.0.2</v4-firewall-prefix>
+ <v4-firewall-prefix-length>2</v4-firewall-prefix-length>
+ <allow-icmp-ping>Y</allow-icmp-ping>
+ <udp-ports>
+ <port-number>2</port-number>
+ </udp-ports>
+ <tcp-ports>
+ <port-number>2</port-number>
+ </tcp-ports>
+ </v4-firewall-packet-filters>
+ <v6-firewall-packet-filters>
+ <v6-firewall-prefix>:</v6-firewall-prefix>
+ <v6-firewall-prefix-length>0</v6-firewall-prefix-length>
+ <allow-icmp-ping>Y</allow-icmp-ping>
+ <udp-ports>
+ <port-number>3</port-number>
+ </udp-ports>
+ <tcp-ports>
+ <port-number>3</port-number>
+ </tcp-ports>
+ </v6-firewall-packet-filters>
+ <v6-firewall-packet-filters>
+ <v6-firewall-prefix>:</v6-firewall-prefix>
+ <v6-firewall-prefix-length>1</v6-firewall-prefix-length>
+ <allow-icmp-ping>Y</allow-icmp-ping>
+ <udp-ports>
+ <port-number>4</port-number>
+ </udp-ports>
+ <tcp-ports>
+ <port-number>4</port-number>
+ </tcp-ports>
+ </v6-firewall-packet-filters>
+ </firewall-lite>
+ <pat>
+ <v4-pat-pools>
+ <v4-pat-pool-prefix>192.168.1.44</v4-pat-pool-prefix>
+ <v4-pat-pool-next-hop-address>192.168.1.5</v4-pat-pool-next-hop-address>
+ <v4-pat-pool-prefix-length>0</v4-pat-pool-prefix-length>
+ </v4-pat-pools>
+ <use-v4-default-pool>Y</use-v4-default-pool>
+ <v4-pat-enabled>N</v4-pat-enabled>
+ <v4-pat-pools>
+ <v4-pat-pool-prefix>192.168.1.45</v4-pat-pool-prefix>
+ <v4-pat-pool-next-hop-address>192.168.1.6</v4-pat-pool-next-hop-address>
+ <v4-pat-pool-prefix-length>28</v4-pat-pool-prefix-length>
+ </v4-pat-pools>
+ </pat>
+ <nat>
+ <v4-nat-enabled>Y</v4-nat-enabled>
+ <v4-nat-mapping-entries>
+ <v4-nat-internal>0.0.0.0</v4-nat-internal>
+ <v4-nat-next-hop-address>0.0.0.0</v4-nat-next-hop-address>
+ <v4-nat-external>0.0.0.0</v4-nat-external>
+ </v4-nat-mapping-entries>
+ <v4-nat-mapping-entries>
+ <v4-nat-internal>0.0.0.1</v4-nat-internal>
+ <v4-nat-next-hop-address>0.0.0.1</v4-nat-next-hop-address>
+ <v4-nat-external>0.0.0.1</v4-nat-external>
+ </v4-nat-mapping-entries>
+ </nat>
+ <vr-designation>primary</vr-designation>
+ <v4-vce-loopback-address>162.200.3.144</v4-vce-loopback-address>
+ <v6-vr-lan-prefix-length>64</v6-vr-lan-prefix-length>
+ <v6-vce-wan-address>2001:1890:12e3:2da::</v6-vce-wan-address>
+ <v6-vr-lan-prefix>2620:0:10d0:f:ffff:ffff:ffff:fffe</v6-vr-lan-prefix>
+ <v4-vr-lan-prefix-length>24</v4-vr-lan-prefix-length>
+ <v4-vr-lan-prefix>10.192.27.254</v4-vr-lan-prefix>
+ <v4-public-lan-prefixes>
+ <t-provided-v4-lan-public-prefixes>
+ <request-index>1</request-index>
+ <v4-next-hop-address>192.168.1.2</v4-next-hop-address>
+ <v4-lan-public-prefix>192.168.1.1</v4-lan-public-prefix>
+ <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length>
+ </t-provided-v4-lan-public-prefixes>
+ <t-provided-v4-lan-public-prefixes>
+ <request-index>1</request-index>
+ <v4-next-hop-address>192.168.1.72</v4-next-hop-address>
+ <v4-lan-public-prefix>192.168.1.71</v4-lan-public-prefix>
+ <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length>
+ </t-provided-v4-lan-public-prefixes>
+ <t-provided-v4-lan-public-prefixes>
+ <request-index>1</request-index>
+ <v4-next-hop-address>192.168.1.68</v4-next-hop-address>
+ <v4-lan-public-prefix>192.168.1.67</v4-lan-public-prefix>
+ <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length>
+ </t-provided-v4-lan-public-prefixes>
+ </v4-public-lan-prefixes>
+ <v6-public-lan-prefixes>
+ <t-provided-v6-lan-public-prefixes>
+ <request-index>1</request-index>
+ <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address>
+ <v6-lan-public-prefix>2001:1890:12e3:2da::</v6-lan-public-prefix>
+ <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length>
+ </t-provided-v6-lan-public-prefixes>
+ <t-provided-v6-lan-public-prefixes>
+ <request-index>1</request-index>
+ <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address>
+ <v6-lan-public-prefix>2001:1890:12e3:3da::</v6-lan-public-prefix>
+ <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length>
+ </t-provided-v6-lan-public-prefixes>
+ <t-provided-v6-lan-public-prefixes>
+ <request-index>1</request-index>
+ <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address>
+ <v6-lan-public-prefix>2001:1890:12e3:4da::</v6-lan-public-prefix>
+ <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length>
+ </t-provided-v6-lan-public-prefixes>
+ </v6-public-lan-prefixes>
+ </vr-lan-interface>
+ <routing-protocol>none</routing-protocol>
+ </vr-lan>
+ <ucpe-vms-service-information>
+ <transport-service-information>
+ <transport-service-type>AVPN</transport-service-type>
+ <access-circuit-info>
+ <access-circuit-id>1</access-circuit-id>
+ <dual-mode>Active</dual-mode>
+ </access-circuit-info>
+ <access-circuit-info>
+ <access-circuit-id>2</access-circuit-id>
+ <dual-mode>Standby</dual-mode>
+ </access-circuit-info>
+ </transport-service-information>
+ <ucpe-information>
+ <ucpe-host-name>hostname</ucpe-host-name>
+ <ucpe-activation-code>activecode</ucpe-activation-code>
+ <out-of-band-management-modem>OOB</out-of-band-management-modem>
+ </ucpe-information>
+ <vnf-list>
+ <vnf-information>
+ <vnf-instance-id>1</vnf-instance-id>
+ <vnf-sequence-number>1</vnf-sequence-number>
+ <vnf-type>ZZ</vnf-type>
+ <vnf-vendor>JUNIPER</vnf-vendor>
+ <vnf-model>MODEL1</vnf-model>
+ <vnf-id>1</vnf-id>
+ <prov-status>1</prov-status>
+ <operational-state>1</operational-state>
+ <orchestration-status>1</orchestration-status>
+ <equipment-role>1</equipment-role>
+ </vnf-information>
+ <vnf-information>
+ <vnf-instance-id>2</vnf-instance-id>
+ <vnf-sequence-number>2</vnf-sequence-number>
+ <vnf-type>HY</vnf-type>
+ <vnf-vendor>JUNIPER</vnf-vendor>
+ <vnf-model>MODEL2</vnf-model>
+ <vnf-id>2</vnf-id>
+ <prov-status>2</prov-status>
+ <operational-state>2</operational-state>
+ <orchestration-status>2</orchestration-status>
+ <equipment-role>2</equipment-role>
+ </vnf-information>
+ </vnf-list>
+ </ucpe-vms-service-information>
+ <request-information>
+ <request-action>Layer3ServiceActivateRequest</request-action>
+ <order-number>4281555</order-number>
+ <request-id>155415ab-b4a7-4382-b4c6-d17d9sm42855</request-id>
+ <notification-url>https://csi-tst-q22.it.com:22443/Services/com/cingular/csi/sdn/SendManagedNetworkStatusNotification.jws</notification-url>
+ <source>OMX</source>
+ <order-version>1</order-version>
+ </request-information>
+ <sdnc-request-header>
+ <svc-action>activate</svc-action>
+ <svc-notification-url>https://localhost:8443/adapters/rest/SDNCNotify</svc-notification-url>
+ <svc-request-id>5b1f3c5d-cdf9-488d-8a4b-d3f1229d7760</svc-request-id>
+ </sdnc-request-header>
+ <l2-homing-information>
+ <topology>MultiPoint</topology>
+ <preferred-aic-clli>MTSNJA4LCP1</preferred-aic-clli>
+ <evc-name>AS/VLXM/003717//SW</evc-name>
+ </l2-homing-information>
+ <service-information>
+ <service-instance-id>FK/VLXM/003717//SW_INTERNET</service-instance-id>
+ <subscriber-name>ST E2E Test42855_1300004281555</subscriber-name>
+ <service-type>SDN-ETHERNET-INTERNET</service-type>
+ </service-information>
+ <internet-service-change-details>
+ <internet-evc-speed-value>10</internet-evc-speed-value>
+ <internet-evc-speed-units>Kbps</internet-evc-speed-units>
+ <t-provided-v4-lan-public-prefixes>
+ <request-index>1</request-index>
+ <v4-next-hop-address>192.168.1.15</v4-next-hop-address>
+ <v4-lan-public-prefix>192.168.1.15</v4-lan-public-prefix>
+ <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length>
+ </t-provided-v4-lan-public-prefixes>
+ <t-provided-v4-lan-public-prefixes>
+ <request-index>2</request-index>
+ <v4-next-hop-address>192.168.1.16</v4-next-hop-address>
+ <v4-lan-public-prefix>192.168.1.16</v4-lan-public-prefix>
+ <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length>
+ </t-provided-v4-lan-public-prefixes>
+ <t-provided-v6-lan-public-prefixes>
+ <request-index>1</request-index>
+ <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address>
+ <v6-lan-public-prefix>2001:1890:12e3:2da::</v6-lan-public-prefix>
+ <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length>
+ </t-provided-v6-lan-public-prefixes>
+ <t-provided-v6-lan-public-prefixes>
+ <request-index>1</request-index>
+ <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address>
+ <v6-lan-public-prefix>2001:1890:12e3:2da::</v6-lan-public-prefix>
+ <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length>
+ </t-provided-v6-lan-public-prefixes>
+ </internet-service-change-details>
+ </service-data>
+ </layer3-service-list>
+ </tag0:RequestData>
+ </sdncadapterworkflow:response-data>
+</sdncadapterworkflow:SDNCAdapterWorkflowResponse>"""
+
+ String sdncAdapterRequest = """
+ <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
+ <SOAP-ENV:Body>
+ <aetgt:SDNCAdapterRequest xmlns:aetgt="http://org.onap/workflow/sdnc/adapter/schema/v1" xmlns:sdncadaptersc="http://org.onap/workflow/sdnc/adapter/schema/v1">
+ <sdncadapter:RequestHeader xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
+ <sdncadapter:RequestId>745b1b50-e39e-4685-9cc8-c71f0bde8bf0</sdncadapter:RequestId>
+ <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
+ <sdncadapter:SvcOperation>services/layer3-service-list/AS%2FVLXM%2F000199%2F%2FSB_INTERNET</sdncadapter:SvcOperation>
+ <sdncadapter:CallbackUrl>http://myhost.com:28080/mso/sdncAdapterCallbackServiceImpl</sdncadapter:CallbackUrl>
+ </sdncadapter:RequestHeader>
+ <sdncadaptersc:RequestData>
+ <rest:payload xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"
+ contentType="text/xml">
+ <service-request xmlns="http://org.onap/so/request/details/schema/v1">
+ <request-information>
+ <request-id>12570a36-7388-4c0a-bec4-189ce3kg9956</request-id>
+ <request-action>GetLayer3ServiceDetailsRequest</request-action>
+ <source>OMX</source>
+ </request-information>
+ <service-information>
+ <service-type>SDN-ETHERNET-INTERNET</service-type>
+ <service-instance-id>PD/VLXM/003717//SW_INTERNET</service-instance-id>
+ </service-information>
+ </service-request>
+</rest:payload>
+ </sdncadaptersc:RequestData></aetgt:SDNCAdapterRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>"""
+
+def sdncAdapterResponse = """<sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1">
+<sdncadapterworkflow:response-data>
+<tag0:CallbackHeader xmlns:tag0="http://org.onap/workflow/sdnc/adapter/schema/v1">
+ <tag0:RequestId>39542e39-ccc3-4d1a-8b79-04ce88526613</tag0:RequestId>
+ <tag0:ResponseCode>404</tag0:ResponseCode>
+ <tag0:ResponseMessage>Error processing request to SDNC. Not Found.
+ https://localhost:8443/restconf/config/L3SDN-API:services/layer3-service-list/MVM%2FVLXP%2F000855%2F%2FShakeout.
+ SDNC Returned-[error-type:application, error-tag:data-missing,
+ error-message:Request could not be completed because the relevant
+ data model content does not exist.]</tag0:ResponseMessage>
+</tag0:CallbackHeader>
+</sdncadapterworkflow:response-data>
+</sdncadapterworkflow:SDNCAdapterWorkflowResponse>
+"""
+
+def workflowErrorResponse = """<aetgt:WorkflowException xmlns:aetgt="http://org.onap/so/workflow/schema/v1">
+ <aetgt:ErrorMessage>Received error from SDN-C: Error processing request to SDNC. Not Found.
+ https://localhost:8443/restconf/config/L3SDN-API:services/layer3-service-list/MVM%2FVLXP%2F000855%2F%2FShakeout.
+ SDNC Returned-[error-type:application, error-tag:data-missing,
+ error-message:Request could not be completed because the relevant
+ data model content does not exist.]</aetgt:ErrorMessage>
+ <aetgt:ErrorCode>5300</aetgt:ErrorCode>
+ <aetgt:SourceSystemErrorCode>404</aetgt:SourceSystemErrorCode>
+ </aetgt:WorkflowException>"""
+
+String workflowErrorResponse1 = """<aetgt:WorkflowException xmlns:aetgt="http://org.onap/so/workflow/schema/v1">
+ <aetgt:ErrorMessage>Invalid Callback Response from SDNC Adapter</aetgt:ErrorMessage>
+ <aetgt:ErrorCode>5300</aetgt:ErrorCode>
+ </aetgt:WorkflowException>"""
+
+String enhancedCallbackRequestData =
+ """<tag0:RequestData xmlns:tag0="http://org.onap/workflow/sdnc/adapter/schema/v1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:type="xs:string"> <layer3-service-list xmlns="com:att:sdnctl:l3api">
+ <service-instance-id>FK/VLXM/003717//SW_INTERNET</service-instance-id>
+ <service-status>
+ <rpc-name>service-configuration-operation</rpc-name>
+ <rpc-action>activate</rpc-action>
+ <request-status>synccomplete</request-status>
+ <final-indicator>N</final-indicator>
+ <l3sdn-action>Layer3ServiceActivateRequest</l3sdn-action>
+ <l3sdn-subaction>SUPP</l3sdn-subaction>
+ <response-timestamp>2015-04-28T21:32:11.386Z</response-timestamp>
+ </service-status>
+ <service-data>
+ <internet-evc-access-information>
+ <ip-version>ds</ip-version>
+ <internet-evc-speed-value>8</internet-evc-speed-value>
+ <internet-evc-speed-units>Mbps</internet-evc-speed-units>
+ </internet-evc-access-information>
+ <vr-lan xmlns="com:att:sdnctl:l3api">
+ <vr-lan-interface>
+ <static-routes>
+ <v6-static-routes>
+ <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address>
+ <v6-static-route-prefix>2001:1890:12e3:2da::</v6-static-route-prefix>
+ <v6-static-route-prefix-length>28</v6-static-route-prefix-length>
+ </v6-static-routes>
+ <v4-static-routes>
+ <v4-static-route-prefix>255.255.252.1</v4-static-route-prefix>
+ <v4-next-hop-address>192.168.1.15</v4-next-hop-address>
+ <v4-static-route-prefix-length>28</v4-static-route-prefix-length>
+ </v4-static-routes>
+ <v6-static-routes>
+ <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address>
+ <v6-static-route-prefix>2001:1890:12e3:2da::</v6-static-route-prefix>
+ <v6-static-route-prefix-length>28</v6-static-route-prefix-length>
+ </v6-static-routes>
+ <v4-static-routes>
+ <v4-static-route-prefix>255.255.252.2</v4-static-route-prefix>
+ <v4-next-hop-address>192.168.1.15</v4-next-hop-address>
+ <v4-static-route-prefix-length>28</v4-static-route-prefix-length>
+ </v4-static-routes>
+ <v4-static-routes>
+ <v4-static-route-prefix>255.255.252.3</v4-static-route-prefix>
+ <v4-next-hop-address>192.168.1.15</v4-next-hop-address>
+ <v4-static-route-prefix-length>28</v4-static-route-prefix-length>
+ </v4-static-routes>
+ </static-routes>
+ <dhcp>
+ <v6-dhcp-server-enabled>N</v6-dhcp-server-enabled>
+ <v4-dhcp-server-enabled>Y</v4-dhcp-server-enabled>
+ <use-v6-default-pool>N</use-v6-default-pool>
+ <excluded-v4-dhcp-addresses-from-default-pool>
+ <excluded-v4-address>192.168.1.7</excluded-v4-address>
+ </excluded-v4-dhcp-addresses-from-default-pool>
+ <excluded-v4-dhcp-addresses-from-default-pool>
+ <excluded-v4-address>192.168.1.8</excluded-v4-address>
+ </excluded-v4-dhcp-addresses-from-default-pool>
+ <v4-dhcp-pools>
+ <v4-dhcp-relay-next-hop-address>1.1.1.1</v4-dhcp-relay-next-hop-address>
+ <v4-dhcp-pool-prefix-length>28</v4-dhcp-pool-prefix-length>
+ <excluded-v4-addresses>
+ <excluded-v4-address>192.168.1.5</excluded-v4-address>
+ </excluded-v4-addresses>
+ <v4-dhcp-relay-gateway-address>2.2.2.1</v4-dhcp-relay-gateway-address>
+ <excluded-v4-addresses>
+ <excluded-v4-address>192.168.1.6</excluded-v4-address>
+ </excluded-v4-addresses>
+ <v4-dhcp-pool-prefix>192.155.2.3</v4-dhcp-pool-prefix>
+ </v4-dhcp-pools>
+ <v4-dhcp-pools>
+ <v4-dhcp-relay-next-hop-address>1.1.1.2</v4-dhcp-relay-next-hop-address>
+ <v4-dhcp-pool-prefix-length>28</v4-dhcp-pool-prefix-length>
+ <excluded-v4-addresses>
+ <excluded-v4-address>192.168.1.6</excluded-v4-address>
+ </excluded-v4-addresses>
+ <v4-dhcp-relay-gateway-address>2.2.2.2</v4-dhcp-relay-gateway-address>
+ <excluded-v4-addresses>
+ <excluded-v4-address>192.168.1.7</excluded-v4-address>
+ </excluded-v4-addresses>
+ <v4-dhcp-pool-prefix>192.155.2.4</v4-dhcp-pool-prefix>
+ </v4-dhcp-pools>
+ <use-v4-default-pool>Y</use-v4-default-pool>
+ <excluded-v6-dhcp-addresses-from-default-pool>
+ <excluded-v6-address>1:5</excluded-v6-address>
+ </excluded-v6-dhcp-addresses-from-default-pool>
+ <excluded-v6-dhcp-addresses-from-default-pool>
+ <excluded-v6-address>1:6</excluded-v6-address>
+ </excluded-v6-dhcp-addresses-from-default-pool>
+ <v6-dhcp-pools>
+ <v6-dhcp-relay-next-hop-address>4:4</v6-dhcp-relay-next-hop-address>
+ <v6-dhcp-pool-prefix-length>28</v6-dhcp-pool-prefix-length>
+ <excluded-v6-addresses>
+ <excluded-v6-address>1:1</excluded-v6-address>
+ </excluded-v6-addresses>
+ <v6-dhcp-relay-gateway-address>3:3</v6-dhcp-relay-gateway-address>
+ <excluded-v6-addresses>
+ <excluded-v6-address>2:2</excluded-v6-address>
+ </excluded-v6-addresses>
+ <v6-dhcp-pool-prefix>0:0</v6-dhcp-pool-prefix>
+ </v6-dhcp-pools>
+ <v6-dhcp-pools>
+ <v6-dhcp-relay-next-hop-address>4:4</v6-dhcp-relay-next-hop-address>
+ <v6-dhcp-pool-prefix-length>28</v6-dhcp-pool-prefix-length>
+ <excluded-v6-addresses>
+ <excluded-v6-address>1:1</excluded-v6-address>
+ </excluded-v6-addresses>
+ <v6-dhcp-relay-gateway-address>3:3</v6-dhcp-relay-gateway-address>
+ <excluded-v6-addresses>
+ <excluded-v6-address>2:2</excluded-v6-address>
+ </excluded-v6-addresses>
+ <v6-dhcp-pool-prefix>0:0</v6-dhcp-pool-prefix>
+ </v6-dhcp-pools>
+ </dhcp>
+ <firewall-lite>
+ <stateful-firewall-lite-v6-enabled>N</stateful-firewall-lite-v6-enabled>
+ <stateful-firewall-lite-v4-enabled>Y</stateful-firewall-lite-v4-enabled>
+ <v4-firewall-packet-filters>
+ <v4-firewall-prefix>0.0.0.1</v4-firewall-prefix>
+ <v4-firewall-prefix-length>1</v4-firewall-prefix-length>
+ <allow-icmp-ping>Y</allow-icmp-ping>
+ <udp-ports>
+ <port-number>1</port-number>
+ </udp-ports>
+ <tcp-ports>
+ <port-number>1</port-number>
+ </tcp-ports>
+ </v4-firewall-packet-filters>
+ <v4-firewall-packet-filters>
+ <v4-firewall-prefix>0.0.0.2</v4-firewall-prefix>
+ <v4-firewall-prefix-length>2</v4-firewall-prefix-length>
+ <allow-icmp-ping>Y</allow-icmp-ping>
+ <udp-ports>
+ <port-number>2</port-number>
+ </udp-ports>
+ <tcp-ports>
+ <port-number>2</port-number>
+ </tcp-ports>
+ </v4-firewall-packet-filters>
+ <v6-firewall-packet-filters>
+ <v6-firewall-prefix>:</v6-firewall-prefix>
+ <v6-firewall-prefix-length>0</v6-firewall-prefix-length>
+ <allow-icmp-ping>Y</allow-icmp-ping>
+ <udp-ports>
+ <port-number>3</port-number>
+ </udp-ports>
+ <tcp-ports>
+ <port-number>3</port-number>
+ </tcp-ports>
+ </v6-firewall-packet-filters>
+ <v6-firewall-packet-filters>
+ <v6-firewall-prefix>:</v6-firewall-prefix>
+ <v6-firewall-prefix-length>1</v6-firewall-prefix-length>
+ <allow-icmp-ping>Y</allow-icmp-ping>
+ <udp-ports>
+ <port-number>4</port-number>
+ </udp-ports>
+ <tcp-ports>
+ <port-number>4</port-number>
+ </tcp-ports>
+ </v6-firewall-packet-filters>
+ </firewall-lite>
+ <pat>
+ <v4-pat-pools>
+ <v4-pat-pool-prefix>192.168.1.44</v4-pat-pool-prefix>
+ <v4-pat-pool-next-hop-address>192.168.1.5</v4-pat-pool-next-hop-address>
+ <v4-pat-pool-prefix-length>0</v4-pat-pool-prefix-length>
+ </v4-pat-pools>
+ <use-v4-default-pool>Y</use-v4-default-pool>
+ <v4-pat-enabled>N</v4-pat-enabled>
+ <v4-pat-pools>
+ <v4-pat-pool-prefix>192.168.1.45</v4-pat-pool-prefix>
+ <v4-pat-pool-next-hop-address>192.168.1.6</v4-pat-pool-next-hop-address>
+ <v4-pat-pool-prefix-length>28</v4-pat-pool-prefix-length>
+ </v4-pat-pools>
+ </pat>
+ <nat>
+ <v4-nat-enabled>Y</v4-nat-enabled>
+ <v4-nat-mapping-entries>
+ <v4-nat-internal>0.0.0.0</v4-nat-internal>
+ <v4-nat-next-hop-address>0.0.0.0</v4-nat-next-hop-address>
+ <v4-nat-external>0.0.0.0</v4-nat-external>
+ </v4-nat-mapping-entries>
+ <v4-nat-mapping-entries>
+ <v4-nat-internal>0.0.0.1</v4-nat-internal>
+ <v4-nat-next-hop-address>0.0.0.1</v4-nat-next-hop-address>
+ <v4-nat-external>0.0.0.1</v4-nat-external>
+ </v4-nat-mapping-entries>
+ </nat>
+ <vr-designation>primary</vr-designation>
+ <v4-vce-loopback-address>162.200.3.144</v4-vce-loopback-address>
+ <v6-vr-lan-prefix-length>64</v6-vr-lan-prefix-length>
+ <v6-vce-wan-address>2001:1890:12e3:2da::</v6-vce-wan-address>
+ <v6-vr-lan-prefix>2620:0:10d0:f:ffff:ffff:ffff:fffe</v6-vr-lan-prefix>
+ <v4-vr-lan-prefix-length>24</v4-vr-lan-prefix-length>
+ <v4-vr-lan-prefix>10.192.27.254</v4-vr-lan-prefix>
+ <v4-public-lan-prefixes>
+ <t-provided-v4-lan-public-prefixes>
+ <request-index>1</request-index>
+ <v4-next-hop-address>192.168.1.2</v4-next-hop-address>
+ <v4-lan-public-prefix>192.168.1.1</v4-lan-public-prefix>
+ <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length>
+ </t-provided-v4-lan-public-prefixes>
+ <t-provided-v4-lan-public-prefixes>
+ <request-index>1</request-index>
+ <v4-next-hop-address>192.168.1.72</v4-next-hop-address>
+ <v4-lan-public-prefix>192.168.1.71</v4-lan-public-prefix>
+ <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length>
+ </t-provided-v4-lan-public-prefixes>
+ <t-provided-v4-lan-public-prefixes>
+ <request-index>1</request-index>
+ <v4-next-hop-address>192.168.1.68</v4-next-hop-address>
+ <v4-lan-public-prefix>192.168.1.67</v4-lan-public-prefix>
+ <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length>
+ </t-provided-v4-lan-public-prefixes>
+ </v4-public-lan-prefixes>
+ <v6-public-lan-prefixes>
+ <t-provided-v6-lan-public-prefixes>
+ <request-index>1</request-index>
+ <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address>
+ <v6-lan-public-prefix>2001:1890:12e3:2da::</v6-lan-public-prefix>
+ <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length>
+ </t-provided-v6-lan-public-prefixes>
+ <t-provided-v6-lan-public-prefixes>
+ <request-index>1</request-index>
+ <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address>
+ <v6-lan-public-prefix>2001:1890:12e3:3da::</v6-lan-public-prefix>
+ <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length>
+ </t-provided-v6-lan-public-prefixes>
+ <t-provided-v6-lan-public-prefixes>
+ <request-index>1</request-index>
+ <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address>
+ <v6-lan-public-prefix>2001:1890:12e3:4da::</v6-lan-public-prefix>
+ <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length>
+ </t-provided-v6-lan-public-prefixes>
+ </v6-public-lan-prefixes>
+ </vr-lan-interface>
+ <routing-protocol>none</routing-protocol>
+ </vr-lan>
+<ucpe-vms-service-information>
+ <transport-service-information>
+ <transport-service-type>AVPN</transport-service-type>
+ <access-circuit-info>
+ <access-circuit-id>1</access-circuit-id>
+ <dual-mode>Active</dual-mode>
+ </access-circuit-info>
+ <access-circuit-info>
+ <access-circuit-id>2</access-circuit-id>
+ <dual-mode>Standby</dual-mode>
+ </access-circuit-info>
+ </transport-service-information>
+ <ucpe-information>
+ <ucpe-host-name>hostname</ucpe-host-name>
+ <ucpe-activation-code>activecode</ucpe-activation-code>
+ <out-of-band-management-modem>OOB</out-of-band-management-modem>
+ </ucpe-information>
+ <vnf-list>
+ <vnf-information>
+ <vnf-instance-id>1</vnf-instance-id>
+ <vnf-sequence-number>1</vnf-sequence-number>
+ <vnf-type>ZZ</vnf-type>
+ <vnf-vendor>JUNIPER</vnf-vendor>
+ <vnf-model>MODEL1</vnf-model>
+ <vnf-id>1</vnf-id>
+ <prov-status>1</prov-status>
+ <operational-state>1</operational-state>
+ <orchestration-status>1</orchestration-status>
+ <equipment-role>1</equipment-role>
+ </vnf-information>
+ <vnf-information>
+ <vnf-instance-id>2</vnf-instance-id>
+ <vnf-sequence-number>2</vnf-sequence-number>
+ <vnf-type>HY</vnf-type>
+ <vnf-vendor>JUNIPER</vnf-vendor>
+ <vnf-model>MODEL2</vnf-model>
+ <vnf-id>2</vnf-id>
+ <prov-status>2</prov-status>
+ <operational-state>2</operational-state>
+ <orchestration-status>2</orchestration-status>
+ <equipment-role>2</equipment-role>
+ </vnf-information>
+ </vnf-list>
+ </ucpe-vms-service-information>
+ <request-information>
+ <request-action>Layer3ServiceActivateRequest</request-action>
+ <order-number>4281555</order-number>
+ <request-id>155415ab-b4a7-4382-b4c6-d17d9sm42855</request-id>
+ <notification-url>https://csi-tst-q22.it.com:22443/Services/com/cingular/csi/sdn/SendManagedNetworkStatusNotification.jws</notification-url>
+ <source>OMX</source>
+ <order-version>1</order-version>
+ </request-information>
+ <sdnc-request-header>
+ <svc-action>activate</svc-action>
+ <svc-notification-url>https://localhost:8443/adapters/rest/SDNCNotify</svc-notification-url>
+ <svc-request-id>5b1f3c5d-cdf9-488d-8a4b-d3f1229d7760</svc-request-id>
+ </sdnc-request-header>
+ <l2-homing-information>
+ <topology>MultiPoint</topology>
+ <preferred-aic-clli>MTSNJA4LCP1</preferred-aic-clli>
+ <evc-name>AS/VLXM/003717//SW</evc-name>
+ </l2-homing-information>
+ <service-information>
+ <service-instance-id>FK/VLXM/003717//SW_INTERNET</service-instance-id>
+ <subscriber-name>ST E2E Test42855_1300004281555</subscriber-name>
+ <service-type>SDN-ETHERNET-INTERNET</service-type>
+ </service-information>
+ <internet-service-change-details>
+ <internet-evc-speed-value>10</internet-evc-speed-value>
+ <internet-evc-speed-units>Kbps</internet-evc-speed-units>
+ <t-provided-v4-lan-public-prefixes>
+ <request-index>1</request-index>
+ <v4-next-hop-address>192.168.1.15</v4-next-hop-address>
+ <v4-lan-public-prefix>192.168.1.15</v4-lan-public-prefix>
+ <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length>
+ </t-provided-v4-lan-public-prefixes>
+ <t-provided-v4-lan-public-prefixes>
+ <request-index>2</request-index>
+ <v4-next-hop-address>192.168.1.16</v4-next-hop-address>
+ <v4-lan-public-prefix>192.168.1.16</v4-lan-public-prefix>
+ <v4-lan-public-prefix-length>28</v4-lan-public-prefix-length>
+ </t-provided-v4-lan-public-prefixes>
+ <t-provided-v6-lan-public-prefixes>
+ <request-index>1</request-index>
+ <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address>
+ <v6-lan-public-prefix>2001:1890:12e3:2da::</v6-lan-public-prefix>
+ <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length>
+ </t-provided-v6-lan-public-prefixes>
+ <t-provided-v6-lan-public-prefixes>
+ <request-index>1</request-index>
+ <v6-next-hop-address>2001:1890:12e3:2da::</v6-next-hop-address>
+ <v6-lan-public-prefix>2001:1890:12e3:2da::</v6-lan-public-prefix>
+ <v6-lan-public-prefix-length>28</v6-lan-public-prefix-length>
+ </t-provided-v6-lan-public-prefixes>
+ </internet-service-change-details>
+ </service-data>
+ </layer3-service-list>
+</tag0:RequestData>
+"""
+
+def sdncAdapterResponseEmpty =
+"""<sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1">
+ <sdncadapterworkflow:response-data/>
+</sdncadapterworkflow:SDNCAdapterWorkflowResponse>"""
+
+def sdncAdapterResponseError =
+"""<sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
+ xmlns:tag0="http://org.onap/workflow/sdnc/adapter/schema/v1">
+ <sdncadapterworkflow:response-data>
+ <tag0:CallbackHeader>
+ <tag0:RequestId>39542e39-ccc3-4d1a-8b79-04ce88526613</tag0:RequestId>
+ <tag0:ResponseCode>404</tag0:ResponseCode>
+ <tag0:ResponseMessage>Error processing request to SDNC. Not Found.
+ https://localhost:8443/restconf/config/L3SDN-API:services/layer3-service-list/MVM%2FVLXP%2F000855%2F%2FShakeout.
+ SDNC Returned-[error-type:application, error-tag:data-missing,
+ error-message:Request could not be completed because the relevant
+ data model content does not exist.]</tag0:ResponseMessage>
+ </tag0:CallbackHeader>
+ </sdncadapterworkflow:response-data>
+</sdncadapterworkflow:SDNCAdapterWorkflowResponse>"""
+
+
+ @Test
+ public void testPreProcessRequest() {
+
+ String sdncAdapterWorkflowRequest = FileUtil.readResourceFile("__files/SDN-ETHERNET-INTERNET/SDNCAdapterV1/sdncadapterworkflowrequest.xml");
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B")
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
+ when(mockExecution.getVariable("sdncAdapterWorkflowRequest")).thenReturn(sdncAdapterWorkflowRequest)
+ when(mockExecution.getVariable("mso.workflow.sdncadapter.callback")).thenReturn("http://someurl.someting.com:28080/mso/sdncAdapterCallbackServiceImpl")
+ when(mockExecution.getVariable("mso.use.qualified.host")).thenReturn("true")
+
+ when(mockExecution.getProcessInstanceId()).thenReturn("745b1b50-e39e-4685-9cc8-c71f0bde8bf0")
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+
+
+ SDNCAdapter sdncAdapter = new SDNCAdapter()
+ sdncAdapter.preProcessRequest(mockExecution)
+
+ MockitoDebuggerImpl debugger = new MockitoDebuggerImpl()
+ debugger.printInvocations(mockExecution)
+
+
+ verify(mockExecution).setVariable("prefix","SDNCA_")
+ verify(mockExecution).setVariable("sdncAdapterResponse","")
+ verify(mockExecution).setVariable("asynchronousResponseTimeout",false)
+ verify(mockExecution).setVariable("continueListening",false)
+ verify(mockExecution).setVariable("BasicAuthHeaderValue","Basic cGFzc3dvcmQ=")
+ verify(mockExecution).setVariable("serviceConfigActivate",false)
+ verify(mockExecution).setVariable("SDNCA_requestId", "745b1b50-e39e-4685-9cc8-c71f0bde8bf0")
+ verify(mockExecution).setVariable("SDNCA_SuccessIndicator",false)
+ verify(mockExecution).setVariable("source","")
+ verify(mockExecution).setVariable("SDNCA_InterimNotify",false)
+ verify(mockExecution).setVariable("sdncAdapterRequest", sdncAdapterRequest)
+ }
+
+ @Test
+ public void testProcessResponse()
+ {
+ String sdncAdapterCallbackResponse = FileUtil.readResourceFile("__files/SDN-ETHERNET-INTERNET/SDNCAdapterV1mock/sdncadaptercallbackrequest.xml");
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("sdncAdapterCallbackRequest")).thenReturn(sdncAdapterCallbackResponse)
+ SDNCAdapter sdncAdapter = new SDNCAdapter()
+ sdncAdapter.postProcessResponse(mockExecution)
+
+// MockitoDebuggerImpl debugger = new MockitoDebuggerImpl()
+// debugger.printInvocations(mockExecution)
+
+ verify(mockExecution,times(2)).getVariable("sdncAdapterCallbackRequest")
+ verify(mockExecution).setVariable("enhancedCallbackRequestData",enhancedCallbackRequestData)
+ verify(mockExecution).setVariable("sdncAdapterResponse",workflowResponse)
+ verify(mockExecution).setVariable("continueListening",false)
+
+ }
+
+ @Test
+ public void testProcessResponse_ErrorCase_404()
+ {
+ String sdncAdapterCallbackErrorResponse = FileUtil.readResourceFile("sdncadaptercallbackrequest_404CallBack.xml");
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("sdncAdapterCallbackRequest")).thenReturn(sdncAdapterCallbackErrorResponse)
+ SDNCAdapter sdncAdapter = new SDNCAdapter()
+ sdncAdapter.postProcessResponse(mockExecution)
+
+ verify(mockExecution,times(2)).getVariable("sdncAdapterCallbackRequest")
+ verify(mockExecution).setVariable("sdncAdapterResponse", sdncAdapterResponseError)
+ verify(mockExecution).setVariable("enhancedCallbackRequestData", "")
+ verify(mockExecution).setVariable("continueListening",false)
+
+ }
+
+ @Test
+ public void testProcessResponse_ErrorCase_InvalidCallback()
+ {
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("sdncAdapterCallbackRequest")).thenReturn("<h1>Service Unavailable</h1>")
+ SDNCAdapter sdncAdapter = new SDNCAdapter()
+ sdncAdapter.postProcessResponse(mockExecution)
+
+ verify(mockExecution,times(2)).getVariable("sdncAdapterCallbackRequest")
+ verify(mockExecution).setVariable("sdncAdapterResponse", sdncAdapterResponseEmpty)
+ verify(mockExecution).setVariable("enhancedCallbackRequestData", "")
+ verify(mockExecution).setVariable("continueListening",false)
+
+ }
+
+ @Test
+ public void postProcessResponse()
+ {
+
+ String SDNCAdapterCallbackRequest =
+ """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<SDNCAdapterCallbackRequest
+ xmlns="http://org.onap/workflow/sdnc/adapter/schema/v1">
+ <CallbackHeader>
+ <RequestId>3bb02798-b344-4d28-9bca-1f029954d1c9</RequestId>
+ <ResponseCode>404</ResponseCode>
+ <ResponseMessage>Error processing request to SDNC. Not Found.
+ https://localhost:8443/restconf/config/L3SDN-API:services/layer3-service-list/85%2FCSIP%2F141203%2FPT_CSI9999998693.
+ SDNC Returned-[error-type:application, error-tag:data-missing,
+ error-message:Request could not be completed because the relevant
+ data model content does not exist ]</ResponseMessage>
+ </CallbackHeader>
+</SDNCAdapterCallbackRequest>"""
+
+ String sdncAdapterResponse =
+ """<sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
+ xmlns:tag0="http://org.onap/workflow/sdnc/adapter/schema/v1">
+ <sdncadapterworkflow:response-data>
+ <tag0:CallbackHeader>
+ <tag0:RequestId>3bb02798-b344-4d28-9bca-1f029954d1c9</tag0:RequestId>
+ <tag0:ResponseCode>404</tag0:ResponseCode>
+ <tag0:ResponseMessage>Error processing request to SDNC. Not Found.
+ https://localhost:8443/restconf/config/L3SDN-API:services/layer3-service-list/85%2FCSIP%2F141203%2FPT_CSI9999998693.
+ SDNC Returned-[error-type:application, error-tag:data-missing,
+ error-message:Request could not be completed because the relevant
+ data model content does not exist ]</tag0:ResponseMessage>
+ </tag0:CallbackHeader>
+ </sdncadapterworkflow:response-data>
+</sdncadapterworkflow:SDNCAdapterWorkflowResponse>"""
+
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("sdncAdapterCallbackRequest")).thenReturn(SDNCAdapterCallbackRequest)
+ SDNCAdapter sdncAdapter = new SDNCAdapter()
+ sdncAdapter.postProcessResponse(mockExecution)
+
+ verify(mockExecution,times(2)).getVariable("sdncAdapterCallbackRequest")
+ verify(mockExecution).setVariable("sdncAdapterResponse", sdncAdapterResponse)
+ verify(mockExecution).setVariable("enhancedCallbackRequestData", "")
+ verify(mockExecution).setVariable("continueListening",false)
+
+ }
+
+} \ No newline at end of file
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtilsTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtilsTest.groovy
new file mode 100644
index 0000000000..803e2b03a3
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterUtilsTest.groovy
@@ -0,0 +1,191 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*
+
+import org.junit.Before
+import org.junit.Ignore
+import org.junit.Test
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
+
+import org.onap.so.bpmn.mock.FileUtil
+
+public class SDNCAdapterUtilsTest {
+
+ private def map
+ private ExecutionEntity svcex
+ private WorkflowException wfex
+ private AbstractServiceTaskProcessor tp
+ private String resp
+ private SDNCAdapterUtils utils
+
+ @Before
+ public void init()
+ {
+ map = new HashMap<String,Object>()
+ svcex = mock(ExecutionEntity.class)
+ wfex = null
+ tp = new AbstractServiceTaskProcessor() {
+ @Override
+ public void preProcessRequest(DelegateExecution execution) {
+ }
+ };
+ utils = new SDNCAdapterUtils(tp)
+
+ // svcex gets its variables from "map"
+ when(svcex.getVariable(any())).thenAnswer(
+ { invocation ->
+ return map.get(invocation.getArgumentAt(0, String.class)) })
+
+ // svcex puts its variables into "map"
+ when(svcex.setVariable(any(), any())).thenAnswer(
+ { invocation ->
+ return map.put(
+ invocation.getArgumentAt(0, String.class),
+ invocation.getArgumentAt(1, String.class)) })
+
+ map.put("isDebugLogEnabled", "true")
+ map.put("prefix", "mypfx-")
+ map.put("testProcessKey", "mykey")
+ }
+
+ @Test
+ public void testValidateSDNCResponse_Success_NoCode() {
+ resp = """<no-response/>"""
+
+ utils.validateSDNCResponse(svcex, resp, wfex, true)
+
+ assertEquals(true, map.get("mypfx-sdncResponseSuccess"))
+ assertEquals("0", map.get("mypfx-sdncRequestDataResponseCode"))
+ assertFalse(map.containsKey("WorkflowException"))
+ }
+
+ @Test
+ public void testValidateSDNCResponse_200() {
+ utils.validateSDNCResponse(svcex, makeResp("200", "OK", ""), wfex, true)
+
+ assertEquals(true, map.get("mypfx-sdncResponseSuccess"))
+ assertEquals("200", map.get("mypfx-sdncRequestDataResponseCode"))
+ assertFalse(map.containsKey("WorkflowException"))
+ }
+
+ @Test
+ public void testValidateSDNCResponse_408() {
+ try {
+ utils.validateSDNCResponse(svcex, makeResp("408", "failed", ""), wfex, true)
+
+ // this has been commented out as, currently, the code doesn't
+ // throw an exception in this case
+// fail("missing exception")
+
+ } catch(BpmnError ex) {
+ ex.printStackTrace()
+ }
+
+ assertEquals(false, map.get("mypfx-sdncResponseSuccess"))
+ assertEquals("408", map.get("mypfx-sdncRequestDataResponseCode"))
+
+ wfex = map.get("WorkflowException")
+ assertNotNull(wfex)
+
+ assertEquals(5320, wfex.getErrorCode())
+ assertEquals("Received error from SDN-C: failed", wfex.getErrorMessage())
+ }
+
+ @Test
+ public void testValidateSDNCResponse_408_200() {
+
+ utils.validateSDNCResponse(svcex, makeResp("408", "failed", makeReq("200", "ok")), wfex, true)
+
+ assertEquals(true , map.get("mypfx-sdncResponseSuccess"))
+ assertEquals("200", map.get("mypfx-sdncRequestDataResponseCode"))
+ assertFalse(map.containsKey("WorkflowException"))
+ }
+
+ @Test
+ public void testValidateSDNCResponse_408_200_WithEmbeddedLt() {
+
+ utils.validateSDNCResponse(svcex, makeResp("408", "failed", makeReq("200", "<success> message")), wfex, true)
+
+ assertEquals(true, map.get("mypfx-sdncResponseSuccess"))
+ assertEquals("200", map.get("mypfx-sdncRequestDataResponseCode"))
+ assertFalse(map.containsKey("WorkflowException"))
+ }
+
+ @Test
+ public void testUpdateHomingInfo() {
+ String actual = utils.updateHomingInfo(null, "AIC3.0")
+ println actual
+ assertEquals("<l2-homing-information><aic-version>AIC3.0</aic-version></l2-homing-information>", actual)
+ }
+
+ @Test
+ public void testUpdateHomingInfo2() {
+ String homingInfo = "<l2-homing-information><preferred-aic-clli>TESTCLLI</preferred-aic-clli></l2-homing-information>"
+ String actual = utils.updateHomingInfo(homingInfo, "AIC3.0")
+ println actual
+ assertEquals("<l2-homing-information><preferred-aic-clli>TESTCLLI</preferred-aic-clli><aic-version>AIC3.0</aic-version></l2-homing-information>", actual)
+ }
+
+ private String makeResp(String respcode, String respmsg, String reqdata) {
+ def rc = respcode
+ def rm = respmsg
+
+ return """
+<sdncadapterworkflow:SDNCAdapterWorkflowResponse xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
+ xmlns:tag0="http://org.onap/workflow/sdnc/adapter/schema/v1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <sdncadapterworkflow:response-data>
+ <tag0:CallbackHeader>
+ <tag0:RequestId>myreq</tag0:RequestId>
+ <tag0:ResponseCode>${MsoUtils.xmlEscape(rc)}</tag0:ResponseCode>
+ <tag0:ResponseMessage>${MsoUtils.xmlEscape(rm)}</tag0:ResponseMessage>
+ </tag0:CallbackHeader>
+ ${reqdata}
+ </sdncadapterworkflow:response-data>
+</sdncadapterworkflow:SDNCAdapterWorkflowResponse>
+"""
+
+ }
+
+ private String makeReq(String respcode, String respmsg) {
+ def rc = respcode
+ def rm = respmsg
+
+ def output = """
+<output xmlns="org:onap:sdnc:northbound:generic-resource">
+ <svc-request-id>8b46e36e-b44f-4085-9404-427be1bc8a3</svc-request-id>
+ <response-code>${MsoUtils.xmlEscape(rc)}</response-code>
+ <response-message>${MsoUtils.xmlEscape(rm)}</response-message>
+ <ack-final-indicator>Y</ack-final-indicator>
+</output>
+"""
+ output = output
+
+ return """<tag0:RequestData xsi:type="xs:string">${MsoUtils.xmlEscape(output)}</tag0:RequestData>"""
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1Test.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1Test.groovy
new file mode 100644
index 0000000000..b093aaa491
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/SniroHomingV1Test.groovy
@@ -0,0 +1,196 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule
+import org.camunda.bpm.engine.ProcessEngineServices
+import org.camunda.bpm.engine.RepositoryService
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.camunda.bpm.engine.repository.ProcessDefinition
+import org.junit.Assert
+import org.junit.Before
+import org.junit.Ignore
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.mockito.MockitoAnnotations
+import org.mockito.runners.MockitoJUnitRunner
+import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.bpmn.core.domain.AllottedResource
+import org.onap.so.bpmn.core.domain.ModelInfo
+import org.onap.so.bpmn.core.domain.ServiceDecomposition
+import org.onap.so.bpmn.core.domain.VnfResource
+
+import static com.github.tomakehurst.wiremock.client.WireMock.*
+import static org.mockito.Mockito.*
+
+@RunWith(MockitoJUnitRunner.class)
+@Ignore
+class SniroHomingV1Test {
+ String subsInfo = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberCommonSiteId\": \"DALTX0101\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}"
+ ServiceDecomposition serviceDecomp
+
+ {
+ serviceDecomp = new ServiceDecomposition("{\"serviceResources\":{}}", "123")
+ ModelInfo modelInfo = new ModelInfo()
+ serviceDecomp.modelInfo = modelInfo
+
+ AllottedResource allottedResource = new AllottedResource()
+ allottedResource.setModelInfo(modelInfo)
+ List allottedResourceList = new ArrayList()
+ allottedResourceList.add(allottedResource)
+
+ VnfResource vnfResource = new VnfResource()
+ vnfResource.setModelInfo(modelInfo)
+ List vnfResourceList = new ArrayList()
+ vnfResourceList.add(vnfResource)
+
+ serviceDecomp.serviceAllottedResources = allottedResourceList
+ serviceDecomp.setVnfResources(vnfResourceList)
+ }
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(28090)
+
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this)
+ }
+
+ @Test
+ public void testCallSniro() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("msoRequestId")).thenReturn("12345")
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345")
+ when(mockExecution.getVariable("subscriberInfo")).thenReturn(subsInfo)
+ when(mockExecution.getVariable("serviceDecomposition")).thenReturn(serviceDecomp)
+ when(mockExecution.getVariable("mso.sniro.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B")
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
+ when(mockExecution.getVariable("mso.adapters.workflow.message.endpoint")).thenReturn('http://localhost:18080/workflows/messages/message/')
+ when(mockExecution.getVariable("mso.service.agnostic.sniro.endpoint")).thenReturn("/sniro")
+ when(mockExecution.getVariable("mso.service.agnostic.sniro.host")).thenReturn("http://localhost:28090")
+ when(mockExecution.getVariable("mso.workflow.GenericPutVnf.aai.generic-vnf.uri")).thenReturn("/aai/v9/network/generic-vnfs/generic-vnf")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+
+ mockData()
+
+ SniroHomingV1 obj = new SniroHomingV1()
+ obj.callSniro(mockExecution)
+
+ Mockito.verify(mockExecution, times(10)).setVariable(captor.capture(), captor.capture())
+ Assert.assertEquals(200, captor.getAllValues().get(17))
+
+ }
+
+ @Test
+ public void testCallSniroMissingAuth() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("msoRequestId")).thenReturn("12345")
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345")
+ when(mockExecution.getVariable("subscriberInfo")).thenReturn(subsInfo)
+ when(mockExecution.getVariable("serviceDecomposition")).thenReturn(serviceDecomp)
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
+ when(mockExecution.getVariable("mso.adapters.workflow.message.endpoint")).thenReturn('http://localhost:18080/workflows/messages/message/')
+ when(mockExecution.getVariable("mso.service.agnostic.sniro.endpoint")).thenReturn("/sniro")
+ when(mockExecution.getVariable("mso.service.agnostic.sniro.host")).thenReturn("http://localhost:28090")
+ when(mockExecution.getVariable("mso.workflow.GenericPutVnf.aai.generic-vnf.uri")).thenReturn("/aai/v9/network/generic-vnfs/generic-vnf")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+
+ mockData()
+
+ try {
+ SniroHomingV1 obj = new SniroHomingV1()
+ obj.callSniro(mockExecution)
+ } catch (Exception ex) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+ Mockito.verify(mockExecution, times(4)).setVariable(captor.capture(), captor.capture())
+ WorkflowException workflowException = captor.getValue()
+ Assert.assertEquals(401, workflowException.getErrorCode())
+ Assert.assertEquals("Internal Error - BasicAuth value null", workflowException.getErrorMessage())
+ }
+
+ @Test
+ public void testCallSniroHostNull() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("msoRequestId")).thenReturn("12345")
+ when(mockExecution.getVariable("serviceInstanceId")).thenReturn("12345")
+ when(mockExecution.getVariable("subscriberInfo")).thenReturn(subsInfo)
+ when(mockExecution.getVariable("serviceDecomposition")).thenReturn(serviceDecomp)
+ when(mockExecution.getVariable("mso.sniro.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B")
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
+ when(mockExecution.getVariable("mso.adapters.workflow.message.endpoint")).thenReturn('http://localhost:18080/workflows/messages/message/')
+ when(mockExecution.getVariable("mso.service.agnostic.sniro.endpoint")).thenReturn("/sniro")
+ when(mockExecution.getVariable("mso.service.agnostic.sniro.host")).thenReturn(null)
+ when(mockExecution.getVariable("mso.workflow.GenericPutVnf.aai.generic-vnf.uri")).thenReturn("/aai/v9/network/generic-vnfs/generic-vnf")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+
+ mockData()
+ try {
+ SniroHomingV1 obj = new SniroHomingV1()
+ obj.callSniro(mockExecution)
+ } catch (Exception ex) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+ Mockito.verify(mockExecution, times(9)).setVariable(captor.capture(), captor.capture())
+ WorkflowException workflowException = captor.getValue()
+ Assert.assertEquals(2500, workflowException.getErrorCode())
+ Assert.assertEquals("Internal Error - Occured in Homing CallSniro: org.apache.http.client.ClientProtocolException", workflowException.getErrorMessage())
+ }
+
+ private static ExecutionEntity setupMock() {
+ ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
+ when(mockProcessDefinition.getKey()).thenReturn("Homing")
+ RepositoryService mockRepositoryService = mock(RepositoryService.class)
+ when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
+ when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("Homing")
+ 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("Homing")
+ when(mockExecution.getProcessInstanceId()).thenReturn("Homing")
+ when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
+ when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition)
+
+ return mockExecution
+ }
+
+ private static void mockData() {
+ stubFor(post(urlMatching(".*/sniro"))
+ .willReturn(aResponse()
+ .withStatus(200)
+ .withBody("")))
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/TrinityExceptionUtilTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/TrinityExceptionUtilTest.groovy
new file mode 100644
index 0000000000..52f59a3fad
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/TrinityExceptionUtilTest.groovy
@@ -0,0 +1,201 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import org.junit.Assert
+import org.junit.Ignore
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+
+
+
+import static org.mockito.Mockito.*
+
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.junit.Before
+import org.junit.runner.RunWith
+import org.mockito.MockitoAnnotations
+import org.mockito.internal.debugging.MockitoDebuggerImpl
+import org.mockito.runners.MockitoJUnitRunner
+import org.onap.so.bpmn.common.scripts.TrinityExceptionUtil;
+@RunWith(MockitoJUnitRunner.class)
+import org.junit.Test
+
+class TrinityExceptionUtilTest {
+
+ def aotsFault ="""<n1:Fault xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:n1="http://csi.cingular.com/CSI/Namespaces/OneTicketingSystem/InfrastructureCommon/Types/Public/SoapFault.xsd" xmlns:cer="http://csi.cingular.com/CSI/Namespaces/OneTicketingSystem/InfrastructureCommon/Types/Public/ErrorResponse.xsd" xsi:schemaLocation="http://csi.cingular.com/CSI/Namespaces/OneTicketingSystem/InfrastructureCommon/Types/Public/SoapFault.xsd SoapFault-CDM.xsd">
+ <n1:faultcode>xml:space</n1:faultcode>
+ <n1:faultstring>String</n1:faultstring>
+ <n1:faultactor>http://test.com</n1:faultactor>
+ <n1:detail>
+ <n1:CSIApplicationException>
+ <cer:Response>
+ <cer:code>400</cer:code>
+ <cer:description>bad stuff</cer:description>
+ </cer:Response>
+ <cer:ServiceProviderEntity>
+ <cer:reportingServiceEntity>String</cer:reportingServiceEntity>
+ <cer:faultDate>*** ERROR ***</cer:faultDate>
+ <cer:faultSequenceNumber>String</cer:faultSequenceNumber>
+ <cer:faultLevel>String</cer:faultLevel>
+ <cer:faultCode>String</cer:faultCode>
+ <cer:faultDescription>String</cer:faultDescription>
+ <cer:ServiceProviderRawError>
+ <cer:code>String</cer:code>
+ <cer:description>String</cer:description>
+ <cer:BISError>
+ <cer:code>String</cer:code>
+ <cer:description>String</cer:description>
+ <cer:origination>String</cer:origination>
+ <cer:severity>String</cer:severity>
+ </cer:BISError>
+ </cer:ServiceProviderRawError>
+ </cer:ServiceProviderEntity>
+ </n1:CSIApplicationException>
+ <n1:CSIInternalException>
+ <cer:reportingServiceEntity>String</cer:reportingServiceEntity>
+ <cer:faultDate>*** ERROR ***</cer:faultDate>
+ <cer:faultSequenceNumber>String</cer:faultSequenceNumber>
+ <cer:faultLevel>String</cer:faultLevel>
+ <cer:faultCode>String</cer:faultCode>
+ <cer:faultDescription>String</cer:faultDescription>
+ <cer:cingularErrorCode>String</cer:cingularErrorCode>
+ <cer:cingularErrorDescription>String</cer:cingularErrorDescription>
+ <cer:cingularErrorCategory>String</cer:cingularErrorCategory>
+ </n1:CSIInternalException>
+ </n1:detail>
+</n1:Fault>"""
+
+
+ @Before
+ public void init()
+ {
+ MockitoAnnotations.initMocks(this)
+ }
+
+ @Test
+ @Ignore
+ public void testMapAAIExceptionTCommonException() {
+
+
+
+ String restFault = """
+ <Fault>
+<requestError>
+<serviceException>
+<messageId>SVC3002</messageId>
+<text>Error writing output performing %1 on %2 (msg=%3) (ec=%4)</text>
+<variables>
+<variable>PUTcustomer</variable>
+<variable>SubName01</variable>
+<variable>Unexpected error reading/updating database:Adding this property for key [service-instance-id] and value [USSTU2CFCNC0101UJZZ01] violates a uniqueness constraint [service-instance-id]</variable>
+<variable>ERR.5.4.5105</variable>
+</variables>
+</serviceException>
+</requestError>
+</Fault>
+ """
+ def errorString = """<requestError>
+<serviceException>
+<messageId>SVC3002</messageId>
+<text>Error writing output performing %1 on %2 (msg=%3) (ec=%4)</text>
+<variables>
+<variable>PUTcustomer</variable>
+<variable>SubName01</variable>
+<variable>Unexpected error reading/updating database:Adding this property for key [service-instance-id] and value [USSTU2CFCNC0101UJZZ01] violates a uniqueness constraint [service-instance-id]</variable>
+<variable>ERR.5.4.5105</variable>
+</variables>
+</serviceException>
+</requestError>""" as String
+
+
+
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+
+ TrinityExceptionUtil util = new TrinityExceptionUtil()
+ Assert.assertEquals(errorString, util.mapAAIExceptionTCommonException(restFault, mockExecution))
+ }
+
+
+
+
+ @Test
+ public void testBuildException() {
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("prefix")).thenReturn("test_")
+ when(mockExecution.getVariable("test_ResponseCode")).thenReturn("400")
+ ArrayList msgVars = new ArrayList()
+ msgVars.add("var1")
+ msgVars.add("var2")
+ when(mockExecution.getVariable("test_errVariables")).thenReturn(msgVars)
+
+
+ TrinityExceptionUtil util = new TrinityExceptionUtil()
+ String msg = "Bad request"
+ String errorString = """<tns:requestError xmlns:tns="http://org.onap/so/request/types/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://org.onap/so/request/types/v1 MsoServiceInstanceTypesV1.xsd">
+ <tns:serviceException>
+ <tns:messageId>SVC2000</tns:messageId>
+ <tns:text>The following service error occurred: %1. Error code is %2.</tns:text>
+ <tns:variables>var1</tns:variables>
+ <tns:variables>var2</tns:variables>
+ </tns:serviceException>
+</tns:requestError>"""
+ Assert.assertEquals(errorString, util.buildException(msg, mockExecution))
+ }
+
+ @Test
+ public void testMapAOTSExecptionToCommonException() {
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("prefix")).thenReturn("test_")
+ when(mockExecution.getVariable("test_ResponseCode")).thenReturn("400")
+
+ TrinityExceptionUtil util = new TrinityExceptionUtil()
+ String errorString = """<tns:requestError xmlns:tns="http://org.onap/so/request/types/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://org.onap/so/request/types/v1 MsoServiceInstanceTypesV1.xsd">
+ <tns:serviceException>
+ <tns:messageId>SVC2000</tns:messageId>
+ <tns:text>The following service error occurred: %1. Error code is %2.</tns:text>
+ <tns:variables>Received error from AOTS: bad stuff</tns:variables>
+ <tns:variables>400</tns:variables>
+ </tns:serviceException>
+</tns:requestError>"""
+ Assert.assertEquals(errorString, util.mapAOTSExecptionToCommonException(aotsFault, mockExecution))
+ }
+
+
+ @Test
+ public void testParseError() {
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ String errorString = "The following service error occurred: %1. Error code is %2."
+ ArrayList msgVars = new ArrayList()
+ msgVars.add("var1")
+ msgVars.add("var2")
+ when(mockExecution.getVariable("prefix")).thenReturn("test_")
+ when(mockExecution.getVariable("test_errTxt")).thenReturn(errorString)
+ when(mockExecution.getVariable("test_errVariables")).thenReturn(msgVars)
+
+ TrinityExceptionUtil util = new TrinityExceptionUtil()
+
+ Assert.assertEquals("The following service error occurred: var1. Error code is var2.", util.parseError(mockExecution))
+}
+
+
+
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnfTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnfTest.groovy
new file mode 100644
index 0000000000..e0166f3602
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIGenericVnfTest.groovy
@@ -0,0 +1,172 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule
+import org.camunda.bpm.engine.ProcessEngineServices
+import org.camunda.bpm.engine.RepositoryService
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.camunda.bpm.engine.repository.ProcessDefinition
+import org.junit.Before
+import org.junit.Ignore
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.mockito.MockitoAnnotations
+import org.mockito.runners.MockitoJUnitRunner
+import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.bpmn.mock.FileUtil
+import org.onap.so.bpmn.mock.StubResponseAAI
+
+import static com.github.tomakehurst.wiremock.client.WireMock.*
+import static org.mockito.Matchers.any
+import static org.mockito.Matchers.refEq
+import static org.mockito.Mockito.*
+
+@RunWith(MockitoJUnitRunner.class)
+@Ignore
+class UpdateAAIGenericVnfTest {
+
+ String getVfModuleResponse = FileUtil.readResourceFile("__files/VfModularity/GenericVnf.xml")
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(28090)
+
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+ @Before
+ void init() throws IOException {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ void testGetGenericVnf() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("UAAIGenVnf_vnfId")).thenReturn("skask")
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+ when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIGenericVnf.aai.version")).thenReturn('8')
+
+ StubResponseAAI.MockAAIVfModule()
+ UpdateAAIGenericVnf obj = new UpdateAAIGenericVnf()
+ obj.getGenericVnf(mockExecution)
+
+ Mockito.verify(mockExecution).setVariable("UAAIGenVnf_getGenericVnfResponseCode", 200)
+ }
+
+ @Test
+ void testGetGenericVnfEndpointNull() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("UAAIGenVnf_vnfId")).thenReturn("skask")
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn(null)
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+ when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIGenericVnf.aai.version")).thenReturn('8')
+
+ StubResponseAAI.MockAAIVfModule()
+ try {
+ UpdateAAIGenericVnf obj = new UpdateAAIGenericVnf()
+ obj.getGenericVnf(mockExecution)
+ } catch (Exception ex) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+
+ WorkflowException exception = new WorkflowException("UpdateAAIGenericVnf", 9999, "org.apache.http.client.ClientProtocolException")
+ Mockito.verify(mockExecution).setVariable("WorkflowException", refEq(exception, any(WorkflowException.class)))
+ Mockito.verify(mockExecution).setVariable("UAAIGenVnf_getGenericVnfResponseCode", 500)
+ Mockito.verify(mockExecution).setVariable("UAAIGenVnf_getGenericVnfResponse", "AAI GET Failed:null")
+ }
+
+ @Test
+ void testUpdateGenericVnf() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("UAAIGenVnf_vnfId")).thenReturn("skask")
+ when(mockExecution.getVariable("UAAIGenVnf_getGenericVnfResponse")).thenReturn(getVfModuleResponse)
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+ when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIGenericVnf.aai.version")).thenReturn('8')
+
+ stubFor(patch(urlMatching(".*/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*"))
+ .willReturn(aResponse()
+ .withStatus(200)))
+ UpdateAAIGenericVnf obj = new UpdateAAIGenericVnf()
+ obj.updateGenericVnf(mockExecution)
+
+ Mockito.verify(mockExecution).setVariable("UAAIGenVnf_updateGenericVnfResponseCode", 200)
+ Mockito.verify(mockExecution).setVariable("UAAIGenVnf_updateGenericVnfResponse", "")
+ }
+
+ @Test
+ void testUpdateGenericVnfEndpointNull() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("UAAIGenVnf_vnfId")).thenReturn("skask")
+ when(mockExecution.getVariable("UAAIGenVnf_getGenericVnfResponse")).thenReturn(getVfModuleResponse)
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn(null)
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+ when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIGenericVnf.aai.version")).thenReturn('8')
+
+ stubFor(patch(urlMatching(".*/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*"))
+ .willReturn(aResponse()
+ .withStatus(200)))
+
+ try {
+ UpdateAAIGenericVnf obj = new UpdateAAIGenericVnf()
+ obj.updateGenericVnf(mockExecution)
+ } catch (Exception ex) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+ WorkflowException exception = new WorkflowException("UpdateAAIGenericVnf", 9999, "org.apache.http.client.ClientProtocolException")
+ Mockito.verify(mockExecution).setVariable("WorkflowException", refEq(exception, any(WorkflowException.class)))
+ Mockito.verify(mockExecution).setVariable("UAAIGenVnf_updateGenericVnfResponseCode", 500)
+ Mockito.verify(mockExecution).setVariable("UAAIGenVnf_updateGenericVnfResponse", "AAI PATCH Failed:null")
+ }
+
+ private static ExecutionEntity setupMock() {
+ ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
+ when(mockProcessDefinition.getKey()).thenReturn("UpdateAAIGenericVnf")
+ RepositoryService mockRepositoryService = mock(RepositoryService.class)
+ when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
+ when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("UpdateAAIGenericVnf")
+ 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("UpdateAAIGenericVnf")
+ when(mockExecution.getProcessInstanceId()).thenReturn("UpdateAAIGenericVnf")
+ when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
+ when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition)
+
+ return mockExecution
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy
new file mode 100644
index 0000000000..d2f9095e2d
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy
@@ -0,0 +1,175 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule
+import org.camunda.bpm.engine.ProcessEngineServices
+import org.camunda.bpm.engine.RepositoryService
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.camunda.bpm.engine.repository.ProcessDefinition
+import org.junit.Assert
+import org.junit.Before
+import org.junit.Ignore
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
+import org.mockito.Mockito
+import org.mockito.MockitoAnnotations
+import org.mockito.runners.MockitoJUnitRunner
+import org.onap.so.bpmn.core.WorkflowException
+import org.onap.so.bpmn.mock.FileUtil
+import org.onap.so.bpmn.mock.StubResponseAAI
+
+import static org.mockito.Mockito.*
+
+@RunWith(MockitoJUnitRunner.class)
+@Ignore
+class UpdateAAIVfModuleTest {
+ def prefix = "UAAIVfMod_"
+
+ @Rule
+ public WireMockRule wireMockRule = new WireMockRule(28090)
+
+ @Captor
+ static ArgumentCaptor<ExecutionEntity> captor = ArgumentCaptor.forClass(ExecutionEntity.class)
+
+ @Before
+ void init() throws IOException {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ void testGetVfModule() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("prefix")).thenReturn(prefix)
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask")
+ when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool")
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+ when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIVfModule.aai.version")).thenReturn('8')
+
+ StubResponseAAI.MockAAIVfModule()
+ UpdateAAIVfModule obj = new UpdateAAIVfModule()
+ obj.getVfModule(mockExecution)
+
+ verify(mockExecution).setVariable(prefix + "getVfModuleResponseCode", 200)
+ }
+
+ @Test
+ void testGetVfModuleEndpointNull() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("prefix")).thenReturn(prefix)
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask")
+ when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool")
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn(null)
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+ when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIVfModule.aai.version")).thenReturn('8')
+
+ StubResponseAAI.MockAAIVfModule()
+ try {
+ UpdateAAIVfModule obj = new UpdateAAIVfModule()
+ obj.getVfModule(mockExecution)
+ } catch (Exception ex) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+
+ Mockito.verify(mockExecution, times(3)).setVariable(captor.capture(), captor.capture())
+ WorkflowException workflowException = captor.getAllValues().get(1)
+ Assert.assertEquals(9999, workflowException.getErrorCode())
+ Assert.assertEquals("org.apache.http.client.ClientProtocolException", workflowException.getErrorMessage())
+ }
+
+ @Test
+ void testUpdateVfModule() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("prefix")).thenReturn(prefix)
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask")
+ when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool")
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn("http://localhost:28090")
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+ when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIVfModule.aai.version")).thenReturn('8')
+
+ String getVfModuleResponse = FileUtil.readResourceFile("__files/VfModularity/GenericVnf.xml")
+ when(mockExecution.getVariable(prefix + "getVfModuleResponse")).thenReturn(getVfModuleResponse)
+ StubResponseAAI.MockAAIVfModule()
+ UpdateAAIVfModule obj = new UpdateAAIVfModule()
+ obj.updateVfModule(mockExecution)
+
+ verify(mockExecution).setVariable(prefix + "updateVfModuleResponseCode", 200)
+ }
+
+ @Test
+ void testUpdateVfModuleEndpointNull() {
+ ExecutionEntity mockExecution = setupMock()
+ when(mockExecution.getVariable("prefix")).thenReturn(prefix)
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable(prefix + "vnfId")).thenReturn("skask")
+ when(mockExecution.getVariable(prefix + "vfModuleId")).thenReturn("supercool")
+ when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn("/aai/v8/network/generic-vnfs/generic-vnf")
+ when(mockExecution.getVariable("aai.endpoint")).thenReturn(null)
+ when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn("http://org.openecomp.aai.inventory/")
+ when(mockExecution.getVariable("mso.workflow.custom.UpdateAAIVfModule.aai.version")).thenReturn('8')
+
+ String getVfModuleResponse = FileUtil.readResourceFile("__files/VfModularity/GenericVnf.xml")
+ when(mockExecution.getVariable(prefix + "getVfModuleResponse")).thenReturn(getVfModuleResponse)
+ StubResponseAAI.MockAAIVfModule()
+ try {
+ UpdateAAIVfModule obj = new UpdateAAIVfModule()
+ obj.updateVfModule(mockExecution)
+ } catch (Exception ex) {
+ println " Test End - Handle catch-throw BpmnError()! "
+ }
+
+ Mockito.verify(mockExecution, times(3)).setVariable(captor.capture(), captor.capture())
+ WorkflowException workflowException = captor.getAllValues().get(1)
+ Assert.assertEquals(9999, workflowException.getErrorCode())
+ Assert.assertEquals("org.apache.http.client.ClientProtocolException", workflowException.getErrorMessage())
+ }
+
+ private static ExecutionEntity setupMock() {
+ ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class)
+ when(mockProcessDefinition.getKey()).thenReturn("UpdateAAIVfModule")
+ RepositoryService mockRepositoryService = mock(RepositoryService.class)
+ when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition)
+ when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("UpdateAAIVfModule")
+ 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("UpdateAAIVfModule")
+ when(mockExecution.getProcessInstanceId()).thenReturn("UpdateAAIVfModule")
+ when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices)
+ when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition)
+
+ return mockExecution
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VidUtilsTest.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VidUtilsTest.groovy
new file mode 100644
index 0000000000..1ab049571a
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VidUtilsTest.groovy
@@ -0,0 +1,969 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts;
+
+import static org.mockito.Mockito.*
+
+import org.onap.so.bpmn.common.scripts.VidUtils;
+import org.onap.so.bpmn.core.WorkflowException
+
+import groovy.json.JsonSlurper
+
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.ProcessEngineServices
+import org.camunda.bpm.engine.RepositoryService
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl
+import org.camunda.bpm.engine.repository.ProcessDefinition
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+
+import static org.junit.Assert.*;
+
+import org.mockito.MockitoAnnotations
+import org.mockito.runners.MockitoJUnitRunner
+import org.mockito.internal.debugging.MockitoDebuggerImpl
+import org.junit.Before
+import org.junit.Rule;
+import org.junit.Test
+import org.junit.Ignore
+import org.junit.runner.RunWith
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity;
+import org.junit.Before;
+import org.junit.Test;
+
+@RunWith(MockitoJUnitRunner.class)
+
+class VidUtilsTest {
+
+ def vfModuleReqJson = """
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "vfModule",
+ "modelInvariantUuid": "ff5256d2-5a33-55df-13ab-12abad84e7ff",
+ "modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "STMTN5MMSC21-MMSC::model-1-0",
+ "modelVersion": "1",
+ "modelCustomizationUuid": "ee6478e5-ea33-3346-ac12-ab121484a3fe"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "MDTWNJ21",
+ "tenantId": "fba1bd1e195a404cacb9ce17a9b2b421"
+ },
+ "requestInfo": {
+ "instanceName": "PCRF::module-0-2",
+ "source": "VID",
+ "suppressRollback": true
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c",
+ "instanceName": "MSOTESTVOL103a-vSAMP12_base_module-0_vol",
+ "modelInfo": {
+ "modelType": "volumeGroup",
+ "modelInvariantUuid": "ff5256d2-5a33-55df-13ab-12abad84e7ff",
+ "modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "vSAMP12..base..module-0",
+ "modelVersion": "1"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "123456",
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantUuid": "ff3514e3-5a33-55df-13ab-12abad84e7ff",
+ "modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "SERVICE_MODEL_NAME",
+ "modelVersion": "1.0"
+ }
+ }
+ },
+ {
+ "relatedInstance": {
+ "instanceId": "skask",
+ "instanceName": "skask-test",
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelInvariantUuid": "skask",
+ "modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "vSAMP12",
+ "modelVersion": "1.0",
+ "modelInstanceName": "vSAMP12 1"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "userParams": [
+ {
+ "name": "vnfName",
+ "value": "STMTN5MMSC20"
+ },
+ {
+ "name": "tenantId",
+ "value": "vpe-tenant-123"
+ },
+ {
+ "name": "aicCloudRegion",
+ "value": "MDTWNJ21"
+ },
+ {
+ "name": "isAvpnService",
+ "value": "true"
+ },
+ {
+ "name": "asn",
+ "value": "asn-1234"
+ },
+ {
+ "name": "releaseForAero",
+ "value": "release-for-aero-something"
+ },
+ {
+ "name": "aicClli",
+ "value": "MTJWNJA4LCP"
+ },
+ {
+ "name": "svcProviderPartNumber",
+ "value": "svc-provide-number-1234"
+ }
+ ]
+ }
+ }
+}
+"""
+ def bpmnReq1 = """
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "volumeGroup",
+ "modelId": "ff5256d2-5a33-55df-13ab-12abad84e7ff",
+ "modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "vSAMP12::base::module-0",
+ "modelVersion": "1"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "requestInfo": {
+ "instanceName": "MSOTESTVOL101a-vSAMP12_base_vol_module-0",
+ "source": "VID",
+ "suppressRollback": false
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "{service-instance-id}",
+ "modelInfo": {
+ "modelType": "service",
+ "modelId": "ff3514e3-5a33-55df-13ab-12abad84e7ff",
+ "modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "Test",
+ "modelVersion": "2.0"
+ }
+ }
+ }, {
+ "relatedInstance": {
+ "instanceId": "{vnf-instance-id}",
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelId": "ff5256d1-5a33-55df-13ab-12abad84e7ff",
+ "modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "vSAMP12",
+ "modelVersion": "1",
+ "modelInstanceName": "vSAMP12"
+ }
+ }
+ }
+ ],
+ "requestParameters": {
+ "serviceId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "userParams": [
+ {"name": "vnfName", "value": "STMTN5MMSC20" },
+ {"name": "vnfName2", "value": "US1117MTSNJVBR0246" },
+ {"name": "vnfNmInformation", "value": "" },
+ {"name": "vnfType", "value": "pcrf-capacity" },
+ {"name": "vnfId", "value": "skask" },
+ {"name": "vnfStackId", "value": "slowburn" },
+ {"name": "vnfStatus", "value": "created" },
+ {"name": "aicCloudRegion", "value": "MDTWNJ21" },
+ {"name": "availabilityZone", "value": "slcp3-esx-az01" },
+ {"name": "oamNetworkName", "value": "VLAN-OAM-1323" },
+ {"name": "vmName", "value": "slcp34246vbc246ceb" },
+ {"name": "ipagNetworkId", "value": "970cd2b9-7f09-4a12-af47-182ea38ba1f0" },
+ {"name": "vpeNetworkId", "value": "545cc2c3-1930-4100-b534-5d82d0e12bb6" }
+ ]
+ }
+ }
+}
+"""
+
+ def vidUtilResp1 = """<volume-request xmlns="http://www.w3.org/2001/XMLSchema">
+ <request-info>
+ <action>CREATE_VF_MODULE_VOL</action>
+ <source>VID</source>
+ <service-instance-id>test-service-instance-id-123</service-instance-id>
+ </request-info>
+ <volume-inputs>
+ <volume-group-id/>
+ <volume-group-name>MSOTESTVOL101a-vSAMP12_base_vol_module-0</volume-group-name>
+ <vnf-type>Test/vSAMP12</vnf-type>
+ <vf-module-model-name>vSAMP12::base::module-0</vf-module-model-name>
+ <asdc-service-model-version>2.0</asdc-service-model-version>
+ <aic-cloud-region>mdt1</aic-cloud-region>
+ <tenant-id>88a6ca3ee0394ade9403f075db23167e</tenant-id>
+ <service-id>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-id>
+ <backout-on-failure>true</backout-on-failure>
+ <model-customization-id/>
+ </volume-inputs>
+ <volume-params>
+ <param name="vnf_name">STMTN5MMSC20</param>
+ <param name="vnf_name2">US1117MTSNJVBR0246</param>
+ <param name="vnf_nm_information"/>
+ <param name="vnf_type">pcrf-capacity</param>
+ <param name="vnf_id">skask</param>
+ <param name="vnf_stack_id">slowburn</param>
+ <param name="vnf_status">created</param>
+ <param name="aic_cloud_region">MDTWNJ21</param>
+ <param name="availability_zone">slcp3-esx-az01</param>
+ <param name="oam_network_name">VLAN-OAM-1323</param>
+ <param name="vm_name">slcp34246vbc246ceb</param>
+ <param name="ipag_network_id">970cd2b9-7f09-4a12-af47-182ea38ba1f0</param>
+ <param name="vpe_network_id">545cc2c3-1930-4100-b534-5d82d0e12bb6</param>
+ </volume-params>
+</volume-request>
+"""
+
+ def bpmnReq2 = """
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "volumeGroup",
+ "modelId": "ff5256d2-5a33-55df-13ab-12abad84e7ff",
+ "modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "vSAMP12::base::module-0",
+ "modelVersion": "1"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "requestInfo": {
+ "instanceName": "MSOTESTVOL101a-vSAMP12_base_vol_module-0",
+ "source": "VID",
+ "suppressRollback": false
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "{service-instance-id}",
+ "modelInfo": {
+ "modelType": "service",
+ "modelId": "ff3514e3-5a33-55df-13ab-12abad84e7ff",
+ "modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "Test",
+ "modelVersion": "2.0"
+ }
+ }
+ }, {
+ "relatedInstance": {
+ "instanceId": "{vnf-instance-id}",
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelId": "ff5256d1-5a33-55df-13ab-12abad84e7ff",
+ "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "vSAMP12",
+ "modelVersion": "1",
+ "modelInstanceName": "vSAMP12"
+ }
+ }
+ }
+ ]
+ }
+}
+"""
+
+ def bpmnReqJsonVolumeSuppressRollbackTrue = """
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "volumeGroup",
+ "modelId": "ff5256d2-5a33-55df-13ab-12abad84e7ff",
+ "modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "vSAMP12::base::module-0",
+ "modelVersion": "1"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "requestInfo": {
+ "instanceName": "MSOTESTVOL101a-vSAMP12_base_vol_module-0",
+ "source": "VID",
+ "suppressRollback": true
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "{service-instance-id}",
+ "modelInfo": {
+ "modelType": "service",
+ "modelId": "ff3514e3-5a33-55df-13ab-12abad84e7ff",
+ "modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "Test",
+ "modelVersion": "2.0"
+ }
+ }
+ }, {
+ "relatedInstance": {
+ "instanceId": "{vnf-instance-id}",
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelId": "ff5256d1-5a33-55df-13ab-12abad84e7ff",
+ "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "vSAMP12",
+ "modelVersion": "1",
+ "modelInstanceName": "vSAMP12"
+ }
+ }
+ }
+ ]
+ }
+}
+"""
+
+def bpmnReqJsonVolumeSuppressRollbackFalse = """
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "volumeGroup",
+ "modelId": "ff5256d2-5a33-55df-13ab-12abad84e7ff",
+ "modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "vSAMP12::base::module-0",
+ "modelVersion": "1"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "requestInfo": {
+ "instanceName": "MSOTESTVOL101a-vSAMP12_base_vol_module-0",
+ "source": "VID",
+ "suppressRollback": false
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "{service-instance-id}",
+ "modelInfo": {
+ "modelType": "service",
+ "modelId": "ff3514e3-5a33-55df-13ab-12abad84e7ff",
+ "modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "Test",
+ "modelVersion": "2.0"
+ }
+ }
+ }, {
+ "relatedInstance": {
+ "instanceId": "{vnf-instance-id}",
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelId": "ff5256d1-5a33-55df-13ab-12abad84e7ff",
+ "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "vSAMP12",
+ "modelVersion": "1",
+ "modelInstanceName": "vSAMP12"
+ }
+ }
+ }
+ ]
+ }
+}
+"""
+
+def bpmnReqJsonVolumeSuppressRollbackNone = """
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "volumeGroup",
+ "modelId": "ff5256d2-5a33-55df-13ab-12abad84e7ff",
+ "modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "vSAMP12::base::module-0",
+ "modelVersion": "1"
+ },
+ "cloudConfiguration": {
+ "lcpCloudRegionId": "mdt1",
+ "tenantId": "88a6ca3ee0394ade9403f075db23167e"
+ },
+ "requestInfo": {
+ "instanceName": "MSOTESTVOL101a-vSAMP12_base_vol_module-0",
+ "source": "VID"
+ },
+ "relatedInstanceList": [
+ {
+ "relatedInstance": {
+ "instanceId": "{service-instance-id}",
+ "modelInfo": {
+ "modelType": "service",
+ "modelId": "ff3514e3-5a33-55df-13ab-12abad84e7ff",
+ "modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "Test",
+ "modelVersion": "2.0"
+ }
+ }
+ }, {
+ "relatedInstance": {
+ "instanceId": "{vnf-instance-id}",
+ "modelInfo": {
+ "modelType": "vnf",
+ "modelId": "ff5256d1-5a33-55df-13ab-12abad84e7ff",
+ "modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe",
+ "modelName": "vSAMP12",
+ "modelVersion": "1",
+ "modelInstanceName": "vSAMP12"
+ }
+ }
+ }
+ ]
+ }
+}
+"""
+
+ def bpmnReqJsonVfModuleSuppressRollbackTrue = """
+{
+"requestDetails": {
+"modelInfo": {
+"modelType": "vfModule",
+"modelInvariantUuid": "ff5256d2-5a33-55df-13ab-12abad84e7ff",
+"modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe",
+"modelName": "STMTN5MMSC21-MMSC::model-1-0",
+"modelVersion": "1"
+},
+"cloudConfiguration": {
+"lcpCloudRegionId": "MDTWNJ21",
+"tenantId": "fba1bd1e195a404cacb9ce17a9b2b421"
+},
+"requestInfo": {
+"instanceName": "PCRF::module-0-2",
+"source": "VID",
+"suppressRollback": true
+},
+"relatedInstanceList": [
+{
+"relatedInstance": {
+"instanceId": "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c",
+"instanceName": "MSOTESTVOL103a-vSAMP12_base_module-0_vol",
+"modelInfo": {
+"modelType": "volumeGroup",
+"modelInvariantUuid": "ff5256d2-5a33-55df-13ab-12abad84e7ff",
+"modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe",
+"modelName": "vSAMP12..base..module-0",
+"modelVersion": "1"
+}
+}
+},
+{
+"relatedInstance": {
+"instanceId": "123456",
+"modelInfo": {
+"modelType": "service",
+"modelInvariantUuid": "ff3514e3-5a33-55df-13ab-12abad84e7ff",
+"modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe",
+"modelName": "SERVICE_MODEL_NAME",
+"modelVersion": "1.0"
+}
+}
+},
+{
+"relatedInstance": {
+"instanceId": "skask",
+"instanceName": "skask-test",
+"modelInfo": {
+"modelType": "vnf",
+"modelInvariantUuid": "skask",
+"modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe",
+"modelName": "vSAMP12",
+"modelVersion": "1.0",
+"modelInstanceName": "vSAMP12 1"
+}
+}
+}
+],
+"requestParameters": {
+"userParams": {}
+}
+}
+}
+"""
+
+def bpmnReqJsonVfModuleSuppressRollbackFalse = """
+{
+"requestDetails": {
+"modelInfo": {
+"modelType": "vfModule",
+"modelInvariantUuid": "ff5256d2-5a33-55df-13ab-12abad84e7ff",
+"modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe",
+"modelName": "STMTN5MMSC21-MMSC::model-1-0",
+"modelVersion": "1"
+},
+"cloudConfiguration": {
+"lcpCloudRegionId": "MDTWNJ21",
+"tenantId": "fba1bd1e195a404cacb9ce17a9b2b421"
+},
+"requestInfo": {
+"instanceName": "PCRF::module-0-2",
+"source": "VID",
+"suppressRollback": false
+},
+"relatedInstanceList": [
+{
+"relatedInstance": {
+"instanceId": "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c",
+"instanceName": "MSOTESTVOL103a-vSAMP12_base_module-0_vol",
+"modelInfo": {
+"modelType": "volumeGroup",
+"modelInvariantUuid": "ff5256d2-5a33-55df-13ab-12abad84e7ff",
+"modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe",
+"modelName": "vSAMP12..base..module-0",
+"modelVersion": "1"
+}
+}
+},
+{
+"relatedInstance": {
+"instanceId": "123456",
+"modelInfo": {
+"modelType": "service",
+"modelInvariantUuid": "ff3514e3-5a33-55df-13ab-12abad84e7ff",
+"modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe",
+"modelName": "SERVICE_MODEL_NAME",
+"modelVersion": "1.0"
+}
+}
+},
+{
+"relatedInstance": {
+"instanceId": "skask",
+"instanceName": "skask-test",
+"modelInfo": {
+"modelType": "vnf",
+"modelInvariantUuid": "skask",
+"modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe",
+"modelName": "vSAMP12",
+"modelVersion": "1.0",
+"modelInstanceName": "vSAMP12 1"
+}
+}
+}
+],
+"requestParameters": {
+"userParams": {}
+}
+}
+}
+"""
+
+def bpmnReqJsonVfModuleSuppressRollbackNone = """
+{
+"requestDetails": {
+"modelInfo": {
+"modelType": "vfModule",
+"modelInvariantUuid": "ff5256d2-5a33-55df-13ab-12abad84e7ff",
+"modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe",
+"modelName": "STMTN5MMSC21-MMSC::model-1-0",
+"modelVersion": "1"
+},
+"cloudConfiguration": {
+"lcpCloudRegionId": "MDTWNJ21",
+"tenantId": "fba1bd1e195a404cacb9ce17a9b2b421"
+},
+"requestInfo": {
+"instanceName": "PCRF::module-0-2",
+"source": "VID"
+},
+"relatedInstanceList": [
+{
+"relatedInstance": {
+"instanceId": "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c",
+"instanceName": "MSOTESTVOL103a-vSAMP12_base_module-0_vol",
+"modelInfo": {
+"modelType": "volumeGroup",
+"modelInvariantUuid": "ff5256d2-5a33-55df-13ab-12abad84e7ff",
+"modelUuid": "fe6478e5-ea33-3346-ac12-ab121484a3fe",
+"modelName": "vSAMP12..base..module-0",
+"modelVersion": "1"
+}
+}
+},
+{
+"relatedInstance": {
+"instanceId": "123456",
+"modelInfo": {
+"modelType": "service",
+"modelInvariantUuid": "ff3514e3-5a33-55df-13ab-12abad84e7ff",
+"modelUuid": "fe6985cd-ea33-3346-ac12-ab121484a3fe",
+"modelName": "SERVICE_MODEL_NAME",
+"modelVersion": "1.0"
+}
+}
+},
+{
+"relatedInstance": {
+"instanceId": "skask",
+"instanceName": "skask-test",
+"modelInfo": {
+"modelType": "vnf",
+"modelInvariantUuid": "skask",
+"modelUuid": "fe6478e4-ea33-3346-ac12-ab121484a3fe",
+"modelName": "vSAMP12",
+"modelVersion": "1.0",
+"modelInstanceName": "vSAMP12 1"
+}
+}
+}
+],
+"requestParameters": {
+"userParams": {}
+}
+}
+}
+"""
+ def vidUtilResp2 = """<volume-request xmlns="http://www.w3.org/2001/XMLSchema">
+ <request-info>
+ <action>CREATE_VF_MODULE_VOL</action>
+ <source>VID</source>
+ <service-instance-id>test-service-instance-id-123</service-instance-id>
+ </request-info>
+ <volume-inputs>
+ <volume-group-id/>
+ <volume-group-name>MSOTESTVOL101a-vSAMP12_base_vol_module-0</volume-group-name>
+ <vnf-type>Test/vSAMP12</vnf-type>
+ <vf-module-model-name>vSAMP12::base::module-0</vf-module-model-name>
+ <asdc-service-model-version>2.0</asdc-service-model-version>
+ <aic-cloud-region>mdt1</aic-cloud-region>
+ <tenant-id>88a6ca3ee0394ade9403f075db23167e</tenant-id>
+ <service-id/>
+ <backout-on-failure>true</backout-on-failure>
+ <model-customization-id/>
+ </volume-inputs>
+ <volume-params/>
+</volume-request>
+"""
+
+def vidUtilVolumeRespBackoutOnFailureFalse = """<volume-request xmlns="http://www.w3.org/2001/XMLSchema">
+ <request-info>
+ <action>CREATE_VF_MODULE_VOL</action>
+ <source>VID</source>
+ <service-instance-id>test-service-instance-id-123</service-instance-id>
+ </request-info>
+ <volume-inputs>
+ <volume-group-id/>
+ <volume-group-name>MSOTESTVOL101a-vSAMP12_base_vol_module-0</volume-group-name>
+ <vnf-type>Test/vSAMP12</vnf-type>
+ <vf-module-model-name>vSAMP12::base::module-0</vf-module-model-name>
+ <asdc-service-model-version>2.0</asdc-service-model-version>
+ <aic-cloud-region>mdt1</aic-cloud-region>
+ <tenant-id>88a6ca3ee0394ade9403f075db23167e</tenant-id>
+ <service-id/>
+ <backout-on-failure>false</backout-on-failure>
+ <model-customization-id/>
+ </volume-inputs>
+ <volume-params/>
+</volume-request>
+"""
+
+def vidUtilVolumeRespBackoutOnFailureTrue = """<volume-request xmlns="http://www.w3.org/2001/XMLSchema">
+ <request-info>
+ <action>CREATE_VF_MODULE_VOL</action>
+ <source>VID</source>
+ <service-instance-id>test-service-instance-id-123</service-instance-id>
+ </request-info>
+ <volume-inputs>
+ <volume-group-id/>
+ <volume-group-name>MSOTESTVOL101a-vSAMP12_base_vol_module-0</volume-group-name>
+ <vnf-type>Test/vSAMP12</vnf-type>
+ <vf-module-model-name>vSAMP12::base::module-0</vf-module-model-name>
+ <asdc-service-model-version>2.0</asdc-service-model-version>
+ <aic-cloud-region>mdt1</aic-cloud-region>
+ <tenant-id>88a6ca3ee0394ade9403f075db23167e</tenant-id>
+ <service-id/>
+ <backout-on-failure>true</backout-on-failure>
+ <model-customization-id/>
+ </volume-inputs>
+ <volume-params/>
+</volume-request>
+"""
+
+def vidUtilVolumeRespBackoutOnFailureEmpty = """<volume-request xmlns="http://www.w3.org/2001/XMLSchema">
+ <request-info>
+ <action>CREATE_VF_MODULE_VOL</action>
+ <source>VID</source>
+ <service-instance-id>test-service-instance-id-123</service-instance-id>
+ </request-info>
+ <volume-inputs>
+ <volume-group-id/>
+ <volume-group-name>MSOTESTVOL101a-vSAMP12_base_vol_module-0</volume-group-name>
+ <vnf-type>Test/vSAMP12</vnf-type>
+ <vf-module-model-name>vSAMP12::base::module-0</vf-module-model-name>
+ <asdc-service-model-version>2.0</asdc-service-model-version>
+ <aic-cloud-region>mdt1</aic-cloud-region>
+ <tenant-id>88a6ca3ee0394ade9403f075db23167e</tenant-id>
+ <service-id/>
+ <backout-on-failure/>
+ <model-customization-id/>
+ </volume-inputs>
+ <volume-params/>
+</volume-request>
+"""
+
+def vidUtilVfModuleRespBackoutOnFailureFalse = """<vnf-request>
+ <request-info>
+ <request-id>test-request-id-123</request-id>
+ <action>CREATE_VF_MODULE</action>
+ <source>VID</source>
+ <service-instance-id>test-service-instance-id-123</service-instance-id>
+ </request-info>
+ <vnf-inputs><!-- not in use in 1610 -->
+ <vnf-name>skask-test</vnf-name>
+ <vnf-type>test-vnf-type-123</vnf-type>
+ <vnf-id>test-vnf-id-123</vnf-id>
+ <volume-group-id>test-volume-group-id-123</volume-group-id>
+ <vf-module-id>test-vf-module-id-123</vf-module-id>
+ <vf-module-name>PCRF::module-0-2</vf-module-name>
+ <vf-module-model-name>STMTN5MMSC21-MMSC::model-1-0</vf-module-model-name>
+ <model-customization-id/>
+ <is-base-vf-module>false</is-base-vf-module>
+ <asdc-service-model-version>1.0</asdc-service-model-version>
+ <aic-cloud-region>MDTWNJ21</aic-cloud-region>
+ <tenant-id>fba1bd1e195a404cacb9ce17a9b2b421</tenant-id>
+ <service-id/>
+ <backout-on-failure>false</backout-on-failure>
+ <persona-model-id>ff5256d2-5a33-55df-13ab-12abad84e7ff</persona-model-id>
+ <persona-model-version>fe6478e5-ea33-3346-ac12-ab121484a3fe</persona-model-version>
+ </vnf-inputs>
+ <vnf-params/>
+</vnf-request>
+"""
+
+def vidUtilVfModuleRespBackoutOnFailureTrue = """<vnf-request>
+ <request-info>
+ <request-id>test-request-id-123</request-id>
+ <action>CREATE_VF_MODULE</action>
+ <source>VID</source>
+ <service-instance-id>test-service-instance-id-123</service-instance-id>
+ </request-info>
+ <vnf-inputs><!-- not in use in 1610 -->
+ <vnf-name>skask-test</vnf-name>
+ <vnf-type>test-vnf-type-123</vnf-type>
+ <vnf-id>test-vnf-id-123</vnf-id>
+ <volume-group-id>test-volume-group-id-123</volume-group-id>
+ <vf-module-id>test-vf-module-id-123</vf-module-id>
+ <vf-module-name>PCRF::module-0-2</vf-module-name>
+ <vf-module-model-name>STMTN5MMSC21-MMSC::model-1-0</vf-module-model-name>
+ <model-customization-id/>
+ <is-base-vf-module>false</is-base-vf-module>
+ <asdc-service-model-version>1.0</asdc-service-model-version>
+ <aic-cloud-region>MDTWNJ21</aic-cloud-region>
+ <tenant-id>fba1bd1e195a404cacb9ce17a9b2b421</tenant-id>
+ <service-id/>
+ <backout-on-failure>true</backout-on-failure>
+ <persona-model-id>ff5256d2-5a33-55df-13ab-12abad84e7ff</persona-model-id>
+ <persona-model-version>fe6478e5-ea33-3346-ac12-ab121484a3fe</persona-model-version>
+ </vnf-inputs>
+ <vnf-params/>
+</vnf-request>
+"""
+
+def vidUtilVfModuleRespBackoutOnFailureEmpty = """<vnf-request>
+ <request-info>
+ <request-id>test-request-id-123</request-id>
+ <action>CREATE_VF_MODULE</action>
+ <source>VID</source>
+ <service-instance-id>test-service-instance-id-123</service-instance-id>
+ </request-info>
+ <vnf-inputs><!-- not in use in 1610 -->
+ <vnf-name>skask-test</vnf-name>
+ <vnf-type>test-vnf-type-123</vnf-type>
+ <vnf-id>test-vnf-id-123</vnf-id>
+ <volume-group-id>test-volume-group-id-123</volume-group-id>
+ <vf-module-id>test-vf-module-id-123</vf-module-id>
+ <vf-module-name>PCRF::module-0-2</vf-module-name>
+ <vf-module-model-name>STMTN5MMSC21-MMSC::model-1-0</vf-module-model-name>
+ <model-customization-id/>
+ <is-base-vf-module>false</is-base-vf-module>
+ <asdc-service-model-version>1.0</asdc-service-model-version>
+ <aic-cloud-region>MDTWNJ21</aic-cloud-region>
+ <tenant-id>fba1bd1e195a404cacb9ce17a9b2b421</tenant-id>
+ <service-id/>
+ <backout-on-failure/>
+ <persona-model-id>ff5256d2-5a33-55df-13ab-12abad84e7ff</persona-model-id>
+ <persona-model-version>fe6478e5-ea33-3346-ac12-ab121484a3fe</persona-model-version>
+ </vnf-inputs>
+ <vnf-params/>
+</vnf-request>
+"""
+
+ @Before
+ public void init()
+ {
+ MockitoAnnotations.initMocks(this)
+
+ }
+
+ @Test
+ public void test() {
+
+ def jsonSlurper = new JsonSlurper()
+ Map reqMap = jsonSlurper.parseText(bpmnReq1)
+
+ VidUtils vidUtils = new VidUtils()
+ def xmlReq = vidUtils.createXmlVolumeRequest(reqMap, 'CREATE_VF_MODULE_VOL', 'test-service-instance-id-123')
+ print xmlReq
+ assertEquals(vidUtilResp1, xmlReq)
+ }
+
+ //@Test
+ public void testVfModule() {
+
+ def jsonSlurper = new JsonSlurper()
+ Map reqMap = jsonSlurper.parseText(vfModuleReqJson)
+
+ VidUtils vidUtils = new VidUtils()
+ def xmlReq = vidUtils.createXmlVfModuleRequest(null, reqMap, "CREATE_VF_MODULE", "test-service-instance-id-123")
+ print xmlReq
+ assertTrue(true)
+ }
+
+ @Test
+ public void testNoRequestParams() {
+
+ def jsonSlurper = new JsonSlurper()
+ Map reqMap = jsonSlurper.parseText(bpmnReq2)
+
+ VidUtils vidUtils = new VidUtils()
+ def xmlReq = vidUtils.createXmlVolumeRequest(reqMap, 'CREATE_VF_MODULE_VOL', 'test-service-instance-id-123')
+
+ assertEquals(vidUtilResp2, xmlReq)
+ }
+
+ @Test
+ public void testVfModuleVolumeRollbackTrue() {
+
+ def jsonSlurper = new JsonSlurper()
+ Map reqMap = jsonSlurper.parseText(bpmnReqJsonVolumeSuppressRollbackTrue)
+
+ VidUtils vidUtils = new VidUtils()
+ def xmlReq = vidUtils.createXmlVolumeRequest(reqMap, 'CREATE_VF_MODULE_VOL', 'test-service-instance-id-123')
+
+ assertEquals(vidUtilVolumeRespBackoutOnFailureFalse, xmlReq)
+ }
+
+ @Test
+ public void testVfModuleVolumeRollbackFalse() {
+
+ def jsonSlurper = new JsonSlurper()
+ Map reqMap = jsonSlurper.parseText(bpmnReqJsonVolumeSuppressRollbackFalse)
+
+ VidUtils vidUtils = new VidUtils()
+ def xmlReq = vidUtils.createXmlVolumeRequest(reqMap, 'CREATE_VF_MODULE_VOL', 'test-service-instance-id-123')
+
+ assertEquals(vidUtilVolumeRespBackoutOnFailureTrue, xmlReq)
+ }
+
+ @Test
+ public void testVfModuleVolumeRollbackNone() {
+
+ def jsonSlurper = new JsonSlurper()
+ Map reqMap = jsonSlurper.parseText(bpmnReqJsonVolumeSuppressRollbackNone)
+
+ VidUtils vidUtils = new VidUtils()
+ def xmlReq = vidUtils.createXmlVolumeRequest(reqMap, 'CREATE_VF_MODULE_VOL', 'test-service-instance-id-123')
+
+ assertEquals(vidUtilVolumeRespBackoutOnFailureEmpty, xmlReq)
+ }
+
+ @Test
+ public void testVfModuleRollbackTrue() {
+
+ def jsonSlurper = new JsonSlurper()
+ Map reqMap = jsonSlurper.parseText(bpmnReqJsonVfModuleSuppressRollbackTrue)
+
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("vnfType")).thenReturn('test-vnf-type-123')
+ when(mockExecution.getVariable("vnfId")).thenReturn('test-vnf-id-123')
+ when(mockExecution.getVariable("vfModuleId")).thenReturn('test-vf-module-id-123')
+ when(mockExecution.getVariable("volumeGroupId")).thenReturn('test-volume-group-id-123')
+ when(mockExecution.getVariable("isBaseVfModule")).thenReturn('false')
+ when(mockExecution.getVariable("mso-request-id")).thenReturn('test-request-id-123')
+
+ VidUtils vidUtils = new VidUtils()
+ def xmlReq = vidUtils.createXmlVfModuleRequest(mockExecution, reqMap, 'CREATE_VF_MODULE', 'test-service-instance-id-123')
+
+ println 'ggg->' + xmlReq
+ assertEquals(vidUtilVfModuleRespBackoutOnFailureFalse, xmlReq)
+ }
+
+ @Test
+ public void testVfModuleRollbackFalse() {
+
+ def jsonSlurper = new JsonSlurper()
+ Map reqMap = jsonSlurper.parseText(bpmnReqJsonVfModuleSuppressRollbackFalse)
+
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("vnfType")).thenReturn('test-vnf-type-123')
+ when(mockExecution.getVariable("vnfId")).thenReturn('test-vnf-id-123')
+ when(mockExecution.getVariable("vfModuleId")).thenReturn('test-vf-module-id-123')
+ when(mockExecution.getVariable("volumeGroupId")).thenReturn('test-volume-group-id-123')
+ when(mockExecution.getVariable("isBaseVfModule")).thenReturn('false')
+ when(mockExecution.getVariable("mso-request-id")).thenReturn('test-request-id-123')
+
+ VidUtils vidUtils = new VidUtils()
+ def xmlReq = vidUtils.createXmlVfModuleRequest(mockExecution, reqMap, 'CREATE_VF_MODULE', 'test-service-instance-id-123')
+
+ println 'ggg->' + xmlReq
+ assertEquals(vidUtilVfModuleRespBackoutOnFailureTrue, xmlReq)
+ }
+
+ @Test
+ public void testVfModuleRollbackNone() {
+
+ def jsonSlurper = new JsonSlurper()
+ Map reqMap = jsonSlurper.parseText(bpmnReqJsonVfModuleSuppressRollbackNone)
+
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("vnfType")).thenReturn('test-vnf-type-123')
+ when(mockExecution.getVariable("vnfId")).thenReturn('test-vnf-id-123')
+ when(mockExecution.getVariable("vfModuleId")).thenReturn('test-vf-module-id-123')
+ when(mockExecution.getVariable("volumeGroupId")).thenReturn('test-volume-group-id-123')
+ when(mockExecution.getVariable("isBaseVfModule")).thenReturn('false')
+ when(mockExecution.getVariable("mso-request-id")).thenReturn('test-request-id-123')
+
+ VidUtils vidUtils = new VidUtils()
+ def xmlReq = vidUtils.createXmlVfModuleRequest(mockExecution, reqMap, 'CREATE_VF_MODULE', 'test-service-instance-id-123')
+
+ println 'ggg->' + xmlReq
+ assertEquals(vidUtilVfModuleRespBackoutOnFailureEmpty, xmlReq)
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1Test.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1Test.groovy
new file mode 100644
index 0000000000..22c8e297ca
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1Test.groovy
@@ -0,0 +1,118 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts
+
+import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.MockitoAnnotations
+import org.mockito.internal.debugging.MockitoDebuggerImpl
+import org.mockito.runners.MockitoJUnitRunner
+import org.onap.so.bpmn.mock.FileUtil
+
+import static org.mockito.Mockito.*
+import static org.junit.Assert.*;
+
+@RunWith(MockitoJUnitRunner.class)
+public class VnfAdapterRestV1Test {
+
+ @Before
+ public void init()
+ {
+ MockitoAnnotations.initMocks(this)
+ }
+
+
+ @Test
+ public void testPreProcessRequest() {
+
+ String sdncAdapterWorkflowRequest = FileUtil.readResourceFile("__files/vnfAdapterMocks/vnfadapter_request.xml");
+ ExecutionEntity mockExecution = mock(ExecutionEntity.class)
+ when(mockExecution.getVariable("prefix")).thenReturn("VNFREST_")
+ when(mockExecution.getVariable("mso-request-id")).thenReturn("testMsoRequestId")
+ when(mockExecution.getVariable("VNFREST_Request")).thenReturn(sdncAdapterWorkflowRequest)
+ when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B")
+ when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7")
+
+ when(mockExecution.getVariable("mso.adapters.vnf.rest.endpoint")).thenReturn("http://localhost:18080/vnfs/rest/v1/vnfs")
+
+ when(mockExecution.getVariable("mso.adapters.sdnc.timeout")).thenReturn("PT5M")
+
+ when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
+ when(mockExecution.getVariable("testProcessKey")).thenReturn("testProcessKey")
+
+
+ VnfAdapterRestV1 vnfAdapterRestV1 = new VnfAdapterRestV1()
+ vnfAdapterRestV1.preProcessRequest(mockExecution)
+
+ MockitoDebuggerImpl debugger = new MockitoDebuggerImpl()
+ //debugger.printInvocations(mockExecution)
+
+
+ verify(mockExecution).setVariable("prefix","VNFREST_")
+
+ verify(mockExecution).setVariable("VNFREST_SuccessIndicator",false)
+ verify(mockExecution).setVariable("VNFREST_requestType","createVfModuleRequest")
+ verify(mockExecution).setVariable("VNFAResponse_CORRELATOR","8892cffa-3514-45d4-b2b0-0fde9a96e323-1511813289000")
+ verify(mockExecution).setVariable("VNFREST_vnfAdapterMethod","POST")
+ verify(mockExecution).setVariable("VNFREST_notificationUrl","http://localhost:18080/mso/WorkflowMessage/VNFAResponse/8892cffa-3514-45d4-b2b0-0fde9a96e323-1511813289000")
+ verify(mockExecution).setVariable("VNFREST_vnfAdapterUrl","http://localhost:18080/vnfs/rest/v1/vnfs/6d2e2469-8708-47c3-a0d4-73fa28a8a50b/vf-modules")
+
+ }
+
+ def rollbackReq = """
+<rollbackVolumeGroupRequest>
+ <volumeGroupRollback>
+ <volumeGroupId>8a07b246-155e-4b08-b56e-76e98a3c2d66</volumeGroupId>
+ <volumeGroupStackId>phmaz401me6-vpevre-VOLUMEGROUP/dbd560b6-b03f-4a17-92e7-8942459a60c1</volumeGroupStackId>
+ <cloudSiteId>mtrnj1b</cloudSiteId>
+ <tenantId>cfb5e0a790374c9a98a1c0d2044206a7</tenantId>
+ <volumeGroupCreated>true</volumeGroupCreated>
+ <msoRequest>
+ <requestId>1e1a72ca-7300-4ac4-b718-30351f3b6845</requestId>
+ <serviceInstanceId>15eb2c68-f771-4030-b185-cff179fdad44</serviceInstanceId>
+ </msoRequest>
+ <messageId>683ca1ac-2145-4a00-9484-20d48bd701aa</messageId>
+ </volumeGroupRollback>
+ <skipAAI>true</skipAAI>
+ <notificationUrl>http://localhost:8080/mso/WorkflowMessage/VNFAResponse/683ca1ac-2145-4a00-9484-20d48bd701aa</notificationUrl>
+</rollbackVolumeGroupRequest>
+"""
+
+ @Test
+ public void testGetVolumeGroupId() {
+ Node root = new XmlParser().parseText(rollbackReq)
+ VnfAdapterRestV1 vnfAdapterRestV1 = new VnfAdapterRestV1()
+ def volGrpId = vnfAdapterRestV1.getVolumeGroupIdFromRollbackRequest(root)
+ assertEquals('8a07b246-155e-4b08-b56e-76e98a3c2d66', volGrpId)
+ }
+
+
+ @Test
+ public void testGetMessageId() {
+ Node root = new XmlParser().parseText(rollbackReq)
+
+ VnfAdapterRestV1 p = new VnfAdapterRestV1()
+ def messageId = p.getMessageIdForVolumeGroupRollback(root)
+ assertEquals('683ca1ac-2145-4a00-9484-20d48bd701aa', messageId)
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/utils/IgnoreNamedElementsDifferenceListener.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/utils/IgnoreNamedElementsDifferenceListener.groovy
new file mode 100644
index 0000000000..9c38634885
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/utils/IgnoreNamedElementsDifferenceListener.groovy
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts.utils
+
+import org.custommonkey.xmlunit.Difference
+import org.custommonkey.xmlunit.DifferenceConstants
+import org.custommonkey.xmlunit.DifferenceListener
+import org.w3c.dom.Node
+
+class IgnoreNamedElementsDifferenceListener implements DifferenceListener {
+ private Set<String> blackList = new HashSet<String>();
+
+ public IgnoreNamedElementsDifferenceListener(String ... ignoreTags) {
+ for (String name : ignoreTags) {
+ blackList.add(name);
+ }
+ }
+
+ public int differenceFound(Difference difference) {
+ if (difference.getId() == DifferenceConstants.TEXT_VALUE_ID) {
+ if (blackList.contains(difference.getControlNodeDetail().getNode().getParentNode().getNodeName())) {
+ return DifferenceListener.RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;
+ }
+ }
+
+ return DifferenceListener.RETURN_ACCEPT_DIFFERENCE;
+ }
+
+
+ public void skippedComparison(Node node, Node node1) {
+
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/utils/XmlComparator.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/utils/XmlComparator.groovy
new file mode 100644
index 0000000000..e1c86edd90
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/utils/XmlComparator.groovy
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.bpmn.common.scripts.utils
+
+import org.custommonkey.xmlunit.DetailedDiff
+import org.custommonkey.xmlunit.XMLUnit
+import org.junit.Assert
+
+
+class XmlComparator {
+
+ public static void assertXMLEquals(String expectedXML, String actualXML, String ... ignoreTags ) throws Exception {
+ XMLUnit.setIgnoreWhitespace(true);
+ XMLUnit.setIgnoreAttributeOrder(true);
+
+ DetailedDiff diff = new DetailedDiff(XMLUnit.compareXML(expectedXML, actualXML));
+
+ diff.overrideDifferenceListener(new IgnoreNamedElementsDifferenceListener(ignoreTags));
+
+ List<?> allDifferences = diff.getAllDifferences();
+ Assert.assertEquals("Differences found: "+ diff.toString(), 0, allDifferences.size());
+ }
+}