### Question:
SecurityGroupUpdaterService extends AbstractScheduledService implements ScheduledServiceMBean { @VisibleForTesting Set<Netmask> requiredRulesFor(Collection<CassandraInstance> instances) { ImmutableSet.Builder<Netmask> permissions = ImmutableSet.builder(); for (CassandraInstance instance : instances) { Netmask netmask = Netmask.fromCidr(instance.getPublicIpAddress() + "/32"); if (netmask != null) { permissions.add(netmask); } } return permissions.build(); } @Inject  SecurityGroupUpdaterService(
      CassandraRingService cassandraRingService,
      SecurityGroupService securityGroupService,
      @Named(SecurityGroupModule.SECURITY_GROUP_DATACENTERS_PROPERTY)
          Function<CassandraInstance, String> dataCenterTransformFunction,
      @Named(SecurityGroupModule.CASSANDRA_GOSSIP_PORT_PROPERTY) int listenPort,
      @Named(SecurityGroupModule.CASSANDRA_SSL_GOSSIP_PORT_PROPERTY) int sslListenPort,
      @Named(SecurityGroupModule.CASSANDRA_RING_SSL_ENABLED) Set<String> sslEnabledRings,
      @Named(SecurityGroupModule.SECURITY_GROUP_UPDATE_PERIOD_PROPERTY) Duration updatePeriod,
      @Named(SecurityGroupModule.SECURITY_GROUP_NAME_PREFIX_PROPERTY) String securityGroupNamePrefix); @Override void runOneIteration();  }### Answer:
@Test public void requiredRulesFor_emptyList() { replayAll(); assertEquals(ImmutableSet.<Netmask>of(), service().requiredRulesFor( ImmutableList.<CassandraInstance>of())); }
@Test public void requiredRulesFor() { replayAll(); assertEquals(Netmask.fromCidr(Arrays.asList("1.1.1.1/32", "2.2.2.2/32")), service().requiredRulesFor( ImmutableList.of(instance("1.1.1.1", null), instance("2.2.2.2", null)))); }