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.camunda.bpm.engine.delegate.BpmnError
 
  24 import org.junit.Before
 
  27 import org.junit.rules.ExpectedException
 
  28 import org.onap.aai.domain.yang.VolumeGroup
 
  29 import org.onap.aai.domain.yang.VolumeGroups
 
  30 import org.onap.so.bpmn.common.scripts.MsoGroovyTest
 
  31 import org.onap.aaiclient.client.aai.AAIObjectPlurals
 
  32 import org.onap.aaiclient.client.aai.AAIObjectType
 
  33 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
 
  34 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
 
  35 import org.onap.so.constants.Defaults
 
  37 import static org.mockito.ArgumentMatchers.isA
 
  38 import static org.mockito.Mockito.doThrow
 
  39 import static org.mockito.Mockito.spy
 
  40 import static org.mockito.Mockito.when
 
  42 public class DoDeleteVFCNetworkServiceInstanceTest extends MsoGroovyTest {
 
  45     public ExpectedException thrown = ExpectedException.none();
 
  47     private  DoDeleteVFCNetworkServiceInstance doDeleteVFCNetworkServiceInstance;
 
  50         super.init("DoDeleteVFCNetworkServiceInstance");
 
  51         doDeleteVFCNetworkServiceInstance = spy(DoDeleteVFCNetworkServiceInstance.class);
 
  52         when(doDeleteVFCNetworkServiceInstance.getAAIClient()).thenReturn(client)
 
  56     void callRESTDeleteAAIVolumeGroupTest(){
 
  57         String resourceInstanceId = "resourceInstanceId"
 
  58         when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
 
  59         when(mockExecution.getVariable("resourceInstanceId")).thenReturn(resourceInstanceId)
 
  60         doDeleteVFCNetworkServiceInstance.deleteNSRelationship(mockExecution)
 
  64     void callRESTDeleteAAIVolumeGroupTestException(){
 
  65         String resourceInstanceId = "resourceInstanceId"
 
  66         when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true")
 
  67         when(mockExecution.getVariable("resourceInstanceId")).thenReturn(resourceInstanceId)
 
  68         doThrow(Exception.class).when(client).disconnect(isA(AAIResourceUri.class),isA(AAIResourceUri.class))
 
  69         thrown.expect(BpmnError.class)
 
  70         doDeleteVFCNetworkServiceInstance.deleteNSRelationship(mockExecution)