2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package org.openecomp.mso.bpmn.common.scripts;
\r
23 import static org.junit.Assert.*;
\r
24 import static org.mockito.Mockito.*
\r
26 import org.openecomp.mso.rest.HttpHeader
\r
27 import org.mockito.MockitoAnnotations
\r
28 import org.mockito.runners.MockitoJUnitRunner
\r
29 import org.mockito.internal.debugging.MockitoDebuggerImpl
\r
30 import org.junit.Before
\r
31 import org.openecomp.mso.bpmn.common.scripts.AaiUtil;
\r
32 import org.junit.Rule;
\r
33 import org.junit.Test
\r
34 import org.junit.Ignore
\r
35 import org.junit.runner.RunWith
\r
36 import org.junit.Before;
\r
37 import org.junit.Test;
\r
38 import org.camunda.bpm.engine.ProcessEngineServices
\r
39 import org.camunda.bpm.engine.RepositoryService
\r
40 import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity
\r
41 import org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl
\r
42 import org.camunda.bpm.engine.repository.ProcessDefinition
\r
44 @RunWith(MockitoJUnitRunner.class)
\r
45 class AaiUtilTest extends MsoGroovyTest {
\r
48 public void testGetVersionDefault() {
\r
49 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
\r
50 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
51 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8')
\r
52 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
53 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
54 def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule')
\r
55 assertEquals('8', version)
\r
59 public void testGetVersionResourceSpecific() {
\r
60 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
\r
61 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
62 when(mockExecution.getVariable("URN_mso_workflow_default_aai_l3_network_version")).thenReturn('7')
\r
63 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8')
\r
64 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
65 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
66 def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule')
\r
67 assertEquals('7', version)
\r
71 public void testGetVersionFlowSpecific() {
\r
72 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
\r
73 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
74 when(mockExecution.getVariable("URN_mso_workflow_custom_CreateAAIVfModule_aai_version")).thenReturn('6')
\r
75 when(mockExecution.getVariable("URN_mso_workflow_default_aai_l3_network_version")).thenReturn('7')
\r
76 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8')
\r
77 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
78 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
79 def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule')
\r
80 assertEquals('6', version)
\r
83 @Test(expected=java.lang.Exception.class)
\r
84 public void testGetVersionNotDefined() {
\r
85 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
\r
86 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
87 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
88 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
89 def version = aaiUtil.getVersion(mockExecution, 'l3-network', 'CreateAAIVfModule')
\r
93 public void testGetUriDefaultVersion() {
\r
94 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
\r
95 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
96 when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn('/aai/v8/network/l3-networks/l3-network')
\r
97 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8')
\r
98 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/')
\r
100 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
101 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
102 def uri = aaiUtil.getUri(mockExecution, 'l3-network')
\r
103 assertEquals('/aai/v8/network/l3-networks/l3-network', uri)
\r
107 public void testGetUriFlowAndResourceSpecific() {
\r
108 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
\r
109 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
110 when(mockExecution.getVariable("URN_mso_workflow_CreateAAIVfModule_aai_l3_network_uri")).thenReturn('/aai/v6/network/l3-networks/l3-network')
\r
111 when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn('/aai/v8/network/l3-networks/l3-network')
\r
112 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8')
\r
113 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/')
\r
115 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
116 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
117 def uri = aaiUtil.getUri(mockExecution, 'l3-network')
\r
118 assertEquals('/aai/v6/network/l3-networks/l3-network', uri)
\r
122 public void testGetNetworkGenericVnfEndpoint() {
\r
123 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
\r
124 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
125 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8')
\r
126 when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_generic_vnf_uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf')
\r
127 when(mockExecution.getVariable('URN_aai_endpoint')).thenReturn('http://localhost:28090')
\r
128 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/')
\r
130 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
131 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
132 def endpoint = aaiUtil.getNetworkGenericVnfEndpoint(mockExecution)
\r
133 assertEquals('http://localhost:28090/aai/v8/network/generic-vnfs/generic-vnf', endpoint)
\r
137 public void testGetNetworkGenericVnfUri() {
\r
138 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
\r
139 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
140 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8')
\r
141 when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_generic_vnf_uri")).thenReturn('/aai/v8/network/generic-vnfs/generic-vnf')
\r
142 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/')
\r
144 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
145 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
146 def uri = aaiUtil.getNetworkGenericVnfUri(mockExecution)
\r
147 assertEquals('/aai/v8/network/generic-vnfs/generic-vnf', uri)
\r
151 public void testGetNetworkVpnBindingUri() {
\r
152 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
\r
153 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
154 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8')
\r
155 when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vpn_binding_uri")).thenReturn('/aai/v8/network/vpn-bindings/vpn-binding')
\r
156 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/')
\r
158 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
159 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
160 def uri = aaiUtil.getNetworkVpnBindingUri(mockExecution)
\r
161 assertEquals('/aai/v8/network/vpn-bindings/vpn-binding', uri)
\r
165 public void testGetNetworkPolicyUri() {
\r
166 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
\r
167 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
168 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8')
\r
169 when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_network_policy_uri")).thenReturn('/aai/v8/network/network-policies/network-policy')
\r
170 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/')
\r
172 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
173 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
174 def uri = aaiUtil.getNetworkPolicyUri(mockExecution)
\r
175 assertEquals('/aai/v8/network/network-policies/network-policy', uri)
\r
179 public void testGetNetworkTableReferencesUri() {
\r
180 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
\r
181 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
182 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8')
\r
183 when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_route_table_reference_uri")).thenReturn('/aai/v8/network/route-table-references/route-table-reference')
\r
184 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/')
\r
186 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
187 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
188 def uri = aaiUtil.getNetworkTableReferencesUri(mockExecution)
\r
189 assertEquals('/aai/v8/network/route-table-references/route-table-reference', uri)
\r
193 public void testGetNetworkVceUri() {
\r
194 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
\r
195 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
196 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8')
\r
197 when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vce_uri")).thenReturn('/aai/v8/network/vces/vce')
\r
198 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/')
\r
200 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
201 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
202 def uri = aaiUtil.getNetworkVceUri(mockExecution)
\r
203 assertEquals('/aai/v8/network/vces/vce', uri)
\r
207 public void testGetNetworkL3NetworkUri() {
\r
208 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
\r
209 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
210 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8')
\r
211 when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn('/aai/v8/network/l3-networks/l3-network')
\r
212 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/')
\r
214 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
215 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
216 def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution)
\r
217 assertEquals('/aai/v8/network/l3-networks/l3-network', uri)
\r
221 public void testGetBusinessCustomerUri() {
\r
222 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
\r
223 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
224 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8')
\r
225 when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_customer_uri")).thenReturn('/aai/v8/business/customers/customer')
\r
226 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/')
\r
228 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
229 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
230 def uri = aaiUtil.getBusinessCustomerUri(mockExecution)
\r
231 assertEquals('/aai/v8/business/customers/customer', uri)
\r
235 public void testGetCloudInfrastructureCloudRegionEndpoint() {
\r
236 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
\r
237 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
238 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8')
\r
239 when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic')
\r
240 when(mockExecution.getVariable('URN_aai_endpoint')).thenReturn('http://localhost:28090')
\r
241 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/')
\r
243 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
244 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
245 def uri = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(mockExecution)
\r
246 assertEquals('http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic', uri)
\r
250 public void testGetCloudInfrastructureCloudRegionUri() {
\r
251 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
\r
252 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
253 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8')
\r
254 when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic')
\r
255 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/')
\r
257 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
258 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
259 def uri = aaiUtil.getCloudInfrastructureCloudRegionUri(mockExecution)
\r
260 assertEquals('/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic', uri)
\r
264 public void testGetCloudInfrastructureTenantUri() {
\r
265 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
\r
266 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
267 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8')
\r
268 when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_tenant_uri")).thenReturn('/aai/v8/cloud-infrastructure/tenants/tenant')
\r
269 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/')
\r
271 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
272 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
273 def uri = aaiUtil.getCloudInfrastructureTenantUri(mockExecution)
\r
274 assertEquals('/aai/v8/cloud-infrastructure/tenants/tenant', uri)
\r
278 public void testGetSearchNodesQueryUri() {
\r
279 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
\r
280 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
281 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8')
\r
282 when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_nodes_query_uri")).thenReturn('/aai/v8/search/nodes-query')
\r
283 when(mockExecution.getVariable('URN_aai_endpoint')).thenReturn('http://localhost:28090')
\r
284 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/')
\r
286 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
287 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
288 def uri = aaiUtil.getSearchNodesQueryUri(mockExecution)
\r
289 assertEquals('/aai/v8/search/nodes-query', uri)
\r
293 public void testGetSearchNodesQueryEndpoint() {
\r
294 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
\r
295 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
296 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8')
\r
297 when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_nodes_query_uri")).thenReturn('/aai/v8/search/nodes-query')
\r
298 when(mockExecution.getVariable('URN_aai_endpoint')).thenReturn('http://localhost:28090')
\r
299 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/')
\r
301 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
302 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
303 def uri = aaiUtil.getSearchNodesQueryEndpoint(mockExecution)
\r
304 assertEquals('http://localhost:28090/aai/v8/search/nodes-query', uri)
\r
308 public void testGetSearchGenericQueryUri() {
\r
309 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
\r
310 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
311 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('8')
\r
312 when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_generic_query_uri")).thenReturn('/aai/v8/search/generic-query')
\r
313 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/')
\r
315 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
316 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
317 def uri = aaiUtil.getSearchGenericQueryUri(mockExecution)
\r
318 assertEquals('/aai/v8/search/generic-query', uri)
\r
322 public void testGetNamespaceFromUri() {
\r
323 ExecutionEntity mockExecution = setupMock('CreateAAIVfModule')
\r
324 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
325 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('6')
\r
326 when(mockExecution.getVariable("URN_mso_workflow_default_aai_v6_l3_network_uri")).thenReturn('/aai/v6/network/l3-networks/l3-network')
\r
327 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/')
\r
328 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
329 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
330 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
331 def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) // Required to populate the namespace in the class
\r
332 def ns = aaiUtil.getNamespaceFromUri('/aai/v6/search/generic-query')
\r
333 assertEquals('http://org.openecomp.aai.inventory/v6', ns)
\r
337 public void testGetNamespaceFromUri2() {
\r
338 ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1')
\r
340 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
341 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('10')
\r
342 when(mockExecution.getVariable("URN_mso_workflow_default_aai_v10_l3_network_uri")).thenReturn('/aai/v10/network/l3-networks/l3-network')
\r
343 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/')
\r
345 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
346 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
347 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
348 def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) // Required to populate the namespace in the class
\r
349 def ns = aaiUtil.getNamespaceFromUri('/aai/v10/search/generic-query')
\r
350 assertEquals('http://org.openecomp.aai.inventory/v10', ns)
\r
354 public void testGetNamespaceFromUri3() {
\r
355 ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1')
\r
357 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
358 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('100')
\r
359 when(mockExecution.getVariable("URN_mso_workflow_default_aai_v100_l3_network_uri")).thenReturn('/aai/v100/network/l3-networks/l3-network')
\r
360 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/')
\r
362 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
363 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
364 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
365 def uri = aaiUtil.getNetworkL3NetworkUri(mockExecution) // Required to populate the namespace in the class
\r
366 def ns = aaiUtil.getNamespaceFromUri('/aai/v100/search/generic-query')
\r
367 assertEquals('http://org.openecomp.aai.inventory/v100', ns)
\r
371 public void testGetNamespaceFromUri_twoArguments() { // (execution, uri)
\r
372 ExecutionEntity mockExecution = setupMock('DeleteVfModuleVolumeInfraV1')
\r
374 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
375 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn('10')
\r
376 when(mockExecution.getVariable("URN_mso_workflow_default_aai_v10_l3_network_uri")).thenReturn('/aai/v10/network/l3-networks/l3-network')
\r
377 when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_namespace")).thenReturn('http://org.openecomp.aai.inventory/')
\r
379 when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn('true')
\r
380 CreateAAIVfModule myproc = new CreateAAIVfModule()
\r
381 AaiUtil aaiUtil = new AaiUtil(myproc)
\r
382 def ns = aaiUtil.getNamespaceFromUri(mockExecution,'/aai/v10/search/generic-query')
\r
383 assertEquals('http://org.openecomp.aai.inventory/v10', ns)
\r