LocationIdToURIFromAccessForTypeAndVersion implements Supplier<Map<String, Supplier<URI>>> { @Override public Map<String, Supplier<URI>> get() { FluentIterable<Service> services = FluentIterable.from(access.get()).filter(apiTypeEquals); if (services.toSet().size() == 0) throw new NoSuchElementException(String.format("apiType %s not found in catalog %s", apiType, services)); Iterable<Endpoint> endpoints = concat(services); if (size(endpoints) == 0) throw new NoSuchElementException( String.format("no endpoints for apiType %s in services %s", apiType, services)); boolean checkVersionId = any(endpoints, versionAware); Multimap<String, Endpoint> locationToEndpoints = index(endpoints, endpointToLocationId); Map<String, Endpoint> locationToEndpoint; if (checkVersionId && apiVersion != null) { locationToEndpoint = refineToVersionSpecificEndpoint(locationToEndpoints); if (locationToEndpoint.size() == 0) throw new NoSuchElementException(String.format( "no endpoints for apiType %s are of version %s, or version agnostic: %s", apiType, apiVersion, locationToEndpoints)); } else { locationToEndpoint = firstEndpointInLocation(locationToEndpoints); } logger.debug("endpoints for apiType %s and version %s: %s", apiType, apiVersion, locationToEndpoints); return Maps.transformValues(locationToEndpoint, endpointToSupplierURI); } @Inject  LocationIdToURIFromAccessForTypeAndVersion(Supplier<Access> access,
         EndpointToSupplierURI endpointToSupplierURI, Function<Endpoint, String> endpointToLocationId,
         @Assisted("apiType") String apiType, @Nullable @Assisted("apiVersion") String apiVersion); @Override Map<String, Supplier<URI>> get(); @Override String toString();  }
@Test(expectedExceptions = NoSuchElementException.class) public void testWhenNotInList() { assertEquals(Maps.transformValues(raxFactory.createForApiTypeAndVersion("goo", "1.0").get(), Suppliers .<URI> supplierFunction()), ImmutableMap.of("rackspace", URI .create("https: }