Containerization feature of SO
[so.git] / bpmn / MSOCommonBPMN / src / test / groovy / org / onap / so / bpmn / common / scripts / AaiUtilTest.groovy
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.bpmn.common.scripts
22
23 import com.github.tomakehurst.wiremock.junit.WireMockRule
24
25 import static org.junit.Assert.*;
26 import static org.mockito.Mockito.*
27
28 import org.onap.so.rest.HttpHeader
29 import org.mockito.MockitoAnnotations
30 import org.mockito.runners.MockitoJUnitRunner
31 import org.mockito.internal.debugging.MockitoDebuggerImpl
32 import org.junit.Before
33 import org.onap.so.bpmn.common.scripts.AaiUtil;
34 import org.junit.Rule;
35 import org.junit.Test
36 import org.junit.rules.ExpectedException
37 import org.junit.Ignore
38 import org.junit.runner.RunWith
39 import org.junit.Before;
40 import org.junit.Test;
41 import org.camunda.bpm.engine.ProcessEngineServices
42 import org.camunda.bpm.engine.RepositoryService
43 import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
44 import org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl
45 import org.camunda.bpm.engine.repository.ProcessDefinition
46
47 @RunWith(MockitoJUnitRunner.class)
48 @Ignore
49 class AaiUtilTest extends MsoGroovyTest {
50     
51
52         @Rule
53         public WireMockRule wireMockRule = new WireMockRule(8090);
54         
55         @Rule
56         public ExpectedException thrown = ExpectedException.none
57
58
59         def aaiPaylod = "<allotted-resource xmlns=\"http://org.openecomp.aai.inventory/v9\">\n" +
60                         "\t\t\t\t<id>allottedResourceId</id>\n" +
61                         "\t\t\t\t<description></description>\n" +
62                         "\t\t\t\t<type>allottedResourceType</type>\n" +
63                         "\t\t\t\t<role>allottedResourceRole</role>\n" +
64                         "\t\t\t\t<selflink></selflink>\n" +
65                         "\t\t\t\t<model-invariant-id></model-invariant-id>\n" +
66                         "\t\t\t\t<model-version-id></model-version-id>\n" +
67                         "\t\t\t\t<model-customization-id></model-customization-id>\n" +
68                         "\t\t\t\t<orchestration-status>PendingCreate</orchestration-status>\n" +
69                         "\t\t\t\t<operation-status></operation-status>\n" +
70                         "\t\t\t\t<relationship-list>\n" +
71                         "\t\t\t\t\t<relationship>\n" +
72                         "               \t\t\t<related-to>service-instance</related-to>\n" +
73                         "               \t\t\t<related-link>CSI_resourceLink</related-link>\n" +
74                         "\t\t\t\t\t</relationship>\n" +
75                         "\t\t\t\t</relationship-list>\n" +
76                         "\t\t\t</allotted-resource>";
77
78         @Test
79         public void testGetVersionDefault() {
80                 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
81                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
82                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
83
84                 CreateAAIVfModule myproc = new CreateAAIVfModule()
85                 AaiUtil aaiUtil = new AaiUtil(myproc)
86                 def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule')
87                 assertEquals('8', version)
88         }
89
90         @Test
91         public void testGetVersionResourceSpecific() {
92                 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
93                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
94                 when(mockExecution.getVariable("mso.workflow.default.aai.l3-network.version")).thenReturn('7')
95                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
96                 CreateAAIVfModule myproc = new CreateAAIVfModule()
97                 AaiUtil aaiUtil = new AaiUtil(myproc)
98                 def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule')
99                 assertEquals('7', version)
100         }
101
102         @Test
103         public void testGetVersionFlowSpecific() {
104                 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
105                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
106                 when(mockExecution.getVariable("mso.workflow.custom.CreateAAIVfModule.aai.version")).thenReturn('6')
107                 when(mockExecution.getVariable("mso.workflow.default.aai.l3-network.version")).thenReturn('7')
108
109                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
110
111                 CreateAAIVfModule myproc = new CreateAAIVfModule()
112                 AaiUtil aaiUtil = new AaiUtil(myproc)
113                 def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule')
114                 assertEquals('6', version)
115         }
116
117         @Test
118         public void testGetVersionNotDefined() {
119                 thrown.expect(Exception.class)
120                 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
121                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
122                 CreateAAIVfModule myproc = new CreateAAIVfModule()
123                 AaiUtil aaiUtil = new AaiUtil(myproc)
124                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn("")
125
126                 def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule')
127
128         }
129
130         @Test
131         public void testGetUriDefaultVersion() {
132                 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
133                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
134                 when(mockExecution.getVariable("mso.workflow.default.aai.v8.l3-network.uri")).thenReturn('/aai/v8/network/l3-networks/l3-network')
135                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
136                 when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
137
138                 CreateAAIVfModule myproc = new CreateAAIVfModule()
139                 AaiUtil aaiUtil = new AaiUtil(myproc)
140                 def uri = aaiUtil.getUri(mockExecution, 'l3-network')
141                 assertEquals('/aai/v8/network/l3-networks/l3-network', uri)
142         }
143
144         @Test
145         public void testGetUriFlowAndResourceSpecific() {
146                 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
147                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
148                 when(mockExecution.getVariable("mso.workflow.CreateAAIVfModule.aai.l3-network.uri")).thenReturn('/aai/v6/network/l3-networks/l3-network')
149
150                 when(mockExecution.getVariable("mso.workflow.default.aai.v8.l3-network.uri")).thenReturn('/aai/v8/network/l3-networks/l3-network')
151                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
152                 when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
153
154                 CreateAAIVfModule myproc = new CreateAAIVfModule()
155                 AaiUtil aaiUtil = new AaiUtil(myproc)
156                 def uri = aaiUtil.getUri(mockExecution, 'l3-network')
157                 assertEquals('/aai/v6/network/l3-networks/l3-network', uri)
158         }
159
160         @Test
161         public void testGetNetworkGenericVnfEndpoint() {
162                 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
163                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
164                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
165
166                 when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf')
167
168         when(mockExecution.getVariable('aai.endpoint')).thenReturn('http://localhost:28090')
169                 when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
170
171                 when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn('8')
172
173
174                 CreateAAIVfModule myproc = new CreateAAIVfModule()
175                 AaiUtil aaiUtil = new AaiUtil(myproc)
176                 def endpoint = aaiUtil.getNetworkGenericVnfEndpoint(mockExecution)
177                 assertEquals('http://localhost:28090/aai/v8/network/generic-vnfs/generic-vnf', endpoint)
178         }
179
180         @Test
181         public void testGetNetworkGenericVnfUri() {
182                 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
183                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
184                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
185
186                 when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-vnf.uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf')
187
188                 when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
189
190                 when(mockExecution.getVariable("mso.workflow.default.aai.generic-vnf.version")).thenReturn('8')
191
192                 CreateAAIVfModule myproc = new CreateAAIVfModule()
193                 AaiUtil aaiUtil = new AaiUtil(myproc)
194                 def uri = aaiUtil.getNetworkGenericVnfUri(mockExecution)
195                 assertEquals('/aai/v8/network/generic-vnfs/generic-vnf', uri)
196         }
197
198         @Test
199         public void testGetNetworkVpnBindingUri() {
200                 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
201                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
202                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
203                 when(mockExecution.getVariable("mso.workflow.default.aai.v8.vpn-binding.uri")).thenReturn('/aai/v8/network/vpn-bindings/vpn-binding')
204                 when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
205
206                 CreateAAIVfModule myproc = new CreateAAIVfModule()
207                 AaiUtil aaiUtil = new AaiUtil(myproc)
208                 def uri = aaiUtil.getNetworkVpnBindingUri(mockExecution)
209                 assertEquals('/aai/v8/network/vpn-bindings/vpn-binding', uri)
210         }
211
212         @Test
213         public void testGetNetworkPolicyUri() {
214                 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
215                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
216                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
217                 when(mockExecution.getVariable("mso.workflow.default.aai.v8.network-policy.uri")).thenReturn('/aai/v8/network/network-policies/network-policy')
218                 when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
219
220                 CreateAAIVfModule myproc = new CreateAAIVfModule()
221                 AaiUtil aaiUtil = new AaiUtil(myproc)
222                 def uri = aaiUtil.getNetworkPolicyUri(mockExecution)
223                 assertEquals('/aai/v8/network/network-policies/network-policy', uri)
224         }
225
226         @Test
227         public void testGetNetworkTableReferencesUri() {
228                 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
229                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
230                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
231                 when(mockExecution.getVariable("mso.workflow.default.aai.v8.route-table-reference.uri")).thenReturn('/aai/v8/network/route-table-references/route-table-reference')
232                 when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
233
234                 CreateAAIVfModule myproc = new CreateAAIVfModule()
235                 AaiUtil aaiUtil = new AaiUtil(myproc)
236                 def uri = aaiUtil.getNetworkTableReferencesUri(mockExecution)
237                 assertEquals('/aai/v8/network/route-table-references/route-table-reference', uri)
238         }
239
240         @Test
241         public void testGetNetworkVceUri() {
242                 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
243                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
244                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
245                 when(mockExecution.getVariable("mso.workflow.default.aai.v8.vce.uri")).thenReturn('/aai/v8/network/vces/vce')
246                 when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
247
248                 CreateAAIVfModule myproc = new CreateAAIVfModule()
249                 AaiUtil aaiUtil = new AaiUtil(myproc)
250                 def uri = aaiUtil.getNetworkVceUri(mockExecution)
251                 assertEquals('/aai/v8/network/vces/vce', uri)
252         }
253
254         @Test
255         public void testGetNetworkL3NetworkUri() {
256                 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
257                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
258                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
259                 when(mockExecution.getVariable("mso.workflow.default.aai.v8.l3-network.uri")).thenReturn('/aai/v8/network/l3-networks/l3-network')
260                 when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
261
262                 CreateAAIVfModule myproc = new CreateAAIVfModule()
263                 AaiUtil aaiUtil = new AaiUtil(myproc)
264                 def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution)
265                 assertEquals('/aai/v8/network/l3-networks/l3-network', uri)
266         }
267
268         @Test
269         public void testGetBusinessCustomerUri() {
270                 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
271                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
272                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
273                 when(mockExecution.getVariable("mso.workflow.default.aai.v8.customer.uri")).thenReturn('/aai/v8/business/customers/customer')
274                 when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
275
276                 CreateAAIVfModule myproc = new CreateAAIVfModule()
277                 AaiUtil aaiUtil = new AaiUtil(myproc)
278                 def uri = aaiUtil.getBusinessCustomerUri(mockExecution)
279                 assertEquals('/aai/v8/business/customers/customer', uri)
280         }
281
282         @Test
283         public void testGetCloudInfrastructureCloudRegionEndpoint() {
284                 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
285                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
286                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
287
288                 when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic')
289
290         when(mockExecution.getVariable('aai.endpoint')).thenReturn('http://localhost:28090')
291                 when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
292
293                 CreateAAIVfModule myproc = new CreateAAIVfModule()
294                 AaiUtil aaiUtil = new AaiUtil(myproc)
295                 def uri = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(mockExecution)
296                 assertEquals('http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic', uri)
297         }
298
299         @Test
300         public void testGetCloudInfrastructureCloudRegionUri() {
301                 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
302                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
303                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
304
305                 when(mockExecution.getVariable("mso.workflow.default.aai.v8.cloud-region.uri")).thenReturn('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic')
306
307                 when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
308
309
310                 CreateAAIVfModule myproc = new CreateAAIVfModule()
311                 AaiUtil aaiUtil = new AaiUtil(myproc)
312                 def uri = aaiUtil.getCloudInfrastructureCloudRegionUri(mockExecution)
313                 assertEquals('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic', uri)
314         }
315
316         @Test
317         public void testGetCloudInfrastructureTenantUri() {
318                 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
319                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
320                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
321                 when(mockExecution.getVariable("mso.workflow.default.aai.v8.tenant.uri")).thenReturn('/aai/v8/cloud-infrastructure/tenants/tenant')
322
323                 when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
324
325                 CreateAAIVfModule myproc = new CreateAAIVfModule()
326                 AaiUtil aaiUtil = new AaiUtil(myproc)
327                 def uri = aaiUtil.getCloudInfrastructureTenantUri(mockExecution)
328                 assertEquals('/aai/v8/cloud-infrastructure/tenants/tenant', uri)
329         }
330
331         @Test
332         public void testGetSearchNodesQueryUri() {
333                 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
334                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
335                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
336
337                 when(mockExecution.getVariable("mso.workflow.default.aai.v8.nodes-query.uri")).thenReturn('/aai/v8/search/nodes-query')
338
339                 when(mockExecution.getVariable('aai.endpoint')).thenReturn('http://localhost:28090')
340
341                 when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
342
343
344                 CreateAAIVfModule myproc = new CreateAAIVfModule()
345                 AaiUtil aaiUtil = new AaiUtil(myproc)
346                 def uri = aaiUtil.getSearchNodesQueryUri(mockExecution)
347                 assertEquals('/aai/v8/search/nodes-query', uri)
348         }
349
350         @Test
351         public void testGetSearchNodesQueryEndpoint() {
352                 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
353                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
354                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
355
356                 when(mockExecution.getVariable("mso.workflow.default.aai.v8.nodes-query.uri")).thenReturn('/aai/v8/search/nodes-query')
357
358         when(mockExecution.getVariable('aai.endpoint')).thenReturn('http://localhost:28090')
359
360                 when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
361
362                 CreateAAIVfModule myproc = new CreateAAIVfModule()
363                 AaiUtil aaiUtil = new AaiUtil(myproc)
364                 def uri = aaiUtil.getSearchNodesQueryEndpoint(mockExecution)
365                 assertEquals('http://localhost:28090/aai/v8/search/nodes-query', uri)
366         }
367
368         @Test
369         public void testGetSearchGenericQueryUri() {
370                 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
371                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
372                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('8')
373
374                 when(mockExecution.getVariable("mso.workflow.default.aai.v8.generic-query.uri")).thenReturn('/aai/v8/search/generic-query')
375                 when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
376
377
378                 CreateAAIVfModule myproc = new CreateAAIVfModule()
379                 AaiUtil aaiUtil = new AaiUtil(myproc)
380                 def uri = aaiUtil.getSearchGenericQueryUri(mockExecution)
381                 assertEquals('/aai/v8/search/generic-query', uri)
382         }
383
384         @Test
385         public void testGetNamespaceFromUri() {
386                 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
387                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
388                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('6')
389                 when(mockExecution.getVariable("mso.workflow.default.aai.v6.l3-network.uri")).thenReturn('/aai/v6/network/l3-networks/l3-network')
390                 when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
391                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
392                 CreateAAIVfModule myproc = new CreateAAIVfModule()
393                 AaiUtil aaiUtil = new AaiUtil(myproc)
394                 def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution)  // Required to populate the namespace in the class
395                 def ns = aaiUtil.getNamespaceFromUri('/aai/v6/search/generic-query')
396                 assertEquals('http://org.openecomp.aai.inventory/v6', ns)
397         }
398
399         @Test
400         public void testExecuteAAIGetCall() {
401                 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
402                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
403                 when(mockExecution.getVariable("aai.auth")).thenReturn("9B2278E8B8E95F256A560719055F4DF3")
404                 when(mockExecution.getVariable("mso.msoKey")).thenReturn("aa3871669d893c7fb8abbcda31b88b4f")
405                 CreateAAIVfModule myproc = new CreateAAIVfModule()
406                 AaiUtil aaiUtil = new AaiUtil(myproc)
407                 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")
408         }
409
410
411         @Test
412         public void testExecuteAAIPutCall() {
413                 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
414                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
415                 when(mockExecution.getVariable("aai.auth")).thenReturn("9B2278E8B8E95F256A560719055F4DF3")
416                 when(mockExecution.getVariable("mso.msoKey")).thenReturn("aa3871669d893c7fb8abbcda31b88b4f")
417                 CreateAAIVfModule myproc = new CreateAAIVfModule()
418                 AaiUtil aaiUtil = new AaiUtil(myproc)
419                 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)
420         }
421
422         @Test
423         public void testGetNamespaceFromUri2() {
424                 ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1')
425                 //
426                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
427                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('10')
428                 when(mockExecution.getVariable("mso.workflow.default.aai.v10.l3-network.uri")).thenReturn('/aai/v10/network/l3-networks/l3-network')
429                 when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
430                 //
431                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
432                 CreateAAIVfModule myproc = new CreateAAIVfModule()
433                 AaiUtil aaiUtil = new AaiUtil(myproc)
434                 def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution)  // Required to populate the namespace in the class
435                 def ns = aaiUtil.getNamespaceFromUri('/aai/v10/search/generic-query')
436                 assertEquals('http://org.openecomp.aai.inventory/v10', ns)
437         }
438
439         @Test
440         public void testGetNamespaceFromUri3() {
441                 ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1')
442                 //
443                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
444                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('100')
445                 when(mockExecution.getVariable("mso.workflow.default.aai.v100.l3-network.uri")).thenReturn('/aai/v100/network/l3-networks/l3-network')
446                 when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
447                 //
448                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
449                 CreateAAIVfModule myproc = new CreateAAIVfModule()
450                 AaiUtil aaiUtil = new AaiUtil(myproc)
451                 def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution)  // Required to populate the namespace in the class
452                 def ns = aaiUtil.getNamespaceFromUri('/aai/v100/search/generic-query')
453                 assertEquals('http://org.openecomp.aai.inventory/v100', ns)
454         }
455
456         @Test
457         public void testGetNamespaceFromUri_twoArguments() {  // (execution, uri)
458                 ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1')
459                 //
460                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
461                 when(mockExecution.getVariable("mso.workflow.global.default.aai.version")).thenReturn('10')
462                 when(mockExecution.getVariable("mso.workflow.default.aai.v10.l3-network.uri")).thenReturn('/aai/v10/network/l3-networks/l3-network')
463                 when(mockExecution.getVariable("mso.workflow.global.default.aai.namespace")).thenReturn('http://org.openecomp.aai.inventory/')
464                 //
465                 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
466                 CreateAAIVfModule myproc = new CreateAAIVfModule()
467                 AaiUtil aaiUtil = new AaiUtil(myproc)
468                 def ns = aaiUtil.getNamespaceFromUri(mockExecution, '/aai/v10/search/generic-query')
469                 assertEquals('http://org.openecomp.aai.inventory/v10', ns)
470         }
471 }