@Test public void testDatacentersForCloudLayer() { ImmutableSet.Builder<Datacenter> builder = ImmutableSet.builder(); builder.add(Datacenter.builder().id(18171).name("sea01").longName("Seattle").build()); builder.add(Datacenter.builder().id(37473).name("wdc01").longName("Washington, DC").build()); builder.add(Datacenter.builder().id(138124).name("dal05").longName("Dallas 5").build()); builder.add(Datacenter.builder().id(168642).name("sjc01").longName("San Jose 1").build()); builder.add(Datacenter.builder().id(224092).name("sng01").longName("Singapore 1").build()); builder.add(Datacenter.builder().id(265592).name("ams01").longName("Amsterdam 1").build()); Set<Datacenter> expected = builder.build(); Set<Datacenter> datacenters = cloudServerProductPackage.getDatacenters(); assert datacenters.size() == expected.size() : datacenters; assertTrue(datacenters.containsAll(expected)); for (Datacenter dataCenter : datacenters) { Address address = dataCenter.getLocationAddress(); assertNotNull(address); checkAddress(address); } }
@Test public void testGetIso3166CodeNoCountryAndState() { Datacenter datacenter = Datacenter.builder().id(1).longName("Nowhere").build(); Location location = function.apply(datacenter); assertEquals(location.getId(), Long.toString(datacenter.getId())); Set<String> iso3166Codes = location.getIso3166Codes(); assertEquals(iso3166Codes.size(), 0); }
@Test public void testGetIso3166CodeCountryOnly() { Address address = Address.builder().country("US").description("This is North America!").build(); Datacenter datacenter = Datacenter.builder().id(1).longName("Nowhere").locationAddress(address).build(); Location location = function.apply(datacenter); assertEquals(location.getId(), Long.toString(datacenter.getId())); Set<String> iso3166Codes = location.getIso3166Codes(); assertEquals(iso3166Codes.size(), 1); assertTrue(iso3166Codes.contains("US")); }
@Test public void testDatacenterToLocation() { Address address = Address.builder().country("US").state("TX").description("This is Texas!").build(); Datacenter datacenter = Datacenter.builder().id(1).longName("Texas Datacenter").locationAddress(address).build(); Location location = function.apply(datacenter); assertEquals(location.getId(), Long.toString(datacenter.getId())); Set<String> iso3166Codes = location.getIso3166Codes(); assertEquals(iso3166Codes.size(), 1); assertTrue(iso3166Codes.contains("US-TX")); }
@Test public void testGetIso3166CodeNoCountryAndState() { Datacenter datacenter = Datacenter.builder().id(1).name("Nowhere").longName("No where").build(); Location location = function.apply(datacenter); assertEquals(location.getId(), datacenter.getName()); Set<String> iso3166Codes = location.getIso3166Codes(); assertEquals(iso3166Codes.size(), 0); }
@Test public void testGetIso3166CodeWhitespaceTrimmer() { Address address = Address.builder().country(" US ").state(" TX ").description("This is spaced out Texas") .build(); Datacenter datacenter = Datacenter.builder().id(1).longName("Nowhere").locationAddress(address).build(); Location location = function.apply(datacenter); assertEquals(location.getId(), Long.toString(datacenter.getId())); Set<String> iso3166Codes = location.getIso3166Codes(); assertEquals(iso3166Codes.size(), 1); assertTrue(iso3166Codes.contains("US-TX")); } }
@Test public void testGetIso3166CodeCountryOnly() { Address address = Address.builder().country("US").description("This is North America!").build(); Datacenter datacenter = Datacenter.builder().id(1).name("Nowhere").longName("No where").locationAddress(address) .build(); Location location = function.apply(datacenter); assertEquals(location.getId(), datacenter.getName()); Set<String> iso3166Codes = location.getIso3166Codes(); assertEquals(iso3166Codes.size(), 1); assertTrue(iso3166Codes.contains("US")); }
@Test public void testCreateVirtualGuest() throws Exception { VirtualGuest virtualGuestRequest = VirtualGuest.builder() .domain("jclouds.org") .hostname("virtualGuestApiLiveTest") .startCpus(1) .maxMemory(1024) .operatingSystem(OperatingSystem.builder().id("CENTOS_6_64").operatingSystemReferenceCode("CENTOS_6_64").build()) .datacenter(Datacenter.builder().name(datacenter.getName()).build()) .build(); virtualGuest = virtualGuestApi.createVirtualGuest(virtualGuestRequest); boolean orderInSystem = loginDetailsTester.apply(virtualGuest); checkState(orderInSystem, "order for guest %s doesn't have login details within %sms", virtualGuest, Long.toString(guestLoginDelay)); virtualGuest = virtualGuestApi.getVirtualGuest(virtualGuest.getId()); checkVirtualGuest(virtualGuest); assertNotNull(virtualGuest.getPrimaryIpAddress(), "primaryIpAddress must be not null"); assertNotNull(virtualGuest.getPrimaryBackendIpAddress(), "backendIpAddress must be not null"); }
@Test public void testDatacenterToLocation() { Address address = Address.builder().country("US").state("TX").description("This is Texas!").build(); Datacenter datacenter = Datacenter.builder().id(1).name("Texas").longName("Texas Datacenter") .locationAddress(address).build(); Location location = function.apply(datacenter); assertEquals(location.getId(), datacenter.getName()); Set<String> iso3166Codes = location.getIso3166Codes(); assertEquals(iso3166Codes.size(), 1); assertTrue(iso3166Codes.contains("US-TX")); }
@Test public void testGetIso3166CodeWhitespaceTrimmer() { Address address = Address.builder().country(" US ").state(" TX ").description("This is spaced out Texas") .build(); Datacenter datacenter = Datacenter.builder().id(1).name("NoWhere").longName("Nowhere").locationAddress(address) .build(); Location location = function.apply(datacenter); assertEquals(location.getId(), datacenter.getName()); Set<String> iso3166Codes = location.getIso3166Codes(); assertEquals(iso3166Codes.size(), 1); assertTrue(iso3166Codes.contains("US-TX")); } }
private VirtualGuest createVirtualGuestWithoutOperatingSystem() { return VirtualGuest.builder() .domain("example.com") .hostname("host1") .id(1301396) .maxMemory(1024) .startCpus(1) .localDiskFlag(true) .datacenter(Datacenter.builder().name("test").build()) .softwareLicense(SoftwareLicense.builder().build()) .build(); }
private VirtualGuest createVirtualGuestWithoutSoftwareLicenseDetails() { return VirtualGuest.builder() .domain("example.com") .hostname("host1") .id(1301396) .maxMemory(1024) .startCpus(1) .localDiskFlag(true) .operatingSystem(OperatingSystem.builder().id("UBUNTU_LATEST") .operatingSystemReferenceCode("UBUNTU_LATEST") .build()) .datacenter(Datacenter.builder().name("test").build()) .build(); }
private VirtualGuest createVirtualGuest() { return VirtualGuest.builder() .domain("example.com") .hostname("host1") .id(1301396) .maxMemory(1024) .startCpus(1) .localDiskFlag(true) .operatingSystem(OperatingSystem.builder().id("UBUNTU_LATEST") .operatingSystemReferenceCode("UBUNTU_LATEST") .build()) .datacenter(Datacenter.builder().name("test").build()) .build(); } }
private VirtualGuest createVirtualGuest() { return VirtualGuest.builder() .domain("example.com") .hostname("host1") .id(1301396) .maxMemory(1024) .startCpus(1) .localDiskFlag(true) .operatingSystem(OperatingSystem.builder().id("UBUNTU_LATEST") .operatingSystemReferenceCode("UBUNTU_LATEST") .build()) .datacenter(Datacenter.builder().name("test").build()) .build(); }
@Override @Consumes(MediaType.APPLICATION_JSON) public VirtualGuest expected() { return VirtualGuest .builder() .id(416788).accountId(93750).billingItemId(7185261) .createDate(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-10-02T03:24:43-08:00")) .dedicatedAccountHostOnly(true).domain("me.org").fullyQualifiedDomainName("node1000360500.me.org") .hostname("node1000360500").maxCpu(1).maxCpuUnits("CORE").maxMemory(1024) .modifyDate(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-10-02T03:25:33-08:00")) .primaryBackendIpAddress("10.37.102.194").primaryIpAddress("173.192.29.186").startCpus(1).statusId(1001) .uuid("96fe22ad-8182-924d-ce51-a037e477dd83") .operatingSystem(OperatingSystem.builder().id(913960).build()) .datacenter(Datacenter.builder().id(3).name("dal01").longName("Dallas").build()) //TODO: maybe powerState can be flattened like billingItemId .powerState(new PowerState(VirtualGuest.State.HALTED)).build(); }
private VirtualGuest createVirtualGuestWithSoftwareLicenseDetails() { return VirtualGuest.builder() .domain("example.com") .hostname("host1") .id(1301396) .maxMemory(1024) .startCpus(1) .localDiskFlag(true) .operatingSystem(OperatingSystem.builder().id("UBUNTU_LATEST") .operatingSystemReferenceCode("UBUNTU_LATEST") .softwareLicense(SoftwareLicense.builder() .softwareDescription(SoftwareDescription.builder() .version("12.04-64 Minimal for CCI") .referenceCode("UBUNTU_12_64") .longDescription("Ubuntu Linux 12.04 LTS Precise Pangolin - Minimal Install (64 bit)") .build()) .build()) .build()) .datacenter(Datacenter.builder().name("test").build()) .build(); } }
@Override @Consumes(MediaType.APPLICATION_JSON) public VirtualGuest expected() { return VirtualGuest .builder() .id(416700).accountId(93750).billingItemId(7184019) .createDate(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-10-01T11:47:35-08:00")) .metricPollDate(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-10-02T02:32:00-08:00")) .dedicatedAccountHostOnly(true).domain("me.org").fullyQualifiedDomainName("node1703810489.me.org") .hostname("node1703810489").maxCpu(1).maxCpuUnits("CORE").maxMemory(1024) .modifyDate(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-10-02T03:18:12-08:00")) .primaryBackendIpAddress("10.37.102.195").primaryIpAddress("173.192.29.187").startCpus(1).statusId(1001) .uuid("02ddbbba-9225-3d54-6de5-fc603b309dd8") .operatingSystem(OperatingSystem.builder().id(913824) .passwords(Password.builder().id(729122).username("root").password("KnJqhC2l").build()) .build()) .datacenter(Datacenter.builder().id(3).name("dal01").longName("Dallas").build()) //TODO: maybe powerState can be flattened like billingItemId .powerState(new PowerState(VirtualGuest.State.PAUSED)).build(); }
@Override @Consumes(MediaType.APPLICATION_JSON) public VirtualGuest expected() { return VirtualGuest .builder() .id(416700).accountId(93750).billingItemId(7184019) .createDate(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-10-01T11:47:35-08:00")) .metricPollDate(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-10-02T02:32:00-08:00")) .dedicatedAccountHostOnly(true).domain("me.org").fullyQualifiedDomainName("node1703810489.me.org") .hostname("node1703810489").maxCpu(1).maxCpuUnits("CORE").maxMemory(1024) .modifyDate(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-10-02T03:19:43-08:00")) .primaryBackendIpAddress("10.37.102.195").primaryIpAddress("173.192.29.187").startCpus(1).statusId(1001) .uuid("02ddbbba-9225-3d54-6de5-fc603b309dd8") .operatingSystem(OperatingSystem.builder().id(913824) .passwords(Password.builder().id(729122).username("root").password("KnJqhC2l").build()) .build()) .datacenter(Datacenter.builder().id(3).name("dal01").longName("Dallas").build()) //TODO: maybe powerState can be flattened like billingItemId .powerState(new PowerState(VirtualGuest.State.HALTED)).build(); }
@Override @Consumes(MediaType.APPLICATION_JSON) public VirtualGuest expected() { return VirtualGuest .builder() .id(416700).accountId(93750).billingItemId(7184019) .createDate(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-10-01T11:47:35-08:00")) .metricPollDate(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-10-02T02:32:00-08:00")) .dedicatedAccountHostOnly(true).domain("me.org").fullyQualifiedDomainName("node1703810489.me.org") .hostname("node1703810489").maxCpu(1).maxCpuUnits("CORE").maxMemory(1024) .modifyDate(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-10-02T02:32:40-08:00")) .primaryBackendIpAddress("10.37.102.195").primaryIpAddress("173.192.29.187").startCpus(1).statusId(1001) .uuid("02ddbbba-9225-3d54-6de5-fc603b309dd8") .operatingSystem(OperatingSystem.builder().id(913824) .passwords(Password.builder().id(729122).username("root").password("KnJqhC2l").build()) .build()) .datacenter(Datacenter.builder().id(3).name("dal01").longName("Dallas").build()) //TODO: maybe powerState can be flattened like billingItemId .powerState(new PowerState(VirtualGuest.State.RUNNING)).build(); }
private VirtualGuest createVirtualGuest() { return VirtualGuest.builder() .domain("example.com") .hostname("host1") .fullyQualifiedDomainName("host1.example.com") .id(1301396) .maxMemory(1024) .startCpus(1) .localDiskFlag(true) .operatingSystem(OperatingSystem.builder().id("UBUNTU_LATEST") .operatingSystemReferenceCode("UBUNTU_LATEST") .softwareLicense(SoftwareLicense.builder() .softwareDescription(SoftwareDescription.builder() .version("12.04-64 Minimal for CCI") .referenceCode("UBUNTU_12_64") .longDescription("Ubuntu Linux 12.04 LTS Precise Pangolin - Minimal Install (64 bit)") .build()) .build()) .build()) .datacenter(Datacenter.builder().name("test").build()) .powerState(PowerState.builder().keyName(VirtualGuest.State.RUNNING).build()) .build(); }