### Question:
RegionMetadata { public Region getRegionByEndpoint(final String endpoint) { String host = getHost(endpoint); for (Region region : regions) { for (String serviceEndpoint : region.getServiceEndpoints().values()) { if (host.equals(getHost(serviceEndpoint))) { return region; } } } throw new IllegalArgumentException( "No region found with any service for endpoint " + endpoint); } RegionMetadata(final List<Region> regions); List<Region> getRegions(); Region getRegion(final String name); List<Region> getRegionsForService(final String service); Region getRegionByEndpoint(final String endpoint); @Override String toString();  }### Answer:
@Test public void testGetRegionByEndpoint() { Region region = metadata.getRegionByEndpoint("s3-us-west-1.amazonaws.com"); Assert.assertNotNull(region); Assert.assertEquals("us-west-1", region.getName()); try { metadata.getRegionByEndpoint("bogus-monkeys"); Assert.fail("Expected an IllegalArgumentException"); } catch (IllegalArgumentException e) { } }