@Test public void testCostFor34KGetRequestsInEuRegion()throws Exception { BigDecimal expectedPrice = new BigDecimal(0.340); Product product = s3PriceList.getRequestCostByType(AwsRegion.EU_WEST_1, RequestType.PUT_COPY_POST_LIST); BigDecimal calculatedPrice = new BigDecimal(product.getPrice().getValue().doubleValue() * (34000 / 1000)); assert expectedPrice.compareTo(calculatedPrice) == 0; }
public Product getRequestCostByType(AwsRegion region, RequestType requestType) throws IOException{ Map<String, Object> regionMap = getRegion(region.getRegionId(), getRequestsPrices()); List<Map<String, Object>> types = getSubList(regionMap, "tiers"); for(Map<String, Object> type : types){ if(type.get("name").equals(requestType.getId())){ String priceText = (String) ((Map<String, Object>)type.get("prices")).get("USD"); Price price = RequestPrice.createUsdWithRate(new BigDecimal(priceText), requestType.getRate()); return new Product(requestType.getName(), price); } } return null; }
S3PriceList extends AbstractPriceList { public Product getRequestCostByType(AwsRegion region, RequestType requestType) throws IOException{ Map<String, Object> regionMap = getRegion(region.getRegionId(), getRequestsPrices()); List<Map<String, Object>> types = getSubList(regionMap, "tiers"); for(Map<String, Object> type : types){ if(type.get("name").equals(requestType.getId())){ String priceText = (String) ((Map<String, Object>)type.get("prices")).get("USD"); Price price = RequestPrice.createUsdWithRate(new BigDecimal(priceText), requestType.getRate()); return new Product(requestType.getName(), price); } } return null; } }
S3PriceList extends AbstractPriceList { public Product getRequestCostByType(AwsRegion region, RequestType requestType) throws IOException{ Map<String, Object> regionMap = getRegion(region.getRegionId(), getRequestsPrices()); List<Map<String, Object>> types = getSubList(regionMap, "tiers"); for(Map<String, Object> type : types){ if(type.get("name").equals(requestType.getId())){ String priceText = (String) ((Map<String, Object>)type.get("prices")).get("USD"); Price price = RequestPrice.createUsdWithRate(new BigDecimal(priceText), requestType.getRate()); return new Product(requestType.getName(), price); } } return null; }  }
S3PriceList extends AbstractPriceList { public Product getRequestCostByType(AwsRegion region, RequestType requestType) throws IOException{ Map<String, Object> regionMap = getRegion(region.getRegionId(), getRequestsPrices()); List<Map<String, Object>> types = getSubList(regionMap, "tiers"); for(Map<String, Object> type : types){ if(type.get("name").equals(requestType.getId())){ String priceText = (String) ((Map<String, Object>)type.get("prices")).get("USD"); Price price = RequestPrice.createUsdWithRate(new BigDecimal(priceText), requestType.getRate()); return new Product(requestType.getName(), price); } } return null; }  List<Product> getMonthlyStorageCostForAllTiers(AwsRegion region, StorageType storageType); Product getMonthlyStorageCostForTier(AwsRegion region, StorageType storageType, DataTier dataTier); Product getRequestCostByType(AwsRegion region, RequestType requestType); }
S3PriceList extends AbstractPriceList { public Product getRequestCostByType(AwsRegion region, RequestType requestType) throws IOException{ Map<String, Object> regionMap = getRegion(region.getRegionId(), getRequestsPrices()); List<Map<String, Object>> types = getSubList(regionMap, "tiers"); for(Map<String, Object> type : types){ if(type.get("name").equals(requestType.getId())){ String priceText = (String) ((Map<String, Object>)type.get("prices")).get("USD"); Price price = RequestPrice.createUsdWithRate(new BigDecimal(priceText), requestType.getRate()); return new Product(requestType.getName(), price); } } return null; }  List<Product> getMonthlyStorageCostForAllTiers(AwsRegion region, StorageType storageType); Product getMonthlyStorageCostForTier(AwsRegion region, StorageType storageType, DataTier dataTier); Product getRequestCostByType(AwsRegion region, RequestType requestType);  }