### Question:
KeyspaceHelper { public static Set<String> getDatacenters(Metadata metadata) { Set<String> datacenters = new HashSet<>(); for (Host host : metadata.getAllHosts()) { datacenters.add(host.getDatacenter()); } return datacenters; } private  KeyspaceHelper(); static Set<String> getDatacentersForKeyspace(Metadata metadata, String keyspace); static Set<String> getDatacenters(Metadata metadata);  }### Answer:
@Test public void testGetDatacenters() { Host host1 = mock(Host.class); Host host2 = mock(Host.class); Host host3 = mock(Host.class); Set<Host> hosts = new HashSet<>(); hosts.add(host1); hosts.add(host2); hosts.add(host3); when(metadata.getAllHosts()).thenReturn(hosts); when(host1.getDatacenter()).thenReturn("dc1"); when(host2.getDatacenter()).thenReturn("dc2"); when(host3.getDatacenter()).thenReturn("dc3"); Collection<String> datacenters = KeyspaceHelper.getDatacenters(metadata); assertThat(datacenters).containsOnly("dc1", "dc2", "dc3"); }