AutonomiccsSystemVmDeploymentService implements InitializingBean { protected HostVO searchForAnotherRandomHostInTheClusterToStartSystemVmExcludingHosts(ClusterVO c, List<HostVO> excludeHosts) { List<HostVO> allHostsInCluster = hostService.listAllHostsInCluster(c); allHostsInCluster.removeAll(excludeHosts); Collections.shuffle(allHostsInCluster); for (HostVO h : allHostsInCluster) { if (canDeployAutonomiccsSystemVmOnHost(h)) { return h; } } logger.info(String.format("Could not find any suitable hosts to deploy the system VM into cluster [clusterId=%d, clusterName=%s]", c.getId(), c.getName())); return null; }  HostVO searchForRandomHostInCloudToDeployAutonomiccsSystemVm(); HostVO searchForRandomHostInPodToDeployAutonomiccsSystemVm(HostPodVO pod); HostVO searchForAnotherRandomHostToStartSystemVm(VMInstanceVO vmInstance); AutonomiccsSystemVm deploySystemVmWithJava(Long hostId, SystemVmType systemVmType); @Override void afterPropertiesSet();  }
@Test @PrepareForTest(AutonomiccsSystemVmDeploymentService.class) public void searchForAnotherRandomHostInTheClusterToStartSystemVmExcludingHostsTest() { HostVO host = Mockito.mock(HostVO.class); HostVO hostToExclude = Mockito.mock(HostVO.class); List<HostVO> allHostsInCluster = new ArrayList<>(); allHostsInCluster.add(host); allHostsInCluster.add(hostToExclude); List<HostVO> excludeHosts = new ArrayList<>(); excludeHosts.add(hostToExclude); configureExecuteVerifySearchForAnotherRandomHostInTheClusterToStartSystemVmExcludingHostsTest(allHostsInCluster, excludeHosts, true, 1, host); }