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.*
 
  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
 
  38 import static org.junit.Assert.assertNotNull
 
  39 import static org.junit.Assert.assertTrue
 
  40 import static org.mockito.Mockito.*
 
  42 class DoCommonCoreNSSITest extends MsoGroovyTest {
 
  44     void init() throws IOException {
 
  45         super.init("DoCommonCoreNSSITest")
 
  50     void testPreProcessRequest() {
 
  52         currentNSSI.put("nssiId","5G-999")
 
  53         when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
 
  55         DoCommonCoreNSSI dcnssi = new DoCommonCoreNSSI()
 
  56         dcnssi.preProcessRequest(mockExecution)
 
  57         Mockito.verify(mockExecution,times(1)).getVariable("currentNSSI")
 
  62     void testGetNetworkServiceInstance() {
 
  64         currentNSSI.put("nssiId","5G-999")
 
  66         when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
 
  68         AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "5G-999")
 
  69         AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "NS-777")
 
  71         ServiceInstance nssi = new ServiceInstance()
 
  72         nssi.setServiceInstanceId("5G-999")
 
  74         ServiceInstance networkServiceInstance = new ServiceInstance()
 
  75         networkServiceInstance.setServiceInstanceId("NS-777")
 
  76         networkServiceInstance.setServiceRole("Network Service")
 
  78         Optional<ServiceInstance> nssiOpt = Optional.of(nssi)
 
  79         Optional<ServiceInstance> networkServiceInstaneOpt = Optional.of(networkServiceInstance)
 
  81         DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
 
  82         when(spy.getAAIClient()).thenReturn(client)
 
  84         when(client.get(ServiceInstance.class, nssiUri)).thenReturn(nssiOpt)
 
  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)
 
  94         when(client.get(nssiUri)).thenReturn(wrapperMock)
 
  95         when(wrapperMock.getRelationships()).thenReturn(orsMock)
 
  97         when(rsMock.getRelatedAAIUris(AAIObjectType.SERVICE_INSTANCE)).thenReturn(arus)
 
  98         when(client.get(ServiceInstance.class, aru)).thenReturn(networkServiceInstaneOpt)
 
 100         spy.getNetworkServiceInstance(mockExecution)
 
 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()))
 
 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()))
 
 108         assertNotNull("networkServiceInstanceUri doesn't exist", currentNSSI.get("networkServiceInstanceUri"))
 
 113     void getConstituteVNFFromNetworkServiceInst() {
 
 114         def currentNSSI = [:]
 
 116         when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
 
 118         DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
 
 119         when(spy.getAAIClient()).thenReturn(client)
 
 121         ServiceInstance networkServiceInstance = new ServiceInstance()
 
 122         networkServiceInstance.setServiceInstanceId("NS-777")
 
 123         networkServiceInstance.setServiceRole("Network Service")
 
 125         GenericVnf genericVNF = new GenericVnf()
 
 126         genericVNF.setVnfId("VNF-1")
 
 128         AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, networkServiceInstance.getServiceInstanceId())
 
 130         Optional<GenericVnf> genericVnfOpt = Optional.of(genericVNF)
 
 131         AAIResourceUri genericVNFUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVNF.getVnfId())
 
 133         currentNSSI.put("networkServiceInstanceUri", networkServiceInstanceUri)
 
 134         currentNSSI.put("networkServiceInstance", networkServiceInstance)
 
 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)
 
 143         when(client.get(networkServiceInstanceUri)).thenReturn(wrapperMock)
 
 144         when(wrapperMock.getRelationships()).thenReturn(orsMock)
 
 146         when(rsMock.getRelatedAAIUris(AAIObjectType.GENERIC_VNF)).thenReturn(arus)
 
 147         when(client.get(GenericVnf.class, genericVNFUri)).thenReturn(genericVnfOpt)
 
 149         spy.getConstituteVNFFromNetworkServiceInst(mockExecution)
 
 151         assertNotNull("constituteVnfUri doesn't exist", currentNSSI.get("constituteVnfUri"))
 
 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()))
 
 159     void testGetNSSIAssociatedProfiles() {
 
 160         def currentNSSI = [:]
 
 161         when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
 
 163         ServiceInstance nssi = new ServiceInstance()
 
 164         nssi.setServiceInstanceId("5G-999")
 
 166         SliceProfiles sliceProfiles = new SliceProfiles()
 
 168         List<SliceProfile> slProfiles = sliceProfiles.getSliceProfile()
 
 169         slProfiles.add(new SliceProfile())
 
 170         slProfiles.add(new SliceProfile())
 
 172         nssi.setSliceProfiles(sliceProfiles)
 
 173         currentNSSI.put("nssi", nssi)
 
 175         DoCommonCoreNSSI obj = new DoCommonCoreNSSI()
 
 176         obj.getNSSIAssociatedProfiles(mockExecution)
 
 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))
 
 184     void testInvokePUTServiceInstance() {
 
 185         def currentNSSI = [:]
 
 187         ServiceInstance networkServiceInstance = new ServiceInstance()
 
 188         networkServiceInstance.setServiceInstanceId("NS-777")
 
 189         networkServiceInstance.setServiceRole("Network Service")
 
 191         GenericVnf constituteVnf = new GenericVnf()
 
 192         constituteVnf.setVnfId("VNF-1")
 
 194         when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
 
 196         currentNSSI.put("networkServiceInstance", networkServiceInstance)
 
 197         currentNSSI.put("constituteVnf", constituteVnf)
 
 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")
 
 203         DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
 
 204         when(spy.getAAIClient()).thenReturn(client)
 
 206         when(spy.encryptBasicAuth("mso.infra.endpoint.auth", "mso.msoKey")).thenReturn("auth-value")
 
 208         String authHeaderResponse =  "auth-header"
 
 210         when(spy.getAuthHeader(mockExecution, "auth-value", "mso.msoKey")).thenReturn(authHeaderResponse)
 
 212         String urlString = String.format("http://mso.onap:8088/serviceInstantiation/v7/serviceInstances/%s/vnfs/%s", networkServiceInstance.getServiceInstanceId(), constituteVnf.getVnfId())
 
 214         String callPUTServiceInstanceResponse = "put"
 
 216         RequestDetails requestDetails = new RequestDetails()
 
 217         ObjectMapper mapper = new ObjectMapper()
 
 218         String requestDetailsStr = mapper.writeValueAsString(requestDetails)
 
 220         when(spy.prepareRequestDetails(mockExecution)).thenReturn(requestDetailsStr)
 
 222         when(spy.callPUTServiceInstance(urlString, "auth-header", requestDetailsStr)).thenReturn(callPUTServiceInstanceResponse)
 
 224         spy.invokePUTServiceInstance(mockExecution)
 
 229     void testRemoveSPAssociationWithNSSI() {
 
 230         def currentNSSI = [:]
 
 232         when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
 
 234         String nssiId = "5G-999"
 
 235         currentNSSI.put("nssiId", nssiId)
 
 236         ServiceInstance nssi = new ServiceInstance()
 
 237         nssi.setServiceInstanceId(nssiId)
 
 238         nssi.setSliceProfiles(new SliceProfiles())
 
 240         currentNSSI.put("nssi", nssi)
 
 242         AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId)
 
 244         DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
 
 246         when(spy.getAAIClient()).thenReturn(client)
 
 248         String theSNSSAI = "theS-NSSAI"
 
 249         currentNSSI.put("S-NSSAI", theSNSSAI)
 
 251         List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile()
 
 253         SliceProfile sliceProfile1 = new SliceProfile()
 
 254         sliceProfile1.setSNssai("snssai1")
 
 256         SliceProfile sliceProfile2 = new SliceProfile()
 
 257         sliceProfile2.setSNssai(theSNSSAI)
 
 259         SliceProfile sliceProfile3 = new SliceProfile()
 
 260         sliceProfile3.setSNssai("snssai3")
 
 262         associatedProfiles.add(sliceProfile1)
 
 263         associatedProfiles.add(sliceProfile2)
 
 264         associatedProfiles.add(sliceProfile3)
 
 266         int sizeBefore = associatedProfiles.size()
 
 268         doNothing().when(client).update(nssiUri, nssi)
 
 270         spy.removeSPAssociationWithNSSI(mockExecution)
 
 272         assertTrue("Association between slice profile and NSSI wasn't removed", ((ServiceInstance)currentNSSI.get("nssi")).getSliceProfiles().getSliceProfile().size() == (sizeBefore - 1))
 
 277     void testDeleteSliceProfileInstance() {
 
 278         def currentNSSI = [:]
 
 280         when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
 
 282         String globalSubscriberId = "global-id"
 
 283         String serviceType = "service"
 
 284         String nssiId = "5G-999"
 
 286         currentNSSI.put("globalSubscriberId", globalSubscriberId)
 
 287         currentNSSI.put("serviceType", serviceType)
 
 288         currentNSSI.put("nssiId", nssiId)
 
 290         String theSNSSAI = "theS-NSSAI"
 
 292         SliceProfile sliceProfile = new SliceProfile()
 
 293         sliceProfile.setSNssai(theSNSSAI)
 
 294         sliceProfile.setProfileId("prof-id")
 
 296         AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId)
 
 298         currentNSSI.put("sliceProfileS-NSSAI", sliceProfile)
 
 300         DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
 
 302         when(spy.getAAIClient()).thenReturn(client)
 
 304         doNothing().when(client).delete(nssiUri)
 
 306         spy.deleteSliceProfileInstance(mockExecution)
 
 312     void testUpdateServiceOperationStatus() {
 
 313         def currentNSSI = [:]
 
 315         when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
 
 317         String nssiId = "5G-999"
 
 319         currentNSSI.put("nssiId", nssiId)
 
 320         currentNSSI.put("e2eServiceInstanceId", "e2eServiceInstanceId")
 
 321         currentNSSI.put("operationId", "operationId")
 
 322         currentNSSI.put("operationType", "operationType")
 
 324         DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
 
 326         spy.updateServiceOperationStatus(mockExecution)
 
 332     void testPrepareRequestDetails() {
 
 333         def currentNSSI = [:]
 
 335         when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
 
 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")
 
 343         ServiceInstance nssi = new ServiceInstance()
 
 344         nssi.setServiceInstanceId("5G-999")
 
 345         nssi.setOrchestrationStatus("orchestration-status")
 
 347         AAIResourceUri networkServiceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "networkServiceInstance.getServiceInstanceId()")
 
 349         AAIResourceUri cloudRegionAAIUri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, "cloud-owner", "cloud-region-id")
 
 351         currentNSSI.put("networkServiceInstanceUri", networkServiceInstanceUri)
 
 353         currentNSSI.put("networkServiceInstance", networkServiceInstance)
 
 355         currentNSSI.put("globalSubscriberId", "globalSubscriberId")
 
 357         currentNSSI.put("subscriberName", "subscriber-name")
 
 359         currentNSSI.put("serviceId", "service-id")
 
 361         currentNSSI.put("nssi", nssi)
 
 363         List<SliceProfile> associatedProfiles = new ArrayList<>()
 
 364         SliceProfile sliceProfile1 = new SliceProfile()
 
 365         sliceProfile1.setSNssai("snssai1")
 
 367         SliceProfile sliceProfile2 = new SliceProfile()
 
 368         sliceProfile2.setSNssai("snssai2")
 
 370         associatedProfiles.add(sliceProfile1)
 
 371         associatedProfiles.add(sliceProfile2)
 
 373         List<String> snssais = new ArrayList<>()
 
 374         snssais.add(sliceProfile1.getSNssai())
 
 375         snssais.add(sliceProfile2.getSNssai())
 
 377         currentNSSI.put("S-NSSAIs", snssais)
 
 380         ServiceSubscription serviceSubscription = new ServiceSubscription()
 
 381         serviceSubscription.setServiceType("service-type")
 
 383         currentNSSI.put("serviceSubscription", serviceSubscription)
 
 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")
 
 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")
 
 399         VfModules vfModules = new VfModules()
 
 400         vfModules.getVfModule().add(vfModule)
 
 401         genericVnf.setVfModules(vfModules)
 
 403         currentNSSI.put("constituteVnf", genericVnf)
 
 405         AAIResourceUri constituteVNFURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVnf.getVnfId())
 
 407         currentNSSI.put("constituteVnfUri", constituteVNFURI)
 
 409         DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
 
 411         when(spy.getAAIClient()).thenReturn(client)
 
 413         prepareModelVer(networkServiceInstance)
 
 415         //prepareSubscriberInfo(networkServiceInstanceUri)
 
 417         prepareCloudConfiguration(constituteVNFURI, cloudRegionAAIUri)
 
 419         prepareModelVer(genericVnf)
 
 421         prepareModelVer(vfModule)
 
 423         prepareOwningEntity(networkServiceInstanceUri)
 
 425         prepareProject(cloudRegionAAIUri)
 
 427         String requestDetails = spy.prepareRequestDetails(mockExecution)
 
 432     void prepareProject(AAIResourceUri cloudRegionAAIUri) {
 
 433         Project project = new Project()
 
 434         project.setProjectName("project-name")
 
 436         AAIResultWrapper wrapperMock = mock(AAIResultWrapper.class)
 
 437         Relationships rsMock = mock(Relationships.class)
 
 438         Optional<Relationships> orsMock = Optional.of(rsMock)
 
 440         when(client.get(cloudRegionAAIUri)).thenReturn(wrapperMock)
 
 441         when(wrapperMock.getRelationships()).thenReturn(orsMock)
 
 443         List<AAIResourceUri> arus = new ArrayList<>()
 
 444         AAIResourceUri aru = new AAISimpleUri(cloudRegionAAIUri)
 
 447         when(rsMock.getRelatedAAIUris(AAIObjectType.PROJECT)).thenReturn(arus)
 
 449         Optional<Project> projectOpt = Optional.of(project)
 
 451         when(client.get(Project.class, aru)).thenReturn(projectOpt)
 
 455     void prepareOwningEntity(AAIResourceUri networkServiceInstanceUri) {
 
 456         OwningEntity owningEntity = new OwningEntity()
 
 458         owningEntity.setOwningEntityId("owning-entity-id")
 
 459         owningEntity.setOwningEntityName("owning-entity-name")
 
 461         AAIResultWrapper wrapperMock = mock(AAIResultWrapper.class)
 
 463         Relationships rsMock = mock(Relationships.class)
 
 464         Optional<Relationships> orsMock = Optional.of(rsMock)
 
 466         when(client.get(networkServiceInstanceUri)).thenReturn(wrapperMock)
 
 467         when(wrapperMock.getRelationships()).thenReturn(orsMock)
 
 469         List<AAIResourceUri> arus = new ArrayList<>()
 
 470         AAIResourceUri aru = new AAISimpleUri(networkServiceInstanceUri)
 
 473         when(rsMock.getRelatedAAIUris(AAIObjectType.OWNING_ENTITY)).thenReturn(arus)
 
 475         Optional<OwningEntity> owningEntityOpt = Optional.of(owningEntity)
 
 477         when(client.get(OwningEntity.class, aru)).thenReturn(owningEntityOpt)
 
 482     void prepareCloudConfiguration(AAIResourceUri constituteVNFURI, cloudRegionAAIUri) {
 
 483         AAIResultWrapper wrapperMock = mock(AAIResultWrapper.class)
 
 485         Relationships rsMock = mock(Relationships.class)
 
 486         Optional<Relationships> orsMock = Optional.of(rsMock)
 
 488         when(client.get(constituteVNFURI)).thenReturn(wrapperMock)
 
 489         when(wrapperMock.getRelationships()).thenReturn(orsMock)
 
 491         List<AAIResourceUri> arus = new ArrayList<>()
 
 492         AAIResourceUri aru = new AAISimpleUri(cloudRegionAAIUri)
 
 495         when(rsMock.getRelatedAAIUris(AAIObjectType.CLOUD_REGION)).thenReturn(arus)
 
 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")
 
 503         Tenants tenants = new Tenants()
 
 504         tenants.getTenant().add(tenant)
 
 505         cloudRegion.setTenants(tenants)
 
 506         Optional<CloudRegion> cloudRegionOpt = Optional.of(cloudRegion)
 
 508         when(client.get(CloudRegion.class, aru)).thenReturn(cloudRegionOpt)
 
 512     void prepareSubscriberInfo( AAIResourceUri networkServiceInstanceUri) {
 
 513         AAIResultWrapper wrapperMock = mock(AAIResultWrapper.class)
 
 515         Relationships rsMock = mock(Relationships.class)
 
 516         Optional<Relationships> orsMock = Optional.of(rsMock)
 
 518         when(client.get(networkServiceInstanceUri)).thenReturn(wrapperMock)
 
 519         when(wrapperMock.getRelationships()).thenReturn(orsMock)
 
 521         AAIResourceUri serviceSubscriptionUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_SUBSCRIPTION, "global-customer-id", "service-type")
 
 523         AAIResourceUri customerUri = AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, "global-customer-id")
 
 524         List<AAIResourceUri> arus = new ArrayList<>()
 
 526         arus.add(serviceSubscriptionUri)
 
 528         when(rsMock.getRelatedAAIUris(AAIObjectType.SERVICE_SUBSCRIPTION)).thenReturn(arus)
 
 530         ServiceSubscription serviceSubscription = new ServiceSubscription()
 
 531         serviceSubscription.setServiceType("service-type")
 
 532         Optional<ServiceSubscription> serviceSubscriptionOpt = Optional.of(serviceSubscription)
 
 534         when(client.get(ServiceSubscription.class, serviceSubscriptionUri)).thenReturn(serviceSubscriptionOpt)
 
 536         when(client.get(networkServiceInstanceUri)).thenReturn(wrapperMock)
 
 538         when(rsMock.getRelatedAAIUris(AAIObjectType.CUSTOMER)).thenReturn(arus)
 
 540         Customer customer = new Customer()
 
 541         customer.setSubscriberName("subscriber-name")
 
 542         Optional<Customer> customerOpt = Optional.of(customer)
 
 544         when(client.get(Customer.class, customerUri)).thenReturn(customerOpt)
 
 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")
 
 554         Optional<ModelVer> modelVerOpt = Optional.of(modelVer)
 
 556         AAIResourceUri modelVerUrl = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, networkServiceInstance.getModelInvariantId(), networkServiceInstance.getModelVersionId())
 
 557         when(client.get(ModelVer.class, modelVerUrl)).thenReturn(modelVerOpt)
 
 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")
 
 566         Optional<ModelVer> modelVerOpt = Optional.of(modelVer)
 
 568         AAIResourceUri modelVerUrl = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, genericVnf.getModelInvariantId(), genericVnf.getModelVersionId())
 
 569         when(client.get(ModelVer.class, modelVerUrl)).thenReturn(modelVerOpt)
 
 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")
 
 578         Optional<ModelVer> modelVerOpt = Optional.of(modelVer)
 
 580         AAIResourceUri modelVerUrl = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, vfModule.getModelInvariantId(), vfModule.getModelVersionId())
 
 581         when(client.get(ModelVer.class, modelVerUrl)).thenReturn(modelVerOpt)