ConsolidationScoredPreferenceForSmallHosts extends ConsolidationAlgorithmBase { protected double cloudMemoryUsagePercentage(CloudResources cloudResources) { double cloudMemory = cloudResources.getMemoryInBytes() / BYTES_TO_MEGA_BYTES_AS_DOUBLE; double cloudUsedMemory = cloudResources.getUsedMemory() / BYTES_TO_MEGA_BYTES_AS_DOUBLE; return cloudUsedMemory / cloudMemory; }  @Override List<HostResources> rankHosts(List<HostResources> hostsList); @Override List<HostResources> rankHostToPowerOff(List<HostResources> idleHosts);  }
@Test public void cloudMemoryUsagePercentageTest() { CloudResources cloud = new CloudResources(null, 5000l * BYTES_TO_MEGA_BYTES, 10000l * BYTES_TO_MEGA_BYTES, 5000, 2000l, 5); Assert.assertEquals(0.5, spyAlgorithm.cloudMemoryUsagePercentage(cloud), 0.0); }