### Question:
RandomHostSelector implements HostSelector { @Override public List<Host> selectHostsToBeTurnedOn(List<Host> candidateHosts, int nHosts) { return selectHosts(candidateHosts, nHosts); }  @Override List<Host> selectHostsToBeTurnedOn(List<Host> candidateHosts, int nHosts); @Override List<Host> selectHostsToBeTurnedOn(List<Host> candidateHosts, int minCpus, int maxCpus); @Override List<Host> selectHostsToBeTurnedOff(List<Host> candidateHosts, int nHosts); @Override List<Host> selectHostsToBeTurnedOff(List<Host> candidateHosts, int minCpus, int maxCpus);  }### Answer:
@Test public void selectHostsToBeTurnedOn() { assertEquals(2, randomHostSelector.selectHostsToBeTurnedOn(getTestHosts(), 2).size()); }
@Test public void selectHostsToBeTurnedOnWhenTheGivenNumberIsGreaterThanTheNumberOfHosts() { assertEquals(getTestHosts().size(), randomHostSelector.selectHostsToBeTurnedOn(getTestHosts(), getTestHosts().size() + 1).size()); }
@Test public void selectHostsToBeTurnedOnGivenMinMax() { List<Host> candidateHosts = new ArrayList<>(); candidateHosts.add(new Host("host1", 5, 1024, 1, 0, 0, 0, false)); candidateHosts.add(new Host("host2", 10, 1024, 1, 0, 0, 0, false)); candidateHosts.add(new Host("host3", 15, 1024, 1, 0, 0, 0, false)); List<Host> selectedHosts = randomHostSelector.selectHostsToBeTurnedOn(candidateHosts, 2, 7); assertEquals(1, selectedHosts.size()); assertEquals("host1", selectedHosts.get(0).getHostname()); }
@Test public void selectHostsToBeTurnedOffGivenMinMax() { List<Host> candidateHosts = new ArrayList<>(); candidateHosts.add(new Host("host1", 5, 1024, 1, 0, 0, 0, false)); candidateHosts.add(new Host("host2", 5, 1024, 1, 0, 0, 0, false)); candidateHosts.add(new Host("host3", 20, 1024, 1, 0, 0, 0, false)); List<Host> selectedHosts = randomHostSelector.selectHostsToBeTurnedOn(candidateHosts, 10, 18); assertEquals(2, selectedHosts.size()); assertNotEquals("host3", selectedHosts.get(0).getHostname()); assertNotEquals("host3", selectedHosts.get(1).getHostname()); }