### Question:
ZergHosts { public static @Nullable CassandraInstance toCassandraInstance(ZergHost host) { Matcher m = ZONE_PATTERN.matcher(host.getZone()); if (m.find()) { return new CassandraInstance.Builder() .id(host.getId()) .dataCenter(m.group(1)) .rack(m.group(2)) .hostName(host.getName()) .publicIpAddress(host.getPublicIpAddress()) .fullyQualifiedDomainName(host.getFullyQualifiedDomainName()) .build(); } return null; } private  ZergHosts(ImmutableSet<ZergHost> hosts); static ZergHosts from(Collection<ZergHost> hosts); static @Nullable CassandraInstance toCassandraInstance(ZergHost host); ImmutableSet<String> rings(); ZergHosts filterRing(final String ring); ZergHosts filterRegion(final String region); ZergHosts filterScope(Map<String, String> ringScopes, String region, String ring); ImmutableSet<ZergHost> toSet(); ImmutableSet<CassandraInstance> toCassandraInstances();  }### Answer:
@Test public void toCassandraInstance() { assertEquals(instance("host1", "us-east", "1a", "1.1.1.1", "domain1"), ZergHosts.toCassandraInstance(host("host1", "us-east-1a", "1.1.1.1", "domain1"))); }
@Test public void toCassandraInstance_noAvailabilityZone() { assertNull(ZergHosts.toCassandraInstance(host("host1", "us-east", "1.1.1.1", "domain1"))); }
@Test public void toCassandraInstance_emptyAvailabilityZone() { assertEquals(null, ZergHosts.toCassandraInstance(host("host1", "us-east-", "1.1.1.1", "domain1"))); }
@Test public void toCassandraInstance_invalidRegion() { assertNull(ZergHosts.toCassandraInstance(host("host1", "us", "1.1.1.1", "domain1"))); }
@Test public void toCassandraInstance_emptyRegion() { assertNull(ZergHosts.toCassandraInstance(host("host1", "-1a", "1.1.1.1", "domain1"))); }