From 91789432fe5be3b47c549a4407abc391e29f08d4 Mon Sep 17 00:00:00 2001 From: Ben McIlwain Date: Tue, 21 Apr 2026 15:29:12 -0400 Subject: [PATCH] Migrate core, billing, and history to java.time Migrated core entity primitives (GracePeriod, RegistryLock, TimeOfYear), transfer objects (BaseTransferObject, DomainTransferData, TransferResponse), and HostBase from Joda-Time DateTime to java.time.Instant as Phases 5 and 7. Migrated the Billing Ecosystem (BillingBase, BillingEvent, BillingRecurrence, BillingCancellation) and associated Beam pipelines (ExpandBillingRecurrencesPipeline, InvoicingPipeline) to java.time.Instant as Phase 6. Migrated PollMessage event times and all associated Poll flow utilities (PollAckFlow, PollRequestFlow) to use Instant natively. Migrated core timestamp tracking on EppResource (creationTime, lastEppUpdateTime, deletionTime) as well as CreateAutoTimestamp and UpdateAutoTimestamp to Instant, shedding deprecated DateTime accessors. Migrated the entire HistoryEntry reporting ecosystem (HistoryEntry, DomainTransactionRecord, HistoryEntryDao) completely to java.time.Instant. Updated all associated EPP flows, tools, and testing helpers to handle Instants directly where supported. --- GEMINI.md | 6 + .../google/registry/util/DateTimeUtils.java | 17 +++ .../batch/DeleteLoadTestDataAction.java | 4 +- .../batch/DeleteProberDataAction.java | 7 +- .../registry/beam/billing/BillingEvent.java | 37 ++--- .../ExpandBillingRecurrencesPipeline.java | 8 +- .../registry/bsa/BsaValidateAction.java | 2 +- .../google/registry/flows/FlowModule.java | 2 +- .../flows/domain/DomainCreateFlow.java | 19 +-- .../flows/domain/DomainDeleteFlow.java | 21 +-- .../flows/domain/DomainFlowUtils.java | 4 +- .../registry/flows/domain/DomainInfoFlow.java | 2 +- .../flows/domain/DomainRenewFlow.java | 12 +- .../domain/DomainRestoreRequestFlow.java | 15 ++- .../domain/DomainTransferApproveFlow.java | 20 +-- .../flows/domain/DomainTransferQueryFlow.java | 2 +- .../domain/DomainTransferRejectFlow.java | 4 +- .../domain/DomainTransferRequestFlow.java | 16 ++- .../flows/domain/DomainTransferUtils.java | 29 ++-- .../flows/domain/DomainUpdateFlow.java | 8 +- .../registry/flows/host/HostCreateFlow.java | 10 +- .../registry/flows/host/HostDeleteFlow.java | 9 +- .../registry/flows/host/HostFlowUtils.java | 6 +- .../registry/flows/host/HostInfoFlow.java | 10 +- .../registry/flows/host/HostUpdateFlow.java | 12 +- .../registry/flows/poll/PollAckFlow.java | 4 +- .../registry/flows/poll/PollFlowUtils.java | 43 +----- .../registry/flows/poll/PollRequestFlow.java | 2 +- .../registry/model/CreateAutoTimestamp.java | 21 --- .../google/registry/model/EppResource.java | 62 +-------- .../registry/model/EppResourceUtils.java | 7 +- .../registry/model/ResourceTransferUtils.java | 9 +- .../registry/model/UpdateAutoTimestamp.java | 20 --- .../registry/model/billing/BillingBase.java | 23 +--- .../model/billing/BillingCancellation.java | 15 +-- .../registry/model/billing/BillingEvent.java | 43 +----- .../model/billing/BillingRecurrence.java | 43 +----- .../registry/model/common/TimeOfYear.java | 102 ++------------ .../registry/model/domain/DomainBase.java | 10 +- .../registry/model/domain/GracePeriod.java | 99 +------------- .../model/domain/GracePeriodBase.java | 8 -- .../registry/model/domain/RegistryLock.java | 71 +++------- .../model/domain/token/AllocationToken.java | 2 +- .../google/registry/model/host/HostBase.java | 64 ++------- .../registry/model/poll/PollMessage.java | 13 +- .../poll/PollMessageExternalKeyConverter.java | 7 +- .../registry/model/registrar/Registrar.java | 2 +- .../reporting/DomainTransactionRecord.java | 36 +---- .../model/reporting/HistoryEntry.java | 25 +--- .../java/google/registry/model/tld/Tld.java | 2 +- .../model/transfer/BaseTransferObject.java | 41 +----- .../model/transfer/DomainTransferData.java | 17 --- .../model/transfer/TransferResponse.java | 22 --- .../registry/rdap/RdapJsonFormatter.java | 6 +- .../registry/rde/DomainToXjcConverter.java | 11 +- .../registry/rde/HostToXjcConverter.java | 8 +- .../google/registry/tmch/LordnTaskUtils.java | 8 +- .../registry/tmch/NordnUploadAction.java | 5 +- .../tools/AckPollMessagesCommand.java | 2 +- .../registry/tools/DomainLockUtils.java | 29 ++-- .../tools/EnqueuePollMessageCommand.java | 2 +- .../tools/GenerateDnsReportCommand.java | 6 +- .../tools/GetHistoryEntriesCommand.java | 2 +- .../registry/tools/UnrenewDomainCommand.java | 9 +- .../tools/UpdateRecurrenceCommand.java | 2 +- .../RecreateBillingRecurrencesCommand.java | 14 +- .../tools/server/GenerateZoneFilesAction.java | 6 +- .../console/ConsoleDomainListAction.java | 2 +- .../console/ConsoleRegistryLockAction.java | 4 +- .../batch/CheckBulkComplianceActionTest.java | 10 +- .../batch/DeleteExpiredDomainsActionTest.java | 13 +- .../batch/DeleteProberDataActionTest.java | 11 +- .../batch/ResaveEntityActionTest.java | 5 +- .../beam/billing/BillingEventTest.java | 7 +- .../ExpandBillingRecurrencesPipelineTest.java | 33 +++-- .../beam/billing/InvoicingPipelineTest.java | 80 +++++------ .../beam/common/RegistryJpaReadTest.java | 6 +- .../registry/beam/rde/RdePipelineTest.java | 10 +- .../beam/spec11/Spec11PipelineTest.java | 2 +- .../export/ExportDomainListsActionTest.java | 5 +- .../flows/EppLifecycleDomainTest.java | 5 +- .../google/registry/flows/EppTestCase.java | 25 ++-- .../google/registry/flows/FlowTestCase.java | 2 +- .../flows/domain/DomainCreateFlowTest.java | 17 +-- .../flows/domain/DomainDeleteFlowTest.java | 22 ++- .../domain/DomainDeletionTimeCacheTest.java | 3 +- .../flows/domain/DomainInfoFlowTest.java | 4 +- .../flows/domain/DomainPricingLogicTest.java | 4 +- .../flows/domain/DomainRenewFlowTest.java | 21 ++- .../domain/DomainRestoreRequestFlowTest.java | 5 +- .../domain/DomainTransferApproveFlowTest.java | 24 ++-- .../domain/DomainTransferCancelFlowTest.java | 3 +- .../domain/DomainTransferFlowTestCase.java | 4 +- .../domain/DomainTransferRejectFlowTest.java | 6 +- .../domain/DomainTransferRequestFlowTest.java | 56 +++----- .../flows/host/HostCreateFlowTest.java | 7 +- .../flows/host/HostDeleteFlowTest.java | 17 ++- .../registry/flows/host/HostInfoFlowTest.java | 19 +-- .../flows/host/HostUpdateFlowTest.java | 105 ++++++++------- .../registry/flows/poll/PollAckFlowTest.java | 3 +- .../flows/poll/PollRequestFlowTest.java | 10 +- .../registry/model/EppResourceTest.java | 3 +- .../registry/model/EppResourceUtilsTest.java | 6 +- .../registry/model/ForeignKeyUtilsTest.java | 15 ++- .../registry/model/OteStatsTestHelper.java | 33 ++--- .../model/billing/BillingBaseTest.java | 123 ++++++++--------- .../registry/model/common/TimeOfYearTest.java | 127 ++++++++++-------- .../registry/model/domain/DomainTest.java | 106 ++++++++------- .../domain/token/BulkPricingPackageTest.java | 5 +- .../model/history/DomainHistoryTest.java | 8 +- .../model/history/HostHistoryTest.java | 2 +- .../google/registry/model/host/HostTest.java | 27 ++-- .../PollMessageExternalKeyConverterTest.java | 2 +- .../registry/model/poll/PollMessageTest.java | 16 +-- .../model/reporting/HistoryEntryDaoTest.java | 4 +- .../model/reporting/HistoryEntryTest.java | 14 +- .../model/tld/RegistryLockDaoTest.java | 43 +++--- .../transfer/DomainTransferDataTest.java | 5 +- .../mosapi/module/MosApiModuleTest.java | 4 +- .../registry/rdap/RdapDomainActionTest.java | 21 +-- .../rdap/RdapDomainSearchActionTest.java | 59 ++++---- .../registry/rdap/RdapJsonFormatterTest.java | 16 ++- .../rdap/RdapNameserverActionTest.java | 3 +- .../rdap/RdapNameserverSearchActionTest.java | 12 +- .../rde/DomainToXjcConverterTest.java | 45 ++++--- .../registry/rde/HostToXjcConverterTest.java | 31 ++--- .../testing/AbstractEppResourceSubject.java | 10 +- .../registry/testing/DatabaseHelper.java | 67 ++++----- .../testing/FullFieldsTestEntityHelper.java | 10 +- .../registry/testing/HistoryEntrySubject.java | 7 + .../google/registry/testing/HostSubject.java | 8 +- .../registry/tmch/NordnUploadActionTest.java | 10 +- .../tools/AckPollMessagesCommandTest.java | 34 ++--- .../CreateBulkPricingPackageCommandTest.java | 13 +- .../registry/tools/DomainLockUtilsTest.java | 26 ++-- .../tools/EnqueuePollMessageCommandTest.java | 20 +-- .../registry/tools/EppLifecycleToolsTest.java | 5 +- .../tools/GenerateDnsReportCommandTest.java | 7 +- .../tools/GetAllocationTokenCommandTest.java | 3 +- .../GetBulkPricingPackageCommandTest.java | 7 +- .../registry/tools/GetDomainCommandTest.java | 3 +- .../registry/tools/GetHostCommandTest.java | 3 +- .../registry/tools/MutatingCommandTest.java | 11 +- .../tools/RenewDomainCommandTest.java | 3 +- .../UniformRapidSuspensionCommandTest.java | 7 +- .../tools/UnrenewDomainCommandTest.java | 13 +- .../UpdateBulkPricingPackageCommandTest.java | 5 +- .../tools/UpdateDomainCommandTest.java | 12 +- .../tools/UpdateRecurrenceCommandTest.java | 20 +-- ...cellationsForBillingEventsCommandTest.java | 4 +- ...RecreateBillingRecurrencesCommandTest.java | 38 +++--- .../tools/server/ToolsServerModuleTest.java | 2 +- .../console/ConsoleHistoryDataActionTest.java | 1 + .../ConsoleRegistryLockActionTest.java | 37 +++-- .../ConsoleRegistryLockVerifyActionTest.java | 12 +- 155 files changed, 1182 insertions(+), 1701 deletions(-) diff --git a/GEMINI.md b/GEMINI.md index 3c3307fe464..a591217a412 100644 --- a/GEMINI.md +++ b/GEMINI.md @@ -16,6 +16,8 @@ This document outlines foundational mandates, architectural patterns, and projec ## 2. Time and Precision Handling (java.time Migration) - **Idiomatic java.time Usage:** Avoid redundant conversions between `Instant` and `DateTime`. If a field or parameter is an `Instant`, use it directly. Do not convert to `DateTime` just to call a deprecated method if an `Instant` alternative exists or can be easily created. Furthermore, you should not call `toInstant()` or `toDateTime()` conversion methods when not strictly necessary; always prefer to use an alternative method that returns the correct type if one exists (e.g. use `tm().getTxTime()` which returns an `Instant` instead of calling `tm().getTransactionTime().toInstant()`). +- **CRITICAL MISTAKE TO AVOID:** NEVER use `toInstant(clock.nowUtc())` or `toInstant(fakeClock.nowUtc())`. Both `Clock` and `FakeClock` have a `now()` method that natively returns a `java.time.Instant`. You MUST use `clock.now()` or `fakeClock.now()` directly. Converting `nowUtc()` to an Instant is an embarrassing mistake that demonstrates a lack of basic codebase familiarity. +- **UTC Timezones:** Do not use `ZoneId.of("UTC")`. Use a statically imported `UTC` from `ZoneOffset` instead (`import static java.time.ZoneOffset.UTC;`). - **Millisecond Precision:** Always truncate `Instant.now()` to milliseconds (using `.truncatedTo(ChronoUnit.MILLIS)`) to maintain consistency with Joda `DateTime` and the PostgreSQL schema (which enforces millisecond precision via JPA converters). - **Clock Injection:** - Avoid direct calls to `Instant.now()`, `DateTime.now()`, `ZonedDateTime.now()`, or `System.currentTimeMillis()`. @@ -53,6 +55,10 @@ This document outlines foundational mandates, architectural patterns, and projec ### 6. Project Dependencies - **Common Module:** When using `Clock` or other core utilities in a new or separate module (like `load-testing`), ensure `implementation project(':common')` is added to the module's `build.gradle`. +### 7. Search and Discovery +- **No CodeSearch:** This project is hosted on GitHub, not Google3. Do NOT use `mcp_Coding_search_for_files_codesearch` or other internal Google3 search tools. +- **Local Grep:** Use local shell commands like `git grep` or `grep` via `run_shell_command` to search the codebase. + ## Performance and Efficiency - **Turn Minimization:** Aim for "perfect" code in the first iteration. Iterative fixes for checkstyle or compilation errors consume significant context and time. - **Context Management:** Use sub-agents for batch refactoring or high-volume output tasks to keep the main session history lean and efficient. diff --git a/common/src/main/java/google/registry/util/DateTimeUtils.java b/common/src/main/java/google/registry/util/DateTimeUtils.java index 723e24fe8b2..43afb3c2a65 100644 --- a/common/src/main/java/google/registry/util/DateTimeUtils.java +++ b/common/src/main/java/google/registry/util/DateTimeUtils.java @@ -27,6 +27,7 @@ import java.time.format.DateTimeParseException; import java.time.format.SignStyle; import java.time.temporal.ChronoField; +import java.time.temporal.ChronoUnit; import javax.annotation.Nullable; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; @@ -252,6 +253,22 @@ public static org.joda.time.Instant toJodaInstant(@Nullable java.time.Instant in return (instant == null) ? null : org.joda.time.Instant.ofEpochMilli(instant.toEpochMilli()); } + public static Instant plusHours(Instant instant, long hours) { + return instant.plus(hours, ChronoUnit.HOURS); + } + + public static Instant minusHours(Instant instant, long hours) { + return instant.minus(hours, ChronoUnit.HOURS); + } + + public static Instant plusMinutes(Instant instant, long minutes) { + return instant.plus(minutes, ChronoUnit.MINUTES); + } + + public static Instant minusMinutes(Instant instant, long minutes) { + return instant.minus(minutes, ChronoUnit.MINUTES); + } + public static Instant plusDays(Instant instant, int days) { return instant.atZone(ZoneOffset.UTC).plusDays(days).toInstant(); } diff --git a/core/src/main/java/google/registry/batch/DeleteLoadTestDataAction.java b/core/src/main/java/google/registry/batch/DeleteLoadTestDataAction.java index 004d3630672..7410f520859 100644 --- a/core/src/main/java/google/registry/batch/DeleteLoadTestDataAction.java +++ b/core/src/main/java/google/registry/batch/DeleteLoadTestDataAction.java @@ -20,7 +20,7 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.request.Action.Method.POST; import static google.registry.request.RequestParameters.PARAM_DRY_RUN; -import static google.registry.util.DateTimeUtils.END_OF_TIME; +import static google.registry.util.DateTimeUtils.END_INSTANT; import static google.registry.util.RegistryEnvironment.PRODUCTION; import com.google.common.collect.ImmutableList; @@ -99,7 +99,7 @@ public void run() { private void deletePollMessages(String registrarId) { ImmutableList pollMessages = - PollFlowUtils.createPollMessageQuery(registrarId, END_OF_TIME).list(); + PollFlowUtils.createPollMessageQuery(registrarId, END_INSTANT).list(); if (isDryRun) { logger.atInfo().log( "Would delete %d poll messages for registrar %s.", pollMessages.size(), registrarId); diff --git a/core/src/main/java/google/registry/batch/DeleteProberDataAction.java b/core/src/main/java/google/registry/batch/DeleteProberDataAction.java index 2b27a0ba978..030267201f3 100644 --- a/core/src/main/java/google/registry/batch/DeleteProberDataAction.java +++ b/core/src/main/java/google/registry/batch/DeleteProberDataAction.java @@ -188,7 +188,8 @@ private ImmutableList processDomains( tm().query(DOMAIN_QUERY_STRING, Domain.class) .setParameter("tlds", deletableTlds) .setParameter( - "creationTimeCutoff", CreateAutoTimestamp.create(now.minus(DOMAIN_USED_DURATION))) + "creationTimeCutoff", + CreateAutoTimestamp.create(toInstant(now.minus(DOMAIN_USED_DURATION)))) .setParameter("nowMinusSoftDeleteDelay", toInstant(now.minus(SOFT_DELETE_DELAY))) .setParameter("now", toInstant(now)); ImmutableList domainList = @@ -304,12 +305,12 @@ private static void hardDeleteDomainsAndHosts( // Take a DNS queue + admin registrar id as input so that it can be called from the mapper as well private void softDeleteDomain(Domain domain) { Domain deletedDomain = - domain.asBuilder().setDeletionTime(tm().getTransactionTime()).setStatusValues(null).build(); + domain.asBuilder().setDeletionTime(tm().getTxTime()).setStatusValues(null).build(); DomainHistory historyEntry = new DomainHistory.Builder() .setDomain(domain) .setType(DOMAIN_DELETE) - .setModificationTime(tm().getTransactionTime()) + .setModificationTime(tm().getTxTime()) .setBySuperuser(true) .setReason("Deletion of prober data") .setRegistrarId(registryAdminRegistrarId) diff --git a/core/src/main/java/google/registry/beam/billing/BillingEvent.java b/core/src/main/java/google/registry/beam/billing/BillingEvent.java index 5d2e3e4470e..8cde9d6f4e6 100644 --- a/core/src/main/java/google/registry/beam/billing/BillingEvent.java +++ b/core/src/main/java/google/registry/beam/billing/BillingEvent.java @@ -14,12 +14,17 @@ package google.registry.beam.billing; + import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; import google.registry.reporting.billing.BillingModule; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.time.Instant; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; import java.util.regex.Pattern; import org.apache.beam.sdk.coders.AtomicCoder; import org.apache.beam.sdk.coders.Coder; @@ -29,9 +34,6 @@ import org.apache.beam.sdk.coders.VarIntCoder; import org.apache.beam.sdk.coders.VarLongCoder; import org.jetbrains.annotations.NotNull; -import org.joda.time.DateTime; -import org.joda.time.format.DateTimeFormat; -import org.joda.time.format.DateTimeFormatter; /** * A record representing a single billable event, parsed from a {@code SchemaAndRecord}. @@ -53,8 +55,8 @@ */ public record BillingEvent( long id, - DateTime billingTime, - DateTime eventTime, + Instant billingTime, + Instant eventTime, String registrarId, String billingId, String poNumber, @@ -68,7 +70,7 @@ public record BillingEvent( String flags) { private static final DateTimeFormatter DATE_TIME_FORMATTER = - DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss zzz"); + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss 'UTC'").withZone(ZoneOffset.UTC); private static final Pattern SYNTHETIC_REGEX = Pattern.compile("SYNTHETIC", Pattern.LITERAL); @@ -92,8 +94,8 @@ public record BillingEvent( /** Creates a concrete {@link BillingEvent}. */ static BillingEvent create( long id, - DateTime billingTime, - DateTime eventTime, + Instant billingTime, + Instant eventTime, String registrarId, String billingId, String poNumber, @@ -143,8 +145,8 @@ String toCsv() { .join( ImmutableList.of( id(), - DATE_TIME_FORMATTER.print(billingTime()), - DATE_TIME_FORMATTER.print(eventTime()), + DATE_TIME_FORMATTER.format(billingTime()), + DATE_TIME_FORMATTER.format(eventTime()), registrarId(), billingId(), poNumber(), @@ -162,10 +164,13 @@ String toCsv() { /** Returns the grouping key for this {@code BillingEvent}, to generate the overall invoice. */ InvoiceGroupingKey getInvoiceGroupingKey() { return new InvoiceGroupingKey( - billingTime().toLocalDate().withDayOfMonth(1).toString(), + ZonedDateTime.ofInstant(billingTime(), ZoneOffset.UTC) + .toLocalDate() + .withDayOfMonth(1) + .toString(), years() == 0 ? "" - : billingTime() + : ZonedDateTime.ofInstant(billingTime(), ZoneOffset.UTC) .toLocalDate() .withDayOfMonth(1) .plusYears(years()) @@ -308,8 +313,8 @@ private BillingEventCoder() {} @Override public void encode(BillingEvent value, OutputStream outStream) throws IOException { longCoder.encode(value.id(), outStream); - stringCoder.encode(DATE_TIME_FORMATTER.print(value.billingTime()), outStream); - stringCoder.encode(DATE_TIME_FORMATTER.print(value.eventTime()), outStream); + stringCoder.encode(DATE_TIME_FORMATTER.format(value.billingTime()), outStream); + stringCoder.encode(DATE_TIME_FORMATTER.format(value.eventTime()), outStream); stringCoder.encode(value.registrarId(), outStream); stringCoder.encode(value.billingId(), outStream); stringCoder.encode(value.poNumber(), outStream); @@ -327,8 +332,8 @@ public void encode(BillingEvent value, OutputStream outStream) throws IOExceptio public BillingEvent decode(InputStream inStream) throws IOException { return new BillingEvent( longCoder.decode(inStream), - DATE_TIME_FORMATTER.parseDateTime(stringCoder.decode(inStream)), - DATE_TIME_FORMATTER.parseDateTime(stringCoder.decode(inStream)), + Instant.from(DATE_TIME_FORMATTER.parse(stringCoder.decode(inStream))), + Instant.from(DATE_TIME_FORMATTER.parse(stringCoder.decode(inStream))), stringCoder.decode(inStream), stringCoder.decode(inStream), stringCoder.decode(inStream), diff --git a/core/src/main/java/google/registry/beam/billing/ExpandBillingRecurrencesPipeline.java b/core/src/main/java/google/registry/beam/billing/ExpandBillingRecurrencesPipeline.java index 1678c90919d..53fb5f61f26 100644 --- a/core/src/main/java/google/registry/beam/billing/ExpandBillingRecurrencesPipeline.java +++ b/core/src/main/java/google/registry/beam/billing/ExpandBillingRecurrencesPipeline.java @@ -276,12 +276,12 @@ private void expandOneRecurrence( ImmutableSet.copyOf( billingRecurrence .getRecurrenceTimeOfYear() - .getInstancesInRangeInstant( + .getInstancesInRange( Range.closedOpen( latestOf( - plusYears(billingRecurrence.getRecurrenceLastExpansionInstant(), 1), + plusYears(billingRecurrence.getRecurrenceLastExpansion(), 1), startTime), - earliestOf(billingRecurrence.getRecurrenceEndTimeInstant(), endTime)))); + earliestOf(billingRecurrence.getRecurrenceEndTime(), endTime)))); } catch (IllegalArgumentException e) { return; } @@ -306,7 +306,7 @@ private void expandOneRecurrence( return; } - Instant recurrenceLastExpansionTime = billingRecurrence.getRecurrenceLastExpansionInstant(); + Instant recurrenceLastExpansionTime = billingRecurrence.getRecurrenceLastExpansion(); // Create new OneTime and DomainHistory for EventTimes that needs to be expanded. for (Instant eventTime : eventTimesToExpand) { diff --git a/core/src/main/java/google/registry/bsa/BsaValidateAction.java b/core/src/main/java/google/registry/bsa/BsaValidateAction.java index 23e7df7e81f..87f5cbaeee0 100644 --- a/core/src/main/java/google/registry/bsa/BsaValidateAction.java +++ b/core/src/main/java/google/registry/bsa/BsaValidateAction.java @@ -228,7 +228,7 @@ Optional verifyDomainStillUnblockableWithReason( } boolean isStalenessAllowed(Domain domain) { - return domain.getCreationTimeInstant().plus(maxStaleness).isAfter(clock.now()); + return domain.getCreationTime().plus(maxStaleness).isAfter(clock.now()); } /** Returns unique labels across all block lists in the download specified by {@code jobName}. */ diff --git a/core/src/main/java/google/registry/flows/FlowModule.java b/core/src/main/java/google/registry/flows/FlowModule.java index 99e883d3f47..0f0cef24ccd 100644 --- a/core/src/main/java/google/registry/flows/FlowModule.java +++ b/core/src/main/java/google/registry/flows/FlowModule.java @@ -251,7 +251,7 @@ B makeHistoryEntryBuilder( String registrarId, EppInput eppInput) { builder - .setModificationTime(tm().getTransactionTime()) + .setModificationTime(tm().getTxTime()) .setTrid(trid) .setXmlBytes(inputXmlBytes) .setBySuperuser(isSuperuser) 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 e6e8f90092b..03fd1930de1 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainCreateFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainCreateFlow.java @@ -572,7 +572,7 @@ private DomainHistory buildDomainHistory( ImmutableSet.of( DomainTransactionRecord.create( tld.getTldStr(), - now.plus(addGracePeriod), + toInstant(now.plus(addGracePeriod)), TransactionReportField.netAddsFieldFromYears(period.getValue()), 1))); } @@ -607,13 +607,14 @@ private BillingEvent createBillingEvent( .setRegistrarId(registrarId) .setPeriodYears(years) .setCost(feesAndCredits.getCreateCost()) - .setEventTime(now) + .setEventTime(toInstant(now)) .setAllocationToken(allocationToken.map(AllocationToken::createVKey).orElse(null)) .setBillingTime( - now.plus( - isAnchorTenant - ? tld.getAnchorTenantAddGracePeriodLength() - : tld.getAddGracePeriodLength())) + toInstant( + now.plus( + isAnchorTenant + ? tld.getAnchorTenantAddGracePeriodLength() + : tld.getAddGracePeriodLength()))) .setFlags(flagsBuilder.build()) .setDomainHistoryId(domainHistoryId) .build(); @@ -638,7 +639,7 @@ private BillingRecurrence createAutorenewBillingEvent( .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId(targetId) .setRegistrarId(registrarId) - .setEventTime(registrationExpirationTime) + .setEventTime(toInstant(registrationExpirationTime)) .setRecurrenceEndTime(END_INSTANT) .setDomainHistoryId(domainHistoryId) .setRenewalPriceBehavior(renewalPriceBehavior) @@ -651,7 +652,7 @@ private Autorenew createAutorenewPollMessage( return new PollMessage.Autorenew.Builder() .setTargetId(targetId) .setRegistrarId(registrarId) - .setEventTime(registrationExpirationTime) + .setEventTime(toInstant(registrationExpirationTime)) .setMsg("Domain was auto-renewed.") .setDomainHistoryId(domainHistoryId) .build(); @@ -685,7 +686,7 @@ private static PollMessage.OneTime createNameCollisionOneTimePollMessage( String domainName, HistoryEntry historyEntry, String registrarId, DateTime now) { return new PollMessage.OneTime.Builder() .setRegistrarId(registrarId) - .setEventTime(now) + .setEventTime(toInstant(now)) .setMsg(COLLISION_MESSAGE) // Remind the registrar of the name collision policy. .setResponseData( ImmutableList.of( 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 9eff1530f30..ae176f50cae 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainDeleteFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainDeleteFlow.java @@ -40,6 +40,7 @@ import static google.registry.pricing.PricingEngineProxy.getDomainRenewCost; import static google.registry.util.CollectionUtils.nullToEmpty; import static google.registry.util.CollectionUtils.union; +import static google.registry.util.DateTimeUtils.toDateTime; import static google.registry.util.DateTimeUtils.toInstant; import com.google.common.collect.ImmutableList; @@ -162,7 +163,7 @@ public EppResponse run() throws EppException { } else { builder = existingDomain.asBuilder(); } - builder.setLastEppUpdateTime(now).setLastEppUpdateRegistrarId(registrarId); + builder.setLastEppUpdateTime(toInstant(now)).setLastEppUpdateRegistrarId(registrarId); Duration redemptionGracePeriodLength = tld.getRedemptionGracePeriodLength(); Duration pendingDeleteLength = tld.getPendingDeleteLength(); Optional domainDeleteSuperuserExtension = @@ -187,13 +188,13 @@ public EppResponse run() throws EppException { historyBuilder.setRevisionId(domainHistoryId.getRevisionId()); DateTime deletionTime = now.plus(durationUntilDelete); if (durationUntilDelete.equals(Duration.ZERO)) { - builder.setDeletionTime(now).setStatusValues(null); + builder.setDeletionTime(toInstant(now)).setStatusValues(null); } else { DateTime redemptionTime = now.plus(redemptionGracePeriodLength); asyncTaskEnqueuer.enqueueAsyncResave( existingDomain.createVKey(), now, ImmutableSortedSet.of(redemptionTime, deletionTime)); builder - .setDeletionTime(deletionTime) + .setDeletionTime(toInstant(deletionTime)) .setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE)) // Clear out all old grace periods and add REDEMPTION, which does not include a key to a // billing event because there isn't one for a domain delete. @@ -242,7 +243,8 @@ public EppResponse run() throws EppException { // No cancellation is written if the grace period was not for a billable event. if (gracePeriod.hasBillingEvent()) { entitiesToInsert.add( - BillingCancellation.forGracePeriod(gracePeriod, now, domainHistoryId, targetId)); + BillingCancellation.forGracePeriod( + gracePeriod, toInstant(now), domainHistoryId, targetId)); if (gracePeriod.getBillingEvent() != null) { // Take the amount of registration time being refunded off the expiration time. // This can be either add grace periods or renew grace periods. @@ -290,7 +292,7 @@ public EppResponse run() throws EppException { flowCustomLogic.beforeResponse( BeforeResponseParameters.newBuilder() .setResultCode( - newDomain.getDeletionDateTime().isAfter(now) + newDomain.getDeletionTime().isAfter(toInstant(now)) ? SUCCESS_WITH_ACTION_PENDING : SUCCESS) .setResponseExtensions( @@ -343,7 +345,7 @@ private DomainHistory buildDomainHistory( cancelledRecords, DomainTransactionRecord.create( domain.getTld(), - now.plus(durationUntilDelete), + toInstant(now.plus(durationUntilDelete)), inAddGracePeriod ? TransactionReportField.DELETED_DOMAINS_GRACE : TransactionReportField.DELETED_DOMAINS_NOGRACE, @@ -380,7 +382,7 @@ private PollMessage.OneTime createImmediateDeletePollMessage( Domain existingDomain, HistoryEntryId domainHistoryId, DateTime now, DateTime deletionTime) { return new PollMessage.OneTime.Builder() .setRegistrarId(existingDomain.getPersistedCurrentSponsorRegistrarId()) - .setEventTime(now) + .setEventTime(toInstant(now)) .setDomainHistoryId(domainHistoryId) .setMsg( String.format( @@ -421,7 +423,10 @@ private Money getGracePeriodCost( if (gracePeriod.getType() == GracePeriodStatus.AUTO_RENEW) { // If we updated the autorenew billing event, reuse it. DateTime autoRenewTime = - billingRecurrence.getRecurrenceTimeOfYear().getLastInstanceBeforeOrAt(now); + toDateTime( + billingRecurrence + .getRecurrenceTimeOfYear() + .getLastInstanceBeforeOrAt(toInstant(now))); return getDomainRenewCost(targetId, toInstant(autoRenewTime), 1); } return tm().loadByKey(checkNotNull(gracePeriod.getBillingEvent())).getCost(); 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 779ef75f50b..a6f3e381be7 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java +++ b/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java @@ -560,7 +560,7 @@ public static BillingRecurrence updateAutorenewRecurrenceEndTime( // If the resultant autorenew poll message would have no poll messages to deliver, then just // delete it. Otherwise, save it with the new end time. - if (isAtOrAfter(updatedAutorenewPollMessage.getEventTime(), newEndTime)) { + if (isAtOrAfter(updatedAutorenewPollMessage.getEventTime(), toInstant(newEndTime))) { autorenewPollMessage.ifPresent(autorenew -> tm().delete(autorenew)); } else { tm().put(updatedAutorenewPollMessage); @@ -1081,7 +1081,7 @@ public static ImmutableSet createCancelingRecords( for (DomainTransactionRecord record : historyEntry.getDomainTransactionRecords()) { if (cancelableFields.contains(record.getReportField()) - && record.getReportingTime().isAfter(now)) { + && record.getReportingTime().isAfter(toInstant(now))) { return true; } } diff --git a/core/src/main/java/google/registry/flows/domain/DomainInfoFlow.java b/core/src/main/java/google/registry/flows/domain/DomainInfoFlow.java index 28cfe7240c1..bb473082ae7 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainInfoFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainInfoFlow.java @@ -121,7 +121,7 @@ public EppResponse run() throws EppException { .setStatusValues(domain.getStatusValues()) .setNameservers( hostsRequest.requestDelegated() ? domain.loadNameserverHostNames() : null) - .setCreationTime(domain.getCreationTimeInstant()) + .setCreationTime(domain.getCreationTime()) .setLastEppUpdateTime(domain.getLastEppUpdateTime()) .setRegistrationExpirationTime(domain.getRegistrationExpirationTime()) .setLastTransferTime(domain.getLastTransferTimeInstant()); 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 57cc04768b1..5f32efb1ebc 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainRenewFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainRenewFlow.java @@ -222,14 +222,14 @@ public EppResponse run() throws EppException { // Create a new autorenew billing event and poll message starting at the new expiration time. BillingRecurrence newAutorenewEvent = newAutorenewBillingEvent(existingDomain) - .setEventTime(newExpirationTime) + .setEventTime(toInstant(newExpirationTime)) .setRenewalPrice(existingBillingRecurrence.getRenewalPrice().orElse(null)) .setRenewalPriceBehavior(existingBillingRecurrence.getRenewalPriceBehavior()) .setDomainHistoryId(domainHistoryId) .build(); PollMessage.Autorenew newAutorenewPollMessage = newAutorenewPollMessage(existingDomain) - .setEventTime(newExpirationTime) + .setEventTime(toInstant(newExpirationTime)) .setDomainHistoryId(domainHistoryId) .build(); // End the old autorenew billing event and poll message now. This may delete the poll message. @@ -238,7 +238,7 @@ public EppResponse run() throws EppException { Domain newDomain = existingDomain .asBuilder() - .setLastEppUpdateTime(now) + .setLastEppUpdateTime(toInstant(now)) .setLastEppUpdateRegistrarId(registrarId) .setRegistrationExpirationTime(newExpirationTime) .setAutorenewBillingEvent(newAutorenewEvent.createVKey()) @@ -306,7 +306,7 @@ private DomainHistory buildDomainHistory( ImmutableSet.of( DomainTransactionRecord.create( newDomain.getTld(), - now.plus(renewGracePeriod), + toInstant(now.plus(renewGracePeriod)), TransactionReportField.netRenewsFieldFromYears(period.getValue()), 1))) .build(); @@ -349,13 +349,13 @@ private BillingEvent createRenewBillingEvent( .setRegistrarId(registrarId) .setPeriodYears(years) .setCost(renewCost) - .setEventTime(now) + .setEventTime(toInstant(now)) .setAllocationToken( allocationToken .filter(t -> AllocationToken.TokenBehavior.DEFAULT.equals(t.getTokenBehavior())) .map(AllocationToken::createVKey) .orElse(null)) - .setBillingTime(now.plus(Tld.get(tld).getRenewGracePeriodLength())) + .setBillingTime(toInstant(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 2bdd97ccbdf..d8f4e4e65fe 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainRestoreRequestFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainRestoreRequestFlow.java @@ -164,14 +164,14 @@ public EppResponse run() throws EppException { BillingRecurrence autorenewEvent = newAutorenewBillingEvent(existingDomain) - .setEventTime(newExpirationTime) + .setEventTime(toInstant(newExpirationTime)) .setRecurrenceEndTime(END_INSTANT) .setDomainHistoryId(domainHistoryId) .build(); entitiesToInsert.add(autorenewEvent); PollMessage.Autorenew autorenewPollMessage = newAutorenewPollMessage(existingDomain) - .setEventTime(newExpirationTime) + .setEventTime(toInstant(newExpirationTime)) .setAutorenewEndTime(END_INSTANT) .setDomainHistoryId(domainHistoryId) .build(); @@ -204,7 +204,10 @@ private DomainHistory buildDomainHistory(Domain newDomain, DateTime now) { .setDomainTransactionRecords( ImmutableSet.of( DomainTransactionRecord.create( - newDomain.getTld(), now, TransactionReportField.RESTORED_DOMAINS, 1))) + newDomain.getTld(), + toInstant(now), + TransactionReportField.RESTORED_DOMAINS, + 1))) .build(); } @@ -253,7 +256,7 @@ private static Domain performRestore( // Clear the autorenew end time so if it had expired but is now explicitly being restored, // it won't immediately be deleted again. .setAutorenewEndTime(Optional.empty()) - .setLastEppUpdateTime(now) + .setLastEppUpdateTime(toInstant(now)) .setLastEppUpdateRegistrarId(registrarId) .build(); } @@ -273,8 +276,8 @@ private BillingEvent.Builder prepareBillingEvent( return new BillingEvent.Builder() .setTargetId(targetId) .setRegistrarId(registrarId) - .setEventTime(now) - .setBillingTime(now) + .setEventTime(toInstant(now)) + .setBillingTime(toInstant(now)) .setPeriodYears(1) .setCost(cost) .setDomainHistoryId(domainHistoryId); 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 09ac06217d0..897324ef96d 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainTransferApproveFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainTransferApproveFlow.java @@ -163,14 +163,15 @@ public EppResponse run() throws EppException { .getTransferPrice( Tld.get(tldStr), targetId, - transferData.getTransferRequestTimeInstant(), + transferData.getTransferRequestTime(), // When removing a domain from bulk pricing it should return to the // default recurrence billing behavior so the existing recurrence // billing event should not be passed in. hasBulkToken ? null : existingBillingRecurrence) .getRenewCost()) - .setEventTime(now) - .setBillingTime(now.plus(Tld.get(tldStr).getTransferGracePeriodLength())) + .setEventTime(toInstant(now)) + .setBillingTime( + toInstant(now.plus(Tld.get(tldStr).getTransferGracePeriodLength()))) .setDomainHistoryId(domainHistoryId) .build()); @@ -187,7 +188,8 @@ public EppResponse run() throws EppException { // still needs to be charged for the auto-renew. if (billingEvent.isPresent()) { entitiesToInsert.add( - BillingCancellation.forGracePeriod(autorenewGrace, now, domainHistoryId, targetId)); + BillingCancellation.forGracePeriod( + autorenewGrace, toInstant(now), domainHistoryId, targetId)); } } // Close the old autorenew event and poll message at the transfer time (aka now). This may end @@ -205,7 +207,7 @@ public EppResponse run() throws EppException { .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId(targetId) .setRegistrarId(gainingRegistrarId) - .setEventTime(newExpirationTime) + .setEventTime(toInstant(newExpirationTime)) .setRenewalPriceBehavior( hasBulkToken ? RenewalPriceBehavior.DEFAULT @@ -219,7 +221,7 @@ public EppResponse run() throws EppException { new PollMessage.Autorenew.Builder() .setTargetId(targetId) .setRegistrarId(gainingRegistrarId) - .setEventTime(newExpirationTime) + .setEventTime(toInstant(newExpirationTime)) .setAutorenewEndTime(END_INSTANT) .setMsg("Domain was auto-renewed.") .setDomainHistoryId(domainHistoryId) @@ -236,7 +238,7 @@ public EppResponse run() throws EppException { partiallyApprovedDomain .getTransferData() .asBuilder() - .setTransferredRegistrationExpirationTime(newExpirationTime) + .setTransferredRegistrationExpirationTime(toInstant(newExpirationTime)) .build()) .setRegistrationExpirationTime(newExpirationTime) .setAutorenewBillingEvent(autorenewEvent.createVKey()) @@ -250,7 +252,7 @@ public EppResponse run() throws EppException { GracePeriod.forBillingEvent( GracePeriodStatus.TRANSFER, existingDomain.getRepoId(), event))) .orElseGet(ImmutableSet::of)) - .setLastEppUpdateTime(now) + .setLastEppUpdateTime(toInstant(now)) .setLastEppUpdateRegistrarId(registrarId) // Even if the existing domain had a bulk token, that bulk token should be removed // on transfer @@ -297,7 +299,7 @@ private DomainHistory buildDomainHistory( cancelingRecords, DomainTransactionRecord.create( newDomain.getTld(), - now.plus(tld.getTransferGracePeriodLength()), + toInstant(now.plus(tld.getTransferGracePeriodLength())), TRANSFER_SUCCESSFUL, 1))) .build(); diff --git a/core/src/main/java/google/registry/flows/domain/DomainTransferQueryFlow.java b/core/src/main/java/google/registry/flows/domain/DomainTransferQueryFlow.java index 3e002f60c13..81629803f4d 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainTransferQueryFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainTransferQueryFlow.java @@ -90,7 +90,7 @@ public EppResponse run() throws EppException { } DateTime newExpirationTime = null; if (transferData.getTransferStatus().isApproved()) { - newExpirationTime = transferData.getTransferredRegistrationExpirationDateTime(); + newExpirationTime = toDateTime(transferData.getTransferredRegistrationExpirationTime()); } else if (transferData.getTransferStatus().equals(TransferStatus.PENDING)) { newExpirationTime = toDateTime( 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 39b25d8d551..7fabc7ceb6a 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainTransferRejectFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainTransferRejectFlow.java @@ -33,6 +33,7 @@ import static google.registry.util.CollectionUtils.union; import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.DateTimeUtils.toDateTime; +import static google.registry.util.DateTimeUtils.toInstant; import com.google.common.collect.ImmutableSet; import google.registry.flows.EppException; @@ -143,7 +144,8 @@ private DomainHistory buildDomainHistory(Domain newDomain, Tld tld, DateTime now .setDomainTransactionRecords( union( cancelingRecords, - DomainTransactionRecord.create(newDomain.getTld(), now, TRANSFER_NACKED, 1))) + DomainTransactionRecord.create( + newDomain.getTld(), toInstant(now), TRANSFER_NACKED, 1))) .setDomain(newDomain) .build(); } 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 456e9cd6660..8823247d673 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainTransferRequestFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainTransferRequestFlow.java @@ -257,11 +257,12 @@ public EppResponse run() throws EppException { domainHistoryId.getRevisionId(), new DomainTransferData.Builder() .setTransferRequestTrid(trid) - .setTransferRequestTime(now) + .setTransferRequestTime(toInstant(now)) .setGainingRegistrarId(gainingClientId) .setLosingRegistrarId(existingDomain.getCurrentSponsorRegistrarId()) - .setPendingTransferExpirationTime(automaticTransferTime) - .setTransferredRegistrationExpirationTime(serverApproveNewExpirationTime), + .setPendingTransferExpirationTime(toInstant(automaticTransferTime)) + .setTransferredRegistrationExpirationTime( + toInstant(serverApproveNewExpirationTime)), serverApproveEntities, period); // Create a poll message to notify the losing registrar that a transfer was requested. @@ -269,7 +270,7 @@ public EppResponse run() throws EppException { createLosingTransferPollMessage( targetId, pendingTransferData, serverApproveNewExpirationTime, domainHistoryId) .asBuilder() - .setEventTime(now) + .setEventTime(toInstant(now)) .build(); // End the old autorenew event and poll message at the implicit transfer time. This may delete // the poll message if it has no events left. Note that if the automatic transfer succeeds, then @@ -282,7 +283,7 @@ public EppResponse run() throws EppException { .asBuilder() .setTransferData(pendingTransferData) .addStatusValue(StatusValue.PENDING_TRANSFER) - .setLastEppUpdateTime(now) + .setLastEppUpdateTime(toInstant(now)) .setLastEppUpdateRegistrarId(gainingClientId) .build(); DomainHistory domainHistory = buildDomainHistory(newDomain, tld, now, period); @@ -374,8 +375,9 @@ private DomainHistory buildDomainHistory(Domain newDomain, Tld tld, DateTime now ImmutableSet.of( DomainTransactionRecord.create( tld.getTldStr(), - now.plus(tld.getAutomaticTransferLength()) - .plus(tld.getTransferGracePeriodLength()), + toInstant( + 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 84c94cc49b5..2c707631897 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainTransferUtils.java +++ b/core/src/main/java/google/registry/flows/domain/DomainTransferUtils.java @@ -17,6 +17,7 @@ import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.common.collect.MoreCollectors.onlyElement; import static google.registry.util.DateTimeUtils.END_INSTANT; +import static google.registry.util.DateTimeUtils.toInstant; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; @@ -120,11 +121,11 @@ public static ImmutableSet createTransferServerAppr DomainTransferData serverApproveTransferData = new DomainTransferData.Builder() .setTransferRequestTrid(trid) - .setTransferRequestTime(now) + .setTransferRequestTime(toInstant(now)) .setGainingRegistrarId(gainingRegistrarId) .setLosingRegistrarId(existingDomain.getCurrentSponsorRegistrarId()) - .setPendingTransferExpirationTime(automaticTransferTime) - .setTransferredRegistrationExpirationTime(serverApproveNewExpirationTime) + .setPendingTransferExpirationTime(toInstant(automaticTransferTime)) + .setTransferredRegistrationExpirationTime(toInstant(serverApproveNewExpirationTime)) .setTransferStatus(TransferStatus.SERVER_APPROVED) .build(); Tld tld = Tld.get(existingDomain.getTld()); @@ -184,7 +185,7 @@ public static PollMessage createGainingTransferPollMessage( HistoryEntryId domainHistoryId) { return new PollMessage.OneTime.Builder() .setRegistrarId(transferData.getGainingRegistrarId()) - .setEventTime(transferData.getPendingTransferExpirationDateTime()) + .setEventTime(transferData.getPendingTransferExpirationTime()) .setMsg(transferData.getTransferStatus().getMessage()) .setResponseData( ImmutableList.of( @@ -206,7 +207,7 @@ public static PollMessage createLosingTransferPollMessage( HistoryEntryId domainHistoryId) { return new PollMessage.OneTime.Builder() .setRegistrarId(transferData.getLosingRegistrarId()) - .setEventTime(transferData.getPendingTransferExpirationDateTime()) + .setEventTime(transferData.getPendingTransferExpirationTime()) .setMsg(transferData.getTransferStatus().getMessage()) .setResponseData( ImmutableList.of( @@ -224,10 +225,10 @@ static DomainTransferResponse createTransferResponse( .setDomainName(targetId) .setGainingRegistrarId(transferData.getGainingRegistrarId()) .setLosingRegistrarId(transferData.getLosingRegistrarId()) - .setPendingTransferExpirationTime(transferData.getPendingTransferExpirationDateTime()) + .setPendingTransferExpirationTime(transferData.getPendingTransferExpirationTime()) .setTransferRequestTime(transferData.getTransferRequestTime()) .setTransferStatus(transferData.getTransferStatus()) - .setExtendedRegistrationExpirationTime(extendedRegistrationExpirationTime) + .setExtendedRegistrationExpirationTime(toInstant(extendedRegistrationExpirationTime)) .build(); } @@ -239,7 +240,7 @@ private static PollMessage.Autorenew createGainingClientAutorenewPollMessage( return new PollMessage.Autorenew.Builder() .setTargetId(targetId) .setRegistrarId(gainingRegistrarId) - .setEventTime(serverApproveNewExpirationTime) + .setEventTime(toInstant(serverApproveNewExpirationTime)) .setAutorenewEndTime(END_INSTANT) .setMsg("Domain was auto-renewed.") .setDomainHistoryId(domainHistoryId) @@ -257,7 +258,7 @@ private static BillingRecurrence createGainingClientAutorenewEvent( .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId(targetId) .setRegistrarId(gainingRegistrarId) - .setEventTime(serverApproveNewExpirationTime) + .setEventTime(toInstant(serverApproveNewExpirationTime)) .setRecurrenceEndTime(END_INSTANT) .setRenewalPriceBehavior(existingBillingRecurrence.getRenewalPriceBehavior()) .setRenewalPrice(existingBillingRecurrence.getRenewalPrice().orElse(null)) @@ -294,9 +295,10 @@ private static Optional createOptionalAutorenewCancellation domainAtTransferTime.getGracePeriodsOfType(GracePeriodStatus.AUTO_RENEW), null); if (autorenewGracePeriod != null && transferCost.isPresent()) { return Optional.of( - BillingCancellation.forGracePeriod(autorenewGracePeriod, now, domainHistoryId, targetId) + BillingCancellation.forGracePeriod( + autorenewGracePeriod, toInstant(now), domainHistoryId, targetId) .asBuilder() - .setEventTime(automaticTransferTime) + .setEventTime(toInstant(automaticTransferTime)) .build()); } return Optional.empty(); @@ -315,8 +317,9 @@ private static BillingEvent createTransferBillingEvent( .setRegistrarId(gainingRegistrarId) .setCost(transferCost) .setPeriodYears(1) - .setEventTime(automaticTransferTime) - .setBillingTime(automaticTransferTime.plus(registry.getTransferGracePeriodLength())) + .setEventTime(toInstant(automaticTransferTime)) + .setBillingTime( + toInstant(automaticTransferTime.plus(registry.getTransferGracePeriodLength()))) .setDomainHistoryId(domainHistoryId) .build(); } 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 7098063e161..2921c22ccb8 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainUpdateFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainUpdateFlow.java @@ -263,7 +263,7 @@ private Domain performUpdate(Update command, Domain domain, DateTime now) throws .collect(toImmutableSet()), secDnsUpdate.get()) : domain.getDsData()) - .setLastEppUpdateTime(now) + .setLastEppUpdateTime(toInstant(now)) .setLastEppUpdateRegistrarId(registrarId) .addStatusValues(add.getStatusValues()) .removeStatusValues(remove.getStatusValues()) @@ -319,8 +319,8 @@ private Optional createBillingEventForStatusUpdates( .setTargetId(targetId) .setRegistrarId(registrarId) .setCost(Tld.get(existingDomain.getTld()).getServerStatusChangeBillingCost()) - .setEventTime(now) - .setBillingTime(now) + .setEventTime(toInstant(now)) + .setBillingTime(toInstant(now)) .setDomainHistory(historyEntry) .build()); } @@ -369,7 +369,7 @@ private Optional createPollMessageForServerStatusUpdates( return Optional.ofNullable( new PollMessage.OneTime.Builder() .setHistoryEntry(historyEntry) - .setEventTime(now) + .setEventTime(toInstant(now)) .setRegistrarId(existingDomain.getCurrentSponsorRegistrarId()) .setMsg(msg) .setResponseData( diff --git a/core/src/main/java/google/registry/flows/host/HostCreateFlow.java b/core/src/main/java/google/registry/flows/host/HostCreateFlow.java index 8daca8ebd04..66e18813550 100644 --- a/core/src/main/java/google/registry/flows/host/HostCreateFlow.java +++ b/core/src/main/java/google/registry/flows/host/HostCreateFlow.java @@ -25,7 +25,7 @@ import static google.registry.model.reporting.HistoryEntry.Type.HOST_CREATE; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.util.CollectionUtils.isNullOrEmpty; -import static google.registry.util.DateTimeUtils.toInstant; +import static google.registry.util.DateTimeUtils.toDateTime; import com.google.common.collect.ImmutableSet; import google.registry.config.RegistryConfig.Config; @@ -50,8 +50,8 @@ import google.registry.model.host.HostHistory; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import jakarta.inject.Inject; +import java.time.Instant; import java.util.Optional; -import org.joda.time.DateTime; /** * An EPP flow that creates a new host. @@ -100,8 +100,8 @@ public EppResponse run() throws EppException { validateRegistrarIsLoggedIn(registrarId); extensionManager.validate(); Create command = (Create) resourceCommand; - DateTime now = tm().getTransactionTime(); - verifyResourceDoesNotExist(Host.class, targetId, now, registrarId); + Instant now = tm().getTxTime(); + verifyResourceDoesNotExist(Host.class, targetId, toDateTime(now), registrarId); // The superordinate domain of the host object if creating an in-bailiwick host, or null if // creating an external host. This is looked up before we actually create the Host object, so // we can detect error conditions earlier. @@ -142,7 +142,7 @@ public EppResponse run() throws EppException { requestHostDnsRefresh(targetId); } tm().insertAll(entitiesToInsert); - return responseBuilder.setResData(HostCreateData.create(targetId, toInstant(now))).build(); + return responseBuilder.setResData(HostCreateData.create(targetId, now)).build(); } /** Subordinate hosts must have an ip address. */ diff --git a/core/src/main/java/google/registry/flows/host/HostDeleteFlow.java b/core/src/main/java/google/registry/flows/host/HostDeleteFlow.java index c2f7e06d6b2..5803e26304e 100644 --- a/core/src/main/java/google/registry/flows/host/HostDeleteFlow.java +++ b/core/src/main/java/google/registry/flows/host/HostDeleteFlow.java @@ -24,6 +24,7 @@ import static google.registry.flows.host.HostFlowUtils.validateHostName; import static google.registry.model.eppoutput.Result.Code.SUCCESS; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; +import static google.registry.util.DateTimeUtils.toDateTime; import com.google.common.collect.ImmutableSet; import google.registry.flows.EppException; @@ -43,7 +44,7 @@ import google.registry.model.reporting.HistoryEntry.Type; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import jakarta.inject.Inject; -import org.joda.time.DateTime; +import java.time.Instant; /** * An EPP flow that deletes a host. @@ -82,9 +83,9 @@ public EppResponse run() throws EppException { extensionManager.register(MetadataExtension.class); validateRegistrarIsLoggedIn(registrarId); extensionManager.validate(); - DateTime now = tm().getTransactionTime(); + Instant now = tm().getTxTime(); validateHostName(targetId); - checkLinkedDomains(targetId, now); + checkLinkedDomains(targetId, toDateTime(now)); Host existingHost = loadAndVerifyExistence(Host.class, targetId, now); verifyNoDisallowedStatuses(existingHost, ImmutableSet.of(StatusValue.PENDING_DELETE)); if (!isSuperuser) { @@ -93,7 +94,7 @@ public EppResponse run() throws EppException { // the client id, needs to be read off of it. EppResource owningResource = existingHost.isSubordinate() - ? tm().loadByKey(existingHost.getSuperordinateDomain()).cloneProjectedAtTime(now) + ? tm().loadByKey(existingHost.getSuperordinateDomain()).cloneProjectedAtInstant(now) : existingHost; verifyResourceOwnership(registrarId, owningResource); } diff --git a/core/src/main/java/google/registry/flows/host/HostFlowUtils.java b/core/src/main/java/google/registry/flows/host/HostFlowUtils.java index bfc58c7b38c..d104264e4c2 100644 --- a/core/src/main/java/google/registry/flows/host/HostFlowUtils.java +++ b/core/src/main/java/google/registry/flows/host/HostFlowUtils.java @@ -36,8 +36,8 @@ import google.registry.model.domain.Domain; import google.registry.model.eppcommon.StatusValue; import java.net.InetAddress; +import java.time.Instant; import java.util.Optional; -import org.joda.time.DateTime; /** Static utility functions for host flows. */ public class HostFlowUtils { @@ -90,8 +90,8 @@ public static InternetDomainName validateHostName(String name) throws EppExcepti } /** Return the {@link Domain} this host is subordinate to, or null for external hosts. */ - public static Optional lookupSuperordinateDomain( - InternetDomainName hostName, DateTime now) throws EppException { + public static Optional lookupSuperordinateDomain(InternetDomainName hostName, Instant now) + throws EppException { Optional tld = findTldForName(hostName); if (tld.isEmpty()) { // This is an host on a TLD we don't run, therefore obviously external, so we are done. diff --git a/core/src/main/java/google/registry/flows/host/HostInfoFlow.java b/core/src/main/java/google/registry/flows/host/HostInfoFlow.java index 60cb13bd93d..a6483b814e5 100644 --- a/core/src/main/java/google/registry/flows/host/HostInfoFlow.java +++ b/core/src/main/java/google/registry/flows/host/HostInfoFlow.java @@ -35,7 +35,7 @@ import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import google.registry.util.Clock; import jakarta.inject.Inject; -import org.joda.time.DateTime; +import java.time.Instant; /** * An EPP flow that returns information about a host. @@ -64,7 +64,7 @@ public EppResponse run() throws EppException { validateRegistrarIsLoggedIn(registrarId); extensionManager.validate(); // There are no legal extensions for this flow. validateHostName(targetId); - DateTime now = clock.nowUtc(); + Instant now = clock.now(); Host host = loadAndVerifyExistence(Host.class, targetId, now); ImmutableSet.Builder statusValues = new ImmutableSet.Builder<>(); statusValues.addAll(host.getStatusValues()); @@ -77,7 +77,7 @@ public EppResponse run() throws EppException { // there is no superordinate domain, the host's own values for these fields will be correct. if (host.isSubordinate()) { Domain superordinateDomain = - tm().loadByKey(host.getSuperordinateDomain()).cloneProjectedAtTime(now); + tm().loadByKey(host.getSuperordinateDomain()).cloneProjectedAtInstant(now); hostInfoDataBuilder .setCurrentSponsorRegistrarId(superordinateDomain.getCurrentSponsorRegistrarId()) .setLastTransferTime(host.computeLastTransferTime(superordinateDomain)); @@ -87,7 +87,7 @@ public EppResponse run() throws EppException { } else { hostInfoDataBuilder .setCurrentSponsorRegistrarId(host.getPersistedCurrentSponsorRegistrarId()) - .setLastTransferTime(host.getLastTransferTimeInstant()); + .setLastTransferTime(host.getLastTransferTime()); } return responseBuilder .setResData( @@ -97,7 +97,7 @@ public EppResponse run() throws EppException { .setStatusValues(statusValues.build()) .setInetAddresses(host.getInetAddresses()) .setCreationRegistrarId(host.getCreationRegistrarId()) - .setCreationTime(host.getCreationTimeInstant()) + .setCreationTime(host.getCreationTime()) .setLastEppUpdateRegistrarId(host.getLastEppUpdateRegistrarId()) .setLastEppUpdateTime(host.getLastEppUpdateTime()) .build()) diff --git a/core/src/main/java/google/registry/flows/host/HostUpdateFlow.java b/core/src/main/java/google/registry/flows/host/HostUpdateFlow.java index ce6f0df7bce..f564e911bf9 100644 --- a/core/src/main/java/google/registry/flows/host/HostUpdateFlow.java +++ b/core/src/main/java/google/registry/flows/host/HostUpdateFlow.java @@ -32,7 +32,6 @@ import static google.registry.model.reporting.HistoryEntry.Type.HOST_UPDATE; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.util.CollectionUtils.isNullOrEmpty; -import static google.registry.util.DateTimeUtils.toDateTime; import com.google.cloud.tasks.v2.Task; import com.google.common.collect.ImmutableMultimap; @@ -67,9 +66,9 @@ import google.registry.persistence.VKey; import google.registry.request.Action; import jakarta.inject.Inject; +import java.time.Instant; import java.util.Objects; import java.util.Optional; -import org.joda.time.DateTime; /** * An EPP flow that updates a host. @@ -138,7 +137,7 @@ public EppResponse run() throws EppException { Update command = (Update) resourceCommand; Change change = command.getInnerChange(); String suppliedNewHostName = change.getHostName(); - DateTime now = tm().getTransactionTime(); + Instant now = tm().getTxTime(); validateHostName(targetId); Host existingHost = loadAndVerifyExistence(Host.class, targetId, now); boolean isHostRename = suppliedNewHostName != null; @@ -146,7 +145,7 @@ public EppResponse run() throws EppException { String newHostName = firstNonNull(suppliedNewHostName, oldHostName); Domain oldSuperordinateDomain = existingHost.isSubordinate() - ? tm().loadByKey(existingHost.getSuperordinateDomain()).cloneProjectedAtTime(now) + ? tm().loadByKey(existingHost.getSuperordinateDomain()).cloneProjectedAtInstant(now) : null; // Note that lookupSuperordinateDomain calls cloneProjectedAtTime on the domain for us. Optional newSuperordinateDomain = @@ -168,7 +167,7 @@ public EppResponse run() throws EppException { VKey newSuperordinateDomainKey = newSuperordinateDomain.map(Domain::createVKey).orElse(null); // If the superordinateDomain field is changing, set the lastSuperordinateChange to now. - DateTime lastSuperordinateChange = + Instant lastSuperordinateChange = Objects.equals(newSuperordinateDomainKey, existingHost.getSuperordinateDomain()) ? existingHost.getLastSuperordinateChange() : now; @@ -176,8 +175,7 @@ public EppResponse run() throws EppException { // have just completed. This is only critical for updates that rename a host away from its // current superordinate domain, where we must "freeze" the last transfer time, but it's easiest // to just update it unconditionally. - DateTime lastTransferTime = - toDateTime(existingHost.computeLastTransferTime(oldSuperordinateDomain)); + Instant lastTransferTime = existingHost.computeLastTransferTime(oldSuperordinateDomain); // Copy the clientId onto the host. This is only really needed when the host will be external, // since external hosts store their own clientId. For subordinate hosts the canonical clientId // comes from the superordinate domain, but we might as well update the persisted value. For diff --git a/core/src/main/java/google/registry/flows/poll/PollAckFlow.java b/core/src/main/java/google/registry/flows/poll/PollAckFlow.java index d73a9667388..6be8dec66d9 100644 --- a/core/src/main/java/google/registry/flows/poll/PollAckFlow.java +++ b/core/src/main/java/google/registry/flows/poll/PollAckFlow.java @@ -41,8 +41,8 @@ import google.registry.persistence.PersistenceModule.TransactionIsolationLevel; import google.registry.persistence.VKey; import jakarta.inject.Inject; +import java.time.Instant; import java.util.Optional; -import org.joda.time.DateTime; /** * An EPP flow for acknowledging {@link PollMessage}s. @@ -83,7 +83,7 @@ public EppResponse run() throws EppException { throw new InvalidMessageIdException(messageId); } - final DateTime now = tm().getTransactionTime(); + final Instant now = tm().getTxTime(); // Load the message to be acked. If a message is queued to be delivered in the future, we treat // it as if it doesn't exist yet. Same for if the message ID year isn't the same as the actual diff --git a/core/src/main/java/google/registry/flows/poll/PollFlowUtils.java b/core/src/main/java/google/registry/flows/poll/PollFlowUtils.java index 7f36d88b7e7..b3f3f92e108 100644 --- a/core/src/main/java/google/registry/flows/poll/PollFlowUtils.java +++ b/core/src/main/java/google/registry/flows/poll/PollFlowUtils.java @@ -20,44 +20,20 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.util.DateTimeUtils.isBeforeOrAt; import static google.registry.util.DateTimeUtils.plusYears; -import static google.registry.util.DateTimeUtils.toInstant; import google.registry.model.poll.PollMessage; import google.registry.persistence.transaction.QueryComposer; import java.time.Instant; import java.util.Optional; -import org.joda.time.DateTime; /** Static utility functions for poll flows. */ public final class PollFlowUtils { - /** - * Returns the number of poll messages for the given registrar that are not in the future. - * - * @deprecated Use {@link #getPollMessageCount(String, Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public static int getPollMessageCount(String registrarId, DateTime now) { - return getPollMessageCount(registrarId, toInstant(now)); - } - /** Returns the number of poll messages for the given registrar that are not in the future. */ public static int getPollMessageCount(String registrarId, Instant now) { return (int) createPollMessageQuery(registrarId, now).count(); } - /** - * Returns the first (by event time) poll message not in the future for this registrar. - * - * @deprecated Use {@link #getFirstPollMessage(String, Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public static Optional getFirstPollMessage(String registrarId, DateTime now) { - return getFirstPollMessage(registrarId, toInstant(now)); - } - /** Returns the first (by event time) poll message not in the future for this registrar. */ public static Optional getFirstPollMessage(String registrarId, Instant now) { return createPollMessageQuery(registrarId, now).orderBy("eventTime").first(); @@ -72,17 +48,17 @@ public static Optional getFirstPollMessage(String registrarId, Inst */ public static void ackPollMessage(PollMessage pollMessage) { checkArgument( - isBeforeOrAt(pollMessage.getEventTimeInstant(), tm().getTxTime()), + isBeforeOrAt(pollMessage.getEventTime(), tm().getTxTime()), "Cannot ACK poll message with ID %s because its event time is in the future: %s", pollMessage.getId(), - pollMessage.getEventTimeInstant()); + pollMessage.getEventTime()); if (pollMessage instanceof PollMessage.OneTime) { // One-time poll messages are deleted once acked. tm().delete(pollMessage.createVKey()); } else if (pollMessage instanceof PollMessage.Autorenew autorenewPollMessage) { // Move the eventTime of this autorenew poll message forward by a year. - Instant nextEventTime = plusYears(autorenewPollMessage.getEventTimeInstant(), 1); + Instant nextEventTime = plusYears(autorenewPollMessage.getEventTime(), 1); // If the next event falls within the bounds of the end time, then just update the eventTime // and re-save it for future autorenew poll messages to be delivered. Otherwise, this @@ -97,19 +73,6 @@ public static void ackPollMessage(PollMessage pollMessage) { } } - /** - * Returns the QueryComposer for poll messages from the given registrar that are not in the - * future. - * - * @deprecated Use {@link #createPollMessageQuery(String, Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public static QueryComposer createPollMessageQuery( - String registrarId, DateTime now) { - return createPollMessageQuery(registrarId, toInstant(now)); - } - /** * Returns the QueryComposer for poll messages from the given registrar that are not in the * future. diff --git a/core/src/main/java/google/registry/flows/poll/PollRequestFlow.java b/core/src/main/java/google/registry/flows/poll/PollRequestFlow.java index dd72ca0d532..d24e3637088 100644 --- a/core/src/main/java/google/registry/flows/poll/PollRequestFlow.java +++ b/core/src/main/java/google/registry/flows/poll/PollRequestFlow.java @@ -77,7 +77,7 @@ public EppResponse run() throws EppException { .setResultFromCode(SUCCESS_WITH_ACK_MESSAGE) .setMessageQueueInfo( new MessageQueueInfo.Builder() - .setQueueDate(pollMessage.getEventTimeInstant()) + .setQueueDate(pollMessage.getEventTime()) .setMsg(pollMessage.getMsg()) .setQueueLength(getPollMessageCount(registrarId, now)) .setMessageId(makePollMessageExternalId(pollMessage)) diff --git a/core/src/main/java/google/registry/model/CreateAutoTimestamp.java b/core/src/main/java/google/registry/model/CreateAutoTimestamp.java index 0477d2bfa6e..211872aac63 100644 --- a/core/src/main/java/google/registry/model/CreateAutoTimestamp.java +++ b/core/src/main/java/google/registry/model/CreateAutoTimestamp.java @@ -15,8 +15,6 @@ package google.registry.model; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; -import static google.registry.util.DateTimeUtils.toDateTime; -import static google.registry.util.DateTimeUtils.toInstant; import com.google.gson.annotations.Expose; import google.registry.persistence.EntityCallbacksListener.RecursivePrePersist; @@ -25,7 +23,6 @@ import jakarta.persistence.Embeddable; import java.time.Instant; import javax.annotation.Nullable; -import org.joda.time.DateTime; /** A timestamp that auto-updates when first saved to the database. */ @Embeddable @@ -49,28 +46,10 @@ public Instant getTimestamp() { return creationTime; } - /** - * @deprecated Use {@link #getTimestamp()} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - @Nullable - public DateTime getTimestampDateTime() { - return toDateTime(creationTime); - } - public static CreateAutoTimestamp create(@Nullable Instant creationTime) { CreateAutoTimestamp instance = new CreateAutoTimestamp(); instance.creationTime = creationTime; return instance; } - /** - * @deprecated Use {@link #create(Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public static CreateAutoTimestamp create(@Nullable DateTime creationTime) { - return create(toInstant(creationTime)); - } } diff --git a/core/src/main/java/google/registry/model/EppResource.java b/core/src/main/java/google/registry/model/EppResource.java index 8667a3b5ed0..ac52ff81db1 100644 --- a/core/src/main/java/google/registry/model/EppResource.java +++ b/core/src/main/java/google/registry/model/EppResource.java @@ -25,8 +25,6 @@ import static google.registry.util.CollectionUtils.nullToEmpty; import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy; import static google.registry.util.DateTimeUtils.END_INSTANT; -import static google.registry.util.DateTimeUtils.toDateTime; -import static google.registry.util.DateTimeUtils.toInstant; import com.github.benmanes.caffeine.cache.CacheLoader; import com.github.benmanes.caffeine.cache.LoadingCache; @@ -158,16 +156,7 @@ public void setRepoId(String repoId) { this.repoId = repoId; } - /** - * @deprecated Use {@link #getCreationTimeInstant()} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public final DateTime getCreationTime() { - return creationTime.getTimestampDateTime(); - } - - public final Instant getCreationTimeInstant() { + public final Instant getCreationTime() { return creationTime.getTimestamp(); } @@ -175,12 +164,6 @@ public String getCreationRegistrarId() { return creationRegistrarId; } - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getLastEppUpdateDateTime() { - return toDateTime(lastEppUpdateTime); - } - public Instant getLastEppUpdateTime() { return lastEppUpdateTime; } @@ -203,12 +186,6 @@ public final ImmutableSet getStatusValues() { return nullToEmptyImmutableCopy(statuses); } - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getDeletionDateTime() { - return toDateTime(deletionTime); - } - public Instant getDeletionTime() { return deletionTime; } @@ -260,15 +237,6 @@ public B setCreationTime(Instant creationTime) { return thisCastToDerived(); } - /** - * @deprecated Use {@link #setCreationTime(Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public B setCreationTime(DateTime creationTime) { - return setCreationTime(toInstant(creationTime)); - } - /** Set the time this resource was created. Should only be used in tests. */ @VisibleForTesting public B setCreationTimeForTest(Instant creationTime) { @@ -276,31 +244,12 @@ public B setCreationTimeForTest(Instant creationTime) { return thisCastToDerived(); } - /** - * @deprecated Use {@link #setCreationTimeForTest(Instant)} - */ - @Deprecated - @VisibleForTesting - @SuppressWarnings("InlineMeSuggester") - public B setCreationTimeForTest(DateTime creationTime) { - return setCreationTimeForTest(toInstant(creationTime)); - } - /** Set the time after which this resource should be considered deleted. */ public B setDeletionTime(Instant deletionTime) { getInstance().deletionTime = deletionTime; return thisCastToDerived(); } - /** - * @deprecated Use {@link #setDeletionTime(Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public B setDeletionTime(DateTime deletionTime) { - return setDeletionTime(toInstant(deletionTime)); - } - /** Set the current sponsoring registrar. */ public B setPersistedCurrentSponsorRegistrarId(String currentSponsorRegistrarId) { getInstance().currentSponsorRegistrarId = currentSponsorRegistrarId; @@ -319,15 +268,6 @@ public B setLastEppUpdateTime(Instant lastEppUpdateTime) { return thisCastToDerived(); } - /** - * @deprecated Use {@link #setLastEppUpdateTime(Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public B setLastEppUpdateTime(DateTime lastEppUpdateTime) { - return setLastEppUpdateTime(toInstant(lastEppUpdateTime)); - } - /** Set the registrar who last performed a {@literal } on this resource. */ public B setLastEppUpdateRegistrarId(String lastEppUpdateRegistrarId) { getInstance().lastEppUpdateRegistrarId = lastEppUpdateRegistrarId; diff --git a/core/src/main/java/google/registry/model/EppResourceUtils.java b/core/src/main/java/google/registry/model/EppResourceUtils.java index 94b892c3c44..1e3e39d2bbe 100644 --- a/core/src/main/java/google/registry/model/EppResourceUtils.java +++ b/core/src/main/java/google/registry/model/EppResourceUtils.java @@ -20,6 +20,7 @@ import static google.registry.util.DateTimeUtils.START_INSTANT; import static google.registry.util.DateTimeUtils.isAtOrAfter; import static google.registry.util.DateTimeUtils.isBeforeOrAt; +import static google.registry.util.DateTimeUtils.toDateTime; import static google.registry.util.DateTimeUtils.toInstant; import com.google.common.collect.ImmutableSet; @@ -80,7 +81,7 @@ public static Function transformAtTime(final DateT } public static boolean isActive(EppResource resource, Instant time) { - return isAtOrAfter(time, resource.getCreationTimeInstant()) + return isAtOrAfter(time, resource.getCreationTime()) && time.isBefore(resource.getDeletionTime()); } @@ -120,7 +121,7 @@ public static void setAutomaticTransferSuccessProperties( builder .removeStatusValue(StatusValue.PENDING_TRANSFER) .setTransferData(transferDataBuilder.build()) - .setLastTransferTime(transferData.getPendingTransferExpirationDateTime()) + .setLastTransferTime(toDateTime(transferData.getPendingTransferExpirationTime())) .setPersistedCurrentSponsorRegistrarId(transferData.getGainingRegistrarId()); } @@ -157,7 +158,7 @@ && isBeforeOrAt(expirationTime, now)) { public static T loadAtPointInTime( final T resource, final Instant timestamp) { // If we're before the resource creation time, don't try to find a "most recent revision". - if (timestamp.isBefore(resource.getCreationTimeInstant())) { + if (timestamp.isBefore(resource.getCreationTime())) { return null; } // If the resource was not modified after the requested time, then use it as-is, otherwise find diff --git a/core/src/main/java/google/registry/model/ResourceTransferUtils.java b/core/src/main/java/google/registry/model/ResourceTransferUtils.java index 594e646930e..19d4a685f89 100644 --- a/core/src/main/java/google/registry/model/ResourceTransferUtils.java +++ b/core/src/main/java/google/registry/model/ResourceTransferUtils.java @@ -15,7 +15,6 @@ package google.registry.model; import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.util.DateTimeUtils.toDateTime; import static google.registry.util.DateTimeUtils.toInstant; @@ -53,11 +52,11 @@ public static TransferResponse createTransferResponse( .setDomainName(domain.getForeignKey()) .setExtendedRegistrationExpirationTime( ADD_EXDATE_STATUSES.contains(transferData.getTransferStatus()) - ? transferData.getTransferredRegistrationExpirationDateTime() + ? transferData.getTransferredRegistrationExpirationTime() : null) .setGainingRegistrarId(transferData.getGainingRegistrarId()) .setLosingRegistrarId(transferData.getLosingRegistrarId()) - .setPendingTransferExpirationTime(transferData.getPendingTransferExpirationDateTime()) + .setPendingTransferExpirationTime(transferData.getPendingTransferExpirationTime()) .setTransferRequestTime(transferData.getTransferRequestTime()) .setTransferStatus(transferData.getTransferStatus()) .build(); @@ -145,7 +144,7 @@ private static Domain.Builder resolvePendingTransfer( .getTransferData() .copyConstantFieldsToBuilder() .setTransferStatus(transferStatus) - .setPendingTransferExpirationTime(toDateTime(checkNotNull(now))) + .setPendingTransferExpirationTime(now) .build()); } @@ -191,7 +190,7 @@ public static Domain denyPendingTransfer( Domain domain, TransferStatus transferStatus, Instant now, String lastEppUpdateRegistrarId) { checkArgument(transferStatus.isDenied(), "Not a denial transfer status"); return resolvePendingTransfer(domain, transferStatus, now) - .setLastEppUpdateTime(toDateTime(now)) + .setLastEppUpdateTime(now) .setLastEppUpdateRegistrarId(lastEppUpdateRegistrarId) .build(); } diff --git a/core/src/main/java/google/registry/model/UpdateAutoTimestamp.java b/core/src/main/java/google/registry/model/UpdateAutoTimestamp.java index 8cbbe6b975c..9a4498300bc 100644 --- a/core/src/main/java/google/registry/model/UpdateAutoTimestamp.java +++ b/core/src/main/java/google/registry/model/UpdateAutoTimestamp.java @@ -16,8 +16,6 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.util.DateTimeUtils.START_INSTANT; -import static google.registry.util.DateTimeUtils.toDateTime; -import static google.registry.util.DateTimeUtils.toInstant; import google.registry.persistence.EntityCallbacksListener.RecursivePrePersist; import google.registry.persistence.EntityCallbacksListener.RecursivePreUpdate; @@ -26,7 +24,6 @@ import java.time.Instant; import java.util.Optional; import javax.annotation.Nullable; -import org.joda.time.DateTime; /** A timestamp that auto-updates on each save to Cloud SQL. */ @Embeddable @@ -49,27 +46,10 @@ public Instant getTimestamp() { return Optional.ofNullable(lastUpdateTime).orElse(START_INSTANT); } - /** - * @deprecated Use {@link #getTimestamp()} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getTimestampDateTime() { - return toDateTime(getTimestamp()); - } - public static UpdateAutoTimestamp create(@Nullable Instant timestamp) { UpdateAutoTimestamp instance = new UpdateAutoTimestamp(); instance.lastUpdateTime = timestamp; return instance; } - /** - * @deprecated Use {@link #create(Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public static UpdateAutoTimestamp create(@Nullable DateTime timestamp) { - return create(toInstant(timestamp)); - } } diff --git a/core/src/main/java/google/registry/model/billing/BillingBase.java b/core/src/main/java/google/registry/model/billing/BillingBase.java index 73ab8551294..f242a9aebf5 100644 --- a/core/src/main/java/google/registry/model/billing/BillingBase.java +++ b/core/src/main/java/google/registry/model/billing/BillingBase.java @@ -17,8 +17,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import static google.registry.util.CollectionUtils.forceEmptyToNull; import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy; -import static google.registry.util.DateTimeUtils.toDateTime; -import static google.registry.util.DateTimeUtils.toInstant; import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; import com.google.common.collect.ImmutableSet; @@ -38,7 +36,6 @@ import java.time.Instant; import java.util.Set; import javax.annotation.Nullable; -import org.joda.time.DateTime; /** A billable event in a domain's lifecycle. */ @MappedSuperclass @@ -173,16 +170,7 @@ public String getDomainRepoId() { return domainRepoId; } - /** - * @deprecated Use {@link #getEventTimeInstant()} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getEventTime() { - return toDateTime(eventTime); - } - - public Instant getEventTimeInstant() { + public Instant getEventTime() { return eventTime; } @@ -238,15 +226,6 @@ public B setRegistrarId(String registrarId) { return thisCastToDerived(); } - /** - * @deprecated Use {@link #setEventTime(Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public B setEventTime(DateTime eventTime) { - return setEventTime(toInstant(eventTime)); - } - public B setEventTime(Instant eventTime) { getInstance().eventTime = eventTime; return thisCastToDerived(); diff --git a/core/src/main/java/google/registry/model/billing/BillingCancellation.java b/core/src/main/java/google/registry/model/billing/BillingCancellation.java index 0fc66fba972..a3b03ffda85 100644 --- a/core/src/main/java/google/registry/model/billing/BillingCancellation.java +++ b/core/src/main/java/google/registry/model/billing/BillingCancellation.java @@ -31,7 +31,7 @@ import jakarta.persistence.Entity; import jakarta.persistence.Index; import jakarta.persistence.Table; -import org.joda.time.DateTime; +import java.time.Instant; /** * An event representing a cancellation of one of the other two billable event types. @@ -55,7 +55,7 @@ public class BillingCancellation extends BillingBase { /** The billing time of the charge that is being cancelled. */ - DateTime billingTime; + Instant billingTime; /** The one-time billing event to cancel, or null for autorenew cancellations. */ @Column(name = "billing_event_id") @@ -67,7 +67,7 @@ public class BillingCancellation extends BillingBase { @Convert(converter = VKeyConverter_BillingRecurrence.class) VKey billingRecurrence; - public DateTime getBillingTime() { + public Instant getBillingTime() { return billingTime; } @@ -90,10 +90,7 @@ public VKey getEventKey() { * reason) from the grace period. */ public static BillingCancellation forGracePeriod( - GracePeriod gracePeriod, - DateTime eventTime, - HistoryEntryId domainHistoryId, - String targetId) { + GracePeriod gracePeriod, Instant eventTime, HistoryEntryId domainHistoryId, String targetId) { checkArgument( gracePeriod.hasBillingEvent(), "Cannot create cancellation for grace period without billing event"); @@ -104,7 +101,7 @@ public static BillingCancellation forGracePeriod( .setRegistrarId(gracePeriod.getRegistrarId()) .setEventTime(eventTime) // The charge being cancelled will take place at the grace period's expiration time. - .setBillingTime(gracePeriod.getExpirationDateTime()) + .setBillingTime(gracePeriod.getExpirationTime()) .setDomainHistoryId(domainHistoryId); // Set the grace period's billing event using the appropriate Cancellation builder method. if (gracePeriod.getBillingEvent() != null) { @@ -138,7 +135,7 @@ private Builder(BillingCancellation instance) { super(instance); } - public Builder setBillingTime(DateTime billingTime) { + public Builder setBillingTime(Instant billingTime) { getInstance().billingTime = billingTime; return this; } diff --git a/core/src/main/java/google/registry/model/billing/BillingEvent.java b/core/src/main/java/google/registry/model/billing/BillingEvent.java index 6e6d0629956..6fab00e6b12 100644 --- a/core/src/main/java/google/registry/model/billing/BillingEvent.java +++ b/core/src/main/java/google/registry/model/billing/BillingEvent.java @@ -17,8 +17,6 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; -import static google.registry.util.DateTimeUtils.toDateTime; -import static google.registry.util.DateTimeUtils.toInstant; import google.registry.model.domain.DomainHistory; import google.registry.model.domain.token.AllocationToken; @@ -35,7 +33,6 @@ import java.util.Optional; import javax.annotation.Nullable; import org.joda.money.Money; -import org.joda.time.DateTime; /** A one-time billable event. */ @Entity @@ -108,16 +105,7 @@ public Money getCost() { return cost; } - /** - * @deprecated Use {@link #getBillingTimeInstant()} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getBillingTime() { - return toDateTime(billingTime); - } - - public Instant getBillingTimeInstant() { + public Instant getBillingTime() { return billingTime; } @@ -125,16 +113,7 @@ public Integer getPeriodYears() { return periodYears; } - /** - * @deprecated Use {@link #getSyntheticCreationTimeInstant()} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getSyntheticCreationTime() { - return toDateTime(syntheticCreationTime); - } - - public Instant getSyntheticCreationTimeInstant() { + public Instant getSyntheticCreationTime() { return syntheticCreationTime; } @@ -185,29 +164,11 @@ public Builder setPeriodYears(Integer periodYears) { return this; } - /** - * @deprecated Use {@link #setBillingTime(Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public Builder setBillingTime(DateTime billingTime) { - return setBillingTime(toInstant(billingTime)); - } - public Builder setBillingTime(Instant billingTime) { getInstance().billingTime = billingTime; return this; } - /** - * @deprecated Use {@link #setSyntheticCreationTime(Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public Builder setSyntheticCreationTime(DateTime syntheticCreationTime) { - return setSyntheticCreationTime(toInstant(syntheticCreationTime)); - } - public Builder setSyntheticCreationTime(Instant syntheticCreationTime) { getInstance().syntheticCreationTime = syntheticCreationTime; return this; diff --git a/core/src/main/java/google/registry/model/billing/BillingRecurrence.java b/core/src/main/java/google/registry/model/billing/BillingRecurrence.java index c067a7b0c46..813b72762ea 100644 --- a/core/src/main/java/google/registry/model/billing/BillingRecurrence.java +++ b/core/src/main/java/google/registry/model/billing/BillingRecurrence.java @@ -18,8 +18,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import static google.registry.util.DateTimeUtils.END_INSTANT; import static google.registry.util.DateTimeUtils.minusYears; -import static google.registry.util.DateTimeUtils.toDateTime; -import static google.registry.util.DateTimeUtils.toInstant; import google.registry.model.common.TimeOfYear; import google.registry.persistence.VKey; @@ -37,7 +35,6 @@ import java.util.Optional; import javax.annotation.Nullable; import org.joda.money.Money; -import org.joda.time.DateTime; /** * A recurring billable event. @@ -113,29 +110,11 @@ public class BillingRecurrence extends BillingBase { @Column(name = "renewalPriceBehavior", nullable = false) RenewalPriceBehavior renewalPriceBehavior = RenewalPriceBehavior.DEFAULT; - /** - * @deprecated Use {@link #getRecurrenceEndTimeInstant()} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getRecurrenceEndTime() { - return toDateTime(recurrenceEndTime); - } - - public Instant getRecurrenceEndTimeInstant() { + public Instant getRecurrenceEndTime() { return recurrenceEndTime; } - /** - * @deprecated Use {@link #getRecurrenceLastExpansionInstant()} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getRecurrenceLastExpansion() { - return toDateTime(recurrenceLastExpansion); - } - - public Instant getRecurrenceLastExpansionInstant() { + public Instant getRecurrenceLastExpansion() { return recurrenceLastExpansion; } @@ -174,29 +153,11 @@ private Builder(BillingRecurrence instance) { super(instance); } - /** - * @deprecated Use {@link #setRecurrenceEndTime(Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public Builder setRecurrenceEndTime(DateTime recurrenceEndTime) { - return setRecurrenceEndTime(toInstant(recurrenceEndTime)); - } - public Builder setRecurrenceEndTime(Instant recurrenceEndTime) { getInstance().recurrenceEndTime = recurrenceEndTime; return this; } - /** - * @deprecated Use {@link #setRecurrenceLastExpansion(Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public Builder setRecurrenceLastExpansion(DateTime recurrenceLastExpansion) { - return setRecurrenceLastExpansion(toInstant(recurrenceLastExpansion)); - } - public Builder setRecurrenceLastExpansion(Instant recurrenceLastExpansion) { getInstance().recurrenceLastExpansion = recurrenceLastExpansion; return this; diff --git a/core/src/main/java/google/registry/model/common/TimeOfYear.java b/core/src/main/java/google/registry/model/common/TimeOfYear.java index a98bb13a7ba..71fa4cb6be1 100644 --- a/core/src/main/java/google/registry/model/common/TimeOfYear.java +++ b/core/src/main/java/google/registry/model/common/TimeOfYear.java @@ -17,16 +17,12 @@ import static com.google.common.collect.DiscreteDomain.integers; import static com.google.common.collect.ImmutableList.toImmutableList; import static google.registry.util.DateTimeUtils.END_INSTANT; -import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.DateTimeUtils.START_INSTANT; -import static google.registry.util.DateTimeUtils.START_OF_TIME; import static google.registry.util.DateTimeUtils.isAtOrAfter; import static google.registry.util.DateTimeUtils.isBeforeOrAt; import static google.registry.util.DateTimeUtils.minusYears; import static google.registry.util.DateTimeUtils.plusYears; -import static google.registry.util.DateTimeUtils.toDateTime; -import static google.registry.util.DateTimeUtils.toInstant; -import static org.joda.time.DateTimeZone.UTC; +import static java.time.ZoneOffset.UTC; import com.google.common.base.Splitter; import com.google.common.collect.ContiguousSet; @@ -37,10 +33,8 @@ import java.time.Instant; import java.time.LocalDate; import java.time.LocalTime; -import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.util.List; -import org.joda.time.DateTime; /** * A time of year (month, day, millis of day) that can be stored in a sort-friendly format. @@ -62,20 +56,6 @@ public class TimeOfYear extends ImmutableObject implements UnsafeSerializable { */ String timeString; - /** - * Constructs a {@link TimeOfYear} from a {@link DateTime}. - * - *

This handles leap years in an intentionally peculiar way by always treating February 29 as - * February 28. It is impossible to construct a {@link TimeOfYear} for February 29th. - * - * @deprecated Use {@link #fromInstant(Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public static TimeOfYear fromDateTime(DateTime dateTime) { - return fromInstant(toInstant(dateTime)); - } - /** * Constructs a {@link TimeOfYear} from an {@link Instant}. * @@ -83,7 +63,7 @@ public static TimeOfYear fromDateTime(DateTime dateTime) { * February 28. It is impossible to construct a {@link TimeOfYear} for February 29th. */ public static TimeOfYear fromInstant(Instant instant) { - ZonedDateTime zdt = ZonedDateTime.ofInstant(instant, ZoneOffset.UTC); + ZonedDateTime zdt = ZonedDateTime.ofInstant(instant, UTC); int month = zdt.getMonthValue(); int day = zdt.getDayOfMonth(); if (month == 2 && day == 29) { @@ -95,30 +75,6 @@ public static TimeOfYear fromInstant(Instant instant) { return instance; } - /** - * Returns an {@link Iterable} of {@link DateTime}s of every recurrence of this particular time of - * year within a given {@link Range} (usually one spanning many years). - * - *

WARNING: This can return a potentially very large {@link Iterable} if {@code END_OF_TIME} is - * used as the upper endpoint of the range. - * - * @deprecated Use {@link #getInstancesInRangeInstant(Range)} - */ - @Deprecated - public Iterable getInstancesInRange(Range range) { - // In registry world, all dates are within START_OF_TIME and END_OF_TIME, so restrict any - // ranges without bounds to our notion of zero-to-infinity. - Range normalizedRange = range.intersection(Range.closed(START_OF_TIME, END_OF_TIME)); - Range yearRange = Range.closed( - normalizedRange.lowerEndpoint().getYear(), - normalizedRange.upperEndpoint().getYear()); - return ContiguousSet.create(yearRange, integers()) - .stream() - .map(this::getDateTimeWithYear) - .filter(normalizedRange) - .collect(toImmutableList()); - } - /** * Returns an {@link Iterable} of {@link Instant}s of every recurrence of this particular time of * year within a given {@link Range} (usually one spanning many years). @@ -126,14 +82,14 @@ public Iterable getInstancesInRange(Range range) { *

WARNING: This can return a potentially very large {@link Iterable} if {@code END_INSTANT} is * used as the upper endpoint of the range. */ - public Iterable getInstancesInRangeInstant(Range range) { + public Iterable getInstancesInRange(Range range) { // In registry world, all dates are within START_INSTANT and END_INSTANT, so restrict any // ranges without bounds to our notion of zero-to-infinity. Range normalizedRange = range.intersection(Range.closed(START_INSTANT, END_INSTANT)); Range yearRange = Range.closed( - ZonedDateTime.ofInstant(normalizedRange.lowerEndpoint(), ZoneOffset.UTC).getYear(), - ZonedDateTime.ofInstant(normalizedRange.upperEndpoint(), ZoneOffset.UTC).getYear()); + ZonedDateTime.ofInstant(normalizedRange.lowerEndpoint(), UTC).getYear(), + ZonedDateTime.ofInstant(normalizedRange.upperEndpoint(), UTC).getYear()); return ContiguousSet.create(yearRange, integers()).stream() .map(this::toInstantWithYear) .filter(normalizedRange) @@ -151,57 +107,19 @@ private Instant toInstantWithYear(int year) { int millis = Integer.parseInt(monthDayMillis.get(2)); return LocalDate.of(year, month, day) .atTime(LocalTime.ofNanoOfDay(millis * 1000000L)) - .toInstant(ZoneOffset.UTC); - } - - /** - * Get the first {@link DateTime} with this month/day/millis that is at or after the start. - * - * @deprecated Use {@link #getNextInstanceAtOrAfterInstant(Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getNextInstanceAtOrAfter(DateTime start) { - return toDateTime(getNextInstanceAtOrAfterInstant(toInstant(start))); + .toInstant(UTC); } /** Get the first {@link Instant} with this month/day/millis that is at or after the start. */ - public Instant getNextInstanceAtOrAfterInstant(Instant start) { - Instant withSameYear = - toInstantWithYear(ZonedDateTime.ofInstant(start, ZoneOffset.UTC).getYear()); + public Instant getNextInstanceAtOrAfter(Instant start) { + Instant withSameYear = toInstantWithYear(ZonedDateTime.ofInstant(start, UTC).getYear()); return isAtOrAfter(withSameYear, start) ? withSameYear : plusYears(withSameYear, 1); } - /** - * Get the first {@link DateTime} with this month/day/millis that is at or before the end. - * - * @deprecated Use {@link #getLastInstanceBeforeOrAtInstant(Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getLastInstanceBeforeOrAt(DateTime end) { - return toDateTime(getLastInstanceBeforeOrAtInstant(toInstant(end))); - } - /** Get the first {@link Instant} with this month/day/millis that is at or before the end. */ - public Instant getLastInstanceBeforeOrAtInstant(Instant end) { - Instant withSameYear = - toInstantWithYear(ZonedDateTime.ofInstant(end, ZoneOffset.UTC).getYear()); + public Instant getLastInstanceBeforeOrAt(Instant end) { + Instant withSameYear = toInstantWithYear(ZonedDateTime.ofInstant(end, UTC).getYear()); return isBeforeOrAt(withSameYear, end) ? withSameYear : minusYears(withSameYear, 1); } - /** - * Return a new datetime with the same year as the parameter but projected to the month, day, and - * time of day of this object. - */ - private DateTime getDateTimeWithYear(int year) { - List monthDayMillis = Splitter.on(' ').splitToList(timeString); - // Do not be clever and use Ints.stringConverter here. That does radix guessing, and bad things - // will happen because of the leading zeroes. - return new DateTime(0, UTC) - .withYear(year) - .withMonthOfYear(Integer.parseInt(monthDayMillis.get(0))) - .withDayOfMonth(Integer.parseInt(monthDayMillis.get(1))) - .withMillisOfDay(Integer.parseInt(monthDayMillis.get(2))); - } } 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 5b2b0c3bddb..6fe8b1c3bcc 100644 --- a/core/src/main/java/google/registry/model/domain/DomainBase.java +++ b/core/src/main/java/google/registry/model/domain/DomainBase.java @@ -541,7 +541,7 @@ && isBeforeOrAt(transferExpirationTime, now)) { // Set all remaining transfer properties. setAutomaticTransferSuccessProperties(builder, transferData); builder - .setLastEppUpdateTime(toDateTime(transferExpirationTime)) + .setLastEppUpdateTime(transferExpirationTime) .setLastEppUpdateRegistrarId(transferData.getGainingRegistrarId()); // Finish projecting to now. return (T) builder.build().cloneProjectedAtInstant(now); @@ -592,10 +592,10 @@ && isBeforeOrAt(transferExpirationTime, now)) { // id, so we have to do the comparison instead of having one variable just storing the most // recent time. if (newLastEppUpdateTime.isPresent()) { - if (domain.getLastEppUpdateDateTime() == null + if (domain.getLastEppUpdateTime() == null || newLastEppUpdateTime.get().isAfter(domain.getLastEppUpdateTime())) { builder - .setLastEppUpdateTime(toDateTime(newLastEppUpdateTime.get())) + .setLastEppUpdateTime(newLastEppUpdateTime.get()) .setLastEppUpdateRegistrarId(domain.getCurrentSponsorRegistrarId()); } } @@ -893,13 +893,13 @@ public B copyFrom(DomainBase domainBase) { .setDomainName(domainBase.getDomainName()) .setDeletePollMessage(domainBase.getDeletePollMessage()) .setDsData(domainBase.getDsData()) - .setDeletionTime(domainBase.getDeletionDateTime()) + .setDeletionTime(domainBase.getDeletionTime()) .setGracePeriods(domainBase.getGracePeriods()) .setIdnTableName(domainBase.getIdnTableName()) .setLastTransferTime(domainBase.getLastTransferTime()) .setLaunchNotice(domainBase.getLaunchNotice()) .setLastEppUpdateRegistrarId(domainBase.getLastEppUpdateRegistrarId()) - .setLastEppUpdateTime(domainBase.getLastEppUpdateDateTime()) + .setLastEppUpdateTime(domainBase.getLastEppUpdateTime()) .setNameservers(domainBase.getNameservers()) .setPersistedCurrentSponsorRegistrarId(domainBase.getPersistedCurrentSponsorRegistrarId()) .setRegistrationExpirationTime(domainBase.getRegistrationExpirationDateTime()) diff --git a/core/src/main/java/google/registry/model/domain/GracePeriod.java b/core/src/main/java/google/registry/model/domain/GracePeriod.java index 64e76a0c679..3ad5a2918b7 100644 --- a/core/src/main/java/google/registry/model/domain/GracePeriod.java +++ b/core/src/main/java/google/registry/model/domain/GracePeriod.java @@ -16,7 +16,6 @@ import static com.google.common.base.Preconditions.checkArgument; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; -import static google.registry.util.DateTimeUtils.toInstant; import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; import com.google.common.annotations.VisibleForTesting; @@ -33,7 +32,6 @@ import jakarta.persistence.Table; import java.time.Instant; import javax.annotation.Nullable; -import org.joda.time.DateTime; /** * A domain grace period with an expiration time. @@ -100,22 +98,6 @@ public static GracePeriod create( type, domainRepoId, expirationTime, registrarId, billingEventOneTime, null, null); } - /** - * Creates a GracePeriod for an (optional) OneTime billing event. - * - * @deprecated Use {@link #create(GracePeriodStatus, String, Instant, String, VKey)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public static GracePeriod create( - GracePeriodStatus type, - String domainRepoId, - DateTime expirationTime, - String registrarId, - @Nullable VKey billingEventOneTime) { - return create(type, domainRepoId, toInstant(expirationTime), registrarId, billingEventOneTime); - } - /** * Creates a GracePeriod for an (optional) OneTime billing event and a given {@link * #gracePeriodId}. @@ -136,31 +118,6 @@ public static GracePeriod create( type, domainRepoId, expirationTime, registrarId, billingEventOneTime, null, gracePeriodId); } - /** - * Creates a GracePeriod for an (optional) OneTime billing event and a given {@link - * #gracePeriodId}. - * - * @deprecated Use {@link #create(GracePeriodStatus, String, Instant, String, VKey, Long)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - @VisibleForTesting - public static GracePeriod create( - GracePeriodStatus type, - String domainRepoId, - DateTime expirationTime, - String registrarId, - @Nullable VKey billingEventOneTime, - @Nullable Long gracePeriodId) { - return create( - type, - domainRepoId, - toInstant(expirationTime), - registrarId, - billingEventOneTime, - gracePeriodId); - } - public static GracePeriod createFromHistory(GracePeriodHistory history) { return createInternal( history.type, @@ -184,23 +141,6 @@ public static GracePeriod createForRecurrence( type, domainRepoId, expirationTime, registrarId, null, billingEventRecurrence, null); } - /** - * Creates a GracePeriod for a Recurrence billing event. - * - * @deprecated Use {@link #createForRecurrence(GracePeriodStatus, String, Instant, String, VKey)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public static GracePeriod createForRecurrence( - GracePeriodStatus type, - String domainRepoId, - DateTime expirationTime, - String registrarId, - VKey billingEventRecurrence) { - return createForRecurrence( - type, domainRepoId, toInstant(expirationTime), registrarId, billingEventRecurrence); - } - /** Creates a GracePeriod for a Recurrence billing event and a given {@link #gracePeriodId}. */ @VisibleForTesting public static GracePeriod createForRecurrence( @@ -221,56 +161,19 @@ public static GracePeriod createForRecurrence( gracePeriodId); } - /** - * Creates a GracePeriod for a Recurrence billing event and a given {@link #gracePeriodId}. - * - * @deprecated Use {@link #createForRecurrence(GracePeriodStatus, String, Instant, String, VKey, - * Long)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - @VisibleForTesting - public static GracePeriod createForRecurrence( - GracePeriodStatus type, - String domainRepoId, - DateTime expirationTime, - String registrarId, - VKey billingEventRecurrence, - @Nullable Long gracePeriodId) { - return createForRecurrence( - type, - domainRepoId, - toInstant(expirationTime), - registrarId, - billingEventRecurrence, - gracePeriodId); - } - /** Creates a GracePeriod with no billing event. */ public static GracePeriod createWithoutBillingEvent( GracePeriodStatus type, String domainRepoId, Instant expirationTime, String registrarId) { return createInternal(type, domainRepoId, expirationTime, registrarId, null, null, null); } - /** - * Creates a GracePeriod with no billing event. - * - * @deprecated Use {@link #createWithoutBillingEvent(GracePeriodStatus, String, Instant, String)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public static GracePeriod createWithoutBillingEvent( - GracePeriodStatus type, String domainRepoId, DateTime expirationTime, String registrarId) { - return createWithoutBillingEvent(type, domainRepoId, toInstant(expirationTime), registrarId); - } - /** Constructs a GracePeriod of the given type from the provided one-time BillingEvent. */ public static GracePeriod forBillingEvent( GracePeriodStatus type, String domainRepoId, BillingEvent billingEvent) { return create( type, domainRepoId, - billingEvent.getBillingTimeInstant(), + billingEvent.getBillingTime(), billingEvent.getRegistrarId(), billingEvent.createVKey()); } diff --git a/core/src/main/java/google/registry/model/domain/GracePeriodBase.java b/core/src/main/java/google/registry/model/domain/GracePeriodBase.java index caf74ce3361..a35b5ff34b0 100644 --- a/core/src/main/java/google/registry/model/domain/GracePeriodBase.java +++ b/core/src/main/java/google/registry/model/domain/GracePeriodBase.java @@ -14,7 +14,6 @@ package google.registry.model.domain; -import static google.registry.util.DateTimeUtils.toDateTime; import google.registry.model.ImmutableObject; import google.registry.model.UnsafeSerializable; @@ -33,7 +32,6 @@ import jakarta.persistence.MappedSuperclass; import jakarta.persistence.Transient; import java.time.Instant; -import org.joda.time.DateTime; /** Base class containing common fields and methods for {@link GracePeriod}. */ @MappedSuperclass @@ -93,12 +91,6 @@ public String getDomainRepoId() { return domainRepoId; } - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getExpirationDateTime() { - return toDateTime(expirationTime); - } - public Instant getExpirationTime() { return expirationTime; } diff --git a/core/src/main/java/google/registry/model/domain/RegistryLock.java b/core/src/main/java/google/registry/model/domain/RegistryLock.java index 590b154cf40..f071d2acbbb 100644 --- a/core/src/main/java/google/registry/model/domain/RegistryLock.java +++ b/core/src/main/java/google/registry/model/domain/RegistryLock.java @@ -16,8 +16,6 @@ import static com.google.common.base.Preconditions.checkArgument; import static google.registry.util.DateTimeUtils.isBeforeOrAt; -import static google.registry.util.DateTimeUtils.toDateTime; -import static google.registry.util.DateTimeUtils.toInstant; import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; import com.google.gson.annotations.Expose; @@ -38,11 +36,10 @@ import jakarta.persistence.JoinColumn; import jakarta.persistence.OneToOne; import jakarta.persistence.Table; +import java.time.Duration; import java.time.Instant; import java.util.Optional; import javax.annotation.Nullable; -import org.joda.time.DateTime; -import org.joda.time.Duration; /** * Represents a registry lock/unlock object, meaning that the domain is locked on the registry @@ -124,19 +121,19 @@ public final class RegistryLock extends UpdateAutoTimestampEntity implements Bui private final CreateAutoTimestamp lockRequestTime = CreateAutoTimestamp.create((Instant) null); /** When the unlock is first requested. */ - @Expose private DateTime unlockRequestTime; + @Expose private Instant unlockRequestTime; /** * When the user has verified the lock. If this field is null, it means the lock has not been * verified yet (and thus not been put into effect). */ - @Expose private DateTime lockCompletionTime; + @Expose private Instant lockCompletionTime; /** * When the user has verified the unlock of this lock. If this field is null, it means the unlock * action has not been verified yet (and has not been put into effect). */ - @Expose private DateTime unlockCompletionTime; + @Expose private Instant unlockCompletionTime; /** The user must provide the random verification code in order to complete the action. */ @Column(nullable = false) @@ -158,7 +155,7 @@ public final class RegistryLock extends UpdateAutoTimestampEntity implements Bui /** The duration after which we will re-lock this domain after it is unlocked. */ @Column(columnDefinition = "interval") - private Duration relockDuration; + private org.joda.time.Duration relockDuration; public String getRepoId() { return repoId; @@ -180,29 +177,20 @@ public Instant getLockRequestTime() { return lockRequestTime.getTimestamp(); } - /** - * @deprecated Use {@link #getLockRequestTime()} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getLockRequestDateTime() { - return toDateTime(lockRequestTime.getTimestamp()); - } - /** Returns the unlock request timestamp or null if an unlock has not been requested yet. */ - public Optional getUnlockRequestTime() { + public Optional getUnlockRequestTime() { return Optional.ofNullable(unlockRequestTime); } /** Returns the completion timestamp, or empty if this lock has not been completed yet. */ - public Optional getLockCompletionTime() { + public Optional getLockCompletionTime() { return Optional.ofNullable(lockCompletionTime); } /** * Returns the unlock completion timestamp, or empty if this unlock has not been completed yet. */ - public Optional getUnlockCompletionTime() { + public Optional getUnlockCompletionTime() { return Optional.ofNullable(unlockCompletionTime); } @@ -214,8 +202,8 @@ public boolean isSuperuser() { return isSuperuser; } - public DateTime getLastUpdateTime() { - return getUpdateTimestamp().getTimestampDateTime(); + public Instant getLastUpdateTime() { + return getUpdateTimestamp().getTimestamp(); } public Long getRevisionId() { @@ -233,7 +221,7 @@ public RegistryLock getRelock() { } /** The duration after which we will re-lock this domain after it is unlocked. */ - public Optional getRelockDuration() { + public Optional getRelockDuration() { return Optional.ofNullable(relockDuration); } @@ -241,41 +229,18 @@ public boolean isLocked() { return lockCompletionTime != null && unlockCompletionTime == null; } - /** - * Returns true iff the lock was requested >= 1 hour ago and has not been verified. - * - * @deprecated Use {@link #isLockRequestExpired(Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public boolean isLockRequestExpired(DateTime now) { - return isLockRequestExpired(toInstant(now)); - } - /** Returns true iff the lock was requested >= 1 hour ago and has not been verified. */ public boolean isLockRequestExpired(Instant now) { return getLockCompletionTime().isEmpty() - && isBeforeOrAt(getLockRequestTime(), now.minus(java.time.Duration.ofHours(1))); - } - - /** - * Returns true iff the unlock was requested >= 1 hour ago and has not been verified. - * - * @deprecated Use {@link #isUnlockRequestExpired(Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public boolean isUnlockRequestExpired(DateTime now) { - return isUnlockRequestExpired(toInstant(now)); + && isBeforeOrAt(getLockRequestTime(), now.minus(Duration.ofHours(1))); } /** Returns true iff the unlock was requested >= 1 hour ago and has not been verified. */ public boolean isUnlockRequestExpired(Instant now) { - Optional unlockRequestTimestamp = getUnlockRequestTime(); + Optional unlockRequestTimestamp = getUnlockRequestTime(); return unlockRequestTimestamp.isPresent() && getUnlockCompletionTime().isEmpty() - && isBeforeOrAt( - toInstant(unlockRequestTimestamp.get()), now.minus(java.time.Duration.ofHours(1))); + && isBeforeOrAt(unlockRequestTimestamp.get(), now.minus(Duration.ofHours(1))); } @Override @@ -323,17 +288,17 @@ public Builder setRegistryLockEmail(String registryLockEmail) { return this; } - public Builder setUnlockRequestTime(DateTime unlockRequestTime) { + public Builder setUnlockRequestTime(Instant unlockRequestTime) { getInstance().unlockRequestTime = unlockRequestTime; return this; } - public Builder setLockCompletionTime(DateTime lockCompletionTime) { + public Builder setLockCompletionTime(Instant lockCompletionTime) { getInstance().lockCompletionTime = lockCompletionTime; return this; } - public Builder setUnlockCompletionTime(DateTime unlockCompletionTime) { + public Builder setUnlockCompletionTime(Instant unlockCompletionTime) { getInstance().unlockCompletionTime = unlockCompletionTime; return this; } @@ -353,7 +318,7 @@ public Builder setRelock(RegistryLock relock) { return this; } - public Builder setRelockDuration(@Nullable Duration relockDuration) { + public Builder setRelockDuration(@Nullable org.joda.time.Duration relockDuration) { getInstance().relockDuration = relockDuration; return this; } diff --git a/core/src/main/java/google/registry/model/domain/token/AllocationToken.java b/core/src/main/java/google/registry/model/domain/token/AllocationToken.java index d4d004132c6..92d46a3e492 100644 --- a/core/src/main/java/google/registry/model/domain/token/AllocationToken.java +++ b/core/src/main/java/google/registry/model/domain/token/AllocationToken.java @@ -342,9 +342,9 @@ public TokenType getTokenType() { /** * @deprecated Use {@link #getCreationTime()} */ - @JsonIgnore @Deprecated @SuppressWarnings("InlineMeSuggester") + @JsonIgnore public Optional getCreationDateTime() { return Optional.ofNullable(toDateTime(creationTime.getTimestamp())); } diff --git a/core/src/main/java/google/registry/model/host/HostBase.java b/core/src/main/java/google/registry/model/host/HostBase.java index d2cf034453a..55f0df7a5ec 100644 --- a/core/src/main/java/google/registry/model/host/HostBase.java +++ b/core/src/main/java/google/registry/model/host/HostBase.java @@ -19,8 +19,6 @@ import static com.google.common.collect.Sets.union; import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy; import static google.registry.util.DateTimeUtils.START_INSTANT; -import static google.registry.util.DateTimeUtils.toDateTime; -import static google.registry.util.DateTimeUtils.toInstant; import static google.registry.util.DomainNameUtils.canonicalizeHostname; import com.google.common.collect.ImmutableSet; @@ -29,6 +27,7 @@ import google.registry.model.domain.VKeyConverter_Domain; import google.registry.persistence.VKey; import google.registry.persistence.converter.InetAddressSetUserType; +import google.registry.util.DateTimeUtils; import jakarta.persistence.Access; import jakarta.persistence.AccessType; import jakarta.persistence.Column; @@ -109,29 +108,11 @@ public ImmutableSet getInetAddresses() { return nullToEmptyImmutableCopy(inetAddresses); } - /** - * @deprecated Use {@link #getLastTransferTimeInstant()} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getLastTransferTime() { - return toDateTime(lastTransferTime); - } - - public Instant getLastTransferTimeInstant() { + public Instant getLastTransferTime() { return lastTransferTime; } - /** - * @deprecated Use {@link #getLastSuperordinateChangeInstant()} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getLastSuperordinateChange() { - return toDateTime(lastSuperordinateChange); - } - - public Instant getLastSuperordinateChangeInstant() { + public Instant getLastSuperordinateChange() { return lastSuperordinateChange; } @@ -187,23 +168,16 @@ public Instant computeLastTransferTime(@Nullable Domain superordinateDomain) { superordinateDomain != null && superordinateDomain.createVKey().equals(getSuperordinateDomain())); Instant lastSuperordinateChange = - Optional.ofNullable(getLastSuperordinateChangeInstant()).orElse(getCreationTimeInstant()); + Optional.ofNullable(getLastSuperordinateChange()).orElse(getCreationTime()); Instant lastTransferOfCurrentSuperordinate = - Optional.ofNullable(superordinateDomain.getLastTransferTimeInstant()).orElse(START_INSTANT); + Optional.ofNullable(superordinateDomain.getLastTransferTime()) + .map(DateTimeUtils::toInstant) + .orElse(START_INSTANT); return lastSuperordinateChange.isBefore(lastTransferOfCurrentSuperordinate) ? lastTransferOfCurrentSuperordinate : lastTransferTime; } - /** - * @deprecated Use {@link #computeLastTransferTime(Domain)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime computeLastTransferTimeDateTime(@Nullable Domain superordinateDomain) { - return toDateTime(computeLastTransferTime(superordinateDomain)); - } - /** A builder for constructing {@link HostBase}, since it is immutable. */ protected static class Builder> extends EppResource.Builder { @@ -244,15 +218,6 @@ public B setLastSuperordinateChange(Instant lastSuperordinateChange) { return thisCastToDerived(); } - /** - * @deprecated Use {@link #setLastSuperordinateChange(Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public B setLastSuperordinateChange(DateTime lastSuperordinateChange) { - return setLastSuperordinateChange(toInstant(lastSuperordinateChange)); - } - public B addInetAddresses(ImmutableSet inetAddresses) { return setInetAddresses( ImmutableSet.copyOf(union(getInstance().getInetAddresses(), inetAddresses))); @@ -273,23 +238,14 @@ public B setLastTransferTime(Instant lastTransferTime) { return thisCastToDerived(); } - /** - * @deprecated Use {@link #setLastTransferTime(Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public B setLastTransferTime(DateTime lastTransferTime) { - return setLastTransferTime(toInstant(lastTransferTime)); - } - public B copyFrom(HostBase hostBase) { return setCreationRegistrarId(hostBase.getCreationRegistrarId()) - .setCreationTime(hostBase.getCreationTimeInstant()) + .setCreationTime(hostBase.getCreationTime()) .setDeletionTime(hostBase.getDeletionTime()) .setHostName(hostBase.getHostName()) .setInetAddresses(hostBase.getInetAddresses()) - .setLastTransferTime(hostBase.getLastTransferTimeInstant()) - .setLastSuperordinateChange(hostBase.getLastSuperordinateChangeInstant()) + .setLastTransferTime(hostBase.getLastTransferTime()) + .setLastSuperordinateChange(hostBase.getLastSuperordinateChange()) .setLastEppUpdateRegistrarId(hostBase.getLastEppUpdateRegistrarId()) .setLastEppUpdateTime(hostBase.getLastEppUpdateTime()) .setPersistedCurrentSponsorRegistrarId(hostBase.getPersistedCurrentSponsorRegistrarId()) diff --git a/core/src/main/java/google/registry/model/poll/PollMessage.java b/core/src/main/java/google/registry/model/poll/PollMessage.java index 4d0a70c0e56..6e52f5c6a1f 100644 --- a/core/src/main/java/google/registry/model/poll/PollMessage.java +++ b/core/src/main/java/google/registry/model/poll/PollMessage.java @@ -162,16 +162,7 @@ public String getRegistrarId() { return clientId; } - /** - * @deprecated Use {@link #getEventTimeInstant()} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getEventTime() { - return toDateTime(eventTime); - } - - public Instant getEventTimeInstant() { + public Instant getEventTime() { return eventTime; } @@ -470,7 +461,7 @@ void postLoad() { .setGainingRegistrarId(transferResponse.getGainingRegistrarId()) .setLosingRegistrarId(transferResponse.getLosingRegistrarId()) .setTransferStatus(transferResponse.getTransferStatus()) - .setTransferRequestTime(transferResponse.getTransferRequestTimeInstant()) + .setTransferRequestTime(transferResponse.getTransferRequestTime()) .setPendingTransferExpirationTime( transferResponse.getPendingTransferExpirationTime()) .setExtendedRegistrationExpirationTime(extendedRegistrationExpirationTime) diff --git a/core/src/main/java/google/registry/model/poll/PollMessageExternalKeyConverter.java b/core/src/main/java/google/registry/model/poll/PollMessageExternalKeyConverter.java index 215ec0674c8..72af3027851 100644 --- a/core/src/main/java/google/registry/model/poll/PollMessageExternalKeyConverter.java +++ b/core/src/main/java/google/registry/model/poll/PollMessageExternalKeyConverter.java @@ -16,6 +16,8 @@ import com.google.common.base.Splitter; import google.registry.persistence.VKey; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; import java.util.List; /** @@ -41,7 +43,10 @@ public static class PollMessageExternalKeyParseException extends RuntimeExceptio /** Returns an external poll message ID for the given poll message. */ public static String makePollMessageExternalId(PollMessage pollMessage) { - return String.format("%d-%d", pollMessage.getId(), pollMessage.getEventTime().getYear()); + return String.format( + "%d-%d", + pollMessage.getId(), + ZonedDateTime.ofInstant(pollMessage.getEventTime(), ZoneOffset.UTC).getYear()); } /** 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 f7583e05428..ef5ecbf7918 100644 --- a/core/src/main/java/google/registry/model/registrar/Registrar.java +++ b/core/src/main/java/google/registry/model/registrar/Registrar.java @@ -471,7 +471,7 @@ public ImmutableSortedMap getBillingAccountMap() { @Deprecated @SuppressWarnings("InlineMeSuggester") public DateTime getLastUpdateTime() { - return getUpdateTimestamp().getTimestampDateTime(); + return toDateTime(getUpdateTimestamp().getTimestamp()); } public Instant getLastUpdateTimeInstant() { diff --git a/core/src/main/java/google/registry/model/reporting/DomainTransactionRecord.java b/core/src/main/java/google/registry/model/reporting/DomainTransactionRecord.java index 279872fc12b..f13cc87f717 100644 --- a/core/src/main/java/google/registry/model/reporting/DomainTransactionRecord.java +++ b/core/src/main/java/google/registry/model/reporting/DomainTransactionRecord.java @@ -15,8 +15,6 @@ package google.registry.model.reporting; import static com.google.common.base.Preconditions.checkArgument; -import static google.registry.util.DateTimeUtils.toDateTime; -import static google.registry.util.DateTimeUtils.toInstant; import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; import com.google.common.collect.ImmutableSet; @@ -34,7 +32,6 @@ import jakarta.persistence.Index; import jakarta.persistence.Table; import java.time.Instant; -import org.joda.time.DateTime; /** * The record of the mutations which contribute to transaction reporting. @@ -204,16 +201,7 @@ public int getReportAmount() { return reportAmount; } - /** - * @deprecated Use {@link #getReportingTimeInstant()} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getReportingTime() { - return toDateTime(reportingTime); - } - - public Instant getReportingTimeInstant() { + public Instant getReportingTime() { return reportingTime; } @@ -232,19 +220,6 @@ public static DomainTransactionRecord create( .build(); } - /** - * @deprecated Use {@link #create(String, Instant, TransactionReportField, int)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public static DomainTransactionRecord create( - String tld, - DateTime reportingTime, - TransactionReportField transactionReportField, - int reportAmount) { - return create(tld, toInstant(reportingTime), transactionReportField, reportAmount); - } - @Override public Builder asBuilder() { return new Builder(clone(this)); @@ -272,15 +247,6 @@ public Builder setReportingTime(Instant reportingTime) { return this; } - /** - * @deprecated Use {@link #setReportingTime(Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public Builder setReportingTime(DateTime reportingTime) { - return setReportingTime(toInstant(reportingTime)); - } - public Builder setReportField(TransactionReportField reportField) { checkArgumentNotNull(reportField, "reportField must not be null"); getInstance().reportField = reportField; diff --git a/core/src/main/java/google/registry/model/reporting/HistoryEntry.java b/core/src/main/java/google/registry/model/reporting/HistoryEntry.java index c5a21b13bde..b915d65072c 100644 --- a/core/src/main/java/google/registry/model/reporting/HistoryEntry.java +++ b/core/src/main/java/google/registry/model/reporting/HistoryEntry.java @@ -15,8 +15,6 @@ package google.registry.model.reporting; import static com.google.common.base.Preconditions.checkArgument; -import static google.registry.util.DateTimeUtils.toDateTime; -import static google.registry.util.DateTimeUtils.toInstant; import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; import google.registry.batch.ExpandBillingRecurrencesAction; @@ -47,7 +45,6 @@ import java.util.Optional; import javax.annotation.Nullable; import org.apache.commons.lang3.BooleanUtils; -import org.joda.time.DateTime; /** * A record of an EPP command that mutated a resource. @@ -200,19 +197,8 @@ public byte[] getXmlBytes() { return xmlBytes == null ? null : xmlBytes.clone(); } - /** - * Returns the time the command occurred. - * - * @deprecated Use {@link #getModificationTimeInstant()} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getModificationTime() { - return toDateTime(modificationTime); - } - /** Returns the time the command occurred. */ - public Instant getModificationTimeInstant() { + public Instant getModificationTime() { return modificationTime; } @@ -327,15 +313,6 @@ public B setModificationTime(Instant modificationTime) { return thisCastToDerived(); } - /** - * @deprecated Use {@link #setModificationTime(Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public B setModificationTime(DateTime modificationTime) { - return setModificationTime(toInstant(modificationTime)); - } - public B setRegistrarId(String registrarId) { getInstance().clientId = registrarId; return thisCastToDerived(); diff --git a/core/src/main/java/google/registry/model/tld/Tld.java b/core/src/main/java/google/registry/model/tld/Tld.java index 35c6ecd58cb..615c66199da 100644 --- a/core/src/main/java/google/registry/model/tld/Tld.java +++ b/core/src/main/java/google/registry/model/tld/Tld.java @@ -652,9 +652,9 @@ public Instant getCreationTime() { /** * @deprecated Use {@link #getCreationTime()} */ - @JsonIgnore @Deprecated @SuppressWarnings("InlineMeSuggester") + @JsonIgnore public DateTime getCreationDateTime() { return toDateTime(creationTime.getTimestamp()); } diff --git a/core/src/main/java/google/registry/model/transfer/BaseTransferObject.java b/core/src/main/java/google/registry/model/transfer/BaseTransferObject.java index 49516432983..5118093b38f 100644 --- a/core/src/main/java/google/registry/model/transfer/BaseTransferObject.java +++ b/core/src/main/java/google/registry/model/transfer/BaseTransferObject.java @@ -14,8 +14,6 @@ package google.registry.model.transfer; -import static google.registry.util.DateTimeUtils.toDateTime; -import static google.registry.util.DateTimeUtils.toInstant; import google.registry.model.Buildable.GenericBuilder; import google.registry.model.ImmutableObject; @@ -29,7 +27,6 @@ import jakarta.xml.bind.annotation.XmlTransient; import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import java.time.Instant; -import org.joda.time.DateTime; /** Fields common to {@link DomainTransferData} and {@link TransferResponse}. */ @XmlTransient @@ -73,16 +70,7 @@ public String getGainingRegistrarId() { return gainingClientId; } - /** - * @deprecated Use {@link #getTransferRequestTimeInstant()} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getTransferRequestTime() { - return toDateTime(transferRequestTime); - } - - public Instant getTransferRequestTimeInstant() { + public Instant getTransferRequestTime() { return transferRequestTime; } @@ -90,15 +78,6 @@ public String getLosingRegistrarId() { return losingClientId; } - /** - * @deprecated Use {@link #getPendingTransferExpirationTime()} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getPendingTransferExpirationDateTime() { - return toDateTime(pendingTransferExpirationTime); - } - public Instant getPendingTransferExpirationTime() { return pendingTransferExpirationTime; } @@ -133,15 +112,6 @@ public B setTransferRequestTime(Instant transferRequestTime) { return thisCastToDerived(); } - /** - * @deprecated Use {@link #setTransferRequestTime(Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public B setTransferRequestTime(DateTime transferRequestTime) { - return setTransferRequestTime(toInstant(transferRequestTime)); - } - /** Set the losing registrar for a pending transfer on this resource. */ public B setLosingRegistrarId(String losingRegistrarId) { getInstance().losingClientId = losingRegistrarId; @@ -154,15 +124,6 @@ public B setPendingTransferExpirationTime(Instant pendingTransferExpirationTime) return thisCastToDerived(); } - /** - * @deprecated Use {@link #setPendingTransferExpirationTime(Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public B setPendingTransferExpirationTime(DateTime pendingTransferExpirationTime) { - return setPendingTransferExpirationTime(toInstant(pendingTransferExpirationTime)); - } - @Override public T build() { return super.build(); diff --git a/core/src/main/java/google/registry/model/transfer/DomainTransferData.java b/core/src/main/java/google/registry/model/transfer/DomainTransferData.java index d1801501d77..ce19d88c04f 100644 --- a/core/src/main/java/google/registry/model/transfer/DomainTransferData.java +++ b/core/src/main/java/google/registry/model/transfer/DomainTransferData.java @@ -18,8 +18,6 @@ import static com.google.common.collect.ImmutableList.toImmutableList; import static google.registry.util.CollectionUtils.isNullOrEmpty; import static google.registry.util.CollectionUtils.nullToEmpty; -import static google.registry.util.DateTimeUtils.toDateTime; -import static google.registry.util.DateTimeUtils.toInstant; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; @@ -46,7 +44,6 @@ import java.time.Instant; import java.util.Set; import javax.annotation.Nullable; -import org.joda.time.DateTime; /** Transfer data for domain. */ @Embeddable @@ -170,13 +167,6 @@ public Trid getTransferRequestTrid() { return transferRequestTrid; } - @Nullable - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getTransferredRegistrationExpirationDateTime() { - return toDateTime(transferredRegistrationExpirationTime); - } - @Nullable public Instant getTransferredRegistrationExpirationTime() { return transferredRegistrationExpirationTime; @@ -345,13 +335,6 @@ public Builder setTransferredRegistrationExpirationTime( * @deprecated Use {@link #setTransferredRegistrationExpirationTime(Instant)} */ @Deprecated - @SuppressWarnings("InlineMeSuggester") - public Builder setTransferredRegistrationExpirationTime( - DateTime transferredRegistrationExpirationTime) { - return setTransferredRegistrationExpirationTime( - toInstant(transferredRegistrationExpirationTime)); - } - public Builder setServerApproveBillingEvent(VKey serverApproveBillingEvent) { getInstance().serverApproveBillingEvent = serverApproveBillingEvent; return this; diff --git a/core/src/main/java/google/registry/model/transfer/TransferResponse.java b/core/src/main/java/google/registry/model/transfer/TransferResponse.java index e3a8f46b96f..57bd5ede7dd 100644 --- a/core/src/main/java/google/registry/model/transfer/TransferResponse.java +++ b/core/src/main/java/google/registry/model/transfer/TransferResponse.java @@ -14,8 +14,6 @@ package google.registry.model.transfer; -import static google.registry.util.DateTimeUtils.toDateTime; -import static google.registry.util.DateTimeUtils.toInstant; import google.registry.model.EppResource; import google.registry.model.eppoutput.EppResponse.ResponseData; @@ -27,7 +25,6 @@ import jakarta.xml.bind.annotation.XmlType; import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import java.time.Instant; -import org.joda.time.DateTime; /** * A response to a transfer command on a {@link EppResource}. This base class contains fields that @@ -67,15 +64,6 @@ public String getDomainName() { @XmlJavaTypeAdapter(UtcInstantAdapter.class) Instant extendedRegistrationExpirationTime; - /** - * @deprecated Use {@link #getExtendedRegistrationExpirationTime()} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getExtendedRegistrationExpirationDateTime() { - return toDateTime(extendedRegistrationExpirationTime); - } - public Instant getExtendedRegistrationExpirationTime() { return extendedRegistrationExpirationTime; } @@ -94,16 +82,6 @@ public Builder setExtendedRegistrationExpirationTime( getInstance().extendedRegistrationExpirationTime = extendedRegistrationExpirationTime; return this; } - - /** - * @deprecated Use {@link #setExtendedRegistrationExpirationTime(Instant)} - */ - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public Builder setExtendedRegistrationExpirationTime( - DateTime extendedRegistrationExpirationTime) { - return setExtendedRegistrationExpirationTime(toInstant(extendedRegistrationExpirationTime)); - } } } diff --git a/core/src/main/java/google/registry/rdap/RdapJsonFormatter.java b/core/src/main/java/google/registry/rdap/RdapJsonFormatter.java index ab0d1335e5d..2014924d0bc 100644 --- a/core/src/main/java/google/registry/rdap/RdapJsonFormatter.java +++ b/core/src/main/java/google/registry/rdap/RdapJsonFormatter.java @@ -319,7 +319,7 @@ RdapDomain createRdapDomain(Domain domain, OutputDataType outputDataType) { .setEventAction(EventAction.REGISTRATION) .setEventActor( Optional.ofNullable(domain.getCreationRegistrarId()).orElse("(none)")) - .setEventDate(domain.getCreationTimeInstant()) + .setEventDate(domain.getCreationTime()) .build(), Event.builder() .setEventAction(EventAction.EXPIRATION) @@ -339,7 +339,7 @@ RdapDomain createRdapDomain(Domain domain, OutputDataType outputDataType) { // (i.e. without updating lastEppUpdateTime), that can only happen for domains that have already // been modified in some way. As a result, we can ignore those cases here. if (domain.getLastEppUpdateTime() != null - && domain.getLastEppUpdateTime().isAfter(domain.getCreationTimeInstant())) { + && domain.getLastEppUpdateTime().isAfter(domain.getCreationTime())) { // Creates an RDAP event object as defined by RFC 9083 builder .eventsBuilder() @@ -759,7 +759,7 @@ private static ImmutableMap getLastHistory lastEntryOfType.put( rdapEventAction, new HistoryTimeAndRegistrar( - historyEntry.getModificationTimeInstant(), + historyEntry.getModificationTime(), historyEntry.getRegistrarId())); } })); diff --git a/core/src/main/java/google/registry/rde/DomainToXjcConverter.java b/core/src/main/java/google/registry/rde/DomainToXjcConverter.java index de95f343a6d..45fe1c776ba 100644 --- a/core/src/main/java/google/registry/rde/DomainToXjcConverter.java +++ b/core/src/main/java/google/registry/rde/DomainToXjcConverter.java @@ -14,6 +14,7 @@ package google.registry.rde; +import static google.registry.util.DateTimeUtils.toDateTime; import com.google.common.base.Strings; import com.google.common.collect.ImmutableSet; @@ -88,7 +89,7 @@ static XjcRdeDomain convertDomain(Domain model, RdeMode mode) { // o An OPTIONAL element that contains the date and time of // the domain name object creation. This element MUST be present if // the domain name has been allocated. - bean.setCrDate(model.getCreationTime()); + bean.setCrDate(toDateTime(model.getCreationTime())); // o An OPTIONAL element that contains the date and time // identifying the end (expiration) of the domain name object's @@ -100,7 +101,7 @@ static XjcRdeDomain convertDomain(Domain model, RdeMode mode) { // the most recent domain-name-object modification. This element // MUST NOT be present if the domain name object has never been // modified. - bean.setUpDate(model.getLastEppUpdateDateTime()); + bean.setUpDate(toDateTime(model.getLastEppUpdateTime())); // o An OPTIONAL element that contains the identifier of the // registrar that last updated the domain name object. This element @@ -225,9 +226,9 @@ private static XjcRdeDomainTransferDataType convertTransferData(DomainTransferDa XjcEppcomTrStatusType.fromValue(model.getTransferStatus().getXmlName())); bean.setReRr(RdeUtils.makeXjcRdeRrType(model.getGainingRegistrarId())); bean.setAcRr(RdeUtils.makeXjcRdeRrType(model.getLosingRegistrarId())); - bean.setReDate(model.getTransferRequestTime()); - bean.setAcDate(model.getPendingTransferExpirationDateTime()); - bean.setExDate(model.getTransferredRegistrationExpirationDateTime()); + bean.setReDate(toDateTime(model.getTransferRequestTime())); + bean.setAcDate(toDateTime(model.getPendingTransferExpirationTime())); + bean.setExDate(toDateTime(model.getTransferredRegistrationExpirationTime())); return bean; } diff --git a/core/src/main/java/google/registry/rde/HostToXjcConverter.java b/core/src/main/java/google/registry/rde/HostToXjcConverter.java index c674e9358e0..d5b7ced4934 100644 --- a/core/src/main/java/google/registry/rde/HostToXjcConverter.java +++ b/core/src/main/java/google/registry/rde/HostToXjcConverter.java @@ -62,7 +62,9 @@ static XjcRdeHost convertSubordinateHost(Host model, Domain superordinateDomain) /** Converts {@link Host} to {@link XjcRdeHost}. */ static XjcRdeHost convertExternalHost(Host model) { return convertHostCommon( - model, model.getPersistedCurrentSponsorRegistrarId(), model.getLastTransferTime()); + model, + model.getPersistedCurrentSponsorRegistrarId(), + toDateTime(model.getLastTransferTime())); } private static XjcRdeHost convertHostCommon( @@ -70,8 +72,8 @@ private static XjcRdeHost convertHostCommon( XjcRdeHost bean = new XjcRdeHost(); bean.setName(model.getHostName()); bean.setRoid(model.getRepoId()); - bean.setCrDate(model.getCreationTime()); - bean.setUpDate(model.getLastEppUpdateDateTime()); + bean.setCrDate(toDateTime(model.getCreationTime())); + bean.setUpDate(toDateTime(model.getLastEppUpdateTime())); bean.setCrRr(RdeAdapter.convertRr(model.getCreationRegistrarId(), null)); bean.setUpRr(RdeAdapter.convertRr(model.getLastEppUpdateRegistrarId(), null)); bean.setCrRr(RdeAdapter.convertRr(model.getCreationRegistrarId(), null)); diff --git a/core/src/main/java/google/registry/tmch/LordnTaskUtils.java b/core/src/main/java/google/registry/tmch/LordnTaskUtils.java index b315b1def5e..b605b7282b7 100644 --- a/core/src/main/java/google/registry/tmch/LordnTaskUtils.java +++ b/core/src/main/java/google/registry/tmch/LordnTaskUtils.java @@ -15,6 +15,8 @@ package google.registry.tmch; import static com.google.common.base.Preconditions.checkState; +import static google.registry.util.DateTimeUtils.ISO_8601_FORMATTER; +import static google.registry.util.DateTimeUtils.toInstant; import com.google.common.base.Joiner; import google.registry.model.domain.Domain; @@ -44,7 +46,7 @@ public static String getCsvLineForSunriseDomain(Domain domain) { domain.getDomainName(), domain.getSmdId(), getIanaIdentifier(domain.getCreationRegistrarId()), - domain.getCreationTime()); // Used as creation time. + ISO_8601_FORMATTER.format(domain.getCreationTime())); // Used as creation time. } /** Returns the corresponding CSV LORDN line for a claims domain. */ @@ -55,8 +57,8 @@ public static String getCsvLineForClaimsDomain(Domain domain) { domain.getDomainName(), domain.getLaunchNotice().getNoticeId().getTcnId(), getIanaIdentifier(domain.getCreationRegistrarId()), - domain.getCreationTime(), // Used as creation time. - domain.getLaunchNotice().getAcceptedTime()); + ISO_8601_FORMATTER.format(domain.getCreationTime()), // Used as creation time. + ISO_8601_FORMATTER.format(toInstant(domain.getLaunchNotice().getAcceptedTime()))); } /** Retrieves the IANA identifier for a registrar by its ID. */ diff --git a/core/src/main/java/google/registry/tmch/NordnUploadAction.java b/core/src/main/java/google/registry/tmch/NordnUploadAction.java index 74ef7da8d2b..3c4390b4cf9 100644 --- a/core/src/main/java/google/registry/tmch/NordnUploadAction.java +++ b/core/src/main/java/google/registry/tmch/NordnUploadAction.java @@ -24,6 +24,7 @@ import static google.registry.tmch.LordnTaskUtils.COLUMNS_SUNRISE; import static google.registry.tmch.LordnTaskUtils.getCsvLineForClaimsDomain; import static google.registry.tmch.LordnTaskUtils.getCsvLineForSunriseDomain; +import static google.registry.util.DateTimeUtils.ISO_8601_FORMATTER; import static jakarta.servlet.http.HttpServletResponse.SC_ACCEPTED; import static java.nio.charset.StandardCharsets.US_ASCII; @@ -170,7 +171,9 @@ public void run() { String columns = phase.equals(PARAM_LORDN_PHASE_SUNRISE) ? COLUMNS_SUNRISE : COLUMNS_CLAIMS; String header = - String.format("1,%s,%d\n%s\n", clock.nowUtc(), domains.size(), columns); + String.format( + "1,%s,%d\n%s\n", + ISO_8601_FORMATTER.format(clock.now()), domains.size(), columns); try { URL url = uploadCsvToLordn(String.format("/LORDN/%s/%s", tld, phase), header + csv); diff --git a/core/src/main/java/google/registry/tools/AckPollMessagesCommand.java b/core/src/main/java/google/registry/tools/AckPollMessagesCommand.java index bb6362f47c5..e3384756352 100644 --- a/core/src/main/java/google/registry/tools/AckPollMessagesCommand.java +++ b/core/src/main/java/google/registry/tools/AckPollMessagesCommand.java @@ -83,7 +83,7 @@ public void run() { private void ackPollMessagesSql() { tm().transact( () -> { - QueryComposer query = createPollMessageQuery(clientId, clock.nowUtc()); + QueryComposer query = createPollMessageQuery(clientId, clock.now()); if (!isNullOrEmpty(message)) { query = query.where("msg", LIKE, "%" + message + "%"); } diff --git a/core/src/main/java/google/registry/tools/DomainLockUtils.java b/core/src/main/java/google/registry/tools/DomainLockUtils.java index 26194e8fce4..01d513d0470 100644 --- a/core/src/main/java/google/registry/tools/DomainLockUtils.java +++ b/core/src/main/java/google/registry/tools/DomainLockUtils.java @@ -18,6 +18,7 @@ import static google.registry.batch.AsyncTaskEnqueuer.QUEUE_ASYNC_ACTIONS; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.tools.LockOrUnlockDomainCommand.REGISTRY_LOCK_STATUSES; +import static google.registry.util.DateTimeUtils.toInstant; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; @@ -137,7 +138,7 @@ public RegistryLock administrativelyApplyLock( RegistryLock newLock = RegistryLockDao.save( createLockBuilder(domainName, registrarId, registryLockEmail, isAdmin) - .setLockCompletionTime(now) + .setLockCompletionTime(toInstant(now)) .build()); applyLockStatuses(newLock, now, isAdmin); setAsRelock(newLock); @@ -159,7 +160,7 @@ public RegistryLock administrativelyApplyUnlock( RegistryLock result = RegistryLockDao.save( createUnlockBuilder(domainName, registrarId, isAdmin, relockDuration) - .setUnlockCompletionTime(now) + .setUnlockCompletionTime(toInstant(now)) .build()); removeLockStatuses(result, isAdmin, now); return result; @@ -206,12 +207,13 @@ public void enqueueDomainRelock(Duration countdown, long lockRevisionId, int pre private RegistryLock verifyAndApplyLock(RegistryLock lock, boolean isAdmin) { DateTime now = tm().getTransactionTime(); checkArgument( - !lock.isLockRequestExpired(now), "The pending lock has expired; please try again"); + !lock.isLockRequestExpired(toInstant(now)), + "The pending lock has expired; please try again"); checkArgument(!lock.isSuperuser() || isAdmin, "Non-admin user cannot complete admin lock"); RegistryLock newLock = - RegistryLockDao.save(lock.asBuilder().setLockCompletionTime(now).build()); + RegistryLockDao.save(lock.asBuilder().setLockCompletionTime(toInstant(now)).build()); setAsRelock(newLock); applyLockStatuses(newLock, now, isAdmin); return newLock; @@ -220,12 +222,13 @@ private RegistryLock verifyAndApplyLock(RegistryLock lock, boolean isAdmin) { private RegistryLock verifyAndApplyUnlock(RegistryLock lock, boolean isAdmin) { DateTime now = tm().getTransactionTime(); checkArgument( - !lock.isUnlockRequestExpired(now), "The pending unlock has expired; please try again"); + !lock.isUnlockRequestExpired(toInstant(now)), + "The pending unlock has expired; please try again"); checkArgument(isAdmin || !lock.isSuperuser(), "Non-admin user cannot complete admin unlock"); RegistryLock newLock = - RegistryLockDao.save(lock.asBuilder().setUnlockCompletionTime(now).build()); + RegistryLockDao.save(lock.asBuilder().setUnlockCompletionTime(toInstant(now)).build()); removeLockStatuses(newLock, isAdmin, now); return newLock; } @@ -246,7 +249,7 @@ private RegistryLock.Builder createLockBuilder( .ifPresent( previousLock -> checkArgument( - previousLock.isLockRequestExpired(now) + previousLock.isLockRequestExpired(toInstant(now)) || previousLock.getUnlockCompletionTime().isPresent() || isAdmin, "A pending or completed lock action already exists for %s", @@ -281,7 +284,7 @@ private RegistryLock.Builder createUnlockBuilder( new RegistryLock.Builder() .setRepoId(domain.getRepoId()) .setDomainName(domainName) - .setLockCompletionTime(now) + .setLockCompletionTime(toInstant(now)) .setRegistrarId(registrarId)); } else { RegistryLock lock = @@ -292,7 +295,7 @@ private RegistryLock.Builder createUnlockBuilder( checkArgument( lock.isLocked(), "Lock object for domain %s is not currently locked", domainName); checkArgument( - lock.getUnlockRequestTime().isEmpty() || lock.isUnlockRequestExpired(now), + lock.getUnlockRequestTime().isEmpty() || lock.isUnlockRequestExpired(toInstant(now)), "A pending unlock action already exists for %s", domainName); checkArgument( @@ -307,7 +310,7 @@ private RegistryLock.Builder createUnlockBuilder( return newLockBuilder .setVerificationCode(stringGenerator.createString(VERIFICATION_CODE_LENGTH)) .isSuperuser(isAdmin) - .setUnlockRequestTime(now) + .setUnlockRequestTime(toInstant(now)) .setRegistrarId(registrarId); } @@ -384,7 +387,7 @@ private static void saveEntities(Domain domain, RegistryLock lock, DateTime now, .setBySuperuser(lock.isSuperuser()) .setRequestedByRegistrar(!lock.isSuperuser()) .setType(HistoryEntry.Type.DOMAIN_UPDATE) - .setModificationTime(now) + .setModificationTime(toInstant(now)) .setDomain(domain) .setReason(reason) .build(); @@ -397,8 +400,8 @@ private static void saveEntities(Domain domain, RegistryLock lock, DateTime now, .setTargetId(domain.getForeignKey()) .setRegistrarId(domain.getCurrentSponsorRegistrarId()) .setCost(Tld.get(domain.getTld()).getRegistryLockOrUnlockBillingCost()) - .setEventTime(now) - .setBillingTime(now) + .setEventTime(toInstant(now)) + .setBillingTime(toInstant(now)) .setDomainHistory(domainHistory) .build(); tm().insert(billingEvent); diff --git a/core/src/main/java/google/registry/tools/EnqueuePollMessageCommand.java b/core/src/main/java/google/registry/tools/EnqueuePollMessageCommand.java index b9c1bc260f4..649691983d4 100644 --- a/core/src/main/java/google/registry/tools/EnqueuePollMessageCommand.java +++ b/core/src/main/java/google/registry/tools/EnqueuePollMessageCommand.java @@ -105,7 +105,7 @@ protected final void init() { .setType(SYNTHETIC) .setBySuperuser(true) .setReason("Manual enqueueing of poll message: " + message) - .setModificationTime(tm().getTransactionTime()) + .setModificationTime(tm().getTxTime()) .setRequestedByRegistrar(false) .setRegistrarId(registryAdminClientId) .build(); diff --git a/core/src/main/java/google/registry/tools/GenerateDnsReportCommand.java b/core/src/main/java/google/registry/tools/GenerateDnsReportCommand.java index 80508f14df0..07d81b3e3e2 100644 --- a/core/src/main/java/google/registry/tools/GenerateDnsReportCommand.java +++ b/core/src/main/java/google/registry/tools/GenerateDnsReportCommand.java @@ -19,6 +19,7 @@ import static google.registry.model.tld.Tlds.assertTldExists; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.util.DateTimeUtils.isBeforeOrAt; +import static google.registry.util.DateTimeUtils.toInstant; import static java.nio.charset.StandardCharsets.US_ASCII; import com.beust.jcommander.Parameter; @@ -80,7 +81,8 @@ String generate() { .list()); for (Domain domain : domains) { // Skip deleted domains and domains that don't get published to DNS. - if (isBeforeOrAt(domain.getDeletionDateTime(), now) || !domain.shouldPublishToDns()) { + if (isBeforeOrAt(domain.getDeletionTime(), toInstant(now)) + || !domain.shouldPublishToDns()) { continue; } write(domain); @@ -89,7 +91,7 @@ String generate() { Iterable nameservers = tm().transact(() -> tm().loadAllOf(Host.class)); for (Host nameserver : nameservers) { // Skip deleted hosts and external hosts. - if (isBeforeOrAt(nameserver.getDeletionDateTime(), now) + if (isBeforeOrAt(nameserver.getDeletionTime(), toInstant(now)) || nameserver.getInetAddresses().isEmpty()) { continue; } diff --git a/core/src/main/java/google/registry/tools/GetHistoryEntriesCommand.java b/core/src/main/java/google/registry/tools/GetHistoryEntriesCommand.java index ebca62facd6..c28d7f6834a 100644 --- a/core/src/main/java/google/registry/tools/GetHistoryEntriesCommand.java +++ b/core/src/main/java/google/registry/tools/GetHistoryEntriesCommand.java @@ -73,7 +73,7 @@ public void run() { System.out.printf( "Client: %s\nTime: %s\nClient TRID: %s\nServer TRID: %s\n%s\n", entry.getRegistrarId(), - entry.getModificationTimeInstant(), + entry.getModificationTime(), entry.getTrid() == null ? null : entry.getTrid().getClientTransactionId().orElse(null), entry.getTrid() == null ? null : entry.getTrid().getServerTransactionId(), entry.getXmlBytes() == null diff --git a/core/src/main/java/google/registry/tools/UnrenewDomainCommand.java b/core/src/main/java/google/registry/tools/UnrenewDomainCommand.java index 6d31dc6e426..68bc5107865 100644 --- a/core/src/main/java/google/registry/tools/UnrenewDomainCommand.java +++ b/core/src/main/java/google/registry/tools/UnrenewDomainCommand.java @@ -23,6 +23,7 @@ import static google.registry.util.DateTimeUtils.START_OF_TIME; import static google.registry.util.DateTimeUtils.isBeforeOrAt; import static google.registry.util.DateTimeUtils.minusYears; +import static google.registry.util.DateTimeUtils.toInstant; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; @@ -187,7 +188,7 @@ private void unrenewDomain(String domainName) { DomainHistory domainHistory = new DomainHistory.Builder() .setDomain(domain) - .setModificationTime(now) + .setModificationTime(toInstant(now)) .setBySuperuser(true) .setType(Type.SYNTHETIC) .setRegistrarId(domain.getCurrentSponsorRegistrarId()) @@ -208,12 +209,12 @@ private void unrenewDomain(String domainName) { // Create a new autorenew billing event and poll message starting at the new expiration time. BillingRecurrence newAutorenewEvent = newAutorenewBillingEvent(domain) - .setEventTime(newExpirationTime) + .setEventTime(toInstant(newExpirationTime)) .setDomainHistory(domainHistory) .build(); PollMessage.Autorenew newAutorenewPollMessage = newAutorenewPollMessage(domain) - .setEventTime(newExpirationTime) + .setEventTime(toInstant(newExpirationTime)) .setHistoryEntry(domainHistory) .build(); // End the old autorenew billing event and poll message now. @@ -224,7 +225,7 @@ private void unrenewDomain(String domainName) { domain .asBuilder() .setRegistrationExpirationTime(newExpirationTime) - .setLastEppUpdateTime(now) + .setLastEppUpdateTime(toInstant(now)) .setLastEppUpdateRegistrarId(domain.getCurrentSponsorRegistrarId()) .setAutorenewBillingEvent(newAutorenewEvent.createVKey()) .setAutorenewPollMessage(newAutorenewPollMessage.createVKey()) diff --git a/core/src/main/java/google/registry/tools/UpdateRecurrenceCommand.java b/core/src/main/java/google/registry/tools/UpdateRecurrenceCommand.java index 59d599187f2..c0f78222343 100644 --- a/core/src/main/java/google/registry/tools/UpdateRecurrenceCommand.java +++ b/core/src/main/java/google/registry/tools/UpdateRecurrenceCommand.java @@ -190,7 +190,7 @@ private ImmutableMap loadDomainsAndRecurrences() { endTime)); BillingRecurrence billingRecurrence = tm().loadByKey(domain.getAutorenewBillingEvent()); checkArgument( - billingRecurrence.getRecurrenceEndTimeInstant().equals(END_INSTANT), + billingRecurrence.getRecurrenceEndTime().equals(END_INSTANT), "Domain %s's recurrence's end date is not END_INSTANT", domainName); result.put(domain, billingRecurrence); diff --git a/core/src/main/java/google/registry/tools/javascrap/RecreateBillingRecurrencesCommand.java b/core/src/main/java/google/registry/tools/javascrap/RecreateBillingRecurrencesCommand.java index 7bb2db5b252..f231442104d 100644 --- a/core/src/main/java/google/registry/tools/javascrap/RecreateBillingRecurrencesCommand.java +++ b/core/src/main/java/google/registry/tools/javascrap/RecreateBillingRecurrencesCommand.java @@ -96,9 +96,9 @@ private ImmutableList convertRecurrencesWithoutSaving( .map( existingRecurrence -> { TimeOfYear timeOfYear = existingRecurrence.getRecurrenceTimeOfYear(); - Instant newLastExpansion = timeOfYear.getLastInstanceBeforeOrAtInstant(now); + Instant newLastExpansion = timeOfYear.getLastInstanceBeforeOrAt(now); // event time should be the next date of billing in the future - Instant eventTime = timeOfYear.getNextInstanceAtOrAfterInstant(now); + Instant eventTime = timeOfYear.getNextInstanceAtOrAfter(now); return existingRecurrence .asBuilder() .setRecurrenceEndTime(END_INSTANT) @@ -123,10 +123,10 @@ private ImmutableList loadRecurrences() { "Domain %s does not exist or has been deleted", domainName))); BillingRecurrence billingRecurrence = tm().loadByKey(domain.getAutorenewBillingEvent()); checkArgument( - !billingRecurrence.getRecurrenceEndTimeInstant().equals(END_INSTANT), - "Domain %s's recurrence's end date is already END_OF_TIME", + !billingRecurrence.getRecurrenceEndTime().equals(END_INSTANT), + "Domain %s's recurrence's end date is already END_INSTANT", domainName); - // Double-check that there are no non-linked BillingRecurrences that have an END_OF_TIME end. + // Double-check that there are no non-linked BillingRecurrences that have an END_INSTANT end. // If this is the case, something has been mis-linked. ImmutableList allRecurrencesForDomain = tm().createQueryComposer(BillingRecurrence.class) @@ -135,9 +135,9 @@ private ImmutableList loadRecurrences() { allRecurrencesForDomain.forEach( recurrence -> checkArgument( - !recurrence.getRecurrenceEndTimeInstant().equals(END_INSTANT), + !recurrence.getRecurrenceEndTime().equals(END_INSTANT), "There exists a recurrence with id %s for domain %s with an end date of" - + " END_OF_TIME", + + " END_INSTANT", recurrence.getId(), domainName)); diff --git a/core/src/main/java/google/registry/tools/server/GenerateZoneFilesAction.java b/core/src/main/java/google/registry/tools/server/GenerateZoneFilesAction.java index 878825b4b6b..1d3c95ed6cb 100644 --- a/core/src/main/java/google/registry/tools/server/GenerateZoneFilesAction.java +++ b/core/src/main/java/google/registry/tools/server/GenerateZoneFilesAction.java @@ -19,6 +19,7 @@ import static google.registry.model.EppResourceUtils.loadAtPointInTime; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.request.Action.Method.POST; +import static google.registry.util.DateTimeUtils.minusMinutes; import static java.nio.charset.StandardCharsets.UTF_8; import com.google.cloud.storage.BlobId; @@ -123,11 +124,10 @@ public Map handleJsonRequest(Map json) { // We can only reliably call loadAtPointInTime at times that are UTC midnight and > // databaseRetention ago in the past. Instant now = clock.now(); - if (exportTime.isAfter(now.minus(java.time.Duration.ofMinutes(2)))) { + if (exportTime.isAfter(minusMinutes(now, 2))) { throw new BadRequestException("Invalid export time: must be > 2 minutes ago"); } - if (exportTime.isBefore( - now.minus(java.time.Duration.ofMillis(databaseRetention.getMillis())))) { + if (exportTime.isBefore(now.minusMillis(databaseRetention.getMillis()))) { throw new BadRequestException( String.format( "Invalid export time: must be < %d days ago", databaseRetention.getStandardDays())); diff --git a/core/src/main/java/google/registry/ui/server/console/ConsoleDomainListAction.java b/core/src/main/java/google/registry/ui/server/console/ConsoleDomainListAction.java index 6f74427cc3f..319566e7d5d 100644 --- a/core/src/main/java/google/registry/ui/server/console/ConsoleDomainListAction.java +++ b/core/src/main/java/google/registry/ui/server/console/ConsoleDomainListAction.java @@ -94,7 +94,7 @@ private void runInTransaction() { // We have to use a constant checkpoint time in order to have stable pagination, since domains // can be constantly created or deleted DateTime checkpoint = checkpointTime.orElseGet(tm()::getTransactionTime); - CreateAutoTimestamp checkpointTimestamp = CreateAutoTimestamp.create(checkpoint); + CreateAutoTimestamp checkpointTimestamp = CreateAutoTimestamp.create(toInstant(checkpoint)); // Don't compute the number of total results over and over if we don't need to long actualTotalResults = totalResults.orElseGet( diff --git a/core/src/main/java/google/registry/ui/server/console/ConsoleRegistryLockAction.java b/core/src/main/java/google/registry/ui/server/console/ConsoleRegistryLockAction.java index c50b6565a0d..f165972df5d 100644 --- a/core/src/main/java/google/registry/ui/server/console/ConsoleRegistryLockAction.java +++ b/core/src/main/java/google/registry/ui/server/console/ConsoleRegistryLockAction.java @@ -163,7 +163,7 @@ protected void postHandler(User user) { domainName, registrarId, isAdmin, - relockDurationMillis.map(Duration::new)); + relockDurationMillis.map(Duration::millis)); sendVerificationEmail(registryLock, registryLockEmail, isLock); }); response.setStatus(SC_OK); @@ -194,7 +194,7 @@ private ImmutableList getLockedDomains() { return tm().transact( () -> RegistryLockDao.getLocksByRegistrarId(registrarId).stream() - .filter(lock -> !lock.isLockRequestExpired(tm().getTransactionTime())) + .filter(lock -> !lock.isLockRequestExpired(tm().getTxTime())) .collect(toImmutableList())); } diff --git a/core/src/test/java/google/registry/batch/CheckBulkComplianceActionTest.java b/core/src/test/java/google/registry/batch/CheckBulkComplianceActionTest.java index c7b8417008f..0f763e8dc89 100644 --- a/core/src/test/java/google/registry/batch/CheckBulkComplianceActionTest.java +++ b/core/src/test/java/google/registry/batch/CheckBulkComplianceActionTest.java @@ -106,7 +106,7 @@ void beforeEach() throws Exception { new AllocationToken.Builder() .setToken("abc123") .setTokenType(TokenType.BULK_PRICING) - .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) + .setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) @@ -200,7 +200,7 @@ void testSuccess_multipleBulkPricingPackagesOverCreateLimit() { new AllocationToken.Builder() .setToken("token") .setTokenType(TokenType.BULK_PRICING) - .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) + .setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) @@ -258,7 +258,7 @@ void testSuccess_onlyChecksCurrentBillingYear() { new AllocationToken.Builder() .setToken("token") .setTokenType(TokenType.BULK_PRICING) - .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) + .setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) @@ -334,7 +334,7 @@ void testSuccess_oneBulkPricingPackageOverActiveDomainsLimit() { new AllocationToken.Builder() .setToken("token") .setTokenType(TokenType.BULK_PRICING) - .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) + .setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) @@ -401,7 +401,7 @@ void testSuccess_multipleBulkPricingPackagesOverActiveDomainsLimit() { new AllocationToken.Builder() .setToken("token") .setTokenType(TokenType.BULK_PRICING) - .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) + .setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) diff --git a/core/src/test/java/google/registry/batch/DeleteExpiredDomainsActionTest.java b/core/src/test/java/google/registry/batch/DeleteExpiredDomainsActionTest.java index 00c6375c540..869a238caf5 100644 --- a/core/src/test/java/google/registry/batch/DeleteExpiredDomainsActionTest.java +++ b/core/src/test/java/google/registry/batch/DeleteExpiredDomainsActionTest.java @@ -23,8 +23,11 @@ import static google.registry.testing.DatabaseHelper.loadByEntity; import static google.registry.testing.DatabaseHelper.persistActiveDomain; import static google.registry.testing.DatabaseHelper.persistResource; +import static google.registry.util.DateTimeUtils.END_INSTANT; import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.DateTimeUtils.plusDays; +import static google.registry.util.DateTimeUtils.plusYears; +import static google.registry.util.DateTimeUtils.toInstant; import com.google.common.collect.ImmutableSet; import google.registry.flows.DaggerEppTestComponent; @@ -87,7 +90,7 @@ void test_deletesOnlyExpiredDomain() { DatabaseHelper.newDomain("bar.tld") .asBuilder() .setAutorenewEndTime(Optional.of(clock.nowUtc().minusDays(10))) - .setDeletionTime(clock.nowUtc().plusDays(17)) + .setDeletionTime(plusDays(clock.now(), 17)) .build()); // A non-autorenewing domain that hasn't reached its expiration time and shouldn't be touched. @@ -168,7 +171,7 @@ private Domain persistNonAutorenewingDomain(String domainName) { new DomainHistory.Builder() .setType(DOMAIN_CREATE) .setDomain(pendingExpirationDomain) - .setModificationTime(clock.nowUtc().minusMonths(9)) + .setModificationTime(toInstant(clock.nowUtc().minusMonths(9))) .setRegistrarId(pendingExpirationDomain.getCreationRegistrarId()) .build()); BillingRecurrence autorenewBillingEvent = @@ -193,8 +196,8 @@ private BillingRecurrence.Builder createAutorenewBillingEvent(DomainHistory crea .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId("fizz.tld") .setRegistrarId("TheRegistrar") - .setEventTime(clock.nowUtc().plusYears(1)) - .setRecurrenceEndTime(END_OF_TIME) + .setEventTime(plusYears(clock.now(), 1)) + .setRecurrenceEndTime(END_INSTANT) .setDomainHistory(createHistoryEntry); } @@ -203,7 +206,7 @@ private PollMessage.Autorenew.Builder createAutorenewPollMessage( return new PollMessage.Autorenew.Builder() .setTargetId("fizz.tld") .setRegistrarId("TheRegistrar") - .setEventTime(clock.nowUtc().plusYears(1)) + .setEventTime(plusYears(clock.now(), 1)) .setAutorenewEndTime(END_OF_TIME) .setHistoryEntry(createHistoryEntry); } diff --git a/core/src/test/java/google/registry/batch/DeleteProberDataActionTest.java b/core/src/test/java/google/registry/batch/DeleteProberDataActionTest.java index 20d5de91d36..f6380d91f97 100644 --- a/core/src/test/java/google/registry/batch/DeleteProberDataActionTest.java +++ b/core/src/test/java/google/registry/batch/DeleteProberDataActionTest.java @@ -28,6 +28,7 @@ import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.util.DateTimeUtils.END_INSTANT; import static google.registry.util.DateTimeUtils.minusYears; +import static google.registry.util.DateTimeUtils.toInstant; import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.collect.ImmutableSet; @@ -300,25 +301,25 @@ private static Set persistDomainAndDescendants(String fqdn) { .setDomain(domain) .setType(HistoryEntry.Type.DOMAIN_CREATE) .setRegistrarId("TheRegistrar") - .setModificationTime(DELETION_TIME.minusYears(3)) + .setModificationTime(toInstant(DELETION_TIME.minusYears(3))) .build()); BillingEvent billingEvent = persistResource( new BillingEvent.Builder() .setDomainHistory(historyEntry) - .setBillingTime(DELETION_TIME.plusYears(1)) + .setBillingTime(toInstant(DELETION_TIME.plusYears(1))) .setCost(Money.parse("USD 10")) .setPeriodYears(1) .setReason(Reason.CREATE) .setRegistrarId("TheRegistrar") - .setEventTime(DELETION_TIME) + .setEventTime(toInstant(DELETION_TIME)) .setTargetId(fqdn) .build()); PollMessage.OneTime pollMessage = persistResource( new PollMessage.OneTime.Builder() .setHistoryEntry(historyEntry) - .setEventTime(DELETION_TIME) + .setEventTime(toInstant(DELETION_TIME)) .setRegistrarId("TheRegistrar") .setMsg("Domain registered") .build()); @@ -327,7 +328,7 @@ private static Set persistDomainAndDescendants(String fqdn) { GracePeriod.create( ADD, domain.getRepoId(), - DELETION_TIME.plusDays(5), + toInstant(DELETION_TIME.plusDays(5)), "TheRegistrar", billingEvent.createVKey())); domain = persistResource(domain.asBuilder().addGracePeriod(gracePeriod).build()); diff --git a/core/src/test/java/google/registry/batch/ResaveEntityActionTest.java b/core/src/test/java/google/registry/batch/ResaveEntityActionTest.java index f5541f564f8..09d5532dd9d 100644 --- a/core/src/test/java/google/registry/batch/ResaveEntityActionTest.java +++ b/core/src/test/java/google/registry/batch/ResaveEntityActionTest.java @@ -24,6 +24,7 @@ import static google.registry.testing.DatabaseHelper.persistDomainWithDependentResources; import static google.registry.testing.DatabaseHelper.persistDomainWithPendingTransfer; import static google.registry.testing.DatabaseHelper.persistResource; +import static google.registry.util.DateTimeUtils.plusDays; import static org.joda.time.Duration.standardDays; import static org.mockito.Mockito.verify; @@ -110,14 +111,14 @@ void test_domainPendingDeletion_isResavedAndReenqueued() { persistResource( newDomain .asBuilder() - .setDeletionTime(clock.nowUtc().plusDays(35)) + .setDeletionTime(plusDays(clock.now(), 35)) .setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE)) .setGracePeriods( ImmutableSet.of( GracePeriod.createWithoutBillingEvent( GracePeriodStatus.REDEMPTION, newDomain.getRepoId(), - clock.nowUtc().plusDays(30), + plusDays(clock.now(), 30), "TheRegistrar"))) .build()); clock.advanceBy(standardDays(30)); diff --git a/core/src/test/java/google/registry/beam/billing/BillingEventTest.java b/core/src/test/java/google/registry/beam/billing/BillingEventTest.java index 11dbb88d705..3a27e62b7ce 100644 --- a/core/src/test/java/google/registry/beam/billing/BillingEventTest.java +++ b/core/src/test/java/google/registry/beam/billing/BillingEventTest.java @@ -23,9 +23,8 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; +import java.time.Instant; import org.apache.beam.sdk.coders.NullableCoder; -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -42,8 +41,8 @@ void beforeEach() { private static BillingEvent createBillingEvent(String pONumber, int years) { return BillingEvent.create( 1, - new DateTime(1508835963000L, DateTimeZone.UTC), - new DateTime(1484870383000L, DateTimeZone.UTC), + Instant.ofEpochMilli(1508835963000L), + Instant.ofEpochMilli(1484870383000L), "myRegistrar", "12345-CRRHELLO", pONumber, diff --git a/core/src/test/java/google/registry/beam/billing/ExpandBillingRecurrencesPipelineTest.java b/core/src/test/java/google/registry/beam/billing/ExpandBillingRecurrencesPipelineTest.java index 14f60c07f33..629e421dfa3 100644 --- a/core/src/test/java/google/registry/beam/billing/ExpandBillingRecurrencesPipelineTest.java +++ b/core/src/test/java/google/registry/beam/billing/ExpandBillingRecurrencesPipelineTest.java @@ -154,7 +154,7 @@ void testSuccess_expandSingleEvent() { defaultOneTime(getOnlyAutoRenewHistory()), billingRecurrence .asBuilder() - .setRecurrenceLastExpansion(plusYears(domain.getCreationTimeInstant(), 1)) + .setRecurrenceLastExpansion(plusYears(domain.getCreationTime(), 1)) .build()); // Assert about Cursor. @@ -184,7 +184,7 @@ void testSuccess_expandSingleEvent_deletedDuringGracePeriod() { defaultOneTime(getOnlyAutoRenewHistory()), billingRecurrence .asBuilder() - .setRecurrenceLastExpansion(plusYears(domain.getCreationTimeInstant(), 1)) + .setRecurrenceLastExpansion(plusYears(domain.getCreationTime(), 1)) .build()); // Assert about Cursor. @@ -213,7 +213,7 @@ void testFailure_expandSingleEvent_cursorNotAtStartTime() { defaultOneTime(getOnlyAutoRenewHistory()), billingRecurrence .asBuilder() - .setRecurrenceLastExpansion(plusYears(domain.getCreationTimeInstant(), 1)) + .setRecurrenceLastExpansion(plusYears(domain.getCreationTime(), 1)) .build()); // Assert that the cursor did not change. @@ -226,8 +226,7 @@ void testSuccess_noExpansion_recurrenceClosedBeforeEventTime() { persistResource( billingRecurrence .asBuilder() - .setRecurrenceEndTime( - billingRecurrence.getEventTimeInstant().minus(1, ChronoUnit.DAYS)) + .setRecurrenceEndTime(billingRecurrence.getEventTime().minus(1, ChronoUnit.DAYS)) .build()); runPipeline(); assertNoExpansionsHappened(); @@ -251,7 +250,7 @@ void testSuccess_noExpansion_recurrenceClosedBeforeNextExpansion() { persistResource( billingRecurrence .asBuilder() - .setEventTime(minusYears(billingRecurrence.getEventTimeInstant(), 1)) + .setEventTime(minusYears(billingRecurrence.getEventTime(), 1)) .setRecurrenceEndTime(startTime.plus(6, ChronoUnit.HOURS)) .build()); runPipeline(); @@ -316,7 +315,7 @@ void testSuccess_expandSingleEvent_doesNotAdvanceCursor() { defaultOneTime(getOnlyAutoRenewHistory()), billingRecurrence .asBuilder() - .setRecurrenceLastExpansion(plusYears(domain.getCreationTimeInstant(), 1)) + .setRecurrenceLastExpansion(plusYears(domain.getCreationTime(), 1)) .build()); // Assert that the cursor did not move. @@ -355,7 +354,7 @@ void testSuccess_expandMultipleEvents_multipleDomains(int numOfThreads) { defaultOneTime(getOnlyAutoRenewHistory()), billingRecurrence .asBuilder() - .setRecurrenceLastExpansion(plusYears(domain.getCreationTimeInstant(), 1)) + .setRecurrenceLastExpansion(plusYears(domain.getCreationTime(), 1)) .build()); assertBillingEventsForResource( otherDomain, @@ -363,7 +362,7 @@ void testSuccess_expandMultipleEvents_multipleDomains(int numOfThreads) { otherDomain, getOnlyAutoRenewHistory(otherDomain), otherBillingRecurrence, 100), otherBillingRecurrence .asBuilder() - .setRecurrenceLastExpansion(plusYears(otherDomain.getCreationTimeInstant(), 1)) + .setRecurrenceLastExpansion(plusYears(otherDomain.getCreationTime(), 1)) .build()); // Assert about Cursor. @@ -387,7 +386,7 @@ void testSuccess_expandMultipleEvents_multipleEventTime() { DomainTransactionRecord.create( domain.getTld(), // We report this when the autorenew grace period ends. - plusYears(domain.getCreationTimeInstant(), 2) + plusYears(domain.getCreationTime(), 2) .plus( Duration.ofMillis(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD.getMillis())), TransactionReportField.netRenewsFieldFromYears(1), @@ -404,21 +403,21 @@ void testSuccess_expandMultipleEvents_multipleEventTime() { h.getDomainTransactionRecords().stream() .findFirst() .get() - .getReportingTimeInstant())) + .getReportingTime())) .collect(toImmutableList()); assertBillingEventsForResource( domain, defaultOneTime(histories.get(0)), defaultOneTime(histories.get(1)) .asBuilder() - .setEventTime(plusYears(domain.getCreationTimeInstant(), 2)) + .setEventTime(plusYears(domain.getCreationTime(), 2)) .setBillingTime( - plusYears(domain.getCreationTimeInstant(), 2) + plusYears(domain.getCreationTime(), 2) .plus(Duration.ofMillis(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD.getMillis()))) .build(), billingRecurrence .asBuilder() - .setRecurrenceLastExpansion(plusYears(domain.getCreationTimeInstant(), 2)) + .setRecurrenceLastExpansion(plusYears(domain.getCreationTime(), 2)) .build()); // Assert about Cursor. @@ -472,7 +471,7 @@ private DomainHistory defaultDomainHistory(Domain domain) { DomainTransactionRecord.create( domain.getTld(), // We report this when the autorenew grace period ends. - plusYears(domain.getCreationTimeInstant(), 1) + plusYears(domain.getCreationTime(), 1) .plus(Duration.ofMillis(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD.getMillis())), TransactionReportField.netRenewsFieldFromYears(1), 1))) @@ -487,11 +486,11 @@ private BillingEvent defaultOneTime( Domain domain, DomainHistory history, BillingRecurrence billingRecurrence, int cost) { return new BillingEvent.Builder() .setBillingTime( - plusYears(domain.getCreationTimeInstant(), 1) + plusYears(domain.getCreationTime(), 1) .plus(Duration.ofMillis(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD.getMillis()))) .setRegistrarId("TheRegistrar") .setCost(Money.of(USD, cost)) - .setEventTime(plusYears(domain.getCreationTimeInstant(), 1)) + .setEventTime(plusYears(domain.getCreationTime(), 1)) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW, Flag.SYNTHETIC)) .setPeriodYears(1) .setReason(Reason.RENEW) 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 07ba124b621..f96aa6ac8c4 100644 --- a/core/src/test/java/google/registry/beam/billing/InvoicingPipelineTest.java +++ b/core/src/test/java/google/registry/beam/billing/InvoicingPipelineTest.java @@ -23,7 +23,7 @@ import static google.registry.testing.DatabaseHelper.persistNewRegistrar; import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.LogsSubject.assertAboutLogs; -import static google.registry.util.DateTimeUtils.END_OF_TIME; +import static google.registry.util.DateTimeUtils.END_INSTANT; import static google.registry.util.DateTimeUtils.START_OF_TIME; import static java.util.logging.Level.SEVERE; import static org.joda.money.CurrencyUnit.CAD; @@ -56,6 +56,7 @@ import java.io.Serial; import java.nio.file.Files; import java.nio.file.Path; +import java.time.Instant; import java.util.Arrays; import java.util.Comparator; import java.util.Map.Entry; @@ -70,7 +71,6 @@ import org.apache.beam.sdk.values.PCollection; import org.apache.beam.sdk.values.TypeDescriptor; import org.joda.money.Money; -import org.joda.time.DateTime; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -97,8 +97,8 @@ class InvoicingPipelineTest { ImmutableList.of( google.registry.beam.billing.BillingEvent.create( 1, - DateTime.parse("2017-10-04T00:00:00Z"), - DateTime.parse("2017-10-04T00:00:00Z"), + Instant.parse("2017-10-04T00:00:00Z"), + Instant.parse("2017-10-04T00:00:00Z"), "theRegistrar", "234", "", @@ -112,8 +112,8 @@ class InvoicingPipelineTest { ""), google.registry.beam.billing.BillingEvent.create( 2, - DateTime.parse("2017-10-04T00:00:00Z"), - DateTime.parse("2017-10-04T00:00:00Z"), + Instant.parse("2017-10-04T00:00:00Z"), + Instant.parse("2017-10-04T00:00:00Z"), "theRegistrar", "234", "", @@ -127,8 +127,8 @@ class InvoicingPipelineTest { ""), google.registry.beam.billing.BillingEvent.create( 3, - DateTime.parse("2017-10-02T00:00:00Z"), - DateTime.parse("2017-09-29T00:00:00Z"), + Instant.parse("2017-10-02T00:00:00Z"), + Instant.parse("2017-09-29T00:00:00Z"), "theRegistrar", "234", "", @@ -142,8 +142,8 @@ class InvoicingPipelineTest { ""), google.registry.beam.billing.BillingEvent.create( 4, - DateTime.parse("2017-10-04T00:00:00Z"), - DateTime.parse("2017-10-04T00:00:00Z"), + Instant.parse("2017-10-04T00:00:00Z"), + Instant.parse("2017-10-04T00:00:00Z"), "bestdomains", "456", "116688", @@ -157,8 +157,8 @@ class InvoicingPipelineTest { ""), google.registry.beam.billing.BillingEvent.create( 5, - DateTime.parse("2017-10-04T00:00:00Z"), - DateTime.parse("2017-10-04T00:00:00Z"), + Instant.parse("2017-10-04T00:00:00Z"), + Instant.parse("2017-10-04T00:00:00Z"), "anotherRegistrar", "789", "", @@ -172,8 +172,8 @@ class InvoicingPipelineTest { "SUNRISE ANCHOR_TENANT"), google.registry.beam.billing.BillingEvent.create( 6, - DateTime.parse("2017-10-04T00:00:00Z"), - DateTime.parse("2017-10-04T00:00:00Z"), + Instant.parse("2017-10-04T00:00:00Z"), + Instant.parse("2017-10-04T00:00:00Z"), "theRegistrar", "234", "", @@ -187,8 +187,8 @@ class InvoicingPipelineTest { ""), google.registry.beam.billing.BillingEvent.create( 7, - DateTime.parse("2017-10-04T00:00:00Z"), - DateTime.parse("2017-10-04T00:00:00Z"), + Instant.parse("2017-10-04T00:00:00Z"), + Instant.parse("2017-10-04T00:00:00Z"), "theRegistrar", "234", "", @@ -202,8 +202,8 @@ class InvoicingPipelineTest { ""), google.registry.beam.billing.BillingEvent.create( 15, - DateTime.parse("2017-10-02T00:00:00.0Z"), - DateTime.parse("2017-10-04T00:00:00.0Z"), + Instant.parse("2017-10-02T00:00:00.0Z"), + Instant.parse("2017-10-04T00:00:00.0Z"), "theRegistrarCopy", "234", "", @@ -217,8 +217,8 @@ class InvoicingPipelineTest { ""), google.registry.beam.billing.BillingEvent.create( 16, - DateTime.parse("2017-10-04T00:00:00Z"), - DateTime.parse("2017-10-04T00:00:00Z"), + Instant.parse("2017-10-04T00:00:00Z"), + Instant.parse("2017-10-04T00:00:00Z"), "theRegistrarCopy", "234", "", @@ -478,8 +478,8 @@ private static void setupCloudSql() { Reason.CREATE, 5, Money.ofMajor(JPY, 70), - DateTime.parse("2017-09-29T00:00:00.0Z"), - DateTime.parse("2017-10-02T00:00:00.0Z")); + Instant.parse("2017-09-29T00:00:00.0Z"), + Instant.parse("2017-10-02T00:00:00.0Z")); persistBillingEvent(4, domain4, registrar2, Reason.RENEW, 1, Money.of(USD, 20.5)); persistBillingEvent( 5, @@ -488,8 +488,8 @@ private static void setupCloudSql() { Reason.CREATE, 1, Money.of(USD, 0), - DateTime.parse("2017-10-04T00:00:00.0Z"), - DateTime.parse("2017-10-04T00:00:00.0Z"), + Instant.parse("2017-10-04T00:00:00.0Z"), + Instant.parse("2017-10-04T00:00:00.0Z"), Flag.SUNRISE, Flag.ANCHOR_TENANT); persistBillingEvent(6, domain6, registrar1, Reason.SERVER_STATUS, 0, Money.of(USD, 0)); @@ -529,8 +529,8 @@ private static void setupCloudSql() { Reason.CREATE, 5, Money.ofMajor(JPY, 70), - DateTime.parse("2017-06-29T00:00:00.0Z"), - DateTime.parse("2017-07-02T00:00:00.0Z")); + Instant.parse("2017-06-29T00:00:00.0Z"), + Instant.parse("2017-07-02T00:00:00.0Z")); // Add a billing event with a corresponding cancellation Domain domain12 = persistActiveDomain("cancel.test"); @@ -543,8 +543,8 @@ private static void setupCloudSql() { .asBuilder() .setId(1) .setRegistrarId(registrar1.getRegistrarId()) - .setEventTime(DateTime.parse("2017-10-05T00:00:00.0Z")) - .setBillingTime(DateTime.parse("2017-10-04T00:00:00.0Z")) + .setEventTime(Instant.parse("2017-10-05T00:00:00.0Z")) + .setBillingTime(Instant.parse("2017-10-04T00:00:00.0Z")) .setBillingEvent(billingEvent.createVKey()) .setTargetId(domain12.getDomainName()) .setReason(Reason.RENEW) @@ -560,11 +560,11 @@ private static void setupCloudSql() { new BillingRecurrence() .asBuilder() .setRegistrarId(registrar1.getRegistrarId()) - .setRecurrenceEndTime(END_OF_TIME) + .setRecurrenceEndTime(END_INSTANT) .setId(1) .setDomainHistory(domainHistoryRecurrence) .setTargetId(domain13.getDomainName()) - .setEventTime(DateTime.parse("2017-10-04T00:00:00.0Z")) + .setEventTime(Instant.parse("2017-10-04T00:00:00.0Z")) .setReason(Reason.RENEW) .build(); persistResource(billingRecurrence); @@ -575,7 +575,7 @@ private static void setupCloudSql() { .asBuilder() .setCancellationMatchingBillingEvent(billingRecurrence) .setFlags(ImmutableSet.of(Flag.SYNTHETIC)) - .setSyntheticCreationTime(DateTime.parse("2017-10-03T00:00:00.0Z")) + .setSyntheticCreationTime(Instant.parse("2017-10-03T00:00:00.0Z")) .build(); persistResource(billingEventRecurrence); @@ -584,8 +584,8 @@ private static void setupCloudSql() { .asBuilder() .setId(2) .setRegistrarId(registrar1.getRegistrarId()) - .setEventTime(DateTime.parse("2017-10-05T00:00:00.0Z")) - .setBillingTime(DateTime.parse("2017-10-04T00:00:00.0Z")) + .setEventTime(Instant.parse("2017-10-05T00:00:00.0Z")) + .setBillingTime(Instant.parse("2017-10-04T00:00:00.0Z")) .setBillingRecurrence(billingRecurrence.createVKey()) .setTargetId(domain13.getDomainName()) .setReason(Reason.RENEW) @@ -604,8 +604,8 @@ private static void setupCloudSql() { Reason.CREATE, 5, Money.ofMajor(JPY, 70), - DateTime.parse("2017-10-04T00:00:00.0Z"), - DateTime.parse("2017-10-02T00:00:00.0Z")); + Instant.parse("2017-10-04T00:00:00.0Z"), + Instant.parse("2017-10-02T00:00:00.0Z")); persistBillingEvent(16, domain15, registrar11, Reason.RENEW, 3, Money.of(USD, 20.5)); } @@ -613,7 +613,7 @@ private static DomainHistory persistDomainHistory(Domain domain, Registrar regis DomainHistory domainHistory = new DomainHistory.Builder() .setType(HistoryEntry.Type.DOMAIN_RENEW) - .setModificationTime(DateTime.parse("2017-10-04T00:00:00.0Z")) + .setModificationTime(Instant.parse("2017-10-04T00:00:00.0Z")) .setDomain(domain) .setRegistrarId(registrar.getRegistrarId()) .build(); @@ -629,8 +629,8 @@ private static BillingEvent persistBillingEvent( reason, years, money, - DateTime.parse("2017-10-04T00:00:00.0Z"), - DateTime.parse("2017-10-04T00:00:00.0Z")); + Instant.parse("2017-10-04T00:00:00.0Z"), + Instant.parse("2017-10-04T00:00:00.0Z")); } private static BillingEvent persistBillingEvent( @@ -640,8 +640,8 @@ private static BillingEvent persistBillingEvent( Reason reason, int years, Money money, - DateTime eventTime, - DateTime billingTime, + Instant eventTime, + Instant billingTime, Flag... flags) { BillingEvent.Builder billingEventBuilder = new BillingEvent() 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 2d39c1cb77f..c04ab264604 100644 --- a/core/src/test/java/google/registry/beam/common/RegistryJpaReadTest.java +++ b/core/src/test/java/google/registry/beam/common/RegistryJpaReadTest.java @@ -19,7 +19,7 @@ import static google.registry.testing.DatabaseHelper.newTld; import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistResources; -import static google.registry.util.DateTimeUtils.END_OF_TIME; +import static google.registry.util.DateTimeUtils.END_INSTANT; import static google.registry.util.DateTimeUtils.START_OF_TIME; import com.google.common.collect.ImmutableList; @@ -174,7 +174,7 @@ private void setupForJoinQuery() { .setDomainName("example.com") .setRepoId("4-COM") .setCreationRegistrarId(registrar.getRegistrarId()) - .setLastEppUpdateTime(fakeClock.nowUtc()) + .setLastEppUpdateTime(fakeClock.now()) .setLastEppUpdateRegistrarId(registrar.getRegistrarId()) .setLastTransferTime(fakeClock.nowUtc()) .setStatusValues( @@ -197,7 +197,7 @@ private void setupForJoinQuery() { GracePeriod.create( GracePeriodStatus.ADD, "4-COM", - END_OF_TIME, + END_INSTANT, registrar.getRegistrarId(), null, 100L)) 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 504b108e872..3ddbf0b4eaf 100644 --- a/core/src/test/java/google/registry/beam/rde/RdePipelineTest.java +++ b/core/src/test/java/google/registry/beam/rde/RdePipelineTest.java @@ -159,7 +159,7 @@ private DomainHistory persistDomainHistory(DomainBase domain) { DomainTransactionRecord transactionRecord = new DomainTransactionRecord.Builder() .setTld("soy") - .setReportingTime(clock.nowUtc()) + .setReportingTime(clock.now()) .setReportField(TransactionReportField.NET_ADDS_1_YR) .setReportAmount(1) .build(); @@ -168,7 +168,7 @@ private DomainHistory persistDomainHistory(DomainBase domain) { new DomainHistory.Builder() .setType(HistoryEntry.Type.DOMAIN_CREATE) .setXmlBytes("".getBytes(UTF_8)) - .setModificationTime(clock.nowUtc()) + .setModificationTime(clock.now()) .setRegistrarId("TheRegistrar") .setTrid(Trid.create("ABC-123", "server-trid")) .setBySuperuser(false) @@ -186,7 +186,7 @@ private HostHistory persistHostHistory(HostBase hostBase) { new HostHistory.Builder() .setType(HistoryEntry.Type.HOST_CREATE) .setXmlBytes("".getBytes(UTF_8)) - .setModificationTime(clock.nowUtc()) + .setModificationTime(clock.now()) .setRegistrarId("TheRegistrar") .setTrid(Trid.create("ABC-123", "server-trid")) .setBySuperuser(false) @@ -257,7 +257,7 @@ void beforeEach() throws Exception { // Advance time clock.advanceOneMilli(); - persistDomainHistory(deletedDomain.asBuilder().setDeletionTime(clock.nowUtc()).build()); + persistDomainHistory(deletedDomain.asBuilder().setDeletionTime(clock.now()).build()); kittyDomain = kittyDomain.asBuilder().setDomainName("cat.fun").build(); persistDomainHistory(kittyDomain); @@ -276,7 +276,7 @@ void beforeEach() throws Exception { // Set the clock to 2000-01-02, any change after hereafter should not show up in the // resulting deposit fragments. clock.advanceBy(Duration.standardDays(2)); - persistDomainHistory(kittyDomain.asBuilder().setDeletionTime(clock.nowUtc()).build()); + persistDomainHistory(kittyDomain.asBuilder().setDeletionTime(clock.now()).build()); Host futureHost = persistActiveHost("ns1.future.tld"); persistHostHistory(futureHost); persistDomainHistory( diff --git a/core/src/test/java/google/registry/beam/spec11/Spec11PipelineTest.java b/core/src/test/java/google/registry/beam/spec11/Spec11PipelineTest.java index a25185ef007..935a53fc2cc 100644 --- a/core/src/test/java/google/registry/beam/spec11/Spec11PipelineTest.java +++ b/core/src/test/java/google/registry/beam/spec11/Spec11PipelineTest.java @@ -287,7 +287,7 @@ private Domain createDomain(String domainName, String repoId, Registrar registra .setDomainName(domainName) .setRepoId(repoId) .setCreationRegistrarId(registrar.getRegistrarId()) - .setLastEppUpdateTime(fakeClock.nowUtc()) + .setLastEppUpdateTime(fakeClock.now()) .setLastEppUpdateRegistrarId(registrar.getRegistrarId()) .setLastTransferTime(fakeClock.nowUtc()) .setPersistedCurrentSponsorRegistrarId(registrar.getRegistrarId()) diff --git a/core/src/test/java/google/registry/export/ExportDomainListsActionTest.java b/core/src/test/java/google/registry/export/ExportDomainListsActionTest.java index f6b8f59c151..2a905ca4e9b 100644 --- a/core/src/test/java/google/registry/export/ExportDomainListsActionTest.java +++ b/core/src/test/java/google/registry/export/ExportDomainListsActionTest.java @@ -23,6 +23,7 @@ import static google.registry.testing.DatabaseHelper.persistDeletedDomain; import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.util.DateTimeUtils.START_OF_TIME; +import static google.registry.util.DateTimeUtils.plusDays; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.eq; @@ -176,14 +177,14 @@ void test_outputIncludesDeletionTimes_forPendingDeletes_notRdemption() throws Ex GracePeriod.createWithoutBillingEvent( GracePeriodStatus.REDEMPTION, redemption.getRepoId(), - clock.nowUtc().plusDays(20), + plusDays(clock.now(), 20), redemption.getCurrentSponsorRegistrarId())) .build()); persistResource( persistActiveDomain("pendingdelete.tld") .asBuilder() .addStatusValue(StatusValue.PENDING_DELETE) - .setDeletionTime(clock.nowUtc().plusDays(3)) + .setDeletionTime(plusDays(clock.now(), 3)) .build()); action.run(); diff --git a/core/src/test/java/google/registry/flows/EppLifecycleDomainTest.java b/core/src/test/java/google/registry/flows/EppLifecycleDomainTest.java index 3d3540ab885..ea4302e95b6 100644 --- a/core/src/test/java/google/registry/flows/EppLifecycleDomainTest.java +++ b/core/src/test/java/google/registry/flows/EppLifecycleDomainTest.java @@ -31,6 +31,7 @@ import static google.registry.testing.DomainSubject.assertAboutDomains; import static google.registry.testing.EppMetricSubject.assertThat; import static google.registry.util.DateTimeUtils.START_OF_TIME; +import static google.registry.util.DateTimeUtils.toInstant; import static org.joda.money.CurrencyUnit.USD; import com.google.common.collect.ImmutableMap; @@ -533,8 +534,8 @@ void testEapDomainDeletion_withinAddGracePeriod_eapFeeIsNotRefunded() throws Exc .setRegistrarId("NewRegistrar") .setPeriodYears(1) .setCost(Money.parse("USD 100.00")) - .setEventTime(createTime) - .setBillingTime(createTime.plus(Tld.get("tld").getRenewGracePeriodLength())) + .setEventTime(toInstant(createTime)) + .setBillingTime(toInstant(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 23f6979d6a2..776ccb49789 100644 --- a/core/src/test/java/google/registry/flows/EppTestCase.java +++ b/core/src/test/java/google/registry/flows/EppTestCase.java @@ -19,6 +19,7 @@ import static google.registry.testing.DatabaseHelper.loadAllOf; import static google.registry.testing.DatabaseHelper.stripBillingEventId; import static google.registry.testing.TestDataHelper.loadFile; +import static google.registry.util.DateTimeUtils.toInstant; import static google.registry.xml.XmlTestUtils.assertXmlEqualsWithMessage; import static jakarta.servlet.http.HttpServletResponse.SC_OK; import static java.nio.charset.StandardCharsets.UTF_8; @@ -286,8 +287,9 @@ protected static BillingEvent makeOneTimeCreateBillingEvent(Domain domain, DateT .setRegistrarId(domain.getCurrentSponsorRegistrarId()) .setCost(Money.parse("USD 24.00")) .setPeriodYears(2) - .setEventTime(createTime) - .setBillingTime(createTime.plus(Tld.get(domain.getTld()).getAddGracePeriodLength())) + .setEventTime(toInstant(createTime)) + .setBillingTime( + toInstant(createTime.plus(Tld.get(domain.getTld()).getAddGracePeriodLength()))) .setDomainHistory( getOnlyHistoryEntryOfType(domain, Type.DOMAIN_CREATE, DomainHistory.class)) .build(); @@ -301,8 +303,9 @@ static BillingEvent makeOneTimeRenewBillingEvent(Domain domain, DateTime renewTi .setRegistrarId(domain.getCurrentSponsorRegistrarId()) .setCost(Money.parse("USD 33.00")) .setPeriodYears(3) - .setEventTime(renewTime) - .setBillingTime(renewTime.plus(Tld.get(domain.getTld()).getRenewGracePeriodLength())) + .setEventTime(toInstant(renewTime)) + .setBillingTime( + toInstant(renewTime.plus(Tld.get(domain.getTld()).getRenewGracePeriodLength()))) .setDomainHistory(getOnlyHistoryEntryOfType(domain, Type.DOMAIN_RENEW, DomainHistory.class)) .build(); } @@ -335,8 +338,8 @@ protected static BillingRecurrence makeRecurrence( .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId(domain.getDomainName()) .setRegistrarId(domain.getCurrentSponsorRegistrarId()) - .setEventTime(eventTime) - .setRecurrenceEndTime(endTime) + .setEventTime(toInstant(eventTime)) + .setRecurrenceEndTime(toInstant(endTime)) .setDomainHistory(historyEntry) .build(); } @@ -347,9 +350,10 @@ static BillingCancellation makeCancellationBillingEventForCreate( return new BillingCancellation.Builder() .setTargetId(domain.getDomainName()) .setRegistrarId(domain.getCurrentSponsorRegistrarId()) - .setEventTime(deleteTime) + .setEventTime(toInstant(deleteTime)) .setBillingEvent(findKeyToActualOneTimeBillingEvent(billingEventToCancel)) - .setBillingTime(createTime.plus(Tld.get(domain.getTld()).getAddGracePeriodLength())) + .setBillingTime( + toInstant(createTime.plus(Tld.get(domain.getTld()).getAddGracePeriodLength()))) .setReason(Reason.CREATE) .setDomainHistory( getOnlyHistoryEntryOfType(domain, Type.DOMAIN_DELETE, DomainHistory.class)) @@ -362,9 +366,10 @@ static BillingCancellation makeCancellationBillingEventForRenew( return new BillingCancellation.Builder() .setTargetId(domain.getDomainName()) .setRegistrarId(domain.getCurrentSponsorRegistrarId()) - .setEventTime(deleteTime) + .setEventTime(toInstant(deleteTime)) .setBillingEvent(findKeyToActualOneTimeBillingEvent(billingEventToCancel)) - .setBillingTime(renewTime.plus(Tld.get(domain.getTld()).getRenewGracePeriodLength())) + .setBillingTime( + toInstant(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/FlowTestCase.java b/core/src/test/java/google/registry/flows/FlowTestCase.java index 7f157fd01a0..ec390bbbc0e 100644 --- a/core/src/test/java/google/registry/flows/FlowTestCase.java +++ b/core/src/test/java/google/registry/flows/FlowTestCase.java @@ -182,7 +182,7 @@ private static ImmutableMap canonicalizeGracePeriods( GracePeriod.create( entry.getKey().getType(), entry.getKey().getDomainRepoId(), - entry.getKey().getExpirationDateTime(), + entry.getKey().getExpirationTime(), entry.getKey().getRegistrarId(), null, 1L), diff --git a/core/src/test/java/google/registry/flows/domain/DomainCreateFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainCreateFlowTest.java index c5d4c231619..15ea94575ec 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainCreateFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainCreateFlowTest.java @@ -56,12 +56,13 @@ import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DomainSubject.assertAboutDomains; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; -import static google.registry.util.DateTimeUtils.END_OF_TIME; +import static google.registry.util.DateTimeUtils.END_INSTANT; import static google.registry.util.DateTimeUtils.START_INSTANT; import static google.registry.util.DateTimeUtils.minusDays; import static google.registry.util.DateTimeUtils.minusMonths; import static google.registry.util.DateTimeUtils.minusYears; import static google.registry.util.DateTimeUtils.plusDays; +import static google.registry.util.DateTimeUtils.plusMinutes; import static google.registry.util.DateTimeUtils.plusYears; import static org.joda.money.CurrencyUnit.JPY; import static org.joda.money.CurrencyUnit.USD; @@ -334,7 +335,7 @@ private void assertSuccessfulCreate( DomainHistory historyEntry = getHistoryEntries(domain, DomainHistory.class).get(0); VKey autorenewVKey = domain.getAutorenewBillingEvent(); BillingRecurrence autorenewBR = tm().transact(() -> tm().loadByKey(autorenewVKey)); - Instant eventTime = autorenewBR.getEventTimeInstant(); + Instant eventTime = autorenewBR.getEventTime(); assertAboutDomains() .that(domain) .hasRegistrationExpirationTime(eventTime) @@ -370,8 +371,8 @@ private void assertSuccessfulCreate( .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId(getUniqueIdFromCommand()) .setRegistrarId("TheRegistrar") - .setEventTime(domain.getRegistrationExpirationDateTime()) - .setRecurrenceEndTime(END_OF_TIME) + .setEventTime(domain.getRegistrationExpirationTime()) + .setRecurrenceEndTime(END_INSTANT) .setDomainHistory(historyEntry) .setRenewalPriceBehavior(expectedRenewalPriceBehavior) .setRenewalPrice( @@ -406,7 +407,7 @@ private void assertSuccessfulCreate( new PollMessage.Autorenew.Builder() .setTargetId(domain.getDomainName()) .setRegistrarId("TheRegistrar") - .setEventTime(domain.getRegistrationExpirationDateTime()) + .setEventTime(domain.getRegistrationExpirationTime()) .setMsg("Domain was auto-renewed.") .setHistoryEntry(historyEntry) .build()); @@ -1730,7 +1731,7 @@ private void assertPollMessagesWithCollisionOneTime(Domain domain) { new PollMessage.Autorenew.Builder() .setTargetId(domain.getDomainName()) .setRegistrarId("TheRegistrar") - .setEventTime(domain.getRegistrationExpirationDateTime()) + .setEventTime(domain.getRegistrationExpirationTime()) .setMsg("Domain was auto-renewed.") .setHistoryEntry(historyEntry) .build(), @@ -1863,7 +1864,7 @@ void testSuccess_customLogicIsCalled_andSavesExtraEntity() throws Exception { new PollMessage.Autorenew.Builder() .setTargetId(domain.getDomainName()) .setRegistrarId("TheRegistrar") - .setEventTime(domain.getRegistrationExpirationDateTime()) + .setEventTime(domain.getRegistrationExpirationTime()) .setMsg("Domain was auto-renewed.") .setHistoryEntry(historyEntry) .build(), @@ -2712,7 +2713,7 @@ void testIcannTransactionRecord_getsStored() throws Exception { .containsExactly( DomainTransactionRecord.create( "tld", - historyEntry.getModificationTime().plusMinutes(9), + plusMinutes(historyEntry.getModificationTime(), 9), TransactionReportField.netAddsFieldFromYears(2), 1)); } diff --git a/core/src/test/java/google/registry/flows/domain/DomainDeleteFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainDeleteFlowTest.java index 7b4b056ab7e..95c5fb7fbe3 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainDeleteFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainDeleteFlowTest.java @@ -50,12 +50,14 @@ import static google.registry.testing.DomainSubject.assertAboutDomains; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries; +import static google.registry.util.DateTimeUtils.END_INSTANT; import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.DateTimeUtils.START_INSTANT; import static google.registry.util.DateTimeUtils.minusDays; import static google.registry.util.DateTimeUtils.minusMonths; import static google.registry.util.DateTimeUtils.minusYears; import static google.registry.util.DateTimeUtils.plusDays; +import static google.registry.util.DateTimeUtils.plusHours; import static google.registry.util.DateTimeUtils.plusMonths; import static google.registry.util.DateTimeUtils.plusYears; import static google.registry.util.DateTimeUtils.toDateTime; @@ -241,7 +243,7 @@ private void assertAutorenewClosedAndCancellationCreatedFor( .setTargetId("example.tld") .setRegistrarId("TheRegistrar") .setEventTime(eventTime) - .setBillingTime(toDateTime(plusDays(TIME_BEFORE_FLOW, 1))) + .setBillingTime(plusDays(TIME_BEFORE_FLOW, 1)) .setBillingEvent(graceBillingEvent.createVKey()) .setDomainHistory(historyEntryDomainDelete) .build()); @@ -262,7 +264,7 @@ private BillingEvent createBillingEvent(Reason reason, Money cost) { .setCost(cost) .setPeriodYears(2) .setEventTime(minusDays(TIME_BEFORE_FLOW, 4)) - .setBillingTime(toDateTime(plusDays(TIME_BEFORE_FLOW, 1))) + .setBillingTime(plusDays(TIME_BEFORE_FLOW, 1)) .setDomainHistory(earlierHistoryEntry) .build(); } @@ -274,7 +276,7 @@ private BillingRecurrence.Builder createAutorenewBillingEvent(String registrarId .setTargetId("example.tld") .setRegistrarId(registrarId) .setEventTime(A_MONTH_FROM_NOW) - .setRecurrenceEndTime(END_OF_TIME) + .setRecurrenceEndTime(END_INSTANT) .setDomainHistory(earlierHistoryEntry); } @@ -602,7 +604,7 @@ void testSuccess_pendingTransfer() throws Exception { // The poll message in the future to the gaining registrar should be gone too, but there // should be one at the current time to the gaining registrar. PollMessage gainingPollMessage = getOnlyPollMessage("NewRegistrar"); - assertThat(gainingPollMessage.getEventTime()).isEqualTo(clock.nowUtc()); + assertThat(gainingPollMessage.getEventTime()).isEqualTo(clock.now()); assertThat( gainingPollMessage .getResponseData() @@ -973,10 +975,7 @@ void testIcannTransactionRecord_noGrace_entryOutsideMaxGracePeriod() throws Exce assertThat(persistedEntry.getDomainTransactionRecords()) .containsExactly( DomainTransactionRecord.create( - "tld", - clock.now().plus(java.time.Duration.ofHours(3)), - DELETED_DOMAINS_NOGRACE, - 1)); + "tld", plusHours(clock.now(), 3), DELETED_DOMAINS_NOGRACE, 1)); } @Test @@ -1002,10 +1001,7 @@ void testIcannTransactionRecord_noGrace_noAddOrRenewRecords() throws Exception { assertThat(persistedEntry.getDomainTransactionRecords()) .containsExactly( DomainTransactionRecord.create( - "tld", - clock.now().plus(java.time.Duration.ofHours(3)), - DELETED_DOMAINS_NOGRACE, - 1)); + "tld", plusHours(clock.now(), 3), DELETED_DOMAINS_NOGRACE, 1)); } /** Verifies that if there's no add grace period, we still cancel out valid renew records */ @@ -1033,7 +1029,7 @@ void testIcannTransactionRecord_noGrace_hasRenewRecord() throws Exception { assertThat(persistedEntry.getDomainTransactionRecords()) .containsExactly( DomainTransactionRecord.create( - "tld", clock.now().plus(java.time.Duration.ofHours(3)), DELETED_DOMAINS_NOGRACE, 1), + "tld", plusHours(clock.now(), 3), DELETED_DOMAINS_NOGRACE, 1), renewRecord.asBuilder().setReportAmount(-1).build()); } diff --git a/core/src/test/java/google/registry/flows/domain/DomainDeletionTimeCacheTest.java b/core/src/test/java/google/registry/flows/domain/DomainDeletionTimeCacheTest.java index 25da1daab13..3e7b8384494 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainDeletionTimeCacheTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainDeletionTimeCacheTest.java @@ -19,6 +19,7 @@ import static google.registry.testing.DatabaseHelper.persistActiveDomain; import static google.registry.testing.DatabaseHelper.persistDomainAsDeleted; import static google.registry.util.DateTimeUtils.END_OF_TIME; +import static google.registry.util.DateTimeUtils.plusMinutes; import static google.registry.util.DateTimeUtils.toDateTime; import google.registry.model.domain.Domain; @@ -87,7 +88,7 @@ void testCache_returnsNewDataAfterDomainCreate() { void testCache_expires() { Domain domain = persistActiveDomain("domain.tld"); assertThat(getDeletionTimeFromCache("domain.tld")).hasValue(END_OF_TIME); - Instant elevenMinutesFromNow = clock.now().plus(java.time.Duration.ofMinutes(11)); + Instant elevenMinutesFromNow = plusMinutes(clock.now(), 11); persistDomainAsDeleted(domain, toDateTime(elevenMinutesFromNow)); clock.advanceBy(Duration.standardMinutes(30)); assertThat(getDeletionTimeFromCache("domain.tld")).hasValue(toDateTime(elevenMinutesFromNow)); 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 8be64d0b595..7fe080967cd 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainInfoFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainInfoFlowTest.java @@ -29,7 +29,7 @@ import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; import static google.registry.testing.TestDataHelper.updateSubstitutions; -import static google.registry.util.DateTimeUtils.END_OF_TIME; +import static google.registry.util.DateTimeUtils.END_INSTANT; import static google.registry.util.DateTimeUtils.START_OF_TIME; import static google.registry.util.DateTimeUtils.minusDays; import static google.registry.util.DateTimeUtils.plusDays; @@ -369,7 +369,7 @@ void testSuccess_autoRenewGracePeriod() throws Exception { .setTargetId(getUniqueIdFromCommand()) .setRegistrarId("TheRegistrar") .setEventTime(clock.now()) - .setRecurrenceEndTime(END_OF_TIME) + .setRecurrenceEndTime(END_INSTANT) .setDomainHistory(historyEntry) .build()); VKey recurrenceVKey = renewEvent.createVKey(); 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 58c0322c530..f44f25a3efc 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainPricingLogicTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainPricingLogicTest.java @@ -26,7 +26,7 @@ import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.persistPremiumList; import static google.registry.testing.DatabaseHelper.persistResource; -import static google.registry.util.DateTimeUtils.END_OF_TIME; +import static google.registry.util.DateTimeUtils.END_INSTANT; import static google.registry.util.DateTimeUtils.START_INSTANT; import static org.joda.money.CurrencyUnit.USD; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -124,7 +124,7 @@ private BillingRecurrence persistDomainAndSetRecurrence( .setReason(Reason.RENEW) .setRenewalPriceBehavior(renewalPriceBehavior) .setRenewalPrice(renewalPrice.orElse(null)) - .setRecurrenceEndTime(END_OF_TIME) + .setRecurrenceEndTime(END_INSTANT) .setTargetId(domain.getDomainName()) .build()); persistResource( 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 1d32183b40c..bc82ff9f2ba 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainRenewFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainRenewFlowTest.java @@ -45,8 +45,9 @@ import static google.registry.util.DateTimeUtils.minusDays; import static google.registry.util.DateTimeUtils.minusYears; import static google.registry.util.DateTimeUtils.plusDays; +import static google.registry.util.DateTimeUtils.plusMinutes; import static google.registry.util.DateTimeUtils.plusYears; -import static google.registry.util.DateTimeUtils.toDateTime; +import static google.registry.util.DateTimeUtils.toInstant; import static org.joda.money.CurrencyUnit.EUR; import static org.joda.money.CurrencyUnit.JPY; import static org.joda.money.CurrencyUnit.USD; @@ -173,7 +174,7 @@ private void persistDomain( .setTargetId(getUniqueIdFromCommand()) .setRegistrarId("TheRegistrar") .setEventTime(expirationTime) - .setRecurrenceEndTime(END_OF_TIME) + .setRecurrenceEndTime(toInstant(END_OF_TIME)) .setDomainHistory(historyEntryDomainCreate) .setRenewalPriceBehavior(renewalPriceBehavior) .setRenewalPrice(renewalPrice) @@ -262,7 +263,7 @@ private void doSuccessfulTest( DomainHistory historyEntryDomainRenew = getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RENEW, DomainHistory.class); assertThat(loadByKey(domain.getAutorenewBillingEvent()).getEventTime()) - .isEqualTo(toDateTime(newExpiration)); + .isEqualTo(newExpiration); assertAboutDomains() .that(domain) .isActiveAt(clock.now()) @@ -285,8 +286,7 @@ private void doSuccessfulTest( .setPeriodYears(renewalYears) .setEventTime(clock.now()) .setBillingTime( - toDateTime( - clock.now().plusMillis(Tld.get("tld").getRenewGracePeriodLength().getMillis()))) + clock.now().plusMillis(Tld.get("tld").getRenewGracePeriodLength().getMillis())) .setDomainHistory(historyEntryDomainRenew) .build(); assertBillingEvents( @@ -311,8 +311,8 @@ private void doSuccessfulTest( .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId(getUniqueIdFromCommand()) .setRegistrarId("TheRegistrar") - .setEventTime(domain.getRegistrationExpirationDateTime()) - .setRecurrenceEndTime(END_OF_TIME) + .setEventTime(toInstant(domain.getRegistrationExpirationDateTime())) + .setRecurrenceEndTime(toInstant(END_OF_TIME)) .setDomainHistory(historyEntryDomainRenew) .build()); // There should only be the new autorenew poll message, as the old one will have been deleted @@ -321,7 +321,7 @@ private void doSuccessfulTest( new PollMessage.Autorenew.Builder() .setTargetId(getUniqueIdFromCommand()) .setRegistrarId("TheRegistrar") - .setEventTime(domain.getRegistrationExpirationDateTime()) + .setEventTime(toInstant(domain.getRegistrationExpirationDateTime())) .setAutorenewEndTime(END_OF_TIME) .setMsg("Domain was auto-renewed.") .setHistoryEntry(historyEntryDomainRenew) @@ -332,8 +332,7 @@ private void doSuccessfulTest( GracePeriod.create( GracePeriodStatus.RENEW, domain.getRepoId(), - toDateTime( - clock.now().plusMillis(Tld.get("tld").getRenewGracePeriodLength().getMillis())), + clock.now().plusMillis(Tld.get("tld").getRenewGracePeriodLength().getMillis()), renewalClientId, null), renewBillingEvent)); @@ -1104,7 +1103,7 @@ void testIcannTransactionRecord_getsStored() throws Exception { .containsExactly( DomainTransactionRecord.create( "tld", - historyEntry.getModificationTime().plusMinutes(9), + plusMinutes(historyEntry.getModificationTime(), 9), TransactionReportField.netRenewsFieldFromYears(5), 1)); } 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 ee46ba7dbd8..a1d9ce3c825 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainRestoreRequestFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainRestoreRequestFlowTest.java @@ -36,7 +36,6 @@ import static google.registry.util.DateTimeUtils.plusDays; import static google.registry.util.DateTimeUtils.plusMonths; import static google.registry.util.DateTimeUtils.plusYears; -import static google.registry.util.DateTimeUtils.toDateTime; import static org.joda.money.CurrencyUnit.EUR; import static org.joda.money.CurrencyUnit.JPY; import static org.joda.money.CurrencyUnit.USD; @@ -184,7 +183,7 @@ void testSuccess_expiryStillInFuture_notExtended() throws Exception { getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RESTORE, DomainHistory.class); assertLastHistoryContainsResource(domain); assertThat(loadByKey(domain.getAutorenewBillingEvent()).getEventTime()) - .isEqualTo(toDateTime(expirationTime)); + .isEqualTo(expirationTime); assertAboutDomains() .that(domain) // New expiration time should be the same as from before the deletion. @@ -252,7 +251,7 @@ void testSuccess_expiryInPast_extendedByOneYear() throws Exception { getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RESTORE, DomainHistory.class); assertLastHistoryContainsResource(domain); assertThat(loadByKey(domain.getAutorenewBillingEvent()).getEventTime()) - .isEqualTo(toDateTime(newExpirationTime)); + .isEqualTo(newExpirationTime); assertAboutDomains() .that(domain) // New expiration time should be exactly a year from now. diff --git a/core/src/test/java/google/registry/flows/domain/DomainTransferApproveFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainTransferApproveFlowTest.java index fad8b64342b..9042c573353 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainTransferApproveFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainTransferApproveFlowTest.java @@ -43,7 +43,6 @@ import static google.registry.util.DateTimeUtils.minusYears; import static google.registry.util.DateTimeUtils.plusDays; import static google.registry.util.DateTimeUtils.plusYears; -import static google.registry.util.DateTimeUtils.toDateTime; import static org.joda.money.CurrencyUnit.USD; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -214,7 +213,7 @@ private void runSuccessfulFlowWithAssertions( assertTransferApproved(domain, originalTransferData); assertAboutDomains().that(domain).hasRegistrationExpirationTime(expectedExpirationTime); assertThat(loadByKey(domain.getAutorenewBillingEvent()).getEventTime()) - .isEqualTo(toDateTime(expectedExpirationTime)); + .isEqualTo(expectedExpirationTime); // The poll message (in the future) to the losing registrar for implicit ack should be gone. assertThat(getPollMessages(domain, "TheRegistrar", clock.nowUtc().plusMonths(1))).isEmpty(); @@ -222,9 +221,7 @@ private void runSuccessfulFlowWithAssertions( // should be one at the current time to the gaining registrar, as well as one at the domain's // autorenew time. assertThat(getPollMessages(domain, "NewRegistrar", clock.nowUtc().plusMonths(1))).hasSize(1); - assertThat( - getPollMessages( - domain, "NewRegistrar", toDateTime(domain.getRegistrationExpirationTime()))) + assertThat(getPollMessages(domain, "NewRegistrar", domain.getRegistrationExpirationTime())) .hasSize(2); PollMessage gainingTransferPollMessage = @@ -233,11 +230,11 @@ private void runSuccessfulFlowWithAssertions( getOnlyPollMessage( domain, "NewRegistrar", - toDateTime(domain.getRegistrationExpirationTime()), + domain.getRegistrationExpirationTime(), PollMessage.Autorenew.class); - assertThat(gainingTransferPollMessage.getEventTime()).isEqualTo(clock.nowUtc()); + assertThat(gainingTransferPollMessage.getEventTime()).isEqualTo(clock.now()); assertThat(gainingAutorenewPollMessage.getEventTime()) - .isEqualTo(toDateTime(domain.getRegistrationExpirationTime())); + .isEqualTo(domain.getRegistrationExpirationTime()); DomainTransferResponse transferResponse = gainingTransferPollMessage .getResponseData() @@ -285,8 +282,7 @@ private void assertHistoryEntriesContainBillingEventsAndGracePeriods( .setTargetId(domain.getDomainName()) .setEventTime(clock.now()) .setBillingTime( - toDateTime( - clock.now().plusMillis(registry.getTransferGracePeriodLength().getMillis()))) + clock.now().plusMillis(registry.getTransferGracePeriodLength().getMillis())) .setRegistrarId("NewRegistrar") .setCost(Money.of(USD, 11).multipliedBy(expectedYearsToCharge)) .setPeriodYears(expectedYearsToCharge) @@ -318,8 +314,7 @@ private void assertHistoryEntriesContainBillingEventsAndGracePeriods( GracePeriod.create( GracePeriodStatus.TRANSFER, domain.getRepoId(), - toDateTime( - clock.now().plusMillis(registry.getTransferGracePeriodLength().getMillis())), + clock.now().plusMillis(registry.getTransferGracePeriodLength().getMillis()), "NewRegistrar", null), transferBillingEvent)); @@ -517,9 +512,8 @@ void testSuccess_autorenewBeforeTransfer() throws Exception { .setRegistrarId("TheRegistrar") .setEventTime(clock.now()) // The cancellation happens at the moment of transfer. .setBillingTime( - toDateTime( - oldExpirationTime.plusMillis( - Tld.get("tld").getAutoRenewGracePeriodLength().getMillis()))) + oldExpirationTime.plusMillis( + Tld.get("tld").getAutoRenewGracePeriodLength().getMillis())) .setBillingRecurrence(domain.getAutorenewBillingEvent())); } 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 95aed1e8041..521a0c61862 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainTransferCancelFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainTransferCancelFlowTest.java @@ -31,6 +31,7 @@ import static google.registry.testing.DomainSubject.assertAboutDomains; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries; +import static google.registry.util.DateTimeUtils.END_INSTANT; import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.DateTimeUtils.minusDays; import static google.registry.util.DateTimeUtils.plusDays; @@ -147,7 +148,7 @@ private void doSuccessfulTest(String commandFilename) throws Exception { .hasOtherRegistrarId("TheRegistrar"); // The only billing event left should be the original autorenew event, now reopened. assertBillingEvents( - getLosingClientAutorenewEvent().asBuilder().setRecurrenceEndTime(END_OF_TIME).build()); + getLosingClientAutorenewEvent().asBuilder().setRecurrenceEndTime(END_INSTANT).build()); // The poll message (in the future) to the gaining registrar for implicit ack should be gone. assertThat(getPollMessages("NewRegistrar", clock.nowUtc().plusMonths(1))).isEmpty(); // The poll message in the future to the losing registrar should be gone too, but there should 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 597841a34c8..898fe82aa20 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainTransferFlowTestCase.java +++ b/core/src/test/java/google/registry/flows/domain/DomainTransferFlowTestCase.java @@ -23,7 +23,7 @@ import static google.registry.testing.DatabaseHelper.persistDomainWithPendingTransfer; import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DomainSubject.assertAboutDomains; -import static google.registry.util.DateTimeUtils.END_OF_TIME; +import static google.registry.util.DateTimeUtils.END_INSTANT; import static google.registry.util.DateTimeUtils.plusYears; import com.google.common.base.Ascii; @@ -154,7 +154,7 @@ BillingRecurrence getGainingClientAutorenewEvent() { .setTargetId(domain.getDomainName()) .setRegistrarId("NewRegistrar") .setEventTime(EXTENDED_REGISTRATION_EXPIRATION_TIME) - .setRecurrenceEndTime(END_OF_TIME) + .setRecurrenceEndTime(END_INSTANT) .setDomainHistory( getOnlyHistoryEntryOfType( domain, HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST, DomainHistory.class)) 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 55bb46057bc..86edb652d38 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainTransferRejectFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainTransferRejectFlowTest.java @@ -32,7 +32,7 @@ import static google.registry.testing.DomainSubject.assertAboutDomains; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries; -import static google.registry.util.DateTimeUtils.END_OF_TIME; +import static google.registry.util.DateTimeUtils.END_INSTANT; import static google.registry.util.DateTimeUtils.minusDays; import static google.registry.util.DateTimeUtils.plusDays; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -117,13 +117,13 @@ private void doSuccessfulTest(String commandFilename, String expectedXmlFilename assertLastHistoryContainsResource(domain); // The only billing event left should be the original autorenew event, now reopened. assertBillingEvents( - getLosingClientAutorenewEvent().asBuilder().setRecurrenceEndTime(END_OF_TIME).build()); + getLosingClientAutorenewEvent().asBuilder().setRecurrenceEndTime(END_INSTANT).build()); // The poll message (in the future) to the losing registrar for implicit ack should be gone. assertThat(getPollMessages("TheRegistrar", clock.nowUtc().plusMonths(1))).isEmpty(); // The poll message in the future to the gaining registrar should be gone too, but there // should be one at the current time to the gaining registrar. PollMessage gainingPollMessage = getOnlyPollMessage("NewRegistrar"); - assertThat(gainingPollMessage.getEventTime()).isEqualTo(clock.nowUtc()); + assertThat(gainingPollMessage.getEventTime()).isEqualTo(clock.now()); assertThat( gainingPollMessage .getResponseData() 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 02711108759..adcc529452a 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainTransferRequestFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainTransferRequestFlowTest.java @@ -250,8 +250,7 @@ private void assertTransferApproved( .setTransferPeriod(expectedPeriod) .setTransferStatus(TransferStatus.SERVER_APPROVED) .setPendingTransferExpirationTime(automaticTransferTime) - .setTransferredRegistrationExpirationTime( - domain.getRegistrationExpirationDateTime()) + .setTransferredRegistrationExpirationTime(domain.getRegistrationExpirationTime()) // Server-approve entity fields should all be nulled out. .build()); } @@ -341,7 +340,7 @@ private void assertHistoryEntriesContainBillingEventsAndGracePeriods( // The domain's autorenew billing event should still point to the losing client's event. BillingRecurrence domainAutorenewEvent = loadByKey(domain.getAutorenewBillingEvent()); assertThat(domainAutorenewEvent.getRegistrarId()).isEqualTo("TheRegistrar"); - assertThat(domainAutorenewEvent.getRecurrenceEndTimeInstant()).isEqualTo(implicitTransferTime); + assertThat(domainAutorenewEvent.getRecurrenceEndTime()).isEqualTo(implicitTransferTime); // The original grace periods should remain untouched. assertThat(domain.getGracePeriods()).containsExactlyElementsIn(originalGracePeriods); // If we fast forward AUTOMATIC_TRANSFER_DAYS, the transfer should have cleared out all other @@ -379,8 +378,8 @@ private void assertPollMessagesEmitted( getOnlyPollMessage("NewRegistrar", implicitTransferTime, PollMessage.OneTime.class); PollMessage autorenewPollMessage = getOnlyPollMessage("NewRegistrar", expectedExpirationTime, PollMessage.Autorenew.class); - assertThat(transferApprovedPollMessage.getEventTimeInstant()).isEqualTo(implicitTransferTime); - assertThat(autorenewPollMessage.getEventTimeInstant()).isEqualTo(expectedExpirationTime); + assertThat(transferApprovedPollMessage.getEventTime()).isEqualTo(implicitTransferTime); + assertThat(autorenewPollMessage.getEventTime()).isEqualTo(expectedExpirationTime); assertThat( transferApprovedPollMessage.getResponseData().stream() .filter(TransferResponse.class::isInstance) @@ -407,9 +406,8 @@ private void assertPollMessagesEmitted( getPollMessages("TheRegistrar", implicitTransferTime).stream() .filter(Predicates.not(Predicates.equalTo(losingTransferPendingPollMessage))) .collect(onlyElement()); - assertThat(losingTransferPendingPollMessage.getEventTimeInstant()).isEqualTo(clock.now()); - assertThat(losingTransferApprovedPollMessage.getEventTimeInstant()) - .isEqualTo(implicitTransferTime); + assertThat(losingTransferPendingPollMessage.getEventTime()).isEqualTo(clock.now()); + assertThat(losingTransferApprovedPollMessage.getEventTime()).isEqualTo(implicitTransferTime); assertThat( losingTransferPendingPollMessage.getResponseData().stream() .filter(TransferResponse.class::isInstance) @@ -451,9 +449,7 @@ private void assertAboutDomainAfterAutomaticTransfer( .hasLastEppUpdateTime(implicitTransferTime) .and() .hasLastEppUpdateRegistrarId("NewRegistrar"); - assertThat( - loadByKey(domainAfterAutomaticTransfer.getAutorenewBillingEvent()) - .getEventTimeInstant()) + assertThat(loadByKey(domainAfterAutomaticTransfer.getAutorenewBillingEvent()).getEventTime()) .isEqualTo(expectedExpirationTime); // And after the expected grace time, the grace period should be gone. Domain afterGracePeriod = @@ -1062,10 +1058,8 @@ void testSuccess_autorenewGraceActive_onlyAtTransferRequestTime() throws Excepti // 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. Instant autorenewTime = - clock - .now() - .minusMillis(Tld.get("tld").getAutoRenewGracePeriodLength().getMillis()) - .plus(java.time.Duration.ofDays(1)); + plusDays( + clock.now().minusMillis(Tld.get("tld").getAutoRenewGracePeriodLength().getMillis()), 1); Instant expirationTime = plusYears(autorenewTime, 1); domain = persistResource( @@ -1125,14 +1119,10 @@ void testSuccess_autorenewGraceActive_throughoutTransferWindow() throws Exceptio .setRegistrarId("TheRegistrar") // The cancellation happens at the moment of transfer. .setEventTime( - toDateTime( - clock - .now() - .plusMillis(Tld.get("tld").getAutomaticTransferLength().getMillis()))) + clock.now().plusMillis(Tld.get("tld").getAutomaticTransferLength().getMillis())) .setBillingTime( - toDateTime( - autorenewTime.plusMillis( - Tld.get("tld").getAutoRenewGracePeriodLength().getMillis()))) + autorenewTime.plusMillis( + Tld.get("tld").getAutoRenewGracePeriodLength().getMillis())) // The cancellation should refer to the old autorenew billing event. .setBillingRecurrence(existingAutorenewEvent)); } @@ -1159,14 +1149,10 @@ void testSuccess_autorenewGraceActive_onlyAtAutomaticTransferTime() throws Excep .setRegistrarId("TheRegistrar") // The cancellation happens at the moment of transfer. .setEventTime( - toDateTime( - clock - .now() - .plusMillis(Tld.get("tld").getAutomaticTransferLength().getMillis()))) + clock.now().plusMillis(Tld.get("tld").getAutomaticTransferLength().getMillis())) .setBillingTime( - toDateTime( - expirationTime.plusMillis( - Tld.get("tld").getAutoRenewGracePeriodLength().getMillis()))) + expirationTime.plusMillis( + Tld.get("tld").getAutoRenewGracePeriodLength().getMillis())) // The cancellation should refer to the old autorenew billing event. .setBillingRecurrence(existingAutorenewEvent)); } @@ -1225,8 +1211,7 @@ void testSuccess_nonPremiumRenewalPrice_isReflectedInTransferCostAndCarriesOver( domain, new BillingEvent.Builder() .setBillingTime( - toDateTime( - plusDays(now, 10))) // 5 day pending transfer + 5 day billing grace period + plusDays(now, 10)) // 5 day pending transfer + 5 day billing grace period .setEventTime(plusDays(now, 5)) .setRegistrarId("NewRegistrar") .setCost(Money.of(USD, new BigDecimal("11.00"))) @@ -1282,8 +1267,7 @@ void testSuccess_specifiedRenewalPrice_isReflectedInTransferCostAndCarriesOver() domain, new BillingEvent.Builder() .setBillingTime( - toDateTime( - plusDays(now, 10))) // 5 day pending transfer + 5 day billing grace period + plusDays(now, 10)) // 5 day pending transfer + 5 day billing grace period .setEventTime(plusDays(now, 5)) .setRegistrarId("NewRegistrar") .setCost(Money.of(USD, new BigDecimal("18.79"))) @@ -1345,8 +1329,7 @@ void testSuccess_specifiedRenewalPrice_notCarriedOverForBulkPricingName() throws domain, new BillingEvent.Builder() .setBillingTime( - toDateTime( - plusDays(now, 10))) // 5 day pending transfer + 5 day billing grace period + plusDays(now, 10)) // 5 day pending transfer + 5 day billing grace period .setEventTime(plusDays(now, 5)) .setRegistrarId("NewRegistrar") .setCost(Money.of(USD, new BigDecimal("11.00"))) @@ -1407,8 +1390,7 @@ void testSuccess_defaultRenewalPrice_carriedOverForBulkPricingName() throws Exce domain, new BillingEvent.Builder() .setBillingTime( - toDateTime( - plusDays(now, 10))) // 5 day pending transfer + 5 day billing grace period + plusDays(now, 10)) // 5 day pending transfer + 5 day billing grace period .setEventTime(plusDays(now, 5)) .setRegistrarId("NewRegistrar") .setCost(Money.of(USD, new BigDecimal("11.00"))) diff --git a/core/src/test/java/google/registry/flows/host/HostCreateFlowTest.java b/core/src/test/java/google/registry/flows/host/HostCreateFlowTest.java index 6c50a934ec6..76319cbd459 100644 --- a/core/src/test/java/google/registry/flows/host/HostCreateFlowTest.java +++ b/core/src/test/java/google/registry/flows/host/HostCreateFlowTest.java @@ -27,6 +27,7 @@ import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; import static google.registry.testing.HostSubject.assertAboutHosts; +import static google.registry.util.DateTimeUtils.plusDays; import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.collect.ImmutableMap; @@ -55,7 +56,7 @@ import google.registry.model.host.Host; import google.registry.model.reporting.HistoryEntry; import google.registry.testing.DatabaseHelper; -import org.joda.time.DateTime; +import java.time.Instant; import org.junit.jupiter.api.Test; /** Unit tests for {@link HostCreateFlow}. */ @@ -79,7 +80,7 @@ private void setEppHostCreateInputWithIps(String hostName) { HostCreateFlowTest() { setEppHostCreateInput("ns1.example.tld", null); - clock.setTo(DateTime.parse("1999-04-03T22:00:00.0Z")); + clock.setTo(Instant.parse("1999-04-03T22:00:00.0Z")); } private void doSuccessfulTest() throws Exception { @@ -225,7 +226,7 @@ void testFailure_superordinateInPendingDelete() { persistResource( DatabaseHelper.newDomain("example.tld") .asBuilder() - .setDeletionTime(clock.nowUtc().plusDays(35)) + .setDeletionTime(plusDays(clock.now(), 35)) .setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE)) .build()); clock.advanceOneMilli(); 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 1c0af852600..8f413c92649 100644 --- a/core/src/test/java/google/registry/flows/host/HostDeleteFlowTest.java +++ b/core/src/test/java/google/registry/flows/host/HostDeleteFlowTest.java @@ -26,6 +26,7 @@ import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; import static google.registry.testing.HostSubject.assertAboutHosts; +import static google.registry.util.DateTimeUtils.minusDays; import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.collect.ImmutableMap; @@ -48,7 +49,7 @@ import google.registry.model.transfer.DomainTransferData; import google.registry.model.transfer.TransferStatus; import google.registry.testing.DatabaseHelper; -import org.joda.time.DateTime; +import java.time.Instant; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -236,9 +237,10 @@ void testSuccess_authorizedClientReadFromTransferredSuperordinate() throws Excep sessionMetadata.setRegistrarId("NewRegistrar"); createTld("tld"); // Setup a transfer that should have been server approved a day ago. - DateTime now = clock.nowUtc(); - DateTime requestTime = now.minusDays(1).minus(Tld.DEFAULT_AUTOMATIC_TRANSFER_LENGTH); - DateTime transferExpirationTime = now.minusDays(1); + Instant now = clock.now(); + Instant requestTime = + minusDays(now, 1).minusMillis(Tld.DEFAULT_AUTOMATIC_TRANSFER_LENGTH.getMillis()); + Instant transferExpirationTime = minusDays(now, 1); Domain domain = persistResource( DatabaseHelper.newDomain("example.tld") @@ -270,9 +272,10 @@ void testFailure_unauthorizedClientReadFromTransferredSuperordinate() { sessionMetadata.setRegistrarId("NewRegistrar"); createTld("tld"); // Setup a transfer that should have been server approved a day ago. - DateTime now = clock.nowUtc(); - DateTime requestTime = now.minusDays(1).minus(Tld.DEFAULT_AUTOMATIC_TRANSFER_LENGTH); - DateTime transferExpirationTime = now.minusDays(1); + Instant now = clock.now(); + Instant requestTime = + minusDays(now, 1).minusMillis(Tld.DEFAULT_AUTOMATIC_TRANSFER_LENGTH.getMillis()); + Instant transferExpirationTime = minusDays(now, 1); Domain domain = persistResource( DatabaseHelper.newDomain("example.tld") diff --git a/core/src/test/java/google/registry/flows/host/HostInfoFlowTest.java b/core/src/test/java/google/registry/flows/host/HostInfoFlowTest.java index be4aecae3fe..c028e2895dd 100644 --- a/core/src/test/java/google/registry/flows/host/HostInfoFlowTest.java +++ b/core/src/test/java/google/registry/flows/host/HostInfoFlowTest.java @@ -21,6 +21,7 @@ import static google.registry.testing.DatabaseHelper.persistNewRegistrar; import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; +import static google.registry.util.DateTimeUtils.minusDays; import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.collect.ImmutableMap; @@ -37,8 +38,8 @@ import google.registry.model.eppcommon.StatusValue; import google.registry.model.host.Host; import google.registry.testing.DatabaseHelper; +import java.time.Instant; import javax.annotation.Nullable; -import org.joda.time.DateTime; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -66,9 +67,9 @@ private Host persistHost() throws Exception { .setPersistedCurrentSponsorRegistrarId("TheRegistrar") .setCreationRegistrarId("NewRegistrar") .setLastEppUpdateRegistrarId("NewRegistrar") - .setCreationTimeForTest(DateTime.parse("1999-04-03T22:00:00.0Z")) - .setLastEppUpdateTime(DateTime.parse("1999-12-03T09:00:00.0Z")) - .setLastTransferTime(DateTime.parse("2000-04-08T09:00:00.0Z")) + .setCreationTimeForTest(Instant.parse("1999-04-03T22:00:00.0Z")) + .setLastEppUpdateTime(Instant.parse("1999-12-03T09:00:00.0Z")) + .setLastTransferTime(Instant.parse("2000-04-08T09:00:00.0Z")) .build()); } @@ -111,7 +112,7 @@ void testSuccess_linked() throws Exception { } private void runTest_superordinateDomain( - DateTime domainTransferTime, @Nullable DateTime lastSuperordinateChange) throws Exception { + Instant domainTransferTime, @Nullable Instant lastSuperordinateChange) throws Exception { persistNewRegistrar("superclientid"); Domain domain = persistResource( @@ -143,18 +144,18 @@ private void runTest_superordinateDomain( @Test void testSuccess_withSuperordinateDomain_hostMovedAfterDomainTransfer() throws Exception { runTest_superordinateDomain( - DateTime.parse("2000-01-08T09:00:00.0Z"), DateTime.parse("2000-03-01T01:00:00.0Z")); + Instant.parse("2000-01-08T09:00:00.0Z"), Instant.parse("2000-03-01T01:00:00.0Z")); } @Test void testSuccess_withSuperordinateDomain_hostMovedBeforeDomainTransfer() throws Exception { runTest_superordinateDomain( - DateTime.parse("2000-04-08T09:00:00.0Z"), DateTime.parse("2000-02-08T09:00:00.0Z")); + Instant.parse("2000-04-08T09:00:00.0Z"), Instant.parse("2000-02-08T09:00:00.0Z")); } @Test void testSuccess_withSuperordinateDomain() throws Exception { - runTest_superordinateDomain(DateTime.parse("2000-04-08T09:00:00.0Z"), null); + runTest_superordinateDomain(Instant.parse("2000-04-08T09:00:00.0Z"), null); } @Test @@ -166,7 +167,7 @@ void testFailure_neverExisted() throws Exception { @Test void testFailure_existedButWasDeleted() throws Exception { - persistResource(persistHost().asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); + persistResource(persistHost().asBuilder().setDeletionTime(minusDays(clock.now(), 1)).build()); ResourceDoesNotExistException thrown = assertThrows(ResourceDoesNotExistException.class, this::runFlow); assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand())); 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 2fcc3d7a2e7..379a82a8c69 100644 --- a/core/src/test/java/google/registry/flows/host/HostUpdateFlowTest.java +++ b/core/src/test/java/google/registry/flows/host/HostUpdateFlowTest.java @@ -36,7 +36,10 @@ import static google.registry.testing.GenericEppResourceSubject.assertAboutEppResources; import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries; import static google.registry.testing.HostSubject.assertAboutHosts; -import static google.registry.util.DateTimeUtils.END_OF_TIME; +import static google.registry.util.DateTimeUtils.END_INSTANT; +import static google.registry.util.DateTimeUtils.minusDays; +import static google.registry.util.DateTimeUtils.plusDays; +import static google.registry.util.DateTimeUtils.toInstant; import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.cloud.tasks.v2.HttpMethod; @@ -83,7 +86,6 @@ import google.registry.testing.DatabaseHelper; import java.time.Instant; import javax.annotation.Nullable; -import org.joda.time.DateTime; import org.junit.jupiter.api.Test; /** Unit tests for {@link HostUpdateFlow}. */ @@ -114,9 +116,10 @@ private void setEppHostUpdateInput( *

The transfer is from "TheRegistrar" to "NewRegistrar". */ private Domain createDomainWithServerApprovedTransfer(String domainName) { - DateTime now = clock.nowUtc(); - DateTime requestTime = now.minusDays(1).minus(Tld.DEFAULT_AUTOMATIC_TRANSFER_LENGTH); - DateTime transferExpirationTime = now.minusDays(1); + Instant now = clock.now(); + Instant requestTime = + minusDays(now, 1).minusMillis(Tld.DEFAULT_AUTOMATIC_TRANSFER_LENGTH.getMillis()); + Instant transferExpirationTime = minusDays(now, 1); return DatabaseHelper.newDomain(domainName) .asBuilder() .setPersistedCurrentSponsorRegistrarId("TheRegistrar") @@ -199,7 +202,7 @@ void testSuccess_withReferencingDomain() throws Exception { persistResource( DatabaseHelper.newDomain("test.xn--q9jyb4c") .asBuilder() - .setDeletionTime(END_OF_TIME) + .setDeletionTime(END_INSTANT) .setNameservers(ImmutableSet.of(host.createVKey())) .build()); Host renamedHost = doSuccessfulTest(); @@ -243,7 +246,7 @@ void testSuccess_nameUnchanged_superordinateDomainWasTransferred() throws Except sessionMetadata.setRegistrarId("NewRegistrar"); setEppInput("host_update_name_unchanged.xml"); createTld("tld"); - // Create a domain that will belong to NewRegistrar after cloneProjectedAtTime is called. + // Create a domain that will belong to NewRegistrar after cloneProjectedAtInstant is called. Domain domain = persistResource(createDomainWithServerApprovedTransfer("example.tld")); Host oldHost = persistActiveSubordinateHost(oldHostName(), domain); clock.advanceOneMilli(); @@ -257,7 +260,7 @@ void testSuccess_nameUnchanged_superordinateDomainWasTransferred() throws Except .and() .hasPersistedCurrentSponsorRegistrarId("NewRegistrar") .and() - .hasLastTransferTime(domain.getTransferData().getPendingTransferExpirationDateTime()) + .hasLastTransferTime(domain.getTransferData().getPendingTransferExpirationTime()) .and() .hasOnlyOneHistoryEntryWhich() .hasType(HistoryEntry.Type.HOST_UPDATE); @@ -272,8 +275,8 @@ void testSuccess_internalToInternalOnSameDomain() throws Exception { "192.0.2.22", "1080:0:0:0:8:800:200C:417A"); createTld("tld"); - DateTime now = clock.nowUtc(); - DateTime oneDayAgo = now.minusDays(1); + Instant now = clock.now(); + Instant oneDayAgo = minusDays(now, 1); Domain domain = persistResource( DatabaseHelper.newDomain("example.tld") @@ -293,7 +296,7 @@ void testSuccess_internalToInternalOnSameDomain() throws Exception { .hasPersistedCurrentSponsorRegistrarId("TheRegistrar") .and() .hasLastTransferTime(oneDayAgo); - Domain reloadedDomain = loadByEntity(domain).cloneProjectedAtTime(now); + Domain reloadedDomain = loadByEntity(domain).cloneProjectedAtInstant(now); assertThat(reloadedDomain.getSubordinateHosts()).containsExactly("ns2.example.tld"); assertHostDnsRequests("ns1.example.tld", "ns2.example.tld"); } @@ -317,7 +320,7 @@ void testSuccess_internalToInternalOnSameTld() throws Exception { assertThat(foo.getSubordinateHosts()).containsExactly("ns2.foo.tld"); assertThat(example.getSubordinateHosts()).isEmpty(); Host renamedHost = doSuccessfulTest(); - DateTime now = clock.nowUtc(); + Instant now = clock.now(); assertAboutHosts() .that(renamedHost) .hasSuperordinateDomain(example.createVKey()) @@ -327,8 +330,8 @@ void testSuccess_internalToInternalOnSameTld() throws Exception { .hasPersistedCurrentSponsorRegistrarId("TheRegistrar") .and() .hasLastTransferTime(null); - assertThat(loadByEntity(foo).cloneProjectedAtTime(now).getSubordinateHosts()).isEmpty(); - assertThat(loadByEntity(example).cloneProjectedAtTime(now).getSubordinateHosts()) + assertThat(loadByEntity(foo).cloneProjectedAtInstant(now).getSubordinateHosts()).isEmpty(); + assertThat(loadByEntity(example).cloneProjectedAtInstant(now).getSubordinateHosts()) .containsExactly("ns2.example.tld"); assertHostDnsRequests("ns2.foo.tld", "ns2.example.tld"); } @@ -353,7 +356,7 @@ void testSuccess_internalToInternalOnDifferentTld() throws Exception { assertThat(fooDomain.getSubordinateHosts()).containsExactly("ns1.example.foo"); assertThat(tldDomain.getSubordinateHosts()).isEmpty(); Host renamedHost = doSuccessfulTest(); - DateTime now = clock.nowUtc(); + Instant now = clock.now(); assertAboutHosts() .that(renamedHost) .hasSuperordinateDomain(tldDomain.createVKey()) @@ -363,9 +366,9 @@ void testSuccess_internalToInternalOnDifferentTld() throws Exception { .hasPersistedCurrentSponsorRegistrarId("TheRegistrar") .and() .hasLastTransferTime(null); - Domain reloadedFooDomain = loadByEntity(fooDomain).cloneProjectedAtTime(now); + Domain reloadedFooDomain = loadByEntity(fooDomain).cloneProjectedAtInstant(now); assertThat(reloadedFooDomain.getSubordinateHosts()).isEmpty(); - Domain reloadedTldDomain = loadByEntity(tldDomain).cloneProjectedAtTime(now); + Domain reloadedTldDomain = loadByEntity(tldDomain).cloneProjectedAtInstant(now); assertThat(reloadedTldDomain.getSubordinateHosts()).containsExactly("ns2.example.tld"); assertHostDnsRequests("ns1.example.foo", "ns2.example.tld"); } @@ -387,7 +390,7 @@ void testSuccess_internalToExternal() throws Exception { .setSubordinateHosts(ImmutableSet.of(oldHostName())) .build()); assertThat(domain.getCurrentSponsorRegistrarId()).isEqualTo("TheRegistrar"); - DateTime oneDayAgo = clock.nowUtc().minusDays(1); + Instant oneDayAgo = minusDays(clock.now(), 1); Host oldHost = persistResource( persistActiveSubordinateHost(oldHostName(), domain) @@ -406,7 +409,7 @@ void testSuccess_internalToExternal() throws Exception { .and() .hasLastTransferTime(oneDayAgo) .and() - .hasLastSuperordinateChange(clock.nowUtc()); + .hasLastSuperordinateChange(clock.now()); assertThat(renamedHost.getLastTransferTime()).isEqualTo(oneDayAgo); Domain reloadedDomain = loadByEntity(domain).cloneProjectedAtInstant(clock.now()); assertThat(reloadedDomain.getSubordinateHosts()).isEmpty(); @@ -434,7 +437,7 @@ void testSuccess_superuserExternalToInternal() throws Exception { persistActiveHost(oldHostName()); assertThat(domain.getSubordinateHosts()).isEmpty(); Host renamedHost = doSuccessfulTestAsSuperuser(); - DateTime now = clock.nowUtc(); + Instant now = clock.now(); assertAboutHosts() .that(renamedHost) .hasSuperordinateDomain(domain.createVKey()) @@ -444,7 +447,7 @@ void testSuccess_superuserExternalToInternal() throws Exception { .hasPersistedCurrentSponsorRegistrarId("TheRegistrar") .and() .hasLastTransferTime(null); - assertThat(loadByEntity(domain).cloneProjectedAtTime(now).getSubordinateHosts()) + assertThat(loadByEntity(domain).cloneProjectedAtInstant(now).getSubordinateHosts()) .containsExactly("ns2.example.tld"); assertHostDnsRequests("ns2.example.tld"); } @@ -505,7 +508,7 @@ void testSuccess_subordToSubord_lastTransferTimeFromPreviousSuperordinateWinsOut "192.0.2.22", "1080:0:0:0:8:800:200C:417A"); createTld("tld"); - DateTime lastTransferTime = clock.nowUtc().minusDays(5); + Instant lastTransferTime = minusDays(clock.now(), 5); Domain foo = persistResource( DatabaseHelper.newDomain("foo.tld") @@ -564,12 +567,12 @@ void testSuccess_subordToSubord_lastTransferTimeOnExistingHostWinsOut() throws E newHost(oldHostName()) .asBuilder() .setSuperordinateDomain(domain.createVKey()) - .setLastTransferTime(clock.nowUtc().minusDays(20)) - .setLastSuperordinateChange(clock.nowUtc().minusDays(3)) + .setLastTransferTime(minusDays(clock.now(), 20)) + .setLastSuperordinateChange(minusDays(clock.now(), 3)) .setInetAddresses( ImmutableSet.of(InetAddresses.forString("1080:0:0:0:8:800:200C:417A"))) .build()); - DateTime lastTransferTime = host.getLastTransferTime(); + Instant lastTransferTime = host.getLastTransferTime(); persistResource(domain.asBuilder().setSubordinateHosts(ImmutableSet.of(oldHostName())).build()); Host renamedHost = doSuccessfulTest(); assertAboutHosts() @@ -600,14 +603,14 @@ void testSuccess_subordToSubord_lastTransferTimeOnExistingHostWinsOut_whenNullOn .asBuilder() .setLastTransferTime((Instant) null) .build()); - DateTime lastTransferTime = clock.nowUtc().minusDays(20); + Instant lastTransferTime = minusDays(clock.now(), 20); persistResource( newHost(oldHostName()) .asBuilder() .setSuperordinateDomain(foo.createVKey()) .setLastTransferTime(lastTransferTime) - .setLastSuperordinateChange(clock.nowUtc().minusDays(3)) + .setLastSuperordinateChange(minusDays(clock.now(), 3)) .setInetAddresses( ImmutableSet.of(InetAddresses.forString("1080:0:0:0:8:800:200C:417A"))) .build()); @@ -642,14 +645,14 @@ void testSuccess_subordToSubord_lastTransferTimeOnExistingHostWins_whenNullOnBot .asBuilder() .setLastTransferTime((Instant) null) .build()); - DateTime lastTransferTime = clock.nowUtc().minusDays(20); + Instant lastTransferTime = minusDays(clock.now(), 20); persistResource( newHost(oldHostName()) .asBuilder() .setSuperordinateDomain(foo.createVKey()) .setLastTransferTime(lastTransferTime) - .setLastSuperordinateChange(clock.nowUtc().minusDays(10)) + .setLastSuperordinateChange(minusDays(clock.now(), 10)) .setInetAddresses( ImmutableSet.of(InetAddresses.forString("1080:0:0:0:8:800:200C:417A"))) .build()); @@ -688,7 +691,7 @@ void testSuccess_subordToSubord_lastTransferTimeIsNull_whenNullOnBoth() throws E .asBuilder() .setSuperordinateDomain(foo.createVKey()) .setLastTransferTime((Instant) null) - .setLastSuperordinateChange(clock.nowUtc().minusDays(3)) + .setLastSuperordinateChange(minusDays(clock.now(), 3)) .setInetAddresses( ImmutableSet.of(InetAddresses.forString("1080:0:0:0:8:800:200C:417A"))) .build()); @@ -718,7 +721,7 @@ void testSuccess_internalToExternal_lastTransferTimeFrozenWhenComingFromSuperord .setInetAddresses( ImmutableSet.of(InetAddresses.forString("1080:0:0:0:8:800:200C:417A"))) .build()); - DateTime lastTransferTime = clock.nowUtc().minusDays(2); + Instant lastTransferTime = minusDays(clock.now(), 2); persistResource( domain .asBuilder() @@ -739,7 +742,7 @@ void testSuccess_internalToExternal_lastTransferTimeFrozenWhenComingFromSuperord .and() // Need to add two milliseconds to account for the increment of "persist resource" and the // artificial increment introduced after the flow itself. - .hasLastSuperordinateChange(clock.nowUtc().minusMillis(2)); + .hasLastSuperordinateChange(clock.now().minusMillis(2)); } @Test @@ -751,13 +754,13 @@ void testSuccess_internalToExternal_lastTransferTimeFrozenWhenComingFromHost() t "1080:0:0:0:8:800:200C:417A"); createTld("foo"); Domain domain = persistActiveDomain("example.foo"); - DateTime lastTransferTime = clock.nowUtc().minusDays(12); + Instant lastTransferTime = minusDays(clock.now(), 12); persistResource( newHost(oldHostName()) .asBuilder() .setSuperordinateDomain(domain.createVKey()) .setLastTransferTime(lastTransferTime) - .setLastSuperordinateChange(clock.nowUtc().minusDays(4)) + .setLastSuperordinateChange(minusDays(clock.now(), 4)) .setInetAddresses( ImmutableSet.of(InetAddresses.forString("1080:0:0:0:8:800:200C:417A"))) .build()); @@ -793,8 +796,8 @@ void testSuccess_internalToExternal_lastTransferTimeFrozenWhenDomainOverridesHos newHost(oldHostName()) .asBuilder() .setSuperordinateDomain(domain.createVKey()) - .setLastTransferTime(clock.nowUtc().minusDays(12)) - .setLastSuperordinateChange(clock.nowUtc().minusDays(4)) + .setLastTransferTime(minusDays(clock.now(), 12)) + .setLastSuperordinateChange(minusDays(clock.now(), 4)) .setInetAddresses( ImmutableSet.of(InetAddresses.forString("1080:0:0:0:8:800:200C:417A"))) .build()); @@ -812,11 +815,11 @@ void testSuccess_internalToExternal_lastTransferTimeFrozenWhenDomainOverridesHos .that(renamedHost) .hasPersistedCurrentSponsorRegistrarId("TheRegistrar") .and() - .hasLastTransferTime(domain.getLastTransferTime()); + .hasLastTransferTime(toInstant(domain.getLastTransferTime())); } private void doExternalToInternalLastTransferTimeTest( - DateTime hostTransferTime, @Nullable DateTime domainTransferTime) throws Exception { + Instant hostTransferTime, @Nullable Instant domainTransferTime) throws Exception { setEppHostUpdateInput( "ns1.example.foo", "ns2.example.tld", "192.0.2.22", null); createTld("tld"); @@ -838,21 +841,19 @@ private void doExternalToInternalLastTransferTimeTest( @Test void testSuccess_externalToSubord_lastTransferTimeNotOverridden_whenLessRecent() throws Exception { - doExternalToInternalLastTransferTimeTest( - clock.nowUtc().minusDays(2), clock.nowUtc().minusDays(1)); + doExternalToInternalLastTransferTimeTest(minusDays(clock.now(), 2), minusDays(clock.now(), 1)); } @Test void testSuccess_externalToSubord_lastTransferTimeNotOverridden_whenMoreRecent() throws Exception { - doExternalToInternalLastTransferTimeTest( - clock.nowUtc().minusDays(2), clock.nowUtc().minusDays(3)); + doExternalToInternalLastTransferTimeTest(minusDays(clock.now(), 2), minusDays(clock.now(), 3)); } /** Test when the new superordinate domain has never been transferred before. */ @Test void testSuccess_externalToSubord_lastTransferTimeNotOverridden_whenNull() throws Exception { - doExternalToInternalLastTransferTimeTest(clock.nowUtc().minusDays(2), null); + doExternalToInternalLastTransferTimeTest(minusDays(clock.now(), 2), null); } @Test @@ -877,7 +878,7 @@ void testFailure_superordinateInPendingDelete() throws Exception { DatabaseHelper.newDomain("example.tld") .asBuilder() .setSubordinateHosts(ImmutableSet.of(oldHostName())) - .setDeletionTime(clock.nowUtc().plusDays(35)) + .setDeletionTime(plusDays(clock.now(), 35)) .setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE)) .build()); persistActiveSubordinateHost(oldHostName(), domain); @@ -1049,8 +1050,8 @@ void testFailure_addExistingInetAddress() throws Exception { newHost(oldHostName()) .asBuilder() .setSuperordinateDomain(domain.createVKey()) - .setLastTransferTime(clock.nowUtc().minusDays(12)) - .setLastSuperordinateChange(clock.nowUtc().minusDays(4)) + .setLastTransferTime(minusDays(clock.now(), 12)) + .setLastSuperordinateChange(minusDays(clock.now(), 4)) .setInetAddresses( ImmutableSet.of(InetAddresses.forString("1080:0:0:0:8:800:200C:417A"))) .build()); @@ -1072,8 +1073,8 @@ void testFailure_removeNonexistentInetAddress() throws Exception { newHost(oldHostName()) .asBuilder() .setSuperordinateDomain(domain.createVKey()) - .setLastTransferTime(clock.nowUtc().minusDays(12)) - .setLastSuperordinateChange(clock.nowUtc().minusDays(4)) + .setLastTransferTime(minusDays(clock.now(), 12)) + .setLastSuperordinateChange(minusDays(clock.now(), 4)) .build()); setEppHostUpdateInput( "ns1.example.tld", @@ -1234,7 +1235,7 @@ void testFailure_unauthorizedClientReadFromSuperordinate() { void testSuccess_authorizedClientReadFromTransferredSuperordinate() throws Exception { sessionMetadata.setRegistrarId("NewRegistrar"); createTld("tld"); - // Create a domain that will belong to NewRegistrar after cloneProjectedAtTime is called. + // Create a domain that will belong to NewRegistrar after cloneProjectedAtInstant is called. Domain domain = persistResource(createDomainWithServerApprovedTransfer("example.tld")); persistResource( newHost("ns1.example.tld") @@ -1252,7 +1253,7 @@ void testSuccess_authorizedClientReadFromTransferredSuperordinate() throws Excep void testFailure_unauthorizedClientReadFromTransferredSuperordinate() { sessionMetadata.setRegistrarId("TheRegistrar"); createTld("tld"); - // Create a domain that will belong to NewRegistrar after cloneProjectedAtTime is called. + // Create a domain that will belong to NewRegistrar after cloneProjectedAtInstant is called. Domain domain = persistResource(createDomainWithServerApprovedTransfer("example.tld")); persistResource( newHost("ns1.example.tld") @@ -1293,7 +1294,7 @@ void testFailure_newSuperordinateWasTransferredToDifferentRegistrar() throws Exc createTld("foo"); createTld("tld"); Host host = persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.foo")); - // The domain will belong to NewRegistrar after cloneProjectedAtTime is called. + // The domain will belong to NewRegistrar after cloneProjectedAtInstant is called. Domain domain = persistResource(createDomainWithServerApprovedTransfer("example.tld")); assertAboutDomains().that(domain).hasPersistedCurrentSponsorRegistrarId("TheRegistrar"); assertAboutHosts().that(host).hasPersistedCurrentSponsorRegistrarId("TheRegistrar"); @@ -1309,7 +1310,7 @@ void testSuccess_newSuperordinateWasTransferredToCorrectRegistrar() throws Excep sessionMetadata.setRegistrarId("NewRegistrar"); createTld("foo"); createTld("tld"); - // The domain will belong to NewRegistrar after cloneProjectedAtTime is called. + // The domain will belong to NewRegistrar after cloneProjectedAtInstant is called. Domain domain = persistResource(createDomainWithServerApprovedTransfer("example.tld")); Domain superordinate = persistResource( diff --git a/core/src/test/java/google/registry/flows/poll/PollAckFlowTest.java b/core/src/test/java/google/registry/flows/poll/PollAckFlowTest.java index d3ece82ff75..05116f2ac70 100644 --- a/core/src/test/java/google/registry/flows/poll/PollAckFlowTest.java +++ b/core/src/test/java/google/registry/flows/poll/PollAckFlowTest.java @@ -19,6 +19,7 @@ import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.util.DateTimeUtils.END_OF_TIME; +import static google.registry.util.DateTimeUtils.toInstant; import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.collect.ImmutableMap; @@ -67,7 +68,7 @@ private void persistAutorenewPollMessage(DateTime eventTime, DateTime endTime) { new PollMessage.Autorenew.Builder() .setId(MESSAGE_ID) .setRegistrarId(getRegistrarIdForFlow()) - .setEventTime(eventTime) + .setEventTime(toInstant(eventTime)) .setAutorenewEndTime(endTime) .setMsg("Domain was auto-renewed.") .setTargetId("example.com") diff --git a/core/src/test/java/google/registry/flows/poll/PollRequestFlowTest.java b/core/src/test/java/google/registry/flows/poll/PollRequestFlowTest.java index ad4ae6722dd..ef9df13e2ee 100644 --- a/core/src/test/java/google/registry/flows/poll/PollRequestFlowTest.java +++ b/core/src/test/java/google/registry/flows/poll/PollRequestFlowTest.java @@ -20,6 +20,8 @@ import static google.registry.testing.DatabaseHelper.persistNewRegistrar; import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; +import static google.registry.util.DateTimeUtils.minusDays; +import static google.registry.util.DateTimeUtils.plusYears; import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.collect.ImmutableList; @@ -69,10 +71,10 @@ private void persistPendingTransferPollMessage() { .setDomainName("test.example") .setTransferStatus(TransferStatus.SERVER_APPROVED) .setGainingRegistrarId(getRegistrarIdForFlow()) - .setTransferRequestTime(clock.nowUtc().minusDays(5)) + .setTransferRequestTime(minusDays(clock.now(), 5)) .setLosingRegistrarId("TheRegistrar") - .setPendingTransferExpirationTime(clock.nowUtc().minusDays(1)) - .setExtendedRegistrationExpirationTime(clock.nowUtc().plusYears(1)) + .setPendingTransferExpirationTime(minusDays(clock.now(), 1)) + .setExtendedRegistrationExpirationTime(plusYears(clock.now(), 1)) .build())) .setHistoryEntry(createHistoryEntryForEppResource(domain)) .build()); @@ -202,7 +204,7 @@ void testSuccess_hostDelete() throws Exception { persistResource( new HostHistory.Builder() .setRegistrarId("NewRegistrar") - .setModificationTime(clock.nowUtc().minusDays(1)) + .setModificationTime(minusDays(clock.now(), 1)) .setType(HistoryEntry.Type.HOST_DELETE) .setHost(host) .build()); diff --git a/core/src/test/java/google/registry/model/EppResourceTest.java b/core/src/test/java/google/registry/model/EppResourceTest.java index 46e387594b4..6532cc19018 100644 --- a/core/src/test/java/google/registry/model/EppResourceTest.java +++ b/core/src/test/java/google/registry/model/EppResourceTest.java @@ -17,6 +17,7 @@ import static com.google.common.truth.Truth.assertThat; import static google.registry.testing.DatabaseHelper.persistActiveHost; import static google.registry.testing.DatabaseHelper.persistResource; +import static google.registry.util.DateTimeUtils.minusDays; import com.google.common.collect.ImmutableList; import google.registry.model.host.Host; @@ -39,7 +40,7 @@ void test_loadByCacheIfEnabled_ignoresHostChange() { .containsExactly(originalHost.createVKey(), originalHost); Host modifiedHost = persistResource( - originalHost.asBuilder().setLastTransferTime(fakeClock.nowUtc().minusDays(60)).build()); + originalHost.asBuilder().setLastTransferTime(minusDays(fakeClock.now(), 60)).build()); assertThat(EppResource.loadByCacheIfEnabled(ImmutableList.of(originalHost.createVKey()))) .containsExactly(originalHost.createVKey(), originalHost); assertThat(ForeignKeyUtils.loadResource(Host.class, "ns1.example.com", fakeClock.nowUtc())) diff --git a/core/src/test/java/google/registry/model/EppResourceUtilsTest.java b/core/src/test/java/google/registry/model/EppResourceUtilsTest.java index 67e701f653c..89c9dea67fe 100644 --- a/core/src/test/java/google/registry/model/EppResourceUtilsTest.java +++ b/core/src/test/java/google/registry/model/EppResourceUtilsTest.java @@ -19,7 +19,7 @@ import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.newHost; import static google.registry.testing.DatabaseHelper.persistResource; -import static google.registry.util.DateTimeUtils.START_OF_TIME; +import static google.registry.util.DateTimeUtils.START_INSTANT; import static org.joda.time.DateTimeZone.UTC; import google.registry.model.host.Host; @@ -52,7 +52,7 @@ void testLoadAtPointInTime_beforeCreated_returnsNull() { // Don't save a commit log, we shouldn't need one. Host host = persistResource( - newHost("ns1.cat.tld").asBuilder().setCreationTimeForTest(clock.nowUtc()).build()); + newHost("ns1.cat.tld").asBuilder().setCreationTimeForTest(clock.now()).build()); assertThat(loadAtPointInTime(host, clock.nowUtc().minus(Duration.millis(1)))).isNull(); } @@ -62,7 +62,7 @@ void testLoadAtPointInTime_atOrAfterLastAutoUpdateTime_returnsResource() { // Don't save a commit log, we shouldn't need one. Host host = persistResource( - newHost("ns1.cat.tld").asBuilder().setCreationTimeForTest(START_OF_TIME).build()); + newHost("ns1.cat.tld").asBuilder().setCreationTimeForTest(START_INSTANT).build()); assertThat(loadAtPointInTime(host, clock.nowUtc())).isEqualTo(host); } } diff --git a/core/src/test/java/google/registry/model/ForeignKeyUtilsTest.java b/core/src/test/java/google/registry/model/ForeignKeyUtilsTest.java index 7bd40a5df80..d1d88a499b3 100644 --- a/core/src/test/java/google/registry/model/ForeignKeyUtilsTest.java +++ b/core/src/test/java/google/registry/model/ForeignKeyUtilsTest.java @@ -19,6 +19,7 @@ import static google.registry.testing.DatabaseHelper.persistActiveDomain; import static google.registry.testing.DatabaseHelper.persistActiveHost; import static google.registry.testing.DatabaseHelper.persistResource; +import static google.registry.util.DateTimeUtils.minusDays; import static org.joda.time.DateTimeZone.UTC; import com.google.common.collect.ImmutableList; @@ -73,7 +74,7 @@ void testSuccess_loadDomainKey() { @Test void testSuccess_loadKeyMostRecentResource() { Host host = persistActiveHost("ns1.example.com"); - persistResource(host.asBuilder().setDeletionTime(fakeClock.nowUtc().minusDays(1)).build()); + persistResource(host.asBuilder().setDeletionTime(minusDays(fakeClock.now(), 1)).build()); fakeClock.advanceOneMilli(); Host newHost = persistActiveHost("ns1.example.com"); assertThat(ForeignKeyUtils.loadKey(Host.class, "ns1.example.com", fakeClock.nowUtc())) @@ -89,7 +90,7 @@ void testSuccess_loadKeyNonexistentForeignKey_returnsNull() { @Test void testSuccess_loadKeyDeletedForeignKey_returnsNull() { Host host = persistActiveHost("ns1.example.com"); - persistResource(host.asBuilder().setDeletionTime(fakeClock.nowUtc().minusDays(1)).build()); + persistResource(host.asBuilder().setDeletionTime(minusDays(fakeClock.now(), 1)).build()); assertThat(ForeignKeyUtils.loadKey(Host.class, "ns1.example.com", fakeClock.nowUtc())) .isEmpty(); } @@ -98,7 +99,7 @@ void testSuccess_loadKeyDeletedForeignKey_returnsNull() { void testSuccess_mostRecentKeySoftDeleted_returnsNull() { Host host1 = persistActiveHost("ns1.example.com"); fakeClock.advanceOneMilli(); - persistResource(host1.asBuilder().setDeletionTime(fakeClock.nowUtc()).build()); + persistResource(host1.asBuilder().setDeletionTime(fakeClock.now()).build()); assertThat(ForeignKeyUtils.loadKey(Host.class, "ns1.example.com", fakeClock.nowUtc())) .isEmpty(); } @@ -107,14 +108,14 @@ void testSuccess_mostRecentKeySoftDeleted_returnsNull() { void testSuccess_batchLoadKeys_skipsDeletedAndNonexistent() { Host host1 = persistActiveHost("ns1.example.com"); Host host2 = persistActiveHost("ns2.example.com"); - persistResource(host2.asBuilder().setDeletionTime(fakeClock.nowUtc().minusDays(1)).build()); + persistResource(host2.asBuilder().setDeletionTime(minusDays(fakeClock.now(), 1)).build()); assertThat( ForeignKeyUtils.loadKeys( Host.class, ImmutableList.of("ns1.example.com", "ns2.example.com", "ns3.example.com"), fakeClock.nowUtc())) .containsExactlyEntriesIn(ImmutableMap.of("ns1.example.com", host1.createVKey())); - persistResource(host1.asBuilder().setDeletionTime(fakeClock.nowUtc()).build()); + persistResource(host1.asBuilder().setDeletionTime(fakeClock.now()).build()); fakeClock.advanceOneMilli(); Host newHost1 = persistActiveHost("ns1.example.com"); assertThat( @@ -129,14 +130,14 @@ void testSuccess_batchLoadKeys_skipsDeletedAndNonexistent() { void testSuccess_loadHostKeysCached_cacheIsStale() { Host host1 = persistActiveHost("ns1.example.com"); Host host2 = persistActiveHost("ns2.example.com"); - persistResource(host2.asBuilder().setDeletionTime(fakeClock.nowUtc().minusDays(1)).build()); + persistResource(host2.asBuilder().setDeletionTime(minusDays(fakeClock.now(), 1)).build()); assertThat( ForeignKeyUtils.loadKeysByCacheIfEnabled( Host.class, ImmutableList.of("ns1.example.com", "ns2.example.com", "ns3.example.com"), fakeClock.nowUtc())) .containsExactlyEntriesIn(ImmutableMap.of("ns1.example.com", host1.createVKey())); - persistResource(host1.asBuilder().setDeletionTime(fakeClock.nowUtc()).build()); + persistResource(host1.asBuilder().setDeletionTime(fakeClock.now()).build()); fakeClock.advanceOneMilli(); persistActiveHost("ns1.example.com"); // Even though a new host1 is now live, the cache still returns the VKey to the old one. diff --git a/core/src/test/java/google/registry/model/OteStatsTestHelper.java b/core/src/test/java/google/registry/model/OteStatsTestHelper.java index 2b6de4a0408..30d8d53ed37 100644 --- a/core/src/test/java/google/registry/model/OteStatsTestHelper.java +++ b/core/src/test/java/google/registry/model/OteStatsTestHelper.java @@ -23,7 +23,8 @@ import static google.registry.testing.DatabaseHelper.persistPremiumList; import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.TestDataHelper.loadBytes; -import static google.registry.util.DateTimeUtils.END_OF_TIME; +import static google.registry.util.DateTimeUtils.END_INSTANT; +import static google.registry.util.DateTimeUtils.toInstant; import static org.joda.money.CurrencyUnit.USD; import google.registry.model.domain.Domain; @@ -47,7 +48,7 @@ public static void setupCompleteOte(String baseClientId) throws IOException { .setRegistrarId(oteAccount1) .setType(Type.DOMAIN_CREATE) .setXmlBytes(getBytes("domain_create_idn.xml")) - .setModificationTime(now) + .setModificationTime(toInstant(now)) .build()); persistResource( new DomainHistory.Builder() @@ -55,7 +56,7 @@ public static void setupCompleteOte(String baseClientId) throws IOException { .setRegistrarId(oteAccount1) .setType(Type.DOMAIN_RESTORE) .setXmlBytes(getBytes("domain_restore.xml")) - .setModificationTime(now) + .setModificationTime(toInstant(now)) .build()); persistResource( new HostHistory.Builder() @@ -63,7 +64,7 @@ public static void setupCompleteOte(String baseClientId) throws IOException { .setRegistrarId(oteAccount1) .setType(Type.HOST_DELETE) .setXmlBytes(getBytes("host_delete.xml")) - .setModificationTime(now) + .setModificationTime(toInstant(now)) .build()); } @@ -90,7 +91,7 @@ public static void setupIncompleteOte(String baseClientId) throws IOException { .setRegistrarId(oteAccount1) .setType(Type.DOMAIN_CREATE) .setXmlBytes(getBytes("domain_create_sunrise.xml")) - .setModificationTime(now) + .setModificationTime(toInstant(now)) .build()); persistResource( new DomainHistory.Builder() @@ -98,7 +99,7 @@ public static void setupIncompleteOte(String baseClientId) throws IOException { .setRegistrarId(oteAccount1) .setType(Type.DOMAIN_CREATE) .setXmlBytes(getBytes("domain_create_claim_notice.xml")) - .setModificationTime(now) + .setModificationTime(toInstant(now)) .build()); Domain exampleDomain = loadOrCreateDomain("example.tld"); persistResource( @@ -107,7 +108,7 @@ public static void setupIncompleteOte(String baseClientId) throws IOException { .setRegistrarId(oteAccount1) .setType(Type.DOMAIN_CREATE) .setXmlBytes(getBytes("domain_create_anchor_tenant_fee_standard.xml")) - .setModificationTime(now) + .setModificationTime(toInstant(now)) .build()); persistResource( new DomainHistory.Builder() @@ -115,7 +116,7 @@ public static void setupIncompleteOte(String baseClientId) throws IOException { .setRegistrarId(oteAccount1) .setType(Type.DOMAIN_CREATE) .setXmlBytes(getBytes("domain_create_dsdata.xml")) - .setModificationTime(now) + .setModificationTime(toInstant(now)) .build()); persistResource( new DomainHistory.Builder() @@ -123,7 +124,7 @@ public static void setupIncompleteOte(String baseClientId) throws IOException { .setRegistrarId(oteAccount1) .setType(Type.DOMAIN_DELETE) .setXmlBytes(getBytes("domain_delete.xml")) - .setModificationTime(now) + .setModificationTime(toInstant(now)) .build()); persistResource( new DomainHistory.Builder() @@ -131,7 +132,7 @@ public static void setupIncompleteOte(String baseClientId) throws IOException { .setRegistrarId(oteAccount1) .setType(Type.DOMAIN_TRANSFER_APPROVE) .setXmlBytes(getBytes("domain_transfer_approve.xml")) - .setModificationTime(now) + .setModificationTime(toInstant(now)) .build()); persistResource( new DomainHistory.Builder() @@ -139,7 +140,7 @@ public static void setupIncompleteOte(String baseClientId) throws IOException { .setRegistrarId(oteAccount1) .setType(Type.DOMAIN_TRANSFER_CANCEL) .setXmlBytes(getBytes("domain_transfer_cancel.xml")) - .setModificationTime(now) + .setModificationTime(toInstant(now)) .build()); persistResource( new DomainHistory.Builder() @@ -147,7 +148,7 @@ public static void setupIncompleteOte(String baseClientId) throws IOException { .setRegistrarId(oteAccount1) .setType(Type.DOMAIN_TRANSFER_REJECT) .setXmlBytes(getBytes("domain_transfer_reject.xml")) - .setModificationTime(now) + .setModificationTime(toInstant(now)) .build()); persistResource( new DomainHistory.Builder() @@ -155,7 +156,7 @@ public static void setupIncompleteOte(String baseClientId) throws IOException { .setRegistrarId(oteAccount1) .setType(Type.DOMAIN_TRANSFER_REQUEST) .setXmlBytes(getBytes("domain_transfer_request.xml")) - .setModificationTime(now) + .setModificationTime(toInstant(now)) .build()); persistResource( new DomainHistory.Builder() @@ -163,7 +164,7 @@ public static void setupIncompleteOte(String baseClientId) throws IOException { .setRegistrarId(oteAccount1) .setType(Type.DOMAIN_UPDATE) .setXmlBytes(getBytes("domain_update_with_secdns.xml")) - .setModificationTime(now) + .setModificationTime(toInstant(now)) .build()); persistResource( new HostHistory.Builder() @@ -171,7 +172,7 @@ public static void setupIncompleteOte(String baseClientId) throws IOException { .setRegistrarId(oteAccount1) .setType(Type.HOST_CREATE) .setXmlBytes(getBytes("host_create_complete.xml")) - .setModificationTime(now) + .setModificationTime(toInstant(now)) .build()); // Persist 10 host updates for a total of 25 history entries. Since these also sort last by // modification time, when these cause all tests to pass, only the first will be recorded and @@ -184,7 +185,7 @@ public static void setupIncompleteOte(String baseClientId) throws IOException { .setType(Type.HOST_UPDATE) .setXmlBytes(getBytes("host_update.xml")) .setTrid(Trid.create(null, String.format("blahtrid-%d", i))) - .setModificationTime(END_OF_TIME) + .setModificationTime(END_INSTANT) .build()); } } diff --git a/core/src/test/java/google/registry/model/billing/BillingBaseTest.java b/core/src/test/java/google/registry/model/billing/BillingBaseTest.java index fba629a72a4..2a853b67318 100644 --- a/core/src/test/java/google/registry/model/billing/BillingBaseTest.java +++ b/core/src/test/java/google/registry/model/billing/BillingBaseTest.java @@ -21,7 +21,9 @@ import static google.registry.testing.DatabaseHelper.loadByKey; import static google.registry.testing.DatabaseHelper.persistActiveDomain; import static google.registry.testing.DatabaseHelper.persistResource; -import static google.registry.util.DateTimeUtils.END_OF_TIME; +import static google.registry.util.DateTimeUtils.END_INSTANT; +import static google.registry.util.DateTimeUtils.plusDays; +import static google.registry.util.DateTimeUtils.plusYears; import static google.registry.util.SerializeUtils.serializeDeserialize; import static org.joda.money.CurrencyUnit.USD; import static org.joda.time.DateTimeZone.UTC; @@ -43,6 +45,7 @@ import google.registry.persistence.VKey; import google.registry.util.DateTimeUtils; import java.math.BigDecimal; +import java.time.Instant; import org.joda.money.Money; import org.joda.time.DateTime; import org.junit.jupiter.api.BeforeEach; @@ -50,7 +53,7 @@ /** Unit tests for {@link BillingBase}. */ public class BillingBaseTest extends EntityTestCase { - private final DateTime now = DateTime.parse("2012-01-23T22:33:44Z"); + private final Instant now = Instant.parse("2012-01-23T22:33:44Z"); BillingBaseTest() { super(JpaEntityCoverageCheck.ENABLED); @@ -83,7 +86,7 @@ void setUp() { persistResource( new DomainHistory.Builder() .setDomain(domain) - .setModificationTime(now.plusDays(1)) + .setModificationTime(plusDays(now, 1)) .setRequestedByRegistrar(false) .setRegistrarId("TheRegistrar") .setType(HistoryEntry.Type.DOMAIN_CREATE) @@ -114,7 +117,7 @@ void setUp() { .setPeriodYears(2) .setCost(Money.of(USD, 1)) .setEventTime(now) - .setBillingTime(now.plusDays(5)) + .setBillingTime(plusDays(now, 5)) .setAllocationToken(allocationToken.createVKey()))); billingRecurrence = @@ -124,8 +127,8 @@ void setUp() { .setDomainHistory(domainHistory) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setReason(Reason.RENEW) - .setEventTime(now.plusYears(1)) - .setRecurrenceEndTime(END_OF_TIME))); + .setEventTime(plusYears(now, 1)) + .setRecurrenceEndTime(END_INSTANT))); billingEventSynthetic = persistResource( commonInit( @@ -134,12 +137,12 @@ void setUp() { .setReason(Reason.CREATE) .setFlags( ImmutableSet.of(BillingBase.Flag.ANCHOR_TENANT, BillingBase.Flag.SYNTHETIC)) - .setSyntheticCreationTime(now.plusDays(10)) + .setSyntheticCreationTime(plusDays(now, 10)) .setCancellationMatchingBillingEvent(billingRecurrence) .setPeriodYears(2) .setCost(Money.of(USD, 1)) .setEventTime(now) - .setBillingTime(now.plusDays(5)))); + .setBillingTime(plusDays(now, 5)))); cancellationOneTime = persistResource( @@ -147,8 +150,8 @@ void setUp() { new BillingCancellation.Builder() .setDomainHistory(domainHistory2) .setReason(Reason.CREATE) - .setEventTime(now.plusDays(1)) - .setBillingTime(now.plusDays(5)) + .setEventTime(plusDays(now, 1)) + .setBillingTime(plusDays(now, 5)) .setBillingEvent(billingEvent.createVKey()))); cancellationRecurrence = @@ -157,8 +160,8 @@ void setUp() { new BillingCancellation.Builder() .setDomainHistory(domainHistory2) .setReason(Reason.RENEW) - .setEventTime(now.plusDays(1)) - .setBillingTime(now.plusYears(1).plusDays(45)) + .setEventTime(plusDays(now, 1)) + .setBillingTime(plusDays(plusYears(now, 1), 45)) .setBillingRecurrence(billingRecurrence.createVKey()))); } @@ -218,7 +221,7 @@ void testFailure_syntheticCreationTimeWithoutFlag() { IllegalStateException thrown = assertThrows( IllegalStateException.class, - () -> billingEvent.asBuilder().setSyntheticCreationTime(now.plusDays(10)).build()); + () -> billingEvent.asBuilder().setSyntheticCreationTime(plusDays(now, 10)).build()); assertThat(thrown) .hasMessageThat() .contains("Synthetic creation time must be set if and only if the SYNTHETIC flag is set"); @@ -233,7 +236,7 @@ void testFailure_syntheticFlagWithoutCancellationMatchingKey() { billingEvent .asBuilder() .setFlags(ImmutableSet.of(BillingBase.Flag.SYNTHETIC)) - .setSyntheticCreationTime(END_OF_TIME) + .setSyntheticCreationTime(END_INSTANT) .build()); assertThat(thrown) .hasMessageThat() @@ -279,7 +282,7 @@ void testSuccess_cancellation_forGracePeriod_withRecurrence() { GracePeriod.createForRecurrence( GracePeriodStatus.AUTO_RENEW, domain.getRepoId(), - now.plusYears(1).plusDays(45), + plusDays(plusYears(now, 1), 45), "TheRegistrar", billingRecurrence.createVKey()), domainHistory2.getModificationTime(), @@ -300,7 +303,7 @@ void testFailure_cancellation_forGracePeriodWithoutBillingEvent() { GracePeriod.createWithoutBillingEvent( GracePeriodStatus.REDEMPTION, domain.getRepoId(), - now.plusDays(1), + plusDays(now, 1), "a registrar"), domainHistory.getModificationTime(), domainHistory.getHistoryEntryId(), @@ -343,8 +346,8 @@ void testReasonRequiringPeriodYears_missingPeriodYears_throwsException() { IllegalStateException.class, () -> new BillingEvent.Builder() - .setBillingTime(DateTime.parse("2020-02-05T15:33:11Z")) - .setEventTime(DateTime.parse("2020-01-05T15:33:11Z")) + .setBillingTime(Instant.parse("2020-02-05T15:33:11Z")) + .setEventTime(Instant.parse("2020-01-05T15:33:11Z")) .setCost(Money.of(USD, 10)) .setReason(Reason.RENEW) .setCost(Money.of(USD, 10)) @@ -364,8 +367,8 @@ void testReasonNotRequiringPeriodYears_havingPeriodYears_throwsException() { IllegalStateException.class, () -> new BillingEvent.Builder() - .setBillingTime(DateTime.parse("2020-02-05T15:33:11Z")) - .setEventTime(DateTime.parse("2020-01-05T15:33:11Z")) + .setBillingTime(Instant.parse("2020-02-05T15:33:11Z")) + .setEventTime(Instant.parse("2020-01-05T15:33:11Z")) .setCost(Money.of(USD, 10)) .setPeriodYears(2) .setReason(Reason.SERVER_STATUS) @@ -384,8 +387,8 @@ void testReasonRequiringPeriodYears_missingPeriodYears_isAllowedOnOldData() { // This won't throw even though periodYears is missing on a RESTORE because the event time // is before 2019. new BillingEvent.Builder() - .setBillingTime(DateTime.parse("2018-02-05T15:33:11Z")) - .setEventTime(DateTime.parse("2018-01-05T15:33:11Z")) + .setBillingTime(Instant.parse("2018-02-05T15:33:11Z")) + .setEventTime(Instant.parse("2018-01-05T15:33:11Z")) .setReason(Reason.RESTORE) .setCost(Money.of(USD, 10)) .setRegistrarId("TheRegistrar") @@ -409,9 +412,9 @@ void testSuccess_getRenewalPriceBehavior_returnsRightBehavior() { .setDomainHistory(domainHistory) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setReason(Reason.RENEW) - .setEventTime(now.plusYears(1)) + .setEventTime(plusYears(now, 1)) .setRenewalPriceBehavior(RenewalPriceBehavior.NONPREMIUM) - .setRecurrenceEndTime(END_OF_TIME))); + .setRecurrenceEndTime(END_INSTANT))); assertThat(billingRecurrence.getRenewalPriceBehavior()) .isEqualTo(RenewalPriceBehavior.NONPREMIUM); assertThat(billingRecurrence.getRenewalPrice()).isEmpty(); @@ -426,9 +429,9 @@ void testSuccess_setRenewalPriceBehaviorThenBuild_defaultToSpecified() { .setDomainHistory(domainHistory) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setReason(Reason.RENEW) - .setEventTime(now.plusYears(1)) + .setEventTime(plusYears(now, 1)) .setRenewalPriceBehavior(RenewalPriceBehavior.DEFAULT) - .setRecurrenceEndTime(END_OF_TIME))); + .setRecurrenceEndTime(END_INSTANT))); assertThat(billingRecurrence.getRenewalPriceBehavior()).isEqualTo(RenewalPriceBehavior.DEFAULT); assertThat(billingRecurrence.getRenewalPrice()).isEmpty(); BillingRecurrence loadedEntity = loadByEntity(billingRecurrence); @@ -453,9 +456,9 @@ void testSuccess_setRenewalPriceBehaviorThenBuild_defaultToNonPremium() { .setDomainHistory(domainHistory) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setReason(Reason.RENEW) - .setEventTime(now.plusYears(1)) + .setEventTime(plusYears(now, 1)) .setRenewalPriceBehavior(RenewalPriceBehavior.DEFAULT) - .setRecurrenceEndTime(END_OF_TIME))); + .setRecurrenceEndTime(END_INSTANT))); assertThat(billingRecurrence.getRenewalPriceBehavior()).isEqualTo(RenewalPriceBehavior.DEFAULT); assertThat(billingRecurrence.getRenewalPrice()).isEmpty(); BillingRecurrence loadedEntity = loadByEntity(billingRecurrence); @@ -476,9 +479,9 @@ void testSuccess_setRenewalPriceBehaviorThenBuild_nonPremiumToSpecified() { .setDomainHistory(domainHistory) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setReason(Reason.RENEW) - .setEventTime(now.plusYears(1)) + .setEventTime(plusYears(now, 1)) .setRenewalPriceBehavior(RenewalPriceBehavior.NONPREMIUM) - .setRecurrenceEndTime(END_OF_TIME))); + .setRecurrenceEndTime(END_INSTANT))); assertThat(billingRecurrence.getRenewalPriceBehavior()) .isEqualTo(RenewalPriceBehavior.NONPREMIUM); assertThat(billingRecurrence.getRenewalPrice()).isEmpty(); @@ -504,9 +507,9 @@ void testSuccess_setRenewalPriceBehaviorThenBuild_nonPremiumToDefault() { .setDomainHistory(domainHistory) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setReason(Reason.RENEW) - .setEventTime(now.plusYears(1)) + .setEventTime(plusYears(now, 1)) .setRenewalPriceBehavior(RenewalPriceBehavior.NONPREMIUM) - .setRecurrenceEndTime(END_OF_TIME))); + .setRecurrenceEndTime(END_INSTANT))); assertThat(billingRecurrence.getRenewalPriceBehavior()) .isEqualTo(RenewalPriceBehavior.NONPREMIUM); assertThat(billingRecurrence.getRenewalPrice()).isEmpty(); @@ -528,10 +531,10 @@ void testSuccess_setRenewalPriceBehaviorThenBuild_specifiedToDefault() { .setDomainHistory(domainHistory) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setReason(Reason.RENEW) - .setEventTime(now.plusYears(1)) + .setEventTime(plusYears(now, 1)) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setRenewalPrice(Money.of(USD, 100)) - .setRecurrenceEndTime(END_OF_TIME))); + .setRecurrenceEndTime(END_INSTANT))); assertThat(billingRecurrence.getRenewalPriceBehavior()) .isEqualTo(RenewalPriceBehavior.SPECIFIED); assertThat(billingRecurrence.getRenewalPrice()).hasValue(Money.of(USD, 100)); @@ -557,10 +560,10 @@ void testSuccess_setRenewalPriceBehaviorThenBuild_specifiedToNonPremium() { .setDomainHistory(domainHistory) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setReason(Reason.RENEW) - .setEventTime(now.plusYears(1)) + .setEventTime(plusYears(now, 1)) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setRenewalPrice(Money.of(USD, 100)) - .setRecurrenceEndTime(END_OF_TIME))); + .setRecurrenceEndTime(END_INSTANT))); assertThat(billingRecurrence.getRenewalPriceBehavior()) .isEqualTo(RenewalPriceBehavior.SPECIFIED); assertThat(billingRecurrence.getRenewalPrice()).hasValue(Money.of(USD, 100)); @@ -586,9 +589,9 @@ void testFailure_setRenewalPriceBehaviorThenBuild_defaultToSpecified_needRenewal .setDomainHistory(domainHistory) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setReason(Reason.RENEW) - .setEventTime(now.plusYears(1)) + .setEventTime(plusYears(now, 1)) .setRenewalPriceBehavior(RenewalPriceBehavior.DEFAULT) - .setRecurrenceEndTime(END_OF_TIME))); + .setRecurrenceEndTime(END_INSTANT))); assertThat(billingRecurrence.getRenewalPriceBehavior()).isEqualTo(RenewalPriceBehavior.DEFAULT); assertThat(billingRecurrence.getRenewalPrice()).isEmpty(); BillingRecurrence loadedEntity = loadByEntity(billingRecurrence); @@ -617,9 +620,9 @@ void testFailure_setRenewalPriceBehaviorThenBuild_defaultToPremium_noNeedToAddRe .setDomainHistory(domainHistory) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setReason(Reason.RENEW) - .setEventTime(now.plusYears(1)) + .setEventTime(plusYears(now, 1)) .setRenewalPriceBehavior(RenewalPriceBehavior.DEFAULT) - .setRecurrenceEndTime(END_OF_TIME))); + .setRecurrenceEndTime(END_INSTANT))); assertThat(billingRecurrence.getRenewalPriceBehavior()).isEqualTo(RenewalPriceBehavior.DEFAULT); assertThat(billingRecurrence.getRenewalPrice()).isEmpty(); BillingRecurrence loadedEntity = loadByEntity(billingRecurrence); @@ -649,9 +652,9 @@ void testFailure_setRenewalPriceBehaviorThenBuild_nonPremiumToDefault_noNeedToAd .setDomainHistory(domainHistory) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setReason(Reason.RENEW) - .setEventTime(now.plusYears(1)) + .setEventTime(plusYears(now, 1)) .setRenewalPriceBehavior(RenewalPriceBehavior.NONPREMIUM) - .setRecurrenceEndTime(END_OF_TIME))); + .setRecurrenceEndTime(END_INSTANT))); assertThat(billingRecurrence.getRenewalPriceBehavior()) .isEqualTo(RenewalPriceBehavior.NONPREMIUM); assertThat(billingRecurrence.getRenewalPrice()).isEmpty(); @@ -682,9 +685,9 @@ void testFailure_setRenewalPriceBehaviorThenBuild_nonPremiumToSpecified_needRene .setDomainHistory(domainHistory) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setReason(Reason.RENEW) - .setEventTime(now.plusYears(1)) + .setEventTime(plusYears(now, 1)) .setRenewalPriceBehavior(RenewalPriceBehavior.NONPREMIUM) - .setRecurrenceEndTime(END_OF_TIME))); + .setRecurrenceEndTime(END_INSTANT))); assertThat(billingRecurrence.getRenewalPriceBehavior()) .isEqualTo(RenewalPriceBehavior.NONPREMIUM); assertThat(billingRecurrence.getRenewalPrice()).isEmpty(); @@ -714,10 +717,10 @@ void testFailure_setRenewalPriceBehaviorThenBuild_specifiedToNonPremium_removeRe .setDomainHistory(domainHistory) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setReason(Reason.RENEW) - .setEventTime(now.plusYears(1)) + .setEventTime(plusYears(now, 1)) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setRenewalPrice(Money.of(USD, 100)) - .setRecurrenceEndTime(END_OF_TIME))); + .setRecurrenceEndTime(END_INSTANT))); assertThat(billingRecurrence.getRenewalPriceBehavior()) .isEqualTo(RenewalPriceBehavior.SPECIFIED); assertThat(billingRecurrence.getRenewalPrice()).hasValue(Money.of(USD, 100)); @@ -747,10 +750,10 @@ void testFailure_setRenewalPriceBehaviorThenBuild_specifiedToDefault_removeRenew .setDomainHistory(domainHistory) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setReason(Reason.RENEW) - .setEventTime(now.plusYears(1)) + .setEventTime(plusYears(now, 1)) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setRenewalPrice(Money.of(USD, 100)) - .setRecurrenceEndTime(END_OF_TIME))); + .setRecurrenceEndTime(END_INSTANT))); assertThat(billingRecurrence.getRenewalPriceBehavior()) .isEqualTo(RenewalPriceBehavior.SPECIFIED); assertThat(billingRecurrence.getRenewalPrice()).hasValue(Money.of(USD, 100)); @@ -780,10 +783,10 @@ void testSuccess_buildWithDefaultRenewalBehavior() { .setDomainHistory(domainHistory) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setReason(Reason.RENEW) - .setEventTime(now.plusYears(1)) + .setEventTime(plusYears(now, 1)) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setRenewalPrice(Money.of(USD, BigDecimal.valueOf(100))) - .setRecurrenceEndTime(END_OF_TIME))); + .setRecurrenceEndTime(END_INSTANT))); assertThat(billingRecurrence.getRenewalPriceBehavior()) .isEqualTo(RenewalPriceBehavior.SPECIFIED); assertThat(billingRecurrence.getRenewalPrice()).hasValue(Money.of(USD, 100)); @@ -799,9 +802,9 @@ void testSuccess_buildWithNonPremiumRenewalBehavior() { .setDomainHistory(domainHistory) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setReason(Reason.RENEW) - .setEventTime(now.plusYears(1)) + .setEventTime(plusYears(now, 1)) .setRenewalPriceBehavior(RenewalPriceBehavior.NONPREMIUM) - .setRecurrenceEndTime(END_OF_TIME))); + .setRecurrenceEndTime(END_INSTANT))); assertThat(billingRecurrence.getRenewalPriceBehavior()) .isEqualTo(RenewalPriceBehavior.NONPREMIUM); assertThat(loadByEntity(billingRecurrence).getRenewalPrice()).isEmpty(); @@ -816,10 +819,10 @@ void testSuccess_buildWithSpecifiedRenewalBehavior() { .setDomainHistory(domainHistory) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setReason(Reason.RENEW) - .setEventTime(now.plusYears(1)) + .setEventTime(plusYears(now, 1)) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setRenewalPrice(Money.of(USD, BigDecimal.valueOf(100))) - .setRecurrenceEndTime(END_OF_TIME))); + .setRecurrenceEndTime(END_INSTANT))); assertThat(billingRecurrence.getRenewalPriceBehavior()) .isEqualTo(RenewalPriceBehavior.SPECIFIED); assertThat(billingRecurrence.getRenewalPrice()).hasValue(Money.of(USD, 100)); @@ -835,9 +838,9 @@ void testFailure_buildWithSpecifiedRenewalBehavior_requiresNonNullRenewalPrice() .setDomainHistory(domainHistory) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setReason(Reason.RENEW) - .setEventTime(now.plusYears(1)) + .setEventTime(plusYears(now, 1)) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) - .setRecurrenceEndTime(END_OF_TIME) + .setRecurrenceEndTime(END_INSTANT) .build()); assertThat(thrown) .hasMessageThat() @@ -856,10 +859,10 @@ void testFailure_buildWithNonPremiumRenewalBehavior_requiresNullRenewalPrice() { .setDomainHistory(domainHistory) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setReason(Reason.RENEW) - .setEventTime(now.plusYears(1)) + .setEventTime(plusYears(now, 1)) .setRenewalPriceBehavior(RenewalPriceBehavior.NONPREMIUM) .setRenewalPrice(Money.of(USD, BigDecimal.valueOf(100))) - .setRecurrenceEndTime(END_OF_TIME) + .setRecurrenceEndTime(END_INSTANT) .build()); assertThat(thrown) .hasMessageThat() @@ -878,10 +881,10 @@ void testFailure_buildWithDefaultRenewalBehavior_requiresNullRenewalPrice() { .setDomainHistory(domainHistory) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setReason(Reason.RENEW) - .setEventTime(now.plusYears(1)) + .setEventTime(plusYears(now, 1)) .setRenewalPriceBehavior(RenewalPriceBehavior.DEFAULT) .setRenewalPrice(Money.of(USD, BigDecimal.valueOf(100))) - .setRecurrenceEndTime(END_OF_TIME) + .setRecurrenceEndTime(END_INSTANT) .build()); assertThat(thrown) .hasMessageThat() diff --git a/core/src/test/java/google/registry/model/common/TimeOfYearTest.java b/core/src/test/java/google/registry/model/common/TimeOfYearTest.java index c44f33e8832..0c08a1c7678 100644 --- a/core/src/test/java/google/registry/model/common/TimeOfYearTest.java +++ b/core/src/test/java/google/registry/model/common/TimeOfYearTest.java @@ -15,125 +15,136 @@ package google.registry.model.common; import static com.google.common.truth.Truth.assertThat; -import static google.registry.util.DateTimeUtils.END_OF_TIME; -import static google.registry.util.DateTimeUtils.START_OF_TIME; +import static google.registry.util.DateTimeUtils.END_INSTANT; +import static google.registry.util.DateTimeUtils.START_INSTANT; +import static google.registry.util.DateTimeUtils.minusYears; +import static google.registry.util.DateTimeUtils.plusYears; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Range; -import org.joda.time.DateTime; +import java.time.Duration; +import java.time.Instant; import org.junit.jupiter.api.Test; /** Unit tests for {@link TimeOfYear}. */ class TimeOfYearTest { - private static final DateTime february28 = DateTime.parse("2012-02-28T01:02:03.0Z"); - private static final DateTime february29 = DateTime.parse("2012-02-29T01:02:03.0Z"); - private static final DateTime march1 = DateTime.parse("2012-03-01T01:02:03.0Z"); + private static final Instant february28 = Instant.parse("2012-02-28T01:02:03.0Z"); + private static final Instant february29 = Instant.parse("2012-02-29T01:02:03.0Z"); + private static final Instant march1 = Instant.parse("2012-03-01T01:02:03.0Z"); @Test - void testSuccess_fromDateTime() { + void testSuccess_fromInstant() { // We intentionally don't allow leap years in TimeOfYear, so February 29 should be February 28. - assertThat(TimeOfYear.fromDateTime(february28)).isEqualTo(TimeOfYear.fromDateTime(february29)); - assertThat(TimeOfYear.fromDateTime(february29)).isNotEqualTo(TimeOfYear.fromDateTime(march1)); + assertThat(TimeOfYear.fromInstant(february28)).isEqualTo(TimeOfYear.fromInstant(february29)); + assertThat(TimeOfYear.fromInstant(february29)).isNotEqualTo(TimeOfYear.fromInstant(march1)); } @Test void testSuccess_nextAfter() { // This should be lossless because atOrAfter includes an exact match. - assertThat(TimeOfYear.fromDateTime(march1).getNextInstanceAtOrAfter(march1)).isEqualTo(march1); + assertThat(TimeOfYear.fromInstant(march1).getNextInstanceAtOrAfter(march1)).isEqualTo(march1); // This should be a year later because we stepped forward a millisecond - assertThat(TimeOfYear.fromDateTime(march1).getNextInstanceAtOrAfter(march1.plusMillis(1))) - .isEqualTo(march1.plusYears(1)); + assertThat( + TimeOfYear.fromInstant(march1) + .getNextInstanceAtOrAfter(march1.plus(Duration.ofMillis(1)))) + .isEqualTo(plusYears(march1, 1)); } @Test void testSuccess_nextBefore() { // This should be lossless because beforeOrAt includes an exact match. - assertThat(TimeOfYear.fromDateTime(march1).getLastInstanceBeforeOrAt(march1)).isEqualTo(march1); + assertThat(TimeOfYear.fromInstant(march1).getLastInstanceBeforeOrAt(march1)).isEqualTo(march1); // This should be a year earlier because we stepped backward a millisecond - assertThat(TimeOfYear.fromDateTime(march1).getLastInstanceBeforeOrAt(march1.minusMillis(1))) - .isEqualTo(march1.minusYears(1)); + assertThat( + TimeOfYear.fromInstant(march1) + .getLastInstanceBeforeOrAt(march1.minus(Duration.ofMillis(1)))) + .isEqualTo(minusYears(march1, 1)); } @Test void testSuccess_getInstancesInRange_closed() { - DateTime startDate = DateTime.parse("2012-05-01T00:00:00Z"); - DateTime endDate = DateTime.parse("2016-05-01T00:00:00Z"); - TimeOfYear timeOfYear = TimeOfYear.fromDateTime(DateTime.parse("2012-05-01T00:00:00Z")); - ImmutableSet expected = ImmutableSet.of( - DateTime.parse("2012-05-01T00:00:00Z"), - DateTime.parse("2013-05-01T00:00:00Z"), - DateTime.parse("2014-05-01T00:00:00Z"), - DateTime.parse("2015-05-01T00:00:00Z"), - DateTime.parse("2016-05-01T00:00:00Z")); + Instant startDate = Instant.parse("2012-05-01T00:00:00Z"); + Instant endDate = Instant.parse("2016-05-01T00:00:00Z"); + TimeOfYear timeOfYear = TimeOfYear.fromInstant(Instant.parse("2012-05-01T00:00:00Z")); + ImmutableSet expected = + ImmutableSet.of( + Instant.parse("2012-05-01T00:00:00Z"), + Instant.parse("2013-05-01T00:00:00Z"), + Instant.parse("2014-05-01T00:00:00Z"), + Instant.parse("2015-05-01T00:00:00Z"), + Instant.parse("2016-05-01T00:00:00Z")); assertThat(timeOfYear.getInstancesInRange(Range.closed(startDate, endDate))) .containsExactlyElementsIn(expected); } @Test void testSuccess_getInstancesInRange_openClosed() { - DateTime startDate = DateTime.parse("2012-05-01T00:00:00Z"); - DateTime endDate = DateTime.parse("2016-05-01T00:00:00Z"); - TimeOfYear timeOfYear = TimeOfYear.fromDateTime(DateTime.parse("2012-05-01T00:00:00Z")); - ImmutableSet expected = ImmutableSet.of( - DateTime.parse("2013-05-01T00:00:00Z"), - DateTime.parse("2014-05-01T00:00:00Z"), - DateTime.parse("2015-05-01T00:00:00Z"), - DateTime.parse("2016-05-01T00:00:00Z")); + Instant startDate = Instant.parse("2012-05-01T00:00:00Z"); + Instant endDate = Instant.parse("2016-05-01T00:00:00Z"); + TimeOfYear timeOfYear = TimeOfYear.fromInstant(Instant.parse("2012-05-01T00:00:00Z")); + ImmutableSet expected = + ImmutableSet.of( + Instant.parse("2013-05-01T00:00:00Z"), + Instant.parse("2014-05-01T00:00:00Z"), + Instant.parse("2015-05-01T00:00:00Z"), + Instant.parse("2016-05-01T00:00:00Z")); assertThat(timeOfYear.getInstancesInRange(Range.openClosed(startDate, endDate))) .containsExactlyElementsIn(expected); } @Test void testSuccess_getInstancesInRange_closedOpen() { - DateTime startDate = DateTime.parse("2012-05-01T00:00:00Z"); - DateTime endDate = DateTime.parse("2016-05-01T00:00:00Z"); - TimeOfYear timeOfYear = TimeOfYear.fromDateTime(DateTime.parse("2012-05-01T00:00:00Z")); - ImmutableSet expected = ImmutableSet.of( - DateTime.parse("2012-05-01T00:00:00Z"), - DateTime.parse("2013-05-01T00:00:00Z"), - DateTime.parse("2014-05-01T00:00:00Z"), - DateTime.parse("2015-05-01T00:00:00Z")); + Instant startDate = Instant.parse("2012-05-01T00:00:00Z"); + Instant endDate = Instant.parse("2016-05-01T00:00:00Z"); + TimeOfYear timeOfYear = TimeOfYear.fromInstant(Instant.parse("2012-05-01T00:00:00Z")); + ImmutableSet expected = + ImmutableSet.of( + Instant.parse("2012-05-01T00:00:00Z"), + Instant.parse("2013-05-01T00:00:00Z"), + Instant.parse("2014-05-01T00:00:00Z"), + Instant.parse("2015-05-01T00:00:00Z")); assertThat(timeOfYear.getInstancesInRange(Range.closedOpen(startDate, endDate))) .containsExactlyElementsIn(expected); } @Test void testSuccess_getInstancesInRange_open() { - DateTime startDate = DateTime.parse("2012-05-01T00:00:00Z"); - DateTime endDate = DateTime.parse("2016-05-01T00:00:00Z"); - TimeOfYear timeOfYear = TimeOfYear.fromDateTime(DateTime.parse("2012-05-01T00:00:00Z")); - ImmutableSet expected = ImmutableSet.of( - DateTime.parse("2013-05-01T00:00:00Z"), - DateTime.parse("2014-05-01T00:00:00Z"), - DateTime.parse("2015-05-01T00:00:00Z")); + Instant startDate = Instant.parse("2012-05-01T00:00:00Z"); + Instant endDate = Instant.parse("2016-05-01T00:00:00Z"); + TimeOfYear timeOfYear = TimeOfYear.fromInstant(Instant.parse("2012-05-01T00:00:00Z")); + ImmutableSet expected = + ImmutableSet.of( + Instant.parse("2013-05-01T00:00:00Z"), + Instant.parse("2014-05-01T00:00:00Z"), + Instant.parse("2015-05-01T00:00:00Z")); assertThat(timeOfYear.getInstancesInRange(Range.open(startDate, endDate))) .containsExactlyElementsIn(expected); } @Test void testSuccess_getInstancesInRange_normalizedLowerBound() { - TimeOfYear timeOfYear = TimeOfYear.fromDateTime(START_OF_TIME); - ImmutableSet expected = - ImmutableSet.of(START_OF_TIME, START_OF_TIME.plusYears(1), START_OF_TIME.plusYears(2)); - assertThat(timeOfYear.getInstancesInRange(Range.atMost(START_OF_TIME.plusYears(2)))) + TimeOfYear timeOfYear = TimeOfYear.fromInstant(START_INSTANT); + ImmutableSet expected = + ImmutableSet.of(START_INSTANT, plusYears(START_INSTANT, 1), plusYears(START_INSTANT, 2)); + assertThat(timeOfYear.getInstancesInRange(Range.atMost(plusYears(START_INSTANT, 2)))) .containsExactlyElementsIn(expected); } @Test void testSuccess_getInstancesInRange_normalizedUpperBound() { - TimeOfYear timeOfYear = TimeOfYear.fromDateTime(END_OF_TIME); - ImmutableSet expected = - ImmutableSet.of(END_OF_TIME.minusYears(2), END_OF_TIME.minusYears(1), END_OF_TIME); - assertThat(timeOfYear.getInstancesInRange(Range.atLeast(END_OF_TIME.minusYears(2)))) + TimeOfYear timeOfYear = TimeOfYear.fromInstant(END_INSTANT); + ImmutableSet expected = + ImmutableSet.of(minusYears(END_INSTANT, 2), minusYears(END_INSTANT, 1), END_INSTANT); + assertThat(timeOfYear.getInstancesInRange(Range.atLeast(minusYears(END_INSTANT, 2)))) .containsExactlyElementsIn(expected); } @Test void testSuccess_getInstancesOfTimeOfYearInRange_empty() { - DateTime startDate = DateTime.parse("2012-05-01T00:00:00Z"); - DateTime endDate = DateTime.parse("2013-02-01T00:00:00Z"); - TimeOfYear timeOfYear = TimeOfYear.fromDateTime(DateTime.parse("2012-03-01T00:00:00Z")); + Instant startDate = Instant.parse("2012-05-01T00:00:00Z"); + Instant endDate = Instant.parse("2013-02-01T00:00:00Z"); + TimeOfYear timeOfYear = TimeOfYear.fromInstant(Instant.parse("2012-03-01T00:00:00Z")); assertThat(timeOfYear.getInstancesInRange(Range.closed(startDate, endDate))).isEmpty(); } } 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 5c2919f36bd..7674216ab58 100644 --- a/core/src/test/java/google/registry/model/domain/DomainTest.java +++ b/core/src/test/java/google/registry/model/domain/DomainTest.java @@ -29,12 +29,13 @@ import static google.registry.testing.DatabaseHelper.persistResources; import static google.registry.testing.DomainSubject.assertAboutDomains; import static google.registry.testing.SqlHelper.saveRegistrar; -import static google.registry.util.DateTimeUtils.END_OF_TIME; +import static google.registry.util.DateTimeUtils.END_INSTANT; import static google.registry.util.DateTimeUtils.START_OF_TIME; import static google.registry.util.DateTimeUtils.minusDays; import static google.registry.util.DateTimeUtils.plusDays; import static google.registry.util.DateTimeUtils.plusYears; import static google.registry.util.DateTimeUtils.toDateTime; +import static google.registry.util.DateTimeUtils.toInstant; import static org.joda.money.CurrencyUnit.USD; import static org.joda.time.DateTimeZone.UTC; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -71,6 +72,7 @@ import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationWithCoverageExtension; import google.registry.testing.DatabaseHelper; import google.registry.testing.FakeClock; +import java.time.Duration; import java.time.Instant; import java.time.ZoneOffset; import java.util.Optional; @@ -108,7 +110,7 @@ void setUp() { persistResource( new DomainHistory.Builder() .setDomain(domain) - .setModificationTime(fakeClock.nowUtc()) + .setModificationTime(fakeClock.now()) .setType(HistoryEntry.Type.DOMAIN_CREATE) .setRegistrarId("TheRegistrar") .build()); @@ -119,9 +121,9 @@ void setUp() { .setReason(Reason.SERVER_STATUS) .setTargetId(domain.getDomainName()) .setRegistrarId(domain.getCurrentSponsorRegistrarId()) - .setBillingTime(DateTime.now(UTC)) + .setBillingTime(fakeClock.now()) .setCost(Money.of(USD, 100)) - .setEventTime(DateTime.now(UTC).plusYears(1)) + .setEventTime(plusYears(fakeClock.now(), 1)) .setDomainHistory(domainHistory) .build()) .createVKey(); @@ -130,7 +132,7 @@ void setUp() { .setRevisionId(100L) .setType(HistoryEntry.Type.DOMAIN_CREATE) .setPeriod(Period.create(1, Period.Unit.YEARS)) - .setModificationTime(DateTime.now(UTC)) + .setModificationTime(Instant.now()) .setDomain(domain) .setRegistrarId(domain.getCurrentSponsorRegistrarId()) // These are non-null, but I don't think some tests set them. @@ -145,9 +147,9 @@ void setUp() { .setReason(Reason.SERVER_STATUS) .setTargetId("example.com") .setRegistrarId("registrar1") - .setBillingTime(DateTime.now(UTC)) + .setBillingTime(fakeClock.now()) .setCost(Money.of(USD, 100)) - .setEventTime(DateTime.now(UTC).plusYears(1)) + .setEventTime(plusYears(fakeClock.now(), 1)) .setDomainHistory(historyEntry) .build(); oneTimeBillKey = billingEventBill.createVKey(); @@ -158,8 +160,8 @@ void setUp() { .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId(domain.getDomainName()) .setRegistrarId(domain.getCurrentSponsorRegistrarId()) - .setEventTime(DateTime.now(UTC).plusYears(1)) - .setRecurrenceEndTime(END_OF_TIME) + .setEventTime(plusYears(fakeClock.now(), 1)) + .setRecurrenceEndTime(END_INSTANT) .setDomainHistory(historyEntry) .build(); persistResources(historyEntry, billingEventBill, billingRecurrence); @@ -173,7 +175,7 @@ void setUp() { domain .asBuilder() .setCreationRegistrarId("TheRegistrar") - .setLastEppUpdateTime(fakeClock.nowUtc()) + .setLastEppUpdateTime(fakeClock.now()) .setLastEppUpdateRegistrarId("NewRegistrar") .setPersistedCurrentSponsorRegistrarId("NewRegistrar") .setLastTransferTime(fakeClock.nowUtc()) @@ -197,7 +199,7 @@ void setUp() { new DomainTransferData.Builder() .setGainingRegistrarId("TheRegistrar") .setLosingRegistrarId("NewRegistrar") - .setPendingTransferExpirationTime(fakeClock.nowUtc()) + .setPendingTransferExpirationTime(fakeClock.now()) .setServerApproveEntities( historyEntry.getRepoId(), historyEntry.getRevisionId(), @@ -206,7 +208,7 @@ void setUp() { .setServerApproveBillingEvent(oneTimeBillKey) .setServerApproveAutorenewEvent(recurrenceBillKey) .setServerApproveAutorenewPollMessage(autorenewPollKey) - .setTransferRequestTime(fakeClock.nowUtc().plusDays(1)) + .setTransferRequestTime(plusDays(fakeClock.now(), 1)) .setTransferStatus(TransferStatus.SERVER_APPROVED) .setTransferRequestTrid(Trid.create("client-trid", "server-trid")) .build()) @@ -218,7 +220,7 @@ void setUp() { GracePeriod.create( GracePeriodStatus.ADD, domain.getRepoId(), - fakeClock.nowUtc().plusDays(1), + plusDays(fakeClock.now(), 1), "TheRegistrar", oneTimeBillKey)) .setAutorenewEndTime(Optional.of(fakeClock.nowUtc().plusYears(2))) @@ -401,7 +403,7 @@ private void doExpiredTransferTest(DateTime oldExpirationTime) { persistResource( new DomainHistory.Builder() .setDomain(domain) - .setModificationTime(fakeClock.nowUtc()) + .setModificationTime(fakeClock.now()) .setRegistrarId(domain.getCurrentSponsorRegistrarId()) .setType(HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST) .build()); @@ -411,12 +413,13 @@ private void doExpiredTransferTest(DateTime oldExpirationTime) { .setReason(Reason.TRANSFER) .setRegistrarId("TheRegistrar") .setTargetId(domain.getDomainName()) - .setEventTime(fakeClock.nowUtc()) + .setEventTime(fakeClock.now()) .setBillingTime( fakeClock - .nowUtc() - .plusDays(1) - .plus(Tld.get("com").getTransferGracePeriodLength())) + .now() + .plusMillis( + Duration.ofDays(1).toMillis() + + Tld.get("com").getTransferGracePeriodLength().getMillis())) .setCost(Money.of(USD, 11)) .setPeriodYears(1) .setDomainHistory(historyEntry) @@ -430,8 +433,8 @@ private void doExpiredTransferTest(DateTime oldExpirationTime) { .getTransferData() .asBuilder() .setTransferStatus(TransferStatus.PENDING) - .setTransferRequestTime(fakeClock.nowUtc().minusDays(4)) - .setPendingTransferExpirationTime(fakeClock.nowUtc().plusDays(1)) + .setTransferRequestTime(minusDays(fakeClock.now(), 4)) + .setPendingTransferExpirationTime(plusDays(fakeClock.now(), 1)) .setGainingRegistrarId("TheRegistrar") .setServerApproveBillingEvent(transferBillingEvent.createVKey()) .setServerApproveEntities( @@ -445,7 +448,7 @@ private void doExpiredTransferTest(DateTime oldExpirationTime) { GracePeriod.create( GracePeriodStatus.ADD, domain.getRepoId(), - fakeClock.nowUtc().plusDays(100), + plusDays(fakeClock.now(), 100), "TheRegistrar", oneTimeBillKey)) .build(); @@ -459,7 +462,11 @@ private void doExpiredTransferTest(DateTime oldExpirationTime) { GracePeriod.create( GracePeriodStatus.TRANSFER, domain.getRepoId(), - fakeClock.nowUtc().plusDays(1).plus(Tld.get("com").getTransferGracePeriodLength()), + fakeClock + .now() + .plusMillis( + Duration.ofDays(1).toMillis() + + Tld.get("com").getTransferGracePeriodLength().getMillis()), "TheRegistrar", transferBillingEvent.createVKey(), afterTransfer.getGracePeriods().iterator().next().getGracePeriodId())); @@ -495,10 +502,10 @@ private void setupPendingTransferDomain( .getTransferData() .asBuilder() .setTransferStatus(TransferStatus.PENDING) - .setTransferRequestTime(toDateTime(transferRequestTime)) - .setPendingTransferExpirationTime(toDateTime(transferSuccessTime)) + .setTransferRequestTime(transferRequestTime) + .setPendingTransferExpirationTime(transferSuccessTime) .build()) - .setLastEppUpdateTime(toDateTime(transferRequestTime)) + .setLastEppUpdateTime(transferRequestTime) .setLastEppUpdateRegistrarId(domain.getTransferData().getGainingRegistrarId()) .build(); } @@ -559,11 +566,11 @@ void testEppLastUpdateTimeAndClientId_isSetCorrectlyWithNullPreviousValue() { setupUnmodifiedDomain(autorenewDateTime); Domain beforeAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.minusDays(1)); - assertThat(beforeAutoRenew.getLastEppUpdateDateTime()).isEqualTo(null); + assertThat(beforeAutoRenew.getLastEppUpdateTime()).isEqualTo(null); assertThat(beforeAutoRenew.getLastEppUpdateRegistrarId()).isEqualTo(null); Domain afterAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.plusDays(1)); - assertThat(afterAutoRenew.getLastEppUpdateDateTime()).isEqualTo(autorenewDateTime); + assertThat(afterAutoRenew.getLastEppUpdateTime()).isEqualTo(toInstant(autorenewDateTime)); assertThat(afterAutoRenew.getLastEppUpdateRegistrarId()).isEqualTo("NewRegistrar"); } @@ -574,19 +581,19 @@ void testStackedGracePeriods() { GracePeriod.create( GracePeriodStatus.ADD, domain.getRepoId(), - fakeClock.nowUtc().plusDays(3), + plusDays(fakeClock.now(), 3), "foo", null), GracePeriod.create( GracePeriodStatus.ADD, domain.getRepoId(), - fakeClock.nowUtc().plusDays(2), + plusDays(fakeClock.now(), 2), "bar", null), GracePeriod.create( GracePeriodStatus.ADD, domain.getRepoId(), - fakeClock.nowUtc().plusDays(1), + plusDays(fakeClock.now(), 1), "baz", null)); domain = domain.asBuilder().setGracePeriods(ImmutableSet.copyOf(gracePeriods)).build(); @@ -603,13 +610,13 @@ void testGracePeriodsByType() { GracePeriod.create( GracePeriodStatus.ADD, domain.getRepoId(), - fakeClock.nowUtc().plusDays(3), + plusDays(fakeClock.now(), 3), "foo", null), GracePeriod.create( GracePeriodStatus.ADD, domain.getRepoId(), - fakeClock.nowUtc().plusDays(1), + plusDays(fakeClock.now(), 1), "baz", null)); ImmutableSet renewGracePeriods = @@ -617,13 +624,13 @@ void testGracePeriodsByType() { GracePeriod.create( GracePeriodStatus.RENEW, domain.getRepoId(), - fakeClock.nowUtc().plusDays(3), + plusDays(fakeClock.now(), 3), "foo", null), GracePeriod.create( GracePeriodStatus.RENEW, domain.getRepoId(), - fakeClock.nowUtc().plusDays(1), + plusDays(fakeClock.now(), 1), "baz", null)); domain = @@ -690,14 +697,17 @@ void testMultipleAutoRenews() { Domain renewedThreeTimes = domain.cloneProjectedAtTime(oldExpirationTime.plusYears(2)); assertThat(renewedThreeTimes.getRegistrationExpirationDateTime()) .isEqualTo(oldExpirationTime.plusYears(3)); - assertThat(renewedThreeTimes.getLastEppUpdateDateTime()) - .isEqualTo(oldExpirationTime.plusYears(2)); + assertThat(renewedThreeTimes.getLastEppUpdateTime()) + .isEqualTo(toInstant(oldExpirationTime.plusYears(2))); assertThat(renewedThreeTimes.getGracePeriods()) .containsExactly( GracePeriod.createForRecurrence( GracePeriodStatus.AUTO_RENEW, domain.getRepoId(), - oldExpirationTime.plusYears(2).plus(Tld.get("com").getAutoRenewGracePeriodLength()), + toInstant( + oldExpirationTime + .plusYears(2) + .plus(Tld.get("com").getAutoRenewGracePeriodLength())), renewedThreeTimes.getCurrentSponsorRegistrarId(), renewedThreeTimes.autorenewBillingEvent, renewedThreeTimes.getGracePeriods().iterator().next().getGracePeriodId())); @@ -736,7 +746,7 @@ void testClone_doNotExtendExpirationOnDeletedDomain() { domain .asBuilder() .setRegistrationExpirationTime(now.minusDays(1)) - .setDeletionTime(now.minusDays(10)) + .setDeletionTime(toInstant(now.minusDays(10))) .setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE, StatusValue.INACTIVE)) .build()); assertThat(domain.cloneProjectedAtTime(now).getRegistrationExpirationDateTime()) @@ -752,7 +762,7 @@ void testClone_doNotExtendExpirationOnFutureDeletedDomain() { domain .asBuilder() .setRegistrationExpirationTime(now.plusDays(1)) - .setDeletionTime(now.plusDays(20)) + .setDeletionTime(toInstant(now.plusDays(20))) .setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE, StatusValue.INACTIVE)) .build()); assertThat(domain.cloneProjectedAtTime(now).getRegistrationExpirationDateTime()) @@ -768,7 +778,7 @@ void testClone_extendsExpirationForExpiredTransferredDomain() { DomainTransferData transferData = new DomainTransferData.Builder() - .setPendingTransferExpirationTime(transferExpirationTime) + .setPendingTransferExpirationTime(toInstant(transferExpirationTime)) .setTransferStatus(TransferStatus.PENDING) .setGainingRegistrarId("TheRegistrar") .build(); @@ -796,7 +806,7 @@ void testClone_extendsExpirationForNonExpiredTransferredDomain() { DomainTransferData transferData = new DomainTransferData.Builder() - .setPendingTransferExpirationTime(transferExpirationTime) + .setPendingTransferExpirationTime(toInstant(transferExpirationTime)) .setTransferStatus(TransferStatus.PENDING) .setGainingRegistrarId("TheRegistrar") .build(); @@ -824,7 +834,7 @@ void testClone_removesBulkTokenFromTransferredDomain() { DomainTransferData transferData = new DomainTransferData.Builder() - .setPendingTransferExpirationTime(transferExpirationTime) + .setPendingTransferExpirationTime(toInstant(transferExpirationTime)) .setTransferStatus(TransferStatus.PENDING) .setGainingRegistrarId("TheRegistrar") .build(); @@ -865,7 +875,7 @@ void testClone_doesNotExtendExpirationForPendingTransfer() { DomainTransferData transferData = new DomainTransferData.Builder() - .setPendingTransferExpirationTime(transferExpirationTime) + .setPendingTransferExpirationTime(toInstant(transferExpirationTime)) .setTransferStatus(TransferStatus.PENDING) .setGainingRegistrarId("TheRegistrar") .build(); @@ -890,7 +900,7 @@ void testClone_doesNotRemoveBulkTokenForPendingTransfer() { DomainTransferData transferData = new DomainTransferData.Builder() - .setPendingTransferExpirationTime(transferExpirationTime) + .setPendingTransferExpirationTime(toInstant(transferExpirationTime)) .setTransferStatus(TransferStatus.PENDING) .setGainingRegistrarId("TheRegistrar") .build(); @@ -929,7 +939,7 @@ void testClone_transferDuringAutorenew() { DomainTransferData transferData = new DomainTransferData.Builder() - .setPendingTransferExpirationTime(transferExpirationTime) + .setPendingTransferExpirationTime(toInstant(transferExpirationTime)) .setTransferStatus(TransferStatus.PENDING) .setGainingRegistrarId("TheRegistrar") .setServerApproveAutorenewEvent(recurrenceBillKey) @@ -945,7 +955,7 @@ void testClone_transferDuringAutorenew() { GracePeriod.createForRecurrence( GracePeriodStatus.AUTO_RENEW, domain.getRepoId(), - now.plusDays(1), + toInstant(now.plusDays(1)), "NewRegistrar", recurrenceBillKey))) .setTransferData(transferData) @@ -973,13 +983,13 @@ void testHistoryIdRestoration() { GracePeriod.createForRecurrence( GracePeriodStatus.AUTO_RENEW, domain.getRepoId(), - now.plusDays(1), + toInstant(now.plusDays(1)), "NewRegistrar", recurrenceBillKey), GracePeriod.create( GracePeriodStatus.RENEW, domain.getRepoId(), - now.plusDays(1), + toInstant(now.plusDays(1)), "NewRegistrar", oneTimeBillKey))) .build()); diff --git a/core/src/test/java/google/registry/model/domain/token/BulkPricingPackageTest.java b/core/src/test/java/google/registry/model/domain/token/BulkPricingPackageTest.java index 8893831ff72..e63a58b9ef4 100644 --- a/core/src/test/java/google/registry/model/domain/token/BulkPricingPackageTest.java +++ b/core/src/test/java/google/registry/model/domain/token/BulkPricingPackageTest.java @@ -26,6 +26,7 @@ import google.registry.model.billing.BillingBase.RenewalPriceBehavior; import google.registry.model.domain.fee.FeeQueryCommandExtensionItem.CommandName; import google.registry.model.domain.token.AllocationToken.TokenType; +import java.time.Instant; import org.joda.money.CurrencyUnit; import org.joda.money.Money; import org.joda.time.DateTime; @@ -51,7 +52,7 @@ void testPersistence() { new AllocationToken.Builder() .setToken("abc123") .setTokenType(TokenType.BULK_PRICING) - .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) + .setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) @@ -82,7 +83,7 @@ void testFail_tokenIsNotBulkToken() { new AllocationToken.Builder() .setToken("abc123") .setTokenType(TokenType.SINGLE_USE) - .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) + .setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setDiscountFraction(1.0) diff --git a/core/src/test/java/google/registry/model/history/DomainHistoryTest.java b/core/src/test/java/google/registry/model/history/DomainHistoryTest.java index aca1ba4fbe2..6e8e883cad7 100644 --- a/core/src/test/java/google/registry/model/history/DomainHistoryTest.java +++ b/core/src/test/java/google/registry/model/history/DomainHistoryTest.java @@ -21,7 +21,7 @@ import static google.registry.testing.DatabaseHelper.newDomain; import static google.registry.testing.DatabaseHelper.newHostWithRoid; import static google.registry.testing.DatabaseHelper.persistResource; -import static google.registry.util.DateTimeUtils.END_OF_TIME; +import static google.registry.util.DateTimeUtils.END_INSTANT; import static java.nio.charset.StandardCharsets.UTF_8; import com.google.common.collect.ImmutableSet; @@ -96,7 +96,7 @@ private static Domain addGracePeriodForSql(Domain domain) { .setGracePeriods( ImmutableSet.of( GracePeriod.create( - GracePeriodStatus.ADD, "domainRepoId", END_OF_TIME, "clientId", null))) + GracePeriodStatus.ADD, "domainRepoId", END_INSTANT, "clientId", null))) .build(); } @@ -111,7 +111,7 @@ private DomainHistory createDomainHistory(DomainBase domain) { DomainTransactionRecord transactionRecord = new DomainTransactionRecord.Builder() .setTld("tld") - .setReportingTime(fakeClock.nowUtc()) + .setReportingTime(fakeClock.now()) .setReportField(TransactionReportField.NET_ADDS_1_YR) .setReportAmount(1) .build(); @@ -119,7 +119,7 @@ private DomainHistory createDomainHistory(DomainBase domain) { return new DomainHistory.Builder() .setType(HistoryEntry.Type.DOMAIN_CREATE) .setXmlBytes("".getBytes(UTF_8)) - .setModificationTime(fakeClock.nowUtc()) + .setModificationTime(fakeClock.now()) .setRegistrarId("TheRegistrar") .setTrid(Trid.create("ABC-123", "server-trid")) .setBySuperuser(false) diff --git a/core/src/test/java/google/registry/model/history/HostHistoryTest.java b/core/src/test/java/google/registry/model/history/HostHistoryTest.java index c429f1c8c0c..5918c385dd6 100644 --- a/core/src/test/java/google/registry/model/history/HostHistoryTest.java +++ b/core/src/test/java/google/registry/model/history/HostHistoryTest.java @@ -74,7 +74,7 @@ private HostHistory createHostHistory(HostBase hostBase) { return new HostHistory.Builder() .setType(HistoryEntry.Type.HOST_CREATE) .setXmlBytes("".getBytes(UTF_8)) - .setModificationTime(fakeClock.nowUtc()) + .setModificationTime(fakeClock.now()) .setRegistrarId("TheRegistrar") .setTrid(Trid.create("ABC-123", "server-trid")) .setBySuperuser(false) diff --git a/core/src/test/java/google/registry/model/host/HostTest.java b/core/src/test/java/google/registry/model/host/HostTest.java index 1ae781fea1a..a00d108237b 100644 --- a/core/src/test/java/google/registry/model/host/HostTest.java +++ b/core/src/test/java/google/registry/model/host/HostTest.java @@ -22,7 +22,7 @@ import static google.registry.testing.DatabaseHelper.persistNewRegistrars; import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.HostSubject.assertAboutHosts; -import static google.registry.util.DateTimeUtils.toInstant; +import static google.registry.util.DateTimeUtils.minusDays; import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.collect.ImmutableList; @@ -38,16 +38,15 @@ import google.registry.testing.DatabaseHelper; import google.registry.util.SerializeUtils; import java.time.Instant; -import org.joda.time.DateTime; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; /** Unit tests for {@link Host}. */ class HostTest extends EntityTestCase { - private final DateTime day3 = fakeClock.nowUtc(); - private final DateTime day2 = day3.minusDays(1); - private final DateTime day1 = day2.minusDays(1); + private final Instant day3 = fakeClock.now(); + private final Instant day2 = minusDays(day3, 1); + private final Instant day1 = minusDays(day2, 1); private Domain domain; private Host host; @@ -66,8 +65,8 @@ void setUp() { new DomainTransferData.Builder() .setGainingRegistrarId("gaining") .setLosingRegistrarId("losing") - .setPendingTransferExpirationTime(fakeClock.nowUtc()) - .setTransferRequestTime(fakeClock.nowUtc()) + .setPendingTransferExpirationTime(fakeClock.now()) + .setTransferRequestTime(fakeClock.now()) .setTransferStatus(TransferStatus.SERVER_APPROVED) .setTransferRequestTrid(Trid.create("client-trid", "server-trid")) .build()) @@ -79,9 +78,9 @@ void setUp() { .setRepoId("DEADBEEF-COM") .setHostName("ns1.example.com") .setCreationRegistrarId("thisRegistrar") - .setLastEppUpdateTime(fakeClock.nowUtc()) + .setLastEppUpdateTime(fakeClock.now()) .setLastEppUpdateRegistrarId("thatRegistrar") - .setLastTransferTime(fakeClock.nowUtc()) + .setLastTransferTime(fakeClock.now()) .setInetAddresses(ImmutableSet.of(InetAddresses.forString("127.0.0.1"))) .setStatusValues(ImmutableSet.of(StatusValue.OK)) .setSuperordinateDomain(domain.createVKey()) @@ -213,7 +212,7 @@ void testComputeLastTransferTime_hostNeverSwitchedDomains_domainWasTransferred() .setLastTransferTime((Instant) null) .setLastSuperordinateChange((Instant) null) .build(); - assertThat(host.computeLastTransferTime(domain)).isEqualTo(toInstant(day2)); + assertThat(host.computeLastTransferTime(domain)).isEqualTo(day2); } @Test @@ -229,7 +228,7 @@ void testComputeLastTransferTime_hostCreatedAfterDomainWasTransferred() { .setRepoId("DEADBEEF-COM") .setHostName("ns1.example.com") .setCreationRegistrarId("thisRegistrar") - .setLastEppUpdateTime(fakeClock.nowUtc()) + .setLastEppUpdateTime(fakeClock.now()) .setLastEppUpdateRegistrarId("thatRegistrar") .setInetAddresses(ImmutableSet.of(InetAddresses.forString("127.0.0.1"))) .setStatusValues(ImmutableSet.of(StatusValue.OK)) @@ -245,7 +244,7 @@ void testComputeLastTransferTime_hostWasTransferred_domainWasNeverTransferred() // Domain was never transferred. domain = domain.asBuilder().setLastTransferTime((Instant) null).build(); host = host.asBuilder().setLastTransferTime(day1).setLastSuperordinateChange(day2).build(); - assertThat(host.computeLastTransferTime(domain)).isEqualTo(toInstant(day1)); + assertThat(host.computeLastTransferTime(domain)).isEqualTo(day1); } @Test @@ -255,7 +254,7 @@ void testComputeLastTransferTime_domainWasTransferredBeforeHostBecameSubordinate // Host was made subordinate to domain on Day 3. domain = domain.asBuilder().setLastTransferTime(day2).build(); host = host.asBuilder().setLastTransferTime(day1).setLastSuperordinateChange(day3).build(); - assertThat(host.computeLastTransferTime(domain)).isEqualTo(toInstant(day1)); + assertThat(host.computeLastTransferTime(domain)).isEqualTo(day1); } @Test @@ -265,6 +264,6 @@ void testComputeLastTransferTime_domainWasTransferredAfterHostBecameSubordinate( // Domain was transferred on Day 3. domain = domain.asBuilder().setLastTransferTime(day3).build(); host = host.asBuilder().setLastTransferTime(day1).setLastSuperordinateChange(day2).build(); - assertThat(host.computeLastTransferTime(domain)).isEqualTo(toInstant(day3)); + assertThat(host.computeLastTransferTime(domain)).isEqualTo(day3); } } diff --git a/core/src/test/java/google/registry/model/poll/PollMessageExternalKeyConverterTest.java b/core/src/test/java/google/registry/model/poll/PollMessageExternalKeyConverterTest.java index 52e29f265ea..f7ec2501475 100644 --- a/core/src/test/java/google/registry/model/poll/PollMessageExternalKeyConverterTest.java +++ b/core/src/test/java/google/registry/model/poll/PollMessageExternalKeyConverterTest.java @@ -59,7 +59,7 @@ void beforeEach() { .setType(HistoryEntry.Type.DOMAIN_CREATE) .setPeriod(Period.create(1, Period.Unit.YEARS)) .setXmlBytes("".getBytes(UTF_8)) - .setModificationTime(clock.nowUtc()) + .setModificationTime(clock.now()) .setRegistrarId("TheRegistrar") .setTrid(Trid.create("ABC-123", "server-trid")) .setBySuperuser(false) diff --git a/core/src/test/java/google/registry/model/poll/PollMessageTest.java b/core/src/test/java/google/registry/model/poll/PollMessageTest.java index dc2a9ccb017..590c055c3d7 100644 --- a/core/src/test/java/google/registry/model/poll/PollMessageTest.java +++ b/core/src/test/java/google/registry/model/poll/PollMessageTest.java @@ -58,7 +58,7 @@ void setUp() { .setType(HistoryEntry.Type.DOMAIN_CREATE) .setPeriod(Period.create(1, Period.Unit.YEARS)) .setXmlBytes("".getBytes(UTF_8)) - .setModificationTime(fakeClock.nowUtc()) + .setModificationTime(fakeClock.now()) .setRegistrarId("TheRegistrar") .setTrid(Trid.create("ABC-123", "server-trid")) .setBySuperuser(false) @@ -69,7 +69,7 @@ void setUp() { new PollMessage.OneTime.Builder() .setId(100L) .setRegistrarId("TheRegistrar") - .setEventTime(fakeClock.nowUtc()) + .setEventTime(fakeClock.now()) .setMsg("Test poll message") .setHistoryEntry(historyEntry) .build(); @@ -77,7 +77,7 @@ void setUp() { new PollMessage.Autorenew.Builder() .setId(200L) .setRegistrarId("TheRegistrar") - .setEventTime(fakeClock.nowUtc()) + .setEventTime(fakeClock.now()) .setMsg("Test poll message") .setHistoryEntry(historyEntry) .setAutorenewEndTime(plusYears(fakeClock.nowUtc(), 1)) @@ -104,7 +104,7 @@ void testPersistenceOneTime() { persistResource( new PollMessage.OneTime.Builder() .setRegistrarId("TheRegistrar") - .setEventTime(fakeClock.nowUtc()) + .setEventTime(fakeClock.now()) .setMsg("Test poll message") .setHistoryEntry(historyEntry) .build()); @@ -123,7 +123,7 @@ void testPersistenceOneTime_hostPendingActionNotification() { PollMessage.OneTime pollMessage = new PollMessage.OneTime.Builder() .setRegistrarId("TheRegistrar") - .setEventTime(fakeClock.nowUtc()) + .setEventTime(fakeClock.now()) .setMsg("Test poll message") .setHistoryEntry(historyEntry) .setResponseData(ImmutableList.of(hostPendingActionNotificationResponse)) @@ -142,7 +142,7 @@ void testSerializableOneTime() { persistResource( new PollMessage.OneTime.Builder() .setRegistrarId("TheRegistrar") - .setEventTime(fakeClock.nowUtc()) + .setEventTime(fakeClock.now()) .setMsg("Test poll message") .setHistoryEntry(historyEntry) .build()); @@ -156,7 +156,7 @@ void testPersistenceAutorenew() { persistResource( new PollMessage.Autorenew.Builder() .setRegistrarId("TheRegistrar") - .setEventTime(fakeClock.nowUtc()) + .setEventTime(fakeClock.now()) .setMsg("Test poll message") .setHistoryEntry(historyEntry) .setAutorenewEndTime(plusYears(fakeClock.nowUtc(), 1)) @@ -171,7 +171,7 @@ void testSerializableAutorenew() { persistResource( new PollMessage.Autorenew.Builder() .setRegistrarId("TheRegistrar") - .setEventTime(fakeClock.nowUtc()) + .setEventTime(fakeClock.now()) .setMsg("Test poll message") .setHistoryEntry(historyEntry) .setAutorenewEndTime(plusYears(fakeClock.nowUtc(), 1)) diff --git a/core/src/test/java/google/registry/model/reporting/HistoryEntryDaoTest.java b/core/src/test/java/google/registry/model/reporting/HistoryEntryDaoTest.java index 42d3bebbac5..5d392d5b0fd 100644 --- a/core/src/test/java/google/registry/model/reporting/HistoryEntryDaoTest.java +++ b/core/src/test/java/google/registry/model/reporting/HistoryEntryDaoTest.java @@ -49,7 +49,7 @@ void beforeEach() { DomainTransactionRecord transactionRecord = new DomainTransactionRecord.Builder() .setTld("foobar") - .setReportingTime(fakeClock.nowUtc()) + .setReportingTime(fakeClock.now()) .setReportField(TransactionReportField.NET_ADDS_1_YR) .setReportAmount(1) .build(); @@ -60,7 +60,7 @@ void beforeEach() { .setType(HistoryEntry.Type.DOMAIN_CREATE) .setPeriod(Period.create(1, Period.Unit.YEARS)) .setXmlBytes("".getBytes(UTF_8)) - .setModificationTime(fakeClock.nowUtc()) + .setModificationTime(fakeClock.now()) .setRegistrarId("TheRegistrar") .setOtherRegistrarId("otherClient") .setTrid(Trid.create("ABC-123", "server-trid")) diff --git a/core/src/test/java/google/registry/model/reporting/HistoryEntryTest.java b/core/src/test/java/google/registry/model/reporting/HistoryEntryTest.java index 823b00dc662..3fbca08cd84 100644 --- a/core/src/test/java/google/registry/model/reporting/HistoryEntryTest.java +++ b/core/src/test/java/google/registry/model/reporting/HistoryEntryTest.java @@ -31,7 +31,7 @@ import google.registry.model.eppcommon.Trid; import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField; import google.registry.model.reporting.HistoryEntry.Type; -import org.joda.time.DateTime; +import java.time.Instant; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -48,7 +48,7 @@ void setUp() { DomainTransactionRecord transactionRecord = new DomainTransactionRecord.Builder() .setTld("foobar") - .setReportingTime(fakeClock.nowUtc()) + .setReportingTime(fakeClock.now()) .setReportField(TransactionReportField.NET_ADDS_1_YR) .setReportAmount(1) .build(); @@ -59,7 +59,7 @@ void setUp() { .setType(HistoryEntry.Type.DOMAIN_CREATE) .setPeriod(Period.create(1, Period.Unit.YEARS)) .setXmlBytes("".getBytes(UTF_8)) - .setModificationTime(fakeClock.nowUtc()) + .setModificationTime(fakeClock.now()) .setRegistrarId("TheRegistrar") .setOtherRegistrarId("otherClient") .setTrid(Trid.create("ABC-123", "server-trid")) @@ -90,7 +90,7 @@ void testBuilder_resourceMustBeSpecified() { () -> new DomainHistory.Builder() .setRevisionId(5L) - .setModificationTime(DateTime.parse("1985-07-12T22:30:00Z")) + .setModificationTime(Instant.parse("1985-07-12T22:30:00Z")) .setRegistrarId("TheRegistrar") .setReason("Reason") .setType(Type.DOMAIN_CREATE) @@ -107,7 +107,7 @@ void testBuilder_typeMustBeSpecified() { new DomainHistory.Builder() .setRevisionId(5L) .setDomain(domain) - .setModificationTime(DateTime.parse("1985-07-12T22:30.00Z")) + .setModificationTime(Instant.parse("1985-07-12T22:30:00Z")) .setRegistrarId("TheRegistrar") .setReason("Reason") .build()); @@ -140,7 +140,7 @@ void testBuilder_registrarIdMustBeSpecified() { .setRevisionId(5L) .setDomain(domain) .setType(Type.DOMAIN_CREATE) - .setModificationTime(DateTime.parse("1985-07-12T22:30.00Z")) + .setModificationTime(Instant.parse("1985-07-12T22:30:00Z")) .setReason("Reason") .build()); assertThat(thrown).hasMessageThat().isEqualTo("Registrar ID must be specified"); @@ -156,7 +156,7 @@ void testBuilder_syntheticHistoryEntries_mustNotBeRequestedByRegistrar() { .setRevisionId(5L) .setDomain(domain) .setType(Type.SYNTHETIC) - .setModificationTime(DateTime.parse("1985-07-12T22:30.00Z")) + .setModificationTime(Instant.parse("1985-07-12T22:30:00Z")) .setRegistrarId("TheRegistrar") .setReason("Reason") .setRequestedByRegistrar(true) diff --git a/core/src/test/java/google/registry/model/tld/RegistryLockDaoTest.java b/core/src/test/java/google/registry/model/tld/RegistryLockDaoTest.java index 8550d4fbce3..fd227f19500 100644 --- a/core/src/test/java/google/registry/model/tld/RegistryLockDaoTest.java +++ b/core/src/test/java/google/registry/model/tld/RegistryLockDaoTest.java @@ -46,7 +46,7 @@ void testSaveAndLoad_success() { RegistryLock fromDatabase = getRegistryLockByVerificationCode(lock.getVerificationCode()).get(); assertThat(fromDatabase.getDomainName()).isEqualTo(lock.getDomainName()); assertThat(fromDatabase.getVerificationCode()).isEqualTo(lock.getVerificationCode()); - assertThat(fromDatabase.getLastUpdateTime()).isEqualTo(fakeClock.nowUtc()); + assertThat(fromDatabase.getLastUpdateTime()).isEqualTo(fakeClock.now()); } @Test @@ -59,14 +59,14 @@ void testSaveTwiceAndLoad_returnsLatest() { RegistryLock updatedLock = RegistryLockDao.getByVerificationCode(lock.getVerificationCode()).get(); RegistryLockDao.save( - updatedLock.asBuilder().setLockCompletionTime(fakeClock.nowUtc()).build()); + updatedLock.asBuilder().setLockCompletionTime(fakeClock.now()).build()); }); tm().transact( () -> { RegistryLock fromDatabase = RegistryLockDao.getByVerificationCode(lock.getVerificationCode()).get(); - assertThat(fromDatabase.getLockCompletionTime()).hasValue(fakeClock.nowUtc()); - assertThat(fromDatabase.getLastUpdateTime()).isEqualTo(fakeClock.nowUtc()); + assertThat(fromDatabase.getLockCompletionTime()).hasValue(fakeClock.now()); + assertThat(fromDatabase.getLastUpdateTime()).isEqualTo(fakeClock.now()); }); } @@ -76,14 +76,14 @@ void testSave_load_withUnlock() { saveRegistryLock( createLock() .asBuilder() - .setLockCompletionTime(fakeClock.nowUtc()) - .setUnlockRequestTime(fakeClock.nowUtc()) - .setUnlockCompletionTime(fakeClock.nowUtc()) + .setLockCompletionTime(fakeClock.now()) + .setUnlockRequestTime(fakeClock.now()) + .setUnlockCompletionTime(fakeClock.now()) .setRelockDuration(Duration.standardHours(6)) .build()); RegistryLock fromDatabase = getRegistryLockByVerificationCode(lock.getVerificationCode()).get(); - assertThat(fromDatabase.getUnlockRequestTime()).isEqualTo(Optional.of(fakeClock.nowUtc())); - assertThat(fromDatabase.getUnlockCompletionTime()).isEqualTo(Optional.of(fakeClock.nowUtc())); + assertThat(fromDatabase.getUnlockRequestTime()).hasValue(fakeClock.now()); + assertThat(fromDatabase.getUnlockCompletionTime()).hasValue(fakeClock.now()); assertThat(fromDatabase.isLocked()).isFalse(); assertThat(fromDatabase.getRelockDuration()).hasValue(Duration.standardHours(6)); } @@ -92,14 +92,13 @@ void testSave_load_withUnlock() { void testUpdateLock_usingSamePrimaryKey() { RegistryLock lock = saveRegistryLock(createLock()); fakeClock.advanceOneMilli(); - RegistryLock updatedLock = lock.asBuilder().setLockCompletionTime(fakeClock.nowUtc()).build(); + RegistryLock updatedLock = lock.asBuilder().setLockCompletionTime(fakeClock.now()).build(); saveRegistryLock(updatedLock); tm().transact( () -> { RegistryLock fromDatabase = RegistryLockDao.getByVerificationCode(lock.getVerificationCode()).get(); - assertThat(fromDatabase.getLockCompletionTime()) - .isEqualTo(Optional.of(fakeClock.nowUtc())); + assertThat(fromDatabase.getLockCompletionTime()).hasValue(fakeClock.now()); }); } @@ -134,15 +133,15 @@ void testLoad_lockedDomains_byRegistrarId() { createLock() .asBuilder() .setDomainName("otherexample.test") - .setLockCompletionTime(fakeClock.nowUtc()) + .setLockCompletionTime(fakeClock.now()) .build(); RegistryLock unlockedLock = createLock() .asBuilder() .setDomainName("unlocked.test") - .setLockCompletionTime(fakeClock.nowUtc()) - .setUnlockRequestTime(fakeClock.nowUtc()) - .setUnlockCompletionTime(fakeClock.nowUtc()) + .setLockCompletionTime(fakeClock.now()) + .setUnlockRequestTime(fakeClock.now()) + .setUnlockCompletionTime(fakeClock.now()) .build(); saveRegistryLock(lock); saveRegistryLock(secondLock); @@ -159,7 +158,7 @@ void testLoad_lockedDomains_byRegistrarId() { @Test void testLoad_byRepoId() { RegistryLock completedLock = - createLock().asBuilder().setLockCompletionTime(fakeClock.nowUtc()).build(); + createLock().asBuilder().setLockCompletionTime(fakeClock.now()).build(); saveRegistryLock(completedLock); fakeClock.advanceOneMilli(); @@ -179,7 +178,7 @@ void testLoad_byRepoId_empty() { @Test void testLoad_verified_byRepoId() { RegistryLock completedLock = - createLock().asBuilder().setLockCompletionTime(fakeClock.nowUtc()).build(); + createLock().asBuilder().setLockCompletionTime(fakeClock.now()).build(); saveRegistryLock(completedLock); fakeClock.advanceOneMilli(); @@ -204,9 +203,9 @@ void testLoad_verifiedUnlock_byRepoId() { saveRegistryLock( createLock() .asBuilder() - .setLockCompletionTime(fakeClock.nowUtc()) - .setUnlockRequestTime(fakeClock.nowUtc()) - .setUnlockCompletionTime(fakeClock.nowUtc()) + .setLockCompletionTime(fakeClock.now()) + .setUnlockRequestTime(fakeClock.now()) + .setUnlockCompletionTime(fakeClock.now()) .build()); Optional mostRecent = getMostRecentUnlockedRegistryLockByRepoId(lock.getRepoId()); @@ -216,7 +215,7 @@ void testLoad_verifiedUnlock_byRepoId() { @Test void testLoad_verifiedUnlock_empty() { RegistryLock completedLock = - createLock().asBuilder().setLockCompletionTime(fakeClock.nowUtc()).build(); + createLock().asBuilder().setLockCompletionTime(fakeClock.now()).build(); saveRegistryLock(completedLock); assertThat(getMostRecentUnlockedRegistryLockByRepoId(completedLock.getRepoId()).isPresent()) .isFalse(); diff --git a/core/src/test/java/google/registry/model/transfer/DomainTransferDataTest.java b/core/src/test/java/google/registry/model/transfer/DomainTransferDataTest.java index 971cfb36d9f..76859e3ee41 100644 --- a/core/src/test/java/google/registry/model/transfer/DomainTransferDataTest.java +++ b/core/src/test/java/google/registry/model/transfer/DomainTransferDataTest.java @@ -15,6 +15,7 @@ package google.registry.model.transfer; import static com.google.common.truth.Truth.assertThat; +import static google.registry.util.DateTimeUtils.toInstant; import static org.joda.time.DateTimeZone.UTC; import com.google.common.collect.ImmutableSet; @@ -54,7 +55,7 @@ void test_copyConstantFieldsToBuilder() { DomainTransferData constantTransferData = new DomainTransferData.Builder() .setTransferRequestTrid(Trid.create("server-trid", "client-trid")) - .setTransferRequestTime(now) + .setTransferRequestTime(toInstant(now)) .setGainingRegistrarId("NewRegistrar") .setLosingRegistrarId("TheRegistrar") // Test must use a non-1-year period, since that's the default value. @@ -63,7 +64,7 @@ void test_copyConstantFieldsToBuilder() { DomainTransferData fullTransferData = constantTransferData .asBuilder() - .setPendingTransferExpirationTime(now) + .setPendingTransferExpirationTime(toInstant(now)) .setTransferStatus(TransferStatus.PENDING) .setServerApproveEntities( "4-TLD", diff --git a/core/src/test/java/google/registry/mosapi/module/MosApiModuleTest.java b/core/src/test/java/google/registry/mosapi/module/MosApiModuleTest.java index b0f78239f5d..995495eabd9 100644 --- a/core/src/test/java/google/registry/mosapi/module/MosApiModuleTest.java +++ b/core/src/test/java/google/registry/mosapi/module/MosApiModuleTest.java @@ -34,7 +34,7 @@ import java.security.cert.Certificate; import java.security.cert.X509Certificate; import java.time.Instant; -import java.time.ZoneId; +import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.util.Optional; import javax.net.ssl.SSLContext; @@ -155,7 +155,7 @@ private void generateTestCredentials() throws Exception { KeyPair keyPair = keyGen.generateKeyPair(); this.generatedPrivateKey = keyPair.getPrivate(); DateTimeFormatter formatter = - DateTimeFormatter.ofPattern("yyyyMMddHHmmss'Z'").withZone(ZoneId.of("UTC")); + DateTimeFormatter.ofPattern("yyyyMMddHHmmss'Z'").withZone(ZoneOffset.UTC); Instant now = Instant.parse("2021-01-01T00:00:00Z"); Instant end = plusYears(now, 1); // Convert string to Bouncy Castle Time objects diff --git a/core/src/test/java/google/registry/rdap/RdapDomainActionTest.java b/core/src/test/java/google/registry/rdap/RdapDomainActionTest.java index 95c2cfedb7d..27503619d33 100644 --- a/core/src/test/java/google/registry/rdap/RdapDomainActionTest.java +++ b/core/src/test/java/google/registry/rdap/RdapDomainActionTest.java @@ -28,6 +28,9 @@ import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarPocs; import static google.registry.testing.GsonSubject.assertAboutJson; import static google.registry.util.DateTimeUtils.START_OF_TIME; +import static google.registry.util.DateTimeUtils.minusDays; +import static google.registry.util.DateTimeUtils.minusYears; +import static google.registry.util.DateTimeUtils.plusDays; import static org.mockito.Mockito.verify; import com.google.common.collect.ImmutableList; @@ -78,7 +81,7 @@ void beforeEach() { persistResource( makeDomain("cat.lol", host1, host2, registrarLol) .asBuilder() - .setCreationTimeForTest(clock.nowUtc().minusYears(3)) + .setCreationTimeForTest(minusYears(clock.now(), 3)) .setCreationRegistrarId("TheRegistrar") .build()); @@ -90,9 +93,9 @@ void beforeEach() { persistResource( makeDomain("dodo.lol", host1, hostDodo2, registrarLol) .asBuilder() - .setCreationTimeForTest(clock.nowUtc().minusYears(3)) + .setCreationTimeForTest(minusYears(clock.now(), 3)) .setCreationRegistrarId("TheRegistrar") - .setDeletionTime(clock.nowUtc().minusDays(1)) + .setDeletionTime(minusDays(clock.now(), 1)) .build()); // cat.みんな createTld("xn--q9jyb4c"); @@ -102,7 +105,7 @@ void beforeEach() { persistResource( makeDomain("cat.みんな", host1, host2, registrarIdn) .asBuilder() - .setCreationTimeForTest(clock.nowUtc().minusYears(3)) + .setCreationTimeForTest(minusYears(clock.now(), 3)) .setCreationRegistrarId("TheRegistrar") .build()); @@ -115,7 +118,7 @@ void beforeEach() { persistResource( makeDomain("cat.1.tld", host1, host2, registrar1Tld) .asBuilder() - .setCreationTimeForTest(clock.nowUtc().minusYears(3)) + .setCreationTimeForTest(minusYears(clock.now(), 3)) .setCreationRegistrarId("TheRegistrar") .build()); @@ -356,14 +359,14 @@ void testRedemptionGracePeriod() { domain .asBuilder() .addNameserver(host1.createVKey()) - .setDeletionTime(clock.nowUtc().plusDays(1)) + .setDeletionTime(plusDays(clock.now(), 1)) .setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE)) .setGracePeriods( ImmutableSet.of( GracePeriod.createWithoutBillingEvent( GracePeriodStatus.REDEMPTION, domain.getRepoId(), - clock.nowUtc().plusDays(4), + plusDays(clock.now(), 4), "TheRegistrar"))) .build()); assertAboutJson() @@ -385,7 +388,7 @@ void testRenewGracePeriod() { GracePeriod.create( GracePeriodStatus.RENEW, domain.getRepoId(), - clock.nowUtc().plusDays(1), + plusDays(clock.now(), 1), "TheRegistrar", null)) .build()); @@ -408,7 +411,7 @@ void testTransferGracePeriod() { GracePeriod.create( GracePeriodStatus.TRANSFER, domain.getRepoId(), - clock.nowUtc().plusDays(1), + plusDays(clock.now(), 1), "TheRegistrar", null)) .build()); diff --git a/core/src/test/java/google/registry/rdap/RdapDomainSearchActionTest.java b/core/src/test/java/google/registry/rdap/RdapDomainSearchActionTest.java index dc1a7bf8853..1614e9c1a7a 100644 --- a/core/src/test/java/google/registry/rdap/RdapDomainSearchActionTest.java +++ b/core/src/test/java/google/registry/rdap/RdapDomainSearchActionTest.java @@ -26,6 +26,10 @@ import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarPocs; import static google.registry.testing.GsonSubject.assertAboutJson; +import static google.registry.util.DateTimeUtils.minusDays; +import static google.registry.util.DateTimeUtils.minusMonths; +import static google.registry.util.DateTimeUtils.minusYears; +import static google.registry.util.DateTimeUtils.toDateTime; import static java.nio.charset.StandardCharsets.UTF_8; import com.google.common.collect.ImmutableList; @@ -141,7 +145,7 @@ void beforeEach() { makeDomain("cat.lol", hostNs1CatLol, hostNs2CatLol, registrar) .asBuilder() .setSubordinateHosts(ImmutableSet.of("ns1.cat.lol", "ns2.cat.lol")) - .setCreationTimeForTest(clock.nowUtc().minusYears(3)) + .setCreationTimeForTest(minusYears(clock.now(), 3)) .setCreationRegistrarId("TheRegistrar") .build()); persistResource( @@ -163,7 +167,7 @@ void beforeEach() { clock.nowUtc().minusYears(2))), registrar) .asBuilder() - .setCreationTimeForTest(clock.nowUtc().minusYears(3)) + .setCreationTimeForTest(minusYears(clock.now(), 3)) .setCreationRegistrarId("TheRegistrar") .build()); // cat.example @@ -184,7 +188,7 @@ void beforeEach() { clock.nowUtc().minusYears(2))), registrar) .asBuilder() - .setCreationTimeForTest(clock.nowUtc().minusYears(3)) + .setCreationTimeForTest(minusYears(clock.now(), 3)) .setCreationRegistrarId("TheRegistrar") .build()); // cat.みんな @@ -205,7 +209,7 @@ void beforeEach() { clock.nowUtc().minusYears(2))), registrar) .asBuilder() - .setCreationTimeForTest(clock.nowUtc().minusYears(3)) + .setCreationTimeForTest(minusYears(clock.now(), 3)) .setCreationRegistrarId("TheRegistrar") .build()); // cat.1.test @@ -227,7 +231,7 @@ void beforeEach() { registrar) .asBuilder() .setSubordinateHosts(ImmutableSet.of("ns1.cat.1.test")) - .setCreationTimeForTest(clock.nowUtc().minusYears(3)) + .setCreationTimeForTest(minusYears(clock.now(), 3)) .setCreationRegistrarId("TheRegistrar") .build()); @@ -293,15 +297,14 @@ private JsonObject generateExpectedJsonForTwoDomainsCatStarReplySql() { } private void deleteCatLol() { - persistResource( - domainCatLol.asBuilder().setDeletionTime(clock.nowUtc().minusMonths(6)).build()); + persistResource(domainCatLol.asBuilder().setDeletionTime(minusMonths(clock.now(), 6)).build()); persistResource( makeHistoryEntry( domainCatLol, HistoryEntry.Type.DOMAIN_DELETE, Period.create(1, Period.Unit.YEARS), "deleted", - clock.nowUtc().minusMonths(6))); + toDateTime(minusMonths(clock.now(), 6)))); } private void createManyDomainsAndHosts( @@ -328,13 +331,13 @@ private void createManyDomainsAndHosts( makeDomain(domainName, null, null, registrar) .asBuilder() .setNameservers(hostKeys) - .setCreationTimeForTest(clock.nowUtc().minusYears(3)) + .setCreationTimeForTest(minusYears(clock.now(), 3)) .setCreationRegistrarId("TheRegistrar"); if (domainName.equals(mainDomainName)) { builder.setSubordinateHosts(subordinateHostnamesBuilder.build()); } if (i % numTotalDomainsPerActiveDomain != 0) { - builder = builder.setDeletionTime(clock.nowUtc().minusDays(1)); + builder = builder.setDeletionTime(minusDays(clock.now(), 1)); } domainsBuilder.add(builder.build()); } @@ -877,7 +880,7 @@ void testDomainMatch_dog_notFound() { @Test void testDomainMatchDeletedDomain_notFound() { - persistDomainAsDeleted(domainCatLol, clock.nowUtc().minusDays(1)); + persistDomainAsDeleted(domainCatLol, minusDays(clock.now(), 1)); runNotFoundTest(RequestType.NAME, "cat.lol", "No domains found"); verifyErrorMetrics(SearchType.BY_DOMAIN_NAME); } @@ -885,7 +888,7 @@ void testDomainMatchDeletedDomain_notFound() { @Test void testDomainMatchDeletedDomain_notFound_deletedNotRequested() { login("evilregistrar"); - persistDomainAsDeleted(domainCatLol, clock.nowUtc().minusDays(1)); + persistDomainAsDeleted(domainCatLol, minusDays(clock.now(), 1)); runNotFoundTest(RequestType.NAME, "cat.lol", "No domains found"); verifyErrorMetrics(SearchType.BY_DOMAIN_NAME); } @@ -903,7 +906,7 @@ void testDomainMatchDeletedDomain_found_loggedInAsSameRegistrar() { void testDomainMatchDeletedDomain_notFound_loggedInAsOtherRegistrar() { login("otherregistrar"); action.includeDeletedParam = Optional.of(true); - persistDomainAsDeleted(domainCatLol, clock.nowUtc().minusDays(1)); + persistDomainAsDeleted(domainCatLol, minusDays(clock.now(), 1)); runNotFoundTest(RequestType.NAME, "cat.lol", "No domains found"); verifyErrorMetrics(SearchType.BY_DOMAIN_NAME, Optional.of(1L), 404); } @@ -919,15 +922,15 @@ void testDomainMatchDeletedDomain_found_loggedInAsAdmin() { @Test void testDomainMatchDeletedDomainWithWildcard_notFound() { - persistDomainAsDeleted(domainCatLol, clock.nowUtc().minusDays(1)); + persistDomainAsDeleted(domainCatLol, minusDays(clock.now(), 1)); runNotFoundTest(RequestType.NAME, "cat.lo*", "No domains found"); verifyErrorMetrics(SearchType.BY_DOMAIN_NAME, Optional.of(1L), 404); } @Test void testDomainMatchDeletedDomainsWithWildcardAndTld_notFound() { - persistDomainAsDeleted(domainCatLol, clock.nowUtc().minusDays(1)); - persistDomainAsDeleted(domainCatLol2, clock.nowUtc().minusDays(1)); + persistDomainAsDeleted(domainCatLol, minusDays(clock.now(), 1)); + persistDomainAsDeleted(domainCatLol2, minusDays(clock.now(), 1)); runNotFoundTest(RequestType.NAME, "cat*.lol", "No domains found"); verifyErrorMetrics(SearchType.BY_DOMAIN_NAME, Optional.of(2L), 404); } @@ -1338,7 +1341,7 @@ void testNameserverMatchDeletedDomain_found_loggedInAsSameRegistrar() { void testNameserverMatchDeletedDomain_notFound_loggedInAsOtherRegistrar() { login("otherregistrar"); action.includeDeletedParam = Optional.of(true); - persistDomainAsDeleted(domainCatLol, clock.nowUtc().minusDays(1)); + persistDomainAsDeleted(domainCatLol, minusDays(clock.now(), 1)); runNotFoundTest(RequestType.NS_LDH_NAME, "ns2.cat.lol", "No domains found"); verifyErrorMetrics(SearchType.BY_NAMESERVER_NAME, Optional.of(0L), Optional.of(1L), 404); } @@ -1355,36 +1358,36 @@ void testNameserverMatchDeletedDomain_found_loggedInAsAdmin() { @Test void testNameserverMatchOneDeletedDomain_foundTheOther() { login("evilregistrar"); - persistDomainAsDeleted(domainCatExample, clock.nowUtc().minusDays(1)); + persistDomainAsDeleted(domainCatExample, minusDays(clock.now(), 1)); runSuccessfulTestWithCatLol(RequestType.NS_LDH_NAME, "ns1.cat.lol", "rdap_domain.json"); verifyMetrics(SearchType.BY_NAMESERVER_NAME, 1, 1); } @Test void testNameserverMatchTwoDeletedDomains_notFound() { - persistDomainAsDeleted(domainCatLol, clock.nowUtc().minusDays(1)); - persistDomainAsDeleted(domainCatExample, clock.nowUtc().minusDays(1)); + persistDomainAsDeleted(domainCatLol, minusDays(clock.now(), 1)); + persistDomainAsDeleted(domainCatExample, minusDays(clock.now(), 1)); runNotFoundTest(RequestType.NS_LDH_NAME, "ns1.cat.lol", "No domains found"); verifyErrorMetrics(SearchType.BY_NAMESERVER_NAME, Optional.of(0L), Optional.of(1L), 404); } @Test void testNameserverMatchDeletedNameserver_notFound() { - persistResource(hostNs1CatLol.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); + persistResource(hostNs1CatLol.asBuilder().setDeletionTime(minusDays(clock.now(), 1)).build()); runNotFoundTest(RequestType.NS_LDH_NAME, "ns1.cat.lol", "No matching nameservers found"); verifyErrorMetrics(SearchType.BY_NAMESERVER_NAME, Optional.empty(), Optional.of(0L), 404); } @Test void testNameserverMatchDeletedNameserverWithWildcard_notFound() { - persistResource(hostNs1CatLol.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); + persistResource(hostNs1CatLol.asBuilder().setDeletionTime(minusDays(clock.now(), 1)).build()); runNotFoundTest(RequestType.NS_LDH_NAME, "ns1.cat.l*", "No matching nameservers found"); verifyErrorMetrics(SearchType.BY_NAMESERVER_NAME, Optional.empty(), Optional.of(0L), 404); } @Test void testNameserverMatchDeletedNameserverWithWildcardAndSuffix_notFound() { - persistResource(hostNs1CatLol.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); + persistResource(hostNs1CatLol.asBuilder().setDeletionTime(minusDays(clock.now(), 1)).build()); runNotFoundTest(RequestType.NS_LDH_NAME, "ns1*.cat.lol", "No matching nameservers found"); verifyErrorMetrics(SearchType.BY_NAMESERVER_NAME, Optional.empty(), Optional.of(0L), 404); } @@ -1614,7 +1617,7 @@ void testAddressMatchDeletedDomain_found_loggedInAsSameRegistrar() { void testAddressMatchDeletedDomain_notFound_loggedInAsOtherRegistrar() { login("otherregistrar"); action.includeDeletedParam = Optional.of(true); - persistDomainAsDeleted(domainCatLol, clock.nowUtc().minusDays(1)); + persistDomainAsDeleted(domainCatLol, minusDays(clock.now(), 1)); runNotFoundTest(RequestType.NS_IP, "bad:f00d:cafe:0:0:0:15:beef", "No domains found"); verifyErrorMetrics(SearchType.BY_NAMESERVER_ADDRESS, Optional.of(0L), Optional.of(1L), 404); } @@ -1632,7 +1635,7 @@ void testAddressMatchDeletedDomain_found_loggedInAsAdmin() { @Test void testAddressMatchOneDeletedDomain_foundTheOther() { login("evilregistrar"); - persistDomainAsDeleted(domainCatExample, clock.nowUtc().minusDays(1)); + persistDomainAsDeleted(domainCatExample, minusDays(clock.now(), 1)); rememberWildcardType("1.2.3.4"); assertAboutJson() .that(generateActualJson(RequestType.NS_IP, "1.2.3.4")) @@ -1650,15 +1653,15 @@ void testAddressMatchOneDeletedDomain_foundTheOther() { @Test void testAddressMatchTwoDeletedDomains_notFound() { - persistDomainAsDeleted(domainCatLol, clock.nowUtc().minusDays(1)); - persistDomainAsDeleted(domainCatExample, clock.nowUtc().minusDays(1)); + persistDomainAsDeleted(domainCatLol, minusDays(clock.now(), 1)); + persistDomainAsDeleted(domainCatExample, minusDays(clock.now(), 1)); runNotFoundTest(RequestType.NS_IP, "1.2.3.4", "No domains found"); verifyErrorMetrics(SearchType.BY_NAMESERVER_ADDRESS, Optional.of(0L), Optional.of(1L), 404); } @Test void testAddressMatchDeletedNameserver_notFound() { - persistResource(hostNs1CatLol.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); + persistResource(hostNs1CatLol.asBuilder().setDeletionTime(minusDays(clock.now(), 1)).build()); runNotFoundTest(RequestType.NS_IP, "1.2.3.4", "No domains found"); verifyErrorMetrics(SearchType.BY_NAMESERVER_ADDRESS, Optional.empty(), Optional.of(0L), 404); } diff --git a/core/src/test/java/google/registry/rdap/RdapJsonFormatterTest.java b/core/src/test/java/google/registry/rdap/RdapJsonFormatterTest.java index 7e89ef06fc6..351c3d52816 100644 --- a/core/src/test/java/google/registry/rdap/RdapJsonFormatterTest.java +++ b/core/src/test/java/google/registry/rdap/RdapJsonFormatterTest.java @@ -25,6 +25,10 @@ import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar; import static google.registry.testing.GsonSubject.assertAboutJson; import static google.registry.testing.TestDataHelper.loadFile; +import static google.registry.util.DateTimeUtils.minusDays; +import static google.registry.util.DateTimeUtils.minusMonths; +import static google.registry.util.DateTimeUtils.plusYears; +import static google.registry.util.DateTimeUtils.toInstant; import static jakarta.servlet.http.HttpServletResponse.SC_BAD_REQUEST; import com.google.common.collect.ImmutableList; @@ -129,12 +133,12 @@ void beforeEach() { new DomainTransferData.Builder() .setTransferStatus(TransferStatus.PENDING) .setGainingRegistrarId("NewRegistrar") - .setTransferRequestTime(clock.nowUtc().minusDays(1)) + .setTransferRequestTime(minusDays(clock.now(), 1)) .setLosingRegistrarId("TheRegistrar") .setPendingTransferExpirationTime( - clock.nowUtc().plusYears(100)) + plusYears(clock.now(), 100)) .setTransferredRegistrationExpirationTime( - DateTime.parse("2111-10-08T00:44:59Z")) + Instant.parse("2111-10-08T00:44:59Z")) .build()) .build()) .createVKey()) @@ -143,14 +147,14 @@ void beforeEach() { persistResource( makeDomain("cat.みんな", hostIpv4, hostIpv6, registrar) .asBuilder() - .setCreationTimeForTest(clock.nowUtc().minusMonths(4)) - .setLastEppUpdateTime(clock.nowUtc().minusMonths(1)) + .setCreationTimeForTest(minusMonths(clock.now(), 4)) + .setLastEppUpdateTime(toInstant(clock.nowUtc().minusMonths(1))) .build()); domainNoNameserversNoTransfers = persistResource( makeDomain("fish.みんな", null, null, registrar) .asBuilder() - .setCreationTimeForTest(clock.nowUtc()) + .setCreationTimeForTest(clock.now()) .setLastEppUpdateTime((Instant) null) .build()); diff --git a/core/src/test/java/google/registry/rdap/RdapNameserverActionTest.java b/core/src/test/java/google/registry/rdap/RdapNameserverActionTest.java index a3778ad0e15..8f8b987e1c2 100644 --- a/core/src/test/java/google/registry/rdap/RdapNameserverActionTest.java +++ b/core/src/test/java/google/registry/rdap/RdapNameserverActionTest.java @@ -21,6 +21,7 @@ import static google.registry.testing.FullFieldsTestEntityHelper.makePunycodedHost; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar; import static google.registry.testing.GsonSubject.assertAboutJson; +import static google.registry.util.DateTimeUtils.minusMonths; import static org.mockito.Mockito.verify; import google.registry.model.registrar.Registrar; @@ -56,7 +57,7 @@ void beforeEach() { persistResource( makeAndPersistHost("nsdeleted.cat.lol", "1.2.3.4", clock.nowUtc().minusYears(1)) .asBuilder() - .setDeletionTime(clock.nowUtc().minusMonths(1)) + .setDeletionTime(minusMonths(clock.now(), 1)) .build()); // other registrar persistResource( diff --git a/core/src/test/java/google/registry/rdap/RdapNameserverSearchActionTest.java b/core/src/test/java/google/registry/rdap/RdapNameserverSearchActionTest.java index ff26404a93b..c42f76bd840 100644 --- a/core/src/test/java/google/registry/rdap/RdapNameserverSearchActionTest.java +++ b/core/src/test/java/google/registry/rdap/RdapNameserverSearchActionTest.java @@ -25,6 +25,8 @@ import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarPocs; import static google.registry.testing.GsonSubject.assertAboutJson; +import static google.registry.util.DateTimeUtils.minusDays; +import static google.registry.util.DateTimeUtils.minusMonths; import static java.nio.charset.StandardCharsets.UTF_8; import com.google.common.collect.ImmutableList; @@ -169,7 +171,7 @@ private void createDeletedHost() { FullFieldsTestEntityHelper.makeAndPersistHost( "nsdeleted.cat.lol", "4.3.2.1", clock.nowUtc().minusYears(1)) .asBuilder() - .setDeletionTime(clock.nowUtc().minusMonths(1)) + .setDeletionTime(minusMonths(clock.now(), 1)) .build()); } @@ -523,7 +525,7 @@ void testNameMatch_reallyTruncatedResultSet() { @Test void testNameMatchDeletedHost_foundTheOtherHost() { - persistResource(hostNs1CatLol.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); + persistResource(hostNs1CatLol.asBuilder().setDeletionTime(minusDays(clock.now(), 1)).build()); assertAboutJson() .that(generateActualJsonWithName("ns*.cat.lol")) .isEqualTo( @@ -538,7 +540,7 @@ void testNameMatchDeletedHost_foundTheOtherHost() { @Test void testNameMatchDeletedHost_notFound() { - persistResource(hostNs1CatLol.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); + persistResource(hostNs1CatLol.asBuilder().setDeletionTime(minusDays(clock.now(), 1)).build()); assertAboutJson() .that(generateActualJsonWithName("ns1.cat.lol")) .isEqualTo(generateExpectedJsonError("No nameservers found", 404)); @@ -548,7 +550,7 @@ void testNameMatchDeletedHost_notFound() { @Test void testNameMatchDeletedHostWithWildcard_notFound() { - persistResource(hostNs1CatLol.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); + persistResource(hostNs1CatLol.asBuilder().setDeletionTime(minusDays(clock.now(), 1)).build()); assertAboutJson() .that(generateActualJsonWithName("cat.lo*")) .isEqualTo(generateExpectedJsonError("No nameservers found", 404)); @@ -764,7 +766,7 @@ void testAddressMatchLocalhost_notFound() { @Test void testAddressMatchDeletedHost_notFound() { - persistResource(hostNs1CatLol.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); + persistResource(hostNs1CatLol.asBuilder().setDeletionTime(minusDays(clock.now(), 1)).build()); assertAboutJson() .that(generateActualJsonWithIp("1.2.3.4")) .isEqualTo(generateExpectedJsonError("No nameservers found", 404)); diff --git a/core/src/test/java/google/registry/rde/DomainToXjcConverterTest.java b/core/src/test/java/google/registry/rde/DomainToXjcConverterTest.java index c1593c97e24..9ef555de721 100644 --- a/core/src/test/java/google/registry/rde/DomainToXjcConverterTest.java +++ b/core/src/test/java/google/registry/rde/DomainToXjcConverterTest.java @@ -20,6 +20,7 @@ import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.persistEppResource; import static google.registry.testing.DatabaseHelper.persistResource; +import static google.registry.util.DateTimeUtils.END_INSTANT; import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.xjc.rgp.XjcRgpStatusValueType.RENEW_PERIOD; import static google.registry.xjc.rgp.XjcRgpStatusValueType.TRANSFER_PERIOD; @@ -65,6 +66,7 @@ import google.registry.xjc.secdns.XjcSecdnsDsDataType; import google.registry.xml.XmlException; import java.io.ByteArrayOutputStream; +import java.time.Instant; import org.joda.money.Money; import org.joda.time.DateTime; import org.junit.jupiter.api.BeforeEach; @@ -228,7 +230,7 @@ static Domain makeDomain(FakeClock clock) { DomainHistory domainHistory = persistResource( new DomainHistory.Builder() - .setModificationTime(clock.nowUtc()) + .setModificationTime(clock.now()) .setType(HistoryEntry.Type.DOMAIN_CREATE) .setDomain(domain) .setRegistrarId(domain.getCreationRegistrarId()) @@ -241,8 +243,8 @@ static Domain makeDomain(FakeClock clock) { .setRegistrarId("TheRegistrar") .setCost(Money.of(USD, 26)) .setPeriodYears(2) - .setEventTime(DateTime.parse("1910-01-01T00:00:00Z")) - .setBillingTime(DateTime.parse("1910-01-01T00:00:00Z")) + .setEventTime(Instant.parse("1910-01-01T00:00:00Z")) + .setBillingTime(Instant.parse("1910-01-01T00:00:00Z")) .setDomainHistory(domainHistory) .build()); domain = @@ -250,14 +252,14 @@ static Domain makeDomain(FakeClock clock) { .asBuilder() .setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("secret"))) .setCreationRegistrarId("TheRegistrar") - .setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z")) + .setCreationTimeForTest(Instant.parse("1900-01-01T00:00:00Z")) .setPersistedCurrentSponsorRegistrarId("TheRegistrar") .setDsData( ImmutableSet.of(DomainDsData.create(123, 200, 230, base16().decode("1234567890")))) .setDomainName(Idn.toASCII("love.みんな")) - .setLastTransferTime(DateTime.parse("1910-01-01T00:00:00Z")) + .setLastTransferTime(Instant.parse("1910-01-01T00:00:00Z")) .setLastEppUpdateRegistrarId("TheRegistrar") - .setLastEppUpdateTime(DateTime.parse("1920-01-01T00:00:00Z")) + .setLastEppUpdateTime(Instant.parse("1920-01-01T00:00:00Z")) .setNameservers( ImmutableSet.of( makeHost(clock, "3-Q9JYB4C", "bird.or.devil.みんな", "1.2.3.4").createVKey(), @@ -276,14 +278,14 @@ static Domain makeDomain(FakeClock clock) { .setRegistrarId("TheRegistrar") .setCost(Money.of(USD, 456)) .setPeriodYears(2) - .setEventTime(DateTime.parse("1920-01-01T00:00:00Z")) - .setBillingTime(DateTime.parse("1920-01-01T00:00:00Z")) + .setEventTime(Instant.parse("1920-01-01T00:00:00Z")) + .setBillingTime(Instant.parse("1920-01-01T00:00:00Z")) .setDomainHistory(domainHistory) .build())), GracePeriod.create( GracePeriodStatus.TRANSFER, domain.getRepoId(), - DateTime.parse("1920-01-01T00:00:00Z"), + Instant.parse("1920-01-01T00:00:00Z"), "TheRegistrar", null))) .setSubordinateHosts(ImmutableSet.of("home.by.horror.haunted")) @@ -300,8 +302,8 @@ static Domain makeDomain(FakeClock clock) { .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId("lol") .setRegistrarId("TheRegistrar") - .setEventTime(END_OF_TIME) - .setRecurrenceEndTime(END_OF_TIME) + .setEventTime(END_INSTANT) + .setRecurrenceEndTime(END_INSTANT) .setDomainHistory(domainHistory) .build()) .createVKey()) @@ -310,7 +312,7 @@ static Domain makeDomain(FakeClock clock) { new PollMessage.Autorenew.Builder() .setTargetId("lol") .setRegistrarId("TheRegistrar") - .setEventTime(END_OF_TIME) + .setEventTime(END_INSTANT) .setAutorenewEndTime(END_OF_TIME) .setMsg("Domain was auto-renewed.") .setHistoryEntry(domainHistory) @@ -320,7 +322,7 @@ static Domain makeDomain(FakeClock clock) { new DomainTransferData.Builder() .setGainingRegistrarId("NewRegistrar") .setLosingRegistrarId("TheRegistrar") - .setPendingTransferExpirationTime(DateTime.parse("1925-04-20T00:00:00Z")) + .setPendingTransferExpirationTime(Instant.parse("1925-04-20T00:00:00Z")) .setServerApproveBillingEvent(billingEvent.createVKey()) .setServerApproveAutorenewEvent( persistResource( @@ -329,8 +331,8 @@ static Domain makeDomain(FakeClock clock) { .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId("example.xn--q9jyb4c") .setRegistrarId("TheRegistrar") - .setEventTime(END_OF_TIME) - .setRecurrenceEndTime(END_OF_TIME) + .setEventTime(END_INSTANT) + .setRecurrenceEndTime(END_INSTANT) .setDomainHistory(domainHistory) .build()) .createVKey()) @@ -339,7 +341,7 @@ static Domain makeDomain(FakeClock clock) { new Autorenew.Builder() .setTargetId("example.xn--q9jyb4c") .setRegistrarId("TheRegistrar") - .setEventTime(END_OF_TIME) + .setEventTime(END_INSTANT) .setAutorenewEndTime(END_OF_TIME) .setMsg("Domain was auto-renewed.") .setHistoryEntry(domainHistory) @@ -349,10 +351,9 @@ static Domain makeDomain(FakeClock clock) { domain.getRepoId(), domainHistory.getRevisionId(), ImmutableSet.of(billingEvent.createVKey())) - .setTransferRequestTime(DateTime.parse("1919-01-01T00:00:00Z")) + .setTransferRequestTime(Instant.parse("1919-01-01T00:00:00Z")) .setTransferStatus(TransferStatus.PENDING) - .setTransferredRegistrationExpirationTime( - DateTime.parse("1931-01-01T00:00:00Z")) + .setTransferredRegistrationExpirationTime(Instant.parse("1931-01-01T00:00:00Z")) .setTransferRequestTrid(Trid.create("client-trid", "server-trid")) .build()) .build(); @@ -365,13 +366,13 @@ private static Host makeHost(FakeClock clock, String repoId, String fqhn, String return persistEppResource( new Host.Builder() .setCreationRegistrarId("TheRegistrar") - .setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z")) + .setCreationTimeForTest(Instant.parse("1900-01-01T00:00:00Z")) .setPersistedCurrentSponsorRegistrarId("TheRegistrar") .setHostName(Idn.toASCII(fqhn)) .setInetAddresses(ImmutableSet.of(InetAddresses.forString(ip))) - .setLastTransferTime(DateTime.parse("1910-01-01T00:00:00Z")) + .setLastTransferTime(Instant.parse("1910-01-01T00:00:00Z")) .setLastEppUpdateRegistrarId("TheRegistrar") - .setLastEppUpdateTime(DateTime.parse("1920-01-01T00:00:00Z")) + .setLastEppUpdateTime(Instant.parse("1920-01-01T00:00:00Z")) .setRepoId(repoId) .setStatusValues(ImmutableSet.of(StatusValue.OK)) .build()); diff --git a/core/src/test/java/google/registry/rde/HostToXjcConverterTest.java b/core/src/test/java/google/registry/rde/HostToXjcConverterTest.java index fe6b2ba0182..c3d7be3e483 100644 --- a/core/src/test/java/google/registry/rde/HostToXjcConverterTest.java +++ b/core/src/test/java/google/registry/rde/HostToXjcConverterTest.java @@ -33,6 +33,7 @@ import google.registry.xjc.rdehost.XjcRdeHost; import google.registry.xjc.rdehost.XjcRdeHostElement; import java.io.ByteArrayOutputStream; +import java.time.Instant; import org.joda.time.DateTime; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -68,13 +69,13 @@ void testConvertSubordinateHost() { HostToXjcConverter.convertSubordinateHost( new Host.Builder() .setCreationRegistrarId("LawyerCat") - .setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z")) + .setCreationTimeForTest(Instant.parse("1900-01-01T00:00:00Z")) .setPersistedCurrentSponsorRegistrarId("BusinessCat") .setHostName("ns1.love.foobar") .setInetAddresses(ImmutableSet.of(InetAddresses.forString("127.0.0.1"))) - .setLastTransferTime(DateTime.parse("1910-01-01T00:00:00Z")) + .setLastTransferTime(Instant.parse("1910-01-01T00:00:00Z")) .setLastEppUpdateRegistrarId("CeilingCat") - .setLastEppUpdateTime(DateTime.parse("1920-01-01T00:00:00Z")) + .setLastEppUpdateTime(Instant.parse("1920-01-01T00:00:00Z")) .setRepoId("2-roid") .setStatusValues(ImmutableSet.of(StatusValue.OK)) .setSuperordinateDomain(domain.createVKey()) @@ -124,13 +125,13 @@ void testConvertExternalHost() { HostToXjcConverter.convertExternalHost( new Host.Builder() .setCreationRegistrarId("LawyerCat") - .setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z")) + .setCreationTimeForTest(Instant.parse("1900-01-01T00:00:00Z")) .setPersistedCurrentSponsorRegistrarId("BusinessCat") .setHostName("ns1.love.lol") .setInetAddresses(ImmutableSet.of(InetAddresses.forString("127.0.0.1"))) - .setLastTransferTime(DateTime.parse("1910-01-01T00:00:00Z")) + .setLastTransferTime(Instant.parse("1910-01-01T00:00:00Z")) .setLastEppUpdateRegistrarId("CeilingCat") - .setLastEppUpdateTime(DateTime.parse("1920-01-01T00:00:00Z")) + .setLastEppUpdateTime(Instant.parse("1920-01-01T00:00:00Z")) .setRepoId("2-roid") .setStatusValues(ImmutableSet.of(StatusValue.OK)) .build()); @@ -173,13 +174,13 @@ void testConvertExternalHost_ipv6() { HostToXjcConverter.convertExternalHost( new Host.Builder() .setCreationRegistrarId("LawyerCat") - .setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z")) + .setCreationTimeForTest(Instant.parse("1900-01-01T00:00:00Z")) .setPersistedCurrentSponsorRegistrarId("BusinessCat") .setHostName("ns1.love.lol") .setInetAddresses(ImmutableSet.of(InetAddresses.forString("cafe::abba"))) - .setLastTransferTime(DateTime.parse("1910-01-01T00:00:00Z")) + .setLastTransferTime(Instant.parse("1910-01-01T00:00:00Z")) .setLastEppUpdateRegistrarId("CeilingCat") - .setLastEppUpdateTime(DateTime.parse("1920-01-01T00:00:00Z")) + .setLastEppUpdateTime(Instant.parse("1920-01-01T00:00:00Z")) .setRepoId("2-LOL") .setStatusValues(ImmutableSet.of(StatusValue.OK)) .build()); @@ -196,13 +197,13 @@ void testHostStatusValueIsInvalid() { HostToXjcConverter.convertExternalHost( new Host.Builder() .setCreationRegistrarId("LawyerCat") - .setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z")) + .setCreationTimeForTest(Instant.parse("1900-01-01T00:00:00Z")) .setPersistedCurrentSponsorRegistrarId("BusinessCat") .setHostName("ns1.love.lol") .setInetAddresses(ImmutableSet.of(InetAddresses.forString("cafe::abba"))) - .setLastTransferTime(DateTime.parse("1910-01-01T00:00:00Z")) + .setLastTransferTime(Instant.parse("1910-01-01T00:00:00Z")) .setLastEppUpdateRegistrarId("CeilingCat") - .setLastEppUpdateTime(DateTime.parse("1920-01-01T00:00:00Z")) + .setLastEppUpdateTime(Instant.parse("1920-01-01T00:00:00Z")) .setRepoId("2-LOL") .setStatusValues(ImmutableSet.of(StatusValue.SERVER_HOLD)) // <-- OOPS .build())); @@ -215,13 +216,13 @@ void testMarshal() throws Exception { HostToXjcConverter.convertExternal( new Host.Builder() .setCreationRegistrarId("LawyerCat") - .setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z")) + .setCreationTimeForTest(Instant.parse("1900-01-01T00:00:00Z")) .setPersistedCurrentSponsorRegistrarId("BusinessCat") .setHostName("ns1.love.lol") .setInetAddresses(ImmutableSet.of(InetAddresses.forString("cafe::abba"))) - .setLastTransferTime(DateTime.parse("1910-01-01T00:00:00Z")) + .setLastTransferTime(Instant.parse("1910-01-01T00:00:00Z")) .setLastEppUpdateRegistrarId("CeilingCat") - .setLastEppUpdateTime(DateTime.parse("1920-01-01T00:00:00Z")) + .setLastEppUpdateTime(Instant.parse("1920-01-01T00:00:00Z")) .setRepoId("2-LOL") .setStatusValues(ImmutableSet.of(StatusValue.OK)) .build()); diff --git a/core/src/test/java/google/registry/testing/AbstractEppResourceSubject.java b/core/src/test/java/google/registry/testing/AbstractEppResourceSubject.java index b45d4d32385..2e6018798ae 100644 --- a/core/src/test/java/google/registry/testing/AbstractEppResourceSubject.java +++ b/core/src/test/java/google/registry/testing/AbstractEppResourceSubject.java @@ -21,6 +21,7 @@ import static google.registry.model.EppResourceUtils.isActive; import static google.registry.testing.DatabaseHelper.getHistoryEntriesOfType; import static google.registry.testing.HistoryEntrySubject.historyEntries; +import static google.registry.util.DateTimeUtils.toInstant; import static google.registry.util.DiffUtils.prettyPrintEntityDeepDiff; import com.google.common.collect.ImmutableSet; @@ -151,7 +152,7 @@ public And hasExactlyStatusValues(StatusValue... statusValues) { } public And hasDeletionTime(DateTime deletionTime) { - return hasValue(deletionTime, actual.getDeletionDateTime(), "getDeletionTime()"); + return hasValue(toInstant(deletionTime), actual.getDeletionTime(), "getDeletionTime()"); } public And hasDeletionTime(Instant deletionTime) { @@ -159,7 +160,8 @@ public And hasDeletionTime(Instant deletionTime) { } public And hasLastEppUpdateTime(DateTime lastUpdateTime) { - return hasValue(lastUpdateTime, actual.getLastEppUpdateDateTime(), "has lastEppUpdateTime"); + return hasValue( + toInstant(lastUpdateTime), actual.getLastEppUpdateTime(), "has lastEppUpdateTime"); } public And hasLastEppUpdateTime(Instant lastUpdateTime) { @@ -167,8 +169,8 @@ public And hasLastEppUpdateTime(Instant lastUpdateTime) { } public And hasLastEppUpdateTimeAtLeast(DateTime before) { - DateTime lastEppUpdateTime = actual.getLastEppUpdateDateTime(); - check("getLastEppUpdateTime()").that(lastEppUpdateTime).isAtLeast(before); + Instant lastEppUpdateTime = actual.getLastEppUpdateTime(); + check("getLastEppUpdateTime()").that(lastEppUpdateTime).isAtLeast(toInstant(before)); return andChainer(); } diff --git a/core/src/test/java/google/registry/testing/DatabaseHelper.java b/core/src/test/java/google/registry/testing/DatabaseHelper.java index bc930796c8c..c535c9f2710 100644 --- a/core/src/test/java/google/registry/testing/DatabaseHelper.java +++ b/core/src/test/java/google/registry/testing/DatabaseHelper.java @@ -36,7 +36,9 @@ import static google.registry.pricing.PricingEngineProxy.getDomainRenewCost; import static google.registry.util.CollectionUtils.difference; import static google.registry.util.CollectionUtils.union; +import static google.registry.util.DateTimeUtils.END_INSTANT; import static google.registry.util.DateTimeUtils.END_OF_TIME; +import static google.registry.util.DateTimeUtils.START_INSTANT; import static google.registry.util.DateTimeUtils.START_OF_TIME; import static google.registry.util.DateTimeUtils.toDateTime; import static google.registry.util.DateTimeUtils.toInstant; @@ -154,7 +156,7 @@ public static Host newHostWithRoid(String hostName, String repoId) { .setHostName(hostName) .setCreationRegistrarId("TheRegistrar") .setPersistedCurrentSponsorRegistrarId("TheRegistrar") - .setCreationTimeForTest(START_OF_TIME) + .setCreationTimeForTest(START_INSTANT) .setRepoId(repoId) .build(); } @@ -176,7 +178,7 @@ public static Domain newDomain(String domainName, String repoId) { .setDomainName(domainName) .setCreationRegistrarId("TheRegistrar") .setPersistedCurrentSponsorRegistrarId("TheRegistrar") - .setCreationTimeForTest(START_OF_TIME) + .setCreationTimeForTest(START_INSTANT) .setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("2fooBAR"))) .setRegistrationExpirationTime(END_OF_TIME) .build(); @@ -238,7 +240,8 @@ public static Host persistActiveSubordinateHost(String hostName, Domain superord /** Persists a host resource with the given hostname deleted at the specified time. */ public static Host persistDeletedHost(String hostName, DateTime deletionTime) { - return persistResource(newHost(hostName).asBuilder().setDeletionTime(deletionTime).build()); + return persistResource( + newHost(hostName).asBuilder().setDeletionTime(toInstant(deletionTime)).build()); } public static Domain persistActiveDomain(String domainName) { @@ -247,7 +250,7 @@ public static Domain persistActiveDomain(String domainName) { public static Domain persistActiveDomain(String domainName, DateTime creationTime) { return persistResource( - newDomain(domainName).asBuilder().setCreationTimeForTest(creationTime).build()); + newDomain(domainName).asBuilder().setCreationTimeForTest(toInstant(creationTime)).build()); } public static Domain persistActiveDomain( @@ -255,7 +258,7 @@ public static Domain persistActiveDomain( return persistResource( newDomain(domainName) .asBuilder() - .setCreationTimeForTest(creationTime) + .setCreationTimeForTest(toInstant(creationTime)) .setRegistrationExpirationTime(expirationTime) .build()); } @@ -274,7 +277,7 @@ public static Domain persistDomainAsDeleted(Domain domain, Instant deletionTime) } public static Domain persistDomainAsDeleted(Domain domain, DateTime deletionTime) { - return persistResource(domain.asBuilder().setDeletionTime(deletionTime).build()); + return persistResource(domain.asBuilder().setDeletionTime(toInstant(deletionTime)).build()); } /** @@ -301,7 +304,7 @@ public static Domain persistBillingRecurrenceForDomain( .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setId(2L) .setReason(Reason.RENEW) - .setRecurrenceEndTime(END_OF_TIME) + .setRecurrenceEndTime(END_INSTANT) .setTargetId(domain.getDomainName()) .build()); return persistResource( @@ -447,9 +450,9 @@ private static DomainTransferData.Builder createDomainTransferDataBuilder( return new DomainTransferData.Builder() .setTransferStatus(TransferStatus.PENDING) .setGainingRegistrarId("NewRegistrar") - .setTransferRequestTime(requestTime) + .setTransferRequestTime(toInstant(requestTime)) .setLosingRegistrarId("TheRegistrar") - .setPendingTransferExpirationTime(expirationTime); + .setPendingTransferExpirationTime(toInstant(expirationTime)); } public static PollMessage.OneTime createPollMessageForImplicitTransfer( @@ -479,11 +482,11 @@ public static PollMessage.OneTime createPollMessageForImplicitTransfer( @Nullable DateTime extendedRegistrationExpirationTime) { DomainTransferData transferData = createDomainTransferDataBuilder(requestTime, expirationTime) - .setTransferredRegistrationExpirationTime(extendedRegistrationExpirationTime) + .setTransferredRegistrationExpirationTime(toInstant(extendedRegistrationExpirationTime)) .build(); return new PollMessage.OneTime.Builder() .setRegistrarId(registrarId) - .setEventTime(expirationTime) + .setEventTime(toInstant(expirationTime)) .setMsg("Transfer server approved.") .setResponseData(ImmutableList.of(createTransferResponse(domain, transferData))) .setHistoryEntry(historyEntry) @@ -501,8 +504,9 @@ public static BillingEvent createBillingEventForTransfer( return new BillingEvent.Builder() .setReason(Reason.TRANSFER) .setTargetId(domain.getDomainName()) - .setEventTime(eventTime) - .setBillingTime(eventTime.plus(Tld.get(domain.getTld()).getTransferGracePeriodLength())) + .setEventTime(toInstant(eventTime)) + .setBillingTime( + toInstant(eventTime.plus(Tld.get(domain.getTld()).getTransferGracePeriodLength()))) .setRegistrarId("NewRegistrar") .setPeriodYears(1) .setCost(getDomainRenewCost(domain.getDomainName(), toInstant(costLookupTime), 1)) @@ -530,7 +534,7 @@ public static Domain persistDomainWithDependentResources( .setDomainName(domainName) .setPersistedCurrentSponsorRegistrarId("TheRegistrar") .setCreationRegistrarId("TheRegistrar") - .setCreationTimeForTest(creationTime) + .setCreationTimeForTest(toInstant(creationTime)) .setRegistrationExpirationTime(expirationTime) .setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("fooBAR"))); Duration addGracePeriodLength = Tld.get(tld).getAddGracePeriodLength(); @@ -539,7 +543,7 @@ public static Domain persistDomainWithDependentResources( GracePeriod.create( GracePeriodStatus.ADD, repoId, - creationTime.plus(addGracePeriodLength), + toInstant(creationTime.plus(addGracePeriodLength)), "TheRegistrar", null)); } @@ -548,7 +552,7 @@ public static Domain persistDomainWithDependentResources( persistResource( new DomainHistory.Builder() .setType(HistoryEntry.Type.DOMAIN_CREATE) - .setModificationTime(creationTime) + .setModificationTime(toInstant(creationTime)) .setDomain(domain) .setRegistrarId(domain.getCreationRegistrarId()) .build()); @@ -559,8 +563,8 @@ public static Domain persistDomainWithDependentResources( .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId(domainName) .setRegistrarId("TheRegistrar") - .setEventTime(expirationTime) - .setRecurrenceEndTime(END_OF_TIME) + .setEventTime(toInstant(expirationTime)) + .setRecurrenceEndTime(END_INSTANT) .setDomainHistory(historyEntryDomainCreate) .build()); PollMessage.Autorenew autorenewPollMessage = @@ -568,7 +572,7 @@ public static Domain persistDomainWithDependentResources( new PollMessage.Autorenew.Builder() .setTargetId(domainName) .setRegistrarId("TheRegistrar") - .setEventTime(expirationTime) + .setEventTime(toInstant(expirationTime)) .setAutorenewEndTime(END_OF_TIME) .setMsg("Domain was auto-renewed.") .setHistoryEntry(historyEntryDomainCreate) @@ -602,7 +606,7 @@ public static Domain persistDomainWithPendingTransfer( persistResource( new DomainHistory.Builder() .setType(HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST) - .setModificationTime(tm().transact(() -> tm().getTransactionTime())) + .setModificationTime(tm().transact(() -> tm().getTxTime())) .setDomain(domain) .setRegistrarId("TheRegistrar") .build()); @@ -617,8 +621,8 @@ public static Domain persistDomainWithPendingTransfer( .setReason(Reason.RENEW) .setTargetId(domain.getDomainName()) .setRegistrarId("NewRegistrar") - .setEventTime(extendedRegistrationExpirationTime) - .setRecurrenceEndTime(END_OF_TIME) + .setEventTime(toInstant(extendedRegistrationExpirationTime)) + .setRecurrenceEndTime(END_INSTANT) .setDomainHistory(historyEntryDomainTransfer) .build()); PollMessage.Autorenew gainingClientAutorenewPollMessage = @@ -626,7 +630,7 @@ public static Domain persistDomainWithPendingTransfer( new PollMessage.Autorenew.Builder() .setTargetId(domain.getDomainName()) .setRegistrarId("NewRegistrar") - .setEventTime(extendedRegistrationExpirationTime) + .setEventTime(toInstant(extendedRegistrationExpirationTime)) .setAutorenewEndTime(END_OF_TIME) .setMsg("Domain was auto-renewed.") .setHistoryEntry(historyEntryDomainTransfer) @@ -637,13 +641,13 @@ public static Domain persistDomainWithPendingTransfer( () -> tm().loadByKey(domain.getAutorenewBillingEvent()) .asBuilder() - .setRecurrenceEndTime(expirationTime) + .setRecurrenceEndTime(toInstant(expirationTime)) .build())); // Update the end time of the existing autorenew poll message. We must delete it if it has no // events left in it. PollMessage.Autorenew autorenewPollMessage = tm().transact(() -> tm().loadByKey(domain.getAutorenewPollMessage())); - if (autorenewPollMessage.getEventTime().isBefore(expirationTime)) { + if (autorenewPollMessage.getEventTime().isBefore(toInstant(expirationTime))) { persistResource(autorenewPollMessage.asBuilder().setAutorenewEndTime(expirationTime).build()); } else { deleteResource(autorenewPollMessage); @@ -657,8 +661,9 @@ public static Domain persistDomainWithPendingTransfer( .addStatusValue(StatusValue.PENDING_TRANSFER) .setTransferData( transferDataBuilder - .setPendingTransferExpirationTime(expirationTime) - .setTransferredRegistrationExpirationTime(extendedRegistrationExpirationTime) + .setPendingTransferExpirationTime(toInstant(expirationTime)) + .setTransferredRegistrationExpirationTime( + toInstant(extendedRegistrationExpirationTime)) .setServerApproveBillingEvent(transferBillingEvent.createVKey()) .setServerApproveAutorenewEvent(gainingClientAutorenewEvent.createVKey()) .setServerApproveAutorenewPollMessage( @@ -857,7 +862,7 @@ public static ImmutableList getPollMessages(String registrarId, Ins () -> tm().loadAllOf(PollMessage.class).stream() .filter(pollMessage -> pollMessage.getRegistrarId().equals(registrarId)) - .filter(pollMessage -> !pollMessage.getEventTimeInstant().isAfter(beforeOrAt)) + .filter(pollMessage -> !pollMessage.getEventTime().isAfter(beforeOrAt)) .collect(toImmutableList())); } @@ -875,7 +880,7 @@ public static ImmutableList getPollMessages( .filter( pollMessage -> pollMessage.getDomainRepoId().equals(resource.getRepoId())) .filter(pollMessage -> pollMessage.getRegistrarId().equals(registrarId)) - .filter(pollMessage -> !pollMessage.getEventTimeInstant().isAfter(now)) + .filter(pollMessage -> !pollMessage.getEventTime().isAfter(now)) .collect(toImmutableList())); } @@ -977,7 +982,7 @@ public static R persistEppResource(final R resource) { HistoryEntry.createBuilderForResource(resource) .setRegistrarId(resource.getCreationRegistrarId()) .setType(getHistoryEntryType(resource)) - .setModificationTime(tm().getTransactionTime()) + .setModificationTime(tm().getTxTime()) .build()); }); maybeAdvanceClock(); @@ -1105,7 +1110,7 @@ public static HistoryEntry createHistoryEntryForEppResou return persistResource( HistoryEntry.createBuilderForResource(parentResource) .setType(getHistoryEntryType(parentResource)) - .setModificationTime(DateTime.now(DateTimeZone.UTC)) + .setModificationTime(Instant.now()) .setRegistrarId(parentResource.getPersistedCurrentSponsorRegistrarId()) .build()); } diff --git a/core/src/test/java/google/registry/testing/FullFieldsTestEntityHelper.java b/core/src/test/java/google/registry/testing/FullFieldsTestEntityHelper.java index 3a929943c87..7824c6d1df1 100644 --- a/core/src/test/java/google/registry/testing/FullFieldsTestEntityHelper.java +++ b/core/src/test/java/google/registry/testing/FullFieldsTestEntityHelper.java @@ -17,6 +17,7 @@ import static google.registry.testing.DatabaseHelper.generateNewDomainRoid; import static google.registry.testing.DatabaseHelper.generateNewHostRoid; import static google.registry.testing.DatabaseHelper.persistResource; +import static google.registry.util.DateTimeUtils.toInstant; import static google.registry.util.DomainNameUtils.getTldFromDomainName; import static java.nio.charset.StandardCharsets.UTF_8; @@ -38,6 +39,7 @@ import google.registry.persistence.VKey; import google.registry.util.Idn; import java.net.InetAddress; +import java.time.Instant; import javax.annotation.Nullable; import org.joda.time.DateTime; @@ -137,7 +139,7 @@ public static Host makePunycodedHost( new Host.Builder() .setRepoId(generateNewHostRoid()) .setHostName(fqhn) - .setCreationTimeForTest(DateTime.parse("2000-10-08T00:45:00Z")) + .setCreationTimeForTest(Instant.parse("2000-10-08T00:45:00Z")) .setPersistedCurrentSponsorRegistrarId(registrarClientId); if ((ip1 != null) || (ip2 != null)) { ImmutableSet.Builder ipBuilder = new ImmutableSet.Builder<>(); @@ -185,8 +187,8 @@ public static Domain makeDomain( new Domain.Builder() .setDomainName(Idn.toASCII(domain)) .setRepoId(generateNewDomainRoid(getTldFromDomainName(Idn.toASCII(domain)))) - .setLastEppUpdateTime(DateTime.parse("2009-05-29T20:13:00Z")) - .setCreationTimeForTest(DateTime.parse("2000-10-08T00:45:00Z")) + .setLastEppUpdateTime(Instant.parse("2009-05-29T20:13:00Z")) + .setCreationTimeForTest(Instant.parse("2000-10-08T00:45:00Z")) .setRegistrationExpirationTime(DateTime.parse("2110-10-08T00:44:59Z")) .setPersistedCurrentSponsorRegistrarId(registrar.getRegistrarId()) .setCreationRegistrarId(registrar.getRegistrarId()) @@ -220,7 +222,7 @@ public static HistoryEntry makeHistoryEntry( HistoryEntry.createBuilderForResource(resource) .setType(type) .setXmlBytes("".getBytes(UTF_8)) - .setModificationTime(modificationTime) + .setModificationTime(toInstant(modificationTime)) .setRegistrarId(resource.getPersistedCurrentSponsorRegistrarId()) .setTrid(Trid.create("ABC-123", "server-trid")) .setBySuperuser(false) diff --git a/core/src/test/java/google/registry/testing/HistoryEntrySubject.java b/core/src/test/java/google/registry/testing/HistoryEntrySubject.java index da18930c37b..e48b8dd8d37 100644 --- a/core/src/test/java/google/registry/testing/HistoryEntrySubject.java +++ b/core/src/test/java/google/registry/testing/HistoryEntrySubject.java @@ -16,6 +16,7 @@ import static com.google.common.truth.Fact.simpleFact; import static com.google.common.truth.Truth.assertAbout; +import static google.registry.util.DateTimeUtils.toInstant; import com.google.common.truth.FailureMetadata; import com.google.common.truth.SimpleSubjectBuilder; @@ -24,6 +25,7 @@ import google.registry.model.domain.Period; import google.registry.model.reporting.HistoryEntry; import google.registry.testing.TruthChainer.And; +import java.time.Instant; import java.util.Optional; import org.joda.time.DateTime; @@ -65,6 +67,11 @@ public And hasOtherRegistrarId(String otherRegistrarId) { } public And hasModificationTime(DateTime modificationTime) { + return hasValue( + toInstant(modificationTime), actual.getModificationTime(), "getModificationTime()"); + } + + public And hasModificationTime(Instant modificationTime) { return hasValue(modificationTime, actual.getModificationTime(), "getModificationTime()"); } diff --git a/core/src/test/java/google/registry/testing/HostSubject.java b/core/src/test/java/google/registry/testing/HostSubject.java index a9129b09aa3..23799b093a9 100644 --- a/core/src/test/java/google/registry/testing/HostSubject.java +++ b/core/src/test/java/google/registry/testing/HostSubject.java @@ -23,8 +23,8 @@ import google.registry.model.host.Host; import google.registry.persistence.VKey; import google.registry.testing.TruthChainer.And; +import java.time.Instant; import javax.annotation.Nullable; -import org.joda.time.DateTime; /** Truth subject for asserting things about {@link Host} instances. */ public final class HostSubject extends AbstractEppResourceSubject { @@ -40,15 +40,15 @@ public static SimpleSubjectBuilder assertAboutHosts() { return assertAbout(HostSubject::new); } - public And hasLastTransferTime(DateTime lastTransferTime) { + public And hasLastTransferTime(Instant lastTransferTime) { return hasValue(lastTransferTime, actual.getLastTransferTime(), "has lastTransferTime"); } - public And hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) { + public And hasLastTransferTimeNotEqualTo(Instant lastTransferTime) { return doesNotHaveValue(lastTransferTime, actual.getLastTransferTime(), "lastTransferTime"); } - public And hasLastSuperordinateChange(DateTime lastSuperordinateChange) { + public And hasLastSuperordinateChange(Instant lastSuperordinateChange) { return hasValue( lastSuperordinateChange, actual.getLastSuperordinateChange(), diff --git a/core/src/test/java/google/registry/tmch/NordnUploadActionTest.java b/core/src/test/java/google/registry/tmch/NordnUploadActionTest.java index 1b95855ee4d..44323a76ac2 100644 --- a/core/src/test/java/google/registry/tmch/NordnUploadActionTest.java +++ b/core/src/test/java/google/registry/tmch/NordnUploadActionTest.java @@ -86,7 +86,7 @@ class NordnUploadActionTest { private static final String LOCATION_URL = "http://trololol"; - private final FakeClock clock = new FakeClock(DateTime.parse("2010-05-01T10:11:12Z")); + private final FakeClock clock = new FakeClock(DateTime.parse("2010-05-01T10:11:12.000Z")); private final CloudTasksHelper cloudTasksHelper = new CloudTasksHelper(clock); private final CloudTasksUtils cloudTasksUtils = cloudTasksHelper.getTestCloudTasksUtils(); @@ -196,7 +196,7 @@ private void persistClaimsModeDomain() { persistResource( newDomain("claims-landrush2.tld") .asBuilder() - .setCreationTimeForTest(clock.nowUtc()) + .setCreationTimeForTest(clock.now()) .setCreationRegistrarId("NewRegistrar") .setLaunchNotice( LaunchNotice.create("landrush2tcn", null, null, clock.nowUtc().minusHours(2))) @@ -206,7 +206,7 @@ private void persistClaimsModeDomain() { persistResource( newDomain("claims-landrush1.tld") .asBuilder() - .setCreationTimeForTest(clock.nowUtc()) + .setCreationTimeForTest(clock.now()) .setLaunchNotice( LaunchNotice.create("landrush1tcn", null, null, clock.nowUtc().minusHours(1))) .setLordnPhase(LordnPhase.CLAIMS) @@ -217,7 +217,7 @@ private void persistSunriseModeDomain() { persistResource( newDomain("sunrise2.tld") .asBuilder() - .setCreationTimeForTest(clock.nowUtc()) + .setCreationTimeForTest(clock.now()) .setCreationRegistrarId("NewRegistrar") .setSmdId("new-smdid") .setLordnPhase(LordnPhase.SUNRISE) @@ -226,7 +226,7 @@ private void persistSunriseModeDomain() { persistResource( newDomain("sunrise1.tld") .asBuilder() - .setCreationTimeForTest(clock.nowUtc()) + .setCreationTimeForTest(clock.now()) .setSmdId("my-smdid") .setLordnPhase(LordnPhase.SUNRISE) .build()); diff --git a/core/src/test/java/google/registry/tools/AckPollMessagesCommandTest.java b/core/src/test/java/google/registry/tools/AckPollMessagesCommandTest.java index 2077a822092..fc588c73764 100644 --- a/core/src/test/java/google/registry/tools/AckPollMessagesCommandTest.java +++ b/core/src/test/java/google/registry/tools/AckPollMessagesCommandTest.java @@ -20,6 +20,7 @@ import static google.registry.testing.DatabaseHelper.loadByKeys; import static google.registry.testing.DatabaseHelper.loadByKeysIfPresent; import static google.registry.testing.DatabaseHelper.persistResource; +import static google.registry.util.DateTimeUtils.toInstant; import com.google.common.collect.ImmutableList; import google.registry.model.domain.Domain; @@ -30,6 +31,7 @@ import google.registry.model.reporting.HistoryEntry; import google.registry.persistence.VKey; import google.registry.testing.DatabaseHelper; +import java.time.Instant; import org.joda.time.DateTime; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -50,7 +52,7 @@ final void beforeEach() { domainHistory = persistResource( new DomainHistory.Builder() - .setModificationTime(fakeClock.nowUtc()) + .setModificationTime(fakeClock.now()) .setDomain(domain) .setRegistrarId(domain.getCreationRegistrarId()) .setType(HistoryEntry.Type.DOMAIN_CREATE) @@ -73,10 +75,10 @@ void testSuccess_doesntDeletePollMessagesInFuture() throws Exception { assertThat(loadByKeysIfPresent(ImmutableList.of(pm1, pm2, pm3, pm4)).values()) .containsExactly(futurePollMessage); assertInStdout( - "624-2013,2013-05-01T22:33:44.000Z,ninelives", - "316-2014,2014-01-01T22:33:44.000Z,foobar", - "791-2015,2015-01-08T22:33:44.000Z,ginger"); - assertNotInStdout("123-2015,2015-09-01T22:33:44.000Z,notme"); + "624-2013,2013-05-01T22:33:44Z,ninelives", + "316-2014,2014-01-01T22:33:44Z,foobar", + "791-2015,2015-01-08T22:33:44Z,ginger"); + assertNotInStdout("123-2015,2015-09-01T22:33:44Z,notme"); } @Test @@ -90,20 +92,20 @@ void testSuccess_resavesAutorenewPollMessages() throws Exception { new PollMessage.Autorenew.Builder() .setId(625L) .setHistoryEntry(domainHistory) - .setEventTime(DateTime.parse("2011-04-15T22:33:44Z")) + .setEventTime(Instant.parse("2011-04-15T22:33:44Z")) .setRegistrarId("TheRegistrar") .setMsg("autorenew") .build()); Autorenew resaved = - autorenew.asBuilder().setEventTime(DateTime.parse("2012-04-15T22:33:44Z")).build(); + autorenew.asBuilder().setEventTime(Instant.parse("2012-04-15T22:33:44Z")).build(); VKey pm3 = autorenew.createVKey(); runCommand("-c", "TheRegistrar"); assertThat(loadByKeysIfPresent(ImmutableList.of(pm1, pm2, pm3)).values()) .containsExactly(resaved); assertInStdout( - "625-2011,2011-04-15T22:33:44.000Z,autorenew", - "624-2013,2013-05-01T22:33:44.000Z,ninelives", - "316-2014,2014-01-01T22:33:44.000Z,foobar"); + "625-2011,2011-04-15T22:33:44Z,autorenew", + "624-2013,2013-05-01T22:33:44Z,ninelives", + "316-2014,2014-01-01T22:33:44Z,foobar"); } @Test @@ -117,7 +119,7 @@ void testSuccess_deletesExpiredAutorenewPollMessages() throws Exception { new PollMessage.Autorenew.Builder() .setId(625L) .setHistoryEntry(domainHistory) - .setEventTime(DateTime.parse("2011-04-15T22:33:44Z")) + .setEventTime(Instant.parse("2011-04-15T22:33:44Z")) .setAutorenewEndTime(DateTime.parse("2012-01-01T22:33:44Z")) .setRegistrarId("TheRegistrar") .setMsg("autorenew") @@ -126,9 +128,9 @@ void testSuccess_deletesExpiredAutorenewPollMessages() throws Exception { runCommand("-c", "TheRegistrar"); assertThat(loadByKeysIfPresent(ImmutableList.of(pm1, pm2, pm3))).isEmpty(); assertInStdout( - "625-2011,2011-04-15T22:33:44.000Z,autorenew", - "624-2013,2013-05-01T22:33:44.000Z,ninelives", - "316-2014,2014-01-01T22:33:44.000Z,foobar"); + "625-2011,2011-04-15T22:33:44Z,autorenew", + "624-2013,2013-05-01T22:33:44Z,ninelives", + "316-2014,2014-01-01T22:33:44Z,foobar"); } @Test @@ -163,7 +165,7 @@ void testSuccess_onlyDeletesPollMessagesMatchingClientId() throws Exception { .setId(2474L) .setHistoryEntry(domainHistory) .setRegistrarId("NewRegistrar") - .setEventTime(DateTime.parse("2013-06-01T22:33:44Z")) + .setEventTime(Instant.parse("2013-06-01T22:33:44Z")) .setMsg("baaaahh") .build()); VKey pm3 = notMatched.createVKey(); @@ -193,7 +195,7 @@ private OneTime persistPollMessage(long id, DateTime eventTime, String message) .setId(id) .setHistoryEntry(domainHistory) .setRegistrarId("TheRegistrar") - .setEventTime(eventTime) + .setEventTime(toInstant(eventTime)) .setMsg(message) .build()); } diff --git a/core/src/test/java/google/registry/tools/CreateBulkPricingPackageCommandTest.java b/core/src/test/java/google/registry/tools/CreateBulkPricingPackageCommandTest.java index e8ff93f0ecd..8120a43c823 100644 --- a/core/src/test/java/google/registry/tools/CreateBulkPricingPackageCommandTest.java +++ b/core/src/test/java/google/registry/tools/CreateBulkPricingPackageCommandTest.java @@ -27,6 +27,7 @@ import google.registry.model.domain.token.AllocationToken; import google.registry.model.domain.token.AllocationToken.TokenType; import google.registry.model.domain.token.BulkPricingPackage; +import java.time.Instant; import java.util.Optional; import org.joda.money.CurrencyUnit; import org.joda.money.Money; @@ -43,7 +44,7 @@ void testSuccess() throws Exception { new AllocationToken.Builder() .setToken("abc123") .setTokenType(TokenType.BULK_PRICING) - .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) + .setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) @@ -76,7 +77,7 @@ void testFailure_tokenIsNotBulkType() throws Exception { new AllocationToken.Builder() .setToken("abc123") .setTokenType(TokenType.SINGLE_USE) - .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) + .setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) @@ -121,7 +122,7 @@ void testFailure_bulkPricingPackageAlreadyExists() throws Exception { new AllocationToken.Builder() .setToken("abc123") .setTokenType(TokenType.BULK_PRICING) - .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) + .setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) @@ -158,7 +159,7 @@ void testSuccess_missingMaxDomainsAndCreatesInitializesToZero() throws Exception new AllocationToken.Builder() .setToken("abc123") .setTokenType(TokenType.BULK_PRICING) - .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) + .setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) @@ -185,7 +186,7 @@ void testSuccess_missingNextBillingDateInitializesToEndOfTime() throws Exception new AllocationToken.Builder() .setToken("abc123") .setTokenType(TokenType.BULK_PRICING) - .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) + .setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) @@ -212,7 +213,7 @@ void testFailure_missingPrice() throws Exception { new AllocationToken.Builder() .setToken("abc123") .setTokenType(TokenType.BULK_PRICING) - .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) + .setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) diff --git a/core/src/test/java/google/registry/tools/DomainLockUtilsTest.java b/core/src/test/java/google/registry/tools/DomainLockUtilsTest.java index 341fd350955..4c013fd0fa5 100644 --- a/core/src/test/java/google/registry/tools/DomainLockUtilsTest.java +++ b/core/src/test/java/google/registry/tools/DomainLockUtilsTest.java @@ -28,7 +28,6 @@ import static google.registry.testing.SqlHelper.saveRegistryLock; import static google.registry.tools.LockOrUnlockDomainCommand.REGISTRY_LOCK_STATUSES; import static org.joda.time.Duration.standardDays; -import static org.joda.time.Duration.standardHours; import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.cloud.tasks.v2.HttpMethod; @@ -57,6 +56,7 @@ import java.util.stream.Collectors; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; +import org.joda.time.Duration; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -244,8 +244,8 @@ void testSuccess_createUnlock_relockDuration() { domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false); RegistryLock lock = domainLockUtils.saveNewRegistryUnlockRequest( - DOMAIN_NAME, "TheRegistrar", false, Optional.of(standardDays(1))); - assertThat(lock.getRelockDuration()).isEqualTo(Optional.of(standardDays(1))); + DOMAIN_NAME, "TheRegistrar", false, Optional.of(Duration.standardDays(1))); + assertThat(lock.getRelockDuration()).hasValue(Duration.standardDays(1)); } @Test @@ -253,7 +253,7 @@ void testSuccess_unlock_relockSubmitted() { domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false); RegistryLock lock = domainLockUtils.saveNewRegistryUnlockRequest( - DOMAIN_NAME, "TheRegistrar", false, Optional.of(standardHours(6))); + DOMAIN_NAME, "TheRegistrar", false, Optional.of(Duration.standardHours(6))); domainLockUtils.verifyVerificationCode(lock.getVerificationCode(), false); cloudTasksHelper.assertTasksEnqueued( QUEUE_ASYNC_ACTIONS, @@ -276,7 +276,7 @@ void testSuccess_adminCanLockLockedDomain_withNoSavedLock() { RegistryLock resultLock = domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, true); verifyProperlyLockedDomain(true); - assertThat(resultLock.getLockCompletionTime()).isEqualTo(Optional.of(clock.nowUtc())); + assertThat(resultLock.getLockCompletionTime()).hasValue(clock.now()); } @Test @@ -285,7 +285,7 @@ void testSuccess_adminCanLockUnlockedDomain_withSavedLock() { // what the RegistryLock table says SqlHelper.saveRegistryLock( new RegistryLock.Builder() - .setLockCompletionTime(clock.nowUtc()) + .setLockCompletionTime(clock.now()) .setDomainName(DOMAIN_NAME) .setVerificationCode("hi") .setRegistrarId("TheRegistrar") @@ -297,7 +297,7 @@ void testSuccess_adminCanLockUnlockedDomain_withSavedLock() { RegistryLock resultLock = domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, true); verifyProperlyLockedDomain(true); - assertThat(resultLock.getLockCompletionTime()).isEqualTo(Optional.of(clock.nowUtc())); + assertThat(resultLock.getLockCompletionTime()).hasValue(clock.now()); } @Test @@ -469,13 +469,13 @@ void testEnqueueRelock() { RegistryLock lock = saveRegistryLock( new RegistryLock.Builder() - .setLockCompletionTime(clock.nowUtc()) - .setUnlockRequestTime(clock.nowUtc()) - .setUnlockCompletionTime(clock.nowUtc()) + .setLockCompletionTime(clock.now()) + .setUnlockRequestTime(clock.now()) + .setUnlockCompletionTime(clock.now()) .isSuperuser(false) .setDomainName("example.tld") .setRepoId("repoId") - .setRelockDuration(standardHours(6)) + .setRelockDuration(Duration.standardHours(6)) .setRegistrarId("TheRegistrar") .setRegistryLockEmail("someone@example.com") .setVerificationCode("hi") @@ -571,8 +571,8 @@ private void assertBillingEvents(ImmutableList historyEntries) { .setTargetId(domain.getForeignKey()) .setRegistrarId(domain.getCurrentSponsorRegistrarId()) .setCost(Tld.get(domain.getTld()).getRegistryLockOrUnlockBillingCost()) - .setEventTime(clock.nowUtc()) - .setBillingTime(clock.nowUtc()) + .setEventTime(clock.now()) + .setBillingTime(clock.now()) .setDomainHistory(entry) .build()) .collect(Collectors.toSet()); diff --git a/core/src/test/java/google/registry/tools/EnqueuePollMessageCommandTest.java b/core/src/test/java/google/registry/tools/EnqueuePollMessageCommandTest.java index f8021345634..ea275a4516c 100644 --- a/core/src/test/java/google/registry/tools/EnqueuePollMessageCommandTest.java +++ b/core/src/test/java/google/registry/tools/EnqueuePollMessageCommandTest.java @@ -61,7 +61,7 @@ void testSuccess_domainAndMessage() throws Exception { .and() .hasRegistrarId("AdminRegistrar") .and() - .hasModificationTime(fakeClock.nowUtc()) + .hasModificationTime(fakeClock.now()) .and() .hasMetadataRequestedByRegistrar(false); assertPollMessages( @@ -70,7 +70,7 @@ void testSuccess_domainAndMessage() throws Exception { .setHistoryEntry(synthetic) .setMsg("This domain is bad") .setRegistrarId("TheRegistrar") - .setEventTime(fakeClock.nowUtc()) + .setEventTime(fakeClock.now()) .build()); } @@ -93,7 +93,7 @@ void testSuccess_specifyClientIds() throws Exception { .and() .hasRegistrarId("AdminRegistrar") .and() - .hasModificationTime(fakeClock.nowUtc()) + .hasModificationTime(fakeClock.now()) .and() .hasMetadataRequestedByRegistrar(false); assertPollMessages( @@ -102,7 +102,7 @@ void testSuccess_specifyClientIds() throws Exception { .setHistoryEntry(synthetic) .setMsg("This domain needs work") .setRegistrarId("TheRegistrar") - .setEventTime(fakeClock.nowUtc()) + .setEventTime(fakeClock.now()) .build()); assertPollMessages( "NewRegistrar", @@ -110,7 +110,7 @@ void testSuccess_specifyClientIds() throws Exception { .setHistoryEntry(synthetic) .setMsg("This domain needs work") .setRegistrarId("NewRegistrar") - .setEventTime(fakeClock.nowUtc()) + .setEventTime(fakeClock.now()) .build()); assertPollMessages( "foobaz", @@ -118,7 +118,7 @@ void testSuccess_specifyClientIds() throws Exception { .setHistoryEntry(synthetic) .setMsg("This domain needs work") .setRegistrarId("foobaz") - .setEventTime(fakeClock.nowUtc()) + .setEventTime(fakeClock.now()) .build()); } @@ -138,7 +138,7 @@ void testSuccess_sendToAllRegistrars() throws Exception { .and() .hasRegistrarId("AdminRegistrar") .and() - .hasModificationTime(fakeClock.nowUtc()) + .hasModificationTime(fakeClock.now()) .and() .hasMetadataRequestedByRegistrar(false); assertPollMessages( @@ -147,7 +147,7 @@ void testSuccess_sendToAllRegistrars() throws Exception { .setHistoryEntry(synthetic) .setMsg("This domain needs work") .setRegistrarId("TheRegistrar") - .setEventTime(fakeClock.nowUtc()) + .setEventTime(fakeClock.now()) .build()); assertPollMessages( "NewRegistrar", @@ -155,7 +155,7 @@ void testSuccess_sendToAllRegistrars() throws Exception { .setHistoryEntry(synthetic) .setMsg("This domain needs work") .setRegistrarId("NewRegistrar") - .setEventTime(fakeClock.nowUtc()) + .setEventTime(fakeClock.now()) .build()); assertPollMessages( "foobaz", @@ -163,7 +163,7 @@ void testSuccess_sendToAllRegistrars() throws Exception { .setHistoryEntry(synthetic) .setMsg("This domain needs work") .setRegistrarId("foobaz") - .setEventTime(fakeClock.nowUtc()) + .setEventTime(fakeClock.now()) .build()); } diff --git a/core/src/test/java/google/registry/tools/EppLifecycleToolsTest.java b/core/src/test/java/google/registry/tools/EppLifecycleToolsTest.java index f7974b92e87..3b7372e82c1 100644 --- a/core/src/test/java/google/registry/tools/EppLifecycleToolsTest.java +++ b/core/src/test/java/google/registry/tools/EppLifecycleToolsTest.java @@ -33,6 +33,7 @@ import google.registry.testing.TestCacheExtension; import google.registry.util.Clock; import java.time.Duration; +import java.time.Instant; import java.util.List; import org.joda.money.Money; import org.joda.time.DateTime; @@ -154,8 +155,8 @@ void test_renewDomainThenUnrenew() throws Exception { .setRegistrarId(domain.getCurrentSponsorRegistrarId()) .setCost(Money.parse("USD 44.00")) .setPeriodYears(4) - .setEventTime(DateTime.parse("2000-06-07T00:00:00Z")) - .setBillingTime(DateTime.parse("2000-06-12T00:00:00Z")) + .setEventTime(Instant.parse("2000-06-07T00:00:00Z")) + .setBillingTime(Instant.parse("2000-06-12T00:00:00Z")) .setDomainHistory( getOnlyHistoryEntryOfType(domain, Type.DOMAIN_RENEW, DomainHistory.class)) .build(); diff --git a/core/src/test/java/google/registry/tools/GenerateDnsReportCommandTest.java b/core/src/test/java/google/registry/tools/GenerateDnsReportCommandTest.java index 50d6e844a6d..ef35caa39b6 100644 --- a/core/src/test/java/google/registry/tools/GenerateDnsReportCommandTest.java +++ b/core/src/test/java/google/registry/tools/GenerateDnsReportCommandTest.java @@ -21,6 +21,7 @@ import static google.registry.testing.DatabaseHelper.persistActiveDomain; import static google.registry.testing.DatabaseHelper.persistActiveHost; import static google.registry.testing.DatabaseHelper.persistResource; +import static google.registry.util.DateTimeUtils.plusDays; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -164,7 +165,7 @@ void testSuccess() throws Exception { @Test void testSuccess_skipDeletedDomain() throws Exception { - persistResource(domain1.asBuilder().setDeletionTime(fakeClock.nowUtc()).build()); + persistResource(domain1.asBuilder().setDeletionTime(fakeClock.now()).build()); runCommand("--output=" + output, "--tld=xn--q9jyb4c"); assertThat((Iterable) getOutputAsJson()) .containsExactly(DOMAIN2_OUTPUT, NAMESERVER1_OUTPUT, NAMESERVER2_OUTPUT); @@ -172,7 +173,7 @@ void testSuccess_skipDeletedDomain() throws Exception { @Test void testSuccess_skipDeletedNameserver() throws Exception { - persistResource(nameserver1.asBuilder().setDeletionTime(fakeClock.nowUtc()).build()); + persistResource(nameserver1.asBuilder().setDeletionTime(fakeClock.now()).build()); runCommand("--output=" + output, "--tld=xn--q9jyb4c"); Iterable output = (Iterable) getOutputAsJson(); assertThat(output).containsAnyOf(DOMAIN1_OUTPUT, DOMAIN1_OUTPUT_ALT); @@ -201,7 +202,7 @@ void testSuccess_skipPendingDeleteDomain() throws Exception { domain1 .asBuilder() .addStatusValue(StatusValue.PENDING_DELETE) - .setDeletionTime(fakeClock.nowUtc().plusDays(30)) + .setDeletionTime(plusDays(fakeClock.now(), 30)) .build()); runCommand("--output=" + output, "--tld=xn--q9jyb4c"); assertThat((Iterable) getOutputAsJson()) diff --git a/core/src/test/java/google/registry/tools/GetAllocationTokenCommandTest.java b/core/src/test/java/google/registry/tools/GetAllocationTokenCommandTest.java index f815560fb11..121994c903e 100644 --- a/core/src/test/java/google/registry/tools/GetAllocationTokenCommandTest.java +++ b/core/src/test/java/google/registry/tools/GetAllocationTokenCommandTest.java @@ -31,6 +31,7 @@ import google.registry.model.domain.fee.FeeQueryCommandExtensionItem; import google.registry.model.domain.token.AllocationToken; import google.registry.util.DateTimeUtils; +import java.time.Instant; import org.joda.time.DateTime; import org.junit.jupiter.api.Test; @@ -99,7 +100,7 @@ void testSuccess_multipleTokens() throws Exception { new AllocationToken.Builder() .setToken("fee") .setTokenType(SINGLE_USE) - .setCreationTimeForTest(DateTime.parse("2015-04-07T22:19:17.044Z")) + .setCreationTimeForTest(Instant.parse("2015-04-07T22:19:17.044Z")) .build(), new AllocationToken.Builder() .setToken("fii") diff --git a/core/src/test/java/google/registry/tools/GetBulkPricingPackageCommandTest.java b/core/src/test/java/google/registry/tools/GetBulkPricingPackageCommandTest.java index 497cf834f3e..5a30838569d 100644 --- a/core/src/test/java/google/registry/tools/GetBulkPricingPackageCommandTest.java +++ b/core/src/test/java/google/registry/tools/GetBulkPricingPackageCommandTest.java @@ -27,6 +27,7 @@ import google.registry.model.domain.token.AllocationToken; import google.registry.model.domain.token.AllocationToken.TokenType; import google.registry.model.domain.token.BulkPricingPackage; +import java.time.Instant; import org.joda.money.CurrencyUnit; import org.joda.money.Money; import org.joda.time.DateTime; @@ -49,7 +50,7 @@ void testSuccess() throws Exception { new AllocationToken.Builder() .setToken("abc123") .setTokenType(TokenType.BULK_PRICING) - .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) + .setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) @@ -77,7 +78,7 @@ void testSuccessMultipleBulkPricingPackages() throws Exception { new AllocationToken.Builder() .setToken("abc123") .setTokenType(TokenType.BULK_PRICING) - .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) + .setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) @@ -101,7 +102,7 @@ void testSuccessMultipleBulkPricingPackages() throws Exception { new AllocationToken.Builder() .setToken("123abc") .setTokenType(TokenType.BULK_PRICING) - .setCreationTimeForTest(DateTime.parse("2012-11-12T05:00:00Z")) + .setCreationTimeForTest(Instant.parse("2012-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) diff --git a/core/src/test/java/google/registry/tools/GetDomainCommandTest.java b/core/src/test/java/google/registry/tools/GetDomainCommandTest.java index 29154178721..a3b25a3f289 100644 --- a/core/src/test/java/google/registry/tools/GetDomainCommandTest.java +++ b/core/src/test/java/google/registry/tools/GetDomainCommandTest.java @@ -18,6 +18,7 @@ import static google.registry.testing.DatabaseHelper.persistActiveDomain; import static google.registry.testing.DatabaseHelper.persistDeletedDomain; import static google.registry.testing.DatabaseHelper.persistResource; +import static google.registry.util.DateTimeUtils.plusDays; import static org.junit.jupiter.api.Assertions.assertThrows; import com.beust.jcommander.ParameterException; @@ -75,7 +76,7 @@ void testSuccess_domainDeletedInFuture() throws Exception { persistResource( DatabaseHelper.newDomain("example.tld") .asBuilder() - .setDeletionTime(fakeClock.nowUtc().plusDays(1)) + .setDeletionTime(plusDays(fakeClock.now(), 1)) .build()); runCommand("example.tld", "--read_timestamp=" + fakeClock.nowUtc().plusMonths(1)); assertInStdout("Domain 'example.tld' does not exist or is deleted"); diff --git a/core/src/test/java/google/registry/tools/GetHostCommandTest.java b/core/src/test/java/google/registry/tools/GetHostCommandTest.java index 87a0a1baaf6..529972512c3 100644 --- a/core/src/test/java/google/registry/tools/GetHostCommandTest.java +++ b/core/src/test/java/google/registry/tools/GetHostCommandTest.java @@ -19,6 +19,7 @@ import static google.registry.testing.DatabaseHelper.persistActiveHost; import static google.registry.testing.DatabaseHelper.persistDeletedHost; import static google.registry.testing.DatabaseHelper.persistResource; +import static google.registry.util.DateTimeUtils.plusDays; import static org.junit.jupiter.api.Assertions.assertThrows; import com.beust.jcommander.ParameterException; @@ -90,7 +91,7 @@ void testSuccess_hostDeletedInFuture() throws Exception { persistResource( newHost("ns1.example.tld") .asBuilder() - .setDeletionTime(fakeClock.nowUtc().plusDays(1)) + .setDeletionTime(plusDays(fakeClock.now(), 1)) .build()); runCommand("ns1.example.tld", "--read_timestamp=" + fakeClock.nowUtc().plusMonths(1)); assertInStdout("Host 'ns1.example.tld' does not exist or is deleted"); diff --git a/core/src/test/java/google/registry/tools/MutatingCommandTest.java b/core/src/test/java/google/registry/tools/MutatingCommandTest.java index 58719a78097..54dbfa01228 100644 --- a/core/src/test/java/google/registry/tools/MutatingCommandTest.java +++ b/core/src/test/java/google/registry/tools/MutatingCommandTest.java @@ -24,7 +24,6 @@ import static google.registry.testing.DatabaseHelper.persistActiveHost; import static google.registry.testing.DatabaseHelper.persistNewRegistrar; import static google.registry.testing.DatabaseHelper.persistResource; -import static org.joda.time.DateTimeZone.UTC; import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.collect.ImmutableList; @@ -34,9 +33,9 @@ import google.registry.persistence.VKey; import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; +import java.time.Instant; import java.util.Optional; import java.util.stream.Stream; -import org.joda.time.DateTime; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -67,9 +66,8 @@ void beforeEach() { createTld("tld"); host1 = persistActiveHost("host1.example.tld"); host2 = persistActiveHost("host2.example.tld"); - newHost1 = host1.asBuilder() - .setLastEppUpdateTime(DateTime.parse("2014-09-09T09:09:09.000Z")) - .build(); + newHost1 = + host1.asBuilder().setLastEppUpdateTime(Instant.parse("2014-09-09T09:09:09.000Z")).build(); newHost2 = host2.asBuilder().setPersistedCurrentSponsorRegistrarId("Registrar2").build(); } @@ -331,8 +329,7 @@ void testFailure_updateSameEntityTwice() { @Override protected void init() { stageEntityChange(host1, newHost1); - stageEntityChange( - host1, host1.asBuilder().setLastEppUpdateTime(DateTime.now(UTC)).build()); + stageEntityChange(host1, host1.asBuilder().setLastEppUpdateTime(Instant.now()).build()); } }; IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, command::init); diff --git a/core/src/test/java/google/registry/tools/RenewDomainCommandTest.java b/core/src/test/java/google/registry/tools/RenewDomainCommandTest.java index 800548609d8..63d01f64174 100644 --- a/core/src/test/java/google/registry/tools/RenewDomainCommandTest.java +++ b/core/src/test/java/google/registry/tools/RenewDomainCommandTest.java @@ -28,6 +28,7 @@ import google.registry.model.domain.Domain; import google.registry.model.registrar.Registrar; import google.registry.testing.DatabaseHelper; +import java.time.Instant; import java.util.List; import org.joda.time.DateTime; import org.junit.jupiter.api.BeforeEach; @@ -78,7 +79,7 @@ private static List persistThreeDomains() { persistResource( DatabaseHelper.newDomain("domain3.tld") .asBuilder() - .setCreationTimeForTest(DateTime.parse("2015-01-05T05:05:05Z")) + .setCreationTimeForTest(Instant.parse("2015-01-05T05:05:05Z")) .setRegistrationExpirationTime(DateTime.parse("2016-01-05T05:05:05Z")) .setPersistedCurrentSponsorRegistrarId("NewRegistrar") .build())); diff --git a/core/src/test/java/google/registry/tools/UniformRapidSuspensionCommandTest.java b/core/src/test/java/google/registry/tools/UniformRapidSuspensionCommandTest.java index 9d2c13107aa..9913954aaf5 100644 --- a/core/src/test/java/google/registry/tools/UniformRapidSuspensionCommandTest.java +++ b/core/src/test/java/google/registry/tools/UniformRapidSuspensionCommandTest.java @@ -31,6 +31,7 @@ import google.registry.persistence.VKey; import google.registry.testing.DatabaseHelper; import jakarta.xml.bind.annotation.adapters.HexBinaryAdapter; +import java.time.Instant; import org.joda.time.DateTime; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -297,7 +298,7 @@ void testRenewOneYearWithoutUndo_verifyReasonWithoutUndo() throws Exception { persistDomainWithHosts( DatabaseHelper.newDomain("evil.tld") .asBuilder() - .setCreationTimeForTest(DateTime.parse("2021-10-01T05:01:11Z")) + .setCreationTimeForTest(Instant.parse("2021-10-01T05:01:11Z")) .setRegistrationExpirationTime(DateTime.parse("2022-10-01T05:01:11Z")) .setPersistedCurrentSponsorRegistrarId("CharlestonRoad") .build(), @@ -334,7 +335,7 @@ void testRenewOneYearWithUndo_verifyReasonWithUndo() throws Exception { persistDomainWithHosts( DatabaseHelper.newDomain("evil.tld") .asBuilder() - .setCreationTimeForTest(DateTime.parse("2021-10-01T05:01:11Z")) + .setCreationTimeForTest(Instant.parse("2021-10-01T05:01:11Z")) .setRegistrationExpirationTime(DateTime.parse("2022-10-01T05:01:11Z")) .setPersistedCurrentSponsorRegistrarId("CharlestonRoad") .build(), @@ -372,7 +373,7 @@ void testRenewOneYear_verifyBothRenewAndUpdateFlowsAreTriggered() throws Excepti persistDomainWithHosts( DatabaseHelper.newDomain("evil.tld") .asBuilder() - .setCreationTimeForTest(DateTime.parse("2021-10-01T05:01:11Z")) + .setCreationTimeForTest(Instant.parse("2021-10-01T05:01:11Z")) .setRegistrationExpirationTime(DateTime.parse("2022-10-01T05:01:11Z")) .setPersistedCurrentSponsorRegistrarId("CharlestonRoad") .build(), diff --git a/core/src/test/java/google/registry/tools/UnrenewDomainCommandTest.java b/core/src/test/java/google/registry/tools/UnrenewDomainCommandTest.java index 378231a46af..5886e9c05e8 100644 --- a/core/src/test/java/google/registry/tools/UnrenewDomainCommandTest.java +++ b/core/src/test/java/google/registry/tools/UnrenewDomainCommandTest.java @@ -29,6 +29,7 @@ import static google.registry.testing.DatabaseHelper.persistDomainWithDependentResources; import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries; +import static google.registry.util.DateTimeUtils.toInstant; import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.collect.ImmutableSet; @@ -106,7 +107,7 @@ void test_unrenewDomain_savesDependentEntitiesCorrectly() throws Exception { assertAboutHistoryEntries() .that(getOnlyHistoryEntryOfType(domain, SYNTHETIC)) - .hasModificationTime(unrenewTime) + .hasModificationTime(toInstant(unrenewTime)) .and() .hasMetadataReason("Domain unrenewal") .and() @@ -127,7 +128,7 @@ void test_unrenewDomain_savesDependentEntitiesCorrectly() throws Exception { .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId(domain.getDomainName()) .setRegistrarId("TheRegistrar") - .setEventTime(newExpirationTime) + .setEventTime(toInstant(newExpirationTime)) .build()); assertPollMessagesEqual( getPollMessages(domain), @@ -138,19 +139,19 @@ void test_unrenewDomain_savesDependentEntitiesCorrectly() throws Exception { .setMsg( "Domain foo.tld was unrenewed by 2 years; " + "now expires at 2019-12-06T13:55:01.001Z.") - .setEventTime(unrenewTime) + .setEventTime(toInstant(unrenewTime)) .build(), new PollMessage.Autorenew.Builder() .setHistoryEntry(synthetic) .setTargetId("foo.tld") .setRegistrarId("TheRegistrar") - .setEventTime(newExpirationTime) + .setEventTime(toInstant(newExpirationTime)) .setMsg("Domain was auto-renewed.") .build())); // Check that fields on domain were updated correctly. assertThat(domain.getRegistrationExpirationDateTime()).isEqualTo(newExpirationTime); - assertThat(domain.getLastEppUpdateDateTime()).isEqualTo(unrenewTime); + assertThat(domain.getLastEppUpdateTime()).isEqualTo(toInstant(unrenewTime)); assertThat(domain.getLastEppUpdateRegistrarId()).isEqualTo("TheRegistrar"); } @@ -177,7 +178,7 @@ void test_varietyOfInvalidDomains_displaysErrors() { persistResource( DatabaseHelper.newDomain("deleting.tld") .asBuilder() - .setDeletionTime(now.plusHours(1)) + .setDeletionTime(toInstant(now.plusHours(1))) .setStatusValues(ImmutableSet.of(PENDING_DELETE)) .build()); persistDeletedDomain("deleted.tld", now.minusHours(1)); diff --git a/core/src/test/java/google/registry/tools/UpdateBulkPricingPackageCommandTest.java b/core/src/test/java/google/registry/tools/UpdateBulkPricingPackageCommandTest.java index 35173fa5a3d..d87d64f3f8c 100644 --- a/core/src/test/java/google/registry/tools/UpdateBulkPricingPackageCommandTest.java +++ b/core/src/test/java/google/registry/tools/UpdateBulkPricingPackageCommandTest.java @@ -26,6 +26,7 @@ import google.registry.model.domain.token.AllocationToken; import google.registry.model.domain.token.AllocationToken.TokenType; import google.registry.model.domain.token.BulkPricingPackage; +import java.time.Instant; import java.util.Optional; import org.joda.money.CurrencyUnit; import org.joda.money.Money; @@ -44,7 +45,7 @@ void beforeEach() { new AllocationToken.Builder() .setToken("abc123") .setTokenType(TokenType.BULK_PRICING) - .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) + .setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) @@ -92,7 +93,7 @@ void testFailure_bulkPackageDoesNotExist() throws Exception { new AllocationToken.Builder() .setToken("nullPackage") .setTokenType(TokenType.BULK_PRICING) - .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) + .setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z")) .setAllowedTlds(ImmutableSet.of("foo")) .setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar")) .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) diff --git a/core/src/test/java/google/registry/tools/UpdateDomainCommandTest.java b/core/src/test/java/google/registry/tools/UpdateDomainCommandTest.java index 376c9b1ce4d..4b302c13578 100644 --- a/core/src/test/java/google/registry/tools/UpdateDomainCommandTest.java +++ b/core/src/test/java/google/registry/tools/UpdateDomainCommandTest.java @@ -25,7 +25,9 @@ import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.TestLogHandlerUtils.assertLogMessage; import static google.registry.testing.TestLogHandlerUtils.assertNoLogMessage; -import static google.registry.util.DateTimeUtils.END_OF_TIME; +import static google.registry.util.DateTimeUtils.END_INSTANT; +import static google.registry.util.DateTimeUtils.minusDays; +import static google.registry.util.DateTimeUtils.plusDays; import static org.junit.jupiter.api.Assertions.assertThrows; import com.beust.jcommander.ParameterException; @@ -274,7 +276,7 @@ void testSuccess_disableAutorenew_inAutorenewGracePeriod() throws Exception { DomainHistory createHistoryEntry = persistResource( new DomainHistory.Builder() - .setModificationTime(fakeClock.nowUtc()) + .setModificationTime(fakeClock.now()) .setType(DOMAIN_CREATE) .setDomain(domain) .setRegistrarId(domain.getCreationRegistrarId()) @@ -286,8 +288,8 @@ void testSuccess_disableAutorenew_inAutorenewGracePeriod() throws Exception { .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId("example.tld") .setRegistrarId("NewRegistrar") - .setEventTime(fakeClock.nowUtc().minusDays(5)) - .setRecurrenceEndTime(END_OF_TIME) + .setEventTime(minusDays(fakeClock.now(), 5)) + .setRecurrenceEndTime(END_INSTANT) .setDomainHistory(createHistoryEntry) .build()); persistResource( @@ -300,7 +302,7 @@ void testSuccess_disableAutorenew_inAutorenewGracePeriod() throws Exception { GracePeriod.createForRecurrence( AUTO_RENEW, domain.getRepoId(), - fakeClock.nowUtc().plusDays(40), + plusDays(fakeClock.now(), 40), "NewRegistrar", autorenewBillingEvent.createVKey()))) .build()); diff --git a/core/src/test/java/google/registry/tools/UpdateRecurrenceCommandTest.java b/core/src/test/java/google/registry/tools/UpdateRecurrenceCommandTest.java index a4d5553f527..968adf09b24 100644 --- a/core/src/test/java/google/registry/tools/UpdateRecurrenceCommandTest.java +++ b/core/src/test/java/google/registry/tools/UpdateRecurrenceCommandTest.java @@ -22,7 +22,9 @@ import static google.registry.testing.DatabaseHelper.persistDomainWithDependentResources; import static google.registry.testing.DatabaseHelper.persistDomainWithPendingTransfer; import static google.registry.testing.DatabaseHelper.persistResource; +import static google.registry.util.DateTimeUtils.END_INSTANT; import static google.registry.util.DateTimeUtils.END_OF_TIME; +import static google.registry.util.DateTimeUtils.minusDays; import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.collect.Iterables; @@ -54,7 +56,7 @@ void testSuccess_setsSpecified() throws Exception { persistDomain(); BillingRecurrence existingBillingRecurrence = Iterables.getOnlyElement(loadAllOf(BillingRecurrence.class)); - assertThat(existingBillingRecurrence.getRecurrenceEndTime()).isEqualTo(END_OF_TIME); + assertThat(existingBillingRecurrence.getRecurrenceEndTime()).isEqualTo(END_INSTANT); assertThat(existingBillingRecurrence.getRenewalPriceBehavior()) .isEqualTo(RenewalPriceBehavior.DEFAULT); runCommandForced( @@ -64,7 +66,7 @@ void testSuccess_setsSpecified() throws Exception { "--specified_renewal_price", "USD 9001"); assertThat(loadByEntity(existingBillingRecurrence).getRecurrenceEndTime()) - .isEqualTo(fakeClock.nowUtc()); + .isEqualTo(fakeClock.now()); assertNewBillingEventAndHistory( existingBillingRecurrence.getId(), RenewalPriceBehavior.SPECIFIED, @@ -76,12 +78,12 @@ void testSuccess_setsNonPremium() throws Exception { persistDomain(); BillingRecurrence existingBillingRecurrence = Iterables.getOnlyElement(loadAllOf(BillingRecurrence.class)); - assertThat(existingBillingRecurrence.getRecurrenceEndTime()).isEqualTo(END_OF_TIME); + assertThat(existingBillingRecurrence.getRecurrenceEndTime()).isEqualTo(END_INSTANT); assertThat(existingBillingRecurrence.getRenewalPriceBehavior()) .isEqualTo(RenewalPriceBehavior.DEFAULT); runCommandForced("domain.tld", "--renewal_price_behavior", "NONPREMIUM"); assertThat(loadByEntity(existingBillingRecurrence).getRecurrenceEndTime()) - .isEqualTo(fakeClock.nowUtc()); + .isEqualTo(fakeClock.now()); assertNewBillingEventAndHistory( existingBillingRecurrence.getId(), RenewalPriceBehavior.NONPREMIUM, null); } @@ -97,10 +99,10 @@ void testSuccess_setsDefault() throws Exception { .setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED) .setRenewalPrice(Money.of(CurrencyUnit.USD, 100)) .build()); - assertThat(existingBillingRecurrence.getRecurrenceEndTime()).isEqualTo(END_OF_TIME); + assertThat(existingBillingRecurrence.getRecurrenceEndTime()).isEqualTo(END_INSTANT); runCommandForced("domain.tld", "--renewal_price_behavior", "DEFAULT"); assertThat(loadByEntity(existingBillingRecurrence).getRecurrenceEndTime()) - .isEqualTo(fakeClock.nowUtc()); + .isEqualTo(fakeClock.now()); assertNewBillingEventAndHistory( existingBillingRecurrence.getId(), RenewalPriceBehavior.DEFAULT, null); } @@ -132,7 +134,7 @@ void testSuccess_completedTransfer() throws Exception { .setTransferData( new DomainTransferData.Builder() .setTransferStatus(TransferStatus.CLIENT_APPROVED) - .setPendingTransferExpirationTime(fakeClock.nowUtc().minusDays(8)) + .setPendingTransferExpirationTime(minusDays(fakeClock.now(), 8)) .build()) .build()); BillingRecurrence billingRecurrence = loadByKey(domain.getAutorenewBillingEvent()); @@ -191,7 +193,7 @@ void testFailure_invalidInputs() throws Exception { void testFailure_billingAlreadyClosed() { Domain domain = persistDomain(); BillingRecurrence billingRecurrence = loadByKey(domain.getAutorenewBillingEvent()); - persistResource(billingRecurrence.asBuilder().setRecurrenceEndTime(fakeClock.nowUtc()).build()); + persistResource(billingRecurrence.asBuilder().setRecurrenceEndTime(fakeClock.now()).build()); assertThat( assertThrows( IllegalArgumentException.class, @@ -222,7 +224,7 @@ private void assertNewBillingEventAndHistory( .filter(r -> r.getId() != previousId) .findFirst() .get(); - assertThat(newBillingRecurrence.getRecurrenceEndTime()).isEqualTo(END_OF_TIME); + assertThat(newBillingRecurrence.getRecurrenceEndTime()).isEqualTo(END_INSTANT); assertThat(newBillingRecurrence.getRenewalPriceBehavior()).isEqualTo(expectedBehavior); assertThat(newBillingRecurrence.getRenewalPrice()) .isEqualTo(Optional.ofNullable(expectedPrice)); diff --git a/core/src/test/java/google/registry/tools/javascrap/CreateCancellationsForBillingEventsCommandTest.java b/core/src/test/java/google/registry/tools/javascrap/CreateCancellationsForBillingEventsCommandTest.java index f2b720bf95b..6dc60d8794e 100644 --- a/core/src/test/java/google/registry/tools/javascrap/CreateCancellationsForBillingEventsCommandTest.java +++ b/core/src/test/java/google/registry/tools/javascrap/CreateCancellationsForBillingEventsCommandTest.java @@ -128,8 +128,8 @@ private BillingEvent createBillingEvent() { .setRegistrarId("TheRegistrar") .setCost(Money.of(CurrencyUnit.USD, 10)) .setPeriodYears(2) - .setEventTime(fakeClock.nowUtc()) - .setBillingTime(fakeClock.nowUtc()) + .setEventTime(fakeClock.now()) + .setBillingTime(fakeClock.now()) .setFlags(ImmutableSet.of()) .setDomainHistory( Iterables.getOnlyElement( diff --git a/core/src/test/java/google/registry/tools/javascrap/RecreateBillingRecurrencesCommandTest.java b/core/src/test/java/google/registry/tools/javascrap/RecreateBillingRecurrencesCommandTest.java index 18c8eeafaf2..1705bfa37bc 100644 --- a/core/src/test/java/google/registry/tools/javascrap/RecreateBillingRecurrencesCommandTest.java +++ b/core/src/test/java/google/registry/tools/javascrap/RecreateBillingRecurrencesCommandTest.java @@ -21,13 +21,15 @@ import static google.registry.testing.DatabaseHelper.loadByKey; import static google.registry.testing.DatabaseHelper.persistDomainWithDependentResources; import static google.registry.testing.DatabaseHelper.persistResource; -import static google.registry.util.DateTimeUtils.END_OF_TIME; +import static google.registry.util.DateTimeUtils.END_INSTANT; +import static google.registry.util.DateTimeUtils.plusDays; import static org.junit.Assert.assertThrows; import google.registry.model.ImmutableObjectSubject; import google.registry.model.billing.BillingRecurrence; import google.registry.model.domain.Domain; import google.registry.tools.CommandTestCase; +import java.time.Instant; import org.joda.time.DateTime; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -41,7 +43,7 @@ public class RecreateBillingRecurrencesCommandTest @BeforeEach void beforeEach() { - fakeClock.setTo(DateTime.parse("2022-09-05TZ")); + fakeClock.setTo(Instant.parse("2022-09-05T00:00:00Z")); createTld("tld"); domain = persistDomainWithDependentResources( @@ -53,7 +55,7 @@ void beforeEach() { oldRecurrence = loadByKey(domain.getAutorenewBillingEvent()); oldRecurrence = persistResource( - oldRecurrence.asBuilder().setRecurrenceEndTime(fakeClock.nowUtc().plusDays(1)).build()); + oldRecurrence.asBuilder().setRecurrenceEndTime(plusDays(fakeClock.now(), 1)).build()); fakeClock.setTo(DateTime.parse("2023-07-11TZ")); } @@ -64,10 +66,10 @@ void testSuccess_simpleRecreation() throws Exception { BillingRecurrence newRecurrence = loadByKey(loadByEntity(domain).getAutorenewBillingEvent()); assertThat(newRecurrence.getId()).isNotEqualTo(oldRecurrence.getId()); // The new recurrence should not end and have last year's event time and last expansion. - assertThat(newRecurrence.getRecurrenceEndTime()).isEqualTo(END_OF_TIME); - assertThat(newRecurrence.getEventTime()).isEqualTo(DateTime.parse("2023-09-05TZ")); + assertThat(newRecurrence.getRecurrenceEndTime()).isEqualTo(END_INSTANT); + assertThat(newRecurrence.getEventTime()).isEqualTo(Instant.parse("2023-09-05T00:00:00Z")); assertThat(newRecurrence.getRecurrenceLastExpansion()) - .isEqualTo(DateTime.parse("2022-09-05TZ")); + .isEqualTo(Instant.parse("2022-09-05T00:00:00Z")); assertThat(loadAllOf(BillingRecurrence.class)).containsExactly(oldRecurrence, newRecurrence); } @@ -85,26 +87,26 @@ void testSuccess_multipleDomains() throws Exception { persistResource( otherRecurrence .asBuilder() - .setRecurrenceEndTime(DateTime.parse("2022-09-08TZ")) + .setRecurrenceEndTime(Instant.parse("2022-09-08T00:00:00Z")) .build()); runCommandForced("example.tld", "other.tld"); - // Both domains should have new recurrences with END_OF_TIME expirations + // Both domains should have new recurrences with END_INSTANT expirations BillingRecurrence otherNewRecurrence = loadByKey(loadByEntity(otherDomain).getAutorenewBillingEvent()); assertThat(otherNewRecurrence.getId()).isNotEqualTo(otherRecurrence.getId()); - assertThat(otherNewRecurrence.getRecurrenceEndTime()).isEqualTo(END_OF_TIME); - assertThat(otherNewRecurrence.getEventTime()).isEqualTo(DateTime.parse("2023-09-07TZ")); + assertThat(otherNewRecurrence.getRecurrenceEndTime()).isEqualTo(END_INSTANT); + assertThat(otherNewRecurrence.getEventTime()).isEqualTo(Instant.parse("2023-09-07T00:00:00Z")); assertThat(otherNewRecurrence.getRecurrenceLastExpansion()) - .isEqualTo(DateTime.parse("2022-09-07TZ")); + .isEqualTo(Instant.parse("2022-09-07T00:00:00Z")); assertThat(loadAllOf(BillingRecurrence.class)) .comparingElementsUsing(ImmutableObjectSubject.immutableObjectCorrespondence("id")) .containsExactly( oldRecurrence, oldRecurrence .asBuilder() - .setRecurrenceEndTime(END_OF_TIME) - .setEventTime(DateTime.parse("2023-09-05TZ")) - .setRecurrenceLastExpansion(DateTime.parse("2022-09-05TZ")) + .setRecurrenceEndTime(END_INSTANT) + .setEventTime(Instant.parse("2023-09-05T00:00:00Z")) + .setRecurrenceLastExpansion(Instant.parse("2022-09-05T00:00:00Z")) .build(), otherRecurrence, otherNewRecurrence); @@ -119,19 +121,19 @@ void testFailure_badDomain() { @Test void testFailure_alreadyEndOfTime() { - persistResource(oldRecurrence.asBuilder().setRecurrenceEndTime(END_OF_TIME).build()); + persistResource(oldRecurrence.asBuilder().setRecurrenceEndTime(END_INSTANT).build()); assertThat(assertThrows(IllegalArgumentException.class, () -> runCommandForced("example.tld"))) .hasMessageThat() - .isEqualTo("Domain example.tld's recurrence's end date is already END_OF_TIME"); + .isEqualTo("Domain example.tld's recurrence's end date is already END_INSTANT"); } @Test void testFailure_nonLinkedRecurrenceIsEndOfTime() { - persistResource(oldRecurrence.asBuilder().setRecurrenceEndTime(END_OF_TIME).setId(0).build()); + persistResource(oldRecurrence.asBuilder().setRecurrenceEndTime(END_INSTANT).setId(0).build()); assertThat(assertThrows(IllegalArgumentException.class, () -> runCommandForced("example.tld"))) .hasMessageThat() .isEqualTo( "There exists a recurrence with id 8 for domain example.tld with an end date of" - + " END_OF_TIME"); + + " END_INSTANT"); } } diff --git a/core/src/test/java/google/registry/tools/server/ToolsServerModuleTest.java b/core/src/test/java/google/registry/tools/server/ToolsServerModuleTest.java index a87485ee30c..c22fd3026b0 100644 --- a/core/src/test/java/google/registry/tools/server/ToolsServerModuleTest.java +++ b/core/src/test/java/google/registry/tools/server/ToolsServerModuleTest.java @@ -37,7 +37,7 @@ void test_provideDeletionTime() throws Exception { DateTime expected = DateTime.parse("1991-07-01T00:00:00Z"); Optional dateTimeParam = ToolsServerModule.provideDeletionTime(request); - assertThat(dateTimeParam).isEqualTo(Optional.of(expected)); + assertThat(dateTimeParam).hasValue(expected); } @Test diff --git a/core/src/test/java/google/registry/ui/server/console/ConsoleHistoryDataActionTest.java b/core/src/test/java/google/registry/ui/server/console/ConsoleHistoryDataActionTest.java index 10ef6c2302b..faeee425ef4 100644 --- a/core/src/test/java/google/registry/ui/server/console/ConsoleHistoryDataActionTest.java +++ b/core/src/test/java/google/registry/ui/server/console/ConsoleHistoryDataActionTest.java @@ -14,6 +14,7 @@ package google.registry.ui.server.console; + import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.truth.Truth.assertThat; import static jakarta.servlet.http.HttpServletResponse.SC_BAD_REQUEST; diff --git a/core/src/test/java/google/registry/ui/server/console/ConsoleRegistryLockActionTest.java b/core/src/test/java/google/registry/ui/server/console/ConsoleRegistryLockActionTest.java index b9fd58eae62..fdf7260f539 100644 --- a/core/src/test/java/google/registry/ui/server/console/ConsoleRegistryLockActionTest.java +++ b/core/src/test/java/google/registry/ui/server/console/ConsoleRegistryLockActionTest.java @@ -113,7 +113,7 @@ void afterEach() { @Test void testGet_simpleLock() { - saveRegistryLock(createDefaultLockBuilder().setLockCompletionTime(clock.nowUtc()).build()); + saveRegistryLock(createDefaultLockBuilder().setLockCompletionTime(clock.now()).build()); action.run(); assertThat(response.getStatus()).isEqualTo(SC_OK); assertThat(response.getPayload()) @@ -143,8 +143,8 @@ void testGet_allCurrentlyValidLocks() { .setRegistrarId("TheRegistrar") .setVerificationCode("123456789ABCDEFGHJKLMNPQRSTUVWXY") .setRegistryLockEmail("johndoe@theregistrar.com") - .setLockCompletionTime(clock.nowUtc()) - .setUnlockRequestTime(clock.nowUtc()) + .setLockCompletionTime(clock.now()) + .setUnlockRequestTime(clock.now()) .build(); saveRegistryLock(expiredUnlock); clock.advanceBy(Duration.standardDays(1)); @@ -156,7 +156,7 @@ void testGet_allCurrentlyValidLocks() { .setRegistrarId("TheRegistrar") .setVerificationCode("123456789ABCDEFGHJKLMNPQRSTUVWXY") .setRegistryLockEmail("johndoe@theregistrar.com") - .setLockCompletionTime(clock.nowUtc()) + .setLockCompletionTime(clock.now()) .build(); clock.advanceOneMilli(); RegistryLock adminLock = @@ -166,7 +166,7 @@ void testGet_allCurrentlyValidLocks() { .setRegistrarId("TheRegistrar") .setVerificationCode("122222222ABCDEFGHJKLMNPQRSTUVWXY") .isSuperuser(true) - .setLockCompletionTime(clock.nowUtc()) + .setLockCompletionTime(clock.now()) .build(); RegistryLock incompleteLock = new RegistryLock.Builder() @@ -184,8 +184,8 @@ void testGet_allCurrentlyValidLocks() { .setRegistrarId("TheRegistrar") .setVerificationCode("123456789ABCDEFGHJKLMNPQRSTUVWXY") .setRegistryLockEmail("johndoe@theregistrar.com") - .setLockCompletionTime(clock.nowUtc()) - .setUnlockRequestTime(clock.nowUtc()) + .setLockCompletionTime(clock.now()) + .setUnlockRequestTime(clock.now()) .build(); RegistryLock unlockedLock = @@ -195,9 +195,9 @@ void testGet_allCurrentlyValidLocks() { .setRegistrarId("TheRegistrar") .setRegistryLockEmail("johndoe@theregistrar.com") .setVerificationCode("123456789ABCDEFGHJKLMNPQRSTUUUUU") - .setLockCompletionTime(clock.nowUtc()) - .setUnlockRequestTime(clock.nowUtc()) - .setUnlockCompletionTime(clock.nowUtc()) + .setLockCompletionTime(clock.now()) + .setUnlockRequestTime(clock.now()) + .setUnlockCompletionTime(clock.now()) .build(); saveRegistryLock(regularLock); @@ -318,7 +318,7 @@ void testPost_lock_scryptPasswordToArgon2() throws Exception { @Test void testPost_unlock() throws Exception { - saveRegistryLock(createDefaultLockBuilder().setLockCompletionTime(clock.nowUtc()).build()); + saveRegistryLock(createDefaultLockBuilder().setLockCompletionTime(clock.now()).build()); persistResource(defaultDomain.asBuilder().setStatusValues(REGISTRY_LOCK_STATUSES).build()); action = createDefaultPostAction(false); action.run(); @@ -331,7 +331,7 @@ void testPost_unlock() throws Exception { @Test void testPost_unlock_relockDuration() throws Exception { - saveRegistryLock(createDefaultLockBuilder().setLockCompletionTime(clock.nowUtc()).build()); + saveRegistryLock(createDefaultLockBuilder().setLockCompletionTime(clock.now()).build()); persistResource(defaultDomain.asBuilder().setStatusValues(REGISTRY_LOCK_STATUSES).build()); action = createPostAction( @@ -341,14 +341,13 @@ void testPost_unlock_relockDuration() throws Exception { verifyEmail(); RegistryLock savedUnlockRequest = getMostRecentRegistryLockByRepoId(defaultDomain.getRepoId()).get(); - assertThat(savedUnlockRequest.getRelockDuration()) - .isEqualTo(Optional.of(Duration.standardDays(1))); + assertThat(savedUnlockRequest.getRelockDuration()).hasValue(Duration.standardDays(1)); } @Test void testPost_adminUnlockingAdmin() throws Exception { saveRegistryLock( - createDefaultLockBuilder().setLockCompletionTime(clock.nowUtc()).isSuperuser(true).build()); + createDefaultLockBuilder().setLockCompletionTime(clock.now()).isSuperuser(true).build()); persistResource(defaultDomain.asBuilder().setStatusValues(REGISTRY_LOCK_STATUSES).build()); user = user.asBuilder() @@ -414,7 +413,7 @@ void testPost_failure_unlock_noLock() throws Exception { @Test void testPost_failure_nonAdminUnlockingAdmin() throws Exception { saveRegistryLock( - createDefaultLockBuilder().setLockCompletionTime(clock.nowUtc()).isSuperuser(true).build()); + createDefaultLockBuilder().setLockCompletionTime(clock.now()).isSuperuser(true).build()); persistResource(defaultDomain.asBuilder().setStatusValues(REGISTRY_LOCK_STATUSES).build()); action = createDefaultPostAction(false); action.run(); @@ -488,9 +487,9 @@ void testPost_failure_alreadyLocked() throws Exception { void testPost_failure_alreadyUnlocked() throws Exception { saveRegistryLock( createDefaultLockBuilder() - .setLockCompletionTime(clock.nowUtc()) - .setUnlockRequestTime(clock.nowUtc()) - .setUnlockCompletionTime(clock.nowUtc()) + .setLockCompletionTime(clock.now()) + .setUnlockRequestTime(clock.now()) + .setUnlockCompletionTime(clock.now()) .build()); action = createDefaultPostAction(false); action.run(); diff --git a/core/src/test/java/google/registry/ui/server/console/ConsoleRegistryLockVerifyActionTest.java b/core/src/test/java/google/registry/ui/server/console/ConsoleRegistryLockVerifyActionTest.java index afb3bfa683c..a498126a06a 100644 --- a/core/src/test/java/google/registry/ui/server/console/ConsoleRegistryLockVerifyActionTest.java +++ b/core/src/test/java/google/registry/ui/server/console/ConsoleRegistryLockVerifyActionTest.java @@ -87,8 +87,8 @@ void testSuccess_unlock() { persistResource(defaultDomain.asBuilder().setStatusValues(REGISTRY_LOCK_STATUSES).build()); saveRegistryLock( createDefaultLockBuilder() - .setLockCompletionTime(clock.nowUtc()) - .setUnlockRequestTime(clock.nowUtc()) + .setLockCompletionTime(clock.now()) + .setUnlockRequestTime(clock.now()) .build()); action.run(); assertThat(response.getStatus()).isEqualTo(HttpServletResponse.SC_OK); @@ -121,8 +121,8 @@ void testSuccess_admin_unlock() { saveRegistryLock( createDefaultLockBuilder() .isSuperuser(true) - .setLockCompletionTime(clock.nowUtc()) - .setUnlockRequestTime(clock.nowUtc()) + .setLockCompletionTime(clock.now()) + .setUnlockRequestTime(clock.now()) .build()); user = user.asBuilder() @@ -172,8 +172,8 @@ void testFailure_nonAdmin_unlock() { saveRegistryLock( createDefaultLockBuilder() .isSuperuser(true) - .setLockCompletionTime(clock.nowUtc()) - .setUnlockRequestTime(clock.nowUtc()) + .setLockCompletionTime(clock.now()) + .setUnlockRequestTime(clock.now()) .build()); action.run(); assertThat(response.getStatus()).isEqualTo(HttpServletResponse.SC_BAD_REQUEST);