use of com.cloud.dc.ClusterVO in project cloudstack by apache.
the class ConfigurationManagerTest method checkIfPodIsDeletableFailureOnClusterTest.
@Test(expected = CloudRuntimeException.class)
public void checkIfPodIsDeletableFailureOnClusterTest() {
HostPodVO hostPodVO = Mockito.mock(HostPodVO.class);
Mockito.when(hostPodVO.getDataCenterId()).thenReturn(new Random().nextLong());
Mockito.when(_podDao.findById(anyLong())).thenReturn(hostPodVO);
ClusterVO clusterVO = Mockito.mock(ClusterVO.class);
ArrayList<ClusterVO> arrayList = new ArrayList<ClusterVO>();
arrayList.add(clusterVO);
Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyLong(), anyBoolean())).thenReturn(0);
Mockito.when(_volumeDao.findByPod(anyLong())).thenReturn(new ArrayList<VolumeVO>());
Mockito.when(_hostDao.findByPodId(anyLong())).thenReturn(new ArrayList<HostVO>());
Mockito.when(_vmInstanceDao.listByPodId(anyLong())).thenReturn(new ArrayList<VMInstanceVO>());
Mockito.when(_clusterDao.listByPodId(anyLong())).thenReturn(arrayList);
configurationMgr.checkIfPodIsDeletable(new Random().nextLong());
}
use of com.cloud.dc.ClusterVO in project cloudstack by apache.
the class DeploymentPlanningManagerImplTest method testSetUp.
@Before
public void testSetUp() {
MockitoAnnotations.initMocks(this);
ComponentContext.initComponentsLifeCycle();
PlannerHostReservationVO reservationVO = new PlannerHostReservationVO(200L, 1L, 2L, 3L, PlannerResourceUsage.Shared);
Mockito.when(_plannerHostReserveDao.persist(Matchers.any(PlannerHostReservationVO.class))).thenReturn(reservationVO);
Mockito.when(_plannerHostReserveDao.findById(Matchers.anyLong())).thenReturn(reservationVO);
Mockito.when(_affinityGroupVMMapDao.countAffinityGroupsForVm(Matchers.anyLong())).thenReturn(0L);
VMTemplateVO template = Mockito.mock(VMTemplateVO.class);
Mockito.when(template.isDeployAsIs()).thenReturn(false);
Mockito.when(templateDao.findById(Mockito.anyLong())).thenReturn(template);
VMInstanceVO vm = new VMInstanceVO();
Mockito.when(vmProfile.getVirtualMachine()).thenReturn(vm);
Mockito.when(vmDetailsDao.listDetailsKeyPairs(Matchers.anyLong())).thenReturn(null);
Mockito.when(_dcDao.findById(Matchers.anyLong())).thenReturn(dc);
Mockito.when(dc.getId()).thenReturn(dataCenterId);
ClusterVO clusterVO = new ClusterVO();
clusterVO.setHypervisorType(HypervisorType.XenServer.toString());
Mockito.when(_clusterDao.findById(Matchers.anyLong())).thenReturn(clusterVO);
Mockito.when(_planner.getName()).thenReturn("FirstFitPlanner");
List<DeploymentPlanner> planners = new ArrayList<DeploymentPlanner>();
planners.add(_planner);
_dpm.setPlanners(planners);
Mockito.when(host.getId()).thenReturn(hostId);
Mockito.doNothing().when(_dpm).avoidDisabledResources(vmProfile, dc, avoids);
}
use of com.cloud.dc.ClusterVO in project cloudstack by apache.
the class ConfigurationManagerTest method checkIfPodIsDeletableFailureOnVmInstanceTest.
@Test(expected = CloudRuntimeException.class)
public void checkIfPodIsDeletableFailureOnVmInstanceTest() {
HostPodVO hostPodVO = Mockito.mock(HostPodVO.class);
Mockito.when(hostPodVO.getDataCenterId()).thenReturn(new Random().nextLong());
Mockito.when(_podDao.findById(anyLong())).thenReturn(hostPodVO);
VMInstanceVO vMInstanceVO = Mockito.mock(VMInstanceVO.class);
ArrayList<VMInstanceVO> arrayList = new ArrayList<VMInstanceVO>();
arrayList.add(vMInstanceVO);
Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyLong(), anyBoolean())).thenReturn(0);
Mockito.when(_volumeDao.findByPod(anyLong())).thenReturn(new ArrayList<VolumeVO>());
Mockito.when(_hostDao.findByPodId(anyLong())).thenReturn(new ArrayList<HostVO>());
Mockito.when(_vmInstanceDao.listByPodId(anyLong())).thenReturn(arrayList);
Mockito.when(_clusterDao.listByPodId(anyLong())).thenReturn(new ArrayList<ClusterVO>());
configurationMgr.checkIfPodIsDeletable(new Random().nextLong());
}
use of com.cloud.dc.ClusterVO in project cloudstack by apache.
the class ConfigurationManagerTest method checkIfPodIsDeletableSuccessTest.
@Test
public void checkIfPodIsDeletableSuccessTest() {
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<VolumeVO>());
Mockito.when(_hostDao.findByPodId(anyLong())).thenReturn(new ArrayList<HostVO>());
Mockito.when(_vmInstanceDao.listByPodId(anyLong())).thenReturn(new ArrayList<VMInstanceVO>());
Mockito.when(_clusterDao.listByPodId(anyLong())).thenReturn(new ArrayList<ClusterVO>());
configurationMgr.checkIfPodIsDeletable(new Random().nextLong());
}
use of com.cloud.dc.ClusterVO in project cloudstack by apache.
the class ConfigurationManagerTest method checkIfPodIsDeletableFailureOnHostTest.
@Test(expected = CloudRuntimeException.class)
public void checkIfPodIsDeletableFailureOnHostTest() {
HostPodVO hostPodVO = Mockito.mock(HostPodVO.class);
Mockito.when(hostPodVO.getDataCenterId()).thenReturn(new Random().nextLong());
Mockito.when(_podDao.findById(anyLong())).thenReturn(hostPodVO);
HostVO hostVO = Mockito.mock(HostVO.class);
ArrayList<HostVO> arrayList = new ArrayList<HostVO>();
arrayList.add(hostVO);
Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyLong(), anyBoolean())).thenReturn(0);
Mockito.when(_volumeDao.findByPod(anyLong())).thenReturn(new ArrayList<VolumeVO>());
Mockito.when(_hostDao.findByPodId(anyLong())).thenReturn(arrayList);
Mockito.when(_vmInstanceDao.listByPodId(anyLong())).thenReturn(new ArrayList<VMInstanceVO>());
Mockito.when(_clusterDao.listByPodId(anyLong())).thenReturn(new ArrayList<ClusterVO>());
configurationMgr.checkIfPodIsDeletable(new Random().nextLong());
}
Aggregations