1
0
mirror of https://github.com/google/nomulus synced 2026-06-08 16:02:56 +00:00

Remove the createBillingCost field from Tld (#2425)

* Remove the createBillingCost field from Tld

* fix spacing

* Change field name of map

* Rename getter

* Fix formatting

* Fix todo

* unchange column name
This commit is contained in:
sarahcaseybot
2024-05-08 14:14:03 -04:00
committed by GitHub
parent 73d3b76a89
commit 808432e709
9 changed files with 1 additions and 296 deletions

View File

@@ -458,20 +458,6 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl
@JsonDeserialize(using = CurrencyDeserializer.class)
CurrencyUnit currency = DEFAULT_CURRENCY;
// 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 = {
@Column(name = "create_billing_cost_amount"),
@Column(name = "create_billing_cost_currency")
})
Money createBillingCost = DEFAULT_CREATE_BILLING_COST;
// 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)
@@ -682,19 +668,10 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl
* Use {@code PricingEngineProxy.getDomainCreateCost} instead of this to find the cost for a
* domain create.
*/
@VisibleForTesting
public Money getCreateBillingCost(DateTime now) {
return createBillingCostTransitions.getValueAtTime(now);
}
// This getter is still necessary for the Jackson deserialization in the ConfigureTldCommand
// TODO(sarahbot@): Remove this getter once the deprecated createBillingCost field is removed from
// the schema
@Deprecated
public Money getCreateBillingCost() {
return createBillingCost;
}
public ImmutableSortedMap<DateTime, Money> getCreateBillingCostTransitions() {
return createBillingCostTransitions.toValueMap();
}
@@ -976,12 +953,6 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl
return this;
}
public Builder setCreateBillingCost(Money amount) {
checkArgument(amount.isPositiveOrZero(), "createBillingCost cannot be negative");
getInstance().createBillingCost = amount;
return this;
}
public Builder setCreateBillingCostTransitions(
ImmutableSortedMap<DateTime, Money> createCostsMap) {
checkArgumentNotNull(createCostsMap, "Create billing costs map cannot be null");

View File

@@ -149,7 +149,6 @@ public final class TldTest extends EntityTestCase {
.setDnsAPlusAaaaTtl(Duration.standardHours(1))
.setDnsWriters(ImmutableSet.of("baz", "bang"))
// 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,
@@ -171,7 +170,7 @@ public final class TldTest extends EntityTestCase {
@Test
void testSuccess_tldYamlRoundtrip() throws Exception {
Tld testTld = createTld("test").asBuilder().setCreateBillingCost(Money.of(USD, 8)).build();
Tld testTld = createTld("test");
ObjectMapper mapper = createObjectMapper();
String yaml = mapper.writeValueAsString(testTld);
Tld constructedTld = mapper.readValue(yaml, Tld.class);
@@ -610,15 +609,6 @@ public final class TldTest extends EntityTestCase {
assertThat(thrown).hasMessageThat().contains("billing cost cannot be negative");
}
@Test
void testFailure_negativeCreateBillingCost() {
IllegalArgumentException thrown =
assertThrows(
IllegalArgumentException.class,
() -> Tld.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, -42)));
assertThat(thrown).hasMessageThat().contains("createBillingCost cannot be negative");
}
@Test
void testFailure_negativeRestoreBillingCost() {
IllegalArgumentException thrown =

View File

@@ -248,7 +248,6 @@ public final class DatabaseHelper {
// Set billing costs to distinct small primes to avoid masking bugs in tests.
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 11)))
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(USD)))
.setCreateBillingCost(Money.of(USD, 13))
.setCreateBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 13)))
.setRestoreBillingCost(Money.of(USD, 17))
.setServerStatusChangeBillingCost(Money.of(USD, 19))

View File

