@Test public void testCategoryCodePresentTwoCategories() { ProductItemCategory osCategory = ProductItemCategory.builder().id(2).categoryCode("os").build(); ProductItem item = ProductItem.builder().categories(ImmutableSet.of(ramCategory, osCategory)).build(); assert ProductItemPredicates.categoryCode("ram").apply(item); }
@Test public void testItemCallCategoryExists() { ProductItemCategory category2 = ProductItemCategory.builder() .id(12) .categoryCode("new category") .build(); ProductItem item1 = item.toBuilder().categories(ImmutableSet.of(category2)).build(); ProductItemPrice price = ProductItemPrice.builder().id(1) .categories(category) .item(item1) .build(); ProductItem newItem = item().apply(price); assertEquals(newItem.getCategories(), ImmutableSet.of(category2)); }
@BeforeMethod public void setup() { category = ProductItemCategory.builder().id(1).categoryCode("category").build(); price = ProductItemPrice.builder().id(1).build(); item = ProductItem.builder().id(1) .capacity(2.0f) .description("an item") .prices(price) .build(); }
@BeforeGroups(groups = { "unit" }) public void setupContext() { ramCategory = ProductItemCategory.builder().id(1).categoryCode("ram").build(); item = ProductItem.builder().id(1).description("a test item").categories(ImmutableSet.of(ramCategory)).capacity( 2.0f).units("GB").build(); emptyItem = ProductItem.builder().id(1).build(); }
@Test public void testHardwareWithTwoDisks() { ProductItem localVolumeItem = ProductItem.builder().id(4).description("25 GB").capacity(25F).prices( ProductItemPrice.builder().id(987).build()).categories( ProductItemCategory.builder().categoryCode("guest_disk1").build()).build(); Hardware hardware = toHardware.apply(ImmutableSet.of(cpuItem, ramItem, volumeItem,localVolumeItem)); List<? extends Volume> volumes = hardware.getVolumes(); assertEquals(2, volumes.size()); Volume volume = volumes.get(0); assertEquals(100F, volume.getSize()); assertEquals(Volume.Type.SAN, volume.getType()); assertEquals(true, volume.isBootDevice()); Volume volume1 = volumes.get(1); assertEquals(25F, volume1.getSize()); assertEquals(Volume.Type.LOCAL, volume1.getType()); assertEquals(false, volume1.isBootDevice()); } }
@BeforeMethod public void setup() { toHardware = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bindProperties(binder(), new SoftLayerProviderMetadata().getDefaultProperties()); } }).getInstance(ProductItemsToHardware.class); cpuItem = ProductItem.builder() .id(1) .description("2 x 2.0 GHz Cores") .capacity(2F) .categories(ProductItemCategory.builder().categoryCode("guest_core").build()) .prices(ProductItemPrice.builder().id(123).build()) .build(); ramItem = ProductItem.builder().id(2).description("2GB ram").capacity(2F).categories( ProductItemCategory.builder().categoryCode("ram").build()).prices( ProductItemPrice.builder().id(456).build()).build(); volumeItem = ProductItem.builder().id(3).description("100 GB (SAN)").capacity(100F).prices( ProductItemPrice.builder().id(789).build()).categories( ProductItemCategory.builder().categoryCode("guest_disk0").build()).build(); }