Springboot 2.0 upgrade
[so.git] / bpmn / so-bpmn-infrastructure-common / src / test / groovy / org / onap / so / bpmn / infrastructure / scripts / DoDeleteVFCNetworkServiceInstanceTest.groovy
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
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 org.camunda.bpm.engine.delegate.BpmnError
24 import org.junit.Before
25 import org.junit.Rule
26 import org.junit.Test
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.so.client.aai.AAIObjectPlurals
32 import org.onap.so.client.aai.AAIObjectType
33 import org.onap.so.client.aai.entities.uri.AAIResourceUri
34 import org.onap.so.client.aai.entities.uri.AAIUriFactory
35 import org.onap.so.constants.Defaults
36
37 import static org.mockito.Matchers.isA
38 import static org.mockito.Mockito.doThrow
39 import static org.mockito.Mockito.spy
40 import static org.mockito.Mockito.when
41
42 public class DoDeleteVFCNetworkServiceInstanceTest extends MsoGroovyTest {
43
44     @Rule
45     public ExpectedException thrown = ExpectedException.none();
46
47     private  DoDeleteVFCNetworkServiceInstance doDeleteVFCNetworkServiceInstance;
48     @Before
49     public void init(){
50         super.init("DoDeleteVFCNetworkServiceInstance");
51         doDeleteVFCNetworkServiceInstance = spy(DoDeleteVFCNetworkServiceInstance.class);
52         when(doDeleteVFCNetworkServiceInstance.getAAIClient()).thenReturn(client)
53     }
54
55     @Test
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)
61     }
62
63     @Test
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)
71     }
72
73 }