ScoredClustersAllocationAlgorithmPreferenceForSmallHosts extends AllocationAlgorithmBase { protected double calculateHostScore(HostResources hostToStart) { double hostCpu = hostToStart.getSpeed() * hostToStart.getCpus() * hostToStart.getCpuOverprovisioning(); double hostMemory = hostToStart.getTotalMemoryInBytes() * hostToStart.getMemoryOverprovisioning(); return hostCpu * hostMemory; }  @Override List<ClusterResourcesAvailableToStart> rankClustersToAllocation(List<ClusterResourcesAvailableToStart> clustersAvailableToStart); @Override List<HostResources> rankHostsToStart(List<HostResources> hostsResources);  }
@Test public void calculateHostScoreTest() { HostResources hostToStart = Mockito.mock(HostResources.class); Mockito.when(hostToStart.getCpuOverprovisioning()).thenReturn(1f); Mockito.when(hostToStart.getCpus()).thenReturn(2); Mockito.when(hostToStart.getSpeed()).thenReturn(1000l); Mockito.when(hostToStart.getMemoryOverprovisioning()).thenReturn(2f); Mockito.when(hostToStart.getTotalMemoryInBytes()).thenReturn(1000l); double result = spyAlgorithm.calculateHostScore(hostToStart); Assert.assertEquals(4000000, result, 0f); }