mirror of
https://github.com/google/nomulus
synced 2026-08-18 13:16:20 +00:00
Migrate core temporal models and related entities to java.time.Instant (#3001)
This comprehensive refactor continues the migration from Joda-Time to java.time (Instant), focusing on core timestamp models, transition properties, and their integration across the codebase. Key changes: - Migrated CreateAutoTimestamp and UpdateAutoTimestamp to use Instant internally, providing Joda-Time bridge methods for backward compatibility. - Updated TimedTransitionProperty to handle Instant-based transition maps and updated corresponding Hibernate UserTypes (TimedTransitionBaseUserType). - Migrated GracePeriod, BillingBase, BillingEvent, PollMessage, and PendingActionNotificationResponse fields (e.g., expirationTime, eventTime) to Instant. - Migrated additional core entities (DomainBase, Registrar, HostBase, LaunchNotice, BsaLabel, DomainTransactionRecord) to use Instant for registrationExpirationTime, lastTransferTime, creationTime, etc. - Updated Tld and FeatureFlag models to use Instant for claimsPeriodEnd, bsaEnrollStartTime, and status transitions. - Enhanced CLI tools and parameters (TransitionListParameter, InstantParameter, RequestParameters) to support Instant-based input and output. - Updated EntityYamlUtils with custom Instant serializers/deserializers to maintain format consistency (e.g., .SSSZ precision) required for YAML-based tests. - Implemented UtcInstantAdapter to ensure JAXB XML serialization maintains millisecond accuracy, matching legacy Joda-Time behavior. - Resolved Hibernate 6 type mismatches in JPQL and Native queries by ensuring consistent use of Instant for comparisons. - Updated GEMINI.md with project-specific engineering standards, including the 'one commit per PR' mandate, full-build validation requirement, and commit message style rules. - Cleaned up unnecessary @JsonIgnore and @JsonProperty annotations that were previously added to methods with parameters or redundant fields. - Refactored DateTimeUtils to use strongly-typed overloads and standardized naming (earliestOf, latestOf) while avoiding type erasure clashes. - Cleaned up fully qualified calls to toDateTime and toInstant by adding static imports across core model and flow files. - Refactored test suites to use clock.now() (Instant) instead of nowUtc() (DateTime) and removed custom Truth subjects in favor of standard assertions.
This commit is contained in:
@@ -36,6 +36,7 @@ import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.FakeLockHandler;
|
||||
import google.registry.testing.FakeResponse;
|
||||
import google.registry.util.DateTimeUtils;
|
||||
import java.time.Instant;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -89,39 +90,39 @@ public class BulkDomainTransferActionTest {
|
||||
assertThat(alreadyTransferredDomain.getCurrentSponsorRegistrarId()).isEqualTo("NewRegistrar");
|
||||
assertThat(pendingDeleteDomain.getCurrentSponsorRegistrarId()).isEqualTo("TheRegistrar");
|
||||
assertThat(deletedDomain.getCurrentSponsorRegistrarId()).isEqualTo("TheRegistrar");
|
||||
DateTime preRunTime = fakeClock.nowUtc();
|
||||
Instant preRunTime = fakeClock.now();
|
||||
|
||||
BulkDomainTransferAction action =
|
||||
createAction("active.tld", "alreadytransferred.tld", "pendingdelete.tld", "deleted.tld");
|
||||
fakeClock.advanceOneMilli();
|
||||
|
||||
DateTime runTime = fakeClock.nowUtc();
|
||||
Instant runTime = fakeClock.now();
|
||||
action.run();
|
||||
|
||||
fakeClock.advanceOneMilli();
|
||||
DateTime now = fakeClock.nowUtc();
|
||||
Instant now = fakeClock.now();
|
||||
|
||||
// The active domain should have a new update timestamp and current registrar
|
||||
// The cloneProjectedAtTime calls are necessary to resolve the transfers, even though the
|
||||
// transfers have a time period of 0
|
||||
activeDomain = loadByEntity(activeDomain);
|
||||
assertThat(activeDomain.cloneProjectedAtTime(now).getCurrentSponsorRegistrarId())
|
||||
assertThat(activeDomain.cloneProjectedAtInstant(now).getCurrentSponsorRegistrarId())
|
||||
.isEqualTo("NewRegistrar");
|
||||
assertThat(activeDomain.getUpdateTimestamp().getTimestamp()).isEqualTo(runTime);
|
||||
|
||||
// The other three domains shouldn't change
|
||||
alreadyTransferredDomain = loadByEntity(alreadyTransferredDomain);
|
||||
assertThat(alreadyTransferredDomain.cloneProjectedAtTime(now).getCurrentSponsorRegistrarId())
|
||||
assertThat(alreadyTransferredDomain.cloneProjectedAtInstant(now).getCurrentSponsorRegistrarId())
|
||||
.isEqualTo("NewRegistrar");
|
||||
assertThat(alreadyTransferredDomain.getUpdateTimestamp().getTimestamp()).isEqualTo(preRunTime);
|
||||
|
||||
pendingDeleteDomain = loadByEntity(pendingDeleteDomain);
|
||||
assertThat(pendingDeleteDomain.cloneProjectedAtTime(now).getCurrentSponsorRegistrarId())
|
||||
assertThat(pendingDeleteDomain.cloneProjectedAtInstant(now).getCurrentSponsorRegistrarId())
|
||||
.isEqualTo("TheRegistrar");
|
||||
assertThat(pendingDeleteDomain.getUpdateTimestamp().getTimestamp()).isEqualTo(preRunTime);
|
||||
|
||||
deletedDomain = loadByEntity(deletedDomain);
|
||||
assertThat(deletedDomain.cloneProjectedAtTime(now).getCurrentSponsorRegistrarId())
|
||||
assertThat(deletedDomain.cloneProjectedAtInstant(now).getCurrentSponsorRegistrarId())
|
||||
.isEqualTo("TheRegistrar");
|
||||
assertThat(deletedDomain.getUpdateTimestamp().getTimestamp()).isEqualTo(preRunTime);
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import google.registry.testing.DatabaseHelper;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.ui.server.SendEmailUtils;
|
||||
import google.registry.util.EmailMessage;
|
||||
import java.time.Instant;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
@@ -119,8 +120,8 @@ public class CheckBulkComplianceActionTest {
|
||||
.setMaxDomains(3)
|
||||
.setMaxCreates(1)
|
||||
.setBulkPrice(Money.of(CurrencyUnit.USD, 1000))
|
||||
.setNextBillingDate(DateTime.parse("2012-11-12T05:00:00Z"))
|
||||
.setLastNotificationSent(DateTime.parse("2010-11-12T05:00:00Z"))
|
||||
.setNextBillingDate(Instant.parse("2012-11-12T05:00:00Z"))
|
||||
.setLastNotificationSent(Instant.parse("2010-11-12T05:00:00Z"))
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -213,7 +214,7 @@ public class CheckBulkComplianceActionTest {
|
||||
.setMaxDomains(8)
|
||||
.setMaxCreates(1)
|
||||
.setBulkPrice(Money.of(CurrencyUnit.USD, 1000))
|
||||
.setNextBillingDate(DateTime.parse("2012-11-12T05:00:00Z"))
|
||||
.setNextBillingDate(Instant.parse("2012-11-12T05:00:00Z"))
|
||||
.build();
|
||||
tm().transact(() -> tm().put(bulkPricingPackage2));
|
||||
|
||||
@@ -271,7 +272,7 @@ public class CheckBulkComplianceActionTest {
|
||||
.setMaxDomains(8)
|
||||
.setMaxCreates(1)
|
||||
.setBulkPrice(Money.of(CurrencyUnit.USD, 1000))
|
||||
.setNextBillingDate(DateTime.parse("2015-11-12T05:00:00Z"))
|
||||
.setNextBillingDate(Instant.parse("2015-11-12T05:00:00Z"))
|
||||
.build();
|
||||
tm().transact(() -> tm().put(packagePromotion2));
|
||||
|
||||
@@ -347,7 +348,7 @@ public class CheckBulkComplianceActionTest {
|
||||
.setMaxDomains(8)
|
||||
.setMaxCreates(4)
|
||||
.setBulkPrice(Money.of(CurrencyUnit.USD, 1000))
|
||||
.setNextBillingDate(DateTime.parse("2012-11-12T05:00:00Z"))
|
||||
.setNextBillingDate(Instant.parse("2012-11-12T05:00:00Z"))
|
||||
.build();
|
||||
tm().transact(() -> tm().put(bulkPricingPackage2));
|
||||
persistEppResource(
|
||||
@@ -414,7 +415,7 @@ public class CheckBulkComplianceActionTest {
|
||||
.setMaxDomains(1)
|
||||
.setMaxCreates(5)
|
||||
.setBulkPrice(Money.of(CurrencyUnit.USD, 1000))
|
||||
.setNextBillingDate(DateTime.parse("2012-11-12T05:00:00Z"))
|
||||
.setNextBillingDate(Instant.parse("2012-11-12T05:00:00Z"))
|
||||
.build();
|
||||
tm().transact(() -> tm().put(bulkPricingPackage2));
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ class DeleteExpiredDomainsActionTest {
|
||||
() ->
|
||||
tm()
|
||||
.createQueryComposer(Domain.class)
|
||||
.where("autorenewEndTime", Comparator.LTE, clock.nowUtc())
|
||||
.where("autorenewEndTime", Comparator.LTE, clock.now())
|
||||
.stream()
|
||||
.map(Domain::getDomainName)
|
||||
.collect(toImmutableSet()));
|
||||
|
||||
@@ -27,7 +27,8 @@ import static google.registry.testing.DatabaseHelper.persistDeletedDomain;
|
||||
import static google.registry.testing.DatabaseHelper.persistDomainAsDeleted;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.util.DateTimeUtils.END_INSTANT;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
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;
|
||||
@@ -63,7 +64,7 @@ class DeleteProberDataActionTest {
|
||||
|
||||
private static final DateTime DELETION_TIME = DateTime.parse("2010-01-01T00:00:00.000Z");
|
||||
|
||||
private final FakeClock clock = new FakeClock(DateTime.now(UTC));
|
||||
private final FakeClock clock = new FakeClock(Instant.parse("2021-01-01T00:00:00Z"));
|
||||
|
||||
@RegisterExtension
|
||||
final JpaIntegrationTestExtension jpa =
|
||||
@@ -204,13 +205,13 @@ class DeleteProberDataActionTest {
|
||||
persistResource(
|
||||
DatabaseHelper.newDomain("blah.ib-any.test")
|
||||
.asBuilder()
|
||||
.setCreationTimeForTest(DateTime.now(UTC).minusYears(1))
|
||||
.setCreationTimeForTest(minusYears(clock.now(), 1))
|
||||
.build());
|
||||
action.run();
|
||||
Instant timeAfterDeletion = Instant.now();
|
||||
Instant timeAfterDeletion = clock.now();
|
||||
assertThat(ForeignKeyUtils.loadResource(Domain.class, "blah.ib-any.test", timeAfterDeletion))
|
||||
.isEmpty();
|
||||
assertThat(loadByEntity(domain).getDeletionTime()).isLessThan(timeAfterDeletion);
|
||||
assertThat(loadByEntity(domain).getDeletionTime()).isAtMost(timeAfterDeletion);
|
||||
assertDomainDnsRequests("blah.ib-any.test");
|
||||
}
|
||||
|
||||
@@ -220,15 +221,15 @@ class DeleteProberDataActionTest {
|
||||
persistResource(
|
||||
DatabaseHelper.newDomain("blah.ib-any.test")
|
||||
.asBuilder()
|
||||
.setCreationTimeForTest(DateTime.now(UTC).minusYears(1))
|
||||
.setCreationTimeForTest(minusYears(clock.now(), 1))
|
||||
.build());
|
||||
action.run();
|
||||
Instant timeAfterDeletion = Instant.now();
|
||||
Instant timeAfterDeletion = clock.now();
|
||||
resetAction();
|
||||
action.run();
|
||||
assertThat(ForeignKeyUtils.loadResource(Domain.class, "blah.ib-any.test", timeAfterDeletion))
|
||||
.isEmpty();
|
||||
assertThat(loadByEntity(domain).getDeletionTime()).isLessThan(timeAfterDeletion);
|
||||
assertThat(loadByEntity(domain).getDeletionTime()).isAtMost(timeAfterDeletion);
|
||||
assertDomainDnsRequests("blah.ib-any.test");
|
||||
}
|
||||
|
||||
@@ -237,11 +238,11 @@ class DeleteProberDataActionTest {
|
||||
persistResource(
|
||||
DatabaseHelper.newDomain("blah.ib-any.test")
|
||||
.asBuilder()
|
||||
.setCreationTimeForTest(DateTime.now(UTC).minusSeconds(1))
|
||||
.setCreationTimeForTest(clock.now().minus(java.time.Duration.ofSeconds(1)))
|
||||
.build());
|
||||
action.run();
|
||||
Optional<Domain> domain =
|
||||
ForeignKeyUtils.loadResource(Domain.class, "blah.ib-any.test", DateTime.now(UTC));
|
||||
ForeignKeyUtils.loadResource(Domain.class, "blah.ib-any.test", clock.now());
|
||||
assertThat(domain).isPresent();
|
||||
assertThat(domain.get().getDeletionTime()).isEqualTo(END_INSTANT);
|
||||
}
|
||||
@@ -252,7 +253,7 @@ class DeleteProberDataActionTest {
|
||||
persistResource(
|
||||
DatabaseHelper.newDomain("blah.ib-any.test")
|
||||
.asBuilder()
|
||||
.setCreationTimeForTest(DateTime.now(UTC).minusYears(1))
|
||||
.setCreationTimeForTest(minusYears(clock.now(), 1))
|
||||
.build());
|
||||
action.isDryRun = true;
|
||||
action.run();
|
||||
@@ -263,14 +264,14 @@ class DeleteProberDataActionTest {
|
||||
void test_domainWithSubordinateHosts_isSkipped() throws Exception {
|
||||
persistActiveHost("ns1.blah.ib-any.test");
|
||||
Domain nakedDomain =
|
||||
persistDeletedDomain("todelete.ib-any.test", DateTime.now(UTC).minusYears(1));
|
||||
persistDeletedDomain("todelete.ib-any.test", toDateTime(minusYears(clock.now(), 1)));
|
||||
Domain domainWithSubord =
|
||||
persistDomainAsDeleted(
|
||||
DatabaseHelper.newDomain("blah.ib-any.test")
|
||||
.asBuilder()
|
||||
.setSubordinateHosts(ImmutableSet.of("ns1.blah.ib-any.test"))
|
||||
.build(),
|
||||
DateTime.now(UTC).minusYears(1));
|
||||
toDateTime(minusYears(clock.now(), 1)));
|
||||
action.run();
|
||||
|
||||
assertAllExist(ImmutableSet.of(domainWithSubord));
|
||||
@@ -282,7 +283,7 @@ class DeleteProberDataActionTest {
|
||||
persistResource(
|
||||
DatabaseHelper.newDomain("blah.ib-any.test")
|
||||
.asBuilder()
|
||||
.setCreationTimeForTest(DateTime.now(UTC).minusYears(1))
|
||||
.setCreationTimeForTest(minusYears(clock.now(), 1))
|
||||
.build());
|
||||
action.registryAdminRegistrarId = null;
|
||||
IllegalStateException thrown = assertThrows(IllegalStateException.class, action::run);
|
||||
|
||||
@@ -16,6 +16,7 @@ package google.registry.batch;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.util.DateTimeUtils.toDateTime;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.times;
|
||||
@@ -31,9 +32,9 @@ import google.registry.persistence.transaction.JpaTestExtensions;
|
||||
import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension;
|
||||
import google.registry.testing.FakeClock;
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
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;
|
||||
@@ -42,8 +43,8 @@ import org.mockito.ArgumentCaptor;
|
||||
/** Unit tests for {@link ExpandBillingRecurrencesAction}. */
|
||||
public class ExpandBillingRecurrencesActionTest extends BeamActionTestBase {
|
||||
|
||||
private final DateTime cursorTime = DateTime.parse("2020-02-01T00:00:00Z");
|
||||
private final DateTime now = DateTime.parse("2020-02-02T00:00:00Z");
|
||||
private final Instant cursorTime = Instant.parse("2020-02-01T00:00:00Z");
|
||||
private final Instant now = Instant.parse("2020-02-02T00:00:00Z");
|
||||
|
||||
private final FakeClock clock = new FakeClock(now);
|
||||
private final ExpandBillingRecurrencesAction action = new ExpandBillingRecurrencesAction();
|
||||
@@ -69,11 +70,14 @@ public class ExpandBillingRecurrencesActionTest extends BeamActionTestBase {
|
||||
action.dataflow = dataflow;
|
||||
action.response = response;
|
||||
expectedParameters.put("registryEnvironment", "UNITTEST");
|
||||
expectedParameters.put("startTime", "2020-02-01T00:00:00.000Z");
|
||||
expectedParameters.put("endTime", "2020-02-02T00:00:00.000Z");
|
||||
expectedParameters.put("startTime", "2020-02-01T00:00:00Z");
|
||||
expectedParameters.put("endTime", "2020-02-02T00:00:00Z");
|
||||
expectedParameters.put("isDryRun", "false");
|
||||
expectedParameters.put("advanceCursor", "true");
|
||||
tm().transact(() -> tm().put(Cursor.createGlobal(CursorType.RECURRING_BILLING, cursorTime)));
|
||||
tm().transact(
|
||||
() ->
|
||||
tm().put(
|
||||
Cursor.createGlobal(CursorType.RECURRING_BILLING, toDateTime(cursorTime))));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -89,7 +93,7 @@ public class ExpandBillingRecurrencesActionTest extends BeamActionTestBase {
|
||||
|
||||
@Test
|
||||
void testSuccess_provideEndTime() throws Exception {
|
||||
action.endTimeParam = Optional.of(DateTime.parse("2020-02-01T12:00:00.001Z"));
|
||||
action.endTimeParam = Optional.of(Instant.parse("2020-02-01T12:00:00.001Z"));
|
||||
expectedParameters.put("endTime", "2020-02-01T12:00:00.001Z");
|
||||
action.run();
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
@@ -102,7 +106,7 @@ public class ExpandBillingRecurrencesActionTest extends BeamActionTestBase {
|
||||
|
||||
@Test
|
||||
void testSuccess_provideStartTime() throws Exception {
|
||||
action.startTimeParam = Optional.of(DateTime.parse("2020-01-01T12:00:00.001Z"));
|
||||
action.startTimeParam = Optional.of(Instant.parse("2020-01-01T12:00:00.001Z"));
|
||||
expectedParameters.put("startTime", "2020-01-01T12:00:00.001Z");
|
||||
action.run();
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
@@ -143,7 +147,7 @@ public class ExpandBillingRecurrencesActionTest extends BeamActionTestBase {
|
||||
|
||||
@Test
|
||||
void testFailure_endTimeAfterNow() throws Exception {
|
||||
action.endTimeParam = Optional.of(DateTime.parse("2020-02-03T00:00:00Z"));
|
||||
action.endTimeParam = Optional.of(Instant.parse("2020-02-03T00:00:00Z"));
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(IllegalArgumentException.class, () -> action.run());
|
||||
assertThat(thrown.getMessage()).contains("must be at or before now");
|
||||
@@ -152,7 +156,7 @@ public class ExpandBillingRecurrencesActionTest extends BeamActionTestBase {
|
||||
|
||||
@Test
|
||||
void testFailure_startTimeAfterEndTime() throws Exception {
|
||||
action.startTimeParam = Optional.of(DateTime.parse("2020-02-03T00:00:00Z"));
|
||||
action.startTimeParam = Optional.of(Instant.parse("2020-02-03T00:00:00Z"));
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(IllegalArgumentException.class, () -> action.run());
|
||||
assertThat(thrown.getMessage()).contains("must be before end time");
|
||||
|
||||
+78
-56
@@ -29,7 +29,12 @@ import static google.registry.testing.DatabaseHelper.getOnlyHistoryEntryOfType;
|
||||
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatabaseHelper.persistPremiumList;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.END_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.minusYears;
|
||||
import static google.registry.util.DateTimeUtils.plusDays;
|
||||
import static google.registry.util.DateTimeUtils.plusYears;
|
||||
import static google.registry.util.DateTimeUtils.toDateTime;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
@@ -52,6 +57,9 @@ import google.registry.persistence.PersistenceModule.TransactionIsolationLevel;
|
||||
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.time.temporal.ChronoUnit;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
@@ -61,9 +69,6 @@ import org.apache.beam.sdk.options.PipelineOptionsFactory;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
import org.joda.time.format.DateTimeFormatter;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
@@ -73,16 +78,13 @@ import org.junit.jupiter.params.provider.ValueSource;
|
||||
/** Unit tests for {@link ExpandBillingRecurrencesPipeline}. */
|
||||
public class ExpandBillingRecurrencesPipelineTest {
|
||||
|
||||
private static final DateTimeFormatter DATE_TIME_FORMATTER =
|
||||
DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
|
||||
private final FakeClock clock = new FakeClock(Instant.parse("2021-02-02T00:00:05.000Z"));
|
||||
|
||||
private final FakeClock clock = new FakeClock(DateTime.parse("2021-02-02T00:00:05Z"));
|
||||
private final Instant startTime = Instant.parse("2021-02-01T00:00:00.000Z");
|
||||
|
||||
private final DateTime startTime = DateTime.parse("2021-02-01TZ");
|
||||
private Instant endTime = Instant.parse("2021-02-02T00:00:00.000Z");
|
||||
|
||||
private DateTime endTime = DateTime.parse("2021-02-02TZ");
|
||||
|
||||
private final Cursor cursor = Cursor.createGlobal(RECURRING_BILLING, startTime);
|
||||
private final Cursor cursor = Cursor.createGlobal(RECURRING_BILLING, toDateTime(startTime));
|
||||
|
||||
private Domain domain;
|
||||
|
||||
@@ -106,21 +108,22 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
// Set up the pipeline.
|
||||
options.setStartTime(DATE_TIME_FORMATTER.print(startTime));
|
||||
options.setEndTime(DATE_TIME_FORMATTER.print(endTime));
|
||||
options.setStartTime(startTime.toString());
|
||||
options.setEndTime(endTime.toString());
|
||||
options.setIsDryRun(false);
|
||||
options.setAdvanceCursor(true);
|
||||
tm().transact(() -> tm().put(cursor));
|
||||
|
||||
// Set up the database.
|
||||
createTld("tld");
|
||||
billingRecurrence = createDomainAtTime("example.tld", startTime.minusYears(1).plusHours(12));
|
||||
domain = ForeignKeyUtils.loadResource(Domain.class, "example.tld", clock.nowUtc()).get();
|
||||
billingRecurrence =
|
||||
createDomainAtTime("example.tld", minusYears(startTime, 1).plus(12, ChronoUnit.HOURS));
|
||||
domain = ForeignKeyUtils.loadResource(Domain.class, "example.tld", clock.now()).get();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailure_endTimeAfterNow() {
|
||||
options.setEndTime(DATE_TIME_FORMATTER.print(clock.nowUtc().plusMillis(1)));
|
||||
options.setEndTime(clock.now().plus(1, ChronoUnit.MILLIS).toString());
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(IllegalArgumentException.class, this::runPipeline);
|
||||
assertThat(thrown)
|
||||
@@ -130,12 +133,12 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
|
||||
@Test
|
||||
void testFailure_endTimeBeforeStartTime() {
|
||||
options.setEndTime(DATE_TIME_FORMATTER.print(startTime.minusMillis(1)));
|
||||
options.setEndTime(startTime.minus(1, ChronoUnit.MILLIS).toString());
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(IllegalArgumentException.class, this::runPipeline);
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("[2021-02-01T00:00:00.000Z, 2021-01-31T23:59:59.999Z)");
|
||||
.contains("[2021-02-01T00:00:00Z, 2021-01-31T23:59:59.999Z)");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -151,7 +154,7 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
defaultOneTime(getOnlyAutoRenewHistory()),
|
||||
billingRecurrence
|
||||
.asBuilder()
|
||||
.setRecurrenceLastExpansion(domain.getCreationTime().plusYears(1))
|
||||
.setRecurrenceLastExpansion(plusYears(domain.getCreationTimeInstant(), 1))
|
||||
.build());
|
||||
|
||||
// Assert about Cursor.
|
||||
@@ -160,10 +163,15 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
|
||||
@Test
|
||||
void testSuccess_expandSingleEvent_deletedDuringGracePeriod() {
|
||||
domain = persistResource(domain.asBuilder().setDeletionTime(endTime.minusHours(2)).build());
|
||||
domain =
|
||||
persistResource(
|
||||
domain.asBuilder().setDeletionTime(endTime.minus(Duration.ofHours(2))).build());
|
||||
billingRecurrence =
|
||||
persistResource(
|
||||
billingRecurrence.asBuilder().setRecurrenceEndTime(endTime.minusHours(2)).build());
|
||||
billingRecurrence
|
||||
.asBuilder()
|
||||
.setRecurrenceEndTime(endTime.minus(Duration.ofHours(2)))
|
||||
.build());
|
||||
runPipeline();
|
||||
|
||||
// Assert about DomainHistory, no transaction record should have been written.
|
||||
@@ -176,7 +184,7 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
defaultOneTime(getOnlyAutoRenewHistory()),
|
||||
billingRecurrence
|
||||
.asBuilder()
|
||||
.setRecurrenceLastExpansion(domain.getCreationTime().plusYears(1))
|
||||
.setRecurrenceLastExpansion(plusYears(domain.getCreationTimeInstant(), 1))
|
||||
.build());
|
||||
|
||||
// Assert about Cursor.
|
||||
@@ -185,7 +193,11 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
|
||||
@Test
|
||||
void testFailure_expandSingleEvent_cursorNotAtStartTime() {
|
||||
tm().transact(() -> tm().put(Cursor.createGlobal(RECURRING_BILLING, startTime.plusMillis(1))));
|
||||
tm().transact(
|
||||
() ->
|
||||
tm().put(
|
||||
Cursor.createGlobal(
|
||||
RECURRING_BILLING, toDateTime(startTime.plusMillis(1)))));
|
||||
|
||||
PipelineExecutionException thrown =
|
||||
assertThrows(PipelineExecutionException.class, this::runPipeline);
|
||||
@@ -201,7 +213,7 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
defaultOneTime(getOnlyAutoRenewHistory()),
|
||||
billingRecurrence
|
||||
.asBuilder()
|
||||
.setRecurrenceLastExpansion(domain.getCreationTime().plusYears(1))
|
||||
.setRecurrenceLastExpansion(plusYears(domain.getCreationTimeInstant(), 1))
|
||||
.build());
|
||||
|
||||
// Assert that the cursor did not change.
|
||||
@@ -214,7 +226,8 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
persistResource(
|
||||
billingRecurrence
|
||||
.asBuilder()
|
||||
.setRecurrenceEndTime(billingRecurrence.getEventTime().minusDays(1))
|
||||
.setRecurrenceEndTime(
|
||||
billingRecurrence.getEventTimeInstant().minus(1, ChronoUnit.DAYS))
|
||||
.build());
|
||||
runPipeline();
|
||||
assertNoExpansionsHappened();
|
||||
@@ -224,7 +237,10 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
void testSuccess_noExpansion_recurrenceClosedBeforeStartTime() {
|
||||
billingRecurrence =
|
||||
persistResource(
|
||||
billingRecurrence.asBuilder().setRecurrenceEndTime(startTime.minusDays(1)).build());
|
||||
billingRecurrence
|
||||
.asBuilder()
|
||||
.setRecurrenceEndTime(startTime.minus(1, ChronoUnit.DAYS))
|
||||
.build());
|
||||
runPipeline();
|
||||
assertNoExpansionsHappened();
|
||||
}
|
||||
@@ -235,8 +251,8 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
persistResource(
|
||||
billingRecurrence
|
||||
.asBuilder()
|
||||
.setEventTime(billingRecurrence.getEventTime().minusYears(1))
|
||||
.setRecurrenceEndTime(startTime.plusHours(6))
|
||||
.setEventTime(minusYears(billingRecurrence.getEventTimeInstant(), 1))
|
||||
.setRecurrenceEndTime(startTime.plus(6, ChronoUnit.HOURS))
|
||||
.build());
|
||||
runPipeline();
|
||||
assertNoExpansionsHappened();
|
||||
@@ -245,7 +261,7 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
@Test
|
||||
void testSuccess_noExpansion_eventTimeAfterEndTime() {
|
||||
billingRecurrence =
|
||||
persistResource(billingRecurrence.asBuilder().setEventTime(endTime.plusDays(1)).build());
|
||||
persistResource(billingRecurrence.asBuilder().setEventTime(plusDays(endTime, 1)).build());
|
||||
runPipeline();
|
||||
assertNoExpansionsHappened();
|
||||
}
|
||||
@@ -256,7 +272,7 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
persistResource(
|
||||
billingRecurrence
|
||||
.asBuilder()
|
||||
.setRecurrenceLastExpansion(startTime.minusYears(1).plusDays(1))
|
||||
.setRecurrenceLastExpansion(plusDays(minusYears(startTime, 1), 1))
|
||||
.build());
|
||||
runPipeline();
|
||||
assertNoExpansionsHappened();
|
||||
@@ -300,7 +316,7 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
defaultOneTime(getOnlyAutoRenewHistory()),
|
||||
billingRecurrence
|
||||
.asBuilder()
|
||||
.setRecurrenceLastExpansion(domain.getCreationTime().plusYears(1))
|
||||
.setRecurrenceLastExpansion(plusYears(domain.getCreationTimeInstant(), 1))
|
||||
.build());
|
||||
|
||||
// Assert that the cursor did not move.
|
||||
@@ -319,10 +335,10 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
.asBuilder()
|
||||
.setPremiumList(persistPremiumList("premium", USD, "other,USD 100"))
|
||||
.build());
|
||||
DateTime otherCreateTime = startTime.minusYears(1).plusHours(5);
|
||||
Instant otherCreateTime = minusYears(startTime, 1).plus(5, ChronoUnit.HOURS);
|
||||
BillingRecurrence otherBillingRecurrence = createDomainAtTime("other.test", otherCreateTime);
|
||||
Domain otherDomain =
|
||||
ForeignKeyUtils.loadResource(Domain.class, "other.test", clock.nowUtc()).get();
|
||||
ForeignKeyUtils.loadResource(Domain.class, "other.test", clock.now()).get();
|
||||
|
||||
options.setTargetParallelism(numOfThreads);
|
||||
runPipeline();
|
||||
@@ -339,7 +355,7 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
defaultOneTime(getOnlyAutoRenewHistory()),
|
||||
billingRecurrence
|
||||
.asBuilder()
|
||||
.setRecurrenceLastExpansion(domain.getCreationTime().plusYears(1))
|
||||
.setRecurrenceLastExpansion(plusYears(domain.getCreationTimeInstant(), 1))
|
||||
.build());
|
||||
assertBillingEventsForResource(
|
||||
otherDomain,
|
||||
@@ -347,7 +363,7 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
otherDomain, getOnlyAutoRenewHistory(otherDomain), otherBillingRecurrence, 100),
|
||||
otherBillingRecurrence
|
||||
.asBuilder()
|
||||
.setRecurrenceLastExpansion(otherDomain.getCreationTime().plusYears(1))
|
||||
.setRecurrenceLastExpansion(plusYears(otherDomain.getCreationTimeInstant(), 1))
|
||||
.build());
|
||||
|
||||
// Assert about Cursor.
|
||||
@@ -356,9 +372,9 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
|
||||
@Test
|
||||
void testSuccess_expandMultipleEvents_multipleEventTime() {
|
||||
clock.advanceBy(Duration.standardDays(365));
|
||||
endTime = endTime.plusYears(1);
|
||||
options.setEndTime(DATE_TIME_FORMATTER.print(endTime));
|
||||
clock.advanceBy(org.joda.time.Duration.standardDays(365));
|
||||
endTime = plusYears(endTime, 1);
|
||||
options.setEndTime(endTime.toString());
|
||||
|
||||
runPipeline();
|
||||
// Assert about DomainHistory.
|
||||
@@ -371,10 +387,9 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
DomainTransactionRecord.create(
|
||||
domain.getTld(),
|
||||
// We report this when the autorenew grace period ends.
|
||||
domain
|
||||
.getCreationTime()
|
||||
.plusYears(2)
|
||||
.plus(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD),
|
||||
plusYears(domain.getCreationTimeInstant(), 2)
|
||||
.plus(
|
||||
Duration.ofMillis(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD.getMillis())),
|
||||
TransactionReportField.netRenewsFieldFromYears(1),
|
||||
1)))
|
||||
.build());
|
||||
@@ -389,20 +404,21 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
h.getDomainTransactionRecords().stream()
|
||||
.findFirst()
|
||||
.get()
|
||||
.getReportingTime()))
|
||||
.getReportingTimeInstant()))
|
||||
.collect(toImmutableList());
|
||||
assertBillingEventsForResource(
|
||||
domain,
|
||||
defaultOneTime(histories.get(0)),
|
||||
defaultOneTime(histories.get(1))
|
||||
.asBuilder()
|
||||
.setEventTime(domain.getCreationTime().plusYears(2))
|
||||
.setEventTime(plusYears(domain.getCreationTimeInstant(), 2))
|
||||
.setBillingTime(
|
||||
domain.getCreationTime().plusYears(2).plus(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD))
|
||||
plusYears(domain.getCreationTimeInstant(), 2)
|
||||
.plus(Duration.ofMillis(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD.getMillis())))
|
||||
.build(),
|
||||
billingRecurrence
|
||||
.asBuilder()
|
||||
.setRecurrenceLastExpansion(domain.getCreationTime().plusYears(2))
|
||||
.setRecurrenceLastExpansion(plusYears(domain.getCreationTimeInstant(), 2))
|
||||
.build());
|
||||
|
||||
// Assert about Cursor.
|
||||
@@ -445,7 +461,7 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
return new DomainHistory.Builder()
|
||||
.setBySuperuser(false)
|
||||
.setRegistrarId("TheRegistrar")
|
||||
.setModificationTime(clock.nowUtc())
|
||||
.setModificationTime(clock.now())
|
||||
.setDomain(domain)
|
||||
.setPeriod(Period.create(1, YEARS))
|
||||
.setReason("Domain autorenewal by ExpandRecurringBillingEventsPipeline")
|
||||
@@ -456,7 +472,8 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
DomainTransactionRecord.create(
|
||||
domain.getTld(),
|
||||
// We report this when the autorenew grace period ends.
|
||||
domain.getCreationTime().plusYears(1).plus(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD),
|
||||
plusYears(domain.getCreationTimeInstant(), 1)
|
||||
.plus(Duration.ofMillis(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD.getMillis())),
|
||||
TransactionReportField.netRenewsFieldFromYears(1),
|
||||
1)))
|
||||
.build();
|
||||
@@ -470,10 +487,11 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
Domain domain, DomainHistory history, BillingRecurrence billingRecurrence, int cost) {
|
||||
return new BillingEvent.Builder()
|
||||
.setBillingTime(
|
||||
domain.getCreationTime().plusYears(1).plus(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD))
|
||||
plusYears(domain.getCreationTimeInstant(), 1)
|
||||
.plus(Duration.ofMillis(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD.getMillis())))
|
||||
.setRegistrarId("TheRegistrar")
|
||||
.setCost(Money.of(USD, cost))
|
||||
.setEventTime(domain.getCreationTime().plusYears(1))
|
||||
.setEventTime(plusYears(domain.getCreationTimeInstant(), 1))
|
||||
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW, Flag.SYNTHETIC))
|
||||
.setPeriodYears(1)
|
||||
.setReason(Reason.RENEW)
|
||||
@@ -515,14 +533,18 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
return getOnlyAutoRenewHistory(domain);
|
||||
}
|
||||
|
||||
private static void assertCursorAt(DateTime expectedCursorTime) {
|
||||
private static void assertCursorAt(Instant expectedCursorTime) {
|
||||
Cursor cursor = tm().transact(() -> tm().loadByKey(Cursor.createGlobalVKey(RECURRING_BILLING)));
|
||||
assertThat(cursor).isNotNull();
|
||||
assertThat(cursor.getCursorTime()).isEqualTo(expectedCursorTime);
|
||||
assertThat(cursor.getCursorTimeInstant()).isEqualTo(expectedCursorTime);
|
||||
}
|
||||
|
||||
private static BillingRecurrence createDomainAtTime(String domainName, DateTime createTime) {
|
||||
Domain domain = persistActiveDomain(domainName, createTime);
|
||||
private static void assertCursorAt(DateTime expectedCursorTime) {
|
||||
assertCursorAt(toInstant(expectedCursorTime));
|
||||
}
|
||||
|
||||
private static BillingRecurrence createDomainAtTime(String domainName, Instant createTime) {
|
||||
Domain domain = persistActiveDomain(domainName, toDateTime(createTime));
|
||||
DomainHistory domainHistory =
|
||||
persistResource(
|
||||
new DomainHistory.Builder()
|
||||
@@ -535,10 +557,10 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
new BillingRecurrence.Builder()
|
||||
.setDomainHistory(domainHistory)
|
||||
.setRegistrarId(domain.getCreationRegistrarId())
|
||||
.setEventTime(createTime.plusYears(1))
|
||||
.setEventTime(plusYears(createTime, 1))
|
||||
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
|
||||
.setReason(Reason.RENEW)
|
||||
.setRecurrenceEndTime(END_OF_TIME)
|
||||
.setRecurrenceEndTime(END_INSTANT)
|
||||
.setTargetId(domain.getDomainName())
|
||||
.build());
|
||||
}
|
||||
|
||||
+27
-19
@@ -26,7 +26,7 @@ import static google.registry.testing.DatabaseHelper.persistDomainWithDependentR
|
||||
import static google.registry.testing.DatabaseHelper.persistDomainWithPendingTransfer;
|
||||
import static google.registry.testing.DatabaseHelper.persistNewRegistrars;
|
||||
import static google.registry.util.DateTimeUtils.plusYears;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
import static google.registry.util.DateTimeUtils.toDateTime;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -43,6 +43,8 @@ import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationT
|
||||
import google.registry.persistence.transaction.JpaTransactionManager;
|
||||
import google.registry.persistence.transaction.TransactionManagerFactory;
|
||||
import google.registry.testing.FakeClock;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import org.apache.beam.sdk.options.PipelineOptionsFactory;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.joda.time.DateTime;
|
||||
@@ -82,7 +84,7 @@ public class ResaveAllEppResourcesPipelineTest {
|
||||
@Test
|
||||
void testPipeline_unchangedEntity() {
|
||||
Host host = persistActiveHost("ns1.example.tld");
|
||||
DateTime creationTime = host.getUpdateTimestamp().getTimestamp();
|
||||
Instant creationTime = host.getUpdateTimestamp().getTimestamp();
|
||||
fakeClock.advanceOneMilli();
|
||||
assertThat(loadByEntity(host).getUpdateTimestamp().getTimestamp()).isEqualTo(creationTime);
|
||||
fakeClock.advanceOneMilli();
|
||||
@@ -93,51 +95,57 @@ public class ResaveAllEppResourcesPipelineTest {
|
||||
@Test
|
||||
void testPipeline_fulfilledDomainTransfer() {
|
||||
options.setFast(true);
|
||||
DateTime now = fakeClock.nowUtc();
|
||||
Instant now = fakeClock.now();
|
||||
Domain domain =
|
||||
persistDomainWithPendingTransfer(
|
||||
persistDomainWithDependentResources(
|
||||
"domain", "tld", now.minusDays(5), now.minusDays(5), now.plusYears(2)),
|
||||
now.minusDays(4),
|
||||
now.minusDays(1),
|
||||
now.plusYears(2));
|
||||
"domain",
|
||||
"tld",
|
||||
toDateTime(now.minus(5, ChronoUnit.DAYS)),
|
||||
toDateTime(now.minus(5, ChronoUnit.DAYS)),
|
||||
toDateTime(plusYears(now, 2))),
|
||||
toDateTime(now.minus(4, ChronoUnit.DAYS)),
|
||||
toDateTime(now.minus(1, ChronoUnit.DAYS)),
|
||||
toDateTime(plusYears(now, 2)));
|
||||
assertThat(domain.getStatusValues()).contains(StatusValue.PENDING_TRANSFER);
|
||||
assertThat(domain.getUpdateTimestamp().getTimestamp()).isEqualTo(now);
|
||||
fakeClock.advanceOneMilli();
|
||||
runPipeline();
|
||||
Domain postPipeline = loadByEntity(domain);
|
||||
assertThat(postPipeline.getStatusValues()).doesNotContain(StatusValue.PENDING_TRANSFER);
|
||||
assertThat(postPipeline.getUpdateTimestamp().getTimestamp()).isEqualTo(fakeClock.nowUtc());
|
||||
assertThat(postPipeline.getUpdateTimestamp().getTimestamp()).isEqualTo(fakeClock.now());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPipeline_autorenewedDomain() {
|
||||
DateTime now = fakeClock.nowUtc();
|
||||
Instant now = fakeClock.now();
|
||||
Domain domain =
|
||||
persistDomainWithDependentResources("domain", "tld", now, now, now.plusYears(1));
|
||||
assertThat(domain.getRegistrationExpirationTime()).isEqualTo(plusYears(toInstant(now), 1));
|
||||
persistDomainWithDependentResources(
|
||||
"domain", "tld", toDateTime(now), toDateTime(now), toDateTime(plusYears(now, 1)));
|
||||
assertThat(domain.getRegistrationExpirationTime()).isEqualTo(plusYears(now, 1));
|
||||
fakeClock.advanceBy(Duration.standardDays(500));
|
||||
runPipeline();
|
||||
Domain postPipeline = loadByEntity(domain);
|
||||
assertThat(postPipeline.getRegistrationExpirationTime())
|
||||
.isEqualTo(plusYears(toInstant(now), 2));
|
||||
assertThat(postPipeline.getRegistrationExpirationTime()).isEqualTo(plusYears(now, 2));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPipeline_expiredGracePeriod() {
|
||||
DateTime now = fakeClock.nowUtc();
|
||||
persistDomainWithDependentResources("domain", "tld", now, now, now.plusYears(1));
|
||||
Instant now = fakeClock.now();
|
||||
persistDomainWithDependentResources(
|
||||
"domain", "tld", toDateTime(now), toDateTime(now), toDateTime(plusYears(now, 1)));
|
||||
assertThat(loadAllOf(GracePeriod.class)).hasSize(1);
|
||||
fakeClock.advanceBy(Duration.standardDays(500));
|
||||
fakeClock.advanceBy(org.joda.time.Duration.standardDays(500));
|
||||
runPipeline();
|
||||
assertThat(loadAllOf(GracePeriod.class)).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPipeline_fastOnlySavesChanged() {
|
||||
DateTime now = fakeClock.nowUtc();
|
||||
persistDomainWithDependentResources("renewed", "tld", now, now, now.plusYears(1));
|
||||
persistActiveDomain("nonrenewed.tld", now, now.plusYears(20));
|
||||
Instant now = fakeClock.now();
|
||||
persistDomainWithDependentResources(
|
||||
"renewed", "tld", toDateTime(now), toDateTime(now), toDateTime(plusYears(now, 1)));
|
||||
persistActiveDomain("nonrenewed.tld", toDateTime(now), toDateTime(plusYears(now, 20)));
|
||||
// Spy the transaction manager so we can be sure we're only saving the renewed domain
|
||||
JpaTransactionManager spy = spy(tm());
|
||||
TransactionManagerFactory.setJpaTm(() -> spy);
|
||||
|
||||
@@ -25,7 +25,8 @@ 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_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.toDateTime;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.startsWith;
|
||||
@@ -56,10 +57,10 @@ import google.registry.testing.FakeClock;
|
||||
import google.registry.tldconfig.idn.IdnTableEnum;
|
||||
import google.registry.util.EmailMessage;
|
||||
import jakarta.mail.internet.InternetAddress;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
@@ -75,9 +76,9 @@ public class BsaValidateActionTest {
|
||||
|
||||
private static final String DOWNLOAD_JOB_NAME = "job";
|
||||
|
||||
private static final Duration MAX_STALENESS = Duration.standardMinutes(1);
|
||||
private static final Duration MAX_STALENESS = Duration.ofMinutes(1);
|
||||
|
||||
FakeClock fakeClock = new FakeClock(DateTime.parse("2023-11-09T02:08:57.880Z"));
|
||||
FakeClock fakeClock = new FakeClock(Instant.parse("2023-11-09T02:08:57.880Z"));
|
||||
|
||||
@RegisterExtension
|
||||
final JpaIntegrationWithCoverageExtension jpa =
|
||||
@@ -107,7 +108,7 @@ public class BsaValidateActionTest {
|
||||
idnChecker,
|
||||
new BsaEmailSender(gmailClient, emailRecipient),
|
||||
/* transactionBatchSize= */ 500,
|
||||
MAX_STALENESS,
|
||||
org.joda.time.Duration.millis(MAX_STALENESS.toMillis()),
|
||||
fakeClock,
|
||||
response);
|
||||
createTld("app");
|
||||
@@ -237,16 +238,17 @@ public class BsaValidateActionTest {
|
||||
@Test
|
||||
void isStalenessAllowed_newDomain_allowed() {
|
||||
persistBsaLabel("label");
|
||||
Domain domain = persistActiveDomain("label.app", fakeClock.nowUtc());
|
||||
fakeClock.advanceBy(MAX_STALENESS.minus(Duration.standardSeconds(1)));
|
||||
Domain domain = persistActiveDomain("label.app", toDateTime(fakeClock.now()));
|
||||
fakeClock.advanceBy(
|
||||
org.joda.time.Duration.millis(MAX_STALENESS.minus(Duration.ofSeconds(1)).toMillis()));
|
||||
assertThat(action.isStalenessAllowed(domain)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isStalenessAllowed_newDomain_notAllowed() {
|
||||
persistBsaLabel("label");
|
||||
Domain domain = persistActiveDomain("label.app", fakeClock.nowUtc());
|
||||
fakeClock.advanceBy(MAX_STALENESS);
|
||||
Domain domain = persistActiveDomain("label.app", toDateTime(fakeClock.now()));
|
||||
fakeClock.advanceBy(org.joda.time.Duration.millis(MAX_STALENESS.toMillis()));
|
||||
assertThat(action.isStalenessAllowed(domain)).isFalse();
|
||||
}
|
||||
|
||||
@@ -276,9 +278,15 @@ public class BsaValidateActionTest {
|
||||
@Test
|
||||
void checkForMissingReservedUnblockables_success() {
|
||||
persistResource(
|
||||
createTld("app").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
|
||||
createTld("app")
|
||||
.asBuilder()
|
||||
.setBsaEnrollStartTime(Optional.of(toDateTime(START_INSTANT)))
|
||||
.build());
|
||||
persistResource(
|
||||
createTld("dev").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
|
||||
createTld("dev")
|
||||
.asBuilder()
|
||||
.setBsaEnrollStartTime(Optional.of(toDateTime(START_INSTANT)))
|
||||
.build());
|
||||
persistBsaLabel("registered-reserved");
|
||||
persistBsaLabel("reserved-only");
|
||||
persistBsaLabel("reserved-missing");
|
||||
@@ -294,7 +302,7 @@ public class BsaValidateActionTest {
|
||||
.collect(toImmutableMap(x -> x, x -> ReservationType.RESERVED_FOR_SPECIFIC_USE)));
|
||||
addReservedListsToTld("app", ImmutableList.of("rl"));
|
||||
|
||||
ImmutableList<String> errors = action.checkForMissingReservedUnblockables(fakeClock.nowUtc());
|
||||
ImmutableList<String> errors = action.checkForMissingReservedUnblockables(fakeClock.now());
|
||||
assertThat(errors)
|
||||
.containsExactly("Missing unblockable domain: reserved-missing.app is reserved.");
|
||||
}
|
||||
@@ -302,9 +310,15 @@ public class BsaValidateActionTest {
|
||||
@Test
|
||||
void checkForMissingReservedUnblockablesInOneTld_success() {
|
||||
persistResource(
|
||||
createTld("app").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
|
||||
createTld("app")
|
||||
.asBuilder()
|
||||
.setBsaEnrollStartTime(Optional.of(toDateTime(START_INSTANT)))
|
||||
.build());
|
||||
persistResource(
|
||||
createTld("dev").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
|
||||
createTld("dev")
|
||||
.asBuilder()
|
||||
.setBsaEnrollStartTime(Optional.of(toDateTime(START_INSTANT)))
|
||||
.build());
|
||||
persistBsaLabel("reserved-missing-in-app");
|
||||
persistUnblockableDomain(
|
||||
UnblockableDomain.of("reserved-missing-in-app", "dev", Reason.REGISTERED));
|
||||
@@ -316,7 +330,7 @@ public class BsaValidateActionTest {
|
||||
addReservedListsToTld("app", ImmutableList.of("rl"));
|
||||
addReservedListsToTld("dev", ImmutableList.of("rl"));
|
||||
|
||||
ImmutableList<String> errors = action.checkForMissingReservedUnblockables(fakeClock.nowUtc());
|
||||
ImmutableList<String> errors = action.checkForMissingReservedUnblockables(fakeClock.now());
|
||||
assertThat(errors)
|
||||
.containsExactly("Missing unblockable domain: reserved-missing-in-app.app is reserved.");
|
||||
}
|
||||
@@ -324,7 +338,10 @@ public class BsaValidateActionTest {
|
||||
@Test
|
||||
void checkForMissingReservedUnblockables_unblockedReservedNotReported() {
|
||||
persistResource(
|
||||
createTld("app").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
|
||||
createTld("app")
|
||||
.asBuilder()
|
||||
.setBsaEnrollStartTime(Optional.of(toDateTime(START_INSTANT)))
|
||||
.build());
|
||||
|
||||
createReservedList(
|
||||
"rl",
|
||||
@@ -332,14 +349,17 @@ public class BsaValidateActionTest {
|
||||
.collect(toImmutableMap(x -> x, x -> ReservationType.RESERVED_FOR_SPECIFIC_USE)));
|
||||
addReservedListsToTld("app", ImmutableList.of("rl"));
|
||||
|
||||
ImmutableList<String> errors = action.checkForMissingReservedUnblockables(fakeClock.nowUtc());
|
||||
ImmutableList<String> errors = action.checkForMissingReservedUnblockables(fakeClock.now());
|
||||
assertThat(errors).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkForMissingRegisteredUnblockables_success() {
|
||||
persistResource(
|
||||
createTld("app").asBuilder().setBsaEnrollStartTime(Optional.of(START_OF_TIME)).build());
|
||||
createTld("app")
|
||||
.asBuilder()
|
||||
.setBsaEnrollStartTime(Optional.of(toDateTime(START_INSTANT)))
|
||||
.build());
|
||||
persistBsaLabel("registered");
|
||||
persistBsaLabel("registered-missing");
|
||||
persistUnblockableDomain(UnblockableDomain.of("registered", "app", Reason.REGISTERED));
|
||||
@@ -347,7 +367,7 @@ public class BsaValidateActionTest {
|
||||
persistActiveDomain("registered.app");
|
||||
persistActiveDomain("registered-missing.app");
|
||||
|
||||
ImmutableList<String> errors = action.checkForMissingRegisteredUnblockables(fakeClock.nowUtc());
|
||||
ImmutableList<String> errors = action.checkForMissingRegisteredUnblockables(fakeClock.now());
|
||||
assertThat(errors)
|
||||
.containsExactly(
|
||||
"Registered domain registered-missing.app missing or not recorded as REGISTERED");
|
||||
|
||||
@@ -127,7 +127,7 @@ public class UploadBsaUnavailableDomainsActionTest {
|
||||
persistDeletedDomain("not-blocked.tld", clock.nowUtc().minusDays(1));
|
||||
action.run();
|
||||
BlobId existingFile =
|
||||
BlobId.of(BUCKET, String.format("unavailable_domains_%s.txt", clock.nowUtc()));
|
||||
BlobId.of(BUCKET, String.format("unavailable_domains_%s.txt", clock.now()));
|
||||
String blockList = new String(gcsUtils.readBytesFrom(existingFile), UTF_8);
|
||||
assertThat(blockList).isEqualTo("ace.tld\nflagrant.tld\nfoobar.tld\njimmy.tld\ntine.tld\n");
|
||||
assertThat(blockList).doesNotContain("not-blocked.tld");
|
||||
|
||||
@@ -40,7 +40,8 @@ public class BsaDomainRefreshTest {
|
||||
BsaDomainRefresh persisted =
|
||||
tm().transact(() -> tm().getEntityManager().merge(new BsaDomainRefresh()));
|
||||
assertThat(persisted.jobId).isNotNull();
|
||||
assertThat(persisted.creationTime.getTimestamp()).isEqualTo(fakeClock.nowUtc());
|
||||
assertThat(persisted.creationTime.getTimestamp()).isEqualTo(fakeClock.now());
|
||||
assertThat(persisted.updateTime.getTimestamp()).isEqualTo(fakeClock.now());
|
||||
assertThat(persisted.stage).isEqualTo(CHECK_FOR_CHANGES);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public class BsaDownloadTest {
|
||||
void saveJob() {
|
||||
BsaDownload persisted = tm().transact(() -> tm().getEntityManager().merge(new BsaDownload()));
|
||||
assertThat(persisted.jobId).isNotNull();
|
||||
assertThat(persisted.creationTime.getTimestamp()).isEqualTo(fakeClock.nowUtc());
|
||||
assertThat(persisted.creationTime.getTimestamp()).isEqualTo(fakeClock.now());
|
||||
assertThat(persisted.stage).isEqualTo(DOWNLOAD_BLOCK_LISTS);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,19 +16,18 @@ package google.registry.bsa.persistence;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import google.registry.persistence.transaction.JpaTestExtensions;
|
||||
import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationWithCoverageExtension;
|
||||
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;
|
||||
|
||||
/** Unit tests for {@link BsaLabel}. */
|
||||
public class BsaLabelTest {
|
||||
|
||||
FakeClock fakeClock = new FakeClock(DateTime.now(UTC));
|
||||
FakeClock fakeClock = new FakeClock(Instant.parse("2024-01-01T00:00:00Z"));
|
||||
|
||||
@RegisterExtension
|
||||
final JpaIntegrationWithCoverageExtension jpa =
|
||||
@@ -36,10 +35,10 @@ public class BsaLabelTest {
|
||||
|
||||
@Test
|
||||
void persist() {
|
||||
tm().transact(() -> tm().put(new BsaLabel("label", fakeClock.nowUtc())));
|
||||
tm().transact(() -> tm().put(new BsaLabel("label", fakeClock.now())));
|
||||
BsaLabel persisted = tm().transact(() -> tm().loadByKey(BsaLabel.vKey("label")));
|
||||
assertThat(persisted.getLabel()).isEqualTo("label");
|
||||
assertThat(persisted.creationTime).isEqualTo(fakeClock.nowUtc());
|
||||
assertThat(persisted.creationTime).isEqualTo(fakeClock.now());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -49,7 +48,7 @@ public class BsaLabelTest {
|
||||
|
||||
@Test
|
||||
void isLabelBlocked_yes() {
|
||||
tm().transact(() -> tm().put(new BsaLabel("abc", fakeClock.nowUtc())));
|
||||
tm().transact(() -> tm().put(new BsaLabel("abc", fakeClock.now())));
|
||||
assertThat(tm().transact(() -> BsaLabelUtils.isLabelBlocked("abc"))).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public class BsaLabelUtilsTest {
|
||||
JpaTransactionManager replicaTm = mock(JpaTransactionManager.class);
|
||||
setJpaTm(() -> primaryTm);
|
||||
setReplicaJpaTm(() -> replicaTm);
|
||||
when(replicaTm.loadByKey(any())).thenReturn(new BsaLabel("abc", fakeClock.nowUtc()));
|
||||
when(replicaTm.loadByKey(any())).thenReturn(new BsaLabel("abc", fakeClock.now()));
|
||||
try {
|
||||
assertThat(isLabelBlocked("abc")).isTrue();
|
||||
assertThat(isLabelBlocked("abc")).isTrue();
|
||||
@@ -85,7 +85,7 @@ public class BsaLabelUtilsTest {
|
||||
JpaTransactionManager replicaTmSave = replicaTm();
|
||||
JpaTransactionManager replicaTm = mock(JpaTransactionManager.class);
|
||||
setReplicaJpaTm(() -> replicaTm);
|
||||
when(replicaTm.loadByKey(any())).thenReturn(new BsaLabel("abc", fakeClock.nowUtc()));
|
||||
when(replicaTm.loadByKey(any())).thenReturn(new BsaLabel("abc", fakeClock.now()));
|
||||
try {
|
||||
assertThat(isLabelBlocked("abc")).isTrue();
|
||||
// If test fails, check and fix cache expiry in the config file. Do not increase the duration
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import google.registry.bsa.DownloadStage;
|
||||
import google.registry.bsa.api.UnblockableDomain;
|
||||
import google.registry.util.Clock;
|
||||
import org.joda.time.DateTime;
|
||||
import java.time.Instant;
|
||||
import org.joda.time.Duration;
|
||||
|
||||
/** Exposes BSA persistence entities and tools to test classes. */
|
||||
@@ -31,7 +31,7 @@ public final class BsaTestingUtils {
|
||||
public static final Duration DEFAULT_NOP_INTERVAL = Duration.standardDays(1);
|
||||
|
||||
/** An arbitrary point of time used as BsaLabels' creation time. */
|
||||
public static final DateTime BSA_LABEL_CREATION_TIME = DateTime.parse("2023-12-31T00:00:00Z");
|
||||
public static final Instant BSA_LABEL_CREATION_TIME = Instant.parse("2023-12-31T00:00:00Z");
|
||||
|
||||
private BsaTestingUtils() {}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class BsaUnblockableDomainTest {
|
||||
|
||||
@Test
|
||||
void persist() {
|
||||
tm().transact(() -> tm().put(new BsaLabel("label", fakeClock.nowUtc())));
|
||||
tm().transact(() -> tm().put(new BsaLabel("label", fakeClock.now())));
|
||||
tm().transact(() -> tm().put(new BsaUnblockableDomain("label", "tld", Reason.REGISTERED)));
|
||||
BsaUnblockableDomain persisted =
|
||||
tm().transact(() -> tm().loadByKey(BsaUnblockableDomain.vKey("label", "tld")));
|
||||
@@ -51,7 +51,7 @@ public class BsaUnblockableDomainTest {
|
||||
|
||||
@Test
|
||||
void cascadeDeletion() {
|
||||
tm().transact(() -> tm().put(new BsaLabel("label", fakeClock.nowUtc())));
|
||||
tm().transact(() -> tm().put(new BsaLabel("label", fakeClock.now())));
|
||||
tm().transact(() -> tm().put(new BsaUnblockableDomain("label", "tld", Reason.REGISTERED)));
|
||||
assertThat(
|
||||
tm().transact(() -> tm().loadByKeyIfPresent(BsaUnblockableDomain.vKey("label", "tld"))))
|
||||
|
||||
@@ -23,7 +23,8 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.newDomain;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.toDateTime;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import google.registry.bsa.api.UnblockableDomain;
|
||||
@@ -33,9 +34,9 @@ import google.registry.model.tld.Tld;
|
||||
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.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
@@ -43,7 +44,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
/** Unit tests for {@link DomainsRefresher}. */
|
||||
public class DomainsRefresherTest {
|
||||
|
||||
FakeClock fakeClock = new FakeClock(DateTime.parse("2023-11-09T02:08:57.880Z"));
|
||||
FakeClock fakeClock = new FakeClock(Instant.parse("2023-11-09T02:08:57.880Z"));
|
||||
|
||||
@RegisterExtension
|
||||
final JpaIntegrationWithCoverageExtension jpa =
|
||||
@@ -57,9 +58,9 @@ public class DomainsRefresherTest {
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setBsaEnrollStartTime(Optional.of(fakeClock.nowUtc().minusMillis(1)))
|
||||
.setBsaEnrollStartTime(Optional.of(toDateTime(fakeClock.now().minusMillis(1))))
|
||||
.build());
|
||||
refresher = new DomainsRefresher(START_OF_TIME, fakeClock.nowUtc(), Duration.ZERO, 100);
|
||||
refresher = new DomainsRefresher(START_INSTANT, fakeClock.now(), Duration.ZERO, 100);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -22,8 +22,6 @@ import static google.registry.bsa.DownloadStage.MAKE_ORDER_AND_LABEL_DIFF;
|
||||
import static google.registry.bsa.DownloadStage.NOP;
|
||||
import static google.registry.bsa.persistence.DownloadScheduler.fetchTwoMostRecentDownloads;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static org.joda.time.Duration.standardDays;
|
||||
import static org.joda.time.Duration.standardMinutes;
|
||||
import static org.joda.time.Duration.standardSeconds;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
@@ -35,8 +33,8 @@ import google.registry.bsa.persistence.DownloadSchedule.CompletedJob;
|
||||
import google.registry.persistence.transaction.JpaTestExtensions;
|
||||
import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationWithCoverageExtension;
|
||||
import google.registry.testing.FakeClock;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -46,10 +44,10 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
/** Unit tests for {@link DownloadScheduler} */
|
||||
class DownloadSchedulerTest {
|
||||
|
||||
static final Duration DOWNLOAD_INTERVAL = standardMinutes(30);
|
||||
static final Duration MAX_NOP_INTERVAL = standardDays(1);
|
||||
static final Duration DOWNLOAD_INTERVAL = Duration.standardMinutes(30);
|
||||
static final Duration MAX_NOP_INTERVAL = Duration.standardDays(1);
|
||||
|
||||
FakeClock fakeClock = new FakeClock(DateTime.parse("2023-11-09T02:08:57.880Z"));
|
||||
FakeClock fakeClock = new FakeClock(Instant.parse("2023-11-09T02:08:57.880Z"));
|
||||
|
||||
@RegisterExtension
|
||||
final JpaIntegrationWithCoverageExtension jpa =
|
||||
|
||||
@@ -86,7 +86,7 @@ class LabelDiffUpdatesTest {
|
||||
void applyLabelDiffs_delete() {
|
||||
tm().transact(
|
||||
() -> {
|
||||
tm().insert(new BsaLabel("label", fakeClock.nowUtc()));
|
||||
tm().insert(new BsaLabel("label", fakeClock.now()));
|
||||
tm().insert(new BsaUnblockableDomain("label", "app", Reason.REGISTERED));
|
||||
});
|
||||
when(idnChecker.getSupportingTlds(any())).thenReturn(ImmutableSet.of(app));
|
||||
@@ -108,7 +108,7 @@ class LabelDiffUpdatesTest {
|
||||
void applyLabelDiffs_newAssociationOfLabelToOrder() {
|
||||
tm().transact(
|
||||
() -> {
|
||||
tm().insert(new BsaLabel("label", fakeClock.nowUtc()));
|
||||
tm().insert(new BsaLabel("label", fakeClock.now()));
|
||||
tm().insert(new BsaUnblockableDomain("label", "app", Reason.REGISTERED));
|
||||
});
|
||||
when(idnChecker.getSupportingTlds(any())).thenReturn(ImmutableSet.of(app));
|
||||
@@ -141,7 +141,7 @@ class LabelDiffUpdatesTest {
|
||||
when(idnChecker.getForbiddingTlds(any()))
|
||||
.thenReturn(Sets.difference(ImmutableSet.of(dev), ImmutableSet.of()).immutableCopy());
|
||||
when(idnChecker.getSupportingTlds(any())).thenReturn(ImmutableSet.of(app, page));
|
||||
when(schedule.jobCreationTime()).thenReturn(fakeClock.nowUtc());
|
||||
when(schedule.jobCreationTime()).thenReturn(fakeClock.now());
|
||||
|
||||
ImmutableList<UnblockableDomain> unblockableDomains =
|
||||
applyLabelDiff(
|
||||
|
||||
@@ -33,7 +33,8 @@ import static google.registry.testing.DatabaseHelper.newDomain;
|
||||
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatabaseHelper.persistDomainAsDeleted;
|
||||
import static google.registry.testing.DatabaseHelper.persistNewRegistrar;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.END_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.toDateTime;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -43,8 +44,8 @@ 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.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;
|
||||
@@ -52,7 +53,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
/** Unit tests for {@link Queries}. */
|
||||
class QueriesTest {
|
||||
|
||||
FakeClock fakeClock = new FakeClock(DateTime.parse("2023-11-09T02:08:57.880Z"));
|
||||
FakeClock fakeClock = new FakeClock(Instant.parse("2023-11-09T02:08:57.880Z"));
|
||||
|
||||
@RegisterExtension
|
||||
final JpaIntegrationWithCoverageExtension jpa =
|
||||
@@ -64,9 +65,9 @@ class QueriesTest {
|
||||
() -> {
|
||||
tm().putAll(
|
||||
ImmutableList.of(
|
||||
new BsaLabel("label1", fakeClock.nowUtc()),
|
||||
new BsaLabel("label2", fakeClock.nowUtc()),
|
||||
new BsaLabel("label3", fakeClock.nowUtc())));
|
||||
new BsaLabel("label1", fakeClock.now()),
|
||||
new BsaLabel("label2", fakeClock.now()),
|
||||
new BsaLabel("label3", fakeClock.now())));
|
||||
tm().putAll(
|
||||
ImmutableList.of(
|
||||
BsaUnblockableDomain.of("label1.app", Reason.REGISTERED),
|
||||
@@ -109,7 +110,7 @@ class QueriesTest {
|
||||
() ->
|
||||
queryBsaLabelByLabels(ImmutableList.of("label1"))
|
||||
.collect(toImmutableList())))
|
||||
.containsExactly(new BsaLabel("label1", fakeClock.nowUtc()));
|
||||
.containsExactly(new BsaLabel("label1", fakeClock.now()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -120,7 +121,7 @@ class QueriesTest {
|
||||
queryBsaLabelByLabels(ImmutableList.of("label1", "label2"))
|
||||
.collect(toImmutableList())))
|
||||
.containsExactly(
|
||||
new BsaLabel("label1", fakeClock.nowUtc()), new BsaLabel("label2", fakeClock.nowUtc()));
|
||||
new BsaLabel("label1", fakeClock.now()), new BsaLabel("label2", fakeClock.now()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -139,7 +140,7 @@ class QueriesTest {
|
||||
.isEqualTo(1);
|
||||
assertThat(tm().transact(() -> tm().loadAllOf(BsaLabel.class)))
|
||||
.containsExactly(
|
||||
new BsaLabel("label2", fakeClock.nowUtc()), new BsaLabel("label3", fakeClock.nowUtc()));
|
||||
new BsaLabel("label2", fakeClock.now()), new BsaLabel("label3", fakeClock.now()));
|
||||
assertThat(
|
||||
tm().transact(
|
||||
() ->
|
||||
@@ -156,7 +157,7 @@ class QueriesTest {
|
||||
assertThat(tm().transact(() -> deleteBsaLabelByLabels(ImmutableList.of("label1", "label2"))))
|
||||
.isEqualTo(2);
|
||||
assertThat(tm().transact(() -> tm().loadAllOf(BsaLabel.class)))
|
||||
.containsExactly(new BsaLabel("label3", fakeClock.nowUtc()));
|
||||
.containsExactly(new BsaLabel("label3", fakeClock.now()));
|
||||
assertThat(
|
||||
tm().transact(
|
||||
() ->
|
||||
@@ -171,8 +172,8 @@ class QueriesTest {
|
||||
() ->
|
||||
tm().insertAll(
|
||||
ImmutableList.of(
|
||||
new BsaLabel("a", fakeClock.nowUtc()),
|
||||
new BsaLabel("b", fakeClock.nowUtc()))));
|
||||
new BsaLabel("a", fakeClock.now()),
|
||||
new BsaLabel("b", fakeClock.now()))));
|
||||
BsaUnblockableDomain a1 = new BsaUnblockableDomain("a", "tld1", Reason.RESERVED);
|
||||
BsaUnblockableDomain b1 = new BsaUnblockableDomain("b", "tld1", Reason.REGISTERED);
|
||||
BsaUnblockableDomain a2 = new BsaUnblockableDomain("a", "tld2", Reason.REGISTERED);
|
||||
@@ -203,65 +204,65 @@ class QueriesTest {
|
||||
|
||||
@Test
|
||||
void queryNewlyCreatedDomains_onlyLiveDomainsReturned() {
|
||||
DateTime testStartTime = fakeClock.nowUtc();
|
||||
Instant testStartTime = fakeClock.now();
|
||||
createTlds("tld");
|
||||
persistNewRegistrar("TheRegistrar");
|
||||
// time 0:
|
||||
persistActiveDomain("d1.tld", fakeClock.nowUtc());
|
||||
persistActiveDomain("d1.tld", toDateTime(fakeClock.now()));
|
||||
// time 0, deletion time 1
|
||||
persistDomainAsDeleted(
|
||||
newDomain("will-delete.tld").asBuilder().setCreationTimeForTest(fakeClock.nowUtc()).build(),
|
||||
fakeClock.nowUtc().plusMillis(1));
|
||||
newDomain("will-delete.tld").asBuilder().setCreationTimeForTest(fakeClock.now()).build(),
|
||||
toDateTime(fakeClock.now().plusMillis(1)));
|
||||
fakeClock.advanceOneMilli();
|
||||
// time 1
|
||||
persistActiveDomain("d2.tld", fakeClock.nowUtc());
|
||||
persistActiveDomain("d2.tld", toDateTime(fakeClock.now()));
|
||||
fakeClock.advanceOneMilli();
|
||||
// Now is time 2
|
||||
assertThat(
|
||||
bsaQuery(
|
||||
() ->
|
||||
queryNewlyCreatedDomains(
|
||||
ImmutableList.of("tld"), testStartTime, fakeClock.nowUtc())))
|
||||
ImmutableList.of("tld"), testStartTime, fakeClock.now())))
|
||||
.containsExactly("d1.tld", "d2.tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
void queryNewlyCreatedDomains_onlyDomainsAfterMinCreationTimeReturned() {
|
||||
DateTime testStartTime = fakeClock.nowUtc();
|
||||
Instant testStartTime = fakeClock.now();
|
||||
createTlds("tld");
|
||||
persistNewRegistrar("TheRegistrar");
|
||||
// time 0:
|
||||
persistActiveDomain("d1.tld", fakeClock.nowUtc());
|
||||
persistActiveDomain("d1.tld", toDateTime(fakeClock.now()));
|
||||
// time 0, deletion time 1
|
||||
persistDomainAsDeleted(
|
||||
newDomain("will-delete.tld").asBuilder().setCreationTimeForTest(fakeClock.nowUtc()).build(),
|
||||
fakeClock.nowUtc().plusMillis(1));
|
||||
newDomain("will-delete.tld").asBuilder().setCreationTimeForTest(fakeClock.now()).build(),
|
||||
toDateTime(fakeClock.now().plusMillis(1)));
|
||||
fakeClock.advanceOneMilli();
|
||||
// time 1
|
||||
persistActiveDomain("d2.tld", fakeClock.nowUtc());
|
||||
persistActiveDomain("d2.tld", toDateTime(fakeClock.now()));
|
||||
fakeClock.advanceOneMilli();
|
||||
// Now is time 2, ask for domains created since time 1
|
||||
assertThat(
|
||||
bsaQuery(
|
||||
() ->
|
||||
queryNewlyCreatedDomains(
|
||||
ImmutableList.of("tld"), testStartTime.plusMillis(1), fakeClock.nowUtc())))
|
||||
ImmutableList.of("tld"), testStartTime.plusMillis(1), fakeClock.now())))
|
||||
.containsExactly("d2.tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
void queryNewlyCreatedDomains_onlyDomainsInRequestedTldsReturned() {
|
||||
DateTime testStartTime = fakeClock.nowUtc();
|
||||
Instant testStartTime = fakeClock.now();
|
||||
createTlds("tld", "tld2");
|
||||
persistNewRegistrar("TheRegistrar");
|
||||
persistActiveDomain("d1.tld", fakeClock.nowUtc());
|
||||
persistActiveDomain("d2.tld2", fakeClock.nowUtc());
|
||||
persistActiveDomain("d1.tld", toDateTime(fakeClock.now()));
|
||||
persistActiveDomain("d2.tld2", toDateTime(fakeClock.now()));
|
||||
fakeClock.advanceOneMilli();
|
||||
assertThat(
|
||||
bsaQuery(
|
||||
() ->
|
||||
queryNewlyCreatedDomains(
|
||||
ImmutableList.of("tld"), testStartTime, fakeClock.nowUtc())))
|
||||
ImmutableList.of("tld"), testStartTime, fakeClock.now())))
|
||||
.containsExactly("d1.tld");
|
||||
}
|
||||
|
||||
@@ -269,34 +270,41 @@ class QueriesTest {
|
||||
void queryMissedRegisteredUnblockables_success() {
|
||||
createTlds("tld", "tld2");
|
||||
persistNewRegistrar("TheRegistrar");
|
||||
DateTime time1 = fakeClock.nowUtc();
|
||||
persistActiveDomain("unblocked1.tld", fakeClock.nowUtc());
|
||||
persistActiveDomain("unblocked2.tld2", fakeClock.nowUtc());
|
||||
persistActiveDomain("label1.tld", fakeClock.nowUtc());
|
||||
persistActiveDomain("label2.tld2", fakeClock.nowUtc());
|
||||
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()));
|
||||
fakeClock.advanceOneMilli();
|
||||
DateTime time2 = fakeClock.nowUtc();
|
||||
Instant time2 = fakeClock.now();
|
||||
persistDomainAsDeleted(
|
||||
newDomain("label3.tld").asBuilder().setCreationTimeForTest(fakeClock.nowUtc()).build(),
|
||||
fakeClock.nowUtc().plusMillis(1));
|
||||
newDomain("label3.tld").asBuilder().setCreationTimeForTest(fakeClock.now()).build(),
|
||||
toDateTime(fakeClock.now().plusMillis(1)));
|
||||
// Deleted in the future
|
||||
persistDomainAsDeleted(
|
||||
newDomain("label3.tld2").asBuilder().setCreationTimeForTest(fakeClock.nowUtc()).build(),
|
||||
fakeClock.nowUtc().plusHours(1));
|
||||
newDomain("label3.tld2").asBuilder().setCreationTimeForTest(fakeClock.now()).build(),
|
||||
toDateTime(fakeClock.now().plus(java.time.Duration.ofHours(1))));
|
||||
fakeClock.advanceOneMilli();
|
||||
assertThat(bsaQuery(() -> queryMissedRegisteredUnblockables("tld", fakeClock.nowUtc())))
|
||||
.containsExactly(new DomainLifeSpan("label1.tld", time1, END_OF_TIME));
|
||||
assertThat(bsaQuery(() -> queryMissedRegisteredUnblockables("tld2", fakeClock.nowUtc())))
|
||||
assertThat(
|
||||
(ImmutableList<DomainLifeSpan>)
|
||||
bsaQuery(() -> queryMissedRegisteredUnblockables("tld", fakeClock.now())))
|
||||
.containsExactly(new DomainLifeSpan("label1.tld", time1, END_INSTANT));
|
||||
assertThat(
|
||||
(ImmutableList<DomainLifeSpan>)
|
||||
bsaQuery(() -> queryMissedRegisteredUnblockables("tld2", fakeClock.now())))
|
||||
.containsExactly(
|
||||
new DomainLifeSpan("label2.tld2", time1, END_OF_TIME),
|
||||
new DomainLifeSpan("label3.tld2", time2, time2.plusHours(1)));
|
||||
new DomainLifeSpan("label2.tld2", time1, END_INSTANT),
|
||||
new DomainLifeSpan("label3.tld2", time2, time2.plus(java.time.Duration.ofHours(1))));
|
||||
|
||||
BsaTestingUtils.persistUnblockableDomain(
|
||||
UnblockableDomain.of("label2", "tld2", UnblockableDomain.Reason.REGISTERED));
|
||||
BsaTestingUtils.persistUnblockableDomain(
|
||||
UnblockableDomain.of("label3", "tld2", UnblockableDomain.Reason.RESERVED));
|
||||
assertThat(bsaQuery(() -> queryMissedRegisteredUnblockables("tld2", fakeClock.nowUtc())))
|
||||
.containsExactly(new DomainLifeSpan("label3.tld2", time2, time2.plusHours(1)));
|
||||
assertThat(
|
||||
(ImmutableList<DomainLifeSpan>)
|
||||
bsaQuery(() -> queryMissedRegisteredUnblockables("tld2", fakeClock.now())))
|
||||
.containsExactly(
|
||||
new DomainLifeSpan("label3.tld2", time2, time2.plus(java.time.Duration.ofHours(1))));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -24,8 +24,8 @@ import google.registry.bsa.RefreshStage;
|
||||
import google.registry.persistence.transaction.JpaTestExtensions;
|
||||
import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationWithCoverageExtension;
|
||||
import google.registry.testing.FakeClock;
|
||||
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;
|
||||
@@ -33,7 +33,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
/** Unit tests for {@link RefreshScheduler}. */
|
||||
public class RefreshSchedulerTest {
|
||||
|
||||
FakeClock fakeClock = new FakeClock(DateTime.parse("2023-11-09T02:08:57.880Z"));
|
||||
FakeClock fakeClock = new FakeClock(Instant.parse("2023-11-09T02:08:57.880Z"));
|
||||
|
||||
@RegisterExtension
|
||||
final JpaIntegrationWithCoverageExtension jpa =
|
||||
@@ -62,14 +62,14 @@ public class RefreshSchedulerTest {
|
||||
@Test
|
||||
void schedule_NoPreviousRefresh_withCompletedPrevDownload() {
|
||||
tm().transact(() -> tm().insert(new BsaDownload().setStage(DownloadStage.DONE)));
|
||||
DateTime downloadTime = fakeClock.nowUtc();
|
||||
Instant downloadTime = fakeClock.now();
|
||||
fakeClock.advanceOneMilli();
|
||||
|
||||
Optional<RefreshSchedule> scheduleOptional = scheduler.schedule();
|
||||
assertThat(scheduleOptional).isPresent();
|
||||
RefreshSchedule schedule = scheduleOptional.get();
|
||||
|
||||
assertThat(schedule.jobCreationTime()).isEqualTo(fakeClock.nowUtc());
|
||||
assertThat(schedule.jobCreationTime()).isEqualTo(fakeClock.now());
|
||||
assertThat(schedule.stage()).isEqualTo(RefreshStage.CHECK_FOR_CHANGES);
|
||||
assertThat(schedule.prevRefreshTime()).isEqualTo(downloadTime);
|
||||
}
|
||||
@@ -77,11 +77,11 @@ public class RefreshSchedulerTest {
|
||||
@Test
|
||||
void schedule_firstRefreshOngoing() {
|
||||
tm().transact(() -> tm().insert(new BsaDownload().setStage(DownloadStage.DONE)));
|
||||
DateTime downloadTime = fakeClock.nowUtc();
|
||||
Instant downloadTime = fakeClock.now();
|
||||
fakeClock.advanceOneMilli();
|
||||
|
||||
tm().transact(() -> tm().insert(new BsaDomainRefresh().setStage(APPLY_CHANGES)));
|
||||
DateTime refreshStartTime = fakeClock.nowUtc();
|
||||
Instant refreshStartTime = fakeClock.now();
|
||||
fakeClock.advanceOneMilli();
|
||||
|
||||
Optional<RefreshSchedule> scheduleOptional = scheduler.schedule();
|
||||
@@ -96,14 +96,14 @@ public class RefreshSchedulerTest {
|
||||
@Test
|
||||
void schedule_firstRefreshDone() {
|
||||
tm().transact(() -> tm().insert(new BsaDomainRefresh().setStage(DONE)));
|
||||
DateTime prevRefreshStartTime = fakeClock.nowUtc();
|
||||
Instant prevRefreshStartTime = fakeClock.now();
|
||||
fakeClock.advanceOneMilli();
|
||||
|
||||
Optional<RefreshSchedule> scheduleOptional = scheduler.schedule();
|
||||
assertThat(scheduleOptional).isPresent();
|
||||
RefreshSchedule schedule = scheduleOptional.get();
|
||||
|
||||
assertThat(schedule.jobCreationTime()).isEqualTo(fakeClock.nowUtc());
|
||||
assertThat(schedule.jobCreationTime()).isEqualTo(fakeClock.now());
|
||||
assertThat(schedule.stage()).isEqualTo(RefreshStage.CHECK_FOR_CHANGES);
|
||||
assertThat(schedule.prevRefreshTime()).isEqualTo(prevRefreshStartTime);
|
||||
}
|
||||
@@ -111,10 +111,10 @@ public class RefreshSchedulerTest {
|
||||
@Test
|
||||
void schedule_ongoingRefreshWithPrevCompletion() {
|
||||
tm().transact(() -> tm().insert(new BsaDomainRefresh().setStage(DONE)));
|
||||
DateTime prevRefreshStartTime = fakeClock.nowUtc();
|
||||
Instant prevRefreshStartTime = fakeClock.now();
|
||||
fakeClock.advanceOneMilli();
|
||||
tm().transact(() -> tm().insert(new BsaDomainRefresh().setStage(APPLY_CHANGES)));
|
||||
DateTime ongoingRefreshStartTime = fakeClock.nowUtc();
|
||||
Instant ongoingRefreshStartTime = fakeClock.now();
|
||||
fakeClock.advanceOneMilli();
|
||||
|
||||
Optional<RefreshSchedule> scheduleOptional = scheduler.schedule();
|
||||
|
||||
@@ -42,6 +42,8 @@ import google.registry.persistence.transaction.JpaTestExtensions;
|
||||
import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension;
|
||||
import google.registry.testing.DatabaseHelper;
|
||||
import google.registry.testing.FakeClock;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -88,9 +90,11 @@ public class SyncRegistrarsSheetTest {
|
||||
@Test
|
||||
void test_wereRegistrarsModified_atDifferentCursorTimes() {
|
||||
persistNewRegistrar("SomeRegistrar", "Some Registrar Inc.", Registrar.Type.REAL, 8L);
|
||||
persistResource(Cursor.createGlobal(SYNC_REGISTRAR_SHEET, clock.nowUtc().minusHours(1)));
|
||||
persistResource(
|
||||
Cursor.createGlobal(SYNC_REGISTRAR_SHEET, clock.now().minus(Duration.ofHours(1))));
|
||||
assertThat(newSyncRegistrarsSheet().wereRegistrarsModified()).isTrue();
|
||||
persistResource(Cursor.createGlobal(SYNC_REGISTRAR_SHEET, clock.nowUtc().plusHours(1)));
|
||||
persistResource(
|
||||
Cursor.createGlobal(SYNC_REGISTRAR_SHEET, clock.now().plus(Duration.ofHours(1))));
|
||||
assertThat(newSyncRegistrarsSheet().wereRegistrarsModified()).isFalse();
|
||||
}
|
||||
|
||||
@@ -178,7 +182,7 @@ public class SyncRegistrarsSheetTest {
|
||||
.setTypes(ImmutableSet.of(RegistrarPoc.Type.TECH))
|
||||
.build());
|
||||
// Use registrar key for contacts' parent.
|
||||
DateTime registrarCreationTime = persistResource(registrar).getCreationTime();
|
||||
Instant registrarCreationTime = persistResource(registrar).getCreationTime();
|
||||
persistResources(contacts);
|
||||
|
||||
clock.advanceBy(standardMinutes(1));
|
||||
@@ -315,7 +319,7 @@ public class SyncRegistrarsSheetTest {
|
||||
|
||||
Cursor cursor = loadByKey(Cursor.createGlobalVKey(SYNC_REGISTRAR_SHEET));
|
||||
assertThat(cursor).isNotNull();
|
||||
assertThat(cursor.getCursorTime()).isGreaterThan(registrarCreationTime);
|
||||
assertThat(cursor.getCursorTimeInstant()).isGreaterThan(registrarCreationTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -179,6 +179,7 @@ import google.registry.tmch.TmchTestData;
|
||||
import google.registry.xml.ValidationMode;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -325,10 +326,12 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
: clock.nowUtc().plus(Tld.get(domainTld).getAddGracePeriodLength());
|
||||
assertLastHistoryContainsResource(domain);
|
||||
DomainHistory historyEntry = getHistoryEntries(domain, DomainHistory.class).get(0);
|
||||
VKey<BillingRecurrence> autorenewVKey = domain.getAutorenewBillingEvent();
|
||||
BillingRecurrence autorenewBR = tm().transact(() -> tm().loadByKey(autorenewVKey));
|
||||
Instant eventTime = autorenewBR.getEventTimeInstant();
|
||||
assertAboutDomains()
|
||||
.that(domain)
|
||||
.hasRegistrationExpirationTime(
|
||||
tm().transact(() -> tm().loadByKey(domain.getAutorenewBillingEvent()).getEventTime()))
|
||||
.hasRegistrationExpirationTime(eventTime)
|
||||
.and()
|
||||
.hasOnlyOneHistoryEntryWhich()
|
||||
.hasType(HistoryEntry.Type.DOMAIN_CREATE)
|
||||
|
||||
@@ -73,6 +73,7 @@ import google.registry.persistence.VKey;
|
||||
import google.registry.persistence.transaction.JpaTransactionManagerExtension;
|
||||
import google.registry.testing.DatabaseHelper;
|
||||
import google.registry.xml.ValidationMode;
|
||||
import java.time.Instant;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.annotation.Nullable;
|
||||
import org.joda.money.Money;
|
||||
@@ -336,8 +337,8 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
|
||||
.setCreationRegistrarId("NewRegistrar")
|
||||
.setCreationTimeForTest(DateTime.parse("2003-11-26T22:00:00.0Z"))
|
||||
.setRegistrationExpirationTime(DateTime.parse("2005-11-26T22:00:00.0Z"))
|
||||
.setLastTransferTime(null)
|
||||
.setLastEppUpdateTime(null)
|
||||
.setLastTransferTime((Instant) null)
|
||||
.setLastEppUpdateTime((Instant) null)
|
||||
.setLastEppUpdateRegistrarId(null)
|
||||
.build());
|
||||
doSuccessfulTest("domain_info_response_addperiod.xml", false);
|
||||
|
||||
@@ -241,7 +241,7 @@ class DomainTransferApproveFlowTest
|
||||
.collect(onlyElement());
|
||||
assertThat(transferResponse.getTransferStatus()).isEqualTo(TransferStatus.CLIENT_APPROVED);
|
||||
assertThat(transferResponse.getExtendedRegistrationExpirationTime())
|
||||
.isEqualTo(domain.getRegistrationExpirationDateTime());
|
||||
.isEqualTo(domain.getRegistrationExpirationTime());
|
||||
PendingActionNotificationResponse panData =
|
||||
gainingTransferPollMessage
|
||||
.getResponseData()
|
||||
|
||||
@@ -81,6 +81,7 @@ import google.registry.model.transfer.DomainTransferData;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.testing.CloudTasksHelper.TaskMatcher;
|
||||
import google.registry.testing.DatabaseHelper;
|
||||
import java.time.Instant;
|
||||
import javax.annotation.Nullable;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -523,7 +524,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
|
||||
newHost(oldHostName())
|
||||
.asBuilder()
|
||||
.setSuperordinateDomain(foo.createVKey())
|
||||
.setLastTransferTime(null)
|
||||
.setLastTransferTime((Instant) null)
|
||||
.setInetAddresses(
|
||||
ImmutableSet.of(InetAddresses.forString("1080:0:0:0:8:800:200C:417A")))
|
||||
.build());
|
||||
@@ -595,7 +596,10 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
|
||||
.build());
|
||||
// Set the new domain to have a null last transfer time.
|
||||
persistResource(
|
||||
DatabaseHelper.newDomain("example.tld").asBuilder().setLastTransferTime(null).build());
|
||||
DatabaseHelper.newDomain("example.tld")
|
||||
.asBuilder()
|
||||
.setLastTransferTime((Instant) null)
|
||||
.build());
|
||||
DateTime lastTransferTime = clock.nowUtc().minusDays(20);
|
||||
|
||||
persistResource(
|
||||
@@ -628,10 +632,16 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
|
||||
createTld("tld");
|
||||
Domain foo =
|
||||
persistResource(
|
||||
DatabaseHelper.newDomain("foo.tld").asBuilder().setLastTransferTime(null).build());
|
||||
DatabaseHelper.newDomain("foo.tld")
|
||||
.asBuilder()
|
||||
.setLastTransferTime((Instant) null)
|
||||
.build());
|
||||
// Set the new domain to have a null last transfer time.
|
||||
persistResource(
|
||||
DatabaseHelper.newDomain("example.tld").asBuilder().setLastTransferTime(null).build());
|
||||
DatabaseHelper.newDomain("example.tld")
|
||||
.asBuilder()
|
||||
.setLastTransferTime((Instant) null)
|
||||
.build());
|
||||
DateTime lastTransferTime = clock.nowUtc().minusDays(20);
|
||||
|
||||
persistResource(
|
||||
@@ -669,12 +679,15 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
|
||||
.build());
|
||||
// Set the new domain to have a null last transfer time.
|
||||
persistResource(
|
||||
DatabaseHelper.newDomain("example.tld").asBuilder().setLastTransferTime(null).build());
|
||||
DatabaseHelper.newDomain("example.tld")
|
||||
.asBuilder()
|
||||
.setLastTransferTime((Instant) null)
|
||||
.build());
|
||||
persistResource(
|
||||
newHost(oldHostName())
|
||||
.asBuilder()
|
||||
.setSuperordinateDomain(foo.createVKey())
|
||||
.setLastTransferTime(null)
|
||||
.setLastTransferTime((Instant) null)
|
||||
.setLastSuperordinateChange(clock.nowUtc().minusDays(3))
|
||||
.setInetAddresses(
|
||||
ImmutableSet.of(InetAddresses.forString("1080:0:0:0:8:800:200C:417A")))
|
||||
|
||||
@@ -17,23 +17,27 @@ 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 org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import google.registry.model.common.CrossTldSingleton;
|
||||
import google.registry.persistence.transaction.JpaTestExtensions;
|
||||
import google.registry.persistence.transaction.JpaTestExtensions.JpaUnitTestExtension;
|
||||
import google.registry.testing.FakeClock;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import org.joda.time.DateTime;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link CreateAutoTimestamp}. */
|
||||
public class CreateAutoTimestampTest {
|
||||
|
||||
private final FakeClock clock = new FakeClock(Instant.parse("2024-01-01T00:00:00Z"));
|
||||
|
||||
@RegisterExtension
|
||||
public final JpaUnitTestExtension jpaUnitTestExtension =
|
||||
new JpaTestExtensions.Builder()
|
||||
.withClock(clock)
|
||||
.withEntityClass(CreateAutoTimestampTestObject.class)
|
||||
.buildUnitTestExtension();
|
||||
|
||||
@@ -41,7 +45,7 @@ public class CreateAutoTimestampTest {
|
||||
@Entity
|
||||
public static class CreateAutoTimestampTestObject extends CrossTldSingleton {
|
||||
@Id long id = SINGLETON_ID;
|
||||
CreateAutoTimestamp createTime = CreateAutoTimestamp.create(null);
|
||||
CreateAutoTimestamp createTime = CreateAutoTimestamp.create((Instant) null);
|
||||
}
|
||||
|
||||
private static CreateAutoTimestampTestObject reload() {
|
||||
@@ -50,20 +54,20 @@ public class CreateAutoTimestampTest {
|
||||
|
||||
@Test
|
||||
void testSaveSetsTime() {
|
||||
DateTime transactionTime =
|
||||
Instant transactionTime =
|
||||
tm().transact(
|
||||
() -> {
|
||||
CreateAutoTimestampTestObject object = new CreateAutoTimestampTestObject();
|
||||
assertThat(object.createTime.getTimestamp()).isNull();
|
||||
tm().put(object);
|
||||
return tm().getTransactionTime();
|
||||
return tm().getTxTime();
|
||||
});
|
||||
assertThat(reload().createTime.getTimestamp()).isEqualTo(transactionTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testResavingRespectsOriginalTime() {
|
||||
final DateTime oldCreateTime = DateTime.now(UTC).minusDays(1);
|
||||
final Instant oldCreateTime = clock.now().minus(Duration.ofDays(1));
|
||||
tm().transact(
|
||||
() -> {
|
||||
CreateAutoTimestampTestObject object = new CreateAutoTimestampTestObject();
|
||||
|
||||
@@ -16,8 +16,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_OF_TIME;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
|
||||
import google.registry.model.common.CrossTldSingleton;
|
||||
import google.registry.persistence.VKey;
|
||||
@@ -26,7 +25,8 @@ import google.registry.persistence.transaction.JpaTestExtensions.JpaUnitTestExte
|
||||
import google.registry.testing.FakeClock;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import org.joda.time.DateTime;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
@@ -46,7 +46,7 @@ public class UpdateAutoTimestampTest {
|
||||
@Entity
|
||||
public static class UpdateAutoTimestampTestObject extends CrossTldSingleton {
|
||||
@Id long id = SINGLETON_ID;
|
||||
UpdateAutoTimestamp updateTime = UpdateAutoTimestamp.create(null);
|
||||
UpdateAutoTimestamp updateTime = UpdateAutoTimestamp.create((Instant) null);
|
||||
}
|
||||
|
||||
private static UpdateAutoTimestampTestObject reload() {
|
||||
@@ -56,35 +56,36 @@ public class UpdateAutoTimestampTest {
|
||||
|
||||
@Test
|
||||
void testSaveSetsTime() {
|
||||
DateTime transactionTime =
|
||||
Instant transactionTime =
|
||||
tm().transact(
|
||||
() -> {
|
||||
clock.advanceOneMilli();
|
||||
UpdateAutoTimestampTestObject object = new UpdateAutoTimestampTestObject();
|
||||
assertThat(object.updateTime.getTimestamp()).isEqualTo(START_OF_TIME);
|
||||
assertThat(object.updateTime.getTimestamp()).isEqualTo(START_INSTANT);
|
||||
tm().insert(object);
|
||||
return tm().getTransactionTime();
|
||||
return tm().getTxTime();
|
||||
});
|
||||
assertThat(reload().updateTime.getTimestamp()).isEqualTo(transactionTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testResavingOverwritesOriginalTime() {
|
||||
DateTime transactionTime =
|
||||
Instant transactionTime =
|
||||
tm().transact(
|
||||
() -> {
|
||||
clock.advanceOneMilli();
|
||||
UpdateAutoTimestampTestObject object = new UpdateAutoTimestampTestObject();
|
||||
object.updateTime = UpdateAutoTimestamp.create(DateTime.now(UTC).minusDays(1));
|
||||
object.updateTime =
|
||||
UpdateAutoTimestamp.create(clock.now().minus(Duration.ofDays(1)));
|
||||
tm().insert(object);
|
||||
return tm().getTransactionTime();
|
||||
return tm().getTxTime();
|
||||
});
|
||||
assertThat(reload().updateTime.getTimestamp()).isEqualTo(transactionTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testReadingTwiceDoesNotModify() {
|
||||
DateTime originalTime = DateTime.parse("1999-01-01T00:00:00Z");
|
||||
Instant originalTime = Instant.parse("1999-01-01T00:00:00Z");
|
||||
clock.setTo(originalTime);
|
||||
tm().transact(() -> tm().insert(new UpdateAutoTimestampTestObject()));
|
||||
clock.advanceOneMilli();
|
||||
|
||||
@@ -26,6 +26,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import google.registry.model.EntityTestCase;
|
||||
import google.registry.model.tld.Tld;
|
||||
import google.registry.util.SerializeUtils;
|
||||
import java.time.Instant;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -116,7 +117,7 @@ public class CursorTest extends EntityTestCase {
|
||||
NullPointerException thrown =
|
||||
assertThrows(
|
||||
NullPointerException.class,
|
||||
() -> Cursor.createScoped(RDE_UPLOAD, null, Tld.get("tld")));
|
||||
() -> Cursor.createScoped(RDE_UPLOAD, (Instant) null, Tld.get("tld")));
|
||||
assertThat(thrown).hasMessageThat().contains("Cursor time cannot be null");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class PasswordResetRequestTest extends EntityTestCase {
|
||||
PasswordResetRequest fromDatabase =
|
||||
DatabaseHelper.loadByKey(VKey.create(PasswordResetRequest.class, verificationCode));
|
||||
assertAboutImmutableObjects().that(fromDatabase).isEqualExceptFields(request, "requestTime");
|
||||
assertThat(fromDatabase.getRequestTime()).isEqualTo(fakeClock.nowUtc());
|
||||
assertThat(fromDatabase.getRequestTime()).isEqualTo(fakeClock.now());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -26,9 +26,9 @@ import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static google.registry.testing.SqlHelper.assertThrowForeignKeyViolation;
|
||||
import static google.registry.testing.SqlHelper.saveRegistrar;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
import static google.registry.util.DateTimeUtils.END_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.plusYears;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -49,10 +49,10 @@ import google.registry.persistence.transaction.JpaTestExtensions;
|
||||
import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationWithCoverageExtension;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.util.SerializeUtils;
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
@@ -60,7 +60,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
/** Verify that we can store/retrieve Domain objects from a SQL database. */
|
||||
public class DomainSqlTest {
|
||||
|
||||
protected FakeClock fakeClock = new FakeClock(DateTime.now(UTC));
|
||||
protected FakeClock fakeClock = new FakeClock(Instant.parse("2024-01-01T00:00:00Z"));
|
||||
|
||||
@RegisterExtension
|
||||
final JpaIntegrationWithCoverageExtension jpa =
|
||||
@@ -83,9 +83,9 @@ public class DomainSqlTest {
|
||||
.setDomainName("example.com")
|
||||
.setRepoId("4-COM")
|
||||
.setCreationRegistrarId("registrar1")
|
||||
.setLastEppUpdateTime(fakeClock.nowUtc())
|
||||
.setLastEppUpdateTime(fakeClock.now())
|
||||
.setLastEppUpdateRegistrarId("registrar2")
|
||||
.setLastTransferTime(fakeClock.nowUtc())
|
||||
.setLastTransferTime(fakeClock.now())
|
||||
.setNameservers(host1VKey)
|
||||
.setStatusValues(
|
||||
ImmutableSet.of(
|
||||
@@ -97,15 +97,15 @@ public class DomainSqlTest {
|
||||
StatusValue.SERVER_HOLD))
|
||||
.setSubordinateHosts(ImmutableSet.of("ns1.example.com"))
|
||||
.setPersistedCurrentSponsorRegistrarId("registrar3")
|
||||
.setRegistrationExpirationTime(fakeClock.nowUtc().plusYears(1))
|
||||
.setRegistrationExpirationTime(plusYears(fakeClock.now(), 1))
|
||||
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("password")))
|
||||
.setDsData(ImmutableSet.of(DomainDsData.create(1, 2, 3, new byte[] {0, 1, 2})))
|
||||
.setLaunchNotice(
|
||||
LaunchNotice.create("tcnid", "validatorId", START_OF_TIME, START_OF_TIME))
|
||||
LaunchNotice.create("tcnid", "validatorId", START_INSTANT, START_INSTANT))
|
||||
.setSmdId("smdid")
|
||||
.addGracePeriod(
|
||||
GracePeriod.create(
|
||||
GracePeriodStatus.ADD, "4-COM", END_OF_TIME, "registrar1", null, 100L))
|
||||
GracePeriodStatus.ADD, "4-COM", END_INSTANT, "registrar1", null, 100L))
|
||||
.build();
|
||||
|
||||
host =
|
||||
@@ -121,17 +121,17 @@ public class DomainSqlTest {
|
||||
.setToken("abc123Unlimited")
|
||||
.setTokenType(BULK_PRICING)
|
||||
.setDiscountFraction(1.0)
|
||||
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
|
||||
.setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z"))
|
||||
.setAllowedTlds(ImmutableSet.of("dev", "app"))
|
||||
.setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar"))
|
||||
.setRenewalPriceBehavior(RenewalPriceBehavior.SPECIFIED)
|
||||
.setRenewalPrice(Money.of(CurrencyUnit.USD, 0))
|
||||
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE))
|
||||
.setTokenStatusTransitions(
|
||||
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
|
||||
.put(START_OF_TIME, NOT_STARTED)
|
||||
.put(DateTime.now(UTC), TokenStatus.VALID)
|
||||
.put(DateTime.now(UTC).plusWeeks(8), TokenStatus.ENDED)
|
||||
.setTokenStatusTransitionsInstant(
|
||||
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)
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
@@ -221,7 +221,7 @@ public class DomainSqlTest {
|
||||
GracePeriod.create(
|
||||
GracePeriodStatus.RENEW,
|
||||
"4-COM",
|
||||
END_OF_TIME,
|
||||
END_INSTANT,
|
||||
"registrar1",
|
||||
null,
|
||||
200L))
|
||||
@@ -235,9 +235,9 @@ public class DomainSqlTest {
|
||||
assertThat(persisted.getGracePeriods())
|
||||
.containsExactly(
|
||||
GracePeriod.create(
|
||||
GracePeriodStatus.ADD, "4-COM", END_OF_TIME, "registrar1", null, 100L),
|
||||
GracePeriodStatus.ADD, "4-COM", END_INSTANT, "registrar1", null, 100L),
|
||||
GracePeriod.create(
|
||||
GracePeriodStatus.RENEW, "4-COM", END_OF_TIME, "registrar1", null, 200L));
|
||||
GracePeriodStatus.RENEW, "4-COM", END_INSTANT, "registrar1", null, 200L));
|
||||
assertEqualDomainExcept(persisted, "gracePeriods");
|
||||
});
|
||||
|
||||
@@ -281,7 +281,7 @@ public class DomainSqlTest {
|
||||
GracePeriod.create(
|
||||
GracePeriodStatus.ADD,
|
||||
"4-COM",
|
||||
END_OF_TIME,
|
||||
END_INSTANT,
|
||||
"registrar1",
|
||||
null,
|
||||
100L))
|
||||
@@ -295,7 +295,7 @@ public class DomainSqlTest {
|
||||
assertThat(persisted.getGracePeriods())
|
||||
.containsExactly(
|
||||
GracePeriod.create(
|
||||
GracePeriodStatus.ADD, "4-COM", END_OF_TIME, "registrar1", null, 100L));
|
||||
GracePeriodStatus.ADD, "4-COM", END_INSTANT, "registrar1", null, 100L));
|
||||
assertEqualDomainExcept(persisted, "gracePeriods");
|
||||
});
|
||||
}
|
||||
@@ -387,7 +387,7 @@ public class DomainSqlTest {
|
||||
void testUpdateTimeAfterNameserverUpdate() {
|
||||
persistDomain();
|
||||
Domain persisted = loadByKey(domain.createVKey());
|
||||
DateTime originalUpdateTime = persisted.getUpdateTimestamp().getTimestamp();
|
||||
Instant originalUpdateTime = persisted.getUpdateTimestamp().getTimestamp();
|
||||
fakeClock.advanceOneMilli();
|
||||
Host host2 =
|
||||
new Host.Builder()
|
||||
@@ -408,7 +408,7 @@ public class DomainSqlTest {
|
||||
void testUpdateTimeAfterDsDataUpdate() {
|
||||
persistDomain();
|
||||
Domain persisted = loadByKey(domain.createVKey());
|
||||
DateTime originalUpdateTime = persisted.getUpdateTimestamp().getTimestamp();
|
||||
Instant originalUpdateTime = persisted.getUpdateTimestamp().getTimestamp();
|
||||
fakeClock.advanceOneMilli();
|
||||
domain =
|
||||
persisted
|
||||
|
||||
@@ -547,7 +547,7 @@ public class DomainTest {
|
||||
.setRegistrationExpirationTime(oldExpirationTime)
|
||||
.setTransferData(DomainTransferData.EMPTY)
|
||||
.setGracePeriods(ImmutableSet.of())
|
||||
.setLastEppUpdateTime(null)
|
||||
.setLastEppUpdateTime((Instant) null)
|
||||
.setLastEppUpdateRegistrarId(null)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
package google.registry.model.domain;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import google.registry.model.billing.BillingBase.Reason;
|
||||
@@ -26,9 +25,11 @@ import google.registry.model.reporting.HistoryEntry.HistoryEntryId;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.persistence.transaction.JpaTestExtensions;
|
||||
import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension;
|
||||
import google.registry.testing.FakeClock;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
@@ -36,11 +37,13 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
/** Unit tests for {@link GracePeriod}. */
|
||||
public class GracePeriodTest {
|
||||
|
||||
private final FakeClock fakeClock = new FakeClock(Instant.parse("2024-01-01T00:00:00Z"));
|
||||
|
||||
@RegisterExtension
|
||||
final JpaIntegrationTestExtension jpa =
|
||||
new JpaTestExtensions.Builder().buildIntegrationTestExtension();
|
||||
new JpaTestExtensions.Builder().withClock(fakeClock).buildIntegrationTestExtension();
|
||||
|
||||
private final DateTime now = DateTime.now(UTC);
|
||||
private final Instant now = fakeClock.now();
|
||||
private BillingEvent onetime;
|
||||
private VKey<BillingRecurrence> recurrenceKey;
|
||||
|
||||
@@ -49,7 +52,7 @@ public class GracePeriodTest {
|
||||
onetime =
|
||||
new BillingEvent.Builder()
|
||||
.setEventTime(now)
|
||||
.setBillingTime(now.plusDays(1))
|
||||
.setBillingTime(now.plus(1, ChronoUnit.DAYS))
|
||||
.setRegistrarId("TheRegistrar")
|
||||
.setCost(Money.of(CurrencyUnit.USD, 42))
|
||||
.setDomainHistoryId(new HistoryEntryId("domain", 12345))
|
||||
@@ -68,7 +71,7 @@ public class GracePeriodTest {
|
||||
assertThat(gracePeriod.getBillingEvent()).isEqualTo(onetime.createVKey());
|
||||
assertThat(gracePeriod.getBillingRecurrence()).isNull();
|
||||
assertThat(gracePeriod.getRegistrarId()).isEqualTo("TheRegistrar");
|
||||
assertThat(gracePeriod.getExpirationDateTime()).isEqualTo(now.plusDays(1));
|
||||
assertThat(gracePeriod.getExpirationTime()).isEqualTo(now.plus(1, ChronoUnit.DAYS));
|
||||
assertThat(gracePeriod.hasBillingEvent()).isTrue();
|
||||
}
|
||||
|
||||
@@ -76,13 +79,17 @@ public class GracePeriodTest {
|
||||
void testSuccess_forRecurrence() {
|
||||
GracePeriod gracePeriod =
|
||||
GracePeriod.createForRecurrence(
|
||||
GracePeriodStatus.AUTO_RENEW, "1-TEST", now.plusDays(1), "TheRegistrar", recurrenceKey);
|
||||
GracePeriodStatus.AUTO_RENEW,
|
||||
"1-TEST",
|
||||
now.plus(1, ChronoUnit.DAYS),
|
||||
"TheRegistrar",
|
||||
recurrenceKey);
|
||||
assertThat(gracePeriod.getType()).isEqualTo(GracePeriodStatus.AUTO_RENEW);
|
||||
assertThat(gracePeriod.getDomainRepoId()).isEqualTo("1-TEST");
|
||||
assertThat(gracePeriod.getBillingEvent()).isNull();
|
||||
assertThat(gracePeriod.getBillingRecurrence()).isEqualTo(recurrenceKey);
|
||||
assertThat(gracePeriod.getRegistrarId()).isEqualTo("TheRegistrar");
|
||||
assertThat(gracePeriod.getExpirationDateTime()).isEqualTo(now.plusDays(1));
|
||||
assertThat(gracePeriod.getExpirationTime()).isEqualTo(now.plus(1, ChronoUnit.DAYS));
|
||||
assertThat(gracePeriod.hasBillingEvent()).isTrue();
|
||||
}
|
||||
|
||||
@@ -96,7 +103,7 @@ public class GracePeriodTest {
|
||||
assertThat(gracePeriod.getBillingEvent()).isNull();
|
||||
assertThat(gracePeriod.getBillingRecurrence()).isNull();
|
||||
assertThat(gracePeriod.getRegistrarId()).isEqualTo("TheRegistrar");
|
||||
assertThat(gracePeriod.getExpirationDateTime()).isEqualTo(now);
|
||||
assertThat(gracePeriod.getExpirationTime()).isEqualTo(now);
|
||||
assertThat(gracePeriod.hasBillingEvent()).isFalse();
|
||||
}
|
||||
|
||||
@@ -118,7 +125,7 @@ public class GracePeriodTest {
|
||||
GracePeriod.createForRecurrence(
|
||||
GracePeriodStatus.RENEW,
|
||||
"1-TEST",
|
||||
now.plusDays(1),
|
||||
now.plus(1, ChronoUnit.DAYS),
|
||||
"TheRegistrar",
|
||||
recurrenceKey));
|
||||
assertThat(thrown).hasMessageThat().contains("autorenew");
|
||||
|
||||
@@ -27,8 +27,7 @@ import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.loadByEntity;
|
||||
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -43,9 +42,9 @@ import google.registry.model.domain.token.AllocationToken.TokenStatus;
|
||||
import google.registry.model.domain.token.AllocationToken.TokenType;
|
||||
import google.registry.model.reporting.HistoryEntry.HistoryEntryId;
|
||||
import google.registry.util.SerializeUtils;
|
||||
import java.time.Instant;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -68,17 +67,17 @@ public class AllocationTokenTest extends EntityTestCase {
|
||||
new AllocationToken.Builder()
|
||||
.setToken("abc123Unlimited")
|
||||
.setTokenType(UNLIMITED_USE)
|
||||
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
|
||||
.setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z"))
|
||||
.setAllowedTlds(ImmutableSet.of("dev", "app"))
|
||||
.setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar, NewRegistrar"))
|
||||
.setDiscountFraction(0.5)
|
||||
.setDiscountPremiums(true)
|
||||
.setDiscountYears(3)
|
||||
.setTokenStatusTransitions(
|
||||
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
|
||||
.put(START_OF_TIME, NOT_STARTED)
|
||||
.put(DateTime.now(UTC), TokenStatus.VALID)
|
||||
.put(DateTime.now(UTC).plusWeeks(8), TokenStatus.ENDED)
|
||||
.setTokenStatusTransitionsInstant(
|
||||
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)
|
||||
.build())
|
||||
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE, CommandName.RENEW))
|
||||
.build());
|
||||
@@ -92,7 +91,7 @@ public class AllocationTokenTest extends EntityTestCase {
|
||||
.setToken("abc123Single")
|
||||
.setRedemptionHistoryId(historyEntryId)
|
||||
.setDomainName("example.foo")
|
||||
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
|
||||
.setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z"))
|
||||
.setTokenType(SINGLE_USE)
|
||||
.build());
|
||||
assertThat(loadByEntity(singleUseToken)).isEqualTo(singleUseToken);
|
||||
@@ -105,17 +104,17 @@ public class AllocationTokenTest extends EntityTestCase {
|
||||
new AllocationToken.Builder()
|
||||
.setToken("abc123Unlimited")
|
||||
.setTokenType(UNLIMITED_USE)
|
||||
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
|
||||
.setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z"))
|
||||
.setAllowedTlds(ImmutableSet.of("dev", "app"))
|
||||
.setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar, NewRegistrar"))
|
||||
.setDiscountFraction(0.5)
|
||||
.setDiscountPremiums(true)
|
||||
.setDiscountYears(3)
|
||||
.setTokenStatusTransitions(
|
||||
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
|
||||
.put(START_OF_TIME, NOT_STARTED)
|
||||
.put(DateTime.now(UTC), TokenStatus.VALID)
|
||||
.put(DateTime.now(UTC).plusWeeks(8), TokenStatus.ENDED)
|
||||
.setTokenStatusTransitionsInstant(
|
||||
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)
|
||||
.build())
|
||||
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE, CommandName.RENEW))
|
||||
.build());
|
||||
@@ -130,7 +129,7 @@ public class AllocationTokenTest extends EntityTestCase {
|
||||
.setToken("abc123Single")
|
||||
.setRedemptionHistoryId(historyEntryId)
|
||||
.setDomainName("example.foo")
|
||||
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
|
||||
.setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z"))
|
||||
.setTokenType(SINGLE_USE)
|
||||
.build());
|
||||
persisted = loadByEntity(singleUseToken);
|
||||
@@ -143,7 +142,7 @@ public class AllocationTokenTest extends EntityTestCase {
|
||||
new AllocationToken.Builder().setToken("abc123").setTokenType(SINGLE_USE).build();
|
||||
assertThat(tokenBeforePersisting.getCreationTime()).isEmpty();
|
||||
AllocationToken tokenAfterPersisting = persistResource(tokenBeforePersisting);
|
||||
assertThat(tokenAfterPersisting.getCreationTime()).hasValue(fakeClock.nowUtc());
|
||||
assertThat(tokenAfterPersisting.getCreationTime()).hasValue(fakeClock.now());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -199,11 +198,11 @@ public class AllocationTokenTest extends EntityTestCase {
|
||||
new AllocationToken.Builder()
|
||||
.setToken("foobar")
|
||||
.setTokenType(SINGLE_USE)
|
||||
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"));
|
||||
.setCreationTimeForTest(Instant.parse("2010-11-12T05:00:00Z"));
|
||||
IllegalStateException thrown =
|
||||
assertThrows(
|
||||
IllegalStateException.class,
|
||||
() -> builder.setCreationTimeForTest(DateTime.parse("2010-11-13T05:00:00Z")));
|
||||
() -> builder.setCreationTimeForTest(Instant.parse("2010-11-13T05:00:00Z")));
|
||||
assertThat(thrown).hasMessageThat().isEqualTo("Creation time can only be set once");
|
||||
}
|
||||
|
||||
@@ -420,11 +419,15 @@ public class AllocationTokenTest extends EntityTestCase {
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
new AllocationToken.Builder()
|
||||
.setTokenStatusTransitions(
|
||||
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
|
||||
.put(DateTime.now(UTC), NOT_STARTED)
|
||||
.put(DateTime.now(UTC).plusDays(1), TokenStatus.VALID)
|
||||
.put(DateTime.now(UTC).plusDays(2), TokenStatus.ENDED)
|
||||
.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)
|
||||
.build()));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
@@ -438,10 +441,10 @@ public class AllocationTokenTest extends EntityTestCase {
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
new AllocationToken.Builder()
|
||||
.setTokenStatusTransitions(
|
||||
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
|
||||
.put(START_OF_TIME, TokenStatus.VALID)
|
||||
.put(DateTime.now(UTC), TokenStatus.ENDED)
|
||||
.setTokenStatusTransitionsInstant(
|
||||
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
|
||||
.put(START_INSTANT, TokenStatus.VALID)
|
||||
.put(fakeClock.now(), TokenStatus.ENDED)
|
||||
.build()));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
@@ -459,18 +462,18 @@ public class AllocationTokenTest extends EntityTestCase {
|
||||
void testSetTransitions_badTransitionsFromValid() {
|
||||
// VALID can only go to ENDED or CANCELLED
|
||||
assertBadTransition(
|
||||
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
|
||||
.put(START_OF_TIME, NOT_STARTED)
|
||||
.put(DateTime.now(UTC), VALID)
|
||||
.put(DateTime.now(UTC).plusDays(1), VALID)
|
||||
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
|
||||
.put(START_INSTANT, NOT_STARTED)
|
||||
.put(fakeClock.now(), VALID)
|
||||
.put(fakeClock.now().plus(java.time.Duration.ofDays(1)), VALID)
|
||||
.build(),
|
||||
VALID,
|
||||
VALID);
|
||||
assertBadTransition(
|
||||
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
|
||||
.put(START_OF_TIME, NOT_STARTED)
|
||||
.put(DateTime.now(UTC), VALID)
|
||||
.put(DateTime.now(UTC).plusDays(1), NOT_STARTED)
|
||||
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
|
||||
.put(START_INSTANT, NOT_STARTED)
|
||||
.put(fakeClock.now(), VALID)
|
||||
.put(fakeClock.now().plus(java.time.Duration.ofDays(1)), NOT_STARTED)
|
||||
.build(),
|
||||
VALID,
|
||||
NOT_STARTED);
|
||||
@@ -707,20 +710,20 @@ public class AllocationTokenTest extends EntityTestCase {
|
||||
|
||||
private void assertBadInitialTransition(TokenStatus status) {
|
||||
assertBadTransition(
|
||||
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
|
||||
.put(START_OF_TIME, NOT_STARTED)
|
||||
.put(DateTime.now(UTC), status)
|
||||
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
|
||||
.put(START_INSTANT, NOT_STARTED)
|
||||
.put(fakeClock.now(), status)
|
||||
.build(),
|
||||
NOT_STARTED,
|
||||
status);
|
||||
}
|
||||
|
||||
private void assertBadTransition(
|
||||
ImmutableSortedMap<DateTime, TokenStatus> map, TokenStatus from, TokenStatus to) {
|
||||
ImmutableSortedMap<Instant, TokenStatus> map, TokenStatus from, TokenStatus to) {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> new AllocationToken.Builder().setTokenStatusTransitions(map));
|
||||
() -> new AllocationToken.Builder().setTokenStatusTransitionsInstant(map));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.isEqualTo(
|
||||
@@ -734,12 +737,12 @@ public class AllocationTokenTest extends EntityTestCase {
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
new AllocationToken.Builder()
|
||||
.setTokenStatusTransitions(
|
||||
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
|
||||
.put(START_OF_TIME, NOT_STARTED)
|
||||
.put(DateTime.now(UTC), VALID)
|
||||
.put(DateTime.now(UTC).plusDays(1), status)
|
||||
.put(DateTime.now(UTC).plusDays(2), CANCELLED)
|
||||
.setTokenStatusTransitionsInstant(
|
||||
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)
|
||||
.build()));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
|
||||
@@ -22,6 +22,7 @@ import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.persistNewRegistrars;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.HostSubject.assertAboutHosts;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -36,6 +37,7 @@ import google.registry.model.transfer.DomainTransferData;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.testing.DatabaseHelper;
|
||||
import google.registry.util.SerializeUtils;
|
||||
import java.time.Instant;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -190,8 +192,12 @@ class HostTest extends EntityTestCase {
|
||||
|
||||
@Test
|
||||
void testComputeLastTransferTime_hostNeverSwitchedDomains_domainWasNeverTransferred() {
|
||||
domain = domain.asBuilder().setLastTransferTime(null).build();
|
||||
host = host.asBuilder().setLastTransferTime(null).setLastSuperordinateChange(null).build();
|
||||
domain = domain.asBuilder().setLastTransferTime((Instant) null).build();
|
||||
host =
|
||||
host.asBuilder()
|
||||
.setLastTransferTime((Instant) null)
|
||||
.setLastSuperordinateChange((Instant) null)
|
||||
.build();
|
||||
assertThat(host.computeLastTransferTime(domain)).isNull();
|
||||
}
|
||||
|
||||
@@ -204,10 +210,10 @@ class HostTest extends EntityTestCase {
|
||||
host =
|
||||
host.asBuilder()
|
||||
.setCreationTimeForTest(day1)
|
||||
.setLastTransferTime(null)
|
||||
.setLastSuperordinateChange(null)
|
||||
.setLastTransferTime((Instant) null)
|
||||
.setLastSuperordinateChange((Instant) null)
|
||||
.build();
|
||||
assertThat(host.computeLastTransferTime(domain)).isEqualTo(day2);
|
||||
assertThat(host.computeLastTransferTime(domain)).isEqualTo(toInstant(day2));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -237,9 +243,9 @@ class HostTest extends EntityTestCase {
|
||||
// Host was transferred on Day 1.
|
||||
// Host was made subordinate to domain on Day 2.
|
||||
// Domain was never transferred.
|
||||
domain = domain.asBuilder().setLastTransferTime(null).build();
|
||||
domain = domain.asBuilder().setLastTransferTime((Instant) null).build();
|
||||
host = host.asBuilder().setLastTransferTime(day1).setLastSuperordinateChange(day2).build();
|
||||
assertThat(host.computeLastTransferTime(domain)).isEqualTo(day1);
|
||||
assertThat(host.computeLastTransferTime(domain)).isEqualTo(toInstant(day1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -249,7 +255,7 @@ class HostTest extends EntityTestCase {
|
||||
// Host was made subordinate to domain on Day 3.
|
||||
domain = domain.asBuilder().setLastTransferTime(day2).build();
|
||||
host = host.asBuilder().setLastTransferTime(day1).setLastSuperordinateChange(day3).build();
|
||||
assertThat(host.computeLastTransferTime(domain)).isEqualTo(day1);
|
||||
assertThat(host.computeLastTransferTime(domain)).isEqualTo(toInstant(day1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -259,6 +265,6 @@ class HostTest extends EntityTestCase {
|
||||
// Domain was transferred on Day 3.
|
||||
domain = domain.asBuilder().setLastTransferTime(day3).build();
|
||||
host = host.asBuilder().setLastTransferTime(day1).setLastSuperordinateChange(day2).build();
|
||||
assertThat(host.computeLastTransferTime(domain)).isEqualTo(day3);
|
||||
assertThat(host.computeLastTransferTime(domain)).isEqualTo(toInstant(day3));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.loadByKey;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.util.DateTimeUtils.plusYears;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -79,7 +80,7 @@ public class PollMessageTest extends EntityTestCase {
|
||||
.setEventTime(fakeClock.nowUtc())
|
||||
.setMsg("Test poll message")
|
||||
.setHistoryEntry(historyEntry)
|
||||
.setAutorenewEndTime(fakeClock.nowUtc().plusDays(365))
|
||||
.setAutorenewEndTime(plusYears(fakeClock.nowUtc(), 1))
|
||||
.setTargetId("foobar.foo")
|
||||
.build();
|
||||
}
|
||||
@@ -158,7 +159,7 @@ public class PollMessageTest extends EntityTestCase {
|
||||
.setEventTime(fakeClock.nowUtc())
|
||||
.setMsg("Test poll message")
|
||||
.setHistoryEntry(historyEntry)
|
||||
.setAutorenewEndTime(fakeClock.nowUtc().plusDays(365))
|
||||
.setAutorenewEndTime(plusYears(fakeClock.nowUtc(), 1))
|
||||
.setTargetId("foobar.foo")
|
||||
.build());
|
||||
assertThat(tm().transact(() -> tm().loadByEntity(pollMessage))).isEqualTo(pollMessage);
|
||||
@@ -173,7 +174,7 @@ public class PollMessageTest extends EntityTestCase {
|
||||
.setEventTime(fakeClock.nowUtc())
|
||||
.setMsg("Test poll message")
|
||||
.setHistoryEntry(historyEntry)
|
||||
.setAutorenewEndTime(fakeClock.nowUtc().plusDays(365))
|
||||
.setAutorenewEndTime(plusYears(fakeClock.nowUtc(), 1))
|
||||
.setTargetId("foobar.foo")
|
||||
.build());
|
||||
PollMessage persisted = tm().transact(() -> tm().loadByEntity(pollMessage));
|
||||
|
||||
@@ -48,6 +48,7 @@ import google.registry.testing.DatabaseHelper;
|
||||
import google.registry.util.CidrAddressBlock;
|
||||
import google.registry.util.SerializeUtils;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.money.Money;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -480,7 +481,10 @@ class RegistrarTest extends EntityTestCase {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> new Registrar.Builder().setLastExpiringCertNotificationSentDate(null).build());
|
||||
() ->
|
||||
new Registrar.Builder()
|
||||
.setLastExpiringCertNotificationSentDate((Instant) null)
|
||||
.build());
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.isEqualTo("Registrar lastExpiringCertNotificationSentDate cannot be null");
|
||||
@@ -513,7 +517,7 @@ class RegistrarTest extends EntityTestCase {
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> new Registrar.Builder().setLastPocVerificationDate(null).build());
|
||||
() -> new Registrar.Builder().setLastPocVerificationDate((Instant) null).build());
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.isEqualTo("Registrar lastPocVerificationDate cannot be null");
|
||||
@@ -526,7 +530,7 @@ class RegistrarTest extends EntityTestCase {
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
new Registrar.Builder()
|
||||
.setLastExpiringFailoverCertNotificationSentDate(null)
|
||||
.setLastExpiringFailoverCertNotificationSentDate((Instant) null)
|
||||
.build());
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
|
||||
@@ -48,17 +48,17 @@ public class ClaimsListDaoTest {
|
||||
@Test
|
||||
void save_insertsClaimsListSuccessfully() {
|
||||
ClaimsList claimsList =
|
||||
ClaimsList.create(fakeClock.nowUtc(), ImmutableMap.of("label1", "key1", "label2", "key2"));
|
||||
ClaimsList.create(fakeClock.now(), ImmutableMap.of("label1", "key1", "label2", "key2"));
|
||||
claimsList = ClaimsListDao.save(claimsList);
|
||||
ClaimsList insertedClaimsList = ClaimsListDao.get();
|
||||
assertClaimsListEquals(claimsList, insertedClaimsList);
|
||||
assertThat(insertedClaimsList.getCreationTimestamp()).isEqualTo(fakeClock.nowUtc());
|
||||
assertThat(insertedClaimsList.getCreationTime()).isEqualTo(fakeClock.now());
|
||||
}
|
||||
|
||||
@Test
|
||||
void save_insertsClaimsListSuccessfully_withRetries() {
|
||||
ClaimsList claimsList =
|
||||
ClaimsList.create(fakeClock.nowUtc(), ImmutableMap.of("label1", "key1", "label2", "key2"));
|
||||
ClaimsList.create(fakeClock.now(), ImmutableMap.of("label1", "key1", "label2", "key2"));
|
||||
AtomicBoolean isFirstAttempt = new AtomicBoolean(true);
|
||||
tm().transact(
|
||||
() -> {
|
||||
@@ -69,15 +69,15 @@ public class ClaimsListDaoTest {
|
||||
}
|
||||
});
|
||||
ClaimsList insertedClaimsList = ClaimsListDao.get();
|
||||
assertThat(insertedClaimsList.getTmdbGenerationTime())
|
||||
.isEqualTo(claimsList.getTmdbGenerationTime());
|
||||
assertThat(insertedClaimsList.getTmdbGenerationTimeInstant())
|
||||
.isEqualTo(claimsList.getTmdbGenerationTimeInstant());
|
||||
assertThat(insertedClaimsList.getLabelsToKeys()).isEqualTo(claimsList.getLabelsToKeys());
|
||||
assertThat(insertedClaimsList.getCreationTimestamp()).isEqualTo(fakeClock.nowUtc());
|
||||
assertThat(insertedClaimsList.getCreationTime()).isEqualTo(fakeClock.now());
|
||||
}
|
||||
|
||||
@Test
|
||||
void save_claimsListWithNoEntries() {
|
||||
ClaimsList claimsList = ClaimsList.create(fakeClock.nowUtc(), ImmutableMap.of());
|
||||
ClaimsList claimsList = ClaimsList.create(fakeClock.now(), ImmutableMap.of());
|
||||
claimsList = ClaimsListDao.save(claimsList);
|
||||
ClaimsList insertedClaimsList = ClaimsListDao.get();
|
||||
assertClaimsListEquals(claimsList, insertedClaimsList);
|
||||
@@ -92,9 +92,9 @@ public class ClaimsListDaoTest {
|
||||
@Test
|
||||
void getCurrent_returnsLatestClaims() {
|
||||
ClaimsList oldClaimsList =
|
||||
ClaimsList.create(fakeClock.nowUtc(), ImmutableMap.of("label1", "key1", "label2", "key2"));
|
||||
ClaimsList.create(fakeClock.now(), ImmutableMap.of("label1", "key1", "label2", "key2"));
|
||||
ClaimsList newClaimsList =
|
||||
ClaimsList.create(fakeClock.nowUtc(), ImmutableMap.of("label3", "key3", "label4", "key4"));
|
||||
ClaimsList.create(fakeClock.now(), ImmutableMap.of("label3", "key3", "label4", "key4"));
|
||||
oldClaimsList = ClaimsListDao.save(oldClaimsList);
|
||||
newClaimsList = ClaimsListDao.save(newClaimsList);
|
||||
assertClaimsListEquals(newClaimsList, ClaimsListDao.get());
|
||||
@@ -104,11 +104,11 @@ public class ClaimsListDaoTest {
|
||||
void testDaoCaching_savesAndUpdates() {
|
||||
assertThat(ClaimsListDao.CACHE.getIfPresent(ClaimsListDao.class)).isNull();
|
||||
ClaimsList oldList =
|
||||
ClaimsList.create(fakeClock.nowUtc(), ImmutableMap.of("label1", "key1", "label2", "key2"));
|
||||
ClaimsList.create(fakeClock.now(), ImmutableMap.of("label1", "key1", "label2", "key2"));
|
||||
oldList = ClaimsListDao.save(oldList);
|
||||
assertThat(ClaimsListDao.CACHE.getIfPresent(ClaimsListDao.class)).isEqualTo(oldList);
|
||||
ClaimsList newList =
|
||||
ClaimsList.create(fakeClock.nowUtc(), ImmutableMap.of("label3", "key3", "label4", "key4"));
|
||||
ClaimsList.create(fakeClock.now(), ImmutableMap.of("label3", "key3", "label4", "key4"));
|
||||
newList = ClaimsListDao.save(newList);
|
||||
assertThat(ClaimsListDao.CACHE.getIfPresent(ClaimsListDao.class)).isEqualTo(newList);
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public class ClaimsListDaoTest {
|
||||
@Test
|
||||
void testEntryCaching_savesAndUpdates() {
|
||||
ClaimsList claimsList =
|
||||
ClaimsList.create(fakeClock.nowUtc(), ImmutableMap.of("label1", "key1", "label2", "key2"));
|
||||
ClaimsList.create(fakeClock.now(), ImmutableMap.of("label1", "key1", "label2", "key2"));
|
||||
// Bypass the DAO to avoid the cache
|
||||
tm().transact(() -> tm().insert(claimsList));
|
||||
ClaimsList fromDatabase = ClaimsListDao.get();
|
||||
@@ -140,7 +140,7 @@ public class ClaimsListDaoTest {
|
||||
|
||||
private void assertClaimsListEquals(ClaimsList left, ClaimsList right) {
|
||||
assertThat(left.getRevisionId()).isEqualTo(right.getRevisionId());
|
||||
assertThat(left.getTmdbGenerationTime()).isEqualTo(right.getTmdbGenerationTime());
|
||||
assertThat(left.getTmdbGenerationTimeInstant()).isEqualTo(right.getTmdbGenerationTimeInstant());
|
||||
assertThat(left.getLabelsToKeys()).isEqualTo(right.getLabelsToKeys());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package google.registry.mosapi.module;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.util.DateTimeUtils.plusYears;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
@@ -32,7 +33,6 @@ import java.security.PrivateKey;
|
||||
import java.security.Security;
|
||||
import java.security.cert.Certificate;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
@@ -156,8 +156,8 @@ public class MosApiModuleTest {
|
||||
this.generatedPrivateKey = keyPair.getPrivate();
|
||||
DateTimeFormatter formatter =
|
||||
DateTimeFormatter.ofPattern("yyyyMMddHHmmss'Z'").withZone(ZoneId.of("UTC"));
|
||||
Instant now = Instant.now();
|
||||
Instant end = now.plus(Duration.ofDays(365));
|
||||
Instant now = Instant.parse("2021-01-01T00:00:00Z");
|
||||
Instant end = plusYears(now, 1);
|
||||
// Convert string to Bouncy Castle Time objects
|
||||
Time notBefore = new Time(new ASN1GeneralizedTime(formatter.format(now)));
|
||||
Time notAfter = new Time(new ASN1GeneralizedTime(formatter.format(end)));
|
||||
|
||||
@@ -29,7 +29,7 @@ import google.registry.rdap.RdapDataStructures.PublicId;
|
||||
import google.registry.rdap.RdapDataStructures.RdapConformance;
|
||||
import google.registry.rdap.RdapDataStructures.RdapStatus;
|
||||
import google.registry.rdap.RdapDataStructures.Remark;
|
||||
import org.joda.time.DateTime;
|
||||
import java.time.Instant;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/** Unit tests for {@link RdapDataStructures}. */
|
||||
@@ -121,7 +121,7 @@ final class RdapDataStructuresTest {
|
||||
Event.builder()
|
||||
.setEventAction(EventAction.REGISTRATION)
|
||||
.setEventActor("Event Actor")
|
||||
.setEventDate(DateTime.parse("2012-04-03T14:54Z"))
|
||||
.setEventDate(Instant.parse("2012-04-03T14:54:00Z"))
|
||||
.addLink(Link.builder().setHref("myHref").build())
|
||||
.build();
|
||||
assertThat(event.toJson())
|
||||
@@ -141,7 +141,7 @@ final class RdapDataStructuresTest {
|
||||
EventWithoutActor event =
|
||||
EventWithoutActor.builder()
|
||||
.setEventAction(EventAction.REGISTRATION)
|
||||
.setEventDate(DateTime.parse("2012-04-03T14:54Z"))
|
||||
.setEventDate(Instant.parse("2012-04-03T14:54:00Z"))
|
||||
.addLink(Link.builder().setHref("myHref").build())
|
||||
.build();
|
||||
assertThat(event.toJson())
|
||||
|
||||
@@ -48,6 +48,7 @@ import google.registry.rdap.RdapObjectClasses.BoilerplateType;
|
||||
import google.registry.rdap.RdapObjectClasses.ReplyPayloadBase;
|
||||
import google.registry.rdap.RdapObjectClasses.TopLevelReplyObject;
|
||||
import google.registry.testing.FakeClock;
|
||||
import java.time.Instant;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -150,7 +151,7 @@ class RdapJsonFormatterTest {
|
||||
makeDomain("fish.みんな", null, null, registrar)
|
||||
.asBuilder()
|
||||
.setCreationTimeForTest(clock.nowUtc())
|
||||
.setLastEppUpdateTime(null)
|
||||
.setLastEppUpdateTime((java.time.Instant) null)
|
||||
.build());
|
||||
|
||||
// history entries
|
||||
@@ -330,7 +331,7 @@ class RdapJsonFormatterTest {
|
||||
RdapJsonFormatter.getLastHistoryByType(domainFull),
|
||||
RdapJsonFormatter.HistoryTimeAndRegistrar::modificationTime))
|
||||
.containsExactlyEntriesIn(
|
||||
ImmutableMap.of(TRANSFER, DateTime.parse("1999-12-01T00:00:00.000Z")));
|
||||
ImmutableMap.of(TRANSFER, Instant.parse("1999-12-01T00:00:00.000Z")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -33,6 +33,7 @@ import google.registry.xjc.rderegistrar.XjcRdeRegistrarPostalInfoEnumType;
|
||||
import google.registry.xjc.rderegistrar.XjcRdeRegistrarPostalInfoType;
|
||||
import google.registry.xjc.rderegistrar.XjcRdeRegistrarStatusType;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.time.Instant;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -86,7 +87,7 @@ public class RegistrarToXjcConverterTest {
|
||||
.setUrl("http://www.goblinmen.example")
|
||||
.build();
|
||||
registrar = cloneAndSetAutoTimestamps(registrar); // Set the creation time in 2013.
|
||||
registrar = registrar.asBuilder().setLastUpdateTime(null).build();
|
||||
registrar = registrar.asBuilder().setLastUpdateTime((Instant) null).build();
|
||||
clock.setTo(DateTime.parse("2014-01-01T00:00:00Z"));
|
||||
registrar = cloneAndSetAutoTimestamps(registrar); // Set the update time in 2014.
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public class RegistrarDaoTest {
|
||||
|
||||
assertThat(persisted.getRegistrarId()).isEqualTo("registrarId");
|
||||
assertThat(persisted.getRegistrarName()).isEqualTo("registrarName");
|
||||
assertThat(persisted.getCreationTime()).isEqualTo(fakeClock.nowUtc());
|
||||
assertThat(persisted.getCreationTime()).isEqualTo(fakeClock.now());
|
||||
assertThat(persisted.getLocalizedAddress())
|
||||
.isEqualTo(
|
||||
new RegistrarAddress.Builder()
|
||||
|
||||
@@ -17,6 +17,7 @@ package google.registry.testing;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.truth.Fact.simpleFact;
|
||||
import static com.google.common.truth.Truth.assertAbout;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -28,6 +29,7 @@ import google.registry.model.domain.secdns.DomainDsData;
|
||||
import google.registry.model.eppcommon.AuthInfo;
|
||||
import google.registry.testing.TruthChainer.And;
|
||||
import google.registry.tmch.LordnTaskUtils.LordnPhase;
|
||||
import java.time.Instant;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
import org.joda.time.DateTime;
|
||||
@@ -77,17 +79,30 @@ public final class DomainSubject extends AbstractEppResourceSubject<Domain, Doma
|
||||
}
|
||||
|
||||
public And<DomainSubject> hasRegistrationExpirationTime(DateTime expiration) {
|
||||
return hasRegistrationExpirationTime(toInstant(expiration));
|
||||
}
|
||||
|
||||
public And<DomainSubject> hasRegistrationExpirationTime(Instant expiration) {
|
||||
return hasValue(
|
||||
expiration, actual.getRegistrationExpirationDateTime(), "getRegistrationExpirationTime()");
|
||||
expiration, actual.getRegistrationExpirationTime(), "getRegistrationExpirationTime()");
|
||||
}
|
||||
|
||||
public And<DomainSubject> hasLastTransferTime(DateTime lastTransferTime) {
|
||||
return hasValue(lastTransferTime, actual.getLastTransferTime(), "getLastTransferTime()");
|
||||
return hasLastTransferTime(toInstant(lastTransferTime));
|
||||
}
|
||||
|
||||
public And<DomainSubject> hasLastTransferTime(Instant lastTransferTime) {
|
||||
return hasValue(
|
||||
lastTransferTime, toInstant(actual.getLastTransferTime()), "getLastTransferTime()");
|
||||
}
|
||||
|
||||
public And<DomainSubject> hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) {
|
||||
return hasLastTransferTimeNotEqualTo(toInstant(lastTransferTime));
|
||||
}
|
||||
|
||||
public And<DomainSubject> hasLastTransferTimeNotEqualTo(Instant lastTransferTime) {
|
||||
return doesNotHaveValue(
|
||||
lastTransferTime, actual.getLastTransferTime(), "getLastTransferTime()");
|
||||
lastTransferTime, toInstant(actual.getLastTransferTime()), "getLastTransferTime()");
|
||||
}
|
||||
|
||||
public And<DomainSubject> hasDeletePollMessage() {
|
||||
@@ -109,12 +124,21 @@ public final class DomainSubject extends AbstractEppResourceSubject<Domain, Doma
|
||||
}
|
||||
|
||||
public And<DomainSubject> hasAutorenewEndTime(DateTime autorenewEndTime) {
|
||||
return hasAutorenewEndTime(toInstant(autorenewEndTime));
|
||||
}
|
||||
|
||||
public And<DomainSubject> hasAutorenewEndTime(Instant autorenewEndTime) {
|
||||
checkArgumentNotNull(autorenewEndTime, "Use hasNoAutorenewEndTime() instead");
|
||||
return hasValue(autorenewEndTime, actual.getAutorenewEndTime(), "getAutorenewEndTime()");
|
||||
return hasValue(
|
||||
autorenewEndTime,
|
||||
toInstant(actual.getAutorenewEndTime().orElse(null)),
|
||||
"getAutorenewEndTime()");
|
||||
}
|
||||
|
||||
public And<DomainSubject> hasNoAutorenewEndTime() {
|
||||
return hasNoValue(actual.getAutorenewEndTime(), "getAutorenewEndTime()");
|
||||
return hasNoValue(
|
||||
actual.getAutorenewEndTime().map(google.registry.util.DateTimeUtils::toInstant),
|
||||
"getAutorenewEndTime()");
|
||||
}
|
||||
|
||||
public static SimpleSubjectBuilder<DomainSubject, Domain> assertAboutDomains() {
|
||||
|
||||
@@ -22,7 +22,8 @@ import static google.registry.testing.DatabaseHelper.createTlds;
|
||||
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_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.toDateTime;
|
||||
import static org.joda.money.CurrencyUnit.JPY;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
@@ -42,6 +43,7 @@ import google.registry.flows.certs.CertificateChecker.InsecureCertificateExcepti
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.money.Money;
|
||||
@@ -62,7 +64,11 @@ class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarCommand>
|
||||
command.setConnection(connection);
|
||||
command.certificateChecker =
|
||||
new CertificateChecker(
|
||||
ImmutableSortedMap.of(START_OF_TIME, 825, DateTime.parse("2020-09-01T00:00:00Z"), 398),
|
||||
ImmutableSortedMap.of(
|
||||
toDateTime(START_INSTANT),
|
||||
825,
|
||||
toDateTime(Instant.parse("2020-09-01T00:00:00Z")),
|
||||
398),
|
||||
30,
|
||||
15,
|
||||
2048,
|
||||
@@ -73,7 +79,7 @@ class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarCommand>
|
||||
|
||||
@Test
|
||||
void testSuccess() throws Exception {
|
||||
DateTime before = fakeClock.nowUtc();
|
||||
Instant before = fakeClock.now();
|
||||
runCommandForced(
|
||||
"--name=blobio",
|
||||
"--password=some_password",
|
||||
@@ -87,7 +93,7 @@ class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarCommand>
|
||||
"--zip 00351",
|
||||
"--cc US",
|
||||
"clientz");
|
||||
DateTime after = fakeClock.nowUtc();
|
||||
Instant after = fakeClock.now();
|
||||
|
||||
Optional<Registrar> registrarOptional = Registrar.loadByRegistrarId("clientz");
|
||||
assertThat(registrarOptional).isPresent();
|
||||
@@ -101,7 +107,7 @@ class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarCommand>
|
||||
assertThat(registrar.getClientCertificateHash()).isEmpty();
|
||||
assertThat(registrar.getPhonePasscode()).isEqualTo("01234");
|
||||
assertThat(registrar.getCreationTime()).isIn(Range.closed(before, after));
|
||||
assertThat(registrar.getLastUpdateTime()).isEqualTo(registrar.getCreationTime());
|
||||
assertThat(registrar.getLastUpdateTimeInstant()).isEqualTo(registrar.getCreationTime());
|
||||
assertThat(registrar.getBlockPremiumNames()).isFalse();
|
||||
assertThat(registrar.isRegistryLockAllowed()).isFalse();
|
||||
assertThat(registrar.getPoNumber()).isEmpty();
|
||||
@@ -594,14 +600,14 @@ class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarCommand>
|
||||
newTld("foo", "FOO")
|
||||
.asBuilder()
|
||||
.setCurrency(JPY)
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.of(JPY, new BigDecimal(1300))))
|
||||
.setCreateBillingCostTransitionsInstant(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(JPY, new BigDecimal(1300))))
|
||||
.setRestoreBillingCost(Money.of(JPY, new BigDecimal(1700)))
|
||||
.setServerStatusChangeBillingCost(Money.of(JPY, new BigDecimal(1900)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.of(JPY, new BigDecimal(2700)))
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.of(JPY, new BigDecimal(1100))))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(JPY)))
|
||||
.setRenewBillingCostTransitionsInstant(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(JPY, new BigDecimal(1100))))
|
||||
.setEapFeeScheduleInstant(ImmutableSortedMap.of(START_INSTANT, Money.zero(JPY)))
|
||||
.setPremiumList(null)
|
||||
.build());
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class GetHistoryEntriesCommandTest extends CommandTestCase<GetHistoryEntriesComm
|
||||
assertStdoutIs(
|
||||
"""
|
||||
Client: TheRegistrar
|
||||
Time: 2000-01-01T00:00:00.000Z
|
||||
Time: 2000-01-01T00:00:00Z
|
||||
Client TRID: ABC-123
|
||||
Server TRID: server-trid
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
@@ -104,7 +104,7 @@ class GetHistoryEntriesCommandTest extends CommandTestCase<GetHistoryEntriesComm
|
||||
assertStdoutIs(
|
||||
"""
|
||||
Client: TheRegistrar
|
||||
Time: 2000-01-01T00:00:00.000Z
|
||||
Time: 2000-01-01T00:00:00Z
|
||||
Client TRID: ABC-123
|
||||
Server TRID: server-trid
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
@@ -129,7 +129,7 @@ class GetHistoryEntriesCommandTest extends CommandTestCase<GetHistoryEntriesComm
|
||||
assertStdoutIs(
|
||||
"""
|
||||
Client: TheRegistrar
|
||||
Time: 2000-01-01T00:00:00.000Z
|
||||
Time: 2000-01-01T00:00:00Z
|
||||
Client TRID: null
|
||||
Server TRID: null
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
|
||||
@@ -100,18 +100,18 @@ public class MutatingCommandTest {
|
||||
assertThat(changes)
|
||||
.isEqualTo(
|
||||
"""
|
||||
Update Host@2-ROID
|
||||
lastEppUpdateTime: null -> 2014-09-09T09:09:09.000Z
|
||||
Update Host@2-ROID
|
||||
lastEppUpdateTime: null -> 2014-09-09T09:09:09.000Z
|
||||
|
||||
Update Host@3-ROID
|
||||
currentSponsorRegistrarId: TheRegistrar -> Registrar2
|
||||
Update Host@3-ROID
|
||||
currentSponsorRegistrarId: TheRegistrar -> Registrar2
|
||||
|
||||
Update Registrar@Registrar1
|
||||
poNumber: null -> 23
|
||||
Update Registrar@Registrar1
|
||||
poNumber: null -> 23
|
||||
|
||||
Update Registrar@Registrar2
|
||||
blockPremiumNames: false -> true
|
||||
""");
|
||||
Update Registrar@Registrar2
|
||||
blockPremiumNames: false -> true
|
||||
""");
|
||||
String results = command.execute();
|
||||
assertThat(results).isEqualTo("Updated 4 entities.\n");
|
||||
assertThat(loadByEntity(host1)).isEqualTo(newHost1);
|
||||
@@ -217,12 +217,12 @@ public class MutatingCommandTest {
|
||||
assertThat(changes)
|
||||
.isEqualTo(
|
||||
"""
|
||||
Update Host@2-ROID
|
||||
[no changes]
|
||||
Update Host@2-ROID
|
||||
[no changes]
|
||||
|
||||
Update Registrar@Registrar1
|
||||
[no changes]
|
||||
""");
|
||||
Update Registrar@Registrar1
|
||||
[no changes]
|
||||
""");
|
||||
String results = command.execute();
|
||||
assertThat(results).isEqualTo("Updated 2 entities.\n");
|
||||
assertThat(loadByEntity(host1)).isEqualTo(host1);
|
||||
|
||||
@@ -197,7 +197,7 @@ public class UpdateRecurrenceCommandTest extends CommandTestCase<UpdateRecurrenc
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("domain.tld", "--renewal_price_behavior", "NONPREMIUM")))
|
||||
.hasMessageThat()
|
||||
.isEqualTo("Domain domain.tld's recurrence's end date is not END_OF_TIME");
|
||||
.isEqualTo("Domain domain.tld's recurrence's end date is not END_INSTANT");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -21,6 +21,7 @@ import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatabaseHelper.persistActiveHost;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.TestDataHelper.loadFile;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.joda.time.Duration.standardDays;
|
||||
|
||||
@@ -154,9 +155,11 @@ class GenerateZoneFilesActionTest {
|
||||
action.handleJsonRequest(
|
||||
ImmutableMap.<String, Object>of("tlds", ImmutableList.of("tld"), "exportTime", now));
|
||||
assertThat(response)
|
||||
.containsEntry("filenames", ImmutableList.of("gs://zonefiles-bucket/tld-" + now + ".zone"));
|
||||
.containsEntry(
|
||||
"filenames", ImmutableList.of("gs://zonefiles-bucket/tld-" + toInstant(now) + ".zone"));
|
||||
|
||||
BlobId gcsFilename = BlobId.of("zonefiles-bucket", String.format("tld-%s.zone", now));
|
||||
BlobId gcsFilename =
|
||||
BlobId.of("zonefiles-bucket", String.format("tld-%s.zone", toInstant(now)));
|
||||
String generatedFile = new String(gcsUtils.readBytesFrom(gcsFilename), UTF_8);
|
||||
// The generated file contains spaces and tabs, but the golden file contains only spaces, as
|
||||
// files with literal tabs irritate our build tools.
|
||||
|
||||
Reference in New Issue
Block a user