Skip to content

Commit

Permalink
Change discount price to be optional nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
jicelhay committed Sep 18, 2024
1 parent cddb96f commit 42c7a7f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public static void validateTokenForPossiblePremiumName(
Optional<AllocationToken> token, boolean isPremium)
throws AllocationTokenInvalidForPremiumNameException {
if (token.isPresent()
&& (token.get().getDiscountFraction() != 0.0 || token.get().getDiscountPrice() != null)
&& (token.get().getDiscountFraction() != 0.0 || token.get().getDiscountPrice().isPresent())
&& isPremium
&& !token.get().shouldDiscountPremiums()) {
throw new AllocationTokenInvalidForPremiumNameException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public double getDiscountFraction() {
}

public Optional<Money> getDiscountPrice() {
return Optional.of(discountPrice);
return Optional.ofNullable(discountPrice);
}

public boolean shouldDiscountPremiums() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1022,37 +1022,6 @@ void testGetDomainTransferPrice_standardDomain_default_defaultRenewalPrice() thr
.build());
}

@Test
void testGetDomainTransferPrice_premiumDomain_default_premiumRenewalPrice() throws EppException {
assertThat(
domainPricingLogic.getTransferPrice(
tld,
"premium.example",
clock.nowUtc(),
persistDomainAndSetRecurrence("premium.example", DEFAULT, Optional.empty())))
.isEqualTo(
new FeesAndCredits.Builder()
.setCurrency(USD)
.addFeeOrCredit(Fee.create(new BigDecimal("100.00"), RENEW, true))
.build());
}

@Test
void testGetDomainTransferPrice_standardDomain_nonPremium_nonPremiumRenewalPrice()
throws EppException {
assertThat(
domainPricingLogic.getTransferPrice(
tld,
"standard.example",
clock.nowUtc(),
persistDomainAndSetRecurrence("standard.example", NONPREMIUM, Optional.empty())))
.isEqualTo(
new FeesAndCredits.Builder()
.setCurrency(USD)
.addFeeOrCredit(Fee.create(new BigDecimal("10.00"), RENEW, false))
.build());
}

@Test
void testGetDomainTransferPrice_premiumDomain_nonPremium_nonPremiumRenewalPrice()
throws EppException {
Expand Down

0 comments on commit 42c7a7f

Please sign in to comment.