5d29a7234161a601bb2304dce50054d0df988645
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2020  Telecom Italia
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.infrastructure.scripts
22
23 import com.fasterxml.jackson.databind.ObjectMapper
24 import org.junit.Before
25 import org.junit.Test
26 import org.mockito.Mockito
27 import org.onap.aai.domain.yang.*
28 import org.onap.aaiclient.client.aai.AAIObjectType
29 import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
30 import org.onap.aaiclient.client.aai.entities.Relationships
31 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
32 import org.onap.aaiclient.client.aai.entities.uri.AAISimpleUri
33 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
34 import org.onap.aaiclient.client.aai.entities.uri.ServiceInstanceUri
35 import org.onap.so.bpmn.common.scripts.MsoGroovyTest
36 import org.onap.so.serviceinstancebeans.RequestDetails
37
38 import static org.junit.Assert.assertNotNull
39 import static org.junit.Assert.assertTrue
40 import static org.mockito.Mockito.*
41
42 class DoCommonCoreNSSITest extends MsoGroovyTest {
43     @Before
44     void init() throws IOException {
45         super.init("DoCommonCoreNSSITest")
46     }
47
48
49     @Test
50     void testPreProcessRequest() {
51         def currentNSSI = [:]
52         currentNSSI.put("nssiId","5G-999")
53         when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
54
55         DoCommonCoreNSSI dcnssi = new DoCommonCoreNSSI()
56         dcnssi.preProcessRequest(mockExecution)
57         Mockito.verify(mockExecution,times(1)).getVariable("currentNSSI")
58     }
59
60
61     @Test
62     void testGetNetworkServiceInstance() {
63         def currentNSSI = [:]
64         currentNSSI.put("nssiId","5G-999")
65
66         when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
67
68         AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5G-999")
69         AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "NS-777")
70
71         ServiceInstance nssi = new ServiceInstance()
72         nssi.setServiceInstanceId("5G-999")
73
74         ServiceInstance networkServiceInstance = new ServiceInstance()
75         networkServiceInstance.setServiceInstanceId("NS-777")
76         networkServiceInstance.setServiceRole("Network Service")
77
78         Optional<ServiceInstance> nssiOpt = Optional.of(nssi)
79         Optional<ServiceInstance> networkServiceInstaneOpt = Optional.of(networkServiceInstance)
80
81         DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
82         when(spy.getAAIClient()).thenReturn(client)
83
84         when(client.get(ServiceInstance.class, nssiUri)).thenReturn(nssiOpt)
85
86         //String json = FileUtil.readResourceFile("__files/AAI/ServiceInstanceWithAR.json")
87         AAIResultWrapper wrapperMock = mock(AAIResultWrapper.class) //new AAIResultWrapper(json)
88         Relationships rsMock = mock(Relationships.class)
89         Optional<Relationships> orsMock = Optional.of(rsMock)
90         List<AAIResourceUri> arus = new ArrayList<>()
91         AAIResourceUri aru = new ServiceInstanceUri(networkServiceInstanceUri)
92         arus.add(aru)
93
94         when(client.get(nssiUri)).thenReturn(wrapperMock)
95         when(wrapperMock.getRelationships()).thenReturn(orsMock)
96
97         when(rsMock.getRelatedAAIUris(AAIObjectType.SERVICE_INSTANCE)).thenReturn(arus)
98         when(client.get(ServiceInstance.class, aru)).thenReturn(networkServiceInstaneOpt)
99
100         spy.getNetworkServiceInstance(mockExecution)
101
102         assertTrue("Either NSSI doesn't exist or unexpected NSSI Service Instance ID",
103                 currentNSSI.get("nssi") != null && ((ServiceInstance)currentNSSI.get("nssi")).getServiceInstanceId().equals(nssi.getServiceInstanceId()))
104
105         assertTrue("Either Network Service Instance doesn't exist or unexpected Network Service Instance ID",
106                 currentNSSI.get("networkServiceInstance") != null && ((ServiceInstance)currentNSSI.get("networkServiceInstance")).getServiceInstanceId().equals(networkServiceInstance.getServiceInstanceId()))
107
108         assertNotNull("networkServiceInstanceUri doesn't exist", currentNSSI.get("networkServiceInstanceUri"))
109     }
110
111
112     @Test
113     void getConstituteVNFFromNetworkServiceInst() {
114         def currentNSSI = [:]
115
116         when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
117
118         DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
119         when(spy.getAAIClient()).thenReturn(client)
120
121         ServiceInstance networkServiceInstance = new ServiceInstance()
122         networkServiceInstance.setServiceInstanceId("NS-777")
123         networkServiceInstance.setServiceRole("Network Service")
124
125         GenericVnf genericVNF = new GenericVnf()
126         genericVNF.setVnfId("VNF-1")
127
128         AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, networkServiceInstance.getServiceInstanceId())
129
130         Optional<GenericVnf> genericVnfOpt = Optional.of(genericVNF)
131         AAIResourceUri genericVNFUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVNF.getVnfId())
132
133         currentNSSI.put("networkServiceInstanceUri", networkServiceInstanceUri)
134         currentNSSI.put("networkServiceInstance", networkServiceInstance)
135
136         AAIResultWrapper wrapperMock = mock(AAIResultWrapper.class) //new AAIResultWrapper(json)
137         Relationships rsMock = mock(Relationships.class)
138         Optional<Relationships> orsMock = Optional.of(rsMock)
139         List<AAIResourceUri> arus = new ArrayList<>()
140         AAIResourceUri aru = new AAISimpleUri(genericVNFUri)
141         arus.add(aru)
142
143         when(client.get(networkServiceInstanceUri)).thenReturn(wrapperMock)
144         when(wrapperMock.getRelationships()).thenReturn(orsMock)
145
146         when(rsMock.getRelatedAAIUris(AAIObjectType.GENERIC_VNF)).thenReturn(arus)
147         when(client.get(GenericVnf.class, genericVNFUri)).thenReturn(genericVnfOpt)
148
149         spy.getConstituteVNFFromNetworkServiceInst(mockExecution)
150
151         assertNotNull("constituteVnfUri doesn't exist", currentNSSI.get("constituteVnfUri"))
152
153         assertTrue("Either Constitute VNF doesn't exist or unexpected VNF ID",
154                 currentNSSI.get("constituteVnf") != null && ((GenericVnf)currentNSSI.get("constituteVnf")).getVnfId().equals(genericVNF.getVnfId()))
155     }
156
157
158     @Test
159     void testGetNSSIAssociatedProfiles() {
160         def currentNSSI = [:]
161         when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
162
163         ServiceInstance nssi = new ServiceInstance()
164         nssi.setServiceInstanceId("5G-999")
165
166         SliceProfiles sliceProfiles = new SliceProfiles()
167
168         List<SliceProfile> slProfiles = sliceProfiles.getSliceProfile()
169         slProfiles.add(new SliceProfile())
170         slProfiles.add(new SliceProfile())
171
172         nssi.setSliceProfiles(sliceProfiles)
173         currentNSSI.put("nssi", nssi)
174
175         DoCommonCoreNSSI obj = new DoCommonCoreNSSI()
176         obj.getNSSIAssociatedProfiles(mockExecution)
177
178         List<SliceProfile> associatedProfiles = (List<SliceProfile>)currentNSSI.get("associatedProfiles")
179         assertTrue("Either associatedProfiles doesn't exist or size is incorrect", (associatedProfiles != null && associatedProfiles.size() == 2))
180     }
181
182
183     @Test
184     void testInvokePUTServiceInstance() {
185         def currentNSSI = [:]
186
187         ServiceInstance networkServiceInstance = new ServiceInstance()
188         networkServiceInstance.setServiceInstanceId("NS-777")
189         networkServiceInstance.setServiceRole("Network Service")
190
191         GenericVnf constituteVnf = new GenericVnf()
192         constituteVnf.setVnfId("VNF-1")
193
194         when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
195
196         currentNSSI.put("networkServiceInstance", networkServiceInstance)
197         currentNSSI.put("constituteVnf", constituteVnf)
198
199         when(mockExecution.getVariable("mso.infra.endpoint.url")).thenReturn("http://mso.onap:8088")
200         when(mockExecution.getVariable("mso.msoKey")).thenReturn("mso.msoKey")
201         when(mockExecution.getVariable("mso.infra.endpoint.auth")).thenReturn("mso.infra.endpoint.auth")
202
203         DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
204         when(spy.getAAIClient()).thenReturn(client)
205
206         when(spy.encryptBasicAuth("mso.infra.endpoint.auth", "mso.msoKey")).thenReturn("auth-value")
207
208         String authHeaderResponse =  "auth-header"
209
210         when(spy.getAuthHeader(mockExecution, "auth-value", "mso.msoKey")).thenReturn(authHeaderResponse)
211
212         String urlString = String.format("http://mso.onap:8088/serviceInstantiation/v7/serviceInstances/%s/vnfs/%s", networkServiceInstance.getServiceInstanceId(), constituteVnf.getVnfId())
213
214         String callPUTServiceInstanceResponse = "put"
215
216         RequestDetails requestDetails = new RequestDetails()
217         ObjectMapper mapper = new ObjectMapper()
218         String requestDetailsStr = mapper.writeValueAsString(requestDetails)
219
220         when(spy.prepareRequestDetails(mockExecution)).thenReturn(requestDetailsStr)
221
222         when(spy.callPUTServiceInstance(urlString, "auth-header", requestDetailsStr)).thenReturn(callPUTServiceInstanceResponse)
223
224         spy.invokePUTServiceInstance(mockExecution)
225     }
226
227
228     @Test
229     void testRemoveSPAssociationWithNSSI() {
230         def currentNSSI = [:]
231
232         when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
233
234         String nssiId = "5G-999"
235         currentNSSI.put("nssiId", nssiId)
236         ServiceInstance nssi = new ServiceInstance()
237         nssi.setServiceInstanceId(nssiId)
238         nssi.setSliceProfiles(new SliceProfiles())
239
240         currentNSSI.put("nssi", nssi)
241
242         AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId)
243
244         DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
245
246         when(spy.getAAIClient()).thenReturn(client)
247
248         String theSNSSAI = "theS-NSSAI"
249         currentNSSI.put("S-NSSAI", theSNSSAI)
250
251         List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile()
252
253         SliceProfile sliceProfile1 = new SliceProfile()
254         sliceProfile1.setSNssai("snssai1")
255
256         SliceProfile sliceProfile2 = new SliceProfile()
257         sliceProfile2.setSNssai(theSNSSAI)
258
259         SliceProfile sliceProfile3 = new SliceProfile()
260         sliceProfile3.setSNssai("snssai3")
261
262         associatedProfiles.add(sliceProfile1)
263         associatedProfiles.add(sliceProfile2)
264         associatedProfiles.add(sliceProfile3)
265
266         int sizeBefore = associatedProfiles.size()
267
268         doNothing().when(client).update(nssiUri, nssi)
269
270         spy.removeSPAssociationWithNSSI(mockExecution)
271
272         assertTrue("Association between slice profile and NSSI wasn't removed", ((ServiceInstance)currentNSSI.get("nssi")).getSliceProfiles().getSliceProfile().size() == (sizeBefore - 1))
273     }
274
275
276     @Test
277     void testDeleteSliceProfileInstance() {
278         def currentNSSI = [:]
279
280         when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
281
282         String globalSubscriberId = "global-id"
283         String serviceType = "service"
284         String nssiId = "5G-999"
285
286         currentNSSI.put("globalSubscriberId", globalSubscriberId)
287         currentNSSI.put("serviceType", serviceType)
288         currentNSSI.put("nssiId", nssiId)
289
290         String theSNSSAI = "theS-NSSAI"
291
292         SliceProfile sliceProfile = new SliceProfile()
293         sliceProfile.setSNssai(theSNSSAI)
294         sliceProfile.setProfileId("prof-id")
295
296         AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId)
297
298         currentNSSI.put("sliceProfileS-NSSAI", sliceProfile)
299
300         DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
301
302         when(spy.getAAIClient()).thenReturn(client)
303
304         doNothing().when(client).delete(nssiUri)
305
306         spy.deleteSliceProfileInstance(mockExecution)
307
308     }
309
310
311     @Test
312     void testUpdateServiceOperationStatus() {
313         def currentNSSI = [:]
314
315         when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
316
317         String nssiId = "5G-999"
318
319         currentNSSI.put("nssiId", nssiId)
320         currentNSSI.put("e2eServiceInstanceId", "e2eServiceInstanceId")
321         currentNSSI.put("operationId", "operationId")
322         currentNSSI.put("operationType", "operationType")
323
324         DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
325
326         spy.updateServiceOperationStatus(mockExecution)
327
328     }
329
330
331     @Test
332     void testPrepareRequestDetails() {
333         def currentNSSI = [:]
334
335         when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
336
337         ServiceInstance networkServiceInstance = new ServiceInstance()
338         networkServiceInstance.setServiceInstanceId("NS-777")
339         networkServiceInstance.setServiceRole("Network Service")
340         networkServiceInstance.setModelInvariantId("model-invariant-id")
341         networkServiceInstance.setServiceInstanceName("service-instance-name")
342
343         ServiceInstance nssi = new ServiceInstance()
344         nssi.setServiceInstanceId("5G-999")
345         nssi.setOrchestrationStatus("orchestration-status")
346
347         AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "networkServiceInstance.getServiceInstanceId()")
348
349         AAIResourceUri cloudRegionAAIUri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, "cloud-owner", "cloud-region-id")
350
351         currentNSSI.put("networkServiceInstanceUri", networkServiceInstanceUri)
352
353         currentNSSI.put("networkServiceInstance", networkServiceInstance)
354
355         currentNSSI.put("globalSubscriberId", "globalSubscriberId")
356
357         currentNSSI.put("subscriberName", "subscriber-name")
358
359         currentNSSI.put("serviceId", "service-id")
360
361         currentNSSI.put("nssi", nssi)
362
363         List<SliceProfile> associatedProfiles = new ArrayList<>()
364         SliceProfile sliceProfile1 = new SliceProfile()
365         sliceProfile1.setSNssai("snssai1")
366
367         SliceProfile sliceProfile2 = new SliceProfile()
368         sliceProfile2.setSNssai("snssai2")
369
370         associatedProfiles.add(sliceProfile1)
371         associatedProfiles.add(sliceProfile2)
372
373         List<String> snssais = new ArrayList<>()
374         snssais.add(sliceProfile1.getSNssai())
375         snssais.add(sliceProfile2.getSNssai())
376
377         currentNSSI.put("S-NSSAIs", snssais)
378
379
380         ServiceSubscription serviceSubscription = new ServiceSubscription()
381         serviceSubscription.setServiceType("service-type")
382
383         currentNSSI.put("serviceSubscription", serviceSubscription)
384
385         GenericVnf genericVnf = new GenericVnf()
386         genericVnf.setServiceId("service-id")
387         genericVnf.setVnfName("vnf-name")
388         genericVnf.setModelInvariantId("model-invariant-id")
389         genericVnf.setModelCustomizationId("model-customization-id")
390         genericVnf.setVnfName("vnf-name")
391         genericVnf.setVnfId("vnf-id")
392
393         VfModule vfModule = new VfModule()
394         vfModule.setModelInvariantId("model-invariant-id")
395         vfModule.setModelCustomizationId("model-customization-id")
396         vfModule.setModelVersionId("model-version-id")
397         vfModule.setVfModuleName("vf-module-name")
398
399         VfModules vfModules = new VfModules()
400         vfModules.getVfModule().add(vfModule)
401         genericVnf.setVfModules(vfModules)
402
403         currentNSSI.put("constituteVnf", genericVnf)
404
405         AAIResourceUri constituteVNFURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVnf.getVnfId())
406
407         currentNSSI.put("constituteVnfUri", constituteVNFURI)
408
409         DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
410
411         when(spy.getAAIClient()).thenReturn(client)
412
413         prepareModelVer(networkServiceInstance)
414
415         //prepareSubscriberInfo(networkServiceInstanceUri)
416
417         prepareCloudConfiguration(constituteVNFURI, cloudRegionAAIUri)
418
419         prepareModelVer(genericVnf)
420
421         prepareModelVer(vfModule)
422
423         prepareOwningEntity(networkServiceInstanceUri)
424
425         prepareProject(cloudRegionAAIUri)
426
427         String requestDetails = spy.prepareRequestDetails(mockExecution)
428
429     }
430
431
432     void prepareProject(AAIResourceUri cloudRegionAAIUri) {
433         Project project = new Project()
434         project.setProjectName("project-name")
435
436         AAIResultWrapper wrapperMock = mock(AAIResultWrapper.class)
437         Relationships rsMock = mock(Relationships.class)
438         Optional<Relationships> orsMock = Optional.of(rsMock)
439
440         when(client.get(cloudRegionAAIUri)).thenReturn(wrapperMock)
441         when(wrapperMock.getRelationships()).thenReturn(orsMock)
442
443         List<AAIResourceUri> arus = new ArrayList<>()
444         AAIResourceUri aru = new AAISimpleUri(cloudRegionAAIUri)
445         arus.add(aru)
446
447         when(rsMock.getRelatedAAIUris(AAIObjectType.PROJECT)).thenReturn(arus)
448
449         Optional<Project> projectOpt = Optional.of(project)
450
451         when(client.get(Project.class, aru)).thenReturn(projectOpt)
452     }
453
454
455     void prepareOwningEntity(AAIResourceUri networkServiceInstanceUri) {
456         OwningEntity owningEntity = new OwningEntity()
457
458         owningEntity.setOwningEntityId("owning-entity-id")
459         owningEntity.setOwningEntityName("owning-entity-name")
460
461         AAIResultWrapper wrapperMock = mock(AAIResultWrapper.class)
462
463         Relationships rsMock = mock(Relationships.class)
464         Optional<Relationships> orsMock = Optional.of(rsMock)
465
466         when(client.get(networkServiceInstanceUri)).thenReturn(wrapperMock)
467         when(wrapperMock.getRelationships()).thenReturn(orsMock)
468
469         List<AAIResourceUri> arus = new ArrayList<>()
470         AAIResourceUri aru = new AAISimpleUri(networkServiceInstanceUri)
471         arus.add(aru)
472
473         when(rsMock.getRelatedAAIUris(AAIObjectType.OWNING_ENTITY)).thenReturn(arus)
474
475         Optional<OwningEntity> owningEntityOpt = Optional.of(owningEntity)
476
477         when(client.get(OwningEntity.class, aru)).thenReturn(owningEntityOpt)
478     }
479
480
481
482     void prepareCloudConfiguration(AAIResourceUri constituteVNFURI, cloudRegionAAIUri) {
483         AAIResultWrapper wrapperMock = mock(AAIResultWrapper.class)
484
485         Relationships rsMock = mock(Relationships.class)
486         Optional<Relationships> orsMock = Optional.of(rsMock)
487
488         when(client.get(constituteVNFURI)).thenReturn(wrapperMock)
489         when(wrapperMock.getRelationships()).thenReturn(orsMock)
490
491         List<AAIResourceUri> arus = new ArrayList<>()
492         AAIResourceUri aru = new AAISimpleUri(cloudRegionAAIUri)
493         arus.add(aru)
494
495         when(rsMock.getRelatedAAIUris(AAIObjectType.CLOUD_REGION)).thenReturn(arus)
496
497         CloudRegion cloudRegion = new CloudRegion()
498         cloudRegion.setCloudRegionId("cloud-region-id")
499         cloudRegion.setCloudOwner("cloud-owner")
500         Tenant tenant = new Tenant()
501         tenant.setTenantId("tenant-id")
502
503         Tenants tenants = new Tenants()
504         tenants.getTenant().add(tenant)
505         cloudRegion.setTenants(tenants)
506         Optional<CloudRegion> cloudRegionOpt = Optional.of(cloudRegion)
507
508         when(client.get(CloudRegion.class, aru)).thenReturn(cloudRegionOpt)
509     }
510
511
512     void prepareSubscriberInfo( AAIResourceUri networkServiceInstanceUri) {
513         AAIResultWrapper wrapperMock = mock(AAIResultWrapper.class)
514
515         Relationships rsMock = mock(Relationships.class)
516         Optional<Relationships> orsMock = Optional.of(rsMock)
517
518         when(client.get(networkServiceInstanceUri)).thenReturn(wrapperMock)
519         when(wrapperMock.getRelationships()).thenReturn(orsMock)
520
521         AAIResourceUri serviceSubscriptionUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_SUBSCRIPTION, "global-customer-id", "service-type")
522
523         AAIResourceUri customerUri = AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, "global-customer-id")
524         List<AAIResourceUri> arus = new ArrayList<>()
525
526         arus.add(serviceSubscriptionUri)
527
528         when(rsMock.getRelatedAAIUris(AAIObjectType.SERVICE_SUBSCRIPTION)).thenReturn(arus)
529
530         ServiceSubscription serviceSubscription = new ServiceSubscription()
531         serviceSubscription.setServiceType("service-type")
532         Optional<ServiceSubscription> serviceSubscriptionOpt = Optional.of(serviceSubscription)
533
534         when(client.get(ServiceSubscription.class, serviceSubscriptionUri)).thenReturn(serviceSubscriptionOpt)
535
536         when(client.get(networkServiceInstanceUri)).thenReturn(wrapperMock)
537
538         when(rsMock.getRelatedAAIUris(AAIObjectType.CUSTOMER)).thenReturn(arus)
539
540         Customer customer = new Customer()
541         customer.setSubscriberName("subscriber-name")
542         Optional<Customer> customerOpt = Optional.of(customer)
543
544         when(client.get(Customer.class, customerUri)).thenReturn(customerOpt)
545     }
546
547
548     void prepareModelVer(ServiceInstance networkServiceInstance) {
549         ModelVer modelVer = new ModelVer()
550         modelVer.setModelVersionId("model-version-id")
551         modelVer.setModelName("model-name")
552         modelVer.setModelVersion("model-version")
553
554         Optional<ModelVer> modelVerOpt = Optional.of(modelVer)
555
556         AAIResourceUri modelVerUrl = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, networkServiceInstance.getModelInvariantId(), networkServiceInstance.getModelVersionId())
557         when(client.get(ModelVer.class, modelVerUrl)).thenReturn(modelVerOpt)
558     }
559
560     void prepareModelVer(GenericVnf genericVnf) {
561         ModelVer modelVer = new ModelVer()
562         modelVer.setModelVersionId("model-version-id")
563         modelVer.setModelName("model-name")
564         modelVer.setModelVersion("model-version")
565
566         Optional<ModelVer> modelVerOpt = Optional.of(modelVer)
567
568         AAIResourceUri modelVerUrl = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, genericVnf.getModelInvariantId(), genericVnf.getModelVersionId())
569         when(client.get(ModelVer.class, modelVerUrl)).thenReturn(modelVerOpt)
570     }
571
572     void prepareModelVer(VfModule vfModule) {
573         ModelVer modelVer = new ModelVer()
574         modelVer.setModelVersionId("model-version-id")
575         modelVer.setModelName("model-name")
576         modelVer.setModelVersion("model-version")
577
578         Optional<ModelVer> modelVerOpt = Optional.of(modelVer)
579
580         AAIResourceUri modelVerUrl = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, vfModule.getModelInvariantId(), vfModule.getModelVersionId())
581         when(client.get(ModelVer.class, modelVerUrl)).thenReturn(modelVerOpt)
582     }
583 }