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.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
 
  35 import static org.mockito.Mockito.spy
 
  36 import static org.mockito.Mockito.when;
 
  38 public class DoCreateVfModuleVolumeRollbackTest extends MsoGroovyTest {
 
  40     private  DoCreateVfModuleVolumeRollback doCreateVfModuleVolumeRollback;
 
  43         super.init("DoCreateVfModuleVolumeRollback");
 
  44         doCreateVfModuleVolumeRollback = spy(DoCreateVfModuleVolumeRollback.class);
 
  45         when(doCreateVfModuleVolumeRollback.getAAIClient()).thenReturn(client)
 
  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))
 
  61         doCreateVfModuleVolumeRollback.callRESTDeleteAAIVolumeGroup(mockExecution,null)