@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 testListDatacentersContent() { Builder<Datacenter> builder = ImmutableSet.builder(); builder.add(Datacenter.builder().id(265592).name("ams01").longName("Amsterdam 1").build()); builder.add(Datacenter.builder().id(3).name("dal01").longName("Dallas").build()); builder.add(Datacenter.builder().id(18171).name("sea01").longName("Seattle").build()); builder.add(Datacenter.builder().id(168642).name("sjc01").longName("San Jose 1").build()); builder.add(Datacenter.builder().id(2).name("dal00").longName("Corporate HQ").build()); builder.add(Datacenter.builder().id(37473).name("wdc01").longName("Washington, DC").build()); builder.add(Datacenter.builder().id(154770).name("dal02").longName("Dallas 2").build()); builder.add(Datacenter.builder().id(138124).name("dal05").longName("Dallas 5").build()); builder.add(Datacenter.builder().id(167093).name("hou01").longName("Houston 1").build()); builder.add(Datacenter.builder().id(167094).name("lon01").longName("London 1").build()); builder.add(Datacenter.builder().id(167092).name("dal04").longName("Dallas 4").build()); builder.add(Datacenter.builder().id(224092).name("sng01").longName("Singapore 1").build()); builder.add(Datacenter.builder().id(142775).name("hou02").longName("Houston 2").build()); builder.add(Datacenter.builder().id(142776).name("dal07").longName("Dallas 7").build()); builder.add(Datacenter.builder().id(154820).name("dal06").longName("Dallas 6").build()); Set<Datacenter> response = api().listDatacenters(); Set<Datacenter> expected = builder.build(); assertEquals(response.size(),expected.size()); assertTrue(response.containsAll(expected)); for(Datacenter datacenter: response) { Address address = datacenter.getLocationAddress(); if(address!=null) checkAddress(address); } }
@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(); }
@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-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(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(); }
@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")); } }
@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")); }
public T fromDatacenter(Datacenter in) { return this .id(in.getId()) .name(in.getName()) .longName(in.getLongName()) .locationAddress(in.getLocationAddress()) .regions(in.getRegions()); } }
@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 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); }
public T fromDatacenter(Datacenter in) { return this .id(in.getId()) .name(in.getName()) .longName(in.getLongName()) .locationAddress(in.getLocationAddress()) .regions(in.getRegions()); } }
public T fromDatacenter(Datacenter in) { return this .id(in.getId()) .name(in.getName()) .longName(in.getLongName()) .locationAddress(in.getLocationAddress()) .regions(in.getRegions()); } }
public T fromDatacenter(Datacenter in) { return this .id(in.getId()) .name(in.getName()) .longName(in.getLongName()) .locationAddress(in.getLocationAddress()) .regions(in.getRegions()); } }
@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")); } }
public T fromDatacenter(Datacenter in) { return this .id(in.getId()) .name(in.getName()) .longName(in.getLongName()) .locationAddress(in.getLocationAddress()) .regions(in.getRegions()); } }
public T fromDatacenter(Datacenter in) { return this .id(in.getId()) .name(in.getName()) .longName(in.getLongName()) .locationAddress(in.getLocationAddress()) .regions(in.getRegions()); } }
@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")); }