Package org.jclouds.softlayer.domain

Examples of org.jclouds.softlayer.domain.ProductItem


      assertFalse(os.is64Bit());
   }
  
   @Test
   public void test64BitUnknown() {
      ProductItem item = ProductItem.builder()
            .description("This only has the bit-count (64 bit)")
            .prices(ProductItemPrice.builder().id(1234).build())
            .build();
      Image i = new ProductItemToImage().apply(item);
      OperatingSystem os = i.getOperatingSystem();
View Full Code Here


      new ProductItemToImage().apply(null);
   }
  
   @Test(expectedExceptions = NullPointerException.class)
   public void testNoDescription() {
      ProductItem item = ProductItem.builder()
            .prices(ProductItemPrice.builder().id(1234).build())
            .build();
      new ProductItemToImage().apply(item);
   }
View Full Code Here

   }
  
   @Test
   public void testId() {
      ProductItemPrice price = ProductItemPrice.builder().id(1234).build();
      ProductItem item = ProductItem.builder().id(5678).prices(price).build();
      assertEquals(imageId().apply(item), "1234", "Expected the ID of the ProductItemPrice to be returned");
   }
View Full Code Here

   @Test
   public void testIdManyPrices() {
      ProductItemPrice price1 = ProductItemPrice.builder().id(1234).build();
      ProductItemPrice price2 = ProductItemPrice.builder().id(5678).build();
      ProductItem item = ProductItem.builder().id(9012).prices(ImmutableSet.of(price1,price2)).build();
      assertEquals(imageId().apply(item), "1234", "Expected the ID of the ProductItemPrice to be returned");
   }
View Full Code Here

      assertEquals(imageId().apply(item), "1234", "Expected the ID of the ProductItemPrice to be returned");
   }

   @Test(expectedExceptions = NoSuchElementException.class)
   public void testIdMissingPrices() {
      ProductItem item = ProductItem.builder().build();
      imageId().apply(item);
   }
View Full Code Here

            logger.warn(e, "Cannot get order template for virtualGuestId(%s)", guest.getId());
         }
         if (order == null)
            return null;
         Iterable<ProductItem> items = Iterables.transform(order.getPrices(), ProductItems.item());
         ProductItem os = Iterables.find(items, ProductItemPredicates.categoryCode("os"));
         if (os.getPrices().isEmpty())
             return null;
         return new ProductItemToImage().apply(os);
      }
View Full Code Here

   public static Function<ProductItemPrice, ProductItem> item() {
      return new Function<ProductItemPrice, ProductItem>() {
         @Override
         public ProductItem apply(ProductItemPrice productItemPrice) {
            Set<ProductItemCategory> categories = productItemPrice.getCategories();
            ProductItem item = productItemPrice.getItem();
            ProductItem.Builder builder = productItemPrice.getItem().toBuilder();
            if (item.getCategories().size() == 0 && categories.size() != 0) {
               builder.categories(categories);
            }

            return builder.build();
         }
View Full Code Here

   }

   @Override
   public Hardware apply(Iterable<ProductItem> items) {

      ProductItem coresItem = getOnlyElement(filter(items, matches(cpuDescriptionRegex)));
      ProductItem ramItem = getOnlyElement(filter(items, categoryCode(RAM_CATEGORY)));
      ProductItem volumeItem = get(filter(items, categoryCode(FIRST_GUEST_DISK)), 0);

      String hardwareId = hardwareId().apply(ImmutableList.of(coresItem, ramItem, volumeItem));
      double cores = ProductItems.capacity().apply(coresItem).doubleValue();
      Matcher cpuMatcher = cpuDescriptionRegex.matcher(coresItem.getDescription());
      double coreSpeed = (cpuMatcher.matches()) ? Double.parseDouble(cpuMatcher.group(cpuMatcher.groupCount())) : DEFAULT_CORE_SPEED;
View Full Code Here

            logger.warn(e, "Cannot get order template for virtualGuestId(%s)", guest.getId());
         }
         if (order == null)
            return null;
         Iterable<ProductItem> items = Iterables.transform(order.getPrices(), ProductItems.item());
         ProductItem os = Iterables.find(items, ProductItemPredicates.categoryCode("os"));
         return new ProductItemToImage().apply(os);
      }
View Full Code Here

      assertFalse(os.is64Bit());
   }
  
   @Test
   public void test64BitUnknown() {
      ProductItem item = ProductItem.builder()
            .description("This only has the bit-count (64 bit)")
            .prices(ProductItemPrice.builder().id(1234).build())
            .build();
      Image i = new ProductItemToImage().apply(item);
      OperatingSystem os = i.getOperatingSystem();
View Full Code Here

TOP

Related Classes of org.jclouds.softlayer.domain.ProductItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.