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