2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.bpmn.infrastructure.scripts
23 import com.fasterxml.jackson.databind.ObjectMapper
24 import org.junit.Before
26 import org.mockito.Mockito
27 import org.onap.aai.domain.yang.v19.*
28 import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
29 import org.onap.aaiclient.client.aai.entities.Relationships
30 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
31 import org.onap.aaiclient.client.aai.entities.uri.AAISimpleUri
32 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
33 import org.onap.aaiclient.client.aai.entities.uri.ServiceInstanceUri
34 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
35 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
36 import org.onap.so.bpmn.common.scripts.ExternalAPIUtil
37 import org.onap.so.bpmn.common.scripts.ExternalAPIUtilFactory
38 import org.onap.so.bpmn.common.scripts.MsoGroovyTest
39 import org.onap.so.serviceinstancebeans.RequestDetails
41 import javax.ws.rs.core.Response
42 import java.time.Instant
44 import static org.junit.Assert.assertNotNull
45 import static org.junit.Assert.assertTrue
46 import static org.mockito.Mockito.*
48 class DoCommonCoreNSSITest extends MsoGroovyTest {
50 void init() throws IOException {
51 super.init("DoCommonCoreNSSITest")
56 void testPreProcessRequest() {
58 String nssiId = "5G-999"
59 when(mockExecution.getVariable("serviceInstanceID")).thenReturn(nssiId)
61 String nsiId = "5G-777"
62 when(mockExecution.getVariable("nsiId")).thenReturn(nsiId)
64 String snssai = "S-NSSAI"
65 String snssaiList = "[ \"${snssai}\" ]"
66 String sliceProfileId = "slice-profile-id"
67 String sliceParams = "{\n" +
68 "\"sliceProfile\":{\"sliceProfileId\":\"${sliceProfileId}\",\"snssaiList\":${snssaiList}}\n" +
70 when(mockExecution.getVariable("sliceParams")).thenReturn(sliceParams)
72 DoCommonCoreNSSI dcnssi = new DoCommonCoreNSSI()
73 dcnssi.preProcessRequest(mockExecution)
76 currentNSSI.put("nssiId", nssiId)
77 currentNSSI.put("nsiId", nsiId)
78 currentNSSI.put("sliceProfile", "{\"sliceProfileId\":\"slice-profile-id\",\"snssaiList\":[\"S-NSSAI\"]}")
79 currentNSSI.put("S-NSSAI", snssai)
80 currentNSSI.put("sliceProfileId", sliceProfileId)
81 Mockito.verify(mockExecution,times(1)).setVariable("currentNSSI", currentNSSI)
87 void testGetNetworkServiceInstance() {
89 currentNSSI.put("nssiId","5G-999")
91 when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
93 AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment("5G-999"))
94 AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment("NS-777"))
96 ServiceInstance nssi = new ServiceInstance()
97 nssi.setServiceInstanceId("5G-999")
99 ServiceInstance networkServiceInstance = new ServiceInstance()
100 networkServiceInstance.setServiceInstanceId("NS-777")
101 networkServiceInstance.setServiceRole("Network Service")
103 Optional<ServiceInstance> nssiOpt = Optional.of(nssi)
104 Optional<ServiceInstance> networkServiceInstaneOpt = Optional.of(networkServiceInstance)
106 DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
107 when(spy.getAAIClient()).thenReturn(client)
109 when(client.get(ServiceInstance.class, nssiUri)).thenReturn(nssiOpt)
111 //String json = FileUtil.readResourceFile("__files/AAI/ServiceInstanceWithAR.json")
112 AAIResultWrapper wrapperMock = mock(AAIResultWrapper.class) //new AAIResultWrapper(json)
113 Relationships rsMock = mock(Relationships.class)
114 Optional<Relationships> orsMock = Optional.of(rsMock)
115 List<AAIResourceUri> arus = new ArrayList<>()
116 AAIResourceUri aru = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(networkServiceInstance.getServiceInstanceId()))
119 when(client.get(nssiUri)).thenReturn(wrapperMock)
120 when(wrapperMock.getRelationships()).thenReturn(orsMock)
122 when(rsMock.getRelatedUris(Types.SERVICE_INSTANCE)).thenReturn(arus)
123 when(client.get(ServiceInstance.class, aru)).thenReturn(networkServiceInstaneOpt)
125 spy.getNetworkServiceInstance(mockExecution)
127 assertTrue("Either NSSI doesn't exist or unexpected NSSI Service Instance ID",
128 currentNSSI.get("nssi") != null && ((ServiceInstance)currentNSSI.get("nssi")).getServiceInstanceId().equals(nssi.getServiceInstanceId()))
130 assertTrue("Either Network Service Instance doesn't exist or unexpected Network Service Instance ID",
131 currentNSSI.get("networkServiceInstance") != null && ((ServiceInstance)currentNSSI.get("networkServiceInstance")).getServiceInstanceId().equals(networkServiceInstance.getServiceInstanceId()))
133 assertNotNull("networkServiceInstanceUri doesn't exist", currentNSSI.get("networkServiceInstanceUri"))
138 void getConstituteVNFFromNetworkServiceInst() {
139 def currentNSSI = [:]
141 when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
143 DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
144 when(spy.getAAIClient()).thenReturn(client)
146 ServiceInstance networkServiceInstance = new ServiceInstance()
147 networkServiceInstance.setServiceInstanceId("NS-777")
148 networkServiceInstance.setServiceRole("Network Service")
150 GenericVnf genericVNF = new GenericVnf()
151 genericVNF.setVnfId("VNF-1")
153 AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(networkServiceInstance.getServiceInstanceId()))
155 Optional<GenericVnf> genericVnfOpt = Optional.of(genericVNF)
156 AAIResourceUri genericVNFUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVNF.getVnfId()))
158 currentNSSI.put("networkServiceInstanceUri", networkServiceInstanceUri)
159 currentNSSI.put("networkServiceInstance", networkServiceInstance)
161 AAIResultWrapper wrapperMock = mock(AAIResultWrapper.class) //new AAIResultWrapper(json)
162 Relationships rsMock = mock(Relationships.class)
163 Optional<Relationships> orsMock = Optional.of(rsMock)
164 List<AAIResourceUri> arus = new ArrayList<>()
165 AAIResourceUri aru = new AAISimpleUri(genericVNFUri)
168 when(client.get(networkServiceInstanceUri)).thenReturn(wrapperMock)
169 when(wrapperMock.getRelationships()).thenReturn(orsMock)
171 when(rsMock.getRelatedUris(Types.GENERIC_VNF)).thenReturn(arus)
172 when(client.get(GenericVnf.class, genericVNFUri)).thenReturn(genericVnfOpt)
174 spy.getConstituteVNFFromNetworkServiceInst(mockExecution)
176 assertNotNull("constituteVnfUri doesn't exist", currentNSSI.get("constituteVnfUri"))
178 assertTrue("Either Constitute VNF doesn't exist or unexpected VNF ID",
179 currentNSSI.get("constituteVnf") != null && ((GenericVnf)currentNSSI.get("constituteVnf")).getVnfId().equals(genericVNF.getVnfId()))
184 void testGetNSSIAssociatedProfiles() {
185 def currentNSSI = [:]
186 when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
188 ServiceInstance nssi = new ServiceInstance()
189 nssi.setServiceInstanceId("5G-999")
191 SliceProfiles sliceProfiles = new SliceProfiles()
193 List<SliceProfile> slProfiles = sliceProfiles.getSliceProfile()
194 slProfiles.add(new SliceProfile())
195 slProfiles.add(new SliceProfile())
197 nssi.setSliceProfiles(sliceProfiles)
198 currentNSSI.put("nssi", nssi)
200 DoCommonCoreNSSI obj = new DoCommonCoreNSSI()
201 obj.getNSSIAssociatedProfiles(mockExecution)
203 List<SliceProfile> associatedProfiles = (List<SliceProfile>)currentNSSI.get("associatedProfiles")
204 assertTrue("Either associatedProfiles doesn't exist or size is incorrect", (associatedProfiles != null && associatedProfiles.size() == 2))
209 void testInvokePUTServiceInstance() {
210 def currentNSSI = [:]
212 ServiceInstance networkServiceInstance = new ServiceInstance()
213 networkServiceInstance.setServiceInstanceId("NS-777")
214 networkServiceInstance.setServiceRole("Network Service")
216 when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
218 currentNSSI.put("networkServiceInstance", networkServiceInstance)
220 when(mockExecution.getVariable("mso.infra.endpoint.url")).thenReturn("http://mso.onap:8088")
221 when(mockExecution.getVariable("mso.msoKey")).thenReturn("mso.msoKey")
222 when(mockExecution.getVariable("mso.infra.endpoint.auth")).thenReturn("mso.infra.endpoint.auth")
224 DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
225 when(spy.getAAIClient()).thenReturn(client)
227 when(spy.encryptBasicAuth("mso.infra.endpoint.auth", "mso.msoKey")).thenReturn("auth-value")
229 String authHeaderResponse = "auth-header"
231 when(spy.getAuthHeader(mockExecution, "auth-value", "mso.msoKey")).thenReturn(authHeaderResponse)
233 String urlString = String.format("http://mso.onap:8088/serviceInstantiation/v7/serviceInstances/%s", networkServiceInstance.getServiceInstanceId())
235 String callPUTServiceInstanceResponse = "put"
237 RequestDetails requestDetails = new RequestDetails()
238 ObjectMapper mapper = new ObjectMapper()
239 String requestDetailsStr = mapper.writeValueAsString(requestDetails)
241 when(spy.prepareRequestDetails(mockExecution)).thenReturn(requestDetailsStr)
243 when(spy.callPUTServiceInstance(urlString, "auth-header", requestDetailsStr)).thenReturn(callPUTServiceInstanceResponse)
245 spy.invokePUTServiceInstance(mockExecution)
250 void testRemoveSPAssociationWithNSSI() {
251 def currentNSSI = [:]
253 when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
255 String nssiId = "5G-999"
256 currentNSSI.put("nssiId", nssiId)
257 ServiceInstance nssi = new ServiceInstance()
258 nssi.setServiceInstanceId(nssiId)
259 nssi.setSliceProfiles(new SliceProfiles())
261 currentNSSI.put("nssi", nssi)
263 AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
265 DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
267 when(spy.getAAIClient()).thenReturn(client)
269 String theSNSSAI = "theS-NSSAI"
270 currentNSSI.put("S-NSSAI", theSNSSAI)
272 List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile()
274 SliceProfile sliceProfile1 = new SliceProfile()
275 sliceProfile1.setSNssai("snssai1")
277 SliceProfile sliceProfile2 = new SliceProfile()
278 sliceProfile2.setSNssai(theSNSSAI)
280 SliceProfile sliceProfile3 = new SliceProfile()
281 sliceProfile3.setSNssai("snssai3")
283 associatedProfiles.add(sliceProfile1)
284 associatedProfiles.add(sliceProfile2)
285 associatedProfiles.add(sliceProfile3)
287 int sizeBefore = associatedProfiles.size()
289 doNothing().when(client).update(nssiUri, nssi)
291 spy.removeSPAssociationWithNSSI(mockExecution)
293 assertTrue("Association between slice profile and NSSI wasn't removed", ((ServiceInstance)currentNSSI.get("nssi")).getSliceProfiles().getSliceProfile().size() == (sizeBefore - 1))
298 void testDeleteSliceProfileInstance() {
299 def currentNSSI = [:]
301 when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
303 String globalSubscriberId = "global-id"
304 String subscriptionServiceType = "subscription-service-type"
305 String nssiId = "5G-999"
307 when(mockExecution.getVariable("globalSubscriberId")).thenReturn(globalSubscriberId)
308 when(mockExecution.getVariable("subscriptionServiceType")).thenReturn(subscriptionServiceType)
310 currentNSSI.put("nssiId", nssiId)
312 String theSNSSAI = "theS-NSSAI"
314 SliceProfile sliceProfile = new SliceProfile()
315 sliceProfile.setSNssai(theSNSSAI)
316 sliceProfile.setProfileId("prof-id")
318 AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
320 currentNSSI.put("sliceProfileS-NSSAI", sliceProfile)
322 DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
324 when(spy.getAAIClient()).thenReturn(client)
326 doNothing().when(client).delete(nssiUri)
328 spy.deleteSliceProfileInstance(mockExecution)
334 void testPrepareRequestDetails() {
335 def currentNSSI = [:]
337 when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
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")
345 ServiceInstance nssi = new ServiceInstance()
346 nssi.setServiceInstanceId("5G-999")
347 nssi.setOrchestrationStatus("orchestration-status")
349 AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(networkServiceInstance.getServiceInstanceId()))
351 AAIResourceUri cloudRegionAAIUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion("cloud-owner", "cloud-region-id"))
353 currentNSSI.put("networkServiceInstanceUri", networkServiceInstanceUri)
355 currentNSSI.put("networkServiceInstance", networkServiceInstance)
357 currentNSSI.put("globalSubscriberId", "globalSubscriberId")
359 currentNSSI.put("subscriberName", "subscriber-name")
361 currentNSSI.put("serviceId", "service-id")
363 currentNSSI.put("nssi", nssi)
365 List<SliceProfile> associatedProfiles = new ArrayList<>()
366 SliceProfile sliceProfile1 = new SliceProfile()
367 sliceProfile1.setSNssai("snssai1")
369 SliceProfile sliceProfile2 = new SliceProfile()
370 sliceProfile2.setSNssai("snssai2")
372 associatedProfiles.add(sliceProfile1)
373 associatedProfiles.add(sliceProfile2)
375 List<String> snssais = new ArrayList<>()
376 snssais.add(sliceProfile1.getSNssai())
377 snssais.add(sliceProfile2.getSNssai())
379 currentNSSI.put("S-NSSAIs", snssais)
382 ServiceSubscription serviceSubscription = new ServiceSubscription()
383 serviceSubscription.setServiceType("service-type")
385 currentNSSI.put("serviceSubscription", serviceSubscription)
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")
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")
401 VfModules vfModules = new VfModules()
402 vfModules.getVfModule().add(vfModule)
403 genericVnf.setVfModules(vfModules)
405 currentNSSI.put("constituteVnf", genericVnf)
407 AAIResourceUri constituteVNFURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnf.getVnfId()))
409 currentNSSI.put("constituteVnfUri", constituteVNFURI)
411 DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
413 when(spy.getAAIClient()).thenReturn(client)
415 prepareModelVer(networkServiceInstance)
417 //prepareSubscriberInfo(networkServiceInstanceUri)
419 prepareCloudConfiguration(constituteVNFURI, cloudRegionAAIUri)
421 prepareModelVer(genericVnf)
423 prepareModelVer(vfModule)
425 prepareOwningEntity(networkServiceInstanceUri)
427 prepareProject(cloudRegionAAIUri)
429 String requestDetails = spy.prepareRequestDetails(mockExecution)
435 void testPrepareFailedOperationStatusUpdate() {
436 def currentNSSI = [:]
438 when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
439 when(mockExecution.getVariable("jobId")).thenReturn("job-id")
440 when(mockExecution.getVariable("operationType")).thenReturn("operation-type")
442 String nssiId = "5G-999"
443 String nsiId = "5G-777"
445 currentNSSI.put("nssiId", nssiId)
446 currentNSSI.put("nsiId", nsiId)
447 currentNSSI.put("e2eServiceInstanceId", "e2eServiceInstanceId")
448 currentNSSI.put("operationId", "operationId")
449 currentNSSI.put("operationType", "operationType")
451 DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
453 spy.prepareFailedOperationStatusUpdate(mockExecution)
458 void testPrepareUpdateResourceOperationStatus() {
459 def currentNSSI = [:]
461 when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
462 when(mockExecution.getVariable("jobId")).thenReturn("job-id")
463 when(mockExecution.getVariable("operationType")).thenReturn("operation-type")
465 String nssiId = "5G-999"
466 String nsiId = "5G-777"
468 currentNSSI.put("nssiId", nssiId)
469 currentNSSI.put("nsiId", nsiId)
470 currentNSSI.put("e2eServiceInstanceId", "e2eServiceInstanceId")
471 currentNSSI.put("operationId", "operationId")
472 currentNSSI.put("operationType", "operationType")
474 DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
476 spy.prepareUpdateResourceOperationStatus(mockExecution)
482 void testGetPUTServiceInstanceProgressAcknowledged() {
484 executePUTServiceInstanceProgress("ACKNOWLEDGED")
485 Mockito.verify(mockExecution,times(1)).setVariable("putStatus", "processing")
490 void testGetPUTServiceInstanceProgressInProgress() {
492 executePUTServiceInstanceProgress("INPROGRESS")
493 Mockito.verify(mockExecution,times(1)).setVariable("putStatus", "processing")
498 void testGetPUTServiceInstanceProgressCompleted() {
500 executePUTServiceInstanceProgress("COMPLETED")
501 Mockito.verify(mockExecution,times(1)).setVariable("putStatus", "completed")
506 void testTimeDelay() {
507 DoCommonCoreNSSI obj = spy(DoCommonCoreNSSI.class)
509 long before = Instant.now().toEpochMilli()
510 obj.timeDelay(mockExecution)
512 long after = Instant.now().toEpochMilli()
516 assertTrue(String.format("Didn't wait %d sec", delay), ((after - before) >= delay))
520 void executePUTServiceInstanceProgress(String state) {
522 def currentNSSI = [:]
524 when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
526 String url = "http://mso.onap:8088/serviceInstantiation/v7/serviceInstances/5G-777"
528 currentNSSI.put("putServiceInstanceURL", url)
530 DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
532 ExternalAPIUtilFactory externalAPIUtilFactoryMock = mock(ExternalAPIUtilFactory.class)
533 when(spy.getExternalAPIUtilFactory()).thenReturn(externalAPIUtilFactoryMock)
535 ExternalAPIUtil externalAPIUtilMock = mock(ExternalAPIUtil.class)
537 when(externalAPIUtilFactoryMock.create()).thenReturn(externalAPIUtilMock)
539 Response responseMock = mock(Response.class)
540 when(externalAPIUtilMock.executeExternalAPIGetCall(mockExecution, url)).thenReturn(responseMock)
542 when(responseMock.getStatus()).thenReturn(200)
544 String entity = "{\"state\":\"ACCEPTED\",\"orderItem\":[{\"service\":{\"id\":\"5G-999\"},\"state\":\"${state}\"}]}"
545 when(responseMock.readEntity(String.class)).thenReturn(entity)
547 spy.getPUTServiceInstanceProgress(mockExecution)
552 void prepareProject(AAIResourceUri cloudRegionAAIUri) {
553 Project project = new Project()
554 project.setProjectName("project-name")
556 AAIResultWrapper wrapperMock = mock(AAIResultWrapper.class)
557 Relationships rsMock = mock(Relationships.class)
558 Optional<Relationships> orsMock = Optional.of(rsMock)
560 when(client.get(cloudRegionAAIUri)).thenReturn(wrapperMock)
561 when(wrapperMock.getRelationships()).thenReturn(orsMock)
563 List<AAIResourceUri> arus = new ArrayList<>()
564 AAIResourceUri aru = new AAISimpleUri(cloudRegionAAIUri)
567 when(rsMock.getRelatedUris(Types.PROJECT)).thenReturn(arus)
569 Optional<Project> projectOpt = Optional.of(project)
571 when(client.get(Project.class, aru)).thenReturn(projectOpt)
575 void prepareOwningEntity(AAIResourceUri networkServiceInstanceUri) {
576 OwningEntity owningEntity = new OwningEntity()
578 owningEntity.setOwningEntityId("owning-entity-id")
579 owningEntity.setOwningEntityName("owning-entity-name")
581 AAIResultWrapper wrapperMock = mock(AAIResultWrapper.class)
583 Relationships rsMock = mock(Relationships.class)
584 Optional<Relationships> orsMock = Optional.of(rsMock)
586 when(client.get(networkServiceInstanceUri)).thenReturn(wrapperMock)
587 when(wrapperMock.getRelationships()).thenReturn(orsMock)
589 List<AAIResourceUri> arus = new ArrayList<>()
590 AAIResourceUri aru = new AAISimpleUri(networkServiceInstanceUri)
593 when(rsMock.getRelatedUris(Types.OWNING_ENTITY)).thenReturn(arus)
595 Optional<OwningEntity> owningEntityOpt = Optional.of(owningEntity)
597 when(client.get(OwningEntity.class, aru)).thenReturn(owningEntityOpt)
602 void prepareCloudConfiguration(AAIResourceUri constituteVNFURI, cloudRegionAAIUri) {
603 AAIResultWrapper wrapperMock = mock(AAIResultWrapper.class)
605 Relationships rsMock = mock(Relationships.class)
606 Optional<Relationships> orsMock = Optional.of(rsMock)
608 when(client.get(constituteVNFURI)).thenReturn(wrapperMock)
609 when(wrapperMock.getRelationships()).thenReturn(orsMock)
611 List<AAIResourceUri> arus = new ArrayList<>()
612 AAIResourceUri aru = new AAISimpleUri(cloudRegionAAIUri)
615 when(rsMock.getRelatedUris(Types.CLOUD_REGION)).thenReturn(arus)
617 CloudRegion cloudRegion = new CloudRegion()
618 cloudRegion.setCloudRegionId("cloud-region-id")
619 cloudRegion.setCloudOwner("cloud-owner")
620 Tenant tenant = new Tenant()
621 tenant.setTenantId("tenant-id")
623 Tenants tenants = new Tenants()
624 tenants.getTenant().add(tenant)
625 cloudRegion.setTenants(tenants)
626 Optional<CloudRegion> cloudRegionOpt = Optional.of(cloudRegion)
628 when(client.get(CloudRegion.class, aru)).thenReturn(cloudRegionOpt)
632 void prepareSubscriberInfo( AAIResourceUri networkServiceInstanceUri) {
633 AAIResultWrapper wrapperMock = mock(AAIResultWrapper.class)
635 Relationships rsMock = mock(Relationships.class)
636 Optional<Relationships> orsMock = Optional.of(rsMock)
638 when(client.get(networkServiceInstanceUri)).thenReturn(wrapperMock)
639 when(wrapperMock.getRelationships()).thenReturn(orsMock)
641 AAIResourceUri serviceSubscriptionUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("global-customer-id").serviceSubscription("service-type"))
643 AAIResourceUri customerUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("global-customer-id"))
644 List<AAIResourceUri> arus = new ArrayList<>()
646 arus.add(serviceSubscriptionUri)
648 when(rsMock.getRelatedUris(Types.SERVICE_SUBSCRIPTION)).thenReturn(arus)
650 ServiceSubscription serviceSubscription = new ServiceSubscription()
651 serviceSubscription.setServiceType("service-type")
652 Optional<ServiceSubscription> serviceSubscriptionOpt = Optional.of(serviceSubscription)
654 when(client.get(ServiceSubscription.class, serviceSubscriptionUri)).thenReturn(serviceSubscriptionOpt)
656 when(client.get(networkServiceInstanceUri)).thenReturn(wrapperMock)
658 when(rsMock.getRelatedUris(Types.CUSTOMER)).thenReturn(arus)
660 Customer customer = new Customer()
661 customer.setSubscriberName("subscriber-name")
662 Optional<Customer> customerOpt = Optional.of(customer)
664 when(client.get(Customer.class, customerUri)).thenReturn(customerOpt)
668 void prepareModelVer(ServiceInstance networkServiceInstance) {
669 ModelVer modelVer = new ModelVer()
670 modelVer.setModelVersionId("model-version-id")
671 modelVer.setModelName("model-name")
672 modelVer.setModelVersion("model-version")
674 Optional<ModelVer> modelVerOpt = Optional.of(modelVer)
676 AAIResourceUri modelVerUrl = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.serviceDesignAndCreation().model(networkServiceInstance.getModelInvariantId()).modelVer(networkServiceInstance.getModelVersionId()))
677 when(client.get(ModelVer.class, modelVerUrl)).thenReturn(modelVerOpt)
680 void prepareModelVer(GenericVnf genericVnf) {
681 ModelVer modelVer = new ModelVer()
682 modelVer.setModelVersionId("model-version-id")
683 modelVer.setModelName("model-name")
684 modelVer.setModelVersion("model-version")
686 Optional<ModelVer> modelVerOpt = Optional.of(modelVer)
688 AAIResourceUri modelVerUrl = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.serviceDesignAndCreation().model(genericVnf.getModelInvariantId()).modelVer(genericVnf.getModelVersionId()))
689 when(client.get(ModelVer.class, modelVerUrl)).thenReturn(modelVerOpt)
692 void prepareModelVer(VfModule vfModule) {
693 ModelVer modelVer = new ModelVer()
694 modelVer.setModelVersionId("model-version-id")
695 modelVer.setModelName("model-name")
696 modelVer.setModelVersion("model-version")
698 Optional<ModelVer> modelVerOpt = Optional.of(modelVer)
700 AAIResourceUri modelVerUrl = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.serviceDesignAndCreation().model(vfModule.getModelInvariantId()).modelVer(vfModule.getModelVersionId()))
701 when(client.get(ModelVer.class, modelVerUrl)).thenReturn(modelVerOpt)