mirror of
https://github.com/google/nomulus
synced 2026-01-07 14:05:44 +00:00
Use token's renewalPrice if renewalBehavior is SPECIFIED (#2502)
Previous PRs and token changes (see b/332928676) have made it so that SPECIFIED renewalPriceBehavior tokens must have a renewal price. As such, we can now use that renewalPrice when creating domains with SPECIFIED tokens.
This commit is contained in:
@@ -365,7 +365,7 @@ public final class DomainCreateFlow implements MutatingFlow {
|
|||||||
createAutorenewBillingEvent(
|
createAutorenewBillingEvent(
|
||||||
domainHistoryId,
|
domainHistoryId,
|
||||||
registrationExpirationTime,
|
registrationExpirationTime,
|
||||||
getRenewalPriceInfo(isAnchorTenant, allocationToken, feesAndCredits));
|
getRenewalPriceInfo(isAnchorTenant, allocationToken));
|
||||||
PollMessage.Autorenew autorenewPollMessage =
|
PollMessage.Autorenew autorenewPollMessage =
|
||||||
createAutorenewPollMessage(domainHistoryId, registrationExpirationTime);
|
createAutorenewPollMessage(domainHistoryId, registrationExpirationTime);
|
||||||
ImmutableSet.Builder<ImmutableObject> entitiesToSave = new ImmutableSet.Builder<>();
|
ImmutableSet.Builder<ImmutableObject> entitiesToSave = new ImmutableSet.Builder<>();
|
||||||
@@ -688,9 +688,7 @@ public final class DomainCreateFlow implements MutatingFlow {
|
|||||||
* AllocationToken} is 'SPECIFIED'.
|
* AllocationToken} is 'SPECIFIED'.
|
||||||
*/
|
*/
|
||||||
static RenewalPriceInfo getRenewalPriceInfo(
|
static RenewalPriceInfo getRenewalPriceInfo(
|
||||||
boolean isAnchorTenant,
|
boolean isAnchorTenant, Optional<AllocationToken> allocationToken) {
|
||||||
Optional<AllocationToken> allocationToken,
|
|
||||||
FeesAndCredits feesAndCredits) {
|
|
||||||
if (isAnchorTenant) {
|
if (isAnchorTenant) {
|
||||||
allocationToken.ifPresent(
|
allocationToken.ifPresent(
|
||||||
token ->
|
token ->
|
||||||
@@ -701,7 +699,7 @@ public final class DomainCreateFlow implements MutatingFlow {
|
|||||||
} else if (allocationToken.isPresent()
|
} else if (allocationToken.isPresent()
|
||||||
&& allocationToken.get().getRenewalPriceBehavior() == RenewalPriceBehavior.SPECIFIED) {
|
&& allocationToken.get().getRenewalPriceBehavior() == RenewalPriceBehavior.SPECIFIED) {
|
||||||
return RenewalPriceInfo.create(
|
return RenewalPriceInfo.create(
|
||||||
RenewalPriceBehavior.SPECIFIED, feesAndCredits.getCreateCost());
|
RenewalPriceBehavior.SPECIFIED, allocationToken.get().getRenewalPrice().get());
|
||||||
} else {
|
} else {
|
||||||
return RenewalPriceInfo.create(RenewalPriceBehavior.DEFAULT, null);
|
return RenewalPriceInfo.create(RenewalPriceBehavior.DEFAULT, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -344,8 +344,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
|||||||
.and()
|
.and()
|
||||||
.hasPeriodYears(2);
|
.hasPeriodYears(2);
|
||||||
RenewalPriceInfo renewalPriceInfo =
|
RenewalPriceInfo renewalPriceInfo =
|
||||||
DomainCreateFlow.getRenewalPriceInfo(
|
DomainCreateFlow.getRenewalPriceInfo(isAnchorTenant, Optional.ofNullable(allocationToken));
|
||||||
isAnchorTenant, Optional.ofNullable(allocationToken), feesAndCredits);
|
|
||||||
// There should be one bill for the create and one for the recurrence autorenew event.
|
// There should be one bill for the create and one for the recurrence autorenew event.
|
||||||
BillingEvent createBillingEvent =
|
BillingEvent createBillingEvent =
|
||||||
new BillingEvent.Builder()
|
new BillingEvent.Builder()
|
||||||
@@ -3189,53 +3188,25 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGetRenewalPriceInfo_isAnchorTenantWithoutToken_returnsNonPremiumAndNullPrice() {
|
void testGetRenewalPriceInfo_isAnchorTenantWithoutToken_returnsNonPremiumAndNullPrice() {
|
||||||
assertThat(
|
assertThat(DomainCreateFlow.getRenewalPriceInfo(true, Optional.empty()))
|
||||||
DomainCreateFlow.getRenewalPriceInfo(
|
|
||||||
true,
|
|
||||||
Optional.empty(),
|
|
||||||
new FeesAndCredits.Builder()
|
|
||||||
.setCurrency(USD)
|
|
||||||
.addFeeOrCredit(Fee.create(BigDecimal.valueOf(0), FeeType.CREATE, false))
|
|
||||||
.build()))
|
|
||||||
.isEqualTo(RenewalPriceInfo.create(NONPREMIUM, null));
|
.isEqualTo(RenewalPriceInfo.create(NONPREMIUM, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGetRenewalPriceInfo_isAnchorTenantWithDefaultToken_returnsNonPremiumAndNullPrice() {
|
void testGetRenewalPriceInfo_isAnchorTenantWithDefaultToken_returnsNonPremiumAndNullPrice() {
|
||||||
assertThat(
|
assertThat(DomainCreateFlow.getRenewalPriceInfo(true, Optional.of(allocationToken)))
|
||||||
DomainCreateFlow.getRenewalPriceInfo(
|
|
||||||
true,
|
|
||||||
Optional.of(allocationToken),
|
|
||||||
new FeesAndCredits.Builder()
|
|
||||||
.setCurrency(USD)
|
|
||||||
.addFeeOrCredit(Fee.create(BigDecimal.valueOf(0), FeeType.CREATE, false))
|
|
||||||
.build()))
|
|
||||||
.isEqualTo(RenewalPriceInfo.create(NONPREMIUM, null));
|
.isEqualTo(RenewalPriceInfo.create(NONPREMIUM, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGetRenewalPriceInfo_isNotAnchorTenantWithDefaultToken_returnsDefaultAndNullPrice() {
|
void testGetRenewalPriceInfo_isNotAnchorTenantWithDefaultToken_returnsDefaultAndNullPrice() {
|
||||||
assertThat(
|
assertThat(DomainCreateFlow.getRenewalPriceInfo(false, Optional.of(allocationToken)))
|
||||||
DomainCreateFlow.getRenewalPriceInfo(
|
|
||||||
false,
|
|
||||||
Optional.of(allocationToken),
|
|
||||||
new FeesAndCredits.Builder()
|
|
||||||
.setCurrency(USD)
|
|
||||||
.addFeeOrCredit(Fee.create(BigDecimal.valueOf(100), FeeType.CREATE, false))
|
|
||||||
.build()))
|
|
||||||
.isEqualTo(RenewalPriceInfo.create(DEFAULT, null));
|
.isEqualTo(RenewalPriceInfo.create(DEFAULT, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testGetRenewalPriceInfo_isNotAnchorTenantWithoutToken_returnsDefaultAndNullPrice() {
|
void testGetRenewalPriceInfo_isNotAnchorTenantWithoutToken_returnsDefaultAndNullPrice() {
|
||||||
assertThat(
|
assertThat(DomainCreateFlow.getRenewalPriceInfo(false, Optional.empty()))
|
||||||
DomainCreateFlow.getRenewalPriceInfo(
|
|
||||||
false,
|
|
||||||
Optional.empty(),
|
|
||||||
new FeesAndCredits.Builder()
|
|
||||||
.setCurrency(USD)
|
|
||||||
.addFeeOrCredit(Fee.create(BigDecimal.valueOf(100), FeeType.CREATE, false))
|
|
||||||
.build()))
|
|
||||||
.isEqualTo(RenewalPriceInfo.create(DEFAULT, null));
|
.isEqualTo(RenewalPriceInfo.create(DEFAULT, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3248,17 +3219,10 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
|||||||
.setToken("abc123")
|
.setToken("abc123")
|
||||||
.setTokenType(SINGLE_USE)
|
.setTokenType(SINGLE_USE)
|
||||||
.setRenewalPriceBehavior(SPECIFIED)
|
.setRenewalPriceBehavior(SPECIFIED)
|
||||||
.setRenewalPrice(Money.of(USD, 0))
|
.setRenewalPrice(Money.of(USD, 5))
|
||||||
.build());
|
.build());
|
||||||
assertThat(
|
assertThat(DomainCreateFlow.getRenewalPriceInfo(false, Optional.of(token)))
|
||||||
DomainCreateFlow.getRenewalPriceInfo(
|
.isEqualTo(RenewalPriceInfo.create(SPECIFIED, Money.of(USD, 5)));
|
||||||
false,
|
|
||||||
Optional.of(token),
|
|
||||||
new FeesAndCredits.Builder()
|
|
||||||
.setCurrency(USD)
|
|
||||||
.addFeeOrCredit(Fee.create(BigDecimal.valueOf(100), FeeType.CREATE, false))
|
|
||||||
.build()))
|
|
||||||
.isEqualTo(RenewalPriceInfo.create(SPECIFIED, Money.of(USD, 100)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -3276,11 +3240,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
|||||||
.setTokenType(SINGLE_USE)
|
.setTokenType(SINGLE_USE)
|
||||||
.setRenewalPriceBehavior(SPECIFIED)
|
.setRenewalPriceBehavior(SPECIFIED)
|
||||||
.setRenewalPrice(Money.of(USD, 0))
|
.setRenewalPrice(Money.of(USD, 0))
|
||||||
.build())),
|
.build()))));
|
||||||
new FeesAndCredits.Builder()
|
|
||||||
.setCurrency(USD)
|
|
||||||
.addFeeOrCredit(Fee.create(BigDecimal.valueOf(0), FeeType.CREATE, true))
|
|
||||||
.build()));
|
|
||||||
assertThat(thrown)
|
assertThat(thrown)
|
||||||
.hasMessageThat()
|
.hasMessageThat()
|
||||||
.isEqualTo("Renewal price behavior cannot be SPECIFIED for anchor tenant");
|
.isEqualTo("Renewal price behavior cannot be SPECIFIED for anchor tenant");
|
||||||
@@ -3300,11 +3260,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
|||||||
.setToken("abc123")
|
.setToken("abc123")
|
||||||
.setTokenType(SINGLE_USE)
|
.setTokenType(SINGLE_USE)
|
||||||
.setRenewalPriceBehavior(RenewalPriceBehavior.valueOf("INVALID"))
|
.setRenewalPriceBehavior(RenewalPriceBehavior.valueOf("INVALID"))
|
||||||
.build())),
|
.build()))));
|
||||||
new FeesAndCredits.Builder()
|
|
||||||
.setCurrency(USD)
|
|
||||||
.addFeeOrCredit(Fee.create(BigDecimal.valueOf(0), FeeType.CREATE, true))
|
|
||||||
.build()));
|
|
||||||
assertThat(thrown)
|
assertThat(thrown)
|
||||||
.hasMessageThat()
|
.hasMessageThat()
|
||||||
.isEqualTo(
|
.isEqualTo(
|
||||||
|
|||||||
Reference in New Issue
Block a user