diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/ProductItemToImage.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/ProductItemToImage.java index a26dbf9c8a..e4d8bab868 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/ProductItemToImage.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/ProductItemToImage.java @@ -71,7 +71,7 @@ public class ProductItemToImage implements Function { .build(); return new ImageBuilder() - .id(imageId().apply(productItem)) + .ids(imageId().apply(productItem)) .description(productItem.getDescription()) .operatingSystem(os) .build(); diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/ProductItems.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/ProductItems.java index 1524848c21..ad64654887 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/ProductItems.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/ProductItems.java @@ -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 item() { return new Function() { diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/ProductItemsToHardware.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/ProductItemsToHardware.java index bf618dc9bb..f4a6bbf2f6 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/ProductItemsToHardware.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/ProductItemsToHardware.java @@ -63,7 +63,7 @@ public class ProductItemsToHardware implements Function, 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. of(new VolumeImpl(volumeSize, true, false))) diff --git a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/ProductItemPrice.java b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/ProductItemPrice.java index da93eb3d15..33f736d560 100644 --- a/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/ProductItemPrice.java +++ b/sandbox-providers/softlayer/src/main/java/org/jclouds/softlayer/domain/ProductItemPrice.java @@ -176,7 +176,6 @@ public class ProductItemPrice implements Comparable { 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=" diff --git a/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceLiveTest.java b/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceLiveTest.java index ae78a965a8..f2f7d60f5d 100644 --- a/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceLiveTest.java +++ b/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceLiveTest.java @@ -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 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. } } diff --git a/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/ProductItemsTest.java b/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/ProductItemsTest.java index 72875f450e..85420df25d 100644 --- a/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/ProductItemsTest.java +++ b/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/ProductItemsTest.java @@ -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)); + } + + } diff --git a/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadataTest.java b/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadataTest.java index 36aa78cc29..a1ab4349e2 100644 --- a/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadataTest.java +++ b/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/compute/functions/VirtualGuestToNodeMetadataTest.java @@ -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(); } diff --git a/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/parse/ParseProductOrderTest.java b/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/parse/ParseProductOrderTest.java index f284868977..c0bc3bc1c3 100644 --- a/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/parse/ParseProductOrderTest.java +++ b/sandbox-providers/softlayer/src/test/java/org/jclouds/softlayer/parse/ParseProductOrderTest.java @@ -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 expects = expected(); Function parser = parser(injector()); ProductOrder response = parser.apply(new HttpResponse(200, "ok", payload())); - compare(expects, response); + assertEquals(response,expects); hasOs(response); }