AdministrationAgent implements InitializingBean { protected List<HostResources> getClusterIdleHosts(ClusterVO cluster) { List<HostResources> hosts = getClusterUpHosts(cluster); List<HostResources> hostsIdle = new ArrayList<>(); for (HostResources currentHost : hosts) { if (CollectionUtils.isEmpty(currentHost.getVmsResources())) { hostsIdle.add(currentHost); } } return hostsIdle; }  void receiveClusterToBeManaged(Long clusterId); Long searchClusterToBeManaged(); List<ClusterResourcesUp> createAllClustersResourcesUp(); @Override void afterPropertiesSet();  }
@Test public void getClusterIdleHostsTest() { ClusterVO cluster = createCluster(null); List<HostResources> hosts = createHosts(2); List<VmResources> vmsResources = new ArrayList<>(); vmsResources.add(new VmResources(0l, 1, 1000, 1000)); hosts.get(0).setVmsResources(vmsResources); Mockito.doReturn(hosts).when(administrationAgent).getClusterUpHosts(Mockito.any(ClusterVO.class)); List<HostResources> result = administrationAgent.getClusterIdleHosts(cluster); Mockito.verify(administrationAgent).getClusterUpHosts(Mockito.any(ClusterVO.class)); Assert.assertEquals(1, result.size()); Assert.assertEquals(hosts.get(1), result.get(0)); }