ConsolidationScoredPreferenceForSmallHosts extends ConsolidationAlgorithmBase { protected double cloudCpuUsagePercentage(CloudResources cloudResources) { double cloudCpu = getCloudCpuCapacity(cloudResources); double cloudUsedCpu = cloudResources.getUsedCpu(); return cloudUsedCpu / cloudCpu; }  @Override List<HostResources> rankHosts(List<HostResources> hostsList); @Override List<HostResources> rankHostToPowerOff(List<HostResources> idleHosts);  }
@Test public void cloudCpuUsagePercentageTest() { CloudResources cloud = new CloudResources(null, 5000l * BYTES_TO_MEGA_BYTES, 10000l * BYTES_TO_MEGA_BYTES, 5000, 2000l, 5); Assert.assertEquals(0.5, spyAlgorithm.cloudCpuUsagePercentage(cloud), 0.0); Mockito.verify(spyAlgorithm).getCloudCpuCapacity(cloud); }