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