### Question:
ClusterState extends AbstractPersistable implements Solution<Score> { public int cpusAssignedInHost(Host host) { int result = 0; for (Vm vm: getVmsDeployedInHost(host)) { result += vm.getNcpus(); } return result; } ClusterState(); boolean hostIsIdle(Host host); int countIdleHosts(); int countNonIdleHosts(); List<String> getIdsOfAppsDeployedInHost(Host host); List<Vm> getVmsDeployedInHost(Host host); double avgCpusAssignedPerHost(); int cpusAssignedInHost(Host host); int calculateCumulativeUnusedCpuPerc(); double calculateStdDevCpuPercUsedPerHost(); int countOffHosts(); int countVmMigrationsNeeded(ClusterState destinyClusterState); Vm getVmById(long id); @PlanningEntityCollectionProperty List<Vm> getVms(); void setVms(List<Vm> vms); @ValueRangeProvider(id = "hostRange") List<Host> getHosts(); void setHosts(List<Host> hosts); @Override Score getScore(); @Override void setScore(Score score); @Override Collection<?> getProblemFacts(); @Override String toString();  }### Answer:
@Test public void cpusAssignedInHost() { for (Host host: clusterState.getHosts()) { if (host.getId() == (long) 1) { assertEquals(2, clusterState.cpusAssignedInHost(host)); } else if (host.getId() == (long) 2) { assertEquals(0, clusterState.cpusAssignedInHost(host)); } } }