From 6f3d062c32f716b7e325780eda14cf27a1782acf Mon Sep 17 00:00:00 2001 From: sarahcaseybot Date: Tue, 18 Apr 2023 12:26:14 -0400 Subject: [PATCH] Change Registry class name to Tld (#1991) * Change Registry class name to Tld * Fix merge conflict * Some capitalization fixes --- .../batch/DeleteProberDataAction.java | 2 +- .../ExpandRecurringBillingEventsPipeline.java | 4 +- .../java/google/registry/beam/rde/RdeIO.java | 8 +- .../registry/config/RegistryConfig.java | 2 +- .../google/registry/cron/TldFanoutAction.java | 4 +- .../google/registry/dns/DnsWriterProxy.java | 4 +- .../registry/dns/PublishDnsUpdatesAction.java | 12 +- .../registry/dns/ReadDnsQueueAction.java | 8 +- .../dns/ReadDnsRefreshRequestsAction.java | 10 +- .../export/ExportDomainListsAction.java | 19 +- .../export/ExportPremiumTermsAction.java | 45 +-- .../export/ExportReservedTermsAction.java | 35 ++- .../google/registry/export/ExportUtils.java | 6 +- .../google/registry/flows/CheckApiAction.java | 6 +- .../custom/DomainPricingCustomLogic.java | 22 +- .../flows/domain/DomainCheckFlow.java | 16 +- .../flows/domain/DomainClaimsCheckFlow.java | 16 +- .../flows/domain/DomainCreateFlow.java | 74 +++-- .../flows/domain/DomainDeleteFlow.java | 35 +-- .../flows/domain/DomainFlowUtils.java | 88 +++--- .../flows/domain/DomainPricingLogic.java | 43 ++- .../flows/domain/DomainRenewFlow.java | 19 +- .../domain/DomainRestoreRequestFlow.java | 5 +- .../domain/DomainTransferApproveFlow.java | 22 +- .../domain/DomainTransferCancelFlow.java | 10 +- .../domain/DomainTransferRejectFlow.java | 10 +- .../domain/DomainTransferRequestFlow.java | 25 +- .../flows/domain/DomainTransferUtils.java | 8 +- .../flows/domain/DomainUpdateFlow.java | 16 +- .../token/AllocationTokenCustomLogic.java | 6 +- .../token/AllocationTokenFlowUtils.java | 11 +- .../registry/model/EppResourceUtils.java | 4 +- .../registry/model/OteAccountBuilder.java | 32 +-- .../google/registry/model/common/Cursor.java | 8 +- .../registry/model/domain/DomainBase.java | 7 +- .../StaticPremiumListPricingEngine.java | 12 +- .../registry/model/registrar/Registrar.java | 14 +- .../google/registry/model/tld/Registries.java | 8 +- .../model/tld/{Registry.java => Tld.java} | 115 ++++---- .../model/tld/label/BaseDomainLabelList.java | 6 +- .../registry/model/tld/label/PremiumList.java | 6 +- .../model/tld/label/ReservedList.java | 17 +- .../TldStateTransitionConverter.java | 2 +- .../registry/pricing/PricingEngineProxy.java | 4 +- .../google/registry/rde/BrdaCopyAction.java | 5 +- .../google/registry/rde/EscrowTaskRunner.java | 17 +- .../registry/rde/PendingDepositChecker.java | 23 +- .../google/registry/rde/RdeReportAction.java | 6 +- .../google/registry/rde/RdeUploadAction.java | 13 +- .../icann/IcannReportingUploadAction.java | 18 +- .../tldconfig/idn/IdnLabelValidator.java | 4 +- .../tmch/LordnRequestInitializer.java | 9 +- .../tools/CreateOrUpdateTldCommand.java | 46 +-- .../registry/tools/CreateTldCommand.java | 21 +- .../registry/tools/DeleteTldCommand.java | 26 +- .../registry/tools/DomainLockUtils.java | 4 +- .../google/registry/tools/GetTldCommand.java | 4 +- .../registry/tools/ListCursorsCommand.java | 6 +- .../registry/tools/ListDomainsCommand.java | 2 +- .../registry/tools/UpdateCursorsCommand.java | 8 +- .../registry/tools/UpdateTldCommand.java | 20 +- .../tools/params/TldStateParameter.java | 2 +- .../tools/params/TransitionListParameter.java | 2 +- .../registry/tools/server/ListTldsAction.java | 22 +- .../main/resources/META-INF/persistence.xml | 2 +- .../batch/DeleteProberDataActionTest.java | 10 +- ...andRecurringBillingEventsPipelineTest.java | 18 +- .../beam/billing/InvoicingPipelineTest.java | 18 +- .../beam/common/DatabaseSnapshotTest.java | 24 +- .../beam/common/RegistryJpaReadTest.java | 6 +- .../registry/beam/rde/RdePipelineTest.java | 9 +- .../registry/cron/TldFanoutActionTest.java | 6 +- .../dns/PublishDnsUpdatesActionTest.java | 13 +- .../registry/dns/ReadDnsQueueActionTest.java | 18 +- .../dns/ReadDnsRefreshRequestsActionTest.java | 6 +- .../export/ExportDomainListsActionTest.java | 10 +- .../export/ExportPremiumTermsActionTest.java | 12 +- .../export/ExportReservedTermsActionTest.java | 15 +- .../registry/export/ExportUtilsTest.java | 6 +- .../registry/flows/CheckApiActionTest.java | 6 +- .../flows/EppLifecycleDomainTest.java | 23 +- .../google/registry/flows/EppTestCase.java | 10 +- .../flows/contact/ContactDeleteFlowTest.java | 4 +- .../contact/ContactTransferFlowTestCase.java | 6 +- .../flows/domain/DomainCheckFlowTest.java | 71 +++-- .../domain/DomainClaimsCheckFlowTest.java | 10 +- .../flows/domain/DomainCreateFlowTest.java | 123 ++++---- .../flows/domain/DomainDeleteFlowTest.java | 39 ++- .../flows/domain/DomainFlowUtilsTest.java | 6 +- .../flows/domain/DomainInfoFlowTest.java | 14 +- .../flows/domain/DomainPricingLogicTest.java | 6 +- .../flows/domain/DomainRenewFlowTest.java | 56 ++-- .../domain/DomainRestoreRequestFlowTest.java | 19 +- .../domain/DomainTransferApproveFlowTest.java | 21 +- .../domain/DomainTransferCancelFlowTest.java | 4 +- .../domain/DomainTransferFlowTestCase.java | 6 +- .../domain/DomainTransferRejectFlowTest.java | 4 +- .../domain/DomainTransferRequestFlowTest.java | 51 ++-- .../flows/domain/DomainUpdateFlowTest.java | 20 +- .../token/AllocationTokenFlowUtilsTest.java | 24 +- .../flows/host/HostDeleteFlowTest.java | 6 +- .../flows/host/HostUpdateFlowTest.java | 4 +- .../registry/model/OteAccountBuilderTest.java | 10 +- .../registry/model/common/CursorTest.java | 10 +- .../registry/model/domain/DomainTest.java | 20 +- .../model/registrar/RegistrarTest.java | 12 +- .../registry/model/tld/RegistriesTest.java | 11 +- .../tld/{RegistryTest.java => TldTest.java} | 175 ++++++------ .../model/tld/label/PremiumListDaoTest.java | 8 +- .../model/tld/label/PremiumListTest.java | 4 +- .../model/tld/label/ReservedListTest.java | 18 +- .../TldStateTransitionConverterTest.java | 2 +- .../pricing/PricingEngineProxyTest.java | 8 +- .../registry/rdap/RdapDomainActionTest.java | 4 +- .../rdap/RdapDomainSearchActionTest.java | 10 +- .../registry/rde/BrdaCopyActionTest.java | 6 +- .../registry/rde/EscrowTaskRunnerTest.java | 6 +- .../rde/PendingDepositCheckerTest.java | 16 +- .../registry/rde/RdeReportActionTest.java | 13 +- .../registry/rde/RdeStagingActionTest.java | 6 +- .../registry/rde/RdeUploadActionTest.java | 34 +-- .../icann/IcannReportingUploadActionTest.java | 28 +- .../integration/SqlIntegrationTestSuite.java | 4 +- .../registry/testing/DatabaseHelper.java | 43 ++- .../registry/tmch/NordnUploadActionTest.java | 6 +- .../registry/tmch/NordnVerifyActionTest.java | 4 +- .../tools/CreateAnchorTenantCommandTest.java | 4 +- .../tools/CreateDomainCommandTest.java | 8 +- ...ateOrUpdatePremiumListCommandTestCase.java | 16 +- .../tools/CreatePremiumListCommandTest.java | 9 +- .../tools/CreateRegistrarCommandTest.java | 4 +- .../tools/CreateReservedListCommandTest.java | 4 +- .../registry/tools/CreateTldCommandTest.java | 80 +++--- .../tools/DeletePremiumListCommandTest.java | 4 +- .../tools/DeleteReservedListCommandTest.java | 4 +- .../registry/tools/DeleteTldCommandTest.java | 20 +- .../registry/tools/DomainLockUtilsTest.java | 4 +- .../tools/ListCursorsCommandTest.java | 6 +- .../tools/ListDomainsCommandTest.java | 6 +- .../registry/tools/SetupOteCommandTest.java | 12 +- .../tools/UpdateCursorsCommandTest.java | 14 +- .../tools/UpdatePremiumListCommandTest.java | 8 +- .../tools/UpdateRegistrarCommandTest.java | 4 +- .../registry/tools/UpdateTldCommandTest.java | 265 +++++++++--------- .../tools/params/EnumParameterTest.java | 4 +- .../server/ListReservedListsActionTest.java | 4 +- .../registrar/ConsoleOteSetupActionTest.java | 4 +- .../RegistryLockVerifyActionTest.java | 4 +- .../registry/whois/WhoisActionTest.java | 6 +- .../whois/WhoisCommandFactoryTest.java | 4 +- .../registry/whois/WhoisHttpActionTest.java | 4 +- 151 files changed, 1339 insertions(+), 1411 deletions(-) rename core/src/main/java/google/registry/model/tld/{Registry.java => Tld.java} (91%) rename core/src/test/java/google/registry/model/tld/{RegistryTest.java => TldTest.java} (81%) diff --git a/core/src/main/java/google/registry/batch/DeleteProberDataAction.java b/core/src/main/java/google/registry/batch/DeleteProberDataAction.java index 4370c9e7f..f9236a448 100644 --- a/core/src/main/java/google/registry/batch/DeleteProberDataAction.java +++ b/core/src/main/java/google/registry/batch/DeleteProberDataAction.java @@ -37,7 +37,7 @@ import google.registry.model.CreateAutoTimestamp; import google.registry.model.EppResourceUtils; import google.registry.model.domain.Domain; import google.registry.model.domain.DomainHistory; -import google.registry.model.tld.Registry.TldType; +import google.registry.model.tld.Tld.TldType; import google.registry.request.Action; import google.registry.request.Parameter; import google.registry.request.auth.Auth; diff --git a/core/src/main/java/google/registry/beam/billing/ExpandRecurringBillingEventsPipeline.java b/core/src/main/java/google/registry/beam/billing/ExpandRecurringBillingEventsPipeline.java index f2ec8b7f9..9b95549e5 100644 --- a/core/src/main/java/google/registry/beam/billing/ExpandRecurringBillingEventsPipeline.java +++ b/core/src/main/java/google/registry/beam/billing/ExpandRecurringBillingEventsPipeline.java @@ -48,7 +48,7 @@ import google.registry.model.domain.DomainHistory; import google.registry.model.domain.Period; import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.PersistenceModule.TransactionIsolationLevel; import google.registry.util.Clock; import google.registry.util.SystemClock; @@ -281,7 +281,7 @@ public class ExpandRecurringBillingEventsPipeline implements Serializable { return; } Domain domain = tm().loadByKey(Domain.createVKey(recurring.getDomainRepoId())); - Registry tld = Registry.get(domain.getTld()); + Tld tld = Tld.get(domain.getTld()); // Find the times for which the OneTime billing event are already created, making this expansion // idempotent. There is no need to match to the domain repo ID as the cancellation matching diff --git a/core/src/main/java/google/registry/beam/rde/RdeIO.java b/core/src/main/java/google/registry/beam/rde/RdeIO.java index 1d978d453..b8141c0b6 100644 --- a/core/src/main/java/google/registry/beam/rde/RdeIO.java +++ b/core/src/main/java/google/registry/beam/rde/RdeIO.java @@ -33,7 +33,7 @@ import google.registry.model.common.Cursor; import google.registry.model.rde.RdeMode; import google.registry.model.rde.RdeNamingUtils; import google.registry.model.rde.RdeRevision; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.rde.BrdaCopyAction; import google.registry.rde.DepositFragment; import google.registry.rde.Ghostryde; @@ -272,12 +272,12 @@ public class RdeIO { tm().transact( () -> { PendingDeposit key = input.getKey(); - Registry registry = Registry.get(key.tld()); + Tld tld = Tld.get(key.tld()); Optional cursor = tm().transact( () -> tm().loadByKeyIfPresent( - Cursor.createScopedVKey(key.cursor(), registry))); + Cursor.createScopedVKey(key.cursor(), tld))); DateTime position = getCursorTimeOrStartOfTime(cursor); checkState(key.interval() != null, "Interval must be present"); DateTime newPosition = key.watermark().plus(key.interval()); @@ -290,7 +290,7 @@ public class RdeIO { "Partial ordering of RDE deposits broken: %s %s", position, key); - tm().put(Cursor.createScoped(key.cursor(), newPosition, registry)); + tm().put(Cursor.createScoped(key.cursor(), newPosition, tld)); logger.atInfo().log( "Rolled forward %s on %s cursor to %s.", key.cursor(), key.tld(), newPosition); RdeRevision.saveRevision(key.tld(), key.watermark(), key.mode(), input.getValue()); diff --git a/core/src/main/java/google/registry/config/RegistryConfig.java b/core/src/main/java/google/registry/config/RegistryConfig.java index d083f8688..8250cf532 100644 --- a/core/src/main/java/google/registry/config/RegistryConfig.java +++ b/core/src/main/java/google/registry/config/RegistryConfig.java @@ -63,7 +63,7 @@ import org.joda.time.Duration; *

This class does not represent the total configuration of the Nomulus service. It's only * meant for settings that need to be configured once. Settings which may be subject to * change in the future, should instead be retrieved from the database. The {@link - * google.registry.model.tld.Registry Registry} class is one such example of this. + * google.registry.model.tld.Tld Tld} class is one such example of this. * *

Note: Only settings that are actually configurable belong in this file. It's not a catch-all * for anything widely used throughout the code base. diff --git a/core/src/main/java/google/registry/cron/TldFanoutAction.java b/core/src/main/java/google/registry/cron/TldFanoutAction.java index a41a174f0..46d0d7f55 100644 --- a/core/src/main/java/google/registry/cron/TldFanoutAction.java +++ b/core/src/main/java/google/registry/cron/TldFanoutAction.java @@ -28,8 +28,8 @@ import static google.registry.cron.CronModule.JITTER_SECONDS_PARAM; import static google.registry.cron.CronModule.QUEUE_PARAM; import static google.registry.cron.CronModule.RUN_IN_EMPTY_PARAM; import static google.registry.model.tld.Registries.getTldsOfType; -import static google.registry.model.tld.Registry.TldType.REAL; -import static google.registry.model.tld.Registry.TldType.TEST; +import static google.registry.model.tld.Tld.TldType.REAL; +import static google.registry.model.tld.Tld.TldType.TEST; import com.google.cloud.tasks.v2.Task; import com.google.common.collect.ArrayListMultimap; diff --git a/core/src/main/java/google/registry/dns/DnsWriterProxy.java b/core/src/main/java/google/registry/dns/DnsWriterProxy.java index 0e64f9b34..40549f167 100644 --- a/core/src/main/java/google/registry/dns/DnsWriterProxy.java +++ b/core/src/main/java/google/registry/dns/DnsWriterProxy.java @@ -19,7 +19,7 @@ import static com.google.common.base.Preconditions.checkState; import com.google.common.collect.ImmutableMap; import com.google.common.flogger.FluentLogger; import google.registry.dns.writer.DnsWriter; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import java.util.Map; import javax.inject.Inject; @@ -41,7 +41,7 @@ public final class DnsWriterProxy { * If the DnsWriter doesn't belong to this TLD, will return null. */ public DnsWriter getByClassNameForTld(String className, String tld) { - if (!Registry.get(tld).getDnsWriters().contains(className)) { + if (!Tld.get(tld).getDnsWriters().contains(className)) { logger.atWarning().log( "Loaded potentially stale DNS writer %s which is not active on TLD %s.", className, tld); return null; diff --git a/core/src/main/java/google/registry/dns/PublishDnsUpdatesAction.java b/core/src/main/java/google/registry/dns/PublishDnsUpdatesAction.java index da058a586..b74eb7a57 100644 --- a/core/src/main/java/google/registry/dns/PublishDnsUpdatesAction.java +++ b/core/src/main/java/google/registry/dns/PublishDnsUpdatesAction.java @@ -45,7 +45,7 @@ import google.registry.model.domain.Domain; import google.registry.model.host.Host; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.RegistrarPoc; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.request.Action; import google.registry.request.Action.Service; import google.registry.request.Header; @@ -96,8 +96,8 @@ public final class PublishDnsUpdatesAction implements Runnable, Callable { * *

This comes from the fanout in {@link ReadDnsQueueAction} which dispatches each batch to be * published by each DNS writer on the TLD. So this field contains the value of one of the DNS - * writers configured in {@link Registry#getDnsWriters()}, as of the time the batch was written - * out (and not necessarily currently). + * writers configured in {@link Tld#getDnsWriters()}, as of the time the batch was written out + * (and not necessarily currently). */ private final String dnsWriter; @@ -372,11 +372,11 @@ public final class PublishDnsUpdatesAction implements Runnable, Callable { return false; } // Check if the Registry object's num locks has changed since this task was batched - int registryNumPublishLocks = Registry.get(tld).getNumDnsPublishLocks(); - if (registryNumPublishLocks != numPublishLocks) { + int tldNumPublishLocks = Tld.get(tld).getNumDnsPublishLocks(); + if (tldNumPublishLocks != numPublishLocks) { logger.atWarning().log( "Registry numDnsPublishLocks %d out of sync with parameter %d.", - registryNumPublishLocks, numPublishLocks); + tldNumPublishLocks, numPublishLocks); return false; } return true; diff --git a/core/src/main/java/google/registry/dns/ReadDnsQueueAction.java b/core/src/main/java/google/registry/dns/ReadDnsQueueAction.java index 9c99880ae..466fc8492 100644 --- a/core/src/main/java/google/registry/dns/ReadDnsQueueAction.java +++ b/core/src/main/java/google/registry/dns/ReadDnsQueueAction.java @@ -48,7 +48,7 @@ import google.registry.batch.CloudTasksUtils; import google.registry.config.RegistryConfig.Config; import google.registry.dns.DnsConstants.TargetType; import google.registry.model.tld.Registries; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.request.Action; import google.registry.request.Action.Service; import google.registry.request.Parameter; @@ -292,7 +292,7 @@ public final class ReadDnsQueueAction implements Runnable { } else if (!tlds.contains(tld)) { classifiedTasksBuilder.tasksToKeepBuilder().add(task); classifiedTasksBuilder.unknownTldsBuilder().add(tld); - } else if (Registry.get(tld).getDnsPaused()) { + } else if (Tld.get(tld).getDnsPaused()) { classifiedTasksBuilder.tasksToKeepBuilder().add(task); classifiedTasksBuilder.pausedTldsBuilder().add(tld); } else { @@ -330,7 +330,7 @@ public final class ReadDnsQueueAction implements Runnable { for (Map.Entry> tldRefreshItemsEntry : refreshItemsByTld.asMap().entrySet()) { String tld = tldRefreshItemsEntry.getKey(); - int numPublishLocks = Registry.get(tld).getNumDnsPublishLocks(); + int numPublishLocks = Tld.get(tld).getNumDnsPublishLocks(); // 1 lock or less implies no TLD-wide locks, simply enqueue everything under lock 1 of 1 if (numPublishLocks <= 1) { enqueueUpdates(tld, 1, 1, tldRefreshItemsEntry.getValue()); @@ -368,7 +368,7 @@ public final class ReadDnsQueueAction implements Runnable { for (List chunk : Iterables.partition(items, tldUpdateBatchSize)) { DateTime earliestCreateTime = chunk.stream().map(RefreshItem::creationTime).min(Comparator.naturalOrder()).get(); - for (String dnsWriter : Registry.get(tld).getDnsWriters()) { + for (String dnsWriter : Tld.get(tld).getDnsWriters()) { Task task = cloudTasksUtils.createPostTaskWithJitter( PublishDnsUpdatesAction.PATH, diff --git a/core/src/main/java/google/registry/dns/ReadDnsRefreshRequestsAction.java b/core/src/main/java/google/registry/dns/ReadDnsRefreshRequestsAction.java index 7f2eeef1a..243657f08 100644 --- a/core/src/main/java/google/registry/dns/ReadDnsRefreshRequestsAction.java +++ b/core/src/main/java/google/registry/dns/ReadDnsRefreshRequestsAction.java @@ -41,7 +41,7 @@ import google.registry.batch.CloudTasksUtils; import google.registry.config.RegistryConfig.Config; import google.registry.dns.DnsConstants.TargetType; import google.registry.model.common.DnsRefreshRequest; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.request.Action; import google.registry.request.Action.Service; import google.registry.request.Parameter; @@ -102,14 +102,14 @@ public final class ReadDnsRefreshRequestsAction implements Runnable { */ @Override public void run() { - if (Registry.get(tld).getDnsPaused()) { + if (Tld.get(tld).getDnsPaused()) { logger.atInfo().log("The queue updated is paused for TLD: %s.", tld); return; } DateTime requestedEndTime = clock.nowUtc().plus(requestedMaximumDuration); // See getLockIndex(), requests are evenly distributed to [1, numDnsPublishLocks], so each // bucket would be roughly the size of tldUpdateBatchSize. - int processBatchSize = tldUpdateBatchSize * Registry.get(tld).getNumDnsPublishLocks(); + int processBatchSize = tldUpdateBatchSize * Tld.get(tld).getNumDnsPublishLocks(); while (requestedEndTime.isAfter(clock.nowUtc())) { ImmutableList requests = dnsUtils.readAndUpdateRequestsWithLatestProcessTime( @@ -128,7 +128,7 @@ public final class ReadDnsRefreshRequestsAction implements Runnable { * bucket, and then delete the requests in each bucket. */ void processRequests(Collection requests) { - int numPublishLocks = Registry.get(tld).getNumDnsPublishLocks(); + int numPublishLocks = Tld.get(tld).getNumDnsPublishLocks(); requests.stream() .collect( toImmutableSetMultimap( @@ -181,7 +181,7 @@ public final class ReadDnsRefreshRequestsAction implements Runnable { } ImmutableList domains = domainsBuilder.build(); ImmutableList hosts = hostsBuilder.build(); - for (String dnsWriter : Registry.get(tld).getDnsWriters()) { + for (String dnsWriter : Tld.get(tld).getDnsWriters()) { Task task = cloudTasksUtils.createPostTaskWithJitter( PublishDnsUpdatesAction.PATH, diff --git a/core/src/main/java/google/registry/export/ExportDomainListsAction.java b/core/src/main/java/google/registry/export/ExportDomainListsAction.java index 292bcb817..7d669261f 100644 --- a/core/src/main/java/google/registry/export/ExportDomainListsAction.java +++ b/core/src/main/java/google/registry/export/ExportDomainListsAction.java @@ -27,8 +27,8 @@ import com.google.common.flogger.FluentLogger; import com.google.common.net.MediaType; import google.registry.config.RegistryConfig.Config; import google.registry.gcs.GcsUtils; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.TldType; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldType; import google.registry.request.Action; import google.registry.request.auth.Auth; import google.registry.storage.drive.DriveConnection; @@ -106,27 +106,28 @@ public class ExportDomainListsAction implements Runnable { } protected static boolean exportToDrive( - String tld, String domains, DriveConnection driveConnection) { + String tldStr, String domains, DriveConnection driveConnection) { verifyNotNull(driveConnection, "Expecting non-null driveConnection"); try { - Registry registry = Registry.get(tld); - if (registry.getDriveFolderId() == null) { + Tld tld = Tld.get(tldStr); + if (tld.getDriveFolderId() == null) { logger.atInfo().log( "Skipping registered domains export for TLD %s because Drive folder isn't specified.", - tld); + tldStr); } else { String resultMsg = driveConnection.createOrUpdateFile( REGISTERED_DOMAINS_FILENAME, MediaType.PLAIN_TEXT_UTF_8, - registry.getDriveFolderId(), + tld.getDriveFolderId(), domains.getBytes(UTF_8)); logger.atInfo().log( - "Exporting registered domains succeeded for TLD %s, response was: %s", tld, resultMsg); + "Exporting registered domains succeeded for TLD %s, response was: %s", + tldStr, resultMsg); } } catch (Throwable e) { logger.atSevere().withCause(e).log( - "Error exporting registered domains for TLD %s to Drive, skipping...", tld); + "Error exporting registered domains for TLD %s to Drive, skipping...", tldStr); return false; } return true; diff --git a/core/src/main/java/google/registry/export/ExportPremiumTermsAction.java b/core/src/main/java/google/registry/export/ExportPremiumTermsAction.java index 1bc1f1c46..31ed8ebcd 100644 --- a/core/src/main/java/google/registry/export/ExportPremiumTermsAction.java +++ b/core/src/main/java/google/registry/export/ExportPremiumTermsAction.java @@ -29,7 +29,7 @@ import com.google.common.collect.Iterables; import com.google.common.flogger.FluentLogger; import com.google.common.net.MediaType; import google.registry.config.RegistryConfig.Config; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.tld.label.PremiumList.PremiumEntry; import google.registry.model.tld.label.PremiumListDao; import google.registry.request.Action; @@ -61,7 +61,10 @@ public class ExportPremiumTermsAction implements Runnable { @Config("premiumTermsExportDisclaimer") String exportDisclaimer; - @Inject @Parameter(RequestParameters.PARAM_TLD) String tld; + @Inject + @Parameter(RequestParameters.PARAM_TLD) + String tldStr; + @Inject Response response; @Inject @@ -88,59 +91,59 @@ public class ExportPremiumTermsAction implements Runnable { public void run() { response.setContentType(PLAIN_TEXT_UTF_8); try { - Registry registry = Registry.get(tld); - String resultMsg = checkConfig(registry).orElseGet(() -> exportPremiumTerms(registry)); + Tld tld = Tld.get(tldStr); + String resultMsg = checkConfig(tld).orElseGet(() -> exportPremiumTerms(tld)); response.setStatus(SC_OK); response.setPayload(resultMsg); } catch (Throwable e) { response.setStatus(SC_INTERNAL_SERVER_ERROR); response.setPayload(e.getMessage()); throw new RuntimeException( - String.format("Exception occurred while exporting premium terms for TLD %s.", tld), e); + String.format("Exception occurred while exporting premium terms for TLD %s.", tldStr), e); } } /** - * Checks if {@code registry} is properly configured to export premium terms. + * Checks if {@link Tld} is properly configured to export premium terms. * - * @return {@link Optional#empty()} if {@code registry} export may proceed. Otherwise returns an - * error message + * @return {@link Optional#empty()} if {@link Tld} export may proceed. Otherwise returns an error + * message */ - private Optional checkConfig(Registry registry) { - if (isNullOrEmpty(registry.getDriveFolderId())) { + private Optional checkConfig(Tld tld) { + if (isNullOrEmpty(tld.getDriveFolderId())) { logger.atInfo().log( - "Skipping premium terms export for TLD %s because Drive folder isn't specified.", tld); + "Skipping premium terms export for TLD %s because Drive folder isn't specified.", tldStr); return Optional.of("Skipping export because no Drive folder is associated with this TLD"); } - if (!registry.getPremiumListName().isPresent()) { - logger.atInfo().log("No premium terms to export for TLD '%s'.", tld); + if (!tld.getPremiumListName().isPresent()) { + logger.atInfo().log("No premium terms to export for TLD '%s'.", tldStr); return Optional.of("No premium lists configured"); } return Optional.empty(); } - private String exportPremiumTerms(Registry registry) { + private String exportPremiumTerms(Tld tld) { try { String fileId = driveConnection.createOrUpdateFile( PREMIUM_TERMS_FILENAME, EXPORT_MIME_TYPE, - registry.getDriveFolderId(), - getFormattedPremiumTerms(registry).getBytes(UTF_8)); + tld.getDriveFolderId(), + getFormattedPremiumTerms(tld).getBytes(UTF_8)); logger.atInfo().log( - "Exporting premium terms succeeded for TLD %s, file ID is: %s", tld, fileId); + "Exporting premium terms succeeded for TLD %s, file ID is: %s", tldStr, fileId); return fileId; } catch (IOException e) { throw new RuntimeException("Error exporting premium terms file to Drive.", e); } } - private String getFormattedPremiumTerms(Registry registry) { - checkState(registry.getPremiumListName().isPresent(), "%s does not have a premium list", tld); - String premiumListName = registry.getPremiumListName().get(); + private String getFormattedPremiumTerms(Tld tld) { + checkState(tld.getPremiumListName().isPresent(), "%s does not have a premium list", tldStr); + String premiumListName = tld.getPremiumListName().get(); checkState( PremiumListDao.getLatestRevision(premiumListName).isPresent(), - "Could not load premium list for " + tld); + "Could not load premium list for " + tldStr); SortedSet premiumTerms = PremiumListDao.loadAllPremiumEntries(premiumListName).stream() .map(PremiumEntry::toString) diff --git a/core/src/main/java/google/registry/export/ExportReservedTermsAction.java b/core/src/main/java/google/registry/export/ExportReservedTermsAction.java index 1df7890ae..c9588e447 100644 --- a/core/src/main/java/google/registry/export/ExportReservedTermsAction.java +++ b/core/src/main/java/google/registry/export/ExportReservedTermsAction.java @@ -23,7 +23,7 @@ import static javax.servlet.http.HttpServletResponse.SC_OK; import com.google.common.flogger.FluentLogger; import com.google.common.net.MediaType; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.request.Action; import google.registry.request.Parameter; import google.registry.request.RequestParameters; @@ -46,7 +46,11 @@ public class ExportReservedTermsAction implements Runnable { @Inject DriveConnection driveConnection; @Inject ExportUtils exportUtils; - @Inject @Parameter(RequestParameters.PARAM_TLD) String tld; + + @Inject + @Parameter(RequestParameters.PARAM_TLD) + String tldStr; + @Inject Response response; @Inject ExportReservedTermsAction() {} @@ -61,23 +65,25 @@ public class ExportReservedTermsAction implements Runnable { public void run() { response.setContentType(PLAIN_TEXT_UTF_8); try { - Registry registry = Registry.get(tld); + Tld tld = Tld.get(tldStr); String resultMsg; - if (registry.getReservedListNames().isEmpty() && isNullOrEmpty(registry.getDriveFolderId())) { + if (tld.getReservedListNames().isEmpty() && isNullOrEmpty(tld.getDriveFolderId())) { resultMsg = "No reserved lists configured"; - logger.atInfo().log("No reserved terms to export for TLD '%s'.", tld); - } else if (registry.getDriveFolderId() == null) { + logger.atInfo().log("No reserved terms to export for TLD '%s'.", tldStr); + } else if (tld.getDriveFolderId() == null) { resultMsg = "Skipping export because no Drive folder is associated with this TLD"; logger.atInfo().log( - "Skipping reserved terms export for TLD %s because Drive folder isn't specified.", tld); + "Skipping reserved terms export for TLD %s because Drive folder isn't specified.", + tldStr); } else { - resultMsg = driveConnection.createOrUpdateFile( - RESERVED_TERMS_FILENAME, - EXPORT_MIME_TYPE, - registry.getDriveFolderId(), - exportUtils.exportReservedTerms(registry).getBytes(UTF_8)); + resultMsg = + driveConnection.createOrUpdateFile( + RESERVED_TERMS_FILENAME, + EXPORT_MIME_TYPE, + tld.getDriveFolderId(), + exportUtils.exportReservedTerms(tld).getBytes(UTF_8)); logger.atInfo().log( - "Exporting reserved terms succeeded for TLD %s, response was: %s", tld, resultMsg); + "Exporting reserved terms succeeded for TLD %s, response was: %s", tldStr, resultMsg); } response.setStatus(SC_OK); response.setPayload(resultMsg); @@ -85,7 +91,8 @@ public class ExportReservedTermsAction implements Runnable { response.setStatus(SC_INTERNAL_SERVER_ERROR); response.setPayload(e.getMessage()); throw new RuntimeException( - String.format("Exception occurred while exporting reserved terms for TLD %s.", tld), e); + String.format("Exception occurred while exporting reserved terms for TLD %s.", tldStr), + e); } } } diff --git a/core/src/main/java/google/registry/export/ExportUtils.java b/core/src/main/java/google/registry/export/ExportUtils.java index bf007843f..9c6ccb244 100644 --- a/core/src/main/java/google/registry/export/ExportUtils.java +++ b/core/src/main/java/google/registry/export/ExportUtils.java @@ -16,7 +16,7 @@ package google.registry.export; import com.google.common.base.Joiner; import google.registry.config.RegistryConfig.Config; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.tld.label.ReservedList; import google.registry.model.tld.label.ReservedList.ReservedListEntry; import google.registry.model.tld.label.ReservedListDao; @@ -36,10 +36,10 @@ public final class ExportUtils { } /** Returns the file contents of the auto-export reserved terms document for the given TLD. */ - public String exportReservedTerms(Registry registry) { + public String exportReservedTerms(Tld tld) { StringBuilder termsBuilder = new StringBuilder(reservedTermsExportDisclaimer).append("\n"); Set reservedTerms = new TreeSet<>(); - for (String reservedListName : registry.getReservedListNames()) { + for (String reservedListName : tld.getReservedListNames()) { ReservedList reservedList = ReservedListDao.getLatestRevision(reservedListName) .orElseThrow( diff --git a/core/src/main/java/google/registry/flows/CheckApiAction.java b/core/src/main/java/google/registry/flows/CheckApiAction.java index e4d339a08..64a3248dd 100644 --- a/core/src/main/java/google/registry/flows/CheckApiAction.java +++ b/core/src/main/java/google/registry/flows/CheckApiAction.java @@ -46,7 +46,7 @@ import google.registry.flows.domain.DomainFlowUtils.BadCommandForRegistryPhaseEx import google.registry.flows.domain.DomainFlowUtils.InvalidIdnDomainLabelException; import google.registry.model.ForeignKeyUtils; import google.registry.model.domain.Domain; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.tld.label.ReservationType; import google.registry.monitoring.whitebox.CheckApiMetric; import google.registry.monitoring.whitebox.CheckApiMetric.Availability; @@ -116,9 +116,9 @@ public class CheckApiAction implements Runnable { validateDomainNameWithIdnTables(domainName); DateTime now = clock.nowUtc(); - Registry registry = Registry.get(domainName.parent().toString()); + Tld tld = Tld.get(domainName.parent().toString()); try { - verifyNotInPredelegation(registry, now); + verifyNotInPredelegation(tld, now); } catch (BadCommandForRegistryPhaseException e) { metricBuilder.status(INVALID_REGISTRY_PHASE); return fail("Check in this TLD is not allowed in the current registry phase"); diff --git a/core/src/main/java/google/registry/flows/custom/DomainPricingCustomLogic.java b/core/src/main/java/google/registry/flows/custom/DomainPricingCustomLogic.java index e701edb63..2b3916d31 100644 --- a/core/src/main/java/google/registry/flows/custom/DomainPricingCustomLogic.java +++ b/core/src/main/java/google/registry/flows/custom/DomainPricingCustomLogic.java @@ -23,7 +23,7 @@ import google.registry.flows.domain.DomainPricingLogic; import google.registry.flows.domain.FeesAndCredits; import google.registry.model.ImmutableObject; import google.registry.model.eppinput.EppInput; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import javax.annotation.Nullable; import org.joda.time.DateTime; @@ -81,7 +81,7 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic { public abstract FeesAndCredits feesAndCredits(); - public abstract Registry registry(); + public abstract Tld tld(); public abstract InternetDomainName domainName(); @@ -99,7 +99,7 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic { public abstract Builder setFeesAndCredits(FeesAndCredits feesAndCredits); - public abstract Builder setRegistry(Registry registry); + public abstract Builder setTld(Tld tld); public abstract Builder setDomainName(InternetDomainName domainName); @@ -117,7 +117,7 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic { public abstract FeesAndCredits feesAndCredits(); - public abstract Registry registry(); + public abstract Tld tld(); public abstract InternetDomainName domainName(); @@ -135,7 +135,7 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic { public abstract Builder setFeesAndCredits(FeesAndCredits feesAndCredits); - public abstract Builder setRegistry(Registry registry); + public abstract Builder setTld(Tld tld); public abstract Builder setDomainName(InternetDomainName domainName); @@ -153,7 +153,7 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic { public abstract FeesAndCredits feesAndCredits(); - public abstract Registry registry(); + public abstract Tld tld(); public abstract InternetDomainName domainName(); @@ -169,7 +169,7 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic { public abstract Builder setFeesAndCredits(FeesAndCredits feesAndCredits); - public abstract Builder setRegistry(Registry registry); + public abstract Builder setTld(Tld tld); public abstract Builder setDomainName(InternetDomainName domainName); @@ -185,7 +185,7 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic { public abstract FeesAndCredits feesAndCredits(); - public abstract Registry registry(); + public abstract Tld tld(); public abstract InternetDomainName domainName(); @@ -201,7 +201,7 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic { public abstract Builder setFeesAndCredits(FeesAndCredits feesAndCredits); - public abstract Builder setRegistry(Registry registry); + public abstract Builder setTld(Tld tld); public abstract Builder setDomainName(InternetDomainName domainName); @@ -217,7 +217,7 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic { public abstract FeesAndCredits feesAndCredits(); - public abstract Registry registry(); + public abstract Tld tld(); public abstract InternetDomainName domainName(); @@ -233,7 +233,7 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic { public abstract Builder setFeesAndCredits(FeesAndCredits feesAndCredits); - public abstract Builder setRegistry(Registry registry); + public abstract Builder setTld(Tld tld); public abstract Builder setDomainName(InternetDomainName domainName); diff --git a/core/src/main/java/google/registry/flows/domain/DomainCheckFlow.java b/core/src/main/java/google/registry/flows/domain/DomainCheckFlow.java index cde6ea441..96e692ef6 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainCheckFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainCheckFlow.java @@ -30,7 +30,7 @@ import static google.registry.flows.domain.DomainFlowUtils.isValidReservedCreate import static google.registry.flows.domain.DomainFlowUtils.validateDomainName; import static google.registry.flows.domain.DomainFlowUtils.validateDomainNameWithIdnTables; import static google.registry.flows.domain.DomainFlowUtils.verifyNotInPredelegation; -import static google.registry.model.tld.Registry.TldState.START_DATE_SUNRISE; +import static google.registry.model.tld.Tld.TldState.START_DATE_SUNRISE; import static google.registry.model.tld.label.ReservationType.getTypeOfHighestSeverity; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; @@ -77,8 +77,8 @@ import google.registry.model.eppoutput.CheckData.DomainCheckData; import google.registry.model.eppoutput.EppResponse; import google.registry.model.eppoutput.EppResponse.ResponseExtension; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.TldState; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldState; import google.registry.model.tld.label.ReservationType; import google.registry.persistence.VKey; import google.registry.util.Clock; @@ -164,7 +164,7 @@ public final class DomainCheckFlow implements Flow { if (tldFirstTimeSeen && !isSuperuser) { checkAllowedAccessToTld(registrarId, tld); checkHasBillingAccount(registrarId, tld); - verifyNotInPredelegation(Registry.get(tld), now); + verifyNotInPredelegation(Tld.get(tld), now); } } ImmutableMap parsedDomains = parsedDomainsBuilder.build(); @@ -190,7 +190,7 @@ public final class DomainCheckFlow implements Flow { ImmutableList.Builder checksBuilder = new ImmutableList.Builder<>(); ImmutableSet.Builder availableDomains = new ImmutableSet.Builder<>(); ImmutableMap tldStates = - Maps.toMap(seenTlds, tld -> Registry.get(tld).getTldState(now)); + Maps.toMap(seenTlds, tld -> Tld.get(tld).getTldState(now)); ImmutableMap domainCheckResults = tokenDomainCheckResults .map(AllocationTokenDomainCheckResults::domainCheckResults) @@ -278,7 +278,7 @@ public final class DomainCheckFlow implements Flow { for (String domainName : getDomainNamesToCheckForFee(feeCheckItem, domainNames.keySet())) { Optional defaultToken = DomainFlowUtils.checkForDefaultToken( - Registry.get(InternetDomainName.from(domainName).parent().toString()), + Tld.get(InternetDomainName.from(domainName).parent().toString()), domainName, feeCheckItem.getCommandName(), registrarId, @@ -313,7 +313,7 @@ public final class DomainCheckFlow implements Flow { | AllocationTokenNotInPromotionException e) { // Allocation token is either not an active token or it is not valid for the EPP command, // registrar, domain, or TLD. - Registry registry = Registry.get(InternetDomainName.from(domainName).parent().toString()); + Tld tld = Tld.get(InternetDomainName.from(domainName).parent().toString()); responseItems.add( builder .setDomainNameIfSupported(domainName) @@ -322,7 +322,7 @@ public final class DomainCheckFlow implements Flow { feeCheckItem.getCommandName(), feeCheckItem.getPhase(), feeCheckItem.getSubphase()) - .setCurrencyIfSupported(registry.getCurrency()) + .setCurrencyIfSupported(tld.getCurrency()) .setClass("token-not-supported") .build()); } diff --git a/core/src/main/java/google/registry/flows/domain/DomainClaimsCheckFlow.java b/core/src/main/java/google/registry/flows/domain/DomainClaimsCheckFlow.java index 814125ce2..22fc86885 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainClaimsCheckFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainClaimsCheckFlow.java @@ -45,7 +45,7 @@ import google.registry.model.eppinput.EppInput; import google.registry.model.eppinput.ResourceCommand; import google.registry.model.eppoutput.EppResponse; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.tmch.ClaimsListDao; import google.registry.util.Clock; import java.util.HashSet; @@ -96,16 +96,16 @@ public final class DomainClaimsCheckFlow implements Flow { for (String domainName : ImmutableSet.copyOf(domainNames)) { InternetDomainName parsedDomain = validateDomainName(domainName); validateDomainNameWithIdnTables(parsedDomain); - String tld = parsedDomain.parent().toString(); + String tldStr = parsedDomain.parent().toString(); // Only validate access to a TLD the first time it is encountered. - if (seenTlds.add(tld)) { + if (seenTlds.add(tldStr)) { if (!isSuperuser) { - checkAllowedAccessToTld(registrarId, tld); - checkHasBillingAccount(registrarId, tld); - Registry registry = Registry.get(tld); + checkAllowedAccessToTld(registrarId, tldStr); + checkHasBillingAccount(registrarId, tldStr); + Tld tld = Tld.get(tldStr); DateTime now = clock.nowUtc(); - verifyNotInPredelegation(registry, now); - verifyClaimsPeriodNotEnded(registry, now); + verifyNotInPredelegation(tld, now); + verifyClaimsPeriodNotEnded(tld, now); } } Optional claimKey = ClaimsListDao.get().getClaimKey(parsedDomain.parts().get(0)); diff --git a/core/src/main/java/google/registry/flows/domain/DomainCreateFlow.java b/core/src/main/java/google/registry/flows/domain/DomainCreateFlow.java index 97f8568b0..2e8843a38 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainCreateFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainCreateFlow.java @@ -47,9 +47,9 @@ import static google.registry.model.EppResourceUtils.createDomainRepoId; import static google.registry.model.IdService.allocateId; import static google.registry.model.eppcommon.StatusValue.SERVER_HOLD; import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_CREATE; -import static google.registry.model.tld.Registry.TldState.GENERAL_AVAILABILITY; -import static google.registry.model.tld.Registry.TldState.QUIET_PERIOD; -import static google.registry.model.tld.Registry.TldState.START_DATE_SUNRISE; +import static google.registry.model.tld.Tld.TldState.GENERAL_AVAILABILITY; +import static google.registry.model.tld.Tld.TldState.QUIET_PERIOD; +import static google.registry.model.tld.Tld.TldState.START_DATE_SUNRISE; import static google.registry.model.tld.label.ReservationType.NAME_COLLISION; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.util.DateTimeUtils.END_OF_TIME; @@ -112,9 +112,9 @@ import google.registry.model.reporting.DomainTransactionRecord.TransactionReport import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry.HistoryEntryId; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.TldState; -import google.registry.model.tld.Registry.TldType; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldState; +import google.registry.model.tld.Tld.TldType; import google.registry.model.tld.label.ReservationType; import google.registry.model.tmch.ClaimsList; import google.registry.model.tmch.ClaimsListDao; @@ -253,9 +253,9 @@ public final class DomainCreateFlow implements TransactionalFlow { // Validate that this is actually a legal domain name on a TLD that the registrar has access to. InternetDomainName domainName = validateDomainName(command.getDomainName()); String domainLabel = domainName.parts().get(0); - Registry registry = Registry.get(domainName.parent().toString()); - validateCreateCommandContactsAndNameservers(command, registry, domainName); - TldState tldState = registry.getTldState(now); + Tld tld = Tld.get(domainName.parent().toString()); + validateCreateCommandContactsAndNameservers(command, tld, domainName); + TldState tldState = tld.getTldState(now); Optional launchCreate = eppInput.getSingleExtension(LaunchCreateExtension.class); boolean hasSignedMarks = @@ -270,7 +270,7 @@ public final class DomainCreateFlow implements TransactionalFlow { Optional allocationToken = allocationTokenFlowUtils.verifyAllocationTokenCreateIfPresent( command, - registry, + tld, registrarId, now, eppInput.getSingleExtension(AllocationTokenExtension.class)); @@ -278,7 +278,7 @@ public final class DomainCreateFlow implements TransactionalFlow { if (!allocationToken.isPresent()) { allocationToken = DomainFlowUtils.checkForDefaultToken( - registry, command.getDomainName(), CommandName.CREATE, registrarId, now); + tld, command.getDomainName(), CommandName.CREATE, registrarId, now); if (allocationToken.isPresent()) { defaultTokenUsed = true; } @@ -291,12 +291,12 @@ public final class DomainCreateFlow implements TransactionalFlow { // notice without specifying a claims key, ignore the registry phase, and override blocks on // registering premium domains. if (!isSuperuser) { - checkAllowedAccessToTld(registrarId, registry.getTldStr()); - checkHasBillingAccount(registrarId, registry.getTldStr()); + checkAllowedAccessToTld(registrarId, tld.getTldStr()); + checkHasBillingAccount(registrarId, tld.getTldStr()); boolean isValidReservedCreate = isValidReservedCreate(domainName, allocationToken); ClaimsList claimsList = ClaimsListDao.get(); verifyIsGaOrSpecialCase( - registry, + tld, claimsList, now, domainLabel, @@ -305,15 +305,15 @@ public final class DomainCreateFlow implements TransactionalFlow { isValidReservedCreate, hasSignedMarks); if (launchCreate.isPresent()) { - verifyLaunchPhaseMatchesRegistryPhase(registry, launchCreate.get(), now); + verifyLaunchPhaseMatchesRegistryPhase(tld, launchCreate.get(), now); } if (!isAnchorTenant && !isValidReservedCreate) { verifyNotReserved(domainName, isSunriseCreate); } if (hasClaimsNotice) { - verifyClaimsPeriodNotEnded(registry, now); + verifyClaimsPeriodNotEnded(tld, now); } - if (now.isBefore(registry.getClaimsPeriodEnd())) { + if (now.isBefore(tld.getClaimsPeriodEnd())) { verifyClaimsNoticeIfAndOnlyIfNeeded( domainName, claimsList, hasSignedMarks, hasClaimsNotice); } @@ -338,20 +338,19 @@ public final class DomainCreateFlow implements TransactionalFlow { Optional feeCreate = eppInput.getSingleExtension(FeeCreateCommandExtension.class); FeesAndCredits feesAndCredits = - pricingLogic.getCreatePrice( - registry, targetId, now, years, isAnchorTenant, allocationToken); + pricingLogic.getCreatePrice(tld, targetId, now, years, isAnchorTenant, allocationToken); validateFeeChallenge(feeCreate, feesAndCredits, defaultTokenUsed); Optional secDnsCreate = validateSecDnsExtension(eppInput.getSingleExtension(SecDnsCreateExtension.class)); DateTime registrationExpirationTime = leapSafeAddYears(now, years); - String repoId = createDomainRepoId(allocateId(), registry.getTldStr()); + String repoId = createDomainRepoId(allocateId(), tld.getTldStr()); long historyRevisionId = allocateId(); HistoryEntryId domainHistoryId = new HistoryEntryId(repoId, historyRevisionId); historyBuilder.setRevisionId(historyRevisionId); // Bill for the create. BillingEvent.OneTime createBillingEvent = createOneTimeBillingEvent( - registry, + tld, isAnchorTenant, isSunriseCreate, isReserved(domainName, isSunriseCreate), @@ -414,7 +413,7 @@ public final class DomainCreateFlow implements TransactionalFlow { domain.asBuilder().setCurrentPackageToken(allocationToken.get().createVKey()).build(); } DomainHistory domainHistory = - buildDomainHistory(domain, registry, now, period, registry.getAddGracePeriodLength()); + buildDomainHistory(domain, tld, now, period, tld.getAddGracePeriodLength()); if (reservationTypes.contains(NAME_COLLISION)) { entitiesToSave.add( createNameCollisionOneTimePollMessage(targetId, domainHistory, registrarId, now)); @@ -493,7 +492,7 @@ public final class DomainCreateFlow implements TransactionalFlow { * non-superusers. */ private void verifyIsGaOrSpecialCase( - Registry registry, + Tld tld, ClaimsList claimsList, DateTime now, String domainLabel, @@ -505,7 +504,7 @@ public final class DomainCreateFlow implements TransactionalFlow { MustHaveSignedMarksInCurrentPhaseException, NoTrademarkedRegistrationsBeforeSunriseException { // We allow general registration during GA. - TldState currentState = registry.getTldState(now); + TldState currentState = tld.getTldState(now); if (currentState.equals(GENERAL_AVAILABILITY)) { return; } @@ -526,7 +525,7 @@ public final class DomainCreateFlow implements TransactionalFlow { // Trademarked domains cannot be registered until after the sunrise period has ended, unless // a valid signed mark is provided. Signed marks can only be provided during sunrise. // Thus, when bypassing TLD state checks, a post-sunrise state is always fine. - if (registry.getTldStateTransitions().headMap(now).containsValue(START_DATE_SUNRISE)) { + if (tld.getTldStateTransitions().headMap(now).containsValue(START_DATE_SUNRISE)) { return; } else { // If sunrise hasn't happened yet, trademarked domains are unavailable @@ -559,23 +558,22 @@ public final class DomainCreateFlow implements TransactionalFlow { } private DomainHistory buildDomainHistory( - Domain domain, Registry registry, DateTime now, Period period, Duration addGracePeriod) { + Domain domain, Tld tld, DateTime now, Period period, Duration addGracePeriod) { // We ignore prober transactions - if (registry.getTldType() == TldType.REAL) { - historyBuilder - .setDomainTransactionRecords( - ImmutableSet.of( - DomainTransactionRecord.create( - registry.getTldStr(), - now.plus(addGracePeriod), - TransactionReportField.netAddsFieldFromYears(period.getValue()), - 1))); + if (tld.getTldType() == TldType.REAL) { + historyBuilder.setDomainTransactionRecords( + ImmutableSet.of( + DomainTransactionRecord.create( + tld.getTldStr(), + now.plus(addGracePeriod), + TransactionReportField.netAddsFieldFromYears(period.getValue()), + 1))); } return historyBuilder.setType(DOMAIN_CREATE).setPeriod(period).setDomain(domain).build(); } private BillingEvent.OneTime createOneTimeBillingEvent( - Registry registry, + Tld tld, boolean isAnchorTenant, boolean isSunriseCreate, boolean isReserved, @@ -607,8 +605,8 @@ public final class DomainCreateFlow implements TransactionalFlow { .setBillingTime( now.plus( isAnchorTenant - ? registry.getAnchorTenantAddGracePeriodLength() - : registry.getAddGracePeriodLength())) + ? tld.getAnchorTenantAddGracePeriodLength() + : tld.getAddGracePeriodLength())) .setFlags(flagsBuilder.build()) .setDomainHistoryId(domainHistoryId) .build(); diff --git a/core/src/main/java/google/registry/flows/domain/DomainDeleteFlow.java b/core/src/main/java/google/registry/flows/domain/DomainDeleteFlow.java index f3be54dda..6a6e3b7b6 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainDeleteFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainDeleteFlow.java @@ -88,8 +88,8 @@ import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField; import google.registry.model.reporting.HistoryEntry.HistoryEntryId; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.TldType; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldType; import google.registry.model.transfer.TransferStatus; import java.util.Collections; import java.util.Optional; @@ -146,8 +146,8 @@ public final class DomainDeleteFlow implements TransactionalFlow { DateTime now = tm().getTransactionTime(); // Loads the target resource if it exists Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now); - Registry registry = Registry.get(existingDomain.getTld()); - verifyDeleteAllowed(existingDomain, registry, now); + Tld tld = Tld.get(existingDomain.getTld()); + verifyDeleteAllowed(existingDomain, tld, now); flowCustomLogic.afterValidation( AfterValidationParameters.newBuilder().setExistingDomain(existingDomain).build()); ImmutableSet.Builder entitiesToSave = new ImmutableSet.Builder<>(); @@ -160,8 +160,8 @@ public final class DomainDeleteFlow implements TransactionalFlow { builder = existingDomain.asBuilder(); } builder.setLastEppUpdateTime(now).setLastEppUpdateRegistrarId(registrarId); - Duration redemptionGracePeriodLength = registry.getRedemptionGracePeriodLength(); - Duration pendingDeleteLength = registry.getPendingDeleteLength(); + Duration redemptionGracePeriodLength = tld.getRedemptionGracePeriodLength(); + Duration pendingDeleteLength = tld.getPendingDeleteLength(); Optional domainDeleteSuperuserExtension = eppInput.getSingleExtension(DomainDeleteSuperuserExtension.class); if (domainDeleteSuperuserExtension.isPresent()) { @@ -249,7 +249,7 @@ public final class DomainDeleteFlow implements TransactionalFlow { Domain newDomain = builder.build(); DomainHistory domainHistory = - buildDomainHistory(newDomain, registry, now, durationUntilDelete, inAddGracePeriod); + buildDomainHistory(newDomain, tld, now, durationUntilDelete, inAddGracePeriod); handlePendingTransferOnDelete(existingDomain, newDomain, now, domainHistory); // Close the autorenew billing event and poll message. This may delete the poll message. Store // the updated recurring billing event, we'll need it later and can't reload it. @@ -289,14 +289,14 @@ public final class DomainDeleteFlow implements TransactionalFlow { .build(); } - private void verifyDeleteAllowed(Domain existingDomain, Registry registry, DateTime now) + private void verifyDeleteAllowed(Domain existingDomain, Tld tld, DateTime now) throws EppException { verifyNoDisallowedStatuses(existingDomain, DISALLOWED_STATUSES); verifyOptionalAuthInfo(authInfo, existingDomain); if (!isSuperuser) { verifyResourceOwnership(registrarId, existingDomain); - verifyNotInPredelegation(registry, now); - checkAllowedAccessToTld(registrarId, registry.getTld().toString()); + verifyNotInPredelegation(tld, now); + checkAllowedAccessToTld(registrarId, tld.getTld().toString()); } if (!existingDomain.getSubordinateHosts().isEmpty()) { throw new DomainToDeleteHasHostsException(); @@ -305,17 +305,18 @@ public final class DomainDeleteFlow implements TransactionalFlow { private DomainHistory buildDomainHistory( Domain domain, - Registry registry, + Tld tld, DateTime now, Duration durationUntilDelete, boolean inAddGracePeriod) { // We ignore prober transactions - if (registry.getTldType() == TldType.REAL) { - Duration maxGracePeriod = Collections.max( - ImmutableSet.of( - registry.getAddGracePeriodLength(), - registry.getAutoRenewGracePeriodLength(), - registry.getRenewGracePeriodLength())); + if (tld.getTldType() == TldType.REAL) { + Duration maxGracePeriod = + Collections.max( + ImmutableSet.of( + tld.getAddGracePeriodLength(), + tld.getAutoRenewGracePeriodLength(), + tld.getRenewGracePeriodLength())); ImmutableSet cancelledRecords = createCancelingRecords( domain, diff --git a/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java b/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java index 21ccf96c3..80755b98a 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java +++ b/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java @@ -28,10 +28,10 @@ import static com.google.common.collect.Sets.union; import static google.registry.model.domain.Domain.MAX_REGISTRATION_YEARS; import static google.registry.model.tld.Registries.findTldForName; import static google.registry.model.tld.Registries.getTlds; -import static google.registry.model.tld.Registry.TldState.GENERAL_AVAILABILITY; -import static google.registry.model.tld.Registry.TldState.PREDELEGATION; -import static google.registry.model.tld.Registry.TldState.QUIET_PERIOD; -import static google.registry.model.tld.Registry.TldState.START_DATE_SUNRISE; +import static google.registry.model.tld.Tld.TldState.GENERAL_AVAILABILITY; +import static google.registry.model.tld.Tld.TldState.PREDELEGATION; +import static google.registry.model.tld.Tld.TldState.QUIET_PERIOD; +import static google.registry.model.tld.Tld.TldState.START_DATE_SUNRISE; import static google.registry.model.tld.label.ReservationType.ALLOWED_IN_SUNRISE; import static google.registry.model.tld.label.ReservationType.FULLY_BLOCKED; import static google.registry.model.tld.label.ReservationType.NAME_COLLISION; @@ -124,9 +124,9 @@ import google.registry.model.registrar.Registrar.State; import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField; import google.registry.model.reporting.HistoryEntry.HistoryEntryId; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.TldState; -import google.registry.model.tld.Registry.TldType; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldState; +import google.registry.model.tld.Tld.TldType; import google.registry.model.tld.label.ReservationType; import google.registry.model.tld.label.ReservedList; import google.registry.model.tmch.ClaimsList; @@ -302,17 +302,17 @@ public class DomainFlowUtils { } /** Check if the registrar has the correct billing account map configured. */ - public static void checkHasBillingAccount(String registrarId, String tld) throws EppException { - Registry registry = Registry.get(tld); + public static void checkHasBillingAccount(String registrarId, String tldStr) throws EppException { + Tld tld = Tld.get(tldStr); // Don't enforce the billing account check on test (i.e. prober/OT&E) TLDs. - if (registry.getTldType() == TldType.TEST) { + if (tld.getTldType() == TldType.TEST) { return; } if (!Registrar.loadByRegistrarIdCached(registrarId) .get() .getBillingAccountMap() - .containsKey(registry.getCurrency())) { - throw new DomainFlowUtils.MissingBillingAccountMapException(registry.getCurrency()); + .containsKey(tld.getCurrency())) { + throw new DomainFlowUtils.MissingBillingAccountMapException(tld.getCurrency()); } } @@ -412,8 +412,7 @@ public class DomainFlowUtils { static void validateNameserversCountForTld(String tld, InternetDomainName domainName, int count) throws EppException { // For TLDs with a nameserver allow list, all domains must have at least 1 nameserver. - ImmutableSet tldNameserversAllowList = - Registry.get(tld).getAllowedFullyQualifiedHostNames(); + ImmutableSet tldNameserversAllowList = Tld.get(tld).getAllowedFullyQualifiedHostNames(); if (!tldNameserversAllowList.isEmpty() && count == 0) { throw new NameserversNotSpecifiedForTldWithNameserverAllowListException( domainName.toString()); @@ -470,7 +469,7 @@ public class DomainFlowUtils { static void validateRegistrantAllowedOnTld(String tld, String registrantContactId) throws RegistrantNotAllowedException { - ImmutableSet allowedRegistrants = Registry.get(tld).getAllowedRegistrantContactIds(); + ImmutableSet allowedRegistrants = Tld.get(tld).getAllowedRegistrantContactIds(); // Empty allow list or null registrantContactId are ignored. if (registrantContactId != null && !allowedRegistrants.isEmpty() @@ -481,7 +480,7 @@ public class DomainFlowUtils { static void validateNameserversAllowedOnTld(String tld, Set fullyQualifiedHostNames) throws EppException { - ImmutableSet allowedHostNames = Registry.get(tld).getAllowedFullyQualifiedHostNames(); + ImmutableSet allowedHostNames = Tld.get(tld).getAllowedFullyQualifiedHostNames(); Set hostnames = nullToEmpty(fullyQualifiedHostNames); if (!allowedHostNames.isEmpty()) { // Empty allow list is ignored. Set disallowedNameservers = difference(hostnames, allowedHostNames); @@ -514,13 +513,13 @@ public class DomainFlowUtils { domainName.parts().get(0), domainName.parent().toString()); } - /** Verifies that a launch extension's specified phase matches the specified registry's phase. */ + /** Verifies that a launch extension's specified phase matches the specified tld's phase. */ static void verifyLaunchPhaseMatchesRegistryPhase( - Registry registry, LaunchExtension launchExtension, DateTime now) throws EppException { + Tld tld, LaunchExtension launchExtension, DateTime now) throws EppException { if (!LAUNCH_PHASE_TO_TLD_STATES.containsKey(launchExtension.getPhase()) || !LAUNCH_PHASE_TO_TLD_STATES .get(launchExtension.getPhase()) - .contains(registry.getTldState(now))) { + .contains(tld.getTldState(now))) { // No launch operations are allowed during the quiet period or predelegation. throw new LaunchPhaseMismatchException(); } @@ -652,9 +651,9 @@ public class DomainFlowUtils { builder.setEffectiveDateIfSupported(now); } String domainNameString = domainName.toString(); - Registry registry = Registry.get(domainName.parent().toString()); + Tld tld = Tld.get(domainName.parent().toString()); int years = verifyUnitIsYears(feeRequest.getPeriod()).getValue(); - boolean isSunrise = (registry.getTldState(now) == START_DATE_SUNRISE); + boolean isSunrise = (tld.getTldState(now) == START_DATE_SUNRISE); if (feeRequest.getPhase() != null || feeRequest.getSubphase() != null) { throw new FeeChecksDontSupportPhasesException(); @@ -662,13 +661,13 @@ public class DomainFlowUtils { CurrencyUnit currency = feeRequest.getCurrency() != null ? feeRequest.getCurrency() : topLevelCurrency; - if ((currency != null) && !currency.equals(registry.getCurrency())) { + if ((currency != null) && !currency.equals(tld.getCurrency())) { throw new CurrencyUnitMismatchException(); } builder .setCommand(feeRequest.getCommandName(), feeRequest.getPhase(), feeRequest.getSubphase()) - .setCurrencyIfSupported(registry.getCurrency()) + .setCurrencyIfSupported(tld.getCurrency()) .setPeriod(feeRequest.getPeriod()); String feeClass = null; @@ -685,7 +684,7 @@ public class DomainFlowUtils { fees = pricingLogic .getCreatePrice( - registry, + tld, domainNameString, now, years, @@ -699,7 +698,7 @@ public class DomainFlowUtils { fees = pricingLogic .getRenewPrice( - registry, domainNameString, now, years, recurringBillingEvent, allocationToken) + tld, domainNameString, now, years, recurringBillingEvent, allocationToken) .getFees(); break; case RESTORE: @@ -717,7 +716,7 @@ public class DomainFlowUtils { // restore because they can't be restored in the first place. boolean isExpired = domain.isPresent() && domain.get().getRegistrationExpirationTime().isBefore(now); - fees = pricingLogic.getRestorePrice(registry, domainNameString, now, isExpired).getFees(); + fees = pricingLogic.getRestorePrice(tld, domainNameString, now, isExpired).getFees(); break; case TRANSFER: if (years != 1) { @@ -726,12 +725,12 @@ public class DomainFlowUtils { builder.setAvailIfSupported(true); fees = pricingLogic - .getTransferPrice(registry, domainNameString, now, recurringBillingEvent) + .getTransferPrice(tld, domainNameString, now, recurringBillingEvent) .getFees(); break; case UPDATE: builder.setAvailIfSupported(true); - fees = pricingLogic.getUpdatePrice(registry, domainNameString, now).getFees(); + fees = pricingLogic.getUpdatePrice(tld, domainNameString, now).getFees(); break; default: throw new UnknownFeeCommandException(feeRequest.getUnparsedCommandName()); @@ -742,7 +741,7 @@ public class DomainFlowUtils { // are returning any premium fees, but only if the fee class isn't already set (i.e. because // the domain is reserved, which overrides any other classes). boolean isNameCollisionInSunrise = - registry.getTldState(now).equals(START_DATE_SUNRISE) + tld.getTldState(now).equals(START_DATE_SUNRISE) && getReservationTypes(domainName).contains(NAME_COLLISION); boolean isPremium = fees.stream().anyMatch(BaseFee::isPremium); feeClass = @@ -993,7 +992,7 @@ public class DomainFlowUtils { } /** Check that the registry phase is not predelegation, during which some flows are forbidden. */ - public static void verifyNotInPredelegation(Registry registry, DateTime now) + public static void verifyNotInPredelegation(Tld registry, DateTime now) throws BadCommandForRegistryPhaseException { if (registry.getTldState(now) == PREDELEGATION) { throw new BadCommandForRegistryPhaseException(); @@ -1002,17 +1001,17 @@ public class DomainFlowUtils { /** Validate the contacts and nameservers specified in a domain create command. */ static void validateCreateCommandContactsAndNameservers( - Create command, Registry registry, InternetDomainName domainName) throws EppException { + Create command, Tld tld, InternetDomainName domainName) throws EppException { verifyNotInPendingDelete( command.getContacts(), command.getRegistrant(), command.getNameservers()); validateContactsHaveTypes(command.getContacts()); - String tld = registry.getTldStr(); - validateRegistrantAllowedOnTld(tld, command.getRegistrantContactId()); + String tldStr = tld.getTldStr(); + validateRegistrantAllowedOnTld(tldStr, command.getRegistrantContactId()); validateNoDuplicateContacts(command.getContacts()); validateRequiredContactsPresent(command.getRegistrant(), command.getContacts()); ImmutableSet hostNames = command.getNameserverHostNames(); - validateNameserversCountForTld(tld, domainName, hostNames.size()); - validateNameserversAllowedOnTld(tld, hostNames); + validateNameserversCountForTld(tldStr, domainName, hostNames.size()); + validateNameserversAllowedOnTld(tldStr, hostNames); } /** Validate the secDNS extension, if present. */ @@ -1061,10 +1060,9 @@ public class DomainFlowUtils { } /** Check that the claims period hasn't ended. */ - static void verifyClaimsPeriodNotEnded(Registry registry, DateTime now) - throws ClaimsPeriodEndedException { - if (isAtOrAfter(now, registry.getClaimsPeriodEnd())) { - throw new ClaimsPeriodEndedException(registry.getTldStr()); + static void verifyClaimsPeriodNotEnded(Tld tld, DateTime now) throws ClaimsPeriodEndedException { + if (isAtOrAfter(now, tld.getClaimsPeriodEnd())) { + throw new ClaimsPeriodEndedException(tld.getTldStr()); } } @@ -1202,19 +1200,15 @@ public class DomainFlowUtils { * token found on the TLD's default token list will be returned. */ public static Optional checkForDefaultToken( - Registry registry, - String domainName, - CommandName commandName, - String registrarId, - DateTime now) + Tld tld, String domainName, CommandName commandName, String registrarId, DateTime now) throws EppException { - if (isNullOrEmpty(registry.getDefaultPromoTokens())) { + if (isNullOrEmpty(tld.getDefaultPromoTokens())) { return Optional.empty(); } Map, Optional> tokens = - AllocationToken.getAll(registry.getDefaultPromoTokens()); + AllocationToken.getAll(tld.getDefaultPromoTokens()); ImmutableList> tokenList = - registry.getDefaultPromoTokens().stream() + tld.getDefaultPromoTokens().stream() .map(tokens::get) .filter(Optional::isPresent) .collect(toImmutableList()); diff --git a/core/src/main/java/google/registry/flows/domain/DomainPricingLogic.java b/core/src/main/java/google/registry/flows/domain/DomainPricingLogic.java index 937fe631f..ce1670ff8 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainPricingLogic.java +++ b/core/src/main/java/google/registry/flows/domain/DomainPricingLogic.java @@ -36,7 +36,7 @@ import google.registry.model.domain.fee.Fee; import google.registry.model.domain.token.AllocationToken; import google.registry.model.domain.token.AllocationToken.TokenBehavior; import google.registry.model.pricing.PremiumPricingEngine.DomainPrices; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import java.math.RoundingMode; import java.util.Optional; import javax.annotation.Nullable; @@ -66,14 +66,14 @@ public final class DomainPricingLogic { * applied to the first year. */ FeesAndCredits getCreatePrice( - Registry registry, + Tld tld, String domainName, DateTime dateTime, int years, boolean isAnchorTenant, Optional allocationToken) throws EppException { - CurrencyUnit currency = registry.getCurrency(); + CurrencyUnit currency = tld.getCurrency(); BaseFee createFeeOrCredit; // Domain create cost is always zero for anchor tenants @@ -88,7 +88,7 @@ public final class DomainPricingLogic { } // Create fees for the cost and the EAP fee, if any. - Fee eapFee = registry.getEapFeeFor(dateTime); + Fee eapFee = tld.getEapFeeFor(dateTime); FeesAndCredits.Builder feesBuilder = new FeesAndCredits.Builder().setCurrency(currency).addFeeOrCredit(createFeeOrCredit); // Don't charge anchor tenants EAP fees. @@ -100,7 +100,7 @@ public final class DomainPricingLogic { return customLogic.customizeCreatePrice( CreatePriceParameters.newBuilder() .setFeesAndCredits(feesBuilder.build()) - .setRegistry(registry) + .setTld(tld) .setDomainName(InternetDomainName.from(domainName)) .setAsOfDate(dateTime) .setYears(years) @@ -109,7 +109,7 @@ public final class DomainPricingLogic { /** Returns a new renewal cost for the pricer. */ public FeesAndCredits getRenewPrice( - Registry registry, + Tld tld, String domainName, DateTime dateTime, int years, @@ -150,7 +150,7 @@ public final class DomainPricingLogic { false, years, allocationToken, - Registry.get(getTldFromDomainName(domainName)).getStandardRenewCost(dateTime)); + Tld.get(getTldFromDomainName(domainName)).getStandardRenewCost(dateTime)); isRenewCostPremiumPrice = false; break; default: @@ -168,7 +168,7 @@ public final class DomainPricingLogic { .addFeeOrCredit( Fee.create(renewCost.getAmount(), FeeType.RENEW, isRenewCostPremiumPrice)) .build()) - .setRegistry(registry) + .setTld(tld) .setDomainName(InternetDomainName.from(domainName)) .setAsOfDate(dateTime) .setYears(years) @@ -176,15 +176,14 @@ public final class DomainPricingLogic { } /** Returns a new restore price for the pricer. */ - FeesAndCredits getRestorePrice( - Registry registry, String domainName, DateTime dateTime, boolean isExpired) + FeesAndCredits getRestorePrice(Tld tld, String domainName, DateTime dateTime, boolean isExpired) throws EppException { DomainPrices domainPrices = getPricesForDomainName(domainName, dateTime); FeesAndCredits.Builder feesAndCredits = new FeesAndCredits.Builder() - .setCurrency(registry.getCurrency()) + .setCurrency(tld.getCurrency()) .addFeeOrCredit( - Fee.create(registry.getStandardRestoreCost().getAmount(), FeeType.RESTORE, false)); + Fee.create(tld.getStandardRestoreCost().getAmount(), FeeType.RESTORE, false)); if (isExpired) { feesAndCredits.addFeeOrCredit( Fee.create( @@ -193,7 +192,7 @@ public final class DomainPricingLogic { return customLogic.customizeRestorePrice( RestorePriceParameters.newBuilder() .setFeesAndCredits(feesAndCredits.build()) - .setRegistry(registry) + .setTld(tld) .setDomainName(InternetDomainName.from(domainName)) .setAsOfDate(dateTime) .build()); @@ -201,34 +200,30 @@ public final class DomainPricingLogic { /** Returns a new transfer price for the pricer. */ FeesAndCredits getTransferPrice( - Registry registry, - String domainName, - DateTime dateTime, - @Nullable Recurring recurringBillingEvent) + Tld tld, String domainName, DateTime dateTime, @Nullable Recurring recurringBillingEvent) throws EppException { FeesAndCredits renewPrice = - getRenewPrice(registry, domainName, dateTime, 1, recurringBillingEvent, Optional.empty()); + getRenewPrice(tld, domainName, dateTime, 1, recurringBillingEvent, Optional.empty()); return customLogic.customizeTransferPrice( TransferPriceParameters.newBuilder() .setFeesAndCredits( new FeesAndCredits.Builder() - .setCurrency(registry.getCurrency()) + .setCurrency(tld.getCurrency()) .addFeeOrCredit( Fee.create( renewPrice.getRenewCost().getAmount(), FeeType.RENEW, renewPrice.hasAnyPremiumFees())) .build()) - .setRegistry(registry) + .setTld(tld) .setDomainName(InternetDomainName.from(domainName)) .setAsOfDate(dateTime) .build()); } /** Returns a new update price for the pricer. */ - FeesAndCredits getUpdatePrice(Registry registry, String domainName, DateTime dateTime) - throws EppException { - CurrencyUnit currency = registry.getCurrency(); + FeesAndCredits getUpdatePrice(Tld tld, String domainName, DateTime dateTime) throws EppException { + CurrencyUnit currency = tld.getCurrency(); BaseFee feeOrCredit = Fee.create(zeroInCurrency(currency), FeeType.UPDATE, false); return customLogic.customizeUpdatePrice( UpdatePriceParameters.newBuilder() @@ -237,7 +232,7 @@ public final class DomainPricingLogic { .setCurrency(currency) .setFeesAndCredits(feeOrCredit) .build()) - .setRegistry(registry) + .setTld(tld) .setDomainName(InternetDomainName.from(domainName)) .setAsOfDate(dateTime) .build()); diff --git a/core/src/main/java/google/registry/flows/domain/DomainRenewFlow.java b/core/src/main/java/google/registry/flows/domain/DomainRenewFlow.java index 76cca21f0..9fcec1b86 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainRenewFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainRenewFlow.java @@ -84,7 +84,7 @@ import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField; import google.registry.model.reporting.HistoryEntry.HistoryEntryId; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import java.util.Optional; import javax.inject.Inject; import org.joda.money.Money; @@ -173,12 +173,12 @@ public final class DomainRenewFlow implements TransactionalFlow { Renew command = (Renew) resourceCommand; // Loads the target resource if it exists Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now); - String tld = existingDomain.getTld(); - Registry registry = Registry.get(tld); + String tldStr = existingDomain.getTld(); + Tld tld = Tld.get(tldStr); Optional allocationToken = allocationTokenFlowUtils.verifyAllocationTokenIfPresent( existingDomain, - registry, + tld, registrarId, now, CommandName.RENEW, @@ -187,7 +187,7 @@ public final class DomainRenewFlow implements TransactionalFlow { if (!allocationToken.isPresent()) { allocationToken = DomainFlowUtils.checkForDefaultToken( - registry, existingDomain.getDomainName(), CommandName.RENEW, registrarId, now); + tld, existingDomain.getDomainName(), CommandName.RENEW, registrarId, now); if (allocationToken.isPresent()) { defaultTokenUsed = true; } @@ -207,7 +207,7 @@ public final class DomainRenewFlow implements TransactionalFlow { tm().loadByKey(existingDomain.getAutorenewBillingEvent()); FeesAndCredits feesAndCredits = pricingLogic.getRenewPrice( - Registry.get(existingDomain.getTld()), + Tld.get(existingDomain.getTld()), targetId, now, years, @@ -225,7 +225,7 @@ public final class DomainRenewFlow implements TransactionalFlow { // Bill for this explicit renew itself. BillingEvent.OneTime explicitRenewEvent = createRenewBillingEvent( - tld, feesAndCredits.getTotalCost(), years, domainHistoryId, allocationToken, now); + tldStr, feesAndCredits.getTotalCost(), years, domainHistoryId, allocationToken, now); // Create a new autorenew billing event and poll message starting at the new expiration time. BillingEvent.Recurring newAutorenewEvent = newAutorenewBillingEvent(existingDomain) @@ -255,8 +255,7 @@ public final class DomainRenewFlow implements TransactionalFlow { GracePeriodStatus.RENEW, existingDomain.getRepoId(), explicitRenewEvent)) .build(); DomainHistory domainHistory = - buildDomainHistory( - newDomain, now, command.getPeriod(), registry.getRenewGracePeriodLength()); + buildDomainHistory(newDomain, now, command.getPeriod(), tld.getRenewGracePeriodLength()); ImmutableSet.Builder entitiesToSave = new ImmutableSet.Builder<>(); entitiesToSave.add( newDomain, domainHistory, explicitRenewEvent, newAutorenewEvent, newAutorenewPollMessage); @@ -358,7 +357,7 @@ public final class DomainRenewFlow implements TransactionalFlow { .filter(t -> AllocationToken.TokenBehavior.DEFAULT.equals(t.getTokenBehavior())) .map(AllocationToken::createVKey) .orElse(null)) - .setBillingTime(now.plus(Registry.get(tld).getRenewGracePeriodLength())) + .setBillingTime(now.plus(Tld.get(tld).getRenewGracePeriodLength())) .setDomainHistoryId(domainHistoryId) .build(); } diff --git a/core/src/main/java/google/registry/flows/domain/DomainRestoreRequestFlow.java b/core/src/main/java/google/registry/flows/domain/DomainRestoreRequestFlow.java index e928b1131..3928b6df6 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainRestoreRequestFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainRestoreRequestFlow.java @@ -67,7 +67,7 @@ import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField; import google.registry.model.reporting.HistoryEntry.HistoryEntryId; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import java.util.Optional; import javax.inject.Inject; import org.joda.money.Money; @@ -141,8 +141,7 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow { Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now); boolean isExpired = existingDomain.getRegistrationExpirationTime().isBefore(now); FeesAndCredits feesAndCredits = - pricingLogic.getRestorePrice( - Registry.get(existingDomain.getTld()), targetId, now, isExpired); + pricingLogic.getRestorePrice(Tld.get(existingDomain.getTld()), targetId, now, isExpired); Optional feeUpdate = eppInput.getSingleExtension(FeeUpdateCommandExtension.class); verifyRestoreAllowed(command, existingDomain, feeUpdate, feesAndCredits, now); diff --git a/core/src/main/java/google/registry/flows/domain/DomainTransferApproveFlow.java b/core/src/main/java/google/registry/flows/domain/DomainTransferApproveFlow.java index f9eece8e6..2a8bcb5e1 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainTransferApproveFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainTransferApproveFlow.java @@ -64,7 +64,7 @@ import google.registry.model.poll.PollMessage; import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.HistoryEntry.HistoryEntryId; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.transfer.DomainTransferData; import google.registry.model.transfer.TransferStatus; import java.util.Optional; @@ -133,7 +133,7 @@ public final class DomainTransferApproveFlow implements TransactionalFlow { Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now); allocationTokenFlowUtils.verifyAllocationTokenIfPresent( existingDomain, - Registry.get(existingDomain.getTld()), + Tld.get(existingDomain.getTld()), registrarId, now, CommandName.TRANSFER, @@ -141,9 +141,9 @@ public final class DomainTransferApproveFlow implements TransactionalFlow { verifyOptionalAuthInfo(authInfo, existingDomain); verifyHasPendingTransfer(existingDomain); verifyResourceOwnership(registrarId, existingDomain); - String tld = existingDomain.getTld(); + String tldStr = existingDomain.getTld(); if (!isSuperuser) { - checkAllowedAccessToTld(registrarId, tld); + checkAllowedAccessToTld(registrarId, tldStr); } DomainTransferData transferData = existingDomain.getTransferData(); String gainingRegistrarId = transferData.getGainingRegistrarId(); @@ -166,7 +166,7 @@ public final class DomainTransferApproveFlow implements TransactionalFlow { .setCost( pricingLogic .getTransferPrice( - Registry.get(tld), + Tld.get(tldStr), targetId, transferData.getTransferRequestTime(), // When removing a domain from a package it should return to the @@ -175,7 +175,7 @@ public final class DomainTransferApproveFlow implements TransactionalFlow { hasPackageToken ? null : existingRecurring) .getRenewCost()) .setEventTime(now) - .setBillingTime(now.plus(Registry.get(tld).getTransferGracePeriodLength())) + .setBillingTime(now.plus(Tld.get(tldStr).getTransferGracePeriodLength())) .setDomainHistoryId(domainHistoryId) .build()); @@ -262,8 +262,8 @@ public final class DomainTransferApproveFlow implements TransactionalFlow { .setCurrentPackageToken(null) .build(); - Registry registry = Registry.get(existingDomain.getTld()); - DomainHistory domainHistory = buildDomainHistory(newDomain, registry, now, gainingRegistrarId); + Tld tld = Tld.get(existingDomain.getTld()); + DomainHistory domainHistory = buildDomainHistory(newDomain, tld, now, gainingRegistrarId); // Create a poll message for the gaining client. PollMessage gainingClientPollMessage = createGainingTransferPollMessage( @@ -286,12 +286,12 @@ public final class DomainTransferApproveFlow implements TransactionalFlow { } private DomainHistory buildDomainHistory( - Domain newDomain, Registry registry, DateTime now, String gainingRegistrarId) { + Domain newDomain, Tld tld, DateTime now, String gainingRegistrarId) { ImmutableSet cancelingRecords = createCancelingRecords( newDomain, now, - registry.getAutomaticTransferLength().plus(registry.getTransferGracePeriodLength()), + tld.getAutomaticTransferLength().plus(tld.getTransferGracePeriodLength()), ImmutableSet.of(TRANSFER_SUCCESSFUL)); return historyBuilder .setType(DOMAIN_TRANSFER_APPROVE) @@ -302,7 +302,7 @@ public final class DomainTransferApproveFlow implements TransactionalFlow { cancelingRecords, DomainTransactionRecord.create( newDomain.getTld(), - now.plus(registry.getTransferGracePeriodLength()), + now.plus(tld.getTransferGracePeriodLength()), TRANSFER_SUCCESSFUL, 1))) .build(); diff --git a/core/src/main/java/google/registry/flows/domain/DomainTransferCancelFlow.java b/core/src/main/java/google/registry/flows/domain/DomainTransferCancelFlow.java index 5249a655c..e5cd04efa 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainTransferCancelFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainTransferCancelFlow.java @@ -48,7 +48,7 @@ import google.registry.model.eppoutput.EppResponse; import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.HistoryEntry.HistoryEntryId; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.transfer.TransferStatus; import java.util.Optional; import javax.inject.Inject; @@ -100,7 +100,7 @@ public final class DomainTransferCancelFlow implements TransactionalFlow { if (!isSuperuser) { checkAllowedAccessToTld(registrarId, existingDomain.getTld()); } - Registry registry = Registry.get(existingDomain.getTld()); + Tld tld = Tld.get(existingDomain.getTld()); HistoryEntryId domainHistoryId = createHistoryEntryId(existingDomain); historyBuilder @@ -109,7 +109,7 @@ public final class DomainTransferCancelFlow implements TransactionalFlow { Domain newDomain = denyPendingTransfer(existingDomain, TransferStatus.CLIENT_CANCELLED, now, registrarId); - DomainHistory domainHistory = buildDomainHistory(newDomain, registry, now); + DomainHistory domainHistory = buildDomainHistory(newDomain, tld, now); tm().putAll( newDomain, domainHistory, @@ -128,12 +128,12 @@ public final class DomainTransferCancelFlow implements TransactionalFlow { .build(); } - private DomainHistory buildDomainHistory(Domain newDomain, Registry registry, DateTime now) { + private DomainHistory buildDomainHistory(Domain newDomain, Tld tld, DateTime now) { ImmutableSet cancelingRecords = createCancelingRecords( newDomain, now, - registry.getAutomaticTransferLength().plus(registry.getTransferGracePeriodLength()), + tld.getAutomaticTransferLength().plus(tld.getTransferGracePeriodLength()), ImmutableSet.of(TRANSFER_SUCCESSFUL)); return historyBuilder .setType(DOMAIN_TRANSFER_CANCEL) diff --git a/core/src/main/java/google/registry/flows/domain/DomainTransferRejectFlow.java b/core/src/main/java/google/registry/flows/domain/DomainTransferRejectFlow.java index 7f88b2756..c90555654 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainTransferRejectFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainTransferRejectFlow.java @@ -50,7 +50,7 @@ import google.registry.model.eppoutput.EppResponse; import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.HistoryEntry.HistoryEntryId; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.transfer.TransferStatus; import java.util.Optional; import javax.inject.Inject; @@ -94,7 +94,7 @@ public final class DomainTransferRejectFlow implements TransactionalFlow { extensionManager.validate(); DateTime now = tm().getTransactionTime(); Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now); - Registry registry = Registry.get(existingDomain.getTld()); + Tld tld = Tld.get(existingDomain.getTld()); HistoryEntryId domainHistoryId = createHistoryEntryId(existingDomain); historyBuilder .setRevisionId(domainHistoryId.getRevisionId()) @@ -108,7 +108,7 @@ public final class DomainTransferRejectFlow implements TransactionalFlow { } Domain newDomain = denyPendingTransfer(existingDomain, TransferStatus.CLIENT_REJECTED, now, registrarId); - DomainHistory domainHistory = buildDomainHistory(newDomain, registry, now); + DomainHistory domainHistory = buildDomainHistory(newDomain, tld, now); tm().putAll( newDomain, domainHistory, @@ -127,12 +127,12 @@ public final class DomainTransferRejectFlow implements TransactionalFlow { .build(); } - private DomainHistory buildDomainHistory(Domain newDomain, Registry registry, DateTime now) { + private DomainHistory buildDomainHistory(Domain newDomain, Tld tld, DateTime now) { ImmutableSet cancelingRecords = createCancelingRecords( newDomain, now, - registry.getAutomaticTransferLength().plus(registry.getTransferGracePeriodLength()), + tld.getAutomaticTransferLength().plus(tld.getTransferGracePeriodLength()), ImmutableSet.of(TRANSFER_SUCCESSFUL)); return historyBuilder .setType(DOMAIN_TRANSFER_REJECT) diff --git a/core/src/main/java/google/registry/flows/domain/DomainTransferRequestFlow.java b/core/src/main/java/google/registry/flows/domain/DomainTransferRequestFlow.java index 8a4439d58..b097a48cd 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainTransferRequestFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainTransferRequestFlow.java @@ -74,7 +74,7 @@ import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField; import google.registry.model.reporting.HistoryEntry.HistoryEntryId; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.transfer.DomainTransferData; import google.registry.model.transfer.TransferData.TransferServerApproveEntity; import google.registry.model.transfer.TransferResponse.DomainTransferResponse; @@ -171,7 +171,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow { Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now); allocationTokenFlowUtils.verifyAllocationTokenIfPresent( existingDomain, - Registry.get(existingDomain.getTld()), + Tld.get(existingDomain.getTld()), gainingClientId, now, CommandName.TRANSFER, @@ -184,8 +184,8 @@ public final class DomainTransferRequestFlow implements TransactionalFlow { : ((Transfer) resourceCommand).getPeriod(); verifyTransferAllowed(existingDomain, period, now, superuserExtension); - String tld = existingDomain.getTld(); - Registry registry = Registry.get(tld); + String tldStr = existingDomain.getTld(); + Tld tld = Tld.get(tldStr); // An optional extension from the client specifying what they think the transfer should cost. Optional feeTransfer = eppInput.getSingleExtension(FeeTransferCommandExtension.class); @@ -201,14 +201,14 @@ public final class DomainTransferRequestFlow implements TransactionalFlow { feesAndCredits = Optional.empty(); } else if (!existingDomain.getCurrentPackageToken().isPresent()) { feesAndCredits = - Optional.of(pricingLogic.getTransferPrice(registry, targetId, now, existingRecurring)); + Optional.of(pricingLogic.getTransferPrice(tld, targetId, now, existingRecurring)); } else { // If existing domain is in a package, calculate the transfer price with default renewal price // behavior feesAndCredits = period.getValue() == 0 ? Optional.empty() - : Optional.of(pricingLogic.getTransferPrice(registry, targetId, now, null)); + : Optional.of(pricingLogic.getTransferPrice(tld, targetId, now, null)); } if (feesAndCredits.isPresent()) { @@ -224,7 +224,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow { domainTransferRequestSuperuserExtension -> now.plusDays( domainTransferRequestSuperuserExtension.getAutomaticTransferLength())) - .orElseGet(() -> now.plus(registry.getAutomaticTransferLength())); + .orElseGet(() -> now.plus(tld.getAutomaticTransferLength())); // If the domain will be in the auto-renew grace period at the moment of transfer, the transfer // will subsume the autorenew, so we don't add the normal extra year from the transfer. // The gaining registrar is still billed for the extra year; the losing registrar will get a @@ -283,7 +283,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow { .setLastEppUpdateTime(now) .setLastEppUpdateRegistrarId(gainingClientId) .build(); - DomainHistory domainHistory = buildDomainHistory(newDomain, registry, now, period); + DomainHistory domainHistory = buildDomainHistory(newDomain, tld, now, period); asyncTaskEnqueuer.enqueueAsyncResave(newDomain.createVKey(), now, automaticTransferTime); tm().putAll( @@ -363,8 +363,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow { } } - private DomainHistory buildDomainHistory( - Domain newDomain, Registry registry, DateTime now, Period period) { + private DomainHistory buildDomainHistory(Domain newDomain, Tld tld, DateTime now, Period period) { return historyBuilder .setType(DOMAIN_TRANSFER_REQUEST) .setPeriod(period) @@ -372,9 +371,9 @@ public final class DomainTransferRequestFlow implements TransactionalFlow { .setDomainTransactionRecords( ImmutableSet.of( DomainTransactionRecord.create( - registry.getTldStr(), - now.plus(registry.getAutomaticTransferLength()) - .plus(registry.getTransferGracePeriodLength()), + tld.getTldStr(), + now.plus(tld.getAutomaticTransferLength()) + .plus(tld.getTransferGracePeriodLength()), TransactionReportField.TRANSFER_SUCCESSFUL, 1))) .build(); diff --git a/core/src/main/java/google/registry/flows/domain/DomainTransferUtils.java b/core/src/main/java/google/registry/flows/domain/DomainTransferUtils.java index c1c69b50c..a0d088dcb 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainTransferUtils.java +++ b/core/src/main/java/google/registry/flows/domain/DomainTransferUtils.java @@ -33,7 +33,7 @@ import google.registry.model.eppcommon.Trid; import google.registry.model.poll.PendingActionNotificationResponse.DomainPendingActionNotificationResponse; import google.registry.model.poll.PollMessage; import google.registry.model.reporting.HistoryEntry.HistoryEntryId; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.transfer.DomainTransferData; import google.registry.model.transfer.TransferData; import google.registry.model.transfer.TransferData.TransferServerApproveEntity; @@ -127,7 +127,7 @@ public final class DomainTransferUtils { .setTransferredRegistrationExpirationTime(serverApproveNewExpirationTime) .setTransferStatus(TransferStatus.SERVER_APPROVED) .build(); - Registry registry = Registry.get(existingDomain.getTld()); + Tld tld = Tld.get(existingDomain.getTld()); ImmutableSet.Builder builder = new ImmutableSet.Builder<>(); transferCost.ifPresent( cost -> @@ -137,7 +137,7 @@ public final class DomainTransferUtils { domainHistoryId, targetId, gainingRegistrarId, - registry, + tld, cost))); createOptionalAutorenewCancellation( automaticTransferTime, now, domainHistoryId, targetId, existingDomain, transferCost) @@ -308,7 +308,7 @@ public final class DomainTransferUtils { HistoryEntryId domainHistoryId, String targetId, String gainingRegistrarId, - Registry registry, + Tld registry, Money transferCost) { return new BillingEvent.OneTime.Builder() .setReason(Reason.TRANSFER) diff --git a/core/src/main/java/google/registry/flows/domain/DomainUpdateFlow.java b/core/src/main/java/google/registry/flows/domain/DomainUpdateFlow.java index 101e43807..3322d485b 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainUpdateFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainUpdateFlow.java @@ -86,7 +86,7 @@ import google.registry.model.eppoutput.EppResponse; import google.registry.model.poll.PendingActionNotificationResponse.DomainPendingActionNotificationResponse; import google.registry.model.poll.PollMessage; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import java.util.Objects; import java.util.Optional; import javax.inject.Inject; @@ -219,18 +219,18 @@ public final class DomainUpdateFlow implements TransactionalFlow { verifyOptionalAuthInfo(authInfo, existingDomain); AddRemove add = command.getInnerAdd(); AddRemove remove = command.getInnerRemove(); - String tld = existingDomain.getTld(); + String tldStr = existingDomain.getTld(); if (!isSuperuser) { verifyNoDisallowedStatuses(existingDomain, UPDATE_DISALLOWED_STATUSES); verifyResourceOwnership(registrarId, existingDomain); verifyClientUpdateNotProhibited(command, existingDomain); verifyAllStatusesAreClientSettable(union(add.getStatusValues(), remove.getStatusValues())); - checkAllowedAccessToTld(registrarId, tld); + checkAllowedAccessToTld(registrarId, tldStr); } - Registry registry = Registry.get(tld); + Tld tld = Tld.get(tldStr); Optional feeUpdate = eppInput.getSingleExtension(FeeUpdateCommandExtension.class); - FeesAndCredits feesAndCredits = pricingLogic.getUpdatePrice(registry, targetId, now); + FeesAndCredits feesAndCredits = pricingLogic.getUpdatePrice(tld, targetId, now); validateFeesAckedIfPresent(feeUpdate, feesAndCredits, false); verifyNotInPendingDelete( add.getContacts(), @@ -238,8 +238,8 @@ public final class DomainUpdateFlow implements TransactionalFlow { add.getNameservers()); validateContactsHaveTypes(add.getContacts()); validateContactsHaveTypes(remove.getContacts()); - validateRegistrantAllowedOnTld(tld, command.getInnerChange().getRegistrantContactId()); - validateNameserversAllowedOnTld(tld, add.getNameserverHostNames()); + validateRegistrantAllowedOnTld(tldStr, command.getInnerChange().getRegistrantContactId()); + validateNameserversAllowedOnTld(tldStr, add.getNameserverHostNames()); } private Domain performUpdate(Update command, Domain domain, DateTime now) throws EppException { @@ -338,7 +338,7 @@ public final class DomainUpdateFlow implements TransactionalFlow { .setReason(Reason.SERVER_STATUS) .setTargetId(targetId) .setRegistrarId(registrarId) - .setCost(Registry.get(existingDomain.getTld()).getServerStatusChangeCost()) + .setCost(Tld.get(existingDomain.getTld()).getServerStatusChangeCost()) .setEventTime(now) .setBillingTime(now) .setDomainHistory(historyEntry) diff --git a/core/src/main/java/google/registry/flows/domain/token/AllocationTokenCustomLogic.java b/core/src/main/java/google/registry/flows/domain/token/AllocationTokenCustomLogic.java index fdf6fba3b..fa928849f 100644 --- a/core/src/main/java/google/registry/flows/domain/token/AllocationTokenCustomLogic.java +++ b/core/src/main/java/google/registry/flows/domain/token/AllocationTokenCustomLogic.java @@ -22,7 +22,7 @@ import google.registry.flows.EppException; import google.registry.model.domain.Domain; import google.registry.model.domain.DomainCommand; import google.registry.model.domain.token.AllocationToken; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import org.joda.time.DateTime; /** @@ -36,7 +36,7 @@ public class AllocationTokenCustomLogic { public AllocationToken validateToken( DomainCommand.Create command, AllocationToken token, - Registry registry, + Tld tld, String registrarId, DateTime now) throws EppException { @@ -46,7 +46,7 @@ public class AllocationTokenCustomLogic { /** Performs additional custom logic for validating a token on an existing domain. */ public AllocationToken validateToken( - Domain domain, AllocationToken token, Registry registry, String registrarId, DateTime now) + Domain domain, AllocationToken token, Tld tld, String registrarId, DateTime now) throws EppException { // Do nothing. return token; diff --git a/core/src/main/java/google/registry/flows/domain/token/AllocationTokenFlowUtils.java b/core/src/main/java/google/registry/flows/domain/token/AllocationTokenFlowUtils.java index b78bc7935..812c8680b 100644 --- a/core/src/main/java/google/registry/flows/domain/token/AllocationTokenFlowUtils.java +++ b/core/src/main/java/google/registry/flows/domain/token/AllocationTokenFlowUtils.java @@ -37,7 +37,7 @@ import google.registry.model.domain.token.AllocationToken.TokenStatus; import google.registry.model.domain.token.AllocationToken.TokenType; import google.registry.model.domain.token.AllocationTokenExtension; import google.registry.model.reporting.HistoryEntry.HistoryEntryId; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.VKey; import java.util.List; import java.util.Optional; @@ -173,7 +173,7 @@ public class AllocationTokenFlowUtils { /** Verifies and returns the allocation token if one is specified, otherwise does nothing. */ public Optional verifyAllocationTokenCreateIfPresent( DomainCommand.Create command, - Registry registry, + Tld tld, String registrarId, DateTime now, Optional extension) @@ -188,14 +188,13 @@ public class AllocationTokenFlowUtils { CommandName.CREATE, registrarId, now); - return Optional.of( - tokenCustomLogic.validateToken(command, tokenEntity, registry, registrarId, now)); + return Optional.of(tokenCustomLogic.validateToken(command, tokenEntity, tld, registrarId, now)); } /** Verifies and returns the allocation token if one is specified, otherwise does nothing. */ public Optional verifyAllocationTokenIfPresent( Domain existingDomain, - Registry registry, + Tld tld, String registrarId, DateTime now, CommandName commandName, @@ -212,7 +211,7 @@ public class AllocationTokenFlowUtils { registrarId, now); return Optional.of( - tokenCustomLogic.validateToken(existingDomain, tokenEntity, registry, registrarId, now)); + tokenCustomLogic.validateToken(existingDomain, tokenEntity, tld, registrarId, now)); } public static void verifyTokenAllowedOnDomain( diff --git a/core/src/main/java/google/registry/model/EppResourceUtils.java b/core/src/main/java/google/registry/model/EppResourceUtils.java index a890ee15b..2f1f7bf40 100644 --- a/core/src/main/java/google/registry/model/EppResourceUtils.java +++ b/core/src/main/java/google/registry/model/EppResourceUtils.java @@ -35,7 +35,7 @@ import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.Host; import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntryDao; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.transfer.DomainTransferData; import google.registry.model.transfer.TransferData; import google.registry.model.transfer.TransferStatus; @@ -73,7 +73,7 @@ public final class EppResourceUtils { /** Returns the full domain repoId in the format HEX-TLD for the specified long id and tld. */ public static String createDomainRepoId(long repoId, String tld) { - return createRepoId(repoId, Registry.get(tld).getRoidSuffix()); + return createRepoId(repoId, Tld.get(tld).getRoidSuffix()); } /** Returns the full repoId in the format HEX-TLD for the specified long id and ROID suffix. */ diff --git a/core/src/main/java/google/registry/model/OteAccountBuilder.java b/core/src/main/java/google/registry/model/OteAccountBuilder.java index e70c6efdb..d8b062f8c 100644 --- a/core/src/main/java/google/registry/model/OteAccountBuilder.java +++ b/core/src/main/java/google/registry/model/OteAccountBuilder.java @@ -17,8 +17,8 @@ package google.registry.model; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import static com.google.common.collect.ImmutableList.toImmutableList; -import static google.registry.model.tld.Registry.TldState.GENERAL_AVAILABILITY; -import static google.registry.model.tld.Registry.TldState.START_DATE_SUNRISE; +import static google.registry.model.tld.Tld.TldState.GENERAL_AVAILABILITY; +import static google.registry.model.tld.Tld.TldState.START_DATE_SUNRISE; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.util.DateTimeUtils.START_OF_TIME; @@ -33,9 +33,9 @@ import google.registry.model.pricing.StaticPremiumListPricingEngine; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.RegistrarAddress; import google.registry.model.registrar.RegistrarPoc; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.TldState; -import google.registry.model.tld.Registry.TldType; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldState; +import google.registry.model.tld.Tld.TldType; import google.registry.model.tld.label.PremiumList; import google.registry.model.tld.label.PremiumListDao; import google.registry.persistence.VKey; @@ -121,9 +121,9 @@ public final class OteAccountBuilder { ImmutableMap.of(CurrencyUnit.USD, "123", CurrencyUnit.JPY, "456"); private final ImmutableMap registrarIdToTld; - private final Registry sunriseTld; - private final Registry gaTld; - private final Registry eapTld; + private final Tld sunriseTld; + private final Tld gaTld; + private final Tld eapTld; private final ImmutableList.Builder contactsBuilder = new ImmutableList.Builder<>(); private ImmutableList registrars; @@ -247,7 +247,7 @@ public final class OteAccountBuilder { /** Saves all the OT&E entities we created. */ private void saveAllEntities() { // use ImmutableObject instead of Registry so that the Key generation doesn't break - ImmutableList registries = ImmutableList.of(sunriseTld, gaTld, eapTld); + ImmutableList registries = ImmutableList.of(sunriseTld, gaTld, eapTld); ImmutableList contacts = contactsBuilder.build(); tm().transact( @@ -255,8 +255,7 @@ public final class OteAccountBuilder { if (!replaceExisting) { ImmutableList> keys = Streams.concat( - registries.stream() - .map(registry -> Registry.createVKey(registry.getTldStr())), + registries.stream().map(tld -> Tld.createVKey(tld.getTldStr())), registrars.stream().map(Registrar::createVKey), contacts.stream().map(RegistrarPoc::createVKey)) .collect(toImmutableList()); @@ -291,16 +290,13 @@ public final class OteAccountBuilder { .build(); } - private static Registry createTld( - String tldName, - TldState initialTldState, - boolean isEarlyAccess, - int roidSuffix) { + private static Tld createTld( + String tldName, TldState initialTldState, boolean isEarlyAccess, int roidSuffix) { String tldNameAlphaNumerical = tldName.replaceAll("[^a-z\\d]", ""); Optional premiumList = PremiumListDao.getLatestRevision(DEFAULT_PREMIUM_LIST); checkState(premiumList.isPresent(), "Couldn't find premium list %s.", DEFAULT_PREMIUM_LIST); - Registry.Builder builder = - new Registry.Builder() + Tld.Builder builder = + new Tld.Builder() .setTldStr(tldName) .setPremiumPricingEngine(StaticPremiumListPricingEngine.NAME) .setTldStateTransitions(ImmutableSortedMap.of(START_OF_TIME, initialTldState)) diff --git a/core/src/main/java/google/registry/model/common/Cursor.java b/core/src/main/java/google/registry/model/common/Cursor.java index 63a1e7c6c..eb5cc3bd6 100644 --- a/core/src/main/java/google/registry/model/common/Cursor.java +++ b/core/src/main/java/google/registry/model/common/Cursor.java @@ -22,7 +22,7 @@ import google.registry.model.ImmutableObject; import google.registry.model.UnsafeSerializable; import google.registry.model.UpdateAutoTimestampEntity; import google.registry.model.common.Cursor.CursorId; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.VKey; import java.util.Optional; import javax.persistence.AttributeOverride; @@ -134,7 +134,7 @@ public class Cursor extends UpdateAutoTimestampEntity { return createVKey(type, GLOBAL); } - public static VKey createScopedVKey(CursorType type, Registry tld) { + public static VKey createScopedVKey(CursorType type, Tld tld) { return createVKey(type, tld.getTldStr()); } @@ -172,8 +172,8 @@ public class Cursor extends UpdateAutoTimestampEntity { return create(cursorType, cursorTime, GLOBAL); } - /** Creates a new cursor instance with a given {@link Registry} scope. */ - public static Cursor createScoped(CursorType cursorType, DateTime cursorTime, Registry scope) { + /** Creates a new cursor instance with a given {@link Tld} scope. */ + public static Cursor createScoped(CursorType cursorType, DateTime cursorTime, Tld scope) { checkNotNull(scope, "Cursor scope cannot be null"); return create(cursorType, cursorTime, scope.getTldStr()); } diff --git a/core/src/main/java/google/registry/model/domain/DomainBase.java b/core/src/main/java/google/registry/model/domain/DomainBase.java index 8777931fe..2e527c85f 100644 --- a/core/src/main/java/google/registry/model/domain/DomainBase.java +++ b/core/src/main/java/google/registry/model/domain/DomainBase.java @@ -56,7 +56,7 @@ import google.registry.model.host.Host; import google.registry.model.poll.PollMessage; import google.registry.model.poll.PollMessage.Autorenew; import google.registry.model.poll.PollMessage.OneTime; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.transfer.DomainTransferData; import google.registry.model.transfer.TransferStatus; import google.registry.persistence.VKey; @@ -488,7 +488,7 @@ public class DomainBase extends EppResource GracePeriodStatus.TRANSFER, domain.getRepoId(), transferExpirationTime.plus( - Registry.get(domain.getTld()).getTransferGracePeriodLength()), + Tld.get(domain.getTld()).getTransferGracePeriodLength()), transferData.getGainingRegistrarId(), transferData.getServerApproveBillingEvent()))); } else { @@ -523,8 +523,7 @@ public class DomainBase extends EppResource GracePeriod.createForRecurring( GracePeriodStatus.AUTO_RENEW, domain.getRepoId(), - lastAutorenewTime.plus( - Registry.get(domain.getTld()).getAutoRenewGracePeriodLength()), + lastAutorenewTime.plus(Tld.get(domain.getTld()).getAutoRenewGracePeriodLength()), domain.getCurrentSponsorRegistrarId(), domain.getAutorenewBillingEvent())); newLastEppUpdateTime = Optional.of(lastAutorenewTime); diff --git a/core/src/main/java/google/registry/model/pricing/StaticPremiumListPricingEngine.java b/core/src/main/java/google/registry/model/pricing/StaticPremiumListPricingEngine.java index f1babe964..a3e40c12c 100644 --- a/core/src/main/java/google/registry/model/pricing/StaticPremiumListPricingEngine.java +++ b/core/src/main/java/google/registry/model/pricing/StaticPremiumListPricingEngine.java @@ -18,7 +18,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import static google.registry.util.DomainNameUtils.getTldFromDomainName; import com.google.common.net.InternetDomainName; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.tld.label.PremiumListDao; import java.util.Optional; import javax.inject.Inject; @@ -35,14 +35,14 @@ public final class StaticPremiumListPricingEngine implements PremiumPricingEngin @Override public DomainPrices getDomainPrices(String domainName, DateTime priceTime) { - String tld = getTldFromDomainName(domainName); + String tldStr = getTldFromDomainName(domainName); String label = InternetDomainName.from(domainName).parts().get(0); - Registry registry = Registry.get(checkNotNull(tld, "tld")); + Tld tld = Tld.get(checkNotNull(tldStr, "tld")); Optional premiumPrice = - registry.getPremiumListName().flatMap(pl -> PremiumListDao.getPremiumPrice(pl, label)); + tld.getPremiumListName().flatMap(pl -> PremiumListDao.getPremiumPrice(pl, label)); return DomainPrices.create( premiumPrice.isPresent(), - premiumPrice.orElse(registry.getStandardCreateCost()), - premiumPrice.orElse(registry.getStandardRenewCost(priceTime))); + premiumPrice.orElse(tld.getStandardCreateCost()), + premiumPrice.orElse(tld.getStandardRenewCost(priceTime))); } } diff --git a/core/src/main/java/google/registry/model/registrar/Registrar.java b/core/src/main/java/google/registry/model/registrar/Registrar.java index 577aca356..5a55f0144 100644 --- a/core/src/main/java/google/registry/model/registrar/Registrar.java +++ b/core/src/main/java/google/registry/model/registrar/Registrar.java @@ -57,8 +57,8 @@ import google.registry.model.JsonMapBuilder; import google.registry.model.Jsonifiable; import google.registry.model.UpdateAutoTimestamp; import google.registry.model.UpdateAutoTimestampEntity; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.TldType; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldType; import google.registry.persistence.VKey; import google.registry.util.CidrAddressBlock; import java.security.cert.CertificateParsingException; @@ -723,11 +723,11 @@ public class Registrar extends UpdateAutoTimestampEntity implements Buildable, J * to set the allowed TLDs. */ public Builder setAllowedTldsUncached(Set allowedTlds) { - ImmutableSet> newTldKeys = + ImmutableSet> newTldKeys = Sets.difference(allowedTlds, getInstance().getAllowedTlds()).stream() - .map(Registry::createVKey) + .map(Tld::createVKey) .collect(toImmutableSet()); - Set> missingTldKeys = + Set> missingTldKeys = Sets.difference( newTldKeys, tm().transact(() -> tm().loadByKeysIfPresent(newTldKeys)).keySet()); checkArgument(missingTldKeys.isEmpty(), "Trying to set nonexistent TLDs: %s", missingTldKeys); @@ -903,10 +903,10 @@ public class Registrar extends UpdateAutoTimestampEntity implements Buildable, J // In order to grant access to real TLDs, the registrar must have a corresponding billing // account ID for that TLD's billing currency. ImmutableSet nonBillableTlds = - Registry.get(getInstance().getAllowedTlds()).stream() + Tld.get(getInstance().getAllowedTlds()).stream() .filter(r -> r.getTldType() == TldType.REAL) .filter(r -> !getInstance().getBillingAccountMap().containsKey(r.getCurrency())) - .map(Registry::getTldStr) + .map(Tld::getTldStr) .collect(toImmutableSet()); checkArgument( nonBillableTlds.isEmpty(), diff --git a/core/src/main/java/google/registry/model/tld/Registries.java b/core/src/main/java/google/registry/model/tld/Registries.java index 4bb2e7262..8d40a87fb 100644 --- a/core/src/main/java/google/registry/model/tld/Registries.java +++ b/core/src/main/java/google/registry/model/tld/Registries.java @@ -32,14 +32,14 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; import com.google.common.collect.Streams; import com.google.common.net.InternetDomainName; -import google.registry.model.tld.Registry.TldType; +import google.registry.model.tld.Tld.TldType; import google.registry.util.DomainNameUtils; import java.util.Optional; import java.util.function.Supplier; import java.util.stream.Stream; import javax.persistence.EntityManager; -/** Utilities for finding and listing {@link Registry} entities. */ +/** Utilities for finding and listing {@link Tld} entities. */ public final class Registries { private Registries() {} @@ -85,8 +85,8 @@ public final class Registries { } /** Returns the Registry entities themselves of the given type loaded fresh from the database. */ - public static ImmutableSet getTldEntitiesOfType(TldType type) { - return Registry.get(filterValues(cache.get(), equalTo(type)).keySet()); + public static ImmutableSet getTldEntitiesOfType(TldType type) { + return Tld.get(filterValues(cache.get(), equalTo(type)).keySet()); } /** Pass-through check that the specified TLD exists, otherwise throw an IAE. */ diff --git a/core/src/main/java/google/registry/model/tld/Registry.java b/core/src/main/java/google/registry/model/tld/Tld.java similarity index 91% rename from core/src/main/java/google/registry/model/tld/Registry.java rename to core/src/main/java/google/registry/model/tld/Tld.java index 85ac28f11..e115658f6 100644 --- a/core/src/main/java/google/registry/model/tld/Registry.java +++ b/core/src/main/java/google/registry/model/tld/Tld.java @@ -76,12 +76,12 @@ import org.joda.time.DateTime; import org.joda.time.Duration; /** Persisted per-TLD configuration data. */ -@Entity(name = "Tld") -public class Registry extends ImmutableObject implements Buildable, UnsafeSerializable { +@Entity +public class Tld extends ImmutableObject implements Buildable, UnsafeSerializable { /** - * The canonical string representation of the TLD associated with this {@link Registry}, which is - * the standard ASCII for regular TLDs and punycoded ASCII for IDN TLDs. + * The canonical string representation of the TLD associated with this {@link Tld}, which is the + * standard ASCII for regular TLDs and punycoded ASCII for IDN TLDs. */ @Id @Column(name = "tld_name", nullable = false) @@ -132,7 +132,7 @@ public class Registry extends ImmutableObject implements Buildable, UnsafeSerial */ public enum TldState { - /** The state of not yet being delegated to this registry in the root zone by IANA. */ + /** The state of not yet being delegated to this TLD in the root zone by IANA. */ PREDELEGATION, /** @@ -158,19 +158,19 @@ public class Registry extends ImmutableObject implements Buildable, UnsafeSerial PDT } - /** Returns the registry for a given TLD, throwing if none exists. */ - public static Registry get(String tld) { - Registry maybeRegistry = CACHE.get(tld); - if (maybeRegistry == null) { - throw new RegistryNotFoundException(tld); + /** Returns the TLD for a given TLD, throwing if none exists. */ + public static Tld get(String tld) { + Tld maybeTld = CACHE.get(tld); + if (maybeTld == null) { + throw new TldNotFoundException(tld); } else { - return maybeRegistry; + return maybeTld; } } - /** Returns the registry entities for the given TLD strings, throwing if any don't exist. */ - public static ImmutableSet get(Set tlds) { - Map registries = CACHE.getAll(tlds); + /** Returns the TLD entities for the given TLD strings, throwing if any don't exist. */ + public static ImmutableSet get(Set tlds) { + Map registries = CACHE.getAll(tlds); ImmutableSet missingRegistries = registries.entrySet().stream() .filter(e -> e.getValue() == null) @@ -179,48 +179,48 @@ public class Registry extends ImmutableObject implements Buildable, UnsafeSerial if (missingRegistries.isEmpty()) { return registries.values().stream().collect(toImmutableSet()); } else { - throw new RegistryNotFoundException(missingRegistries); + throw new TldNotFoundException(missingRegistries); } } /** * Invalidates the cache entry. * - *

This is called automatically when the registry is saved. One should also call it when a - * registry is deleted. + *

This is called automatically when the tld is saved. One should also call it when a tld is + * deleted. */ @PostPersist public void invalidateInCache() { CACHE.invalidate(tldStr); } - /** A cache that loads the {@link Registry} for a given tld. */ - private static final LoadingCache CACHE = + /** A cache that loads the {@link Tld} for a given tld. */ + private static final LoadingCache CACHE = CacheUtils.newCacheBuilder(getSingletonCacheRefreshDuration()) .build( - new CacheLoader() { + new CacheLoader() { @Override - public Registry load(final String tld) { + public Tld load(final String tld) { return tm().transact(() -> tm().loadByKeyIfPresent(createVKey(tld))).orElse(null); } @Override - public Map loadAll(Iterable tlds) { - ImmutableMap> keysMap = - toMap(ImmutableSet.copyOf(tlds), Registry::createVKey); - Map, Registry> entities = + public Map loadAll(Iterable tlds) { + ImmutableMap> keysMap = + toMap(ImmutableSet.copyOf(tlds), Tld::createVKey); + Map, Tld> entities = tm().transact(() -> tm().loadByKeysIfPresent(keysMap.values())); return Maps.transformEntries(keysMap, (k, v) -> entities.getOrDefault(v, null)); } }); - public static VKey createVKey(String tld) { - return VKey.create(Registry.class, tld); + public static VKey createVKey(String tld) { + return VKey.create(Tld.class, tld); } @Override - public VKey createVKey() { - return VKey.create(Registry.class, tldStr); + public VKey createVKey() { + return VKey.create(Tld.class, tldStr); } /** @@ -248,7 +248,7 @@ public class Registry extends ImmutableObject implements Buildable, UnsafeSerial /** * The number of locks we allow at once for {@link google.registry.dns.PublishDnsUpdatesAction}. * - *

This should always be a positive integer -- use 1 for TLD-wide locks. All {@link Registry} + *

This should always be a positive integer -- use 1 for TLD-wide locks. All {@link Tld} * objects have this value default to 1. * *

WARNING: changing this parameter changes the lock name for subsequent DNS updates, and thus @@ -259,7 +259,7 @@ public class Registry extends ImmutableObject implements Buildable, UnsafeSerial *

    *
  1. Pause the DNS queue via {@link google.registry.tools.UpdateTldCommand} *
  2. Change this number - *
  3. Let the Registry caches expire (currently 5 minutes) and drain the DNS publish queue + *
  4. Let the Tld caches expire (currently 5 minutes) and drain the DNS publish queue *
  5. Unpause the DNS queue *
* @@ -297,7 +297,7 @@ public class Registry extends ImmutableObject implements Buildable, UnsafeSerial */ Duration dnsDsTtl; /** - * The unicode-aware representation of the TLD associated with this {@link Registry}. + * The unicode-aware representation of the TLD associated with this {@link Tld}. * *

This will be equal to {@link #tldStr} for ASCII TLDs, but will be non-ASCII for IDN TLDs. We * store this in a field so that it will be retained upon import into BigQuery. @@ -335,7 +335,7 @@ public class Registry extends ImmutableObject implements Buildable, UnsafeSerial @Column(nullable = false) CreateAutoTimestamp creationTime = CreateAutoTimestamp.create(null); - /** The set of reserved list names that are applicable to this registry. */ + /** The set of reserved list names that are applicable to this tld. */ @Column(name = "reserved_list_names") Set reservedListNames; @@ -344,8 +344,8 @@ public class Registry extends ImmutableObject implements Buildable, UnsafeSerial * *

This set contains only the names of the list and not a reference to the lists. Updates to a * reserved list in Cloud SQL are saved as a new ReservedList entity. When using the ReservedList - * for a registry, the database should be queried for the entity with this name that has the - * largest revision ID. + * for a tld, the database should be queried for the entity with this name that has the largest + * revision ID. */ public ImmutableSet getReservedListNames() { return nullToEmptyImmutableCopy(reservedListNames); @@ -355,9 +355,8 @@ public class Registry extends ImmutableObject implements Buildable, UnsafeSerial * The name of the {@link PremiumList} for this TLD, if there is one. * *

This is only the name of the list and not a reference to the list. Updates to the premium - * list in Cloud SQL are saved as a new PremiumList entity. When using the PremiumList for a - * registry, the database should be queried for the entity with this name that has the largest - * revision ID. + * list in Cloud SQL are saved as a new PremiumList entity. When using the PremiumList for a tld, + * the database should be queried for the entity with this name that has the largest revision ID. */ @Column(name = "premium_list_name") String premiumListName; @@ -591,8 +590,8 @@ public class Registry extends ImmutableObject implements Buildable, UnsafeSerial } /** - * Returns the add-on cost of a domain restore (the flat registry-wide fee charged in addition to - * one year of renewal for that name). + * Returns the add-on cost of a domain restore (the flat tld-wide fee charged in addition to one + * year of renewal for that name). */ public Money getStandardRestoreCost() { return restoreBillingCost; @@ -625,7 +624,7 @@ public class Registry extends ImmutableObject implements Buildable, UnsafeSerial return renewBillingCostTransitions.toValueMap(); } - /** Returns the EAP fee for the registry at the given time. */ + /** Returns the EAP fee for the tld at the given time. */ public Fee getEapFeeFor(DateTime now) { ImmutableSortedMap valueMap = getEapFeeScheduleAsMap(); DateTime periodStart = valueMap.floorKey(now); @@ -707,11 +706,11 @@ public class Registry extends ImmutableObject implements Buildable, UnsafeSerial return new Builder(clone(this)); } - /** A builder for constructing {@link Registry} objects, since they are immutable. */ - public static class Builder extends Buildable.Builder { + /** A builder for constructing {@link Tld} objects, since they are immutable. */ + public static class Builder extends Buildable.Builder { public Builder() {} - private Builder(Registry instance) { + private Builder(Tld instance) { super(instance); } @@ -1006,8 +1005,8 @@ public class Registry extends ImmutableObject implements Buildable, UnsafeSerial } @Override - public Registry build() { - final Registry instance = getInstance(); + public Tld build() { + final Tld instance = getInstance(); // Pick up the name of the associated TLD from the instance object. String tldName = instance.tldStr; checkArgument(tldName != null, "No registry TLD specified"); @@ -1019,7 +1018,7 @@ public class Registry extends ImmutableObject implements Buildable, UnsafeSerial // Check the validity of all TimedTransitionProperties to ensure that they have values for // START_OF_TIME. The setters above have already checked this for new values, but also check // 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 Registry in an invalid state. + // and cloned it into a new builder, to block re-building a Tld in an invalid state. instance.tldStateTransitions.checkValidity(); instance.renewBillingCostTransitions.checkValidity(); instance.eapFeeSchedule.checkValidity(); @@ -1027,24 +1026,24 @@ public class Registry extends ImmutableObject implements Buildable, UnsafeSerial checkArgumentNotNull(instance.getCurrency(), "Currency must be set"); checkArgument( instance.getStandardCreateCost().getCurrencyUnit().equals(instance.currency), - "Create cost must be in the registry's currency"); + "Create cost must be in the tld's currency"); checkArgument( instance.getStandardRestoreCost().getCurrencyUnit().equals(instance.currency), - "Restore cost must be in the registry's currency"); + "Restore cost must be in the TLD's currency"); checkArgument( instance.getServerStatusChangeCost().getCurrencyUnit().equals(instance.currency), - "Server status change cost must be in the registry's currency"); + "Server status change cost must be in the TLD's currency"); checkArgument( instance.getRegistryLockOrUnlockBillingCost().getCurrencyUnit().equals(instance.currency), - "Registry lock/unlock cost must be in the registry's currency"); + "Registry lock/unlock cost must be in the TLD's currency"); Predicate currencyCheck = (Money money) -> money.getCurrencyUnit().equals(instance.currency); checkArgument( instance.getRenewBillingCostTransitions().values().stream().allMatch(currencyCheck), - "Renew cost must be in the registry's currency"); + "Renew cost must be in the TLD's currency"); checkArgument( instance.eapFeeSchedule.toValueMap().values().stream().allMatch(currencyCheck), - "All EAP fees must be in the registry's currency"); + "All EAP fees must be in the TLD's currency"); checkArgumentNotNull( instance.pricingEngineClassName, "All registries must have a configured pricing engine"); checkArgument( @@ -1062,14 +1061,14 @@ public class Registry extends ImmutableObject implements Buildable, UnsafeSerial } } - /** Exception to throw when no Registry entity is found for given TLD string(s). */ - public static class RegistryNotFoundException extends RuntimeException { + /** Exception to throw when no Tld entity is found for given TLD string(s). */ + public static class TldNotFoundException extends RuntimeException { - RegistryNotFoundException(ImmutableSet tlds) { - super("No registry object(s) found for " + Joiner.on(", ").join(tlds)); + TldNotFoundException(ImmutableSet tlds) { + super("No TLD object(s) found for " + Joiner.on(", ").join(tlds)); } - RegistryNotFoundException(String tld) { + TldNotFoundException(String tld) { this(ImmutableSet.of(tld)); } } diff --git a/core/src/main/java/google/registry/model/tld/label/BaseDomainLabelList.java b/core/src/main/java/google/registry/model/tld/label/BaseDomainLabelList.java index 692ab40e2..c8af606aa 100644 --- a/core/src/main/java/google/registry/model/tld/label/BaseDomainLabelList.java +++ b/core/src/main/java/google/registry/model/tld/label/BaseDomainLabelList.java @@ -27,7 +27,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Multiset; import google.registry.model.Buildable; import google.registry.model.ImmutableObject; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -138,11 +138,11 @@ public abstract class BaseDomainLabelList, R extends Dom /** Gets the names of the tlds that reference this list. */ public final ImmutableSet getReferencingTlds() { return getTlds().stream() - .filter((tld) -> refersToList(Registry.get(tld), name)) + .filter((tld) -> refersToList(Tld.get(tld), name)) .collect(toImmutableSet()); } - protected abstract boolean refersToList(Registry registry, String name); + protected abstract boolean refersToList(Tld tld, String name); /** Base builder for derived classes of {@link BaseDomainLabelList}. */ public abstract static class Builder, B extends Builder> diff --git a/core/src/main/java/google/registry/model/tld/label/PremiumList.java b/core/src/main/java/google/registry/model/tld/label/PremiumList.java index c15c823ca..0bac8f3e4 100644 --- a/core/src/main/java/google/registry/model/tld/label/PremiumList.java +++ b/core/src/main/java/google/registry/model/tld/label/PremiumList.java @@ -23,7 +23,7 @@ import com.google.common.base.Splitter; import com.google.common.collect.ImmutableMap; import com.google.common.hash.BloomFilter; import google.registry.model.Buildable; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.tld.label.PremiumList.PremiumEntry; import java.io.Serializable; import java.math.BigDecimal; @@ -200,8 +200,8 @@ public final class PremiumList extends BaseDomainLabelList getReservedListEntries(String label, String tld) { + private static ImmutableSet getReservedListEntries( + String label, String tldStr) { DateTime startTime = DateTime.now(UTC); - Registry registry = Registry.get(checkNotNull(tld, "tld must not be null")); + Tld tld = Tld.get(checkNotNull(tldStr, "tld must not be null")); ImmutableSet.Builder entriesBuilder = new ImmutableSet.Builder<>(); ImmutableSet.Builder metricMatchesBuilder = new ImmutableSet.Builder<>(); // Loop through all reservation lists and add each of them. - for (ReservedList rl : loadReservedLists(registry.getReservedListNames())) { + for (ReservedList rl : loadReservedLists(tld.getReservedListNames())) { if (rl.getReservedListEntries().containsKey(label)) { ReservedListEntry entry = rl.getReservedListEntries().get(label); entriesBuilder.add(entry); @@ -261,7 +262,9 @@ public final class ReservedList } ImmutableSet entries = entriesBuilder.build(); DomainLabelMetrics.recordReservedListCheckOutcome( - tld, metricMatchesBuilder.build(), DateTime.now(UTC).getMillis() - startTime.getMillis()); + tldStr, + metricMatchesBuilder.build(), + DateTime.now(UTC).getMillis() - startTime.getMillis()); return entries; } diff --git a/core/src/main/java/google/registry/persistence/converter/TldStateTransitionConverter.java b/core/src/main/java/google/registry/persistence/converter/TldStateTransitionConverter.java index 5c6fa7735..db001b8d5 100644 --- a/core/src/main/java/google/registry/persistence/converter/TldStateTransitionConverter.java +++ b/core/src/main/java/google/registry/persistence/converter/TldStateTransitionConverter.java @@ -14,7 +14,7 @@ package google.registry.persistence.converter; -import google.registry.model.tld.Registry.TldState; +import google.registry.model.tld.Tld.TldState; import javax.persistence.Converter; /** JPA converter for storing/retrieving {@code TimedTransitionProperty} objects. */ diff --git a/core/src/main/java/google/registry/pricing/PricingEngineProxy.java b/core/src/main/java/google/registry/pricing/PricingEngineProxy.java index 619e782c8..b22a42749 100644 --- a/core/src/main/java/google/registry/pricing/PricingEngineProxy.java +++ b/core/src/main/java/google/registry/pricing/PricingEngineProxy.java @@ -20,7 +20,7 @@ import static google.registry.util.DomainNameUtils.getTldFromDomainName; import google.registry.model.pricing.PremiumPricingEngine; import google.registry.model.pricing.PremiumPricingEngine.DomainPrices; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import java.util.Map; import org.joda.money.Money; import org.joda.time.DateTime; @@ -58,7 +58,7 @@ public final class PricingEngineProxy { */ public static DomainPrices getPricesForDomainName(String domainName, DateTime priceTime) { String tld = getTldFromDomainName(domainName); - String clazz = Registry.get(tld).getPremiumPricingEngineClassName(); + String clazz = Tld.get(tld).getPremiumPricingEngineClassName(); PremiumPricingEngine engine = premiumPricingEngines.get(clazz); checkState(engine != null, "Could not load pricing engine %s for TLD %s", clazz, tld); return engine.getDomainPrices(domainName, priceTime); diff --git a/core/src/main/java/google/registry/rde/BrdaCopyAction.java b/core/src/main/java/google/registry/rde/BrdaCopyAction.java index 3ad58d99f..fb454df42 100644 --- a/core/src/main/java/google/registry/rde/BrdaCopyAction.java +++ b/core/src/main/java/google/registry/rde/BrdaCopyAction.java @@ -30,7 +30,7 @@ import google.registry.keyring.api.KeyModule.Key; import google.registry.model.common.Cursor; import google.registry.model.rde.RdeNamingUtils; import google.registry.model.rde.RdeRevision; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.request.Action; import google.registry.request.HttpException.NoContentException; import google.registry.request.Parameter; @@ -97,8 +97,7 @@ public final class BrdaCopyAction implements Runnable { // TODO(b/217772483): consider guarding this action with a lock and check if there is work. // Not urgent since file writes on GCS are atomic. Optional cursor = - tm().transact( - () -> tm().loadByKeyIfPresent(Cursor.createScopedVKey(BRDA, Registry.get(tld)))); + tm().transact(() -> tm().loadByKeyIfPresent(Cursor.createScopedVKey(BRDA, Tld.get(tld)))); DateTime brdaCursorTime = getCursorTimeOrStartOfTime(cursor); if (isBeforeOrAt(brdaCursorTime, watermark)) { throw new NoContentException( diff --git a/core/src/main/java/google/registry/rde/EscrowTaskRunner.java b/core/src/main/java/google/registry/rde/EscrowTaskRunner.java index 66b15f2d7..5bbf8b0d5 100644 --- a/core/src/main/java/google/registry/rde/EscrowTaskRunner.java +++ b/core/src/main/java/google/registry/rde/EscrowTaskRunner.java @@ -19,7 +19,7 @@ import static google.registry.persistence.transaction.TransactionManagerFactory. import com.google.common.flogger.FluentLogger; import google.registry.model.common.Cursor; import google.registry.model.common.Cursor.CursorType; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.request.HttpException.NoContentException; import google.registry.request.HttpException.ServiceUnavailableException; import google.registry.request.lock.LockHandler; @@ -74,24 +74,23 @@ class EscrowTaskRunner { * Acquires lock, checks cursor, invokes {@code task}, and advances cursor. * * @param task the task to run - * @param registry the {@link Registry} that we are performing escrow for + * @param tld the {@link Tld} that we are performing escrow for * @param timeout time when we assume failure, kill the task (and instance) and release the lock * @param cursorType the cursor to advance on success, indicating the next required runtime * @param interval how far to advance the cursor (e.g. a day for RDE, a week for BRDA) */ void lockRunAndRollForward( final EscrowTask task, - final Registry registry, + final Tld tld, Duration timeout, final CursorType cursorType, final Duration interval) { Callable lockRunner = () -> { - logger.atInfo().log("Performing escrow for TLD '%s'.", registry.getTld()); + logger.atInfo().log("Performing escrow for TLD '%s'.", tld.getTld()); DateTime startOfToday = clock.nowUtc().withTimeAtStartOfDay(); DateTime nextRequiredRun = - tm().transact( - () -> tm().loadByKeyIfPresent(Cursor.createScopedVKey(cursorType, registry))) + tm().transact(() -> tm().loadByKeyIfPresent(Cursor.createScopedVKey(cursorType, tld))) .map(Cursor::getCursorTime) .orElse(startOfToday); if (nextRequiredRun.isAfter(startOfToday)) { @@ -101,16 +100,16 @@ class EscrowTaskRunner { task.runWithLock(nextRequiredRun); DateTime nextRun = nextRequiredRun.plus(interval); logger.atInfo().log("Rolling cursor forward to %s.", nextRun); - tm().transact(() -> tm().put(Cursor.createScoped(cursorType, nextRun, registry))); + tm().transact(() -> tm().put(Cursor.createScoped(cursorType, nextRun, tld))); return null; }; String lockName = String.format("EscrowTaskRunner %s", task.getClass().getSimpleName()); - if (!lockHandler.executeWithLocks(lockRunner, registry.getTldStr(), timeout, lockName)) { + if (!lockHandler.executeWithLocks(lockRunner, tld.getTldStr(), timeout, lockName)) { // This will happen if either: a) the task is double-executed; b) the task takes a long time // to run and the retry task got executed while the first one is still running. In both // situations the safest thing to do is to just return 503 so the task gets retried later. throw new ServiceUnavailableException( - String.format("Lock in use: %s for TLD: %s", lockName, registry.getTldStr())); + String.format("Lock in use: %s for TLD: %s", lockName, tld.getTldStr())); } } } diff --git a/core/src/main/java/google/registry/rde/PendingDepositChecker.java b/core/src/main/java/google/registry/rde/PendingDepositChecker.java index 8d9d36058..3ac8849fa 100644 --- a/core/src/main/java/google/registry/rde/PendingDepositChecker.java +++ b/core/src/main/java/google/registry/rde/PendingDepositChecker.java @@ -24,8 +24,8 @@ import google.registry.model.common.Cursor; import google.registry.model.common.Cursor.CursorType; import google.registry.model.rde.RdeMode; import google.registry.model.tld.Registries; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.TldType; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldType; import google.registry.util.Clock; import java.util.Optional; import javax.inject.Inject; @@ -83,23 +83,22 @@ public final class PendingDepositChecker { ImmutableSetMultimap.Builder builder = new ImmutableSetMultimap.Builder<>(); DateTime now = clock.nowUtc(); - for (String tld : Registries.getTldsOfType(TldType.REAL)) { - Registry registry = Registry.get(tld); - if (!registry.getEscrowEnabled()) { + for (String tldStr : Registries.getTldsOfType(TldType.REAL)) { + Tld tld = Tld.get(tldStr); + if (!tld.getEscrowEnabled()) { continue; } // Avoid creating a transaction unless absolutely necessary. Optional maybeCursor = - tm().transact( - () -> tm().loadByKeyIfPresent(Cursor.createScopedVKey(cursorType, registry))); + tm().transact(() -> tm().loadByKeyIfPresent(Cursor.createScopedVKey(cursorType, tld))); DateTime cursorValue = maybeCursor.map(Cursor::getCursorTime).orElse(startingPoint); if (isBeforeOrAt(cursorValue, now)) { DateTime watermark = maybeCursor .map(Cursor::getCursorTime) - .orElse(transactionallyInitializeCursor(registry, cursorType, startingPoint)); + .orElse(transactionallyInitializeCursor(tld, cursorType, startingPoint)); if (isBeforeOrAt(watermark, now)) { - builder.put(tld, PendingDeposit.create(tld, watermark, mode, cursorType, interval)); + builder.put(tldStr, PendingDeposit.create(tldStr, watermark, mode, cursorType, interval)); } } } @@ -107,15 +106,15 @@ public final class PendingDepositChecker { } private DateTime transactionallyInitializeCursor( - final Registry registry, final CursorType cursorType, final DateTime initialValue) { + final Tld tld, final CursorType cursorType, final DateTime initialValue) { return tm().transact( () -> { Optional maybeCursor = - tm().loadByKeyIfPresent(Cursor.createScopedVKey(cursorType, registry)); + tm().loadByKeyIfPresent(Cursor.createScopedVKey(cursorType, tld)); if (maybeCursor.isPresent()) { return maybeCursor.get().getCursorTime(); } - tm().put(Cursor.createScoped(cursorType, initialValue, registry)); + tm().put(Cursor.createScoped(cursorType, initialValue, tld)); return initialValue; }); } diff --git a/core/src/main/java/google/registry/rde/RdeReportAction.java b/core/src/main/java/google/registry/rde/RdeReportAction.java index 230479f14..392eb3f85 100644 --- a/core/src/main/java/google/registry/rde/RdeReportAction.java +++ b/core/src/main/java/google/registry/rde/RdeReportAction.java @@ -32,7 +32,7 @@ import google.registry.model.common.Cursor; import google.registry.model.common.Cursor.CursorType; import google.registry.model.rde.RdeNamingUtils; import google.registry.model.rde.RdeRevision; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.rde.EscrowTaskRunner.EscrowTask; import google.registry.request.Action; import google.registry.request.HttpException.NoContentException; @@ -76,7 +76,7 @@ public final class RdeReportAction implements Runnable, EscrowTask { @Override public void run() { - runner.lockRunAndRollForward(this, Registry.get(tld), timeout, CursorType.RDE_REPORT, interval); + runner.lockRunAndRollForward(this, Tld.get(tld), timeout, CursorType.RDE_REPORT, interval); } @Override @@ -85,7 +85,7 @@ public final class RdeReportAction implements Runnable, EscrowTask { tm().transact( () -> tm().loadByKeyIfPresent( - Cursor.createScopedVKey(CursorType.RDE_UPLOAD, Registry.get(tld)))); + Cursor.createScopedVKey(CursorType.RDE_UPLOAD, Tld.get(tld)))); DateTime cursorTime = getCursorTimeOrStartOfTime(cursor); if (isBeforeOrAt(cursorTime, watermark)) { throw new NoContentException( diff --git a/core/src/main/java/google/registry/rde/RdeUploadAction.java b/core/src/main/java/google/registry/rde/RdeUploadAction.java index 93579eca6..6e9013fa7 100644 --- a/core/src/main/java/google/registry/rde/RdeUploadAction.java +++ b/core/src/main/java/google/registry/rde/RdeUploadAction.java @@ -46,7 +46,7 @@ import google.registry.model.common.Cursor; import google.registry.model.common.Cursor.CursorType; import google.registry.model.rde.RdeNamingUtils; import google.registry.model.rde.RdeRevision; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.rde.EscrowTaskRunner.EscrowTask; import google.registry.rde.JSchSshSession.JSchSshSessionFactory; import google.registry.request.Action; @@ -125,7 +125,7 @@ public final class RdeUploadAction implements Runnable, EscrowTask { @Override public void run() { logger.atInfo().log("Attempting to acquire RDE upload lock for TLD '%s'.", tld); - runner.lockRunAndRollForward(this, Registry.get(tld), timeout, CursorType.RDE_UPLOAD, interval); + runner.lockRunAndRollForward(this, Tld.get(tld), timeout, CursorType.RDE_UPLOAD, interval); HashMultimap params = HashMultimap.create(); params.put(RequestParameters.PARAM_TLD, tld); prefix.ifPresent(s -> params.put(RdeModule.PARAM_PREFIX, s)); @@ -160,9 +160,7 @@ public final class RdeUploadAction implements Runnable, EscrowTask { logger.atInfo().log("Verifying readiness to upload the RDE deposit."); Optional cursor = tm().transact( - () -> - tm().loadByKeyIfPresent( - Cursor.createScopedVKey(RDE_STAGING, Registry.get(tld)))); + () -> tm().loadByKeyIfPresent(Cursor.createScopedVKey(RDE_STAGING, Tld.get(tld)))); DateTime stagingCursorTime = getCursorTimeOrStartOfTime(cursor); if (isBeforeOrAt(stagingCursorTime, watermark)) { throw new NoContentException( @@ -174,8 +172,7 @@ public final class RdeUploadAction implements Runnable, EscrowTask { DateTime sftpCursorTime = tm().transact( () -> - tm().loadByKeyIfPresent( - Cursor.createScopedVKey(RDE_UPLOAD_SFTP, Registry.get(tld)))) + tm().loadByKeyIfPresent(Cursor.createScopedVKey(RDE_UPLOAD_SFTP, Tld.get(tld)))) .map(Cursor::getCursorTime) .orElse(START_OF_TIME); Duration timeSinceLastSftp = new Duration(sftpCursorTime, clock.nowUtc()); @@ -214,7 +211,7 @@ public final class RdeUploadAction implements Runnable, EscrowTask { () -> tm().put( Cursor.createScoped( - RDE_UPLOAD_SFTP, tm().getTransactionTime(), Registry.get(tld)))); + RDE_UPLOAD_SFTP, tm().getTransactionTime(), Tld.get(tld)))); response.setContentType(PLAIN_TEXT_UTF_8); response.setPayload(String.format("OK %s %s\n", tld, watermark)); } diff --git a/core/src/main/java/google/registry/reporting/icann/IcannReportingUploadAction.java b/core/src/main/java/google/registry/reporting/icann/IcannReportingUploadAction.java index 2e49849ac..614a2f01c 100644 --- a/core/src/main/java/google/registry/reporting/icann/IcannReportingUploadAction.java +++ b/core/src/main/java/google/registry/reporting/icann/IcannReportingUploadAction.java @@ -30,8 +30,8 @@ import google.registry.gcs.GcsUtils; import google.registry.model.common.Cursor; import google.registry.model.common.Cursor.CursorType; import google.registry.model.tld.Registries; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.TldType; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldType; import google.registry.persistence.VKey; import google.registry.request.Action; import google.registry.request.HttpException.ServiceUnavailableException; @@ -169,7 +169,7 @@ public final class IcannReportingUploadAction implements Runnable { Cursor.createScoped( cursorType, cursorTime.withTimeAtStartOfDay().withDayOfMonth(1).plusMonths(1), - Registry.get(tldStr)); + Tld.get(tldStr)); // In order to keep the transactions short-lived, we load all of the cursors in a single // transaction then later use per-cursor transactions when checking + saving the cursors. We // run behind a lock so the cursors shouldn't be changed, but double check to be sure. @@ -203,11 +203,11 @@ public final class IcannReportingUploadAction implements Runnable { /** Returns a map of each cursor to the tld. */ private ImmutableMap loadCursors() { - ImmutableSet registries = Registries.getTldEntitiesOfType(TldType.REAL); + ImmutableSet registries = Registries.getTldEntitiesOfType(TldType.REAL); - ImmutableMap, Registry> activityKeyMap = + ImmutableMap, Tld> activityKeyMap = loadKeyMap(registries, CursorType.ICANN_UPLOAD_ACTIVITY); - ImmutableMap, Registry> transactionKeyMap = + ImmutableMap, Tld> transactionKeyMap = loadKeyMap(registries, CursorType.ICANN_UPLOAD_TX); ImmutableSet.Builder> keys = new ImmutableSet.Builder<>(); @@ -225,8 +225,8 @@ public final class IcannReportingUploadAction implements Runnable { return cursors.build(); } - private ImmutableMap, Registry> loadKeyMap( - ImmutableSet registries, CursorType type) { + private ImmutableMap, Tld> loadKeyMap( + ImmutableSet registries, CursorType type) { return Maps.uniqueIndex(registries, r -> Cursor.createScopedVKey(type, r)); } @@ -236,7 +236,7 @@ public final class IcannReportingUploadAction implements Runnable { * next month. */ private ImmutableMap defaultNullCursorsToNextMonthAndAddToMap( - Map, Registry> keyMap, + Map, Tld> keyMap, CursorType type, Map, Cursor> cursorMap) { ImmutableMap.Builder cursors = new ImmutableMap.Builder<>(); diff --git a/core/src/main/java/google/registry/tldconfig/idn/IdnLabelValidator.java b/core/src/main/java/google/registry/tldconfig/idn/IdnLabelValidator.java index 8e603eb97..c0307cfda 100644 --- a/core/src/main/java/google/registry/tldconfig/idn/IdnLabelValidator.java +++ b/core/src/main/java/google/registry/tldconfig/idn/IdnLabelValidator.java @@ -18,7 +18,7 @@ import static google.registry.tldconfig.idn.IdnTableEnum.EXTENDED_LATIN; import static google.registry.tldconfig.idn.IdnTableEnum.JA; import com.google.common.collect.ImmutableSet; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.util.Idn; import java.util.Optional; @@ -37,7 +37,7 @@ public final class IdnLabelValidator { */ public Optional findValidIdnTableForTld(String label, String tldStr) { String unicodeString = Idn.toUnicode(label); - Registry tld = Registry.get(tldStr); // uses the cache + Tld tld = Tld.get(tldStr); // uses the cache ImmutableSet idnTablesForTld = tld.getIdnTables(); ImmutableSet idnTables = idnTablesForTld.isEmpty() ? DEFAULT_IDN_TABLES : idnTablesForTld; diff --git a/core/src/main/java/google/registry/tmch/LordnRequestInitializer.java b/core/src/main/java/google/registry/tmch/LordnRequestInitializer.java index 815859793..44aaecb24 100644 --- a/core/src/main/java/google/registry/tmch/LordnRequestInitializer.java +++ b/core/src/main/java/google/registry/tmch/LordnRequestInitializer.java @@ -18,7 +18,7 @@ import static com.google.common.base.Verify.verifyNotNull; import com.google.common.flogger.FluentLogger; import google.registry.keyring.api.KeyModule.Key; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.request.UrlConnectionUtils; import java.net.HttpURLConnection; import java.util.Optional; @@ -45,8 +45,11 @@ final class LordnRequestInitializer { /** Returns the username and password for the current TLD to login to the MarksDB server. */ private Optional getMarksDbLordnCredentials(String tld) { if (marksdbLordnPassword.isPresent()) { - String lordnUsername = verifyNotNull(Registry.get(tld).getLordnUsername(), - "lordnUsername is not set for %s.", Registry.get(tld).getTld()); + String lordnUsername = + verifyNotNull( + Tld.get(tld).getLordnUsername(), + "lordnUsername is not set for %s.", + Tld.get(tld).getTld()); return Optional.of(String.format("%s:%s", lordnUsername, marksdbLordnPassword.get())); } else { logger.atWarning().log( diff --git a/core/src/main/java/google/registry/tools/CreateOrUpdateTldCommand.java b/core/src/main/java/google/registry/tools/CreateOrUpdateTldCommand.java index 4d8addff0..6e73a2077 100644 --- a/core/src/main/java/google/registry/tools/CreateOrUpdateTldCommand.java +++ b/core/src/main/java/google/registry/tools/CreateOrUpdateTldCommand.java @@ -30,9 +30,9 @@ import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.Sets; import google.registry.model.pricing.StaticPremiumListPricingEngine; import google.registry.model.tld.Registries; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.TldState; -import google.registry.model.tld.Registry.TldType; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldState; +import google.registry.model.tld.Tld.TldType; import google.registry.model.tld.label.PremiumList; import google.registry.model.tld.label.PremiumListDao; import google.registry.tldconfig.idn.IdnTableEnum; @@ -274,20 +274,20 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand { + " IdnTableEnum values") List idnTables; - /** Returns the existing registry (for update) or null (for creates). */ + /** Returns the existing tld (for update) or null (for creates). */ @Nullable - abstract Registry getOldRegistry(String tld); + abstract Tld getOldTld(String tld); - abstract ImmutableSet getAllowedRegistrants(Registry oldRegistry); + abstract ImmutableSet getAllowedRegistrants(Tld oldTld); - abstract ImmutableSet getAllowedNameservers(Registry oldRegistry); + abstract ImmutableSet getAllowedNameservers(Tld oldTld); - abstract ImmutableSet getReservedLists(Registry oldRegistry); + abstract ImmutableSet getReservedLists(Tld oldTld); abstract Optional> getTldStateTransitionToAdd(); /** Subclasses can override this to set their own properties. */ - void setCommandSpecificProperties(@SuppressWarnings("unused") Registry.Builder builder) {} + void setCommandSpecificProperties(@SuppressWarnings("unused") Tld.Builder builder) {} /** Subclasses can override this to assert that the command can be run in this environment. */ void assertAllowedEnvironment() {} @@ -312,14 +312,14 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand { checkArgument( !Character.isDigit(tld.charAt(0)), "TLDs cannot begin with a number"); - Registry oldRegistry = getOldRegistry(tld); + Tld oldTld = getOldTld(tld); // TODO(b/26901539): Add a flag to set the pricing engine once we have more than one option. - Registry.Builder builder = - oldRegistry == null - ? new Registry.Builder() + Tld.Builder builder = + oldTld == null + ? new Tld.Builder() .setTldStr(tld) .setPremiumPricingEngine(StaticPremiumListPricingEngine.NAME) - : oldRegistry.asBuilder(); + : oldTld.asBuilder(); if (escrow != null) { builder.setEscrowEnabled(escrow); @@ -336,14 +336,16 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand { } else if (tldStateTransitionToAdd.isPresent()) { ImmutableSortedMap.Builder newTldStateTransitions = ImmutableSortedMap.naturalOrder(); - if (oldRegistry != null) { + if (oldTld != null) { checkArgument( - oldRegistry.getTldStateTransitions().lastKey().isBefore( - tldStateTransitionToAdd.get().getKey()), + oldTld + .getTldStateTransitions() + .lastKey() + .isBefore(tldStateTransitionToAdd.get().getKey()), "Cannot add %s at %s when there is a later transition already scheduled", tldStateTransitionToAdd.get().getValue(), tldStateTransitionToAdd.get().getKey()); - newTldStateTransitions.putAll(oldRegistry.getTldStateTransitions()); + newTldStateTransitions.putAll(oldTld.getTldStateTransitions()); } builder.setTldStateTransitions( newTldStateTransitions.put(getTldStateTransitionToAdd().get()).build()); @@ -410,13 +412,13 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand { builder.setDnsWriters(dnsWritersSet); } - ImmutableSet newReservedListNames = getReservedLists(oldRegistry); + ImmutableSet newReservedListNames = getReservedLists(oldTld); checkReservedListValidityForTld(tld, newReservedListNames); builder.setReservedListsByName(newReservedListNames); - builder.setAllowedRegistrantContactIds(getAllowedRegistrants(oldRegistry)); + builder.setAllowedRegistrantContactIds(getAllowedRegistrants(oldTld)); - builder.setAllowedFullyQualifiedHostNames(getAllowedNameservers(oldRegistry)); + builder.setAllowedFullyQualifiedHostNames(getAllowedNameservers(oldTld)); if (!isNullOrEmpty(defaultTokens)) { if (defaultTokens.equals(ImmutableList.of(""))) { @@ -444,7 +446,7 @@ abstract class CreateOrUpdateTldCommand extends MutatingCommand { } // Update the Registry object. setCommandSpecificProperties(builder); - stageEntityChange(oldRegistry, builder.build()); + stageEntityChange(oldTld, builder.build()); } } diff --git a/core/src/main/java/google/registry/tools/CreateTldCommand.java b/core/src/main/java/google/registry/tools/CreateTldCommand.java index 440796816..56e6b8b2f 100644 --- a/core/src/main/java/google/registry/tools/CreateTldCommand.java +++ b/core/src/main/java/google/registry/tools/CreateTldCommand.java @@ -26,8 +26,8 @@ import com.google.common.base.Strings; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.Maps; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.TldState; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldState; import java.util.Map; import java.util.Optional; import javax.annotation.Nullable; @@ -68,40 +68,39 @@ class CreateTldCommand extends CreateOrUpdateTldCommand { } @Override - void setCommandSpecificProperties(Registry.Builder builder) { + void setCommandSpecificProperties(Tld.Builder builder) { // Pick up the currency from the create cost. Since all costs must be in one currency, and that // condition is enforced by the builder, it doesn't matter which cost we choose it from. - CurrencyUnit currency = createBillingCost != null - ? createBillingCost.getCurrencyUnit() - : Registry.DEFAULT_CURRENCY; + CurrencyUnit currency = + createBillingCost != null ? createBillingCost.getCurrencyUnit() : Tld.DEFAULT_CURRENCY; builder.setCurrency(currency); // If this is a non-default currency and the user hasn't specified an EAP fee schedule, set the // EAP fee schedule to a matching currency. - if (!currency.equals(Registry.DEFAULT_CURRENCY) && eapFeeSchedule.isEmpty()) { + if (!currency.equals(Tld.DEFAULT_CURRENCY) && eapFeeSchedule.isEmpty()) { builder.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(currency))); } } @Override - Registry getOldRegistry(String tld) { + Tld getOldTld(String tld) { checkState(!getTlds().contains(tld), "TLD '%s' already exists", tld); return null; } @Override - ImmutableSet getAllowedRegistrants(Registry oldRegistry) { + ImmutableSet getAllowedRegistrants(Tld oldTld) { return ImmutableSet.copyOf(nullToEmpty(allowedRegistrants)); } @Override - ImmutableSet getAllowedNameservers(Registry oldRegistry) { + ImmutableSet getAllowedNameservers(Tld oldTld) { return ImmutableSet.copyOf(nullToEmpty(allowedNameservers)); } @Override - ImmutableSet getReservedLists(Registry oldRegistry) { + ImmutableSet getReservedLists(Tld oldTld) { return ImmutableSet.copyOf(nullToEmpty(reservedListNames)); } diff --git a/core/src/main/java/google/registry/tools/DeleteTldCommand.java b/core/src/main/java/google/registry/tools/DeleteTldCommand.java index 8f02e9bd0..b1e27bed5 100644 --- a/core/src/main/java/google/registry/tools/DeleteTldCommand.java +++ b/core/src/main/java/google/registry/tools/DeleteTldCommand.java @@ -21,25 +21,25 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import google.registry.model.domain.Domain; import google.registry.model.registrar.Registrar; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.TldType; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldType; import google.registry.persistence.transaction.QueryComposer.Comparator; /** - * Command to delete the {@link Registry} associated with the specified TLD in the database. + * Command to delete the {@link Tld} associated with the specified TLD in the database. * *

This command will fail if any domains are currently registered on the TLD. */ @Parameters(separators = " =", commandDescription = "Delete a TLD from the database.") final class DeleteTldCommand extends ConfirmingCommand { - private Registry registry; + private Tld tld; @Parameter( names = {"-t", "--tld"}, description = "The TLD to delete.", required = true) - private String tld; + private String tldStr; /** * Perform the command by deleting the TLD. @@ -52,28 +52,28 @@ final class DeleteTldCommand extends ConfirmingCommand { */ @Override protected void init() { - registry = Registry.get(tld); - checkState(registry.getTldType().equals(TldType.TEST), "Cannot delete a real TLD"); + tld = Tld.get(tldStr); + checkState(tld.getTldType().equals(TldType.TEST), "Cannot delete a real TLD"); for (Registrar registrar : Registrar.loadAll()) { checkState( - !registrar.getAllowedTlds().contains(tld), + !registrar.getAllowedTlds().contains(tldStr), "Cannot delete TLD because registrar %s lists it as an allowed TLD", registrar.getRegistrarId()); } - checkState(!tldContainsDomains(tld), "Cannot delete TLD because a domain is defined on it"); + checkState(!tldContainsDomains(tldStr), "Cannot delete TLD because a domain is defined on it"); } @Override protected String prompt() { - return "You are about to delete TLD: " + tld; + return "You are about to delete TLD: " + tldStr; } @Override protected String execute() { - tm().transact(() -> tm().delete(registry)); - registry.invalidateInCache(); - return String.format("Deleted TLD '%s'.\n", tld); + tm().transact(() -> tm().delete(tld)); + tld.invalidateInCache(); + return String.format("Deleted TLD '%s'.\n", tldStr); } private boolean tldContainsDomains(String tld) { diff --git a/core/src/main/java/google/registry/tools/DomainLockUtils.java b/core/src/main/java/google/registry/tools/DomainLockUtils.java index 26a4519fa..5676dc4e2 100644 --- a/core/src/main/java/google/registry/tools/DomainLockUtils.java +++ b/core/src/main/java/google/registry/tools/DomainLockUtils.java @@ -32,8 +32,8 @@ import google.registry.model.domain.Domain; import google.registry.model.domain.DomainHistory; import google.registry.model.domain.RegistryLock; import google.registry.model.reporting.HistoryEntry; -import google.registry.model.tld.Registry; import google.registry.model.tld.RegistryLockDao; +import google.registry.model.tld.Tld; import google.registry.request.Action.Service; import google.registry.util.StringGenerator; import java.util.Optional; @@ -402,7 +402,7 @@ public final class DomainLockUtils { .setReason(Reason.SERVER_STATUS) .setTargetId(domain.getForeignKey()) .setRegistrarId(domain.getCurrentSponsorRegistrarId()) - .setCost(Registry.get(domain.getTld()).getRegistryLockOrUnlockBillingCost()) + .setCost(Tld.get(domain.getTld()).getRegistryLockOrUnlockBillingCost()) .setEventTime(now) .setBillingTime(now) .setDomainHistory(domainHistory) diff --git a/core/src/main/java/google/registry/tools/GetTldCommand.java b/core/src/main/java/google/registry/tools/GetTldCommand.java index 966d6ab20..6a8c979d7 100644 --- a/core/src/main/java/google/registry/tools/GetTldCommand.java +++ b/core/src/main/java/google/registry/tools/GetTldCommand.java @@ -18,7 +18,7 @@ import static google.registry.model.tld.Registries.assertTldsExist; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import java.util.List; /** Command to show a TLD record. */ @@ -33,7 +33,7 @@ final class GetTldCommand implements Command { @Override public void run() { for (String tld : assertTldsExist(mainParameters)) { - System.out.println(Registry.get(tld)); + System.out.println(Tld.get(tld)); } } } diff --git a/core/src/main/java/google/registry/tools/ListCursorsCommand.java b/core/src/main/java/google/registry/tools/ListCursorsCommand.java index 979e5b282..15e2e81e0 100644 --- a/core/src/main/java/google/registry/tools/ListCursorsCommand.java +++ b/core/src/main/java/google/registry/tools/ListCursorsCommand.java @@ -24,8 +24,8 @@ import com.google.common.collect.ImmutableMap; import google.registry.model.common.Cursor; import google.registry.model.common.Cursor.CursorType; import google.registry.model.tld.Registries; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.TldType; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldType; import google.registry.persistence.VKey; import java.util.Map; import java.util.Optional; @@ -54,7 +54,7 @@ final class ListCursorsCommand implements Command { Map> cursorKeys = cursorType.isScoped() ? Registries.getTlds().stream() - .map(Registry::get) + .map(Tld::get) .filter(r -> r.getTldType() == filterTldType) .filter(r -> !filterEscrowEnabled || r.getEscrowEnabled()) .collect( diff --git a/core/src/main/java/google/registry/tools/ListDomainsCommand.java b/core/src/main/java/google/registry/tools/ListDomainsCommand.java index 91c3c1680..44752aec4 100644 --- a/core/src/main/java/google/registry/tools/ListDomainsCommand.java +++ b/core/src/main/java/google/registry/tools/ListDomainsCommand.java @@ -22,7 +22,7 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableMap; -import google.registry.model.tld.Registry.TldType; +import google.registry.model.tld.Tld.TldType; import google.registry.tools.server.ListDomainsAction; import java.util.List; diff --git a/core/src/main/java/google/registry/tools/UpdateCursorsCommand.java b/core/src/main/java/google/registry/tools/UpdateCursorsCommand.java index 140b6c9f6..4a724e8c2 100644 --- a/core/src/main/java/google/registry/tools/UpdateCursorsCommand.java +++ b/core/src/main/java/google/registry/tools/UpdateCursorsCommand.java @@ -22,7 +22,7 @@ import com.beust.jcommander.Parameters; import com.google.common.collect.ImmutableList; import google.registry.model.common.Cursor; import google.registry.model.common.Cursor.CursorType; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.tools.params.DateTimeParameter; import java.util.List; import org.joda.time.DateTime; @@ -52,9 +52,9 @@ final class UpdateCursorsCommand extends ConfirmingCommand implements Command { if (isNullOrEmpty(tlds)) { result.add(Cursor.createGlobal(cursorType, newTimestamp)); } else { - for (String tld : tlds) { - Registry registry = Registry.get(tld); - result.add(Cursor.createScoped(cursorType, newTimestamp, registry)); + for (String tldStr : tlds) { + Tld tld = Tld.get(tldStr); + result.add(Cursor.createScoped(cursorType, newTimestamp, tld)); } } cursorsToUpdate = result.build(); diff --git a/core/src/main/java/google/registry/tools/UpdateTldCommand.java b/core/src/main/java/google/registry/tools/UpdateTldCommand.java index 9fd5bf0fe..6f20dc28d 100644 --- a/core/src/main/java/google/registry/tools/UpdateTldCommand.java +++ b/core/src/main/java/google/registry/tools/UpdateTldCommand.java @@ -26,8 +26,8 @@ import com.beust.jcommander.Parameters; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; import google.registry.config.RegistryEnvironment; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.TldState; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldState; import java.util.List; import java.util.Map; import java.util.Optional; @@ -83,35 +83,35 @@ public class UpdateTldCommand extends CreateOrUpdateTldCommand { TldState setCurrentTldState; @Override - Registry getOldRegistry(String tld) { - return Registry.get(assertTldExists(tld)); + Tld getOldTld(String tld) { + return Tld.get(assertTldExists(tld)); } @Override - ImmutableSet getAllowedRegistrants(Registry oldRegistry) { + ImmutableSet getAllowedRegistrants(Tld oldTld) { return formUpdatedList( "allowed registrants", - oldRegistry.getAllowedRegistrantContactIds(), + oldTld.getAllowedRegistrantContactIds(), allowedRegistrants, allowedRegistrantsAdd, allowedRegistrantsRemove); } @Override - ImmutableSet getAllowedNameservers(Registry oldRegistry) { + ImmutableSet getAllowedNameservers(Tld oldTld) { return formUpdatedList( "allowed nameservers", - oldRegistry.getAllowedFullyQualifiedHostNames(), + oldTld.getAllowedFullyQualifiedHostNames(), allowedNameservers, allowedNameserversAdd, allowedNameserversRemove); } @Override - ImmutableSet getReservedLists(Registry oldRegistry) { + ImmutableSet getReservedLists(Tld oldTld) { return formUpdatedList( "reserved lists", - oldRegistry.getReservedListNames(), + oldTld.getReservedListNames(), reservedListNames, reservedListsAdd, reservedListsRemove); diff --git a/core/src/main/java/google/registry/tools/params/TldStateParameter.java b/core/src/main/java/google/registry/tools/params/TldStateParameter.java index fab0bd444..a1609c5b4 100644 --- a/core/src/main/java/google/registry/tools/params/TldStateParameter.java +++ b/core/src/main/java/google/registry/tools/params/TldStateParameter.java @@ -14,7 +14,7 @@ package google.registry.tools.params; -import google.registry.model.tld.Registry.TldState; +import google.registry.model.tld.Tld.TldState; /** * {@link TldState} CLI parameter converter/validator. Required to support multi-value diff --git a/core/src/main/java/google/registry/tools/params/TransitionListParameter.java b/core/src/main/java/google/registry/tools/params/TransitionListParameter.java index 6cb27c261..95b173412 100644 --- a/core/src/main/java/google/registry/tools/params/TransitionListParameter.java +++ b/core/src/main/java/google/registry/tools/params/TransitionListParameter.java @@ -21,7 +21,7 @@ import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.Ordering; import google.registry.model.common.DatabaseMigrationStateSchedule.MigrationState; import google.registry.model.domain.token.AllocationToken.TokenStatus; -import google.registry.model.tld.Registry.TldState; +import google.registry.model.tld.Tld.TldState; import org.joda.money.Money; import org.joda.time.DateTime; diff --git a/core/src/main/java/google/registry/tools/server/ListTldsAction.java b/core/src/main/java/google/registry/tools/server/ListTldsAction.java index 7d6eaff25..2a9cddd63 100644 --- a/core/src/main/java/google/registry/tools/server/ListTldsAction.java +++ b/core/src/main/java/google/registry/tools/server/ListTldsAction.java @@ -22,7 +22,7 @@ import static google.registry.request.Action.Method.POST; import com.google.common.collect.ImmutableBiMap; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.request.Action; import google.registry.request.auth.Auth; import google.registry.util.Clock; @@ -35,7 +35,7 @@ import org.joda.time.DateTime; path = ListTldsAction.PATH, method = {GET, POST}, auth = Auth.AUTH_INTERNAL_OR_ADMIN) -public final class ListTldsAction extends ListObjectsAction { +public final class ListTldsAction extends ListObjectsAction { public static final String PATH = "/_dr/admin/list/tlds"; @@ -48,8 +48,8 @@ public final class ListTldsAction extends ListObjectsAction { } @Override - public ImmutableSet loadObjects() { - return getTlds().stream().map(Registry::get).collect(toImmutableSet()); + public ImmutableSet loadObjects() { + return getTlds().stream().map(Tld::get).collect(toImmutableSet()); } @Override @@ -61,15 +61,15 @@ public final class ListTldsAction extends ListObjectsAction { } @Override - public ImmutableMap getFieldOverrides(Registry registry) { + public ImmutableMap getFieldOverrides(Tld tld) { final DateTime now = clock.nowUtc(); return new ImmutableMap.Builder() - .put("dnsPaused", registry.getDnsPaused() ? "paused" : "-") - .put("escrowEnabled", registry.getEscrowEnabled() ? "enabled" : "-") - .put("tldState", registry.isPdt(now) ? "PDT" : registry.getTldState(now).toString()) - .put("tldStateTransitions", registry.getTldStateTransitions().toString()) - .put("renewBillingCost", registry.getStandardRenewCost(now).toString()) - .put("renewBillingCostTransitions", registry.getRenewBillingCostTransitions().toString()) + .put("dnsPaused", tld.getDnsPaused() ? "paused" : "-") + .put("escrowEnabled", tld.getEscrowEnabled() ? "enabled" : "-") + .put("tldState", tld.isPdt(now) ? "PDT" : tld.getTldState(now).toString()) + .put("tldStateTransitions", tld.getTldStateTransitions().toString()) + .put("renewBillingCost", tld.getStandardRenewCost(now).toString()) + .put("renewBillingCostTransitions", tld.getRenewBillingCostTransitions().toString()) .build(); } } diff --git a/core/src/main/resources/META-INF/persistence.xml b/core/src/main/resources/META-INF/persistence.xml index d4835b6bb..64bd9e8fb 100644 --- a/core/src/main/resources/META-INF/persistence.xml +++ b/core/src/main/resources/META-INF/persistence.xml @@ -67,7 +67,7 @@ google.registry.model.tld.label.PremiumList$PremiumEntry google.registry.model.tld.label.ReservedList google.registry.model.tld.label.ReservedList$ReservedListEntry - google.registry.model.tld.Registry + google.registry.model.tld.Tld google.registry.model.reporting.DomainTransactionRecord google.registry.model.reporting.Spec11ThreatMatch google.registry.model.server.Lock diff --git a/core/src/test/java/google/registry/batch/DeleteProberDataActionTest.java b/core/src/test/java/google/registry/batch/DeleteProberDataActionTest.java index db492982e..b4fbd7c97 100644 --- a/core/src/test/java/google/registry/batch/DeleteProberDataActionTest.java +++ b/core/src/test/java/google/registry/batch/DeleteProberDataActionTest.java @@ -42,8 +42,8 @@ import google.registry.model.domain.Domain; import google.registry.model.domain.DomainHistory; import google.registry.model.poll.PollMessage; import google.registry.model.reporting.HistoryEntry; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.TldType; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldType; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.testing.DatabaseHelper; @@ -82,7 +82,7 @@ class DeleteProberDataActionTest { // Since "example" doesn't end with .test, its entities won't be deleted even though it is of // TEST type. createTld("example", "EXAMPLE"); - persistResource(Registry.get("example").asBuilder().setTldType(TldType.TEST).build()); + persistResource(Tld.get("example").asBuilder().setTldType(TldType.TEST).build()); // Since "not-test.test" isn't of TEST type, its entities won't be deleted even though it ends // with .test. @@ -90,9 +90,9 @@ class DeleteProberDataActionTest { // Entities in these two should be deleted. createTld("ib-any.test", "IBANYT"); - persistResource(Registry.get("ib-any.test").asBuilder().setTldType(TldType.TEST).build()); + persistResource(Tld.get("ib-any.test").asBuilder().setTldType(TldType.TEST).build()); createTld("oa-canary.test", "OACANT"); - persistResource(Registry.get("oa-canary.test").asBuilder().setTldType(TldType.TEST).build()); + persistResource(Tld.get("oa-canary.test").asBuilder().setTldType(TldType.TEST).build()); resetAction(); } diff --git a/core/src/test/java/google/registry/beam/billing/ExpandRecurringBillingEventsPipelineTest.java b/core/src/test/java/google/registry/beam/billing/ExpandRecurringBillingEventsPipelineTest.java index b53213849..558831800 100644 --- a/core/src/test/java/google/registry/beam/billing/ExpandRecurringBillingEventsPipelineTest.java +++ b/core/src/test/java/google/registry/beam/billing/ExpandRecurringBillingEventsPipelineTest.java @@ -48,7 +48,7 @@ import google.registry.model.domain.DomainHistory; import google.registry.model.domain.Period; import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.PersistenceModule.TransactionIsolationLevel; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; @@ -313,7 +313,7 @@ public class ExpandRecurringBillingEventsPipelineTest { void testSuccess_expandMultipleEvents_multipleDomains(int numOfThreads) { createTld("test"); persistResource( - Registry.get("test") + Tld.get("test") .asBuilder() .setPremiumList(persistPremiumList("premium", USD, "other,USD 100")) .build()); @@ -370,7 +370,7 @@ public class ExpandRecurringBillingEventsPipelineTest { domain .getCreationTime() .plusYears(2) - .plus(Registry.DEFAULT_AUTO_RENEW_GRACE_PERIOD), + .plus(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD), TransactionReportField.netRenewsFieldFromYears(1), 1))) .build()); @@ -394,10 +394,7 @@ public class ExpandRecurringBillingEventsPipelineTest { .asBuilder() .setEventTime(domain.getCreationTime().plusYears(2)) .setBillingTime( - domain - .getCreationTime() - .plusYears(2) - .plus(Registry.DEFAULT_AUTO_RENEW_GRACE_PERIOD)) + domain.getCreationTime().plusYears(2).plus(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD)) .build(), recurring .asBuilder() @@ -455,10 +452,7 @@ public class ExpandRecurringBillingEventsPipelineTest { DomainTransactionRecord.create( domain.getTld(), // We report this when the autorenew grace period ends. - domain - .getCreationTime() - .plusYears(1) - .plus(Registry.DEFAULT_AUTO_RENEW_GRACE_PERIOD), + domain.getCreationTime().plusYears(1).plus(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD), TransactionReportField.netRenewsFieldFromYears(1), 1))) .build(); @@ -472,7 +466,7 @@ public class ExpandRecurringBillingEventsPipelineTest { Domain domain, DomainHistory history, Recurring recurring, int cost) { return new BillingEvent.OneTime.Builder() .setBillingTime( - domain.getCreationTime().plusYears(1).plus(Registry.DEFAULT_AUTO_RENEW_GRACE_PERIOD)) + domain.getCreationTime().plusYears(1).plus(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD)) .setRegistrarId("TheRegistrar") .setCost(Money.of(USD, cost)) .setEventTime(domain.getCreationTime().plusYears(1)) diff --git a/core/src/test/java/google/registry/beam/billing/InvoicingPipelineTest.java b/core/src/test/java/google/registry/beam/billing/InvoicingPipelineTest.java index 80485a4db..0bfdc21ac 100644 --- a/core/src/test/java/google/registry/beam/billing/InvoicingPipelineTest.java +++ b/core/src/test/java/google/registry/beam/billing/InvoicingPipelineTest.java @@ -16,9 +16,9 @@ package google.registry.beam.billing; import static com.google.common.collect.ImmutableSet.toImmutableSet; import static com.google.common.truth.Truth.assertThat; -import static google.registry.model.tld.Registry.TldState.GENERAL_AVAILABILITY; +import static google.registry.model.tld.Tld.TldState.GENERAL_AVAILABILITY; import static google.registry.testing.DatabaseHelper.createTld; -import static google.registry.testing.DatabaseHelper.newRegistry; +import static google.registry.testing.DatabaseHelper.newTld; import static google.registry.testing.DatabaseHelper.persistActiveDomain; import static google.registry.testing.DatabaseHelper.persistNewRegistrar; import static google.registry.testing.DatabaseHelper.persistResource; @@ -45,7 +45,7 @@ import google.registry.model.domain.Domain; import google.registry.model.domain.DomainHistory; import google.registry.model.registrar.Registrar; import google.registry.model.reporting.HistoryEntry; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.testing.FakeClock; @@ -291,8 +291,8 @@ class InvoicingPipelineTest { .setPoNumber(Optional.of("22446688")) .build(); persistResource(registrar); - Registry test = - newRegistry("test", "_TEST", ImmutableSortedMap.of(START_OF_TIME, GENERAL_AVAILABILITY)) + Tld test = + newTld("test", "_TEST", ImmutableSortedMap.of(START_OF_TIME, GENERAL_AVAILABILITY)) .asBuilder() .setInvoicingEnabled(true) .build(); @@ -395,14 +395,14 @@ class InvoicingPipelineTest { registrar3 = registrar3.asBuilder().setBillingAccountMap(ImmutableMap.of(USD, "789")).build(); persistResource(registrar3); - Registry test = - newRegistry("test", "_TEST", ImmutableSortedMap.of(START_OF_TIME, GENERAL_AVAILABILITY)) + Tld test = + newTld("test", "_TEST", ImmutableSortedMap.of(START_OF_TIME, GENERAL_AVAILABILITY)) .asBuilder() .setInvoicingEnabled(true) .build(); persistResource(test); - Registry hello = - newRegistry("hello", "_HELLO", ImmutableSortedMap.of(START_OF_TIME, GENERAL_AVAILABILITY)) + Tld hello = + newTld("hello", "_HELLO", ImmutableSortedMap.of(START_OF_TIME, GENERAL_AVAILABILITY)) .asBuilder() .setInvoicingEnabled(true) .build(); diff --git a/core/src/test/java/google/registry/beam/common/DatabaseSnapshotTest.java b/core/src/test/java/google/registry/beam/common/DatabaseSnapshotTest.java index becd358e9..dca7108a2 100644 --- a/core/src/test/java/google/registry/beam/common/DatabaseSnapshotTest.java +++ b/core/src/test/java/google/registry/beam/common/DatabaseSnapshotTest.java @@ -20,7 +20,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.truth.Truth; import google.registry.beam.TestPipelineExtension; import google.registry.beam.common.RegistryJpaIO.Read; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.NomulusPostgreSql; import google.registry.persistence.PersistenceModule; import google.registry.persistence.transaction.CriteriaQueryBuilder; @@ -67,7 +67,7 @@ public class DatabaseSnapshotTest { static JpaTransactionManager origJpa; static JpaTransactionManager jpa; - static Registry registry; + static Tld registry; @BeforeAll static void setup() { @@ -84,7 +84,7 @@ public class DatabaseSnapshotTest { origJpa = tm(); TransactionManagerFactory.setJpaTm(() -> jpa); - Registry tld = DatabaseHelper.newRegistry("tld", "TLD"); + Tld tld = DatabaseHelper.newTld("tld", "TLD"); tm().transact(() -> tm().put(tld)); registry = tm().transact(() -> tm().loadByEntity(tld)); } @@ -112,7 +112,7 @@ public class DatabaseSnapshotTest { @Test void readSnapshot() { try (DatabaseSnapshot databaseSnapshot = DatabaseSnapshot.createSnapshot()) { - Registry snapshotRegistry = + Tld snapshotRegistry = tm().transact( () -> tm().setDatabaseSnapshot(databaseSnapshot.getSnapshotId()) @@ -124,17 +124,17 @@ public class DatabaseSnapshotTest { @Test void readSnapshot_withSubsequentChange() { try (DatabaseSnapshot databaseSnapshot = DatabaseSnapshot.createSnapshot()) { - Registry updated = + Tld updated = registry .asBuilder() .setCreateBillingCost(registry.getStandardCreateCost().plus(1)) .build(); tm().transact(() -> tm().put(updated)); - Registry persistedUpdate = tm().transact(() -> tm().loadByEntity(registry)); + Tld persistedUpdate = tm().transact(() -> tm().loadByEntity(registry)); Truth.assertThat(persistedUpdate).isNotEqualTo(registry); - Registry snapshotRegistry = + Tld snapshotRegistry = tm().transact( () -> tm().setDatabaseSnapshot(databaseSnapshot.getSnapshotId()) @@ -149,18 +149,18 @@ public class DatabaseSnapshotTest { @Test void readWithRegistryJpaIO() { try (DatabaseSnapshot databaseSnapshot = DatabaseSnapshot.createSnapshot()) { - Registry updated = + Tld updated = registry .asBuilder() .setCreateBillingCost(registry.getStandardCreateCost().plus(1)) .build(); tm().transact(() -> tm().put(updated)); - Read read = - RegistryJpaIO.read(() -> CriteriaQueryBuilder.create(Registry.class).build(), x -> x) - .withCoder(SerializableCoder.of(Registry.class)) + Read read = + RegistryJpaIO.read(() -> CriteriaQueryBuilder.create(Tld.class).build(), x -> x) + .withCoder(SerializableCoder.of(Tld.class)) .withSnapshot(databaseSnapshot.getSnapshotId()); - PCollection registries = testPipeline.apply(read); + PCollection registries = testPipeline.apply(read); // This assertion depends on Registry being Serializable, which may change if the // UnsafeSerializable interface is removed after migration. diff --git a/core/src/test/java/google/registry/beam/common/RegistryJpaReadTest.java b/core/src/test/java/google/registry/beam/common/RegistryJpaReadTest.java index 738dbf2c8..c5d67d080 100644 --- a/core/src/test/java/google/registry/beam/common/RegistryJpaReadTest.java +++ b/core/src/test/java/google/registry/beam/common/RegistryJpaReadTest.java @@ -17,7 +17,7 @@ package google.registry.beam.common; import static google.registry.persistence.transaction.JpaTransactionManagerExtension.makeRegistrar1; import static google.registry.testing.DatabaseHelper.insertInDb; import static google.registry.testing.DatabaseHelper.newContact; -import static google.registry.testing.DatabaseHelper.newRegistry; +import static google.registry.testing.DatabaseHelper.newTld; import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.DateTimeUtils.START_OF_TIME; @@ -37,7 +37,7 @@ import google.registry.model.domain.secdns.DomainDsData; import google.registry.model.eppcommon.AuthInfo.PasswordAuth; import google.registry.model.eppcommon.StatusValue; import google.registry.model.registrar.Registrar; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.transfer.ContactTransferData; import google.registry.persistence.transaction.CriteriaQueryBuilder; import google.registry.persistence.transaction.JpaTestExtensions; @@ -161,7 +161,7 @@ public class RegistryJpaReadTest { } private void setupForJoinQuery() { - Registry registry = newRegistry("com", "ABCD_APP"); + Tld registry = newTld("com", "ABCD_APP"); Registrar registrar = makeRegistrar1() .asBuilder() diff --git a/core/src/test/java/google/registry/beam/rde/RdePipelineTest.java b/core/src/test/java/google/registry/beam/rde/RdePipelineTest.java index bb1dc826f..14561d12e 100644 --- a/core/src/test/java/google/registry/beam/rde/RdePipelineTest.java +++ b/core/src/test/java/google/registry/beam/rde/RdePipelineTest.java @@ -73,7 +73,7 @@ import google.registry.model.registrar.Registrar.State; import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField; import google.registry.model.reporting.HistoryEntry; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.VKey; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; @@ -247,8 +247,8 @@ public class RdePipelineTest { tm().transact( () -> { - tm().put(Cursor.createScoped(CursorType.BRDA, now, Registry.get("soy"))); - tm().put(Cursor.createScoped(RDE_STAGING, now, Registry.get("soy"))); + tm().put(Cursor.createScoped(CursorType.BRDA, now, Tld.get("soy"))); + tm().put(Cursor.createScoped(RDE_STAGING, now, Tld.get("soy"))); RdeRevision.saveRevision("soy", now, THIN, 0); RdeRevision.saveRevision("soy", now, FULL, 0); }); @@ -562,8 +562,7 @@ public class RdePipelineTest { private static DateTime loadCursorTime(CursorType type) { return tm().transact( - () -> - tm().loadByKey(Cursor.createScopedVKey(type, Registry.get("soy"))).getCursorTime()); + () -> tm().loadByKey(Cursor.createScopedVKey(type, Tld.get("soy"))).getCursorTime()); } private static Function getXmlElement(String pattern) { diff --git a/core/src/test/java/google/registry/cron/TldFanoutActionTest.java b/core/src/test/java/google/registry/cron/TldFanoutActionTest.java index 1e31936b3..7ae5b92ba 100644 --- a/core/src/test/java/google/registry/cron/TldFanoutActionTest.java +++ b/core/src/test/java/google/registry/cron/TldFanoutActionTest.java @@ -25,8 +25,8 @@ import com.google.cloud.tasks.v2.Task; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableSet; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.TldType; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldType; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.testing.CloudTasksHelper; @@ -81,7 +81,7 @@ class TldFanoutActionTest { @BeforeEach void beforeEach() { createTlds("com", "net", "org", "example"); - persistResource(Registry.get("example").asBuilder().setTldType(TldType.TEST).build()); + persistResource(Tld.get("example").asBuilder().setTldType(TldType.TEST).build()); } private void assertTasks(String... tasks) { diff --git a/core/src/test/java/google/registry/dns/PublishDnsUpdatesActionTest.java b/core/src/test/java/google/registry/dns/PublishDnsUpdatesActionTest.java index b40170888..39b8aef18 100644 --- a/core/src/test/java/google/registry/dns/PublishDnsUpdatesActionTest.java +++ b/core/src/test/java/google/registry/dns/PublishDnsUpdatesActionTest.java @@ -47,7 +47,7 @@ import google.registry.dns.DnsMetrics.CommitStatus; import google.registry.dns.DnsMetrics.PublishStatus; import google.registry.dns.writer.DnsWriter; import google.registry.model.domain.Domain; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.request.HttpException.ServiceUnavailableException; @@ -99,10 +99,7 @@ public class PublishDnsUpdatesActionTest { registrySupportEmail = Lazies.of(new InternetAddress("registry@test.com")); registryCcEmail = Lazies.of(new InternetAddress("registry-cc@test.com")); persistResource( - Registry.get("xn--q9jyb4c") - .asBuilder() - .setDnsWriters(ImmutableSet.of("correctWriter")) - .build()); + Tld.get("xn--q9jyb4c").asBuilder().setDnsWriters(ImmutableSet.of("correctWriter")).build()); Domain domain1 = persistActiveDomain("example.xn--q9jyb4c"); persistActiveSubordinateHost("ns1.example.xn--q9jyb4c", domain1); persistActiveSubordinateHost("ns2.example.xn--q9jyb4c", domain1); @@ -231,7 +228,7 @@ public class PublishDnsUpdatesActionTest { @Test void testAction_acquiresCorrectLock() { - persistResource(Registry.get("xn--q9jyb4c").asBuilder().setNumDnsPublishLocks(4).build()); + persistResource(Tld.get("xn--q9jyb4c").asBuilder().setNumDnsPublishLocks(4).build()); LockHandler mockLockHandler = mock(LockHandler.class); when(mockLockHandler.executeWithLocks(any(), any(), any(), any())).thenReturn(true); action = @@ -561,7 +558,7 @@ public class PublishDnsUpdatesActionTest { @Test void testParam_invalidLockIndex() { - persistResource(Registry.get("xn--q9jyb4c").asBuilder().setNumDnsPublishLocks(4).build()); + persistResource(Tld.get("xn--q9jyb4c").asBuilder().setNumDnsPublishLocks(4).build()); action = createActionWithCustomLocks( "xn--q9jyb4c", @@ -589,7 +586,7 @@ public class PublishDnsUpdatesActionTest { @Test void testRegistryParam_mismatchedMaxLocks() { - persistResource(Registry.get("xn--q9jyb4c").asBuilder().setNumDnsPublishLocks(4).build()); + persistResource(Tld.get("xn--q9jyb4c").asBuilder().setNumDnsPublishLocks(4).build()); action = createActionWithCustomLocks( "xn--q9jyb4c", diff --git a/core/src/test/java/google/registry/dns/ReadDnsQueueActionTest.java b/core/src/test/java/google/registry/dns/ReadDnsQueueActionTest.java index 9bcf6d3cb..22d448665 100644 --- a/core/src/test/java/google/registry/dns/ReadDnsQueueActionTest.java +++ b/core/src/test/java/google/registry/dns/ReadDnsQueueActionTest.java @@ -39,8 +39,8 @@ import com.google.common.collect.ImmutableSet; import com.google.common.hash.Hashing; import com.google.common.net.InternetDomainName; import google.registry.dns.DnsConstants.TargetType; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.TldType; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldType; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.testing.CloudTasksHelper; @@ -82,18 +82,16 @@ public class ReadDnsQueueActionTest { // To make sure it's never in the past, we set the date far-far into the future clock.setTo(DateTime.parse("3000-01-01TZ")); createTlds("com", "net", "example", "multilock.uk"); + persistResource(Tld.get("com").asBuilder().setDnsWriters(ImmutableSet.of("comWriter")).build()); + persistResource(Tld.get("net").asBuilder().setDnsWriters(ImmutableSet.of("netWriter")).build()); persistResource( - Registry.get("com").asBuilder().setDnsWriters(ImmutableSet.of("comWriter")).build()); - persistResource( - Registry.get("net").asBuilder().setDnsWriters(ImmutableSet.of("netWriter")).build()); - persistResource( - Registry.get("example") + Tld.get("example") .asBuilder() .setTldType(TldType.TEST) .setDnsWriters(ImmutableSet.of("exampleWriter")) .build()); persistResource( - Registry.get("multilock.uk") + Tld.get("multilock.uk") .asBuilder() .setNumDnsPublishLocks(1000) .setDnsWriters(ImmutableSet.of("multilockWriter")) @@ -217,7 +215,7 @@ public class ReadDnsQueueActionTest { @RetryingTest(4) void testSuccess_twoDnsWriters() { persistResource( - Registry.get("com") + Tld.get("com") .asBuilder() .setDnsWriters(ImmutableSet.of("comWriter", "otherWriter")) .build()); @@ -256,7 +254,7 @@ public class ReadDnsQueueActionTest { @RetryingTest(4) void testSuccess_oneTldPaused_returnedToQueue() { - persistResource(Registry.get("net").asBuilder().setDnsPaused(true).build()); + persistResource(Tld.get("net").asBuilder().setDnsPaused(true).build()); dnsQueue.addDomainRefreshTask("domain.com"); dnsQueue.addDomainRefreshTask("domain.net"); dnsQueue.addDomainRefreshTask("domain.example"); diff --git a/core/src/test/java/google/registry/dns/ReadDnsRefreshRequestsActionTest.java b/core/src/test/java/google/registry/dns/ReadDnsRefreshRequestsActionTest.java index 6d0b0a71b..2bbb7af2e 100644 --- a/core/src/test/java/google/registry/dns/ReadDnsRefreshRequestsActionTest.java +++ b/core/src/test/java/google/registry/dns/ReadDnsRefreshRequestsActionTest.java @@ -43,7 +43,7 @@ import com.google.common.collect.Ordering; import google.registry.dns.DnsConstants.TargetType; import google.registry.model.common.DnsRefreshRequest; import google.registry.model.common.DnsRefreshRequestTest; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.testing.CloudTasksHelper; @@ -151,7 +151,7 @@ public class ReadDnsRefreshRequestsActionTest { @Test void testSuccess_runAction_twoBatches() { // Make the read batch size 2 * 1 = 2. - persistResource(Registry.get("tld").asBuilder().setNumDnsPublishLocks(1).build()); + persistResource(Tld.get("tld").asBuilder().setNumDnsPublishLocks(1).build()); doReturn(1).when(action).getLockIndex(anyInt(), any(DnsRefreshRequest.class)); doAnswer( invocation -> { @@ -181,7 +181,7 @@ public class ReadDnsRefreshRequestsActionTest { @Test void testSuccess_runAction_timeOutAfterFirstRead() { // Make the process batch size 2 * 1 = 2. - persistResource(Registry.get("tld").asBuilder().setNumDnsPublishLocks(1).build()); + persistResource(Tld.get("tld").asBuilder().setNumDnsPublishLocks(1).build()); // Both requests in the first batch will be bucketed to the same bucket. doReturn(1).when(action).getLockIndex(anyInt(), any(DnsRefreshRequest.class)); doAnswer( diff --git a/core/src/test/java/google/registry/export/ExportDomainListsActionTest.java b/core/src/test/java/google/registry/export/ExportDomainListsActionTest.java index 3235e420d..b1332472f 100644 --- a/core/src/test/java/google/registry/export/ExportDomainListsActionTest.java +++ b/core/src/test/java/google/registry/export/ExportDomainListsActionTest.java @@ -33,8 +33,8 @@ import com.google.cloud.storage.contrib.nio.testing.LocalStorageHelper; import com.google.common.collect.ImmutableList; import com.google.common.net.MediaType; import google.registry.gcs.GcsUtils; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.TldType; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldType; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.storage.drive.DriveConnection; @@ -62,8 +62,8 @@ class ExportDomainListsActionTest { void beforeEach() { createTld("tld"); createTld("testtld"); - persistResource(Registry.get("tld").asBuilder().setDriveFolderId("brouhaha").build()); - persistResource(Registry.get("testtld").asBuilder().setTldType(TldType.TEST).build()); + persistResource(Tld.get("tld").asBuilder().setDriveFolderId("brouhaha").build()); + persistResource(Tld.get("testtld").asBuilder().setTldType(TldType.TEST).build()); action = new ExportDomainListsAction(); action.gcsBucket = "outputbucket"; @@ -118,7 +118,7 @@ class ExportDomainListsActionTest { @Test void test_outputsDomainsFromDifferentTldsToMultipleFiles() throws Exception { createTld("tldtwo"); - persistResource(Registry.get("tldtwo").asBuilder().setDriveFolderId("hooray").build()); + persistResource(Tld.get("tldtwo").asBuilder().setDriveFolderId("hooray").build()); createTld("tldthree"); // You'd think this test was written around Christmas, but it wasn't. diff --git a/core/src/test/java/google/registry/export/ExportPremiumTermsActionTest.java b/core/src/test/java/google/registry/export/ExportPremiumTermsActionTest.java index 78c3d1493..41f206e4b 100644 --- a/core/src/test/java/google/registry/export/ExportPremiumTermsActionTest.java +++ b/core/src/test/java/google/registry/export/ExportPremiumTermsActionTest.java @@ -36,7 +36,7 @@ import static org.mockito.Mockito.when; import com.google.common.collect.ImmutableList; import com.google.common.net.MediaType; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.tld.label.PremiumList; import google.registry.model.tld.label.PremiumListDao; import google.registry.persistence.transaction.JpaTestExtensions; @@ -70,7 +70,7 @@ public class ExportPremiumTermsActionTest { action.response = response; action.driveConnection = driveConnection; action.exportDisclaimer = DISCLAIMER_WITH_NEWLINE; - action.tld = tld; + action.tldStr = tld; action.run(); } @@ -79,7 +79,7 @@ public class ExportPremiumTermsActionTest { createTld("tld"); PremiumList pl = PremiumListDao.save("pl-name", USD, PREMIUM_NAMES); persistResource( - Registry.get("tld").asBuilder().setPremiumList(pl).setDriveFolderId("folder_id").build()); + Tld.get("tld").asBuilder().setPremiumList(pl).setDriveFolderId("folder_id").build()); when(driveConnection.createOrUpdateFile( anyString(), any(MediaType.class), eq("folder_id"), any(byte[].class))) .thenReturn("file_id"); @@ -108,7 +108,7 @@ public class ExportPremiumTermsActionTest { @Test void test_exportPremiumTerms_doNothing_listNotConfigured() { - persistResource(Registry.get("tld").asBuilder().setPremiumList(null).build()); + persistResource(Tld.get("tld").asBuilder().setPremiumList(null).build()); runAction("tld"); verifyNoInteractions(driveConnection); @@ -120,7 +120,7 @@ public class ExportPremiumTermsActionTest { @Test void testExportPremiumTerms_doNothing_driveIdNotConfiguredInTld() { - persistResource(Registry.get("tld").asBuilder().setDriveFolderId(null).build()); + persistResource(Tld.get("tld").asBuilder().setDriveFolderId(null).build()); runAction("tld"); verifyNoInteractions(driveConnection); @@ -157,7 +157,7 @@ public class ExportPremiumTermsActionTest { @Test void testExportPremiumTerms_failure_driveIdThrowsException() throws IOException { - persistResource(Registry.get("tld").asBuilder().setDriveFolderId("bad_folder_id").build()); + persistResource(Tld.get("tld").asBuilder().setDriveFolderId("bad_folder_id").build()); assertThrows(RuntimeException.class, () -> runAction("tld")); verify(driveConnection) diff --git a/core/src/test/java/google/registry/export/ExportReservedTermsActionTest.java b/core/src/test/java/google/registry/export/ExportReservedTermsActionTest.java index d303aed52..3a21bb258 100644 --- a/core/src/test/java/google/registry/export/ExportReservedTermsActionTest.java +++ b/core/src/test/java/google/registry/export/ExportReservedTermsActionTest.java @@ -32,7 +32,7 @@ import static org.mockito.Mockito.when; import com.google.common.collect.ImmutableSet; import com.google.common.net.MediaType; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.tld.label.ReservedList; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; @@ -57,7 +57,7 @@ public class ExportReservedTermsActionTest { action.response = response; action.driveConnection = driveConnection; action.exportUtils = new ExportUtils("# This is a disclaimer."); - action.tld = tld; + action.tldStr = tld; action.run(); } @@ -68,9 +68,8 @@ public class ExportReservedTermsActionTest { "lol,FULLY_BLOCKED", "cat,FULLY_BLOCKED"); createTld("tld"); - persistResource(Registry.get("tld").asBuilder() - .setReservedLists(rl) - .setDriveFolderId("brouhaha").build()); + persistResource( + Tld.get("tld").asBuilder().setReservedLists(rl).setDriveFolderId("brouhaha").build()); when(driveConnection.createOrUpdateFile( anyString(), any(MediaType.class), @@ -91,7 +90,7 @@ public class ExportReservedTermsActionTest { @Test void test_uploadFileToDrive_doesNothingIfReservedListsNotConfigured() { persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setReservedLists(ImmutableSet.of()) .setDriveFolderId(null) @@ -103,7 +102,7 @@ public class ExportReservedTermsActionTest { @Test void test_uploadFileToDrive_doesNothingWhenDriveFolderIdIsNull() { - persistResource(Registry.get("tld").asBuilder().setDriveFolderId(null).build()); + persistResource(Tld.get("tld").asBuilder().setDriveFolderId(null).build()); runAction("tld"); verify(response).setStatus(SC_OK); verify(response) @@ -129,6 +128,6 @@ public class ExportReservedTermsActionTest { assertThat(thrown) .hasCauseThat() .hasMessageThat() - .isEqualTo("No registry object(s) found for fakeTld"); + .isEqualTo("No TLD object(s) found for fakeTld"); } } diff --git a/core/src/test/java/google/registry/export/ExportUtilsTest.java b/core/src/test/java/google/registry/export/ExportUtilsTest.java index def5b5f17..cfa496ee9 100644 --- a/core/src/test/java/google/registry/export/ExportUtilsTest.java +++ b/core/src/test/java/google/registry/export/ExportUtilsTest.java @@ -19,7 +19,7 @@ import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.persistReservedList; import static google.registry.testing.DatabaseHelper.persistResource; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.tld.label.ReservedList; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; @@ -48,9 +48,9 @@ class ExportUtilsTest { false, "tine,FULLY_BLOCKED"); createTld("tld"); - persistResource(Registry.get("tld").asBuilder().setReservedLists(rl1, rl2, rl3).build()); + persistResource(Tld.get("tld").asBuilder().setReservedLists(rl1, rl2, rl3).build()); // Should not contain jimmy, tine, or oval. - assertThat(new ExportUtils("# This is a disclaimer.").exportReservedTerms(Registry.get("tld"))) + assertThat(new ExportUtils("# This is a disclaimer.").exportReservedTerms(Tld.get("tld"))) .isEqualTo("# This is a disclaimer.\ncat\nlol\nsnow\n"); } } diff --git a/core/src/test/java/google/registry/flows/CheckApiActionTest.java b/core/src/test/java/google/registry/flows/CheckApiActionTest.java index 9f20989a9..15e6a8ed1 100644 --- a/core/src/test/java/google/registry/flows/CheckApiActionTest.java +++ b/core/src/test/java/google/registry/flows/CheckApiActionTest.java @@ -16,7 +16,7 @@ package google.registry.flows; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth8.assertThat; -import static google.registry.model.tld.Registry.TldState.PREDELEGATION; +import static google.registry.model.tld.Tld.TldState.PREDELEGATION; import static google.registry.monitoring.whitebox.CheckApiMetric.Availability.AVAILABLE; import static google.registry.monitoring.whitebox.CheckApiMetric.Availability.REGISTERED; import static google.registry.monitoring.whitebox.CheckApiMetric.Availability.RESERVED; @@ -28,7 +28,7 @@ import static google.registry.testing.DatabaseHelper.persistReservedList; import static google.registry.testing.DatabaseHelper.persistResource; import static org.mockito.Mockito.verify; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.monitoring.whitebox.CheckApiMetric; import google.registry.monitoring.whitebox.CheckApiMetric.Availability; import google.registry.monitoring.whitebox.CheckApiMetric.Status; @@ -68,7 +68,7 @@ class CheckApiActionTest { void beforeEach() { createTld("example"); persistResource( - Registry.get("example") + Tld.get("example") .asBuilder() .setReservedLists( persistReservedList( diff --git a/core/src/test/java/google/registry/flows/EppLifecycleDomainTest.java b/core/src/test/java/google/registry/flows/EppLifecycleDomainTest.java index ad875c971..8fc5a567a 100644 --- a/core/src/test/java/google/registry/flows/EppLifecycleDomainTest.java +++ b/core/src/test/java/google/registry/flows/EppLifecycleDomainTest.java @@ -18,9 +18,9 @@ import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.model.eppoutput.Result.Code.SUCCESS; import static google.registry.model.eppoutput.Result.Code.SUCCESS_AND_CLOSE; import static google.registry.model.eppoutput.Result.Code.SUCCESS_WITH_ACTION_PENDING; -import static google.registry.model.tld.Registry.TldState.GENERAL_AVAILABILITY; -import static google.registry.model.tld.Registry.TldState.PREDELEGATION; -import static google.registry.model.tld.Registry.TldState.START_DATE_SUNRISE; +import static google.registry.model.tld.Tld.TldState.GENERAL_AVAILABILITY; +import static google.registry.model.tld.Tld.TldState.PREDELEGATION; +import static google.registry.model.tld.Tld.TldState.START_DATE_SUNRISE; import static google.registry.testing.DatabaseHelper.assertBillingEventsForResource; import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.createTlds; @@ -44,8 +44,8 @@ import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.domain.Domain; import google.registry.model.domain.DomainHistory; import google.registry.model.reporting.HistoryEntry.Type; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.TldState; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldState; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.testing.TaskQueueExtension; @@ -512,13 +512,16 @@ class EppLifecycleDomainTest extends EppTestCase { // Set the EAP schedule. persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setEapFeeSchedule( ImmutableSortedMap.of( - START_OF_TIME, Money.of(USD, 0), - DateTime.parse("2000-06-01T00:00:00Z"), Money.of(USD, 100), - DateTime.parse("2000-06-02T00:00:00Z"), Money.of(USD, 0))) + START_OF_TIME, + Money.of(USD, 0), + DateTime.parse("2000-06-01T00:00:00Z"), + Money.of(USD, 100), + DateTime.parse("2000-06-02T00:00:00Z"), + Money.of(USD, 0))) .build()); // Create domain example.tld, which should have an EAP fee of USD 100. @@ -546,7 +549,7 @@ class EppLifecycleDomainTest extends EppTestCase { .setPeriodYears(1) .setCost(Money.parse("USD 100.00")) .setEventTime(createTime) - .setBillingTime(createTime.plus(Registry.get("tld").getRenewGracePeriodLength())) + .setBillingTime(createTime.plus(Tld.get("tld").getRenewGracePeriodLength())) .setDomainHistory( getOnlyHistoryEntryOfType(domain, Type.DOMAIN_CREATE, DomainHistory.class)) .build(); diff --git a/core/src/test/java/google/registry/flows/EppTestCase.java b/core/src/test/java/google/registry/flows/EppTestCase.java index bbfa612e4..b9aa451d7 100644 --- a/core/src/test/java/google/registry/flows/EppTestCase.java +++ b/core/src/test/java/google/registry/flows/EppTestCase.java @@ -36,7 +36,7 @@ import google.registry.model.domain.Domain; import google.registry.model.domain.DomainHistory; import google.registry.model.eppcommon.EppXmlTransformer; import google.registry.model.reporting.HistoryEntry.Type; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.monitoring.whitebox.EppMetric; import google.registry.persistence.VKey; import google.registry.testing.FakeClock; @@ -310,7 +310,7 @@ public class EppTestCase { .setCost(Money.parse("USD 26.00")) .setPeriodYears(2) .setEventTime(createTime) - .setBillingTime(createTime.plus(Registry.get(domain.getTld()).getAddGracePeriodLength())) + .setBillingTime(createTime.plus(Tld.get(domain.getTld()).getAddGracePeriodLength())) .setDomainHistory( getOnlyHistoryEntryOfType(domain, Type.DOMAIN_CREATE, DomainHistory.class)) .build(); @@ -325,7 +325,7 @@ public class EppTestCase { .setCost(Money.parse("USD 33.00")) .setPeriodYears(3) .setEventTime(renewTime) - .setBillingTime(renewTime.plus(Registry.get(domain.getTld()).getRenewGracePeriodLength())) + .setBillingTime(renewTime.plus(Tld.get(domain.getTld()).getRenewGracePeriodLength())) .setDomainHistory(getOnlyHistoryEntryOfType(domain, Type.DOMAIN_RENEW, DomainHistory.class)) .build(); } @@ -372,7 +372,7 @@ public class EppTestCase { .setRegistrarId(domain.getCurrentSponsorRegistrarId()) .setEventTime(deleteTime) .setOneTimeEventKey(findKeyToActualOneTimeBillingEvent(billingEventToCancel)) - .setBillingTime(createTime.plus(Registry.get(domain.getTld()).getAddGracePeriodLength())) + .setBillingTime(createTime.plus(Tld.get(domain.getTld()).getAddGracePeriodLength())) .setReason(Reason.CREATE) .setDomainHistory( getOnlyHistoryEntryOfType(domain, Type.DOMAIN_DELETE, DomainHistory.class)) @@ -387,7 +387,7 @@ public class EppTestCase { .setRegistrarId(domain.getCurrentSponsorRegistrarId()) .setEventTime(deleteTime) .setOneTimeEventKey(findKeyToActualOneTimeBillingEvent(billingEventToCancel)) - .setBillingTime(renewTime.plus(Registry.get(domain.getTld()).getRenewGracePeriodLength())) + .setBillingTime(renewTime.plus(Tld.get(domain.getTld()).getRenewGracePeriodLength())) .setReason(Reason.RENEW) .setDomainHistory( getOnlyHistoryEntryOfType(domain, Type.DOMAIN_DELETE, DomainHistory.class)) diff --git a/core/src/test/java/google/registry/flows/contact/ContactDeleteFlowTest.java b/core/src/test/java/google/registry/flows/contact/ContactDeleteFlowTest.java index 4df9d0332..7303afa4a 100644 --- a/core/src/test/java/google/registry/flows/contact/ContactDeleteFlowTest.java +++ b/core/src/test/java/google/registry/flows/contact/ContactDeleteFlowTest.java @@ -44,7 +44,7 @@ import google.registry.model.poll.PendingActionNotificationResponse; import google.registry.model.poll.PollMessage; import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry.Type; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.transfer.TransferData; import google.registry.model.transfer.TransferResponse; import google.registry.model.transfer.TransferStatus; @@ -90,7 +90,7 @@ class ContactDeleteFlowTest extends ResourceFlowTestCase(Ordering.natural()) @@ -1059,7 +1059,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase(Ordering.natural()) @@ -1136,8 +1136,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase(Ordering.natural()) diff --git a/core/src/test/java/google/registry/flows/domain/DomainClaimsCheckFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainClaimsCheckFlowTest.java index b49904ac0..4dd4fb9e9 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainClaimsCheckFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainClaimsCheckFlowTest.java @@ -14,7 +14,7 @@ package google.registry.flows.domain; -import static google.registry.model.tld.Registry.TldState.PREDELEGATION; +import static google.registry.model.tld.Tld.TldState.PREDELEGATION; import static google.registry.testing.DatabaseHelper.assertNoBillingEvents; import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.createTlds; @@ -39,8 +39,8 @@ import google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException import google.registry.flows.domain.DomainFlowUtils.TldDoesNotExistException; import google.registry.flows.exceptions.TooManyResourceChecksException; import google.registry.model.domain.Domain; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.TldState; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldState; import org.joda.money.Money; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -131,7 +131,7 @@ public class DomainClaimsCheckFlowTest extends ResourceFlowTestCase(Ordering.natural()) @@ -1518,7 +1512,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase { private void persistFoobarTld(TldType tldType) { persistResource( - newRegistry("foobar", "FOOBAR") + newTld("foobar", "FOOBAR") .asBuilder() .setTldType(tldType) .setCurrency(CHF) diff --git a/core/src/test/java/google/registry/flows/domain/DomainInfoFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainInfoFlowTest.java index c15e6d1e6..dda151e16 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainInfoFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainInfoFlowTest.java @@ -20,7 +20,7 @@ import static google.registry.model.billing.BillingEvent.RenewalPriceBehavior.DE import static google.registry.model.billing.BillingEvent.RenewalPriceBehavior.NONPREMIUM; import static google.registry.model.billing.BillingEvent.RenewalPriceBehavior.SPECIFIED; import static google.registry.model.eppcommon.EppXmlTransformer.marshal; -import static google.registry.model.tld.Registry.TldState.QUIET_PERIOD; +import static google.registry.model.tld.Tld.TldState.QUIET_PERIOD; import static google.registry.testing.DatabaseHelper.assertNoBillingEvents; import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.persistActiveContact; @@ -72,7 +72,7 @@ import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppoutput.EppOutput; import google.registry.model.host.Host; import google.registry.model.reporting.HistoryEntry; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.VKey; import google.registry.persistence.transaction.JpaTransactionManagerExtension; import google.registry.testing.DatabaseHelper; @@ -322,7 +322,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase { @Test void testSuccess_inQuietPeriod() throws Exception { persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setTldStateTransitions(ImmutableSortedMap.of(START_OF_TIME, QUIET_PERIOD)) .build()); @@ -853,7 +853,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase { void testFeeExtension_renewCommandPremium_anchorTenant() throws Exception { createTld("tld"); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setPremiumList(persistPremiumList("tld", USD, "example,USD 70")) .build()); @@ -873,7 +873,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase { void testFeeExtension_renewCommandPremium_internalRegistration() throws Exception { createTld("tld"); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setPremiumList(persistPremiumList("tld", USD, "example,USD 70")) .build()); @@ -893,7 +893,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase { void testFeeExtension_renewCommandPremium_anchorTenant_multiYear() throws Exception { createTld("tld"); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setPremiumList(persistPremiumList("tld", USD, "example,USD 70")) .build()); @@ -913,7 +913,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase { void testFeeExtension_renewCommandPremium_internalRegistration_multiYear() throws Exception { createTld("tld"); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setPremiumList(persistPremiumList("tld", USD, "example,USD 70")) .build()); diff --git a/core/src/test/java/google/registry/flows/domain/DomainPricingLogicTest.java b/core/src/test/java/google/registry/flows/domain/DomainPricingLogicTest.java index 63990ed3b..43b6f9497 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainPricingLogicTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainPricingLogicTest.java @@ -49,7 +49,7 @@ import google.registry.model.domain.DomainHistory; import google.registry.model.domain.fee.Fee; import google.registry.model.domain.token.AllocationToken; import google.registry.model.eppinput.EppInput; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.testing.DatabaseHelper; @@ -77,7 +77,7 @@ public class DomainPricingLogicTest { @Mock EppInput eppInput; SessionMetadata sessionMetadata; @Mock FlowMetadata flowMetadata; - Registry registry; + Tld registry; Domain domain; @BeforeEach @@ -89,7 +89,7 @@ public class DomainPricingLogicTest { new DomainPricingCustomLogic(eppInput, sessionMetadata, flowMetadata)); registry = persistResource( - Registry.get("example") + Tld.get("example") .asBuilder() .setRenewBillingCostTransitions( ImmutableSortedMap.of( diff --git a/core/src/test/java/google/registry/flows/domain/DomainRenewFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainRenewFlowTest.java index 953b6cbf6..fb4d5a432 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainRenewFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainRenewFlowTest.java @@ -99,7 +99,7 @@ import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField; import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry.HistoryEntryId; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.VKey; import google.registry.testing.DatabaseHelper; import java.util.Map; @@ -281,7 +281,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase .setCost(totalRenewCost) .setPeriodYears(renewalYears) .setEventTime(clock.nowUtc()) - .setBillingTime(clock.nowUtc().plus(Registry.get("tld").getRenewGracePeriodLength())) + .setBillingTime(clock.nowUtc().plus(Tld.get("tld").getRenewGracePeriodLength())) .setDomainHistory(historyEntryDomainRenew) .build(); assertBillingEvents( @@ -327,7 +327,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase GracePeriod.create( GracePeriodStatus.RENEW, domain.getRepoId(), - clock.nowUtc().plus(Registry.get("tld").getRenewGracePeriodLength()), + clock.nowUtc().plus(Tld.get("tld").getRenewGracePeriodLength()), renewalClientId, null), renewBillingEvent)); @@ -397,7 +397,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase @Test void testSuccess_internalRegiration_premiumDomain() throws Exception { persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setPremiumList(persistPremiumList("tld", USD, "example,USD 100")) .build()); @@ -434,7 +434,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase @Test void testSuccess_anchorTenant_premiumDomain() throws Exception { persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setPremiumList(persistPremiumList("tld", USD, "example,USD 100")) .build()); @@ -842,10 +842,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase @Test void testSuccess_nonDefaultRenewGracePeriod() throws Exception { persistResource( - Registry.get("tld") - .asBuilder() - .setRenewGracePeriodLength(Duration.standardMinutes(9)) - .build()); + Tld.get("tld").asBuilder().setRenewGracePeriodLength(Duration.standardMinutes(9)).build()); persistDomain(); doSuccessfulTest( "domain_renew_response.xml", @@ -994,7 +991,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase void testFailure_wrongFeeAmount_v06() throws Exception { setEppInput("domain_renew_fee.xml", FEE_06_MAP); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20))) .build()); @@ -1007,7 +1004,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase void testFailure_wrongFeeAmount_v11() throws Exception { setEppInput("domain_renew_fee.xml", FEE_11_MAP); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20))) .build()); @@ -1020,7 +1017,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase void testFailure_wrongFeeAmount_v12() throws Exception { setEppInput("domain_renew_fee.xml", FEE_12_MAP); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20))) .build()); @@ -1033,7 +1030,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase void testFailure_wrongCurrency_v06() throws Exception { setEppInput("domain_renew_fee.xml", FEE_06_MAP); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setCurrency(EUR) .setCreateBillingCost(Money.of(EUR, 13)) @@ -1052,7 +1049,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase void testFailure_wrongCurrency_v11() throws Exception { setEppInput("domain_renew_fee.xml", FEE_11_MAP); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setCurrency(EUR) .setCreateBillingCost(Money.of(EUR, 13)) @@ -1071,7 +1068,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase void testFailure_wrongCurrency_v12() throws Exception { setEppInput("domain_renew_fee.xml", FEE_12_MAP); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setCurrency(EUR) .setCreateBillingCost(Money.of(EUR, 13)) @@ -1114,7 +1111,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase void testFailure_missingBillingAccountMap() throws Exception { persistDomain(); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setCurrency(JPY) .setCreateBillingCost(Money.ofMajor(JPY, 800)) @@ -1236,10 +1233,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase persistDomain(); // Test with a nonstandard Renew period to ensure the reporting time is correct regardless persistResource( - Registry.get("tld") - .asBuilder() - .setRenewGracePeriodLength(Duration.standardMinutes(9)) - .build()); + Tld.get("tld").asBuilder().setRenewGracePeriodLength(Duration.standardMinutes(9)).build()); runFlow(); Domain domain = reloadResourceByForeignKey(); DomainHistory historyEntry = @@ -1401,7 +1395,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase .setAllowedTlds(ImmutableSet.of("tld")) .build()); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setDefaultPromoTokens( ImmutableList.of(defaultToken1.createVKey(), defaultToken2.createVKey())) @@ -1452,7 +1446,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase .setAllowedTlds(ImmutableSet.of("tld")) .build()); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setDefaultPromoTokens( ImmutableList.of(defaultToken1.createVKey(), defaultToken2.createVKey())) @@ -1495,7 +1489,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase .setAllowedTlds(ImmutableSet.of("tld")) .build()); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setDefaultPromoTokens( ImmutableList.of(defaultToken1.createVKey(), defaultToken2.createVKey())) @@ -1544,7 +1538,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase .setAllowedTlds(ImmutableSet.of("tld")) .build()); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setDefaultPromoTokens( ImmutableList.of( @@ -1588,7 +1582,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase .setAllowedTlds(ImmutableSet.of("tld")) .build()); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setDefaultPromoTokens( ImmutableList.of(defaultToken1.createVKey(), defaultToken2.createVKey())) @@ -1621,7 +1615,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase .setAllowedTlds(ImmutableSet.of("tld")) .build()); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setDefaultPromoTokens(ImmutableList.of(defaultToken1.createVKey())) .build()); @@ -1659,7 +1653,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase .setAllowedTlds(ImmutableSet.of("tld")) .build()); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setDefaultPromoTokens(ImmutableList.of(defaultToken1.createVKey())) .setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20))) @@ -1682,7 +1676,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase .setAllowedTlds(ImmutableSet.of("tld")) .build()); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setDefaultPromoTokens(ImmutableList.of(defaultToken1.createVKey())) .build()); @@ -1720,7 +1714,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase .setAllowedTlds(ImmutableSet.of("tld")) .build()); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setDefaultPromoTokens(ImmutableList.of(defaultToken1.createVKey())) .setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20))) @@ -1743,7 +1737,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase .setAllowedTlds(ImmutableSet.of("tld")) .build()); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setDefaultPromoTokens(ImmutableList.of(defaultToken1.createVKey())) .build()); @@ -1781,7 +1775,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase .setAllowedTlds(ImmutableSet.of("tld")) .build()); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setDefaultPromoTokens(ImmutableList.of(defaultToken1.createVKey())) .setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20))) diff --git a/core/src/test/java/google/registry/flows/domain/DomainRestoreRequestFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainRestoreRequestFlowTest.java index e7a5fb1f4..84248373d 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainRestoreRequestFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainRestoreRequestFlowTest.java @@ -72,7 +72,7 @@ import google.registry.model.registrar.Registrar.State; import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField; import google.registry.model.reporting.HistoryEntry; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.testing.DatabaseHelper; import java.util.Map; import java.util.Optional; @@ -469,7 +469,7 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase(Ordering.natural()) @@ -185,7 +185,7 @@ class DomainTransferApproveFlowTest DateTime expectedExpirationTime) throws Exception { setEppLoader(commandFilename); - Registry registry = Registry.get(tld); + Tld registry = Tld.get(tld); domain = reloadResourceByForeignKey(); // Make sure the implicit billing event is there; it will be deleted by the flow. // We also expect to see autorenew events for the gaining and losing registrars. @@ -271,7 +271,7 @@ class DomainTransferApproveFlowTest int expectedYearsToCharge, BillingEvent.Cancellation.Builder... expectedCancellationBillingEvents) throws Exception { - Registry registry = Registry.get(tld); + Tld registry = Tld.get(tld); domain = reloadResourceByForeignKey(); final DomainHistory historyEntryTransferApproved = getOnlyHistoryEntryOfType(domain, DOMAIN_TRANSFER_APPROVE, DomainHistory.class); @@ -471,7 +471,7 @@ class DomainTransferApproveFlowTest // with the new transfer grace period in mind. createTld("net"); persistResource( - Registry.get("net") + Tld.get("net") .asBuilder() .setTransferGracePeriodLength(Duration.standardMinutes(10)) .build()); @@ -515,8 +515,7 @@ class DomainTransferApproveFlowTest .setTargetId("example.tld") .setRegistrarId("TheRegistrar") .setEventTime(clock.nowUtc()) // The cancellation happens at the moment of transfer. - .setBillingTime( - oldExpirationTime.plus(Registry.get("tld").getAutoRenewGracePeriodLength())) + .setBillingTime(oldExpirationTime.plus(Tld.get("tld").getAutoRenewGracePeriodLength())) .setRecurringEventKey(domain.getAutorenewBillingEvent())); } @@ -529,7 +528,7 @@ class DomainTransferApproveFlowTest .setName("tld") .setLabelsToPrices(ImmutableMap.of("example", new BigDecimal("67.89"))) .build()); - persistResource(Registry.get("tld").asBuilder().setPremiumList(pl).build()); + persistResource(Tld.get("tld").asBuilder().setPremiumList(pl).build()); domain = loadByEntity(domain); persistResource( loadByKey(domain.getAutorenewBillingEvent()) @@ -575,7 +574,7 @@ class DomainTransferApproveFlowTest .setName("tld") .setLabelsToPrices(ImmutableMap.of("example", new BigDecimal("67.89"))) .build()); - persistResource(Registry.get("tld").asBuilder().setPremiumList(pl).build()); + persistResource(Tld.get("tld").asBuilder().setPremiumList(pl).build()); domain = loadByEntity(domain); persistResource( loadByKey(domain.getAutorenewBillingEvent()) @@ -773,7 +772,7 @@ class DomainTransferApproveFlowTest private void setUpGracePeriodDurations() { persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setAutomaticTransferLength(Duration.standardDays(2)) .setTransferGracePeriodLength(Duration.standardDays(3)) @@ -863,7 +862,7 @@ class DomainTransferApproveFlowTest GracePeriod.createForRecurring( GracePeriodStatus.AUTO_RENEW, domain.getRepoId(), - autorenewTime.plus(Registry.get("tld").getAutoRenewGracePeriodLength()), + autorenewTime.plus(Tld.get("tld").getAutoRenewGracePeriodLength()), "TheRegistrar", existingAutorenewEvent)) .build()); diff --git a/core/src/test/java/google/registry/flows/domain/DomainTransferCancelFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainTransferCancelFlowTest.java index 895bf5663..259a49c0f 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainTransferCancelFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainTransferCancelFlowTest.java @@ -52,7 +52,7 @@ import google.registry.model.eppcommon.AuthInfo.PasswordAuth; import google.registry.model.poll.PollMessage; import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.HistoryEntry; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.transfer.DomainTransferData; import google.registry.model.transfer.TransferResponse.DomainTransferResponse; import google.registry.model.transfer.TransferStatus; @@ -391,7 +391,7 @@ class DomainTransferCancelFlowTest void testIcannTransactionRecord_cancelsPreviousRecords() throws Exception { clock.advanceOneMilli(); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setAutomaticTransferLength(Duration.standardDays(2)) .setTransferGracePeriodLength(Duration.standardDays(3)) diff --git a/core/src/test/java/google/registry/flows/domain/DomainTransferFlowTestCase.java b/core/src/test/java/google/registry/flows/domain/DomainTransferFlowTestCase.java index 78038ac26..1dbd4ac65 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainTransferFlowTestCase.java +++ b/core/src/test/java/google/registry/flows/domain/DomainTransferFlowTestCase.java @@ -41,7 +41,7 @@ import google.registry.model.domain.DomainHistory; import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.Host; import google.registry.model.reporting.HistoryEntry; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.transfer.TransferData; import google.registry.model.transfer.TransferStatus; import google.registry.persistence.transaction.JpaTransactionManagerExtension; @@ -63,7 +63,7 @@ abstract class DomainTransferFlowTestCase static final DateTime TRANSFER_REQUEST_TIME = DateTime.parse("2000-06-06T22:00:00.0Z"); static final DateTime TRANSFER_EXPIRATION_TIME = - TRANSFER_REQUEST_TIME.plus(Registry.DEFAULT_AUTOMATIC_TRANSFER_LENGTH); + TRANSFER_REQUEST_TIME.plus(Tld.DEFAULT_AUTOMATIC_TRANSFER_LENGTH); private static final Duration TIME_SINCE_REQUEST = Duration.standardDays(3); private static final int EXTENDED_REGISTRATION_YEARS = 1; private static final DateTime REGISTRATION_EXPIRATION_TIME = @@ -77,7 +77,7 @@ abstract class DomainTransferFlowTestCase private DomainHistory historyEntryDomainCreate; DomainTransferFlowTestCase() { - checkState(!Registry.DEFAULT_TRANSFER_GRACE_PERIOD.isShorterThan(TIME_SINCE_REQUEST)); + checkState(!Tld.DEFAULT_TRANSFER_GRACE_PERIOD.isShorterThan(TIME_SINCE_REQUEST)); clock.setTo(TRANSFER_REQUEST_TIME.plus(TIME_SINCE_REQUEST)); } diff --git a/core/src/test/java/google/registry/flows/domain/DomainTransferRejectFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainTransferRejectFlowTest.java index 0991cedce..568d6e553 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainTransferRejectFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainTransferRejectFlowTest.java @@ -54,7 +54,7 @@ import google.registry.model.poll.PendingActionNotificationResponse; import google.registry.model.poll.PollMessage; import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.HistoryEntry; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.transfer.TransferData; import google.registry.model.transfer.TransferResponse; import google.registry.model.transfer.TransferStatus; @@ -343,7 +343,7 @@ class DomainTransferRejectFlowTest private void setUpGracePeriodDurations() { persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setAutomaticTransferLength(Duration.standardDays(2)) .setTransferGracePeriodLength(Duration.standardDays(3)) diff --git a/core/src/test/java/google/registry/flows/domain/DomainTransferRequestFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainTransferRequestFlowTest.java index ce4a1888c..44599a5eb 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainTransferRequestFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainTransferRequestFlowTest.java @@ -27,7 +27,7 @@ import static google.registry.model.domain.token.AllocationToken.TokenType.UNLIM import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.TRANSFER_SUCCESSFUL; import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_CREATE; import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST; -import static google.registry.model.tld.Registry.TldState.QUIET_PERIOD; +import static google.registry.model.tld.Tld.TldState.QUIET_PERIOD; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.testing.DatabaseHelper.assertBillingEvents; import static google.registry.testing.DatabaseHelper.assertBillingEventsEqual; @@ -115,7 +115,7 @@ import google.registry.model.registrar.Registrar.State; import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry.HistoryEntryId; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.tld.label.PremiumList; import google.registry.model.tld.label.PremiumListDao; import google.registry.model.transfer.DomainTransferData; @@ -259,7 +259,7 @@ class DomainTransferRequestFlowTest ImmutableSet originalGracePeriods, boolean expectTransferBillingEvent, BillingEvent.Cancellation.Builder... extraExpectedBillingEvents) { - Registry registry = Registry.get(domain.getTld()); + Tld registry = Tld.get(domain.getTld()); final DomainHistory historyEntryTransferRequest = getOnlyHistoryEntryOfType(domain, DOMAIN_TRANSFER_REQUEST, DomainHistory.class); @@ -435,7 +435,7 @@ class DomainTransferRequestFlowTest private void assertAboutDomainAfterAutomaticTransfer( DateTime expectedExpirationTime, DateTime implicitTransferTime, Period expectedPeriod) throws Exception { - Registry registry = Registry.get(domain.getTld()); + Tld registry = Tld.get(domain.getTld()); Domain domainAfterAutomaticTransfer = domain.cloneProjectedAtTime(implicitTransferTime); assertTransferApproved(domainAfterAutomaticTransfer, implicitTransferTime, expectedPeriod); assertAboutDomains() @@ -477,7 +477,7 @@ class DomainTransferRequestFlowTest // For all of the other transfer flow tests, 'now' corresponds to day 3 of the transfer, but // for the request test we want that same 'now' to be the initial request time, so we shift // the transfer timeline 3 days later by adjusting the implicit transfer time here. - Registry registry = Registry.get(domain.getTld()); + Tld registry = Tld.get(domain.getTld()); DateTime implicitTransferTime = clock.nowUtc().plus(registry.getAutomaticTransferLength()); // Setup done; run the test. assertTransactionalFlow(true); @@ -845,7 +845,7 @@ class DomainTransferRequestFlowTest void testSuccess_nonDefaultAutomaticTransferLength() throws Exception { setupDomain("example", "tld"); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setAutomaticTransferLength(Duration.standardMinutes(15)) .build()); @@ -857,7 +857,7 @@ class DomainTransferRequestFlowTest void testSuccess_nonDefaultTransferGracePeriod() throws Exception { setupDomain("example", "tld"); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setTransferGracePeriodLength(Duration.standardMinutes(5)) .build()); @@ -888,7 +888,7 @@ class DomainTransferRequestFlowTest void testSuccess_inQuietPeriod() throws Exception { setupDomain("example", "tld"); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setTldStateTransitions(ImmutableSortedMap.of(START_OF_TIME, QUIET_PERIOD)) .build()); @@ -966,7 +966,7 @@ class DomainTransferRequestFlowTest GracePeriod.createForRecurring( GracePeriodStatus.AUTO_RENEW, domain.getRepoId(), - autorenewTime.plus(Registry.get("tld").getAutoRenewGracePeriodLength()), + autorenewTime.plus(Tld.get("tld").getAutoRenewGracePeriodLength()), "TheRegistrar", existingAutorenewEvent)) .build()); @@ -1023,7 +1023,7 @@ class DomainTransferRequestFlowTest doSuccessfulTest( "domain_transfer_request.xml", "domain_transfer_request_response_10_year_cap.xml", - clock.nowUtc().plus(Registry.get("tld").getAutomaticTransferLength()).plusYears(10)); + clock.nowUtc().plus(Tld.get("tld").getAutomaticTransferLength()).plusYears(10)); } @Test @@ -1070,7 +1070,7 @@ class DomainTransferRequestFlowTest void testFailure_missingBillingAccount() { setupDomain("example", "tld"); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setCurrency(JPY) .setCreateBillingCost(Money.ofMajor(JPY, 800)) @@ -1106,7 +1106,7 @@ class DomainTransferRequestFlowTest // Set the domain to have auto-renewed long enough ago that it is still in the autorenew grace // period at the transfer request time, but will have exited it by the automatic transfer time. DateTime autorenewTime = - clock.nowUtc().minus(Registry.get("tld").getAutoRenewGracePeriodLength()).plusDays(1); + clock.nowUtc().minus(Tld.get("tld").getAutoRenewGracePeriodLength()).plusDays(1); DateTime expirationTime = autorenewTime.plusYears(1); domain = persistResource( @@ -1117,7 +1117,7 @@ class DomainTransferRequestFlowTest GracePeriod.createForRecurring( GracePeriodStatus.AUTO_RENEW, domain.getRepoId(), - autorenewTime.plus(Registry.get("tld").getAutoRenewGracePeriodLength()), + autorenewTime.plus(Tld.get("tld").getAutoRenewGracePeriodLength()), "TheRegistrar", domain.getAutorenewBillingEvent())) .build()); @@ -1147,7 +1147,7 @@ class DomainTransferRequestFlowTest GracePeriod.createForRecurring( GracePeriodStatus.AUTO_RENEW, domain.getRepoId(), - autorenewTime.plus(Registry.get("tld").getAutoRenewGracePeriodLength()), + autorenewTime.plus(Tld.get("tld").getAutoRenewGracePeriodLength()), "TheRegistrar", existingAutorenewEvent)) .build()); @@ -1163,8 +1163,8 @@ class DomainTransferRequestFlowTest .setTargetId("example.tld") .setRegistrarId("TheRegistrar") // The cancellation happens at the moment of transfer. - .setEventTime(clock.nowUtc().plus(Registry.get("tld").getAutomaticTransferLength())) - .setBillingTime(autorenewTime.plus(Registry.get("tld").getAutoRenewGracePeriodLength())) + .setEventTime(clock.nowUtc().plus(Tld.get("tld").getAutomaticTransferLength())) + .setBillingTime(autorenewTime.plus(Tld.get("tld").getAutoRenewGracePeriodLength())) // The cancellation should refer to the old autorenew billing event. .setRecurringEventKey(existingAutorenewEvent)); } @@ -1190,9 +1190,8 @@ class DomainTransferRequestFlowTest .setTargetId("example.tld") .setRegistrarId("TheRegistrar") // The cancellation happens at the moment of transfer. - .setEventTime(clock.nowUtc().plus(Registry.get("tld").getAutomaticTransferLength())) - .setBillingTime( - expirationTime.plus(Registry.get("tld").getAutoRenewGracePeriodLength())) + .setEventTime(clock.nowUtc().plus(Tld.get("tld").getAutomaticTransferLength())) + .setBillingTime(expirationTime.plus(Tld.get("tld").getAutoRenewGracePeriodLength())) // The cancellation should refer to the old autorenew billing event. .setRecurringEventKey(existingAutorenewEvent)); } @@ -1226,7 +1225,7 @@ class DomainTransferRequestFlowTest .setName("tld") .setLabelsToPrices(ImmutableMap.of("example", new BigDecimal("67.89"))) .build()); - persistResource(Registry.get("tld").asBuilder().setPremiumList(pl).build()); + persistResource(Tld.get("tld").asBuilder().setPremiumList(pl).build()); domain = loadByEntity(domain); persistResource( loadByKey(domain.getAutorenewBillingEvent()) @@ -1281,7 +1280,7 @@ class DomainTransferRequestFlowTest .setName("tld") .setLabelsToPrices(ImmutableMap.of("example", new BigDecimal("67.89"))) .build()); - persistResource(Registry.get("tld").asBuilder().setPremiumList(pl).build()); + persistResource(Tld.get("tld").asBuilder().setPremiumList(pl).build()); domain = loadByEntity(domain); persistResource( loadByKey(domain.getAutorenewBillingEvent()) @@ -1329,7 +1328,7 @@ class DomainTransferRequestFlowTest @Test void testSuccess_specifiedRenewalPrice_notCarriedOverForPackageName() throws Exception { setupDomain("example", "tld"); - persistResource(Registry.get("tld").asBuilder().build()); + persistResource(Tld.get("tld").asBuilder().build()); domain = loadByEntity(domain); persistResource( loadByKey(domain.getAutorenewBillingEvent()) @@ -1388,7 +1387,7 @@ class DomainTransferRequestFlowTest @Test void testSuccess_defaultRenewalPrice_carriedOverForPackageName() throws Exception { setupDomain("example", "tld"); - persistResource(Registry.get("tld").asBuilder().build()); + persistResource(Tld.get("tld").asBuilder().build()); domain = loadByEntity(domain); persistResource( loadByKey(domain.getAutorenewBillingEvent()) @@ -1445,7 +1444,7 @@ class DomainTransferRequestFlowTest @Test void testSuccess_packageName_zeroPeriod() throws Exception { setupDomain("example", "tld"); - persistResource(Registry.get("tld").asBuilder().build()); + persistResource(Tld.get("tld").asBuilder().build()); domain = loadByEntity(domain); persistResource( loadByKey(domain.getAutorenewBillingEvent()) @@ -1544,7 +1543,7 @@ class DomainTransferRequestFlowTest private void runWrongFeeAmountTest(Map substitutions) { persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20))) .build()); @@ -1818,7 +1817,7 @@ class DomainTransferRequestFlowTest void testIcannTransactionRecord_getsStored() throws Exception { setupDomain("example", "tld"); persistResource( - Registry.get("tld") + Tld.get("tld") .asBuilder() .setAutomaticTransferLength(Duration.standardDays(2)) .setTransferGracePeriodLength(Duration.standardDays(3)) diff --git a/core/src/test/java/google/registry/flows/domain/DomainUpdateFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainUpdateFlowTest.java index e5a5a64ee..e64ba8278 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainUpdateFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainUpdateFlowTest.java @@ -28,7 +28,7 @@ import static google.registry.model.eppcommon.StatusValue.SERVER_TRANSFER_PROHIB import static google.registry.model.eppcommon.StatusValue.SERVER_UPDATE_PROHIBITED; import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_CREATE; import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_UPDATE; -import static google.registry.model.tld.Registry.TldState.QUIET_PERIOD; +import static google.registry.model.tld.Tld.TldState.QUIET_PERIOD; import static google.registry.testing.DatabaseHelper.assertBillingEvents; import static google.registry.testing.DatabaseHelper.assertNoBillingEvents; import static google.registry.testing.DatabaseHelper.assertPollMessagesForResource; @@ -101,7 +101,7 @@ import google.registry.model.eppcommon.Trid; import google.registry.model.host.Host; import google.registry.model.poll.PendingActionNotificationResponse.DomainPendingActionNotificationResponse; import google.registry.model.poll.PollMessage; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.VKey; import google.registry.testing.DatabaseHelper; import java.util.Optional; @@ -265,7 +265,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase flowUtils.verifyAllocationTokenCreateIfPresent( createCommand("blah.tld"), - Registry.get("tld"), + Tld.get("tld"), "TheRegistrar", DateTime.now(UTC), Optional.of(allocationTokenExtension)))) @@ -177,7 +177,7 @@ class AllocationTokenFlowUtilsTest { () -> flowUtils.verifyAllocationTokenIfPresent( DatabaseHelper.newDomain("blah.tld"), - Registry.get("tld"), + Tld.get("tld"), "TheRegistrar", DateTime.now(UTC), CommandName.RENEW, @@ -198,7 +198,7 @@ class AllocationTokenFlowUtilsTest { () -> failingFlowUtils.verifyAllocationTokenCreateIfPresent( createCommand("blah.tld"), - Registry.get("tld"), + Tld.get("tld"), "TheRegistrar", DateTime.now(UTC), Optional.of(allocationTokenExtension))); @@ -218,7 +218,7 @@ class AllocationTokenFlowUtilsTest { () -> failingFlowUtils.verifyAllocationTokenIfPresent( DatabaseHelper.newDomain("blah.tld"), - Registry.get("tld"), + Tld.get("tld"), "TheRegistrar", DateTime.now(UTC), CommandName.RENEW, @@ -434,7 +434,7 @@ class AllocationTokenFlowUtilsTest { () -> flowUtils.verifyAllocationTokenCreateIfPresent( createCommand("blah.tld"), - Registry.get("tld"), + Tld.get("tld"), "TheRegistrar", DateTime.now(UTC), Optional.of(allocationTokenExtension)))) @@ -449,7 +449,7 @@ class AllocationTokenFlowUtilsTest { () -> flowUtils.verifyAllocationTokenIfPresent( DatabaseHelper.newDomain("blah.tld"), - Registry.get("tld"), + Tld.get("tld"), "TheRegistrar", DateTime.now(UTC), CommandName.RENEW, @@ -483,7 +483,7 @@ class AllocationTokenFlowUtilsTest { public AllocationToken validateToken( DomainCommand.Create command, AllocationToken token, - Registry registry, + Tld tld, String registrarId, DateTime now) { throw new IllegalStateException("failed for tests"); @@ -491,7 +491,7 @@ class AllocationTokenFlowUtilsTest { @Override public AllocationToken validateToken( - Domain domain, AllocationToken token, Registry registry, String registrarId, DateTime now) { + Domain domain, AllocationToken token, Tld tld, String registrarId, DateTime now) { throw new IllegalStateException("failed for tests"); } diff --git a/core/src/test/java/google/registry/flows/host/HostDeleteFlowTest.java b/core/src/test/java/google/registry/flows/host/HostDeleteFlowTest.java index 2187e9a55..945f4cc19 100644 --- a/core/src/test/java/google/registry/flows/host/HostDeleteFlowTest.java +++ b/core/src/test/java/google/registry/flows/host/HostDeleteFlowTest.java @@ -42,7 +42,7 @@ import google.registry.model.domain.Domain; import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.Host; import google.registry.model.reporting.HistoryEntry.Type; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.transfer.DomainTransferData; import google.registry.model.transfer.TransferStatus; import google.registry.testing.DatabaseHelper; @@ -198,7 +198,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase { createTld("tld"); // Setup a transfer that should have been server approved a day ago. DateTime now = clock.nowUtc(); - DateTime requestTime = now.minusDays(1).minus(Registry.DEFAULT_AUTOMATIC_TRANSFER_LENGTH); + DateTime requestTime = now.minusDays(1).minus(Tld.DEFAULT_AUTOMATIC_TRANSFER_LENGTH); DateTime transferExpirationTime = now.minusDays(1); Domain domain = persistResource( @@ -232,7 +232,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase { createTld("tld"); // Setup a transfer that should have been server approved a day ago. DateTime now = clock.nowUtc(); - DateTime requestTime = now.minusDays(1).minus(Registry.DEFAULT_AUTOMATIC_TRANSFER_LENGTH); + DateTime requestTime = now.minusDays(1).minus(Tld.DEFAULT_AUTOMATIC_TRANSFER_LENGTH); DateTime transferExpirationTime = now.minusDays(1); Domain domain = persistResource( diff --git a/core/src/test/java/google/registry/flows/host/HostUpdateFlowTest.java b/core/src/test/java/google/registry/flows/host/HostUpdateFlowTest.java index 87475a5eb..2cd95f8e3 100644 --- a/core/src/test/java/google/registry/flows/host/HostUpdateFlowTest.java +++ b/core/src/test/java/google/registry/flows/host/HostUpdateFlowTest.java @@ -73,7 +73,7 @@ import google.registry.model.domain.Domain; import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.Host; import google.registry.model.reporting.HistoryEntry; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.transfer.DomainTransferData; import google.registry.model.transfer.TransferStatus; import google.registry.persistence.VKey; @@ -112,7 +112,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { */ private Domain createDomainWithServerApprovedTransfer(String domainName) { DateTime now = clock.nowUtc(); - DateTime requestTime = now.minusDays(1).minus(Registry.DEFAULT_AUTOMATIC_TRANSFER_LENGTH); + DateTime requestTime = now.minusDays(1).minus(Tld.DEFAULT_AUTOMATIC_TRANSFER_LENGTH); DateTime transferExpirationTime = now.minusDays(1); return DatabaseHelper.newDomain(domainName) .asBuilder() diff --git a/core/src/test/java/google/registry/model/OteAccountBuilderTest.java b/core/src/test/java/google/registry/model/OteAccountBuilderTest.java index 13b2cdf61..2442d4a48 100644 --- a/core/src/test/java/google/registry/model/OteAccountBuilderTest.java +++ b/core/src/test/java/google/registry/model/OteAccountBuilderTest.java @@ -16,8 +16,8 @@ package google.registry.model; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth8.assertThat; -import static google.registry.model.tld.Registry.TldState.GENERAL_AVAILABILITY; -import static google.registry.model.tld.Registry.TldState.START_DATE_SUNRISE; +import static google.registry.model.tld.Tld.TldState.GENERAL_AVAILABILITY; +import static google.registry.model.tld.Tld.TldState.START_DATE_SUNRISE; import static google.registry.persistence.transaction.JpaTransactionManagerExtension.makeRegistrar1; import static google.registry.testing.CertificateSamples.SAMPLE_CERT; import static google.registry.testing.CertificateSamples.SAMPLE_CERT_HASH; @@ -31,8 +31,8 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.collect.ImmutableList; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.RegistrarPoc; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.TldState; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldState; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.util.CidrAddressBlock; @@ -67,7 +67,7 @@ public final class OteAccountBuilderTest { } private static void assertTldExists(String tld, TldState tldState, Money eapFee) { - Registry registry = Registry.get(tld); + Tld registry = Tld.get(tld); assertThat(registry).isNotNull(); assertThat(registry.getPremiumListName()).hasValue("default_sandbox_list"); assertThat(registry.getTldStateTransitions()).containsExactly(START_OF_TIME, tldState); diff --git a/core/src/test/java/google/registry/model/common/CursorTest.java b/core/src/test/java/google/registry/model/common/CursorTest.java index 648cac1e2..1c041fefe 100644 --- a/core/src/test/java/google/registry/model/common/CursorTest.java +++ b/core/src/test/java/google/registry/model/common/CursorTest.java @@ -24,7 +24,7 @@ import static google.registry.util.DateTimeUtils.START_OF_TIME; import static org.junit.jupiter.api.Assertions.assertThrows; import google.registry.model.EntityTestCase; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.util.SerializeUtils; import org.joda.time.DateTime; import org.junit.jupiter.api.BeforeEach; @@ -53,7 +53,7 @@ public class CursorTest extends EntityTestCase { @Test void testSuccess_persistScopedCursor() { - Registry tld = createTld("tld"); + Tld tld = createTld("tld"); this.fakeClock.advanceOneMilli(); final DateTime time = DateTime.parse("2012-07-12T03:30:00.000Z"); Cursor cursor = Cursor.createScoped(RDE_UPLOAD, time, tld); @@ -78,7 +78,7 @@ public class CursorTest extends EntityTestCase { @Test void testFailure_VKeyWrongScope() { - Registry tld = createTld("tld"); + Tld tld = createTld("tld"); assertThrows( IllegalArgumentException.class, () -> Cursor.createGlobalVKey(RDE_UPLOAD), @@ -106,7 +106,7 @@ public class CursorTest extends EntityTestCase { NullPointerException thrown = assertThrows( NullPointerException.class, - () -> Cursor.createScoped(null, START_OF_TIME, Registry.get("tld"))); + () -> Cursor.createScoped(null, START_OF_TIME, Tld.get("tld"))); assertThat(thrown).hasMessageThat().contains("Cursor type cannot be null"); } @@ -116,7 +116,7 @@ public class CursorTest extends EntityTestCase { NullPointerException thrown = assertThrows( NullPointerException.class, - () -> Cursor.createScoped(RDE_UPLOAD, null, Registry.get("tld"))); + () -> Cursor.createScoped(RDE_UPLOAD, null, Tld.get("tld"))); assertThat(thrown).hasMessageThat().contains("Cursor time cannot be null"); } } diff --git a/core/src/test/java/google/registry/model/domain/DomainTest.java b/core/src/test/java/google/registry/model/domain/DomainTest.java index 11de9d5b7..4a96b45c1 100644 --- a/core/src/test/java/google/registry/model/domain/DomainTest.java +++ b/core/src/test/java/google/registry/model/domain/DomainTest.java @@ -61,7 +61,7 @@ import google.registry.model.eppcommon.Trid; import google.registry.model.host.Host; import google.registry.model.poll.PollMessage; import google.registry.model.reporting.HistoryEntry; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.transfer.DomainTransferData; import google.registry.model.transfer.TransferStatus; import google.registry.persistence.VKey; @@ -414,7 +414,7 @@ public class DomainTest { fakeClock .nowUtc() .plusDays(1) - .plus(Registry.get("com").getTransferGracePeriodLength())) + .plus(Tld.get("com").getTransferGracePeriodLength())) .setCost(Money.of(USD, 11)) .setPeriodYears(1) .setDomainHistory(historyEntry) @@ -457,20 +457,14 @@ public class DomainTest { GracePeriod.create( GracePeriodStatus.TRANSFER, domain.getRepoId(), - fakeClock - .nowUtc() - .plusDays(1) - .plus(Registry.get("com").getTransferGracePeriodLength()), + fakeClock.nowUtc().plusDays(1).plus(Tld.get("com").getTransferGracePeriodLength()), "TheRegistrar", transferBillingEvent.createVKey(), afterTransfer.getGracePeriods().iterator().next().getGracePeriodId())); // If we project after the grace period expires all should be the same except the grace period. Domain afterGracePeriod = domain.cloneProjectedAtTime( - fakeClock - .nowUtc() - .plusDays(2) - .plus(Registry.get("com").getTransferGracePeriodLength())); + fakeClock.nowUtc().plusDays(2).plus(Tld.get("com").getTransferGracePeriodLength())); assertTransferred(afterGracePeriod, newExpirationTime, serverApproveAutorenewEvent); assertThat(afterGracePeriod.getGracePeriods()).isEmpty(); } @@ -676,7 +670,7 @@ public class DomainTest { // autorenew time as the lookup time for the cost. DateTime oldExpirationTime = domain.getRegistrationExpirationTime(); persistResource( - Registry.get("com") + Tld.get("com") .asBuilder() .setRenewBillingCostTransitions( new ImmutableSortedMap.Builder(Ordering.natural()) @@ -698,9 +692,7 @@ public class DomainTest { GracePeriod.createForRecurring( GracePeriodStatus.AUTO_RENEW, domain.getRepoId(), - oldExpirationTime - .plusYears(2) - .plus(Registry.get("com").getAutoRenewGracePeriodLength()), + oldExpirationTime.plusYears(2).plus(Tld.get("com").getAutoRenewGracePeriodLength()), renewedThreeTimes.getCurrentSponsorRegistrarId(), renewedThreeTimes.autorenewBillingEvent, renewedThreeTimes.getGracePeriods().iterator().next().getGracePeriodId())); diff --git a/core/src/test/java/google/registry/model/registrar/RegistrarTest.java b/core/src/test/java/google/registry/model/registrar/RegistrarTest.java index ed40ad13e..03c0f6f5b 100644 --- a/core/src/test/java/google/registry/model/registrar/RegistrarTest.java +++ b/core/src/test/java/google/registry/model/registrar/RegistrarTest.java @@ -24,7 +24,7 @@ import static google.registry.testing.CertificateSamples.SAMPLE_CERT2_HASH; import static google.registry.testing.CertificateSamples.SAMPLE_CERT_HASH; import static google.registry.testing.DatabaseHelper.cloneAndSetAutoTimestamps; import static google.registry.testing.DatabaseHelper.createTld; -import static google.registry.testing.DatabaseHelper.newRegistry; +import static google.registry.testing.DatabaseHelper.newTld; import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistSimpleResource; import static google.registry.testing.DatabaseHelper.persistSimpleResources; @@ -43,8 +43,8 @@ import google.registry.model.EntityTestCase; import google.registry.model.registrar.Registrar.State; import google.registry.model.registrar.Registrar.Type; import google.registry.model.tld.Registries; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.TldType; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldType; import google.registry.util.CidrAddressBlock; import google.registry.util.SerializeUtils; import java.math.BigDecimal; @@ -63,7 +63,7 @@ class RegistrarTest extends EntityTestCase { void setUp() { createTld("tld"); persistResource( - newRegistry("xn--q9jyb4c", "MINNA") + newTld("xn--q9jyb4c", "MINNA") .asBuilder() .setCurrency(JPY) .setCreateBillingCost(Money.of(JPY, new BigDecimal(1300))) @@ -608,7 +608,7 @@ class RegistrarTest extends EntityTestCase { // This is also important because getTlds fills out the cache when used. assertThat(Registries.getTlds()).doesNotContain("newtld"); // We can't use createTld here because it fails when the cache is used. - persistResource(newRegistry("newtld", "NEWTLD")); + persistResource(newTld("newtld", "NEWTLD")); // Make sure we set up the cache correctly, so the newly created TLD isn't in the cache assertThat(Registries.getTlds()).doesNotContain("newtld"); @@ -703,7 +703,7 @@ class RegistrarTest extends EntityTestCase { @Test void testSuccess_nonRealTldDoesntNeedEntryInBillingMap() { - persistResource(Registry.get("xn--q9jyb4c").asBuilder().setTldType(TldType.TEST).build()); + persistResource(Tld.get("xn--q9jyb4c").asBuilder().setTldType(TldType.TEST).build()); // xn--q9jyb4c bills in JPY and we don't have a JPY entry in this billing account map, but it // should succeed without throwing an error because xn--q9jyb4c is set to be a TEST TLD. registrar diff --git a/core/src/test/java/google/registry/model/tld/RegistriesTest.java b/core/src/test/java/google/registry/model/tld/RegistriesTest.java index 8295060fd..7ca166c82 100644 --- a/core/src/test/java/google/registry/model/tld/RegistriesTest.java +++ b/core/src/test/java/google/registry/model/tld/RegistriesTest.java @@ -17,12 +17,12 @@ package google.registry.model.tld; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth8.assertThat; import static google.registry.testing.DatabaseHelper.createTlds; -import static google.registry.testing.DatabaseHelper.newRegistry; +import static google.registry.testing.DatabaseHelper.newTld; import static google.registry.testing.DatabaseHelper.persistResource; import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.net.InternetDomainName; -import google.registry.model.tld.Registry.TldType; +import google.registry.model.tld.Tld.TldType; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import org.junit.jupiter.api.Test; @@ -48,11 +48,10 @@ class RegistriesTest { @Test void test_getTldEntities() { initTestTlds(); - persistResource(newRegistry("testtld", "TESTTLD").asBuilder().setTldType(TldType.TEST).build()); + persistResource(newTld("testtld", "TESTTLD").asBuilder().setTldType(TldType.TEST).build()); assertThat(Registries.getTldEntitiesOfType(TldType.REAL)) - .containsExactly(Registry.get("foo"), Registry.get("a.b.c")); - assertThat(Registries.getTldEntitiesOfType(TldType.TEST)) - .containsExactly(Registry.get("testtld")); + .containsExactly(Tld.get("foo"), Tld.get("a.b.c")); + assertThat(Registries.getTldEntitiesOfType(TldType.TEST)).containsExactly(Tld.get("testtld")); } @Test diff --git a/core/src/test/java/google/registry/model/tld/RegistryTest.java b/core/src/test/java/google/registry/model/tld/TldTest.java similarity index 81% rename from core/src/test/java/google/registry/model/tld/RegistryTest.java rename to core/src/test/java/google/registry/model/tld/TldTest.java index dd5f37719..e29645f03 100644 --- a/core/src/test/java/google/registry/model/tld/RegistryTest.java +++ b/core/src/test/java/google/registry/model/tld/TldTest.java @@ -19,13 +19,13 @@ import static com.google.common.truth.Truth.assertWithMessage; import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.domain.token.AllocationToken.TokenType.DEFAULT_PROMO; import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE; -import static google.registry.model.tld.Registry.TldState.GENERAL_AVAILABILITY; -import static google.registry.model.tld.Registry.TldState.PREDELEGATION; -import static google.registry.model.tld.Registry.TldState.QUIET_PERIOD; -import static google.registry.model.tld.Registry.TldState.START_DATE_SUNRISE; +import static google.registry.model.tld.Tld.TldState.GENERAL_AVAILABILITY; +import static google.registry.model.tld.Tld.TldState.PREDELEGATION; +import static google.registry.model.tld.Tld.TldState.QUIET_PERIOD; +import static google.registry.model.tld.Tld.TldState.START_DATE_SUNRISE; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.testing.DatabaseHelper.createTld; -import static google.registry.testing.DatabaseHelper.newRegistry; +import static google.registry.testing.DatabaseHelper.newTld; import static google.registry.testing.DatabaseHelper.persistPremiumList; import static google.registry.testing.DatabaseHelper.persistReservedList; import static google.registry.testing.DatabaseHelper.persistResource; @@ -42,8 +42,8 @@ import com.google.common.collect.ImmutableSortedMap; import google.registry.dns.writer.VoidDnsWriter; import google.registry.model.EntityTestCase; import google.registry.model.domain.token.AllocationToken; -import google.registry.model.tld.Registry.RegistryNotFoundException; -import google.registry.model.tld.Registry.TldState; +import google.registry.model.tld.Tld.TldNotFoundException; +import google.registry.model.tld.Tld.TldState; import google.registry.model.tld.label.PremiumList; import google.registry.model.tld.label.PremiumListDao; import google.registry.model.tld.label.ReservedList; @@ -56,10 +56,10 @@ import org.joda.time.DateTime; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -/** Unit tests for {@link Registry}. */ -public final class RegistryTest extends EntityTestCase { +/** Unit tests for {@link Tld}. */ +public final class TldTest extends EntityTestCase { - RegistryTest() { + TldTest() { super(JpaEntityCoverageCheck.ENABLED); } @@ -72,47 +72,45 @@ public final class RegistryTest extends EntityTestCase { void testPersistence_updateReservedAndPremiumListSuccessfully() { ReservedList rl15 = persistReservedList("tld-reserved15", "potato,FULLY_BLOCKED"); PremiumList pl = persistPremiumList("tld2", USD, "lol,USD 50", "cat,USD 700"); - Registry registry = - Registry.get("tld").asBuilder().setReservedLists(rl15).setPremiumList(pl).build(); + Tld registry = Tld.get("tld").asBuilder().setReservedLists(rl15).setPremiumList(pl).build(); tm().transact(() -> tm().put(registry)); - Registry persisted = tm().transact(() -> tm().loadByKey(Registry.createVKey(registry.tldStr))); + Tld persisted = tm().transact(() -> tm().loadByKey(Tld.createVKey(registry.tldStr))); assertThat(persisted).isEqualTo(registry); } @Test void testPersistence() { - assertWithMessage("Registry not found").that(Registry.get("tld")).isNotNull(); - assertThat(tm().transact(() -> tm().loadByKey(Registry.createVKey("tld")))) - .isEqualTo(Registry.get("tld")); + assertWithMessage("Registry not found").that(Tld.get("tld")).isNotNull(); + assertThat(tm().transact(() -> tm().loadByKey(Tld.createVKey("tld")))) + .isEqualTo(Tld.get("tld")); } @Test void testSerializable() { ReservedList rl15 = persistReservedList("tld-reserved15", "potato,FULLY_BLOCKED"); - Registry registry = Registry.get("tld").asBuilder().setReservedLists(rl15).build(); + Tld registry = Tld.get("tld").asBuilder().setReservedLists(rl15).build(); tm().transact(() -> tm().put(registry)); - Registry persisted = tm().transact(() -> tm().loadByKey(Registry.createVKey(registry.tldStr))); + Tld persisted = tm().transact(() -> tm().loadByKey(Tld.createVKey(registry.tldStr))); assertThat(SerializeUtils.serializeDeserialize(persisted)).isEqualTo(persisted); } @Test void testFailure_registryNotFound() { createTld("foo"); - assertThrows(RegistryNotFoundException.class, () -> Registry.get("baz")); + assertThrows(TldNotFoundException.class, () -> Tld.get("baz")); } @Test void testSettingEscrowEnabled_null() { - assertThat(Registry.get("tld").asBuilder().setEscrowEnabled(true).build().getEscrowEnabled()) + assertThat(Tld.get("tld").asBuilder().setEscrowEnabled(true).build().getEscrowEnabled()) .isTrue(); - assertThat(Registry.get("tld").asBuilder().setEscrowEnabled(false).build().getEscrowEnabled()) + assertThat(Tld.get("tld").asBuilder().setEscrowEnabled(false).build().getEscrowEnabled()) .isFalse(); } @Test void testSettingCreateBillingCost() { - Registry registry = - Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, 42)).build(); + Tld registry = Tld.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, 42)).build(); assertThat(registry.getStandardCreateCost()).isEqualTo(Money.of(USD, 42)); // The default value of 17 is set in createTld(). assertThat(registry.getStandardRestoreCost()).isEqualTo(Money.of(USD, 17)); @@ -120,8 +118,7 @@ public final class RegistryTest extends EntityTestCase { @Test void testSettingRestoreBillingCost() { - Registry registry = - Registry.get("tld").asBuilder().setRestoreBillingCost(Money.of(USD, 42)).build(); + Tld registry = Tld.get("tld").asBuilder().setRestoreBillingCost(Money.of(USD, 42)).build(); // The default value of 13 is set in createTld(). assertThat(registry.getStandardCreateCost()).isEqualTo(Money.of(USD, 13)); assertThat(registry.getStandardRestoreCost()).isEqualTo(Money.of(USD, 42)); @@ -129,13 +126,13 @@ public final class RegistryTest extends EntityTestCase { @Test void testDefaultNumDnsPublishShards_equalToOne() { - Registry registry = Registry.get("tld").asBuilder().build(); + Tld registry = Tld.get("tld").asBuilder().build(); assertThat(registry.getNumDnsPublishLocks()).isEqualTo(1); } @Test void testSettingNumDnsPublishShards() { - Registry registry = Registry.get("tld").asBuilder().setNumDnsPublishLocks(2).build(); + Tld registry = Tld.get("tld").asBuilder().setNumDnsPublishLocks(2).build(); assertThat(registry.getNumDnsPublishLocks()).isEqualTo(2); } @@ -159,21 +156,17 @@ public final class RegistryTest extends EntityTestCase { .setShouldPublish(true) .setCreationTimestamp(fakeClock.nowUtc()) .build()); - Registry registry1 = - newRegistry("propter", "PROPTER") - .asBuilder() - .setReservedLists(ImmutableSet.of(rl15)) - .build(); + Tld registry1 = + newTld("propter", "PROPTER").asBuilder().setReservedLists(ImmutableSet.of(rl15)).build(); assertThat(registry1.getReservedListNames()).hasSize(1); - Registry registry2 = - registry1.asBuilder().setReservedLists(ImmutableSet.of(rl15, rl16)).build(); + Tld registry2 = registry1.asBuilder().setReservedLists(ImmutableSet.of(rl15, rl16)).build(); assertThat(registry1.getReservedListNames()).hasSize(1); assertThat(registry2.getReservedListNames()).hasSize(2); } @Test void testGetReservedLists_doesntReturnNullWhenUninitialized() { - Registry registry = newRegistry("foo", "FOO"); + Tld registry = newTld("foo", "FOO"); assertThat(registry.getReservedListNames()).isNotNull(); assertThat(registry.getReservedListNames()).isEmpty(); } @@ -181,13 +174,12 @@ public final class RegistryTest extends EntityTestCase { @Test void testGetAll() { createTld("foo"); - assertThat(Registry.get(ImmutableSet.of("foo", "tld"))) + assertThat(Tld.get(ImmutableSet.of("foo", "tld"))) .containsExactlyElementsIn( tm().transact( () -> tm().loadByKeys( - ImmutableSet.of( - Registry.createVKey("foo"), Registry.createVKey("tld")))) + ImmutableSet.of(Tld.createVKey("foo"), Tld.createVKey("tld")))) .values()); } @@ -211,10 +203,9 @@ public final class RegistryTest extends EntityTestCase { .setShouldPublish(true) .setCreationTimestamp(fakeClock.nowUtc()) .build()); - Registry r = - Registry.get("tld").asBuilder().setReservedLists(ImmutableSet.of(rl5, rl6)).build(); + Tld r = Tld.get("tld").asBuilder().setReservedLists(ImmutableSet.of(rl5, rl6)).build(); assertThat(r.getReservedListNames()).containsExactly("tld-reserved5", "tld-reserved6"); - r = Registry.get("tld").asBuilder().setReservedLists(ImmutableSet.of()).build(); + r = Tld.get("tld").asBuilder().setReservedLists(ImmutableSet.of()).build(); assertThat(r.getReservedListNames()).isEmpty(); } @@ -236,20 +227,20 @@ public final class RegistryTest extends EntityTestCase { .setShouldPublish(true) .setCreationTimestamp(fakeClock.nowUtc()) .build()); - Registry r = - Registry.get("tld") + Tld r = + Tld.get("tld") .asBuilder() .setReservedListsByName(ImmutableSet.of("tld-reserved15", "tld-reserved16")) .build(); assertThat(r.getReservedListNames()).containsExactly("tld-reserved15", "tld-reserved16"); - r = Registry.get("tld").asBuilder().setReservedListsByName(ImmutableSet.of()).build(); + r = Tld.get("tld").asBuilder().setReservedListsByName(ImmutableSet.of()).build(); assertThat(r.getReservedListNames()).isEmpty(); } @Test void testSetPremiumList() { PremiumList pl2 = persistPremiumList("tld2", USD, "lol,USD 50", "cat,USD 700"); - Registry registry = Registry.get("tld").asBuilder().setPremiumList(pl2).build(); + Tld registry = Tld.get("tld").asBuilder().setPremiumList(pl2).build(); Optional pl = registry.getPremiumListName(); assertThat(pl).hasValue("tld2"); assertThat(PremiumListDao.getLatestRevision("tld2")).isPresent(); @@ -258,20 +249,20 @@ public final class RegistryTest extends EntityTestCase { @Test void testSettingServerStatusChangeBillingCost() { - Registry registry = - Registry.get("tld").asBuilder().setServerStatusChangeBillingCost(Money.of(USD, 42)).build(); + Tld registry = + Tld.get("tld").asBuilder().setServerStatusChangeBillingCost(Money.of(USD, 42)).build(); assertThat(registry.getServerStatusChangeCost()).isEqualTo(Money.of(USD, 42)); } @Test void testSettingLordnUsername() { - Registry registry = Registry.get("tld").asBuilder().setLordnUsername("username").build(); + Tld registry = Tld.get("tld").asBuilder().setLordnUsername("username").build(); assertThat(registry.getLordnUsername()).isEqualTo("username"); } @Test void testSettingDnsWriters() { - Registry registry = Registry.get("tld"); + Tld registry = Tld.get("tld"); assertThat(registry.getDnsWriters()).containsExactly(VoidDnsWriter.NAME); registry = registry.asBuilder().setDnsWriters(ImmutableSet.of("baz", "bang")).build(); assertThat(registry.getDnsWriters()).containsExactly("baz", "bang"); @@ -279,8 +270,8 @@ public final class RegistryTest extends EntityTestCase { @Test void testPdtLooksLikeGa() { - Registry registry = - Registry.get("tld") + Tld registry = + Tld.get("tld") .asBuilder() .setTldStateTransitions(ImmutableSortedMap.of(START_OF_TIME, TldState.PDT)) .build(); @@ -289,8 +280,8 @@ public final class RegistryTest extends EntityTestCase { @Test void testTldStateTransitionTimes() { - Registry registry = - Registry.get("tld") + Tld registry = + Tld.get("tld") .asBuilder() .setTldStateTransitions( ImmutableSortedMap.naturalOrder() @@ -324,7 +315,7 @@ public final class RegistryTest extends EntityTestCase { @Test void testQuietPeriodCanAppearMultipleTimesAnywhere() { - Registry.get("tld") + Tld.get("tld") .asBuilder() .setTldStateTransitions( ImmutableSortedMap.naturalOrder() @@ -339,8 +330,8 @@ public final class RegistryTest extends EntityTestCase { @Test void testRenewBillingCostTransitionTimes() { - Registry registry = - Registry.get("tld") + Tld registry = + Tld.get("tld") .asBuilder() .setRenewBillingCostTransitions( ImmutableSortedMap.of( @@ -378,7 +369,7 @@ public final class RegistryTest extends EntityTestCase { @Test void testRenewBillingCostNoTransitions() { - Registry registry = Registry.get("tld"); + Tld registry = Tld.get("tld"); // The default value of 11 is set in createTld(). assertThat(registry.getStandardRenewCost(START_OF_TIME)).isEqualTo(Money.of(USD, 11)); assertThat(registry.getStandardRenewCost(fakeClock.nowUtc().minusMillis(1))) @@ -392,14 +383,14 @@ public final class RegistryTest extends EntityTestCase { @Test void testFailure_tldNeverSet() { IllegalArgumentException thrown = - assertThrows(IllegalArgumentException.class, () -> new Registry.Builder().build()); + assertThrows(IllegalArgumentException.class, () -> new Tld.Builder().build()); assertThat(thrown).hasMessageThat().contains("No registry TLD specified"); } @Test void testFailure_setTldStr_null() { IllegalArgumentException thrown = - assertThrows(IllegalArgumentException.class, () -> new Registry.Builder().setTldStr(null)); + assertThrows(IllegalArgumentException.class, () -> new Tld.Builder().setTldStr(null)); assertThat(thrown).hasMessageThat().contains("TLD must not be null"); } @@ -407,7 +398,7 @@ public final class RegistryTest extends EntityTestCase { void testFailure_setTldStr_invalidTld() { IllegalArgumentException thrown = assertThrows( - IllegalArgumentException.class, () -> new Registry.Builder().setTldStr(".tld").build()); + IllegalArgumentException.class, () -> new Tld.Builder().setTldStr(".tld").build()); assertThat(thrown) .hasMessageThat() .contains("Cannot create registry for TLD that is not a valid, canonical domain name"); @@ -417,7 +408,7 @@ public final class RegistryTest extends EntityTestCase { void testFailure_setTldStr_nonCanonicalTld() { IllegalArgumentException thrown = assertThrows( - IllegalArgumentException.class, () -> new Registry.Builder().setTldStr("TLD").build()); + IllegalArgumentException.class, () -> new Tld.Builder().setTldStr("TLD").build()); assertThat(thrown) .hasMessageThat() .contains("Cannot create registry for TLD that is not a valid, canonical domain name"); @@ -428,7 +419,7 @@ public final class RegistryTest extends EntityTestCase { assertThrows( IllegalArgumentException.class, () -> - Registry.get("tld") + Tld.get("tld") .asBuilder() .setTldStateTransitions( ImmutableSortedMap.of( @@ -442,7 +433,7 @@ public final class RegistryTest extends EntityTestCase { assertThrows( IllegalArgumentException.class, () -> - Registry.get("tld") + Tld.get("tld") .asBuilder() .setTldStateTransitions( ImmutableSortedMap.of( @@ -455,8 +446,7 @@ public final class RegistryTest extends EntityTestCase { void testFailure_pricingEngineIsRequired() { IllegalArgumentException thrown = assertThrows( - IllegalArgumentException.class, - () -> new Registry.Builder().setTldStr("invalid").build()); + IllegalArgumentException.class, () -> new Tld.Builder().setTldStr("invalid").build()); assertThat(thrown) .hasMessageThat() .contains("All registries must have a configured pricing engine"); @@ -468,7 +458,7 @@ public final class RegistryTest extends EntityTestCase { assertThrows( IllegalArgumentException.class, () -> - Registry.get("tld") + Tld.get("tld") .asBuilder() .setRenewBillingCostTransitions( ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, -42)))); @@ -480,7 +470,7 @@ public final class RegistryTest extends EntityTestCase { IllegalArgumentException thrown = assertThrows( IllegalArgumentException.class, - () -> Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, -42))); + () -> Tld.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, -42))); assertThat(thrown).hasMessageThat().contains("createBillingCost cannot be negative"); } @@ -489,7 +479,7 @@ public final class RegistryTest extends EntityTestCase { IllegalArgumentException thrown = assertThrows( IllegalArgumentException.class, - () -> Registry.get("tld").asBuilder().setRestoreBillingCost(Money.of(USD, -42))); + () -> Tld.get("tld").asBuilder().setRestoreBillingCost(Money.of(USD, -42))); assertThat(thrown).hasMessageThat().contains("restoreBillingCost cannot be negative"); } @@ -498,7 +488,7 @@ public final class RegistryTest extends EntityTestCase { IllegalArgumentException thrown = assertThrows( IllegalArgumentException.class, - () -> Registry.get("tld").asBuilder().setNumDnsPublishLocks(-1)); + () -> Tld.get("tld").asBuilder().setNumDnsPublishLocks(-1)); assertThat(thrown) .hasMessageThat() .contains( @@ -506,7 +496,7 @@ public final class RegistryTest extends EntityTestCase { thrown = assertThrows( IllegalArgumentException.class, - () -> Registry.get("tld").asBuilder().setNumDnsPublishLocks(0)); + () -> Tld.get("tld").asBuilder().setNumDnsPublishLocks(0)); assertThat(thrown) .hasMessageThat() .contains( @@ -518,10 +508,7 @@ public final class RegistryTest extends EntityTestCase { IllegalArgumentException thrown = assertThrows( IllegalArgumentException.class, - () -> - Registry.get("tld") - .asBuilder() - .setServerStatusChangeBillingCost(Money.of(USD, -42))); + () -> Tld.get("tld").asBuilder().setServerStatusChangeBillingCost(Money.of(USD, -42))); assertThat(thrown).hasMessageThat().contains("billing cost cannot be negative"); } @@ -531,12 +518,12 @@ public final class RegistryTest extends EntityTestCase { assertThrows( IllegalArgumentException.class, () -> - Registry.get("tld") + Tld.get("tld") .asBuilder() .setRenewBillingCostTransitions( ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 42))) .build()); - assertThat(thrown).hasMessageThat().contains("cost must be in the registry's currency"); + assertThat(thrown).hasMessageThat().contains("cost must be in the TLD's currency"); } @Test @@ -544,8 +531,8 @@ public final class RegistryTest extends EntityTestCase { IllegalArgumentException thrown = assertThrows( IllegalArgumentException.class, - () -> Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(EUR, 42)).build()); - assertThat(thrown).hasMessageThat().contains("cost must be in the registry's currency"); + () -> Tld.get("tld").asBuilder().setCreateBillingCost(Money.of(EUR, 42)).build()); + assertThat(thrown).hasMessageThat().contains("cost must be in the tld's currency"); } @Test @@ -553,8 +540,8 @@ public final class RegistryTest extends EntityTestCase { IllegalArgumentException thrown = assertThrows( IllegalArgumentException.class, - () -> Registry.get("tld").asBuilder().setRestoreBillingCost(Money.of(EUR, 42)).build()); - assertThat(thrown).hasMessageThat().contains("cost must be in the registry's currency"); + () -> Tld.get("tld").asBuilder().setRestoreBillingCost(Money.of(EUR, 42)).build()); + assertThat(thrown).hasMessageThat().contains("cost must be in the TLD's currency"); } @Test @@ -563,16 +550,16 @@ public final class RegistryTest extends EntityTestCase { assertThrows( IllegalArgumentException.class, () -> - Registry.get("tld") + Tld.get("tld") .asBuilder() .setServerStatusChangeBillingCost(Money.of(EUR, 42)) .build()); - assertThat(thrown).hasMessageThat().contains("cost must be in the registry's currency"); + assertThat(thrown).hasMessageThat().contains("cost must be in the TLD's currency"); } @Test void testEapFee_undefined() { - assertThat(Registry.get("tld").getEapFeeFor(fakeClock.nowUtc()).getCost()) + assertThat(Tld.get("tld").getEapFeeFor(fakeClock.nowUtc()).getCost()) .isEqualTo(BigDecimal.ZERO.setScale(2, UNNECESSARY)); } @@ -580,8 +567,8 @@ public final class RegistryTest extends EntityTestCase { void testEapFee_specified() { DateTime a = fakeClock.nowUtc().minusDays(1); DateTime b = fakeClock.nowUtc().plusDays(1); - Registry registry = - Registry.get("tld") + Tld registry = + Tld.get("tld") .asBuilder() .setEapFeeSchedule( ImmutableSortedMap.of( @@ -604,11 +591,11 @@ public final class RegistryTest extends EntityTestCase { assertThrows( IllegalArgumentException.class, () -> - Registry.get("tld") + Tld.get("tld") .asBuilder() .setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR))) .build()); - assertThat(thrown).hasMessageThat().contains("All EAP fees must be in the registry's currency"); + assertThat(thrown).hasMessageThat().contains("All EAP fees must be in the TLD's currency"); } @Test @@ -616,27 +603,25 @@ public final class RegistryTest extends EntityTestCase { IllegalArgumentException e = assertThrows( IllegalArgumentException.class, - () -> Registry.get("tld").asBuilder().setRoidSuffix("123456789")); + () -> Tld.get("tld").asBuilder().setRoidSuffix("123456789")); assertThat(e).hasMessageThat().isEqualTo("ROID suffix must be in format ^[A-Z\\d_]{1,8}$"); } @Test void testFailure_roidSuffixNotUppercased() { assertThrows( - IllegalArgumentException.class, - () -> Registry.get("tld").asBuilder().setRoidSuffix("abcd")); + IllegalArgumentException.class, () -> Tld.get("tld").asBuilder().setRoidSuffix("abcd")); } @Test void testFailure_roidSuffixContainsInvalidCharacters() { assertThrows( - IllegalArgumentException.class, - () -> Registry.get("tld").asBuilder().setRoidSuffix("ABC-DEF")); + IllegalArgumentException.class, () -> Tld.get("tld").asBuilder().setRoidSuffix("ABC-DEF")); } @Test void testSuccess_setDefaultPromoTokens() { - Registry registry = Registry.get("tld"); + Tld registry = Tld.get("tld"); assertThat(registry.getDefaultPromoTokens()).isEmpty(); AllocationToken token1 = persistResource( @@ -662,7 +647,7 @@ public final class RegistryTest extends EntityTestCase { @Test void testFailure_setDefaultPromoTokensWrongTokenType() { - Registry registry = Registry.get("tld"); + Tld registry = Tld.get("tld"); assertThat(registry.getDefaultPromoTokens()).isEmpty(); AllocationToken token1 = persistResource( @@ -688,7 +673,7 @@ public final class RegistryTest extends EntityTestCase { @Test void testFailure_setDefaultPromoTokensNotValidForTld() { - Registry registry = Registry.get("tld"); + Tld registry = Tld.get("tld"); assertThat(registry.getDefaultPromoTokens()).isEmpty(); AllocationToken token1 = persistResource( diff --git a/core/src/test/java/google/registry/model/tld/label/PremiumListDaoTest.java b/core/src/test/java/google/registry/model/tld/label/PremiumListDaoTest.java index 20ded9d2b..d18d1ef38 100644 --- a/core/src/test/java/google/registry/model/tld/label/PremiumListDaoTest.java +++ b/core/src/test/java/google/registry/model/tld/label/PremiumListDaoTest.java @@ -18,7 +18,7 @@ import static com.google.common.collect.ImmutableMap.toImmutableMap; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth8.assertThat; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; -import static google.registry.testing.DatabaseHelper.newRegistry; +import static google.registry.testing.DatabaseHelper.newTld; import static google.registry.testing.DatabaseHelper.persistResource; import static org.joda.money.CurrencyUnit.JPY; import static org.joda.money.CurrencyUnit.USD; @@ -205,8 +205,7 @@ public class PremiumListDaoTest { .setLabelsToPrices(TEST_PRICES) .setCreationTimestamp(fakeClock.nowUtc()) .build()); - persistResource( - newRegistry("foobar", "FOOBAR").asBuilder().setPremiumList(premiumList).build()); + persistResource(newTld("foobar", "FOOBAR").asBuilder().setPremiumList(premiumList).build()); assertThat(PremiumListDao.getPremiumPrice("premlist", "silver")).hasValue(Money.of(USD, 10.23)); assertThat(PremiumListDao.getPremiumPrice("premlist", "gold")).hasValue(Money.of(USD, 1305.47)); assertThat(PremiumListDao.getPremiumPrice("premlist", "zirconium")).isEmpty(); @@ -229,8 +228,7 @@ public class PremiumListDaoTest { BigDecimal.valueOf(15000))) .setCreationTimestamp(fakeClock.nowUtc()) .build()); - persistResource( - newRegistry("foobar", "FOOBAR").asBuilder().setPremiumList(premiumList).build()); + persistResource(newTld("foobar", "FOOBAR").asBuilder().setPremiumList(premiumList).build()); assertThat(PremiumListDao.getPremiumPrice("premlist", "silver")).hasValue(moneyOf(JPY, 10)); assertThat(PremiumListDao.getPremiumPrice("premlist", "gold")).hasValue(moneyOf(JPY, 1000)); assertThat(PremiumListDao.getPremiumPrice("premlist", "palladium")) diff --git a/core/src/test/java/google/registry/model/tld/label/PremiumListTest.java b/core/src/test/java/google/registry/model/tld/label/PremiumListTest.java index 8327cb671..c7bdf8028 100644 --- a/core/src/test/java/google/registry/model/tld/label/PremiumListTest.java +++ b/core/src/test/java/google/registry/model/tld/label/PremiumListTest.java @@ -27,7 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.collect.ImmutableList; import com.google.common.hash.BloomFilter; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.tld.label.PremiumList.PremiumEntry; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; @@ -51,7 +51,7 @@ public class PremiumListTest { PremiumList pl = persistPremiumList( "tld", USD, "lol, 999", "rich, 1999", "icann, 100", "johnny-be-goode, 20.50"); - persistResource(Registry.get("tld").asBuilder().setPremiumList(pl).build()); + persistResource(Tld.get("tld").asBuilder().setPremiumList(pl).build()); } @Test diff --git a/core/src/test/java/google/registry/model/tld/label/ReservedListTest.java b/core/src/test/java/google/registry/model/tld/label/ReservedListTest.java index d6ad3cfa3..06bd6f26d 100644 --- a/core/src/test/java/google/registry/model/tld/label/ReservedListTest.java +++ b/core/src/test/java/google/registry/model/tld/label/ReservedListTest.java @@ -33,7 +33,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.testing.FakeClock; @@ -73,7 +73,7 @@ class ReservedListTest { @Test void testGetReservationTypes_allLabelsAreUnreserved_withNoReservedLists() { - assertThat(Registry.get("tld").getReservedListNames()).isEmpty(); + assertThat(Tld.get("tld").getReservedListNames()).isEmpty(); assertThat(getReservationTypes("doodle", "tld")).isEmpty(); assertThat(getReservationTypes("access", "tld")).isEmpty(); assertThat(getReservationTypes("rich", "tld")).isEmpty(); @@ -114,7 +114,7 @@ class ReservedListTest { "roflcopter,FULLY_BLOCKED", "snowcrash,FULLY_BLOCKED"); createTld("tld"); - persistResource(Registry.get("tld").asBuilder().setReservedLists(rl1, rl2).build()); + persistResource(Tld.get("tld").asBuilder().setReservedLists(rl1, rl2).build()); assertThat(getReservationTypes("lol", "tld")).containsExactly(FULLY_BLOCKED); assertThat(getReservationTypes("cat", "tld")).containsExactly(FULLY_BLOCKED); @@ -152,7 +152,7 @@ class ReservedListTest { ReservedList rl2 = persistReservedList("reserved2", "lol,ALLOWED_IN_SUNRISE", "snowcrash,FULLY_BLOCKED"); createTld("tld"); - persistResource(Registry.get("tld").asBuilder().setReservedLists(rl1, rl2).build()); + persistResource(Tld.get("tld").asBuilder().setReservedLists(rl1, rl2).build()); assertThat(getReservationTypes("lol", "tld")) .containsExactly(NAME_COLLISION, ALLOWED_IN_SUNRISE); @@ -167,9 +167,9 @@ class ReservedListTest { ReservedList rl2 = persistReservedList( "reserved2", "roflcopter,FULLY_BLOCKED", "snowcrash,FULLY_BLOCKED"); createTld("tld"); - persistResource(Registry.get("tld").asBuilder().setReservedLists(rl1, rl2).build()); + persistResource(Tld.get("tld").asBuilder().setReservedLists(rl1, rl2).build()); assertThat(getReservationTypes("roflcopter", "tld")).containsExactly(FULLY_BLOCKED); - persistResource(Registry.get("tld").asBuilder().setReservedLists(rl1).build()); + persistResource(Tld.get("tld").asBuilder().setReservedLists(rl1).build()); assertWithMessage( "roflcopter.tld should be unreserved" + " after unsetting the registry's second reserved list") @@ -199,7 +199,7 @@ class ReservedListTest { "reserved1", "lol,NAME_COLLISION", "roflcopter,ALLOWED_IN_SUNRISE"); ReservedList rl2 = persistReservedList("reserved2", "lol,FULLY_BLOCKED"); createTld("tld"); - persistResource(Registry.get("tld").asBuilder().setReservedLists(rl1, rl2).build()); + persistResource(Tld.get("tld").asBuilder().setReservedLists(rl1, rl2).build()); assertThat(getReservationTypes("lol", "tld")).containsExactly(FULLY_BLOCKED, NAME_COLLISION); assertThat(getReservationTypes("roflcopter", "tld")).containsExactly(ALLOWED_IN_SUNRISE); assertThat(reservedListChecks) @@ -228,7 +228,7 @@ class ReservedListTest { void testSave() { ReservedList rl = persistReservedList("tld-reserved", "lol,FULLY_BLOCKED # yup"); createTld("tld"); - persistResource(Registry.get("tld").asBuilder().setReservedLists(rl).build()); + persistResource(Tld.get("tld").asBuilder().setReservedLists(rl).build()); assertThat(getReservationTypes("lol", "tld")).containsExactly(FULLY_BLOCKED); } @@ -260,7 +260,7 @@ class ReservedListTest { @Test void testIsInUse_returnsTrueWhenInUse() { ReservedList rl = persistReservedList("reserved", "trombone,FULLY_BLOCKED"); - persistResource(Registry.get("tld").asBuilder().setReservedLists(ImmutableSet.of(rl)).build()); + persistResource(Tld.get("tld").asBuilder().setReservedLists(ImmutableSet.of(rl)).build()); assertThat(rl.isInUse()).isTrue(); } diff --git a/core/src/test/java/google/registry/persistence/converter/TldStateTransitionConverterTest.java b/core/src/test/java/google/registry/persistence/converter/TldStateTransitionConverterTest.java index 9d56887ce..27bb5ba9a 100644 --- a/core/src/test/java/google/registry/persistence/converter/TldStateTransitionConverterTest.java +++ b/core/src/test/java/google/registry/persistence/converter/TldStateTransitionConverterTest.java @@ -22,7 +22,7 @@ import static google.registry.util.DateTimeUtils.START_OF_TIME; import com.google.common.collect.ImmutableSortedMap; import google.registry.model.ImmutableObject; import google.registry.model.common.TimedTransitionProperty; -import google.registry.model.tld.Registry.TldState; +import google.registry.model.tld.Tld.TldState; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaUnitTestExtension; import javax.persistence.Entity; diff --git a/core/src/test/java/google/registry/pricing/PricingEngineProxyTest.java b/core/src/test/java/google/registry/pricing/PricingEngineProxyTest.java index 86560c391..f008fc724 100644 --- a/core/src/test/java/google/registry/pricing/PricingEngineProxyTest.java +++ b/core/src/test/java/google/registry/pricing/PricingEngineProxyTest.java @@ -26,7 +26,7 @@ import static org.joda.money.CurrencyUnit.USD; import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.collect.ImmutableSortedMap; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.tld.label.PremiumList; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; @@ -53,7 +53,7 @@ public class PricingEngineProxyTest { persistPremiumList( "premium list", USD, "rich,USD 100", "richer,USD 999", "fraction,USD 20.50"); createTld("moka"); - persistResource(Registry.get("moka").asBuilder().setPremiumList(premiumList).build()); + persistResource(Tld.get("moka").asBuilder().setPremiumList(premiumList).build()); clock = new FakeClock(DateTime.parse("2016-03-17T12:01:00Z")); } @@ -107,7 +107,7 @@ public class PricingEngineProxyTest { // The example tld has a premium price for "rich". createTld("example"); persistResource( - Registry.get("example") + Tld.get("example") .asBuilder() .setRenewBillingCostTransitions( ImmutableSortedMap.of( @@ -126,7 +126,7 @@ public class PricingEngineProxyTest { @Test void testFailure_cantLoadPricingEngine() { createTld("example"); - persistResource(Registry.get("example").asBuilder().setPremiumPricingEngine("fake").build()); + persistResource(Tld.get("example").asBuilder().setPremiumPricingEngine("fake").build()); IllegalStateException thrown = assertThrows( IllegalStateException.class, diff --git a/core/src/test/java/google/registry/rdap/RdapDomainActionTest.java b/core/src/test/java/google/registry/rdap/RdapDomainActionTest.java index fa9f1c105..fb04d0bde 100644 --- a/core/src/test/java/google/registry/rdap/RdapDomainActionTest.java +++ b/core/src/test/java/google/registry/rdap/RdapDomainActionTest.java @@ -33,7 +33,7 @@ import google.registry.model.domain.Period; import google.registry.model.host.Host; import google.registry.model.registrar.Registrar; import google.registry.model.reporting.HistoryEntry; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.rdap.RdapMetrics.EndpointType; import google.registry.rdap.RdapMetrics.SearchType; import google.registry.rdap.RdapMetrics.WildcardType; @@ -372,7 +372,7 @@ class RdapDomainActionTest extends RdapActionBaseTestCase { @Disabled @Test void testDomainInTestTld_notFound() { - persistResource(Registry.get("lol").asBuilder().setTldType(Registry.TldType.TEST).build()); + persistResource(Tld.get("lol").asBuilder().setTldType(Tld.TldType.TEST).build()); generateActualJson("cat.lol"); assertThat(response.getStatus()).isEqualTo(404); } diff --git a/core/src/test/java/google/registry/rdap/RdapDomainSearchActionTest.java b/core/src/test/java/google/registry/rdap/RdapDomainSearchActionTest.java index 96865142e..701a50223 100644 --- a/core/src/test/java/google/registry/rdap/RdapDomainSearchActionTest.java +++ b/core/src/test/java/google/registry/rdap/RdapDomainSearchActionTest.java @@ -41,7 +41,7 @@ import google.registry.model.domain.Period; import google.registry.model.host.Host; import google.registry.model.registrar.Registrar; import google.registry.model.reporting.HistoryEntry; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.VKey; import google.registry.rdap.RdapMetrics.EndpointType; import google.registry.rdap.RdapMetrics.SearchType; @@ -1024,7 +1024,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase { RdeRevision.saveRevision("lol", DateTime.parse("2010-10-17TZ"), RdeMode.THIN, 0); }); - persistResource(Cursor.createScoped(BRDA, action.watermark.plusDays(1), Registry.get("lol"))); + persistResource(Cursor.createScoped(BRDA, action.watermark.plusDays(1), Tld.get("lol"))); } @ParameterizedTest @ValueSource(strings = {"", "job-name/"}) void testRun_stagingNotFinished_throws204(String prefix) throws Exception { - persistResource(Cursor.createScoped(BRDA, action.watermark, Registry.get("lol"))); + persistResource(Cursor.createScoped(BRDA, action.watermark, Tld.get("lol"))); NoContentException thrown = assertThrows(NoContentException.class, () -> runAction(prefix)); assertThat(thrown) .hasMessageThat() diff --git a/core/src/test/java/google/registry/rde/EscrowTaskRunnerTest.java b/core/src/test/java/google/registry/rde/EscrowTaskRunnerTest.java index 41b8446e3..8fd7b34df 100644 --- a/core/src/test/java/google/registry/rde/EscrowTaskRunnerTest.java +++ b/core/src/test/java/google/registry/rde/EscrowTaskRunnerTest.java @@ -26,7 +26,7 @@ import static org.mockito.Mockito.verify; import google.registry.model.common.Cursor; import google.registry.model.common.Cursor.CursorType; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.rde.EscrowTaskRunner.EscrowTask; @@ -53,12 +53,12 @@ public class EscrowTaskRunnerTest { private DateTimeZone previousDateTimeZone; private EscrowTaskRunner runner; - private Registry registry; + private Tld registry; @BeforeEach void beforeEach() { createTld("lol"); - registry = Registry.get("lol"); + registry = Tld.get("lol"); runner = new EscrowTaskRunner(); runner.clock = clock; runner.lockHandler = new FakeLockHandler(true); diff --git a/core/src/test/java/google/registry/rde/PendingDepositCheckerTest.java b/core/src/test/java/google/registry/rde/PendingDepositCheckerTest.java index ce1999943..1a7d5af4a 100644 --- a/core/src/test/java/google/registry/rde/PendingDepositCheckerTest.java +++ b/core/src/test/java/google/registry/rde/PendingDepositCheckerTest.java @@ -31,7 +31,7 @@ import com.google.common.collect.ImmutableSetMultimap; import com.google.common.truth.Truth8; import google.registry.model.common.Cursor; import google.registry.model.common.Cursor.CursorType; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.testing.FakeClock; @@ -94,7 +94,7 @@ public class PendingDepositCheckerTest { clock.setTo(DateTime.parse("2000-01-01TZ")); // Saturday createTldWithEscrowEnabled("lol"); clock.advanceOneMilli(); - Registry registry = Registry.get("lol"); + Tld registry = Tld.get("lol"); Truth8.assertThat(loadByKeyIfPresent(Cursor.createScopedVKey(RDE_STAGING, registry))).isEmpty(); checker.getTldsAndWatermarksPendingDepositForRdeAndBrda(); assertThat(loadByKey(Cursor.createScopedVKey(RDE_STAGING, registry)).getCursorTime()) @@ -107,10 +107,10 @@ public class PendingDepositCheckerTest { createTldWithEscrowEnabled("lol"); clock.advanceOneMilli(); DateTime yesterday = DateTime.parse("1999-12-31TZ"); - setCursor(Registry.get("lol"), RDE_STAGING, yesterday); + setCursor(Tld.get("lol"), RDE_STAGING, yesterday); clock.advanceOneMilli(); checker.getTldsAndWatermarksPendingDepositForRdeAndBrda(); - Cursor cursor = loadByKey(Cursor.createScopedVKey(RDE_STAGING, Registry.get("lol"))); + Cursor cursor = loadByKey(Cursor.createScopedVKey(RDE_STAGING, Tld.get("lol"))); assertThat(cursor.getCursorTime()).isEqualTo(yesterday); } @@ -118,7 +118,7 @@ public class PendingDepositCheckerTest { void testMethod_firstBrdaDepositButNotOnBrdaDay_doesntInitializeCursor() { clock.setTo(DateTime.parse("2000-01-01TZ")); // Saturday createTldWithEscrowEnabled("lol"); - Registry registry = Registry.get("lol"); + Tld registry = Tld.get("lol"); clock.advanceOneMilli(); setCursor(registry, RDE_STAGING, DateTime.parse("2000-01-02TZ")); // assume rde is already done clock.advanceOneMilli(); @@ -132,7 +132,7 @@ public class PendingDepositCheckerTest { clock.setTo(DateTime.parse("2000-01-01TZ")); createTldWithEscrowEnabled("lol"); clock.advanceOneMilli(); - setCursor(Registry.get("lol"), RDE_STAGING, DateTime.parse("1999-12-30TZ")); + setCursor(Tld.get("lol"), RDE_STAGING, DateTime.parse("1999-12-30TZ")); clock.advanceOneMilli(); assertThat(checker.getTldsAndWatermarksPendingDepositForRdeAndBrda()).isEqualTo( ImmutableSetMultimap.of( @@ -163,13 +163,13 @@ public class PendingDepositCheckerTest { } private static void setCursor( - final Registry registry, final CursorType cursorType, final DateTime value) { + final Tld registry, final CursorType cursorType, final DateTime value) { tm().transact(() -> tm().put(Cursor.createScoped(cursorType, value, registry))); } private static void createTldWithEscrowEnabled(final String tld) { createTld(tld); - persistResource(Registry.get(tld).asBuilder().setEscrowEnabled(true).build()); + persistResource(Tld.get(tld).asBuilder().setEscrowEnabled(true).build()); } } diff --git a/core/src/test/java/google/registry/rde/RdeReportActionTest.java b/core/src/test/java/google/registry/rde/RdeReportActionTest.java index 9b2a9f547..7bc64f572 100644 --- a/core/src/test/java/google/registry/rde/RdeReportActionTest.java +++ b/core/src/test/java/google/registry/rde/RdeReportActionTest.java @@ -47,7 +47,7 @@ import com.google.common.io.ByteSource; import google.registry.gcs.GcsUtils; import google.registry.model.common.Cursor; import google.registry.model.rde.RdeRevision; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.request.HttpException.InternalServerErrorException; @@ -96,7 +96,7 @@ public class RdeReportActionTest { private final GcsUtils gcsUtils = new GcsUtils(LocalStorageHelper.getOptions()); private final BlobId reportFile = BlobId.of("tub", "test_2006-06-06_full_S1_R0-report.xml.ghostryde"); - private Registry registry; + private Tld registry; private RdeReportAction createAction() { RdeReporter reporter = new RdeReporter(); @@ -133,8 +133,9 @@ public class RdeReportActionTest { RdeReportAction action = createAction(); action.tld = "lol"; action.run(); - verify(runner).lockRunAndRollForward( - action, Registry.get("lol"), standardSeconds(30), RDE_REPORT, standardDays(1)); + verify(runner) + .lockRunAndRollForward( + action, Tld.get("lol"), standardSeconds(30), RDE_REPORT, standardDays(1)); verifyNoMoreInteractions(runner); } @@ -209,7 +210,7 @@ public class RdeReportActionTest { } void testRunWithLock_nonexistentCursor_throws204() { - tm().transact(() -> tm().delete(Cursor.createScopedVKey(RDE_UPLOAD, Registry.get("test")))); + tm().transact(() -> tm().delete(Cursor.createScopedVKey(RDE_UPLOAD, Tld.get("test")))); NoContentException thrown = assertThrows( NoContentException.class, () -> createAction().runWithLock(loadRdeReportCursor())); @@ -223,7 +224,7 @@ public class RdeReportActionTest { @Test void testRunWithLock_uploadNotFinished_throws204() { persistResource( - Cursor.createScoped(RDE_UPLOAD, DateTime.parse("2006-06-06TZ"), Registry.get("test"))); + Cursor.createScoped(RDE_UPLOAD, DateTime.parse("2006-06-06TZ"), Tld.get("test"))); NoContentException thrown = assertThrows( NoContentException.class, () -> createAction().runWithLock(loadRdeReportCursor())); diff --git a/core/src/test/java/google/registry/rde/RdeStagingActionTest.java b/core/src/test/java/google/registry/rde/RdeStagingActionTest.java index 46bcba2eb..f99f89d9c 100644 --- a/core/src/test/java/google/registry/rde/RdeStagingActionTest.java +++ b/core/src/test/java/google/registry/rde/RdeStagingActionTest.java @@ -29,7 +29,7 @@ import com.google.cloud.storage.contrib.nio.testing.LocalStorageHelper; import com.google.common.collect.ImmutableSet; import google.registry.beam.BeamActionTestBase; import google.registry.gcs.GcsUtils; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.request.HttpException.BadRequestException; @@ -127,7 +127,7 @@ public class RdeStagingActionTest extends BeamActionTestBase { @Test void testRun_tldWithoutEscrowEnabled_returns204() { createTld("lol"); - persistResource(Registry.get("lol").asBuilder().setEscrowEnabled(false).build()); + persistResource(Tld.get("lol").asBuilder().setEscrowEnabled(false).build()); clock.setTo(DateTime.parse("2000-01-01TZ")); action.run(); assertThat(response.getStatus()).isEqualTo(204); @@ -259,6 +259,6 @@ public class RdeStagingActionTest extends BeamActionTestBase { private static void createTldWithEscrowEnabled(final String tld) { createTld(tld); - persistResource(Registry.get(tld).asBuilder().setEscrowEnabled(true).build()); + persistResource(Tld.get(tld).asBuilder().setEscrowEnabled(true).build()); } } diff --git a/core/src/test/java/google/registry/rde/RdeUploadActionTest.java b/core/src/test/java/google/registry/rde/RdeUploadActionTest.java index e0dda61f1..c0be113c6 100644 --- a/core/src/test/java/google/registry/rde/RdeUploadActionTest.java +++ b/core/src/test/java/google/registry/rde/RdeUploadActionTest.java @@ -54,7 +54,7 @@ import google.registry.keyring.api.Keyring; import google.registry.model.common.Cursor; import google.registry.model.common.Cursor.CursorType; import google.registry.model.rde.RdeRevision; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.rde.JSchSshSession.JSchSshSessionFactory; @@ -224,11 +224,7 @@ public class RdeUploadActionTest { action.run(); verify(runner) .lockRunAndRollForward( - action, - Registry.get("lol"), - standardSeconds(23), - CursorType.RDE_UPLOAD, - standardDays(1)); + action, Tld.get("lol"), standardSeconds(23), CursorType.RDE_UPLOAD, standardDays(1)); cloudTasksHelper.assertTasksEnqueued( "rde-report", new TaskMatcher().url(RdeReportAction.PATH).param(RequestParameters.PARAM_TLD, "lol")); @@ -244,11 +240,7 @@ public class RdeUploadActionTest { action.run(); verify(runner) .lockRunAndRollForward( - action, - Registry.get("lol"), - standardSeconds(23), - CursorType.RDE_UPLOAD, - standardDays(1)); + action, Tld.get("lol"), standardSeconds(23), CursorType.RDE_UPLOAD, standardDays(1)); cloudTasksHelper.assertTasksEnqueued( "rde-report", new TaskMatcher() @@ -264,7 +256,7 @@ public class RdeUploadActionTest { URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port)); DateTime stagingCursor = DateTime.parse("2010-10-18TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); - persistResource(Cursor.createScoped(RDE_STAGING, stagingCursor, Registry.get("tld"))); + persistResource(Cursor.createScoped(RDE_STAGING, stagingCursor, Tld.get("tld"))); RdeUploadAction action = createAction(uploadUrl); action.lazyJsch = Lazies.of(createThrowingJSchSpy(action.lazyJsch.get(), 2)); action.runWithLock(uploadCursor); @@ -283,7 +275,7 @@ public class RdeUploadActionTest { URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port)); DateTime stagingCursor = DateTime.parse("2010-10-18TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); - persistResource(Cursor.createScoped(RDE_STAGING, stagingCursor, Registry.get("tld"))); + persistResource(Cursor.createScoped(RDE_STAGING, stagingCursor, Tld.get("tld"))); RdeUploadAction action = createAction(uploadUrl); action.lazyJsch = Lazies.of(createThrowingJSchSpy(action.lazyJsch.get(), 3)); RuntimeException thrown = @@ -297,7 +289,7 @@ public class RdeUploadActionTest { URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port)); DateTime stagingCursor = DateTime.parse("2010-10-18TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); - persistResource(Cursor.createScoped(RDE_STAGING, stagingCursor, Registry.get("tld"))); + persistResource(Cursor.createScoped(RDE_STAGING, stagingCursor, Tld.get("tld"))); gcsUtils.delete(GHOSTRYDE_FILE_WITH_PREFIX); gcsUtils.delete(LENGTH_FILE_WITH_PREFIX); gcsUtils.delete(REPORT_FILE_WITH_PREFIX); @@ -317,7 +309,7 @@ public class RdeUploadActionTest { URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port)); DateTime stagingCursor = DateTime.parse("2010-10-18TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); - persistResource(Cursor.createScoped(RDE_STAGING, stagingCursor, Registry.get("tld"))); + persistResource(Cursor.createScoped(RDE_STAGING, stagingCursor, Tld.get("tld"))); RdeUploadAction action = createAction(uploadUrl); action.prefix = Optional.of(JOB_PREFIX + "-job-name/"); gcsUtils.delete(GHOSTRYDE_FILE); @@ -346,7 +338,7 @@ public class RdeUploadActionTest { URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port)); DateTime stagingCursor = DateTime.parse("2010-10-18TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); - persistResource(Cursor.createScoped(RDE_STAGING, stagingCursor, Registry.get("tld"))); + persistResource(Cursor.createScoped(RDE_STAGING, stagingCursor, Tld.get("tld"))); RdeUploadAction action = createAction(uploadUrl); gcsUtils.delete(GHOSTRYDE_FILE); gcsUtils.delete(LENGTH_FILE); @@ -387,7 +379,7 @@ public class RdeUploadActionTest { URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port)); DateTime stagingCursor = DateTime.parse("2010-10-18TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); - persistSimpleResource(Cursor.createScoped(RDE_STAGING, stagingCursor, Registry.get("tld"))); + persistSimpleResource(Cursor.createScoped(RDE_STAGING, stagingCursor, Tld.get("tld"))); BlobId ghostrydeR1FileWithPrefix = BlobId.of("bucket", JOB_PREFIX + "-job-name/tld_2010-10-17_full_S1_R1.xml.ghostryde"); BlobId lengthR1FileWithPrefix = @@ -418,7 +410,7 @@ public class RdeUploadActionTest { URI uploadUrl = URI.create(String.format("sftp://user:password@localhost:%d/", port)); DateTime stagingCursor = DateTime.parse("2010-10-18TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); - persistResource(Cursor.createScoped(RDE_STAGING, stagingCursor, Registry.get("tld"))); + persistResource(Cursor.createScoped(RDE_STAGING, stagingCursor, Tld.get("tld"))); createAction(uploadUrl).runWithLock(uploadCursor); // Only verify signature for SFTP versions, since we check elsewhere that the GCS files are // identical to the ones sent over SFTP. @@ -456,7 +448,7 @@ public class RdeUploadActionTest { URI url = URI.create("sftp://user:password@localhost:32323/"); DateTime stagingCursor = DateTime.parse("2010-10-17TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); - persistResource(Cursor.createScoped(RDE_STAGING, stagingCursor, Registry.get("tld"))); + persistResource(Cursor.createScoped(RDE_STAGING, stagingCursor, Tld.get("tld"))); NoContentException thrown = assertThrows(NoContentException.class, () -> createAction(url).runWithLock(uploadCursor)); assertThat(thrown) @@ -473,8 +465,8 @@ public class RdeUploadActionTest { DateTime stagingCursor = DateTime.parse("2010-10-18TZ"); DateTime uploadCursor = DateTime.parse("2010-10-17TZ"); DateTime sftpCursor = uploadCursor.minusMinutes(97); // Within the 2 hour cooldown period. - persistResource(Cursor.createScoped(RDE_STAGING, stagingCursor, Registry.get("tld"))); - persistResource(Cursor.createScoped(RDE_UPLOAD_SFTP, sftpCursor, Registry.get("tld"))); + persistResource(Cursor.createScoped(RDE_STAGING, stagingCursor, Tld.get("tld"))); + persistResource(Cursor.createScoped(RDE_UPLOAD_SFTP, sftpCursor, Tld.get("tld"))); NoContentException thrown = assertThrows(NoContentException.class, () -> action.runWithLock(uploadCursor)); assertThat(thrown) diff --git a/core/src/test/java/google/registry/reporting/icann/IcannReportingUploadActionTest.java b/core/src/test/java/google/registry/reporting/icann/IcannReportingUploadActionTest.java index 888238a05..3538d7b55 100644 --- a/core/src/test/java/google/registry/reporting/icann/IcannReportingUploadActionTest.java +++ b/core/src/test/java/google/registry/reporting/icann/IcannReportingUploadActionTest.java @@ -33,7 +33,7 @@ import com.google.common.testing.TestLogHandler; import google.registry.gcs.GcsUtils; import google.registry.model.common.Cursor; import google.registry.model.common.Cursor.CursorType; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.request.HttpException.ServiceUnavailableException; @@ -104,16 +104,16 @@ class IcannReportingUploadActionTest { clock.setTo(DateTime.parse("2006-07-05T00:30:00Z")); persistResource( Cursor.createScoped( - CursorType.ICANN_UPLOAD_ACTIVITY, DateTime.parse("2006-07-01TZ"), Registry.get("tld"))); + CursorType.ICANN_UPLOAD_ACTIVITY, DateTime.parse("2006-07-01TZ"), Tld.get("tld"))); persistResource( Cursor.createScoped( - CursorType.ICANN_UPLOAD_TX, DateTime.parse("2006-07-01TZ"), Registry.get("tld"))); + CursorType.ICANN_UPLOAD_TX, DateTime.parse("2006-07-01TZ"), Tld.get("tld"))); persistResource( Cursor.createScoped( - CursorType.ICANN_UPLOAD_ACTIVITY, DateTime.parse("2006-07-01TZ"), Registry.get("foo"))); + CursorType.ICANN_UPLOAD_ACTIVITY, DateTime.parse("2006-07-01TZ"), Tld.get("foo"))); persistResource( Cursor.createScoped( - CursorType.ICANN_UPLOAD_TX, DateTime.parse("2006-07-01TZ"), Registry.get("foo"))); + CursorType.ICANN_UPLOAD_TX, DateTime.parse("2006-07-01TZ"), Tld.get("foo"))); loggerToIntercept.addHandler(logHandler); } @@ -145,10 +145,10 @@ class IcannReportingUploadActionTest { clock.setTo(DateTime.parse("2006-01-22T00:30:00Z")); persistResource( Cursor.createScoped( - CursorType.ICANN_UPLOAD_ACTIVITY, DateTime.parse("2006-01-01TZ"), Registry.get("tld"))); + CursorType.ICANN_UPLOAD_ACTIVITY, DateTime.parse("2006-01-01TZ"), Tld.get("tld"))); persistResource( Cursor.createScoped( - CursorType.ICANN_UPLOAD_TX, DateTime.parse("2006-01-01TZ"), Registry.get("tld"))); + CursorType.ICANN_UPLOAD_TX, DateTime.parse("2006-01-01TZ"), Tld.get("tld"))); gcsUtils.createFromBytes( BlobId.of("basin/icann/monthly/2005-12", "tld-transactions-200512.csv"), PAYLOAD_SUCCESS); gcsUtils.createFromBytes( @@ -181,7 +181,7 @@ class IcannReportingUploadActionTest { IcannReportingUploadAction action = createAction(); action.run(); Cursor cursor = - loadByKey(Cursor.createScopedVKey(CursorType.ICANN_UPLOAD_ACTIVITY, Registry.get("tld"))); + loadByKey(Cursor.createScopedVKey(CursorType.ICANN_UPLOAD_ACTIVITY, Tld.get("tld"))); assertThat(cursor.getCursorTime()).isEqualTo(DateTime.parse("2006-08-01TZ")); } @@ -238,7 +238,7 @@ class IcannReportingUploadActionTest { runTest_nonRetryableException( new IOException("Your IP address 25.147.130.158 is not allowed to connect")); Cursor cursor = - loadByKey(Cursor.createScopedVKey(CursorType.ICANN_UPLOAD_ACTIVITY, Registry.get("tld"))); + loadByKey(Cursor.createScopedVKey(CursorType.ICANN_UPLOAD_ACTIVITY, Tld.get("tld"))); assertThat(cursor.getCursorTime()).isEqualTo(DateTime.parse("2006-07-01TZ")); } @@ -248,7 +248,7 @@ class IcannReportingUploadActionTest { IcannReportingUploadAction action = createAction(); action.run(); Cursor cursor = - loadByKey(Cursor.createScopedVKey(CursorType.ICANN_UPLOAD_ACTIVITY, Registry.get("foo"))); + loadByKey(Cursor.createScopedVKey(CursorType.ICANN_UPLOAD_ACTIVITY, Tld.get("foo"))); assertThat(cursor.getCursorTime()).isEqualTo(DateTime.parse("2006-07-01TZ")); verifyNoMoreInteractions(mockReporter); } @@ -284,7 +284,7 @@ class IcannReportingUploadActionTest { clock.setTo(DateTime.parse("2006-01-22T00:30:00Z")); persistResource( Cursor.createScoped( - CursorType.ICANN_UPLOAD_ACTIVITY, DateTime.parse("2006-01-01TZ"), Registry.get("tld"))); + CursorType.ICANN_UPLOAD_ACTIVITY, DateTime.parse("2006-01-01TZ"), Tld.get("tld"))); IcannReportingUploadAction action = createAction(); action.run(); assertAboutLogs() @@ -300,7 +300,7 @@ class IcannReportingUploadActionTest { void testWarning_fileNotStagedYet() throws Exception { persistResource( Cursor.createScoped( - CursorType.ICANN_UPLOAD_ACTIVITY, DateTime.parse("2006-08-01TZ"), Registry.get("foo"))); + CursorType.ICANN_UPLOAD_ACTIVITY, DateTime.parse("2006-08-01TZ"), Tld.get("foo"))); clock.setTo(DateTime.parse("2006-08-01T00:30:00Z")); IcannReportingUploadAction action = createAction(); action.run(); @@ -349,10 +349,10 @@ class IcannReportingUploadActionTest { new InternetAddress("sender@example.com"))); Cursor newActivityCursor = - loadByKey(Cursor.createScopedVKey(CursorType.ICANN_UPLOAD_ACTIVITY, Registry.get("new"))); + loadByKey(Cursor.createScopedVKey(CursorType.ICANN_UPLOAD_ACTIVITY, Tld.get("new"))); assertThat(newActivityCursor.getCursorTime()).isEqualTo(DateTime.parse("2006-08-01TZ")); Cursor newTransactionCursor = - loadByKey(Cursor.createScopedVKey(CursorType.ICANN_UPLOAD_TX, Registry.get("new"))); + loadByKey(Cursor.createScopedVKey(CursorType.ICANN_UPLOAD_TX, Tld.get("new"))); assertThat(newTransactionCursor.getCursorTime()).isEqualTo(DateTime.parse("2006-08-01TZ")); } } diff --git a/core/src/test/java/google/registry/schema/integration/SqlIntegrationTestSuite.java b/core/src/test/java/google/registry/schema/integration/SqlIntegrationTestSuite.java index 16e705e77..3b75cd11d 100644 --- a/core/src/test/java/google/registry/schema/integration/SqlIntegrationTestSuite.java +++ b/core/src/test/java/google/registry/schema/integration/SqlIntegrationTestSuite.java @@ -34,7 +34,7 @@ import google.registry.model.server.LockTest; import google.registry.model.server.ServerSecretTest; import google.registry.model.smd.SignedMarkRevocationListDaoTest; import google.registry.model.tld.RegistryLockDaoTest; -import google.registry.model.tld.RegistryTest; +import google.registry.model.tld.TldTest; import google.registry.model.tld.label.PremiumListDaoTest; import google.registry.model.tld.label.ReservedListDaoTest; import google.registry.model.tmch.ClaimsListDaoTest; @@ -96,7 +96,7 @@ import org.junit.runner.RunWith; PremiumListDaoTest.class, RdeRevisionTest.class, RegistrarDaoTest.class, - RegistryTest.class, + TldTest.class, ReservedListDaoTest.class, RegistryLockDaoTest.class, ServerSecretTest.class, diff --git a/core/src/test/java/google/registry/testing/DatabaseHelper.java b/core/src/test/java/google/registry/testing/DatabaseHelper.java index d4ebf1af6..d5e5ab1ae 100644 --- a/core/src/test/java/google/registry/testing/DatabaseHelper.java +++ b/core/src/test/java/google/registry/testing/DatabaseHelper.java @@ -32,7 +32,7 @@ import static google.registry.model.IdService.allocateId; import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects; import static google.registry.model.ImmutableObjectSubject.immutableObjectCorrespondence; import static google.registry.model.ResourceTransferUtils.createTransferResponse; -import static google.registry.model.tld.Registry.TldState.GENERAL_AVAILABILITY; +import static google.registry.model.tld.Tld.TldState.GENERAL_AVAILABILITY; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.pricing.PricingEngineProxy.getDomainRenewCost; import static google.registry.util.CollectionUtils.difference; @@ -91,9 +91,9 @@ import google.registry.model.registrar.Registrar.State; import google.registry.model.registrar.RegistrarAddress; import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntryDao; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.TldState; -import google.registry.model.tld.Registry.TldType; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldState; +import google.registry.model.tld.Tld.TldType; import google.registry.model.tld.label.PremiumList; import google.registry.model.tld.label.PremiumList.PremiumEntry; import google.registry.model.tld.label.PremiumListDao; @@ -211,29 +211,29 @@ public final class DatabaseHelper { .build(); } - public static Registry newRegistry(String tld, String roidSuffix) { - return newRegistry(tld, roidSuffix, ImmutableSortedMap.of(START_OF_TIME, GENERAL_AVAILABILITY)); + public static Tld newTld(String tld, String roidSuffix) { + return newTld(tld, roidSuffix, ImmutableSortedMap.of(START_OF_TIME, GENERAL_AVAILABILITY)); } - public static Registry newRegistry( + public static Tld newTld( String tld, String roidSuffix, ImmutableSortedMap tldStates) { - return setupRegistry(new Registry.Builder(), tld, roidSuffix, tldStates); + return setupTld(new Tld.Builder(), tld, roidSuffix, tldStates); } - public static Registry newRegistry( + public static Tld newTld( String tld, String roidSuffix, ImmutableSortedMap tldStates, TldType tldType) { - return setupRegistry(new Registry.Builder().setTldType(tldType), tld, roidSuffix, tldStates); + return setupTld(new Tld.Builder().setTldType(tldType), tld, roidSuffix, tldStates); } - private static Registry setupRegistry( - Registry.Builder registryBuilder, + private static Tld setupTld( + Tld.Builder tldBuilder, String tld, String roidSuffix, ImmutableSortedMap tldStates) { - return registryBuilder + return tldBuilder .setTldStr(tld) .setRoidSuffix(roidSuffix) .setTldStateTransitions(tldStates) @@ -396,11 +396,11 @@ public final class DatabaseHelper { } /** Creates and persists a tld. */ - public static Registry createTld(String tld) { + public static Tld createTld(String tld) { return createTld(tld, GENERAL_AVAILABILITY); } - public static Registry createTld(String tld, String roidSuffix) { + public static Tld createTld(String tld, String roidSuffix) { return createTld(tld, roidSuffix, ImmutableSortedMap.of(START_OF_TIME, GENERAL_AVAILABILITY)); } @@ -411,11 +411,11 @@ public final class DatabaseHelper { } } - public static Registry createTld(String tld, TldState tldState) { + public static Tld createTld(String tld, TldState tldState) { return createTld(tld, ImmutableSortedMap.of(START_OF_TIME, tldState)); } - public static Registry createTld(String tld, ImmutableSortedMap tldStates) { + public static Tld createTld(String tld, ImmutableSortedMap tldStates) { // Coerce the TLD string into a valid ROID suffix. String roidSuffix = Ascii.toUpperCase(tld.replaceFirst(ACE_PREFIX_REGEX, "").replace('.', '_')) @@ -424,16 +424,16 @@ public final class DatabaseHelper { tld, roidSuffix.length() > 8 ? roidSuffix.substring(0, 8) : roidSuffix, tldStates); } - public static Registry createTld( + public static Tld createTld( String tld, String roidSuffix, ImmutableSortedMap tldStates) { - Registry registry = persistResource(newRegistry(tld, roidSuffix, tldStates)); + Tld registry = persistResource(newTld(tld, roidSuffix, tldStates)); allowRegistrarAccess("TheRegistrar", tld); allowRegistrarAccess("NewRegistrar", tld); return registry; } public static void deleteTld(String tld) { - deleteResource(Registry.get(tld)); + deleteResource(Tld.get(tld)); disallowRegistrarAccess("TheRegistrar", tld); disallowRegistrarAccess("NewRegistrar", tld); } @@ -527,8 +527,7 @@ public final class DatabaseHelper { .setReason(Reason.TRANSFER) .setTargetId(domain.getDomainName()) .setEventTime(eventTime) - .setBillingTime( - eventTime.plus(Registry.get(domain.getTld()).getTransferGracePeriodLength())) + .setBillingTime(eventTime.plus(Tld.get(domain.getTld()).getTransferGracePeriodLength())) .setRegistrarId("NewRegistrar") .setPeriodYears(1) .setCost(getDomainRenewCost(domain.getDomainName(), costLookupTime, 1)) diff --git a/core/src/test/java/google/registry/tmch/NordnUploadActionTest.java b/core/src/test/java/google/registry/tmch/NordnUploadActionTest.java index 2e8df684b..65a36434c 100644 --- a/core/src/test/java/google/registry/tmch/NordnUploadActionTest.java +++ b/core/src/test/java/google/registry/tmch/NordnUploadActionTest.java @@ -42,7 +42,7 @@ import com.google.common.base.VerifyException; import google.registry.batch.CloudTasksUtils; import google.registry.model.domain.Domain; import google.registry.model.domain.launch.LaunchNotice; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.VKey; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; @@ -114,7 +114,7 @@ class NordnUploadActionTest { persistResource(loadRegistrar("TheRegistrar").asBuilder().setIanaIdentifier(99999L).build()); persistResource(loadRegistrar("NewRegistrar").asBuilder().setIanaIdentifier(88888L).build()); createTld("tld"); - persistResource(Registry.get("tld").asBuilder().setLordnUsername("lolcat").build()); + persistResource(Tld.get("tld").asBuilder().setLordnUsername("lolcat").build()); persistSunriseModeDomain(); clock.advanceBy(Duration.standardDays(1)); persistClaimsModeDomain(); @@ -172,7 +172,7 @@ class NordnUploadActionTest { @Test void testFailure_nullRegistryUser() { - persistResource(Registry.get("tld").asBuilder().setLordnUsername(null).build()); + persistResource(Tld.get("tld").asBuilder().setLordnUsername(null).build()); VerifyException thrown = assertThrows(VerifyException.class, action::run); assertThat(thrown).hasMessageThat().contains("lordnUsername is not set for tld."); } diff --git a/core/src/test/java/google/registry/tmch/NordnVerifyActionTest.java b/core/src/test/java/google/registry/tmch/NordnVerifyActionTest.java index 2c0e341f3..891401df0 100644 --- a/core/src/test/java/google/registry/tmch/NordnVerifyActionTest.java +++ b/core/src/test/java/google/registry/tmch/NordnVerifyActionTest.java @@ -30,7 +30,7 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.request.HttpException.ConflictException; @@ -89,7 +89,7 @@ class NordnVerifyActionTest { @BeforeEach void beforeEach() throws Exception { createTld("gtld"); - persistResource(Registry.get("gtld").asBuilder().setLordnUsername("lolcat").build()); + persistResource(Tld.get("gtld").asBuilder().setLordnUsername("lolcat").build()); action.tld = "gtld"; action.urlConnectionService = urlConnectionService; when(httpUrlConnection.getResponseCode()).thenReturn(SC_OK); diff --git a/core/src/test/java/google/registry/tools/CreateAnchorTenantCommandTest.java b/core/src/test/java/google/registry/tools/CreateAnchorTenantCommandTest.java index 279f28c6a..f6930918f 100644 --- a/core/src/test/java/google/registry/tools/CreateAnchorTenantCommandTest.java +++ b/core/src/test/java/google/registry/tools/CreateAnchorTenantCommandTest.java @@ -21,7 +21,7 @@ import static org.joda.money.CurrencyUnit.JPY; import static org.junit.jupiter.api.Assertions.assertThrows; import com.beust.jcommander.ParameterException; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.testing.DeterministicStringGenerator; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -75,7 +75,7 @@ class CreateAnchorTenantCommandTest extends EppToolCommandTestCase extends CreateOrUpdatePremiumListCommandTestCase { - Registry registry; + Tld registry; @BeforeEach void beforeEach() { - registry = createRegistry(TLD_TEST, null, null); + registry = createTld(TLD_TEST, null, null); } @Test @@ -82,7 +83,7 @@ class CreatePremiumListCommandTest @Test void commandPrompt_failurePremiumListAlreadyExists() { String randomStr = "random"; - createTld(randomStr); + DatabaseHelper.createTld(randomStr); CreatePremiumListCommand command = new CreatePremiumListCommand(); command.name = randomStr; command.currencyUnit = "USD"; diff --git a/core/src/test/java/google/registry/tools/CreateRegistrarCommandTest.java b/core/src/test/java/google/registry/tools/CreateRegistrarCommandTest.java index 6d698c7cb..e17136ecd 100644 --- a/core/src/test/java/google/registry/tools/CreateRegistrarCommandTest.java +++ b/core/src/test/java/google/registry/tools/CreateRegistrarCommandTest.java @@ -20,7 +20,7 @@ import static google.registry.testing.CertificateSamples.SAMPLE_CERT; import static google.registry.testing.CertificateSamples.SAMPLE_CERT3; import static google.registry.testing.CertificateSamples.SAMPLE_CERT3_HASH; import static google.registry.testing.DatabaseHelper.createTlds; -import static google.registry.testing.DatabaseHelper.newRegistry; +import static google.registry.testing.DatabaseHelper.newTld; import static google.registry.testing.DatabaseHelper.persistNewRegistrar; import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.util.DateTimeUtils.START_OF_TIME; @@ -611,7 +611,7 @@ class CreateRegistrarCommandTest extends CommandTestCase @Test void testSuccess_billingAccountMap_onlyAppliesToRealRegistrar() throws Exception { persistResource( - newRegistry("foo", "FOO") + newTld("foo", "FOO") .asBuilder() .setCurrency(JPY) .setCreateBillingCost(Money.of(JPY, new BigDecimal(1300))) diff --git a/core/src/test/java/google/registry/tools/CreateReservedListCommandTest.java b/core/src/test/java/google/registry/tools/CreateReservedListCommandTest.java index 1009a2ad9..4e3e559f0 100644 --- a/core/src/test/java/google/registry/tools/CreateReservedListCommandTest.java +++ b/core/src/test/java/google/registry/tools/CreateReservedListCommandTest.java @@ -24,7 +24,7 @@ import static google.registry.tools.CreateReservedListCommand.INVALID_FORMAT_ERR import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.io.Files; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.tld.label.ReservedList; import java.nio.file.Path; import java.nio.file.Paths; @@ -80,7 +80,7 @@ class CreateReservedListCommandTest @Test void testFailure_reservedListWithThatNameAlreadyExists() { ReservedList rl = persistReservedList("xn--q9jyb4c_foo", "jones,FULLY_BLOCKED"); - persistResource(Registry.get("xn--q9jyb4c").asBuilder().setReservedLists(rl).build()); + persistResource(Tld.get("xn--q9jyb4c").asBuilder().setReservedLists(rl).build()); IllegalArgumentException thrown = assertThrows( IllegalArgumentException.class, diff --git a/core/src/test/java/google/registry/tools/CreateTldCommandTest.java b/core/src/test/java/google/registry/tools/CreateTldCommandTest.java index 1fbda5776..db14314d4 100644 --- a/core/src/test/java/google/registry/tools/CreateTldCommandTest.java +++ b/core/src/test/java/google/registry/tools/CreateTldCommandTest.java @@ -17,8 +17,8 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.domain.token.AllocationToken.TokenType.DEFAULT_PROMO; -import static google.registry.model.tld.Registry.TldState.GENERAL_AVAILABILITY; -import static google.registry.model.tld.Registry.TldState.PREDELEGATION; +import static google.registry.model.tld.Tld.TldState.GENERAL_AVAILABILITY; +import static google.registry.model.tld.Tld.TldState.PREDELEGATION; import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.persistPremiumList; import static google.registry.testing.DatabaseHelper.persistReservedList; @@ -35,7 +35,7 @@ import com.beust.jcommander.ParameterException; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Range; import google.registry.model.domain.token.AllocationToken; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.tldconfig.idn.IdnTableEnum; import java.math.BigDecimal; import org.joda.money.Money; @@ -63,17 +63,17 @@ class CreateTldCommandTest extends CommandTestCase { runCommandForced("xn--q9jyb4c", "--roid_suffix=Q9JYB4C", "--dns_writers=FooDnsWriter"); DateTime after = fakeClock.nowUtc(); - Registry registry = Registry.get("xn--q9jyb4c"); + Tld registry = Tld.get("xn--q9jyb4c"); assertThat(registry).isNotNull(); - assertThat(registry.getAddGracePeriodLength()).isEqualTo(Registry.DEFAULT_ADD_GRACE_PERIOD); + assertThat(registry.getAddGracePeriodLength()).isEqualTo(Tld.DEFAULT_ADD_GRACE_PERIOD); assertThat(registry.getCreationTime()).isIn(Range.closed(before, after)); assertThat(registry.getDnsWriters()).containsExactly("FooDnsWriter"); assertThat(registry.getTldState(registry.getCreationTime())).isEqualTo(PREDELEGATION); assertThat(registry.getRedemptionGracePeriodLength()) - .isEqualTo(Registry.DEFAULT_REDEMPTION_GRACE_PERIOD); - assertThat(registry.getPendingDeleteLength()).isEqualTo(Registry.DEFAULT_PENDING_DELETE_LENGTH); + .isEqualTo(Tld.DEFAULT_REDEMPTION_GRACE_PERIOD); + assertThat(registry.getPendingDeleteLength()).isEqualTo(Tld.DEFAULT_PENDING_DELETE_LENGTH); assertThat(registry.getRegistryLockOrUnlockBillingCost()) - .isEqualTo(Registry.DEFAULT_REGISTRY_LOCK_OR_UNLOCK_BILLING_COST); + .isEqualTo(Tld.DEFAULT_REGISTRY_LOCK_OR_UNLOCK_BILLING_COST); } @Test @@ -85,7 +85,7 @@ class CreateTldCommandTest extends CommandTestCase { "--dns_a_plus_aaaa_ttl=PT300S", "--dns_ds_ttl=PT240S", "--dns_ns_ttl=PT180S"); - Registry registry = Registry.get("xn--q9jyb4c"); + Tld registry = Tld.get("xn--q9jyb4c"); assertThat(registry).isNotNull(); assertThat(registry.getDnsAPlusAaaaTtl()).isEqualTo(standardMinutes(5)); assertThat(registry.getDnsDsTtl()).isEqualTo(standardMinutes(4)); @@ -121,7 +121,7 @@ class CreateTldCommandTest extends CommandTestCase { "--roid_suffix=Q9JYB4C", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getTldState(DateTime.now(UTC))) + assertThat(Tld.get("xn--q9jyb4c").getTldState(DateTime.now(UTC))) .isEqualTo(GENERAL_AVAILABILITY); } @@ -132,7 +132,7 @@ class CreateTldCommandTest extends CommandTestCase { "--roid_suffix=Q9JYB4C", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getStandardRenewCost(DateTime.now(UTC))) + assertThat(Tld.get("xn--q9jyb4c").getStandardRenewCost(DateTime.now(UTC))) .isEqualTo(Money.of(USD, 42.42)); } @@ -148,7 +148,7 @@ class CreateTldCommandTest extends CommandTestCase { "--dns_writers=VoidDnsWriter", "xn--q9jyb4c"); - Registry registry = Registry.get("xn--q9jyb4c"); + Tld registry = Tld.get("xn--q9jyb4c"); assertThat(registry.getEapFeeFor(now.minusHours(1)).getCost()) .isEqualTo(BigDecimal.ZERO.setScale(2, ROUND_UNNECESSARY)); assertThat(registry.getEapFeeFor(now.plusHours(1)).getCost()) @@ -164,27 +164,27 @@ class CreateTldCommandTest extends CommandTestCase { "--roid_suffix=Q9JYB4C", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getAddGracePeriodLength()).isEqualTo(standardMinutes(5)); + assertThat(Tld.get("xn--q9jyb4c").getAddGracePeriodLength()).isEqualTo(standardMinutes(5)); } @Test void testSuccess_roidSuffixWorks() throws Exception { runCommandForced("--roid_suffix=RSUFFIX", "--dns_writers=VoidDnsWriter", "tld"); - assertThat(Registry.get("tld").getRoidSuffix()).isEqualTo("RSUFFIX"); + assertThat(Tld.get("tld").getRoidSuffix()).isEqualTo("RSUFFIX"); } @Test void testSuccess_escrow() throws Exception { runCommandForced( "--escrow=true", "--roid_suffix=Q9JYB4C", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getEscrowEnabled()).isTrue(); + assertThat(Tld.get("xn--q9jyb4c").getEscrowEnabled()).isTrue(); } @Test void testSuccess_noEscrow() throws Exception { runCommandForced( "--escrow=false", "--roid_suffix=Q9JYB4C", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getEscrowEnabled()).isFalse(); + assertThat(Tld.get("xn--q9jyb4c").getEscrowEnabled()).isFalse(); } @Test @@ -194,7 +194,7 @@ class CreateTldCommandTest extends CommandTestCase { "--roid_suffix=Q9JYB4C", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getRedemptionGracePeriodLength()) + assertThat(Tld.get("xn--q9jyb4c").getRedemptionGracePeriodLength()) .isEqualTo(standardMinutes(5)); } @@ -205,7 +205,7 @@ class CreateTldCommandTest extends CommandTestCase { "--roid_suffix=Q9JYB4C", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getPendingDeleteLength()).isEqualTo(standardMinutes(5)); + assertThat(Tld.get("xn--q9jyb4c").getPendingDeleteLength()).isEqualTo(standardMinutes(5)); } @Test @@ -215,8 +215,7 @@ class CreateTldCommandTest extends CommandTestCase { "--roid_suffix=Q9JYB4C", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getAutomaticTransferLength()) - .isEqualTo(standardMinutes(5)); + assertThat(Tld.get("xn--q9jyb4c").getAutomaticTransferLength()).isEqualTo(standardMinutes(5)); } @Test @@ -226,7 +225,7 @@ class CreateTldCommandTest extends CommandTestCase { "--roid_suffix=Q9JYB4C", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getStandardCreateCost()).isEqualTo(Money.of(USD, 42.42)); + assertThat(Tld.get("xn--q9jyb4c").getStandardCreateCost()).isEqualTo(Money.of(USD, 42.42)); } @Test @@ -236,8 +235,7 @@ class CreateTldCommandTest extends CommandTestCase { "--roid_suffix=Q9JYB4C", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getStandardRestoreCost()) - .isEqualTo(Money.of(USD, 42.42)); + assertThat(Tld.get("xn--q9jyb4c").getStandardRestoreCost()).isEqualTo(Money.of(USD, 42.42)); } @Test @@ -247,8 +245,7 @@ class CreateTldCommandTest extends CommandTestCase { "--roid_suffix=Q9JYB4C", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getServerStatusChangeCost()) - .isEqualTo(Money.of(USD, 42.42)); + assertThat(Tld.get("xn--q9jyb4c").getServerStatusChangeCost()).isEqualTo(Money.of(USD, 42.42)); } @Test @@ -258,7 +255,7 @@ class CreateTldCommandTest extends CommandTestCase { "--roid_suffix=Q9JYB4C", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getRegistryLockOrUnlockBillingCost()) + assertThat(Tld.get("xn--q9jyb4c").getRegistryLockOrUnlockBillingCost()) .isEqualTo(Money.of(USD, 42.42)); } @@ -273,7 +270,7 @@ class CreateTldCommandTest extends CommandTestCase { "--roid_suffix=Q9JYB4C", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c"); - Registry registry = Registry.get("xn--q9jyb4c"); + Tld registry = Tld.get("xn--q9jyb4c"); assertThat(registry.getStandardCreateCost()).isEqualTo(Money.ofMajor(JPY, 12345)); assertThat(registry.getStandardRestoreCost()).isEqualTo(Money.ofMajor(JPY, 67890)); assertThat(registry.getStandardRenewCost(START_OF_TIME)).isEqualTo(Money.ofMajor(JPY, 101112)); @@ -283,12 +280,12 @@ class CreateTldCommandTest extends CommandTestCase { void testSuccess_multipartTld() throws Exception { runCommandForced("co.uk", "--roid_suffix=COUK", "--dns_writers=VoidDnsWriter"); - Registry registry = Registry.get("co.uk"); + Tld registry = Tld.get("co.uk"); assertThat(registry.getTldState(new DateTime())).isEqualTo(PREDELEGATION); - assertThat(registry.getAddGracePeriodLength()).isEqualTo(Registry.DEFAULT_ADD_GRACE_PERIOD); + assertThat(registry.getAddGracePeriodLength()).isEqualTo(Tld.DEFAULT_ADD_GRACE_PERIOD); assertThat(registry.getRedemptionGracePeriodLength()) - .isEqualTo(Registry.DEFAULT_REDEMPTION_GRACE_PERIOD); - assertThat(registry.getPendingDeleteLength()).isEqualTo(Registry.DEFAULT_PENDING_DELETE_LENGTH); + .isEqualTo(Tld.DEFAULT_REDEMPTION_GRACE_PERIOD); + assertThat(registry.getPendingDeleteLength()).isEqualTo(Tld.DEFAULT_PENDING_DELETE_LENGTH); } @Test @@ -298,7 +295,7 @@ class CreateTldCommandTest extends CommandTestCase { "--roid_suffix=Q9JYB4C", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getReservedListNames()) + assertThat(Tld.get("xn--q9jyb4c").getReservedListNames()) .containsExactly("xn--q9jyb4c_abuse", "common_abuse"); } @@ -402,7 +399,7 @@ class CreateTldCommandTest extends CommandTestCase { "--roid_suffix=Q9JYB4C", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c")); - assertThat(thrown).hasMessageThat().contains("All EAP fees must be in the registry's currency"); + assertThat(thrown).hasMessageThat().contains("All EAP fees must be in the TLD's currency"); } @Test @@ -450,7 +447,7 @@ class CreateTldCommandTest extends CommandTestCase { "--roid_suffix=Q9JYB4C", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getAllowedRegistrantContactIds()) + assertThat(Tld.get("xn--q9jyb4c").getAllowedRegistrantContactIds()) .containsExactly("alice", "bob"); } @@ -461,7 +458,7 @@ class CreateTldCommandTest extends CommandTestCase { "--roid_suffix=Q9JYB4C", "--dns_writers=FooDnsWriter", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getAllowedFullyQualifiedHostNames()) + assertThat(Tld.get("xn--q9jyb4c").getAllowedFullyQualifiedHostNames()) .containsExactly("ns1.example.com", "ns2.example.com"); } @@ -538,7 +535,7 @@ class CreateTldCommandTest extends CommandTestCase { "--roid_suffix=Q9JYB4C", "--dns_writers=FooDnsWriter", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getPremiumListName()).hasValue("xn--q9jyb4c"); + assertThat(Tld.get("xn--q9jyb4c").getPremiumListName()).hasValue("xn--q9jyb4c"); } @Test @@ -548,7 +545,7 @@ class CreateTldCommandTest extends CommandTestCase { "--roid_suffix=Q9JYB4C", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getDriveFolderId()).isEqualTo("madmax2030"); + assertThat(Tld.get("xn--q9jyb4c").getDriveFolderId()).isEqualTo("madmax2030"); } @Test @@ -558,7 +555,7 @@ class CreateTldCommandTest extends CommandTestCase { "--roid_suffix=Q9JYB4C", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getDriveFolderId()).isNull(); + assertThat(Tld.get("xn--q9jyb4c").getDriveFolderId()).isNull(); } @Test @@ -568,7 +565,7 @@ class CreateTldCommandTest extends CommandTestCase { "--roid_suffix=ASDF", "--dns_writers=VoidDnsWriter", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getIdnTables()) + assertThat(Tld.get("xn--q9jyb4c").getIdnTables()) .containsExactly(IdnTableEnum.EXTENDED_LATIN, IdnTableEnum.JA); } @@ -632,8 +629,7 @@ class CreateTldCommandTest extends CommandTestCase { "--roid_suffix=Q9JYB4C", "--dns_writers=FooDnsWriter", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getDefaultPromoTokens()) - .containsExactly(token.createVKey()); + assertThat(Tld.get("xn--q9jyb4c").getDefaultPromoTokens()).containsExactly(token.createVKey()); } @Test @@ -659,7 +655,7 @@ class CreateTldCommandTest extends CommandTestCase { "--roid_suffix=Q9JYB4C", "--dns_writers=FooDnsWriter", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getDefaultPromoTokens()) + assertThat(Tld.get("xn--q9jyb4c").getDefaultPromoTokens()) .containsExactly(token.createVKey(), token2.createVKey()); } diff --git a/core/src/test/java/google/registry/tools/DeletePremiumListCommandTest.java b/core/src/test/java/google/registry/tools/DeletePremiumListCommandTest.java index bc0806865..83a16611a 100644 --- a/core/src/test/java/google/registry/tools/DeletePremiumListCommandTest.java +++ b/core/src/test/java/google/registry/tools/DeletePremiumListCommandTest.java @@ -23,7 +23,7 @@ import static google.registry.testing.DatabaseHelper.persistResource; import static org.joda.money.CurrencyUnit.USD; import static org.junit.jupiter.api.Assertions.assertThrows; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.tld.label.PremiumList; import google.registry.model.tld.label.PremiumListDao; import org.junit.jupiter.api.Test; @@ -52,7 +52,7 @@ class DeletePremiumListCommandTest extends CommandTestCase { @BeforeEach void beforeEach() { persistResource( - newRegistry( + newTld( TLD_REAL, Ascii.toUpperCase(TLD_REAL), ImmutableSortedMap.of(START_OF_TIME, GENERAL_AVAILABILITY), TldType.REAL)); persistResource( - newRegistry( + newTld( TLD_TEST, Ascii.toUpperCase(TLD_TEST), ImmutableSortedMap.of(START_OF_TIME, GENERAL_AVAILABILITY), @@ -57,13 +57,13 @@ class DeleteTldCommandTest extends CommandTestCase { void testSuccess_otherTldUnaffected() throws Exception { runCommandForced("--tld=" + TLD_TEST); - Registry.get(TLD_REAL); - assertThrows(RegistryNotFoundException.class, () -> Registry.get(TLD_TEST)); + Tld.get(TLD_REAL); + assertThrows(TldNotFoundException.class, () -> Tld.get(TLD_TEST)); } @Test void testFailure_whenTldDoesNotExist() { - assertThrows(RegistryNotFoundException.class, () -> runCommandForced("--tld=nonexistenttld")); + assertThrows(TldNotFoundException.class, () -> runCommandForced("--tld=nonexistenttld")); } @Test diff --git a/core/src/test/java/google/registry/tools/DomainLockUtilsTest.java b/core/src/test/java/google/registry/tools/DomainLockUtilsTest.java index 623acc135..a71a252e9 100644 --- a/core/src/test/java/google/registry/tools/DomainLockUtilsTest.java +++ b/core/src/test/java/google/registry/tools/DomainLockUtilsTest.java @@ -42,7 +42,7 @@ import google.registry.model.domain.DomainHistory; import google.registry.model.domain.RegistryLock; import google.registry.model.host.Host; import google.registry.model.reporting.HistoryEntry; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.testing.CloudTasksHelper; @@ -566,7 +566,7 @@ public final class DomainLockUtilsTest { .setReason(Reason.SERVER_STATUS) .setTargetId(domain.getForeignKey()) .setRegistrarId(domain.getCurrentSponsorRegistrarId()) - .setCost(Registry.get(domain.getTld()).getRegistryLockOrUnlockBillingCost()) + .setCost(Tld.get(domain.getTld()).getRegistryLockOrUnlockBillingCost()) .setEventTime(clock.nowUtc()) .setBillingTime(clock.nowUtc()) .setDomainHistory(entry) diff --git a/core/src/test/java/google/registry/tools/ListCursorsCommandTest.java b/core/src/test/java/google/registry/tools/ListCursorsCommandTest.java index c43bb9756..df4b5b017 100644 --- a/core/src/test/java/google/registry/tools/ListCursorsCommandTest.java +++ b/core/src/test/java/google/registry/tools/ListCursorsCommandTest.java @@ -23,7 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import com.beust.jcommander.ParameterException; import google.registry.model.common.Cursor; import google.registry.model.common.Cursor.CursorType; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import org.joda.time.DateTime; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -58,7 +58,7 @@ public class ListCursorsCommandTest extends CommandTestCase void testListCursors_twoTldsOneAbsent_printsAbsentAndTimestampSorted() throws Exception { createTlds("foo", "bar"); persistResource( - Cursor.createScoped(CursorType.BRDA, DateTime.parse("1984-12-18TZ"), Registry.get("bar"))); + Cursor.createScoped(CursorType.BRDA, DateTime.parse("1984-12-18TZ"), Tld.get("bar"))); runCommand("--type=BRDA"); assertThat(getStdoutAsLines()) .containsExactly( @@ -84,7 +84,7 @@ public class ListCursorsCommandTest extends CommandTestCase @Test void testListCursors_filterEscrowEnabled_doesWhatItSays() throws Exception { createTlds("foo", "bar"); - persistResource(Registry.get("bar").asBuilder().setEscrowEnabled(true).build()); + persistResource(Tld.get("bar").asBuilder().setEscrowEnabled(true).build()); runCommand("--type=BRDA", "--escrow_enabled"); assertThat(getStdoutAsLines()) .containsExactly( diff --git a/core/src/test/java/google/registry/tools/ListDomainsCommandTest.java b/core/src/test/java/google/registry/tools/ListDomainsCommandTest.java index 3315cd4f9..73fa60134 100644 --- a/core/src/test/java/google/registry/tools/ListDomainsCommandTest.java +++ b/core/src/test/java/google/registry/tools/ListDomainsCommandTest.java @@ -16,7 +16,7 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; import static google.registry.testing.DatabaseHelper.createTlds; -import static google.registry.testing.DatabaseHelper.newRegistry; +import static google.registry.testing.DatabaseHelper.newTld; import static google.registry.testing.DatabaseHelper.persistResource; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.eq; @@ -25,7 +25,7 @@ import static org.mockito.Mockito.verify; import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; import com.google.common.net.MediaType; -import google.registry.model.tld.Registry.TldType; +import google.registry.model.tld.Tld.TldType; import google.registry.tools.server.ListDomainsAction; import org.junit.jupiter.api.Test; import org.mockito.junit.jupiter.MockitoSettings; @@ -73,7 +73,7 @@ public class ListDomainsCommandTest extends ListObjectsCommandTestCase { String roidSuffix, TldState tldState, boolean isEarlyAccess) { - Registry registry = Registry.get(tldName); + Tld registry = Tld.get(tldName); assertThat(registry).isNotNull(); assertThat(registry.getRoidSuffix()).isEqualTo(roidSuffix); assertThat(registry.getTldState(DateTime.now(UTC))).isEqualTo(tldState); @@ -330,7 +330,7 @@ class SetupOteCommandTest extends CommandTestCase { "--registrar=blobio", "--email=contact@email.com", "--certfile=" + getCertFilename())); - assertThat(thrown).hasMessageThat().contains("VKey(sql:blobio-sunrise)"); + assertThat(thrown).hasMessageThat().contains("VKey(sql:blobio-sunrise)"); } @Test diff --git a/core/src/test/java/google/registry/tools/UpdateCursorsCommandTest.java b/core/src/test/java/google/registry/tools/UpdateCursorsCommandTest.java index 9c1eac8de..df7066cc4 100644 --- a/core/src/test/java/google/registry/tools/UpdateCursorsCommandTest.java +++ b/core/src/test/java/google/registry/tools/UpdateCursorsCommandTest.java @@ -25,8 +25,8 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import com.beust.jcommander.ParameterException; import google.registry.model.common.Cursor; import google.registry.model.common.Cursor.CursorType; -import google.registry.model.tld.Registry; -import google.registry.model.tld.Registry.RegistryNotFoundException; +import google.registry.model.tld.Tld; +import google.registry.model.tld.Tld.TldNotFoundException; import org.joda.time.DateTime; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -34,7 +34,7 @@ import org.junit.jupiter.api.Test; /** Unit tests for {@link UpdateCursorsCommand}. */ class UpdateCursorsCommandTest extends CommandTestCase { - private Registry registry; + private Tld registry; @BeforeEach void beforeEach() { @@ -88,8 +88,8 @@ class UpdateCursorsCommandTest extends CommandTestCase { @Test void testSuccess_multipleTlds_hasOldValue() throws Exception { - Registry barRegistry = createTld("bar"); - Registry registry2 = Registry.get("bar"); + Tld barRegistry = createTld("bar"); + Tld registry2 = Tld.get("bar"); persistResource(Cursor.createScoped(CursorType.BRDA, DateTime.parse("1950-12-18TZ"), registry)); persistResource( Cursor.createScoped(CursorType.BRDA, DateTime.parse("1950-12-18TZ"), registry2)); @@ -107,7 +107,7 @@ class UpdateCursorsCommandTest extends CommandTestCase { @Test void testSuccess_multipleTlds_oldValueisEmpty() throws Exception { - Registry barRegistry = createTld("bar"); + Tld barRegistry = createTld("bar"); assertThat(loadByKeyIfPresent(Cursor.createScopedVKey(CursorType.BRDA, registry))).isEmpty(); assertThat(loadByKeyIfPresent(Cursor.createScopedVKey(CursorType.BRDA, barRegistry))).isEmpty(); runCommandForced("--type=brda", "--timestamp=1984-12-18T00:00:00Z", "foo", "bar"); @@ -125,7 +125,7 @@ class UpdateCursorsCommandTest extends CommandTestCase { @Test void testFailure_badTld() { assertThrows( - RegistryNotFoundException.class, + TldNotFoundException.class, () -> runCommandForced("--type=brda", "--timestamp=1984-12-18T00:00:00Z", "bar")); } diff --git a/core/src/test/java/google/registry/tools/UpdatePremiumListCommandTest.java b/core/src/test/java/google/registry/tools/UpdatePremiumListCommandTest.java index bf4247e63..212ec6eab 100644 --- a/core/src/test/java/google/registry/tools/UpdatePremiumListCommandTest.java +++ b/core/src/test/java/google/registry/tools/UpdatePremiumListCommandTest.java @@ -22,7 +22,7 @@ import static org.joda.money.CurrencyUnit.USD; import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.io.Files; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.tld.label.PremiumList; import google.registry.model.tld.label.PremiumList.PremiumEntry; import google.registry.model.tld.label.PremiumListDao; @@ -37,11 +37,11 @@ import org.junit.jupiter.api.Test; /** Unit tests for {@link UpdatePremiumListCommand}. */ class UpdatePremiumListCommandTest extends CreateOrUpdatePremiumListCommandTestCase { - Registry registry; + Tld registry; @BeforeEach void beforeEach() { - registry = createRegistry(TLD_TEST, USD, initialPremiumListData); + registry = createTld(TLD_TEST, USD, initialPremiumListData); } @Test @@ -135,7 +135,7 @@ class UpdatePremiumListCommandTest @Test void commandPrompt_failureNoPreviousVersion() { String fileName = "random"; - registry = createRegistry(fileName, null, null); + registry = createTld(fileName, null, null); UpdatePremiumListCommand command = new UpdatePremiumListCommand(); command.name = fileName; IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, command::prompt); diff --git a/core/src/test/java/google/registry/tools/UpdateRegistrarCommandTest.java b/core/src/test/java/google/registry/tools/UpdateRegistrarCommandTest.java index 7ac8d8ae3..77d3dc1b4 100644 --- a/core/src/test/java/google/registry/tools/UpdateRegistrarCommandTest.java +++ b/core/src/test/java/google/registry/tools/UpdateRegistrarCommandTest.java @@ -21,7 +21,7 @@ import static google.registry.testing.CertificateSamples.SAMPLE_CERT3; import static google.registry.testing.CertificateSamples.SAMPLE_CERT3_HASH; import static google.registry.testing.DatabaseHelper.createTlds; import static google.registry.testing.DatabaseHelper.loadRegistrar; -import static google.registry.testing.DatabaseHelper.newRegistry; +import static google.registry.testing.DatabaseHelper.newTld; import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.util.DateTimeUtils.START_OF_TIME; import static org.joda.money.CurrencyUnit.JPY; @@ -403,7 +403,7 @@ class UpdateRegistrarCommandTest extends CommandTestCase @Test void testSuccess_billingAccountMap_onlyAppliesToRealRegistrar() throws Exception { persistResource( - newRegistry("foo", "FOO") + newTld("foo", "FOO") .asBuilder() .setCurrency(JPY) .setCreateBillingCost(Money.of(JPY, new BigDecimal(1300))) diff --git a/core/src/test/java/google/registry/tools/UpdateTldCommandTest.java b/core/src/test/java/google/registry/tools/UpdateTldCommandTest.java index 64c6cad95..411d654a4 100644 --- a/core/src/test/java/google/registry/tools/UpdateTldCommandTest.java +++ b/core/src/test/java/google/registry/tools/UpdateTldCommandTest.java @@ -17,10 +17,10 @@ package google.registry.tools; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth8.assertThat; import static google.registry.model.domain.token.AllocationToken.TokenType.DEFAULT_PROMO; -import static google.registry.model.tld.Registry.TldState.GENERAL_AVAILABILITY; -import static google.registry.model.tld.Registry.TldState.PREDELEGATION; -import static google.registry.model.tld.Registry.TldState.QUIET_PERIOD; -import static google.registry.model.tld.Registry.TldState.START_DATE_SUNRISE; +import static google.registry.model.tld.Tld.TldState.GENERAL_AVAILABILITY; +import static google.registry.model.tld.Tld.TldState.PREDELEGATION; +import static google.registry.model.tld.Tld.TldState.QUIET_PERIOD; +import static google.registry.model.tld.Tld.TldState.START_DATE_SUNRISE; import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.persistPremiumList; import static google.registry.testing.DatabaseHelper.persistReservedList; @@ -38,7 +38,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedMap; import google.registry.model.domain.token.AllocationToken; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.tldconfig.idn.IdnTableEnum; import java.util.Optional; import org.joda.money.Money; @@ -77,7 +77,7 @@ class UpdateTldCommandTest extends CommandTestCase { START_OF_TIME, sunriseStart, quietPeriodStart, gaStart), "xn--q9jyb4c"); - Registry registry = Registry.get("xn--q9jyb4c"); + Tld registry = Tld.get("xn--q9jyb4c"); assertThat(registry.getTldState(sunriseStart.minusMillis(1))).isEqualTo(PREDELEGATION); assertThat(registry.getTldState(sunriseStart)).isEqualTo(START_DATE_SUNRISE); assertThat(registry.getTldState(sunriseStart.plusMillis(1))).isEqualTo(START_DATE_SUNRISE); @@ -93,13 +93,12 @@ class UpdateTldCommandTest extends CommandTestCase { @Test void testSuccess_setTldState() throws Exception { persistResource( - Registry.get("xn--q9jyb4c") + Tld.get("xn--q9jyb4c") .asBuilder() .setTldStateTransitions(ImmutableSortedMap.of(START_OF_TIME, PREDELEGATION)) .build()); runCommandForced("--set_current_tld_state=START_DATE_SUNRISE", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getTldState(now.plusDays(1))) - .isEqualTo(START_DATE_SUNRISE); + assertThat(Tld.get("xn--q9jyb4c").getTldState(now.plusDays(1))).isEqualTo(START_DATE_SUNRISE); } @Test @@ -113,7 +112,7 @@ class UpdateTldCommandTest extends CommandTestCase { later), "xn--q9jyb4c"); - Registry registry = Registry.get("xn--q9jyb4c"); + Tld registry = Tld.get("xn--q9jyb4c"); assertThat(registry.getStandardRenewCost(START_OF_TIME)).isEqualTo(Money.of(USD, 1)); assertThat(registry.getStandardRenewCost(now.minusMillis(1))).isEqualTo(Money.of(USD, 1)); assertThat(registry.getStandardRenewCost(now)).isEqualTo(Money.of(USD, 2)); @@ -126,55 +125,52 @@ class UpdateTldCommandTest extends CommandTestCase { @Test void testSuccess_multipleArguments() throws Exception { - assertThat(Registry.get("xn--q9jyb4c").getAddGracePeriodLength()) - .isNotEqualTo(standardMinutes(5)); + assertThat(Tld.get("xn--q9jyb4c").getAddGracePeriodLength()).isNotEqualTo(standardMinutes(5)); createTld("example"); - assertThat(Registry.get("example").getAddGracePeriodLength()).isNotEqualTo(standardMinutes(5)); + assertThat(Tld.get("example").getAddGracePeriodLength()).isNotEqualTo(standardMinutes(5)); runCommandForced("--add_grace_period=PT300S", "xn--q9jyb4c", "example"); - assertThat(Registry.get("xn--q9jyb4c").getAddGracePeriodLength()).isEqualTo(standardMinutes(5)); - assertThat(Registry.get("example").getAddGracePeriodLength()).isEqualTo(standardMinutes(5)); + assertThat(Tld.get("xn--q9jyb4c").getAddGracePeriodLength()).isEqualTo(standardMinutes(5)); + assertThat(Tld.get("example").getAddGracePeriodLength()).isEqualTo(standardMinutes(5)); } @Test void testSuccess_addGracePeriodFlag() throws Exception { - assertThat(Registry.get("xn--q9jyb4c").getAddGracePeriodLength()) - .isNotEqualTo(standardMinutes(5)); + assertThat(Tld.get("xn--q9jyb4c").getAddGracePeriodLength()).isNotEqualTo(standardMinutes(5)); runCommandForced("--add_grace_period=PT300S", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getAddGracePeriodLength()).isEqualTo(standardMinutes(5)); + assertThat(Tld.get("xn--q9jyb4c").getAddGracePeriodLength()).isEqualTo(standardMinutes(5)); } @Test void testSuccess_redemptionGracePeriodFlag() throws Exception { - assertThat(Registry.get("xn--q9jyb4c").getRedemptionGracePeriodLength()) + assertThat(Tld.get("xn--q9jyb4c").getRedemptionGracePeriodLength()) .isNotEqualTo(standardMinutes(5)); runCommandForced("--redemption_grace_period=PT300S", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getRedemptionGracePeriodLength()) + assertThat(Tld.get("xn--q9jyb4c").getRedemptionGracePeriodLength()) .isEqualTo(standardMinutes(5)); } @Test void testSuccess_pendingDeleteLengthFlag() throws Exception { - assertThat(Registry.get("xn--q9jyb4c").getPendingDeleteLength()) - .isNotEqualTo(standardMinutes(5)); + assertThat(Tld.get("xn--q9jyb4c").getPendingDeleteLength()).isNotEqualTo(standardMinutes(5)); runCommandForced("--pending_delete_length=PT300S", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getPendingDeleteLength()).isEqualTo(standardMinutes(5)); + assertThat(Tld.get("xn--q9jyb4c").getPendingDeleteLength()).isEqualTo(standardMinutes(5)); } @Test void testSuccess_dnsWriter() throws Exception { - assertThat(Registry.get("xn--q9jyb4c").getDnsWriters()).containsExactly("VoidDnsWriter"); + assertThat(Tld.get("xn--q9jyb4c").getDnsWriters()).containsExactly("VoidDnsWriter"); runCommandForced("--dns_writers=FooDnsWriter", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getDnsWriters()).containsExactly("FooDnsWriter"); + assertThat(Tld.get("xn--q9jyb4c").getDnsWriters()).containsExactly("FooDnsWriter"); } @Test void testSuccess_multipleDnsWriters() throws Exception { - assertThat(Registry.get("xn--q9jyb4c").getDnsWriters()).containsExactly("VoidDnsWriter"); + assertThat(Tld.get("xn--q9jyb4c").getDnsWriters()).containsExactly("VoidDnsWriter"); runCommandForced("--dns_writers=FooDnsWriter,VoidDnsWriter", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getDnsWriters()) + assertThat(Tld.get("xn--q9jyb4c").getDnsWriters()) .containsExactly("FooDnsWriter", "VoidDnsWriter"); } @@ -188,10 +184,9 @@ class UpdateTldCommandTest extends CommandTestCase { .setTokenType(DEFAULT_PROMO) .setAllowedTlds(ImmutableSet.of("xn--q9jyb4c")) .build()); - assertThat(Registry.get("xn--q9jyb4c").getDefaultPromoTokens()).isEmpty(); + assertThat(Tld.get("xn--q9jyb4c").getDefaultPromoTokens()).isEmpty(); runCommandForced("--default_tokens=abc123", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getDefaultPromoTokens()) - .containsExactly(token.createVKey()); + assertThat(Tld.get("xn--q9jyb4c").getDefaultPromoTokens()).containsExactly(token.createVKey()); } @Test @@ -212,9 +207,9 @@ class UpdateTldCommandTest extends CommandTestCase { .setTokenType(DEFAULT_PROMO) .setAllowedTlds(ImmutableSet.of("xn--q9jyb4c")) .build()); - assertThat(Registry.get("xn--q9jyb4c").getDefaultPromoTokens()).isEmpty(); + assertThat(Tld.get("xn--q9jyb4c").getDefaultPromoTokens()).isEmpty(); runCommandForced("--default_tokens=abc123,token", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getDefaultPromoTokens()) + assertThat(Tld.get("xn--q9jyb4c").getDefaultPromoTokens()) .containsExactly(token.createVKey(), token2.createVKey()); } @@ -228,16 +223,15 @@ class UpdateTldCommandTest extends CommandTestCase { .setTokenType(DEFAULT_PROMO) .setAllowedTlds(ImmutableSet.of("xn--q9jyb4c")) .build()); - assertThat(Registry.get("xn--q9jyb4c").getDefaultPromoTokens()).isEmpty(); + assertThat(Tld.get("xn--q9jyb4c").getDefaultPromoTokens()).isEmpty(); persistResource( - Registry.get("xn--q9jyb4c") + Tld.get("xn--q9jyb4c") .asBuilder() .setDefaultPromoTokens(ImmutableList.of(token.createVKey())) .build()); - assertThat(Registry.get("xn--q9jyb4c").getDefaultPromoTokens()) - .containsExactly(token.createVKey()); + assertThat(Tld.get("xn--q9jyb4c").getDefaultPromoTokens()).containsExactly(token.createVKey()); runCommandForced("--default_tokens=", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getDefaultPromoTokens()).isEmpty(); + assertThat(Tld.get("xn--q9jyb4c").getDefaultPromoTokens()).isEmpty(); } @Test @@ -266,16 +260,16 @@ class UpdateTldCommandTest extends CommandTestCase { .setTokenType(DEFAULT_PROMO) .setAllowedTlds(ImmutableSet.of("xn--q9jyb4c")) .build()); - assertThat(Registry.get("xn--q9jyb4c").getDefaultPromoTokens()).isEmpty(); + assertThat(Tld.get("xn--q9jyb4c").getDefaultPromoTokens()).isEmpty(); persistResource( - Registry.get("xn--q9jyb4c") + Tld.get("xn--q9jyb4c") .asBuilder() .setDefaultPromoTokens(ImmutableList.of(token.createVKey(), token2.createVKey())) .build()); - assertThat(Registry.get("xn--q9jyb4c").getDefaultPromoTokens()) + assertThat(Tld.get("xn--q9jyb4c").getDefaultPromoTokens()) .containsExactly(token.createVKey(), token2.createVKey()); runCommandForced("--default_tokens=token,othertoken", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getDefaultPromoTokens()) + assertThat(Tld.get("xn--q9jyb4c").getDefaultPromoTokens()) .containsExactly(token2.createVKey(), token3.createVKey()); } @@ -293,32 +287,31 @@ class UpdateTldCommandTest extends CommandTestCase { @Test void testSuccess_escrow() throws Exception { runCommandForced("--escrow=true", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getEscrowEnabled()).isTrue(); + assertThat(Tld.get("xn--q9jyb4c").getEscrowEnabled()).isTrue(); } @Test void testSuccess_noEscrow() throws Exception { runCommandForced("--escrow=false", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getEscrowEnabled()).isFalse(); + assertThat(Tld.get("xn--q9jyb4c").getEscrowEnabled()).isFalse(); } @Test void testSuccess_createBillingCostFlag() throws Exception { runCommandForced("--create_billing_cost=\"USD 42.42\"", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getStandardCreateCost()).isEqualTo(Money.of(USD, 42.42)); + assertThat(Tld.get("xn--q9jyb4c").getStandardCreateCost()).isEqualTo(Money.of(USD, 42.42)); } @Test void testSuccess_restoreBillingCostFlag() throws Exception { runCommandForced("--restore_billing_cost=\"USD 42.42\"", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getStandardRestoreCost()) - .isEqualTo(Money.of(USD, 42.42)); + assertThat(Tld.get("xn--q9jyb4c").getStandardRestoreCost()).isEqualTo(Money.of(USD, 42.42)); } @Test void testSuccess_nonUsdBillingCostFlag() throws Exception { persistResource( - Registry.get("xn--q9jyb4c") + Tld.get("xn--q9jyb4c") .asBuilder() .setCurrency(JPY) .setCreateBillingCost(Money.ofMajor(JPY, 1)) @@ -336,7 +329,7 @@ class UpdateTldCommandTest extends CommandTestCase { "--server_status_change_cost=\"JPY 97865\"", "--registry_lock_or_unlock_cost=\"JPY 9001\"", "xn--q9jyb4c"); - Registry registry = Registry.get("xn--q9jyb4c"); + Tld registry = Tld.get("xn--q9jyb4c"); assertThat(registry.getStandardCreateCost()).isEqualTo(Money.ofMajor(JPY, 12345)); assertThat(registry.getStandardRestoreCost()).isEqualTo(Money.ofMajor(JPY, 67890)); assertThat(registry.getStandardRenewCost(START_OF_TIME)).isEqualTo(Money.ofMajor(JPY, 101112)); @@ -347,173 +340,183 @@ class UpdateTldCommandTest extends CommandTestCase { @Test void testSuccess_setLordnUsername() throws Exception { runCommandForced("--lordn_username=lordn000", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getLordnUsername()).isEqualTo("lordn000"); + assertThat(Tld.get("xn--q9jyb4c").getLordnUsername()).isEqualTo("lordn000"); } @Test void testSuccess_setOptionalParamsNullString() throws Exception { - persistResource(Registry.get("xn--q9jyb4c").asBuilder().setLordnUsername("lordn000").build()); + persistResource(Tld.get("xn--q9jyb4c").asBuilder().setLordnUsername("lordn000").build()); runCommandForced("--lordn_username=null", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getLordnUsername()).isNull(); + assertThat(Tld.get("xn--q9jyb4c").getLordnUsername()).isNull(); } @Test void testSuccess_setOptionalParamsEmptyString() throws Exception { - persistResource(Registry.get("xn--q9jyb4c").asBuilder().setLordnUsername("lordn000").build()); + persistResource(Tld.get("xn--q9jyb4c").asBuilder().setLordnUsername("lordn000").build()); runCommandForced("--lordn_username=", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getLordnUsername()).isNull(); + assertThat(Tld.get("xn--q9jyb4c").getLordnUsername()).isNull(); } @Test void testSuccess_setReservedLists() throws Exception { runCommandForced("--reserved_lists=xn--q9jyb4c_r1,xn--q9jyb4c_r2", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getReservedListNames()) + assertThat(Tld.get("xn--q9jyb4c").getReservedListNames()) .containsExactly("xn--q9jyb4c_r1", "xn--q9jyb4c_r2"); } @Test void testSuccess_setReservedListsOverwrites() throws Exception { - persistResource(Registry.get("xn--q9jyb4c").asBuilder() - .setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2")) - .build()); + persistResource( + Tld.get("xn--q9jyb4c") + .asBuilder() + .setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2")) + .build()); runCommandForced("--reserved_lists=xn--q9jyb4c_r2", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getReservedListNames()) - .containsExactly("xn--q9jyb4c_r2"); + assertThat(Tld.get("xn--q9jyb4c").getReservedListNames()).containsExactly("xn--q9jyb4c_r2"); } @Test void testSuccess_addReservedLists() throws Exception { - persistResource(Registry.get("xn--q9jyb4c").asBuilder() - .setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1")) - .build()); + persistResource( + Tld.get("xn--q9jyb4c") + .asBuilder() + .setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1")) + .build()); runCommandForced("--add_reserved_lists=xn--q9jyb4c_r2", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getReservedListNames()) + assertThat(Tld.get("xn--q9jyb4c").getReservedListNames()) .containsExactly("xn--q9jyb4c_r1", "xn--q9jyb4c_r2"); } @Test void testSuccess_removeAllReservedLists() throws Exception { - persistResource(Registry.get("xn--q9jyb4c").asBuilder() - .setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2")) - .build()); + persistResource( + Tld.get("xn--q9jyb4c") + .asBuilder() + .setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2")) + .build()); runCommandForced("--remove_reserved_lists=xn--q9jyb4c_r1,xn--q9jyb4c_r2", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getReservedListNames()).isEmpty(); + assertThat(Tld.get("xn--q9jyb4c").getReservedListNames()).isEmpty(); } @Test void testSuccess_removeSomeReservedLists() throws Exception { - persistResource(Registry.get("xn--q9jyb4c").asBuilder() - .setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2")) - .build()); + persistResource( + Tld.get("xn--q9jyb4c") + .asBuilder() + .setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2")) + .build()); runCommandForced("--remove_reserved_lists=xn--q9jyb4c_r1", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getReservedListNames()) - .containsExactly("xn--q9jyb4c_r2"); + assertThat(Tld.get("xn--q9jyb4c").getReservedListNames()).containsExactly("xn--q9jyb4c_r2"); } @Test void testSuccess_setAllowedRegistrants() throws Exception { runCommandForced("--allowed_registrants=alice,bob", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getAllowedRegistrantContactIds()) + assertThat(Tld.get("xn--q9jyb4c").getAllowedRegistrantContactIds()) .containsExactly("alice", "bob"); } @Test void testSuccess_setAllowedRegistrantsOverwrites() throws Exception { persistResource( - Registry.get("xn--q9jyb4c").asBuilder() + Tld.get("xn--q9jyb4c") + .asBuilder() .setAllowedRegistrantContactIds(ImmutableSet.of("jane", "john")) .build()); runCommandForced("--allowed_registrants=alice,bob", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getAllowedRegistrantContactIds()) + assertThat(Tld.get("xn--q9jyb4c").getAllowedRegistrantContactIds()) .containsExactly("alice", "bob"); } @Test void testSuccess_addAllowedRegistrants() throws Exception { persistResource( - Registry.get("xn--q9jyb4c").asBuilder() + Tld.get("xn--q9jyb4c") + .asBuilder() .setAllowedRegistrantContactIds(ImmutableSet.of("alice")) .build()); runCommandForced("--add_allowed_registrants=bob", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getAllowedRegistrantContactIds()) + assertThat(Tld.get("xn--q9jyb4c").getAllowedRegistrantContactIds()) .containsExactly("alice", "bob"); } @Test void testSuccess_removeAllAllowedRegistrants() throws Exception { persistResource( - Registry.get("xn--q9jyb4c").asBuilder() + Tld.get("xn--q9jyb4c") + .asBuilder() .setAllowedRegistrantContactIds(ImmutableSet.of("alice", "bob")) .build()); runCommandForced("--remove_allowed_registrants=alice,bob", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getAllowedRegistrantContactIds()).isEmpty(); + assertThat(Tld.get("xn--q9jyb4c").getAllowedRegistrantContactIds()).isEmpty(); } @Test void testSuccess_removeSomeAllowedRegistrants() throws Exception { persistResource( - Registry.get("xn--q9jyb4c").asBuilder() + Tld.get("xn--q9jyb4c") + .asBuilder() .setAllowedRegistrantContactIds(ImmutableSet.of("alice", "bob")) .build()); runCommandForced("--remove_allowed_registrants=alice", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getAllowedRegistrantContactIds()).containsExactly("bob"); + assertThat(Tld.get("xn--q9jyb4c").getAllowedRegistrantContactIds()).containsExactly("bob"); } @Test void testSuccess_setAllowedNameservers() throws Exception { runCommandForced("--allowed_nameservers=ns1.example.com,ns2.example.com", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getAllowedFullyQualifiedHostNames()) + assertThat(Tld.get("xn--q9jyb4c").getAllowedFullyQualifiedHostNames()) .containsExactly("ns1.example.com", "ns2.example.com"); } @Test void testSuccess_setAllowedNameserversOverwrites() throws Exception { persistResource( - Registry.get("xn--q9jyb4c") + Tld.get("xn--q9jyb4c") .asBuilder() .setAllowedFullyQualifiedHostNames( ImmutableSet.of("ns1.example.tld", "ns2.example.tld")) .build()); runCommandForced("--allowed_nameservers=ns1.example.com,ns2.example.com", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getAllowedFullyQualifiedHostNames()) + assertThat(Tld.get("xn--q9jyb4c").getAllowedFullyQualifiedHostNames()) .containsExactly("ns1.example.com", "ns2.example.com"); } @Test void testSuccess_addAllowedNameservers() throws Exception { persistResource( - Registry.get("xn--q9jyb4c") + Tld.get("xn--q9jyb4c") .asBuilder() .setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns1.example.com")) .build()); runCommandForced("--add_allowed_nameservers=ns2.example.com", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getAllowedFullyQualifiedHostNames()) + assertThat(Tld.get("xn--q9jyb4c").getAllowedFullyQualifiedHostNames()) .containsExactly("ns1.example.com", "ns2.example.com"); } @Test void testSuccess_removeAllAllowedNameservers() throws Exception { persistResource( - Registry.get("xn--q9jyb4c") + Tld.get("xn--q9jyb4c") .asBuilder() .setAllowedFullyQualifiedHostNames( ImmutableSet.of("ns1.example.com", "ns2.example.com")) .build()); runCommandForced("--remove_allowed_nameservers=ns1.example.com,ns2.example.com", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getAllowedFullyQualifiedHostNames()).isEmpty(); + assertThat(Tld.get("xn--q9jyb4c").getAllowedFullyQualifiedHostNames()).isEmpty(); } @Test void testSuccess_removeSomeAllowedNameservers() throws Exception { persistResource( - Registry.get("xn--q9jyb4c") + Tld.get("xn--q9jyb4c") .asBuilder() .setAllowedFullyQualifiedHostNames( ImmutableSet.of("ns1.example.com", "ns2.example.com")) .build()); runCommandForced("--remove_allowed_nameservers=ns1.example.com", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getAllowedFullyQualifiedHostNames()) + assertThat(Tld.get("xn--q9jyb4c").getAllowedFullyQualifiedHostNames()) .containsExactly("ns2.example.com"); } @@ -648,11 +651,11 @@ class UpdateTldCommandTest extends CommandTestCase { @Test void testFailure_setCurrentTldState_outOfOrder() { persistResource( - Registry.get("xn--q9jyb4c").asBuilder() + Tld.get("xn--q9jyb4c") + .asBuilder() .setTldStateTransitions( ImmutableSortedMap.of( - START_OF_TIME, PREDELEGATION, - now.minusMonths(1), GENERAL_AVAILABILITY)) + START_OF_TIME, PREDELEGATION, now.minusMonths(1), GENERAL_AVAILABILITY)) .build()); IllegalArgumentException thrown = assertThrows( @@ -664,11 +667,11 @@ class UpdateTldCommandTest extends CommandTestCase { @Test void testFailure_setCurrentTldState_laterTransitionScheduled() { persistResource( - Registry.get("xn--q9jyb4c").asBuilder() + Tld.get("xn--q9jyb4c") + .asBuilder() .setTldStateTransitions( ImmutableSortedMap.of( - START_OF_TIME, PREDELEGATION, - now.plusMonths(1), GENERAL_AVAILABILITY)) + START_OF_TIME, PREDELEGATION, now.plusMonths(1), GENERAL_AVAILABILITY)) .build()); IllegalArgumentException thrown = assertThrows( @@ -682,11 +685,11 @@ class UpdateTldCommandTest extends CommandTestCase { @Test void testFailure_setCurrentTldState_inProduction() { persistResource( - Registry.get("xn--q9jyb4c").asBuilder() + Tld.get("xn--q9jyb4c") + .asBuilder() .setTldStateTransitions( ImmutableSortedMap.of( - START_OF_TIME, PREDELEGATION, - now.minusMonths(1), GENERAL_AVAILABILITY)) + START_OF_TIME, PREDELEGATION, now.minusMonths(1), GENERAL_AVAILABILITY)) .build()); IllegalArgumentException thrown = assertThrows( @@ -825,9 +828,11 @@ class UpdateTldCommandTest extends CommandTestCase { @Test void testFailure_cantAddDuplicateReservedList() { - persistResource(Registry.get("xn--q9jyb4c").asBuilder() - .setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2")) - .build()); + persistResource( + Tld.get("xn--q9jyb4c") + .asBuilder() + .setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2")) + .build()); IllegalArgumentException thrown = assertThrows( IllegalArgumentException.class, @@ -837,9 +842,11 @@ class UpdateTldCommandTest extends CommandTestCase { @Test void testFailure_cantRemoveReservedListThatIsntPresent() { - persistResource(Registry.get("xn--q9jyb4c").asBuilder() - .setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2")) - .build()); + persistResource( + Tld.get("xn--q9jyb4c") + .asBuilder() + .setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2")) + .build()); IllegalArgumentException thrown = assertThrows( IllegalArgumentException.class, @@ -863,9 +870,10 @@ class UpdateTldCommandTest extends CommandTestCase { @Test void testFailure_cantAddDuplicateAllowedRegistrants() { persistResource( - Registry.get("xn--q9jyb4c").asBuilder() - .setAllowedRegistrantContactIds(ImmutableSet.of("alice", "bob")) - .build()); + Tld.get("xn--q9jyb4c") + .asBuilder() + .setAllowedRegistrantContactIds(ImmutableSet.of("alice", "bob")) + .build()); IllegalArgumentException thrown = assertThrows( IllegalArgumentException.class, @@ -876,9 +884,10 @@ class UpdateTldCommandTest extends CommandTestCase { @Test void testFailure_cantRemoveAllowedRegistrantThatIsntPresent() { persistResource( - Registry.get("xn--q9jyb4c").asBuilder() - .setAllowedRegistrantContactIds(ImmutableSet.of("alice")) - .build()); + Tld.get("xn--q9jyb4c") + .asBuilder() + .setAllowedRegistrantContactIds(ImmutableSet.of("alice")) + .build()); IllegalArgumentException thrown = assertThrows( IllegalArgumentException.class, @@ -902,7 +911,7 @@ class UpdateTldCommandTest extends CommandTestCase { @Test void testFailure_cantAddDuplicateAllowedNameservers() { persistResource( - Registry.get("xn--q9jyb4c") + Tld.get("xn--q9jyb4c") .asBuilder() .setAllowedFullyQualifiedHostNames( ImmutableSet.of("ns1.example.com", "ns2.example.com")) @@ -917,7 +926,7 @@ class UpdateTldCommandTest extends CommandTestCase { @Test void testFailure_cantRemoveAllowedNameserverThatIsntPresent() { persistResource( - Registry.get("xn--q9jyb4c") + Tld.get("xn--q9jyb4c") .asBuilder() .setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns1.example.com")) .build()); @@ -945,40 +954,40 @@ class UpdateTldCommandTest extends CommandTestCase { void testSuccess_canSetRoidSuffixToWhatItAlreadyIs() throws Exception { createTld("foo", "BLAH"); runCommandForced("--roid_suffix=BLAH", "foo"); - assertThat(Registry.get("foo").getRoidSuffix()).isEqualTo("BLAH"); + assertThat(Tld.get("foo").getRoidSuffix()).isEqualTo("BLAH"); } @Test void testSuccess_updateRoidSuffix() throws Exception { createTld("foo", "ARGLE"); runCommandForced("--roid_suffix=BARGLE", "foo"); - assertThat(Registry.get("foo").getRoidSuffix()).isEqualTo("BARGLE"); + assertThat(Tld.get("foo").getRoidSuffix()).isEqualTo("BARGLE"); } @Test void testSuccess_removePremiumListWithNull() throws Exception { runCommandForced("--premium_list=null", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getPremiumListName()).isEmpty(); + assertThat(Tld.get("xn--q9jyb4c").getPremiumListName()).isEmpty(); } @Test void testSuccess_removePremiumListWithBlank() throws Exception { runCommandForced("--premium_list=", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getPremiumListName()).isEmpty(); + assertThat(Tld.get("xn--q9jyb4c").getPremiumListName()).isEmpty(); } @Test void testSuccess_premiumListNotRemovedWhenNotSpecified() throws Exception { runCommandForced("--add_reserved_lists=xn--q9jyb4c_r1,xn--q9jyb4c_r2", "xn--q9jyb4c"); - Optional premiumListName = Registry.get("xn--q9jyb4c").getPremiumListName(); + Optional premiumListName = Tld.get("xn--q9jyb4c").getPremiumListName(); assertThat(premiumListName).hasValue("xn--q9jyb4c"); } @Test void testSuccess_driveFolderId_notRemovedWhenNotSpecified() throws Exception { - persistResource(Registry.get("xn--q9jyb4c").asBuilder().setDriveFolderId("foobar").build()); + persistResource(Tld.get("xn--q9jyb4c").asBuilder().setDriveFolderId("foobar").build()); runCommandForced("xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getDriveFolderId()).isEqualTo("foobar"); + assertThat(Tld.get("xn--q9jyb4c").getDriveFolderId()).isEqualTo("foobar"); } @Test @@ -1039,38 +1048,38 @@ class UpdateTldCommandTest extends CommandTestCase { @Test void testSuccess_setPremiumList() throws Exception { runCommandForced("--premium_list=xn--q9jyb4c", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getPremiumListName()).hasValue("xn--q9jyb4c"); + assertThat(Tld.get("xn--q9jyb4c").getPremiumListName()).hasValue("xn--q9jyb4c"); } @Test void testSuccess_setDriveFolderIdToValue() throws Exception { runCommandForced("--drive_folder_id=madmax2030", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getDriveFolderId()).isEqualTo("madmax2030"); + assertThat(Tld.get("xn--q9jyb4c").getDriveFolderId()).isEqualTo("madmax2030"); } @Test void testSuccess_setDriveFolderIdToNull() throws Exception { runCommandForced("--drive_folder_id=null", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getDriveFolderId()).isNull(); + assertThat(Tld.get("xn--q9jyb4c").getDriveFolderId()).isNull(); } @Test void testSuccess_setsIdnTables() throws Exception { - assertThat(Registry.get("xn--q9jyb4c").getIdnTables()).isEmpty(); + assertThat(Tld.get("xn--q9jyb4c").getIdnTables()).isEmpty(); runCommandForced("--idn_tables=extended_latin,ja", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getIdnTables()) + assertThat(Tld.get("xn--q9jyb4c").getIdnTables()) .containsExactly(IdnTableEnum.EXTENDED_LATIN, IdnTableEnum.JA); } @Test void testSuccess_removesIndTables() throws Exception { persistResource( - Registry.get("xn--q9jyb4c") + Tld.get("xn--q9jyb4c") .asBuilder() .setIdnTables(ImmutableSet.of(IdnTableEnum.EXTENDED_LATIN, IdnTableEnum.JA)) .build()); runCommandForced("--idn_tables=", "xn--q9jyb4c"); - assertThat(Registry.get("xn--q9jyb4c").getIdnTables()).isEmpty(); + assertThat(Tld.get("xn--q9jyb4c").getIdnTables()).isEmpty(); } @Test @@ -1102,7 +1111,7 @@ class UpdateTldCommandTest extends CommandTestCase { "--dns_ds_ttl=PT240S", "--dns_ns_ttl=PT180S", "xn--q9jyb4c"); - Registry registry = Registry.get("xn--q9jyb4c"); + Tld registry = Tld.get("xn--q9jyb4c"); assertThat(registry.getDnsAPlusAaaaTtl()).isEqualTo(standardMinutes(5)); assertThat(registry.getDnsDsTtl()).isEqualTo(standardMinutes(4)); assertThat(registry.getDnsNsTtl()).isEqualTo(standardMinutes(3)); diff --git a/core/src/test/java/google/registry/tools/params/EnumParameterTest.java b/core/src/test/java/google/registry/tools/params/EnumParameterTest.java index ceeaaabb0..b64d3ef94 100644 --- a/core/src/test/java/google/registry/tools/params/EnumParameterTest.java +++ b/core/src/test/java/google/registry/tools/params/EnumParameterTest.java @@ -17,7 +17,7 @@ package google.registry.tools.params; import static com.google.common.truth.Truth.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; -import google.registry.model.tld.Registry.TldState; +import google.registry.model.tld.Tld.TldState; import org.junit.jupiter.api.Test; /** Unit tests for {@link EnumParameter}. */ @@ -38,6 +38,6 @@ class EnumParameterTest { assertThrows(IllegalArgumentException.class, () -> instance.convert("FREE_DOMAINS")); assertThat(thrown) .hasMessageThat() - .contains("No enum constant google.registry.model.tld.Registry.TldState.FREE_DOMAINS"); + .contains("No enum constant google.registry.model.tld.Tld.TldState.FREE_DOMAINS"); } } diff --git a/core/src/test/java/google/registry/tools/server/ListReservedListsActionTest.java b/core/src/test/java/google/registry/tools/server/ListReservedListsActionTest.java index 5ba2cd8e9..bd5f67e8d 100644 --- a/core/src/test/java/google/registry/tools/server/ListReservedListsActionTest.java +++ b/core/src/test/java/google/registry/tools/server/ListReservedListsActionTest.java @@ -18,7 +18,7 @@ import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.persistReservedList; import static google.registry.testing.DatabaseHelper.persistResource; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.tld.label.ReservedList; import java.util.Optional; import org.junit.jupiter.api.BeforeEach; @@ -34,7 +34,7 @@ class ListReservedListsActionTest extends ListActionTestCase { ReservedList rl1 = persistReservedList("xn--q9jyb4c-published", true, "blah,FULLY_BLOCKED"); ReservedList rl2 = persistReservedList("xn--q9jyb4c-private", false, "dugong,FULLY_BLOCKED"); createTld("xn--q9jyb4c"); - persistResource(Registry.get("xn--q9jyb4c").asBuilder().setReservedLists(rl1, rl2).build()); + persistResource(Tld.get("xn--q9jyb4c").asBuilder().setReservedLists(rl1, rl2).build()); action = new ListReservedListsAction(); } diff --git a/core/src/test/java/google/registry/ui/server/registrar/ConsoleOteSetupActionTest.java b/core/src/test/java/google/registry/ui/server/registrar/ConsoleOteSetupActionTest.java index 7d45bd09f..27e7195d6 100644 --- a/core/src/test/java/google/registry/ui/server/registrar/ConsoleOteSetupActionTest.java +++ b/core/src/test/java/google/registry/ui/server/registrar/ConsoleOteSetupActionTest.java @@ -31,7 +31,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSetMultimap; import google.registry.config.RegistryEnvironment; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.request.Action.Method; @@ -151,7 +151,7 @@ public final class ConsoleOteSetupActionTest { // We just check some samples to make sure OteAccountBuilder was called successfully. We aren't // checking that all the entities are there or that they have the correct values. assertThat(loadByRegistrarId("myclientid-3")).isPresent(); - assertThat(Registry.get("myclientid-ga")).isNotNull(); + assertThat(Tld.get("myclientid-ga")).isNotNull(); assertThat( loadByRegistrarId("myclientid-5").get().getContacts().asList().get(0).getEmailAddress()) .isEqualTo("contact@registry.example"); diff --git a/core/src/test/java/google/registry/ui/server/registrar/RegistryLockVerifyActionTest.java b/core/src/test/java/google/registry/ui/server/registrar/RegistryLockVerifyActionTest.java index 30c6d78de..4f37c7bce 100644 --- a/core/src/test/java/google/registry/ui/server/registrar/RegistryLockVerifyActionTest.java +++ b/core/src/test/java/google/registry/ui/server/registrar/RegistryLockVerifyActionTest.java @@ -39,7 +39,7 @@ import google.registry.model.domain.DomainHistory; import google.registry.model.domain.RegistryLock; import google.registry.model.host.Host; import google.registry.model.reporting.HistoryEntry; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.request.auth.AuthLevel; @@ -317,7 +317,7 @@ final class RegistryLockVerifyActionTest { .setReason(Reason.SERVER_STATUS) .setTargetId(domain.getForeignKey()) .setRegistrarId(domain.getCurrentSponsorRegistrarId()) - .setCost(Registry.get(domain.getTld()).getRegistryLockOrUnlockBillingCost()) + .setCost(Tld.get(domain.getTld()).getRegistryLockOrUnlockBillingCost()) .setEventTime(fakeClock.nowUtc()) .setBillingTime(fakeClock.nowUtc()) .setDomainHistory(historyEntry) diff --git a/core/src/test/java/google/registry/whois/WhoisActionTest.java b/core/src/test/java/google/registry/whois/WhoisActionTest.java index 8c42d9a0b..b2dabca6a 100644 --- a/core/src/test/java/google/registry/whois/WhoisActionTest.java +++ b/core/src/test/java/google/registry/whois/WhoisActionTest.java @@ -45,7 +45,7 @@ import google.registry.model.domain.Domain; import google.registry.model.eppcommon.Trid; import google.registry.model.host.Host; import google.registry.model.registrar.Registrar; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.model.transfer.DomainTransferData; import google.registry.model.transfer.TransferStatus; import google.registry.persistence.transaction.JpaTestExtensions; @@ -259,7 +259,7 @@ public class WhoisActionTest { @Disabled @Test void testRun_domainInTestTld_isConsideredNotFound() { - persistResource(Registry.get("lol").asBuilder().setTldType(Registry.TldType.TEST).build()); + persistResource(Tld.get("lol").asBuilder().setTldType(Tld.TldType.TEST).build()); Registrar registrar = persistResource(makeRegistrar( "evilregistrar", "Yes Virginia", ACTIVE)); persistResource( @@ -500,7 +500,7 @@ public class WhoisActionTest { @Disabled @Test void testRun_nameserverInTestTld_notFound() { - persistResource(Registry.get("lol").asBuilder().setTldType(Registry.TldType.TEST).build()); + persistResource(Tld.get("lol").asBuilder().setTldType(Tld.TldType.TEST).build()); persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")); newWhoisAction("nameserver ns1.cat.lol").run(); assertThat(response.getStatus()).isEqualTo(200); diff --git a/core/src/test/java/google/registry/whois/WhoisCommandFactoryTest.java b/core/src/test/java/google/registry/whois/WhoisCommandFactoryTest.java index ed0f6726d..3dfb67460 100644 --- a/core/src/test/java/google/registry/whois/WhoisCommandFactoryTest.java +++ b/core/src/test/java/google/registry/whois/WhoisCommandFactoryTest.java @@ -17,7 +17,7 @@ package google.registry.whois; import static com.google.common.truth.Truth.assertThat; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.testing.DatabaseHelper.newHost; -import static google.registry.testing.DatabaseHelper.newRegistry; +import static google.registry.testing.DatabaseHelper.newTld; import static google.registry.testing.DatabaseHelper.persistNewRegistrar; import static google.registry.testing.DatabaseHelper.persistResource; @@ -61,7 +61,7 @@ class WhoisCommandFactoryTest { @BeforeEach void setUp() throws Exception { - persistResource(newRegistry("tld", "TLD")); + persistResource(newTld("tld", "TLD")); host = newHost("ns.example.tld") .asBuilder() diff --git a/core/src/test/java/google/registry/whois/WhoisHttpActionTest.java b/core/src/test/java/google/registry/whois/WhoisHttpActionTest.java index 8191b0b26..33fdbd57d 100644 --- a/core/src/test/java/google/registry/whois/WhoisHttpActionTest.java +++ b/core/src/test/java/google/registry/whois/WhoisHttpActionTest.java @@ -36,7 +36,7 @@ import static org.mockito.Mockito.when; import google.registry.model.contact.Contact; import google.registry.model.registrar.Registrar; -import google.registry.model.tld.Registry; +import google.registry.model.tld.Tld; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.testing.FakeClock; @@ -115,7 +115,7 @@ class WhoisHttpActionTest { @Disabled @Test void testRun_domainInTestTld_isConsideredNotFound() { - persistResource(Registry.get("lol").asBuilder().setTldType(Registry.TldType.TEST).build()); + persistResource(Tld.get("lol").asBuilder().setTldType(Tld.TldType.TEST).build()); Registrar registrar = persistResource(makeRegistrar( "evilregistrar", "Yes Virginia", Registrar.State.ACTIVE)); persistResource(