}
}
@Test
public void testTemplateBuilderWithLessRegions() throws IOException, SecurityException, NoSuchMethodException {
ComputeServiceContext context = null;
try {
Properties overrides = setupProperties();
// set regions to only 1
overrides.setProperty(LocationConstants.PROPERTY_REGIONS, Region.EU_WEST_1);
overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_CC_REGIONS, "");
overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_AMI_QUERY, "");
overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY, "");
final List<HttpCommand> commandsInvoked = Lists.newArrayList();
context = createView(
overrides,
ImmutableSet.<Module> of(new Log4JLoggingModule(),
TrackingJavaUrlHttpCommandExecutorService.newTrackingModule(commandsInvoked)));
assert context.getComputeService().listAssignableLocations().size() < this.view.getComputeService()
.listAssignableLocations().size();
assertOnlyOneRegionQueriedForAvailabilityZone(commandsInvoked);
assert context.getComputeService().listImages().size() < this.view.getComputeService().listImages().size();
Template template = context.getComputeService().templateBuilder().imageId("eu-west-1/ami-a33b06d7").build();
assert (template.getImage().getProviderId().startsWith("ami-")) : template;
assertEquals(template.getImage().getOperatingSystem().getVersion(), "2011.09.2");
assertEquals(template.getImage().getOperatingSystem().is64Bit(), true);
assertEquals(template.getImage().getOperatingSystem().getFamily(), OsFamily.AMZN_LINUX);
assertEquals(template.getImage().getVersion(), "2011.09.2");
assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "instance-store");
assertEquals(template.getLocation().getId(), "eu-west-1");
assertEquals(getCores(template.getHardware()), 1.0d);
assertEquals(template.getHardware().getId(), "m1.small");
} finally {
if (context != null)
context.close();
}
}