Search in sources :

Example 81 with HostPodVO

use of com.cloud.dc.HostPodVO in project cosmic by MissionCriticalCloud.

the class ConfigurationManagerTest method checkIfPodIsDeletableSuccessTest.

@Test
public void checkIfPodIsDeletableSuccessTest() {
    final HostPodVO hostPodVO = Mockito.mock(HostPodVO.class);
    Mockito.when(hostPodVO.getDataCenterId()).thenReturn(new Random().nextLong());
    Mockito.when(_podDao.findById(anyLong())).thenReturn(hostPodVO);
    Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyLong(), anyBoolean())).thenReturn(0);
    Mockito.when(_volumeDao.findByPod(anyLong())).thenReturn(new ArrayList<>());
    Mockito.when(_hostDao.findByPodId(anyLong())).thenReturn(new ArrayList<>());
    Mockito.when(_vmInstanceDao.listByPodId(anyLong())).thenReturn(new ArrayList<>());
    Mockito.when(_clusterDao.listByPodId(anyLong())).thenReturn(new ArrayList<>());
    configurationMgr.checkIfPodIsDeletable(new Random().nextLong());
}
Also used : Random(java.util.Random) HostPodVO(com.cloud.dc.HostPodVO) Test(org.junit.Test)

Example 82 with HostPodVO

use of com.cloud.dc.HostPodVO in project cosmic by MissionCriticalCloud.

the class ConfigurationManagerTest method checkIfPodIsDeletableFailureOnClusterTest.

@Test(expected = CloudRuntimeException.class)
public void checkIfPodIsDeletableFailureOnClusterTest() {
    final HostPodVO hostPodVO = Mockito.mock(HostPodVO.class);
    Mockito.when(hostPodVO.getDataCenterId()).thenReturn(new Random().nextLong());
    Mockito.when(_podDao.findById(anyLong())).thenReturn(hostPodVO);
    final ClusterVO clusterVO = Mockito.mock(ClusterVO.class);
    final ArrayList<ClusterVO> arrayList = new ArrayList<>();
    arrayList.add(clusterVO);
    Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyLong(), anyBoolean())).thenReturn(0);
    Mockito.when(_volumeDao.findByPod(anyLong())).thenReturn(new ArrayList<>());
    Mockito.when(_hostDao.findByPodId(anyLong())).thenReturn(new ArrayList<>());
    Mockito.when(_vmInstanceDao.listByPodId(anyLong())).thenReturn(new ArrayList<>());
    Mockito.when(_clusterDao.listByPodId(anyLong())).thenReturn(arrayList);
    configurationMgr.checkIfPodIsDeletable(new Random().nextLong());
}
Also used : ClusterVO(com.cloud.dc.ClusterVO) Random(java.util.Random) ArrayList(java.util.ArrayList) HostPodVO(com.cloud.dc.HostPodVO) Test(org.junit.Test)

Example 83 with HostPodVO

use of com.cloud.dc.HostPodVO in project cosmic by MissionCriticalCloud.

the class ConfigurationManagerTest method checkIfPodIsDeletableFailureOnPrivateIpAddressTest.

@Test(expected = CloudRuntimeException.class)
public void checkIfPodIsDeletableFailureOnPrivateIpAddressTest() {
    final HostPodVO hostPodVO = Mockito.mock(HostPodVO.class);
    Mockito.when(hostPodVO.getDataCenterId()).thenReturn(new Random().nextLong());
    Mockito.when(_podDao.findById(anyLong())).thenReturn(hostPodVO);
    Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyLong(), anyBoolean())).thenReturn(1);
    Mockito.when(_volumeDao.findByPod(anyLong())).thenReturn(new ArrayList<>());
    Mockito.when(_hostDao.findByPodId(anyLong())).thenReturn(new ArrayList<>());
    Mockito.when(_vmInstanceDao.listByPodId(anyLong())).thenReturn(new ArrayList<>());
    Mockito.when(_clusterDao.listByPodId(anyLong())).thenReturn(new ArrayList<>());
    configurationMgr.checkIfPodIsDeletable(new Random().nextLong());
}
Also used : Random(java.util.Random) HostPodVO(com.cloud.dc.HostPodVO) Test(org.junit.Test)

