Migrate Domain, Registrar, and Token models to java.time (#3022)

Migrated core EppResource and Token models from Joda-Time DateTime to java.time.Instant.

Specific migrations include:
- `DomainBase` and `Domain`: Migrated `registrationExpirationTime` and various other timestamps to use `Instant` directly.
- `Registrar`: Migrated `lastPocVerificationDate` and certificate dates to `Instant`.
- `BulkPricingPackage`: Migrated `nextBillingDate` and `lastNotificationSent`.
- `AllocationToken`: Migrated `tokenStatusTransitions` map keys to `Instant`.
- `LaunchNotice`: Migrated `acceptedTime` and `expirationTime`.

Updated all associated EPP flows (e.g., DomainCreateFlow, DomainRenewFlow), batch actions (e.g., CheckBulkComplianceAction, DeleteExpiredDomainsAction), command-line tools (e.g., UnrenewDomainCommand, UpdateBulkPricingPackageCommand), and tests to handle `Instant` directly.
This commit is contained in:
Ben McIlwain
2026-04-29 14:06:25 +00:00
committed by GitHub
parent 76131fbd4e
commit fa15a66d9a
112 changed files with 623 additions and 817 deletions
@@ -106,23 +106,23 @@ public class BulkDomainTransferActionTest {
// The cloneProjectedAtTime calls are necessary to resolve the transfers, even though the
// transfers have a time period of 0
activeDomain = loadByEntity(activeDomain);
assertThat(activeDomain.cloneProjectedAtInstant(now).getCurrentSponsorRegistrarId())
assertThat(activeDomain.cloneProjectedAtTime(now).getCurrentSponsorRegistrarId())
.isEqualTo("NewRegistrar");
assertThat(activeDomain.getUpdateTimestamp().getTimestamp()).isEqualTo(runTime);
// The other three domains shouldn't change
alreadyTransferredDomain = loadByEntity(alreadyTransferredDomain);
assertThat(alreadyTransferredDomain.cloneProjectedAtInstant(now).getCurrentSponsorRegistrarId())
assertThat(alreadyTransferredDomain.cloneProjectedAtTime(now).getCurrentSponsorRegistrarId())
.isEqualTo("NewRegistrar");
assertThat(alreadyTransferredDomain.getUpdateTimestamp().getTimestamp()).isEqualTo(preRunTime);
pendingDeleteDomain = loadByEntity(pendingDeleteDomain);
assertThat(pendingDeleteDomain.cloneProjectedAtInstant(now).getCurrentSponsorRegistrarId())
assertThat(pendingDeleteDomain.cloneProjectedAtTime(now).getCurrentSponsorRegistrarId())
.isEqualTo("TheRegistrar");
assertThat(pendingDeleteDomain.getUpdateTimestamp().getTimestamp()).isEqualTo(preRunTime);
deletedDomain = loadByEntity(deletedDomain);
assertThat(deletedDomain.cloneProjectedAtInstant(now).getCurrentSponsorRegistrarId())
assertThat(deletedDomain.cloneProjectedAtTime(now).getCurrentSponsorRegistrarId())
.isEqualTo("TheRegistrar");
assertThat(deletedDomain.getUpdateTimestamp().getTimestamp()).isEqualTo(preRunTime);
}
@@ -19,6 +19,7 @@ import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.persistEppResource;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.LogsSubject.assertAboutLogs;
import static google.registry.util.DateTimeUtils.minusDays;
import static org.joda.money.CurrencyUnit.USD;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
@@ -376,7 +377,7 @@ public class CheckBulkComplianceActionTest {
String.format(DOMAIN_LIMIT_WARNING_EMAIL_BODY, 1, "abc123", "The Registrar", 1, 2));
BulkPricingPackage packageAfterCheck =
tm().transact(() -> BulkPricingPackage.loadByTokenString(token.getToken()).get());
assertThat(packageAfterCheck.getLastNotificationSent().get()).isEqualTo(clock.nowUtc());
assertThat(packageAfterCheck.getLastNotificationSent().get()).isEqualTo(clock.now());
}
@Test
@@ -458,7 +459,7 @@ public class CheckBulkComplianceActionTest {
.asBuilder()
.setMaxCreates(4)
.setMaxDomains(1)
.setLastNotificationSent(clock.nowUtc().minusDays(5))
.setLastNotificationSent(minusDays(clock.now(), 5))
.build();
tm().transact(() -> tm().put(bulkPricingPackage));
// Domains limit is 1, creating 2 domains to go over the limit
@@ -488,7 +489,7 @@ public class CheckBulkComplianceActionTest {
BulkPricingPackage packageAfterCheck =
tm().transact(() -> BulkPricingPackage.loadByTokenString(token.getToken()).get());
assertThat(packageAfterCheck.getLastNotificationSent().get())
.isEqualTo(clock.nowUtc().minusDays(5));
.isEqualTo(minusDays(clock.now(), 5));
}
@Test
@@ -499,7 +500,7 @@ public class CheckBulkComplianceActionTest {
.asBuilder()
.setMaxCreates(4)
.setMaxDomains(1)
.setLastNotificationSent(clock.nowUtc().minusDays(45))
.setLastNotificationSent(minusDays(clock.now(), 45))
.build();
tm().transact(() -> tm().put(bulkPricingPackage));
// Domains limit is 1, creating 2 domains to go over the limit
@@ -533,7 +534,7 @@ public class CheckBulkComplianceActionTest {
String.format(DOMAIN_LIMIT_WARNING_EMAIL_BODY, 1, "abc123", "The Registrar", 1, 2));
BulkPricingPackage packageAfterCheck =
tm().transact(() -> BulkPricingPackage.loadByTokenString(token.getToken()).get());
assertThat(packageAfterCheck.getLastNotificationSent().get()).isEqualTo(clock.nowUtc());
assertThat(packageAfterCheck.getLastNotificationSent().get()).isEqualTo(clock.now());
}
@Test
@@ -544,7 +545,7 @@ public class CheckBulkComplianceActionTest {
.asBuilder()
.setMaxCreates(4)
.setMaxDomains(1)
.setLastNotificationSent(clock.nowUtc().minusDays(31))
.setLastNotificationSent(minusDays(clock.now(), 31))
.build();
tm().transact(() -> tm().put(bulkPricingPackage));
// Domains limit is 1, creating 2 domains to go over the limit
@@ -578,6 +579,6 @@ public class CheckBulkComplianceActionTest {
String.format(DOMAIN_LIMIT_UPGRADE_EMAIL_BODY, 1, "abc123", "The Registrar", 1, 2));
BulkPricingPackage packageAfterCheck =
tm().transact(() -> BulkPricingPackage.loadByTokenString(token.getToken()).get());
assertThat(packageAfterCheck.getLastNotificationSent().get()).isEqualTo(clock.nowUtc());
assertThat(packageAfterCheck.getLastNotificationSent().get()).isEqualTo(clock.now());
}
}
@@ -25,9 +25,10 @@ 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.minusDays;
import static google.registry.util.DateTimeUtils.minusMonths;
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;
@@ -89,7 +90,7 @@ class DeleteExpiredDomainsActionTest {
persistResource(
DatabaseHelper.newDomain("bar.tld")
.asBuilder()
.setAutorenewEndTime(Optional.of(clock.nowUtc().minusDays(10)))
.setAutorenewEndTime(Optional.of(minusDays(clock.now(), 10)))
.setDeletionTime(plusDays(clock.now(), 17))
.build());
@@ -98,7 +99,7 @@ class DeleteExpiredDomainsActionTest {
persistResource(
DatabaseHelper.newDomain("baz.tld")
.asBuilder()
.setAutorenewEndTime(Optional.of(clock.nowUtc().plusDays(15)))
.setAutorenewEndTime(Optional.of(plusDays(clock.now(), 15)))
.build());
// A non-autorenewing domain that is past its expiration time and should be deleted.
@@ -171,7 +172,7 @@ class DeleteExpiredDomainsActionTest {
new DomainHistory.Builder()
.setType(DOMAIN_CREATE)
.setDomain(pendingExpirationDomain)
.setModificationTime(toInstant(clock.nowUtc().minusMonths(9)))
.setModificationTime(minusMonths(clock.now(), 9))
.setRegistrarId(pendingExpirationDomain.getCreationRegistrarId())
.build());
BillingRecurrence autorenewBillingEvent =
@@ -182,7 +183,7 @@ class DeleteExpiredDomainsActionTest {
persistResource(
pendingExpirationDomain
.asBuilder()
.setAutorenewEndTime(Optional.of(clock.nowUtc().minusDays(10)))
.setAutorenewEndTime(Optional.of(minusDays(clock.now(), 10)))
.setAutorenewBillingEvent(autorenewBillingEvent.createVKey())
.setAutorenewPollMessage(autorenewPollMessage.createVKey())
.build());
@@ -118,7 +118,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
persistResource(
makeRegistrar1()
.asBuilder()
.setFailoverClientCertificate(cert.get(), clock.nowUtc())
.setFailoverClientCertificate(cert.get(), clock.now())
.build());
persistSampleContacts(registrar, Type.TECH);
assertThat(
@@ -140,7 +140,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
persistResource(
makeRegistrar1()
.asBuilder()
.setFailoverClientCertificate(cert.get(), clock.nowUtc())
.setFailoverClientCertificate(cert.get(), clock.now())
.build());
persistSampleContacts(registrar, Type.ADMIN);
assertThat(
@@ -211,7 +211,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
persistResource(
makeRegistrar1()
.asBuilder()
.setFailoverClientCertificate(cert.get(), clock.nowUtc())
.setFailoverClientCertificate(cert.get(), clock.now())
.build());
ImmutableList<RegistrarPoc> contacts =
ImmutableList.of(
@@ -340,7 +340,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
persistResource(registrar);
action.updateLastNotificationSentDate(registrar, clock.nowUtc(), CertificateType.PRIMARY);
assertThat(loadByEntity(registrar).getLastExpiringCertNotificationSentDate())
.isEqualTo(clock.nowUtc());
.isEqualTo(clock.now());
}
@Test
@@ -356,7 +356,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
persistResource(registrar);
action.updateLastNotificationSentDate(registrar, clock.nowUtc(), CertificateType.FAILOVER);
assertThat(loadByEntity(registrar).getLastExpiringFailoverCertNotificationSentDate())
.isEqualTo(clock.nowUtc());
.isEqualTo(clock.now());
}
@Test
@@ -690,11 +690,11 @@ class SendExpiringCertificateNotificationEmailActionTest {
if (failOverCertificate != null) {
builder.setFailoverClientCertificate(
certificateChecker.serializeCertificate(failOverCertificate), clock.nowUtc());
certificateChecker.serializeCertificate(failOverCertificate), clock.now());
}
if (certificate != null) {
builder.setClientCertificate(
certificateChecker.serializeCertificate(certificate), clock.nowUtc());
certificateChecker.serializeCertificate(certificate), clock.now());
}
return builder;
}
@@ -20,7 +20,8 @@ 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_INSTANT;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static google.registry.util.DateTimeUtils.START_INSTANT;
import static google.registry.util.DateTimeUtils.plusYears;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@@ -176,7 +177,7 @@ public class RegistryJpaReadTest {
.setCreationRegistrarId(registrar.getRegistrarId())
.setLastEppUpdateTime(fakeClock.now())
.setLastEppUpdateRegistrarId(registrar.getRegistrarId())
.setLastTransferTime(fakeClock.nowUtc())
.setLastTransferTime(fakeClock.now())
.setStatusValues(
ImmutableSet.of(
StatusValue.CLIENT_DELETE_PROHIBITED,
@@ -187,11 +188,11 @@ public class RegistryJpaReadTest {
StatusValue.SERVER_HOLD))
.setSubordinateHosts(ImmutableSet.of("ns1.example.com"))
.setPersistedCurrentSponsorRegistrarId(registrar.getRegistrarId())
.setRegistrationExpirationTime(fakeClock.nowUtc().plusYears(1))
.setRegistrationExpirationTime(plusYears(fakeClock.now(), 1))
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("password")))
.setDsData(ImmutableSet.of(DomainDsData.create(1, 2, 3, new byte[] {0, 1, 2})))
.setLaunchNotice(
LaunchNotice.create("tcnid", "validatorId", START_OF_TIME, START_OF_TIME))
LaunchNotice.create("tcnid", "validatorId", START_INSTANT, START_INSTANT))
.setSmdId("smdid")
.addGracePeriod(
GracePeriod.create(
@@ -22,6 +22,7 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.persistNewRegistrar;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.util.DateTimeUtils.plusYears;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -289,9 +290,9 @@ class Spec11PipelineTest {
.setCreationRegistrarId(registrar.getRegistrarId())
.setLastEppUpdateTime(fakeClock.now())
.setLastEppUpdateRegistrarId(registrar.getRegistrarId())
.setLastTransferTime(fakeClock.nowUtc())
.setLastTransferTime(fakeClock.now())
.setPersistedCurrentSponsorRegistrarId(registrar.getRegistrarId())
.setRegistrationExpirationTime(fakeClock.nowUtc().plusYears(1))
.setRegistrationExpirationTime(plusYears(fakeClock.now(), 1))
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("password")))
.build();
}
@@ -24,7 +24,6 @@ import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.newDomain;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.util.DateTimeUtils.START_INSTANT;
import static google.registry.util.DateTimeUtils.toDateTime;
import com.google.common.collect.ImmutableList;
import google.registry.bsa.api.UnblockableDomain;
@@ -58,7 +57,7 @@ public class DomainsRefresherTest {
persistResource(
Tld.get("tld")
.asBuilder()
.setBsaEnrollStartTime(Optional.of(toDateTime(fakeClock.now().minusMillis(1))))
.setBsaEnrollStartTime(Optional.of(fakeClock.nowUtc().minusMillis(1)))
.build());
refresher = new DomainsRefresher(START_INSTANT, fakeClock.now(), Duration.ZERO, 100);
}
@@ -34,7 +34,6 @@ import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistDomainAsDeleted;
import static google.registry.testing.DatabaseHelper.persistNewRegistrar;
import static google.registry.util.DateTimeUtils.END_INSTANT;
import static google.registry.util.DateTimeUtils.toDateTime;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@@ -284,7 +283,7 @@ class QueriesTest {
// Deleted in the future
persistDomainAsDeleted(
newDomain("label3.tld2").asBuilder().setCreationTimeForTest(fakeClock.now()).build(),
toDateTime(fakeClock.now().plus(Duration.ofHours(1))));
fakeClock.nowUtc().plusHours(1));
fakeClock.advanceOneMilli();
assertThat(
(ImmutableList<DomainLifeSpan>)
@@ -488,8 +488,9 @@ class EppLifecycleDomainTest extends EppTestCase {
assertThatLogoutSucceeds();
// Make sure that in the future, the domain expiration is unchanged after deletion
Domain clonedDomain = domain.cloneProjectedAtTime(deleteTime.plusYears(5));
assertThat(clonedDomain.getRegistrationExpirationDateTime()).isEqualTo(createTime.plusYears(2));
Domain clonedDomain = domain.cloneProjectedAtTime(toInstant(deleteTime.plusYears(5)));
assertThat(clonedDomain.getRegistrationExpirationTime())
.isEqualTo(toInstant(createTime.plusYears(2)));
}
@Test
@@ -18,6 +18,7 @@ import static google.registry.testing.CertificateSamples.SAMPLE_CERT3_HASH;
import static google.registry.testing.DatabaseHelper.loadRegistrar;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static google.registry.util.DateTimeUtils.toInstant;
import static google.registry.util.X509Utils.getCertificateHash;
import com.google.common.collect.ImmutableMap;
@@ -77,13 +78,13 @@ class EppLoginTlsTest extends EppTestCase {
persistResource(
loadRegistrar("NewRegistrar")
.asBuilder()
.setClientCertificate(CertificateSamples.SAMPLE_CERT3, clock.nowUtc())
.setClientCertificate(CertificateSamples.SAMPLE_CERT3, clock.now())
.build());
// Set a cert for the second registrar, or else any cert will be allowed for login.
persistResource(
loadRegistrar("TheRegistrar")
.asBuilder()
.setClientCertificate(CertificateSamples.SAMPLE_CERT2, clock.nowUtc())
.setClientCertificate(CertificateSamples.SAMPLE_CERT2, clock.now())
.build());
}
@@ -156,8 +157,8 @@ class EppLoginTlsTest extends EppTestCase {
persistResource(
loadRegistrar("NewRegistrar")
.asBuilder()
.setClientCertificate(CertificateSamples.SAMPLE_CERT3, now)
.setFailoverClientCertificate(CertificateSamples.SAMPLE_CERT2, now)
.setClientCertificate(CertificateSamples.SAMPLE_CERT3, toInstant(now))
.setFailoverClientCertificate(CertificateSamples.SAMPLE_CERT2, toInstant(now))
.build());
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
}
@@ -169,8 +170,8 @@ class EppLoginTlsTest extends EppTestCase {
persistResource(
loadRegistrar("NewRegistrar")
.asBuilder()
.setClientCertificate(CertificateSamples.SAMPLE_CERT, now)
.setFailoverClientCertificate(CertificateSamples.SAMPLE_CERT3, now)
.setClientCertificate(CertificateSamples.SAMPLE_CERT, toInstant(now))
.setFailoverClientCertificate(CertificateSamples.SAMPLE_CERT3, toInstant(now))
.build());
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
}
@@ -182,8 +183,8 @@ class EppLoginTlsTest extends EppTestCase {
persistResource(
loadRegistrar("NewRegistrar")
.asBuilder()
.setClientCertificate(null, now)
.setFailoverClientCertificate(CertificateSamples.SAMPLE_CERT3, now)
.setClientCertificate(null, toInstant(now))
.setFailoverClientCertificate(CertificateSamples.SAMPLE_CERT3, toInstant(now))
.build());
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
}
@@ -195,8 +196,8 @@ class EppLoginTlsTest extends EppTestCase {
persistResource(
loadRegistrar("NewRegistrar")
.asBuilder()
.setClientCertificate(null, now)
.setFailoverClientCertificate(null, now)
.setClientCertificate(null, toInstant(now))
.setFailoverClientCertificate(null, toInstant(now))
.build());
assertThatLogin("NewRegistrar", "foo-BAR2")
.hasResponse(
@@ -211,8 +212,8 @@ class EppLoginTlsTest extends EppTestCase {
persistResource(
loadRegistrar("NewRegistrar")
.asBuilder()
.setClientCertificate(CertificateSamples.SAMPLE_CERT, clock.nowUtc())
.setFailoverClientCertificate(CertificateSamples.SAMPLE_CERT2, clock.nowUtc())
.setClientCertificate(CertificateSamples.SAMPLE_CERT, clock.now())
.setFailoverClientCertificate(CertificateSamples.SAMPLE_CERT2, clock.now())
.build());
assertThatLogin("NewRegistrar", "foo-BAR2")
.hasResponse(
@@ -244,8 +245,8 @@ class EppLoginTlsTest extends EppTestCase {
persistResource(
loadRegistrar("NewRegistrar")
.asBuilder()
.setClientCertificate(sw.toString(), clock.nowUtc())
.setFailoverClientCertificate(CertificateSamples.SAMPLE_CERT2, clock.nowUtc())
.setClientCertificate(sw.toString(), clock.now())
.setFailoverClientCertificate(CertificateSamples.SAMPLE_CERT2, clock.now())
.build());
assertThatLogin("NewRegistrar", "foo-BAR2")
.hasResponse(
@@ -255,9 +256,10 @@ class EppLoginTlsTest extends EppTestCase {
"2200",
"MSG",
"""
Registrar certificate contains the following security violations:
Certificate is expired.
Certificate validity period is too long; it must be less than or equal to 398\
days."""));
Registrar certificate contains the following security violations:
Certificate is expired.
Certificate validity period is too long; it must be less than or equal to 398\
days.\
"""));
}
}
@@ -17,6 +17,7 @@ package google.registry.flows;
import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import static google.registry.testing.LogsSubject.assertAboutLogs;
import static google.registry.util.DateTimeUtils.toInstant;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@@ -81,7 +82,7 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
protected <T extends EppResource> T reloadResourceAndCloneAtTime(T resource, DateTime now) {
@SuppressWarnings("unchecked")
T refreshedResource =
(T) tm().transact(() -> tm().loadByEntity(resource)).cloneProjectedAtTime(now);
(T) tm().transact(() -> tm().loadByEntity(resource)).cloneProjectedAtTime(toInstant(now));
return refreshedResource;
}
@@ -79,7 +79,7 @@ final class TlsCredentialsTest {
persistResource(
loadRegistrar("TheRegistrar")
.asBuilder()
.setClientCertificate(SAMPLE_CERT, clock.nowUtc())
.setClientCertificate(SAMPLE_CERT, clock.now())
.build());
assertThrows(
MissingRegistrarCertificateException.class,
@@ -97,7 +97,7 @@ final class TlsCredentialsTest {
persistResource(
loadRegistrar("TheRegistrar")
.asBuilder()
.setClientCertificate(SAMPLE_CERT, clock.nowUtc())
.setClientCertificate(SAMPLE_CERT, clock.now())
.setIpAddressAllowList(ImmutableSet.of(CidrAddressBlock.create("3.5.8.13")))
.build());
@@ -118,7 +118,7 @@ final class TlsCredentialsTest {
persistResource(
loadRegistrar("TheRegistrar")
.asBuilder()
.setClientCertificate(SAMPLE_CERT, clock.nowUtc())
.setClientCertificate(SAMPLE_CERT, clock.now())
.setIpAddressAllowList(ImmutableSet.of(CidrAddressBlock.create("3.5.8.13")))
.build());
@@ -155,8 +155,8 @@ final class TlsCredentialsTest {
persistResource(
loadRegistrar("TheRegistrar")
.asBuilder()
.setClientCertificate(null, clock.nowUtc())
.setFailoverClientCertificate(null, clock.nowUtc())
.setClientCertificate(null, clock.now())
.setFailoverClientCertificate(null, clock.now())
.build());
// This would throw a RegistrarCertificateNotConfiguredException if cert hashes wren't bypassed.
tls.validateCertificateHash(Registrar.loadByRegistrarId("TheRegistrar").get());
@@ -173,8 +173,8 @@ final class TlsCredentialsTest {
persistResource(
loadRegistrar("TheRegistrar")
.asBuilder()
.setClientCertificate(null, clock.nowUtc())
.setFailoverClientCertificate(SAMPLE_CERT, clock.nowUtc())
.setClientCertificate(null, clock.now())
.setFailoverClientCertificate(SAMPLE_CERT, clock.now())
.build());
tls.validateCertificateHash(Registrar.loadByRegistrarId("TheRegistrar").get());
}
@@ -346,7 +346,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setToken("abc123")
.setTokenType(SINGLE_USE)
.setDomainName("specificuse.tld")
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
@@ -370,7 +370,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE))
.setDiscountFraction(0.5)
.setDiscountYears(2)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
@@ -393,7 +393,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setDiscountFraction(0.5)
.setDiscountYears(2)
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE))
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
@@ -415,7 +415,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setDiscountFraction(0.9)
.setDiscountYears(3)
.setDiscountPremiums(true)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
@@ -473,7 +473,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setToken("abc123")
.setTokenType(SINGLE_USE)
.setDomainName("specificuse.tld")
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 2), TokenStatus.VALID)
@@ -535,7 +535,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setDomainName("single.tld")
.setDiscountFraction(0.444)
.setDiscountYears(2)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
@@ -568,7 +568,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setToken("abc123")
.setTokenType(UNLIMITED_USE)
.setDiscountFraction(0.5)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(plusDays(clock.now(), 1), TokenStatus.VALID)
@@ -592,7 +592,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setTokenType(UNLIMITED_USE)
.setDiscountFraction(0.5)
.setAllowedTlds(ImmutableSet.of("example"))
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
@@ -616,7 +616,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setTokenType(UNLIMITED_USE)
.setDiscountFraction(0.5)
.setAllowedRegistrarIds(ImmutableSet.of("someOtherClient"))
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
@@ -1218,7 +1218,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
persistResource(
setUpDefaultToken("NewRegistrar")
.asBuilder()
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.of(
START_INSTANT,
TokenStatus.NOT_STARTED,
@@ -2117,7 +2117,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
persistResource(
setUpDefaultToken("NewRegistrar")
.asBuilder()
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.of(
START_INSTANT,
TokenStatus.NOT_STARTED,
@@ -2156,7 +2156,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setDiscountFraction(0.5)
.setDiscountYears(2)
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE))
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
@@ -2190,7 +2190,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setDomainName("single.tld")
.setDiscountFraction(0.444)
.setDiscountYears(2)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
@@ -2225,7 +2225,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setDiscountFraction(0.9)
.setDiscountYears(3)
.setDiscountPremiums(true)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
@@ -2274,7 +2274,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setToken("abc123")
.setTokenType(UNLIMITED_USE)
.setDiscountFraction(0.5)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(plusDays(clock.now(), 1), TokenStatus.VALID)
@@ -2303,7 +2303,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE))
.setDiscountFraction(0.5)
.setDiscountYears(2)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
@@ -2323,7 +2323,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setTokenType(UNLIMITED_USE)
.setDiscountFraction(0.5)
.setAllowedTlds(ImmutableSet.of("example"))
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
@@ -2351,7 +2351,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setTokenType(UNLIMITED_USE)
.setDiscountFraction(0.5)
.setAllowedRegistrarIds(ImmutableSet.of("someOtherClient"))
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
@@ -583,7 +583,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
new AllocationToken.Builder()
.setTokenType(UNLIMITED_USE)
.setToken("abc123")
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
@@ -1327,7 +1327,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
.setToken("abc123")
.setTokenType(UNLIMITED_USE)
.setDiscountFraction(0.5)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(clock.now().plusMillis(1), TokenStatus.VALID)
@@ -1371,7 +1371,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
.setDiscountFraction(discountFraction)
.setDiscountYears(discountYears)
.setDiscountPremiums(discountPremiums)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(clock.now().plusMillis(1), TokenStatus.VALID)
@@ -1408,7 +1408,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
.setDiscountFraction(0.98)
.setDiscountYears(2)
.setDiscountPremiums(true)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(clock.now().plusMillis(1), TokenStatus.VALID)
@@ -1447,7 +1447,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
.setDomainName("rich.example")
.setDiscountFraction(0.95555)
.setDiscountPremiums(true)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(clock.now().plusMillis(1), TokenStatus.VALID)
@@ -1504,7 +1504,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
.setToken("abc123")
.setTokenType(UNLIMITED_USE)
.setDiscountFraction(0.5)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(plusDays(clock.now(), 1), TokenStatus.VALID)
@@ -1528,7 +1528,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
.setTokenType(UNLIMITED_USE)
.setAllowedRegistrarIds(ImmutableSet.of("someClientId"))
.setDiscountFraction(0.5)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
@@ -1615,7 +1615,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
setupDefaultTokenWithDiscount()
.asBuilder()
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 2), TokenStatus.VALID)
@@ -3287,7 +3287,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
setupDefaultTokenWithDiscount("NewRegistrar")
.asBuilder()
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.of(
START_INSTANT,
TokenStatus.NOT_STARTED,
@@ -3879,7 +3879,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
.setDiscountFraction(0.98)
.setDiscountYears(2)
.setDiscountPremiums(true)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(clock.now().plusMillis(1), TokenStatus.VALID)
@@ -3988,7 +3988,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
.setDomainName("rich.example")
.setDiscountFraction(0.95555)
.setDiscountPremiums(true)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(clock.now().plusMillis(1), TokenStatus.VALID)
@@ -4019,7 +4019,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
setupDefaultTokenWithDiscount("NewRegistrar")
.asBuilder()
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.of(
START_INSTANT,
TokenStatus.NOT_STARTED,
@@ -385,7 +385,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
Domain domain = reloadResourceByForeignKey();
Instant redemptionEndTime = plusDays(domain.getLastEppUpdateTime(), 3);
Domain domainAtRedemptionTime = domain.cloneProjectedAtInstant(redemptionEndTime);
Domain domainAtRedemptionTime = domain.cloneProjectedAtTime(redemptionEndTime);
assertAboutDomains()
.that(domainAtRedemptionTime)
.hasLastEppUpdateRegistrarId("TheRegistrar")
@@ -39,6 +39,7 @@ import static google.registry.testing.DomainSubject.assertAboutDomains;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
import static google.registry.testing.TestDataHelper.updateSubstitutions;
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;
@@ -47,7 +48,6 @@ 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.toInstant;
import static org.joda.money.CurrencyUnit.EUR;
import static org.joda.money.CurrencyUnit.JPY;
import static org.joda.money.CurrencyUnit.USD;
@@ -174,7 +174,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
.setTargetId(getUniqueIdFromCommand())
.setRegistrarId("TheRegistrar")
.setEventTime(expirationTime)
.setRecurrenceEndTime(toInstant(END_OF_TIME))
.setRecurrenceEndTime(END_INSTANT)
.setDomainHistory(historyEntryDomainCreate)
.setRenewalPriceBehavior(renewalPriceBehavior)
.setRenewalPrice(renewalPrice)
@@ -311,8 +311,8 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
.setTargetId(getUniqueIdFromCommand())
.setRegistrarId("TheRegistrar")
.setEventTime(toInstant(domain.getRegistrationExpirationDateTime()))
.setRecurrenceEndTime(toInstant(END_OF_TIME))
.setEventTime(domain.getRegistrationExpirationTime())
.setRecurrenceEndTime(END_INSTANT)
.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(toInstant(domain.getRegistrationExpirationDateTime()))
.setEventTime(domain.getRegistrationExpirationTime())
.setAutorenewEndTime(END_OF_TIME)
.setMsg("Domain was auto-renewed.")
.setHistoryEntry(historyEntryDomainRenew)
@@ -667,7 +667,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
.setToken("abc123")
.setTokenType(UNLIMITED_USE)
.setDiscountFraction(0.5)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(plusDays(clock.now(), 1), TokenStatus.VALID)
@@ -691,7 +691,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
.setTokenType(UNLIMITED_USE)
.setAllowedRegistrarIds(ImmutableSet.of("someClientId"))
.setDiscountFraction(0.5)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
@@ -716,7 +716,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
.setTokenType(UNLIMITED_USE)
.setAllowedTlds(ImmutableSet.of("example"))
.setDiscountFraction(0.5)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
@@ -208,7 +208,7 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
new PollMessage.Autorenew.Builder()
.setTargetId("example.tld")
.setRegistrarId("TheRegistrar")
.setEventTime(domain.getRegistrationExpirationDateTime())
.setEventTime(domain.getRegistrationExpirationTime())
.setAutorenewEndTime(END_OF_TIME)
.setMsg("Domain was auto-renewed.")
.setHistoryEntry(historyEntryDomainRestore)
@@ -276,7 +276,7 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
new PollMessage.Autorenew.Builder()
.setTargetId("example.tld")
.setRegistrarId("TheRegistrar")
.setEventTime(domain.getRegistrationExpirationDateTime())
.setEventTime(domain.getRegistrationExpirationTime())
.setAutorenewEndTime(END_OF_TIME)
.setMsg("Domain was auto-renewed.")
.setHistoryEntry(historyEntryDomainRestore)
@@ -322,7 +322,7 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
persistResource(
reloadResourceByForeignKey()
.asBuilder()
.setAutorenewEndTimeInstant(Optional.of(plusYears(clock.now(), 2)))
.setAutorenewEndTime(Optional.of(plusYears(clock.now(), 2)))
.build());
assertThat(reloadResourceByForeignKey().getAutorenewEndTime()).isPresent();
runFlowAssertResponse(
@@ -259,7 +259,7 @@ class DomainTransferApproveFlowTest
// After the expected grace time, the grace period should be gone.
assertThat(
domain
.cloneProjectedAtInstant(
.cloneProjectedAtTime(
clock.now().plusMillis(registry.getTransferGracePeriodLength().getMillis()))
.getGracePeriods())
.isEmpty();
@@ -917,7 +917,7 @@ class DomainTransferApproveFlowTest
.setToken("abc123")
.setTokenType(UNLIMITED_USE)
.setDiscountFraction(0.5)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(plusDays(clock.now(), 1), TokenStatus.VALID)
@@ -937,7 +937,7 @@ class DomainTransferApproveFlowTest
.setTokenType(UNLIMITED_USE)
.setAllowedRegistrarIds(ImmutableSet.of("someClientId"))
.setDiscountFraction(0.5)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
@@ -958,7 +958,7 @@ class DomainTransferApproveFlowTest
.setTokenType(UNLIMITED_USE)
.setAllowedTlds(ImmutableSet.of("example"))
.setDiscountFraction(0.5)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
@@ -146,8 +146,7 @@ class DomainTransferQueryFlowTest
persistResource(
domain
.asBuilder()
.setRegistrationExpirationTime(
domain.getRegistrationExpirationDateTime().plusYears(9))
.setRegistrationExpirationTime(plusYears(domain.getRegistrationExpirationTime(), 9))
.build());
doSuccessfulTest("domain_transfer_query.xml", "domain_transfer_query_response_10_years.xml", 1);
}
@@ -235,7 +234,7 @@ class DomainTransferQueryFlowTest
// Set the clock to just past the extended registration time. We'd expect the domain to have
// auto-renewed once, but the transfer query response should be the same.
clock.setTo(EXTENDED_REGISTRATION_EXPIRATION_TIME.plusMillis(1));
assertThat(domain.cloneProjectedAtInstant(clock.now()).getRegistrationExpirationTime())
assertThat(domain.cloneProjectedAtTime(clock.now()).getRegistrationExpirationTime())
.isEqualTo(plusYears(EXTENDED_REGISTRATION_EXPIRATION_TIME, 1));
doSuccessfulTest(
"domain_transfer_query.xml", "domain_transfer_query_response_server_approved.xml", 2);
@@ -52,7 +52,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.JPY;
import static org.joda.money.CurrencyUnit.USD;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -345,7 +344,7 @@ class DomainTransferRequestFlowTest
assertThat(domain.getGracePeriods()).containsExactlyElementsIn(originalGracePeriods);
// If we fast forward AUTOMATIC_TRANSFER_DAYS, the transfer should have cleared out all other
// grace periods, but expect a transfer grace period (if there was a transfer billing event).
Domain domainAfterAutomaticTransfer = domain.cloneProjectedAtInstant(implicitTransferTime);
Domain domainAfterAutomaticTransfer = domain.cloneProjectedAtTime(implicitTransferTime);
if (expectTransferBillingEvent) {
assertGracePeriods(
domainAfterAutomaticTransfer.getGracePeriods(),
@@ -440,7 +439,7 @@ class DomainTransferRequestFlowTest
Instant expectedExpirationTime, Instant implicitTransferTime, Period expectedPeriod)
throws Exception {
Tld registry = Tld.get(domain.getTld());
Domain domainAfterAutomaticTransfer = domain.cloneProjectedAtInstant(implicitTransferTime);
Domain domainAfterAutomaticTransfer = domain.cloneProjectedAtTime(implicitTransferTime);
assertTransferApproved(domainAfterAutomaticTransfer, implicitTransferTime, expectedPeriod);
assertAboutDomains()
.that(domainAfterAutomaticTransfer)
@@ -453,7 +452,7 @@ class DomainTransferRequestFlowTest
.isEqualTo(expectedExpirationTime);
// And after the expected grace time, the grace period should be gone.
Domain afterGracePeriod =
domain.cloneProjectedAtInstant(
domain.cloneProjectedAtTime(
clock
.now()
.plusMillis(registry.getAutomaticTransferLength().getMillis())
@@ -526,9 +525,7 @@ class DomainTransferRequestFlowTest
.header("content-type", "application/x-www-form-urlencoded")
.param(PARAM_RESOURCE_KEY, domain.createVKey().stringify())
.param(PARAM_REQUESTED_TIME, clock.now().toString())
.scheduleTime(
toDateTime(
clock.now().plusMillis(registry.getAutomaticTransferLength().getMillis()))));
.scheduleTime(clock.nowUtc().plus(registry.getAutomaticTransferLength())));
}
private void doSuccessfulTest(
@@ -1795,7 +1792,7 @@ class DomainTransferRequestFlowTest
.setToken("abc123")
.setTokenType(UNLIMITED_USE)
.setDiscountFraction(0.5)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(plusDays(clock.now(), 1), TokenStatus.VALID)
@@ -1816,7 +1813,7 @@ class DomainTransferRequestFlowTest
.setTokenType(UNLIMITED_USE)
.setAllowedRegistrarIds(ImmutableSet.of("someClientId"))
.setDiscountFraction(0.5)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
@@ -53,7 +53,6 @@ import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntr
import static google.registry.util.DateTimeUtils.START_OF_TIME;
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;
@@ -1503,7 +1502,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
persistResource(
persistDomain()
.asBuilder()
.setAutorenewEndTime(Optional.of(toDateTime(expirationTime)))
.setAutorenewEndTime(Optional.of(expirationTime))
.setRegistrationExpirationTime(expirationTime)
.build());
clock.advanceOneMilli();
@@ -293,7 +293,7 @@ class AllocationTokenFlowUtilsTest {
// the promo would be valid, but it was cancelled 12 hours ago
persistResource(
createOneMonthPromoTokenBuilder(minusDays(clock.now(), 1))
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, NOT_STARTED)
.put(minusMonths(clock.now(), 1), VALID)
@@ -485,7 +485,7 @@ class AllocationTokenFlowUtilsTest {
return new AllocationToken.Builder()
.setToken("tokeN")
.setTokenType(UNLIMITED_USE)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, NOT_STARTED)
.put(promoStart, VALID)
@@ -39,7 +39,6 @@ import static google.registry.testing.HostSubject.assertAboutHosts;
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;
@@ -296,7 +295,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
.hasPersistedCurrentSponsorRegistrarId("TheRegistrar")
.and()
.hasLastTransferTime(oneDayAgo);
Domain reloadedDomain = loadByEntity(domain).cloneProjectedAtInstant(now);
Domain reloadedDomain = loadByEntity(domain).cloneProjectedAtTime(now);
assertThat(reloadedDomain.getSubordinateHosts()).containsExactly("ns2.example.tld");
assertHostDnsRequests("ns1.example.tld", "ns2.example.tld");
}
@@ -330,8 +329,8 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
.hasPersistedCurrentSponsorRegistrarId("TheRegistrar")
.and()
.hasLastTransferTime(null);
assertThat(loadByEntity(foo).cloneProjectedAtInstant(now).getSubordinateHosts()).isEmpty();
assertThat(loadByEntity(example).cloneProjectedAtInstant(now).getSubordinateHosts())
assertThat(loadByEntity(foo).cloneProjectedAtTime(now).getSubordinateHosts()).isEmpty();
assertThat(loadByEntity(example).cloneProjectedAtTime(now).getSubordinateHosts())
.containsExactly("ns2.example.tld");
assertHostDnsRequests("ns2.foo.tld", "ns2.example.tld");
}
@@ -366,9 +365,9 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
.hasPersistedCurrentSponsorRegistrarId("TheRegistrar")
.and()
.hasLastTransferTime(null);
Domain reloadedFooDomain = loadByEntity(fooDomain).cloneProjectedAtInstant(now);
Domain reloadedFooDomain = loadByEntity(fooDomain).cloneProjectedAtTime(now);
assertThat(reloadedFooDomain.getSubordinateHosts()).isEmpty();
Domain reloadedTldDomain = loadByEntity(tldDomain).cloneProjectedAtInstant(now);
Domain reloadedTldDomain = loadByEntity(tldDomain).cloneProjectedAtTime(now);
assertThat(reloadedTldDomain.getSubordinateHosts()).containsExactly("ns2.example.tld");
assertHostDnsRequests("ns1.example.foo", "ns2.example.tld");
}
@@ -411,7 +410,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
.and()
.hasLastSuperordinateChange(clock.now());
assertThat(renamedHost.getLastTransferTime()).isEqualTo(oneDayAgo);
Domain reloadedDomain = loadByEntity(domain).cloneProjectedAtInstant(clock.now());
Domain reloadedDomain = loadByEntity(domain).cloneProjectedAtTime(clock.now());
assertThat(reloadedDomain.getSubordinateHosts()).isEmpty();
assertHostDnsRequests("ns1.example.foo");
}
@@ -447,7 +446,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
.hasPersistedCurrentSponsorRegistrarId("TheRegistrar")
.and()
.hasLastTransferTime(null);
assertThat(loadByEntity(domain).cloneProjectedAtInstant(now).getSubordinateHosts())
assertThat(loadByEntity(domain).cloneProjectedAtTime(now).getSubordinateHosts())
.containsExactly("ns2.example.tld");
assertHostDnsRequests("ns2.example.tld");
}
@@ -520,7 +519,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
persistResource(
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setLastTransferTime(clock.nowUtc().minusDays(10))
.setLastTransferTime(minusDays(clock.now(), 10))
.build());
persistResource(
@@ -553,14 +552,14 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
persistResource(
DatabaseHelper.newDomain("foo.tld")
.asBuilder()
.setLastTransferTime(clock.nowUtc().minusDays(5))
.setLastTransferTime(minusDays(clock.now(), 5))
.build());
// Set the new domain to have a last transfer time that is different from the last transfer
// time on the host in question.
persistResource(
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setLastTransferTime(clock.nowUtc().minusDays(10))
.setLastTransferTime(minusDays(clock.now(), 10))
.build());
Host host =
persistResource(
@@ -595,7 +594,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
persistResource(
DatabaseHelper.newDomain("foo.tld")
.asBuilder()
.setLastTransferTime(clock.nowUtc().minusDays(5))
.setLastTransferTime(minusDays(clock.now(), 5))
.build());
// Set the new domain to have a null last transfer time.
persistResource(
@@ -678,7 +677,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
persistResource(
DatabaseHelper.newDomain("foo.tld")
.asBuilder()
.setLastTransferTime(clock.nowUtc().minusDays(5))
.setLastTransferTime(minusDays(clock.now(), 5))
.build());
// Set the new domain to have a null last transfer time.
persistResource(
@@ -731,7 +730,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
clock.advanceOneMilli();
Host renamedHost = doSuccessfulTest();
clock.advanceOneMilli();
persistResource(domain.asBuilder().setLastTransferTime(clock.nowUtc().minusDays(1)).build());
persistResource(domain.asBuilder().setLastTransferTime(minusDays(clock.now(), 1)).build());
// The last transfer time should be what was on the superordinate domain at the time of the host
// update, not what it is later changed to.
assertAboutHosts()
@@ -767,7 +766,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
persistResource(
domain
.asBuilder()
.setLastTransferTime(clock.nowUtc().minusDays(14))
.setLastTransferTime(minusDays(clock.now(), 14))
.setSubordinateHosts(ImmutableSet.of(oldHostName()))
.build());
clock.advanceOneMilli();
@@ -805,7 +804,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
persistResource(
domain
.asBuilder()
.setLastTransferTime(clock.nowUtc().minusDays(2))
.setLastTransferTime(minusDays(clock.now(), 2))
.setSubordinateHosts(ImmutableSet.of(oldHostName()))
.build());
Host renamedHost = doSuccessfulTest();
@@ -815,7 +814,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
.that(renamedHost)
.hasPersistedCurrentSponsorRegistrarId("TheRegistrar")
.and()
.hasLastTransferTime(toInstant(domain.getLastTransferTime()));
.hasLastTransferTime(domain.getLastTransferTime());
}
private void doExternalToInternalLastTransferTimeTest(
@@ -16,7 +16,6 @@ package google.registry.flows.session;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static org.joda.time.DateTimeZone.UTC;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@@ -31,6 +30,8 @@ import google.registry.model.registrar.Registrar;
import google.registry.testing.CertificateSamples;
import google.registry.util.CidrAddressBlock;
import java.net.InetAddress;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Optional;
import org.joda.time.DateTime;
import org.junit.jupiter.api.Test;
@@ -63,7 +64,7 @@ public class LoginFlowViaTlsTest extends LoginFlowTestCase {
@Override
protected Registrar.Builder getRegistrarBuilder() {
return super.getRegistrarBuilder()
.setClientCertificate(GOOD_CERT.get(), DateTime.now(UTC))
.setClientCertificate(GOOD_CERT.get(), Instant.now().truncatedTo(ChronoUnit.MILLIS))
.setIpAddressAllowList(ImmutableList.of(CidrAddressBlock.create(GOOD_IP.get(), 32)));
}
@@ -22,11 +22,11 @@ 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_INSTANT;
import static google.registry.util.DateTimeUtils.START_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;
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.collect.ImmutableSet;
@@ -43,11 +43,11 @@ import google.registry.model.domain.token.AllocationToken;
import google.registry.model.domain.token.AllocationToken.TokenStatus;
import google.registry.model.reporting.HistoryEntry;
import google.registry.persistence.VKey;
import google.registry.util.DateTimeUtils;
import java.math.BigDecimal;
import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -100,10 +100,12 @@ public class BillingBaseTest extends EntityTestCase {
.setTokenType(UNLIMITED_USE)
.setDiscountFraction(0.5)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(DateTimeUtils.START_OF_TIME, TokenStatus.NOT_STARTED)
.put(DateTime.now(UTC), TokenStatus.VALID)
.put(DateTime.now(UTC).plusWeeks(8), TokenStatus.ENDED)
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(Instant.now().truncatedTo(ChronoUnit.MILLIS), TokenStatus.VALID)
.put(
Instant.now().truncatedTo(ChronoUnit.MILLIS).plus(Duration.ofDays(56)),
TokenStatus.ENDED)
.build())
.build());
@@ -81,7 +81,7 @@ class DomainCommandTest extends ResourceCommandTestCase {
persistActiveHost("ns2.example.net");
DomainCommand.Create create =
(DomainCommand.Create) loadEppResourceCommand("domain_create.xml");
create.cloneAndLinkReferences(fakeClock.nowUtc());
create.cloneAndLinkReferences(fakeClock.now());
}
@Test
@@ -91,8 +91,7 @@ class DomainCommandTest extends ResourceCommandTestCase {
DomainCommand.Create create =
(DomainCommand.Create) loadEppResourceCommand("domain_create_with_contacts.xml");
assertThrows(
RegistrantProhibitedException.class,
() -> create.cloneAndLinkReferences(fakeClock.nowUtc()));
RegistrantProhibitedException.class, () -> create.cloneAndLinkReferences(fakeClock.now()));
}
@Test
@@ -101,15 +100,14 @@ class DomainCommandTest extends ResourceCommandTestCase {
(DomainCommand.Create)
loadEppResourceCommand("domain_create_missing_non_registrant_contacts.xml");
assertThrows(
RegistrantProhibitedException.class,
() -> create.cloneAndLinkReferences(fakeClock.nowUtc()));
RegistrantProhibitedException.class, () -> create.cloneAndLinkReferences(fakeClock.now()));
}
@Test
void testCreate_emptyCommand_cloneAndLinkReferences() throws Exception {
DomainCommand.Create create =
(DomainCommand.Create) loadEppResourceCommand("domain_create_empty.xml");
create.cloneAndLinkReferences(fakeClock.nowUtc());
create.cloneAndLinkReferences(fakeClock.now());
}
@Test
@@ -134,7 +132,7 @@ class DomainCommandTest extends ResourceCommandTestCase {
persistActiveHost("ns2.example.com");
DomainCommand.Update update =
(DomainCommand.Update) loadEppResourceCommand("domain_update.xml");
update.cloneAndLinkReferences(fakeClock.nowUtc());
update.cloneAndLinkReferences(fakeClock.now());
}
@Test
@@ -144,7 +142,7 @@ class DomainCommandTest extends ResourceCommandTestCase {
DomainCommand.Update update =
(DomainCommand.Update) loadEppResourceCommand("domain_update_with_contacts.xml");
assertThrows(
ContactsProhibitedException.class, () -> update.cloneAndLinkReferences(fakeClock.nowUtc()));
ContactsProhibitedException.class, () -> update.cloneAndLinkReferences(fakeClock.now()));
}
@Test
@@ -152,7 +150,7 @@ class DomainCommandTest extends ResourceCommandTestCase {
// This EPP command wouldn't be allowed for policy reasons, but should clone-and-link fine.
DomainCommand.Update update =
(DomainCommand.Update) loadEppResourceCommand("domain_update_empty.xml");
update.cloneAndLinkReferences(fakeClock.nowUtc());
update.cloneAndLinkReferences(fakeClock.now());
}
@Test
@@ -128,7 +128,7 @@ public class DomainSqlTest {
.setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED)
.setRenewalPrice(Money.of(CurrencyUnit.USD, 0))
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE))
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, NOT_STARTED)
.put(fakeClock.now(), TokenStatus.VALID)
@@ -30,6 +30,7 @@ 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_INSTANT;
import static google.registry.util.DateTimeUtils.START_INSTANT;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static google.registry.util.DateTimeUtils.minusDays;
import static google.registry.util.DateTimeUtils.plusDays;
@@ -178,7 +179,7 @@ public class DomainTest {
.setLastEppUpdateTime(fakeClock.now())
.setLastEppUpdateRegistrarId("NewRegistrar")
.setPersistedCurrentSponsorRegistrarId("NewRegistrar")
.setLastTransferTime(fakeClock.nowUtc())
.setLastTransferTime(fakeClock.now())
.setStatusValues(
ImmutableSet.of(
StatusValue.CLIENT_DELETE_PROHIBITED,
@@ -190,11 +191,11 @@ public class DomainTest {
.setNameservers(ImmutableSet.of(hostKey))
.setSubordinateHosts(ImmutableSet.of("ns1.example.com"))
.setPersistedCurrentSponsorRegistrarId("NewRegistrar")
.setRegistrationExpirationTime(fakeClock.nowUtc().plusYears(1))
.setRegistrationExpirationTime(plusYears(fakeClock.now(), 1))
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("password")))
.setDsData(ImmutableSet.of(DomainDsData.create(1, 2, 3, new byte[] {0, 1, 2})))
.setLaunchNotice(
LaunchNotice.create("tcnid", "validatorId", START_OF_TIME, START_OF_TIME))
LaunchNotice.create("tcnid", "validatorId", START_INSTANT, START_INSTANT))
.setTransferData(
new DomainTransferData.Builder()
.setGainingRegistrarId("TheRegistrar")
@@ -223,7 +224,7 @@ public class DomainTest {
plusDays(fakeClock.now(), 1),
"TheRegistrar",
oneTimeBillKey))
.setAutorenewEndTime(Optional.of(fakeClock.nowUtc().plusYears(2)))
.setAutorenewEndTime(Optional.of(plusYears(fakeClock.now(), 2)))
.build()));
}
@@ -393,8 +394,8 @@ public class DomainTest {
assertThat(domain.getTransferData().getTransferStatus())
.isEqualTo(TransferStatus.SERVER_APPROVED);
assertThat(domain.getCurrentSponsorRegistrarId()).isEqualTo("TheRegistrar");
assertThat(domain.getLastTransferTime()).isEqualTo(fakeClock.nowUtc().plusDays(1));
assertThat(domain.getRegistrationExpirationDateTime()).isEqualTo(newExpirationTime);
assertThat(domain.getLastTransferTime()).isEqualTo(plusDays(fakeClock.now(), 1));
assertThat(domain.getRegistrationExpirationTime()).isEqualTo(toInstant(newExpirationTime));
assertThat(domain.getAutorenewBillingEvent()).isEqualTo(newAutorenewEvent);
}
@@ -427,7 +428,7 @@ public class DomainTest {
domain =
domain
.asBuilder()
.setRegistrationExpirationTime(oldExpirationTime)
.setRegistrationExpirationTime(toInstant(oldExpirationTime))
.setTransferData(
domain
.getTransferData()
@@ -452,7 +453,7 @@ public class DomainTest {
"TheRegistrar",
oneTimeBillKey))
.build();
Domain afterTransfer = domain.cloneProjectedAtTime(fakeClock.nowUtc().plusDays(1));
Domain afterTransfer = domain.cloneProjectedAtTime(plusDays(fakeClock.now(), 1));
DateTime newExpirationTime = oldExpirationTime.plusYears(1);
VKey<BillingRecurrence> serverApproveAutorenewEvent =
domain.getTransferData().getServerApproveAutorenewEvent();
@@ -473,7 +474,11 @@ public class DomainTest {
// If we project after the grace period expires all should be the same except the grace period.
Domain afterGracePeriod =
domain.cloneProjectedAtTime(
fakeClock.nowUtc().plusDays(2).plus(Tld.get("com").getTransferGracePeriodLength()));
toInstant(
fakeClock
.nowUtc()
.plusDays(2)
.plus(Tld.get("com").getTransferGracePeriodLength())));
assertTransferred(afterGracePeriod, newExpirationTime, serverApproveAutorenewEvent);
assertThat(afterGracePeriod.getGracePeriods()).isEmpty();
}
@@ -496,7 +501,7 @@ public class DomainTest {
domain =
domain
.asBuilder()
.setRegistrationExpirationTime(toDateTime(oldExpirationTime))
.setRegistrationExpirationTime(oldExpirationTime)
.setTransferData(
domain
.getTransferData()
@@ -518,13 +523,13 @@ public class DomainTest {
Instant transferSuccessDateTime = plusDays(now, 5);
setupPendingTransferDomain(autorenewDateTime, transferRequestDateTime, transferSuccessDateTime);
Domain beforeAutoRenew = domain.cloneProjectedAtInstant(minusDays(autorenewDateTime, 1));
Domain beforeAutoRenew = domain.cloneProjectedAtTime(minusDays(autorenewDateTime, 1));
assertThat(beforeAutoRenew.getLastEppUpdateTime()).isEqualTo(transferRequestDateTime);
assertThat(beforeAutoRenew.getLastEppUpdateRegistrarId()).isEqualTo("TheRegistrar");
// If autorenew happens before transfer succeeds(before transfer grace period starts as well),
// lastEppUpdateRegistrarId should still be the current sponsor client id
Domain afterAutoRenew = domain.cloneProjectedAtInstant(plusDays(autorenewDateTime, 1));
Domain afterAutoRenew = domain.cloneProjectedAtTime(plusDays(autorenewDateTime, 1));
assertThat(afterAutoRenew.getLastEppUpdateTime()).isEqualTo(autorenewDateTime);
assertThat(afterAutoRenew.getLastEppUpdateRegistrarId()).isEqualTo("NewRegistrar");
}
@@ -537,12 +542,11 @@ public class DomainTest {
Instant transferSuccessDateTime = plusDays(now, 5);
setupPendingTransferDomain(autorenewDateTime, transferRequestDateTime, transferSuccessDateTime);
Domain beforeAutoRenew = domain.cloneProjectedAtInstant(minusDays(autorenewDateTime, 1));
Domain beforeAutoRenew = domain.cloneProjectedAtTime(minusDays(autorenewDateTime, 1));
assertThat(beforeAutoRenew.getLastEppUpdateTime()).isEqualTo(transferRequestDateTime);
assertThat(beforeAutoRenew.getLastEppUpdateRegistrarId()).isEqualTo("TheRegistrar");
Domain afterTransferSuccess =
domain.cloneProjectedAtInstant(plusDays(transferSuccessDateTime, 1));
Domain afterTransferSuccess = domain.cloneProjectedAtTime(plusDays(transferSuccessDateTime, 1));
assertThat(afterTransferSuccess.getLastEppUpdateTime()).isEqualTo(transferSuccessDateTime);
assertThat(afterTransferSuccess.getLastEppUpdateRegistrarId()).isEqualTo("TheRegistrar");
}
@@ -551,7 +555,7 @@ public class DomainTest {
domain =
domain
.asBuilder()
.setRegistrationExpirationTime(oldExpirationTime)
.setRegistrationExpirationTime(toInstant(oldExpirationTime))
.setTransferData(DomainTransferData.EMPTY)
.setGracePeriods(ImmutableSet.of())
.setLastEppUpdateTime((Instant) null)
@@ -565,11 +569,11 @@ public class DomainTest {
DateTime autorenewDateTime = now.plusDays(3);
setupUnmodifiedDomain(autorenewDateTime);
Domain beforeAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.minusDays(1));
Domain beforeAutoRenew = domain.cloneProjectedAtTime(toInstant(autorenewDateTime.minusDays(1)));
assertThat(beforeAutoRenew.getLastEppUpdateTime()).isEqualTo(null);
assertThat(beforeAutoRenew.getLastEppUpdateRegistrarId()).isEqualTo(null);
Domain afterAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.plusDays(1));
Domain afterAutoRenew = domain.cloneProjectedAtTime(toInstant(autorenewDateTime.plusDays(1)));
assertThat(afterAutoRenew.getLastEppUpdateTime()).isEqualTo(toInstant(autorenewDateTime));
assertThat(afterAutoRenew.getLastEppUpdateRegistrarId()).isEqualTo("NewRegistrar");
}
@@ -598,7 +602,7 @@ public class DomainTest {
null));
domain = domain.asBuilder().setGracePeriods(ImmutableSet.copyOf(gracePeriods)).build();
for (int i = 1; i < 3; ++i) {
assertThat(domain.cloneProjectedAtTime(fakeClock.nowUtc().plusDays(i)).getGracePeriods())
assertThat(domain.cloneProjectedAtTime(plusDays(fakeClock.now(), i)).getGracePeriods())
.containsExactlyElementsIn(Iterables.limit(gracePeriods, 3 - i));
}
}
@@ -647,7 +651,7 @@ public class DomainTest {
@Test
void testRenewalsHappenAtExpiration() {
Domain renewed = domain.cloneProjectedAtInstant(domain.getRegistrationExpirationTime());
Domain renewed = domain.cloneProjectedAtTime(domain.getRegistrationExpirationTime());
assertThat(renewed.getRegistrationExpirationTime())
.isEqualTo(plusYears(domain.getRegistrationExpirationTime(), 1));
assertThat(renewed.getLastEppUpdateTime()).isEqualTo(domain.getRegistrationExpirationTime());
@@ -667,10 +671,10 @@ public class DomainTest {
domain =
domain
.asBuilder()
.setRegistrationExpirationTime(DateTime.parse("2004-02-29T22:00:00.0Z"))
.setRegistrationExpirationTime(Instant.parse("2004-02-29T22:00:00.0Z"))
.build();
Domain renewed =
domain.cloneProjectedAtInstant(plusYears(domain.getRegistrationExpirationTime(), 4));
domain.cloneProjectedAtTime(plusYears(domain.getRegistrationExpirationTime(), 4));
assertThat(renewed.getRegistrationExpirationTime().atZone(ZoneOffset.UTC).getDayOfMonth())
.isEqualTo(28);
}
@@ -679,35 +683,36 @@ public class DomainTest {
void testMultipleAutoRenews() {
// Change the registry so that renewal costs change every year to make sure we are using the
// autorenew time as the lookup time for the cost.
DateTime oldExpirationTime = domain.getRegistrationExpirationDateTime();
Instant oldExpirationTime = domain.getRegistrationExpirationTime();
persistResource(
Tld.get("com")
.asBuilder()
.setRenewBillingCostTransitions(
new ImmutableSortedMap.Builder<DateTime, Money>(Ordering.natural())
.put(START_OF_TIME, Money.of(USD, 1))
.put(oldExpirationTime.plusMillis(1), Money.of(USD, 2))
.put(oldExpirationTime.plusYears(1).plusMillis(1), Money.of(USD, 3))
.put(toDateTime(oldExpirationTime.plusMillis(1)), Money.of(USD, 2))
.put(
toDateTime(plusYears(oldExpirationTime, 1).plusMillis(1)), Money.of(USD, 3))
// Surround the third autorenew with price changes right before and after just
// to be 100% sure that we lookup the cost at the expiration time.
.put(oldExpirationTime.plusYears(2).minusMillis(1), Money.of(USD, 4))
.put(oldExpirationTime.plusYears(2).plusMillis(1), Money.of(USD, 5))
.put(
toDateTime(plusYears(oldExpirationTime, 2).minusMillis(1)),
Money.of(USD, 4))
.put(
toDateTime(plusYears(oldExpirationTime, 2).plusMillis(1)), Money.of(USD, 5))
.build())
.build());
Domain renewedThreeTimes = domain.cloneProjectedAtTime(oldExpirationTime.plusYears(2));
assertThat(renewedThreeTimes.getRegistrationExpirationDateTime())
.isEqualTo(oldExpirationTime.plusYears(3));
assertThat(renewedThreeTimes.getLastEppUpdateTime())
.isEqualTo(toInstant(oldExpirationTime.plusYears(2)));
Domain renewedThreeTimes = domain.cloneProjectedAtTime(plusYears(oldExpirationTime, 2));
assertThat(renewedThreeTimes.getRegistrationExpirationTime())
.isEqualTo(plusYears(oldExpirationTime, 3));
assertThat(renewedThreeTimes.getLastEppUpdateTime()).isEqualTo(plusYears(oldExpirationTime, 2));
assertThat(renewedThreeTimes.getGracePeriods())
.containsExactly(
GracePeriod.createForRecurrence(
GracePeriodStatus.AUTO_RENEW,
domain.getRepoId(),
toInstant(
oldExpirationTime
.plusYears(2)
.plus(Tld.get("com").getAutoRenewGracePeriodLength())),
plusYears(oldExpirationTime, 2)
.plusMillis(Tld.get("com").getAutoRenewGracePeriodLength().getMillis()),
renewedThreeTimes.getCurrentSponsorRegistrarId(),
renewedThreeTimes.autorenewBillingEvent,
renewedThreeTimes.getGracePeriods().iterator().next().getGracePeriodId()));
@@ -745,12 +750,12 @@ public class DomainTest {
persistResource(
domain
.asBuilder()
.setRegistrationExpirationTime(now.minusDays(1))
.setRegistrationExpirationTime(toInstant(now.minusDays(1)))
.setDeletionTime(toInstant(now.minusDays(10)))
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE, StatusValue.INACTIVE))
.build());
assertThat(domain.cloneProjectedAtTime(now).getRegistrationExpirationDateTime())
.isEqualTo(now.minusDays(1));
assertThat(domain.cloneProjectedAtTime(toInstant(now)).getRegistrationExpirationTime())
.isEqualTo(toInstant(now.minusDays(1)));
}
@Test
@@ -761,12 +766,12 @@ public class DomainTest {
persistResource(
domain
.asBuilder()
.setRegistrationExpirationTime(now.plusDays(1))
.setRegistrationExpirationTime(toInstant(now.plusDays(1)))
.setDeletionTime(toInstant(now.plusDays(20)))
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE, StatusValue.INACTIVE))
.build());
assertThat(domain.cloneProjectedAtTime(now).getRegistrationExpirationDateTime())
.isEqualTo(now.plusDays(1));
assertThat(domain.cloneProjectedAtTime(toInstant(now)).getRegistrationExpirationTime())
.isEqualTo(toInstant(now.plusDays(1)));
}
@Test
@@ -788,12 +793,12 @@ public class DomainTest {
persistResource(
domain
.asBuilder()
.setRegistrationExpirationTime(previousExpiration)
.setRegistrationExpirationTime(toInstant(previousExpiration))
.setTransferData(transferData)
.build());
assertThat(domain.cloneProjectedAtTime(now).getRegistrationExpirationDateTime())
.isEqualTo(newExpiration);
assertThat(domain.cloneProjectedAtTime(toInstant(now)).getRegistrationExpirationTime())
.isEqualTo(toInstant(newExpiration));
}
@Test
@@ -816,12 +821,12 @@ public class DomainTest {
persistResource(
domain
.asBuilder()
.setRegistrationExpirationTime(previousExpiration)
.setRegistrationExpirationTime(toInstant(previousExpiration))
.setTransferData(transferData)
.build());
assertThat(domain.cloneProjectedAtTime(now).getRegistrationExpirationDateTime())
.isEqualTo(newExpiration);
assertThat(domain.cloneProjectedAtTime(toInstant(now)).getRegistrationExpirationTime())
.isEqualTo(toInstant(newExpiration));
}
@Test
@@ -855,14 +860,14 @@ public class DomainTest {
persistResource(
domain
.asBuilder()
.setRegistrationExpirationTime(previousExpiration)
.setRegistrationExpirationTime(toInstant(previousExpiration))
.setTransferData(transferData)
.setCurrentBulkToken(allocationToken.createVKey())
.build());
assertThat(domain.getCurrentBulkToken()).isPresent();
Domain clonedDomain = domain.cloneProjectedAtTime(now);
assertThat(clonedDomain.getRegistrationExpirationDateTime()).isEqualTo(newExpiration);
Domain clonedDomain = domain.cloneProjectedAtTime(toInstant(now));
assertThat(clonedDomain.getRegistrationExpirationTime()).isEqualTo(toInstant(newExpiration));
assertThat(clonedDomain.getCurrentBulkToken()).isEmpty();
}
@@ -883,12 +888,12 @@ public class DomainTest {
persistResource(
domain
.asBuilder()
.setRegistrationExpirationTime(previousExpiration)
.setRegistrationExpirationTime(toInstant(previousExpiration))
.setTransferData(transferData)
.build());
assertThat(domain.cloneProjectedAtTime(now).getRegistrationExpirationDateTime())
.isEqualTo(previousExpiration);
assertThat(domain.cloneProjectedAtTime(toInstant(now)).getRegistrationExpirationTime())
.isEqualTo(toInstant(previousExpiration));
}
@Test
@@ -919,13 +924,14 @@ public class DomainTest {
persistResource(
domain
.asBuilder()
.setRegistrationExpirationTime(previousExpiration)
.setRegistrationExpirationTime(toInstant(previousExpiration))
.setTransferData(transferData)
.setCurrentBulkToken(allocationToken.createVKey())
.build());
Domain clonedDomain = domain.cloneProjectedAtTime(now);
assertThat(clonedDomain.getRegistrationExpirationDateTime()).isEqualTo(previousExpiration);
Domain clonedDomain = domain.cloneProjectedAtTime(toInstant(now));
assertThat(clonedDomain.getRegistrationExpirationTime())
.isEqualTo(toInstant(previousExpiration));
assertThat(clonedDomain.getCurrentBulkToken().get()).isEqualTo(allocationToken.createVKey());
}
@@ -949,7 +955,7 @@ public class DomainTest {
persistResource(
domain
.asBuilder()
.setRegistrationExpirationTime(previousExpiration)
.setRegistrationExpirationTime(toInstant(previousExpiration))
.setGracePeriods(
ImmutableSet.of(
GracePeriod.createForRecurrence(
@@ -961,9 +967,9 @@ public class DomainTest {
.setTransferData(transferData)
.setAutorenewBillingEvent(recurrenceBillKey)
.build());
Domain clone = domain.cloneProjectedAtTime(now);
assertThat(clone.getRegistrationExpirationDateTime())
.isEqualTo(domain.getRegistrationExpirationDateTime().plusYears(1));
Domain clone = domain.cloneProjectedAtTime(toInstant(now));
assertThat(clone.getRegistrationExpirationTime())
.isEqualTo(plusYears(domain.getRegistrationExpirationTime(), 1));
// Transferring removes the AUTORENEW grace period and adds a TRANSFER grace period
assertThat(getOnlyElement(clone.getGracePeriods()).getType())
.isEqualTo(GracePeriodStatus.TRANSFER);
@@ -977,7 +983,7 @@ public class DomainTest {
persistResource(
domain
.asBuilder()
.setRegistrationExpirationTime(now.plusYears(1))
.setRegistrationExpirationTime(toInstant(now.plusYears(1)))
.setGracePeriods(
ImmutableSet.of(
GracePeriod.createForRecurrence(
@@ -74,7 +74,7 @@ public class AllocationTokenTest extends EntityTestCase {
.setDiscountFraction(0.5)
.setDiscountPremiums(true)
.setDiscountYears(3)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, NOT_STARTED)
.put(fakeClock.now(), TokenStatus.VALID)
@@ -111,7 +111,7 @@ public class AllocationTokenTest extends EntityTestCase {
.setDiscountFraction(0.5)
.setDiscountPremiums(true)
.setDiscountYears(3)
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, NOT_STARTED)
.put(fakeClock.now(), TokenStatus.VALID)
@@ -420,7 +420,7 @@ public class AllocationTokenTest extends EntityTestCase {
IllegalArgumentException.class,
() ->
new AllocationToken.Builder()
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(fakeClock.now(), NOT_STARTED)
.put(plusDays(fakeClock.now(), 1), TokenStatus.VALID)
@@ -438,7 +438,7 @@ public class AllocationTokenTest extends EntityTestCase {
IllegalArgumentException.class,
() ->
new AllocationToken.Builder()
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.VALID)
.put(fakeClock.now(), TokenStatus.ENDED)
@@ -720,7 +720,7 @@ public class AllocationTokenTest extends EntityTestCase {
IllegalArgumentException thrown =
assertThrows(
IllegalArgumentException.class,
() -> new AllocationToken.Builder().setTokenStatusTransitionsInstant(map));
() -> new AllocationToken.Builder().setTokenStatusTransitions(map));
assertThat(thrown)
.hasMessageThat()
.isEqualTo(
@@ -734,7 +734,7 @@ public class AllocationTokenTest extends EntityTestCase {
IllegalArgumentException.class,
() ->
new AllocationToken.Builder()
.setTokenStatusTransitionsInstant(
.setTokenStatusTransitions(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, NOT_STARTED)
.put(fakeClock.now(), VALID)
@@ -29,7 +29,6 @@ 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;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -67,7 +66,7 @@ public class BulkPricingPackageTest extends EntityTestCase {
.setBulkPrice(Money.of(CurrencyUnit.USD, 10000))
.setMaxCreates(40)
.setMaxDomains(10)
.setNextBillingDate(DateTime.parse("2011-11-12T05:00:00Z"))
.setNextBillingDate(Instant.parse("2011-11-12T05:00:00Z"))
.build();
tm().transact(() -> tm().put(bulkPricingPackage));
@@ -99,7 +98,7 @@ public class BulkPricingPackageTest extends EntityTestCase {
.setBulkPrice(Money.of(CurrencyUnit.USD, 10000))
.setMaxCreates(40)
.setMaxDomains(10)
.setNextBillingDate(DateTime.parse("2011-11-12T05:00:00Z"))
.setNextBillingDate(Instant.parse("2011-11-12T05:00:00Z"))
.build()));
assertThat(thrown).hasMessageThat().isEqualTo("Allocation token must be a BULK_PRICING type");
@@ -27,6 +27,7 @@ import static google.registry.testing.DatabaseHelper.createTlds;
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.START_INSTANT;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static org.joda.money.CurrencyUnit.JPY;
import static org.joda.money.CurrencyUnit.USD;
@@ -88,7 +89,7 @@ class RegistrarTest extends EntityTestCase {
.setAllowedTlds(ImmutableSet.of("xn--q9jyb4c"))
.setWhoisServer("whois.example.com")
.setBlockPremiumNames(true)
.setClientCertificate(SAMPLE_CERT, fakeClock.nowUtc())
.setClientCertificate(SAMPLE_CERT, fakeClock.now())
.setIpAddressAllowList(
ImmutableList.of(
CidrAddressBlock.create("192.168.1.1/31"),
@@ -222,10 +223,10 @@ class RegistrarTest extends EntityTestCase {
@Test
void testSetCertificateHash_alsoSetsHash() {
registrar = registrar.asBuilder().setClientCertificate(null, fakeClock.nowUtc()).build();
registrar = registrar.asBuilder().setClientCertificate(null, fakeClock.now()).build();
fakeClock.advanceOneMilli();
registrar = registrar.asBuilder().setClientCertificate(SAMPLE_CERT, fakeClock.nowUtc()).build();
assertThat(registrar.getLastCertificateUpdateTime()).isEqualTo(fakeClock.nowUtc());
registrar = registrar.asBuilder().setClientCertificate(SAMPLE_CERT, fakeClock.now()).build();
assertThat(registrar.getLastCertificateUpdateTime()).isEqualTo(fakeClock.now());
assertThat(registrar.getClientCertificate()).hasValue(SAMPLE_CERT);
assertThat(registrar.getClientCertificateHash()).hasValue(SAMPLE_CERT_HASH);
}
@@ -234,8 +235,8 @@ class RegistrarTest extends EntityTestCase {
void testDeleteCertificateHash_alsoDeletesHash() {
assertThat(registrar.getClientCertificateHash()).isPresent();
fakeClock.advanceOneMilli();
registrar = registrar.asBuilder().setClientCertificate(null, fakeClock.nowUtc()).build();
assertThat(registrar.getLastCertificateUpdateTime()).isEqualTo(fakeClock.nowUtc());
registrar = registrar.asBuilder().setClientCertificate(null, fakeClock.now()).build();
assertThat(registrar.getLastCertificateUpdateTime()).isEqualTo(fakeClock.now());
assertThat(registrar.getClientCertificate()).isEmpty();
assertThat(registrar.getClientCertificateHash()).isEmpty();
}
@@ -244,11 +245,8 @@ class RegistrarTest extends EntityTestCase {
void testSetFailoverCertificateHash_alsoSetsHash() {
fakeClock.advanceOneMilli();
registrar =
registrar
.asBuilder()
.setFailoverClientCertificate(SAMPLE_CERT2, fakeClock.nowUtc())
.build();
assertThat(registrar.getLastCertificateUpdateTime()).isEqualTo(fakeClock.nowUtc());
registrar.asBuilder().setFailoverClientCertificate(SAMPLE_CERT2, fakeClock.now()).build();
assertThat(registrar.getLastCertificateUpdateTime()).isEqualTo(fakeClock.now());
assertThat(registrar.getFailoverClientCertificate()).hasValue(SAMPLE_CERT2);
assertThat(registrar.getFailoverClientCertificateHash()).hasValue(SAMPLE_CERT2_HASH);
}
@@ -256,12 +254,11 @@ class RegistrarTest extends EntityTestCase {
@Test
void testDeleteFailoverCertificateHash_alsoDeletesHash() {
registrar =
registrar.asBuilder().setFailoverClientCertificate(SAMPLE_CERT, fakeClock.nowUtc()).build();
registrar.asBuilder().setFailoverClientCertificate(SAMPLE_CERT, fakeClock.now()).build();
assertThat(registrar.getFailoverClientCertificateHash()).isPresent();
fakeClock.advanceOneMilli();
registrar =
registrar.asBuilder().setFailoverClientCertificate(null, fakeClock.nowUtc()).build();
assertThat(registrar.getLastCertificateUpdateTime()).isEqualTo(fakeClock.nowUtc());
registrar = registrar.asBuilder().setFailoverClientCertificate(null, fakeClock.now()).build();
assertThat(registrar.getLastCertificateUpdateTime()).isEqualTo(fakeClock.now());
assertThat(registrar.getFailoverClientCertificate()).isEmpty();
assertThat(registrar.getFailoverClientCertificateHash()).isEmpty();
}
@@ -456,13 +453,13 @@ class RegistrarTest extends EntityTestCase {
@Test
void testSuccess_getLastExpiringCertNotificationSentDate_returnsInitialValue() {
assertThat(registrar.getLastExpiringCertNotificationSentDate()).isEqualTo(START_OF_TIME);
assertThat(registrar.getLastExpiringCertNotificationSentDate()).isEqualTo(START_INSTANT);
}
@Test
void testSuccess_getLastExpiringFailoverCertNotificationSentDate_returnsInitialValue() {
assertThat(registrar.getLastExpiringFailoverCertNotificationSentDate())
.isEqualTo(START_OF_TIME);
.isEqualTo(START_INSTANT);
}
@Test
@@ -470,10 +467,10 @@ class RegistrarTest extends EntityTestCase {
assertThat(
registrar
.asBuilder()
.setLastExpiringCertNotificationSentDate(fakeClock.nowUtc())
.setLastExpiringCertNotificationSentDate(fakeClock.now())
.build()
.getLastExpiringCertNotificationSentDate())
.isEqualTo(fakeClock.nowUtc());
.isEqualTo(fakeClock.now());
}
@Test
@@ -495,10 +492,10 @@ class RegistrarTest extends EntityTestCase {
assertThat(
registrar
.asBuilder()
.setLastExpiringFailoverCertNotificationSentDate(fakeClock.nowUtc())
.setLastExpiringFailoverCertNotificationSentDate(fakeClock.now())
.build()
.getLastExpiringFailoverCertNotificationSentDate())
.isEqualTo(fakeClock.nowUtc());
.isEqualTo(fakeClock.now());
}
@Test
@@ -506,10 +503,10 @@ class RegistrarTest extends EntityTestCase {
assertThat(
registrar
.asBuilder()
.setLastPocVerificationDate(fakeClock.nowUtc())
.setLastPocVerificationDate(fakeClock.now())
.build()
.getLastPocVerificationDate())
.isEqualTo(fakeClock.nowUtc());
.isEqualTo(fakeClock.now());
}
@Test
@@ -29,7 +29,6 @@ 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;
@@ -304,7 +303,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
HistoryEntry.Type.DOMAIN_DELETE,
Period.create(1, Period.Unit.YEARS),
"deleted",
toDateTime(minusMonths(clock.now(), 6))));
clock.nowUtc().minusMonths(6)));
}
private void createManyDomainsAndHosts(
@@ -28,7 +28,6 @@ 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;
@@ -148,7 +147,7 @@ class RdapJsonFormatterTest {
makeDomain("cat.みんな", hostIpv4, hostIpv6, registrar)
.asBuilder()
.setCreationTimeForTest(minusMonths(clock.now(), 4))
.setLastEppUpdateTime(toInstant(clock.nowUtc().minusMonths(1)))
.setLastEppUpdateTime(minusMonths(clock.now(), 1))
.build());
domainNoNameserversNoTransfers =
persistResource(
@@ -265,7 +265,7 @@ public class DomainToXjcConverterTest {
makeHost(clock, "3-Q9JYB4C", "bird.or.devil.みんな", "1.2.3.4").createVKey(),
makeHost(clock, "4-Q9JYB4C", "ns2.cat.みんな", "bad:f00d:cafe::15:beef")
.createVKey()))
.setRegistrationExpirationTime(DateTime.parse("1930-01-01T00:00:00Z"))
.setRegistrationExpirationTime(Instant.parse("1930-01-01T00:00:00Z"))
.setGracePeriods(
ImmutableSet.of(
GracePeriod.forBillingEvent(
@@ -62,7 +62,7 @@ public class HostToXjcConverterTest {
DatabaseHelper.newDomain("love.foobar")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("LeisureDog")
.setLastTransferTime(DateTime.parse("2010-01-01T00:00:00Z"))
.setLastTransferTime(Instant.parse("2010-01-01T00:00:00Z"))
.addStatusValue(StatusValue.PENDING_TRANSFER)
.build();
XjcRdeHost bean =
@@ -180,7 +180,7 @@ public final class DatabaseHelper {
.setPersistedCurrentSponsorRegistrarId("TheRegistrar")
.setCreationTimeForTest(START_INSTANT)
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("2fooBAR")))
.setRegistrationExpirationTime(END_OF_TIME)
.setRegistrationExpirationTime(END_INSTANT)
.build();
}
@@ -259,7 +259,7 @@ public final class DatabaseHelper {
newDomain(domainName)
.asBuilder()
.setCreationTimeForTest(toInstant(creationTime))
.setRegistrationExpirationTime(expirationTime)
.setRegistrationExpirationTime(toInstant(expirationTime))
.build());
}
@@ -535,7 +535,7 @@ public final class DatabaseHelper {
.setPersistedCurrentSponsorRegistrarId("TheRegistrar")
.setCreationRegistrarId("TheRegistrar")
.setCreationTimeForTest(toInstant(creationTime))
.setRegistrationExpirationTime(expirationTime)
.setRegistrationExpirationTime(toInstant(expirationTime))
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("fooBAR")));
Duration addGracePeriodLength = Tld.get(tld).getAddGracePeriodLength();
if (creationTime.plus(addGracePeriodLength).isAfter(now)) {
@@ -92,8 +92,7 @@ public final class DomainSubject extends AbstractEppResourceSubject<Domain, Doma
}
public And<DomainSubject> hasLastTransferTime(Instant lastTransferTime) {
return hasValue(
lastTransferTime, toInstant(actual.getLastTransferTime()), "getLastTransferTime()");
return hasValue(lastTransferTime, actual.getLastTransferTime(), "getLastTransferTime()");
}
public And<DomainSubject> hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) {
@@ -102,7 +101,7 @@ public final class DomainSubject extends AbstractEppResourceSubject<Domain, Doma
public And<DomainSubject> hasLastTransferTimeNotEqualTo(Instant lastTransferTime) {
return doesNotHaveValue(
lastTransferTime, toInstant(actual.getLastTransferTime()), "getLastTransferTime()");
lastTransferTime, actual.getLastTransferTime(), "getLastTransferTime()");
}
public And<DomainSubject> hasDeletePollMessage() {
@@ -130,13 +129,11 @@ public final class DomainSubject extends AbstractEppResourceSubject<Domain, Doma
public And<DomainSubject> hasAutorenewEndTime(Instant autorenewEndTime) {
checkArgumentNotNull(autorenewEndTime, "Use hasNoAutorenewEndTime() instead");
return hasValue(
autorenewEndTime,
toInstant(actual.getAutorenewEndTime().orElse(null)),
"getAutorenewEndTime()");
autorenewEndTime, actual.getAutorenewEndTime().orElse(null), "getAutorenewEndTime()");
}
public And<DomainSubject> hasNoAutorenewEndTime() {
return hasNoValue(actual.getAutorenewEndTimeInstant(), "getAutorenewEndTime()");
return hasNoValue(actual.getAutorenewEndTime(), "getAutorenewEndTime()");
}
public static SimpleSubjectBuilder<DomainSubject, Domain> assertAboutDomains() {
@@ -189,7 +189,7 @@ public final class FullFieldsTestEntityHelper {
.setRepoId(generateNewDomainRoid(getTldFromDomainName(Idn.toASCII(domain))))
.setLastEppUpdateTime(Instant.parse("2009-05-29T20:13:00Z"))
.setCreationTimeForTest(Instant.parse("2000-10-08T00:45:00Z"))
.setRegistrationExpirationTime(DateTime.parse("2110-10-08T00:44:59Z"))
.setRegistrationExpirationTime(Instant.parse("2110-10-08T00:44:59Z"))
.setPersistedCurrentSponsorRegistrarId(registrar.getRegistrarId())
.setCreationRegistrarId(registrar.getRegistrarId())
.setStatusValues(
@@ -23,6 +23,7 @@ import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.loadRegistrar;
import static google.registry.testing.DatabaseHelper.newDomain;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.util.DateTimeUtils.minusHours;
import static jakarta.servlet.http.HttpServletResponse.SC_ACCEPTED;
import static jakarta.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -199,7 +200,7 @@ class NordnUploadActionTest {
.setCreationTimeForTest(clock.now())
.setCreationRegistrarId("NewRegistrar")
.setLaunchNotice(
LaunchNotice.create("landrush2tcn", null, null, clock.nowUtc().minusHours(2)))
LaunchNotice.create("landrush2tcn", null, null, minusHours(clock.now(), 2)))
.setLordnPhase(LordnPhase.CLAIMS)
.build());
clock.advanceBy(Duration.standardDays(1));
@@ -208,7 +209,7 @@ class NordnUploadActionTest {
.asBuilder()
.setCreationTimeForTest(clock.now())
.setLaunchNotice(
LaunchNotice.create("landrush1tcn", null, null, clock.nowUtc().minusHours(1)))
LaunchNotice.create("landrush1tcn", null, null, minusHours(clock.now(), 1)))
.setLordnPhase(LordnPhase.CLAIMS)
.build());
}
@@ -17,7 +17,7 @@ package google.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
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 org.joda.money.CurrencyUnit.USD;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -31,7 +31,6 @@ import java.time.Instant;
import java.util.Optional;
import org.joda.money.CurrencyUnit;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.junit.jupiter.api.Test;
/** Unit tests for {@link CreateBulkPricingPackageCommand}. */
@@ -67,7 +66,7 @@ public class CreateBulkPricingPackageCommandTest
assertThat(bulkPricingPackage.getMaxCreates()).isEqualTo(500);
assertThat(bulkPricingPackage.getBulkPrice()).isEqualTo(Money.of(CurrencyUnit.USD, 1000));
assertThat(bulkPricingPackage.getNextBillingDate())
.isEqualTo(DateTime.parse("2012-03-17T00:00:00Z"));
.isEqualTo(Instant.parse("2012-03-17T00:00:00Z"));
assertThat(bulkPricingPackage.getLastNotificationSent()).isEmpty();
}
@@ -176,7 +175,7 @@ public class CreateBulkPricingPackageCommandTest
assertThat(bulkPricingPackage.getMaxCreates()).isEqualTo(0);
assertThat(bulkPricingPackage.getBulkPrice()).isEqualTo(Money.of(CurrencyUnit.USD, 1000));
assertThat(bulkPricingPackage.getNextBillingDate())
.isEqualTo(DateTime.parse("2012-03-17T00:00:00Z"));
.isEqualTo(Instant.parse("2012-03-17T00:00:00Z"));
assertThat(bulkPricingPackage.getLastNotificationSent()).isEmpty();
}
@@ -203,7 +202,7 @@ public class CreateBulkPricingPackageCommandTest
assertThat(bulkPricingPackage.getMaxDomains()).isEqualTo(100);
assertThat(bulkPricingPackage.getMaxCreates()).isEqualTo(500);
assertThat(bulkPricingPackage.getBulkPrice()).isEqualTo(Money.of(CurrencyUnit.USD, 1000));
assertThat(bulkPricingPackage.getNextBillingDate()).isEqualTo(END_OF_TIME);
assertThat(bulkPricingPackage.getNextBillingDate()).isEqualTo(END_INSTANT);
assertThat(bulkPricingPackage.getLastNotificationSent()).isEmpty();
}
@@ -103,7 +103,7 @@ class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarCommand>
assertThat(registrar.getClientCertificateHash()).isEmpty();
assertThat(registrar.getPhonePasscode()).isEqualTo("01234");
assertThat(registrar.getCreationTime()).isIn(Range.closed(before, after));
assertThat(registrar.getLastUpdateTimeInstant()).isEqualTo(registrar.getCreationTime());
assertThat(registrar.getLastUpdateTime()).isEqualTo(registrar.getCreationTime());
assertThat(registrar.getBlockPremiumNames()).isFalse();
assertThat(registrar.isRegistryLockAllowed()).isFalse();
assertThat(registrar.getPoNumber()).isEmpty();
@@ -265,7 +265,8 @@ public final class DomainLockUtilsTest {
RelockDomainAction.OLD_UNLOCK_REVISION_ID_PARAM,
String.valueOf(lock.getRevisionId()))
.param(RelockDomainAction.PREVIOUS_ATTEMPTS_PARAM, "0")
.scheduleTime(clock.nowUtc().plus(lock.getRelockDuration().get())));
.scheduleTime(
clock.nowUtc().plusMillis((int) lock.getRelockDuration().get().getMillis())));
}
@Test
@@ -491,7 +492,8 @@ public final class DomainLockUtilsTest {
RelockDomainAction.OLD_UNLOCK_REVISION_ID_PARAM,
String.valueOf(lock.getRevisionId()))
.param(RelockDomainAction.PREVIOUS_ATTEMPTS_PARAM, "0")
.scheduleTime(clock.nowUtc().plus(lock.getRelockDuration().get())));
.scheduleTime(
clock.nowUtc().plusMillis((int) lock.getRelockDuration().get().getMillis())));
}
@MockitoSettings(strictness = Strictness.LENIENT)
@@ -24,7 +24,9 @@ import static google.registry.testing.DatabaseHelper.assertAllocationTokens;
import static google.registry.testing.DatabaseHelper.createTlds;
import static google.registry.testing.DatabaseHelper.loadAllOf;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.util.DateTimeUtils.START_INSTANT;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static google.registry.util.DateTimeUtils.toInstant;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.joda.time.DateTimeZone.UTC;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -44,6 +46,7 @@ import google.registry.testing.DeterministicStringGenerator;
import google.registry.testing.DeterministicStringGenerator.Rule;
import google.registry.util.StringGenerator.Alphabets;
import java.io.File;
import java.time.Instant;
import java.util.Collection;
import javax.annotation.Nullable;
import org.joda.money.CurrencyUnit;
@@ -158,10 +161,10 @@ class GenerateAllocationTokensCommandTest extends CommandTestCase<GenerateAlloca
.setDiscountPremiums(true)
.setDiscountYears(6)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(promoStart, TokenStatus.VALID)
.put(promoEnd, TokenStatus.ENDED)
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(toInstant(promoStart), TokenStatus.VALID)
.put(toInstant(promoEnd), TokenStatus.ENDED)
.build())
.build());
}
@@ -200,10 +203,10 @@ class GenerateAllocationTokensCommandTest extends CommandTestCase<GenerateAlloca
.setDiscountPremiums(false)
.setDiscountYears(6)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(promoStart, TokenStatus.VALID)
.put(promoEnd, TokenStatus.ENDED)
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(toInstant(promoStart), TokenStatus.VALID)
.put(toInstant(promoEnd), TokenStatus.ENDED)
.build())
.build());
}
@@ -17,7 +17,7 @@ package google.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatabaseHelper.createTld;
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 java.nio.charset.StandardCharsets.UTF_8;
import google.registry.model.domain.launch.LaunchNotice;
@@ -47,7 +47,7 @@ class GenerateLordnCommandTest extends CommandTestCase<GenerateLordnCommand> {
persistResource(
DatabaseHelper.newDomain("fleecey.tld")
.asBuilder()
.setLaunchNotice(LaunchNotice.create("smd3", "validator", START_OF_TIME, START_OF_TIME))
.setLaunchNotice(LaunchNotice.create("smd3", "validator", START_INSTANT, START_INSTANT))
.setSmdId("smd3")
.build());
Path claimsCsv = outputDir.resolve("claims.csv");
@@ -54,9 +54,9 @@ class GetAllocationTokenCommandTest extends CommandTestCase<GetAllocationTokenCo
.setDiscountYears(2)
.setTokenStatusTransitions(
ImmutableSortedMap.of(
DateTimeUtils.START_OF_TIME,
DateTimeUtils.START_INSTANT,
AllocationToken.TokenStatus.NOT_STARTED,
fakeClock.nowUtc(),
fakeClock.now(),
AllocationToken.TokenStatus.VALID))
.setDomainName("foo.bar")
.build());
@@ -30,7 +30,6 @@ 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;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -64,8 +63,8 @@ public class GetBulkPricingPackageCommandTest
.setMaxDomains(100)
.setMaxCreates(500)
.setBulkPrice(Money.of(CurrencyUnit.USD, 1000))
.setNextBillingDate(DateTime.parse("2012-11-12T05:00:00Z"))
.setLastNotificationSent(DateTime.parse("2010-11-12T05:00:00Z"))
.setNextBillingDate(Instant.parse("2012-11-12T05:00:00Z"))
.setLastNotificationSent(Instant.parse("2010-11-12T05:00:00Z"))
.build();
tm().transact(() -> tm().put(bulkPricingPackage));
runCommand("abc123");
@@ -94,8 +93,8 @@ public class GetBulkPricingPackageCommandTest
.setMaxDomains(100)
.setMaxCreates(500)
.setBulkPrice(Money.of(CurrencyUnit.USD, 1000))
.setNextBillingDate(DateTime.parse("2012-11-12T05:00:00Z"))
.setLastNotificationSent(DateTime.parse("2010-11-12T05:00:00Z"))
.setNextBillingDate(Instant.parse("2012-11-12T05:00:00Z"))
.setLastNotificationSent(Instant.parse("2010-11-12T05:00:00Z"))
.build()));
AllocationToken token2 =
persistResource(
@@ -118,8 +117,8 @@ public class GetBulkPricingPackageCommandTest
.setMaxDomains(1000)
.setMaxCreates(700)
.setBulkPrice(Money.of(CurrencyUnit.USD, 3000))
.setNextBillingDate(DateTime.parse("2014-11-12T05:00:00Z"))
.setLastNotificationSent(DateTime.parse("2013-11-12T05:00:00Z"))
.setNextBillingDate(Instant.parse("2014-11-12T05:00:00Z"))
.setLastNotificationSent(Instant.parse("2013-11-12T05:00:00Z"))
.build()));
runCommand("abc123", "123abc");
@@ -80,7 +80,7 @@ public class RenewDomainCommandTest extends EppToolCommandTestCase<RenewDomainCo
DatabaseHelper.newDomain("domain3.tld")
.asBuilder()
.setCreationTimeForTest(Instant.parse("2015-01-05T05:05:05Z"))
.setRegistrationExpirationTime(DateTime.parse("2016-01-05T05:05:05Z"))
.setRegistrationExpirationTime(Instant.parse("2016-01-05T05:05:05Z"))
.setPersistedCurrentSponsorRegistrarId("NewRegistrar")
.build()));
return domains.build();
@@ -32,7 +32,6 @@ 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;
@@ -299,7 +298,7 @@ class UniformRapidSuspensionCommandTest
DatabaseHelper.newDomain("evil.tld")
.asBuilder()
.setCreationTimeForTest(Instant.parse("2021-10-01T05:01:11Z"))
.setRegistrationExpirationTime(DateTime.parse("2022-10-01T05:01:11Z"))
.setRegistrationExpirationTime(Instant.parse("2022-10-01T05:01:11Z"))
.setPersistedCurrentSponsorRegistrarId("CharlestonRoad")
.build(),
defaultDsData,
@@ -336,7 +335,7 @@ class UniformRapidSuspensionCommandTest
DatabaseHelper.newDomain("evil.tld")
.asBuilder()
.setCreationTimeForTest(Instant.parse("2021-10-01T05:01:11Z"))
.setRegistrationExpirationTime(DateTime.parse("2022-10-01T05:01:11Z"))
.setRegistrationExpirationTime(Instant.parse("2022-10-01T05:01:11Z"))
.setPersistedCurrentSponsorRegistrarId("CharlestonRoad")
.build(),
defaultDsData,
@@ -374,7 +373,7 @@ class UniformRapidSuspensionCommandTest
DatabaseHelper.newDomain("evil.tld")
.asBuilder()
.setCreationTimeForTest(Instant.parse("2021-10-01T05:01:11Z"))
.setRegistrationExpirationTime(DateTime.parse("2022-10-01T05:01:11Z"))
.setRegistrationExpirationTime(Instant.parse("2022-10-01T05:01:11Z"))
.setPersistedCurrentSponsorRegistrarId("CharlestonRoad")
.build(),
defaultDsData,
@@ -42,6 +42,8 @@ import google.registry.model.domain.DomainHistory;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.poll.PollMessage;
import google.registry.testing.DatabaseHelper;
import google.registry.util.DateTimeUtils;
import java.time.Instant;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -52,7 +54,7 @@ public class UnrenewDomainCommandTest extends CommandTestCase<UnrenewDomainComma
@BeforeEach
void beforeEach() {
createTld("tld");
fakeClock.setTo(DateTime.parse("2016-12-06T13:55:01Z"));
fakeClock.setTo(Instant.parse("2016-12-06T13:55:01Z"));
command.clock = fakeClock;
command.printStream = System.out;
}
@@ -79,13 +81,13 @@ public class UnrenewDomainCommandTest extends CommandTestCase<UnrenewDomainComma
assertThat(
ForeignKeyUtils.loadResource(Domain.class, "foo.tld", fakeClock.nowUtc())
.get()
.getRegistrationExpirationDateTime())
.isEqualTo(DateTime.parse("2019-12-06T13:55:01.001Z"));
.getRegistrationExpirationTime())
.isEqualTo(Instant.parse("2019-12-06T13:55:01.001Z"));
assertThat(
ForeignKeyUtils.loadResource(Domain.class, "bar.tld", fakeClock.nowUtc())
.get()
.getRegistrationExpirationDateTime())
.isEqualTo(DateTime.parse("2018-12-06T13:55:01.002Z"));
.getRegistrationExpirationTime())
.isEqualTo(Instant.parse("2018-12-06T13:55:01.002Z"));
assertInStdout("Successfully unrenewed all domains.");
}
@@ -98,16 +100,16 @@ public class UnrenewDomainCommandTest extends CommandTestCase<UnrenewDomainComma
fakeClock.nowUtc(),
fakeClock.nowUtc(),
fakeClock.nowUtc().plusYears(5));
DateTime newExpirationTime = fakeClock.nowUtc().plusYears(3);
Instant newExpirationTime = DateTimeUtils.plusYears(fakeClock.now(), 3);
fakeClock.advanceOneMilli();
runCommandForced("-p", "2", "foo.tld");
DateTime unrenewTime = fakeClock.nowUtc();
Instant unrenewTime = fakeClock.now();
fakeClock.advanceOneMilli();
Domain domain = ForeignKeyUtils.loadResource(Domain.class, "foo.tld", fakeClock.nowUtc()).get();
assertAboutHistoryEntries()
.that(getOnlyHistoryEntryOfType(domain, SYNTHETIC))
.hasModificationTime(toInstant(unrenewTime))
.hasModificationTime(unrenewTime)
.and()
.hasMetadataReason("Domain unrenewal")
.and()
@@ -128,7 +130,7 @@ public class UnrenewDomainCommandTest extends CommandTestCase<UnrenewDomainComma
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
.setTargetId(domain.getDomainName())
.setRegistrarId("TheRegistrar")
.setEventTime(toInstant(newExpirationTime))
.setEventTime(newExpirationTime)
.build());
assertPollMessagesEqual(
getPollMessages(domain),
@@ -139,19 +141,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(toInstant(unrenewTime))
.setEventTime(unrenewTime)
.build(),
new PollMessage.Autorenew.Builder()
.setHistoryEntry(synthetic)
.setTargetId("foo.tld")
.setRegistrarId("TheRegistrar")
.setEventTime(toInstant(newExpirationTime))
.setEventTime(newExpirationTime)
.setMsg("Domain was auto-renewed.")
.build()));
// Check that fields on domain were updated correctly.
assertThat(domain.getRegistrationExpirationDateTime()).isEqualTo(newExpirationTime);
assertThat(domain.getLastEppUpdateTime()).isEqualTo(toInstant(unrenewTime));
assertThat(domain.getRegistrationExpirationTime()).isEqualTo(newExpirationTime);
assertThat(domain.getLastEppUpdateTime()).isEqualTo(unrenewTime);
assertThat(domain.getLastEppUpdateRegistrarId()).isEqualTo("TheRegistrar");
}
@@ -29,7 +29,9 @@ 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.START_INSTANT;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static google.registry.util.DateTimeUtils.toInstant;
import static org.joda.time.DateTimeZone.UTC;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -41,6 +43,7 @@ import google.registry.model.domain.token.AllocationToken;
import google.registry.model.domain.token.AllocationToken.RegistrationBehavior;
import google.registry.model.domain.token.AllocationToken.TokenStatus;
import google.registry.testing.DatabaseHelper;
import java.time.Instant;
import org.joda.money.CurrencyUnit;
import org.joda.money.Money;
import org.joda.time.DateTime;
@@ -423,9 +426,9 @@ class UpdateAllocationTokensCommandTest extends CommandTestCase<UpdateAllocation
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE))
.setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar"))
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, NOT_STARTED)
.put(now.minusDays(1), VALID)
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, NOT_STARTED)
.put(toInstant(now.minusDays(1)), VALID)
.build())
.build());
runCommandForced(
@@ -452,9 +455,9 @@ class UpdateAllocationTokensCommandTest extends CommandTestCase<UpdateAllocation
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE))
.setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar"))
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, NOT_STARTED)
.put(now.minusDays(1), VALID)
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, NOT_STARTED)
.put(toInstant(now.minusDays(1)), VALID)
.build())
.build());
createTld("tld");
@@ -568,10 +571,10 @@ class UpdateAllocationTokensCommandTest extends CommandTestCase<UpdateAllocation
.setToken("token")
.setTokenType(UNLIMITED_USE)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, NOT_STARTED)
.put(now.minusDays(1), VALID)
.put(now.plusDays(1), ENDED)
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, NOT_STARTED)
.put(toInstant(now.minusDays(1)), VALID)
.put(toInstant(now.plusDays(1)), ENDED)
.build());
}
}
@@ -30,7 +30,6 @@ import java.time.Instant;
import java.util.Optional;
import org.joda.money.CurrencyUnit;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -59,8 +58,8 @@ public class UpdateBulkPricingPackageCommandTest
.setMaxDomains(100)
.setMaxCreates(500)
.setBulkPrice(Money.of(CurrencyUnit.USD, 1000))
.setNextBillingDate(DateTime.parse("2012-11-12T05:00:00Z"))
.setLastNotificationSent(DateTime.parse("2010-11-12T05:00:00Z"))
.setNextBillingDate(Instant.parse("2012-11-12T05:00:00Z"))
.setLastNotificationSent(Instant.parse("2010-11-12T05:00:00Z"))
.build();
tm().transact(() -> tm().put(bulkPricingPackage));
}
@@ -83,7 +82,7 @@ public class UpdateBulkPricingPackageCommandTest
assertThat(bulkPricingPackage.getMaxCreates()).isEqualTo(1000);
assertThat(bulkPricingPackage.getBulkPrice()).isEqualTo(Money.of(CurrencyUnit.USD, 2000));
assertThat(bulkPricingPackage.getNextBillingDate())
.isEqualTo(DateTime.parse("2013-03-17T00:00:00Z"));
.isEqualTo(Instant.parse("2013-03-17T00:00:00Z"));
assertThat(bulkPricingPackage.getLastNotificationSent()).isEmpty();
}
@@ -132,7 +131,7 @@ public class UpdateBulkPricingPackageCommandTest
assertThat(bulkPricingPackage.getMaxCreates()).isEqualTo(1000);
assertThat(bulkPricingPackage.getBulkPrice()).isEqualTo(Money.of(CurrencyUnit.USD, 2000));
assertThat(bulkPricingPackage.getNextBillingDate())
.isEqualTo(DateTime.parse("2013-03-17T00:00:00Z"));
.isEqualTo(Instant.parse("2013-03-17T00:00:00Z"));
assertThat(bulkPricingPackage.getLastNotificationSent()).isEmpty();
}
@@ -153,7 +152,7 @@ public class UpdateBulkPricingPackageCommandTest
assertThat(bulkPricingPackage.getMaxCreates()).isEqualTo(1000);
assertThat(bulkPricingPackage.getBulkPrice()).isEqualTo(Money.of(CurrencyUnit.USD, 2000));
assertThat(bulkPricingPackage.getNextBillingDate())
.isEqualTo(DateTime.parse("2012-11-12T05:00:00Z"));
.isEqualTo(Instant.parse("2012-11-12T05:00:00Z"));
assertThat(bulkPricingPackage.getLastNotificationSent()).isEmpty();
}
@@ -174,7 +173,7 @@ public class UpdateBulkPricingPackageCommandTest
assertThat(bulkPricingPackage.getMaxCreates()).isEqualTo(1000);
assertThat(bulkPricingPackage.getBulkPrice()).isEqualTo(Money.of(CurrencyUnit.USD, 1000));
assertThat(bulkPricingPackage.getNextBillingDate())
.isEqualTo(DateTime.parse("2013-03-17T00:00:00Z"));
.isEqualTo(Instant.parse("2013-03-17T00:00:00Z"));
assertThat(bulkPricingPackage.getLastNotificationSent()).isEmpty();
}
@@ -190,8 +189,8 @@ public class UpdateBulkPricingPackageCommandTest
assertThat(bulkPricingPackage.getMaxCreates()).isEqualTo(1000);
assertThat(bulkPricingPackage.getBulkPrice()).isEqualTo(Money.of(CurrencyUnit.USD, 2000));
assertThat(bulkPricingPackage.getNextBillingDate())
.isEqualTo(DateTime.parse("2012-11-12T05:00:00Z"));
.isEqualTo(Instant.parse("2012-11-12T05:00:00Z"));
assertThat(bulkPricingPackage.getLastNotificationSent().get())
.isEqualTo(DateTime.parse("2010-11-12T05:00:00.000Z"));
.isEqualTo(Instant.parse("2010-11-12T05:00:00.000Z"));
}
}
@@ -295,7 +295,7 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
persistResource(
domain
.asBuilder()
.setRegistrationExpirationTime(fakeClock.nowUtc().plusDays(360))
.setRegistrationExpirationTime(plusDays(fakeClock.now(), 360))
.setAutorenewBillingEvent(autorenewBillingEvent.createVKey())
.setGracePeriods(
ImmutableSet.of(
@@ -25,7 +25,6 @@ import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static org.joda.money.CurrencyUnit.JPY;
import static org.joda.money.CurrencyUnit.USD;
import static org.joda.time.DateTimeZone.UTC;
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.beust.jcommander.ParameterException;
@@ -42,6 +41,8 @@ import google.registry.model.registrar.Registrar.Type;
import google.registry.persistence.transaction.JpaTransactionManagerExtension;
import google.registry.util.CidrAddressBlock;
import java.math.BigDecimal;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Optional;
import org.joda.money.Money;
import org.joda.time.DateTime;
@@ -275,8 +276,8 @@ class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarCommand>
persistResource(
loadRegistrar("NewRegistrar")
.asBuilder()
.setClientCertificate(SAMPLE_CERT3, fakeClock.nowUtc())
.setFailoverClientCertificate(null, fakeClock.nowUtc())
.setClientCertificate(SAMPLE_CERT3, fakeClock.now())
.setFailoverClientCertificate(null, fakeClock.now())
.build());
Registrar registrar = loadRegistrar("NewRegistrar");
@@ -408,7 +409,7 @@ class UpdateRegistrarCommandTest extends CommandTestCase<UpdateRegistrarCommand>
persistResource(
loadRegistrar("NewRegistrar")
.asBuilder()
.setClientCertificate(SAMPLE_CERT, DateTime.now(UTC))
.setClientCertificate(SAMPLE_CERT, Instant.now().truncatedTo(ChronoUnit.MILLIS))
.build());
assertThat(loadRegistrar("NewRegistrar").getClientCertificate()).isPresent();
runCommand("--cert_file=/dev/null", "--force", "NewRegistrar");
@@ -21,7 +21,6 @@ import static google.registry.testing.DatabaseHelper.loadRegistrar;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static org.joda.time.DateTimeZone.UTC;
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.beust.jcommander.ParameterException;
@@ -37,6 +36,8 @@ import google.registry.testing.CertificateSamples;
import google.registry.util.CidrAddressBlock;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -56,7 +57,8 @@ class ValidateLoginCredentialsCommandTest extends CommandTestCase<ValidateLoginC
loadRegistrar("NewRegistrar")
.asBuilder()
.setPassword(PASSWORD)
.setClientCertificate(CertificateSamples.SAMPLE_CERT3, DateTime.now(UTC))
.setClientCertificate(
CertificateSamples.SAMPLE_CERT3, Instant.now().truncatedTo(ChronoUnit.MILLIS))
.setIpAddressAllowList(ImmutableList.of(new CidrAddressBlock(CLIENT_IP)))
.setState(ACTIVE)
.setAllowedTlds(ImmutableSet.of("tld"))
@@ -46,8 +46,8 @@ import jakarta.mail.internet.InternetAddress;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.time.Instant;
import java.util.Optional;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
@@ -115,7 +115,7 @@ class ConsoleUpdateRegistrarActionTest extends ConsoleActionBaseTestCase {
action.run();
Registrar newRegistrar = Registrar.loadByRegistrarId("TheRegistrar").get();
assertThat(newRegistrar.getLastPocVerificationDate())
.isEqualTo(DateTime.parse("1970-01-01T00:00:00.000Z"));
.isEqualTo(Instant.parse("1970-01-01T00:00:00.000Z"));
}
@Test
@@ -23,9 +23,9 @@ import google.registry.model.console.GlobalRole;
import google.registry.model.console.RegistrarRole;
import google.registry.model.registrar.Registrar;
import google.registry.server.RegistryTestServer;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.List;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
@@ -80,7 +80,10 @@ public class ConsoleScreenshotTest {
server.setRegistrarRoles(ImmutableMap.of("TheRegistrar", RegistrarRole.ACCOUNT_MANAGER));
Registrar registrar = Registrar.loadByRegistrarId("TheRegistrar").get();
registrar =
registrar.asBuilder().setLastPocVerificationDate(DateTime.now(DateTimeZone.UTC)).build();
registrar
.asBuilder()
.setLastPocVerificationDate(Instant.now().truncatedTo(ChronoUnit.MILLIS))
.build();
persistResource(registrar);
loadHomePage();
}