@@ -176,54 +176,6 @@ public class ConfigureTldCommandTest extends CommandTestCase<ConfigureTldCommand
assertThat(updatedTld.getCreateBillingCost(fakeClock.nowUtc())).isEqualTo(Money.of(USD, 25));
}
@Test
void testSuccess_fileMissingCreateBillingCostTransitions() throws Exception {
createTld("nocreatecostmap");
File tldFile = tmpDir.resolve("nocreatecostmap.yaml").toFile();
Files.asCharSink(tldFile, UTF_8).write(loadFile(getClass(), "nocreatecostmap.yaml"));
runCommandForced("--input=" + tldFile);
Tld updatedTld = Tld.get("nocreatecostmap");
assertThat(updatedTld.getCreateBillingCostTransitions())
.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 {
ImmutableSortedMap<DateTime, Money> createCostTransitions =
ImmutableSortedMap.of(
START_OF_TIME,
Money.of(USD, 8),
fakeClock.nowUtc(),
Money.of(USD, 1),
fakeClock.nowUtc().plusMonths(1),
Money.of(USD, 2),
fakeClock.nowUtc().plusMonths(2),
Money.of(USD, 3));
Tld tld =
createTld("nocreatecostmap")
.asBuilder()
.setCreateBillingCostTransitions(createCostTransitions)
.build();
assertThat(tld.getCreateBillingCostTransitions().size()).isEqualTo(4);
File tldFile = tmpDir.resolve("nocreatecostmap.yaml").toFile();
Files.asCharSink(tldFile, UTF_8).write(loadFile(getClass(), "nocreatecostmap.yaml"));
runCommandForced("--input=" + tldFile);
Tld updatedTld = Tld.get("nocreatecostmap");
assertThat(updatedTld.getCreateBillingCostTransitions())
.isEqualTo(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 25)));
}
@Test
void testFailure_fileMissingNullableFieldsOnCreate() throws Exception {
File tldFile = tmpDir.resolve("missingnullablefields.yaml").toFile();
@@ -236,20 +188,6 @@ public class ConfigureTldCommandTest extends CommandTestCase<ConfigureTldCommand
+ " premiumListName, currency, numDnsPublishLocks]");
}
@Test
void testSuccess_addCreateBillingCostTransitions() throws Exception {
createTld("costmap");
File tldFile = tmpDir.resolve("costmap.yaml").toFile();
Files.asCharSink(tldFile, UTF_8).write(loadFile(getClass(), "costmap.yaml"));
runCommandForced("--input=" + tldFile);
Tld updatedTld = Tld.get("costmap");
ImmutableSortedMap<DateTime, Money> costTransitions =
updatedTld.getCreateBillingCostTransitions();
assertThat(costTransitions.size()).isEqualTo(3);
assertThat(costTransitions.get(START_OF_TIME)).isEqualTo(Money.of(USD, 13));
assertThat(costTransitions.get(START_OF_TIME.plusYears(26))).isEqualTo(Money.of(USD, 14));
}
@Test
void testFailure_fileMissingNullableFieldOnUpdate() throws Exception {
Tld tld = createTld("missingnullablefields");

View File

@@ -50,7 +50,6 @@ class GetTldCommandTest extends CommandTestCase<GetTldCommand> {
tld.asBuilder()
.setDnsAPlusAaaaTtl(Duration.standardMinutes(15))
.setDriveFolderId("driveFolder")
.setCreateBillingCost(Money.of(USD, 25))
.setCreateBillingCostTransitions(
ImmutableSortedMap.of(
START_OF_TIME,

View File

@@ -1,72 +0,0 @@
addGracePeriodLength: "PT432000S"
allowedFullyQualifiedHostNames:
- "foo"
allowedRegistrantContactIds: []
anchorTenantAddGracePeriodLength: "PT2592000S"
autoRenewGracePeriodLength: "PT3888000S"
automaticTransferLength: "PT432000S"
claimsPeriodEnd: "294247-01-10T04:00:54.775Z"
createBillingCostTransitions:
"1970-01-01T00:00:00.000Z":
currency: "USD"
amount: 13.00
"1996-01-01T00:00:00.000Z":
currency: "USD"
amount: 14.00
"2050-01-01T00:00:00.000Z":
currency: "USD"
amount: 15.00
creationTime: "1970-01-01T00:00:00.000Z"
currency: "USD"
defaultPromoTokens:
- "bbbbb"
dnsAPlusAaaaTtl: "PT3600S"
dnsDsTtl: null
dnsNsTtl: null
dnsPaused: false
dnsWriters:
- "VoidDnsWriter"
driveFolderId: null
eapFeeSchedule:
"1970-01-01T00:00:00.000Z":
currency: "USD"
amount: 0.00
"2000-06-01T00:00:00.000Z":
currency: "USD"
amount: 100.00
"2000-06-02T00:00:00.000Z":
currency: "USD"
amount: 0.00
escrowEnabled: false
idnTables:
- "EXTENDED_LATIN"
- "JA"
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: "COSTMAP"
serverStatusChangeBillingCost:
currency: "USD"
amount: 19.00
tldStateTransitions:
"1970-01-01T00:00:00.000Z": "GENERAL_AVAILABILITY"
tldStr: "costmap"
tldType: "REAL"
tldUnicode: "costmap"
transferGracePeriodLength: "PT432000S"

View File

@@ -1,56 +0,0 @@
addGracePeriodLength: "PT432000S"
allowedFullyQualifiedHostNames: []
allowedRegistrantContactIds: []
anchorTenantAddGracePeriodLength: "PT2592000S"
autoRenewGracePeriodLength: "PT3888000S"
automaticTransferLength: "PT432000S"
claimsPeriodEnd: "294247-01-10T04:00:54.775Z"
createBillingCostTransitions:
"1970-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: "NOCREATE"
serverStatusChangeBillingCost:
currency: "USD"
amount: 19.00
tldStateTransitions:
"1970-01-01T00:00:00.000Z": "GENERAL_AVAILABILITY"
tldStr: "nocreatecostmap"
tldType: "REAL"
tldUnicode: "nocreatecostmap"
transferGracePeriodLength: "PT432000S"

View File

@@ -1,62 +0,0 @@
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"

View File

@@ -833,8 +833,6 @@
breakglass_mode boolean not null,
bsa_enroll_start_time timestamptz,
claims_period_end timestamptz not null,
create_billing_cost_amount numeric(19, 2),
create_billing_cost_currency text,
create_billing_cost_transitions hstore not null,
creation_time timestamptz not null,
currency text not null,