mirror of https://github.com/apache/jclouds.git
Issue 158: Fixing unit/live tests
This commit is contained in:
parent
5b6b4da3f9
commit
c674bdb1b3
|
@ -71,7 +71,7 @@ public class ProductItemToImage implements Function<ProductItem, Image> {
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
return new ImageBuilder()
|
return new ImageBuilder()
|
||||||
.id(imageId().apply(productItem))
|
.ids(imageId().apply(productItem))
|
||||||
.description(productItem.getDescription())
|
.description(productItem.getDescription())
|
||||||
.operatingSystem(os)
|
.operatingSystem(os)
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class ProductItems {
|
||||||
/**
|
/**
|
||||||
* Creates a function to get the ProductItem for the ProductItemPrice.
|
* Creates a function to get the ProductItem for the ProductItemPrice.
|
||||||
* Copies the category information from the price to the item if necessary
|
* Copies the category information from the price to the item if necessary
|
||||||
* // TODO: This method needs unit testing.
|
* The ProductItemPrices must have ProductItems.
|
||||||
*/
|
*/
|
||||||
public static Function<ProductItemPrice,ProductItem> item() {
|
public static Function<ProductItemPrice,ProductItem> item() {
|
||||||
return new Function<ProductItemPrice,ProductItem>() {
|
return new Function<ProductItemPrice,ProductItem>() {
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class ProductItemsToHardware implements Function<Set<ProductItem>, Hardwa
|
||||||
final float volumeSize = ProductItems.capacity().apply(volumeItem);
|
final float volumeSize = ProductItems.capacity().apply(volumeItem);
|
||||||
|
|
||||||
return new HardwareBuilder()
|
return new HardwareBuilder()
|
||||||
.id(hardwareId)
|
.ids(hardwareId)
|
||||||
.processors(ImmutableList.of(new Processor(cores, CORE_SPEED)))
|
.processors(ImmutableList.of(new Processor(cores, CORE_SPEED)))
|
||||||
.ram(ram)
|
.ram(ram)
|
||||||
.volumes(ImmutableList.<Volume> of(new VolumeImpl(volumeSize, true, false)))
|
.volumes(ImmutableList.<Volume> of(new VolumeImpl(volumeSize, true, false)))
|
||||||
|
|
|
@ -176,7 +176,6 @@ public class ProductItemPrice implements Comparable<ProductItemPrice> {
|
||||||
return Builder.fromPrice(this);
|
return Builder.fromPrice(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Add category and item (breaks unit tests that compare toString()).
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[id=" + id + ", itemId=" + itemId + ", recurringFee=" + recurringFee + ", hourlyRecurringFee="
|
return "[id=" + id + ", itemId=" + itemId + ", recurringFee=" + recurringFee + ", hourlyRecurringFee="
|
||||||
|
|
|
@ -43,6 +43,7 @@ import static org.testng.Assert.assertEquals;
|
||||||
public class SoftLayerComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
public class SoftLayerComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
public SoftLayerComputeServiceLiveTest() {
|
public SoftLayerComputeServiceLiveTest() {
|
||||||
provider = "softlayer";
|
provider = "softlayer";
|
||||||
|
group = "soft-layer";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -57,33 +58,7 @@ public class SoftLayerComputeServiceLiveTest extends BaseComputeServiceLiveTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void checkNodes(Iterable<? extends NodeMetadata> nodes, String tag) throws IOException {
|
public void testOptionToNotBlock() {
|
||||||
super.checkNodes(nodes, tag);
|
// start call is blocking anyway.
|
||||||
for (NodeMetadata node : nodes) {
|
|
||||||
assertEquals(node.getLocation().getScope(), LocationScope.HOST);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = "testReboot", expectedExceptions = UnsupportedOperationException.class)
|
|
||||||
public void testSuspendResume() throws Exception {
|
|
||||||
super.testSuspendResume();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = "testSuspendResume")
|
|
||||||
@Override
|
|
||||||
public void testGetNodesWithDetails() throws Exception {
|
|
||||||
super.testGetNodesWithDetails();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = "testSuspendResume")
|
|
||||||
@Override
|
|
||||||
public void testListNodes() throws Exception {
|
|
||||||
super.testListNodes();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = { "testListNodes", "testGetNodesWithDetails" })
|
|
||||||
@Override
|
|
||||||
public void testDestroyNodes() {
|
|
||||||
super.testDestroyNodes();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,15 +20,14 @@ package org.jclouds.softlayer.compute.functions;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import org.jclouds.softlayer.domain.ProductItem;
|
import org.jclouds.softlayer.domain.ProductItem;
|
||||||
|
import org.jclouds.softlayer.domain.ProductItemCategory;
|
||||||
import org.jclouds.softlayer.domain.ProductItemPrice;
|
import org.jclouds.softlayer.domain.ProductItemPrice;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import static org.jclouds.softlayer.compute.functions.ProductItems.capacity;
|
import static org.jclouds.softlayer.compute.functions.ProductItems.*;
|
||||||
import static org.jclouds.softlayer.compute.functions.ProductItems.description;
|
|
||||||
import static org.jclouds.softlayer.compute.functions.ProductItems.price;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNull;
|
import static org.testng.Assert.assertNull;
|
||||||
|
|
||||||
|
@ -40,12 +39,15 @@ import static org.testng.Assert.assertNull;
|
||||||
@Test(groups = "unit")
|
@Test(groups = "unit")
|
||||||
public class ProductItemsTest {
|
public class ProductItemsTest {
|
||||||
|
|
||||||
|
private ProductItemCategory category;
|
||||||
private ProductItemPrice price;
|
private ProductItemPrice price;
|
||||||
private ProductItem item;
|
private ProductItem item;
|
||||||
|
|
||||||
@BeforeMethod
|
@BeforeMethod
|
||||||
public void setup() {
|
public void setup() {
|
||||||
|
|
||||||
|
category = ProductItemCategory.builder().id(1).categoryCode("category").build();
|
||||||
|
|
||||||
price = ProductItemPrice.builder().id(1).build();
|
price = ProductItemPrice.builder().id(1).build();
|
||||||
|
|
||||||
item = ProductItem.builder().id(1)
|
item = ProductItem.builder().id(1)
|
||||||
|
@ -54,6 +56,7 @@ public class ProductItemsTest {
|
||||||
.price(price)
|
.price(price)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCapacity() {
|
public void testCapacity() {
|
||||||
assertEquals(capacity().apply(item), 2.0f);
|
assertEquals(capacity().apply(item), 2.0f);
|
||||||
|
@ -93,4 +96,48 @@ public class ProductItemsTest {
|
||||||
ProductItem noPriceItem = ProductItem.builder().id(1).build();
|
ProductItem noPriceItem = ProductItem.builder().id(1).build();
|
||||||
price().apply(noPriceItem);
|
price().apply(noPriceItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testItemCallGetsCategory() {
|
||||||
|
ProductItemPrice price = ProductItemPrice.builder().id(1)
|
||||||
|
.category(category)
|
||||||
|
.item(item)
|
||||||
|
.build();
|
||||||
|
ProductItem newItem = item().apply(price);
|
||||||
|
assertEquals(newItem.getCategories(), ImmutableSet.of(category));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testItemCallNoCategoryOnPrice() {
|
||||||
|
|
||||||
|
ProductItem item1 = ProductItem.Builder.fromProductItem(item)
|
||||||
|
.categories(ImmutableSet.of(category)).build();
|
||||||
|
|
||||||
|
ProductItemPrice price = ProductItemPrice.builder().id(1)
|
||||||
|
.item(item1)
|
||||||
|
.build();
|
||||||
|
ProductItem newItem = item().apply(price);
|
||||||
|
assertEquals(newItem.getCategories(), ImmutableSet.of(category));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testItemCallCategoryExists() {
|
||||||
|
|
||||||
|
ProductItemCategory category2 = ProductItemCategory.builder()
|
||||||
|
.id(12)
|
||||||
|
.categoryCode("new category")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
ProductItem item1 = ProductItem.Builder.fromProductItem(item)
|
||||||
|
.categories(ImmutableSet.of(category2)).build();
|
||||||
|
|
||||||
|
ProductItemPrice price = ProductItemPrice.builder().id(1)
|
||||||
|
.category(category)
|
||||||
|
.item(item1)
|
||||||
|
.build();
|
||||||
|
ProductItem newItem = item().apply(price);
|
||||||
|
assertEquals(newItem.getCategories(), ImmutableSet.of(category2));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,7 @@ public class VirtualGuestToNodeMetadataTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Hardware getHardware(VirtualGuest guest) {
|
public Hardware getHardware(VirtualGuest guest) {
|
||||||
return new HardwareBuilder().id("mocked hardware").build();
|
return new HardwareBuilder().ids("mocked hardware").build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ public class VirtualGuestToNodeMetadataTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Image getImage(VirtualGuest guest) {
|
public Image getImage(VirtualGuest guest) {
|
||||||
return new ImageBuilder().id("123").description("mocked image")
|
return new ImageBuilder().ids("123").description("mocked image")
|
||||||
.operatingSystem(OperatingSystem.builder().description("foo os").build())
|
.operatingSystem(OperatingSystem.builder().description("foo os").build())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ import javax.ws.rs.Consumes;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,7 +88,7 @@ public class ParseProductOrderTest extends BaseItemParserTest<ProductOrder> {
|
||||||
ProductOrder expects = expected();
|
ProductOrder expects = expected();
|
||||||
Function<HttpResponse, ProductOrder> parser = parser(injector());
|
Function<HttpResponse, ProductOrder> parser = parser(injector());
|
||||||
ProductOrder response = parser.apply(new HttpResponse(200, "ok", payload()));
|
ProductOrder response = parser.apply(new HttpResponse(200, "ok", payload()));
|
||||||
compare(expects, response);
|
assertEquals(response,expects);
|
||||||
hasOs(response);
|
hasOs(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue