@Override public boolean apply(Region region) { return region.available(); } });
@Override public String apply(Region input) { return input.slug(); } }));
@Override public Location apply(Region input) { LocationBuilder builder = new LocationBuilder(); builder.id(input.slug()); builder.description(input.name()); builder.scope(LocationScope.REGION); builder.parent(getOnlyElement(justProvider.get())); builder.iso3166Codes(ImmutableSet.<String> of()); builder.metadata(ImmutableMap.<String, Object> of("available", input.available(), "features", input.features())); return builder.build(); } }
@Test public void testConvertRegion() { DigitalOcean2ProviderMetadata metadata = new DigitalOcean2ProviderMetadata(); JustProvider locationsSupplier = new JustProvider(metadata.getId(), Suppliers.<URI> ofInstance(URI .create(metadata.getEndpoint())), ImmutableSet.<String> of()); Region region = Region.create("reg1", "Region1", ImmutableList.<String> of(), true, ImmutableList.<String> of("virtio", "metadata")); Location expected = new LocationBuilder().id("reg1").description("reg1/Region 1") .parent(getOnlyElement(locationsSupplier.get())).scope(LocationScope.REGION).build(); Location location = new RegionToLocation(locationsSupplier).apply(region); assertEquals(location, expected); assertEquals(location.getMetadata().get("available"), true); assertEquals(location.getMetadata().get("features"), ImmutableList.of("virtio", "metadata")); } }
@Override public Location apply(Region input) { LocationBuilder builder = new LocationBuilder(); builder.id(input.slug()); builder.description(input.name()); builder.scope(LocationScope.REGION); builder.parent(getOnlyElement(justProvider.get())); builder.iso3166Codes(ImmutableSet.<String> of()); builder.metadata(ImmutableMap.<String, Object> of("available", input.available(), "features", input.features())); return builder.build(); } }
@BeforeMethod public void setup() { image = org.jclouds.digitalocean2.domain.Image.create(1, "14.04 x64", "distribution", "Ubuntu", "ubuntu-1404-x86", true, ImmutableList.of("sfo1"), new Date(), 20, 20); region = Region.create("sfo1", "San Francisco 1", ImmutableList.of("2gb"), true, ImmutableList.<String> of()); images = ImmutableSet.of(new ImageBuilder() .id("sfo1/ubuntu-1404-x86") .providerId("1") .name("mock image") .status(AVAILABLE) .operatingSystem( OperatingSystem.builder().name("Ubuntu 14.04 x86_64").description("Ubuntu").family(OsFamily.UBUNTU) .version("10.04").arch("x86_64").is64Bit(true).build()).build()); hardwares = ImmutableSet.of(new HardwareBuilder().id("2gb").providerId("2gb").name("mock hardware") .processor(new Processor(1.0, 1.0)).ram(2048) .volume(new VolumeBuilder().size(20f).type(Type.LOCAL).build()).build()); locations = ImmutableSet.of(new LocationBuilder() .id("sfo1") .description("sfo1/San Francisco 1") .scope(LocationScope.REGION) .parent( new LocationBuilder().id("0").description("mock parent location").scope(LocationScope.PROVIDER) .build()).build()); credentials = LoginCredentials.builder().user("foo").password("bar").build(); function = createNodeParser(hardwares, images, locations, ImmutableMap.of("node#1", (Credentials) credentials)); }
@Override public Location apply(Region input) { LocationBuilder builder = new LocationBuilder(); builder.id(input.slug()); builder.description(input.name()); builder.scope(LocationScope.REGION); builder.parent(getOnlyElement(justProvider.get())); builder.iso3166Codes(ImmutableSet.<String> of()); builder.metadata(ImmutableMap.<String, Object> of("available", input.available(), "features", input.features())); return builder.build(); } }
@Override public String apply(Region input) { return input.slug(); } }));
@Override public boolean apply(Region region) { return region.available(); } });
@Override public String apply(Region input) { return input.slug(); } }));
@Override public boolean apply(Region region) { return region.available(); } });
@Override public boolean apply(Location location) { return region != null && region.slug().equals(location.getId()); } }, null);
@Override public boolean apply(Region input) { return input.available(); }
@Override public boolean apply(Location location) { return region != null && region.slug().equals(location.getId()); } }, null);
@Override public boolean apply(Region input) { return input.available(); }
@Override public boolean apply(Location location) { return region != null && region.slug().equals(location.getId()); } }, null);
@Override public boolean apply(Region input) { return input.available(); }
@Override public boolean apply(Region input) { found.incrementAndGet(); return !Strings.isNullOrEmpty(input.slug()); } }), "All regions must have the 'slug' field populated");
@Override public boolean apply(Region input) { return input.available(); } }).get();
@Override public boolean apply(Region input) { found.incrementAndGet(); return !Strings.isNullOrEmpty(input.slug()); } }), "All regions must have the 'slug' field populated");