Example 84 with HostPodVO

use of com.cloud.dc.HostPodVO in project cosmic by MissionCriticalCloud.

the class ConfigurationManagerTest method checkIfPodIsDeletableFailureOnHostTest.

@Test(expected = CloudRuntimeException.class)
public void checkIfPodIsDeletableFailureOnHostTest() {
    final HostPodVO hostPodVO = Mockito.mock(HostPodVO.class);
    Mockito.when(hostPodVO.getDataCenterId()).thenReturn(new Random().nextLong());
    Mockito.when(_podDao.findById(anyLong())).thenReturn(hostPodVO);
    final HostVO hostVO = Mockito.mock(HostVO.class);
    final ArrayList<HostVO> arrayList = new ArrayList<>();
    arrayList.add(hostVO);
    Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyLong(), anyBoolean())).thenReturn(0);
    Mockito.when(_volumeDao.findByPod(anyLong())).thenReturn(new ArrayList<>());
    Mockito.when(_hostDao.findByPodId(anyLong())).thenReturn(arrayList);
    Mockito.when(_vmInstanceDao.listByPodId(anyLong())).thenReturn(new ArrayList<>());
    Mockito.when(_clusterDao.listByPodId(anyLong())).thenReturn(new ArrayList<>());
    configurationMgr.checkIfPodIsDeletable(new Random().nextLong());
}
Also used : Random(java.util.Random) ArrayList(java.util.ArrayList) HostPodVO(com.cloud.dc.HostPodVO) HostVO(com.cloud.host.HostVO) Test(org.junit.Test)

Example 85 with HostPodVO

use of com.cloud.dc.HostPodVO in project cosmic by MissionCriticalCloud.

the class ConfigurationManagerTest method checkIfPodIsDeletableFailureOnVolumeTest.

@Test(expected = CloudRuntimeException.class)
public void checkIfPodIsDeletableFailureOnVolumeTest() {
    final HostPodVO hostPodVO = Mockito.mock(HostPodVO.class);
    Mockito.when(hostPodVO.getDataCenterId()).thenReturn(new Random().nextLong());
    Mockito.when(_podDao.findById(anyLong())).thenReturn(hostPodVO);
    final VolumeVO volumeVO = Mockito.mock(VolumeVO.class);
    final ArrayList<VolumeVO> arrayList = new ArrayList<>();
    arrayList.add(volumeVO);
    Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyLong(), anyBoolean())).thenReturn(0);
    Mockito.when(_volumeDao.findByPod(anyLong())).thenReturn(arrayList);
    Mockito.when(_hostDao.findByPodId(anyLong())).thenReturn(new ArrayList<>());
    Mockito.when(_vmInstanceDao.listByPodId(anyLong())).thenReturn(new ArrayList<>());
    Mockito.when(_clusterDao.listByPodId(anyLong())).thenReturn(new ArrayList<>());
    configurationMgr.checkIfPodIsDeletable(new Random().nextLong());
}
Also used : Random(java.util.Random) VolumeVO(com.cloud.storage.VolumeVO) ArrayList(java.util.ArrayList) HostPodVO(com.cloud.dc.HostPodVO) Test(org.junit.Test)

Aggregations

HostPodVO (com.cloud.dc.HostPodVO)126 ArrayList (java.util.ArrayList)52 HostVO (com.cloud.host.HostVO)47 ClusterVO (com.cloud.dc.ClusterVO)46 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)46 DataCenterVO (com.cloud.dc.DataCenterVO)39 Account (com.cloud.user.Account)25 DB (com.cloud.utils.db.DB)25 Test (org.junit.Test)23 ConfigurationException (javax.naming.ConfigurationException)22 TransactionStatus (com.cloud.utils.db.TransactionStatus)21 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)20 VMInstanceVO (com.cloud.vm.VMInstanceVO)18 Random (java.util.Random)18 VolumeVO (com.cloud.storage.VolumeVO)17 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)16 HashMap (java.util.HashMap)16 List (java.util.List)16 Zone (com.cloud.db.model.Zone)15 DataCenter (com.cloud.dc.DataCenter)14