### Question:
RegionToProvider implements LocationsSupplier { @Override public Set<? extends Location> get() { Builder<Location> locations = ImmutableSet.builder(); Location provider = Iterables.getOnlyElement(justProvider.get()); Set<String> regions = regionsSupplier.get(); checkState(!regions.isEmpty(), "no regions found for provider %s, using supplier %s", provider, regionsSupplier); Map<String, Supplier<Set<String>>> isoCodesById = isoCodesByIdSupplier.get(); for (String region : regions) { LocationBuilder builder = new LocationBuilder().scope(LocationScope.REGION).id(region).description(region) .parent(provider); if (isoCodesById.containsKey(region)) builder.iso3166Codes(isoCodesById.get(region).get()); locations.add(builder.build()); } return locations.build(); } @Inject  RegionToProvider(JustProvider justProvider, @Region Supplier<Set<String>> regionsSupplier,
            @Iso3166 Supplier<Map<String, Supplier<Set<String>>>> isoCodesByIdSupplier); @Override Set<? extends Location> get();  }### Answer:
@Test public void test() { Supplier<Set<String>> regionIdsSupplier = Suppliers.<Set<String>>ofInstance(ImmutableSet.of("region1", "region2")); Supplier<Map<String, Supplier<Set<String>>>> locationToIsoCodes = Suppliers.<Map<String, Supplier<Set<String>>>>ofInstance( ImmutableMap.of( "servo", Suppliers.<Set<String>>ofInstance(ImmutableSet.of("US")), "region1", Suppliers.<Set<String>>ofInstance(ImmutableSet.of("US-CA")), "region2", Suppliers.<Set<String>>ofInstance(ImmutableSet.of("US-VA")) )); RegionToProvider fn = new RegionToProvider(justProvider, regionIdsSupplier, locationToIsoCodes); assertEquals(fn.get(), ImmutableSet.of( new LocationBuilder().scope(LocationScope.REGION).id("region1").description("region1").iso3166Codes(ImmutableSet.of("US-CA")).parent(provider).build(), new LocationBuilder().scope(LocationScope.REGION).id("region2").description("region2").iso3166Codes(ImmutableSet.of("US-VA")).parent(provider).build() )); }
@Test(expectedExceptions = IllegalStateException.class) public void testWhenNoRegions() { Supplier<Set<String>> regionIdsSupplier = Suppliers.<Set<String>>ofInstance(ImmutableSet.<String>of()); Supplier<Map<String, Supplier<Set<String>>>> locationToIsoCodes = Suppliers.<Map<String, Supplier<Set<String>>>>ofInstance( ImmutableMap.<String, Supplier<Set<String>>>of()); RegionToProvider fn = new RegionToProvider(justProvider, regionIdsSupplier, locationToIsoCodes); fn.get(); }