### Question:
PerDataCenterSeedService implements SeedService { @Override public ImmutableSet<String> getSeeds(CassandraRing ring) { ImmutableSet.Builder<String> seedBuilder = ImmutableSet.builder(); ImmutableSetMultimap<String, CassandraInstance> dataCenterToInstanceMap = buildDataCenterToInstanceMap(ring.getInstances()); for (String dc : dataCenterToInstanceMap.keySet()) { seedBuilder.addAll(getSeeds(dc, dataCenterToInstanceMap.get(dc))); } return seedBuilder.build(); } @Inject  PerDataCenterSeedService(@Named(ServiceModule.SEEDS_PER_DATACENTER_PROPERTY) int numSeeds); @Override ImmutableSet<String> getSeeds(CassandraRing ring);  }### Answer:
@Test public void getSeeds() { CassandraInstance instance1 = buildInstance(DATACENTER1, IP_ADDRESS_1); CassandraInstance instance2 = buildInstance(DATACENTER1, IP_ADDRESS_2); CassandraInstance instance3 = buildInstance(DATACENTER2, IP_ADDRESS_3); CassandraInstance instance4 = buildInstance(DATACENTER2, IP_ADDRESS_4); ImmutableSet<CassandraInstance> instances = ImmutableSet.of(instance1, instance2, instance3, instance4); expect(ring.getInstances()).andReturn(instances); replayAll(); assertEquals(ImmutableSet.of(IP_ADDRESS_1, IP_ADDRESS_2, IP_ADDRESS_3, IP_ADDRESS_4), seedProvider.getSeeds(ring)); }
@Test public void getSeeds_returnsFullyQualifiedDomainNameIfAvailable() { CassandraInstance instance1 = buildInstance(DATACENTER1, IP_ADDRESS_1, DOMAIN_NAME_1); CassandraInstance instance2 = buildInstance(DATACENTER1, IP_ADDRESS_2); ImmutableSet<CassandraInstance> instances = ImmutableSet.of(instance1, instance2); expect(ring.getInstances()).andReturn(instances); replayAll(); assertEquals(ImmutableSet.of(DOMAIN_NAME_1, IP_ADDRESS_2), seedProvider.getSeeds(ring)); }
@Test public void getSeeds_insufficientInstancesInDataCenter() { CassandraInstance instance1 = buildInstance(DATACENTER1, IP_ADDRESS_1); CassandraInstance instance2 = buildInstance(DATACENTER2, IP_ADDRESS_2); CassandraInstance instance3 = buildInstance(DATACENTER2, IP_ADDRESS_3); ImmutableSet<CassandraInstance> instances = ImmutableSet.of(instance1, instance2, instance3); expect(ring.getInstances()).andReturn(instances); replayAll(); assertEquals(ImmutableSet.of(IP_ADDRESS_1, IP_ADDRESS_2, IP_ADDRESS_3), seedProvider.getSeeds(ring)); }