### Question:
HostsManager { public Host getHost(String hostname) { for (Host host: hosts) { if (hostname.equals(host.getHostname())) { host.refreshMonitoringInfo(); return host; } } return null; } HostsManager(List<Host> hosts); List<Host> getHosts(); Host getHost(String hostname); void pressHostPowerButton(String hostname);  }### Answer:
@Test public void getHost() { List<Host> hosts = new ArrayList<>(); HostFake host1 = new HostFake("host1", 1, 1024, 10, 0, 0, 0); HostFake host2 = new HostFake("host2", 2, 2048, 20, 0, 0, 0); hosts.add(host1); hosts.add(host2); HostsManager hostsManager = new HostsManager(hosts); assertEquals(host1, hostsManager.getHost("host1")); assertEquals(host2, hostsManager.getHost("host2")); }
@Test public void getHostReturnsNullWhenDoesNotExist() { HostsManager hostsManager = new HostsManager(new ArrayList<Host>()); assertNull(hostsManager.getHost("NonExistingHost")); }