2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
 
   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 org.junit.Before
 
  25 import org.mockito.Mockito
 
  26 import org.mockito.Spy
 
  27 import org.onap.aai.domain.yang.AllottedResource
 
  28 import org.onap.so.bpmn.common.scripts.MsoGroovyTest
 
  29 import org.onap.so.bpmn.mock.FileUtil
 
  30 import org.onap.so.client.aai.AAIObjectType
 
  31 import org.onap.so.client.aai.entities.uri.AAIResourceUri
 
  32 import org.onap.so.client.aai.entities.uri.AAIUriFactory
 
  33 import javax.ws.rs.core.UriBuilder
 
  34 import static org.mockito.Mockito.times
 
  35 import static org.mockito.Mockito.when
 
  37 class DoCustomDeleteE2EServiceInstanceV2Test extends MsoGroovyTest {
 
  40     DoCustomDeleteE2EServiceInstanceV2 doCustomDeleteE2EServiceInstanceV2
 
  44         super.init("DoCustomDeleteE2EServiceInstanceV2")
 
  45         Mockito.when(doCustomDeleteE2EServiceInstanceV2.getAAIClient()).thenReturn(client)
 
  49     void testPrepareServiceDeleteResource(){
 
  50         when(mockExecution.getVariable("serviceInstance")).thenReturn(FileUtil.readResourceFile("__files/AAI/ServiceInstanceWithAR.json"))
 
  51         def relink = "/aai/v11/business/customers/customer/testCustIdInfra/service-subscriptions/service-subscription/HNPORTAL/service-instances/service-instance/testServiceInstanceIdPortalPri/allotted-resources/allotted-resource/testAllottedResourceIdPortalPri"
 
  52         AAIResourceUri uri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.ALLOTTED_RESOURCE, UriBuilder.fromPath(relink).build())
 
  53         AllottedResource ar = new AllottedResource();
 
  57         ar.setResourceVersion("1234")
 
  58         when(client.get(AllottedResource.class,uri)).thenReturn(Optional.of(ar))
 
  59         doCustomDeleteE2EServiceInstanceV2.prepareServiceDeleteResource(mockExecution)
 
  60         Mockito.verify(client, times(1)).get(AllottedResource.class,uri)