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.
This commit is contained in:
Ben McIlwain
2026-04-24 19:50:55 +00:00
committed by GitHub
parent 8cf222d1c9
commit 6be0a32741
155 changed files with 1182 additions and 1701 deletions
@@ -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)
@@ -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);
}
@@ -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());
@@ -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));
@@ -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,
@@ -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)
@@ -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()
@@ -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))
@@ -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("<xml></xml>".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("<xml></xml>".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(
@@ -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())
@@ -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();
@@ -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();
@@ -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))
@@ -182,7 +182,7 @@ public abstract class FlowTestCase<F extends Flow> {
GracePeriod.create(
entry.getKey().getType(),
entry.getKey().getDomainRepoId(),
entry.getKey().getExpirationDateTime(),
entry.getKey().getExpirationTime(),
entry.getKey().getRegistrarId(),
null,
1L),
@@ -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<DomainCreateFlow, Domain
DomainHistory historyEntry = getHistoryEntries(domain, DomainHistory.class).get(0);
VKey<BillingRecurrence> 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<DomainCreateFlow, Domain
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
.setTargetId(getUniqueIdFromCommand())
.setRegistrarId("TheRegistrar")
.setEventTime(domain.getRegistrationExpirationDateTime())
.setRecurrenceEndTime(END_OF_TIME)
.setEventTime(domain.getRegistrationExpirationTime())
.setRecurrenceEndTime(END_INSTANT)
.setDomainHistory(historyEntry)
.setRenewalPriceBehavior(expectedRenewalPriceBehavior)
.setRenewalPrice(
@@ -406,7 +407,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
new PollMessage.Autorenew.Builder()
.setTargetId(domain.getDomainName())
.setRegistrarId("TheRegistrar")
.setEventTime(domain.getRegistrationExpirationDateTime())
.setEventTime(domain.getRegistrationExpirationTime())
.setMsg("Domain was auto-renewed.")
.setHistoryEntry(historyEntry)
.build());
@@ -1730,7 +1731,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
new PollMessage.Autorenew.Builder()
.setTargetId(domain.getDomainName())
.setRegistrarId("TheRegistrar")
.setEventTime(domain.getRegistrationExpirationDateTime())
.setEventTime(domain.getRegistrationExpirationTime())
.setMsg("Domain was auto-renewed.")
.setHistoryEntry(historyEntry)
.build(),
@@ -1863,7 +1864,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
new PollMessage.Autorenew.Builder()
.setTargetId(domain.getDomainName())
.setRegistrarId("TheRegistrar")
.setEventTime(domain.getRegistrationExpirationDateTime())
.setEventTime(domain.getRegistrationExpirationTime())
.setMsg("Domain was auto-renewed.")
.setHistoryEntry(historyEntry)
.build(),
@@ -2712,7 +2713,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
.containsExactly(
DomainTransactionRecord.create(
"tld",
historyEntry.getModificationTime().plusMinutes(9),
plusMinutes(historyEntry.getModificationTime(), 9),
TransactionReportField.netAddsFieldFromYears(2),
1));
}
@@ -50,12 +50,14 @@ 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_INSTANT;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_INSTANT;
import static google.registry.util.DateTimeUtils.minusDays;
import static google.registry.util.DateTimeUtils.minusMonths;
import static google.registry.util.DateTimeUtils.minusYears;
import static google.registry.util.DateTimeUtils.plusDays;
import static google.registry.util.DateTimeUtils.plusHours;
import static google.registry.util.DateTimeUtils.plusMonths;
import static google.registry.util.DateTimeUtils.plusYears;
import static google.registry.util.DateTimeUtils.toDateTime;
@@ -241,7 +243,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
.setTargetId("example.tld")
.setRegistrarId("TheRegistrar")
.setEventTime(eventTime)
.setBillingTime(toDateTime(plusDays(TIME_BEFORE_FLOW, 1)))
.setBillingTime(plusDays(TIME_BEFORE_FLOW, 1))
.setBillingEvent(graceBillingEvent.createVKey())
.setDomainHistory(historyEntryDomainDelete)
.build());
@@ -262,7 +264,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
.setCost(cost)
.setPeriodYears(2)
.setEventTime(minusDays(TIME_BEFORE_FLOW, 4))
.setBillingTime(toDateTime(plusDays(TIME_BEFORE_FLOW, 1)))
.setBillingTime(plusDays(TIME_BEFORE_FLOW, 1))
.setDomainHistory(earlierHistoryEntry)
.build();
}
@@ -274,7 +276,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
.setTargetId("example.tld")
.setRegistrarId(registrarId)
.setEventTime(A_MONTH_FROM_NOW)
.setRecurrenceEndTime(END_OF_TIME)
.setRecurrenceEndTime(END_INSTANT)
.setDomainHistory(earlierHistoryEntry);
}
@@ -602,7 +604,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
// The poll message in the future to the gaining registrar should be gone too, but there
// should be one at the current time to the gaining registrar.
PollMessage gainingPollMessage = getOnlyPollMessage("NewRegistrar");
assertThat(gainingPollMessage.getEventTime()).isEqualTo(clock.nowUtc());
assertThat(gainingPollMessage.getEventTime()).isEqualTo(clock.now());
assertThat(
gainingPollMessage
.getResponseData()
@@ -973,10 +975,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
assertThat(persistedEntry.getDomainTransactionRecords())
.containsExactly(
DomainTransactionRecord.create(
"tld",
clock.now().plus(java.time.Duration.ofHours(3)),
DELETED_DOMAINS_NOGRACE,
1));
"tld", plusHours(clock.now(), 3), DELETED_DOMAINS_NOGRACE, 1));
}
@Test
@@ -1002,10 +1001,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
assertThat(persistedEntry.getDomainTransactionRecords())
.containsExactly(
DomainTransactionRecord.create(
"tld",
clock.now().plus(java.time.Duration.ofHours(3)),
DELETED_DOMAINS_NOGRACE,
1));
"tld", plusHours(clock.now(), 3), DELETED_DOMAINS_NOGRACE, 1));
}
/** Verifies that if there's no add grace period, we still cancel out valid renew records */
@@ -1033,7 +1029,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
assertThat(persistedEntry.getDomainTransactionRecords())
.containsExactly(
DomainTransactionRecord.create(
"tld", clock.now().plus(java.time.Duration.ofHours(3)), DELETED_DOMAINS_NOGRACE, 1),
"tld", plusHours(clock.now(), 3), DELETED_DOMAINS_NOGRACE, 1),
renewRecord.asBuilder().setReportAmount(-1).build());
}
@@ -19,6 +19,7 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistDomainAsDeleted;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.plusMinutes;
import static google.registry.util.DateTimeUtils.toDateTime;
import google.registry.model.domain.Domain;
@@ -87,7 +88,7 @@ public class DomainDeletionTimeCacheTest {
void testCache_expires() {
Domain domain = persistActiveDomain("domain.tld");
assertThat(getDeletionTimeFromCache("domain.tld")).hasValue(END_OF_TIME);
Instant elevenMinutesFromNow = clock.now().plus(java.time.Duration.ofMinutes(11));
Instant elevenMinutesFromNow = plusMinutes(clock.now(), 11);
persistDomainAsDeleted(domain, toDateTime(elevenMinutesFromNow));
clock.advanceBy(Duration.standardMinutes(30));
assertThat(getDeletionTimeFromCache("domain.tld")).hasValue(toDateTime(elevenMinutesFromNow));
@@ -29,7 +29,7 @@ import static google.registry.testing.DatabaseHelper.persistPremiumList;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.TestDataHelper.updateSubstitutions;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.END_INSTANT;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static google.registry.util.DateTimeUtils.minusDays;
import static google.registry.util.DateTimeUtils.plusDays;
@@ -369,7 +369,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
.setTargetId(getUniqueIdFromCommand())
.setRegistrarId("TheRegistrar")
.setEventTime(clock.now())
.setRecurrenceEndTime(END_OF_TIME)
.setRecurrenceEndTime(END_INSTANT)
.setDomainHistory(historyEntry)
.build());
VKey<BillingRecurrence> recurrenceVKey = renewEvent.createVKey();
@@ -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(
@@ -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<DomainRenewFlow, Domain>
.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<DomainRenewFlow, Domain>
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<DomainRenewFlow, Domain>
.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<DomainRenewFlow, Domain>
.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<DomainRenewFlow, Domain>
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<DomainRenewFlow, Domain>
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<DomainRenewFlow, Domain>
.containsExactly(
DomainTransactionRecord.create(
"tld",
historyEntry.getModificationTime().plusMinutes(9),
plusMinutes(historyEntry.getModificationTime(), 9),
TransactionReportField.netRenewsFieldFromYears(5),
1));
}
@@ -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<DomainRestoreReq
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RESTORE, DomainHistory.class);
assertLastHistoryContainsResource(domain);
assertThat(loadByKey(domain.getAutorenewBillingEvent()).getEventTime())
.isEqualTo(toDateTime(expirationTime));
.isEqualTo(expirationTime);
assertAboutDomains()
.that(domain)
// New expiration time should be the same as from before the deletion.
@@ -252,7 +251,7 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RESTORE, DomainHistory.class);
assertLastHistoryContainsResource(domain);
assertThat(loadByKey(domain.getAutorenewBillingEvent()).getEventTime())
.isEqualTo(toDateTime(newExpirationTime));
.isEqualTo(newExpirationTime);
assertAboutDomains()
.that(domain)
// New expiration time should be exactly a year from now.
@@ -43,7 +43,6 @@ 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.plusYears;
import static google.registry.util.DateTimeUtils.toDateTime;
import static org.joda.money.CurrencyUnit.USD;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -214,7 +213,7 @@ class DomainTransferApproveFlowTest
assertTransferApproved(domain, originalTransferData);
assertAboutDomains().that(domain).hasRegistrationExpirationTime(expectedExpirationTime);
assertThat(loadByKey(domain.getAutorenewBillingEvent()).getEventTime())
.isEqualTo(toDateTime(expectedExpirationTime));
.isEqualTo(expectedExpirationTime);
// The poll message (in the future) to the losing registrar for implicit ack should be gone.
assertThat(getPollMessages(domain, "TheRegistrar", clock.nowUtc().plusMonths(1))).isEmpty();
@@ -222,9 +221,7 @@ class DomainTransferApproveFlowTest
// should be one at the current time to the gaining registrar, as well as one at the domain's
// autorenew time.
assertThat(getPollMessages(domain, "NewRegistrar", clock.nowUtc().plusMonths(1))).hasSize(1);
assertThat(
getPollMessages(
domain, "NewRegistrar", toDateTime(domain.getRegistrationExpirationTime())))
assertThat(getPollMessages(domain, "NewRegistrar", domain.getRegistrationExpirationTime()))
.hasSize(2);
PollMessage gainingTransferPollMessage =
@@ -233,11 +230,11 @@ class DomainTransferApproveFlowTest
getOnlyPollMessage(
domain,
"NewRegistrar",
toDateTime(domain.getRegistrationExpirationTime()),
domain.getRegistrationExpirationTime(),
PollMessage.Autorenew.class);
assertThat(gainingTransferPollMessage.getEventTime()).isEqualTo(clock.nowUtc());
assertThat(gainingTransferPollMessage.getEventTime()).isEqualTo(clock.now());
assertThat(gainingAutorenewPollMessage.getEventTime())
.isEqualTo(toDateTime(domain.getRegistrationExpirationTime()));
.isEqualTo(domain.getRegistrationExpirationTime());
DomainTransferResponse transferResponse =
gainingTransferPollMessage
.getResponseData()
@@ -285,8 +282,7 @@ class DomainTransferApproveFlowTest
.setTargetId(domain.getDomainName())
.setEventTime(clock.now())
.setBillingTime(
toDateTime(
clock.now().plusMillis(registry.getTransferGracePeriodLength().getMillis())))
clock.now().plusMillis(registry.getTransferGracePeriodLength().getMillis()))
.setRegistrarId("NewRegistrar")
.setCost(Money.of(USD, 11).multipliedBy(expectedYearsToCharge))
.setPeriodYears(expectedYearsToCharge)
@@ -318,8 +314,7 @@ class DomainTransferApproveFlowTest
GracePeriod.create(
GracePeriodStatus.TRANSFER,
domain.getRepoId(),
toDateTime(
clock.now().plusMillis(registry.getTransferGracePeriodLength().getMillis())),
clock.now().plusMillis(registry.getTransferGracePeriodLength().getMillis()),
"NewRegistrar",
null),
transferBillingEvent));
@@ -517,9 +512,8 @@ class DomainTransferApproveFlowTest
.setRegistrarId("TheRegistrar")
.setEventTime(clock.now()) // The cancellation happens at the moment of transfer.
.setBillingTime(
toDateTime(
oldExpirationTime.plusMillis(
Tld.get("tld").getAutoRenewGracePeriodLength().getMillis())))
oldExpirationTime.plusMillis(
Tld.get("tld").getAutoRenewGracePeriodLength().getMillis()))
.setBillingRecurrence(domain.getAutorenewBillingEvent()));
}
@@ -31,6 +31,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_INSTANT;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.minusDays;
import static google.registry.util.DateTimeUtils.plusDays;
@@ -147,7 +148,7 @@ class DomainTransferCancelFlowTest
.hasOtherRegistrarId("TheRegistrar");
// The only billing event left should be the original autorenew event, now reopened.
assertBillingEvents(
getLosingClientAutorenewEvent().asBuilder().setRecurrenceEndTime(END_OF_TIME).build());
getLosingClientAutorenewEvent().asBuilder().setRecurrenceEndTime(END_INSTANT).build());
// The poll message (in the future) to the gaining registrar for implicit ack should be gone.
assertThat(getPollMessages("NewRegistrar", clock.nowUtc().plusMonths(1))).isEmpty();
// The poll message in the future to the losing registrar should be gone too, but there should
@@ -23,7 +23,7 @@ import static google.registry.testing.DatabaseHelper.persistDomainWithDependentR
import static google.registry.testing.DatabaseHelper.persistDomainWithPendingTransfer;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DomainSubject.assertAboutDomains;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.END_INSTANT;
import static google.registry.util.DateTimeUtils.plusYears;
import com.google.common.base.Ascii;
@@ -154,7 +154,7 @@ abstract class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
.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))
@@ -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()
@@ -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")))
@@ -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<HostCreateFlow, Host> {
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<HostCreateFlow, Host> {
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();
@@ -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<HostDeleteFlow, Host> {
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<HostDeleteFlow, Host> {
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")
@@ -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<HostInfoFlow, Host> {
.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<HostInfoFlow, Host> {
}
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<HostInfoFlow, Host> {
@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<HostInfoFlow, Host> {
@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()));
@@ -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<HostUpdateFlow, Host> {
* <p>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<HostUpdateFlow, Host> {
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<HostUpdateFlow, Host> {
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<HostUpdateFlow, Host> {
.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<HostUpdateFlow, Host> {
"<host:addr ip=\"v4\">192.0.2.22</host:addr>",
"<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
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<HostUpdateFlow, Host> {
.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<HostUpdateFlow, Host> {
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<HostUpdateFlow, Host> {
.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<HostUpdateFlow, Host> {
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<HostUpdateFlow, Host> {
.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<HostUpdateFlow, Host> {
.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<HostUpdateFlow, Host> {
.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<HostUpdateFlow, Host> {
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<HostUpdateFlow, Host> {
.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<HostUpdateFlow, Host> {
"<host:addr ip=\"v4\">192.0.2.22</host:addr>",
"<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
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<HostUpdateFlow, Host> {
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<HostUpdateFlow, Host> {
.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<HostUpdateFlow, Host> {
.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<HostUpdateFlow, Host> {
.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<HostUpdateFlow, Host> {
.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<HostUpdateFlow, Host> {
.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<HostUpdateFlow, Host> {
"<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
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<HostUpdateFlow, Host> {
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<HostUpdateFlow, Host> {
.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", "<host:addr ip=\"v4\">192.0.2.22</host:addr>", null);
createTld("tld");
@@ -838,21 +841,19 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
@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<HostUpdateFlow, Host> {
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<HostUpdateFlow, Host> {
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<HostUpdateFlow, Host> {
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<HostUpdateFlow, Host> {
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<HostUpdateFlow, Host> {
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<HostUpdateFlow, Host> {
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<HostUpdateFlow, Host> {
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(
@@ -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<PollAckFlow> {
new PollMessage.Autorenew.Builder()
.setId(MESSAGE_ID)
.setRegistrarId(getRegistrarIdForFlow())
.setEventTime(eventTime)
.setEventTime(toInstant(eventTime))
.setAutorenewEndTime(endTime)
.setMsg("Domain was auto-renewed.")
.setTargetId("example.com")
@@ -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<PollRequestFlow> {
.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<PollRequestFlow> {
persistResource(
new HostHistory.Builder()
.setRegistrarId("NewRegistrar")
.setModificationTime(clock.nowUtc().minusDays(1))
.setModificationTime(minusDays(clock.now(), 1))
.setType(HistoryEntry.Type.HOST_DELETE)
.setHost(host)
.build());
@@ -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()))
@@ -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);
}
}
@@ -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.
@@ -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());
}
}
@@ -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()
@@ -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<DateTime> 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<Instant> 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<DateTime> 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<Instant> 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<DateTime> 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<Instant> 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<DateTime> 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<Instant> 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<DateTime> 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<Instant> 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<DateTime> 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<Instant> 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();
}
}
@@ -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<GracePeriod> 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());
@@ -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)
@@ -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("<xml></xml>".getBytes(UTF_8))
.setModificationTime(fakeClock.nowUtc())
.setModificationTime(fakeClock.now())
.setRegistrarId("TheRegistrar")
.setTrid(Trid.create("ABC-123", "server-trid"))
.setBySuperuser(false)
@@ -74,7 +74,7 @@ public class HostHistoryTest extends EntityTestCase {
return new HostHistory.Builder()
.setType(HistoryEntry.Type.HOST_CREATE)
.setXmlBytes("<xml></xml>".getBytes(UTF_8))
.setModificationTime(fakeClock.nowUtc())
.setModificationTime(fakeClock.now())
.setRegistrarId("TheRegistrar")
.setTrid(Trid.create("ABC-123", "server-trid"))
.setBySuperuser(false)
@@ -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);
}
}
@@ -59,7 +59,7 @@ public class PollMessageExternalKeyConverterTest {
.setType(HistoryEntry.Type.DOMAIN_CREATE)
.setPeriod(Period.create(1, Period.Unit.YEARS))
.setXmlBytes("<xml></xml>".getBytes(UTF_8))
.setModificationTime(clock.nowUtc())
.setModificationTime(clock.now())
.setRegistrarId("TheRegistrar")
.setTrid(Trid.create("ABC-123", "server-trid"))
.setBySuperuser(false)
@@ -58,7 +58,7 @@ public class PollMessageTest extends EntityTestCase {
.setType(HistoryEntry.Type.DOMAIN_CREATE)
.setPeriod(Period.create(1, Period.Unit.YEARS))
.setXmlBytes("<xml></xml>".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))
@@ -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("<xml></xml>".getBytes(UTF_8))
.setModificationTime(fakeClock.nowUtc())
.setModificationTime(fakeClock.now())
.setRegistrarId("TheRegistrar")
.setOtherRegistrarId("otherClient")
.setTrid(Trid.create("ABC-123", "server-trid"))
@@ -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("<xml></xml>".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)
@@ -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<RegistryLock> 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();
@@ -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",
@@ -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
@@ -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<RdapDomainAction> {
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<RdapDomainAction> {
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<RdapDomainAction> {
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<RdapDomainAction> {
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<RdapDomainAction> {
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<RdapDomainAction> {
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<RdapDomainAction> {
GracePeriod.create(
GracePeriodStatus.TRANSFER,
domain.getRepoId(),
clock.nowUtc().plusDays(1),
plusDays(clock.now(), 1),
"TheRegistrar",
null))
.build());
@@ -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<RdapDomainSear
makeDomain("cat.lol", hostNs1CatLol, hostNs2CatLol, registrar)
.asBuilder()
.setSubordinateHosts(ImmutableSet.of("ns1.cat.lol", "ns2.cat.lol"))
.setCreationTimeForTest(clock.nowUtc().minusYears(3))
.setCreationTimeForTest(minusYears(clock.now(), 3))
.setCreationRegistrarId("TheRegistrar")
.build());
persistResource(
@@ -163,7 +167,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
clock.nowUtc().minusYears(2))),
registrar)
.asBuilder()
.setCreationTimeForTest(clock.nowUtc().minusYears(3))
.setCreationTimeForTest(minusYears(clock.now(), 3))
.setCreationRegistrarId("TheRegistrar")
.build());
// cat.example
@@ -184,7 +188,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
clock.nowUtc().minusYears(2))),
registrar)
.asBuilder()
.setCreationTimeForTest(clock.nowUtc().minusYears(3))
.setCreationTimeForTest(minusYears(clock.now(), 3))
.setCreationRegistrarId("TheRegistrar")
.build());
// cat.みんな
@@ -205,7 +209,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
clock.nowUtc().minusYears(2))),
registrar)
.asBuilder()
.setCreationTimeForTest(clock.nowUtc().minusYears(3))
.setCreationTimeForTest(minusYears(clock.now(), 3))
.setCreationRegistrarId("TheRegistrar")
.build());
// cat.1.test
@@ -227,7 +231,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
registrar)
.asBuilder()
.setSubordinateHosts(ImmutableSet.of("ns1.cat.1.test"))
.setCreationTimeForTest(clock.nowUtc().minusYears(3))
.setCreationTimeForTest(minusYears(clock.now(), 3))
.setCreationRegistrarId("TheRegistrar")
.build());
@@ -293,15 +297,14 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
}
private void deleteCatLol() {
persistResource(
domainCatLol.asBuilder().setDeletionTime(clock.nowUtc().minusMonths(6)).build());
persistResource(domainCatLol.asBuilder().setDeletionTime(minusMonths(clock.now(), 6)).build());
persistResource(
makeHistoryEntry(
domainCatLol,
HistoryEntry.Type.DOMAIN_DELETE,
Period.create(1, Period.Unit.YEARS),
"deleted",
clock.nowUtc().minusMonths(6)));
toDateTime(minusMonths(clock.now(), 6))));
}
private void createManyDomainsAndHosts(
@@ -328,13 +331,13 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
makeDomain(domainName, null, null, registrar)
.asBuilder()
.setNameservers(hostKeys)
.setCreationTimeForTest(clock.nowUtc().minusYears(3))
.setCreationTimeForTest(minusYears(clock.now(), 3))
.setCreationRegistrarId("TheRegistrar");
if (domainName.equals(mainDomainName)) {
builder.setSubordinateHosts(subordinateHostnamesBuilder.build());
}
if (i % numTotalDomainsPerActiveDomain != 0) {
builder = builder.setDeletionTime(clock.nowUtc().minusDays(1));
builder = builder.setDeletionTime(minusDays(clock.now(), 1));
}
domainsBuilder.add(builder.build());
}
@@ -877,7 +880,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
@Test
void testDomainMatchDeletedDomain_notFound() {
persistDomainAsDeleted(domainCatLol, clock.nowUtc().minusDays(1));
persistDomainAsDeleted(domainCatLol, minusDays(clock.now(), 1));
runNotFoundTest(RequestType.NAME, "cat.lol", "No domains found");
verifyErrorMetrics(SearchType.BY_DOMAIN_NAME);
}
@@ -885,7 +888,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
@Test
void testDomainMatchDeletedDomain_notFound_deletedNotRequested() {
login("evilregistrar");
persistDomainAsDeleted(domainCatLol, clock.nowUtc().minusDays(1));
persistDomainAsDeleted(domainCatLol, minusDays(clock.now(), 1));
runNotFoundTest(RequestType.NAME, "cat.lol", "No domains found");
verifyErrorMetrics(SearchType.BY_DOMAIN_NAME);
}
@@ -903,7 +906,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
void testDomainMatchDeletedDomain_notFound_loggedInAsOtherRegistrar() {
login("otherregistrar");
action.includeDeletedParam = Optional.of(true);
persistDomainAsDeleted(domainCatLol, clock.nowUtc().minusDays(1));
persistDomainAsDeleted(domainCatLol, minusDays(clock.now(), 1));
runNotFoundTest(RequestType.NAME, "cat.lol", "No domains found");
verifyErrorMetrics(SearchType.BY_DOMAIN_NAME, Optional.of(1L), 404);
}
@@ -919,15 +922,15 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
@Test
void testDomainMatchDeletedDomainWithWildcard_notFound() {
persistDomainAsDeleted(domainCatLol, clock.nowUtc().minusDays(1));
persistDomainAsDeleted(domainCatLol, minusDays(clock.now(), 1));
runNotFoundTest(RequestType.NAME, "cat.lo*", "No domains found");
verifyErrorMetrics(SearchType.BY_DOMAIN_NAME, Optional.of(1L), 404);
}
@Test
void testDomainMatchDeletedDomainsWithWildcardAndTld_notFound() {
persistDomainAsDeleted(domainCatLol, clock.nowUtc().minusDays(1));
persistDomainAsDeleted(domainCatLol2, clock.nowUtc().minusDays(1));
persistDomainAsDeleted(domainCatLol, minusDays(clock.now(), 1));
persistDomainAsDeleted(domainCatLol2, minusDays(clock.now(), 1));
runNotFoundTest(RequestType.NAME, "cat*.lol", "No domains found");
verifyErrorMetrics(SearchType.BY_DOMAIN_NAME, Optional.of(2L), 404);
}
@@ -1338,7 +1341,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
void testNameserverMatchDeletedDomain_notFound_loggedInAsOtherRegistrar() {
login("otherregistrar");
action.includeDeletedParam = Optional.of(true);
persistDomainAsDeleted(domainCatLol, clock.nowUtc().minusDays(1));
persistDomainAsDeleted(domainCatLol, minusDays(clock.now(), 1));
runNotFoundTest(RequestType.NS_LDH_NAME, "ns2.cat.lol", "No domains found");
verifyErrorMetrics(SearchType.BY_NAMESERVER_NAME, Optional.of(0L), Optional.of(1L), 404);
}
@@ -1355,36 +1358,36 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
@Test
void testNameserverMatchOneDeletedDomain_foundTheOther() {
login("evilregistrar");
persistDomainAsDeleted(domainCatExample, clock.nowUtc().minusDays(1));
persistDomainAsDeleted(domainCatExample, minusDays(clock.now(), 1));
runSuccessfulTestWithCatLol(RequestType.NS_LDH_NAME, "ns1.cat.lol", "rdap_domain.json");
verifyMetrics(SearchType.BY_NAMESERVER_NAME, 1, 1);
}
@Test
void testNameserverMatchTwoDeletedDomains_notFound() {
persistDomainAsDeleted(domainCatLol, clock.nowUtc().minusDays(1));
persistDomainAsDeleted(domainCatExample, clock.nowUtc().minusDays(1));
persistDomainAsDeleted(domainCatLol, minusDays(clock.now(), 1));
persistDomainAsDeleted(domainCatExample, minusDays(clock.now(), 1));
runNotFoundTest(RequestType.NS_LDH_NAME, "ns1.cat.lol", "No domains found");
verifyErrorMetrics(SearchType.BY_NAMESERVER_NAME, Optional.of(0L), Optional.of(1L), 404);
}
@Test
void testNameserverMatchDeletedNameserver_notFound() {
persistResource(hostNs1CatLol.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
persistResource(hostNs1CatLol.asBuilder().setDeletionTime(minusDays(clock.now(), 1)).build());
runNotFoundTest(RequestType.NS_LDH_NAME, "ns1.cat.lol", "No matching nameservers found");
verifyErrorMetrics(SearchType.BY_NAMESERVER_NAME, Optional.empty(), Optional.of(0L), 404);
}
@Test
void testNameserverMatchDeletedNameserverWithWildcard_notFound() {
persistResource(hostNs1CatLol.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
persistResource(hostNs1CatLol.asBuilder().setDeletionTime(minusDays(clock.now(), 1)).build());
runNotFoundTest(RequestType.NS_LDH_NAME, "ns1.cat.l*", "No matching nameservers found");
verifyErrorMetrics(SearchType.BY_NAMESERVER_NAME, Optional.empty(), Optional.of(0L), 404);
}
@Test
void testNameserverMatchDeletedNameserverWithWildcardAndSuffix_notFound() {
persistResource(hostNs1CatLol.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
persistResource(hostNs1CatLol.asBuilder().setDeletionTime(minusDays(clock.now(), 1)).build());
runNotFoundTest(RequestType.NS_LDH_NAME, "ns1*.cat.lol", "No matching nameservers found");
verifyErrorMetrics(SearchType.BY_NAMESERVER_NAME, Optional.empty(), Optional.of(0L), 404);
}
@@ -1614,7 +1617,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
void testAddressMatchDeletedDomain_notFound_loggedInAsOtherRegistrar() {
login("otherregistrar");
action.includeDeletedParam = Optional.of(true);
persistDomainAsDeleted(domainCatLol, clock.nowUtc().minusDays(1));
persistDomainAsDeleted(domainCatLol, minusDays(clock.now(), 1));
runNotFoundTest(RequestType.NS_IP, "bad:f00d:cafe:0:0:0:15:beef", "No domains found");
verifyErrorMetrics(SearchType.BY_NAMESERVER_ADDRESS, Optional.of(0L), Optional.of(1L), 404);
}
@@ -1632,7 +1635,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
@Test
void testAddressMatchOneDeletedDomain_foundTheOther() {
login("evilregistrar");
persistDomainAsDeleted(domainCatExample, clock.nowUtc().minusDays(1));
persistDomainAsDeleted(domainCatExample, minusDays(clock.now(), 1));
rememberWildcardType("1.2.3.4");
assertAboutJson()
.that(generateActualJson(RequestType.NS_IP, "1.2.3.4"))
@@ -1650,15 +1653,15 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
@Test
void testAddressMatchTwoDeletedDomains_notFound() {
persistDomainAsDeleted(domainCatLol, clock.nowUtc().minusDays(1));
persistDomainAsDeleted(domainCatExample, clock.nowUtc().minusDays(1));
persistDomainAsDeleted(domainCatLol, minusDays(clock.now(), 1));
persistDomainAsDeleted(domainCatExample, minusDays(clock.now(), 1));
runNotFoundTest(RequestType.NS_IP, "1.2.3.4", "No domains found");
verifyErrorMetrics(SearchType.BY_NAMESERVER_ADDRESS, Optional.of(0L), Optional.of(1L), 404);
}
@Test
void testAddressMatchDeletedNameserver_notFound() {
persistResource(hostNs1CatLol.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
persistResource(hostNs1CatLol.asBuilder().setDeletionTime(minusDays(clock.now(), 1)).build());
runNotFoundTest(RequestType.NS_IP, "1.2.3.4", "No domains found");
verifyErrorMetrics(SearchType.BY_NAMESERVER_ADDRESS, Optional.empty(), Optional.of(0L), 404);
}
@@ -25,6 +25,10 @@ import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntr
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.GsonSubject.assertAboutJson;
import static google.registry.testing.TestDataHelper.loadFile;
import static google.registry.util.DateTimeUtils.minusDays;
import static google.registry.util.DateTimeUtils.minusMonths;
import static google.registry.util.DateTimeUtils.plusYears;
import static google.registry.util.DateTimeUtils.toInstant;
import static jakarta.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
import com.google.common.collect.ImmutableList;
@@ -129,12 +133,12 @@ class RdapJsonFormatterTest {
new DomainTransferData.Builder()
.setTransferStatus(TransferStatus.PENDING)
.setGainingRegistrarId("NewRegistrar")
.setTransferRequestTime(clock.nowUtc().minusDays(1))
.setTransferRequestTime(minusDays(clock.now(), 1))
.setLosingRegistrarId("TheRegistrar")
.setPendingTransferExpirationTime(
clock.nowUtc().plusYears(100))
plusYears(clock.now(), 100))
.setTransferredRegistrationExpirationTime(
DateTime.parse("2111-10-08T00:44:59Z"))
Instant.parse("2111-10-08T00:44:59Z"))
.build())
.build())
.createVKey())
@@ -143,14 +147,14 @@ class RdapJsonFormatterTest {
persistResource(
makeDomain("cat.みんな", hostIpv4, hostIpv6, registrar)
.asBuilder()
.setCreationTimeForTest(clock.nowUtc().minusMonths(4))
.setLastEppUpdateTime(clock.nowUtc().minusMonths(1))
.setCreationTimeForTest(minusMonths(clock.now(), 4))
.setLastEppUpdateTime(toInstant(clock.nowUtc().minusMonths(1)))
.build());
domainNoNameserversNoTransfers =
persistResource(
makeDomain("fish.みんな", null, null, registrar)
.asBuilder()
.setCreationTimeForTest(clock.nowUtc())
.setCreationTimeForTest(clock.now())
.setLastEppUpdateTime((Instant) null)
.build());
@@ -21,6 +21,7 @@ import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistH
import static google.registry.testing.FullFieldsTestEntityHelper.makePunycodedHost;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.GsonSubject.assertAboutJson;
import static google.registry.util.DateTimeUtils.minusMonths;
import static org.mockito.Mockito.verify;
import google.registry.model.registrar.Registrar;
@@ -56,7 +57,7 @@ class RdapNameserverActionTest extends RdapActionBaseTestCase<RdapNameserverActi
persistResource(
makeAndPersistHost("nsdeleted.cat.lol", "1.2.3.4", clock.nowUtc().minusYears(1))
.asBuilder()
.setDeletionTime(clock.nowUtc().minusMonths(1))
.setDeletionTime(minusMonths(clock.now(), 1))
.build());
// other registrar
persistResource(
@@ -25,6 +25,8 @@ import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarPocs;
import static google.registry.testing.GsonSubject.assertAboutJson;
import static google.registry.util.DateTimeUtils.minusDays;
import static google.registry.util.DateTimeUtils.minusMonths;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.ImmutableList;
@@ -169,7 +171,7 @@ class RdapNameserverSearchActionTest extends RdapSearchActionTestCase<RdapNamese
FullFieldsTestEntityHelper.makeAndPersistHost(
"nsdeleted.cat.lol", "4.3.2.1", clock.nowUtc().minusYears(1))
.asBuilder()
.setDeletionTime(clock.nowUtc().minusMonths(1))
.setDeletionTime(minusMonths(clock.now(), 1))
.build());
}
@@ -523,7 +525,7 @@ class RdapNameserverSearchActionTest extends RdapSearchActionTestCase<RdapNamese
@Test
void testNameMatchDeletedHost_foundTheOtherHost() {
persistResource(hostNs1CatLol.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
persistResource(hostNs1CatLol.asBuilder().setDeletionTime(minusDays(clock.now(), 1)).build());
assertAboutJson()
.that(generateActualJsonWithName("ns*.cat.lol"))
.isEqualTo(
@@ -538,7 +540,7 @@ class RdapNameserverSearchActionTest extends RdapSearchActionTestCase<RdapNamese
@Test
void testNameMatchDeletedHost_notFound() {
persistResource(hostNs1CatLol.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
persistResource(hostNs1CatLol.asBuilder().setDeletionTime(minusDays(clock.now(), 1)).build());
assertAboutJson()
.that(generateActualJsonWithName("ns1.cat.lol"))
.isEqualTo(generateExpectedJsonError("No nameservers found", 404));
@@ -548,7 +550,7 @@ class RdapNameserverSearchActionTest extends RdapSearchActionTestCase<RdapNamese
@Test
void testNameMatchDeletedHostWithWildcard_notFound() {
persistResource(hostNs1CatLol.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
persistResource(hostNs1CatLol.asBuilder().setDeletionTime(minusDays(clock.now(), 1)).build());
assertAboutJson()
.that(generateActualJsonWithName("cat.lo*"))
.isEqualTo(generateExpectedJsonError("No nameservers found", 404));
@@ -764,7 +766,7 @@ class RdapNameserverSearchActionTest extends RdapSearchActionTestCase<RdapNamese
@Test
void testAddressMatchDeletedHost_notFound() {
persistResource(hostNs1CatLol.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
persistResource(hostNs1CatLol.asBuilder().setDeletionTime(minusDays(clock.now(), 1)).build());
assertAboutJson()
.that(generateActualJsonWithIp("1.2.3.4"))
.isEqualTo(generateExpectedJsonError("No nameservers found", 404));
@@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertWithMessage;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.persistEppResource;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.util.DateTimeUtils.END_INSTANT;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.xjc.rgp.XjcRgpStatusValueType.RENEW_PERIOD;
import static google.registry.xjc.rgp.XjcRgpStatusValueType.TRANSFER_PERIOD;
@@ -65,6 +66,7 @@ import google.registry.xjc.rgp.XjcRgpStatusType;
import google.registry.xjc.secdns.XjcSecdnsDsDataType;
import google.registry.xml.XmlException;
import java.io.ByteArrayOutputStream;
import java.time.Instant;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
@@ -228,7 +230,7 @@ public class DomainToXjcConverterTest {
DomainHistory domainHistory =
persistResource(
new DomainHistory.Builder()
.setModificationTime(clock.nowUtc())
.setModificationTime(clock.now())
.setType(HistoryEntry.Type.DOMAIN_CREATE)
.setDomain(domain)
.setRegistrarId(domain.getCreationRegistrarId())
@@ -241,8 +243,8 @@ public class DomainToXjcConverterTest {
.setRegistrarId("TheRegistrar")
.setCost(Money.of(USD, 26))
.setPeriodYears(2)
.setEventTime(DateTime.parse("1910-01-01T00:00:00Z"))
.setBillingTime(DateTime.parse("1910-01-01T00:00:00Z"))
.setEventTime(Instant.parse("1910-01-01T00:00:00Z"))
.setBillingTime(Instant.parse("1910-01-01T00:00:00Z"))
.setDomainHistory(domainHistory)
.build());
domain =
@@ -250,14 +252,14 @@ public class DomainToXjcConverterTest {
.asBuilder()
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("secret")))
.setCreationRegistrarId("TheRegistrar")
.setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z"))
.setCreationTimeForTest(Instant.parse("1900-01-01T00:00:00Z"))
.setPersistedCurrentSponsorRegistrarId("TheRegistrar")
.setDsData(
ImmutableSet.of(DomainDsData.create(123, 200, 230, base16().decode("1234567890"))))
.setDomainName(Idn.toASCII("love.みんな"))
.setLastTransferTime(DateTime.parse("1910-01-01T00:00:00Z"))
.setLastTransferTime(Instant.parse("1910-01-01T00:00:00Z"))
.setLastEppUpdateRegistrarId("TheRegistrar")
.setLastEppUpdateTime(DateTime.parse("1920-01-01T00:00:00Z"))
.setLastEppUpdateTime(Instant.parse("1920-01-01T00:00:00Z"))
.setNameservers(
ImmutableSet.of(
makeHost(clock, "3-Q9JYB4C", "bird.or.devil.みんな", "1.2.3.4").createVKey(),
@@ -276,14 +278,14 @@ public class DomainToXjcConverterTest {
.setRegistrarId("TheRegistrar")
.setCost(Money.of(USD, 456))
.setPeriodYears(2)
.setEventTime(DateTime.parse("1920-01-01T00:00:00Z"))
.setBillingTime(DateTime.parse("1920-01-01T00:00:00Z"))
.setEventTime(Instant.parse("1920-01-01T00:00:00Z"))
.setBillingTime(Instant.parse("1920-01-01T00:00:00Z"))
.setDomainHistory(domainHistory)
.build())),
GracePeriod.create(
GracePeriodStatus.TRANSFER,
domain.getRepoId(),
DateTime.parse("1920-01-01T00:00:00Z"),
Instant.parse("1920-01-01T00:00:00Z"),
"TheRegistrar",
null)))
.setSubordinateHosts(ImmutableSet.of("home.by.horror.haunted"))
@@ -300,8 +302,8 @@ public class DomainToXjcConverterTest {
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
.setTargetId("lol")
.setRegistrarId("TheRegistrar")
.setEventTime(END_OF_TIME)
.setRecurrenceEndTime(END_OF_TIME)
.setEventTime(END_INSTANT)
.setRecurrenceEndTime(END_INSTANT)
.setDomainHistory(domainHistory)
.build())
.createVKey())
@@ -310,7 +312,7 @@ public class DomainToXjcConverterTest {
new PollMessage.Autorenew.Builder()
.setTargetId("lol")
.setRegistrarId("TheRegistrar")
.setEventTime(END_OF_TIME)
.setEventTime(END_INSTANT)
.setAutorenewEndTime(END_OF_TIME)
.setMsg("Domain was auto-renewed.")
.setHistoryEntry(domainHistory)
@@ -320,7 +322,7 @@ public class DomainToXjcConverterTest {
new DomainTransferData.Builder()
.setGainingRegistrarId("NewRegistrar")
.setLosingRegistrarId("TheRegistrar")
.setPendingTransferExpirationTime(DateTime.parse("1925-04-20T00:00:00Z"))
.setPendingTransferExpirationTime(Instant.parse("1925-04-20T00:00:00Z"))
.setServerApproveBillingEvent(billingEvent.createVKey())
.setServerApproveAutorenewEvent(
persistResource(
@@ -329,8 +331,8 @@ public class DomainToXjcConverterTest {
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
.setTargetId("example.xn--q9jyb4c")
.setRegistrarId("TheRegistrar")
.setEventTime(END_OF_TIME)
.setRecurrenceEndTime(END_OF_TIME)
.setEventTime(END_INSTANT)
.setRecurrenceEndTime(END_INSTANT)
.setDomainHistory(domainHistory)
.build())
.createVKey())
@@ -339,7 +341,7 @@ public class DomainToXjcConverterTest {
new Autorenew.Builder()
.setTargetId("example.xn--q9jyb4c")
.setRegistrarId("TheRegistrar")
.setEventTime(END_OF_TIME)
.setEventTime(END_INSTANT)
.setAutorenewEndTime(END_OF_TIME)
.setMsg("Domain was auto-renewed.")
.setHistoryEntry(domainHistory)
@@ -349,10 +351,9 @@ public class DomainToXjcConverterTest {
domain.getRepoId(),
domainHistory.getRevisionId(),
ImmutableSet.of(billingEvent.createVKey()))
.setTransferRequestTime(DateTime.parse("1919-01-01T00:00:00Z"))
.setTransferRequestTime(Instant.parse("1919-01-01T00:00:00Z"))
.setTransferStatus(TransferStatus.PENDING)
.setTransferredRegistrationExpirationTime(
DateTime.parse("1931-01-01T00:00:00Z"))
.setTransferredRegistrationExpirationTime(Instant.parse("1931-01-01T00:00:00Z"))
.setTransferRequestTrid(Trid.create("client-trid", "server-trid"))
.build())
.build();
@@ -365,13 +366,13 @@ public class DomainToXjcConverterTest {
return persistEppResource(
new Host.Builder()
.setCreationRegistrarId("TheRegistrar")
.setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z"))
.setCreationTimeForTest(Instant.parse("1900-01-01T00:00:00Z"))
.setPersistedCurrentSponsorRegistrarId("TheRegistrar")
.setHostName(Idn.toASCII(fqhn))
.setInetAddresses(ImmutableSet.of(InetAddresses.forString(ip)))
.setLastTransferTime(DateTime.parse("1910-01-01T00:00:00Z"))
.setLastTransferTime(Instant.parse("1910-01-01T00:00:00Z"))
.setLastEppUpdateRegistrarId("TheRegistrar")
.setLastEppUpdateTime(DateTime.parse("1920-01-01T00:00:00Z"))
.setLastEppUpdateTime(Instant.parse("1920-01-01T00:00:00Z"))
.setRepoId(repoId)
.setStatusValues(ImmutableSet.of(StatusValue.OK))
.build());
@@ -33,6 +33,7 @@ import google.registry.xjc.host.XjcHostStatusValueType;
import google.registry.xjc.rdehost.XjcRdeHost;
import google.registry.xjc.rdehost.XjcRdeHostElement;
import java.io.ByteArrayOutputStream;
import java.time.Instant;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -68,13 +69,13 @@ public class HostToXjcConverterTest {
HostToXjcConverter.convertSubordinateHost(
new Host.Builder()
.setCreationRegistrarId("LawyerCat")
.setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z"))
.setCreationTimeForTest(Instant.parse("1900-01-01T00:00:00Z"))
.setPersistedCurrentSponsorRegistrarId("BusinessCat")
.setHostName("ns1.love.foobar")
.setInetAddresses(ImmutableSet.of(InetAddresses.forString("127.0.0.1")))
.setLastTransferTime(DateTime.parse("1910-01-01T00:00:00Z"))
.setLastTransferTime(Instant.parse("1910-01-01T00:00:00Z"))
.setLastEppUpdateRegistrarId("CeilingCat")
.setLastEppUpdateTime(DateTime.parse("1920-01-01T00:00:00Z"))
.setLastEppUpdateTime(Instant.parse("1920-01-01T00:00:00Z"))
.setRepoId("2-roid")
.setStatusValues(ImmutableSet.of(StatusValue.OK))
.setSuperordinateDomain(domain.createVKey())
@@ -124,13 +125,13 @@ public class HostToXjcConverterTest {
HostToXjcConverter.convertExternalHost(
new Host.Builder()
.setCreationRegistrarId("LawyerCat")
.setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z"))
.setCreationTimeForTest(Instant.parse("1900-01-01T00:00:00Z"))
.setPersistedCurrentSponsorRegistrarId("BusinessCat")
.setHostName("ns1.love.lol")
.setInetAddresses(ImmutableSet.of(InetAddresses.forString("127.0.0.1")))
.setLastTransferTime(DateTime.parse("1910-01-01T00:00:00Z"))
.setLastTransferTime(Instant.parse("1910-01-01T00:00:00Z"))
.setLastEppUpdateRegistrarId("CeilingCat")
.setLastEppUpdateTime(DateTime.parse("1920-01-01T00:00:00Z"))
.setLastEppUpdateTime(Instant.parse("1920-01-01T00:00:00Z"))
.setRepoId("2-roid")
.setStatusValues(ImmutableSet.of(StatusValue.OK))
.build());
@@ -173,13 +174,13 @@ public class HostToXjcConverterTest {
HostToXjcConverter.convertExternalHost(
new Host.Builder()
.setCreationRegistrarId("LawyerCat")
.setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z"))
.setCreationTimeForTest(Instant.parse("1900-01-01T00:00:00Z"))
.setPersistedCurrentSponsorRegistrarId("BusinessCat")
.setHostName("ns1.love.lol")
.setInetAddresses(ImmutableSet.of(InetAddresses.forString("cafe::abba")))
.setLastTransferTime(DateTime.parse("1910-01-01T00:00:00Z"))
.setLastTransferTime(Instant.parse("1910-01-01T00:00:00Z"))
.setLastEppUpdateRegistrarId("CeilingCat")
.setLastEppUpdateTime(DateTime.parse("1920-01-01T00:00:00Z"))
.setLastEppUpdateTime(Instant.parse("1920-01-01T00:00:00Z"))
.setRepoId("2-LOL")
.setStatusValues(ImmutableSet.of(StatusValue.OK))
.build());
@@ -196,13 +197,13 @@ public class HostToXjcConverterTest {
HostToXjcConverter.convertExternalHost(
new Host.Builder()
.setCreationRegistrarId("LawyerCat")
.setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z"))
.setCreationTimeForTest(Instant.parse("1900-01-01T00:00:00Z"))
.setPersistedCurrentSponsorRegistrarId("BusinessCat")
.setHostName("ns1.love.lol")
.setInetAddresses(ImmutableSet.of(InetAddresses.forString("cafe::abba")))
.setLastTransferTime(DateTime.parse("1910-01-01T00:00:00Z"))
.setLastTransferTime(Instant.parse("1910-01-01T00:00:00Z"))
.setLastEppUpdateRegistrarId("CeilingCat")
.setLastEppUpdateTime(DateTime.parse("1920-01-01T00:00:00Z"))
.setLastEppUpdateTime(Instant.parse("1920-01-01T00:00:00Z"))
.setRepoId("2-LOL")
.setStatusValues(ImmutableSet.of(StatusValue.SERVER_HOLD)) // <-- OOPS
.build()));
@@ -215,13 +216,13 @@ public class HostToXjcConverterTest {
HostToXjcConverter.convertExternal(
new Host.Builder()
.setCreationRegistrarId("LawyerCat")
.setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z"))
.setCreationTimeForTest(Instant.parse("1900-01-01T00:00:00Z"))
.setPersistedCurrentSponsorRegistrarId("BusinessCat")
.setHostName("ns1.love.lol")
.setInetAddresses(ImmutableSet.of(InetAddresses.forString("cafe::abba")))
.setLastTransferTime(DateTime.parse("1910-01-01T00:00:00Z"))
.setLastTransferTime(Instant.parse("1910-01-01T00:00:00Z"))
.setLastEppUpdateRegistrarId("CeilingCat")
.setLastEppUpdateTime(DateTime.parse("1920-01-01T00:00:00Z"))
.setLastEppUpdateTime(Instant.parse("1920-01-01T00:00:00Z"))
.setRepoId("2-LOL")
.setStatusValues(ImmutableSet.of(StatusValue.OK))
.build());
@@ -21,6 +21,7 @@ import static com.google.common.truth.OptionalSubject.optionals;
import static google.registry.model.EppResourceUtils.isActive;
import static google.registry.testing.DatabaseHelper.getHistoryEntriesOfType;
import static google.registry.testing.HistoryEntrySubject.historyEntries;
import static google.registry.util.DateTimeUtils.toInstant;
import static google.registry.util.DiffUtils.prettyPrintEntityDeepDiff;
import com.google.common.collect.ImmutableSet;
@@ -151,7 +152,7 @@ abstract class AbstractEppResourceSubject<
}
public And<S> hasDeletionTime(DateTime deletionTime) {
return hasValue(deletionTime, actual.getDeletionDateTime(), "getDeletionTime()");
return hasValue(toInstant(deletionTime), actual.getDeletionTime(), "getDeletionTime()");
}
public And<S> hasDeletionTime(Instant deletionTime) {
@@ -159,7 +160,8 @@ abstract class AbstractEppResourceSubject<
}
public And<S> hasLastEppUpdateTime(DateTime lastUpdateTime) {
return hasValue(lastUpdateTime, actual.getLastEppUpdateDateTime(), "has lastEppUpdateTime");
return hasValue(
toInstant(lastUpdateTime), actual.getLastEppUpdateTime(), "has lastEppUpdateTime");
}
public And<S> hasLastEppUpdateTime(Instant lastUpdateTime) {
@@ -167,8 +169,8 @@ abstract class AbstractEppResourceSubject<
}
public And<S> 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();
}
@@ -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());
}
@@ -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<InetAddress> 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("<xml></xml>".getBytes(UTF_8))
.setModificationTime(modificationTime)
.setModificationTime(toInstant(modificationTime))
.setRegistrarId(resource.getPersistedCurrentSponsorRegistrarId())
.setTrid(Trid.create("ABC-123", "server-trid"))
.setBySuperuser(false)
@@ -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<HistoryEntrySubject> hasModificationTime(DateTime modificationTime) {
return hasValue(
toInstant(modificationTime), actual.getModificationTime(), "getModificationTime()");
}
public And<HistoryEntrySubject> hasModificationTime(Instant modificationTime) {
return hasValue(modificationTime, actual.getModificationTime(), "getModificationTime()");
}
@@ -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<Host, HostSubject> {
@@ -40,15 +40,15 @@ public final class HostSubject extends AbstractEppResourceSubject<Host, HostSubj
return assertAbout(HostSubject::new);
}
public And<HostSubject> hasLastTransferTime(DateTime lastTransferTime) {
public And<HostSubject> hasLastTransferTime(Instant lastTransferTime) {
return hasValue(lastTransferTime, actual.getLastTransferTime(), "has lastTransferTime");
}
public And<HostSubject> hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) {
public And<HostSubject> hasLastTransferTimeNotEqualTo(Instant lastTransferTime) {
return doesNotHaveValue(lastTransferTime, actual.getLastTransferTime(), "lastTransferTime");
}
public And<HostSubject> hasLastSuperordinateChange(DateTime lastSuperordinateChange) {
public And<HostSubject> hasLastSuperordinateChange(Instant lastSuperordinateChange) {
return hasValue(
lastSuperordinateChange,
actual.getLastSuperordinateChange(),
@@ -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());
@@ -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<AckPollMessagesC
domainHistory =
persistResource(
new DomainHistory.Builder()
.setModificationTime(fakeClock.nowUtc())
.setModificationTime(fakeClock.now())
.setDomain(domain)
.setRegistrarId(domain.getCreationRegistrarId())
.setType(HistoryEntry.Type.DOMAIN_CREATE)
@@ -73,10 +75,10 @@ public class AckPollMessagesCommandTest extends CommandTestCase<AckPollMessagesC
assertThat(loadByKeysIfPresent(ImmutableList.of(pm1, pm2, pm3, pm4)).values())
.containsExactly(futurePollMessage);
assertInStdout(
"624-2013,2013-05-01T22:33:44.000Z,ninelives",
"316-2014,2014-01-01T22:33:44.000Z,foobar",
"791-2015,2015-01-08T22:33:44.000Z,ginger");
assertNotInStdout("123-2015,2015-09-01T22:33:44.000Z,notme");
"624-2013,2013-05-01T22:33:44Z,ninelives",
"316-2014,2014-01-01T22:33:44Z,foobar",
"791-2015,2015-01-08T22:33:44Z,ginger");
assertNotInStdout("123-2015,2015-09-01T22:33:44Z,notme");
}
@Test
@@ -90,20 +92,20 @@ public class AckPollMessagesCommandTest extends CommandTestCase<AckPollMessagesC
new PollMessage.Autorenew.Builder()
.setId(625L)
.setHistoryEntry(domainHistory)
.setEventTime(DateTime.parse("2011-04-15T22:33:44Z"))
.setEventTime(Instant.parse("2011-04-15T22:33:44Z"))
.setRegistrarId("TheRegistrar")
.setMsg("autorenew")
.build());
Autorenew resaved =
autorenew.asBuilder().setEventTime(DateTime.parse("2012-04-15T22:33:44Z")).build();
autorenew.asBuilder().setEventTime(Instant.parse("2012-04-15T22:33:44Z")).build();
VKey<Autorenew> 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<AckPollMessagesC
new PollMessage.Autorenew.Builder()
.setId(625L)
.setHistoryEntry(domainHistory)
.setEventTime(DateTime.parse("2011-04-15T22:33:44Z"))
.setEventTime(Instant.parse("2011-04-15T22:33:44Z"))
.setAutorenewEndTime(DateTime.parse("2012-01-01T22:33:44Z"))
.setRegistrarId("TheRegistrar")
.setMsg("autorenew")
@@ -126,9 +128,9 @@ public class AckPollMessagesCommandTest extends CommandTestCase<AckPollMessagesC
runCommand("-c", "TheRegistrar");
assertThat(loadByKeysIfPresent(ImmutableList.of(pm1, pm2, pm3))).isEmpty();
assertInStdout(
"625-2011,2011-04-15T22:33:44.000Z,autorenew",
"624-2013,2013-05-01T22:33:44.000Z,ninelives",
"316-2014,2014-01-01T22:33:44.000Z,foobar");
"625-2011,2011-04-15T22:33:44Z,autorenew",
"624-2013,2013-05-01T22:33:44Z,ninelives",
"316-2014,2014-01-01T22:33:44Z,foobar");
}
@Test
@@ -163,7 +165,7 @@ public class AckPollMessagesCommandTest extends CommandTestCase<AckPollMessagesC
.setId(2474L)
.setHistoryEntry(domainHistory)
.setRegistrarId("NewRegistrar")
.setEventTime(DateTime.parse("2013-06-01T22:33:44Z"))
.setEventTime(Instant.parse("2013-06-01T22:33:44Z"))
.setMsg("baaaahh")
.build());
VKey<OneTime> pm3 = notMatched.createVKey();
@@ -193,7 +195,7 @@ public class AckPollMessagesCommandTest extends CommandTestCase<AckPollMessagesC
.setId(id)
.setHistoryEntry(domainHistory)
.setRegistrarId("TheRegistrar")
.setEventTime(eventTime)
.setEventTime(toInstant(eventTime))
.setMsg(message)
.build());
}
@@ -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 java.util.Optional;
import org.joda.money.CurrencyUnit;
import org.joda.money.Money;
@@ -43,7 +44,7 @@ public class CreateBulkPricingPackageCommandTest
new AllocationToken.Builder()
.setToken("abc123")
.setTokenType(TokenType.BULK_PRICING)
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
.setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z"))
.setAllowedTlds(ImmutableSet.of("foo"))
.setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar"))
.setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED)
@@ -76,7 +77,7 @@ public class CreateBulkPricingPackageCommandTest
new AllocationToken.Builder()
.setToken("abc123")
.setTokenType(TokenType.SINGLE_USE)
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
.setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z"))
.setAllowedTlds(ImmutableSet.of("foo"))
.setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar"))
.setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED)
@@ -121,7 +122,7 @@ public class CreateBulkPricingPackageCommandTest
new AllocationToken.Builder()
.setToken("abc123")
.setTokenType(TokenType.BULK_PRICING)
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
.setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z"))
.setAllowedTlds(ImmutableSet.of("foo"))
.setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar"))
.setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED)
@@ -158,7 +159,7 @@ public class CreateBulkPricingPackageCommandTest
new AllocationToken.Builder()
.setToken("abc123")
.setTokenType(TokenType.BULK_PRICING)
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
.setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z"))
.setAllowedTlds(ImmutableSet.of("foo"))
.setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar"))
.setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED)
@@ -185,7 +186,7 @@ public class CreateBulkPricingPackageCommandTest
new AllocationToken.Builder()
.setToken("abc123")
.setTokenType(TokenType.BULK_PRICING)
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
.setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z"))
.setAllowedTlds(ImmutableSet.of("foo"))
.setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar"))
.setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED)
@@ -212,7 +213,7 @@ public class CreateBulkPricingPackageCommandTest
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)
@@ -28,7 +28,6 @@ import static google.registry.testing.SqlHelper.getRegistryLockByVerificationCod
import static google.registry.testing.SqlHelper.saveRegistryLock;
import static google.registry.tools.LockOrUnlockDomainCommand.REGISTRY_LOCK_STATUSES;
import static org.joda.time.Duration.standardDays;
import static org.joda.time.Duration.standardHours;
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.cloud.tasks.v2.HttpMethod;
@@ -57,6 +56,7 @@ import java.util.Set;
import java.util.stream.Collectors;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.Duration;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -244,8 +244,8 @@ public final class DomainLockUtilsTest {
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
RegistryLock lock =
domainLockUtils.saveNewRegistryUnlockRequest(
DOMAIN_NAME, "TheRegistrar", false, Optional.of(standardDays(1)));
assertThat(lock.getRelockDuration()).isEqualTo(Optional.of(standardDays(1)));
DOMAIN_NAME, "TheRegistrar", false, Optional.of(Duration.standardDays(1)));
assertThat(lock.getRelockDuration()).hasValue(Duration.standardDays(1));
}
@Test
@@ -253,7 +253,7 @@ public final class DomainLockUtilsTest {
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, false);
RegistryLock lock =
domainLockUtils.saveNewRegistryUnlockRequest(
DOMAIN_NAME, "TheRegistrar", false, Optional.of(standardHours(6)));
DOMAIN_NAME, "TheRegistrar", false, Optional.of(Duration.standardHours(6)));
domainLockUtils.verifyVerificationCode(lock.getVerificationCode(), false);
cloudTasksHelper.assertTasksEnqueued(
QUEUE_ASYNC_ACTIONS,
@@ -276,7 +276,7 @@ public final class DomainLockUtilsTest {
RegistryLock resultLock =
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, true);
verifyProperlyLockedDomain(true);
assertThat(resultLock.getLockCompletionTime()).isEqualTo(Optional.of(clock.nowUtc()));
assertThat(resultLock.getLockCompletionTime()).hasValue(clock.now());
}
@Test
@@ -285,7 +285,7 @@ public final class DomainLockUtilsTest {
// what the RegistryLock table says
SqlHelper.saveRegistryLock(
new RegistryLock.Builder()
.setLockCompletionTime(clock.nowUtc())
.setLockCompletionTime(clock.now())
.setDomainName(DOMAIN_NAME)
.setVerificationCode("hi")
.setRegistrarId("TheRegistrar")
@@ -297,7 +297,7 @@ public final class DomainLockUtilsTest {
RegistryLock resultLock =
domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, "TheRegistrar", POC_ID, true);
verifyProperlyLockedDomain(true);
assertThat(resultLock.getLockCompletionTime()).isEqualTo(Optional.of(clock.nowUtc()));
assertThat(resultLock.getLockCompletionTime()).hasValue(clock.now());
}
@Test
@@ -469,13 +469,13 @@ public final class DomainLockUtilsTest {
RegistryLock lock =
saveRegistryLock(
new RegistryLock.Builder()
.setLockCompletionTime(clock.nowUtc())
.setUnlockRequestTime(clock.nowUtc())
.setUnlockCompletionTime(clock.nowUtc())
.setLockCompletionTime(clock.now())
.setUnlockRequestTime(clock.now())
.setUnlockCompletionTime(clock.now())
.isSuperuser(false)
.setDomainName("example.tld")
.setRepoId("repoId")
.setRelockDuration(standardHours(6))
.setRelockDuration(Duration.standardHours(6))
.setRegistrarId("TheRegistrar")
.setRegistryLockEmail("someone@example.com")
.setVerificationCode("hi")
@@ -571,8 +571,8 @@ public final class DomainLockUtilsTest {
.setTargetId(domain.getForeignKey())
.setRegistrarId(domain.getCurrentSponsorRegistrarId())
.setCost(Tld.get(domain.getTld()).getRegistryLockOrUnlockBillingCost())
.setEventTime(clock.nowUtc())
.setBillingTime(clock.nowUtc())
.setEventTime(clock.now())
.setBillingTime(clock.now())
.setDomainHistory(entry)
.build())
.collect(Collectors.toSet());
@@ -61,7 +61,7 @@ class EnqueuePollMessageCommandTest extends CommandTestCase<EnqueuePollMessageCo
.and()
.hasRegistrarId("AdminRegistrar")
.and()
.hasModificationTime(fakeClock.nowUtc())
.hasModificationTime(fakeClock.now())
.and()
.hasMetadataRequestedByRegistrar(false);
assertPollMessages(
@@ -70,7 +70,7 @@ class EnqueuePollMessageCommandTest extends CommandTestCase<EnqueuePollMessageCo
.setHistoryEntry(synthetic)
.setMsg("This domain is bad")
.setRegistrarId("TheRegistrar")
.setEventTime(fakeClock.nowUtc())
.setEventTime(fakeClock.now())
.build());
}
@@ -93,7 +93,7 @@ class EnqueuePollMessageCommandTest extends CommandTestCase<EnqueuePollMessageCo
.and()
.hasRegistrarId("AdminRegistrar")
.and()
.hasModificationTime(fakeClock.nowUtc())
.hasModificationTime(fakeClock.now())
.and()
.hasMetadataRequestedByRegistrar(false);
assertPollMessages(
@@ -102,7 +102,7 @@ class EnqueuePollMessageCommandTest extends CommandTestCase<EnqueuePollMessageCo
.setHistoryEntry(synthetic)
.setMsg("This domain needs work")
.setRegistrarId("TheRegistrar")
.setEventTime(fakeClock.nowUtc())
.setEventTime(fakeClock.now())
.build());
assertPollMessages(
"NewRegistrar",
@@ -110,7 +110,7 @@ class EnqueuePollMessageCommandTest extends CommandTestCase<EnqueuePollMessageCo
.setHistoryEntry(synthetic)
.setMsg("This domain needs work")
.setRegistrarId("NewRegistrar")
.setEventTime(fakeClock.nowUtc())
.setEventTime(fakeClock.now())
.build());
assertPollMessages(
"foobaz",
@@ -118,7 +118,7 @@ class EnqueuePollMessageCommandTest extends CommandTestCase<EnqueuePollMessageCo
.setHistoryEntry(synthetic)
.setMsg("This domain needs work")
.setRegistrarId("foobaz")
.setEventTime(fakeClock.nowUtc())
.setEventTime(fakeClock.now())
.build());
}
@@ -138,7 +138,7 @@ class EnqueuePollMessageCommandTest extends CommandTestCase<EnqueuePollMessageCo
.and()
.hasRegistrarId("AdminRegistrar")
.and()
.hasModificationTime(fakeClock.nowUtc())
.hasModificationTime(fakeClock.now())
.and()
.hasMetadataRequestedByRegistrar(false);
assertPollMessages(
@@ -147,7 +147,7 @@ class EnqueuePollMessageCommandTest extends CommandTestCase<EnqueuePollMessageCo
.setHistoryEntry(synthetic)
.setMsg("This domain needs work")
.setRegistrarId("TheRegistrar")
.setEventTime(fakeClock.nowUtc())
.setEventTime(fakeClock.now())
.build());
assertPollMessages(
"NewRegistrar",
@@ -155,7 +155,7 @@ class EnqueuePollMessageCommandTest extends CommandTestCase<EnqueuePollMessageCo
.setHistoryEntry(synthetic)
.setMsg("This domain needs work")
.setRegistrarId("NewRegistrar")
.setEventTime(fakeClock.nowUtc())
.setEventTime(fakeClock.now())
.build());
assertPollMessages(
"foobaz",
@@ -163,7 +163,7 @@ class EnqueuePollMessageCommandTest extends CommandTestCase<EnqueuePollMessageCo
.setHistoryEntry(synthetic)
.setMsg("This domain needs work")
.setRegistrarId("foobaz")
.setEventTime(fakeClock.nowUtc())
.setEventTime(fakeClock.now())
.build());
}
@@ -33,6 +33,7 @@ import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationT
import google.registry.testing.TestCacheExtension;
import google.registry.util.Clock;
import java.time.Duration;
import java.time.Instant;
import java.util.List;
import org.joda.money.Money;
import org.joda.time.DateTime;
@@ -154,8 +155,8 @@ class EppLifecycleToolsTest extends EppTestCase {
.setRegistrarId(domain.getCurrentSponsorRegistrarId())
.setCost(Money.parse("USD 44.00"))
.setPeriodYears(4)
.setEventTime(DateTime.parse("2000-06-07T00:00:00Z"))
.setBillingTime(DateTime.parse("2000-06-12T00:00:00Z"))
.setEventTime(Instant.parse("2000-06-07T00:00:00Z"))
.setBillingTime(Instant.parse("2000-06-12T00:00:00Z"))
.setDomainHistory(
getOnlyHistoryEntryOfType(domain, Type.DOMAIN_RENEW, DomainHistory.class))
.build();
@@ -21,6 +21,7 @@ import static google.registry.testing.DatabaseHelper.newHost;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.util.DateTimeUtils.plusDays;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -164,7 +165,7 @@ class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsReportComm
@Test
void testSuccess_skipDeletedDomain() throws Exception {
persistResource(domain1.asBuilder().setDeletionTime(fakeClock.nowUtc()).build());
persistResource(domain1.asBuilder().setDeletionTime(fakeClock.now()).build());
runCommand("--output=" + output, "--tld=xn--q9jyb4c");
assertThat((Iterable<?>) getOutputAsJson())
.containsExactly(DOMAIN2_OUTPUT, NAMESERVER1_OUTPUT, NAMESERVER2_OUTPUT);
@@ -172,7 +173,7 @@ class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsReportComm
@Test
void testSuccess_skipDeletedNameserver() throws Exception {
persistResource(nameserver1.asBuilder().setDeletionTime(fakeClock.nowUtc()).build());
persistResource(nameserver1.asBuilder().setDeletionTime(fakeClock.now()).build());
runCommand("--output=" + output, "--tld=xn--q9jyb4c");
Iterable<?> output = (Iterable<?>) getOutputAsJson();
assertThat(output).containsAnyOf(DOMAIN1_OUTPUT, DOMAIN1_OUTPUT_ALT);
@@ -201,7 +202,7 @@ class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsReportComm
domain1
.asBuilder()
.addStatusValue(StatusValue.PENDING_DELETE)
.setDeletionTime(fakeClock.nowUtc().plusDays(30))
.setDeletionTime(plusDays(fakeClock.now(), 30))
.build());
runCommand("--output=" + output, "--tld=xn--q9jyb4c");
assertThat((Iterable<?>) getOutputAsJson())
@@ -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")
@@ -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)
@@ -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<GetDomainCommand> {
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");
@@ -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<GetHostCommand> {
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");
@@ -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);
@@ -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<RenewDomainCo
persistResource(
DatabaseHelper.newDomain("domain3.tld")
.asBuilder()
.setCreationTimeForTest(DateTime.parse("2015-01-05T05:05:05Z"))
.setCreationTimeForTest(Instant.parse("2015-01-05T05:05:05Z"))
.setRegistrationExpirationTime(DateTime.parse("2016-01-05T05:05:05Z"))
.setPersistedCurrentSponsorRegistrarId("NewRegistrar")
.build()));
@@ -31,6 +31,7 @@ import google.registry.model.host.Host;
import google.registry.persistence.VKey;
import google.registry.testing.DatabaseHelper;
import jakarta.xml.bind.annotation.adapters.HexBinaryAdapter;
import java.time.Instant;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -297,7 +298,7 @@ class UniformRapidSuspensionCommandTest
persistDomainWithHosts(
DatabaseHelper.newDomain("evil.tld")
.asBuilder()
.setCreationTimeForTest(DateTime.parse("2021-10-01T05:01:11Z"))
.setCreationTimeForTest(Instant.parse("2021-10-01T05:01:11Z"))
.setRegistrationExpirationTime(DateTime.parse("2022-10-01T05:01:11Z"))
.setPersistedCurrentSponsorRegistrarId("CharlestonRoad")
.build(),
@@ -334,7 +335,7 @@ class UniformRapidSuspensionCommandTest
persistDomainWithHosts(
DatabaseHelper.newDomain("evil.tld")
.asBuilder()
.setCreationTimeForTest(DateTime.parse("2021-10-01T05:01:11Z"))
.setCreationTimeForTest(Instant.parse("2021-10-01T05:01:11Z"))
.setRegistrationExpirationTime(DateTime.parse("2022-10-01T05:01:11Z"))
.setPersistedCurrentSponsorRegistrarId("CharlestonRoad")
.build(),
@@ -372,7 +373,7 @@ class UniformRapidSuspensionCommandTest
persistDomainWithHosts(
DatabaseHelper.newDomain("evil.tld")
.asBuilder()
.setCreationTimeForTest(DateTime.parse("2021-10-01T05:01:11Z"))
.setCreationTimeForTest(Instant.parse("2021-10-01T05:01:11Z"))
.setRegistrationExpirationTime(DateTime.parse("2022-10-01T05:01:11Z"))
.setPersistedCurrentSponsorRegistrarId("CharlestonRoad")
.build(),
@@ -29,6 +29,7 @@ import static google.registry.testing.DatabaseHelper.persistDeletedDomain;
import static google.registry.testing.DatabaseHelper.persistDomainWithDependentResources;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
import static google.registry.util.DateTimeUtils.toInstant;
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.collect.ImmutableSet;
@@ -106,7 +107,7 @@ public class UnrenewDomainCommandTest extends CommandTestCase<UnrenewDomainComma
assertAboutHistoryEntries()
.that(getOnlyHistoryEntryOfType(domain, SYNTHETIC))
.hasModificationTime(unrenewTime)
.hasModificationTime(toInstant(unrenewTime))
.and()
.hasMetadataReason("Domain unrenewal")
.and()
@@ -127,7 +128,7 @@ public class UnrenewDomainCommandTest extends CommandTestCase<UnrenewDomainComma
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
.setTargetId(domain.getDomainName())
.setRegistrarId("TheRegistrar")
.setEventTime(newExpirationTime)
.setEventTime(toInstant(newExpirationTime))
.build());
assertPollMessagesEqual(
getPollMessages(domain),
@@ -138,19 +139,19 @@ public class UnrenewDomainCommandTest extends CommandTestCase<UnrenewDomainComma
.setMsg(
"Domain foo.tld was unrenewed by 2 years; "
+ "now expires at 2019-12-06T13:55:01.001Z.")
.setEventTime(unrenewTime)
.setEventTime(toInstant(unrenewTime))
.build(),
new PollMessage.Autorenew.Builder()
.setHistoryEntry(synthetic)
.setTargetId("foo.tld")
.setRegistrarId("TheRegistrar")
.setEventTime(newExpirationTime)
.setEventTime(toInstant(newExpirationTime))
.setMsg("Domain was auto-renewed.")
.build()));
// Check that fields on domain were updated correctly.
assertThat(domain.getRegistrationExpirationDateTime()).isEqualTo(newExpirationTime);
assertThat(domain.getLastEppUpdateDateTime()).isEqualTo(unrenewTime);
assertThat(domain.getLastEppUpdateTime()).isEqualTo(toInstant(unrenewTime));
assertThat(domain.getLastEppUpdateRegistrarId()).isEqualTo("TheRegistrar");
}
@@ -177,7 +178,7 @@ public class UnrenewDomainCommandTest extends CommandTestCase<UnrenewDomainComma
persistResource(
DatabaseHelper.newDomain("deleting.tld")
.asBuilder()
.setDeletionTime(now.plusHours(1))
.setDeletionTime(toInstant(now.plusHours(1)))
.setStatusValues(ImmutableSet.of(PENDING_DELETE))
.build());
persistDeletedDomain("deleted.tld", now.minusHours(1));
@@ -26,6 +26,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 java.util.Optional;
import org.joda.money.CurrencyUnit;
import org.joda.money.Money;
@@ -44,7 +45,7 @@ public class UpdateBulkPricingPackageCommandTest
new AllocationToken.Builder()
.setToken("abc123")
.setTokenType(TokenType.BULK_PRICING)
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
.setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z"))
.setAllowedTlds(ImmutableSet.of("foo"))
.setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar"))
.setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED)
@@ -92,7 +93,7 @@ public class UpdateBulkPricingPackageCommandTest
new AllocationToken.Builder()
.setToken("nullPackage")
.setTokenType(TokenType.BULK_PRICING)
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
.setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z"))
.setAllowedTlds(ImmutableSet.of("foo"))
.setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar"))
.setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED)
@@ -25,7 +25,9 @@ import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.TestLogHandlerUtils.assertLogMessage;
import static google.registry.testing.TestLogHandlerUtils.assertNoLogMessage;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.END_INSTANT;
import static google.registry.util.DateTimeUtils.minusDays;
import static google.registry.util.DateTimeUtils.plusDays;
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.beust.jcommander.ParameterException;
@@ -274,7 +276,7 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
DomainHistory createHistoryEntry =
persistResource(
new DomainHistory.Builder()
.setModificationTime(fakeClock.nowUtc())
.setModificationTime(fakeClock.now())
.setType(DOMAIN_CREATE)
.setDomain(domain)
.setRegistrarId(domain.getCreationRegistrarId())
@@ -286,8 +288,8 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
.setTargetId("example.tld")
.setRegistrarId("NewRegistrar")
.setEventTime(fakeClock.nowUtc().minusDays(5))
.setRecurrenceEndTime(END_OF_TIME)
.setEventTime(minusDays(fakeClock.now(), 5))
.setRecurrenceEndTime(END_INSTANT)
.setDomainHistory(createHistoryEntry)
.build());
persistResource(
@@ -300,7 +302,7 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
GracePeriod.createForRecurrence(
AUTO_RENEW,
domain.getRepoId(),
fakeClock.nowUtc().plusDays(40),
plusDays(fakeClock.now(), 40),
"NewRegistrar",
autorenewBillingEvent.createVKey())))
.build());
@@ -22,7 +22,9 @@ import static google.registry.testing.DatabaseHelper.loadByKey;
import static google.registry.testing.DatabaseHelper.persistDomainWithDependentResources;
import static google.registry.testing.DatabaseHelper.persistDomainWithPendingTransfer;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.util.DateTimeUtils.END_INSTANT;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.minusDays;
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.collect.Iterables;
@@ -54,7 +56,7 @@ public class UpdateRecurrenceCommandTest extends CommandTestCase<UpdateRecurrenc
persistDomain();
BillingRecurrence existingBillingRecurrence =
Iterables.getOnlyElement(loadAllOf(BillingRecurrence.class));
assertThat(existingBillingRecurrence.getRecurrenceEndTime()).isEqualTo(END_OF_TIME);
assertThat(existingBillingRecurrence.getRecurrenceEndTime()).isEqualTo(END_INSTANT);
assertThat(existingBillingRecurrence.getRenewalPriceBehavior())
.isEqualTo(RenewalPriceBehavior.DEFAULT);
runCommandForced(
@@ -64,7 +66,7 @@ public class UpdateRecurrenceCommandTest extends CommandTestCase<UpdateRecurrenc
"--specified_renewal_price",
"USD 9001");
assertThat(loadByEntity(existingBillingRecurrence).getRecurrenceEndTime())
.isEqualTo(fakeClock.nowUtc());
.isEqualTo(fakeClock.now());
assertNewBillingEventAndHistory(
existingBillingRecurrence.getId(),
RenewalPriceBehavior.SPECIFIED,
@@ -76,12 +78,12 @@ public class UpdateRecurrenceCommandTest extends CommandTestCase<UpdateRecurrenc
persistDomain();
BillingRecurrence existingBillingRecurrence =
Iterables.getOnlyElement(loadAllOf(BillingRecurrence.class));
assertThat(existingBillingRecurrence.getRecurrenceEndTime()).isEqualTo(END_OF_TIME);
assertThat(existingBillingRecurrence.getRecurrenceEndTime()).isEqualTo(END_INSTANT);
assertThat(existingBillingRecurrence.getRenewalPriceBehavior())
.isEqualTo(RenewalPriceBehavior.DEFAULT);
runCommandForced("domain.tld", "--renewal_price_behavior", "NONPREMIUM");
assertThat(loadByEntity(existingBillingRecurrence).getRecurrenceEndTime())
.isEqualTo(fakeClock.nowUtc());
.isEqualTo(fakeClock.now());
assertNewBillingEventAndHistory(
existingBillingRecurrence.getId(), RenewalPriceBehavior.NONPREMIUM, null);
}
@@ -97,10 +99,10 @@ public class UpdateRecurrenceCommandTest extends CommandTestCase<UpdateRecurrenc
.setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED)
.setRenewalPrice(Money.of(CurrencyUnit.USD, 100))
.build());
assertThat(existingBillingRecurrence.getRecurrenceEndTime()).isEqualTo(END_OF_TIME);
assertThat(existingBillingRecurrence.getRecurrenceEndTime()).isEqualTo(END_INSTANT);
runCommandForced("domain.tld", "--renewal_price_behavior", "DEFAULT");
assertThat(loadByEntity(existingBillingRecurrence).getRecurrenceEndTime())
.isEqualTo(fakeClock.nowUtc());
.isEqualTo(fakeClock.now());
assertNewBillingEventAndHistory(
existingBillingRecurrence.getId(), RenewalPriceBehavior.DEFAULT, null);
}
@@ -132,7 +134,7 @@ public class UpdateRecurrenceCommandTest extends CommandTestCase<UpdateRecurrenc
.setTransferData(
new DomainTransferData.Builder()
.setTransferStatus(TransferStatus.CLIENT_APPROVED)
.setPendingTransferExpirationTime(fakeClock.nowUtc().minusDays(8))
.setPendingTransferExpirationTime(minusDays(fakeClock.now(), 8))
.build())
.build());
BillingRecurrence billingRecurrence = loadByKey(domain.getAutorenewBillingEvent());
@@ -191,7 +193,7 @@ public class UpdateRecurrenceCommandTest extends CommandTestCase<UpdateRecurrenc
void testFailure_billingAlreadyClosed() {
Domain domain = persistDomain();
BillingRecurrence billingRecurrence = loadByKey(domain.getAutorenewBillingEvent());
persistResource(billingRecurrence.asBuilder().setRecurrenceEndTime(fakeClock.nowUtc()).build());
persistResource(billingRecurrence.asBuilder().setRecurrenceEndTime(fakeClock.now()).build());
assertThat(
assertThrows(
IllegalArgumentException.class,
@@ -222,7 +224,7 @@ public class UpdateRecurrenceCommandTest extends CommandTestCase<UpdateRecurrenc
.filter(r -> r.getId() != previousId)
.findFirst()
.get();
assertThat(newBillingRecurrence.getRecurrenceEndTime()).isEqualTo(END_OF_TIME);
assertThat(newBillingRecurrence.getRecurrenceEndTime()).isEqualTo(END_INSTANT);
assertThat(newBillingRecurrence.getRenewalPriceBehavior()).isEqualTo(expectedBehavior);
assertThat(newBillingRecurrence.getRenewalPrice())
.isEqualTo(Optional.ofNullable(expectedPrice));
@@ -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(
@@ -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");
}
}
@@ -37,7 +37,7 @@ public class ToolsServerModuleTest {
DateTime expected = DateTime.parse("1991-07-01T00:00:00Z");
Optional<DateTime> dateTimeParam = ToolsServerModule.provideDeletionTime(request);
assertThat(dateTimeParam).isEqualTo(Optional.of(expected));
assertThat(dateTimeParam).hasValue(expected);
}
@Test
@@ -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;
@@ -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();
@@ -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);