ScoredClustersAllocationAlgorithmPreferenceForSmallHosts extends AllocationAlgorithmBase { protected void setClustersScore(List<ClusterResourcesAvailableToStart> clusters) { for (ClusterResourcesAvailableToStart cluster : clusters) { long clusterScore = calculateClusterScore(cluster); cluster.setScore(clusterScore); } }  @Override List<ClusterResourcesAvailableToStart> rankClustersToAllocation(List<ClusterResourcesAvailableToStart> clustersAvailableToStart); @Override List<HostResources> rankHostsToStart(List<HostResources> hostsResources);  }
@Test public void setClustersScoreTest() { List<ClusterResourcesAvailableToStart> clustersAvailableToStart = new ArrayList<ClusterResourcesAvailableToStart>(); ClusterResourcesAvailableToStart spyCluster = Mockito.spy(new ClusterResourcesAvailableToStart(0, null, 0, 0, 0, null)); clustersAvailableToStart.add(spyCluster); Mockito.doReturn(0l).when(spyAlgorithm).calculateClusterScore(Mockito.any(ClusterResourcesAvailableToStart.class)); Mockito.doNothing().when(spyCluster).setScore(Mockito.anyDouble()); spyAlgorithm.setClustersScore(clustersAvailableToStart); InOrder inOrder = Mockito.inOrder(spyAlgorithm, spyCluster); inOrder.verify(spyAlgorithm, Mockito.times(clustersAvailableToStart.size())).calculateClusterScore(Mockito.any(ClusterResourcesAvailableToStart.class)); inOrder.verify(spyCluster, Mockito.times(clustersAvailableToStart.size())).setScore(Mockito.anyDouble()); }