Migrate TMCH, SMD, and Fee models to java.time (#3019)

Continues the project-wide migration from Joda-Time's DateTime to java.time.Instant, focusing on Trademark Clearinghouse (TMCH), Signed Mark Data (SMD), and Fee extension models.

Key updates:
- TMCH & SMD: Updated SmdRevocationList and domain check/create flows to use Instant for sunrise validations and revocation checks.
- Fee Extension Ecosystem: Refactored FeeCheckRequest, FeeCreateCommandExtension, and BaseFee to use Instant for effective dates and period calculations.
- EPP Objects: Updated DomainInfoData, TransferResponse, and PollMessage objects to use Instant for event timestamps.
- Pricing Logic: DomainPricingLogic methods now accept Instant for cost calculations.

Additionally, DateTimeUtils was enhanced with Instant compatibility methods for plusMonths and minusMonths to safely handle leap years.

Redundant conversions between DateTime and Instant were eliminated throughout the flows and tests. DomainFlowUtils leverages Instant natively to avoid inline casting, and test assertions now utilize Truth's Instant subjects for cleaner validation.
This commit is contained in:
Ben McIlwain
2026-04-22 16:44:47 +00:00
committed by GitHub
parent 653704811b
commit 925482ea58
108 changed files with 1561 additions and 1383 deletions
@@ -28,7 +28,6 @@ import static google.registry.testing.DatabaseHelper.persistDomainAsDeleted;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.util.DateTimeUtils.END_INSTANT;
import static google.registry.util.DateTimeUtils.minusYears;
import static google.registry.util.DateTimeUtils.toDateTime;
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.collect.ImmutableSet;
@@ -49,6 +48,7 @@ import google.registry.testing.DatabaseHelper;
import google.registry.testing.FakeClock;
import google.registry.testing.SystemPropertyExtension;
import google.registry.util.RegistryEnvironment;
import java.time.Duration;
import java.time.Instant;
import java.util.Optional;
import java.util.Set;
@@ -238,7 +238,7 @@ class DeleteProberDataActionTest {
persistResource(
DatabaseHelper.newDomain("blah.ib-any.test")
.asBuilder()
.setCreationTimeForTest(clock.now().minus(java.time.Duration.ofSeconds(1)))
.setCreationTimeForTest(clock.now().minus(Duration.ofSeconds(1)))
.build());
action.run();
Optional<Domain> domain =
@@ -263,15 +263,14 @@ class DeleteProberDataActionTest {
@Test
void test_domainWithSubordinateHosts_isSkipped() throws Exception {
persistActiveHost("ns1.blah.ib-any.test");
Domain nakedDomain =
persistDeletedDomain("todelete.ib-any.test", toDateTime(minusYears(clock.now(), 1)));
Domain nakedDomain = persistDeletedDomain("todelete.ib-any.test", clock.nowUtc().minusYears(1));
Domain domainWithSubord =
persistDomainAsDeleted(
DatabaseHelper.newDomain("blah.ib-any.test")
.asBuilder()
.setSubordinateHosts(ImmutableSet.of("ns1.blah.ib-any.test"))
.build(),
toDateTime(minusYears(clock.now(), 1)));
clock.nowUtc().minusYears(1));
action.run();
assertAllExist(ImmutableSet.of(domainWithSubord));
@@ -25,8 +25,7 @@ import static google.registry.bsa.persistence.BsaTestingUtils.persistUnblockable
import static google.registry.testing.DatabaseHelper.createTld;
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.toDateTime;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.startsWith;
@@ -238,7 +237,7 @@ public class BsaValidateActionTest {
@Test
void isStalenessAllowed_newDomain_allowed() {
persistBsaLabel("label");
Domain domain = persistActiveDomain("label.app", toDateTime(fakeClock.now()));
Domain domain = persistActiveDomain("label.app", fakeClock.nowUtc());
fakeClock.advanceBy(
org.joda.time.Duration.millis(MAX_STALENESS.minus(Duration.ofSeconds(1)).toMillis()));
assertThat(action.isStalenessAllowed(domain)).isTrue();
@@ -247,7 +246,7 @@ public class BsaValidateActionTest {
@Test
void isStalenessAllowed_newDomain_notAllowed() {
persistBsaLabel("label");
Domain domain = persistActiveDomain("label.app", toDateTime(fakeClock.now()));
Domain domain = persistActiveDomain("label.app", fakeClock.nowUtc());
fakeClock.advanceBy(org.joda.time.Duration.millis(MAX_STALENESS.toMillis()));
assertThat(action.isStalenessAllowed(domain)).isFalse();
}
@@ -278,15 +277,9 @@ public class BsaValidateActionTest {
@Test
void checkForMissingReservedUnblockables_success() {
persistResource(
createTld("app")
.asBuilder()
.setBsaEnrollStartTime(Optional.of(toDateTime(START_INSTANT)))
.build());
createTld("app").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
persistResource(
createTld("dev")
.asBuilder()
.setBsaEnrollStartTime(Optional.of(toDateTime(START_INSTANT)))
.build());
createTld("dev").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
persistBsaLabel("registered-reserved");
persistBsaLabel("reserved-only");
persistBsaLabel("reserved-missing");
@@ -310,15 +303,9 @@ public class BsaValidateActionTest {
@Test
void checkForMissingReservedUnblockablesInOneTld_success() {
persistResource(
createTld("app")
.asBuilder()
.setBsaEnrollStartTime(Optional.of(toDateTime(START_INSTANT)))
.build());
createTld("app").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
persistResource(
createTld("dev")
.asBuilder()
.setBsaEnrollStartTime(Optional.of(toDateTime(START_INSTANT)))
.build());
createTld("dev").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
persistBsaLabel("reserved-missing-in-app");
persistUnblockableDomain(
UnblockableDomain.of("reserved-missing-in-app", "dev", Reason.REGISTERED));
@@ -338,10 +325,7 @@ public class BsaValidateActionTest {
@Test
void checkForMissingReservedUnblockables_unblockedReservedNotReported() {
persistResource(
createTld("app")
.asBuilder()
.setBsaEnrollStartTime(Optional.of(toDateTime(START_INSTANT)))
.build());
createTld("app").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
createReservedList(
"rl",
@@ -356,10 +340,7 @@ public class BsaValidateActionTest {
@Test
void checkForMissingRegisteredUnblockables_success() {
persistResource(
createTld("app")
.asBuilder()
.setBsaEnrollStartTime(Optional.of(toDateTime(START_INSTANT)))
.build());
createTld("app").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
persistBsaLabel("registered");
persistBsaLabel("registered-missing");
persistUnblockableDomain(UnblockableDomain.of("registered", "app", Reason.REGISTERED));
@@ -44,6 +44,7 @@ import google.registry.bsa.persistence.Queries.DomainLifeSpan;
import google.registry.persistence.transaction.JpaTestExtensions;
import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationWithCoverageExtension;
import google.registry.testing.FakeClock;
import java.time.Duration;
import java.time.Instant;
import java.util.Optional;
import org.junit.jupiter.api.BeforeEach;
@@ -208,14 +209,14 @@ class QueriesTest {
createTlds("tld");
persistNewRegistrar("TheRegistrar");
// time 0:
persistActiveDomain("d1.tld", toDateTime(fakeClock.now()));
persistActiveDomain("d1.tld", fakeClock.nowUtc());
// time 0, deletion time 1
persistDomainAsDeleted(
newDomain("will-delete.tld").asBuilder().setCreationTimeForTest(fakeClock.now()).build(),
toDateTime(fakeClock.now().plusMillis(1)));
fakeClock.now().plusMillis(1));
fakeClock.advanceOneMilli();
// time 1
persistActiveDomain("d2.tld", toDateTime(fakeClock.now()));
persistActiveDomain("d2.tld", fakeClock.nowUtc());
fakeClock.advanceOneMilli();
// Now is time 2
assertThat(
@@ -232,14 +233,14 @@ class QueriesTest {
createTlds("tld");
persistNewRegistrar("TheRegistrar");
// time 0:
persistActiveDomain("d1.tld", toDateTime(fakeClock.now()));
persistActiveDomain("d1.tld", fakeClock.nowUtc());
// time 0, deletion time 1
persistDomainAsDeleted(
newDomain("will-delete.tld").asBuilder().setCreationTimeForTest(fakeClock.now()).build(),
toDateTime(fakeClock.now().plusMillis(1)));
fakeClock.now().plusMillis(1));
fakeClock.advanceOneMilli();
// time 1
persistActiveDomain("d2.tld", toDateTime(fakeClock.now()));
persistActiveDomain("d2.tld", fakeClock.nowUtc());
fakeClock.advanceOneMilli();
// Now is time 2, ask for domains created since time 1
assertThat(
@@ -255,8 +256,8 @@ class QueriesTest {
Instant testStartTime = fakeClock.now();
createTlds("tld", "tld2");
persistNewRegistrar("TheRegistrar");
persistActiveDomain("d1.tld", toDateTime(fakeClock.now()));
persistActiveDomain("d2.tld2", toDateTime(fakeClock.now()));
persistActiveDomain("d1.tld", fakeClock.nowUtc());
persistActiveDomain("d2.tld2", fakeClock.nowUtc());
fakeClock.advanceOneMilli();
assertThat(
bsaQuery(
@@ -271,19 +272,19 @@ class QueriesTest {
createTlds("tld", "tld2");
persistNewRegistrar("TheRegistrar");
Instant time1 = fakeClock.now();
persistActiveDomain("unblocked1.tld", toDateTime(fakeClock.now()));
persistActiveDomain("unblocked2.tld2", toDateTime(fakeClock.now()));
persistActiveDomain("label1.tld", toDateTime(fakeClock.now()));
persistActiveDomain("label2.tld2", toDateTime(fakeClock.now()));
persistActiveDomain("unblocked1.tld", fakeClock.nowUtc());
persistActiveDomain("unblocked2.tld2", fakeClock.nowUtc());
persistActiveDomain("label1.tld", fakeClock.nowUtc());
persistActiveDomain("label2.tld2", fakeClock.nowUtc());
fakeClock.advanceOneMilli();
Instant time2 = fakeClock.now();
persistDomainAsDeleted(
newDomain("label3.tld").asBuilder().setCreationTimeForTest(fakeClock.now()).build(),
toDateTime(fakeClock.now().plusMillis(1)));
fakeClock.now().plusMillis(1));
// Deleted in the future
persistDomainAsDeleted(
newDomain("label3.tld2").asBuilder().setCreationTimeForTest(fakeClock.now()).build(),
toDateTime(fakeClock.now().plus(java.time.Duration.ofHours(1))));
toDateTime(fakeClock.now().plus(Duration.ofHours(1))));
fakeClock.advanceOneMilli();
assertThat(
(ImmutableList<DomainLifeSpan>)
@@ -294,7 +295,7 @@ class QueriesTest {
bsaQuery(() -> queryMissedRegisteredUnblockables("tld2", fakeClock.now())))
.containsExactly(
new DomainLifeSpan("label2.tld2", time1, END_INSTANT),
new DomainLifeSpan("label3.tld2", time2, time2.plus(java.time.Duration.ofHours(1))));
new DomainLifeSpan("label3.tld2", time2, time2.plus(Duration.ofHours(1))));
BsaTestingUtils.persistUnblockableDomain(
UnblockableDomain.of("label2", "tld2", UnblockableDomain.Reason.REGISTERED));
@@ -303,8 +304,7 @@ class QueriesTest {
assertThat(
(ImmutableList<DomainLifeSpan>)
bsaQuery(() -> queryMissedRegisteredUnblockables("tld2", fakeClock.now())))
.containsExactly(
new DomainLifeSpan("label3.tld2", time2, time2.plus(java.time.Duration.ofHours(1))));
.containsExactly(new DomainLifeSpan("label3.tld2", time2, time2.plus(Duration.ofHours(1))));
}
@Test
@@ -101,7 +101,7 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
/** Persists a testing claims list to Cloud SQL. */
protected void persistClaimsList(ImmutableMap<String, String> labelsToKeys) {
ClaimsListDao.save(ClaimsList.create(clock.nowUtc(), labelsToKeys));
ClaimsListDao.save(ClaimsList.create(clock.now(), labelsToKeys));
}
protected void assertClientIdFieldLogged(String registrarId) {
@@ -37,7 +37,9 @@ import static google.registry.testing.DatabaseHelper.persistPremiumList;
import static google.registry.testing.DatabaseHelper.persistReservedList;
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 google.registry.util.DateTimeUtils.START_INSTANT;
import static google.registry.util.DateTimeUtils.minusDays;
import static google.registry.util.DateTimeUtils.plusDays;
import static org.joda.money.CurrencyUnit.JPY;
import static org.joda.money.CurrencyUnit.USD;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -93,9 +95,9 @@ import google.registry.model.tld.Tld.TldState;
import google.registry.model.tld.label.ReservedList;
import google.registry.testing.DatabaseHelper;
import java.math.BigDecimal;
import java.time.Instant;
import java.util.Optional;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
@@ -105,7 +107,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
DomainCheckFlowTest() {
setEppInput("domain_check_one_tld.xml");
clock.setTo(DateTime.parse("2009-01-01T10:00:00Z"));
clock.setTo(Instant.parse("2009-01-01T10:00:00Z"));
}
static ReservedList createReservedList() {
@@ -158,7 +160,10 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
@Test
void testSuccess_bsaBlocked_otherwiseAvailable_blocked() throws Exception {
persistResource(
Tld.get("tld").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
Tld.get("tld")
.asBuilder()
.setBsaEnrollStartTimeInstant(Optional.of(START_INSTANT))
.build());
persistBsaLabel("example1");
doCheckTest(
create(false, "example1.tld", "Blocked by a GlobalBlock service"),
@@ -169,7 +174,10 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
@Test
void testSuccess_bsaBlocked_alsoRegistered_registered() throws Exception {
persistResource(
Tld.get("tld").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
Tld.get("tld")
.asBuilder()
.setBsaEnrollStartTimeInstant(Optional.of(START_INSTANT))
.build());
persistBsaLabel("example1");
persistActiveDomain("example1.tld");
doCheckTest(
@@ -181,7 +189,10 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
@Test
void testSuccess_bsaBlocked_alsoReserved_reserved() throws Exception {
persistResource(
Tld.get("tld").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
Tld.get("tld")
.asBuilder()
.setBsaEnrollStartTimeInstant(Optional.of(START_INSTANT))
.build());
persistBsaLabel("reserved");
persistBsaLabel("allowedinsunrise");
setEppInput("domain_check_one_tld_reserved.xml");
@@ -195,7 +206,10 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
@Test
void testSuccess_bsaBlocked_createAllowedWithToken() throws Exception {
persistResource(
Tld.get("tld").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
Tld.get("tld")
.asBuilder()
.setBsaEnrollStartTimeInstant(Optional.of(START_INSTANT))
.build());
persistBsaLabel("example1");
setEppInput("domain_check_allocationtoken.xml");
persistResource(
@@ -214,7 +228,10 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
@Test
void testSuccess_bsaBlocked_withIrrelevantTokenType() throws Exception {
persistResource(
Tld.get("tld").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
Tld.get("tld")
.asBuilder()
.setBsaEnrollStartTimeInstant(Optional.of(START_INSTANT))
.build());
persistBsaLabel("example1");
setEppInput("domain_check_allocationtoken.xml");
persistResource(
@@ -235,7 +252,10 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
setEppInput("domain_check.xml");
createTlds("com", "net", "org");
persistResource(
Tld.get("com").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
Tld.get("com")
.asBuilder()
.setBsaEnrollStartTimeInstant(Optional.of(START_INSTANT))
.build());
persistBsaLabel("example");
doCheckTest(
create(false, "example.com", "Blocked by a GlobalBlock service"),
@@ -326,11 +346,11 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setToken("abc123")
.setTokenType(SINGLE_USE)
.setDomainName("specificuse.tld")
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().minusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 1), TokenStatus.ENDED)
.build())
.build());
doCheckTest(
@@ -350,11 +370,11 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE))
.setDiscountFraction(0.5)
.setDiscountYears(2)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().minusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 1), TokenStatus.ENDED)
.build())
.build());
setEppInput("domain_check_allocationtoken_fee_stdv1.xml");
@@ -373,11 +393,11 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setDiscountFraction(0.5)
.setDiscountYears(2)
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE))
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().minusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 1), TokenStatus.ENDED)
.build())
.build());
setEppInput("domain_check_allocationtoken_fee_stdv1.xml");
@@ -395,11 +415,11 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setDiscountFraction(0.9)
.setDiscountYears(3)
.setDiscountPremiums(true)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().minusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 1), TokenStatus.ENDED)
.build())
.build());
setEppInput(
@@ -453,11 +473,11 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setToken("abc123")
.setTokenType(SINGLE_USE)
.setDomainName("specificuse.tld")
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().minusDays(2), TokenStatus.VALID)
.put(clock.nowUtc().minusDays(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 2), TokenStatus.VALID)
.put(minusDays(clock.now(), 1), TokenStatus.ENDED)
.build())
.build());
doCheckTest(
@@ -515,11 +535,11 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setDomainName("single.tld")
.setDiscountFraction(0.444)
.setDiscountYears(2)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().minusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 1), TokenStatus.ENDED)
.build())
.build());
setEppInput(
@@ -548,11 +568,11 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setToken("abc123")
.setTokenType(UNLIMITED_USE)
.setDiscountFraction(0.5)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().plusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(60), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(plusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 60), TokenStatus.ENDED)
.build())
.build());
setEppInput("domain_check_allocationtoken_fee_stdv1.xml");
@@ -572,11 +592,11 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setTokenType(UNLIMITED_USE)
.setDiscountFraction(0.5)
.setAllowedTlds(ImmutableSet.of("example"))
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().minusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 1), TokenStatus.ENDED)
.build())
.build());
setEppInput("domain_check_allocationtoken_fee_stdv1.xml");
@@ -596,11 +616,11 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setTokenType(UNLIMITED_USE)
.setDiscountFraction(0.5)
.setAllowedRegistrarIds(ImmutableSet.of("someOtherClient"))
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().minusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 1), TokenStatus.ENDED)
.build())
.build());
setEppInput("domain_check_allocationtoken_fee_stdv1.xml");
@@ -781,11 +801,11 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
Tld.get("tld")
.asBuilder()
.setCurrency(JPY)
.setCreateBillingCostTransitions(
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
.setRenewBillingCostTransitions(
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
.setCreateBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
.setEapFeeScheduleInstant(ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
.setRenewBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
.setRegistryLockOrUnlockBillingCost(Money.ofMajor(JPY, 800))
.setServerStatusChangeBillingCost(Money.ofMajor(JPY, 800))
.setRestoreBillingCost(Money.ofMajor(JPY, 800))
@@ -1027,8 +1047,8 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
persistResource(
Tld.get("tld")
.asBuilder()
.setCreateBillingCostTransitions(
ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 11.1)))
.setCreateBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 11.1)))
.build());
setEppInput("domain_check_fee_fractional_stdv1.xml");
runFlowAssertResponse(loadFile("domain_check_fee_fractional_response_stdv1.xml"));
@@ -1130,11 +1150,11 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
createTld("example")
.asBuilder()
.setCurrency(JPY)
.setCreateBillingCostTransitions(
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
.setRenewBillingCostTransitions(
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
.setCreateBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
.setEapFeeScheduleInstant(ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
.setRenewBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
.setRegistryLockOrUnlockBillingCost(Money.ofMajor(JPY, 800))
.setServerStatusChangeBillingCost(Money.ofMajor(JPY, 800))
.setRestoreBillingCost(Money.ofMajor(JPY, 800))
@@ -1198,11 +1218,11 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
persistResource(
setUpDefaultToken("NewRegistrar")
.asBuilder()
.setTokenStatusTransitions(
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.of(
START_OF_TIME,
START_INSTANT,
TokenStatus.NOT_STARTED,
clock.nowUtc().plusDays(1),
plusDays(clock.now(), 1),
TokenStatus.VALID))
.build());
@@ -1303,16 +1323,16 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
void testFeeExtension_premium_eap_v06() throws Exception {
createTld("example");
setEppInput("domain_check_fee_premium_v06.xml");
clock.setTo(DateTime.parse("2010-01-01T10:00:00Z"));
clock.setTo(Instant.parse("2010-01-01T10:00:00Z"));
persistResource(
Tld.get("example")
.asBuilder()
.setEapFeeSchedule(
new ImmutableSortedMap.Builder<DateTime, Money>(Ordering.natural())
.put(START_OF_TIME, Money.of(USD, 0))
.put(clock.nowUtc().minusDays(1), Money.of(USD, 100))
.put(clock.nowUtc().plusDays(1), Money.of(USD, 50))
.put(clock.nowUtc().plusDays(2), Money.of(USD, 0))
.setEapFeeScheduleInstant(
new ImmutableSortedMap.Builder<Instant, Money>(Ordering.natural())
.put(START_INSTANT, Money.of(USD, 0))
.put(minusDays(clock.now(), 1), Money.of(USD, 100))
.put(plusDays(clock.now(), 1), Money.of(USD, 50))
.put(plusDays(clock.now(), 2), Money.of(USD, 0))
.build())
.build());
@@ -1322,13 +1342,13 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
@Test
void testFeeExtension_premium_eap_v06_withRenewalOnRestore() throws Exception {
createTld("example");
DateTime startTime = DateTime.parse("2010-01-01T10:00:00Z");
Instant startTime = Instant.parse("2010-01-01T10:00:00Z");
clock.setTo(startTime);
persistResource(
persistActiveDomain("rich.example")
.asBuilder()
.setDeletionTime(clock.nowUtc().plusDays(25))
.setRegistrationExpirationTime(clock.nowUtc().minusDays(1))
.setDeletionTime(plusDays(clock.now(), 25))
.setRegistrationExpirationTime(minusDays(clock.now(), 1))
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
.build());
persistPendingDeleteDomain("rich.example");
@@ -1336,12 +1356,12 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
persistResource(
Tld.get("example")
.asBuilder()
.setEapFeeSchedule(
new ImmutableSortedMap.Builder<DateTime, Money>(Ordering.natural())
.put(START_OF_TIME, Money.of(USD, 0))
.put(startTime.minusDays(1), Money.of(USD, 100))
.put(startTime.plusDays(1), Money.of(USD, 50))
.put(startTime.plusDays(2), Money.of(USD, 0))
.setEapFeeScheduleInstant(
new ImmutableSortedMap.Builder<Instant, Money>(Ordering.natural())
.put(START_INSTANT, Money.of(USD, 0))
.put(minusDays(startTime, 1), Money.of(USD, 100))
.put(plusDays(startTime, 1), Money.of(USD, 50))
.put(plusDays(startTime, 2), Money.of(USD, 0))
.build())
.build());
runFlowAssertResponse(loadFile("domain_check_fee_premium_eap_response_v06_with_renewal.xml"));
@@ -2053,11 +2073,11 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
createTld("example")
.asBuilder()
.setCurrency(JPY)
.setCreateBillingCostTransitions(
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
.setRenewBillingCostTransitions(
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
.setCreateBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
.setEapFeeScheduleInstant(ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
.setRenewBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
.setRegistryLockOrUnlockBillingCost(Money.ofMajor(JPY, 800))
.setServerStatusChangeBillingCost(Money.ofMajor(JPY, 800))
.setRestoreBillingCost(Money.ofMajor(JPY, 800))
@@ -2097,11 +2117,11 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
persistResource(
setUpDefaultToken("NewRegistrar")
.asBuilder()
.setTokenStatusTransitions(
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.of(
START_OF_TIME,
START_INSTANT,
TokenStatus.NOT_STARTED,
clock.nowUtc().plusDays(1),
plusDays(clock.now(), 1),
TokenStatus.VALID))
.build());
@@ -2117,8 +2137,8 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
persistResource(
Tld.get("tld")
.asBuilder()
.setCreateBillingCostTransitions(
ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 11.1)))
.setCreateBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 11.1)))
.build());
setEppInput("domain_check_fee_fractional_v06.xml");
runFlowAssertResponse(loadFile("domain_check_fee_fractional_response_v06.xml"));
@@ -2136,11 +2156,11 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setDiscountFraction(0.5)
.setDiscountYears(2)
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE))
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().minusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 1), TokenStatus.ENDED)
.build())
.build());
setEppInput("domain_check_allocationtoken_fee_v06.xml");
@@ -2170,11 +2190,11 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setDomainName("single.tld")
.setDiscountFraction(0.444)
.setDiscountYears(2)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().minusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 1), TokenStatus.ENDED)
.build())
.build());
setEppInput(
@@ -2205,11 +2225,11 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setDiscountFraction(0.9)
.setDiscountYears(3)
.setDiscountPremiums(true)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().minusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 1), TokenStatus.ENDED)
.build())
.build());
setEppInput(
@@ -2254,11 +2274,11 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setToken("abc123")
.setTokenType(UNLIMITED_USE)
.setDiscountFraction(0.5)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().plusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(60), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(plusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 60), TokenStatus.ENDED)
.build())
.build());
setEppInput("domain_check_allocationtoken_fee_v06.xml");
@@ -2283,11 +2303,11 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE))
.setDiscountFraction(0.5)
.setDiscountYears(2)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().minusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 1), TokenStatus.ENDED)
.build())
.build());
setEppInput("domain_check_allocationtoken_fee_v06.xml");
@@ -2303,11 +2323,11 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setTokenType(UNLIMITED_USE)
.setDiscountFraction(0.5)
.setAllowedTlds(ImmutableSet.of("example"))
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().minusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 1), TokenStatus.ENDED)
.build())
.build());
setEppInput("domain_check_allocationtoken_fee_v06.xml");
@@ -2331,11 +2351,11 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setTokenType(UNLIMITED_USE)
.setDiscountFraction(0.5)
.setAllowedRegistrarIds(ImmutableSet.of("someOtherClient"))
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().minusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 1), TokenStatus.ENDED)
.build())
.build());
setEppInput("domain_check_allocationtoken_fee_v06.xml");
@@ -2399,8 +2419,8 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
persistResource(
DatabaseHelper.newDomain(domainName)
.asBuilder()
.setDeletionTime(clock.nowUtc().plusDays(25))
.setRegistrationExpirationTime(clock.nowUtc().minusDays(1))
.setDeletionTime(plusDays(clock.now(), 25))
.setRegistrationExpirationTime(minusDays(clock.now(), 1))
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
.build());
DomainHistory historyEntry =
@@ -2419,7 +2439,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
.setTargetId(existingDomain.getDomainName())
.setRegistrarId("TheRegistrar")
.setEventTime(existingDomain.getCreationTime())
.setRecurrenceEndTime(clock.nowUtc())
.setRecurrenceEndTime(clock.now())
.setDomainHistory(historyEntry)
.build());
return persistResource(
@@ -2428,17 +2448,17 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
private void runEapFeeCheckTestWithXmlInputOutput(String inputXml, String outputXml)
throws Exception {
clock.setTo(DateTime.parse("2010-01-01T10:00:00Z"));
clock.setTo(Instant.parse("2010-01-01T10:00:00Z"));
persistActiveDomain("example1.tld");
persistResource(
Tld.get("tld")
.asBuilder()
.setEapFeeSchedule(
new ImmutableSortedMap.Builder<DateTime, Money>(Ordering.natural())
.put(START_OF_TIME, Money.of(USD, 0))
.put(clock.nowUtc().minusDays(1), Money.of(USD, 100))
.put(clock.nowUtc().plusDays(1), Money.of(USD, 50))
.put(clock.nowUtc().plusDays(2), Money.of(USD, 0))
.setEapFeeScheduleInstant(
new ImmutableSortedMap.Builder<Instant, Money>(Ordering.natural())
.put(START_INSTANT, Money.of(USD, 0))
.put(minusDays(clock.now(), 1), Money.of(USD, 100))
.put(plusDays(clock.now(), 1), Money.of(USD, 50))
.put(plusDays(clock.now(), 2), Money.of(USD, 0))
.build())
.build());
setEppInputXml(inputXml);
@@ -181,7 +181,7 @@ public class DomainClaimsCheckFlowTest extends ResourceFlowTestCase<DomainClaims
void testFailure_multipleTlds_oneHasEndedClaims() {
createTlds("tld1", "tld2");
persistResource(
Tld.get("tld2").asBuilder().setClaimsPeriodEnd(clock.nowUtc().minusMillis(1)).build());
Tld.get("tld2").asBuilder().setClaimsPeriodEndInstant(clock.now().minusMillis(1)).build());
setEppInput("domain_check_claims_multiple_tlds.xml");
EppException thrown = assertThrows(ClaimsPeriodEndedException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
@@ -57,7 +57,12 @@ import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DomainSubject.assertAboutDomains;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static google.registry.util.DateTimeUtils.START_INSTANT;
import static google.registry.util.DateTimeUtils.minusDays;
import static google.registry.util.DateTimeUtils.minusMonths;
import static google.registry.util.DateTimeUtils.minusYears;
import static google.registry.util.DateTimeUtils.plusDays;
import static google.registry.util.DateTimeUtils.plusYears;
import static org.joda.money.CurrencyUnit.JPY;
import static org.joda.money.CurrencyUnit.USD;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -184,7 +189,6 @@ import java.util.Map;
import java.util.Optional;
import javax.annotation.Nullable;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -197,12 +201,12 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
private static final String CLAIMS_KEY = "2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001";
// This is a time when SMD itself is not valid, but its signing certificates are. It will
// trigger a different exception than when any signing cert is not valid yet.
private static final DateTime SMD_NOT_YET_VALID_TIME = DateTime.parse("2022-11-20T12:34:56Z");
private static final DateTime SMD_VALID_TIME = DateTime.parse("2023-01-02T12:34:56Z");
private static final Instant SMD_NOT_YET_VALID_TIME = Instant.parse("2022-11-20T12:34:56Z");
private static final Instant SMD_VALID_TIME = Instant.parse("2023-01-02T12:34:56Z");
// This is a time when the imtermediate certificate in the SMD signature chain has expired. The
// SMD itself has not expired yet. It will trigger a different exception than when the SMD itself
// has expired.
private static final DateTime SMD_CERT_EXPIRED_TIME = DateTime.parse("2027-11-02T12:34:56Z");
private static final Instant SMD_CERT_EXPIRED_TIME = Instant.parse("2027-11-02T12:34:56Z");
private static final String SMD_ID = "000000851669081693741-65535";
private static final String SMD_FILE_PATH = "smd/active.smd";
private static final String ENCODED_SMD =
@@ -224,7 +228,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
DomainCreateFlowTest() {
setEppInput("domain_create.xml", ImmutableMap.of("DOMAIN", "example.tld"));
clock.setTo(DateTime.parse("1999-04-03T22:00:00.0Z").minus(Duration.millis(2)));
clock.setTo(Instant.parse("1999-04-03T22:00:00.0Z").minusMillis(2));
}
@BeforeEach
@@ -257,7 +261,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setBsaEnrollStartTime(Optional.of(clock.nowUtc().minusSeconds(1)))
.setBsaEnrollStartTimeInstant(Optional.of(clock.now().minusSeconds(1)))
.build());
}
@@ -314,16 +318,18 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
boolean isAnchorTenant = expectedBillingFlags.contains(ANCHOR_TENANT);
// Set up the creation cost.
boolean isDomainPremium = isDomainPremium(getUniqueIdFromCommand(), clock.nowUtc());
boolean isDomainPremium = isDomainPremium(getUniqueIdFromCommand(), clock.now());
Money eapFee =
Money.of(
Tld.get(domainTld).getCurrency(),
Tld.get(domainTld).getEapFeeFor(clock.nowUtc()).getCost());
DateTime billingTime =
Tld.get(domainTld).getEapFeeFor(clock.now()).getCost());
Instant billingTime =
isAnchorTenant
? clock.nowUtc().plus(Tld.get(domainTld).getAnchorTenantAddGracePeriodLength())
: clock.nowUtc().plus(Tld.get(domainTld).getAddGracePeriodLength());
? clock
.now()
.plusMillis(Tld.get(domainTld).getAnchorTenantAddGracePeriodLength().getMillis())
: clock.now().plusMillis(Tld.get(domainTld).getAddGracePeriodLength().getMillis());
assertLastHistoryContainsResource(domain);
DomainHistory historyEntry = getHistoryEntries(domain, DomainHistory.class).get(0);
VKey<BillingRecurrence> autorenewVKey = domain.getAutorenewBillingEvent();
@@ -351,7 +357,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
.setRegistrarId("TheRegistrar")
.setCost(Money.of(USD, BigDecimal.valueOf(createCost)))
.setPeriodYears(2)
.setEventTime(clock.nowUtc())
.setEventTime(clock.now())
.setBillingTime(billingTime)
.setFlags(expectedBillingFlags)
.setDomainHistory(historyEntry)
@@ -387,7 +393,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
.setRegistrarId("TheRegistrar")
.setPeriodYears(1)
.setCost(eapFee)
.setEventTime(clock.nowUtc())
.setEventTime(clock.now())
.setBillingTime(billingTime)
.setFlags(expectedBillingFlags)
.setDomainHistory(historyEntry)
@@ -443,8 +449,8 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
LaunchNotice.create(
"370d0b7c9223372036854775807",
"tmch",
DateTime.parse("2010-08-16T09:00:00.0Z"),
DateTime.parse("2009-08-16T09:00:00.0Z")))
Instant.parse("2010-08-16T09:00:00.0Z"),
Instant.parse("2009-08-16T09:00:00.0Z")))
.and()
.hasLordnPhase(LordnPhase.CLAIMS);
}
@@ -576,11 +582,11 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
new AllocationToken.Builder()
.setTokenType(UNLIMITED_USE)
.setToken("abc123")
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().minusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 1), TokenStatus.ENDED)
.build())
.build());
clock.advanceOneMilli();
@@ -628,7 +634,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
@Test
void testFailure_generalAvailability_withEncodedSignedMark() {
createTld("tld", GENERAL_AVAILABILITY);
clock.setTo(DateTime.parse("2014-09-09T09:09:09Z"));
clock.setTo(Instant.parse("2014-09-09T09:09:09Z"));
setEppInput(
"domain_create_registration_encoded_signed_mark.xml",
ImmutableMap.of("DOMAIN", "test-validate.tld", "PHASE", "open", "SMD", ENCODED_SMD));
@@ -726,13 +732,13 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("example")
.asBuilder()
.setEapFeeSchedule(
.setEapFeeScheduleInstant(
ImmutableSortedMap.of(
START_OF_TIME,
START_INSTANT,
Money.of(USD, 0),
clock.nowUtc().minusDays(1),
minusDays(clock.now(), 1),
Money.of(USD, 100),
clock.nowUtc().plusDays(1),
plusDays(clock.now(), 1),
Money.of(USD, 0)))
.build());
assertMutatingFlow(true);
@@ -829,7 +835,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
"epp.response.resData.creData.exDate"); // Ignore expiration date; we verify it below
assertAboutDomains()
.that(reloadResourceByForeignKey())
.hasRegistrationExpirationTime(clock.nowUtc().plusYears(1));
.hasRegistrationExpirationTime(plusYears(clock.now(), 1));
assertDomainDnsRequests("example.tld");
}
@@ -843,7 +849,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
@Test
void testSuccess_claimsNotice() throws Exception {
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
clock.setTo(Instant.parse("2009-08-16T09:00:00.0Z"));
setEppInput("domain_create_claim_notice.xml");
persistHosts();
runFlowAssertResponse(loadFile("domain_create_response_claims.xml"));
@@ -864,15 +870,15 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setTldStateTransitions(
.setTldStateTransitionsInstant(
ImmutableSortedMap.of(
START_OF_TIME,
START_INSTANT,
PREDELEGATION,
DateTime.parse("1999-01-01T00:00:00Z"),
Instant.parse("1999-01-01T00:00:00Z"),
QUIET_PERIOD))
.setReservedLists(persistReservedList("res1", "example-one,RESERVED_FOR_SPECIFIC_USE"))
.build());
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
clock.setTo(Instant.parse("2009-08-16T09:00:00.0Z"));
setEppInput("domain_create_allocationtoken_claims.xml");
persistHosts();
runFlowAssertResponse(loadFile("domain_create_response_claims.xml"));
@@ -886,7 +892,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
void testSuccess_noClaimsNotice_forClaimsListName_afterClaimsPeriodEnd() throws Exception {
persistClaimsList(ImmutableMap.of("example", CLAIMS_KEY));
persistHosts();
persistResource(Tld.get("tld").asBuilder().setClaimsPeriodEnd(clock.nowUtc()).build());
persistResource(Tld.get("tld").asBuilder().setClaimsPeriodEndInstant(clock.now()).build());
runFlowAssertResponse(
loadFile("domain_create_response.xml", ImmutableMap.of("DOMAIN", "example.tld")));
assertSuccessfulCreate("tld", ImmutableSet.of());
@@ -915,7 +921,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
setEppInput("domain_create_claim_notice.xml");
persistClaimsList(ImmutableMap.of("example-one", CLAIMS_KEY));
persistHosts();
persistResource(Tld.get("tld").asBuilder().setClaimsPeriodEnd(clock.nowUtc()).build());
persistResource(Tld.get("tld").asBuilder().setClaimsPeriodEndInstant(clock.now()).build());
EppException thrown = assertThrows(ClaimsPeriodEndedException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@@ -974,8 +980,8 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setCreateBillingCostTransitions(
ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
.setCreateBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 20)))
.build());
persistHosts();
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
@@ -988,7 +994,8 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setCreateBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 8)))
.setCreateBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 8)))
.build());
// Expects fee of $24
setEppInput("domain_create_fee.xml", FEE_STD_1_0_MAP);
@@ -1003,8 +1010,8 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setCreateBillingCostTransitions(
ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 100)))
.setCreateBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 100)))
.build());
// Expects fee of $24
setEppInput("domain_create_fee.xml", FEE_STD_1_0_MAP);
@@ -1139,7 +1146,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistReservedList("anchor-with-claims", "example-one,RESERVED_FOR_ANCHOR_TENANT"))
.build());
setEppInput("domain_create_allocationtoken_claims.xml");
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
clock.setTo(Instant.parse("2009-08-16T09:00:00.0Z"));
persistHosts();
runFlowAssertResponse(loadFile("domain_create_response_claims.xml"));
assertSuccessfulCreate("tld", ImmutableSet.of(ANCHOR_TENANT), allocationToken, 0);
@@ -1189,7 +1196,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
"CREATE_TIME",
SMD_VALID_TIME.toString(),
"EXPIRATION_TIME",
SMD_VALID_TIME.plusYears(2).toString())));
plusYears(SMD_VALID_TIME, 2).toString())));
assertSuccessfulCreate("tld", ImmutableSet.of(SUNRISE, ANCHOR_TENANT), 0);
}
@@ -1207,7 +1214,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
.asBuilder()
.setReservedLists(
persistReservedList("anchor_tenants", "test-validate,RESERVED_FOR_ANCHOR_TENANT"))
.setTldStateTransitions(ImmutableSortedMap.of(START_OF_TIME, START_DATE_SUNRISE))
.setTldStateTransitionsInstant(ImmutableSortedMap.of(START_INSTANT, START_DATE_SUNRISE))
.build());
setEppInput("domain_create_anchor_tenant_signed_mark.xml", ImmutableMap.of("SMD", ENCODED_SMD));
clock.setTo(SMD_VALID_TIME);
@@ -1221,7 +1228,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
"CREATE_TIME",
SMD_VALID_TIME.toString(),
"EXPIRATION_TIME",
SMD_VALID_TIME.plusYears(2).toString())));
plusYears(SMD_VALID_TIME, 2).toString())));
assertSuccessfulCreate("tld", ImmutableSet.of(ANCHOR_TENANT, SUNRISE), allocationToken, 0);
assertDomainDnsRequests("test-validate.tld");
assertSunriseLordn();
@@ -1233,12 +1240,12 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setTldStateTransitions(
new ImmutableSortedMap.Builder<DateTime, TldState>(Ordering.natural())
.put(START_OF_TIME, PREDELEGATION)
.put(DateTime.parse("1999-01-01T00:00:00Z"), QUIET_PERIOD)
.put(DateTime.parse("1999-07-01T00:00:00Z"), START_DATE_SUNRISE)
.put(DateTime.parse("2000-01-01T00:00:00Z"), GENERAL_AVAILABILITY)
.setTldStateTransitionsInstant(
new ImmutableSortedMap.Builder<Instant, TldState>(Ordering.natural())
.put(START_INSTANT, PREDELEGATION)
.put(Instant.parse("1999-01-01T00:00:00Z"), QUIET_PERIOD)
.put(Instant.parse("1999-07-01T00:00:00Z"), START_DATE_SUNRISE)
.put(Instant.parse("2000-01-01T00:00:00Z"), GENERAL_AVAILABILITY)
.build())
.build());
// The anchor tenant is created during the quiet period, on 1999-04-03.
@@ -1276,7 +1283,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setTldStateTransitions(ImmutableSortedMap.of(START_OF_TIME, QUIET_PERIOD))
.setTldStateTransitionsInstant(ImmutableSortedMap.of(START_INSTANT, QUIET_PERIOD))
.build());
allocationToken =
persistResource(
@@ -1319,11 +1326,11 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
.setToken("abc123")
.setTokenType(UNLIMITED_USE)
.setDiscountFraction(0.5)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().plusMillis(1), TokenStatus.VALID)
.put(clock.nowUtc().plusSeconds(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(clock.now().plusMillis(1), TokenStatus.VALID)
.put(clock.now().plusSeconds(1), TokenStatus.ENDED)
.build())
.build());
clock.advanceOneMilli();
@@ -1363,11 +1370,11 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
.setDiscountFraction(discountFraction)
.setDiscountYears(discountYears)
.setDiscountPremiums(discountPremiums)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().plusMillis(1), TokenStatus.VALID)
.put(clock.nowUtc().plusSeconds(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(clock.now().plusMillis(1), TokenStatus.VALID)
.put(clock.now().plusSeconds(1), TokenStatus.ENDED)
.build())
.build());
clock.advanceOneMilli();
@@ -1400,11 +1407,11 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
.setDiscountFraction(0.98)
.setDiscountYears(2)
.setDiscountPremiums(true)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().plusMillis(1), TokenStatus.VALID)
.put(clock.nowUtc().plusSeconds(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(clock.now().plusMillis(1), TokenStatus.VALID)
.put(clock.now().plusSeconds(1), TokenStatus.ENDED)
.build())
.build());
clock.advanceOneMilli();
@@ -1439,11 +1446,11 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
.setDomainName("rich.example")
.setDiscountFraction(0.95555)
.setDiscountPremiums(true)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().plusMillis(1), TokenStatus.VALID)
.put(clock.nowUtc().plusSeconds(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(clock.now().plusMillis(1), TokenStatus.VALID)
.put(clock.now().plusSeconds(1), TokenStatus.ENDED)
.build())
.build());
clock.advanceOneMilli();
@@ -1496,11 +1503,11 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
.setToken("abc123")
.setTokenType(UNLIMITED_USE)
.setDiscountFraction(0.5)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().plusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(60), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(plusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 60), TokenStatus.ENDED)
.build())
.build());
setEppInput(
@@ -1520,11 +1527,11 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
.setTokenType(UNLIMITED_USE)
.setAllowedRegistrarIds(ImmutableSet.of("someClientId"))
.setDiscountFraction(0.5)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().minusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 1), TokenStatus.ENDED)
.build())
.build());
setEppInput(
@@ -1607,11 +1614,11 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
setupDefaultTokenWithDiscount()
.asBuilder()
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().minusDays(2), TokenStatus.VALID)
.put(clock.nowUtc().minusDays(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 2), TokenStatus.VALID)
.put(minusDays(clock.now(), 1), TokenStatus.ENDED)
.build())
.build());
doSuccessfulTest();
@@ -1672,7 +1679,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setTldStateTransitions(ImmutableSortedMap.of(START_OF_TIME, START_DATE_SUNRISE))
.setTldStateTransitionsInstant(ImmutableSortedMap.of(START_INSTANT, START_DATE_SUNRISE))
.build());
clock.setTo(SMD_VALID_TIME);
setEppInput(
@@ -1688,7 +1695,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
"CREATE_TIME",
SMD_VALID_TIME.toString(),
"EXPIRATION_TIME",
SMD_VALID_TIME.plusYears(2).toString())));
plusYears(SMD_VALID_TIME, 2).toString())));
assertSunriseLordn();
@@ -1735,7 +1742,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
.setResponseData(
ImmutableList.of(
DomainPendingActionNotificationResponse.create(
domain.getDomainName(), true, historyEntry.getTrid(), clock.nowUtc())))
domain.getDomainName(), true, historyEntry.getTrid(), clock.now())))
.setId(1L)
.build());
}
@@ -1913,7 +1920,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
@Test
void testFailure_expiredClaim() {
clock.setTo(DateTime.parse("2010-08-17T09:00:00.0Z"));
clock.setTo(Instant.parse("2010-08-17T09:00:00.0Z"));
setEppInput("domain_create_claim_notice.xml");
persistHosts();
EppException thrown = assertThrows(ExpiredClaimException.class, this::runFlow);
@@ -1922,7 +1929,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
@Test
void testFailure_expiredAcceptance() {
clock.setTo(DateTime.parse("2009-09-16T09:00:00.0Z"));
clock.setTo(Instant.parse("2009-09-16T09:00:00.0Z"));
setEppInput("domain_create_claim_notice.xml");
persistHosts();
EppException thrown = assertThrows(AcceptedTooLongAgoException.class, this::runFlow);
@@ -1931,7 +1938,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
@Test
void testFailure_malformedTcnIdWrongLength() {
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
clock.setTo(Instant.parse("2009-08-16T09:00:00.0Z"));
setEppInput("domain_create_malformed_claim_notice1.xml");
persistHosts();
EppException thrown = assertThrows(MalformedTcnIdException.class, this::runFlow);
@@ -1940,7 +1947,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
@Test
void testFailure_malformedTcnIdBadChar() {
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
clock.setTo(Instant.parse("2009-08-16T09:00:00.0Z"));
setEppInput("domain_create_malformed_claim_notice2.xml");
persistHosts();
EppException thrown = assertThrows(MalformedTcnIdException.class, this::runFlow);
@@ -1949,7 +1956,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
@Test
void testFailure_badTcnIdChecksum() {
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
clock.setTo(Instant.parse("2009-08-16T09:00:00.0Z"));
setEppInput("domain_create_bad_checksum_claim_notice.xml");
persistHosts();
EppException thrown = assertThrows(InvalidTcnIdChecksumException.class, this::runFlow);
@@ -2045,7 +2052,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setBsaEnrollStartTime(Optional.of(clock.nowUtc().plusSeconds(1)))
.setBsaEnrollStartTimeInstant(Optional.of(clock.now().plusSeconds(1)))
.build());
persistBsaLabel("example");
persistHosts();
@@ -2111,7 +2118,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setTldStateTransitions(ImmutableSortedMap.of(START_OF_TIME, QUIET_PERIOD))
.setTldStateTransitionsInstant(ImmutableSortedMap.of(START_INSTANT, QUIET_PERIOD))
.build());
runFlow();
assertSuccessfulCreate("tld", ImmutableSet.of(), token);
@@ -2296,7 +2303,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
"CREATE_TIME",
SMD_VALID_TIME.toString(),
"EXPIRATION_TIME",
SMD_VALID_TIME.plusYears(2).toString())));
plusYears(SMD_VALID_TIME, 2).toString())));
assertSuccessfulCreate("tld", ImmutableSet.of(SUNRISE), 20.40);
assertSunriseLordn();
}
@@ -2319,7 +2326,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
"CREATE_TIME",
SMD_VALID_TIME.toString(),
"EXPIRATION_TIME",
SMD_VALID_TIME.plusYears(2).toString())));
plusYears(SMD_VALID_TIME, 2).toString())));
assertSuccessfulCreate("tld", ImmutableSet.of(SUNRISE), 20.40);
assertSunriseLordn();
}
@@ -2409,7 +2416,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
@Test
void testFailure_startDateSunriseRegistration_withClaimsNotice() {
createTld("tld", START_DATE_SUNRISE);
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
clock.setTo(Instant.parse("2009-08-16T09:00:00.0Z"));
setEppInput("domain_create_registration_start_date_sunrise_claims_notice.xml");
persistHosts();
EppException thrown =
@@ -2437,11 +2444,11 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
Tld.get("tld")
.asBuilder()
.setCurrency(JPY)
.setCreateBillingCostTransitions(
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
.setRenewBillingCostTransitions(
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
.setCreateBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
.setEapFeeScheduleInstant(ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
.setRenewBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
.setRegistryLockOrUnlockBillingCost(Money.ofMajor(JPY, 800))
.setServerStatusChangeBillingCost(Money.ofMajor(JPY, 800))
.setRestoreBillingCost(Money.ofMajor(JPY, 800))
@@ -2628,13 +2635,13 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get(tld)
.asBuilder()
.setEapFeeSchedule(
.setEapFeeScheduleInstant(
ImmutableSortedMap.of(
START_OF_TIME,
START_INSTANT,
Money.of(USD, 0),
clock.nowUtc().minusDays(1),
minusDays(clock.now(), 1),
Money.of(USD, 100),
clock.nowUtc().plusDays(1),
plusDays(clock.now(), 1),
Money.of(USD, 0)))
.build());
}
@@ -2645,13 +2652,13 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setEapFeeSchedule(
.setEapFeeScheduleInstant(
ImmutableSortedMap.of(
START_OF_TIME,
START_INSTANT,
Money.of(USD, 0),
clock.nowUtc().plusDays(1),
plusDays(clock.now(), 1),
Money.of(USD, 10),
clock.nowUtc().plusDays(2),
plusDays(clock.now(), 2),
Money.of(USD, 0)))
.build());
doSuccessfulTest("tld", "domain_create_response.xml", ImmutableMap.of("DOMAIN", "example.tld"));
@@ -2663,13 +2670,13 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setEapFeeSchedule(
.setEapFeeScheduleInstant(
ImmutableSortedMap.of(
START_OF_TIME,
START_INSTANT,
Money.of(USD, 0),
clock.nowUtc().minusDays(2),
minusDays(clock.now(), 2),
Money.of(USD, 100),
clock.nowUtc().minusDays(1),
minusDays(clock.now(), 1),
Money.of(USD, 0)))
.build());
doSuccessfulTest("tld", "domain_create_response.xml", ImmutableMap.of("DOMAIN", "example.tld"));
@@ -2804,7 +2811,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setTldStateTransitions(ImmutableSortedMap.of(START_OF_TIME, QUIET_PERIOD))
.setTldStateTransitionsInstant(ImmutableSortedMap.of(START_INSTANT, QUIET_PERIOD))
.build());
runFlow();
assertSuccessfulCreate("tld", ImmutableSet.of(), token);
@@ -2826,7 +2833,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setTldStateTransitions(ImmutableSortedMap.of(START_OF_TIME, QUIET_PERIOD))
.setTldStateTransitionsInstant(ImmutableSortedMap.of(START_INSTANT, QUIET_PERIOD))
.build());
runFlow();
assertSuccessfulCreate("tld", ImmutableSet.of(), token);
@@ -2860,7 +2867,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setTldStateTransitions(ImmutableSortedMap.of(START_OF_TIME, QUIET_PERIOD))
.setTldStateTransitionsInstant(ImmutableSortedMap.of(START_INSTANT, QUIET_PERIOD))
.build());
assertThrows(NoGeneralRegistrationsInCurrentPhaseException.class, this::runFlow);
}
@@ -2879,9 +2886,9 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setTldStateTransitions(
.setTldStateTransitionsInstant(
ImmutableSortedMap.of(
START_OF_TIME, QUIET_PERIOD, clock.nowUtc().plusYears(1), START_DATE_SUNRISE))
START_INSTANT, QUIET_PERIOD, plusYears(clock.now(), 1), START_DATE_SUNRISE))
.build());
persistHosts();
setEppInput("domain_create_allocationtoken_claims.xml");
@@ -2902,13 +2909,13 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setTldStateTransitions(
.setTldStateTransitionsInstant(
ImmutableSortedMap.of(
START_OF_TIME,
START_INSTANT,
QUIET_PERIOD,
clock.nowUtc().minusYears(1),
minusYears(clock.now(), 1),
START_DATE_SUNRISE,
clock.nowUtc().minusMonths(1),
minusMonths(clock.now(), 1),
QUIET_PERIOD))
.build());
persistHosts();
@@ -3050,13 +3057,13 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setTldStateTransitions(
.setTldStateTransitionsInstant(
ImmutableSortedMap.of(
START_OF_TIME,
START_INSTANT,
QUIET_PERIOD,
clock.nowUtc().minusYears(1),
minusYears(clock.now(), 1),
START_DATE_SUNRISE,
clock.nowUtc().minusMonths(1),
minusMonths(clock.now(), 1),
QUIET_PERIOD))
.build());
AllocationToken token =
@@ -3081,13 +3088,13 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setTldStateTransitions(
.setTldStateTransitionsInstant(
ImmutableSortedMap.of(
START_OF_TIME,
START_INSTANT,
QUIET_PERIOD,
clock.nowUtc().minusYears(1),
minusYears(clock.now(), 1),
START_DATE_SUNRISE,
clock.nowUtc().minusMonths(1),
minusMonths(clock.now(), 1),
QUIET_PERIOD))
.build());
persistResource(
@@ -3107,13 +3114,13 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setTldStateTransitions(
.setTldStateTransitionsInstant(
ImmutableSortedMap.of(
START_OF_TIME,
START_INSTANT,
QUIET_PERIOD,
clock.nowUtc().minusYears(1),
minusYears(clock.now(), 1),
START_DATE_SUNRISE,
clock.nowUtc().minusMonths(1),
minusMonths(clock.now(), 1),
QUIET_PERIOD))
.build());
persistResource(
@@ -3279,11 +3286,11 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
setupDefaultTokenWithDiscount("NewRegistrar")
.asBuilder()
.setTokenStatusTransitions(
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.of(
START_OF_TIME,
START_INSTANT,
TokenStatus.NOT_STARTED,
clock.nowUtc().plusDays(1),
plusDays(clock.now(), 1),
TokenStatus.VALID))
.build());
@@ -3305,8 +3312,8 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setCreateBillingCostTransitions(
ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
.setCreateBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 20)))
.build());
persistHosts();
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
@@ -3319,8 +3326,8 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setCreateBillingCostTransitions(
ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
.setCreateBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 20)))
.build());
persistHosts();
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
@@ -3333,8 +3340,8 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setCreateBillingCostTransitions(
ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
.setCreateBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 20)))
.build());
persistHosts();
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
@@ -3347,7 +3354,8 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setCreateBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 8)))
.setCreateBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 8)))
.build());
// Expects fee of $24
setEppInput("domain_create_fee.xml", FEE_06_MAP);
@@ -3362,7 +3370,8 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setCreateBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 8)))
.setCreateBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 8)))
.build());
// Expects fee of $24
setEppInput("domain_create_fee.xml", FEE_11_MAP);
@@ -3377,7 +3386,8 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setCreateBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 8)))
.setCreateBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 8)))
.build());
// Expects fee of $24
setEppInput("domain_create_fee.xml", FEE_12_MAP);
@@ -3518,8 +3528,8 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setCreateBillingCostTransitions(
ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 100)))
.setCreateBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 100)))
.build());
// Expects fee of $24
setEppInput("domain_create_fee.xml", FEE_06_MAP);
@@ -3534,8 +3544,8 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setCreateBillingCostTransitions(
ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 100)))
.setCreateBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 100)))
.build());
// Expects fee of $24
setEppInput("domain_create_fee.xml", FEE_11_MAP);
@@ -3550,8 +3560,8 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setCreateBillingCostTransitions(
ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 100)))
.setCreateBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 100)))
.build());
// Expects fee of $24
setEppInput("domain_create_fee.xml", FEE_12_MAP);
@@ -3868,11 +3878,11 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
.setDiscountFraction(0.98)
.setDiscountYears(2)
.setDiscountPremiums(true)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().plusMillis(1), TokenStatus.VALID)
.put(clock.nowUtc().plusSeconds(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(clock.now().plusMillis(1), TokenStatus.VALID)
.put(clock.now().plusSeconds(1), TokenStatus.ENDED)
.build())
.build());
clock.advanceOneMilli();
@@ -3937,13 +3947,13 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
Tld.get("example")
.asBuilder()
.setEapFeeSchedule(
.setEapFeeScheduleInstant(
ImmutableSortedMap.of(
START_OF_TIME,
START_INSTANT,
Money.of(USD, 0),
clock.nowUtc().minusDays(1),
minusDays(clock.now(), 1),
Money.of(USD, 100),
clock.nowUtc().plusDays(1),
plusDays(clock.now(), 1),
Money.of(USD, 0)))
.build());
assertMutatingFlow(true);
@@ -3977,11 +3987,11 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
.setDomainName("rich.example")
.setDiscountFraction(0.95555)
.setDiscountPremiums(true)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().plusMillis(1), TokenStatus.VALID)
.put(clock.nowUtc().plusSeconds(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(clock.now().plusMillis(1), TokenStatus.VALID)
.put(clock.now().plusSeconds(1), TokenStatus.ENDED)
.build())
.build());
clock.advanceOneMilli();
@@ -4008,11 +4018,11 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistResource(
setupDefaultTokenWithDiscount("NewRegistrar")
.asBuilder()
.setTokenStatusTransitions(
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.of(
START_OF_TIME,
START_INSTANT,
TokenStatus.NOT_STARTED,
clock.nowUtc().plusDays(1),
plusDays(clock.now(), 1),
TokenStatus.VALID))
.build());
@@ -51,7 +51,14 @@ import static google.registry.testing.DomainSubject.assertAboutDomains;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static google.registry.util.DateTimeUtils.START_INSTANT;
import static google.registry.util.DateTimeUtils.minusDays;
import static google.registry.util.DateTimeUtils.minusMonths;
import static google.registry.util.DateTimeUtils.minusYears;
import static google.registry.util.DateTimeUtils.plusDays;
import static google.registry.util.DateTimeUtils.plusMonths;
import static google.registry.util.DateTimeUtils.plusYears;
import static google.registry.util.DateTimeUtils.toDateTime;
import static org.joda.money.CurrencyUnit.USD;
import static org.joda.time.Duration.standardDays;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -101,10 +108,10 @@ import google.registry.model.transfer.TransferStatus;
import google.registry.testing.CloudTasksHelper.TaskMatcher;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.LogsSubject;
import java.time.Instant;
import java.util.Map;
import java.util.logging.Level;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -115,9 +122,9 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
private Domain domain;
private DomainHistory earlierHistoryEntry;
private static final DateTime TIME_BEFORE_FLOW = DateTime.parse("2000-06-06T22:00:00.0Z");
private static final DateTime A_MONTH_AGO = TIME_BEFORE_FLOW.minusMonths(1);
private static final DateTime A_MONTH_FROM_NOW = TIME_BEFORE_FLOW.plusMonths(1);
private static final Instant TIME_BEFORE_FLOW = Instant.parse("2000-06-06T22:00:00.0Z");
private static final Instant A_MONTH_AGO = minusMonths(TIME_BEFORE_FLOW, 1);
private static final Instant A_MONTH_FROM_NOW = plusMonths(TIME_BEFORE_FLOW, 1);
private static final ImmutableMap<String, String> FEE_06_MAP =
ImmutableMap.of("FEE_VERSION", "fee-0.6", "FEE_NS", "fee");
@@ -156,7 +163,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
assertMutatingFlow(true);
}
private void createReferencedEntities(DateTime expirationTime) throws Exception {
private void createReferencedEntities(Instant expirationTime) throws Exception {
domain =
persistResource(
DatabaseHelper.newDomain(getUniqueIdFromCommand())
@@ -169,7 +176,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
new DomainHistory.Builder()
.setType(DOMAIN_CREATE)
.setDomain(domain)
.setModificationTime(clock.nowUtc())
.setModificationTime(clock.now())
.setRegistrarId(domain.getCreationRegistrarId())
.build());
}
@@ -193,7 +200,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
}
private void setUpAutorenewGracePeriod() throws Exception {
createReferencedEntities(A_MONTH_AGO.plusYears(1));
createReferencedEntities(plusYears(A_MONTH_AGO, 1));
BillingRecurrence autorenewBillingEvent =
persistResource(
createAutorenewBillingEvent("TheRegistrar").setEventTime(A_MONTH_AGO).build());
@@ -209,7 +216,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
GracePeriod.createForRecurrence(
GracePeriodStatus.AUTO_RENEW,
domain.getRepoId(),
A_MONTH_AGO.plusDays(45),
plusDays(A_MONTH_AGO, 45),
"TheRegistrar",
autorenewBillingEvent.createVKey())))
.setAutorenewBillingEvent(autorenewBillingEvent.createVKey())
@@ -221,11 +228,11 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
private void assertAutorenewClosedAndCancellationCreatedFor(
BillingEvent graceBillingEvent, DomainHistory historyEntryDomainDelete) {
assertAutorenewClosedAndCancellationCreatedFor(
graceBillingEvent, historyEntryDomainDelete, clock.nowUtc());
graceBillingEvent, historyEntryDomainDelete, clock.now());
}
private void assertAutorenewClosedAndCancellationCreatedFor(
BillingEvent graceBillingEvent, DomainHistory historyEntryDomainDelete, DateTime eventTime) {
BillingEvent graceBillingEvent, DomainHistory historyEntryDomainDelete, Instant eventTime) {
assertBillingEvents(
createAutorenewBillingEvent("TheRegistrar").setRecurrenceEndTime(eventTime).build(),
graceBillingEvent,
@@ -234,7 +241,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
.setTargetId("example.tld")
.setRegistrarId("TheRegistrar")
.setEventTime(eventTime)
.setBillingTime(TIME_BEFORE_FLOW.plusDays(1))
.setBillingTime(toDateTime(plusDays(TIME_BEFORE_FLOW, 1)))
.setBillingEvent(graceBillingEvent.createVKey())
.setDomainHistory(historyEntryDomainDelete)
.build());
@@ -244,7 +251,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
// There should be no billing events (even timed to when the transfer would have expired) except
// for the now closed autorenew one.
assertBillingEvents(
createAutorenewBillingEvent(registrarId).setRecurrenceEndTime(clock.nowUtc()).build());
createAutorenewBillingEvent(registrarId).setRecurrenceEndTime(clock.now()).build());
}
private BillingEvent createBillingEvent(Reason reason, Money cost) {
@@ -254,8 +261,8 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
.setRegistrarId("TheRegistrar")
.setCost(cost)
.setPeriodYears(2)
.setEventTime(TIME_BEFORE_FLOW.minusDays(4))
.setBillingTime(TIME_BEFORE_FLOW.plusDays(1))
.setEventTime(minusDays(TIME_BEFORE_FLOW, 4))
.setBillingTime(toDateTime(plusDays(TIME_BEFORE_FLOW, 1)))
.setDomainHistory(earlierHistoryEntry)
.build();
}
@@ -298,7 +305,6 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
setUpSuccessfulTest();
clock.advanceOneMilli();
runFlowAssertResponse(loadFile("domain_delete_response_pending.xml"));
Duration when = standardDays(3);
cloudTasksHelper.assertTasksEnqueued(
QUEUE_ASYNC_ACTIONS,
new TaskMatcher()
@@ -307,9 +313,9 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
.service("backend")
.header("content-type", "application/x-www-form-urlencoded")
.param(PARAM_RESOURCE_KEY, domain.createVKey().stringify())
.param(PARAM_REQUESTED_TIME, clock.nowUtc().toString())
.param(PARAM_RESAVE_TIMES, clock.nowUtc().plusDays(5).toString())
.scheduleTime(clock.nowUtc().plus(when)));
.param(PARAM_REQUESTED_TIME, clock.now().toString())
.param(PARAM_RESAVE_TIMES, plusDays(clock.now(), 5).toString())
.scheduleTime(clock.nowUtc().plus(standardDays(3))));
}
@Test
@@ -319,7 +325,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
GracePeriod.create(
GracePeriodStatus.ADD,
domain.getRepoId(),
TIME_BEFORE_FLOW.plusDays(1),
plusDays(TIME_BEFORE_FLOW, 1),
"TheRegistrar",
null));
dryRunFlowAssertResponse(loadFile("generic_success_response.xml"));
@@ -376,8 +382,8 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
runFlowAssertResponse(loadFile("domain_delete_response_pending.xml"));
Domain domain = reloadResourceByForeignKey();
DateTime redemptionEndTime = domain.getLastEppUpdateDateTime().plusDays(3);
Domain domainAtRedemptionTime = domain.cloneProjectedAtTime(redemptionEndTime);
Instant redemptionEndTime = plusDays(domain.getLastEppUpdateTime(), 3);
Domain domainAtRedemptionTime = domain.cloneProjectedAtInstant(redemptionEndTime);
assertAboutDomains()
.that(domainAtRedemptionTime)
.hasLastEppUpdateRegistrarId("TheRegistrar")
@@ -413,12 +419,12 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
GracePeriod.create(
GracePeriodStatus.TRANSFER,
domain.getRepoId(),
TIME_BEFORE_FLOW.plusDays(1),
plusDays(TIME_BEFORE_FLOW, 1),
"NewRegistrar",
null));
// We should see exactly one poll message, which is for the autorenew 1 month in the future.
assertPollMessages(createAutorenewPollMessage("TheRegistrar").build());
DateTime expectedExpirationTime = domain.getRegistrationExpirationDateTime().minusYears(2);
Instant expectedExpirationTime = minusYears(domain.getRegistrationExpirationTime(), 2);
clock.advanceOneMilli();
runFlowAssertResponse(loadFile(responseFilename, substitutions));
Domain resource = reloadResourceByForeignKey();
@@ -428,10 +434,11 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
.hasStatusValue(StatusValue.PENDING_DELETE)
.and()
.hasDeletionTime(
clock
.nowUtc()
.plus(Tld.get("tld").getRedemptionGracePeriodLength())
.plus(Tld.get("tld").getPendingDeleteLength()))
toDateTime(
clock
.now()
.plusMillis(Tld.get("tld").getRedemptionGracePeriodLength().getMillis())
.plusMillis(Tld.get("tld").getPendingDeleteLength().getMillis())))
.and()
.hasExactlyStatusValues(StatusValue.INACTIVE, StatusValue.PENDING_DELETE)
.and()
@@ -451,7 +458,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
GracePeriod.create(
GracePeriodStatus.REDEMPTION,
domain.getRepoId(),
clock.nowUtc().plus(Tld.get("tld").getRedemptionGracePeriodLength()),
clock.now().plusMillis(Tld.get("tld").getRedemptionGracePeriodLength().getMillis()),
"TheRegistrar",
null,
resource.getGracePeriods().iterator().next().getGracePeriodId()));
@@ -462,8 +469,9 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
// There should be a future poll message at the deletion time. The previous autorenew poll
// message should now be deleted.
assertAboutDomains().that(domain).hasDeletePollMessage();
DateTime deletionTime = domain.getDeletionDateTime();
assertThat(getPollMessages("TheRegistrar", deletionTime.minusMinutes(1))).isEmpty();
Instant deletionTime = domain.getDeletionTime();
assertThat(getPollMessages("TheRegistrar", deletionTime.minus(java.time.Duration.ofMinutes(1))))
.isEmpty();
assertThat(getPollMessages("TheRegistrar", deletionTime)).hasSize(1);
assertThat(domain.getDeletePollMessage())
.isEqualTo(getOnlyPollMessage("TheRegistrar").createVKey());
@@ -490,14 +498,15 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
persistResource(
loadByKey(reloadResourceByForeignKey().getAutorenewPollMessage())
.asBuilder()
.setEventTime(A_MONTH_FROM_NOW.minusYears(3))
.setEventTime(minusYears(A_MONTH_FROM_NOW, 3))
.build());
clock.advanceOneMilli();
runFlowAssertResponse(loadFile("domain_delete_response_pending.xml"));
// There should now be two poll messages; one for the delete of the domain (in the future), and
// another for the unacked autorenew messages.
DateTime deletionTime = reloadResourceByForeignKey().getDeletionDateTime();
assertThat(getPollMessages("TheRegistrar", deletionTime.minusMinutes(1))).hasSize(1);
Instant deletionTime = reloadResourceByForeignKey().getDeletionTime();
assertThat(getPollMessages("TheRegistrar", deletionTime.minus(java.time.Duration.ofMinutes(1))))
.hasSize(1);
assertThat(getPollMessages("TheRegistrar", deletionTime)).hasSize(2);
}
@@ -532,11 +541,11 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setRenewBillingCostTransitions(
.setRenewBillingCostTransitionsInstant(
ImmutableSortedMap.of(
START_OF_TIME,
START_INSTANT,
Money.of(USD, 11),
TIME_BEFORE_FLOW.minusDays(5),
minusDays(TIME_BEFORE_FLOW, 5),
Money.of(USD, 20)))
.build());
setUpAutorenewGracePeriod();
@@ -571,10 +580,11 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
.hasExactlyStatusValues(StatusValue.INACTIVE, StatusValue.PENDING_DELETE)
.and()
.hasDeletionTime(
clock
.nowUtc()
.plus(Tld.get("tld").getRedemptionGracePeriodLength())
.plus(Tld.get("tld").getPendingDeleteLength()))
toDateTime(
clock
.now()
.plusMillis(Tld.get("tld").getRedemptionGracePeriodLength().getMillis())
.plusMillis(Tld.get("tld").getPendingDeleteLength().getMillis())))
.and()
.hasOneHistoryEntryEachOfTypes(DOMAIN_CREATE, DOMAIN_TRANSFER_REQUEST, DOMAIN_DELETE);
// All existing grace periods should be gone, and a new REDEMPTION one should be added.
@@ -583,7 +593,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
GracePeriod.create(
GracePeriodStatus.REDEMPTION,
domain.getRepoId(),
clock.nowUtc().plus(Tld.get("tld").getRedemptionGracePeriodLength()),
clock.now().plusMillis(Tld.get("tld").getRedemptionGracePeriodLength().getMillis()),
"TheRegistrar",
null,
domain.getGracePeriods().iterator().next().getGracePeriodId()));
@@ -613,8 +623,9 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
.isEqualTo(Trid.create("transferClient-trid", "transferServer-trid"));
assertThat(panData.getActionResult()).isFalse();
// There should be a future poll message to the losing registrar at the deletion time.
DateTime deletionTime = domain.getDeletionDateTime();
assertThat(getPollMessages("TheRegistrar", deletionTime.minusMinutes(1))).isEmpty();
Instant deletionTime = domain.getDeletionTime();
assertThat(getPollMessages("TheRegistrar", deletionTime.minus(java.time.Duration.ofMinutes(1))))
.isEmpty();
assertThat(getPollMessages("TheRegistrar", deletionTime)).hasSize(1);
assertOnlyBillingEventIsClosedAutorenew("TheRegistrar");
// The domain TransferData should reflect the cancelled transfer as we expect, with
@@ -624,7 +635,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
oldTransferData
.copyConstantFieldsToBuilder()
.setTransferStatus(TransferStatus.SERVER_CANCELLED)
.setPendingTransferExpirationTime(clock.nowUtc())
.setPendingTransferExpirationTime(clock.now())
.build());
// The server-approve entities should all be deleted.
assertThat(loadByKeyIfPresent(oldTransferData.getServerApproveBillingEvent())).isEmpty();
@@ -648,7 +659,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
// Add a nameserver.
Host host = persistResource(newHost("ns1.example.tld"));
persistResource(
ForeignKeyUtils.loadResource(Domain.class, getUniqueIdFromCommand(), clock.nowUtc())
ForeignKeyUtils.loadResource(Domain.class, getUniqueIdFromCommand(), clock.now())
.get()
.asBuilder()
.setNameservers(ImmutableSet.of(host.createVKey()))
@@ -658,9 +669,9 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
DatabaseHelper.newDomain("example1.tld")
.asBuilder()
.setNameservers(ImmutableSet.of(host.createVKey()))
.setDeletionTime(START_OF_TIME)
.setDeletionTime(START_INSTANT)
.build());
DateTime eventTime = clock.nowUtc();
Instant eventTime = clock.now();
runFlowAssertResponse(loadFile("generic_success_response.xml"));
assertDomainDnsRequests("example.tld");
assertAutorenewClosedAndCancellationCreatedFor(
@@ -676,7 +687,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
newHost("ns1." + getUniqueIdFromCommand())
.asBuilder()
.setSuperordinateDomain(reloadResourceByForeignKey().createVKey())
.setDeletionTime(clock.nowUtc().minusDays(1))
.setDeletionTime(minusDays(clock.now(), 1))
.build());
clock.advanceOneMilli();
runFlowAssertResponse(loadFile("domain_delete_response_pending.xml"));
@@ -747,7 +758,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response_pending.xml"));
HistoryEntry deleteHistoryEntry = getOnlyHistoryEntryOfType(domain, DOMAIN_DELETE);
DateTime now = clock.nowUtc();
Instant now = clock.now();
assertPollMessages(
new PollMessage.OneTime.Builder()
.setRegistrarId("TheRegistrar")
@@ -764,7 +775,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
new PollMessage.OneTime.Builder()
.setRegistrarId("TheRegistrar")
.setHistoryEntry(deleteHistoryEntry)
.setEventTime(DateTime.parse("2000-07-11T22:00:00.010Z"))
.setEventTime(Instant.parse("2000-07-11T22:00:00.010Z"))
.setMsg("Deleted by registry administrator.")
.setResponseData(
ImmutableList.of(
@@ -772,7 +783,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
"example.tld",
true,
deleteHistoryEntry.getTrid(),
DateTime.parse("2000-07-11T22:00:00.010Z"))))
Instant.parse("2000-07-11T22:00:00.010Z"))))
.build());
}
@@ -888,7 +899,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
.that(reloadResourceByForeignKey())
.hasOneHistoryEntryEachOfTypes(DOMAIN_CREATE, DOMAIN_DELETE)
.and()
.hasLastEppUpdateTime(clock.nowUtc())
.hasLastEppUpdateTime(clock.now())
.and()
.hasLastEppUpdateRegistrarId("TheRegistrar");
assertAboutHistoryEntries()
@@ -928,11 +939,11 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
earlierHistoryEntry
.asBuilder()
.setType(DOMAIN_CREATE)
.setModificationTime(TIME_BEFORE_FLOW.minusDays(2))
.setModificationTime(minusDays(TIME_BEFORE_FLOW, 2))
.setDomainTransactionRecords(
ImmutableSet.of(
DomainTransactionRecord.create(
"tld", TIME_BEFORE_FLOW.plusDays(1), NET_ADDS_1_YR, 1)))
"tld", plusDays(TIME_BEFORE_FLOW, 1), NET_ADDS_1_YR, 1)))
.build());
runFlow();
DomainHistory persistedEntry = (DomainHistory) getOnlyHistoryEntryOfType(domain, DOMAIN_DELETE);
@@ -950,11 +961,11 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
earlierHistoryEntry
.asBuilder()
.setType(DOMAIN_CREATE)
.setModificationTime(TIME_BEFORE_FLOW.minusDays(4))
.setModificationTime(minusDays(TIME_BEFORE_FLOW, 4))
.setDomainTransactionRecords(
ImmutableSet.of(
DomainTransactionRecord.create(
"tld", TIME_BEFORE_FLOW.plusDays(1), NET_ADDS_1_YR, 1)))
"tld", plusDays(TIME_BEFORE_FLOW, 1), NET_ADDS_1_YR, 1)))
.build());
runFlow();
DomainHistory persistedEntry = (DomainHistory) getOnlyHistoryEntryOfType(domain, DOMAIN_DELETE);
@@ -962,7 +973,10 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
assertThat(persistedEntry.getDomainTransactionRecords())
.containsExactly(
DomainTransactionRecord.create(
"tld", clock.nowUtc().plusHours(3), DELETED_DOMAINS_NOGRACE, 1));
"tld",
clock.now().plus(java.time.Duration.ofHours(3)),
DELETED_DOMAINS_NOGRACE,
1));
}
@Test
@@ -975,12 +989,12 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
earlierHistoryEntry
.asBuilder()
.setType(DOMAIN_CREATE)
.setModificationTime(TIME_BEFORE_FLOW.minusDays(2))
.setModificationTime(minusDays(TIME_BEFORE_FLOW, 2))
.setDomainTransactionRecords(
ImmutableSet.of(
// Only add or renew records counts should be cancelled
DomainTransactionRecord.create(
"tld", TIME_BEFORE_FLOW.plusDays(1), RESTORED_DOMAINS, 1)))
"tld", plusDays(TIME_BEFORE_FLOW, 1), RESTORED_DOMAINS, 1)))
.build());
runFlow();
DomainHistory persistedEntry = (DomainHistory) getOnlyHistoryEntryOfType(domain, DOMAIN_DELETE);
@@ -988,7 +1002,10 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
assertThat(persistedEntry.getDomainTransactionRecords())
.containsExactly(
DomainTransactionRecord.create(
"tld", clock.nowUtc().plusHours(3), DELETED_DOMAINS_NOGRACE, 1));
"tld",
clock.now().plus(java.time.Duration.ofHours(3)),
DELETED_DOMAINS_NOGRACE,
1));
}
/** Verifies that if there's no add grace period, we still cancel out valid renew records */
@@ -998,16 +1015,16 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
setUpGracePeriodDurations();
clock.advanceOneMilli();
DomainTransactionRecord renewRecord =
DomainTransactionRecord.create("tld", TIME_BEFORE_FLOW.plusDays(1), NET_RENEWS_3_YR, 1);
DomainTransactionRecord.create("tld", plusDays(TIME_BEFORE_FLOW, 1), NET_RENEWS_3_YR, 1);
// We don't want to cancel non-add or renew records
DomainTransactionRecord notCancellableRecord =
DomainTransactionRecord.create("tld", TIME_BEFORE_FLOW.plusDays(1), RESTORED_DOMAINS, 5);
DomainTransactionRecord.create("tld", plusDays(TIME_BEFORE_FLOW, 1), RESTORED_DOMAINS, 5);
earlierHistoryEntry =
persistResource(
earlierHistoryEntry
.asBuilder()
.setType(DOMAIN_CREATE)
.setModificationTime(TIME_BEFORE_FLOW.minusDays(2))
.setModificationTime(minusDays(TIME_BEFORE_FLOW, 2))
.setDomainTransactionRecords(ImmutableSet.of(renewRecord, notCancellableRecord))
.build());
runFlow();
@@ -1016,7 +1033,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
assertThat(persistedEntry.getDomainTransactionRecords())
.containsExactly(
DomainTransactionRecord.create(
"tld", clock.nowUtc().plusHours(3), DELETED_DOMAINS_NOGRACE, 1),
"tld", clock.now().plus(java.time.Duration.ofHours(3)), DELETED_DOMAINS_NOGRACE, 1),
renewRecord.asBuilder().setReportAmount(-1).build());
}
@@ -1027,7 +1044,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
GracePeriod.create(
GracePeriodStatus.ADD,
domain.getRepoId(),
TIME_BEFORE_FLOW.plusDays(1),
plusDays(TIME_BEFORE_FLOW, 1),
"TheRegistrar",
null));
setUpGracePeriodDurations();
@@ -1037,7 +1054,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
// Transaction record should just be the grace period delete
assertThat(persistedEntry.getDomainTransactionRecords())
.containsExactly(
DomainTransactionRecord.create("tld", clock.nowUtc(), DELETED_DOMAINS_GRACE, 1));
DomainTransactionRecord.create("tld", clock.now(), DELETED_DOMAINS_GRACE, 1));
}
@Test
@@ -1047,7 +1064,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
GracePeriod.create(
GracePeriodStatus.ADD,
domain.getRepoId(),
TIME_BEFORE_FLOW.plusDays(1),
plusDays(TIME_BEFORE_FLOW, 1),
"TheRegistrar",
null));
setUpGracePeriodDurations();
@@ -1057,20 +1074,20 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
earlierHistoryEntry
.asBuilder()
.setType(DOMAIN_CREATE)
.setModificationTime(TIME_BEFORE_FLOW.minusDays(2))
.setModificationTime(minusDays(TIME_BEFORE_FLOW, 2))
.setDomainTransactionRecords(
ImmutableSet.of(
DomainTransactionRecord.create(
"tld", TIME_BEFORE_FLOW.plusDays(1), NET_ADDS_10_YR, 1)))
"tld", plusDays(TIME_BEFORE_FLOW, 1), NET_ADDS_10_YR, 1)))
.build());
DomainTransactionRecord existingRecord =
DomainTransactionRecord.create("tld", TIME_BEFORE_FLOW.plusDays(2), NET_ADDS_10_YR, 1);
DomainTransactionRecord.create("tld", plusDays(TIME_BEFORE_FLOW, 2), NET_ADDS_10_YR, 1);
// Create a HistoryEntry with a later modification time
persistResource(
new DomainHistory.Builder()
.setType(DOMAIN_CREATE)
.setDomain(domain)
.setModificationTime(TIME_BEFORE_FLOW.minusDays(1))
.setModificationTime(minusDays(TIME_BEFORE_FLOW, 1))
.setRegistrarId("TheRegistrar")
.setDomainTransactionRecords(ImmutableSet.of(existingRecord))
.build());
@@ -1079,7 +1096,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
// Transaction record should be the grace period delete, and the more recent cancellation record
assertThat(persistedEntry.getDomainTransactionRecords())
.containsExactly(
DomainTransactionRecord.create("tld", clock.nowUtc(), DELETED_DOMAINS_GRACE, 1),
DomainTransactionRecord.create("tld", clock.now(), DELETED_DOMAINS_GRACE, 1),
// The cancellation record is the same as the original, except with a -1 counter
existingRecord.asBuilder().setReportAmount(-1).build());
}
@@ -1099,13 +1116,13 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
.that(resource)
.hasExactlyStatusValues(StatusValue.INACTIVE, StatusValue.PENDING_DELETE)
.and()
.hasDeletionTime(clock.nowUtc().plus(standardDays(19)));
.hasDeletionTime(clock.now().plusMillis(standardDays(19).getMillis()));
assertThat(resource.getGracePeriods())
.containsExactly(
GracePeriod.create(
GracePeriodStatus.REDEMPTION,
domain.getRepoId(),
clock.nowUtc().plus(standardDays(15)),
clock.now().plusMillis(standardDays(15).getMillis()),
"TheRegistrar",
null,
resource.getGracePeriods().iterator().next().getGracePeriodId()));
@@ -1127,7 +1144,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
.that(resource)
.hasExactlyStatusValues(StatusValue.INACTIVE, StatusValue.PENDING_DELETE)
.and()
.hasDeletionTime(clock.nowUtc().plus(standardDays(4)));
.hasDeletionTime(clock.now().plusMillis(standardDays(4).getMillis()));
assertThat(resource.getGracePeriods()).isEmpty();
assertDeletionPollMessageFor(resource, "Deleted by registry administrator.");
}
@@ -1147,13 +1164,13 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
.that(resource)
.hasExactlyStatusValues(StatusValue.INACTIVE, StatusValue.PENDING_DELETE)
.and()
.hasDeletionTime(clock.nowUtc().plus(standardDays(15)));
.hasDeletionTime(clock.now().plusMillis(standardDays(15).getMillis()));
assertThat(resource.getGracePeriods())
.containsExactly(
GracePeriod.create(
GracePeriodStatus.REDEMPTION,
domain.getRepoId(),
clock.nowUtc().plus(standardDays(15)),
clock.now().plusMillis(standardDays(15).getMillis()),
"TheRegistrar",
null,
resource.getGracePeriods().iterator().next().getGracePeriodId()));
@@ -1312,11 +1329,11 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setRenewBillingCostTransitions(
.setRenewBillingCostTransitionsInstant(
ImmutableSortedMap.of(
START_OF_TIME,
START_INSTANT,
Money.of(USD, 11),
TIME_BEFORE_FLOW.minusDays(5),
minusDays(TIME_BEFORE_FLOW, 5),
Money.of(USD, 20)))
.build());
setUpAutorenewGracePeriod();
@@ -1331,11 +1348,11 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setRenewBillingCostTransitions(
.setRenewBillingCostTransitionsInstant(
ImmutableSortedMap.of(
START_OF_TIME,
START_INSTANT,
Money.of(USD, 11),
TIME_BEFORE_FLOW.minusDays(5),
minusDays(TIME_BEFORE_FLOW, 5),
Money.of(USD, 20)))
.build());
setUpAutorenewGracePeriod();
@@ -1349,11 +1366,11 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
persistResource(
Tld.get("tld")
.asBuilder()
.setRenewBillingCostTransitions(
.setRenewBillingCostTransitionsInstant(
ImmutableSortedMap.of(
START_OF_TIME,
START_INSTANT,
Money.of(USD, 11),
TIME_BEFORE_FLOW.minusDays(5),
minusDays(TIME_BEFORE_FLOW, 5),
Money.of(USD, 20)))
.build());
setUpAutorenewGracePeriod();
@@ -19,11 +19,13 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistDomainAsDeleted;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.toDateTime;
import google.registry.model.domain.Domain;
import google.registry.persistence.transaction.JpaTestExtensions;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.FakeClock;
import java.time.Instant;
import java.util.Optional;
import org.joda.time.DateTime;
import org.joda.time.Duration;
@@ -34,7 +36,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
/** Tests for {@link DomainDeletionTimeCache}. */
public class DomainDeletionTimeCacheTest {
private final FakeClock clock = new FakeClock(DateTime.parse("2025-10-01T00:00:00.000Z"));
private final FakeClock clock = new FakeClock(Instant.parse("2025-10-01T00:00:00.000Z"));
private final DomainDeletionTimeCache cache = DomainDeletionTimeCache.create();
@RegisterExtension
@@ -85,10 +87,10 @@ public class DomainDeletionTimeCacheTest {
void testCache_expires() {
Domain domain = persistActiveDomain("domain.tld");
assertThat(getDeletionTimeFromCache("domain.tld")).hasValue(END_OF_TIME);
DateTime elevenMinutesFromNow = clock.nowUtc().plusMinutes(11);
persistDomainAsDeleted(domain, elevenMinutesFromNow);
Instant elevenMinutesFromNow = clock.now().plus(java.time.Duration.ofMinutes(11));
persistDomainAsDeleted(domain, toDateTime(elevenMinutesFromNow));
clock.advanceBy(Duration.standardMinutes(30));
assertThat(getDeletionTimeFromCache("domain.tld")).hasValue(elevenMinutesFromNow);
assertThat(getDeletionTimeFromCache("domain.tld")).hasValue(toDateTime(elevenMinutesFromNow));
}
private Optional<DateTime> getDeletionTimeFromCache(String domainName) {
@@ -31,6 +31,8 @@ import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptio
import static google.registry.testing.TestDataHelper.updateSubstitutions;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static google.registry.util.DateTimeUtils.minusDays;
import static google.registry.util.DateTimeUtils.plusDays;
import static google.registry.xml.XmlTestUtils.assertXmlEquals;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.joda.money.CurrencyUnit.USD;
@@ -77,7 +79,6 @@ import java.time.Instant;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -106,7 +107,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
@BeforeEach
void setup() {
setEppInput("domain_info.xml");
clock.setTo(DateTime.parse("2005-03-03T22:00:00.000Z"));
clock.setTo(Instant.parse("2005-03-03T22:00:00.000Z"));
sessionMetadata.setRegistrarId("NewRegistrar");
createTld("tld");
persistResource(
@@ -127,10 +128,10 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
.setPersistedCurrentSponsorRegistrarId("NewRegistrar")
.setCreationRegistrarId("TheRegistrar")
.setLastEppUpdateRegistrarId("NewRegistrar")
.setCreationTimeForTest(DateTime.parse("1999-04-03T22:00:00.0Z"))
.setLastEppUpdateTime(DateTime.parse("1999-12-03T09:00:00.0Z"))
.setLastTransferTime(DateTime.parse("2000-04-08T09:00:00.0Z"))
.setRegistrationExpirationTime(DateTime.parse("2005-04-03T22:00:00.0Z"))
.setCreationTimeForTest(Instant.parse("1999-04-03T22:00:00.0Z"))
.setLastEppUpdateTime(Instant.parse("1999-12-03T09:00:00.0Z"))
.setLastTransferTime(Instant.parse("2000-04-08T09:00:00.0Z"))
.setRegistrationExpirationTime(Instant.parse("2005-04-03T22:00:00.0Z"))
.setNameservers(
inactive ? null : ImmutableSet.of(host1.createVKey(), host2.createVKey()))
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("2fooBAR")))
@@ -331,12 +332,12 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
GracePeriod.create(
gracePeriodStatus,
domain.getRepoId(),
clock.nowUtc().plusDays(1),
plusDays(clock.now(), 1),
"TheRegistrar",
null))
.setCreationRegistrarId("NewRegistrar")
.setCreationTimeForTest(DateTime.parse("2003-11-26T22:00:00.0Z"))
.setRegistrationExpirationTime(DateTime.parse("2005-11-26T22:00:00.0Z"))
.setCreationTimeForTest(Instant.parse("2003-11-26T22:00:00.0Z"))
.setRegistrationExpirationTime(Instant.parse("2005-11-26T22:00:00.0Z"))
.setLastTransferTime((Instant) null)
.setLastEppUpdateTime((Instant) null)
.setLastEppUpdateRegistrarId(null)
@@ -357,7 +358,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
new DomainHistory.Builder()
.setDomain(domain)
.setType(HistoryEntry.Type.DOMAIN_CREATE)
.setModificationTime(clock.nowUtc())
.setModificationTime(clock.now())
.setRegistrarId(domain.getCreationRegistrarId())
.build());
BillingRecurrence renewEvent =
@@ -367,7 +368,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
.setTargetId(getUniqueIdFromCommand())
.setRegistrarId("TheRegistrar")
.setEventTime(clock.nowUtc())
.setEventTime(clock.now())
.setRecurrenceEndTime(END_OF_TIME)
.setDomainHistory(historyEntry)
.build());
@@ -380,7 +381,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
GracePeriod.createForRecurrence(
GracePeriodStatus.AUTO_RENEW,
domain.getRepoId(),
clock.nowUtc().plusDays(1),
plusDays(clock.now(), 1),
"TheRegistrar",
recurrenceVKey))
.build());
@@ -399,7 +400,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
GracePeriod.create(
GracePeriodStatus.REDEMPTION,
domain.getRepoId(),
clock.nowUtc().plusDays(1),
plusDays(clock.now(), 1),
"TheRegistrar",
null))
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
@@ -418,7 +419,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
GracePeriod.create(
GracePeriodStatus.RENEW,
domain.getRepoId(),
clock.nowUtc().plusDays(1),
plusDays(clock.now(), 1),
"TheRegistrar",
null))
.build());
@@ -436,14 +437,14 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
GracePeriod.create(
GracePeriodStatus.RENEW,
domain.getRepoId(),
clock.nowUtc().plusDays(1),
plusDays(clock.now(), 1),
"TheRegistrar",
null))
.addGracePeriod(
GracePeriod.create(
GracePeriodStatus.RENEW,
domain.getRepoId(),
clock.nowUtc().plusDays(2),
plusDays(clock.now(), 2),
"TheRegistrar",
null))
.build());
@@ -461,7 +462,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
GracePeriod.create(
GracePeriodStatus.TRANSFER,
domain.getRepoId(),
clock.nowUtc().plusDays(1),
plusDays(clock.now(), 1),
"TheRegistrar",
null))
.build());
@@ -489,14 +490,14 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
GracePeriod.create(
GracePeriodStatus.ADD,
domain.getRepoId(),
clock.nowUtc().plusDays(1),
plusDays(clock.now(), 1),
"TheRegistrar",
null))
.addGracePeriod(
GracePeriod.create(
GracePeriodStatus.RENEW,
domain.getRepoId(),
clock.nowUtc().plusDays(2),
plusDays(clock.now(), 2),
"TheRegistrar",
null))
.build());
@@ -514,7 +515,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
GracePeriod.create(
GracePeriodStatus.ADD,
domain.getRepoId(),
clock.nowUtc().plusDays(1),
plusDays(clock.now(), 1),
"TheRegistrar",
null))
.setDsData(
@@ -536,7 +537,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
persistResource(
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setDeletionTime(clock.nowUtc().minusDays(1))
.setDeletionTime(minusDays(clock.now(), 1))
.build());
ResourceDoesNotExistException thrown =
assertThrows(ResourceDoesNotExistException.class, this::runFlow);
@@ -588,7 +589,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
new AllocationToken.Builder()
.setToken("abc123")
.setTokenType(TokenType.BULK_PRICING)
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
.setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z"))
.setAllowedTlds(ImmutableSet.of("foo"))
.setAllowedRegistrarIds(ImmutableSet.of("NewRegistrar"))
.setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED)
@@ -610,7 +611,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
new AllocationToken.Builder()
.setToken("abc123")
.setTokenType(TokenType.BULK_PRICING)
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
.setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z"))
.setAllowedTlds(ImmutableSet.of("foo"))
.setAllowedRegistrarIds(ImmutableSet.of("NewRegistrar"))
.setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED)
@@ -644,7 +645,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
new AllocationToken.Builder()
.setToken("abc123")
.setTokenType(TokenType.BULK_PRICING)
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
.setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z"))
.setAllowedTlds(ImmutableSet.of("foo"))
.setAllowedRegistrarIds(ImmutableSet.of("NewRegistrar"))
.setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED)
@@ -673,8 +674,8 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
persistResource(
domain
.asBuilder()
.setDeletionTime(clock.nowUtc().plusDays(25))
.setRegistrationExpirationTime(clock.nowUtc().minusDays(1))
.setDeletionTime(plusDays(clock.now(), 25))
.setRegistrationExpirationTime(minusDays(clock.now(), 1))
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
.build());
doSuccessfulTest(
@@ -762,7 +763,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
persistResource(
domain
.asBuilder()
.setDeletionTime(clock.nowUtc().plusDays(25))
.setDeletionTime(plusDays(clock.now(), 25))
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
.build());
doSuccessfulTest(
@@ -27,7 +27,7 @@ import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.persistPremiumList;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static google.registry.util.DateTimeUtils.START_INSTANT;
import static org.joda.money.CurrencyUnit.USD;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -56,9 +56,10 @@ import google.registry.testing.FakeClock;
import google.registry.testing.FakeHttpSession;
import google.registry.util.Clock;
import java.math.BigDecimal;
import java.time.Duration;
import java.time.Instant;
import java.util.Optional;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -72,7 +73,7 @@ public class DomainPricingLogicTest {
final JpaIntegrationTestExtension jpa =
new JpaTestExtensions.Builder().buildIntegrationTestExtension();
Clock clock = new FakeClock(DateTime.parse("2023-05-13T00:00:00.000Z"));
Clock clock = new FakeClock(Instant.parse("2023-05-13T00:00:00.000Z"));
@Mock EppInput eppInput;
SessionMetadata sessionMetadata;
Tld tld;
@@ -88,9 +89,9 @@ public class DomainPricingLogicTest {
persistResource(
Tld.get("example")
.asBuilder()
.setRenewBillingCostTransitions(
.setRenewBillingCostTransitionsInstant(
ImmutableSortedMap.of(
START_OF_TIME, Money.of(USD, 1), clock.nowUtc(), Money.of(USD, 10)))
START_INSTANT, Money.of(USD, 1), clock.now(), Money.of(USD, 10)))
.setPremiumList(persistPremiumList("tld2", USD, "premium,USD 100"))
.build());
}
@@ -102,14 +103,14 @@ public class DomainPricingLogicTest {
persistResource(
DatabaseHelper.newDomain(domainName)
.asBuilder()
.setCreationTimeForTest(DateTime.parse("1999-01-05T00:00:00Z"))
.setCreationTimeForTest(Instant.parse("1999-01-05T00:00:00Z"))
.build());
DomainHistory historyEntry =
persistResource(
new DomainHistory.Builder()
.setRegistrarId(domain.getCreationRegistrarId())
.setType(DOMAIN_CREATE)
.setModificationTime(DateTime.parse("1999-01-05T00:00:00Z"))
.setModificationTime(Instant.parse("1999-01-05T00:00:00Z"))
.setDomain(domain)
.build());
BillingRecurrence billingRecurrence =
@@ -117,7 +118,7 @@ public class DomainPricingLogicTest {
new BillingRecurrence.Builder()
.setDomainHistory(historyEntry)
.setRegistrarId(domain.getCreationRegistrarId())
.setEventTime(DateTime.parse("1999-01-05T00:00:00Z"))
.setEventTime(Instant.parse("1999-01-05T00:00:00Z"))
.setFlags(ImmutableSet.of(AUTO_RENEW))
.setId(2L)
.setReason(Reason.RENEW)
@@ -133,16 +134,19 @@ public class DomainPricingLogicTest {
@Test
void testGetDomainCreatePrice_sunrise_appliesDiscount() throws EppException {
ImmutableSortedMap<DateTime, TldState> transitions =
ImmutableSortedMap.<DateTime, TldState>naturalOrder()
.put(START_OF_TIME, TldState.PREDELEGATION)
.put(clock.nowUtc().minusHours(1), TldState.START_DATE_SUNRISE)
.put(clock.nowUtc().plusHours(1), TldState.GENERAL_AVAILABILITY)
ImmutableSortedMap<Instant, TldState> transitions =
ImmutableSortedMap.<Instant, TldState>naturalOrder()
.put(START_INSTANT, TldState.PREDELEGATION)
.put(clock.now().minus(Duration.ofHours(1)), TldState.START_DATE_SUNRISE)
.put(clock.now().plus(Duration.ofHours(1)), TldState.GENERAL_AVAILABILITY)
.build();
Tld sunriseTld = createTld("sunrise", transitions);
createTld("sunrise");
Tld sunriseTld =
persistResource(
Tld.get("sunrise").asBuilder().setTldStateTransitionsInstant(transitions).build());
assertThat(
domainPricingLogic.getCreatePrice(
sunriseTld, "domain.sunrise", clock.nowUtc(), 2, false, true, Optional.empty()))
sunriseTld, "domain.sunrise", clock.now(), 2, false, true, Optional.empty()))
.isEqualTo(
new FeesAndCredits.Builder()
.setCurrency(USD)
@@ -166,13 +170,7 @@ public class DomainPricingLogicTest {
.build());
assertThat(
domainPricingLogic.getCreatePrice(
tld,
"default.example",
clock.nowUtc(),
1,
false,
false,
Optional.of(allocationToken)))
tld, "default.example", clock.now(), 1, false, false, Optional.of(allocationToken)))
.isEqualTo(
new FeesAndCredits.Builder()
.setCurrency(USD)
@@ -197,13 +195,7 @@ public class DomainPricingLogicTest {
// 3 year create should be 5 (discount price) + 10*2 (regular price) = 25.
assertThat(
domainPricingLogic.getCreatePrice(
tld,
"default.example",
clock.nowUtc(),
3,
false,
false,
Optional.of(allocationToken)))
tld, "default.example", clock.now(), 3, false, false, Optional.of(allocationToken)))
.isEqualTo(
new FeesAndCredits.Builder()
.setCurrency(USD)
@@ -216,7 +208,7 @@ public class DomainPricingLogicTest {
throws EppException {
assertThat(
domainPricingLogic.getRenewPrice(
tld, "standard.example", clock.nowUtc(), 1, null, Optional.empty()))
tld, "standard.example", clock.now(), 1, null, Optional.empty()))
.isEqualTo(
new FeesAndCredits.Builder()
.setCurrency(USD)
@@ -229,7 +221,7 @@ public class DomainPricingLogicTest {
throws EppException {
assertThat(
domainPricingLogic.getRenewPrice(
tld, "standard.example", clock.nowUtc(), 5, null, Optional.empty()))
tld, "standard.example", clock.now(), 5, null, Optional.empty()))
.isEqualTo(
new FeesAndCredits.Builder()
.setCurrency(USD)
@@ -242,7 +234,7 @@ public class DomainPricingLogicTest {
throws EppException {
assertThat(
domainPricingLogic.getRenewPrice(
tld, "premium.example", clock.nowUtc(), 1, null, Optional.empty()))
tld, "premium.example", clock.now(), 1, null, Optional.empty()))
.isEqualTo(
new FeesAndCredits.Builder()
.setCurrency(USD)
@@ -255,7 +247,7 @@ public class DomainPricingLogicTest {
throws EppException {
assertThat(
domainPricingLogic.getRenewPrice(
tld, "premium.example", clock.nowUtc(), 5, null, Optional.empty()))
tld, "premium.example", clock.now(), 5, null, Optional.empty()))
.isEqualTo(
new FeesAndCredits.Builder()
.setCurrency(USD)
@@ -269,7 +261,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"premium.example",
clock.nowUtc(),
clock.now(),
1,
persistDomainAndSetRecurrence("premium.example", DEFAULT, Optional.empty()),
Optional.empty()))
@@ -295,7 +287,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"premium.example",
clock.nowUtc(),
clock.now(),
1,
persistDomainAndSetRecurrence("premium.example", DEFAULT, Optional.empty()),
Optional.of(allocationToken)))
@@ -312,7 +304,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"premium.example",
clock.nowUtc(),
clock.now(),
5,
persistDomainAndSetRecurrence("premium.example", DEFAULT, Optional.empty()),
Optional.empty()))
@@ -339,7 +331,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"premium.example",
clock.nowUtc(),
clock.now(),
5,
persistDomainAndSetRecurrence("premium.example", DEFAULT, Optional.empty()),
Optional.of(allocationToken)))
@@ -357,7 +349,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"standard.example",
clock.nowUtc(),
clock.now(),
1,
persistDomainAndSetRecurrence("standard.example", DEFAULT, Optional.empty()),
Optional.empty()))
@@ -383,7 +375,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"standard.example",
clock.nowUtc(),
clock.now(),
1,
persistDomainAndSetRecurrence("standard.example", DEFAULT, Optional.empty()),
Optional.of(allocationToken)))
@@ -410,7 +402,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"standard.example",
clock.nowUtc(),
clock.now(),
1,
persistDomainAndSetRecurrence("standard.example", DEFAULT, Optional.empty()),
Optional.of(allocationToken)))
@@ -428,7 +420,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"standard.example",
clock.nowUtc(),
clock.now(),
5,
persistDomainAndSetRecurrence("standard.example", DEFAULT, Optional.empty()),
Optional.empty()))
@@ -455,7 +447,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"standard.example",
clock.nowUtc(),
clock.now(),
5,
persistDomainAndSetRecurrence("standard.example", DEFAULT, Optional.empty()),
Optional.of(allocationToken)))
@@ -485,7 +477,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"standard.example",
clock.nowUtc(),
clock.now(),
5,
persistDomainAndSetRecurrence("standard.example", DEFAULT, Optional.empty()),
Optional.of(allocationToken)))
@@ -503,7 +495,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"premium.example",
clock.nowUtc(),
clock.now(),
1,
persistDomainAndSetRecurrence("premium.example", NONPREMIUM, Optional.empty()),
Optional.empty()))
@@ -530,7 +522,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"premium.example",
clock.nowUtc(),
clock.now(),
1,
persistDomainAndSetRecurrence("premium.example", NONPREMIUM, Optional.empty()),
Optional.of(allocationToken)))
@@ -548,7 +540,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"premium.example",
clock.nowUtc(),
clock.now(),
5,
persistDomainAndSetRecurrence("premium.example", NONPREMIUM, Optional.empty()),
Optional.empty()))
@@ -576,7 +568,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"premium.example",
clock.nowUtc(),
clock.now(),
5,
persistDomainAndSetRecurrence("premium.example", NONPREMIUM, Optional.empty()),
Optional.of(allocationToken)))
@@ -594,7 +586,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"standard.example",
clock.nowUtc(),
clock.now(),
1,
persistDomainAndSetRecurrence("standard.example", NONPREMIUM, Optional.empty()),
Optional.empty()))
@@ -612,7 +604,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"standard.example",
clock.nowUtc(),
clock.now(),
5,
persistDomainAndSetRecurrence("standard.example", NONPREMIUM, Optional.empty()),
Optional.empty()))
@@ -630,7 +622,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"standard.example",
clock.nowUtc(),
clock.now(),
1,
persistDomainAndSetRecurrence(
"standard.example", SPECIFIED, Optional.of(Money.of(USD, 1))),
@@ -658,7 +650,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"standard.example",
clock.nowUtc(),
clock.now(),
1,
persistDomainAndSetRecurrence(
"standard.example", SPECIFIED, Optional.of(Money.of(USD, 1))),
@@ -688,7 +680,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"standard.example",
clock.nowUtc(),
clock.now(),
1,
persistDomainAndSetRecurrence(
"standard.example", SPECIFIED, Optional.of(Money.of(USD, 1))),
@@ -719,7 +711,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"standard.example",
clock.nowUtc(),
clock.now(),
1,
persistDomainAndSetRecurrence(
"standard.example", SPECIFIED, Optional.of(Money.of(USD, 1))),
@@ -744,7 +736,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"standard.example",
clock.nowUtc(),
clock.now(),
5,
persistDomainAndSetRecurrence(
"standard.example", SPECIFIED, Optional.of(Money.of(USD, 1))),
@@ -772,7 +764,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"standard.example",
clock.nowUtc(),
clock.now(),
5,
persistDomainAndSetRecurrence(
"standard.example", SPECIFIED, Optional.of(Money.of(USD, 1))),
@@ -800,7 +792,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"standard.example",
clock.nowUtc(),
clock.now(),
5,
persistDomainAndSetRecurrence(
"standard.example", SPECIFIED, Optional.of(Money.of(USD, 1))),
@@ -819,7 +811,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"premium.example",
clock.nowUtc(),
clock.now(),
1,
persistDomainAndSetRecurrence(
"premium.example", SPECIFIED, Optional.of(Money.of(USD, 17))),
@@ -838,7 +830,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"premium.example",
clock.nowUtc(),
clock.now(),
5,
persistDomainAndSetRecurrence(
"premium.example", SPECIFIED, Optional.of(Money.of(USD, 17))),
@@ -857,14 +849,14 @@ public class DomainPricingLogicTest {
IllegalArgumentException.class,
() ->
domainPricingLogic.getRenewPrice(
tld, "standard.example", clock.nowUtc(), -1, null, Optional.empty()));
tld, "standard.example", clock.now(), -1, null, Optional.empty()));
assertThat(thrown).hasMessageThat().isEqualTo("Number of years must be positive");
}
@Test
void testGetDomainTransferPrice_standardDomain_default_noBilling_defaultRenewalPrice()
throws EppException {
assertThat(domainPricingLogic.getTransferPrice(tld, "standard.example", clock.nowUtc(), null))
assertThat(domainPricingLogic.getTransferPrice(tld, "standard.example", clock.now(), null))
.isEqualTo(
new FeesAndCredits.Builder()
.setCurrency(USD)
@@ -875,7 +867,7 @@ public class DomainPricingLogicTest {
@Test
void testGetDomainTransferPrice_premiumDomain_default_noBilling_premiumRenewalPrice()
throws EppException {
assertThat(domainPricingLogic.getTransferPrice(tld, "premium.example", clock.nowUtc(), null))
assertThat(domainPricingLogic.getTransferPrice(tld, "premium.example", clock.now(), null))
.isEqualTo(
new FeesAndCredits.Builder()
.setCurrency(USD)
@@ -889,7 +881,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getTransferPrice(
tld,
"standard.example",
clock.nowUtc(),
clock.now(),
persistDomainAndSetRecurrence("standard.example", DEFAULT, Optional.empty())))
.isEqualTo(
new FeesAndCredits.Builder()
@@ -904,7 +896,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getTransferPrice(
tld,
"premium.example",
clock.nowUtc(),
clock.now(),
persistDomainAndSetRecurrence("premium.example", DEFAULT, Optional.empty())))
.isEqualTo(
new FeesAndCredits.Builder()
@@ -920,7 +912,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getTransferPrice(
tld,
"standard.example",
clock.nowUtc(),
clock.now(),
persistDomainAndSetRecurrence("standard.example", NONPREMIUM, Optional.empty())))
.isEqualTo(
new FeesAndCredits.Builder()
@@ -936,7 +928,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getTransferPrice(
tld,
"premium.example",
clock.nowUtc(),
clock.now(),
persistDomainAndSetRecurrence("premium.example", NONPREMIUM, Optional.empty())))
.isEqualTo(
new FeesAndCredits.Builder()
@@ -952,7 +944,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getTransferPrice(
tld,
"standard.example",
clock.nowUtc(),
clock.now(),
persistDomainAndSetRecurrence(
"standard.example", SPECIFIED, Optional.of(Money.of(USD, 1.23)))))
.isEqualTo(
@@ -969,7 +961,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getTransferPrice(
tld,
"premium.example",
clock.nowUtc(),
clock.now(),
persistDomainAndSetRecurrence(
"premium.example", SPECIFIED, Optional.of(Money.of(USD, 1.23)))))
.isEqualTo(
@@ -991,13 +983,7 @@ public class DomainPricingLogicTest {
.build());
assertThat(
domainPricingLogic.getCreatePrice(
tld,
"premium.example",
clock.nowUtc(),
1,
false,
false,
Optional.of(allocationToken)))
tld, "premium.example", clock.now(), 1, false, false, Optional.of(allocationToken)))
.isEqualTo(
new FeesAndCredits.Builder()
.setCurrency(USD)
@@ -1006,13 +992,7 @@ public class DomainPricingLogicTest {
// Two-year create should be 13 (standard price) + 100 (premium price), and it's premium
assertThat(
domainPricingLogic.getCreatePrice(
tld,
"premium.example",
clock.nowUtc(),
2,
false,
false,
Optional.of(allocationToken)))
tld, "premium.example", clock.now(), 2, false, false, Optional.of(allocationToken)))
.isEqualTo(
new FeesAndCredits.Builder()
.setCurrency(USD)
@@ -1022,7 +1002,7 @@ public class DomainPricingLogicTest {
domainPricingLogic.getRenewPrice(
tld,
"premium.example",
clock.nowUtc(),
clock.now(),
1,
persistDomainAndSetRecurrence("premium.example", DEFAULT, Optional.empty()),
Optional.of(allocationToken)))
@@ -1048,13 +1028,7 @@ public class DomainPricingLogicTest {
// are standard
assertThat(
domainPricingLogic.getCreatePrice(
tld,
"premium.example",
clock.nowUtc(),
2,
false,
false,
Optional.of(allocationToken)))
tld, "premium.example", clock.now(), 2, false, false, Optional.of(allocationToken)))
.isEqualTo(
new FeesAndCredits.Builder()
.setCurrency(USD)
@@ -1063,13 +1037,7 @@ public class DomainPricingLogicTest {
// Similarly, 3 years should be 13 + 10 + 10
assertThat(
domainPricingLogic.getCreatePrice(
tld,
"premium.example",
clock.nowUtc(),
3,
false,
false,
Optional.of(allocationToken)))
tld, "premium.example", clock.now(), 3, false, false, Optional.of(allocationToken)))
.isEqualTo(
new FeesAndCredits.Builder()
.setCurrency(USD)
@@ -1090,13 +1058,7 @@ public class DomainPricingLogicTest {
// Two-year create should be 100 (premium 1st year) plus 10 (nonpremium 2nd year)
assertThat(
domainPricingLogic.getCreatePrice(
tld,
"premium.example",
clock.nowUtc(),
2,
false,
false,
Optional.of(allocationToken)))
tld, "premium.example", clock.now(), 2, false, false, Optional.of(allocationToken)))
.isEqualTo(
new FeesAndCredits.Builder()
.setCurrency(USD)
@@ -1105,13 +1067,7 @@ public class DomainPricingLogicTest {
// Similarly, 3 years should be 100 + 10 + 10
assertThat(
domainPricingLogic.getCreatePrice(
tld,
"premium.example",
clock.nowUtc(),
3,
false,
false,
Optional.of(allocationToken)))
tld, "premium.example", clock.now(), 3, false, false, Optional.of(allocationToken)))
.isEqualTo(
new FeesAndCredits.Builder()
.setCurrency(USD)
@@ -1133,7 +1089,7 @@ public class DomainPricingLogicTest {
assertThat(
domainPricingLogic
.getRenewPrice(
tld, "premium.example", clock.nowUtc(), 1, null, Optional.of(allocationToken))
tld, "premium.example", clock.now(), 1, null, Optional.of(allocationToken))
.getRenewCost())
.isEqualTo(Money.of(USD, 5));
}
@@ -40,7 +40,13 @@ import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptio
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
import static google.registry.testing.TestDataHelper.updateSubstitutions;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_INSTANT;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static google.registry.util.DateTimeUtils.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.EUR;
import static org.joda.money.CurrencyUnit.JPY;
import static org.joda.money.CurrencyUnit.USD;
@@ -100,10 +106,10 @@ import google.registry.model.reporting.HistoryEntry.HistoryEntryId;
import google.registry.model.tld.Tld;
import google.registry.persistence.VKey;
import google.registry.testing.DatabaseHelper;
import java.time.Instant;
import java.util.Map;
import javax.annotation.Nullable;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -128,7 +134,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
private static final ImmutableMap<String, String> FEE_STD_1_0_MAP =
updateSubstitutions(FEE_BASE_MAP, "FEE_VERSION", "epp:fee-1.0", "FEE_NS", "fee1_00");
private final DateTime expirationTime = DateTime.parse("2000-04-03T22:00:00.0Z");
private final Instant expirationTime = Instant.parse("2000-04-03T22:00:00.0Z");
@BeforeEach
void initDomainTest() {
@@ -157,7 +163,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
new DomainHistory.Builder()
.setDomain(domain)
.setType(HistoryEntry.Type.DOMAIN_CREATE)
.setModificationTime(clock.nowUtc())
.setModificationTime(clock.now())
.setRegistrarId(domain.getCreationRegistrarId())
.build();
BillingRecurrence autorenewEvent =
@@ -247,8 +253,8 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
@Nullable Money renewalPrice)
throws Exception {
assertMutatingFlow(true);
DateTime currentExpiration = reloadResourceByForeignKey().getRegistrationExpirationDateTime();
DateTime newExpiration = currentExpiration.plusYears(renewalYears);
Instant currentExpiration = reloadResourceByForeignKey().getRegistrationExpirationTime();
Instant newExpiration = plusYears(currentExpiration, renewalYears);
runFlowAssertResponse(
CommitMode.LIVE, userPrivileges, loadFile(responseFilename, substitutions));
Domain domain = reloadResourceByForeignKey();
@@ -256,17 +262,17 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
DomainHistory historyEntryDomainRenew =
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RENEW, DomainHistory.class);
assertThat(loadByKey(domain.getAutorenewBillingEvent()).getEventTime())
.isEqualTo(newExpiration);
.isEqualTo(toDateTime(newExpiration));
assertAboutDomains()
.that(domain)
.isActiveAt(clock.nowUtc())
.isActiveAt(clock.now())
.and()
.hasRegistrationExpirationTime(newExpiration)
.and()
.hasOneHistoryEntryEachOfTypes(
HistoryEntry.Type.DOMAIN_CREATE, HistoryEntry.Type.DOMAIN_RENEW)
.and()
.hasLastEppUpdateTime(clock.nowUtc())
.hasLastEppUpdateTime(clock.now())
.and()
.hasLastEppUpdateRegistrarId(renewalClientId);
assertAboutHistoryEntries().that(historyEntryDomainRenew).hasPeriodYears(renewalYears);
@@ -277,8 +283,10 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
.setRegistrarId(renewalClientId)
.setCost(totalRenewCost)
.setPeriodYears(renewalYears)
.setEventTime(clock.nowUtc())
.setBillingTime(clock.nowUtc().plus(Tld.get("tld").getRenewGracePeriodLength()))
.setEventTime(clock.now())
.setBillingTime(
toDateTime(
clock.now().plusMillis(Tld.get("tld").getRenewGracePeriodLength().getMillis())))
.setDomainHistory(historyEntryDomainRenew)
.build();
assertBillingEvents(
@@ -291,7 +299,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
.setTargetId(getUniqueIdFromCommand())
.setRegistrarId("TheRegistrar")
.setEventTime(expirationTime)
.setRecurrenceEndTime(clock.nowUtc())
.setRecurrenceEndTime(clock.now())
.setDomainHistory(
getOnlyHistoryEntryOfType(
domain, HistoryEntry.Type.DOMAIN_CREATE, DomainHistory.class))
@@ -324,7 +332,8 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
GracePeriod.create(
GracePeriodStatus.RENEW,
domain.getRepoId(),
clock.nowUtc().plus(Tld.get("tld").getRenewGracePeriodLength()),
toDateTime(
clock.now().plusMillis(Tld.get("tld").getRenewGracePeriodLength().getMillis())),
renewalClientId,
null),
renewBillingEvent));
@@ -659,11 +668,11 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
.setToken("abc123")
.setTokenType(UNLIMITED_USE)
.setDiscountFraction(0.5)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().plusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(60), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(plusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 60), TokenStatus.ENDED)
.build())
.build());
assertAboutEppExceptions()
@@ -683,11 +692,11 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
.setTokenType(UNLIMITED_USE)
.setAllowedRegistrarIds(ImmutableSet.of("someClientId"))
.setDiscountFraction(0.5)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().minusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 1), TokenStatus.ENDED)
.build())
.build());
assertAboutEppExceptions()
@@ -708,11 +717,11 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
.setTokenType(UNLIMITED_USE)
.setAllowedTlds(ImmutableSet.of("example"))
.setDiscountFraction(0.5)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().minusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 1), TokenStatus.ENDED)
.build())
.build());
runFlowAssertResponse(
@@ -795,7 +804,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
persistResource(
loadByKey(reloadResourceByForeignKey().getAutorenewPollMessage())
.asBuilder()
.setEventTime(expirationTime.minusYears(1))
.setEventTime(minusYears(expirationTime, 1))
.build());
runFlowAssertResponse(
loadFile(
@@ -807,8 +816,8 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
new PollMessage.Autorenew.Builder()
.setTargetId(getUniqueIdFromCommand())
.setRegistrarId("TheRegistrar")
.setEventTime(expirationTime.minusYears(1))
.setAutorenewEndTime(clock.nowUtc())
.setEventTime(minusYears(expirationTime, 1))
.setAutorenewEndTime(clock.now())
.setMsg("Domain was auto-renewed.")
.setHistoryEntry(
getOnlyHistoryEntryOfType(
@@ -817,7 +826,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
new PollMessage.Autorenew.Builder()
.setTargetId(getUniqueIdFromCommand())
.setRegistrarId("TheRegistrar")
.setEventTime(reloadResourceByForeignKey().getRegistrationExpirationDateTime())
.setEventTime(reloadResourceByForeignKey().getRegistrationExpirationTime())
.setAutorenewEndTime(END_OF_TIME)
.setMsg("Domain was auto-renewed.")
.setHistoryEntry(historyEntryDomainRenew)
@@ -910,7 +919,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setRegistrationExpirationTime(expirationTime)
.setDeletionTime(clock.nowUtc().plusDays(1))
.setDeletionTime(plusDays(clock.now(), 1))
.addStatusValue(StatusValue.PENDING_DELETE)
.build());
ResourceStatusProhibitsOperationException thrown =
@@ -985,7 +994,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
persistWithPendingTransfer(
reloadResourceByForeignKey()
.asBuilder()
.setRegistrationExpirationTime(DateTime.parse("2001-09-08T22:00:00.0Z"))
.setRegistrationExpirationTime(Instant.parse("2001-09-08T22:00:00.0Z"))
.build());
ResourceStatusProhibitsOperationException thrown =
assertThrows(ResourceStatusProhibitsOperationException.class, this::runFlow);
@@ -1015,7 +1024,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
persistResource(
reloadResourceByForeignKey()
.asBuilder()
.setRegistrationExpirationTime(DateTime.parse("2000-04-04T22:00:00.0Z"))
.setRegistrationExpirationTime(Instant.parse("2000-04-04T22:00:00.0Z"))
.build());
EppException thrown =
assertThrows(IncorrectCurrentExpirationDateException.class, this::runFlow);
@@ -29,8 +29,14 @@ import static google.registry.testing.DatabaseHelper.persistReservedList;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DomainSubject.assertAboutDomains;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.util.DateTimeUtils.END_INSTANT;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static google.registry.util.DateTimeUtils.START_INSTANT;
import static google.registry.util.DateTimeUtils.minusDays;
import static google.registry.util.DateTimeUtils.plusDays;
import static google.registry.util.DateTimeUtils.plusMonths;
import static google.registry.util.DateTimeUtils.plusYears;
import static google.registry.util.DateTimeUtils.toDateTime;
import static org.joda.money.CurrencyUnit.EUR;
import static org.joda.money.CurrencyUnit.JPY;
import static org.joda.money.CurrencyUnit.USD;
@@ -76,10 +82,11 @@ import google.registry.model.reporting.HistoryEntry;
import google.registry.model.tld.Tld;
import google.registry.persistence.VKey;
import google.registry.testing.DatabaseHelper;
import java.time.Duration;
import java.time.Instant;
import java.util.Map;
import java.util.Optional;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -108,16 +115,16 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
Domain persistPendingDeleteDomain() throws Exception {
// The domain is now past what had been its expiration date at the time of deletion.
return persistPendingDeleteDomain(clock.nowUtc().minusDays(5));
return persistPendingDeleteDomain(minusDays(clock.now(), 5));
}
Domain persistPendingDeleteDomain(DateTime expirationTime) throws Exception {
Domain persistPendingDeleteDomain(Instant expirationTime) throws Exception {
Domain domain = persistResource(DatabaseHelper.newDomain(getUniqueIdFromCommand()));
HistoryEntry historyEntry =
persistResource(
new DomainHistory.Builder()
.setType(HistoryEntry.Type.DOMAIN_DELETE)
.setModificationTime(clock.nowUtc())
.setModificationTime(clock.now())
.setRegistrarId(domain.getCurrentSponsorRegistrarId())
.setDomain(domain)
.build());
@@ -126,12 +133,12 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
domain
.asBuilder()
.setRegistrationExpirationTime(expirationTime)
.setDeletionTime(clock.nowUtc().plusDays(35))
.setDeletionTime(plusDays(clock.now(), 35))
.addGracePeriod(
GracePeriod.create(
GracePeriodStatus.REDEMPTION,
domain.getRepoId(),
clock.nowUtc().plusDays(1),
plusDays(clock.now(), 1),
"TheRegistrar",
null))
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
@@ -139,7 +146,7 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
persistResource(
new PollMessage.OneTime.Builder()
.setRegistrarId("TheRegistrar")
.setEventTime(clock.nowUtc().plusDays(5))
.setEventTime(plusDays(clock.now(), 5))
.setHistoryEntry(historyEntry)
.build())
.createVKey())
@@ -165,7 +172,7 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
@Test
void testSuccess_expiryStillInFuture_notExtended() throws Exception {
setEppInput("domain_update_restore_request.xml", ImmutableMap.of("DOMAIN", "example.tld"));
DateTime expirationTime = clock.nowUtc().plusYears(5).plusDays(45);
Instant expirationTime = plusYears(clock.now(), 5).plus(Duration.ofDays(45));
persistPendingDeleteDomain(expirationTime);
assertMutatingFlow(true);
// Double check that we see a poll message in the future for when the delete happens.
@@ -176,7 +183,7 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RESTORE, DomainHistory.class);
assertLastHistoryContainsResource(domain);
assertThat(loadByKey(domain.getAutorenewBillingEvent()).getEventTime())
.isEqualTo(expirationTime);
.isEqualTo(toDateTime(expirationTime));
assertAboutDomains()
.that(domain)
// New expiration time should be the same as from before the deletion.
@@ -184,12 +191,12 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
.and()
.doesNotHaveStatusValue(StatusValue.PENDING_DELETE)
.and()
.hasDeletionTime(END_OF_TIME)
.hasDeletionTime(END_INSTANT)
.and()
.hasOneHistoryEntryEachOfTypes(
HistoryEntry.Type.DOMAIN_DELETE, HistoryEntry.Type.DOMAIN_RESTORE)
.and()
.hasLastEppUpdateTime(clock.nowUtc())
.hasLastEppUpdateTime(clock.now())
.and()
.hasLastEppUpdateRegistrarId("TheRegistrar");
assertThat(domain.getGracePeriods()).isEmpty();
@@ -214,7 +221,7 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
.setTargetId("example.tld")
.setRegistrarId("TheRegistrar")
.setEventTime(expirationTime)
.setRecurrenceEndTime(END_OF_TIME)
.setRecurrenceEndTime(END_INSTANT)
.setDomainHistory(historyEntryDomainRestore)
.build(),
new BillingEvent.Builder()
@@ -223,8 +230,8 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
.setRegistrarId("TheRegistrar")
.setCost(Money.of(USD, 17))
.setPeriodYears(1)
.setEventTime(clock.nowUtc())
.setBillingTime(clock.nowUtc())
.setEventTime(clock.now())
.setBillingTime(clock.now())
.setDomainHistory(historyEntryDomainRestore)
.build());
}
@@ -232,8 +239,8 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
@Test
void testSuccess_expiryInPast_extendedByOneYear() throws Exception {
setEppInput("domain_update_restore_request.xml", ImmutableMap.of("DOMAIN", "example.tld"));
DateTime expirationTime = clock.nowUtc().minusDays(20);
DateTime newExpirationTime = expirationTime.plusYears(1);
Instant expirationTime = minusDays(clock.now(), 20);
Instant newExpirationTime = plusYears(expirationTime, 1);
persistPendingDeleteDomain(expirationTime);
assertMutatingFlow(true);
// Double check that we see a poll message in the future for when the delete happens.
@@ -244,7 +251,7 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RESTORE, DomainHistory.class);
assertLastHistoryContainsResource(domain);
assertThat(loadByKey(domain.getAutorenewBillingEvent()).getEventTime())
.isEqualTo(newExpirationTime);
.isEqualTo(toDateTime(newExpirationTime));
assertAboutDomains()
.that(domain)
// New expiration time should be exactly a year from now.
@@ -252,12 +259,12 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
.and()
.doesNotHaveStatusValue(StatusValue.PENDING_DELETE)
.and()
.hasDeletionTime(END_OF_TIME)
.hasDeletionTime(END_INSTANT)
.and()
.hasOneHistoryEntryEachOfTypes(
HistoryEntry.Type.DOMAIN_DELETE, HistoryEntry.Type.DOMAIN_RESTORE)
.and()
.hasLastEppUpdateTime(clock.nowUtc())
.hasLastEppUpdateTime(clock.now())
.and()
.hasLastEppUpdateRegistrarId("TheRegistrar");
assertThat(domain.getGracePeriods()).isEmpty();
@@ -283,7 +290,7 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
.setTargetId("example.tld")
.setRegistrarId("TheRegistrar")
.setEventTime(newExpirationTime)
.setRecurrenceEndTime(END_OF_TIME)
.setRecurrenceEndTime(END_INSTANT)
.setDomainHistory(historyEntryDomainRestore)
.build(),
new BillingEvent.Builder()
@@ -292,8 +299,8 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
.setRegistrarId("TheRegistrar")
.setCost(Money.of(USD, 17))
.setPeriodYears(1)
.setEventTime(clock.nowUtc())
.setBillingTime(clock.nowUtc())
.setEventTime(clock.now())
.setBillingTime(clock.now())
.setDomainHistory(historyEntryDomainRestore)
.build(),
new BillingEvent.Builder()
@@ -302,8 +309,8 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
.setRegistrarId("TheRegistrar")
.setCost(Money.of(USD, 11))
.setPeriodYears(1)
.setEventTime(clock.nowUtc())
.setBillingTime(clock.nowUtc())
.setEventTime(clock.now())
.setBillingTime(clock.now())
.setDomainHistory(historyEntryDomainRestore)
.build());
}
@@ -315,7 +322,7 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
persistResource(
reloadResourceByForeignKey()
.asBuilder()
.setAutorenewEndTime(Optional.of(clock.nowUtc().plusYears(2)))
.setAutorenewEndTimeInstant(Optional.of(plusYears(clock.now(), 2)))
.build());
assertThat(reloadResourceByForeignKey().getAutorenewEndTime()).isPresent();
runFlowAssertResponse(
@@ -386,7 +393,7 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
void testSuccess_premiumNotBlocked_andNoRenewal_std_v1() throws Exception {
createTld("example");
setEppInput("domain_update_restore_request_premium_no_renewal.xml", FEE_STD_1_0_MAP);
persistPendingDeleteDomain(clock.nowUtc().plusYears(2));
persistPendingDeleteDomain(plusYears(clock.now(), 2));
runFlowAssertResponse(
loadFile("domain_update_restore_request_response_fee_no_renewal.xml", FEE_STD_1_0_MAP));
}
@@ -475,11 +482,12 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
Tld.get("tld")
.asBuilder()
.setCurrency(EUR)
.setCreateBillingCostTransitions(
ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 13)))
.setCreateBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.of(EUR, 13)))
.setRestoreBillingCost(Money.of(EUR, 11))
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 7)))
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
.setRenewBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.of(EUR, 7)))
.setEapFeeScheduleInstant(ImmutableSortedMap.of(START_INSTANT, Money.zero(EUR)))
.setServerStatusChangeBillingCost(Money.of(EUR, 19))
.setRegistryLockOrUnlockBillingCost(Money.of(EUR, 0))
.build());
@@ -505,7 +513,7 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
persistResource(
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setDeletionTime(clock.nowUtc().plusDays(4))
.setDeletionTime(plusDays(clock.now(), 4))
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
.build());
EppException thrown = assertThrows(DomainNotEligibleForRestoreException.class, this::runFlow);
@@ -593,11 +601,11 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
Tld.get("tld")
.asBuilder()
.setCurrency(JPY)
.setCreateBillingCostTransitions(
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
.setRenewBillingCostTransitions(
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
.setCreateBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
.setEapFeeScheduleInstant(ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
.setRenewBillingCostTransitionsInstant(
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
.setRegistryLockOrUnlockBillingCost(Money.ofMajor(JPY, 800))
.setServerStatusChangeBillingCost(Money.ofMajor(JPY, 800))
.setRestoreBillingCost(Money.ofMajor(JPY, 800))
@@ -790,7 +798,7 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
@Test
void testSuccess_fee_v06_noRenewal() throws Exception {
setEppInput("domain_update_restore_request_fee_no_renewal.xml", FEE_06_MAP);
persistPendingDeleteDomain(clock.nowUtc().plusMonths(6));
persistPendingDeleteDomain(plusMonths(clock.now(), 6));
runFlowAssertResponse(
loadFile("domain_update_restore_request_response_fee_no_renewal.xml", FEE_06_MAP));
}
@@ -887,7 +895,7 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
void testSuccess_premiumNotBlocked_andNoRenewal_v12() throws Exception {
createTld("example");
setEppInput("domain_update_restore_request_premium_no_renewal.xml", FEE_12_MAP);
persistPendingDeleteDomain(clock.nowUtc().plusYears(2));
persistPendingDeleteDomain(plusYears(clock.now(), 2));
runFlowAssertResponse(
loadFile("domain_update_restore_request_response_fee_no_renewal.xml", FEE_12_MAP));
}
@@ -38,7 +38,12 @@ import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DomainSubject.assertAboutDomains;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static google.registry.util.DateTimeUtils.START_INSTANT;
import static google.registry.util.DateTimeUtils.minusDays;
import static google.registry.util.DateTimeUtils.minusYears;
import static google.registry.util.DateTimeUtils.plusDays;
import static google.registry.util.DateTimeUtils.plusYears;
import static google.registry.util.DateTimeUtils.toDateTime;
import static org.joda.money.CurrencyUnit.USD;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -92,10 +97,10 @@ import google.registry.model.transfer.TransferStatus;
import google.registry.persistence.VKey;
import google.registry.testing.DatabaseHelper;
import java.math.BigDecimal;
import java.time.Instant;
import java.util.Arrays;
import java.util.stream.Stream;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -116,10 +121,10 @@ class DomainTransferApproveFlowTest
persistResource(
Tld.get("tld")
.asBuilder()
.setRenewBillingCostTransitions(
new ImmutableSortedMap.Builder<DateTime, Money>(Ordering.natural())
.put(START_OF_TIME, Money.of(USD, 1))
.put(clock.nowUtc().minusDays(1).plusMillis(1), Money.of(USD, 22))
.setRenewBillingCostTransitionsInstant(
new ImmutableSortedMap.Builder<Instant, Money>(Ordering.natural())
.put(START_INSTANT, Money.of(USD, 1))
.put(minusDays(clock.now(), 1).plusMillis(1), Money.of(USD, 22))
.put(TRANSFER_REQUEST_TIME.plusMillis(1), Money.of(USD, 333))
.build())
.build());
@@ -134,11 +139,11 @@ class DomainTransferApproveFlowTest
.that(domain)
.hasCurrentSponsorRegistrarId("NewRegistrar")
.and()
.hasLastTransferTime(clock.nowUtc())
.hasLastTransferTime(clock.now())
.and()
.doesNotHaveStatusValue(StatusValue.PENDING_TRANSFER)
.and()
.hasLastEppUpdateTime(clock.nowUtc())
.hasLastEppUpdateTime(clock.now())
.and()
.hasLastEppUpdateRegistrarId("TheRegistrar");
// The domain TransferData should reflect the approved transfer as we expect, with
@@ -148,9 +153,8 @@ class DomainTransferApproveFlowTest
oldTransferData
.copyConstantFieldsToBuilder()
.setTransferStatus(TransferStatus.CLIENT_APPROVED)
.setPendingTransferExpirationTime(clock.nowUtc())
.setTransferredRegistrationExpirationTime(
domain.getRegistrationExpirationDateTime())
.setPendingTransferExpirationTime(clock.now())
.setTransferredRegistrationExpirationTime(domain.getRegistrationExpirationTime())
.build());
}
@@ -163,7 +167,7 @@ class DomainTransferApproveFlowTest
String tld,
String commandFilename,
String expectedXmlFilename,
DateTime expectedExpirationTime,
Instant expectedExpirationTime,
int expectedYearsToCharge,
BillingCancellation.Builder... expectedCancellationBillingEvents)
throws Exception {
@@ -177,7 +181,7 @@ class DomainTransferApproveFlowTest
String tld,
String commandFilename,
String expectedXmlFilename,
DateTime expectedExpirationTime)
Instant expectedExpirationTime)
throws Exception {
setEppInput(commandFilename);
Tld registry = Tld.get(tld);
@@ -210,7 +214,7 @@ class DomainTransferApproveFlowTest
assertTransferApproved(domain, originalTransferData);
assertAboutDomains().that(domain).hasRegistrationExpirationTime(expectedExpirationTime);
assertThat(loadByKey(domain.getAutorenewBillingEvent()).getEventTime())
.isEqualTo(expectedExpirationTime);
.isEqualTo(toDateTime(expectedExpirationTime));
// The poll message (in the future) to the losing registrar for implicit ack should be gone.
assertThat(getPollMessages(domain, "TheRegistrar", clock.nowUtc().plusMonths(1))).isEmpty();
@@ -218,7 +222,9 @@ class DomainTransferApproveFlowTest
// should be one at the current time to the gaining registrar, as well as one at the domain's
// autorenew time.
assertThat(getPollMessages(domain, "NewRegistrar", clock.nowUtc().plusMonths(1))).hasSize(1);
assertThat(getPollMessages(domain, "NewRegistrar", domain.getRegistrationExpirationDateTime()))
assertThat(
getPollMessages(
domain, "NewRegistrar", toDateTime(domain.getRegistrationExpirationTime())))
.hasSize(2);
PollMessage gainingTransferPollMessage =
@@ -227,11 +233,11 @@ class DomainTransferApproveFlowTest
getOnlyPollMessage(
domain,
"NewRegistrar",
domain.getRegistrationExpirationDateTime(),
toDateTime(domain.getRegistrationExpirationTime()),
PollMessage.Autorenew.class);
assertThat(gainingTransferPollMessage.getEventTime()).isEqualTo(clock.nowUtc());
assertThat(gainingAutorenewPollMessage.getEventTime())
.isEqualTo(domain.getRegistrationExpirationDateTime());
.isEqualTo(toDateTime(domain.getRegistrationExpirationTime()));
DomainTransferResponse transferResponse =
gainingTransferPollMessage
.getResponseData()
@@ -256,7 +262,8 @@ class DomainTransferApproveFlowTest
// After the expected grace time, the grace period should be gone.
assertThat(
domain
.cloneProjectedAtTime(clock.nowUtc().plus(registry.getTransferGracePeriodLength()))
.cloneProjectedAtInstant(
clock.now().plusMillis(registry.getTransferGracePeriodLength().getMillis()))
.getGracePeriods())
.isEmpty();
}
@@ -276,8 +283,10 @@ class DomainTransferApproveFlowTest
new BillingEvent.Builder()
.setReason(Reason.TRANSFER)
.setTargetId(domain.getDomainName())
.setEventTime(clock.nowUtc())
.setBillingTime(clock.nowUtc().plus(registry.getTransferGracePeriodLength()))
.setEventTime(clock.now())
.setBillingTime(
toDateTime(
clock.now().plusMillis(registry.getTransferGracePeriodLength().getMillis())))
.setRegistrarId("NewRegistrar")
.setCost(Money.of(USD, 11).multipliedBy(expectedYearsToCharge))
.setPeriodYears(expectedYearsToCharge)
@@ -292,13 +301,13 @@ class DomainTransferApproveFlowTest
transferBillingEvent,
getLosingClientAutorenewEvent()
.asBuilder()
.setRecurrenceEndTime(clock.nowUtc())
.setRecurrenceEndTime(clock.now())
.build(),
getGainingClientAutorenewEvent()
.asBuilder()
.setEventTime(domain.getRegistrationExpirationDateTime())
.setEventTime(domain.getRegistrationExpirationTime())
.setRecurrenceLastExpansion(
domain.getRegistrationExpirationDateTime().minusYears(1))
minusYears(domain.getRegistrationExpirationTime(), 1))
.setDomainHistory(historyEntryTransferApproved)
.build()))
.toArray(BillingBase[]::new));
@@ -309,7 +318,8 @@ class DomainTransferApproveFlowTest
GracePeriod.create(
GracePeriodStatus.TRANSFER,
domain.getRepoId(),
clock.nowUtc().plus(registry.getTransferGracePeriodLength()),
toDateTime(
clock.now().plusMillis(registry.getTransferGracePeriodLength().getMillis())),
"NewRegistrar",
null),
transferBillingEvent));
@@ -330,13 +340,13 @@ class DomainTransferApproveFlowTest
Stream.of(
getLosingClientAutorenewEvent()
.asBuilder()
.setRecurrenceEndTime(clock.nowUtc())
.setRecurrenceEndTime(clock.now())
.build(),
getGainingClientAutorenewEvent()
.asBuilder()
.setEventTime(domain.getRegistrationExpirationDateTime())
.setEventTime(domain.getRegistrationExpirationTime())
.setRecurrenceLastExpansion(
domain.getRegistrationExpirationDateTime().minusYears(1))
minusYears(domain.getRegistrationExpirationTime(), 1))
.setDomainHistory(historyEntryTransferApproved)
.build()))
.toArray(BillingBase[]::new));
@@ -351,7 +361,7 @@ class DomainTransferApproveFlowTest
tld,
commandFilename,
expectedXmlFilename,
domain.getRegistrationExpirationDateTime().plusYears(1),
plusYears(domain.getRegistrationExpirationTime(), 1),
1);
}
@@ -429,7 +439,7 @@ class DomainTransferApproveFlowTest
persistResource(domain.asBuilder().setCurrentBulkToken(allocationToken.createVKey()).build());
clock.advanceOneMilli();
setEppInput("domain_transfer_approve_wildcard.xml", ImmutableMap.of("DOMAIN", "example.tld"));
DateTime now = clock.nowUtc();
Instant now = clock.now();
runFlowAssertResponse(loadFile("domain_transfer_approve_response.xml"));
domain = reloadResourceByForeignKey();
DomainHistory acceptHistory =
@@ -437,7 +447,7 @@ class DomainTransferApproveFlowTest
assertBillingEventsForResource(
domain,
new BillingEvent.Builder()
.setBillingTime(now.plusDays(5))
.setBillingTime(plusDays(now, 5))
.setEventTime(now)
.setRegistrarId("NewRegistrar")
.setCost(Money.of(USD, new BigDecimal("11.00")))
@@ -490,7 +500,7 @@ class DomainTransferApproveFlowTest
@Test
void testSuccess_autorenewBeforeTransfer() throws Exception {
domain = reloadResourceByForeignKey();
DateTime oldExpirationTime = clock.nowUtc().minusDays(1);
Instant oldExpirationTime = minusDays(clock.now(), 1);
persistResource(domain.asBuilder().setRegistrationExpirationTime(oldExpirationTime).build());
// The autorenew should be subsumed into the transfer resulting in 1 year of renewal in total.
clock.advanceOneMilli();
@@ -498,15 +508,18 @@ class DomainTransferApproveFlowTest
"tld",
"domain_transfer_approve_domain_authinfo.xml",
"domain_transfer_approve_response_autorenew.xml",
oldExpirationTime.plusYears(1),
plusYears(oldExpirationTime, 1),
1,
// Expect the grace period for autorenew to be cancelled.
new BillingCancellation.Builder()
.setReason(Reason.RENEW)
.setTargetId("example.tld")
.setRegistrarId("TheRegistrar")
.setEventTime(clock.nowUtc()) // The cancellation happens at the moment of transfer.
.setBillingTime(oldExpirationTime.plus(Tld.get("tld").getAutoRenewGracePeriodLength()))
.setEventTime(clock.now()) // The cancellation happens at the moment of transfer.
.setBillingTime(
toDateTime(
oldExpirationTime.plusMillis(
Tld.get("tld").getAutoRenewGracePeriodLength().getMillis())))
.setBillingRecurrence(domain.getAutorenewBillingEvent()));
}
@@ -529,7 +542,7 @@ class DomainTransferApproveFlowTest
.setRenewalPriceBehavior(RenewalPriceBehavior.NONPREMIUM)
.build());
setEppInput("domain_transfer_approve_wildcard.xml", ImmutableMap.of("DOMAIN", "example.tld"));
DateTime now = clock.nowUtc();
Instant now = clock.now();
runFlowAssertResponse(loadFile("domain_transfer_approve_response.xml"));
domain = reloadResourceByForeignKey();
DomainHistory acceptHistory =
@@ -537,7 +550,7 @@ class DomainTransferApproveFlowTest
assertBillingEventsForResource(
domain,
new BillingEvent.Builder()
.setBillingTime(now.plusDays(5))
.setBillingTime(plusDays(now, 5))
.setEventTime(now)
.setRegistrarId("NewRegistrar")
.setCost(Money.of(USD, new BigDecimal("11.00")))
@@ -578,7 +591,7 @@ class DomainTransferApproveFlowTest
.setRenewalPrice(Money.of(USD, new BigDecimal("43.10")))
.build());
setEppInput("domain_transfer_approve_wildcard.xml", ImmutableMap.of("DOMAIN", "example.tld"));
DateTime now = clock.nowUtc();
Instant now = clock.now();
runFlowAssertResponse(loadFile("domain_transfer_approve_response.xml"));
domain = reloadResourceByForeignKey();
DomainHistory acceptHistory =
@@ -586,7 +599,7 @@ class DomainTransferApproveFlowTest
assertBillingEventsForResource(
domain,
new BillingEvent.Builder()
.setBillingTime(now.plusDays(5))
.setBillingTime(plusDays(now, 5))
.setEventTime(now)
.setRegistrarId("NewRegistrar")
.setCost(Money.of(USD, new BigDecimal("43.10")))
@@ -708,7 +721,7 @@ class DomainTransferApproveFlowTest
@Test
void testFailure_deletedDomain() throws Exception {
persistResource(domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
persistResource(domain.asBuilder().setDeletionTime(minusDays(clock.now(), 1)).build());
ResourceDoesNotExistException thrown =
assertThrows(
ResourceDoesNotExistException.class,
@@ -779,7 +792,7 @@ class DomainTransferApproveFlowTest
assertThat(persistedEntry.getDomainTransactionRecords())
.containsExactly(
DomainTransactionRecord.create(
"tld", clock.nowUtc().plusDays(3), TRANSFER_SUCCESSFUL, 1));
"tld", plusDays(clock.now(), 3), TRANSFER_SUCCESSFUL, 1));
}
@Test
@@ -787,15 +800,15 @@ class DomainTransferApproveFlowTest
clock.advanceOneMilli();
setUpGracePeriodDurations();
DomainTransactionRecord previousSuccessRecord =
DomainTransactionRecord.create("tld", clock.nowUtc().plusDays(1), TRANSFER_SUCCESSFUL, 1);
DomainTransactionRecord.create("tld", plusDays(clock.now(), 1), TRANSFER_SUCCESSFUL, 1);
// We only want to cancel TRANSFER_SUCCESSFUL records
DomainTransactionRecord notCancellableRecord =
DomainTransactionRecord.create("tld", clock.nowUtc().plusDays(1), NET_ADDS_4_YR, 5);
DomainTransactionRecord.create("tld", plusDays(clock.now(), 1), NET_ADDS_4_YR, 5);
persistResource(
new DomainHistory.Builder()
.setType(DOMAIN_TRANSFER_REQUEST)
.setDomain(domain)
.setModificationTime(clock.nowUtc().minusDays(4))
.setModificationTime(minusDays(clock.now(), 4))
.setRegistrarId("TheRegistrar")
.setDomainTransactionRecords(
ImmutableSet.of(previousSuccessRecord, notCancellableRecord))
@@ -809,7 +822,7 @@ class DomainTransferApproveFlowTest
.containsExactly(
previousSuccessRecord.asBuilder().setReportAmount(-1).build(),
DomainTransactionRecord.create(
"tld", clock.nowUtc().plusDays(3), TRANSFER_SUCCESSFUL, 1));
"tld", plusDays(clock.now(), 3), TRANSFER_SUCCESSFUL, 1));
}
@Test
@@ -827,7 +840,7 @@ class DomainTransferApproveFlowTest
"tld",
"domain_transfer_approve.xml",
"domain_transfer_approve_response_zero_period.xml",
domain.getRegistrationExpirationDateTime());
domain.getRegistrationExpirationTime());
assertHistoryEntriesDoNotContainTransferBillingEventsOrGracePeriods();
}
@@ -837,8 +850,8 @@ class DomainTransferApproveFlowTest
VKey<BillingRecurrence> existingAutorenewEvent = domain.getAutorenewBillingEvent();
// Set domain to have auto-renewed just before the transfer request, so that it will have an
// active autorenew grace period spanning the entire transfer window.
DateTime autorenewTime = clock.nowUtc().minusDays(1);
DateTime expirationTime = autorenewTime.plusYears(1);
Instant autorenewTime = minusDays(clock.now(), 1);
Instant expirationTime = plusYears(autorenewTime, 1);
DomainTransferData.Builder transferDataBuilder = domain.getTransferData().asBuilder();
domain =
persistResource(
@@ -851,7 +864,8 @@ class DomainTransferApproveFlowTest
GracePeriod.createForRecurrence(
GracePeriodStatus.AUTO_RENEW,
domain.getRepoId(),
autorenewTime.plus(Tld.get("tld").getAutoRenewGracePeriodLength()),
autorenewTime.plusMillis(
Tld.get("tld").getAutoRenewGracePeriodLength().getMillis()),
"TheRegistrar",
existingAutorenewEvent))
.build());
@@ -860,7 +874,7 @@ class DomainTransferApproveFlowTest
"tld",
"domain_transfer_approve.xml",
"domain_transfer_approve_response_zero_period_autorenew_grace.xml",
domain.getRegistrationExpirationDateTime());
domain.getRegistrationExpirationTime());
assertHistoryEntriesDoNotContainTransferBillingEventsOrGracePeriods();
}
@@ -909,11 +923,11 @@ class DomainTransferApproveFlowTest
.setToken("abc123")
.setTokenType(UNLIMITED_USE)
.setDiscountFraction(0.5)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().plusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(60), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(plusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 60), TokenStatus.ENDED)
.build())
.build());
setEppInput("domain_transfer_approve_allocation_token.xml");
@@ -929,11 +943,11 @@ class DomainTransferApproveFlowTest
.setTokenType(UNLIMITED_USE)
.setAllowedRegistrarIds(ImmutableSet.of("someClientId"))
.setDiscountFraction(0.5)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().minusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 1), TokenStatus.ENDED)
.build())
.build());
setEppInput("domain_transfer_approve_allocation_token.xml");
@@ -950,11 +964,11 @@ class DomainTransferApproveFlowTest
.setTokenType(UNLIMITED_USE)
.setAllowedTlds(ImmutableSet.of("example"))
.setDiscountFraction(0.5)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().minusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 1), TokenStatus.ENDED)
.build())
.build());
setEppInput("domain_transfer_approve_allocation_token.xml");
@@ -32,6 +32,8 @@ import static google.registry.testing.DomainSubject.assertAboutDomains;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.minusDays;
import static google.registry.util.DateTimeUtils.plusDays;
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.collect.ImmutableList;
@@ -55,7 +57,7 @@ import google.registry.model.tld.Tld;
import google.registry.model.transfer.DomainTransferData;
import google.registry.model.transfer.TransferResponse.DomainTransferResponse;
import google.registry.model.transfer.TransferStatus;
import org.joda.time.DateTime;
import java.time.Instant;
import org.joda.time.Duration;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -114,7 +116,7 @@ class DomainTransferCancelFlowTest
// Setup done; run the test.
assertMutatingFlow(true);
DateTime originalExpirationTime = domain.getRegistrationExpirationDateTime();
Instant originalExpirationTime = domain.getRegistrationExpirationTime();
ImmutableSet<GracePeriod> originalGracePeriods = domain.getGracePeriods();
DomainTransferData originalTransferData = domain.getTransferData();
runFlowAssertResponse(loadFile("domain_transfer_cancel_response.xml"));
@@ -127,13 +129,13 @@ class DomainTransferCancelFlowTest
.that(domain)
.hasRegistrationExpirationTime(originalExpirationTime)
.and()
.hasLastTransferTimeNotEqualTo(clock.nowUtc());
.hasLastTransferTimeNotEqualTo(clock.now());
assertAboutDomains()
.that(domain)
.hasOneHistoryEntryEachOfTypes(
DOMAIN_CREATE, DOMAIN_TRANSFER_REQUEST, DOMAIN_TRANSFER_CANCEL)
.and()
.hasLastEppUpdateTime(clock.nowUtc())
.hasLastEppUpdateTime(clock.now())
.and()
.hasLastEppUpdateRegistrarId("NewRegistrar");
final HistoryEntry historyEntryTransferCancel =
@@ -163,7 +165,7 @@ class DomainTransferCancelFlowTest
.build(),
new PollMessage.OneTime.Builder()
.setRegistrarId("TheRegistrar")
.setEventTime(clock.nowUtc())
.setEventTime(clock.now())
.setResponseData(
ImmutableList.of(
new DomainTransferResponse.Builder()
@@ -172,7 +174,7 @@ class DomainTransferCancelFlowTest
.setTransferRequestTime(TRANSFER_REQUEST_TIME)
.setGainingRegistrarId("NewRegistrar")
.setLosingRegistrarId("TheRegistrar")
.setPendingTransferExpirationTime(clock.nowUtc())
.setPendingTransferExpirationTime(clock.now())
.build()))
.setMsg("Transfer cancelled.")
.setHistoryEntry(getOnlyHistoryEntryOfType(domain, DOMAIN_TRANSFER_CANCEL))
@@ -312,8 +314,7 @@ class DomainTransferCancelFlowTest
@Test
void testFailure_deletedDomain() throws Exception {
domain =
persistResource(domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
domain = persistResource(domain.asBuilder().setDeletionTime(minusDays(clock.now(), 1)).build());
ResourceDoesNotExistException thrown =
assertThrows(
ResourceDoesNotExistException.class, () -> doFailingTest("domain_transfer_cancel.xml"));
@@ -380,15 +381,15 @@ class DomainTransferCancelFlowTest
.setTransferGracePeriodLength(Duration.standardDays(3))
.build());
DomainTransactionRecord previousSuccessRecord =
DomainTransactionRecord.create("tld", clock.nowUtc().plusDays(1), TRANSFER_SUCCESSFUL, 1);
DomainTransactionRecord.create("tld", plusDays(clock.now(), 1), TRANSFER_SUCCESSFUL, 1);
// We only want to cancel TRANSFER_SUCCESSFUL records
DomainTransactionRecord notCancellableRecord =
DomainTransactionRecord.create("tld", clock.nowUtc().plusDays(1), RESTORED_DOMAINS, 5);
DomainTransactionRecord.create("tld", plusDays(clock.now(), 1), RESTORED_DOMAINS, 5);
persistResource(
new DomainHistory.Builder()
.setType(DOMAIN_TRANSFER_REQUEST)
.setDomain(domain)
.setModificationTime(clock.nowUtc().minusDays(4))
.setModificationTime(minusDays(clock.now(), 4))
.setRegistrarId("TheRegistrar")
.setDomainTransactionRecords(
ImmutableSet.of(previousSuccessRecord, notCancellableRecord))
@@ -11,7 +11,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package google.registry.flows.domain;
import static com.google.common.base.Preconditions.checkState;
@@ -25,6 +24,7 @@ import static google.registry.testing.DatabaseHelper.persistDomainWithPendingTra
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DomainSubject.assertAboutDomains;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.plusYears;
import com.google.common.base.Ascii;
import com.google.common.collect.ImmutableSet;
@@ -44,7 +44,7 @@ import google.registry.model.tld.Tld;
import google.registry.model.transfer.DomainTransferData;
import google.registry.model.transfer.TransferStatus;
import google.registry.persistence.transaction.JpaTransactionManagerExtension;
import org.joda.time.DateTime;
import java.time.Instant;
import org.joda.time.Duration;
import org.junit.jupiter.api.BeforeEach;
@@ -60,15 +60,15 @@ abstract class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
// Transfer is requested on the 6th and expires on the 11th.
// The "now" of this flow is on the 9th, 3 days in.
static final DateTime TRANSFER_REQUEST_TIME = DateTime.parse("2000-06-06T22:00:00.0Z");
static final DateTime TRANSFER_EXPIRATION_TIME =
TRANSFER_REQUEST_TIME.plus(Tld.DEFAULT_AUTOMATIC_TRANSFER_LENGTH);
static final Instant TRANSFER_REQUEST_TIME = Instant.parse("2000-06-06T22:00:00.0Z");
static final Instant TRANSFER_EXPIRATION_TIME =
TRANSFER_REQUEST_TIME.plusMillis(Tld.DEFAULT_AUTOMATIC_TRANSFER_LENGTH.getMillis());
private static final Duration TIME_SINCE_REQUEST = Duration.standardDays(3);
private static final int EXTENDED_REGISTRATION_YEARS = 1;
private static final DateTime REGISTRATION_EXPIRATION_TIME =
DateTime.parse("2001-09-08T22:00:00.0Z");
static final DateTime EXTENDED_REGISTRATION_EXPIRATION_TIME =
REGISTRATION_EXPIRATION_TIME.plusYears(EXTENDED_REGISTRATION_YEARS);
private static final Instant REGISTRATION_EXPIRATION_TIME =
Instant.parse("2001-09-08T22:00:00.0Z");
static final Instant EXTENDED_REGISTRATION_EXPIRATION_TIME =
plusYears(REGISTRATION_EXPIRATION_TIME, EXTENDED_REGISTRATION_YEARS);
protected Domain domain;
Host subordinateHost;
@@ -76,7 +76,7 @@ abstract class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
DomainTransferFlowTestCase() {
checkState(!Tld.DEFAULT_TRANSFER_GRACE_PERIOD.isShorterThan(TIME_SINCE_REQUEST));
clock.setTo(TRANSFER_REQUEST_TIME.plus(TIME_SINCE_REQUEST));
clock.setTo(TRANSFER_REQUEST_TIME.plusMillis(TIME_SINCE_REQUEST.getMillis()));
}
@BeforeEach
@@ -105,8 +105,8 @@ abstract class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
persistDomainWithDependentResources(
label,
tld,
clock.nowUtc(),
DateTime.parse("1999-04-03T22:00:00.0Z"),
clock.now(),
Instant.parse("1999-04-03T22:00:00.0Z"),
REGISTRATION_EXPIRATION_TIME);
subordinateHost =
persistResource(
@@ -115,7 +115,7 @@ abstract class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
.setHostName("ns1." + label + "." + tld)
.setPersistedCurrentSponsorRegistrarId("TheRegistrar")
.setCreationRegistrarId("TheRegistrar")
.setCreationTimeForTest(DateTime.parse("1999-04-03T22:00:00.0Z"))
.setCreationTimeForTest(Instant.parse("1999-04-03T22:00:00.0Z"))
.setSuperordinateDomain(domain.createVKey())
.build());
domain =
@@ -172,9 +172,10 @@ abstract class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
// all the speculative server-approve fields nulled out.
assertThat(domain.getTransferData())
.isEqualTo(
oldTransferData.copyConstantFieldsToBuilder()
oldTransferData
.copyConstantFieldsToBuilder()
.setTransferStatus(status)
.setPendingTransferExpirationTime(clock.nowUtc())
.setPendingTransferExpirationTime(clock.now())
.build());
}
@@ -21,6 +21,9 @@ import static google.registry.testing.DatabaseHelper.getPollMessages;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DomainSubject.assertAboutDomains;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.util.DateTimeUtils.minusDays;
import static google.registry.util.DateTimeUtils.plusDays;
import static google.registry.util.DateTimeUtils.plusYears;
import static org.junit.jupiter.api.Assertions.assertThrows;
import google.registry.flows.EppException;
@@ -152,8 +155,7 @@ class DomainTransferQueryFlowTest
@Test
void testFailure_pendingDeleteDomain() throws Exception {
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
domain =
persistResource(domain.asBuilder().setDeletionTime(clock.nowUtc().plusDays(1)).build());
domain = persistResource(domain.asBuilder().setDeletionTime(plusDays(clock.now(), 1)).build());
doSuccessfulTest(
"domain_transfer_query.xml", "domain_transfer_query_response_server_cancelled.xml", 1);
}
@@ -205,8 +207,7 @@ class DomainTransferQueryFlowTest
@Test
void testFailure_deletedDomain() throws Exception {
domain =
persistResource(domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
domain = persistResource(domain.asBuilder().setDeletionTime(minusDays(clock.now(), 1)).build());
ResourceDoesNotExistException thrown =
assertThrows(
ResourceDoesNotExistException.class, () -> doFailingTest("domain_transfer_query.xml"));
@@ -234,8 +235,8 @@ 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.cloneProjectedAtTime(clock.nowUtc()).getRegistrationExpirationDateTime())
.isEqualTo(EXTENDED_REGISTRATION_EXPIRATION_TIME.plusYears(1));
assertThat(domain.cloneProjectedAtInstant(clock.now()).getRegistrationExpirationTime())
.isEqualTo(plusYears(EXTENDED_REGISTRATION_EXPIRATION_TIME, 1));
doSuccessfulTest(
"domain_transfer_query.xml", "domain_transfer_query_response_server_approved.xml", 2);
}
@@ -33,6 +33,8 @@ import static google.registry.testing.DomainSubject.assertAboutDomains;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.minusDays;
import static google.registry.util.DateTimeUtils.plusDays;
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.collect.ImmutableSet;
@@ -57,7 +59,7 @@ import google.registry.model.tld.Tld;
import google.registry.model.transfer.DomainTransferData;
import google.registry.model.transfer.TransferResponse;
import google.registry.model.transfer.TransferStatus;
import org.joda.time.DateTime;
import java.time.Instant;
import org.joda.time.Duration;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -88,7 +90,7 @@ class DomainTransferRejectFlowTest
assertThat(getPollMessages("TheRegistrar", clock.nowUtc().plusMonths(1))).hasSize(1);
// Setup done; run the test.
assertMutatingFlow(true);
DateTime originalExpirationTime = domain.getRegistrationExpirationDateTime();
Instant originalExpirationTime = domain.getRegistrationExpirationTime();
ImmutableSet<GracePeriod> originalGracePeriods = domain.getGracePeriods();
DomainTransferData originalTransferData = domain.getTransferData();
runFlowAssertResponse(loadFile(expectedXmlFilename));
@@ -99,12 +101,12 @@ class DomainTransferRejectFlowTest
.that(domain)
.hasRegistrationExpirationTime(originalExpirationTime)
.and()
.hasLastTransferTimeNotEqualTo(clock.nowUtc())
.hasLastTransferTimeNotEqualTo(clock.now())
.and()
.hasOneHistoryEntryEachOfTypes(
DOMAIN_CREATE, DOMAIN_TRANSFER_REQUEST, DOMAIN_TRANSFER_REJECT)
.and()
.hasLastEppUpdateTime(clock.nowUtc())
.hasLastEppUpdateTime(clock.now())
.and()
.hasLastEppUpdateRegistrarId("TheRegistrar");
final HistoryEntry historyEntryTransferRejected =
@@ -297,8 +299,7 @@ class DomainTransferRejectFlowTest
@Test
void testFailure_deletedDomain() throws Exception {
domain =
persistResource(domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
domain = persistResource(domain.asBuilder().setDeletionTime(minusDays(clock.now(), 1)).build());
ResourceDoesNotExistException thrown =
assertThrows(
ResourceDoesNotExistException.class, () -> doFailingTest("domain_transfer_reject.xml"));
@@ -341,22 +342,22 @@ class DomainTransferRejectFlowTest
(DomainHistory) getOnlyHistoryEntryOfType(domain, DOMAIN_TRANSFER_REJECT);
// We should only produce transfer nacked records, reported now
assertThat(persistedEntry.getDomainTransactionRecords())
.containsExactly(DomainTransactionRecord.create("tld", clock.nowUtc(), TRANSFER_NACKED, 1));
.containsExactly(DomainTransactionRecord.create("tld", clock.now(), TRANSFER_NACKED, 1));
}
@Test
void testIcannTransactionRecord_cancelsPreviousRecords() throws Exception {
setUpGracePeriodDurations();
DomainTransactionRecord previousSuccessRecord =
DomainTransactionRecord.create("tld", clock.nowUtc().plusDays(1), TRANSFER_SUCCESSFUL, 1);
DomainTransactionRecord.create("tld", plusDays(clock.now(), 1), TRANSFER_SUCCESSFUL, 1);
// We only want to cancel TRANSFER_SUCCESSFUL records
DomainTransactionRecord notCancellableRecord =
DomainTransactionRecord.create("tld", clock.nowUtc().plusDays(1), NET_RENEWS_3_YR, 5);
DomainTransactionRecord.create("tld", plusDays(clock.now(), 1), NET_RENEWS_3_YR, 5);
persistResource(
new DomainHistory.Builder()
.setType(DOMAIN_TRANSFER_REQUEST)
.setDomain(domain)
.setModificationTime(clock.nowUtc().minusDays(4))
.setModificationTime(minusDays(clock.now(), 4))
.setRegistrarId("TheRegistrar")
.setDomainTransactionRecords(
ImmutableSet.of(previousSuccessRecord, notCancellableRecord))
@@ -368,6 +369,6 @@ class DomainTransferRejectFlowTest
assertThat(persistedEntry.getDomainTransactionRecords())
.containsExactly(
previousSuccessRecord.asBuilder().setReportAmount(-1).build(),
DomainTransactionRecord.create("tld", clock.nowUtc(), TRANSFER_NACKED, 1));
DomainTransactionRecord.create("tld", clock.now(), TRANSFER_NACKED, 1));
}
}
@@ -46,7 +46,13 @@ import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptio
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
import static google.registry.testing.HostSubject.assertAboutHosts;
import static google.registry.testing.TestDataHelper.updateSubstitutions;
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.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;
@@ -125,11 +131,11 @@ import google.registry.persistence.VKey;
import google.registry.testing.CloudTasksHelper.TaskMatcher;
import google.registry.testing.DatabaseHelper;
import java.math.BigDecimal;
import java.time.Instant;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Stream;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.joda.time.Duration;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -183,9 +189,9 @@ class DomainTransferRequestFlowTest
private void assertTransferRequested(
Domain domain,
DateTime automaticTransferTime,
Instant automaticTransferTime,
Period expectedPeriod,
DateTime expectedExpirationTime)
Instant expectedExpirationTime)
throws Exception {
assertAboutDomains()
.that(domain)
@@ -193,7 +199,7 @@ class DomainTransferRequestFlowTest
.and()
.hasStatusValue(StatusValue.PENDING_TRANSFER)
.and()
.hasLastEppUpdateTime(clock.nowUtc())
.hasLastEppUpdateTime(clock.now())
.and()
.hasLastEppUpdateRegistrarId("NewRegistrar");
Trid expectedTrid =
@@ -211,7 +217,7 @@ class DomainTransferRequestFlowTest
.setGainingRegistrarId("NewRegistrar")
.setLosingRegistrarId("TheRegistrar")
.setTransferRequestTrid(expectedTrid)
.setTransferRequestTime(clock.nowUtc())
.setTransferRequestTime(clock.now())
.setTransferPeriod(expectedPeriod)
.setTransferStatus(TransferStatus.PENDING)
.setPendingTransferExpirationTime(automaticTransferTime)
@@ -222,7 +228,7 @@ class DomainTransferRequestFlowTest
}
private void assertTransferApproved(
Domain domain, DateTime automaticTransferTime, Period expectedPeriod) throws Exception {
Domain domain, Instant automaticTransferTime, Period expectedPeriod) throws Exception {
assertAboutDomains()
.that(domain)
.hasCurrentSponsorRegistrarId("NewRegistrar")
@@ -240,7 +246,7 @@ class DomainTransferRequestFlowTest
.setGainingRegistrarId("NewRegistrar")
.setLosingRegistrarId("TheRegistrar")
.setTransferRequestTrid(expectedTrid)
.setTransferRequestTime(clock.nowUtc())
.setTransferRequestTime(clock.now())
.setTransferPeriod(expectedPeriod)
.setTransferStatus(TransferStatus.SERVER_APPROVED)
.setPendingTransferExpirationTime(automaticTransferTime)
@@ -251,8 +257,8 @@ class DomainTransferRequestFlowTest
}
private void assertHistoryEntriesContainBillingEventsAndGracePeriods(
DateTime expectedExpirationTime,
DateTime implicitTransferTime,
Instant expectedExpirationTime,
Instant implicitTransferTime,
Optional<Money> transferCost,
ImmutableSet<GracePeriod> originalGracePeriods,
boolean expectTransferBillingEvent,
@@ -274,7 +280,8 @@ class DomainTransferRequestFlowTest
.setTargetId(domain.getDomainName())
.setEventTime(implicitTransferTime)
.setBillingTime(
implicitTransferTime.plus(registry.getTransferGracePeriodLength()))
implicitTransferTime.plusMillis(
registry.getTransferGracePeriodLength().getMillis()))
.setRegistrarId("NewRegistrar")
.setCost(transferCost.orElse(Money.of(USD, 11)))
.setPeriodYears(1)
@@ -297,7 +304,7 @@ class DomainTransferRequestFlowTest
getGainingClientAutorenewEvent()
.asBuilder()
.setEventTime(expectedExpirationTime)
.setRecurrenceLastExpansion(expectedExpirationTime.minusYears(1))
.setRecurrenceLastExpansion(minusYears(expectedExpirationTime, 1))
.build();
// Construct extra billing events expected by the specific test.
ImmutableSet<BillingBase> extraBillingBases =
@@ -334,12 +341,12 @@ class DomainTransferRequestFlowTest
// The domain's autorenew billing event should still point to the losing client's event.
BillingRecurrence domainAutorenewEvent = loadByKey(domain.getAutorenewBillingEvent());
assertThat(domainAutorenewEvent.getRegistrarId()).isEqualTo("TheRegistrar");
assertThat(domainAutorenewEvent.getRecurrenceEndTime()).isEqualTo(implicitTransferTime);
assertThat(domainAutorenewEvent.getRecurrenceEndTimeInstant()).isEqualTo(implicitTransferTime);
// The original grace periods should remain untouched.
assertThat(domain.getGracePeriods()).containsExactlyElementsIn(originalGracePeriods);
// If we fast forward AUTOMATIC_TRANSFER_DAYS, the transfer should have cleared out all other
// grace periods, but expect a transfer grace period (if there was a transfer billing event).
Domain domainAfterAutomaticTransfer = domain.cloneProjectedAtTime(implicitTransferTime);
Domain domainAfterAutomaticTransfer = domain.cloneProjectedAtInstant(implicitTransferTime);
if (expectTransferBillingEvent) {
assertGracePeriods(
domainAfterAutomaticTransfer.getGracePeriods(),
@@ -347,7 +354,8 @@ class DomainTransferRequestFlowTest
GracePeriod.create(
GracePeriodStatus.TRANSFER,
domain.getRepoId(),
implicitTransferTime.plus(registry.getTransferGracePeriodLength()),
implicitTransferTime.plusMillis(
registry.getTransferGracePeriodLength().getMillis()),
"NewRegistrar",
null),
optionalTransferBillingEvent.get()));
@@ -357,12 +365,12 @@ class DomainTransferRequestFlowTest
}
private void assertPollMessagesEmitted(
DateTime expectedExpirationTime, DateTime implicitTransferTime) {
Instant expectedExpirationTime, Instant implicitTransferTime) {
// Assert that there exists a poll message to notify the losing registrar that a transfer was
// requested. If the implicit transfer time is now (i.e. the automatic transfer length is zero)
// then also expect a server approved poll message.
assertThat(getPollMessages("TheRegistrar", clock.nowUtc()))
.hasSize(implicitTransferTime.equals(clock.nowUtc()) ? 2 : 1);
.hasSize(implicitTransferTime.equals(clock.now()) ? 2 : 1);
// Two poll messages on the gaining registrar's side at the expected expiration time: a
// (OneTime) transfer approved message, and an Autorenew poll message.
@@ -371,8 +379,8 @@ class DomainTransferRequestFlowTest
getOnlyPollMessage("NewRegistrar", implicitTransferTime, PollMessage.OneTime.class);
PollMessage autorenewPollMessage =
getOnlyPollMessage("NewRegistrar", expectedExpirationTime, PollMessage.Autorenew.class);
assertThat(transferApprovedPollMessage.getEventTime()).isEqualTo(implicitTransferTime);
assertThat(autorenewPollMessage.getEventTime()).isEqualTo(expectedExpirationTime);
assertThat(transferApprovedPollMessage.getEventTimeInstant()).isEqualTo(implicitTransferTime);
assertThat(autorenewPollMessage.getEventTimeInstant()).isEqualTo(expectedExpirationTime);
assertThat(
transferApprovedPollMessage.getResponseData().stream()
.filter(TransferResponse.class::isInstance)
@@ -399,8 +407,9 @@ class DomainTransferRequestFlowTest
getPollMessages("TheRegistrar", implicitTransferTime).stream()
.filter(Predicates.not(Predicates.equalTo(losingTransferPendingPollMessage)))
.collect(onlyElement());
assertThat(losingTransferPendingPollMessage.getEventTime()).isEqualTo(clock.nowUtc());
assertThat(losingTransferApprovedPollMessage.getEventTime()).isEqualTo(implicitTransferTime);
assertThat(losingTransferPendingPollMessage.getEventTimeInstant()).isEqualTo(clock.now());
assertThat(losingTransferApprovedPollMessage.getEventTimeInstant())
.isEqualTo(implicitTransferTime);
assertThat(
losingTransferPendingPollMessage.getResponseData().stream()
.filter(TransferResponse.class::isInstance)
@@ -430,10 +439,10 @@ class DomainTransferRequestFlowTest
}
private void assertAboutDomainAfterAutomaticTransfer(
DateTime expectedExpirationTime, DateTime implicitTransferTime, Period expectedPeriod)
Instant expectedExpirationTime, Instant implicitTransferTime, Period expectedPeriod)
throws Exception {
Tld registry = Tld.get(domain.getTld());
Domain domainAfterAutomaticTransfer = domain.cloneProjectedAtTime(implicitTransferTime);
Domain domainAfterAutomaticTransfer = domain.cloneProjectedAtInstant(implicitTransferTime);
assertTransferApproved(domainAfterAutomaticTransfer, implicitTransferTime, expectedPeriod);
assertAboutDomains()
.that(domainAfterAutomaticTransfer)
@@ -442,15 +451,17 @@ class DomainTransferRequestFlowTest
.hasLastEppUpdateTime(implicitTransferTime)
.and()
.hasLastEppUpdateRegistrarId("NewRegistrar");
assertThat(loadByKey(domainAfterAutomaticTransfer.getAutorenewBillingEvent()).getEventTime())
assertThat(
loadByKey(domainAfterAutomaticTransfer.getAutorenewBillingEvent())
.getEventTimeInstant())
.isEqualTo(expectedExpirationTime);
// And after the expected grace time, the grace period should be gone.
Domain afterGracePeriod =
domain.cloneProjectedAtTime(
domain.cloneProjectedAtInstant(
clock
.nowUtc()
.plus(registry.getAutomaticTransferLength())
.plus(registry.getTransferGracePeriodLength()));
.now()
.plusMillis(registry.getAutomaticTransferLength().getMillis())
.plusMillis(registry.getTransferGracePeriodLength().getMillis()));
assertThat(afterGracePeriod.getGracePeriods()).isEmpty();
}
@@ -462,7 +473,7 @@ class DomainTransferRequestFlowTest
private void doSuccessfulTest(
String commandFilename,
String expectedXmlFilename,
DateTime expectedExpirationTime,
Instant expectedExpirationTime,
Map<String, String> substitutions,
Optional<Money> transferCost,
BillingCancellation.Builder... extraExpectedBillingEvents)
@@ -473,7 +484,8 @@ class DomainTransferRequestFlowTest
// for the request test we want that same 'now' to be the initial request time, so we shift
// the transfer timeline 3 days later by adjusting the implicit transfer time here.
Tld registry = Tld.get(domain.getTld());
DateTime implicitTransferTime = clock.nowUtc().plus(registry.getAutomaticTransferLength());
Instant implicitTransferTime =
clock.now().plusMillis(registry.getAutomaticTransferLength().getMillis());
// Setup done; run the test.
assertMutatingFlow(true);
runFlowAssertResponse(loadFile(expectedXmlFilename, substitutions));
@@ -517,14 +529,16 @@ class DomainTransferRequestFlowTest
.service("backend")
.header("content-type", "application/x-www-form-urlencoded")
.param(PARAM_RESOURCE_KEY, domain.createVKey().stringify())
.param(PARAM_REQUESTED_TIME, clock.nowUtc().toString())
.scheduleTime(clock.nowUtc().plus(registry.getAutomaticTransferLength())));
.param(PARAM_REQUESTED_TIME, clock.now().toString())
.scheduleTime(
toDateTime(
clock.now().plusMillis(registry.getAutomaticTransferLength().getMillis()))));
}
private void doSuccessfulTest(
String commandFilename,
String expectedXmlFilename,
DateTime expectedExpirationTime,
Instant expectedExpirationTime,
BillingCancellation.Builder... extraExpectedBillingEvents)
throws Exception {
doSuccessfulTest(
@@ -543,7 +557,7 @@ class DomainTransferRequestFlowTest
doSuccessfulTest(
commandFilename,
expectedXmlFilename,
domain.getRegistrationExpirationDateTime().plusYears(1),
plusYears(domain.getRegistrationExpirationTime(), 1),
substitutions,
Optional.empty());
}
@@ -552,15 +566,13 @@ class DomainTransferRequestFlowTest
throws Exception {
clock.advanceOneMilli();
doSuccessfulTest(
commandFilename,
expectedXmlFilename,
domain.getRegistrationExpirationDateTime().plusYears(1));
commandFilename, expectedXmlFilename, plusYears(domain.getRegistrationExpirationTime(), 1));
}
private void doSuccessfulSuperuserExtensionTest(
String commandFilename,
String expectedXmlFilename,
DateTime expectedExpirationTime,
Instant expectedExpirationTime,
Map<String, String> substitutions,
Optional<Money> transferCost,
Period expectedPeriod,
@@ -573,7 +585,8 @@ class DomainTransferRequestFlowTest
// For all of the other transfer flow tests, 'now' corresponds to day 3 of the transfer, but
// for the request test we want that same 'now' to be the initial request time, so we shift
// the transfer timeline 3 days later by adjusting the implicit transfer time here.
DateTime implicitTransferTime = clock.nowUtc().plus(expectedAutomaticTransferLength);
Instant implicitTransferTime =
clock.now().plusMillis(expectedAutomaticTransferLength.getMillis());
// Setup done; run the test.
assertMutatingFlow(true);
runFlowAssertResponse(
@@ -815,7 +828,7 @@ class DomainTransferRequestFlowTest
doSuccessfulSuperuserExtensionTest(
"domain_transfer_request_superuser_extension.xml",
"domain_transfer_request_response_su_ext_zero_period_nonzero_transfer_length.xml",
domain.getRegistrationExpirationDateTime().plusYears(0),
plusYears(domain.getRegistrationExpirationTime(), 0),
ImmutableMap.of("PERIOD", "0", "AUTOMATIC_TRANSFER_LENGTH", "5"),
Optional.empty(),
Period.create(0, Unit.YEARS),
@@ -829,7 +842,7 @@ class DomainTransferRequestFlowTest
doSuccessfulSuperuserExtensionTest(
"domain_transfer_request_superuser_extension.xml",
"domain_transfer_request_response_su_ext_zero_period_zero_transfer_length.xml",
domain.getRegistrationExpirationDateTime().plusYears(0),
plusYears(domain.getRegistrationExpirationTime(), 0),
ImmutableMap.of("PERIOD", "0", "AUTOMATIC_TRANSFER_LENGTH", "0"),
Optional.empty(),
Period.create(0, Unit.YEARS),
@@ -844,7 +857,7 @@ class DomainTransferRequestFlowTest
doSuccessfulSuperuserExtensionTest(
"domain_transfer_request_superuser_extension.xml",
"domain_transfer_request_response_su_ext_one_year_period_nonzero_transfer_length.xml",
domain.getRegistrationExpirationDateTime().plusYears(1),
plusYears(domain.getRegistrationExpirationTime(), 1),
ImmutableMap.of("PERIOD", "1", "AUTOMATIC_TRANSFER_LENGTH", "5"),
Optional.empty(),
Period.create(1, Unit.YEARS),
@@ -857,8 +870,8 @@ class DomainTransferRequestFlowTest
VKey<BillingRecurrence> existingAutorenewEvent = domain.getAutorenewBillingEvent();
// Set domain to have auto-renewed just before the transfer request, so that it will have an
// active autorenew grace period spanning the entire transfer window.
DateTime autorenewTime = clock.nowUtc().minusDays(1);
DateTime expirationTime = autorenewTime.plusYears(1);
Instant autorenewTime = minusDays(clock.now(), 1);
Instant expirationTime = plusYears(autorenewTime, 1);
domain =
persistResource(
domain
@@ -868,7 +881,8 @@ class DomainTransferRequestFlowTest
GracePeriod.createForRecurrence(
GracePeriodStatus.AUTO_RENEW,
domain.getRepoId(),
autorenewTime.plus(Tld.get("tld").getAutoRenewGracePeriodLength()),
autorenewTime.plusMillis(
Tld.get("tld").getAutoRenewGracePeriodLength().getMillis()),
"TheRegistrar",
existingAutorenewEvent))
.build());
@@ -876,7 +890,7 @@ class DomainTransferRequestFlowTest
doSuccessfulSuperuserExtensionTest(
"domain_transfer_request_superuser_extension.xml",
"domain_transfer_request_response_su_ext_zero_period_autorenew_grace.xml",
domain.getRegistrationExpirationDateTime(),
domain.getRegistrationExpirationTime(),
ImmutableMap.of("PERIOD", "0", "AUTOMATIC_TRANSFER_LENGTH", "0"),
Optional.empty(),
Period.create(0, Unit.YEARS),
@@ -925,7 +939,7 @@ class DomainTransferRequestFlowTest
doSuccessfulSuperuserExtensionTest(
"domain_transfer_request_superuser_extension.xml",
"domain_transfer_request_response_su_ext_zero_period_zero_transfer_length.xml",
domain.getRegistrationExpirationDateTime().plusYears(0),
plusYears(domain.getRegistrationExpirationTime(), 0),
ImmutableMap.of("PERIOD", "0", "AUTOMATIC_TRANSFER_LENGTH", "0"),
Optional.empty(),
Period.create(0, Unit.YEARS),
@@ -942,7 +956,7 @@ class DomainTransferRequestFlowTest
doSuccessfulSuperuserExtensionTest(
"domain_transfer_request_superuser_extension.xml",
"domain_transfer_request_response_su_ext_zero_period_zero_transfer_length.xml",
domain.getRegistrationExpirationDateTime().plusYears(0),
plusYears(domain.getRegistrationExpirationTime(), 0),
ImmutableMap.of("PERIOD", "0", "AUTOMATIC_TRANSFER_LENGTH", "0"),
Optional.empty(),
Period.create(0, Unit.YEARS),
@@ -955,7 +969,7 @@ class DomainTransferRequestFlowTest
// Set the domain to expire 10 years from now (as if it were just created with a 10-year term).
domain =
persistResource(
domain.asBuilder().setRegistrationExpirationTime(clock.nowUtc().plusYears(10)).build());
domain.asBuilder().setRegistrationExpirationTime(plusYears(clock.now(), 10)).build());
// New expiration time should be capped at exactly 10 years from the transfer server-approve
// time, so the domain only ends up gaining the 5-day transfer window's worth of extra
// registration time.
@@ -963,7 +977,8 @@ class DomainTransferRequestFlowTest
doSuccessfulTest(
"domain_transfer_request.xml",
"domain_transfer_request_response_10_year_cap.xml",
clock.nowUtc().plus(Tld.get("tld").getAutomaticTransferLength()).plusYears(10));
plusYears(
clock.now().plusMillis(Tld.get("tld").getAutomaticTransferLength().getMillis()), 10));
}
@Test
@@ -980,7 +995,7 @@ class DomainTransferRequestFlowTest
doSuccessfulTest(
"domain_transfer_request_separate_fees.xml",
"domain_transfer_request_response_fees.xml",
domain.getRegistrationExpirationDateTime().plusYears(1),
plusYears(domain.getRegistrationExpirationTime(), 1),
new ImmutableMap.Builder<String, String>()
.put("DOMAIN", "expensive-domain.foo")
.put("YEARS", "1")
@@ -1046,9 +1061,12 @@ class DomainTransferRequestFlowTest
setupDomain("example", "tld");
// Set the domain to have auto-renewed long enough ago that it is still in the autorenew grace
// period at the transfer request time, but will have exited it by the automatic transfer time.
DateTime autorenewTime =
clock.nowUtc().minus(Tld.get("tld").getAutoRenewGracePeriodLength()).plusDays(1);
DateTime expirationTime = autorenewTime.plusYears(1);
Instant autorenewTime =
clock
.now()
.minusMillis(Tld.get("tld").getAutoRenewGracePeriodLength().getMillis())
.plus(java.time.Duration.ofDays(1));
Instant expirationTime = plusYears(autorenewTime, 1);
domain =
persistResource(
domain
@@ -1058,7 +1076,8 @@ class DomainTransferRequestFlowTest
GracePeriod.createForRecurrence(
GracePeriodStatus.AUTO_RENEW,
domain.getRepoId(),
autorenewTime.plus(Tld.get("tld").getAutoRenewGracePeriodLength()),
autorenewTime.plusMillis(
Tld.get("tld").getAutoRenewGracePeriodLength().getMillis()),
"TheRegistrar",
domain.getAutorenewBillingEvent()))
.build());
@@ -1068,7 +1087,7 @@ class DomainTransferRequestFlowTest
doSuccessfulTest(
"domain_transfer_request.xml",
"domain_transfer_request_response_autorenew_grace_at_request_only.xml",
expirationTime.plusYears(1));
plusYears(expirationTime, 1));
}
@Test
@@ -1077,8 +1096,8 @@ class DomainTransferRequestFlowTest
VKey<BillingRecurrence> existingAutorenewEvent = domain.getAutorenewBillingEvent();
// Set domain to have auto-renewed just before the transfer request, so that it will have an
// active autorenew grace period spanning the entire transfer window.
DateTime autorenewTime = clock.nowUtc().minusDays(1);
DateTime expirationTime = autorenewTime.plusYears(1);
Instant autorenewTime = minusDays(clock.now(), 1);
Instant expirationTime = plusYears(autorenewTime, 1);
domain =
persistResource(
domain
@@ -1088,7 +1107,8 @@ class DomainTransferRequestFlowTest
GracePeriod.createForRecurrence(
GracePeriodStatus.AUTO_RENEW,
domain.getRepoId(),
autorenewTime.plus(Tld.get("tld").getAutoRenewGracePeriodLength()),
autorenewTime.plusMillis(
Tld.get("tld").getAutoRenewGracePeriodLength().getMillis()),
"TheRegistrar",
existingAutorenewEvent))
.build());
@@ -1104,8 +1124,15 @@ class DomainTransferRequestFlowTest
.setTargetId("example.tld")
.setRegistrarId("TheRegistrar")
// The cancellation happens at the moment of transfer.
.setEventTime(clock.nowUtc().plus(Tld.get("tld").getAutomaticTransferLength()))
.setBillingTime(autorenewTime.plus(Tld.get("tld").getAutoRenewGracePeriodLength()))
.setEventTime(
toDateTime(
clock
.now()
.plusMillis(Tld.get("tld").getAutomaticTransferLength().getMillis())))
.setBillingTime(
toDateTime(
autorenewTime.plusMillis(
Tld.get("tld").getAutoRenewGracePeriodLength().getMillis())))
// The cancellation should refer to the old autorenew billing event.
.setBillingRecurrence(existingAutorenewEvent));
}
@@ -1116,7 +1143,7 @@ class DomainTransferRequestFlowTest
VKey<BillingRecurrence> existingAutorenewEvent = domain.getAutorenewBillingEvent();
// Set domain to expire in 1 day, so that it will be in the autorenew grace period by the
// automatic transfer time, even though it isn't yet.
DateTime expirationTime = clock.nowUtc().plusDays(1);
Instant expirationTime = plusDays(clock.now(), 1);
domain =
persistResource(domain.asBuilder().setRegistrationExpirationTime(expirationTime).build());
clock.advanceOneMilli();
@@ -1125,14 +1152,21 @@ class DomainTransferRequestFlowTest
doSuccessfulTest(
"domain_transfer_request.xml",
"domain_transfer_request_response_autorenew_grace_at_transfer_only.xml",
expirationTime.plusYears(1),
plusYears(expirationTime, 1),
new BillingCancellation.Builder()
.setReason(Reason.RENEW)
.setTargetId("example.tld")
.setRegistrarId("TheRegistrar")
// The cancellation happens at the moment of transfer.
.setEventTime(clock.nowUtc().plus(Tld.get("tld").getAutomaticTransferLength()))
.setBillingTime(expirationTime.plus(Tld.get("tld").getAutoRenewGracePeriodLength()))
.setEventTime(
toDateTime(
clock
.now()
.plusMillis(Tld.get("tld").getAutomaticTransferLength().getMillis())))
.setBillingTime(
toDateTime(
expirationTime.plusMillis(
Tld.get("tld").getAutoRenewGracePeriodLength().getMillis())))
// The cancellation should refer to the old autorenew billing event.
.setBillingRecurrence(existingAutorenewEvent));
}
@@ -1175,7 +1209,7 @@ class DomainTransferRequestFlowTest
.asBuilder()
.setRenewalPriceBehavior(RenewalPriceBehavior.NONPREMIUM)
.build());
DateTime now = clock.nowUtc();
Instant now = clock.now();
// This ensures that the transfer has non-premium cost, as otherwise, the fee extension would be
// required to ack the premium price.
@@ -1190,8 +1224,10 @@ class DomainTransferRequestFlowTest
assertBillingEventsForResource(
domain,
new BillingEvent.Builder()
.setBillingTime(now.plusDays(10)) // 5 day pending transfer + 5 day billing grace period
.setEventTime(now.plusDays(5))
.setBillingTime(
toDateTime(
plusDays(now, 10))) // 5 day pending transfer + 5 day billing grace period
.setEventTime(plusDays(now, 5))
.setRegistrarId("NewRegistrar")
.setCost(Money.of(USD, new BigDecimal("11.00")))
.setDomainHistory(requestHistory)
@@ -1206,7 +1242,7 @@ class DomainTransferRequestFlowTest
.build(),
getLosingClientAutorenewEvent()
.asBuilder()
.setRecurrenceEndTime(now.plusDays(5))
.setRecurrenceEndTime(plusDays(now, 5))
.setRenewalPriceBehavior(RenewalPriceBehavior.NONPREMIUM)
.build());
}
@@ -1232,7 +1268,7 @@ class DomainTransferRequestFlowTest
.setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED)
.setRenewalPrice(Money.of(USD, new BigDecimal("18.79")))
.build());
DateTime now = clock.nowUtc();
Instant now = clock.now();
setEppInput("domain_transfer_request.xml");
runFlowAssertResponse(loadFile("domain_transfer_request_response.xml"));
@@ -1245,8 +1281,10 @@ class DomainTransferRequestFlowTest
assertBillingEventsForResource(
domain,
new BillingEvent.Builder()
.setBillingTime(now.plusDays(10)) // 5 day pending transfer + 5 day billing grace period
.setEventTime(now.plusDays(5))
.setBillingTime(
toDateTime(
plusDays(now, 10))) // 5 day pending transfer + 5 day billing grace period
.setEventTime(plusDays(now, 5))
.setRegistrarId("NewRegistrar")
.setCost(Money.of(USD, new BigDecimal("18.79")))
.setDomainHistory(requestHistory)
@@ -1262,7 +1300,7 @@ class DomainTransferRequestFlowTest
.build(),
getLosingClientAutorenewEvent()
.asBuilder()
.setRecurrenceEndTime(now.plusDays(5))
.setRecurrenceEndTime(plusDays(now, 5))
.setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED)
.setRenewalPrice(Money.of(USD, new BigDecimal("18.79")))
.build());
@@ -1293,7 +1331,7 @@ class DomainTransferRequestFlowTest
domain =
persistResource(
domain.asBuilder().setCurrentBulkToken(allocationToken.createVKey()).build());
DateTime now = clock.nowUtc();
Instant now = clock.now();
setEppInput("domain_transfer_request.xml");
runFlowAssertResponse(loadFile("domain_transfer_request_response.xml"));
@@ -1306,8 +1344,10 @@ class DomainTransferRequestFlowTest
assertBillingEventsForResource(
domain,
new BillingEvent.Builder()
.setBillingTime(now.plusDays(10)) // 5 day pending transfer + 5 day billing grace period
.setEventTime(now.plusDays(5))
.setBillingTime(
toDateTime(
plusDays(now, 10))) // 5 day pending transfer + 5 day billing grace period
.setEventTime(plusDays(now, 5))
.setRegistrarId("NewRegistrar")
.setCost(Money.of(USD, new BigDecimal("11.00")))
.setDomainHistory(requestHistory)
@@ -1323,7 +1363,7 @@ class DomainTransferRequestFlowTest
.build(),
getLosingClientAutorenewEvent()
.asBuilder()
.setRecurrenceEndTime(now.plusDays(5))
.setRecurrenceEndTime(plusDays(now, 5))
.setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED)
.setRenewalPrice(Money.of(USD, new BigDecimal("18.79")))
.build());
@@ -1353,7 +1393,7 @@ class DomainTransferRequestFlowTest
domain =
persistResource(
domain.asBuilder().setCurrentBulkToken(allocationToken.createVKey()).build());
DateTime now = clock.nowUtc();
Instant now = clock.now();
setEppInput("domain_transfer_request.xml");
runFlowAssertResponse(loadFile("domain_transfer_request_response.xml"));
@@ -1366,8 +1406,10 @@ class DomainTransferRequestFlowTest
assertBillingEventsForResource(
domain,
new BillingEvent.Builder()
.setBillingTime(now.plusDays(10)) // 5 day pending transfer + 5 day billing grace period
.setEventTime(now.plusDays(5))
.setBillingTime(
toDateTime(
plusDays(now, 10))) // 5 day pending transfer + 5 day billing grace period
.setEventTime(plusDays(now, 5))
.setRegistrarId("NewRegistrar")
.setCost(Money.of(USD, new BigDecimal("11.00")))
.setDomainHistory(requestHistory)
@@ -1383,7 +1425,7 @@ class DomainTransferRequestFlowTest
.build(),
getLosingClientAutorenewEvent()
.asBuilder()
.setRecurrenceEndTime(now.plusDays(5))
.setRecurrenceEndTime(plusDays(now, 5))
.setRenewalPriceBehavior(RenewalPriceBehavior.DEFAULT)
.build());
}
@@ -1416,7 +1458,7 @@ class DomainTransferRequestFlowTest
doSuccessfulSuperuserExtensionTest(
"domain_transfer_request_superuser_extension.xml",
"domain_transfer_request_response_su_ext_zero_period_zero_transfer_length.xml",
domain.getRegistrationExpirationDateTime().plusYears(0),
plusYears(domain.getRegistrationExpirationTime(), 0),
ImmutableMap.of("PERIOD", "0", "AUTOMATIC_TRANSFER_LENGTH", "0"),
Optional.empty(),
Period.create(0, Unit.YEARS),
@@ -1559,7 +1601,7 @@ class DomainTransferRequestFlowTest
.getTransferData()
.asBuilder()
.setTransferStatus(TransferStatus.PENDING)
.setPendingTransferExpirationTime(clock.nowUtc().plusDays(1))
.setPendingTransferExpirationTime(plusDays(clock.now(), 1))
.build())
.build());
EppException thrown =
@@ -1600,8 +1642,7 @@ class DomainTransferRequestFlowTest
@Test
void testFailure_deletedDomain() throws Exception {
setupDomain("example", "tld");
domain =
persistResource(domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
domain = persistResource(domain.asBuilder().setDeletionTime(minusDays(clock.now(), 1)).build());
ResourceDoesNotExistException thrown =
assertThrows(
ResourceDoesNotExistException.class,
@@ -1738,7 +1779,7 @@ class DomainTransferRequestFlowTest
assertThat(persistedEntry.getDomainTransactionRecords())
.containsExactly(
DomainTransactionRecord.create(
"tld", clock.nowUtc().plusDays(5), TRANSFER_SUCCESSFUL, 1));
"tld", plusDays(clock.now(), 5), TRANSFER_SUCCESSFUL, 1));
}
@Test
@@ -1772,11 +1813,11 @@ class DomainTransferRequestFlowTest
.setToken("abc123")
.setTokenType(UNLIMITED_USE)
.setDiscountFraction(0.5)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().plusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(60), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(plusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 60), TokenStatus.ENDED)
.build())
.build());
setEppInput("domain_transfer_request_allocation_token.xml", ImmutableMap.of("TOKEN", "abc123"));
@@ -1793,11 +1834,11 @@ class DomainTransferRequestFlowTest
.setTokenType(UNLIMITED_USE)
.setAllowedRegistrarIds(ImmutableSet.of("someClientId"))
.setDiscountFraction(0.5)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
.put(clock.nowUtc().minusDays(1), TokenStatus.VALID)
.put(clock.nowUtc().plusDays(1), TokenStatus.ENDED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, TokenStatus.NOT_STARTED)
.put(minusDays(clock.now(), 1), TokenStatus.VALID)
.put(plusDays(clock.now(), 1), TokenStatus.ENDED)
.build())
.build());
setEppInput("domain_transfer_request_allocation_token.xml", ImmutableMap.of("TOKEN", "abc123"));
@@ -2031,7 +2072,7 @@ class DomainTransferRequestFlowTest
doSuccessfulTest(
"domain_transfer_request_separate_fees.xml",
"domain_transfer_request_response_fees.xml",
domain.getRegistrationExpirationDateTime().plusYears(1),
plusYears(domain.getRegistrationExpirationTime(), 1),
new ImmutableMap.Builder<String, String>()
.put("DOMAIN", "expensive-domain.foo")
.put("YEARS", "1")
@@ -51,6 +51,9 @@ import static google.registry.testing.DomainSubject.assertAboutDomains;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
import static google.registry.util.DateTimeUtils.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;
@@ -103,9 +106,9 @@ import google.registry.model.poll.PollMessage;
import google.registry.model.tld.Tld;
import google.registry.persistence.VKey;
import google.registry.testing.DatabaseHelper;
import java.time.Instant;
import java.util.Optional;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -138,7 +141,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
}
private Domain persistDomain() throws Exception {
Host host = loadResource(Host.class, "ns1.example.foo", clock.nowUtc()).get();
Host host = loadResource(Host.class, "ns1.example.foo", clock.now()).get();
Domain domain =
persistResource(
DatabaseHelper.newDomain(getUniqueIdFromCommand())
@@ -148,7 +151,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
persistResource(
new DomainHistory.Builder()
.setType(DOMAIN_CREATE)
.setModificationTime(clock.nowUtc())
.setModificationTime(clock.now())
.setRegistrarId(domain.getCreationRegistrarId())
.setDomain(domain)
.build());
@@ -173,7 +176,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
.and()
.hasOneHistoryEntryEachOfTypes(DOMAIN_CREATE, DOMAIN_UPDATE)
.and()
.hasLastEppUpdateTime(clock.nowUtc())
.hasLastEppUpdateTime(clock.now())
.and()
.hasLastEppUpdateRegistrarId("TheRegistrar")
.and()
@@ -234,7 +237,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
.and()
.hasOneHistoryEntryEachOfTypes(DOMAIN_CREATE, DOMAIN_UPDATE)
.and()
.hasLastEppUpdateTime(clock.nowUtc())
.hasLastEppUpdateTime(clock.now())
.and()
.hasLastEppUpdateRegistrarId("TheRegistrar")
.and()
@@ -286,7 +289,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
for (int i = 1; i < 15; i++) {
if (i != 2) { // Skip 2 since that's the one that the tests will add.
nameservers.add(
loadResource(Host.class, String.format("ns%d.example.foo", i), clock.nowUtc())
loadResource(Host.class, String.format("ns%d.example.foo", i), clock.now())
.get()
.createVKey());
}
@@ -378,7 +381,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
.addSubordinateHost("ns2.example.tld")
.setNameservers(
ImmutableSet.of(
loadResource(Host.class, "ns1.example.tld", clock.nowUtc()).get().createVKey()))
loadResource(Host.class, "ns1.example.tld", clock.now()).get().createVKey()))
.build());
clock.advanceOneMilli();
assertMutatingFlow(true);
@@ -386,8 +389,8 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
domain = reloadResourceByForeignKey();
assertThat(domain.getNameservers()).containsExactly(addedHost.createVKey());
assertThat(domain.getSubordinateHosts()).containsExactly("ns1.example.tld", "ns2.example.tld");
Host existingHost = loadResource(Host.class, "ns1.example.tld", clock.nowUtc()).get();
addedHost = loadResource(Host.class, "ns2.example.tld", clock.nowUtc()).get();
Host existingHost = loadResource(Host.class, "ns1.example.tld", clock.now()).get();
addedHost = loadResource(Host.class, "ns2.example.tld", clock.now()).get();
assertThat(existingHost.getSuperordinateDomain()).isEqualTo(domain.createVKey());
assertThat(addedHost.getSuperordinateDomain()).isEqualTo(domain.createVKey());
}
@@ -797,8 +800,8 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
.setTargetId("example.tld")
.setRegistrarId("TheRegistrar")
.setCost(Money.of(USD, 19))
.setEventTime(clock.nowUtc())
.setBillingTime(clock.nowUtc())
.setEventTime(clock.now())
.setBillingTime(clock.now())
.setDomainHistory(
getOnlyHistoryEntryOfType(
reloadResourceByForeignKey(), DOMAIN_UPDATE, DomainHistory.class))
@@ -1095,17 +1098,14 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
assertPollMessagesForResource(
updatedDomain,
new PollMessage.OneTime.Builder()
.setEventTime(clock.nowUtc())
.setEventTime(clock.now())
.setHistoryEntry(getOnlyHistoryEntryOfType(updatedDomain, DOMAIN_UPDATE))
.setRegistrarId("NewRegistrar")
.setMsg("The registry administrator has added the status(es) [serverHold].")
.setResponseData(
ImmutableList.of(
DomainPendingActionNotificationResponse.create(
"example.tld",
true,
Trid.create("ABC-12345", "server-trid"),
clock.nowUtc())))
"example.tld", true, Trid.create("ABC-12345", "server-trid"), clock.now())))
.build());
}
@@ -1134,7 +1134,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
assertPollMessagesForResource(
updatedDomain,
new PollMessage.OneTime.Builder()
.setEventTime(clock.nowUtc())
.setEventTime(clock.now())
.setHistoryEntry(getOnlyHistoryEntryOfType(updatedDomain, DOMAIN_UPDATE))
.setRegistrarId("NewRegistrar")
.setMsg(
@@ -1143,10 +1143,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
.setResponseData(
ImmutableList.of(
DomainPendingActionNotificationResponse.create(
"example.tld",
true,
Trid.create("ABC-12345", "server-trid"),
clock.nowUtc())))
"example.tld", true, Trid.create("ABC-12345", "server-trid"), clock.now())))
.build());
}
@@ -1172,7 +1169,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
assertPollMessagesForResource(
updatedDomain,
new PollMessage.OneTime.Builder()
.setEventTime(clock.nowUtc())
.setEventTime(clock.now())
.setHistoryEntry(getOnlyHistoryEntryOfType(updatedDomain, DOMAIN_UPDATE))
.setRegistrarId("NewRegistrar")
.setMsg(
@@ -1182,10 +1179,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
.setResponseData(
ImmutableList.of(
DomainPendingActionNotificationResponse.create(
"example.tld",
true,
Trid.create("ABC-12345", "server-trid"),
clock.nowUtc())))
"example.tld", true, Trid.create("ABC-12345", "server-trid"), clock.now())))
.build());
}
@@ -1262,7 +1256,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
persistResource(
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setDeletionTime(clock.nowUtc().plusDays(1))
.setDeletionTime(plusDays(clock.now(), 1))
.addStatusValue(PENDING_DELETE)
.build());
ResourceStatusProhibitsOperationException thrown =
@@ -1319,7 +1313,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
.asBuilder()
.setNameservers(
ImmutableSet.of(
loadResource(Host.class, "ns1.example.foo", clock.nowUtc()).get().createVKey()))
loadResource(Host.class, "ns1.example.foo", clock.now()).get().createVKey()))
.build());
EppException thrown = assertThrows(AddRemoveSameValueException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
@@ -1387,7 +1381,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
persistReferencedEntities();
persistDomain();
persistResource(
loadResource(Host.class, "ns2.example.foo", clock.nowUtc())
loadResource(Host.class, "ns2.example.foo", clock.now())
.get()
.asBuilder()
.addStatusValue(PENDING_DELETE)
@@ -1422,7 +1416,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
reloadResourceByForeignKey()
.asBuilder()
.addNameserver(
loadResource(Host.class, "ns2.example.foo", clock.nowUtc()).get().createVKey())
loadResource(Host.class, "ns2.example.foo", clock.now()).get().createVKey())
.build());
persistResource(
Tld.get("tld")
@@ -1431,12 +1425,12 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
ImmutableSet.of("ns1.example.foo", "ns2.example.foo"))
.build());
assertThat(reloadResourceByForeignKey().getNameservers())
.contains(loadResource(Host.class, "ns1.example.foo", clock.nowUtc()).get().createVKey());
.contains(loadResource(Host.class, "ns1.example.foo", clock.now()).get().createVKey());
clock.advanceOneMilli();
runFlow();
assertThat(reloadResourceByForeignKey().getNameservers())
.doesNotContain(
loadResource(Host.class, "ns1.example.foo", clock.nowUtc())
loadResource(Host.class, "ns1.example.foo", clock.now())
.map(ImmutableObject::createVKey)
.get());
}
@@ -1491,7 +1485,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
void testSuperuserExtension_turnsOffAutorenew() throws Exception {
eppRequestSource = EppRequestSource.TOOL;
setEppInput("domain_update_superuser_extension.xml", ImmutableMap.of("AUTORENEWS", "false"));
DateTime expirationTime = clock.nowUtc().plusYears(3);
Instant expirationTime = plusYears(clock.now(), 3);
persistReferencedEntities();
persistResource(
persistDomain().asBuilder().setRegistrationExpirationTime(expirationTime).build());
@@ -1504,12 +1498,12 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
void testSuperuserExtension_turnsOnAutorenew() throws Exception {
eppRequestSource = EppRequestSource.TOOL;
setEppInput("domain_update_superuser_extension.xml", ImmutableMap.of("AUTORENEWS", "true"));
DateTime expirationTime = clock.nowUtc().plusYears(3);
Instant expirationTime = plusYears(clock.now(), 3);
persistReferencedEntities();
persistResource(
persistDomain()
.asBuilder()
.setAutorenewEndTime(Optional.of(expirationTime))
.setAutorenewEndTime(Optional.of(toDateTime(expirationTime)))
.setRegistrationExpirationTime(expirationTime)
.build());
clock.advanceOneMilli();
@@ -86,7 +86,7 @@ public class ProductionSimulatingFeeExtensionsTest
FEE_EXTENSION_1_DOT_0_IN_PROD.name(),
"--force",
"--status_map",
String.format("%s=INACTIVE,%s=ACTIVE", START_OF_TIME, fakeClock.nowUtc().plusMillis(1)));
String.format("%s=INACTIVE,%s=ACTIVE", START_OF_TIME, fakeClock.now().plusMillis(1)));
RegistryEnvironment.PRODUCTION.setup();
ProtocolDefinition.reloadServiceExtensionUris();
// prod shouldn't have the fee extension version 1.0
@@ -107,7 +107,7 @@ public class ProductionSimulatingFeeExtensionsTest
FEE_EXTENSION_1_DOT_0_IN_PROD.name(),
"--force",
"--status_map",
String.format("%s=INACTIVE,%s=ACTIVE", START_OF_TIME, fakeClock.nowUtc().minusMillis(1)));
String.format("%s=INACTIVE,%s=ACTIVE", START_OF_TIME, fakeClock.now().minusMillis(1)));
RegistryEnvironment.PRODUCTION.setup();
ProtocolDefinition.reloadServiceExtensionUris();
// prod should have the fee extension version 1.0
@@ -25,7 +25,11 @@ import static google.registry.model.domain.token.AllocationToken.TokenType.UNLIM
import static google.registry.testing.DatabaseHelper.createTld;
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 google.registry.util.DateTimeUtils.START_INSTANT;
import static google.registry.util.DateTimeUtils.minusDays;
import static google.registry.util.DateTimeUtils.minusMonths;
import static google.registry.util.DateTimeUtils.plusDays;
import static google.registry.util.DateTimeUtils.plusMonths;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -49,8 +53,9 @@ import google.registry.model.tld.Tld;
import google.registry.persistence.transaction.JpaTestExtensions;
import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension;
import google.registry.testing.FakeClock;
import java.time.Duration;
import java.time.Instant;
import java.util.Optional;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -58,7 +63,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
/** Unit tests for {@link AllocationTokenFlowUtils}. */
class AllocationTokenFlowUtilsTest {
private final FakeClock clock = new FakeClock(DateTime.parse("2025-01-10T01:00:00.000Z"));
private final FakeClock clock = new FakeClock(Instant.parse("2025-01-10T01:00:00.000Z"));
@RegisterExtension
final JpaIntegrationTestExtension jpa =
@@ -247,7 +252,7 @@ class AllocationTokenFlowUtilsTest {
IllegalArgumentException.class,
() ->
AllocationTokenFlowUtils.redeemToken(
createOneMonthPromoTokenBuilder(clock.nowUtc()).build(),
createOneMonthPromoTokenBuilder(clock.now()).build(),
new HistoryEntryId("repoId", 10L)));
}
@@ -265,7 +270,7 @@ class AllocationTokenFlowUtilsTest {
@Test
void testFailure_tokenInvalidForRegistrar() {
persistResource(
createOneMonthPromoTokenBuilder(clock.nowUtc().minusDays(1))
createOneMonthPromoTokenBuilder(minusDays(clock.now(), 1))
.setAllowedRegistrarIds(ImmutableSet.of("NewRegistrar"))
.build());
assertLoadTokenFromExtensionThrowsException(AllocationTokenNotValidForRegistrarException.class);
@@ -273,13 +278,13 @@ class AllocationTokenFlowUtilsTest {
@Test
void testFailure_beforePromoStart() {
persistResource(createOneMonthPromoTokenBuilder(clock.nowUtc().plusDays(1)).build());
persistResource(createOneMonthPromoTokenBuilder(plusDays(clock.now(), 1)).build());
assertLoadTokenFromExtensionThrowsException(AllocationTokenNotInPromotionException.class);
}
@Test
void testFailure_afterPromoEnd() {
persistResource(createOneMonthPromoTokenBuilder(clock.nowUtc().minusMonths(2)).build());
persistResource(createOneMonthPromoTokenBuilder(minusMonths(clock.now(), 2)).build());
assertLoadTokenFromExtensionThrowsException(AllocationTokenNotInPromotionException.class);
}
@@ -287,12 +292,12 @@ class AllocationTokenFlowUtilsTest {
void testFailure_promoCancelled() {
// the promo would be valid, but it was cancelled 12 hours ago
persistResource(
createOneMonthPromoTokenBuilder(clock.nowUtc().minusDays(1))
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, NOT_STARTED)
.put(clock.nowUtc().minusMonths(1), VALID)
.put(clock.nowUtc().minusHours(12), CANCELLED)
createOneMonthPromoTokenBuilder(minusDays(clock.now(), 1))
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, NOT_STARTED)
.put(minusMonths(clock.now(), 1), VALID)
.put(clock.now().minus(Duration.ofHours(12)), CANCELLED)
.build())
.build());
assertLoadTokenFromExtensionThrowsException(AllocationTokenNotInPromotionException.class);
@@ -475,16 +480,16 @@ class AllocationTokenFlowUtilsTest {
.setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar"));
}
private AllocationToken.Builder createOneMonthPromoTokenBuilder(DateTime promoStart) {
private AllocationToken.Builder createOneMonthPromoTokenBuilder(Instant promoStart) {
when(allocationTokenExtension.getAllocationToken()).thenReturn("tokeN");
return new AllocationToken.Builder()
.setToken("tokeN")
.setTokenType(UNLIMITED_USE)
.setTokenStatusTransitions(
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
.put(START_OF_TIME, NOT_STARTED)
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, NOT_STARTED)
.put(promoStart, VALID)
.put(promoStart.plusMonths(1), ENDED)
.put(plusMonths(promoStart, 1), ENDED)
.build());
}
}
@@ -345,7 +345,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Host> {
Host deletedHost = reloadResourceByForeignKey(clock.nowUtc().minusMillis(1));
assertAboutHosts()
.that(deletedHost)
.isNotActiveAt(clock.nowUtc())
.isNotActiveAt(clock.now())
.and()
.hasExactlyStatusValues(StatusValue.OK)
.and()
@@ -408,7 +408,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
.and()
.hasLastSuperordinateChange(clock.nowUtc());
assertThat(renamedHost.getLastTransferTime()).isEqualTo(oneDayAgo);
Domain reloadedDomain = loadByEntity(domain).cloneProjectedAtTime(clock.nowUtc());
Domain reloadedDomain = loadByEntity(domain).cloneProjectedAtInstant(clock.now());
assertThat(reloadedDomain.getSubordinateHosts()).isEmpty();
assertHostDnsRequests("ns1.example.foo");
}
@@ -17,6 +17,7 @@ package google.registry.model;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import static google.registry.testing.DatabaseHelper.loadByEntity;
import static google.registry.util.DateTimeUtils.minusDays;
import google.registry.model.common.CrossTldSingleton;
import google.registry.persistence.transaction.JpaTestExtensions;
@@ -24,7 +25,6 @@ import google.registry.persistence.transaction.JpaTestExtensions.JpaUnitTestExte
import google.registry.testing.FakeClock;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import java.time.Duration;
import java.time.Instant;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -67,7 +67,7 @@ public class CreateAutoTimestampTest {
@Test
void testResavingRespectsOriginalTime() {
final Instant oldCreateTime = clock.now().minus(Duration.ofDays(1));
final Instant oldCreateTime = minusDays(clock.now(), 1);
tm().transact(
() -> {
CreateAutoTimestampTestObject object = new CreateAutoTimestampTestObject();
@@ -17,6 +17,7 @@ package google.registry.model;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import static google.registry.util.DateTimeUtils.START_INSTANT;
import static google.registry.util.DateTimeUtils.minusDays;
import google.registry.model.common.CrossTldSingleton;
import google.registry.persistence.VKey;
@@ -25,7 +26,6 @@ import google.registry.persistence.transaction.JpaTestExtensions.JpaUnitTestExte
import google.registry.testing.FakeClock;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import java.time.Duration;
import java.time.Instant;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -75,8 +75,7 @@ public class UpdateAutoTimestampTest {
() -> {
clock.advanceOneMilli();
UpdateAutoTimestampTestObject object = new UpdateAutoTimestampTestObject();
object.updateTime =
UpdateAutoTimestamp.create(clock.now().minus(Duration.ofDays(1)));
object.updateTime = UpdateAutoTimestamp.create(minusDays(clock.now(), 1));
tm().insert(object);
return tm().getTxTime();
});
@@ -15,7 +15,7 @@
package google.registry.model.adapters;
import static com.google.common.truth.Truth.assertThat;
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 com.google.common.collect.ImmutableMap;
@@ -46,7 +46,7 @@ public class StatusValueAdapterTest {
.setResData(
HostInfoData.newBuilder()
.setCreationRegistrarId("")
.setCreationTime(START_OF_TIME)
.setCreationTime(START_INSTANT)
.setCurrentSponsorRegistrarId("")
.setHostName("")
.setInetAddresses(ImmutableSet.of())
@@ -28,6 +28,7 @@ import static google.registry.testing.SqlHelper.assertThrowForeignKeyViolation;
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.plusDays;
import static google.registry.util.DateTimeUtils.plusYears;
import com.google.common.collect.ImmutableList;
@@ -131,7 +132,7 @@ public class DomainSqlTest {
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, NOT_STARTED)
.put(fakeClock.now(), TokenStatus.VALID)
.put(fakeClock.now().plus(java.time.Duration.ofDays(56)), TokenStatus.ENDED)
.put(plusDays(fakeClock.now(), 56), TokenStatus.ENDED)
.build())
.build();
}
@@ -28,6 +28,7 @@ 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.plusDays;
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.collect.ImmutableSet;
@@ -77,7 +78,7 @@ public class AllocationTokenTest extends EntityTestCase {
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, NOT_STARTED)
.put(fakeClock.now(), TokenStatus.VALID)
.put(fakeClock.now().plus(java.time.Duration.ofDays(56)), TokenStatus.ENDED)
.put(plusDays(fakeClock.now(), 56), TokenStatus.ENDED)
.build())
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE, CommandName.RENEW))
.build());
@@ -114,7 +115,7 @@ public class AllocationTokenTest extends EntityTestCase {
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, NOT_STARTED)
.put(fakeClock.now(), TokenStatus.VALID)
.put(fakeClock.now().plus(java.time.Duration.ofDays(56)), TokenStatus.ENDED)
.put(plusDays(fakeClock.now(), 56), TokenStatus.ENDED)
.build())
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE, CommandName.RENEW))
.build());
@@ -422,12 +423,8 @@ public class AllocationTokenTest extends EntityTestCase {
.setTokenStatusTransitionsInstant(
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(fakeClock.now(), NOT_STARTED)
.put(
fakeClock.now().plus(java.time.Duration.ofDays(1)),
TokenStatus.VALID)
.put(
fakeClock.now().plus(java.time.Duration.ofDays(2)),
TokenStatus.ENDED)
.put(plusDays(fakeClock.now(), 1), TokenStatus.VALID)
.put(plusDays(fakeClock.now(), 2), TokenStatus.ENDED)
.build()));
assertThat(thrown)
.hasMessageThat()
@@ -465,7 +462,7 @@ public class AllocationTokenTest extends EntityTestCase {
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, NOT_STARTED)
.put(fakeClock.now(), VALID)
.put(fakeClock.now().plus(java.time.Duration.ofDays(1)), VALID)
.put(plusDays(fakeClock.now(), 1), VALID)
.build(),
VALID,
VALID);
@@ -473,7 +470,7 @@ public class AllocationTokenTest extends EntityTestCase {
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, NOT_STARTED)
.put(fakeClock.now(), VALID)
.put(fakeClock.now().plus(java.time.Duration.ofDays(1)), NOT_STARTED)
.put(plusDays(fakeClock.now(), 1), NOT_STARTED)
.build(),
VALID,
NOT_STARTED);
@@ -741,8 +738,8 @@ public class AllocationTokenTest extends EntityTestCase {
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
.put(START_INSTANT, NOT_STARTED)
.put(fakeClock.now(), VALID)
.put(fakeClock.now().plus(java.time.Duration.ofDays(1)), status)
.put(fakeClock.now().plus(java.time.Duration.ofDays(2)), CANCELLED)
.put(plusDays(fakeClock.now(), 1), status)
.put(plusDays(fakeClock.now(), 2), CANCELLED)
.build()));
assertThat(thrown)
.hasMessageThat()
@@ -21,6 +21,7 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.
import com.google.common.collect.ImmutableMap;
import google.registry.model.EntityTestCase;
import jakarta.persistence.OptimisticLockException;
import java.time.Duration;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.jupiter.api.Test;
@@ -34,7 +35,7 @@ public class SignedMarkRevocationListDaoTest extends EntityTestCase {
void testSave_success() {
SignedMarkRevocationList list =
SignedMarkRevocationList.create(
fakeClock.nowUtc(), ImmutableMap.of("mark", fakeClock.nowUtc().minusHours(1)));
fakeClock.now(), ImmutableMap.of("mark", fakeClock.now().minus(Duration.ofHours(1))));
list = SignedMarkRevocationListDao.save(list);
SignedMarkRevocationList fromDb = SignedMarkRevocationListDao.load();
assertAboutImmutableObjects().that(fromDb).isEqualExceptFields(list);
@@ -44,7 +45,7 @@ public class SignedMarkRevocationListDaoTest extends EntityTestCase {
void testSave_retrySuccess() {
SignedMarkRevocationList list =
SignedMarkRevocationList.create(
fakeClock.nowUtc(), ImmutableMap.of("mark", fakeClock.nowUtc().minusHours(1)));
fakeClock.now(), ImmutableMap.of("mark", fakeClock.now().minus(Duration.ofHours(1))));
AtomicBoolean isFirstAttempt = new AtomicBoolean(true);
tm().transact(
() -> {
@@ -61,7 +62,7 @@ public class SignedMarkRevocationListDaoTest extends EntityTestCase {
@Test
void testSaveAndLoad_emptyList() {
SignedMarkRevocationList list =
SignedMarkRevocationList.create(fakeClock.nowUtc(), ImmutableMap.of());
SignedMarkRevocationList.create(fakeClock.now(), ImmutableMap.of());
SignedMarkRevocationListDao.save(list);
SignedMarkRevocationList fromDb = SignedMarkRevocationListDao.load();
assertAboutImmutableObjects().that(fromDb).isEqualExceptFields(list, "revisionId");
@@ -71,17 +72,14 @@ public class SignedMarkRevocationListDaoTest extends EntityTestCase {
void testSave_multipleVersions() {
SignedMarkRevocationList list =
SignedMarkRevocationList.create(
fakeClock.nowUtc(), ImmutableMap.of("mark", fakeClock.nowUtc().minusHours(1)));
fakeClock.now(), ImmutableMap.of("mark", fakeClock.now().minus(Duration.ofHours(1))));
SignedMarkRevocationListDao.save(list);
assertThat(SignedMarkRevocationListDao.load().isSmdRevoked("mark", fakeClock.nowUtc()))
.isTrue();
assertThat(SignedMarkRevocationListDao.load().isSmdRevoked("mark", fakeClock.now())).isTrue();
// Now remove the revocation
SignedMarkRevocationList secondList =
SignedMarkRevocationList.create(fakeClock.nowUtc(), ImmutableMap.of());
SignedMarkRevocationList.create(fakeClock.now(), ImmutableMap.of());
SignedMarkRevocationListDao.save(secondList);
assertThat(SignedMarkRevocationListDao.load().isSmdRevoked("mark", fakeClock.nowUtc()))
.isFalse();
assertThat(SignedMarkRevocationListDao.load().isSmdRevoked("mark", fakeClock.now())).isFalse();
}
}
@@ -15,7 +15,7 @@
package google.registry.model.smd;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static google.registry.util.DateTimeUtils.START_INSTANT;
import static org.joda.time.Duration.standardDays;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -23,7 +23,7 @@ import com.google.common.collect.ImmutableMap;
import google.registry.persistence.transaction.JpaTestExtensions;
import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension;
import google.registry.testing.FakeClock;
import org.joda.time.DateTime;
import java.time.Instant;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -34,22 +34,21 @@ public class SignedMarkRevocationListTest {
final JpaIntegrationTestExtension jpa =
new JpaTestExtensions.Builder().buildIntegrationTestExtension();
private final FakeClock clock = new FakeClock(DateTime.parse("2013-01-01T00:00:00Z"));
private final FakeClock clock = new FakeClock(Instant.parse("2013-01-01T00:00:00Z"));
@Test
void testEmpty() {
// When Cloud SQL is empty, it should give us an empty thing.
assertThat(SignedMarkRevocationList.get())
.isEqualTo(SignedMarkRevocationList.create(START_OF_TIME, ImmutableMap.of()));
.isEqualTo(SignedMarkRevocationList.create(START_INSTANT, ImmutableMap.of()));
}
private SignedMarkRevocationList createSaveGetHelper(int rows) {
ImmutableMap.Builder<String, DateTime> revokes = new ImmutableMap.Builder<>();
ImmutableMap.Builder<String, Instant> revokes = new ImmutableMap.Builder<>();
for (int i = 0; i < rows; i++) {
revokes.put(Integer.toString(i), clock.nowUtc());
revokes.put(Integer.toString(i), clock.now());
}
SignedMarkRevocationListDao.save(
SignedMarkRevocationList.create(clock.nowUtc(), revokes.build()));
SignedMarkRevocationListDao.save(SignedMarkRevocationList.create(clock.now(), revokes.build()));
SignedMarkRevocationList res = SignedMarkRevocationList.get();
assertThat(res.size()).isEqualTo(rows);
return res;
@@ -60,36 +59,36 @@ public class SignedMarkRevocationListTest {
assertThrows(
NullPointerException.class,
() ->
SignedMarkRevocationList.create(START_OF_TIME, ImmutableMap.of())
.isSmdRevoked(null, clock.nowUtc()));
SignedMarkRevocationList.create(START_INSTANT, ImmutableMap.of())
.isSmdRevoked(null, clock.now()));
}
@Test
void test_isSmdRevoked_garbage() {
SignedMarkRevocationList smdrl = createSaveGetHelper(100);
assertThat(smdrl.getCreationTime()).isEqualTo(clock.nowUtc());
assertThat(smdrl.isSmdRevoked("rofl", clock.nowUtc())).isFalse();
assertThat(smdrl.isSmdRevoked("31337", clock.nowUtc())).isFalse();
assertThat(smdrl.getCreationTime()).isEqualTo(clock.now());
assertThat(smdrl.isSmdRevoked("rofl", clock.now())).isFalse();
assertThat(smdrl.isSmdRevoked("31337", clock.now())).isFalse();
}
@Test
void test_getCreationTime() {
clock.setTo(DateTime.parse("2000-01-01T00:00:00Z"));
clock.setTo(Instant.parse("2000-01-01T00:00:00Z"));
createSaveGetHelper(5);
assertThat(SignedMarkRevocationList.get().getCreationTime())
.isEqualTo(DateTime.parse("2000-01-01T00:00:00Z"));
.isEqualTo(Instant.parse("2000-01-01T00:00:00Z"));
clock.advanceBy(standardDays(1));
assertThat(SignedMarkRevocationList.get().getCreationTime())
.isEqualTo(DateTime.parse("2000-01-01T00:00:00Z"));
.isEqualTo(Instant.parse("2000-01-01T00:00:00Z"));
}
@Test
void test_isSmdRevoked_present() {
final int rows = 100;
SignedMarkRevocationList smdrl = createSaveGetHelper(rows);
assertThat(smdrl.isSmdRevoked("0", clock.nowUtc())).isTrue();
assertThat(smdrl.isSmdRevoked(Integer.toString(rows - 1), clock.nowUtc())).isTrue();
assertThat(smdrl.isSmdRevoked(Integer.toString(rows), clock.nowUtc())).isFalse();
assertThat(smdrl.isSmdRevoked("0", clock.now())).isTrue();
assertThat(smdrl.isSmdRevoked(Integer.toString(rows - 1), clock.now())).isTrue();
assertThat(smdrl.isSmdRevoked(Integer.toString(rows), clock.now())).isFalse();
}
@Test
@@ -97,18 +96,18 @@ public class SignedMarkRevocationListTest {
final int rows = 100;
SignedMarkRevocationList smdrl = createSaveGetHelper(rows);
clock.advanceOneMilli();
assertThat(smdrl.isSmdRevoked("0", clock.nowUtc())).isTrue();
assertThat(smdrl.isSmdRevoked(Integer.toString(rows - 1), clock.nowUtc())).isTrue();
assertThat(smdrl.isSmdRevoked(Integer.toString(rows), clock.nowUtc())).isFalse();
assertThat(smdrl.isSmdRevoked("0", clock.now())).isTrue();
assertThat(smdrl.isSmdRevoked(Integer.toString(rows - 1), clock.now())).isTrue();
assertThat(smdrl.isSmdRevoked(Integer.toString(rows), clock.now())).isFalse();
}
@Test
void test_isSmdRevoked_past() {
final int rows = 100;
SignedMarkRevocationList smdrl = createSaveGetHelper(rows);
clock.setTo(clock.nowUtc().minusMillis(1));
assertThat(smdrl.isSmdRevoked("0", clock.nowUtc())).isFalse();
assertThat(smdrl.isSmdRevoked(Integer.toString(rows - 1), clock.nowUtc())).isFalse();
assertThat(smdrl.isSmdRevoked(Integer.toString(rows), clock.nowUtc())).isFalse();
clock.setTo(clock.now().minusMillis(1));
assertThat(smdrl.isSmdRevoked("0", clock.now())).isFalse();
assertThat(smdrl.isSmdRevoked(Integer.toString(rows - 1), clock.now())).isFalse();
assertThat(smdrl.isSmdRevoked(Integer.toString(rows), clock.now())).isFalse();
}
}
@@ -69,8 +69,8 @@ public class ClaimsListDaoTest {
}
});
ClaimsList insertedClaimsList = ClaimsListDao.get();
assertThat(insertedClaimsList.getTmdbGenerationTimeInstant())
.isEqualTo(claimsList.getTmdbGenerationTimeInstant());
assertThat(insertedClaimsList.getTmdbGenerationTime())
.isEqualTo(claimsList.getTmdbGenerationTime());
assertThat(insertedClaimsList.getLabelsToKeys()).isEqualTo(claimsList.getLabelsToKeys());
assertThat(insertedClaimsList.getCreationTime()).isEqualTo(fakeClock.now());
}
@@ -140,7 +140,7 @@ public class ClaimsListDaoTest {
private void assertClaimsListEquals(ClaimsList left, ClaimsList right) {
assertThat(left.getRevisionId()).isEqualTo(right.getRevisionId());
assertThat(left.getTmdbGenerationTimeInstant()).isEqualTo(right.getTmdbGenerationTimeInstant());
assertThat(left.getTmdbGenerationTime()).isEqualTo(right.getTmdbGenerationTime());
assertThat(left.getLabelsToKeys()).isEqualTo(right.getLabelsToKeys());
}
}
@@ -21,7 +21,7 @@ import static google.registry.pricing.PricingEngineProxy.isDomainPremium;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.persistPremiumList;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static google.registry.util.DateTimeUtils.START_INSTANT;
import static org.joda.money.CurrencyUnit.USD;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -32,8 +32,8 @@ import google.registry.persistence.transaction.JpaTestExtensions;
import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension;
import google.registry.testing.FakeClock;
import google.registry.util.Clock;
import java.time.Instant;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -54,39 +54,39 @@ public class PricingEngineProxyTest {
"premium list", USD, "rich,USD 100", "richer,USD 999", "fraction,USD 20.50");
createTld("moka");
persistResource(Tld.get("moka").asBuilder().setPremiumList(premiumList).build());
clock = new FakeClock(DateTime.parse("2016-03-17T12:01:00Z"));
clock = new FakeClock(Instant.parse("2016-03-17T12:01:00Z"));
}
@Test
void test_getDomainCreateCost_multipleYears() {
assertThat(getDomainCreateCost("espresso.moka", clock.nowUtc(), 1))
assertThat(getDomainCreateCost("espresso.moka", clock.now(), 1))
.isEqualTo(Money.parse("USD 13"));
assertThat(getDomainCreateCost("espresso.moka", clock.nowUtc(), 5))
assertThat(getDomainCreateCost("espresso.moka", clock.now(), 5))
.isEqualTo(Money.parse("USD 65"));
assertThat(getDomainCreateCost("fraction.moka", clock.nowUtc(), 1))
assertThat(getDomainCreateCost("fraction.moka", clock.now(), 1))
.isEqualTo(Money.parse("USD 20.50"));
assertThat(getDomainCreateCost("fraction.moka", clock.nowUtc(), 3))
assertThat(getDomainCreateCost("fraction.moka", clock.now(), 3))
.isEqualTo(Money.parse("USD 61.50"));
}
@Test
void test_getDomainRenewCost_multipleYears() {
assertThat(getDomainRenewCost("espresso.moka", clock.nowUtc(), 1))
assertThat(getDomainRenewCost("espresso.moka", clock.now(), 1))
.isEqualTo(Money.parse("USD 11"));
assertThat(getDomainRenewCost("espresso.moka", clock.nowUtc(), 5))
assertThat(getDomainRenewCost("espresso.moka", clock.now(), 5))
.isEqualTo(Money.parse("USD 55"));
assertThat(getDomainRenewCost("fraction.moka", clock.nowUtc(), 1))
assertThat(getDomainRenewCost("fraction.moka", clock.now(), 1))
.isEqualTo(Money.parse("USD 20.50"));
assertThat(getDomainRenewCost("fraction.moka", clock.nowUtc(), 3))
assertThat(getDomainRenewCost("fraction.moka", clock.now(), 3))
.isEqualTo(Money.parse("USD 61.50"));
}
@Test
void testIsPremiumDomain() {
createTld("example");
assertThat(isDomainPremium("poor.example", clock.nowUtc())).isFalse();
assertThat(isDomainPremium("rich.example", clock.nowUtc())).isTrue();
assertThat(isDomainPremium("richer.example", clock.nowUtc())).isTrue();
assertThat(isDomainPremium("poor.example", clock.now())).isFalse();
assertThat(isDomainPremium("rich.example", clock.now())).isTrue();
assertThat(isDomainPremium("richer.example", clock.now())).isTrue();
}
@Test
@@ -94,12 +94,10 @@ public class PricingEngineProxyTest {
// The example tld has a premium price for "rich".
createTld("example");
// The default value of 17 is set in createTld().
assertThat(getDomainCreateCost("poor.example", clock.nowUtc(), 1)).isEqualTo(Money.of(USD, 13));
assertThat(getDomainCreateCost("poor.example", clock.nowUtc(), 2)).isEqualTo(Money.of(USD, 26));
assertThat(getDomainCreateCost("rich.example", clock.nowUtc(), 1))
.isEqualTo(Money.of(USD, 100));
assertThat(getDomainCreateCost("rich.example", clock.nowUtc(), 2))
.isEqualTo(Money.of(USD, 200));
assertThat(getDomainCreateCost("poor.example", clock.now(), 1)).isEqualTo(Money.of(USD, 13));
assertThat(getDomainCreateCost("poor.example", clock.now(), 2)).isEqualTo(Money.of(USD, 26));
assertThat(getDomainCreateCost("rich.example", clock.now(), 1)).isEqualTo(Money.of(USD, 100));
assertThat(getDomainCreateCost("rich.example", clock.now(), 2)).isEqualTo(Money.of(USD, 200));
}
@Test
@@ -109,18 +107,18 @@ public class PricingEngineProxyTest {
persistResource(
Tld.get("example")
.asBuilder()
.setRenewBillingCostTransitions(
.setRenewBillingCostTransitionsInstant(
ImmutableSortedMap.of(
START_OF_TIME, Money.of(USD, 8), clock.nowUtc(), Money.of(USD, 10)))
START_INSTANT, Money.of(USD, 8), clock.now(), Money.of(USD, 10)))
.build());
assertThat(getDomainRenewCost("poor.example", START_OF_TIME, 1)).isEqualTo(Money.of(USD, 8));
assertThat(getDomainRenewCost("poor.example", START_OF_TIME, 2)).isEqualTo(Money.of(USD, 16));
assertThat(getDomainRenewCost("poor.example", clock.nowUtc(), 1)).isEqualTo(Money.of(USD, 10));
assertThat(getDomainRenewCost("poor.example", clock.nowUtc(), 2)).isEqualTo(Money.of(USD, 20));
assertThat(getDomainRenewCost("rich.example", START_OF_TIME, 1)).isEqualTo(Money.of(USD, 100));
assertThat(getDomainRenewCost("rich.example", START_OF_TIME, 2)).isEqualTo(Money.of(USD, 200));
assertThat(getDomainRenewCost("rich.example", clock.nowUtc(), 1)).isEqualTo(Money.of(USD, 100));
assertThat(getDomainRenewCost("rich.example", clock.nowUtc(), 2)).isEqualTo(Money.of(USD, 200));
assertThat(getDomainRenewCost("poor.example", START_INSTANT, 1)).isEqualTo(Money.of(USD, 8));
assertThat(getDomainRenewCost("poor.example", START_INSTANT, 2)).isEqualTo(Money.of(USD, 16));
assertThat(getDomainRenewCost("poor.example", clock.now(), 1)).isEqualTo(Money.of(USD, 10));
assertThat(getDomainRenewCost("poor.example", clock.now(), 2)).isEqualTo(Money.of(USD, 20));
assertThat(getDomainRenewCost("rich.example", START_INSTANT, 1)).isEqualTo(Money.of(USD, 100));
assertThat(getDomainRenewCost("rich.example", START_INSTANT, 2)).isEqualTo(Money.of(USD, 200));
assertThat(getDomainRenewCost("rich.example", clock.now(), 1)).isEqualTo(Money.of(USD, 100));
assertThat(getDomainRenewCost("rich.example", clock.now(), 2)).isEqualTo(Money.of(USD, 200));
}
@Test
@@ -129,8 +127,7 @@ public class PricingEngineProxyTest {
persistResource(Tld.get("example").asBuilder().setPremiumPricingEngine("fake").build());
IllegalStateException thrown =
assertThrows(
IllegalStateException.class,
() -> getDomainCreateCost("bad.example", clock.nowUtc(), 1));
IllegalStateException.class, () -> getDomainCreateCost("bad.example", clock.now(), 1));
assertThat(thrown)
.hasMessageThat()
.contains("Could not load pricing engine fake for TLD example");
@@ -151,7 +151,7 @@ class RdapJsonFormatterTest {
makeDomain("fish.みんな", null, null, registrar)
.asBuilder()
.setCreationTimeForTest(clock.nowUtc())
.setLastEppUpdateTime((java.time.Instant) null)
.setLastEppUpdateTime((Instant) null)
.build());
// history entries
@@ -32,6 +32,7 @@ import google.registry.model.eppcommon.StatusValue;
import google.registry.model.reporting.HistoryEntry;
import google.registry.testing.TruthChainer.And;
import google.registry.testing.TruthChainer.Which;
import java.time.Instant;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;
@@ -153,16 +154,30 @@ abstract class AbstractEppResourceSubject<
return hasValue(deletionTime, actual.getDeletionDateTime(), "getDeletionTime()");
}
public And<S> hasDeletionTime(Instant deletionTime) {
return hasValue(deletionTime, actual.getDeletionTime(), "getDeletionTime()");
}
public And<S> hasLastEppUpdateTime(DateTime lastUpdateTime) {
return hasValue(lastUpdateTime, actual.getLastEppUpdateDateTime(), "has lastEppUpdateTime");
}
public And<S> hasLastEppUpdateTime(Instant lastUpdateTime) {
return hasValue(lastUpdateTime, actual.getLastEppUpdateTime(), "has lastEppUpdateTime");
}
public And<S> hasLastEppUpdateTimeAtLeast(DateTime before) {
DateTime lastEppUpdateTime = actual.getLastEppUpdateDateTime();
check("getLastEppUpdateTime()").that(lastEppUpdateTime).isAtLeast(before);
return andChainer();
}
public And<S> hasLastEppUpdateTimeAtLeast(Instant before) {
Instant lastEppUpdateTime = actual.getLastEppUpdateTime();
check("getLastEppUpdateTime()").that(lastEppUpdateTime).isAtLeast(before);
return andChainer();
}
public And<S> hasLastEppUpdateRegistrarId(String registrarId) {
return hasValue(
registrarId, actual.getLastEppUpdateRegistrarId(), "getLastEppUpdateRegistrarId()");
@@ -182,9 +197,23 @@ abstract class AbstractEppResourceSubject<
return andChainer();
}
public And<S> isActiveAt(Instant time) {
if (!isActive(actual, DateTime.parse(time.toString()))) {
failWithActual("expected to be active at", time);
}
return andChainer();
}
public And<S> isNotActiveAt(DateTime time) {
if (isActive(actual, time)) {
failWithActual("expected not to be active at", time);
failWithActual("expected to not be active at", time);
}
return andChainer();
}
public And<S> isNotActiveAt(Instant time) {
if (isActive(actual, DateTime.parse(time.toString()))) {
failWithActual("expected to not be active at", time);
}
return andChainer();
}
@@ -38,7 +38,8 @@ import static google.registry.util.CollectionUtils.difference;
import static google.registry.util.CollectionUtils.union;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static google.registry.util.DateTimeUtils.isBeforeOrAt;
import static google.registry.util.DateTimeUtils.toDateTime;
import static google.registry.util.DateTimeUtils.toInstant;
import static google.registry.util.DomainNameUtils.ACE_PREFIX_REGEX;
import static google.registry.util.DomainNameUtils.getTldFromDomainName;
import static google.registry.util.PreconditionsUtils.checkArgumentPresent;
@@ -102,6 +103,7 @@ import google.registry.model.tld.label.ReservedListDao;
import google.registry.model.transfer.DomainTransferData;
import google.registry.model.transfer.TransferStatus;
import google.registry.persistence.VKey;
import java.time.Instant;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -267,6 +269,10 @@ public final class DatabaseHelper {
* Returns a persisted domain that is the passed-in domain modified to be deleted at the specified
* time.
*/
public static Domain persistDomainAsDeleted(Domain domain, Instant deletionTime) {
return persistResource(domain.asBuilder().setDeletionTime(deletionTime).build());
}
public static Domain persistDomainAsDeleted(Domain domain, DateTime deletionTime) {
return persistResource(domain.asBuilder().setDeletionTime(deletionTime).build());
}
@@ -446,6 +452,24 @@ public final class DatabaseHelper {
.setPendingTransferExpirationTime(expirationTime);
}
public static PollMessage.OneTime createPollMessageForImplicitTransfer(
Domain domain,
HistoryEntry historyEntry,
String registrarId,
Instant requestTime,
Instant expirationTime,
@Nullable Instant extendedRegistrationExpirationTime) {
return createPollMessageForImplicitTransfer(
domain,
historyEntry,
registrarId,
toDateTime(requestTime),
toDateTime(expirationTime),
extendedRegistrationExpirationTime != null
? toDateTime(extendedRegistrationExpirationTime)
: null);
}
public static PollMessage.OneTime createPollMessageForImplicitTransfer(
Domain domain,
HistoryEntry historyEntry,
@@ -466,6 +490,12 @@ public final class DatabaseHelper {
.build();
}
public static BillingEvent createBillingEventForTransfer(
Domain domain, DomainHistory historyEntry, Instant costLookupTime, Instant eventTime) {
return createBillingEventForTransfer(
domain, historyEntry, toDateTime(costLookupTime), toDateTime(eventTime));
}
public static BillingEvent createBillingEventForTransfer(
Domain domain, DomainHistory historyEntry, DateTime costLookupTime, DateTime eventTime) {
return new BillingEvent.Builder()
@@ -475,11 +505,17 @@ public final class DatabaseHelper {
.setBillingTime(eventTime.plus(Tld.get(domain.getTld()).getTransferGracePeriodLength()))
.setRegistrarId("NewRegistrar")
.setPeriodYears(1)
.setCost(getDomainRenewCost(domain.getDomainName(), costLookupTime, 1))
.setCost(getDomainRenewCost(domain.getDomainName(), toInstant(costLookupTime), 1))
.setDomainHistory(historyEntry)
.build();
}
public static Domain persistDomainWithDependentResources(
String label, String tld, Instant now, Instant creationTime, Instant expirationTime) {
return persistDomainWithDependentResources(
label, tld, toDateTime(now), toDateTime(creationTime), toDateTime(expirationTime));
}
public static Domain persistDomainWithDependentResources(
String label,
String tld,
@@ -545,6 +581,18 @@ public final class DatabaseHelper {
.build());
}
public static Domain persistDomainWithPendingTransfer(
Domain domain,
Instant requestTime,
Instant expirationTime,
Instant extendedRegistrationExpirationTime) {
return persistDomainWithPendingTransfer(
domain,
toDateTime(requestTime),
toDateTime(expirationTime),
toDateTime(extendedRegistrationExpirationTime));
}
public static Domain persistDomainWithPendingTransfer(
Domain domain,
DateTime requestTime,
@@ -801,27 +849,33 @@ public final class DatabaseHelper {
public static ImmutableList<PollMessage> getPollMessages(
String registrarId, DateTime beforeOrAt) {
return getPollMessages(registrarId, toInstant(beforeOrAt));
}
public static ImmutableList<PollMessage> getPollMessages(String registrarId, Instant beforeOrAt) {
return tm().transact(
() ->
tm().loadAllOf(PollMessage.class).stream()
.filter(pollMessage -> pollMessage.getRegistrarId().equals(registrarId))
.filter(pollMessage -> isBeforeOrAt(pollMessage.getEventTime(), beforeOrAt))
.filter(pollMessage -> !pollMessage.getEventTimeInstant().isAfter(beforeOrAt))
.collect(toImmutableList()));
}
/** Gets all PollMessages associated with the given EppResource. */
public static ImmutableList<PollMessage> getPollMessages(
EppResource resource, String registrarId, DateTime now) {
return getPollMessages(resource, registrarId, toInstant(now));
}
public static ImmutableList<PollMessage> getPollMessages(
EppResource resource, String registrarId, Instant now) {
return tm().transact(
() ->
tm().loadAllOf(PollMessage.class).stream()
.filter(
pollMessage -> pollMessage.getDomainRepoId().equals(resource.getRepoId()))
.filter(pollMessage -> pollMessage.getRegistrarId().equals(registrarId))
.filter(
pollMessage ->
pollMessage.getEventTime().isEqual(now)
|| pollMessage.getEventTime().isBefore(now))
.filter(pollMessage -> !pollMessage.getEventTimeInstant().isAfter(now))
.collect(toImmutableList()));
}
@@ -830,11 +884,20 @@ public final class DatabaseHelper {
}
public static PollMessage getOnlyPollMessage(String registrarId, DateTime now) {
return getOnlyPollMessage(registrarId, toInstant(now));
}
public static PollMessage getOnlyPollMessage(String registrarId, Instant now) {
return Iterables.getOnlyElement(getPollMessages(registrarId, now));
}
public static PollMessage getOnlyPollMessage(
String registrarId, DateTime now, Class<? extends PollMessage> subType) {
return getOnlyPollMessage(registrarId, toInstant(now), subType);
}
public static PollMessage getOnlyPollMessage(
String registrarId, Instant now, Class<? extends PollMessage> subType) {
return getPollMessages(registrarId, now).stream()
.filter(subType::isInstance)
.map(subType::cast)
@@ -843,6 +906,11 @@ public final class DatabaseHelper {
public static PollMessage getOnlyPollMessage(
DomainBase domain, String registrarId, DateTime now, Class<? extends PollMessage> subType) {
return getOnlyPollMessage(domain, registrarId, toInstant(now), subType);
}
public static PollMessage getOnlyPollMessage(
DomainBase domain, String registrarId, Instant now, Class<? extends PollMessage> subType) {
return getPollMessages(domain, registrarId, now).stream()
.filter(subType::isInstance)
.map(subType::cast)
@@ -24,7 +24,8 @@ import com.google.common.collect.ImmutableList;
import com.google.common.io.CharSource;
import google.registry.model.smd.SignedMarkRevocationList;
import google.registry.testing.FakeClock;
import org.joda.time.DateTime;
import java.time.Instant;
import java.time.format.DateTimeParseException;
import org.junit.jupiter.api.Test;
/** Unit tests for {@link SmdrlCsvParser}. */
@@ -39,38 +40,38 @@ class SmdrlCsvParserTest {
void testParse() throws Exception {
SignedMarkRevocationList smdrl = SmdrlCsvParser.parse(SMDRL_LATEST_CSV.readLines());
assertThat(smdrl.size()).isEqualTo(150);
assertThat(smdrl.getCreationTime()).isEqualTo(DateTime.parse("2013-11-24T23:30:04.3Z"));
assertThat(smdrl.getCreationTime()).isEqualTo(Instant.parse("2013-11-24T23:30:04.3Z"));
}
@Test
void testFirstRow() throws Exception {
SignedMarkRevocationList smdrl = SmdrlCsvParser.parse(SMDRL_LATEST_CSV.readLines());
clock.setTo(DateTime.parse("2013-08-09T12:00:00.0Z"));
assertThat(smdrl.isSmdRevoked("0000001681375789102250-65535", clock.nowUtc())).isTrue();
clock.setTo(clock.nowUtc().minusMillis(1));
assertThat(smdrl.isSmdRevoked("0000001681375789102250-65535", clock.nowUtc())).isFalse();
clock.setTo(Instant.parse("2013-08-09T12:00:00.0Z"));
assertThat(smdrl.isSmdRevoked("0000001681375789102250-65535", clock.now())).isTrue();
clock.setTo(clock.now().minusMillis(1));
assertThat(smdrl.isSmdRevoked("0000001681375789102250-65535", clock.now())).isFalse();
clock.advanceBy(millis(2));
assertThat(smdrl.isSmdRevoked("0000001681375789102250-65535", clock.nowUtc())).isTrue();
assertThat(smdrl.isSmdRevoked("0000001681375789102250-65535", clock.now())).isTrue();
}
@Test
void testLastRow() throws Exception {
SignedMarkRevocationList smdrl = SmdrlCsvParser.parse(SMDRL_LATEST_CSV.readLines());
clock.setTo(DateTime.parse("2013-08-09T12:00:00.0Z"));
assertThat(smdrl.isSmdRevoked("0000002211373633641407-65535", clock.nowUtc())).isTrue();
clock.setTo(clock.nowUtc().minusMillis(1));
assertThat(smdrl.isSmdRevoked("0000002211373633641407-65535", clock.nowUtc())).isFalse();
clock.setTo(Instant.parse("2013-08-09T12:00:00.0Z"));
assertThat(smdrl.isSmdRevoked("0000002211373633641407-65535", clock.now())).isTrue();
clock.setTo(clock.now().minusMillis(1));
assertThat(smdrl.isSmdRevoked("0000002211373633641407-65535", clock.now())).isFalse();
clock.advanceBy(millis(2));
assertThat(smdrl.isSmdRevoked("0000002211373633641407-65535", clock.nowUtc())).isTrue();
assertThat(smdrl.isSmdRevoked("0000002211373633641407-65535", clock.now())).isTrue();
}
@Test
void testRowWithDifferentDate() throws Exception {
SignedMarkRevocationList smdrl = SmdrlCsvParser.parse(SMDRL_LATEST_CSV.readLines());
clock.setTo(DateTime.parse("2013-08-09T12:00:00.0Z"));
assertThat(smdrl.isSmdRevoked("0000002101376042766438-65535", clock.nowUtc())).isFalse();
clock.setTo(Instant.parse("2013-08-09T12:00:00.0Z"));
assertThat(smdrl.isSmdRevoked("0000002101376042766438-65535", clock.now())).isFalse();
clock.advanceBy(standardDays(1));
assertThat(smdrl.isSmdRevoked("0000002101376042766438-65535", clock.nowUtc())).isTrue();
assertThat(smdrl.isSmdRevoked("0000002101376042766438-65535", clock.now())).isTrue();
}
@Test
@@ -82,9 +83,9 @@ class SmdrlCsvParserTest {
"smd-id,insertion-datetime",
"0000001681375789102250-65535,2013-08-09T12:00:00.0Z"));
assertThat(smdrl.size()).isEqualTo(1);
assertThat(smdrl.getCreationTime()).isEqualTo(DateTime.parse("2013-11-24T23:30:04.3Z"));
clock.setTo(DateTime.parse("2020-08-09T12:00:00.0Z"));
assertThat(smdrl.isSmdRevoked("0000001681375789102250-65535", clock.nowUtc())).isTrue();
assertThat(smdrl.getCreationTime()).isEqualTo(Instant.parse("2013-11-24T23:30:04.3Z"));
clock.setTo(Instant.parse("2020-08-09T12:00:00.0Z"));
assertThat(smdrl.isSmdRevoked("0000001681375789102250-65535", clock.now())).isTrue();
}
@Test
@@ -93,9 +94,9 @@ class SmdrlCsvParserTest {
SmdrlCsvParser.parse(
ImmutableList.of("1,2014-11-24T23:30:04.3Z", "smd-id,insertion-datetime"));
assertThat(smdrl.size()).isEqualTo(0);
assertThat(smdrl.getCreationTime()).isEqualTo(DateTime.parse("2014-11-24T23:30:04.3Z"));
clock.setTo(DateTime.parse("2020-08-09T12:00:00.0Z"));
assertThat(smdrl.isSmdRevoked("0000001681375789102250-65535", clock.nowUtc())).isFalse();
assertThat(smdrl.getCreationTime()).isEqualTo(Instant.parse("2014-11-24T23:30:04.3Z"));
clock.setTo(Instant.parse("2020-08-09T12:00:00.0Z"));
assertThat(smdrl.isSmdRevoked("0000001681375789102250-65535", clock.now())).isFalse();
}
@Test
@@ -130,15 +131,15 @@ class SmdrlCsvParserTest {
@Test
void testFail_tooManyColumns() {
IllegalArgumentException thrown =
DateTimeParseException thrown =
assertThrows(
IllegalArgumentException.class,
DateTimeParseException.class,
() ->
SmdrlCsvParser.parse(
ImmutableList.of(
"1,2013-11-24T23:30:04.3Z",
"smd-id,insertion-datetime",
"0000001681375789102250-65535,haha,2013-08-09T12:00:00.0Z")));
assertThat(thrown).hasMessageThat().isEqualTo("Invalid format: \"haha\"");
assertThat(thrown).hasMessageThat().contains("Text 'haha' could not be parsed at index 0");
}
}
@@ -25,8 +25,8 @@ import google.registry.model.tmch.ClaimsList;
import google.registry.model.tmch.ClaimsListDao;
import java.io.ByteArrayInputStream;
import java.net.URL;
import java.time.Instant;
import java.util.Optional;
import org.joda.time.DateTime;
import org.junit.jupiter.api.Test;
/** Unit tests for {@link TmchDnlAction}. */
@@ -57,7 +57,7 @@ class TmchDnlActionTest extends TmchActionTestCase {
// Make sure the contents of testdata/dnl-latest.csv got inserted into the database.
ClaimsList claimsList = ClaimsListDao.get();
assertThat(claimsList.getTmdbGenerationTime())
.isEqualTo(DateTime.parse("2013-11-24T23:15:37.4Z"));
.isEqualTo(Instant.parse("2013-11-24T23:15:37.4Z"));
assertThat(tm().transact(() -> claimsList.getClaimKey("xn----7sbejwbn3axu3d")))
.hasValue("2013112500/7/4/8/dIHW0DiuybvhdP8kIz");
assertThat(tm().transact(() -> claimsList.getClaimKey("lolcat"))).isEmpty();
@@ -24,14 +24,14 @@ import static org.mockito.Mockito.when;
import google.registry.model.smd.SignedMarkRevocationList;
import java.io.ByteArrayInputStream;
import java.net.URL;
import java.time.Instant;
import java.util.Optional;
import org.joda.time.DateTime;
import org.junit.jupiter.api.Test;
/** Unit tests for {@link TmchSmdrlAction}. */
class TmchSmdrlActionTest extends TmchActionTestCase {
private static final DateTime now = DateTime.parse("2014-01-01T00:00:00Z");
private static final Instant now = Instant.parse("2014-01-01T00:00:00Z");
private TmchSmdrlAction newTmchSmdrlAction() {
TmchSmdrlAction action = new TmchSmdrlAction();
@@ -15,7 +15,6 @@
package google.registry.tmch;
import static google.registry.testing.TestDataHelper.loadFile;
import static org.joda.time.DateTimeZone.UTC;
import google.registry.config.RegistryConfig.ConfigModule.TmchCaMode;
import google.registry.flows.EppException;
@@ -24,7 +23,7 @@ import google.registry.model.smd.EncodedSignedMark;
import google.registry.persistence.transaction.JpaTestExtensions;
import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension;
import google.registry.util.SystemClock;
import org.joda.time.DateTime;
import java.time.Instant;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -57,7 +56,7 @@ class TmchTestDataExpirationTest {
String tmchData = loadFile(TmchTestDataExpirationTest.class, filePath);
EncodedSignedMark smd = TmchData.readEncodedSignedMark(tmchData);
try {
tmchUtils.verifyEncodedSignedMark(smd, DateTime.now(UTC));
tmchUtils.verifyEncodedSignedMark(smd, Instant.now());
} catch (EppException e) {
throw new AssertionError("Error verifying signed mark " + filePath, e);
}
@@ -23,7 +23,7 @@ import static google.registry.testing.DatabaseHelper.newTld;
import static google.registry.testing.DatabaseHelper.persistNewRegistrar;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.util.DateTimeUtils.START_INSTANT;
import static google.registry.util.DateTimeUtils.toDateTime;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static org.joda.money.CurrencyUnit.JPY;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.eq;
@@ -64,11 +64,7 @@ class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarCommand>
command.setConnection(connection);
command.certificateChecker =
new CertificateChecker(
ImmutableSortedMap.of(
toDateTime(START_INSTANT),
825,
toDateTime(Instant.parse("2020-09-01T00:00:00Z")),
398),
ImmutableSortedMap.of(START_OF_TIME, 825, DateTime.parse("2020-09-01T00:00:00Z"), 398),
30,
15,
2048,
@@ -17,7 +17,6 @@ package google.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.readAllLines;
import static org.joda.time.DateTimeZone.UTC;
import com.google.common.collect.ImmutableMap;
import google.registry.model.tmch.ClaimsList;
@@ -25,7 +24,7 @@ import google.registry.model.tmch.ClaimsListDao;
import google.registry.testing.TestCacheExtension;
import java.io.File;
import java.nio.file.Files;
import org.joda.time.DateTime;
import java.time.Duration;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -34,11 +33,11 @@ class GetClaimsListCommandTest extends CommandTestCase<GetClaimsListCommand> {
@RegisterExtension
public final TestCacheExtension testCacheExtension =
new TestCacheExtension.Builder().withClaimsListCache(java.time.Duration.ofHours(6)).build();
new TestCacheExtension.Builder().withClaimsListCache(Duration.ofHours(6)).build();
@Test
void testSuccess_getWorks() throws Exception {
ClaimsListDao.save(ClaimsList.create(DateTime.now(UTC), ImmutableMap.of("a", "1", "b", "2")));
ClaimsListDao.save(ClaimsList.create(fakeClock.now(), ImmutableMap.of("a", "1", "b", "2")));
File output = tmpDir.resolve("claims.txt").toFile();
runCommand("--output=" + output.getAbsolutePath());
assertThat(readAllLines(output.toPath(), UTF_8)).containsExactly("a,1", "b,2");
@@ -46,7 +45,7 @@ class GetClaimsListCommandTest extends CommandTestCase<GetClaimsListCommand> {
@Test
void testSuccess_endsWithNewline() throws Exception {
ClaimsListDao.save(ClaimsList.create(DateTime.now(UTC), ImmutableMap.of("a", "1")));
ClaimsListDao.save(ClaimsList.create(fakeClock.now(), ImmutableMap.of("a", "1")));
File output = tmpDir.resolve("claims.txt").toFile();
runCommand("--output=" + output.getAbsolutePath());
assertThat(Files.readString(output.toPath())).endsWith("\n");
@@ -22,7 +22,9 @@ import google.registry.model.tmch.ClaimsList;
import google.registry.model.tmch.ClaimsListDao;
import google.registry.testing.TestCacheExtension;
import java.io.FileNotFoundException;
import org.joda.time.DateTime;
import java.time.Duration;
import java.time.Instant;
import java.time.format.DateTimeParseException;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -31,7 +33,7 @@ class UploadClaimsListCommandTest extends CommandTestCase<UploadClaimsListComman
@RegisterExtension
public final TestCacheExtension testCacheExtension =
new TestCacheExtension.Builder().withClaimsListCache(java.time.Duration.ofHours(6)).build();
new TestCacheExtension.Builder().withClaimsListCache(Duration.ofHours(6)).build();
@Test
void testSuccess() throws Exception {
@@ -45,7 +47,7 @@ class UploadClaimsListCommandTest extends CommandTestCase<UploadClaimsListComman
ClaimsList claimsList = ClaimsListDao.get();
assertThat(claimsList.getTmdbGenerationTime())
.isEqualTo(DateTime.parse("2012-08-16T00:00:00.0Z"));
.isEqualTo(Instant.parse("2012-08-16T00:00:00.0Z"));
assertThat(tm().transact(() -> claimsList.getClaimKey("example")))
.hasValue("2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001");
assertThat(tm().transact(() -> claimsList.getClaimKey("another-example")))
@@ -84,73 +86,79 @@ class UploadClaimsListCommandTest extends CommandTestCase<UploadClaimsListComman
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
assertThrows(IllegalArgumentException.class, () -> runCommand("--force", filename));
assertThrows(DateTimeParseException.class, () -> runCommand("--force", filename));
}
@Test
void testFailure_badFirstHeader() throws Exception {
String filename = writeToTmpFile(
"1,foo",
"SNL,lookup-key,insertion-datetime",
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
String filename =
writeToTmpFile(
"1,2010-01-01T00:00:00.0Z",
"SNL,lookup-key,insertion-datetime",
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
assertThrows(IllegalArgumentException.class, () -> runCommand("--force", filename));
}
@Test
void testFailure_badSecondHeader() throws Exception {
String filename = writeToTmpFile(
"1,foo",
"DNL,lookup-keys,insertion-datetime",
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
String filename =
writeToTmpFile(
"1,2010-01-01T00:00:00.0Z",
"DNL,lookup-keys,insertion-datetime",
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
assertThrows(IllegalArgumentException.class, () -> runCommand("--force", filename));
}
@Test
void testFailure_badThirdHeader() throws Exception {
String filename = writeToTmpFile(
"1,foo",
"DNL,lookup-key,insertion-datetimes",
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
String filename =
writeToTmpFile(
"1,2010-01-01T00:00:00.0Z",
"DNL,lookup-key,insertion-datetimes",
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
assertThrows(IllegalArgumentException.class, () -> runCommand("--force", filename));
}
@Test
void testFailure_wrongNumberOfHeaders() throws Exception {
String filename = writeToTmpFile(
"1,foo",
"DNL,lookup-key,insertion-datetime,extra-field",
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
String filename =
writeToTmpFile(
"1,2010-01-01T00:00:00.0Z",
"DNL,lookup-key,insertion-datetime,extra-field",
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
assertThrows(IllegalArgumentException.class, () -> runCommand("--force", filename));
}
@Test
void testFailure_wrongNumberOfFields() throws Exception {
String filename = writeToTmpFile(
"1,foo",
"DNL,lookup-key,insertion-datetime",
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z,extra",
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
String filename =
writeToTmpFile(
"1,2010-01-01T00:00:00.0Z",
"DNL,lookup-key,insertion-datetime",
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z,extra",
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,2012-08-16T00:00:00.0Z",
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
assertThrows(IllegalArgumentException.class, () -> runCommand("--force", filename));
}
@Test
void testFailure_badInsertionTime() throws Exception {
String filename = writeToTmpFile(
"1,foo",
"DNL,lookup-key,insertion-datetime",
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,foo",
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
assertThrows(IllegalArgumentException.class, () -> runCommand("--force", filename));
String filename =
writeToTmpFile(
"1,2010-01-01T00:00:00.0Z",
"DNL,lookup-key,insertion-datetime",
"example,2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001,2010-07-14T00:00:00.0Z",
"another-example,2013041500/6/A/5/alJAqG2vI2BmCv5PfUvuDkf40000000002,foo",
"anotherexample,2013041500/A/C/7/rHdC4wnrWRvPY6nneCVtQhFj0000000003,2011-08-16T12:00:00.0Z");
assertThrows(DateTimeParseException.class, () -> runCommand("--force", filename));
}
@Test