mirror of https://github.com/apache/jclouds.git
ProductPackageClientLiveTest used Cloud Server pkg name instead of id
This commit is contained in:
parent
528a89a6fe
commit
c52c13e625
|
@ -19,6 +19,7 @@
|
||||||
package org.jclouds.softlayer.features;
|
package org.jclouds.softlayer.features;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertNotNull;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -42,13 +43,17 @@ public class ProductPackageClientLiveTest extends BaseSoftLayerClientLiveTest {
|
||||||
public void setupClient() {
|
public void setupClient() {
|
||||||
super.setupClient();
|
super.setupClient();
|
||||||
client = context.getApi().getProductPackageClient();
|
client = context.getApi().getProductPackageClient();
|
||||||
|
accountClient = context.getApi().getAccountClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String CLOUD_SERVER_PACKAGE_NAME = "Cloud Server";
|
||||||
|
|
||||||
private ProductPackageClient client;
|
private ProductPackageClient client;
|
||||||
|
private AccountClient accountClient;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetProductPackage() {
|
public void testGetProductPackage() {
|
||||||
for (ProductPackage productPackage : context.getApi().getAccountClient().getActivePackages()) {
|
for (ProductPackage productPackage : accountClient.getActivePackages()) {
|
||||||
ProductPackage response = client.getProductPackage(productPackage.getId());
|
ProductPackage response = client.getProductPackage(productPackage.getId());
|
||||||
|
|
||||||
assert null != response;
|
assert null != response;
|
||||||
|
@ -72,7 +77,6 @@ public class ProductPackageClientLiveTest extends BaseSoftLayerClientLiveTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDatacentersForCloudLayer() {
|
public void testDatacentersForCloudLayer() {
|
||||||
ProductPackage productPackage = context.getApi().getProductPackageClient().getProductPackage(getCloudLayerPackageId());
|
|
||||||
|
|
||||||
ImmutableSet.Builder<Datacenter> builder = ImmutableSet.builder();
|
ImmutableSet.Builder<Datacenter> builder = ImmutableSet.builder();
|
||||||
builder.add(Datacenter.builder().id(3).name("dal01").longName("Dallas").build());
|
builder.add(Datacenter.builder().id(3).name("dal01").longName("Dallas").build());
|
||||||
|
@ -83,15 +87,21 @@ public class ProductPackageClientLiveTest extends BaseSoftLayerClientLiveTest {
|
||||||
|
|
||||||
Set<Datacenter> expected = builder.build();
|
Set<Datacenter> expected = builder.build();
|
||||||
|
|
||||||
|
Long productPackageId = getProductPackageId(CLOUD_SERVER_PACKAGE_NAME);
|
||||||
|
assertNotNull(productPackageId);
|
||||||
|
|
||||||
|
ProductPackage productPackage = client.getProductPackage(productPackageId);
|
||||||
Set<Datacenter> datacenters = productPackage.getDatacenters();
|
Set<Datacenter> datacenters = productPackage.getDatacenters();
|
||||||
assertEquals(datacenters.size(), expected.size());
|
assertEquals(datacenters.size(), expected.size());
|
||||||
assertTrue(datacenters.containsAll(expected));
|
assertTrue(datacenters.containsAll(expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO The packageId will be obtained via a search call later.
|
private Long getProductPackageId(String name) {
|
||||||
private int getCloudLayerPackageId() {
|
for (ProductPackage productPackage : accountClient.getActivePackages()) {
|
||||||
return 46;
|
if (productPackage.getName().equals(name)) return productPackage.getId();
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private void checkProductItem(ProductItem item) {
|
private void checkProductItem(ProductItem item) {
|
||||||
assert item.getId() > 0 : item;
|
assert item.getId() > 0 : item;
|
||||||
|
|
Loading…
Reference in New Issue