ClusterResourcesService { public ClusterResourcesUp createClusterResourcesUp(long clusterId, String clusterName, List<HostResources> hostsResources) { long clusterUsedCpu = 0, clusterCpuSpeed = 0, clusterMemory = 0, clusterUsedMemory = 0; int clusterCpus = 0; for (HostResources currentHost : hostsResources) { clusterMemory += currentHost.getTotalMemoryInBytes() * currentHost.getMemoryOverprovisioning(); clusterUsedMemory += currentHost.getUsedMemoryInMegaBytes(); clusterUsedCpu += currentHost.getUsedCpu(); clusterCpuSpeed += currentHost.getSpeed() * currentHost.getCpuOverprovisioning(); clusterCpus += currentHost.getCpus(); } ClusterResourcesUp clusterResourcesUp = new ClusterResourcesUp(clusterId, clusterName, clusterCpuSpeed, clusterUsedCpu, clusterCpus, clusterMemory, clusterUsedMemory, hostsResources); return clusterResourcesUp; }  ClusterResourcesUp createClusterResourcesUp(long clusterId, String clusterName, List<HostResources> hostsResources); ClusterResourcesAvailableToStart createClusterResourcesAvailableToStart(long clusterId, String clusterName, List<HostResources> hostsToStart);  }
@Test public void createClusterResourcesUpOneHostTest() { List<HostResources> hosts = createClusterHomogeneousHosts(1); ClusterResourcesUp cluster = clusterResourcesService.createClusterResourcesUp(random.nextLong(), "cluster", hosts); Assert.assertEquals(512, cluster.getUsedMemory()); Assert.assertEquals(1000l, cluster.getUsedCpu()); checkCpuAndMemory(cluster); }