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();
|
||||
|
||||
return new ImageBuilder()
|
||||
.id(imageId().apply(productItem))
|
||||
.ids(imageId().apply(productItem))
|
||||
.description(productItem.getDescription())
|
||||
.operatingSystem(os)
|
||||
.build();
|
||||
|
|
|
@ -71,7 +71,7 @@ public class ProductItems {
|
|||
/**
|
||||
* Creates a function to get the ProductItem for the ProductItemPrice.
|
||||
* 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() {
|
||||
return new Function<ProductItemPrice,ProductItem>() {
|
||||
|
|
|
@ -63,7 +63,7 @@ public class ProductItemsToHardware implements Function<Set<ProductItem>, Hardwa
|
|||
final float volumeSize = ProductItems.capacity().apply(volumeItem);
|
||||
|
||||
return new HardwareBuilder()
|
||||
.id(hardwareId)
|
||||
.ids(hardwareId)
|
||||
.processors(ImmutableList.of(new Processor(cores, CORE_SPEED)))
|
||||
.ram(ram)
|
||||
.volumes(ImmutableList.<Volume> of(new VolumeImpl(volumeSize, true, false)))
|
||||
|
|
|
@ -176,7 +176,6 @@ public class ProductItemPrice implements Comparable<ProductItemPrice> {
|
|||
return Builder.fromPrice(this);
|
||||
}
|
||||
|
||||
//TODO: Add category and item (breaks unit tests that compare toString()).
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[id=" + id + ", itemId=" + itemId + ", recurringFee=" + recurringFee + ", hourlyRecurringFee="
|
||||
|
|
|
@ -43,6 +43,7 @@ import static org.testng.Assert.assertEquals;
|
|||
public class SoftLayerComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||
public SoftLayerComputeServiceLiveTest() {
|
||||
provider = "softlayer";
|
||||
group = "soft-layer";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -57,33 +58,7 @@ public class SoftLayerComputeServiceLiveTest extends BaseComputeServiceLiveTest
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void checkNodes(Iterable<? extends NodeMetadata> nodes, String tag) throws IOException {
|
||||
super.checkNodes(nodes, tag);
|
||||
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();
|
||||
public void testOptionToNotBlock() {
|
||||
// start call is blocking anyway.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,15 +20,14 @@ package org.jclouds.softlayer.compute.functions;
|
|||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.jclouds.softlayer.domain.ProductItem;
|
||||
import org.jclouds.softlayer.domain.ProductItemCategory;
|
||||
import org.jclouds.softlayer.domain.ProductItemPrice;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import static org.jclouds.softlayer.compute.functions.ProductItems.capacity;
|
||||
import static org.jclouds.softlayer.compute.functions.ProductItems.description;
|
||||
import static org.jclouds.softlayer.compute.functions.ProductItems.price;
|
||||
import static org.jclouds.softlayer.compute.functions.ProductItems.*;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
|
@ -40,12 +39,15 @@ import static org.testng.Assert.assertNull;
|
|||
@Test(groups = "unit")
|
||||
public class ProductItemsTest {
|
||||
|
||||
private ProductItemCategory category;
|
||||
private ProductItemPrice price;
|
||||
private ProductItem item;
|
||||
|
||||
@BeforeMethod
|
||||
public void setup() {
|
||||
|
||||
category = ProductItemCategory.builder().id(1).categoryCode("category").build();
|
||||
|
||||
price = ProductItemPrice.builder().id(1).build();
|
||||
|
||||
item = ProductItem.builder().id(1)
|
||||
|
@ -54,6 +56,7 @@ public class ProductItemsTest {
|
|||
.price(price)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCapacity() {
|
||||
assertEquals(capacity().apply(item), 2.0f);
|
||||
|
@ -93,4 +96,48 @@ public class ProductItemsTest {
|
|||
ProductItem noPriceItem = ProductItem.builder().id(1).build();
|
||||
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
|
||||
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
|
||||
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())
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import javax.ws.rs.Consumes;
|
|||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
|
@ -87,7 +88,7 @@ public class ParseProductOrderTest extends BaseItemParserTest<ProductOrder> {
|
|||
ProductOrder expects = expected();
|
||||
Function<HttpResponse, ProductOrder> parser = parser(injector());
|
||||
ProductOrder response = parser.apply(new HttpResponse(200, "ok", payload()));
|
||||
compare(expects, response);
|
||||
assertEquals(response,expects);
|
||||
hasOs(response);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue