ScoredClustersAllocationAlgorithmPreferenceForSmallHosts extends AllocationAlgorithmBase { protected List<HostResources> setEachHostScore(List<HostResources> hosts) { for (HostResources hostToStart : hosts) { double hostScore = calculateHostScore(hostToStart); hostToStart.setScore(hostScore); } return hosts; }  @Override List<ClusterResourcesAvailableToStart> rankClustersToAllocation(List<ClusterResourcesAvailableToStart> clustersAvailableToStart); @Override List<HostResources> rankHostsToStart(List<HostResources> hostsResources);  }
@Test public void setEachHostScoreTest() { List<HostResources> hosts = new ArrayList<HostResources>(); HostResources spyHost = Mockito.spy(new HostResources()); hosts.add(spyHost); Mockito.doReturn(0d).when(spyAlgorithm).calculateHostScore(Mockito.any(HostResources.class)); Mockito.doNothing().when(spyHost).setScore(Mockito.anyDouble()); spyAlgorithm.setEachHostScore(hosts); InOrder inOrder = Mockito.inOrder(spyAlgorithm, spyHost); inOrder.verify(spyAlgorithm, Mockito.times(hosts.size())).calculateHostScore(Mockito.any(HostResources.class)); inOrder.verify(spyHost, Mockito.times(hosts.size())).setScore(Mockito.anyDouble()); }