1
0
mirror of https://github.com/google/nomulus synced 2026-05-23 08:11:48 +00:00

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 14:22:45 -04:00
committed by GitHub
parent e809e967a3
commit f729802094
26 changed files with 115 additions and 82 deletions

View File

@@ -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();

View File

@@ -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);

View File

@@ -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 {

View File

@@ -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"

View File

@@ -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: []

View File

@@ -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"

View File

@@ -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: []

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -27,9 +27,6 @@ transferGracePeriodLength: "PT2592000S"
automaticTransferLength: "PT2592000S"
pendingDeleteLength: "PT2592000S"
currency: "USD"
createBillingCost:
currency: "USD"
amount: 25.00
restoreBillingCost:
currency: "USD"
amount: 17.00

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -261,11 +261,11 @@ td.section {
</tr>
<tr>
<td class="property_name">generated on</td>
<td class="property_value">2024-03-28 21:10:10.784013213</td>
<td class="property_value">2024-04-17 19:49:33.30624492</td>
</tr>
<tr>
<td class="property_name">last flyway file</td>
<td id="lastFlywayFile" class="property_value">V166__drop_should_publish_column.sql</td>
<td id="lastFlywayFile" class="property_value">V167__creat_billing_cost_transitions_not_null.sql</td>
</tr>
</tbody>
</table>
@@ -277,11 +277,11 @@ td.section {
SchemaCrawler_Diagram
</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-3493.5 4025,-3493.5 4025,4 -4,4" />
<text text-anchor="start" x="3730.5" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated by</text>
<text text-anchor="start" x="3813.5" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">SchemaCrawler 16.10.1</text>
<text text-anchor="start" x="3729.5" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated on</text>
<text text-anchor="start" x="3813.5" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">2024-03-28 21:10:10.784013213</text>
<polygon fill="none" stroke="#888888" points="3726,-4 3726,-44 4013,-44 4013,-4 3726,-4" /> <!-- allocationtoken_a08ccbef -->
<text text-anchor="start" x="3737" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated by</text>
<text text-anchor="start" x="3820" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">SchemaCrawler 16.10.1</text>
<text text-anchor="start" x="3736" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated on</text>
<text text-anchor="start" x="3820" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">2024-04-17 19:49:33.30624492</text>
<polygon fill="none" stroke="#888888" points="3733,-4 3733,-44 4013,-44 4013,-4 3733,-4" /> <!-- allocationtoken_a08ccbef -->
<g id="node1" class="node">
<title>
allocationtoken_a08ccbef

View File

@@ -261,11 +261,11 @@ td.section {
</tr>
<tr>
<td class="property_name">generated on</td>
<td class="property_value">2024-03-28 21:10:08.34519385</td>
<td class="property_value">2024-04-17 19:49:29.701469664</td>
</tr>
<tr>
<td class="property_name">last flyway file</td>
<td id="lastFlywayFile" class="property_value">V166__drop_should_publish_column.sql</td>
<td id="lastFlywayFile" class="property_value">V167__creat_billing_cost_transitions_not_null.sql</td>
</tr>
</tbody>
</table>
@@ -277,11 +277,11 @@ td.section {
SchemaCrawler_Diagram
</title>
<polygon fill="white" stroke="transparent" points="-4,4 -4,-9310 4738,-9310 4738,4 -4,4" />
<text text-anchor="start" x="4450" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated by</text>
<text text-anchor="start" x="4533" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">SchemaCrawler 16.10.1</text>
<text text-anchor="start" x="4449" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated on</text>
<text text-anchor="start" x="4533" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">2024-03-28 21:10:08.34519385</text>
<polygon fill="none" stroke="#888888" points="4446,-4 4446,-44 4726,-44 4726,-4 4446,-4" /> <!-- allocationtoken_a08ccbef -->
<text text-anchor="start" x="4443.5" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated by</text>
<text text-anchor="start" x="4526.5" y="-29.8" font-family="Helvetica,sans-Serif" font-size="14.00">SchemaCrawler 16.10.1</text>
<text text-anchor="start" x="4442.5" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">generated on</text>
<text text-anchor="start" x="4526.5" y="-10.8" font-family="Helvetica,sans-Serif" font-size="14.00">2024-04-17 19:49:29.701469664</text>
<polygon fill="none" stroke="#888888" points="4439,-4 4439,-44 4726,-44 4726,-4 4439,-4" /> <!-- allocationtoken_a08ccbef -->
<g id="node1" class="node">
<title>
allocationtoken_a08ccbef
@@ -1626,7 +1626,7 @@ td.section {
<text text-anchor="start" x="1639" y="-3319.3" font-family="Helvetica,sans-Serif" font-size="14.00">timestamptz</text>
<text text-anchor="start" x="1360" y="-3300.3" font-family="Helvetica,sans-Serif" font-size="14.00">create_billing_cost_transitions</text>
<text text-anchor="start" x="1631" y="-3300.3" font-family="Helvetica,sans-Serif" font-size="14.00"> </text>
<text text-anchor="start" x="1639" y="-3300.3" font-family="Helvetica,sans-Serif" font-size="14.00">"hstore"</text>
<text text-anchor="start" x="1639" y="-3300.3" font-family="Helvetica,sans-Serif" font-size="14.00">"hstore" not null</text>
<polygon fill="none" stroke="#888888" points="1356.5,-3294 1356.5,-4189 1763.5,-4189 1763.5,-3294 1356.5,-3294" />
</g> <!-- domain_6c51cffa&#45;&gt;tld_f1fa57e2 -->
<g id="edge83" class="edge">
@@ -12871,7 +12871,7 @@ td.section {
<tr>
<td class="spacer"></td>
<td class="minwidth">create_billing_cost_transitions</td>
<td class="minwidth">"hstore"</td>
<td class="minwidth">"hstore" not null</td>
</tr>
<tr>
<td colspan="3"></td>

View File

@@ -164,3 +164,4 @@ V163__rename_console_registrar_history_time.sql
V164__rename_console_user_history_time.sql
V165__add_domain_repo_id_indexes_to_more_tables.sql
V166__drop_should_publish_column.sql
V167__creat_billing_cost_transitions_not_null.sql

View File

@@ -0,0 +1,18 @@
-- Copyright 2024 The Nomulus Authors. All Rights Reserved.
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- Note: we drop the not-null constraints from the history tables but we keep them in the
-- EPP resource tables since nothing inserted there should be null
ALTER TABLE "Tld" ALTER COLUMN create_billing_cost_transitions SET NOT NULL;

View File

@@ -739,7 +739,7 @@
claims_period_end timestamptz not null,
create_billing_cost_amount numeric(19, 2),
create_billing_cost_currency text,
create_billing_cost_transitions hstore,
create_billing_cost_transitions hstore not null,
creation_time timestamptz not null,
currency text not null,
default_promo_tokens text[],

View File

@@ -1286,7 +1286,7 @@ CREATE TABLE public."Tld" (
idn_tables text[],
breakglass_mode boolean DEFAULT false NOT NULL,
bsa_enroll_start_time timestamp with time zone,
create_billing_cost_transitions public.hstore
create_billing_cost_transitions public.hstore NOT NULL
);