@Test public void listProductsShouldReturnDefaultTemplateProduct() throws CloudException, InternalException { new ListProductsRequestExecutorMockUp(); List<VirtualMachineProduct> products = IteratorUtils.toList( azurePackVirtualMachineSupport .listProducts(TPL_1_ID, VirtualMachineProductFilterOptions.getInstance()) .iterator()); assertEquals("listProducts doesn't return correct result", 1, products.size()); VirtualMachineProduct virtualMachineProduct = products.get(0); assertEquals( "listProducts doesn't return correct result", "Default", virtualMachineProduct.getName()); assertEquals( "listProducts doesn't return correct result", "default", virtualMachineProduct.getProviderProductId()); assertEquals( "listProducts doesn't return correct result", Integer.parseInt(TPL_CPU_COUNT), virtualMachineProduct.getCpuCount()); assertEquals( "listProducts doesn't return correct result", Double.parseDouble(TPL_MEMORY), virtualMachineProduct.getRamSize().getQuantity()); assertEquals( "listProducts doesn't return correct result", Storage.MEGABYTE, virtualMachineProduct.getRamSize().getUnitOfMeasure()); }
@Test public void listAllProductsShouldReturnCorrectHardwareProfileProducts() throws CloudException, InternalException { new ListProductsRequestExecutorMockUp(); List<VirtualMachineProduct> products = IteratorUtils.toList(azurePackVirtualMachineSupport.listAllProducts().iterator()); // listAllProducts returns all available hardware profile plus default product assertEquals("listProducts doesn't return correct result", 2, products.size()); VirtualMachineProduct virtualMachineProduct = products.get(0); assertEquals( "listProducts doesn't return correct result", HWP_1_NAME, virtualMachineProduct.getName()); assertEquals( "listProducts doesn't return correct result", HWP_1_ID, virtualMachineProduct.getProviderProductId()); assertEquals( "listProducts doesn't return correct result", Integer.parseInt(HWP_1_CPU_COUNT), virtualMachineProduct.getCpuCount()); assertEquals( "listProducts doesn't return correct result", Double.parseDouble(HWP_1_MEMORY), virtualMachineProduct.getRamSize().getQuantity()); assertEquals( "listProducts doesn't return correct result", Storage.MEGABYTE, virtualMachineProduct.getRamSize().getUnitOfMeasure()); // assert default product virtualMachineProduct = products.get(1); assertEquals( "listProducts doesn't return correct result", "default", virtualMachineProduct.getName().toLowerCase()); assertEquals( "listProducts doesn't return correct result", "default", virtualMachineProduct.getProviderProductId().toLowerCase()); assertEquals( "listProducts doesn't return correct result", "default", virtualMachineProduct.getDescription().toLowerCase()); }
private void assertHardwareProfileProducts(List<VirtualMachineProduct> products) { assertEquals("listProducts doesn't return correct result", 1, products.size()); VirtualMachineProduct virtualMachineProduct = products.get(0); assertEquals( "listProducts doesn't return correct result", HWP_1_NAME, virtualMachineProduct.getName()); assertEquals( "listProducts doesn't return correct result", HWP_1_ID, virtualMachineProduct.getProviderProductId()); assertEquals( "listProducts doesn't return correct result", Integer.parseInt(HWP_1_CPU_COUNT), virtualMachineProduct.getCpuCount()); assertEquals( "listProducts doesn't return correct result", Double.parseDouble(HWP_1_MEMORY), virtualMachineProduct.getRamSize().getQuantity()); assertEquals( "listProducts doesn't return correct result", Storage.MEGABYTE, virtualMachineProduct.getRamSize().getUnitOfMeasure()); }