mirror of
https://github.com/google/nomulus.git
synced 2025-05-16 09:27:16 +02:00
Add EAP fee schedule to the Registry object
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=123894969
This commit is contained in:
parent
89066a7215
commit
b9ae0a2550
2 changed files with 57 additions and 1 deletions
|
@ -111,6 +111,7 @@ public class Registry extends ImmutableObject implements Buildable {
|
||||||
public static final Duration DEFAULT_ANCHOR_TENANT_ADD_GRACE_PERIOD = Duration.standardDays(30);
|
public static final Duration DEFAULT_ANCHOR_TENANT_ADD_GRACE_PERIOD = Duration.standardDays(30);
|
||||||
public static final CurrencyUnit DEFAULT_CURRENCY = USD;
|
public static final CurrencyUnit DEFAULT_CURRENCY = USD;
|
||||||
public static final Money DEFAULT_CREATE_BILLING_COST = Money.of(USD, 8);
|
public static final Money DEFAULT_CREATE_BILLING_COST = Money.of(USD, 8);
|
||||||
|
public static final Money DEFAULT_EAP_BILLING_COST = Money.of(USD, 0);
|
||||||
public static final Money DEFAULT_RENEW_BILLING_COST = Money.of(USD, 8);
|
public static final Money DEFAULT_RENEW_BILLING_COST = Money.of(USD, 8);
|
||||||
public static final Money DEFAULT_RESTORE_BILLING_COST = Money.of(USD, 100);
|
public static final Money DEFAULT_RESTORE_BILLING_COST = Money.of(USD, 100);
|
||||||
public static final Money DEFAULT_SERVER_STATUS_CHANGE_BILLING_COST = Money.of(USD, 20);
|
public static final Money DEFAULT_SERVER_STATUS_CHANGE_BILLING_COST = Money.of(USD, 20);
|
||||||
|
@ -360,6 +361,13 @@ public class Registry extends ImmutableObject implements Buildable {
|
||||||
TimedTransitionProperty<Money, BillingCostTransition> renewBillingCostTransitions =
|
TimedTransitionProperty<Money, BillingCostTransition> renewBillingCostTransitions =
|
||||||
TimedTransitionProperty.forMapify(DEFAULT_RENEW_BILLING_COST, BillingCostTransition.class);
|
TimedTransitionProperty.forMapify(DEFAULT_RENEW_BILLING_COST, BillingCostTransition.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A property that tracks the EAP fee schedule (if any) for the TLD.
|
||||||
|
*/
|
||||||
|
@Mapify(TimedTransitionProperty.TimeMapper.class)
|
||||||
|
TimedTransitionProperty<Money, BillingCostTransition> eapFeeSchedule =
|
||||||
|
TimedTransitionProperty.forMapify(DEFAULT_EAP_BILLING_COST, BillingCostTransition.class);
|
||||||
|
|
||||||
String lordnUsername;
|
String lordnUsername;
|
||||||
|
|
||||||
/** The end of the claims period (at or after this time, claims no longer applies). */
|
/** The end of the claims period (at or after this time, claims no longer applies). */
|
||||||
|
@ -510,6 +518,13 @@ public class Registry extends ImmutableObject implements Buildable {
|
||||||
return renewBillingCostTransitions.toValueMap();
|
return renewBillingCostTransitions.toValueMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the EAP fee for the registry at the given time.
|
||||||
|
*/
|
||||||
|
public Money getEapFeeFor(DateTime now) {
|
||||||
|
return eapFeeSchedule.getValueAtTime(now);
|
||||||
|
}
|
||||||
|
|
||||||
public String getLordnUsername() {
|
public String getLordnUsername() {
|
||||||
return lordnUsername;
|
return lordnUsername;
|
||||||
}
|
}
|
||||||
|
@ -714,7 +729,7 @@ public class Registry extends ImmutableObject implements Buildable {
|
||||||
*/
|
*/
|
||||||
public Builder setRenewBillingCostTransitions(
|
public Builder setRenewBillingCostTransitions(
|
||||||
ImmutableSortedMap<DateTime, Money> renewCostsMap) {
|
ImmutableSortedMap<DateTime, Money> renewCostsMap) {
|
||||||
checkNotNull(renewCostsMap, "renew billing costs map cannot be null");
|
checkArgumentNotNull(renewCostsMap, "renew billing costs map cannot be null");
|
||||||
checkArgument(Iterables.all(
|
checkArgument(Iterables.all(
|
||||||
renewCostsMap.values(),
|
renewCostsMap.values(),
|
||||||
new Predicate<Money>() {
|
new Predicate<Money>() {
|
||||||
|
@ -728,6 +743,25 @@ public class Registry extends ImmutableObject implements Buildable {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the EAP fee schedule for the TLD.
|
||||||
|
*/
|
||||||
|
public Builder setEapFeeSchedule(
|
||||||
|
ImmutableSortedMap<DateTime, Money> eapFeeSchedule) {
|
||||||
|
checkArgumentNotNull(eapFeeSchedule, "EAP schedule map cannot be null");
|
||||||
|
checkArgument(Iterables.all(
|
||||||
|
eapFeeSchedule.values(),
|
||||||
|
new Predicate<Money>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(Money amount) {
|
||||||
|
return amount.isPositiveOrZero();
|
||||||
|
}}),
|
||||||
|
"EAP fee cannot be negative");
|
||||||
|
getInstance().eapFeeSchedule =
|
||||||
|
TimedTransitionProperty.fromValueMap(eapFeeSchedule, BillingCostTransition.class);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Builder setRoidSuffix(String roidSuffix) {
|
public Builder setRoidSuffix(String roidSuffix) {
|
||||||
getInstance().roidSuffix = roidSuffix;
|
getInstance().roidSuffix = roidSuffix;
|
||||||
return this;
|
return this;
|
||||||
|
@ -779,6 +813,7 @@ public class Registry extends ImmutableObject implements Buildable {
|
||||||
// cloned it into a new builder, to block re-building a Registry in an invalid state.
|
// cloned it into a new builder, to block re-building a Registry in an invalid state.
|
||||||
instance.tldStateTransitions.checkValidity();
|
instance.tldStateTransitions.checkValidity();
|
||||||
instance.renewBillingCostTransitions.checkValidity();
|
instance.renewBillingCostTransitions.checkValidity();
|
||||||
|
instance.eapFeeSchedule.checkValidity();
|
||||||
// All costs must be in the expected currency.
|
// All costs must be in the expected currency.
|
||||||
// TODO(b/21854155): When we move PremiumList into datastore, verify its currency too.
|
// TODO(b/21854155): When we move PremiumList into datastore, verify its currency too.
|
||||||
checkArgument(
|
checkArgument(
|
||||||
|
|
|
@ -413,4 +413,25 @@ public class RegistryTest extends EntityTestCase {
|
||||||
thrown.expect(IllegalArgumentException.class, "cost must be in the registry's currency");
|
thrown.expect(IllegalArgumentException.class, "cost must be in the registry's currency");
|
||||||
Registry.get("tld").asBuilder().setServerStatusChangeBillingCost(Money.of(EUR, 42)).build();
|
Registry.get("tld").asBuilder().setServerStatusChangeBillingCost(Money.of(EUR, 42)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEapFee_undefined() {
|
||||||
|
assertThat(Registry.get("tld").getEapFeeFor(clock.nowUtc())).isEqualTo(Money.of(USD, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEapFee_specified() {
|
||||||
|
DateTime a = clock.nowUtc().minusDays(1);
|
||||||
|
DateTime b = clock.nowUtc().plusDays(1);
|
||||||
|
Registry registry =
|
||||||
|
Registry.get("tld").asBuilder().setEapFeeSchedule(
|
||||||
|
ImmutableSortedMap.of(
|
||||||
|
START_OF_TIME, Money.of(USD, 0),
|
||||||
|
a, Money.of(USD, 100),
|
||||||
|
b, Money.of(USD, 50))).build();
|
||||||
|
|
||||||
|
assertThat(registry.getEapFeeFor(clock.nowUtc())).isEqualTo(Money.of(USD, 100));
|
||||||
|
assertThat(registry.getEapFeeFor(clock.nowUtc().minusDays(2))).isEqualTo(Money.of(USD, 0));
|
||||||
|
assertThat(registry.getEapFeeFor(clock.nowUtc().plusDays(2))).isEqualTo(Money.of(USD, 50));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue