From 6be0a327418ff753396518a718f059ec0c689df8 Mon Sep 17 00:00:00 2001 From: Ben McIlwain Date: Fri, 24 Apr 2026 15:50:55 -0400 Subject: [PATCH] Migrate core, billing, and history to java.time (#3020) 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 3c3307fe4..a591217a4 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 723e24fe8..43afb3c2a 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.DateTimeFormatterBuilder; 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 abstract class DateTimeUtils { 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 004d36306..7410f5208 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.PersistenceModule.TransactionIsolation 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 class DeleteLoadTestDataAction implements Runnable { 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 2b27a0ba9..030267201 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 @@ public class DeleteProberDataAction implements Runnable { 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 @@ public class DeleteProberDataAction implements Runnable { // 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 5d2e3e447..8cde9d6f4 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.StringUtf8Coder; 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 @@ import org.joda.time.format.DateTimeFormatter; */ 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 @@ public record BillingEvent( .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 @@ public record BillingEvent( /** 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 @@ public record BillingEvent( @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 record BillingEvent( 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 1678c9091..53fb5f61f 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 @@ public class ExpandBillingRecurrencesPipeline implements Serializable { 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 @@ public class ExpandBillingRecurrencesPipeline implements Serializable { 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 23e7df7e8..87f5cbaee 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 @@ public class BsaValidateAction implements Runnable { } 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 99e883d3f..0f0cef24c 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 @@ public class FlowModule { 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 e6e8f9009..03fd1930d 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 @@ public final class DomainCreateFlow implements MutatingFlow { ImmutableSet.of( DomainTransactionRecord.create( tld.getTldStr(), - now.plus(addGracePeriod), + toInstant(now.plus(addGracePeriod)), TransactionReportField.netAddsFieldFromYears(period.getValue()), 1))); } @@ -607,13 +607,14 @@ public final class DomainCreateFlow implements MutatingFlow { .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 @@ public final class DomainCreateFlow implements MutatingFlow { .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 @@ public final class DomainCreateFlow implements MutatingFlow { 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 @@ public final class DomainCreateFlow implements MutatingFlow { 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 9eff1530f..ae176f50c 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.persistence.transaction.TransactionManagerFactory. 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 final class DomainDeleteFlow implements MutatingFlow, SqlStatementLogging } 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 final class DomainDeleteFlow implements MutatingFlow, SqlStatementLogging 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 final class DomainDeleteFlow implements MutatingFlow, SqlStatementLogging // 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 final class DomainDeleteFlow implements MutatingFlow, SqlStatementLogging flowCustomLogic.beforeResponse( BeforeResponseParameters.newBuilder() .setResultCode( - newDomain.getDeletionDateTime().isAfter(now) + newDomain.getDeletionTime().isAfter(toInstant(now)) ? SUCCESS_WITH_ACTION_PENDING : SUCCESS) .setResponseExtensions( @@ -343,7 +345,7 @@ public final class DomainDeleteFlow implements MutatingFlow, SqlStatementLogging 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 @@ public final class DomainDeleteFlow implements MutatingFlow, SqlStatementLogging 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 @@ public final class DomainDeleteFlow implements MutatingFlow, SqlStatementLogging 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 779ef75f5..a6f3e381b 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 class DomainFlowUtils { // 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 class DomainFlowUtils { 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 28cfe7240..bb473082a 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 final class DomainInfoFlow implements MutatingFlow { .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 57cc04768..5f32efb1e 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 final class DomainRenewFlow implements MutatingFlow { // 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 final class DomainRenewFlow implements MutatingFlow { Domain newDomain = existingDomain .asBuilder() - .setLastEppUpdateTime(now) + .setLastEppUpdateTime(toInstant(now)) .setLastEppUpdateRegistrarId(registrarId) .setRegistrationExpirationTime(newExpirationTime) .setAutorenewBillingEvent(newAutorenewEvent.createVKey()) @@ -306,7 +306,7 @@ public final class DomainRenewFlow implements MutatingFlow { ImmutableSet.of( DomainTransactionRecord.create( newDomain.getTld(), - now.plus(renewGracePeriod), + toInstant(now.plus(renewGracePeriod)), TransactionReportField.netRenewsFieldFromYears(period.getValue()), 1))) .build(); @@ -349,13 +349,13 @@ public final class DomainRenewFlow implements MutatingFlow { .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 2bdd97ccb..d8f4e4e65 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 final class DomainRestoreRequestFlow implements MutatingFlow { 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 @@ public final class DomainRestoreRequestFlow implements MutatingFlow { .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 @@ public final class DomainRestoreRequestFlow implements MutatingFlow { // 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 @@ public final class DomainRestoreRequestFlow implements MutatingFlow { 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 09ac06217..897324ef9 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 final class DomainTransferApproveFlow implements MutatingFlow { .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 final class DomainTransferApproveFlow implements MutatingFlow { // 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 final class DomainTransferApproveFlow implements MutatingFlow { .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) .setTargetId(targetId) .setRegistrarId(gainingRegistrarId) - .setEventTime(newExpirationTime) + .setEventTime(toInstant(newExpirationTime)) .setRenewalPriceBehavior( hasBulkToken ? RenewalPriceBehavior.DEFAULT @@ -219,7 +221,7 @@ public final class DomainTransferApproveFlow implements MutatingFlow { 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 final class DomainTransferApproveFlow implements MutatingFlow { partiallyApprovedDomain .getTransferData() .asBuilder() - .setTransferredRegistrationExpirationTime(newExpirationTime) + .setTransferredRegistrationExpirationTime(toInstant(newExpirationTime)) .build()) .setRegistrationExpirationTime(newExpirationTime) .setAutorenewBillingEvent(autorenewEvent.createVKey()) @@ -250,7 +252,7 @@ public final class DomainTransferApproveFlow implements MutatingFlow { 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 @@ public final class DomainTransferApproveFlow implements MutatingFlow { 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 3e002f60c..81629803f 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 final class DomainTransferQueryFlow implements TransactionalFlow { } 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 39b25d8d5..7fabc7ceb 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.persistence.transaction.TransactionManagerFactory. 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 @@ public final class DomainTransferRejectFlow implements MutatingFlow { .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 456e9cd66..8823247d6 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 final class DomainTransferRequestFlow implements MutatingFlow { 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 final class DomainTransferRequestFlow implements MutatingFlow { 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 final class DomainTransferRequestFlow implements MutatingFlow { .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 @@ public final class DomainTransferRequestFlow implements MutatingFlow { 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 84c94cc49..2c7076318 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 @@ package google.registry.flows.domain; 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 final class DomainTransferUtils { 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 final class DomainTransferUtils { 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 final class DomainTransferUtils { 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 @@ public final class DomainTransferUtils { .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 @@ public final class DomainTransferUtils { 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 @@ public final class DomainTransferUtils { .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 @@ public final class DomainTransferUtils { 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 @@ public final class DomainTransferUtils { .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 7098063e1..2921c22cc 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 @@ public final class DomainUpdateFlow implements MutatingFlow { .collect(toImmutableSet()), secDnsUpdate.get()) : domain.getDsData()) - .setLastEppUpdateTime(now) + .setLastEppUpdateTime(toInstant(now)) .setLastEppUpdateRegistrarId(registrarId) .addStatusValues(add.getStatusValues()) .removeStatusValues(remove.getStatusValues()) @@ -319,8 +319,8 @@ public final class DomainUpdateFlow implements MutatingFlow { .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 @@ public final class DomainUpdateFlow implements MutatingFlow { 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 8daca8ebd..66e188135 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.EppResourceUtils.createRepoId; 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.HostCommand.Create; 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 final class HostCreateFlow implements MutatingFlow { 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 final class HostCreateFlow implements MutatingFlow { 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 c2f7e06d6..5803e2630 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.ResourceFlowUtils.verifyResourceOwnership; 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.host.HostHistory; 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 final class HostDeleteFlow implements MutatingFlow { 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 final class HostDeleteFlow implements MutatingFlow { // 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 bfc58c7b3..d104264e4 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.ForeignKeyUtils; 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 class HostFlowUtils { } /** 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 60cb13bd9..a6483b814 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.host.HostInfoData; 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 final class HostInfoFlow implements TransactionalFlow { 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 final class HostInfoFlow implements TransactionalFlow { // 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 final class HostInfoFlow implements TransactionalFlow { } else { hostInfoDataBuilder .setCurrentSponsorRegistrarId(host.getPersistedCurrentSponsorRegistrarId()) - .setLastTransferTime(host.getLastTransferTimeInstant()); + .setLastTransferTime(host.getLastTransferTime()); } return responseBuilder .setResData( @@ -97,7 +97,7 @@ public final class HostInfoFlow implements TransactionalFlow { .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 ce6f0df7b..f564e911b 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.flows.host.HostFlowUtils.verifySuperordinateDomain 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.model.reporting.IcannReportingTypes.ActivityReportField; 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 final class HostUpdateFlow implements MutatingFlow { 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 final class HostUpdateFlow implements MutatingFlow { 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 final class HostUpdateFlow implements MutatingFlow { 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 final class HostUpdateFlow implements MutatingFlow { // 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 d73a96673..6be8dec66 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.IsolationLevel; 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 final class PollAckFlow implements MutatingFlow { 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 7f36d88b7..b3f3f92e1 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.QueryComposer.Comparator.L 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 final class PollFlowUtils { */ 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 final class PollFlowUtils { } } - /** - * 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 dd72ca0d5..d24e36370 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 final class PollRequestFlow implements TransactionalFlow { .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 0477d2bfa..211872aac 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.Column; 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 class CreateAutoTimestamp extends ImmutableObject implements UnsafeSerial 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 8667a3b5e..ac52ff81d 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.persistence.transaction.TransactionManagerFactory. 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 abstract class EppResource extends UpdateAutoTimestampEntity implements B 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 abstract class EppResource extends UpdateAutoTimestampEntity implements B return creationRegistrarId; } - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getLastEppUpdateDateTime() { - return toDateTime(lastEppUpdateTime); - } - public Instant getLastEppUpdateTime() { return lastEppUpdateTime; } @@ -203,12 +186,6 @@ public abstract class EppResource extends UpdateAutoTimestampEntity implements B return nullToEmptyImmutableCopy(statuses); } - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getDeletionDateTime() { - return toDateTime(deletionTime); - } - public Instant getDeletionTime() { return deletionTime; } @@ -260,15 +237,6 @@ public abstract class EppResource extends UpdateAutoTimestampEntity implements B 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 abstract class EppResource extends UpdateAutoTimestampEntity implements B 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 abstract class EppResource extends UpdateAutoTimestampEntity implements B 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 94b892c3c..1e3e39d2b 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.persistence.transaction.TransactionManagerFactory. 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 final class EppResourceUtils { } 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 final class EppResourceUtils { builder .removeStatusValue(StatusValue.PENDING_TRANSFER) .setTransferData(transferDataBuilder.build()) - .setLastTransferTime(transferData.getPendingTransferExpirationDateTime()) + .setLastTransferTime(toDateTime(transferData.getPendingTransferExpirationTime())) .setPersistedCurrentSponsorRegistrarId(transferData.getGainingRegistrarId()); } @@ -157,7 +158,7 @@ public final class EppResourceUtils { 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 594e64693..19d4a685f 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 final class ResourceTransferUtils { .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 @@ public final class ResourceTransferUtils { .getTransferData() .copyConstantFieldsToBuilder() .setTransferStatus(transferStatus) - .setPendingTransferExpirationTime(toDateTime(checkNotNull(now))) + .setPendingTransferExpirationTime(now) .build()); } @@ -191,7 +190,7 @@ public final class ResourceTransferUtils { 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 8cbbe6b97..9a4498300 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 @@ package google.registry.model; 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 jakarta.persistence.Embeddable; 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 class UpdateAutoTimestamp extends ImmutableObject implements UnsafeSerial 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 73ab85512..f242a9aeb 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 @@ package google.registry.model.billing; 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 jakarta.persistence.MappedSuperclass; 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 abstract class BillingBase extends ImmutableObject 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 abstract class BillingBase extends ImmutableObject 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 0fc66fba9..a3b03ffda 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.Convert; 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 @@ import org.joda.time.DateTime; 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 class BillingCancellation extends BillingBase { * 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 class BillingCancellation extends BillingBase { .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 @@ public class BillingCancellation extends BillingBase { 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 6e6d06299..6fab00e6b 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 @@ package google.registry.model.billing; 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.time.Instant; 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 class BillingEvent extends BillingBase { 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 class BillingEvent extends BillingBase { 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 class BillingEvent extends BillingBase { 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 c067a7b0c..813b72762 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.checkArgument; 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.time.Instant; 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 @@ public class BillingRecurrence extends BillingBase { 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 a98bb13a7..71fa4cb6b 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 @@ package google.registry.model.common; 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 jakarta.persistence.Embeddable; 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 class TimeOfYear extends ImmutableObject implements UnsafeSerializable { * 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 class TimeOfYear extends ImmutableObject implements UnsafeSerializable { 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 class TimeOfYear extends ImmutableObject implements UnsafeSerializable { *

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 @@ public class TimeOfYear extends ImmutableObject implements UnsafeSerializable { 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 5b2b0c3bd..6fe8b1c3b 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 @@ public class DomainBase extends EppResource { // 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 @@ public class DomainBase extends EppResource { // 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 class DomainBase extends EppResource { .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 64e76a0c6..3ad5a2918 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 @@ package google.registry.model.domain; 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.Index; 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 class GracePeriod extends GracePeriodBase { 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 class GracePeriod extends GracePeriodBase { 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 class GracePeriod extends GracePeriodBase { 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 class GracePeriod extends GracePeriodBase { 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 caf74ce33..a35b5ff34 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.Enumerated; 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 class GracePeriodBase extends ImmutableObject implements UnsafeSerializab 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 590b154cf..f071d2acb 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 @@ package google.registry.model.domain; 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.Index; 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 final class RegistryLock extends UpdateAutoTimestampEntity implements Bui 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 final class RegistryLock extends UpdateAutoTimestampEntity implements Bui return isSuperuser; } - public DateTime getLastUpdateTime() { - return getUpdateTimestamp().getTimestampDateTime(); + public Instant getLastUpdateTime() { + return getUpdateTimestamp().getTimestamp(); } public Long getRevisionId() { @@ -233,7 +221,7 @@ public final class RegistryLock extends UpdateAutoTimestampEntity implements Bui } /** 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 final class RegistryLock extends UpdateAutoTimestampEntity implements Bui 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 final class RegistryLock extends UpdateAutoTimestampEntity implements Bui 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 final class RegistryLock extends UpdateAutoTimestampEntity implements Bui 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 d4d004132..92d46a3e4 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 class AllocationToken extends UpdateAutoTimestampEntity implements Builda /** * @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 d2cf03445..55f0df7a5 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.difference; 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.Domain; 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 class HostBase extends EppResource { 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 class HostBase extends EppResource { 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 class HostBase extends EppResource { 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 class HostBase extends EppResource { 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 4d0a70c0e..6e52f5c6a 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 abstract class PollMessage extends ImmutableObject 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 @@ public abstract class PollMessage extends ImmutableObject .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 215ec0674..72af30278 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 @@ package google.registry.model.poll; 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 final class PollMessageExternalKeyConverter { /** 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 f7583e054..ef5ecbf79 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 class Registrar extends UpdateAutoTimestampEntity implements Buildable, J @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 279872fc1..f13cc87f7 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.Id; 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 class DomainTransactionRecord extends ImmutableObject 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 class DomainTransactionRecord extends ImmutableObject .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 class DomainTransactionRecord extends ImmutableObject 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 c5a21b13b..b915d6507 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.time.Instant; 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 abstract class HistoryEntry extends ImmutableObject 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 abstract class HistoryEntry extends ImmutableObject 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 35c6ecd58..615c66199 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 class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl /** * @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 495164329..5118093b3 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.XmlElement; 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 abstract class BaseTransferObject extends ImmutableObject implements Unsa 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 abstract class BaseTransferObject extends ImmutableObject implements Unsa 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 abstract class BaseTransferObject extends ImmutableObject implements Unsa 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 abstract class BaseTransferObject extends ImmutableObject implements Unsa 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 d1801501d..ce19d88c0 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.base.Preconditions.checkState; 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 jakarta.persistence.Embedded; 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 class DomainTransferData extends BaseTransferObject implements Buildable return transferRequestTrid; } - @Nullable - @Deprecated - @SuppressWarnings("InlineMeSuggester") - public DateTime getTransferredRegistrationExpirationDateTime() { - return toDateTime(transferredRegistrationExpirationTime); - } - @Nullable public Instant getTransferredRegistrationExpirationTime() { return transferredRegistrationExpirationTime; @@ -345,13 +335,6 @@ public class DomainTransferData extends BaseTransferObject implements Buildable * @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 e3a8f46b9..57bd5ede7 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.XmlTransient; 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 class TransferResponse extends BaseTransferObject implements ResponseData @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 class TransferResponse extends BaseTransferObject implements ResponseData 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 ab0d1335e..2014924d0 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 @@ public class RdapJsonFormatter { .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 @@ public class RdapJsonFormatter { // (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 @@ public class RdapJsonFormatter { 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 de95f343a..45fe1c776 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 @@ final class DomainToXjcConverter { // 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 @@ final class DomainToXjcConverter { // 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 @@ final class DomainToXjcConverter { 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 c674e9358..d5b7ced49 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 @@ final class HostToXjcConverter { /** 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 @@ final class HostToXjcConverter { 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 b315b1def..b605b7282 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 final class LordnTaskUtils { 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 final class LordnTaskUtils { 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 74ef7da8d..3c4390b4c 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_CLAIMS; 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 final class NordnUploadAction implements Runnable { 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 bb6362f47..e33847563 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 @@ final class AckPollMessagesCommand implements Command { 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 26194e8fc..01d513d04 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 com.google.common.base.Preconditions.checkArgument; 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 final class DomainLockUtils { 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 final class DomainLockUtils { 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 final class DomainLockUtils { 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 @@ public final class DomainLockUtils { 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 @@ public final class DomainLockUtils { .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 @@ public final class DomainLockUtils { new RegistryLock.Builder() .setRepoId(domain.getRepoId()) .setDomainName(domainName) - .setLockCompletionTime(now) + .setLockCompletionTime(toInstant(now)) .setRegistrarId(registrarId)); } else { RegistryLock lock = @@ -292,7 +295,7 @@ public final class DomainLockUtils { 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 @@ public final class DomainLockUtils { return newLockBuilder .setVerificationCode(stringGenerator.createString(VERIFICATION_CODE_LENGTH)) .isSuperuser(isAdmin) - .setUnlockRequestTime(now) + .setUnlockRequestTime(toInstant(now)) .setRegistrarId(registrarId); } @@ -384,7 +387,7 @@ public final class DomainLockUtils { .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 @@ public final class DomainLockUtils { .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 b9c1bc260..649691983 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 @@ class EnqueuePollMessageCommand extends MutatingCommand { .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 80508f14d..07d81b3e3 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 com.google.common.io.BaseEncoding.base16; 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 @@ final class GenerateDnsReportCommand implements Command { .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 @@ final class GenerateDnsReportCommand implements Command { 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 ebca62fac..c28d7f683 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 @@ final class GetHistoryEntriesCommand implements Command { 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 6d31dc6e4..68bc51078 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.persistence.transaction.TransactionManagerFactory. 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 @@ class UnrenewDomainCommand extends ConfirmingCommand { DomainHistory domainHistory = new DomainHistory.Builder() .setDomain(domain) - .setModificationTime(now) + .setModificationTime(toInstant(now)) .setBySuperuser(true) .setType(Type.SYNTHETIC) .setRegistrarId(domain.getCurrentSponsorRegistrarId()) @@ -208,12 +209,12 @@ class UnrenewDomainCommand extends ConfirmingCommand { // 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 @@ class UnrenewDomainCommand extends ConfirmingCommand { 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 59d599187..c0f782223 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 @@ public class UpdateRecurrenceCommand extends ConfirmingCommand { 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 7bb2db5b2..f23144210 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 @@ public class RecreateBillingRecurrencesCommand extends ConfirmingCommand { .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 @@ public class RecreateBillingRecurrencesCommand extends ConfirmingCommand { "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 @@ public class RecreateBillingRecurrencesCommand extends ConfirmingCommand { 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 878825b4b..1d3c95ed6 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 com.google.common.io.BaseEncoding.base16; 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 class GenerateZoneFilesAction implements Runnable, JsonActionRunner.JsonA // 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 6f74427cc..319566e7d 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 @@ public class ConsoleDomainListAction extends ConsoleApiAction { // 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 c50b6565a..f165972df 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 @@ public class ConsoleRegistryLockAction extends ConsoleApiAction { domainName, registrarId, isAdmin, - relockDurationMillis.map(Duration::new)); + relockDurationMillis.map(Duration::millis)); sendVerificationEmail(registryLock, registryLockEmail, isLock); }); response.setStatus(SC_OK); @@ -194,7 +194,7 @@ public class ConsoleRegistryLockAction extends ConsoleApiAction { 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 c7b841700..0f763e8dc 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 @@ public class CheckBulkComplianceActionTest { 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 @@ public class CheckBulkComplianceActionTest { 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 @@ public class CheckBulkComplianceActionTest { 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 @@ public class CheckBulkComplianceActionTest { 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 @@ public class CheckBulkComplianceActionTest { 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 00c6375c5..869a238ca 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.createTld; 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 @@ class DeleteExpiredDomainsActionTest { 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 @@ class DeleteExpiredDomainsActionTest { 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 @@ class DeleteExpiredDomainsActionTest { .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 @@ class DeleteExpiredDomainsActionTest { 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 20d5de91d..f6380d91f 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.persistDomainAsDeleted; 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 @@ class DeleteProberDataActionTest { .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 @@ class DeleteProberDataActionTest { 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 f5541f564..09d5532dd 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.newDomain; 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 @@ public class ResaveEntityActionTest { 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 11dbb88d7..3a27e62b7 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.ByteArrayInputStream; 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 @@ class BillingEventTest { 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 14f60c07f..629e421df 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 @@ public class ExpandBillingRecurrencesPipelineTest { defaultOneTime(getOnlyAutoRenewHistory()), billingRecurrence .asBuilder() - .setRecurrenceLastExpansion(plusYears(domain.getCreationTimeInstant(), 1)) + .setRecurrenceLastExpansion(plusYears(domain.getCreationTime(), 1)) .build()); // Assert about Cursor. @@ -184,7 +184,7 @@ public class ExpandBillingRecurrencesPipelineTest { defaultOneTime(getOnlyAutoRenewHistory()), billingRecurrence .asBuilder() - .setRecurrenceLastExpansion(plusYears(domain.getCreationTimeInstant(), 1)) + .setRecurrenceLastExpansion(plusYears(domain.getCreationTime(), 1)) .build()); // Assert about Cursor. @@ -213,7 +213,7 @@ public class ExpandBillingRecurrencesPipelineTest { 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 @@ public class ExpandBillingRecurrencesPipelineTest { persistResource( billingRecurrence .asBuilder() - .setRecurrenceEndTime( - billingRecurrence.getEventTimeInstant().minus(1, ChronoUnit.DAYS)) + .setRecurrenceEndTime(billingRecurrence.getEventTime().minus(1, ChronoUnit.DAYS)) .build()); runPipeline(); assertNoExpansionsHappened(); @@ -251,7 +250,7 @@ public class ExpandBillingRecurrencesPipelineTest { 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 @@ public class ExpandBillingRecurrencesPipelineTest { 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 @@ public class ExpandBillingRecurrencesPipelineTest { defaultOneTime(getOnlyAutoRenewHistory()), billingRecurrence .asBuilder() - .setRecurrenceLastExpansion(plusYears(domain.getCreationTimeInstant(), 1)) + .setRecurrenceLastExpansion(plusYears(domain.getCreationTime(), 1)) .build()); assertBillingEventsForResource( otherDomain, @@ -363,7 +362,7 @@ public class ExpandBillingRecurrencesPipelineTest { 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 @@ public class ExpandBillingRecurrencesPipelineTest { 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 @@ public class ExpandBillingRecurrencesPipelineTest { 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 @@ public class ExpandBillingRecurrencesPipelineTest { 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 @@ public class ExpandBillingRecurrencesPipelineTest { 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 07ba124b6..f96aa6ac8 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.persistActiveDomain; 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.File; 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.transforms.PTransform; 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 @@ AND cr.id IS NULL 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 @@ AND cr.id IS NULL 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 @@ AND cr.id IS NULL 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 @@ AND cr.id IS NULL .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 @@ AND cr.id IS NULL 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 @@ AND cr.id IS NULL .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 @@ AND cr.id IS NULL .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 @@ AND cr.id IS NULL 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 @@ AND cr.id IS NULL 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 @@ AND cr.id IS NULL 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 @@ AND cr.id IS NULL 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 2d39c1cb7..c04ab2646 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.newHost; 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 @@ public class RegistryJpaReadTest { .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 @@ public class RegistryJpaReadTest { 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 504b108e8..3ddbf0b4e 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 @@ public class RdePipelineTest { 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 @@ public class RdePipelineTest { 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 @@ public class RdePipelineTest { 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 @@ public class RdePipelineTest { // 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 @@ public class RdePipelineTest { // 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 a25185ef0..935a53fc2 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 @@ class Spec11PipelineTest { .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 f6b8f59c1..2a905ca4e 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.persistActiveDomain; 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 @@ class ExportDomainListsActionTest { 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 3d3540ab8..ea4302e95 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.DatabaseHelper.persistResource; 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 @@ class EppLifecycleDomainTest extends EppTestCase { .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 23f6979d6..776ccb497 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.getOnlyHistoryEntryOfType; 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 @@ public class EppTestCase { .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 @@ public class EppTestCase { .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 @@ public class EppTestCase { .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 @@ public class EppTestCase { 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 @@ public class EppTestCase { 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 7f157fd01..ec390bbbc 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 @@ public abstract class FlowTestCase { 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 c5d4c2316..15ea94575 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.persistReservedList; 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 @@ class DomainCreateFlowTest extends ResourceFlowTestCase 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 @@ class DomainCreateFlowTest extends ResourceFlowTestCase { .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 58c0322c5..f44f25a3e 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.model.reporting.HistoryEntry.Type.DOMAIN_CREATE; 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 @@ public class DomainPricingLogicTest { .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 1d32183b4..bc82ff9f2 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.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 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 @@ class DomainRenewFlowTest extends ResourceFlowTestCase .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 @@ class DomainRenewFlowTest extends ResourceFlowTestCase 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 @@ class DomainRenewFlowTest extends ResourceFlowTestCase .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 @@ class DomainRenewFlowTest extends ResourceFlowTestCase .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 @@ class DomainRenewFlowTest extends ResourceFlowTestCase 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 @@ class DomainRenewFlowTest extends ResourceFlowTestCase 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 @@ class DomainRenewFlowTest extends ResourceFlowTestCase .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 ee46ba7db..a1d9ce3c8 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.minusDays; 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 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase .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 55bb46057..86edb652d 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.DatabaseHelper.persistResource; 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 @@ class DomainTransferRejectFlowTest 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 027111087..adcc52945 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 @@ class DomainTransferRequestFlowTest .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 @@ class DomainTransferRequestFlowTest // 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 @@ class DomainTransferRequestFlowTest 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 @@ class DomainTransferRequestFlowTest 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 @@ class DomainTransferRequestFlowTest .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 @@ class DomainTransferRequestFlowTest // Set the domain to have auto-renewed long enough ago that it is still in the autorenew grace // period at the transfer request time, but will have exited it by the automatic transfer time. 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 @@ class DomainTransferRequestFlowTest .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 @@ class DomainTransferRequestFlowTest .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 @@ class DomainTransferRequestFlowTest 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 @@ class DomainTransferRequestFlowTest 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 @@ class DomainTransferRequestFlowTest 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 @@ class DomainTransferRequestFlowTest 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 6c50a934e..76319cbd4 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.persistDeletedHost; 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.eppcommon.StatusValue; 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 @@ class HostCreateFlowTest extends ResourceFlowTestCase { 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 @@ class HostCreateFlowTest extends ResourceFlowTestCase { 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 1c0af8526..8f413c926 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.persistDeletedHost; 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.tld.Tld; 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 @@ class HostDeleteFlowTest extends ResourceFlowTestCase { 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 @@ class HostDeleteFlowTest extends ResourceFlowTestCase { 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 be4aecae3..c028e2895 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.deleteResource; 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.domain.Domain; 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 @@ class HostInfoFlowTest extends ResourceFlowTestCase { .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 @@ class HostInfoFlowTest extends ResourceFlowTestCase { } 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 @@ class HostInfoFlowTest extends ResourceFlowTestCase { @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 @@ class HostInfoFlowTest extends ResourceFlowTestCase { @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 2fcc3d7a2..379a82a8c 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.EppExceptionSubject.assertAboutEppExceptio 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.CloudTasksHelper.TaskMatcher; 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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { *

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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { 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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { 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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { .and() .hasPersistedCurrentSponsorRegistrarId("NewRegistrar") .and() - .hasLastTransferTime(domain.getTransferData().getPendingTransferExpirationDateTime()) + .hasLastTransferTime(domain.getTransferData().getPendingTransferExpirationTime()) .and() .hasOnlyOneHistoryEntryWhich() .hasType(HistoryEntry.Type.HOST_UPDATE); @@ -272,8 +275,8 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { "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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { .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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { 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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { .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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { 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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { .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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { .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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { .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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { 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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { .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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { "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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { 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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { .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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { .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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { .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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { .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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { .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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { "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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { 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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { .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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { @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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { 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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { 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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { 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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { 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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { 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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { 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 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { 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 d3ece82ff..05116f2ac 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.createHistoryEntryForEppRes 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 @@ class PollAckFlowTest extends FlowTestCase { 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 ad4ae6722..ef9df13e2 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.persistActiveHost; 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 @@ class PollRequestFlowTest extends FlowTestCase { .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 @@ class PollRequestFlowTest extends FlowTestCase { 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 46e387594..6532cc190 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 @@ package google.registry.model; 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 @@ public class EppResourceTest extends EntityTestCase { .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 67e701f65..89c9dea67 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.model.EppResourceUtils.loadAtPointInTime; 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 @@ class EppResourceUtilsTest { // 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 @@ class EppResourceUtilsTest { // 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 7bd40a5df..d1d88a499 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.createTld; 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 @@ class ForeignKeyUtilsTest { @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 @@ class ForeignKeyUtilsTest { @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 @@ class ForeignKeyUtilsTest { 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 @@ class ForeignKeyUtilsTest { 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 @@ class ForeignKeyUtilsTest { 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 2b6de4a04..30d8d53ed 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.persistDomainAsDeleted; 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 final class OteStatsTestHelper { .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 final class OteStatsTestHelper { .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 final class OteStatsTestHelper { .setRegistrarId(oteAccount1) .setType(Type.HOST_DELETE) .setXmlBytes(getBytes("host_delete.xml")) - .setModificationTime(now) + .setModificationTime(toInstant(now)) .build()); } @@ -90,7 +91,7 @@ public final class OteStatsTestHelper { .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 final class OteStatsTestHelper { .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 final class OteStatsTestHelper { .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 final class OteStatsTestHelper { .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 final class OteStatsTestHelper { .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 final class OteStatsTestHelper { .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 final class OteStatsTestHelper { .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 final class OteStatsTestHelper { .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 final class OteStatsTestHelper { .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 final class OteStatsTestHelper { .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 final class OteStatsTestHelper { .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 final class OteStatsTestHelper { .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 fba629a72..2a853b673 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.loadByEntity; 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.model.reporting.HistoryEntry; 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 @@ import org.junit.jupiter.api.Test; /** 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 @@ public class BillingBaseTest extends EntityTestCase { 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 @@ public class BillingBaseTest extends EntityTestCase { .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 @@ public class BillingBaseTest extends EntityTestCase { .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 @@ public class BillingBaseTest extends EntityTestCase { .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 @@ public class BillingBaseTest extends EntityTestCase { 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 @@ public class BillingBaseTest extends EntityTestCase { 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 @@ public class BillingBaseTest extends EntityTestCase { 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 @@ public class BillingBaseTest extends EntityTestCase { billingEvent .asBuilder() .setFlags(ImmutableSet.of(BillingBase.Flag.SYNTHETIC)) - .setSyntheticCreationTime(END_OF_TIME) + .setSyntheticCreationTime(END_INSTANT) .build()); assertThat(thrown) .hasMessageThat() @@ -279,7 +282,7 @@ public class BillingBaseTest extends EntityTestCase { 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 @@ public class BillingBaseTest extends EntityTestCase { GracePeriod.createWithoutBillingEvent( GracePeriodStatus.REDEMPTION, domain.getRepoId(), - now.plusDays(1), + plusDays(now, 1), "a registrar"), domainHistory.getModificationTime(), domainHistory.getHistoryEntryId(), @@ -343,8 +346,8 @@ public class BillingBaseTest extends EntityTestCase { 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 @@ public class BillingBaseTest extends EntityTestCase { 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 @@ public class BillingBaseTest extends EntityTestCase { // 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 @@ public class BillingBaseTest extends EntityTestCase { .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 @@ public class BillingBaseTest extends EntityTestCase { .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 @@ public class BillingBaseTest extends EntityTestCase { .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 @@ public class BillingBaseTest extends EntityTestCase { .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 @@ public class BillingBaseTest extends EntityTestCase { .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 @@ public class BillingBaseTest extends EntityTestCase { .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 @@ public class BillingBaseTest extends EntityTestCase { .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 @@ public class BillingBaseTest extends EntityTestCase { .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 @@ public class BillingBaseTest extends EntityTestCase { .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 @@ public class BillingBaseTest extends EntityTestCase { .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 @@ public class BillingBaseTest extends EntityTestCase { .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 @@ public class BillingBaseTest extends EntityTestCase { .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 @@ public class BillingBaseTest extends EntityTestCase { .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 @@ public class BillingBaseTest extends EntityTestCase { .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 @@ public class BillingBaseTest extends EntityTestCase { .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 @@ public class BillingBaseTest extends EntityTestCase { .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 @@ public class BillingBaseTest extends EntityTestCase { .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 @@ public class BillingBaseTest extends EntityTestCase { .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 @@ public class BillingBaseTest extends EntityTestCase { .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 c44f33e88..0c08a1c76 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 5c2919f36..7674216ab 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.persistResource; 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; 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 @@ public class DomainTest { persistResource( new DomainHistory.Builder() .setDomain(domain) - .setModificationTime(fakeClock.nowUtc()) + .setModificationTime(fakeClock.now()) .setType(HistoryEntry.Type.DOMAIN_CREATE) .setRegistrarId("TheRegistrar") .build()); @@ -119,9 +121,9 @@ public class DomainTest { .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 @@ public class DomainTest { .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 @@ public class DomainTest { .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 @@ public class DomainTest { .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 @@ public class DomainTest { domain .asBuilder() .setCreationRegistrarId("TheRegistrar") - .setLastEppUpdateTime(fakeClock.nowUtc()) + .setLastEppUpdateTime(fakeClock.now()) .setLastEppUpdateRegistrarId("NewRegistrar") .setPersistedCurrentSponsorRegistrarId("NewRegistrar") .setLastTransferTime(fakeClock.nowUtc()) @@ -197,7 +199,7 @@ public class DomainTest { new DomainTransferData.Builder() .setGainingRegistrarId("TheRegistrar") .setLosingRegistrarId("NewRegistrar") - .setPendingTransferExpirationTime(fakeClock.nowUtc()) + .setPendingTransferExpirationTime(fakeClock.now()) .setServerApproveEntities( historyEntry.getRepoId(), historyEntry.getRevisionId(), @@ -206,7 +208,7 @@ public class DomainTest { .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 @@ public class DomainTest { 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 @@ public class DomainTest { 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 @@ public class DomainTest { .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 @@ public class DomainTest { .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 @@ public class DomainTest { GracePeriod.create( GracePeriodStatus.ADD, domain.getRepoId(), - fakeClock.nowUtc().plusDays(100), + plusDays(fakeClock.now(), 100), "TheRegistrar", oneTimeBillKey)) .build(); @@ -459,7 +462,11 @@ public class DomainTest { 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 @@ public class DomainTest { .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 @@ public class DomainTest { 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 @@ public class DomainTest { 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 @@ public class DomainTest { 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 @@ public class DomainTest { 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 @@ public class DomainTest { 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 @@ public class DomainTest { 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 @@ public class DomainTest { 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 @@ public class DomainTest { DomainTransferData transferData = new DomainTransferData.Builder() - .setPendingTransferExpirationTime(transferExpirationTime) + .setPendingTransferExpirationTime(toInstant(transferExpirationTime)) .setTransferStatus(TransferStatus.PENDING) .setGainingRegistrarId("TheRegistrar") .build(); @@ -796,7 +806,7 @@ public class DomainTest { DomainTransferData transferData = new DomainTransferData.Builder() - .setPendingTransferExpirationTime(transferExpirationTime) + .setPendingTransferExpirationTime(toInstant(transferExpirationTime)) .setTransferStatus(TransferStatus.PENDING) .setGainingRegistrarId("TheRegistrar") .build(); @@ -824,7 +834,7 @@ public class DomainTest { DomainTransferData transferData = new DomainTransferData.Builder() - .setPendingTransferExpirationTime(transferExpirationTime) + .setPendingTransferExpirationTime(toInstant(transferExpirationTime)) .setTransferStatus(TransferStatus.PENDING) .setGainingRegistrarId("TheRegistrar") .build(); @@ -865,7 +875,7 @@ public class DomainTest { DomainTransferData transferData = new DomainTransferData.Builder() - .setPendingTransferExpirationTime(transferExpirationTime) + .setPendingTransferExpirationTime(toInstant(transferExpirationTime)) .setTransferStatus(TransferStatus.PENDING) .setGainingRegistrarId("TheRegistrar") .build(); @@ -890,7 +900,7 @@ public class DomainTest { DomainTransferData transferData = new DomainTransferData.Builder() - .setPendingTransferExpirationTime(transferExpirationTime) + .setPendingTransferExpirationTime(toInstant(transferExpirationTime)) .setTransferStatus(TransferStatus.PENDING) .setGainingRegistrarId("TheRegistrar") .build(); @@ -929,7 +939,7 @@ public class DomainTest { DomainTransferData transferData = new DomainTransferData.Builder() - .setPendingTransferExpirationTime(transferExpirationTime) + .setPendingTransferExpirationTime(toInstant(transferExpirationTime)) .setTransferStatus(TransferStatus.PENDING) .setGainingRegistrarId("TheRegistrar") .setServerApproveAutorenewEvent(recurrenceBillKey) @@ -945,7 +955,7 @@ public class DomainTest { GracePeriod.createForRecurrence( GracePeriodStatus.AUTO_RENEW, domain.getRepoId(), - now.plusDays(1), + toInstant(now.plusDays(1)), "NewRegistrar", recurrenceBillKey))) .setTransferData(transferData) @@ -973,13 +983,13 @@ public class DomainTest { 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 8893831ff..e63a58b9e 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.EntityTestCase; 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 @@ public class BulkPricingPackageTest extends EntityTestCase { 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 @@ public class BulkPricingPackageTest extends EntityTestCase { 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 aca1ba4fb..6e8e883ca 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.createTld; 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 @@ public class DomainHistoryTest extends EntityTestCase { .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 @@ public class DomainHistoryTest extends EntityTestCase { 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 @@ public class DomainHistoryTest extends EntityTestCase { 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 c429f1c8c..5918c385d 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 @@ public class HostHistoryTest extends EntityTestCase { 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 1ae781fea..a00d10823 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.createTld; 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.model.transfer.TransferStatus; 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 @@ class HostTest extends EntityTestCase { 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 @@ class HostTest extends EntityTestCase { .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 @@ class HostTest extends EntityTestCase { .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 @@ class HostTest extends EntityTestCase { .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 @@ class HostTest extends EntityTestCase { // 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 @@ class HostTest extends EntityTestCase { // 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 @@ class HostTest extends EntityTestCase { // 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 52e29f265..f7ec25014 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 @@ public class PollMessageExternalKeyConverterTest { .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 dc2a9ccb0..590c055c3 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 @@ public class PollMessageTest extends EntityTestCase { .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 @@ public class PollMessageTest extends EntityTestCase { 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 @@ public class PollMessageTest extends EntityTestCase { 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 @@ public class PollMessageTest extends EntityTestCase { persistResource( new PollMessage.OneTime.Builder() .setRegistrarId("TheRegistrar") - .setEventTime(fakeClock.nowUtc()) + .setEventTime(fakeClock.now()) .setMsg("Test poll message") .setHistoryEntry(historyEntry) .build()); @@ -123,7 +123,7 @@ public class PollMessageTest extends EntityTestCase { 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 @@ public class PollMessageTest extends EntityTestCase { persistResource( new PollMessage.OneTime.Builder() .setRegistrarId("TheRegistrar") - .setEventTime(fakeClock.nowUtc()) + .setEventTime(fakeClock.now()) .setMsg("Test poll message") .setHistoryEntry(historyEntry) .build()); @@ -156,7 +156,7 @@ public class PollMessageTest extends EntityTestCase { 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 @@ public class PollMessageTest extends EntityTestCase { 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 42d3bebba..5d392d5b0 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 @@ class HistoryEntryDaoTest extends EntityTestCase { 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 @@ class HistoryEntryDaoTest extends EntityTestCase { .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 823b00dc6..3fbca08cd 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.domain.Period; 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 @@ class HistoryEntryTest extends EntityTestCase { 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 @@ class HistoryEntryTest extends EntityTestCase { .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 @@ class HistoryEntryTest extends EntityTestCase { () -> 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 @@ class HistoryEntryTest extends EntityTestCase { 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 @@ class HistoryEntryTest extends EntityTestCase { .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 @@ class HistoryEntryTest extends EntityTestCase { .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 8550d4fbc..fd227f195 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 @@ public final class RegistryLockDaoTest extends EntityTestCase { 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 @@ public final class RegistryLockDaoTest extends EntityTestCase { 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 @@ public final class RegistryLockDaoTest extends EntityTestCase { 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 @@ public final class RegistryLockDaoTest extends EntityTestCase { 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 @@ public final class RegistryLockDaoTest extends EntityTestCase { 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 @@ public final class RegistryLockDaoTest extends EntityTestCase { @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 @@ public final class RegistryLockDaoTest extends EntityTestCase { @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 @@ public final class RegistryLockDaoTest extends EntityTestCase { 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 @@ public final class RegistryLockDaoTest extends EntityTestCase { @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 971cfb36d..76859e3ee 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 @@ public class DomainTransferDataTest { 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 @@ public class DomainTransferDataTest { 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 b0f78239f..995495eab 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.Security; 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 @@ public class MosApiModuleTest { 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 95c2cfedb..27503619d 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.makeRegistrar; 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 @@ class RdapDomainActionTest extends RdapActionBaseTestCase { 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 @@ class RdapDomainActionTest extends RdapActionBaseTestCase { 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 @@ class RdapDomainActionTest extends RdapActionBaseTestCase { persistResource( makeDomain("cat.みんな", host1, host2, registrarIdn) .asBuilder() - .setCreationTimeForTest(clock.nowUtc().minusYears(3)) + .setCreationTimeForTest(minusYears(clock.now(), 3)) .setCreationRegistrarId("TheRegistrar") .build()); @@ -115,7 +118,7 @@ class RdapDomainActionTest extends RdapActionBaseTestCase { 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 @@ class RdapDomainActionTest extends RdapActionBaseTestCase { 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 @@ class RdapDomainActionTest extends RdapActionBaseTestCase { GracePeriod.create( GracePeriodStatus.RENEW, domain.getRepoId(), - clock.nowUtc().plusDays(1), + plusDays(clock.now(), 1), "TheRegistrar", null)) .build()); @@ -408,7 +411,7 @@ class RdapDomainActionTest extends RdapActionBaseTestCase { 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 dc1a7bf88..1614e9c1a 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.makeHistoryEntr 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 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase 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 @@ abstract class AbstractEppResourceSubject< } 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 @@ abstract class AbstractEppResourceSubject< } 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 bc930796c..c535c9f27 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.persistence.transaction.TransactionManagerFactory. 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 final class DatabaseHelper { .setHostName(hostName) .setCreationRegistrarId("TheRegistrar") .setPersistedCurrentSponsorRegistrarId("TheRegistrar") - .setCreationTimeForTest(START_OF_TIME) + .setCreationTimeForTest(START_INSTANT) .setRepoId(repoId) .build(); } @@ -176,7 +178,7 @@ public final class DatabaseHelper { .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 final class DatabaseHelper { /** 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 final class DatabaseHelper { 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 final class DatabaseHelper { return persistResource( newDomain(domainName) .asBuilder() - .setCreationTimeForTest(creationTime) + .setCreationTimeForTest(toInstant(creationTime)) .setRegistrationExpirationTime(expirationTime) .build()); } @@ -274,7 +277,7 @@ public final class DatabaseHelper { } 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 final class DatabaseHelper { .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 @@ public final class DatabaseHelper { 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 final class DatabaseHelper { @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 final class DatabaseHelper { 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 final class DatabaseHelper { .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 final class DatabaseHelper { GracePeriod.create( GracePeriodStatus.ADD, repoId, - creationTime.plus(addGracePeriodLength), + toInstant(creationTime.plus(addGracePeriodLength)), "TheRegistrar", null)); } @@ -548,7 +552,7 @@ public final class DatabaseHelper { 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 final class DatabaseHelper { .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 final class DatabaseHelper { 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 final class DatabaseHelper { 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 final class DatabaseHelper { .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 final class DatabaseHelper { 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 final class DatabaseHelper { () -> 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 final class DatabaseHelper { .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 final class DatabaseHelper { () -> 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 final class DatabaseHelper { .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 final class DatabaseHelper { HistoryEntry.createBuilderForResource(resource) .setRegistrarId(resource.getCreationRegistrarId()) .setType(getHistoryEntryType(resource)) - .setModificationTime(tm().getTransactionTime()) + .setModificationTime(tm().getTxTime()) .build()); }); maybeAdvanceClock(); @@ -1105,7 +1110,7 @@ public final class DatabaseHelper { 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 3a929943c..7824c6d1d 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 @@ package google.registry.testing; 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.model.reporting.HistoryEntry; 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 final class FullFieldsTestEntityHelper { 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 final class FullFieldsTestEntityHelper { 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 final class FullFieldsTestEntityHelper { 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 da18930c3..e48b8dd8d 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 @@ package google.registry.testing; 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.DomainHistory; 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 class HistoryEntrySubject extends Subject { } 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 a9129b09a..23799b093 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.domain.Domain; 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 final class HostSubject extends AbstractEppResourceSubject 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 1b95855ee..44323a76a 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 @@ class NordnUploadActionTest { 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 @@ class NordnUploadActionTest { 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 @@ class NordnUploadActionTest { persistResource( newDomain("sunrise2.tld") .asBuilder() - .setCreationTimeForTest(clock.nowUtc()) + .setCreationTimeForTest(clock.now()) .setCreationRegistrarId("NewRegistrar") .setSmdId("new-smdid") .setLordnPhase(LordnPhase.SUNRISE) @@ -226,7 +226,7 @@ class NordnUploadActionTest { 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 2077a8220..fc588c737 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.createTld; 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.poll.PollMessage.OneTime; 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 @@ public class AckPollMessagesCommandTest extends CommandTestCase 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 @@ public class AckPollMessagesCommandTest extends CommandTestCase pm3 = notMatched.createVKey(); @@ -193,7 +195,7 @@ public class AckPollMessagesCommandTest extends CommandTestCase) getOutputAsJson()) .containsExactly(DOMAIN2_OUTPUT, NAMESERVER1_OUTPUT, NAMESERVER2_OUTPUT); @@ -172,7 +173,7 @@ class GenerateDnsReportCommandTest extends CommandTestCase output = (Iterable) getOutputAsJson(); assertThat(output).containsAnyOf(DOMAIN1_OUTPUT, DOMAIN1_OUTPUT_ALT); @@ -201,7 +202,7 @@ class GenerateDnsReportCommandTest extends CommandTestCase) getOutputAsJson()) diff --git a/core/src/test/java/google/registry/tools/GetAllocationTokenCommandTest.java b/core/src/test/java/google/registry/tools/GetAllocationTokenCommandTest.java index f815560fb..121994c90 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.Domain; 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 @@ Token foo was not redeemed. 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 497cf834f..5a3083856 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.fee.FeeQueryCommandExtensionItem.CommandName 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 @@ public class GetBulkPricingPackageCommandTest 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 @@ public class GetBulkPricingPackageCommandTest 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 @@ public class GetBulkPricingPackageCommandTest 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 291541787..a3b25a3f2 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.createTld; 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 @@ class GetDomainCommandTest extends CommandTestCase { 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 87a0a1baa..529972512 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.newHost; 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 @@ class GetHostCommandTest extends CommandTestCase { 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 58719a780..54dbfa012 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.loadByEntity; 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.model.registrar.Registrar; 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 @@ public class MutatingCommandTest { 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 @@ public class MutatingCommandTest { @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 800548609..63d01f641 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.flows.ResourceFlowUtils; 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 @@ public class RenewDomainCommandTest extends EppToolCommandTestCase 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 f2b720bf9..6dc60d879 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 @@ public class CreateCancellationsForBillingEventsCommandTest .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 18c8eeafa..1705bfa37 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.loadByEntity; 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 @@ public class RecreateBillingRecurrencesCommandTest 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 @@ public class RecreateBillingRecurrencesCommandTest 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 @@ public class RecreateBillingRecurrencesCommandTest 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 @@ public class RecreateBillingRecurrencesCommandTest @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 a87485ee3..c22fd3026 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 @@ public class ToolsServerModuleTest { 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 10ef6c230..faeee425e 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 b9fd58eae..fdf7260f5 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 @@ public class ConsoleRegistryLockActionTest extends ConsoleActionBaseTestCase { @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 @@ public class ConsoleRegistryLockActionTest extends ConsoleActionBaseTestCase { .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 @@ public class ConsoleRegistryLockActionTest extends ConsoleActionBaseTestCase { .setRegistrarId("TheRegistrar") .setVerificationCode("123456789ABCDEFGHJKLMNPQRSTUVWXY") .setRegistryLockEmail("johndoe@theregistrar.com") - .setLockCompletionTime(clock.nowUtc()) + .setLockCompletionTime(clock.now()) .build(); clock.advanceOneMilli(); RegistryLock adminLock = @@ -166,7 +166,7 @@ public class ConsoleRegistryLockActionTest extends ConsoleActionBaseTestCase { .setRegistrarId("TheRegistrar") .setVerificationCode("122222222ABCDEFGHJKLMNPQRSTUVWXY") .isSuperuser(true) - .setLockCompletionTime(clock.nowUtc()) + .setLockCompletionTime(clock.now()) .build(); RegistryLock incompleteLock = new RegistryLock.Builder() @@ -184,8 +184,8 @@ public class ConsoleRegistryLockActionTest extends ConsoleActionBaseTestCase { .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 @@ public class ConsoleRegistryLockActionTest extends ConsoleActionBaseTestCase { .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 @@ public class ConsoleRegistryLockActionTest extends ConsoleActionBaseTestCase { @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 @@ public class ConsoleRegistryLockActionTest extends ConsoleActionBaseTestCase { @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 @@ public class ConsoleRegistryLockActionTest extends ConsoleActionBaseTestCase { 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 @@ public class ConsoleRegistryLockActionTest extends ConsoleActionBaseTestCase { @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 @@ public class ConsoleRegistryLockActionTest extends ConsoleActionBaseTestCase { 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 afb3bfa68..a498126a0 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 @@ public class ConsoleRegistryLockVerifyActionTest extends ConsoleActionBaseTestCa 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 @@ public class ConsoleRegistryLockVerifyActionTest extends ConsoleActionBaseTestCa saveRegistryLock( createDefaultLockBuilder() .isSuperuser(true) - .setLockCompletionTime(clock.nowUtc()) - .setUnlockRequestTime(clock.nowUtc()) + .setLockCompletionTime(clock.now()) + .setUnlockRequestTime(clock.now()) .build()); user = user.asBuilder() @@ -172,8 +172,8 @@ public class ConsoleRegistryLockVerifyActionTest extends ConsoleActionBaseTestCa 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);