diff options
author | Harald Musum <musum@yahooinc.com> | 2023-10-13 13:29:05 +0200 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2023-10-13 13:29:05 +0200 |
commit | 247535e91dee2dbf6fd28484e702d9371ff8892a (patch) | |
tree | 4496876a31def1bf14ea48fa2c60a5211508bcdb /controller-api | |
parent | 499b9d9198b90349d07f7519545835950de9403d (diff) |
Test pricing API with 2 apps
Diffstat (limited to 'controller-api')
-rw-r--r-- | controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/MockPricingController.java | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/MockPricingController.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/MockPricingController.java index 4de4ff29f1d..8ea1882bff6 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/MockPricingController.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/MockPricingController.java @@ -49,15 +49,29 @@ public class MockPricingController implements PricingController { BigDecimal supportLevelCost = pricingInfo.supportLevel() == BASIC ? new BigDecimal("-160.00") : new BigDecimal("800.00"); BigDecimal listPriceWithSupport = listPrice.add(supportLevelCost); - BigDecimal enclaveDiscount = (resources.enclaveVcpu().compareTo(ZERO) > 0) ? new BigDecimal("-15.1234") : BigDecimal.ZERO; + BigDecimal enclaveDiscount = isEnclave(resources) ? new BigDecimal("-15.1234") : BigDecimal.ZERO; BigDecimal volumeDiscount = new BigDecimal("-5.64315634"); - BigDecimal committedAmountDiscount = new BigDecimal("-1.23"); - BigDecimal totalAmount = listPrice.add(supportLevelCost).add(enclaveDiscount).add(volumeDiscount).add(committedAmountDiscount); + BigDecimal appTotalAmount = listPrice.add(supportLevelCost).add(enclaveDiscount).add(volumeDiscount); + + List<PriceInformation> appPrices = applicationResources.stream() + .map(appResources -> new PriceInformation(appResources.applicationName(), + listPriceWithSupport, + volumeDiscount, + ZERO, + enclaveDiscount, + appTotalAmount)) + .toList(); - var appPrice = new PriceInformation("app1", listPriceWithSupport, volumeDiscount, committedAmountDiscount, enclaveDiscount, totalAmount); - var totalPrice = new PriceInformation("total", ZERO, ZERO, committedAmountDiscount, enclaveDiscount, totalAmount); + PriceInformation sum = PriceInformation.sum(appPrices); + var committedAmountDiscount = new BigDecimal("-1.23"); + var totalAmount = sum.totalAmount().add(committedAmountDiscount); + var totalPrice = new PriceInformation("total", ZERO, ZERO, committedAmountDiscount, ZERO, totalAmount); + + return new Prices(appPrices, totalPrice); + } - return new Prices(List.of(appPrice), totalPrice); + private static boolean isEnclave(ApplicationResources resources) { + return resources.enclaveVcpu().compareTo(ZERO) > 0; } } |