Springboot 2.0 upgrade
[so.git] / bpmn / so-bpmn-infrastructure-common / src / test / groovy / org / onap / so / bpmn / infrastructure / scripts / DoCreateVfModuleVolumeRollbackTest.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.junit.Before;
24 import org.junit.Test
25 import org.onap.aai.domain.yang.VfModule
26 import org.onap.aai.domain.yang.VolumeGroup
27 import org.onap.aai.domain.yang.VolumeGroups;
28 import org.onap.so.bpmn.common.scripts.MsoGroovyTest
29 import org.onap.so.client.aai.AAIObjectPlurals
30 import org.onap.so.client.aai.entities.uri.AAIResourceUri
31 import org.onap.so.client.aai.entities.uri.AAIUriFactory
32 import org.onap.so.constants.Defaults
33
34 import static org.mockito.Mockito.spy
35 import static org.mockito.Mockito.when;
36
37 public class DoCreateVfModuleVolumeRollbackTest extends MsoGroovyTest {
38
39     private  DoCreateVfModuleVolumeRollback doCreateVfModuleVolumeRollback;
40     @Before
41     public void init(){
42         super.init("DoCreateVfModuleVolumeRollback");
43         doCreateVfModuleVolumeRollback = spy(DoCreateVfModuleVolumeRollback.class);
44         when(doCreateVfModuleVolumeRollback.getAAIClient()).thenReturn(client)
45     }
46
47     @Test
48     void callRESTDeleteAAIVolumeGroupTest(){
49         String volumeGroupName = "volumeGroupName"
50         String cloudRegionId = "cloudRegionId"
51         when(mockExecution.getVariable("DCVFMODVOLRBK_volumeGroupName")).thenReturn(volumeGroupName)
52         when(mockExecution.getVariable("DCVFMODVOLRBK_lcpCloudRegionId")).thenReturn(cloudRegionId)
53         AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VOLUME_GROUP, Defaults.CLOUD_OWNER.toString(), cloudRegionId).queryParam("volume-group-name", volumeGroupName)
54         VolumeGroup volumeGroup = new VolumeGroup();
55         volumeGroup.setVolumeGroupId("volumeGroupId")
56         VolumeGroups groups = new VolumeGroups();
57         groups.getVolumeGroup().add(volumeGroup)
58         when(client.get(VolumeGroups.class,uri)).thenReturn(Optional.of(groups))
59
60         doCreateVfModuleVolumeRollback.callRESTDeleteAAIVolumeGroup(mockExecution,null)
61     }
62
63 }