ConsolidationScoredPreferenceForSmallHosts extends ConsolidationAlgorithmBase { protected double getCloudExpetedCpuUsageAfterHostShutdown(HostResources hostToPowerOff, CloudResources cloudResources) { double hostCpu = hostToPowerOff.getSpeed() * hostToPowerOff.getCpus() * hostToPowerOff.getCpuOverprovisioning(); double expectedcloudCpuAfterShutDown = getCloudCpuCapacity(cloudResources) - hostCpu; return cloudResources.getUsedCpu() / expectedcloudCpuAfterShutDown; }  @Override List<HostResources> rankHosts(List<HostResources> hostsList); @Override List<HostResources> rankHostToPowerOff(List<HostResources> idleHosts);  }
@Test public void getCloudExpetedCpuUsageAfterHostShutdownTest() { HostResources host = createHost(2, 1000l, 0l, 2000l, 0l); CloudResources cloud = new CloudResources(null, 0, 0, 3000l, 2000, 4); Assert.assertEquals(0.5, spyAlgorithm.getCloudExpetedCpuUsageAfterHostShutdown(host, cloud), 0.0); Mockito.verify(spyAlgorithm).getCloudCpuCapacity(cloud); }