Make createBillingCostTransitions not null (#2405)

* Make createBillingCostTransitions not null

* Set up createBillingCost field to be removed form config files

* Add clarifying comment
This commit is contained in:
sarahcaseybot
2024-04-23 18:22:45 +00:00
committed by GitHub
parent e809e967a3
commit f729802094
26 changed files with 115 additions and 82 deletions
@@ -458,10 +458,10 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl
@JsonDeserialize(using = CurrencyDeserializer.class)
CurrencyUnit currency = DEFAULT_CURRENCY;
// TODO(sarahbot@): Remove this field and make createBillingCostTransitions not-null once all TLDs
// are populated with a create cost transition map
// TODO(sarahbot@): Remove this field once all saved configuration files have this field removed
/** The per-year billing cost for registering a new domain name. */
@Deprecated
@JsonIgnore
@Type(type = JodaMoneyType.TYPE_NAME)
@Columns(
columns = {
@@ -470,10 +470,10 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl
})
Money createBillingCost = DEFAULT_CREATE_BILLING_COST;
// TODO(sarahbot@): Make this field not null in the database
// TODO(sarahbot@): Rename this field to createBillingCost once the old createBillingCost has been
// removed
/** A property that transitions to different create billing costs at different times. */
@Column(nullable = false)
@JsonDeserialize(using = TimedTransitionPropertyMoneyDeserializer.class)
TimedTransitionProperty<Money> createBillingCostTransitions =
TimedTransitionProperty.withInitialValue(DEFAULT_CREATE_BILLING_COST);
@@ -1165,10 +1165,6 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl
// here to catch cases where we loaded an invalid TimedTransitionProperty from the database
// and cloned it into a new builder, to block re-building a Tld in an invalid state.
instance.tldStateTransitions.checkValidity();
// TODO(sarahbot@): Remove null check when createBillingCostTransitions field is made not-null
checkArgumentNotNull(
instance.getCreateBillingCostTransitions(),
"CreateBillingCostTransitions cannot be null");
instance.createBillingCostTransitions.checkValidity();
instance.renewBillingCostTransitions.checkValidity();
instance.eapFeeSchedule.checkValidity();
@@ -45,7 +45,6 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedMap;
import google.registry.dns.writer.VoidDnsWriter;
import google.registry.model.EntityTestCase;
import google.registry.model.common.TimedTransitionProperty;
import google.registry.model.domain.token.AllocationToken;
import google.registry.model.tld.Tld.TldNotFoundException;
import google.registry.model.tld.Tld.TldState;
@@ -149,8 +148,8 @@ public final class TldTest extends EntityTestCase {
.asBuilder()
.setDnsAPlusAaaaTtl(Duration.standardHours(1))
.setDnsWriters(ImmutableSet.of("baz", "bang"))
.setCreateBillingCostTransitions(
TimedTransitionProperty.withInitialValue(Money.of(USD, 13)).toValueMap())
// set create billing cost back to the default (database helper sets it to $13)
.setCreateBillingCost(Money.of(USD, 8))
.setEapFeeSchedule(
ImmutableSortedMap.of(
START_OF_TIME,
@@ -172,12 +171,7 @@ public final class TldTest extends EntityTestCase {
@Test
void testSuccess_tldYamlRoundtrip() throws Exception {
Tld testTld =
createTld("test")
.asBuilder()
.setCreateBillingCostTransitions(
TimedTransitionProperty.withInitialValue(Money.of(USD, 8)).toValueMap())
.build();
Tld testTld = createTld("test").asBuilder().setCreateBillingCost(Money.of(USD, 8)).build();
ObjectMapper mapper = createObjectMapper();
String yaml = mapper.writeValueAsString(testTld);
Tld constructedTld = mapper.readValue(yaml, Tld.class);
@@ -187,6 +187,16 @@ public class ConfigureTldCommandTest extends CommandTestCase<ConfigureTldCommand
.isEqualTo(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 25)));
}
@Test
void testSuccess_fileHasCreateBillingCost() throws Exception {
createTld("withcreatecost");
File tldFile = tmpDir.resolve("withcreatecost.yaml").toFile();
Files.asCharSink(tldFile, UTF_8).write(loadFile(getClass(), "withcreatecost.yaml"));
runCommandForced("--input=" + tldFile);
Tld updatedTld = Tld.get("withcreatecost");
assertThat(updatedTld.getCreateBillingCost()).isEqualTo(Money.of(USD, 8));
}
@Test
void testSuccess_fileMissingCreateBillingCostTransitionsRevertsToBasicConstructedMap()
throws Exception {
@@ -6,9 +6,6 @@ anchorTenantAddGracePeriodLength: "PT2592000S"
autoRenewGracePeriodLength: "PT3888000S"
automaticTransferLength: "PT432000S"
claimsPeriodEnd: "294247-01-10T04:00:54.775Z"
createBillingCost:
currency: "USD"
amount: 13.00
createBillingCostTransitions:
"1970-01-01T00:00:00.000Z":
currency: "USD"
@@ -5,9 +5,6 @@ anchorTenantAddGracePeriodLength: "PT2592000S"
autoRenewGracePeriodLength: "PT2592000S"
automaticTransferLength: "PT2592000S"
claimsPeriodEnd: "294247-01-10T04:00:54.775Z"
createBillingCost:
currency: "USD"
amount: 25.00
creationTime: "2022-09-01T00:00:00.000Z"
currency: "USD"
defaultPromoTokens: []
@@ -5,9 +5,6 @@ anchorTenantAddGracePeriodLength: "PT2592000S"
autoRenewGracePeriodLength: "PT2592000S"
automaticTransferLength: "PT2592000S"
claimsPeriodEnd: "294247-01-10T04:00:54.775Z"
createBillingCost:
currency: "USD"
amount: 25.00
createBillingCostTransitions:
"1970-01-01T00:00:00.000Z":
currency: "USD"
@@ -5,9 +5,6 @@ anchorTenantAddGracePeriodLength: "PT2592000S"
autoRenewGracePeriodLength: "PT2592000S"
automaticTransferLength: "PT2592000S"
claimsPeriodEnd: "294247-01-10T04:00:54.775Z"
createBillingCost:
currency: "USD"
amount: 25.00
creationTime: "2022-09-01T00:00:00.000Z"
currency: "USD"
defaultPromoTokens: []
@@ -6,9 +6,6 @@ anchorTenantAddGracePeriodLength: "PT2592000S"
autoRenewGracePeriodLength: "PT3888000S"
automaticTransferLength: "PT432000S"
claimsPeriodEnd: "294247-01-10T04:00:54.775Z"
createBillingCost:
currency: "USD"
amount: 14.00
createBillingCostTransitions:
"1970-01-01T00:00:00.000Z":
currency: "USD"
@@ -5,9 +5,6 @@ anchorTenantAddGracePeriodLength: "PT2592000S"
autoRenewGracePeriodLength: "PT3888000S"
automaticTransferLength: "PT432000S"
claimsPeriodEnd: "294247-01-10T04:00:54.775Z"
createBillingCost:
currency: "USD"
amount: 25.00
createBillingCostTransitions:
"1970-01-01T00:00:00.000Z":
currency: "USD"
@@ -5,9 +5,6 @@ anchorTenantAddGracePeriodLength: "PT2592000S"
autoRenewGracePeriodLength: "PT2592000S"
automaticTransferLength: "PT2592000S"
claimsPeriodEnd: "294247-01-10T04:00:54.775Z"
createBillingCost:
currency: "USD"
amount: 25.00
createBillingCostTransitions:
"1970-01-01T00:00:00.000Z":
currency: "USD"
@@ -9,9 +9,6 @@ anchorTenantAddGracePeriodLength: "PT2592000S"
autoRenewGracePeriodLength: "PT3888000S"
automaticTransferLength: "PT432000S"
claimsPeriodEnd: "294247-01-10T04:00:54.775Z"
createBillingCost:
currency: "USD"
amount: 13.00
createBillingCostTransitions:
"1970-01-01T00:00:00.000Z":
currency: "USD"
@@ -5,9 +5,6 @@ anchorTenantAddGracePeriodLength: "PT2592000S"
autoRenewGracePeriodLength: "PT3888000S"
automaticTransferLength: "PT432000S"
claimsPeriodEnd: "294247-01-10T04:00:54.775Z"
createBillingCost:
currency: "JPY"
amount: 250
createBillingCostTransitions:
"1970-01-01T00:00:00.000Z":
currency: "JPY"
@@ -5,9 +5,6 @@ anchorTenantAddGracePeriodLength: "PT2592000S"
automaticTransferLength: "PT2592000S"
autoRenewGracePeriodLength: "PT2592000S"
claimsPeriodEnd: "294247-01-10T04:00:54.775Z"
createBillingCost:
currency: "USD"
amount: 25.00
createBillingCostTransitions:
"1970-01-01T00:00:00.000Z":
currency: "USD"
@@ -5,9 +5,6 @@ anchorTenantAddGracePeriodLength: "PT2592000S"
autoRenewGracePeriodLength: "PT3888000S"
automaticTransferLength: "PT432000S"
claimsPeriodEnd: "294247-01-10T04:00:54.775Z"
createBillingCost:
currency: "USD"
amount: 25.00
createBillingCostTransitions:
"1970-01-01T00:00:00.000Z":
currency: "USD"
@@ -27,9 +27,6 @@ transferGracePeriodLength: "PT2592000S"
automaticTransferLength: "PT2592000S"
pendingDeleteLength: "PT2592000S"
currency: "USD"
createBillingCost:
currency: "USD"
amount: 25.00
createBillingCostTransitions:
"1970-01-01T00:00:00.000Z":
currency: "USD"
@@ -27,9 +27,6 @@ transferGracePeriodLength: "PT2592000S"
automaticTransferLength: "PT2592000S"
pendingDeleteLength: "PT2592000S"
currency: "USD"
createBillingCost:
currency: "USD"
amount: 25.00
restoreBillingCost:
currency: "USD"
amount: 17.00
@@ -5,9 +5,6 @@ anchorTenantAddGracePeriodLength: "PT2592000S"
autoRenewGracePeriodLength: "PT3888000S"
automaticTransferLength: "PT432000S"
claimsPeriodEnd: "294247-01-10T04:00:54.775Z"
createBillingCost:
currency: "USD"
amount: 25.00
createBillingCostTransitions:
"1970-01-01T00:00:00.000Z":
currency: "USD"
@@ -5,9 +5,6 @@ anchorTenantAddGracePeriodLength: "PT2592000S"
autoRenewGracePeriodLength: "PT3888000S"
automaticTransferLength: "PT432000S"
claimsPeriodEnd: "294247-01-10T04:00:54.775Z"
createBillingCost:
currency: "USD"
amount: 25.00
createBillingCostTransitions:
"1970-01-01T00:00:00.000Z":
currency: "USD"
@@ -0,0 +1,62 @@
addGracePeriodLength: "PT432000S"
allowedFullyQualifiedHostNames: []
allowedRegistrantContactIds: []
anchorTenantAddGracePeriodLength: "PT2592000S"
autoRenewGracePeriodLength: "PT3888000S"
automaticTransferLength: "PT432000S"
claimsPeriodEnd: "294247-01-10T04:00:54.775Z"
createBillingCost:
currency: "USD"
amount: 25.00
createBillingCostTransitions:
"1970-01-01T00:00:00.000Z":
currency: "USD"
amount: 8.00
"2020-01-01T00:00:00.000Z":
currency: "USD"
amount: 25.00
creationTime: "2022-09-01T00:00:00.000Z"
currency: "USD"
defaultPromoTokens: []
dnsAPlusAaaaTtl: "PT900S"
dnsDsTtl: null
dnsNsTtl: null
dnsPaused: false
dnsWriters:
- "VoidDnsWriter"
driveFolderId: "driveFolder"
eapFeeSchedule:
"1970-01-01T00:00:00.000Z":
currency: "USD"
amount: 0.00
escrowEnabled: false
idnTables: []
invoicingEnabled: false
lordnUsername: null
numDnsPublishLocks: 1
pendingDeleteLength: "PT432000S"
premiumListName: "test"
pricingEngineClassName: "google.registry.model.pricing.StaticPremiumListPricingEngine"
redemptionGracePeriodLength: "PT2592000S"
registryLockOrUnlockBillingCost:
currency: "USD"
amount: 0.00
renewBillingCostTransitions:
"1970-01-01T00:00:00.000Z":
currency: "USD"
amount: 11.00
renewGracePeriodLength: "PT432000S"
reservedListNames: []
restoreBillingCost:
currency: "USD"
amount: 17.00
roidSuffix: "TLD"
serverStatusChangeBillingCost:
currency: "USD"
amount: 19.00
tldStateTransitions:
"1970-01-01T00:00:00.000Z": "GENERAL_AVAILABILITY"
tldStr: "withcreatecost"
tldType: "REAL"
tldUnicode: "withcreatecost"
transferGracePeriodLength: "PT432000S"
@@ -27,9 +27,6 @@ transferGracePeriodLength: 432000000
automaticTransferLength: 432000000
pendingDeleteLength: 432000000
currency: "USD"
createBillingCost:
currency: "USD"
amount: 25.00
createBillingCostTransitions:
"1970-01-01T00:00:00.000Z":
currency: "USD"