mirror of
https://github.com/google/nomulus
synced 2026-07-19 14:32:44 +00:00
Migrate EPP Flows, TLD, and Domain Base models to java.time (#3025)
Migrates the massive DomainBase, DomainHistory, and Registrar models to use java.time.Instant natively, removing all deprecated DateTime accessors and fixing their associated JPA converters. Migrates the Tld entity and its entire JSON/YAML testing ecosystem, including implementing an InstantKeySerializer to preserve millisecond precision in Jackson. Migrates the entire Epp Flow ecosystem (Create, Update, Delete, Renew, Transfer for Domains/Hosts/Contacts) to use native Instant parameters and operations. Migrates EppTestCase and EppLifecycleDomainTest to use Instant natively instead of constantly double-wrapping timestamps. Rebases against upstream and standardizes all Duration and DateTimeUtils static imports across the test suites.
This commit is contained in:
@@ -16,7 +16,11 @@ This document outlines foundational mandates, architectural patterns, and projec
|
||||
## 2. Time and Precision Handling (java.time Migration)
|
||||
|
||||
- **Idiomatic java.time Usage:** Avoid redundant conversions between `Instant` and `DateTime`. If a field or parameter is an `Instant`, use it directly. Do not convert to `DateTime` just to call a deprecated method if an `Instant` alternative exists or can be easily created. Furthermore, you should not call `toInstant()` or `toDateTime()` conversion methods when not strictly necessary; always prefer to use an alternative method that returns the correct type if one exists (e.g. use `tm().getTxTime()` which returns an `Instant` instead of calling `tm().getTransactionTime().toInstant()`).
|
||||
- **CRITICAL MISTAKE TO AVOID:** NEVER use `toInstant(clock.nowUtc())` or `toInstant(fakeClock.nowUtc())`. Both `Clock` and `FakeClock` have a `now()` method that natively returns a `java.time.Instant`. You MUST use `clock.now()` or `fakeClock.now()` directly. Converting `nowUtc()` to an Instant is an embarrassing mistake that demonstrates a lack of basic codebase familiarity.
|
||||
- **CRITICAL MISTAKES TO AVOID:**
|
||||
- NEVER use `toInstant(clock.nowUtc())` or `toInstant(fakeClock.nowUtc())`. Both `Clock` and `FakeClock` have a `now()` method that natively returns a `java.time.Instant`. You MUST use `clock.now()` or `fakeClock.now()` directly.
|
||||
- NEVER double-wrap conversions like `toInstant(toDateTime(...))` or `toDateTime(toInstant(...))`.
|
||||
- NEVER mark `Instant` parameters or local variables as `final` unnecessarily, as it clutters the codebase.
|
||||
- When using test helpers like `assertThatCommand().atTime(...)` or `ForeignKeyUtils.loadResource(...)`, ALWAYS use the `Instant` overloads. DO NOT wrap `Instant` instances in `toDateTime(...)` just to pass them to deprecated overloads.
|
||||
- **UTC Timezones:** Do not use `ZoneId.of("UTC")`. Use a statically imported `UTC` from `ZoneOffset` instead (`import static java.time.ZoneOffset.UTC;`).
|
||||
- **Millisecond Precision:** Always truncate `Instant.now()` to milliseconds (using `.truncatedTo(ChronoUnit.MILLIS)`) to maintain consistency with Joda `DateTime` and the PostgreSQL schema (which enforces millisecond precision via JPA converters).
|
||||
- **Clock Injection:**
|
||||
@@ -139,9 +143,13 @@ This project treats Error Prone warnings as errors.
|
||||
|
||||
## 🚫 Common Pitfalls to Avoid
|
||||
|
||||
- **Mixing Joda and Java Durations:** Methods like `Tld.get().getRenewGracePeriodLength()` return a **Joda** `Duration`, which cannot be passed directly to `Instant.plus(...)` because it doesn't implement `TemporalAmount`. You MUST use `.plusMillis(duration.getMillis())` instead.
|
||||
- **Serialization Precision (`.000Z`):** When asserting against or generating XML/YAML files, remember that millisecond precision (`.000Z`) is required. Always use `DateTimeUtils.formatInstant(...)` to format `Instant` objects (it preserves the `.000Z` suffix) instead of `Instant.toString()` (which drops it for exact seconds). We have added custom Jackson `InstantKeySerializer`s for this purpose, but you must keep this precision in mind when manually updating `.xml` or `.yaml` test data.
|
||||
- **Static Imports:** Methods like `toDateTime`, `toInstant`, `plusYears`, `plusMonths`, and `minusDays` from `DateTimeUtils` MUST be statically imported. Do NOT use them fully qualified (e.g., `DateTimeUtils.plusMonths(...)`).
|
||||
|
||||
- **Redundant Parses:** Never write `toDateTime(Instant.parse(...))` or `toInstant(DateTime.parse(...))`. If you need a `DateTime`, use `DateTime.parse(...)` directly. If you need an `Instant`, use `Instant.parse(...)` directly.
|
||||
- **cloneProjectedAtTime vs cloneProjectedAtInstant:** When converting tests and logic that use `clock.now()` to project resource state into the future or past, do not wrap the Java `Instant` in `toDateTime()` just to call `cloneProjectedAtTime()`. Instead, switch the method call to use the native `cloneProjectedAtInstant()` method which is available on all `EppResource` models.
|
||||
- **Do not go in circles with the build:** If you see an `InlineMeSuggester` error, apply the suppression to **ALL** similar methods in that file and related files in one turn. Do not fix them one by one.
|
||||
- **Do not go in circles with the build:** If you see an `InlineMeSuggester` error, apply the suppression to **ALL** similar methods in that file and related files in one turn. Do not fix them one by one. Furthermore, do not run a global `./gradlew build` when a scoped `./gradlew :core:build` or `./gradlew :core:test` is faster and more appropriate. Run global builds only when doing final verification.
|
||||
- **Exception Conversion in Tests:** When migrating time types (e.g., from Joda `DateTime` to Java `Instant`), be extremely careful with tests that verify parsing failures (e.g., `assertThrows(IllegalArgumentException.class, ...)`). Joda's `DateTime.parse()` throws an `IllegalArgumentException` on failure, but `Instant.parse()` throws a `java.time.format.DateTimeParseException`. You must update the expected exception type in these tests to ensure they actually test the correct behavior, and verify the tests are not failing prematurely on the first line if it contains invalid data meant to be ignored.
|
||||
- Dagger/AutoValue corruption: If you modify a builder or a component incorrectly, Dagger will fail to generate code, leading to hundreds of "cannot find symbol" errors. If this happens, `git checkout` the last working state of the specific file and re-apply changes more surgically.
|
||||
- **`replace` tool context**: When using `replace` on large files (like `Tld.java` or `DomainBase.java`), provide significant surrounding context. These files have many similar method signatures (getters/setters) that can lead to incorrect replacements.
|
||||
|
||||
@@ -69,13 +69,18 @@ public abstract class DateTimeUtils {
|
||||
* <p>Handles large/negative years by using a sign prefix if necessary, compatible with {@link
|
||||
* Instant#parse}.
|
||||
*/
|
||||
public static final DateTimeFormatter ISO_8601_FORMATTER =
|
||||
private static final DateTimeFormatter ISO_8601_FORMATTER =
|
||||
new DateTimeFormatterBuilder()
|
||||
.appendValue(ChronoField.YEAR, 4, 10, SignStyle.NORMAL)
|
||||
.appendPattern("-MM-dd'T'HH:mm:ss.SSS'Z'")
|
||||
.toFormatter()
|
||||
.withZone(ZoneOffset.UTC);
|
||||
|
||||
/** Formats an {@link Instant} to an ISO-8601 string. */
|
||||
public static String formatInstant(Instant instant) {
|
||||
return ISO_8601_FORMATTER.format(instant);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses an ISO-8601 string to an {@link Instant}.
|
||||
*
|
||||
|
||||
+1
-3
@@ -55,7 +55,6 @@ import google.registry.util.Clock;
|
||||
import google.registry.util.SystemClock;
|
||||
import jakarta.inject.Singleton;
|
||||
import java.io.Serializable;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@@ -312,8 +311,7 @@ public class ExpandBillingRecurrencesPipeline implements Serializable {
|
||||
for (Instant eventTime : eventTimesToExpand) {
|
||||
recurrenceLastExpansionTime = latestOf(recurrenceLastExpansionTime, eventTime);
|
||||
oneTimesToExpandCounter.inc();
|
||||
Instant billingTime =
|
||||
eventTime.plus(Duration.ofMillis(tld.getAutoRenewGracePeriodLength().getMillis()));
|
||||
Instant billingTime = eventTime.plusMillis(tld.getAutoRenewGracePeriodLength().getMillis());
|
||||
// Note that the DomainHistory is created as of transaction time, as opposed to event time.
|
||||
// This might be counterintuitive because other DomainHistories are created at the time
|
||||
// mutation events occur, such as in DomainDeleteFlow or DomainRenewFlow. Therefore, it is
|
||||
|
||||
@@ -17,7 +17,7 @@ package google.registry.bsa.persistence;
|
||||
import static com.google.common.collect.ImmutableMap.toImmutableMap;
|
||||
import static google.registry.bsa.DownloadStage.DONE;
|
||||
import static google.registry.bsa.DownloadStage.DOWNLOAD_BLOCK_LISTS;
|
||||
import static google.registry.util.DateTimeUtils.ISO_8601_FORMATTER;
|
||||
import static google.registry.util.DateTimeUtils.formatInstant;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Objects;
|
||||
@@ -84,7 +84,7 @@ class BsaDownload {
|
||||
*/
|
||||
String getJobName() {
|
||||
// Return a value based on job start time, which is unique.
|
||||
return ISO_8601_FORMATTER.format(getCreationTime()).toLowerCase(Locale.ROOT).replace(":", "");
|
||||
return formatInstant(getCreationTime()).toLowerCase(Locale.ROOT).replace(":", "");
|
||||
}
|
||||
|
||||
boolean isDone() {
|
||||
|
||||
@@ -117,8 +117,8 @@ public final class DownloadScheduler {
|
||||
private boolean isTimeAgain(BsaDownload mostRecent, Duration interval) {
|
||||
return mostRecent
|
||||
.getCreationTime()
|
||||
.plus(java.time.Duration.ofMillis(interval.getMillis()))
|
||||
.minus(java.time.Duration.ofMillis(CRON_JITTER.getMillis()))
|
||||
.plusMillis(interval.getMillis())
|
||||
.minusMillis(CRON_JITTER.getMillis())
|
||||
.isBefore(clock.now());
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* Class for synchronizing all {@link Registrar} objects to a Google Spreadsheet.
|
||||
@@ -75,7 +74,7 @@ class SyncRegistrarsSheet {
|
||||
|
||||
/** Performs the synchronization operation. */
|
||||
void run(String spreadsheetId) throws IOException {
|
||||
final DateTime executionTime = clock.nowUtc();
|
||||
Instant executionTime = clock.now();
|
||||
sheetSynchronizer.synchronize(
|
||||
spreadsheetId,
|
||||
new Ordering<Registrar>() {
|
||||
|
||||
@@ -35,7 +35,6 @@ import static google.registry.monitoring.whitebox.CheckApiMetric.Tier.STANDARD;
|
||||
import static google.registry.persistence.PersistenceModule.TransactionIsolationLevel.TRANSACTION_REPEATABLE_READ;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.replicaTm;
|
||||
import static google.registry.pricing.PricingEngineProxy.isDomainPremium;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
import static google.registry.util.DomainNameUtils.canonicalizeHostname;
|
||||
import static org.json.simple.JSONValue.toJSONString;
|
||||
|
||||
@@ -61,9 +60,9 @@ import google.registry.request.Response;
|
||||
import google.registry.request.auth.Auth;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* An action that returns availability and premium checks as JSON.
|
||||
@@ -131,7 +130,7 @@ public class CheckApiAction implements Runnable {
|
||||
// Throws an EppException with a reasonable error message which will be sent back to caller.
|
||||
validateDomainNameWithIdnTables(domainName);
|
||||
|
||||
DateTime now = replicaTm().getTransactionTime();
|
||||
Instant now = replicaTm().getTxTime();
|
||||
Tld tld = Tld.get(domainName.parent().toString());
|
||||
try {
|
||||
verifyNotInPredelegation(tld, now);
|
||||
@@ -166,7 +165,7 @@ public class CheckApiAction implements Runnable {
|
||||
metricBuilder.status(SUCCESS).availability(availability);
|
||||
responseBuilder.put("status", "success").put("available", availability.equals(AVAILABLE));
|
||||
|
||||
boolean isPremium = isDomainPremium(domainString, toInstant(now));
|
||||
boolean isPremium = isDomainPremium(domainString, now);
|
||||
metricBuilder.tier(isPremium ? PREMIUM : STANDARD);
|
||||
responseBuilder.put("tier", isPremium ? "premium" : "standard");
|
||||
if (!AVAILABLE.equals(availability)) {
|
||||
@@ -183,7 +182,7 @@ public class CheckApiAction implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkExists(String domainString, DateTime now) {
|
||||
private boolean checkExists(String domainString, Instant now) {
|
||||
return ForeignKeyUtils.loadKeyByCache(Domain.class, domainString, now).isPresent();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ package google.registry.flows;
|
||||
|
||||
import static com.google.common.collect.Sets.intersection;
|
||||
import static google.registry.model.EppResourceUtils.isLinked;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
@@ -50,7 +49,6 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/** Static utility functions for resource flows. */
|
||||
public final class ResourceFlowUtils {
|
||||
@@ -66,8 +64,7 @@ public final class ResourceFlowUtils {
|
||||
}
|
||||
|
||||
/** Check if there are domains linked to the host to be deleted. Throws an exception if so. */
|
||||
public static void checkLinkedDomains(final String targetId, final DateTime now)
|
||||
throws EppException {
|
||||
public static void checkLinkedDomains(final String targetId, Instant now) throws EppException {
|
||||
VKey<Host> key =
|
||||
ForeignKeyUtils.loadKey(Host.class, targetId, now)
|
||||
.orElseThrow(() -> new ResourceDoesNotExistException(Host.class, targetId));
|
||||
@@ -89,11 +86,6 @@ public final class ResourceFlowUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static <R extends EppResource & ForeignKeyedEppResource> R loadAndVerifyExistence(
|
||||
Class<R> clazz, String targetId, DateTime now) throws ResourceDoesNotExistException {
|
||||
return loadAndVerifyExistence(clazz, targetId, toInstant(now));
|
||||
}
|
||||
|
||||
public static <R extends EppResource & ForeignKeyedEppResource> R loadAndVerifyExistence(
|
||||
Class<R> clazz, String targetId, Instant now) throws ResourceDoesNotExistException {
|
||||
return verifyExistence(clazz, targetId, ForeignKeyUtils.loadResource(clazz, targetId, now));
|
||||
@@ -105,7 +97,7 @@ public final class ResourceFlowUtils {
|
||||
}
|
||||
|
||||
public static <R extends EppResource> void verifyResourceDoesNotExist(
|
||||
Class<R> clazz, String targetId, DateTime now, String registrarId) throws EppException {
|
||||
Class<R> clazz, String targetId, Instant now, String registrarId) throws EppException {
|
||||
Optional<R> resource = ForeignKeyUtils.loadResource(clazz, targetId, now);
|
||||
if (resource.isPresent()) {
|
||||
// These are similar exceptions, but we can track them internally as log-based metrics.
|
||||
|
||||
@@ -25,7 +25,7 @@ import google.registry.flows.domain.DomainCheckFlow;
|
||||
import google.registry.model.eppinput.EppInput;
|
||||
import google.registry.model.eppoutput.CheckData.DomainCheck;
|
||||
import google.registry.model.eppoutput.EppResponse.ResponseExtension;
|
||||
import org.joda.time.DateTime;
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* A no-op base class for {@link DomainCheckFlow} custom logic.
|
||||
@@ -75,7 +75,7 @@ public class DomainCheckFlowCustomLogic extends BaseFlowCustomLogic {
|
||||
* but can be overridden in v>=0.12 of the fee extension.
|
||||
*/
|
||||
public record AfterValidationParameters(
|
||||
ImmutableMap<String, InternetDomainName> domainNames, DateTime asOfDate) {
|
||||
ImmutableMap<String, InternetDomainName> domainNames, Instant asOfDate) {
|
||||
|
||||
public static Builder newBuilder() {
|
||||
return new AutoBuilder_DomainCheckFlowCustomLogic_AfterValidationParameters_Builder();
|
||||
@@ -87,7 +87,7 @@ public class DomainCheckFlowCustomLogic extends BaseFlowCustomLogic {
|
||||
|
||||
Builder setDomainNames(ImmutableMap<String, InternetDomainName> domainNames);
|
||||
|
||||
Builder setAsOfDate(DateTime asOfDate);
|
||||
Builder setAsOfDate(Instant asOfDate);
|
||||
|
||||
AfterValidationParameters build();
|
||||
}
|
||||
@@ -102,7 +102,7 @@ public class DomainCheckFlowCustomLogic extends BaseFlowCustomLogic {
|
||||
public record BeforeResponseParameters(
|
||||
ImmutableList<DomainCheck> domainChecks,
|
||||
ImmutableList<? extends ResponseExtension> responseExtensions,
|
||||
DateTime asOfDate) {
|
||||
Instant asOfDate) {
|
||||
|
||||
public static Builder newBuilder() {
|
||||
return new AutoBuilder_DomainCheckFlowCustomLogic_BeforeResponseParameters_Builder();
|
||||
@@ -116,7 +116,7 @@ public class DomainCheckFlowCustomLogic extends BaseFlowCustomLogic {
|
||||
|
||||
Builder setResponseExtensions(ImmutableList<? extends ResponseExtension> responseExtensions);
|
||||
|
||||
Builder setAsOfDate(DateTime asOfDate);
|
||||
Builder setAsOfDate(Instant asOfDate);
|
||||
|
||||
BeforeResponseParameters build();
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ import google.registry.flows.domain.DomainPricingLogic;
|
||||
import google.registry.flows.domain.FeesAndCredits;
|
||||
import google.registry.model.eppinput.EppInput;
|
||||
import google.registry.model.tld.Tld;
|
||||
import java.time.Instant;
|
||||
import javax.annotation.Nullable;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* A no-op base class to customize {@link DomainPricingLogic}.
|
||||
@@ -79,7 +79,7 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic {
|
||||
FeesAndCredits feesAndCredits,
|
||||
Tld tld,
|
||||
InternetDomainName domainName,
|
||||
DateTime asOfDate,
|
||||
Instant asOfDate,
|
||||
int years) {
|
||||
|
||||
public static Builder newBuilder() {
|
||||
@@ -96,7 +96,7 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic {
|
||||
|
||||
Builder setDomainName(InternetDomainName domainName);
|
||||
|
||||
Builder setAsOfDate(DateTime asOfDate);
|
||||
Builder setAsOfDate(Instant asOfDate);
|
||||
|
||||
Builder setYears(int years);
|
||||
|
||||
@@ -109,7 +109,7 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic {
|
||||
FeesAndCredits feesAndCredits,
|
||||
Tld tld,
|
||||
InternetDomainName domainName,
|
||||
DateTime asOfDate,
|
||||
Instant asOfDate,
|
||||
int years) {
|
||||
|
||||
public static Builder newBuilder() {
|
||||
@@ -126,7 +126,7 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic {
|
||||
|
||||
Builder setDomainName(InternetDomainName domainName);
|
||||
|
||||
Builder setAsOfDate(DateTime asOfDate);
|
||||
Builder setAsOfDate(Instant asOfDate);
|
||||
|
||||
Builder setYears(int years);
|
||||
|
||||
@@ -136,7 +136,7 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic {
|
||||
|
||||
/** A record to encapsulate parameters for a call to {@link #customizeRestorePrice} . */
|
||||
public record RestorePriceParameters(
|
||||
FeesAndCredits feesAndCredits, Tld tld, InternetDomainName domainName, DateTime asOfDate) {
|
||||
FeesAndCredits feesAndCredits, Tld tld, InternetDomainName domainName, Instant asOfDate) {
|
||||
|
||||
public static Builder newBuilder() {
|
||||
return new AutoBuilder_DomainPricingCustomLogic_RestorePriceParameters_Builder();
|
||||
@@ -152,7 +152,7 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic {
|
||||
|
||||
Builder setDomainName(InternetDomainName domainName);
|
||||
|
||||
Builder setAsOfDate(DateTime asOfDate);
|
||||
Builder setAsOfDate(Instant asOfDate);
|
||||
|
||||
RestorePriceParameters build();
|
||||
}
|
||||
@@ -160,7 +160,7 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic {
|
||||
|
||||
/** A record to encapsulate parameters for a call to {@link #customizeTransferPrice} . */
|
||||
public record TransferPriceParameters(
|
||||
FeesAndCredits feesAndCredits, Tld tld, InternetDomainName domainName, DateTime asOfDate) {
|
||||
FeesAndCredits feesAndCredits, Tld tld, InternetDomainName domainName, Instant asOfDate) {
|
||||
|
||||
public static Builder newBuilder() {
|
||||
return new AutoBuilder_DomainPricingCustomLogic_TransferPriceParameters_Builder();
|
||||
@@ -176,7 +176,7 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic {
|
||||
|
||||
Builder setDomainName(InternetDomainName domainName);
|
||||
|
||||
Builder setAsOfDate(DateTime asOfDate);
|
||||
Builder setAsOfDate(Instant asOfDate);
|
||||
|
||||
TransferPriceParameters build();
|
||||
}
|
||||
@@ -184,7 +184,7 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic {
|
||||
|
||||
/** A record to encapsulate parameters for a call to {@link #customizeUpdatePrice} . */
|
||||
public record UpdatePriceParameters(
|
||||
FeesAndCredits feesAndCredits, Tld tld, InternetDomainName domainName, DateTime asOfDate) {
|
||||
FeesAndCredits feesAndCredits, Tld tld, InternetDomainName domainName, Instant asOfDate) {
|
||||
|
||||
public static Builder newBuilder() {
|
||||
return new AutoBuilder_DomainPricingCustomLogic_UpdatePriceParameters_Builder();
|
||||
@@ -200,7 +200,7 @@ public class DomainPricingCustomLogic extends BaseFlowCustomLogic {
|
||||
|
||||
Builder setDomainName(InternetDomainName domainName);
|
||||
|
||||
Builder setAsOfDate(DateTime asOfDate);
|
||||
Builder setAsOfDate(Instant asOfDate);
|
||||
|
||||
UpdatePriceParameters build();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import google.registry.model.eppinput.EppInput;
|
||||
import google.registry.model.eppoutput.EppResponse.ResponseData;
|
||||
import google.registry.model.eppoutput.EppResponse.ResponseExtension;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import org.joda.time.DateTime;
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* A no-op base class for {@link DomainRenewFlow} custom logic.
|
||||
@@ -80,7 +80,7 @@ public class DomainRenewFlowCustomLogic extends BaseFlowCustomLogic {
|
||||
}
|
||||
|
||||
/** A class to encapsulate parameters for a call to {@link #afterValidation}. */
|
||||
public record AfterValidationParameters(Domain existingDomain, int years, DateTime now) {
|
||||
public record AfterValidationParameters(Domain existingDomain, int years, Instant now) {
|
||||
|
||||
public static Builder newBuilder() {
|
||||
return new AutoBuilder_DomainRenewFlowCustomLogic_AfterValidationParameters_Builder();
|
||||
@@ -94,7 +94,7 @@ public class DomainRenewFlowCustomLogic extends BaseFlowCustomLogic {
|
||||
|
||||
Builder setYears(int years);
|
||||
|
||||
Builder setNow(DateTime now);
|
||||
Builder setNow(Instant now);
|
||||
|
||||
AfterValidationParameters build();
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class DomainRenewFlowCustomLogic extends BaseFlowCustomLogic {
|
||||
HistoryEntry historyEntry,
|
||||
EntityChanges entityChanges,
|
||||
int years,
|
||||
DateTime now) {
|
||||
Instant now) {
|
||||
|
||||
public static Builder newBuilder() {
|
||||
return new AutoBuilder_DomainRenewFlowCustomLogic_BeforeSaveParameters_Builder();
|
||||
@@ -133,7 +133,7 @@ public class DomainRenewFlowCustomLogic extends BaseFlowCustomLogic {
|
||||
|
||||
Builder setYears(int years);
|
||||
|
||||
Builder setNow(DateTime now);
|
||||
Builder setNow(Instant now);
|
||||
|
||||
BeforeSaveParameters build();
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ import google.registry.model.tld.label.ReservationType;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.util.Clock;
|
||||
import jakarta.inject.Inject;
|
||||
import java.time.Instant;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@@ -89,7 +90,6 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* An EPP flow that checks whether a domain can be provisioned.
|
||||
@@ -156,7 +156,7 @@ public final class DomainCheckFlow implements TransactionalFlow {
|
||||
extensionManager.validate();
|
||||
ImmutableList<String> domainNames = ((Check) resourceCommand).getTargetIds();
|
||||
verifyTargetIdCount(domainNames, maxChecks);
|
||||
DateTime now = clock.nowUtc();
|
||||
Instant now = clock.now();
|
||||
ImmutableMap.Builder<String, InternetDomainName> parsedDomainsBuilder =
|
||||
new ImmutableMap.Builder<>();
|
||||
// Only check that the registrar has access to a TLD the first time it is encountered
|
||||
@@ -225,7 +225,7 @@ public final class DomainCheckFlow implements TransactionalFlow {
|
||||
ImmutableSet<InternetDomainName> bsaBlockedDomainNames,
|
||||
ImmutableMap<String, TldState> tldStates,
|
||||
ImmutableMap<String, InternetDomainName> parsedDomains,
|
||||
DateTime now)
|
||||
Instant now)
|
||||
throws EppException {
|
||||
InternetDomainName idn = parsedDomains.get(domainName);
|
||||
Optional<AllocationToken> token;
|
||||
@@ -286,7 +286,7 @@ public final class DomainCheckFlow implements TransactionalFlow {
|
||||
ImmutableMap<String, InternetDomainName> domainNames,
|
||||
ImmutableMap<String, VKey<Domain>> existingDomains,
|
||||
ImmutableSet<String> availableDomains,
|
||||
DateTime now)
|
||||
Instant now)
|
||||
throws EppException {
|
||||
Optional<FeeCheckCommandExtension> feeCheckOpt =
|
||||
eppInput.getSingleExtension(FeeCheckCommandExtension.class);
|
||||
@@ -480,7 +480,7 @@ public final class DomainCheckFlow implements TransactionalFlow {
|
||||
}
|
||||
|
||||
static ImmutableSet<InternetDomainName> getBsaBlockedDomains(
|
||||
ImmutableCollection<InternetDomainName> parsedDomains, DateTime now) {
|
||||
ImmutableCollection<InternetDomainName> parsedDomains, Instant now) {
|
||||
Map<String, ImmutableList<InternetDomainName>> labelToDomainNames =
|
||||
parsedDomains.stream()
|
||||
.filter(
|
||||
|
||||
@@ -49,10 +49,10 @@ import google.registry.model.tld.Tld;
|
||||
import google.registry.model.tmch.ClaimsListDao;
|
||||
import google.registry.util.Clock;
|
||||
import jakarta.inject.Inject;
|
||||
import java.time.Instant;
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* An EPP flow that checks whether domain labels are trademarked.
|
||||
@@ -103,7 +103,7 @@ public final class DomainClaimsCheckFlow implements TransactionalFlow {
|
||||
checkAllowedAccessToTld(registrarId, tldStr);
|
||||
checkHasBillingAccount(registrarId, tldStr);
|
||||
Tld tld = Tld.get(tldStr);
|
||||
DateTime now = clock.nowUtc();
|
||||
Instant now = clock.now();
|
||||
verifyNotInPredelegation(tld, now);
|
||||
verifyClaimsPeriodNotEnded(tld, now);
|
||||
}
|
||||
|
||||
@@ -121,6 +121,7 @@ import google.registry.model.tmch.ClaimsList;
|
||||
import google.registry.model.tmch.ClaimsListDao;
|
||||
import google.registry.tmch.LordnTaskUtils.LordnPhase;
|
||||
import jakarta.inject.Inject;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
@@ -236,7 +237,7 @@ public final class DomainCreateFlow implements MutatingFlow {
|
||||
verifyRegistrarIsActive(registrarId);
|
||||
extensionManager.validate();
|
||||
verifyDomainDoesNotExist();
|
||||
DateTime now = tm().getTransactionTime();
|
||||
Instant now = tm().getTxTime();
|
||||
DomainCommand.Create command = cloneAndLinkReferences((Create) resourceCommand, now);
|
||||
Period period = command.getPeriod();
|
||||
verifyUnitIsYears(period);
|
||||
@@ -314,7 +315,7 @@ public final class DomainCreateFlow implements MutatingFlow {
|
||||
// at this point so that we can verify it before the "after validation" extension point.
|
||||
signedMarkId =
|
||||
tmchUtils
|
||||
.verifySignedMarks(launchCreate.get().getSignedMarks(), domainLabel, toInstant(now))
|
||||
.verifySignedMarks(launchCreate.get().getSignedMarks(), domainLabel, now)
|
||||
.getId();
|
||||
}
|
||||
verifyNotBlockedByBsa(domainName, tld, now, allocationToken);
|
||||
@@ -328,11 +329,11 @@ public final class DomainCreateFlow implements MutatingFlow {
|
||||
eppInput.getSingleExtension(FeeCreateCommandExtension.class);
|
||||
FeesAndCredits feesAndCredits =
|
||||
pricingLogic.getCreatePrice(
|
||||
tld, targetId, toInstant(now), years, isAnchorTenant, isSunriseCreate, allocationToken);
|
||||
tld, targetId, now, years, isAnchorTenant, isSunriseCreate, allocationToken);
|
||||
validateFeeChallenge(feeCreate, feesAndCredits, defaultTokenUsed);
|
||||
Optional<SecDnsCreateExtension> secDnsCreate =
|
||||
validateSecDnsExtension(eppInput.getSingleExtension(SecDnsCreateExtension.class));
|
||||
DateTime registrationExpirationTime = plusYears(now, years);
|
||||
Instant registrationExpirationTime = plusYears(now, years);
|
||||
String repoId = createDomainRepoId(tm().allocateId(), tld.getTldStr());
|
||||
long historyRevisionId = tm().allocateId();
|
||||
HistoryEntryId domainHistoryId = new HistoryEntryId(repoId, historyRevisionId);
|
||||
@@ -373,7 +374,7 @@ public final class DomainCreateFlow implements MutatingFlow {
|
||||
.setPersistedCurrentSponsorRegistrarId(registrarId)
|
||||
.setRepoId(repoId)
|
||||
.setIdnTableName(validateDomainNameWithIdnTables(domainName))
|
||||
.setRegistrationExpirationTime(toInstant(registrationExpirationTime))
|
||||
.setRegistrationExpirationTime(registrationExpirationTime)
|
||||
.setAutorenewBillingEvent(autorenewBillingEvent.createVKey())
|
||||
.setAutorenewPollMessage(autorenewPollMessage.createVKey())
|
||||
.setLaunchNotice(hasClaimsNotice ? launchCreate.get().getNotice() : null)
|
||||
@@ -435,21 +436,13 @@ public final class DomainCreateFlow implements MutatingFlow {
|
||||
FeesAndCredits responseFeesAndCredits =
|
||||
shouldShowDefaultPrice
|
||||
? pricingLogic.getCreatePrice(
|
||||
tld,
|
||||
targetId,
|
||||
toInstant(now),
|
||||
years,
|
||||
isAnchorTenant,
|
||||
isSunriseCreate,
|
||||
Optional.empty())
|
||||
tld, targetId, now, years, isAnchorTenant, isSunriseCreate, Optional.empty())
|
||||
: feesAndCredits;
|
||||
|
||||
BeforeResponseReturnData responseData =
|
||||
flowCustomLogic.beforeResponse(
|
||||
BeforeResponseParameters.newBuilder()
|
||||
.setResData(
|
||||
DomainCreateData.create(
|
||||
targetId, toInstant(now), toInstant(registrationExpirationTime)))
|
||||
.setResData(DomainCreateData.create(targetId, now, registrationExpirationTime))
|
||||
.setResponseExtensions(createResponseExtensions(feeCreate, responseFeesAndCredits))
|
||||
.build());
|
||||
return responseBuilder
|
||||
@@ -501,7 +494,7 @@ public final class DomainCreateFlow implements MutatingFlow {
|
||||
private void verifyIsGaOrSpecialCase(
|
||||
Tld tld,
|
||||
ClaimsList claimsList,
|
||||
DateTime now,
|
||||
Instant now,
|
||||
String domainLabel,
|
||||
Optional<AllocationToken> allocationToken,
|
||||
boolean isAnchorTenant,
|
||||
@@ -565,14 +558,14 @@ public final class DomainCreateFlow implements MutatingFlow {
|
||||
}
|
||||
|
||||
private DomainHistory buildDomainHistory(
|
||||
Domain domain, Tld tld, DateTime now, Period period, Duration addGracePeriod) {
|
||||
Domain domain, Tld tld, Instant now, Period period, Duration addGracePeriod) {
|
||||
// We ignore prober transactions
|
||||
if (tld.getTldType() == TldType.REAL) {
|
||||
historyBuilder.setDomainTransactionRecords(
|
||||
ImmutableSet.of(
|
||||
DomainTransactionRecord.create(
|
||||
tld.getTldStr(),
|
||||
toInstant(now.plus(addGracePeriod)),
|
||||
now.plusMillis(addGracePeriod.getMillis()),
|
||||
TransactionReportField.netAddsFieldFromYears(period.getValue()),
|
||||
1)));
|
||||
}
|
||||
@@ -588,7 +581,7 @@ public final class DomainCreateFlow implements MutatingFlow {
|
||||
FeesAndCredits feesAndCredits,
|
||||
HistoryEntryId domainHistoryId,
|
||||
Optional<AllocationToken> allocationToken,
|
||||
DateTime now) {
|
||||
Instant now) {
|
||||
ImmutableSet.Builder<Flag> flagsBuilder = new ImmutableSet.Builder<>();
|
||||
// Sunrise and anchor tenancy are orthogonal tags and thus both can be present together.
|
||||
if (isSunriseCreate) {
|
||||
@@ -607,14 +600,14 @@ public final class DomainCreateFlow implements MutatingFlow {
|
||||
.setRegistrarId(registrarId)
|
||||
.setPeriodYears(years)
|
||||
.setCost(feesAndCredits.getCreateCost())
|
||||
.setEventTime(toInstant(now))
|
||||
.setEventTime(now)
|
||||
.setAllocationToken(allocationToken.map(AllocationToken::createVKey).orElse(null))
|
||||
.setBillingTime(
|
||||
toInstant(
|
||||
now.plus(
|
||||
isAnchorTenant
|
||||
now.plusMillis(
|
||||
(isAnchorTenant
|
||||
? tld.getAnchorTenantAddGracePeriodLength()
|
||||
: tld.getAddGracePeriodLength())))
|
||||
: tld.getAddGracePeriodLength())
|
||||
.getMillis()))
|
||||
.setFlags(flagsBuilder.build())
|
||||
.setDomainHistoryId(domainHistoryId)
|
||||
.build();
|
||||
@@ -622,7 +615,7 @@ public final class DomainCreateFlow implements MutatingFlow {
|
||||
|
||||
private BillingRecurrence createAutorenewBillingEvent(
|
||||
HistoryEntryId domainHistoryId,
|
||||
DateTime registrationExpirationTime,
|
||||
Instant registrationExpirationTime,
|
||||
boolean isAnchorTenant,
|
||||
Optional<AllocationToken> allocationToken) {
|
||||
// Non-standard renewal behaviors can occur for anchor tenants (always NONPREMIUM pricing) or if
|
||||
@@ -639,7 +632,7 @@ public final class DomainCreateFlow implements MutatingFlow {
|
||||
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
|
||||
.setTargetId(targetId)
|
||||
.setRegistrarId(registrarId)
|
||||
.setEventTime(toInstant(registrationExpirationTime))
|
||||
.setEventTime(registrationExpirationTime)
|
||||
.setRecurrenceEndTime(END_INSTANT)
|
||||
.setDomainHistoryId(domainHistoryId)
|
||||
.setRenewalPriceBehavior(renewalPriceBehavior)
|
||||
@@ -648,11 +641,11 @@ public final class DomainCreateFlow implements MutatingFlow {
|
||||
}
|
||||
|
||||
private Autorenew createAutorenewPollMessage(
|
||||
HistoryEntryId domainHistoryId, DateTime registrationExpirationTime) {
|
||||
HistoryEntryId domainHistoryId, Instant registrationExpirationTime) {
|
||||
return new PollMessage.Autorenew.Builder()
|
||||
.setTargetId(targetId)
|
||||
.setRegistrarId(registrarId)
|
||||
.setEventTime(toInstant(registrationExpirationTime))
|
||||
.setEventTime(registrationExpirationTime)
|
||||
.setMsg("Domain was auto-renewed.")
|
||||
.setDomainHistoryId(domainHistoryId)
|
||||
.build();
|
||||
@@ -662,7 +655,7 @@ public final class DomainCreateFlow implements MutatingFlow {
|
||||
Optional<DateTime> previousDeletionTime =
|
||||
domainDeletionTimeCache.getDeletionTimeForDomain(targetId);
|
||||
if (previousDeletionTime.isPresent()
|
||||
&& !tm().getTransactionTime().isAfter(previousDeletionTime.get())) {
|
||||
&& !tm().getTxTime().isAfter(toInstant(previousDeletionTime.get()))) {
|
||||
throw new ResourceCreateContentionException(targetId);
|
||||
}
|
||||
}
|
||||
@@ -683,10 +676,10 @@ public final class DomainCreateFlow implements MutatingFlow {
|
||||
}
|
||||
|
||||
private static PollMessage.OneTime createNameCollisionOneTimePollMessage(
|
||||
String domainName, HistoryEntry historyEntry, String registrarId, DateTime now) {
|
||||
String domainName, HistoryEntry historyEntry, String registrarId, Instant now) {
|
||||
return new PollMessage.OneTime.Builder()
|
||||
.setRegistrarId(registrarId)
|
||||
.setEventTime(toInstant(now))
|
||||
.setEventTime(now)
|
||||
.setMsg(COLLISION_MESSAGE) // Remind the registrar of the name collision policy.
|
||||
.setResponseData(
|
||||
ImmutableList.of(
|
||||
|
||||
@@ -100,6 +100,8 @@ import google.registry.model.tld.Tld;
|
||||
import google.registry.model.tld.Tld.TldType;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import jakarta.inject.Inject;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@@ -147,7 +149,7 @@ public final class DomainDeleteFlow implements MutatingFlow, SqlStatementLogging
|
||||
flowCustomLogic.beforeValidation();
|
||||
validateRegistrarIsLoggedIn(registrarId);
|
||||
extensionManager.validate();
|
||||
DateTime now = tm().getTransactionTime();
|
||||
Instant now = tm().getTxTime();
|
||||
// Loads the target resource if it exists
|
||||
Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now);
|
||||
Tld tld = Tld.get(existingDomain.getTld());
|
||||
@@ -163,7 +165,7 @@ public final class DomainDeleteFlow implements MutatingFlow, SqlStatementLogging
|
||||
} else {
|
||||
builder = existingDomain.asBuilder();
|
||||
}
|
||||
builder.setLastEppUpdateTime(toInstant(now)).setLastEppUpdateRegistrarId(registrarId);
|
||||
builder.setLastEppUpdateTime(now).setLastEppUpdateRegistrarId(registrarId);
|
||||
Duration redemptionGracePeriodLength = tld.getRedemptionGracePeriodLength();
|
||||
Duration pendingDeleteLength = tld.getPendingDeleteLength();
|
||||
Optional<DomainDeleteSuperuserExtension> domainDeleteSuperuserExtension =
|
||||
@@ -186,15 +188,17 @@ public final class DomainDeleteFlow implements MutatingFlow, SqlStatementLogging
|
||||
: redemptionGracePeriodLength.plus(pendingDeleteLength);
|
||||
HistoryEntryId domainHistoryId = createHistoryEntryId(existingDomain);
|
||||
historyBuilder.setRevisionId(domainHistoryId.getRevisionId());
|
||||
DateTime deletionTime = now.plus(durationUntilDelete);
|
||||
Instant deletionTime = now.plusMillis(durationUntilDelete.getMillis());
|
||||
if (durationUntilDelete.equals(Duration.ZERO)) {
|
||||
builder.setDeletionTime(toInstant(now)).setStatusValues(null);
|
||||
builder.setDeletionTime(now).setStatusValues(null);
|
||||
} else {
|
||||
DateTime redemptionTime = now.plus(redemptionGracePeriodLength);
|
||||
Instant redemptionTime = now.plusMillis(redemptionGracePeriodLength.getMillis());
|
||||
asyncTaskEnqueuer.enqueueAsyncResave(
|
||||
existingDomain.createVKey(), now, ImmutableSortedSet.of(redemptionTime, deletionTime));
|
||||
existingDomain.createVKey(),
|
||||
toDateTime(now),
|
||||
ImmutableSortedSet.of(toDateTime(redemptionTime), toDateTime(deletionTime)));
|
||||
builder
|
||||
.setDeletionTime(toInstant(deletionTime))
|
||||
.setDeletionTime(deletionTime)
|
||||
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
|
||||
// Clear out all old grace periods and add REDEMPTION, which does not include a key to a
|
||||
// billing event because there isn't one for a domain delete.
|
||||
@@ -203,7 +207,7 @@ public final class DomainDeleteFlow implements MutatingFlow, SqlStatementLogging
|
||||
GracePeriod.createWithoutBillingEvent(
|
||||
GracePeriodStatus.REDEMPTION,
|
||||
existingDomain.getRepoId(),
|
||||
toInstant(redemptionTime),
|
||||
redemptionTime,
|
||||
registrarId)));
|
||||
// Note: The expiration time is unchanged, so if it's before the new deletion time, there will
|
||||
// be a "phantom autorenew" where the expiration time advances. No poll message will be
|
||||
@@ -238,26 +242,29 @@ public final class DomainDeleteFlow implements MutatingFlow, SqlStatementLogging
|
||||
}
|
||||
|
||||
// Cancel any grace periods that were still active, and set the expiration time accordingly.
|
||||
DateTime newExpirationTime = toDateTime(existingDomain.getRegistrationExpirationTime());
|
||||
Instant newExpirationTime = existingDomain.getRegistrationExpirationTime();
|
||||
for (GracePeriod gracePeriod : existingDomain.getGracePeriods()) {
|
||||
// No cancellation is written if the grace period was not for a billable event.
|
||||
if (gracePeriod.hasBillingEvent()) {
|
||||
entitiesToInsert.add(
|
||||
BillingCancellation.forGracePeriod(
|
||||
gracePeriod, toInstant(now), domainHistoryId, targetId));
|
||||
BillingCancellation.forGracePeriod(gracePeriod, now, domainHistoryId, targetId));
|
||||
if (gracePeriod.getBillingEvent() != null) {
|
||||
// Take the amount of registration time being refunded off the expiration time.
|
||||
// This can be either add grace periods or renew grace periods.
|
||||
BillingEvent billingEvent = tm().loadByKey(gracePeriod.getBillingEvent());
|
||||
newExpirationTime = newExpirationTime.minusYears(billingEvent.getPeriodYears());
|
||||
newExpirationTime =
|
||||
newExpirationTime
|
||||
.atZone(ZoneOffset.UTC)
|
||||
.minusYears(billingEvent.getPeriodYears())
|
||||
.toInstant();
|
||||
} else if (gracePeriod.getBillingRecurrence() != null) {
|
||||
// Take 1 year off the registration if in the autorenew grace period (no need to load the
|
||||
// recurrence billing event; all autorenews are for 1 year).
|
||||
newExpirationTime = newExpirationTime.minusYears(1);
|
||||
newExpirationTime = newExpirationTime.atZone(ZoneOffset.UTC).minusYears(1).toInstant();
|
||||
}
|
||||
}
|
||||
}
|
||||
builder.setRegistrationExpirationTime(toInstant(newExpirationTime));
|
||||
builder.setRegistrationExpirationTime(newExpirationTime);
|
||||
|
||||
Domain newDomain = builder.build();
|
||||
DomainHistory domainHistory =
|
||||
@@ -292,7 +299,7 @@ public final class DomainDeleteFlow implements MutatingFlow, SqlStatementLogging
|
||||
flowCustomLogic.beforeResponse(
|
||||
BeforeResponseParameters.newBuilder()
|
||||
.setResultCode(
|
||||
newDomain.getDeletionTime().isAfter(toInstant(now))
|
||||
newDomain.getDeletionTime().isAfter(now)
|
||||
? SUCCESS_WITH_ACTION_PENDING
|
||||
: SUCCESS)
|
||||
.setResponseExtensions(
|
||||
@@ -305,7 +312,7 @@ public final class DomainDeleteFlow implements MutatingFlow, SqlStatementLogging
|
||||
.build();
|
||||
}
|
||||
|
||||
private void verifyDeleteAllowed(Domain existingDomain, Tld tld, DateTime now)
|
||||
private void verifyDeleteAllowed(Domain existingDomain, Tld tld, Instant now)
|
||||
throws EppException {
|
||||
verifyOptionalAuthInfo(authInfo, existingDomain);
|
||||
verifyNoDisallowedStatuses(existingDomain, ImmutableSet.of(StatusValue.PENDING_DELETE));
|
||||
@@ -321,11 +328,7 @@ public final class DomainDeleteFlow implements MutatingFlow, SqlStatementLogging
|
||||
}
|
||||
|
||||
private DomainHistory buildDomainHistory(
|
||||
Domain domain,
|
||||
Tld tld,
|
||||
DateTime now,
|
||||
Duration durationUntilDelete,
|
||||
boolean inAddGracePeriod) {
|
||||
Domain domain, Tld tld, Instant now, Duration durationUntilDelete, boolean inAddGracePeriod) {
|
||||
// We ignore prober transactions
|
||||
if (tld.getTldType() == TldType.REAL) {
|
||||
Duration maxGracePeriod =
|
||||
@@ -345,7 +348,7 @@ public final class DomainDeleteFlow implements MutatingFlow, SqlStatementLogging
|
||||
cancelledRecords,
|
||||
DomainTransactionRecord.create(
|
||||
domain.getTld(),
|
||||
toInstant(now.plus(durationUntilDelete)),
|
||||
now.plusMillis(durationUntilDelete.getMillis()),
|
||||
inAddGracePeriod
|
||||
? TransactionReportField.DELETED_DOMAINS_GRACE
|
||||
: TransactionReportField.DELETED_DOMAINS_NOGRACE,
|
||||
@@ -355,7 +358,7 @@ public final class DomainDeleteFlow implements MutatingFlow, SqlStatementLogging
|
||||
}
|
||||
|
||||
private PollMessage.OneTime createDeletePollMessage(
|
||||
Domain existingDomain, HistoryEntryId domainHistoryId, DateTime deletionTime) {
|
||||
Domain existingDomain, HistoryEntryId domainHistoryId, Instant deletionTime) {
|
||||
Optional<MetadataExtension> metadataExtension =
|
||||
eppInput.getSingleExtension(MetadataExtension.class);
|
||||
boolean hasMetadataMessage =
|
||||
@@ -379,10 +382,10 @@ public final class DomainDeleteFlow implements MutatingFlow, SqlStatementLogging
|
||||
}
|
||||
|
||||
private PollMessage.OneTime createImmediateDeletePollMessage(
|
||||
Domain existingDomain, HistoryEntryId domainHistoryId, DateTime now, DateTime deletionTime) {
|
||||
Domain existingDomain, HistoryEntryId domainHistoryId, Instant now, Instant deletionTime) {
|
||||
return new PollMessage.OneTime.Builder()
|
||||
.setRegistrarId(existingDomain.getPersistedCurrentSponsorRegistrarId())
|
||||
.setEventTime(toInstant(now))
|
||||
.setEventTime(now)
|
||||
.setDomainHistoryId(domainHistoryId)
|
||||
.setMsg(
|
||||
String.format(
|
||||
@@ -397,7 +400,7 @@ public final class DomainDeleteFlow implements MutatingFlow, SqlStatementLogging
|
||||
|
||||
@Nullable
|
||||
private ImmutableList<FeeTransformResponseExtension> getResponseExtensions(
|
||||
BillingRecurrence billingRecurrence, Domain existingDomain, DateTime now) {
|
||||
BillingRecurrence billingRecurrence, Domain existingDomain, Instant now) {
|
||||
FeeTransformResponseExtension.Builder feeResponseBuilder = getDeleteResponseBuilder();
|
||||
if (feeResponseBuilder == null) {
|
||||
return ImmutableList.of();
|
||||
@@ -419,14 +422,11 @@ public final class DomainDeleteFlow implements MutatingFlow, SqlStatementLogging
|
||||
}
|
||||
|
||||
private Money getGracePeriodCost(
|
||||
BillingRecurrence billingRecurrence, GracePeriod gracePeriod, DateTime now) {
|
||||
BillingRecurrence billingRecurrence, GracePeriod gracePeriod, Instant now) {
|
||||
if (gracePeriod.getType() == GracePeriodStatus.AUTO_RENEW) {
|
||||
// If we updated the autorenew billing event, reuse it.
|
||||
DateTime autoRenewTime =
|
||||
toDateTime(
|
||||
billingRecurrence
|
||||
.getRecurrenceTimeOfYear()
|
||||
.getLastInstanceBeforeOrAt(toInstant(now)));
|
||||
toDateTime(billingRecurrence.getRecurrenceTimeOfYear().getLastInstanceBeforeOrAt(now));
|
||||
return getDomainRenewCost(targetId, toInstant(autoRenewTime), 1);
|
||||
}
|
||||
return tm().loadByKey(checkNotNull(gracePeriod.getBillingEvent())).getCost();
|
||||
|
||||
@@ -42,8 +42,7 @@ import static google.registry.pricing.PricingEngineProxy.isDomainPremium;
|
||||
import static google.registry.util.CollectionUtils.nullToEmpty;
|
||||
import static google.registry.util.DateTimeUtils.END_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.isAtOrAfter;
|
||||
import static google.registry.util.DateTimeUtils.plusYears;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
import static google.registry.util.DateTimeUtils.minusDays;
|
||||
import static google.registry.util.DomainNameUtils.ACE_PREFIX;
|
||||
import static java.util.stream.Collectors.joining;
|
||||
|
||||
@@ -125,6 +124,7 @@ import google.registry.tools.DigestType;
|
||||
import google.registry.util.Idn;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
@@ -133,7 +133,6 @@ import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.xbill.DNS.DNSSEC.Algorithm;
|
||||
|
||||
@@ -253,7 +252,7 @@ public class DomainFlowUtils {
|
||||
public static void verifyNotBlockedByBsa(
|
||||
InternetDomainName domainName,
|
||||
Tld tld,
|
||||
DateTime now,
|
||||
Instant now,
|
||||
Optional<AllocationToken> allocationToken)
|
||||
throws DomainLabelBlockedByBsaException {
|
||||
if (!isRegisterBsaCreate(domainName, allocationToken)
|
||||
@@ -262,7 +261,7 @@ public class DomainFlowUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isBlockedByBsa(String domainLabel, Tld tld, DateTime now) {
|
||||
public static boolean isBlockedByBsa(String domainLabel, Tld tld, Instant now) {
|
||||
return isEnrolledWithBsa(tld, now) && isLabelBlocked(domainLabel);
|
||||
}
|
||||
|
||||
@@ -458,7 +457,7 @@ public class DomainFlowUtils {
|
||||
|
||||
/** Verifies that a launch extension's specified phase matches the specified tld's phase. */
|
||||
static void verifyLaunchPhaseMatchesRegistryPhase(
|
||||
Tld tld, LaunchExtension launchExtension, DateTime now) throws EppException {
|
||||
Tld tld, LaunchExtension launchExtension, Instant now) throws EppException {
|
||||
if (!LAUNCH_PHASE_TO_TLD_STATES.containsKey(launchExtension.getPhase())
|
||||
|| !LAUNCH_PHASE_TO_TLD_STATES
|
||||
.get(launchExtension.getPhase())
|
||||
@@ -474,8 +473,8 @@ public class DomainFlowUtils {
|
||||
* this registrar.
|
||||
*/
|
||||
static void verifyPremiumNameIsNotBlocked(
|
||||
String domainName, DateTime priceTime, String registrarId) throws EppException {
|
||||
if (isDomainPremium(domainName, toInstant(priceTime))) {
|
||||
String domainName, Instant priceTime, String registrarId) throws EppException {
|
||||
if (isDomainPremium(domainName, priceTime)) {
|
||||
if (Registrar.loadByRegistrarIdCached(registrarId).get().getBlockPremiumNames()) {
|
||||
throw new PremiumNameBlockedException();
|
||||
}
|
||||
@@ -486,10 +485,10 @@ public class DomainFlowUtils {
|
||||
* Helper to call {@link CreateOrUpdate#cloneAndLinkReferences} and convert exceptions to
|
||||
* EppExceptions, since this is needed in several places.
|
||||
*/
|
||||
static <T extends CreateOrUpdate<T>> T cloneAndLinkReferences(T command, DateTime now)
|
||||
static <T extends CreateOrUpdate<T>> T cloneAndLinkReferences(T command, Instant now)
|
||||
throws EppException {
|
||||
try {
|
||||
return command.cloneAndLinkReferences(toInstant(now));
|
||||
return command.cloneAndLinkReferences(now);
|
||||
} catch (InvalidReferencesException e) {
|
||||
throw new LinkedResourcesDoNotExistException(e.getType(), e.getForeignKeys());
|
||||
}
|
||||
@@ -532,7 +531,7 @@ public class DomainFlowUtils {
|
||||
public static BillingRecurrence updateAutorenewRecurrenceEndTime(
|
||||
Domain domain,
|
||||
BillingRecurrence existingBillingRecurrence,
|
||||
DateTime newEndTime,
|
||||
Instant newEndTime,
|
||||
@Nullable HistoryEntryId historyId) {
|
||||
Optional<Autorenew> autorenewPollMessage =
|
||||
tm().loadByKeyIfPresent(domain.getAutorenewPollMessage());
|
||||
@@ -560,14 +559,14 @@ public class DomainFlowUtils {
|
||||
|
||||
// If the resultant autorenew poll message would have no poll messages to deliver, then just
|
||||
// delete it. Otherwise, save it with the new end time.
|
||||
if (isAtOrAfter(updatedAutorenewPollMessage.getEventTime(), toInstant(newEndTime))) {
|
||||
if (isAtOrAfter(updatedAutorenewPollMessage.getEventTime(), newEndTime)) {
|
||||
autorenewPollMessage.ifPresent(autorenew -> tm().delete(autorenew));
|
||||
} else {
|
||||
tm().put(updatedAutorenewPollMessage);
|
||||
}
|
||||
|
||||
BillingRecurrence newBillingRecurrence =
|
||||
existingBillingRecurrence.asBuilder().setRecurrenceEndTime(toInstant(newEndTime)).build();
|
||||
existingBillingRecurrence.asBuilder().setRecurrenceEndTime(newEndTime).build();
|
||||
tm().update(newBillingRecurrence);
|
||||
return newBillingRecurrence;
|
||||
}
|
||||
@@ -582,13 +581,13 @@ public class DomainFlowUtils {
|
||||
InternetDomainName domainName,
|
||||
Optional<Domain> domain,
|
||||
@Nullable CurrencyUnit topLevelCurrency,
|
||||
DateTime currentDate,
|
||||
Instant currentDate,
|
||||
DomainPricingLogic pricingLogic,
|
||||
Optional<AllocationToken> allocationToken,
|
||||
boolean isAvailable,
|
||||
@Nullable BillingRecurrence billingRecurrence)
|
||||
throws EppException {
|
||||
Instant now = toInstant(currentDate);
|
||||
Instant now = currentDate;
|
||||
// Use the custom effective date specified in the fee check request, if there is one.
|
||||
if (feeRequest.getEffectiveDate().isPresent()) {
|
||||
now = feeRequest.getEffectiveDate().get();
|
||||
@@ -847,9 +846,12 @@ public class DomainFlowUtils {
|
||||
*
|
||||
* @throws ExceedsMaxRegistrationYearsException if the new registration period is too long
|
||||
*/
|
||||
public static void validateRegistrationPeriod(DateTime now, DateTime newExpirationTime)
|
||||
public static void validateRegistrationPeriod(Instant now, Instant newExpirationTime)
|
||||
throws EppException {
|
||||
if (plusYears(now, MAX_REGISTRATION_YEARS).isBefore(newExpirationTime)) {
|
||||
if (now.atZone(ZoneOffset.UTC)
|
||||
.plusYears(MAX_REGISTRATION_YEARS)
|
||||
.toInstant()
|
||||
.isBefore(newExpirationTime)) {
|
||||
throw new ExceedsMaxRegistrationYearsException();
|
||||
}
|
||||
}
|
||||
@@ -935,7 +937,7 @@ public class DomainFlowUtils {
|
||||
}
|
||||
|
||||
/** Check that the registry phase is not predelegation, during which some flows are forbidden. */
|
||||
public static void verifyNotInPredelegation(Tld registry, DateTime now)
|
||||
public static void verifyNotInPredelegation(Tld registry, Instant now)
|
||||
throws BadCommandForRegistryPhaseException {
|
||||
if (registry.getTldState(now) == PREDELEGATION) {
|
||||
throw new BadCommandForRegistryPhaseException();
|
||||
@@ -970,7 +972,7 @@ public class DomainFlowUtils {
|
||||
|
||||
/** Validate the notice from a launch create extension, allowing null as a valid notice. */
|
||||
static void validateLaunchCreateNotice(
|
||||
@Nullable LaunchNotice notice, String domainLabel, boolean isSuperuser, DateTime now)
|
||||
@Nullable LaunchNotice notice, String domainLabel, boolean isSuperuser, Instant now)
|
||||
throws EppException {
|
||||
if (notice == null) {
|
||||
return;
|
||||
@@ -980,11 +982,11 @@ public class DomainFlowUtils {
|
||||
}
|
||||
// Superuser can force domain creations regardless of the current date.
|
||||
if (!isSuperuser) {
|
||||
if (notice.getExpirationTime().isBefore(toInstant(now))) {
|
||||
if (notice.getExpirationTime().isBefore(now)) {
|
||||
throw new ExpiredClaimException();
|
||||
}
|
||||
// An acceptance within the past 48 hours is mandated by the TMCH Functional Spec.
|
||||
if (notice.getAcceptedTime().isBefore(toInstant(now.minusHours(48)))) {
|
||||
if (notice.getAcceptedTime().isBefore(minusDays(now, 2))) {
|
||||
throw new AcceptedTooLongAgoException();
|
||||
}
|
||||
}
|
||||
@@ -998,8 +1000,8 @@ public class DomainFlowUtils {
|
||||
}
|
||||
|
||||
/** Check that the claims period hasn't ended. */
|
||||
static void verifyClaimsPeriodNotEnded(Tld tld, DateTime now) throws ClaimsPeriodEndedException {
|
||||
if (isAtOrAfter(now, tld.getClaimsPeriodEnd())) {
|
||||
static void verifyClaimsPeriodNotEnded(Tld tld, Instant now) throws ClaimsPeriodEndedException {
|
||||
if (!now.isBefore(tld.getClaimsPeriodEnd())) {
|
||||
throw new ClaimsPeriodEndedException(tld.getTldStr());
|
||||
}
|
||||
}
|
||||
@@ -1066,7 +1068,7 @@ public class DomainFlowUtils {
|
||||
*/
|
||||
public static ImmutableSet<DomainTransactionRecord> createCancelingRecords(
|
||||
Domain domain,
|
||||
final DateTime now,
|
||||
Instant now,
|
||||
Duration maxSearchPeriod,
|
||||
final ImmutableSet<TransactionReportField> cancelableFields) {
|
||||
|
||||
@@ -1081,7 +1083,7 @@ public class DomainFlowUtils {
|
||||
for (DomainTransactionRecord record :
|
||||
historyEntry.getDomainTransactionRecords()) {
|
||||
if (cancelableFields.contains(record.getReportField())
|
||||
&& record.getReportingTime().isAfter(toInstant(now))) {
|
||||
&& record.getReportingTime().isAfter(now)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1110,12 +1112,12 @@ public class DomainFlowUtils {
|
||||
}
|
||||
|
||||
private static List<DomainHistory> findRecentHistoryEntries(
|
||||
Domain domain, DateTime now, Duration maxSearchPeriod) {
|
||||
Domain domain, Instant now, Duration maxSearchPeriod) {
|
||||
return tm().query(
|
||||
"FROM DomainHistory WHERE modificationTime >= :beginning AND repoId = "
|
||||
+ ":repoId ORDER BY modificationTime ASC",
|
||||
DomainHistory.class)
|
||||
.setParameter("beginning", toInstant(now.minus(maxSearchPeriod)))
|
||||
.setParameter("beginning", now.minusMillis(maxSearchPeriod.getMillis()))
|
||||
.setParameter("repoId", domain.getRepoId())
|
||||
.getResultList();
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@ import google.registry.persistence.IsolationLevel;
|
||||
import google.registry.persistence.PersistenceModule;
|
||||
import google.registry.util.Clock;
|
||||
import jakarta.inject.Inject;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* An EPP flow that returns information about a domain.
|
||||
@@ -105,7 +105,7 @@ public final class DomainInfoFlow implements MutatingFlow {
|
||||
flowCustomLogic.beforeValidation();
|
||||
validateRegistrarIsLoggedIn(registrarId);
|
||||
extensionManager.validate();
|
||||
DateTime now = clock.nowUtc();
|
||||
Instant now = clock.now();
|
||||
Domain domain = loadAndVerifyExistence(Domain.class, targetId, now);
|
||||
verifyOptionalAuthInfo(authInfo, domain);
|
||||
flowCustomLogic.afterValidation(
|
||||
@@ -149,7 +149,7 @@ public final class DomainInfoFlow implements MutatingFlow {
|
||||
.build();
|
||||
}
|
||||
|
||||
private ImmutableList<ResponseExtension> getDomainResponseExtensions(Domain domain, DateTime now)
|
||||
private ImmutableList<ResponseExtension> getDomainResponseExtensions(Domain domain, Instant now)
|
||||
throws EppException {
|
||||
ImmutableList.Builder<ResponseExtension> extensions = new ImmutableList.Builder<>();
|
||||
addSecDnsExtensionIfPresent(extensions, domain.getDsData());
|
||||
|
||||
@@ -18,7 +18,6 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.zeroInCurrency;
|
||||
import static google.registry.flows.domain.token.AllocationTokenFlowUtils.discountTokenInvalidForPremiumName;
|
||||
import static google.registry.pricing.PricingEngineProxy.getPricesForDomainName;
|
||||
import static google.registry.util.DateTimeUtils.toDateTime;
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentPresent;
|
||||
|
||||
import com.google.common.net.InternetDomainName;
|
||||
@@ -117,7 +116,7 @@ public final class DomainPricingLogic {
|
||||
.setFeesAndCredits(feesBuilder.build())
|
||||
.setTld(tld)
|
||||
.setDomainName(InternetDomainName.from(domainName))
|
||||
.setAsOfDate(toDateTime(dateTime))
|
||||
.setAsOfDate(dateTime)
|
||||
.setYears(years)
|
||||
.build());
|
||||
}
|
||||
@@ -188,7 +187,7 @@ public final class DomainPricingLogic {
|
||||
.build())
|
||||
.setTld(tld)
|
||||
.setDomainName(InternetDomainName.from(domainName))
|
||||
.setAsOfDate(toDateTime(dateTime))
|
||||
.setAsOfDate(dateTime)
|
||||
.setYears(years)
|
||||
.build());
|
||||
}
|
||||
@@ -212,7 +211,7 @@ public final class DomainPricingLogic {
|
||||
.setFeesAndCredits(feesAndCredits.build())
|
||||
.setTld(tld)
|
||||
.setDomainName(InternetDomainName.from(domainName))
|
||||
.setAsOfDate(toDateTime(dateTime))
|
||||
.setAsOfDate(dateTime)
|
||||
.build());
|
||||
}
|
||||
|
||||
@@ -235,7 +234,7 @@ public final class DomainPricingLogic {
|
||||
.build())
|
||||
.setTld(tld)
|
||||
.setDomainName(InternetDomainName.from(domainName))
|
||||
.setAsOfDate(toDateTime(dateTime))
|
||||
.setAsOfDate(dateTime)
|
||||
.build());
|
||||
}
|
||||
|
||||
@@ -253,7 +252,7 @@ public final class DomainPricingLogic {
|
||||
.build())
|
||||
.setTld(tld)
|
||||
.setDomainName(InternetDomainName.from(domainName))
|
||||
.setAsOfDate(toDateTime(dateTime))
|
||||
.setAsOfDate(dateTime)
|
||||
.build());
|
||||
}
|
||||
|
||||
|
||||
@@ -34,9 +34,7 @@ import static google.registry.flows.domain.token.AllocationTokenFlowUtils.maybeA
|
||||
import static google.registry.flows.domain.token.AllocationTokenFlowUtils.verifyBulkTokenAllowedOnDomain;
|
||||
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_RENEW;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.util.DateTimeUtils.plusYears;
|
||||
import static google.registry.util.DateTimeUtils.toDateTime;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -88,9 +86,10 @@ import google.registry.model.reporting.HistoryEntry.HistoryEntryId;
|
||||
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
|
||||
import google.registry.model.tld.Tld;
|
||||
import jakarta.inject.Inject;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.Optional;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
|
||||
/**
|
||||
@@ -165,7 +164,7 @@ public final class DomainRenewFlow implements MutatingFlow {
|
||||
validateRegistrarIsLoggedIn(registrarId);
|
||||
verifyRegistrarIsActive(registrarId);
|
||||
extensionManager.validate();
|
||||
DateTime now = tm().getTransactionTime();
|
||||
Instant now = tm().getTxTime();
|
||||
Renew command = (Renew) resourceCommand;
|
||||
// Loads the target resource if it exists
|
||||
Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now);
|
||||
@@ -192,8 +191,12 @@ public final class DomainRenewFlow implements MutatingFlow {
|
||||
// If client passed an applicable static token this updates the domain
|
||||
existingDomain = maybeApplyBulkPricingRemovalToken(existingDomain, allocationToken);
|
||||
|
||||
DateTime newExpirationTime =
|
||||
toDateTime(plusYears(existingDomain.getRegistrationExpirationTime(), years)); // Uncapped
|
||||
Instant newExpirationTime =
|
||||
existingDomain
|
||||
.getRegistrationExpirationTime()
|
||||
.atZone(ZoneOffset.UTC)
|
||||
.plusYears(years)
|
||||
.toInstant(); // Uncapped
|
||||
validateRegistrationPeriod(now, newExpirationTime);
|
||||
Optional<FeeRenewCommandExtension> feeRenew =
|
||||
eppInput.getSingleExtension(FeeRenewCommandExtension.class);
|
||||
@@ -203,7 +206,7 @@ public final class DomainRenewFlow implements MutatingFlow {
|
||||
pricingLogic.getRenewPrice(
|
||||
Tld.get(existingDomain.getTld()),
|
||||
targetId,
|
||||
toInstant(now),
|
||||
now,
|
||||
years,
|
||||
existingBillingRecurrence,
|
||||
allocationToken);
|
||||
@@ -223,14 +226,14 @@ public final class DomainRenewFlow implements MutatingFlow {
|
||||
// Create a new autorenew billing event and poll message starting at the new expiration time.
|
||||
BillingRecurrence newAutorenewEvent =
|
||||
newAutorenewBillingEvent(existingDomain)
|
||||
.setEventTime(toInstant(newExpirationTime))
|
||||
.setEventTime(newExpirationTime)
|
||||
.setRenewalPrice(existingBillingRecurrence.getRenewalPrice().orElse(null))
|
||||
.setRenewalPriceBehavior(existingBillingRecurrence.getRenewalPriceBehavior())
|
||||
.setDomainHistoryId(domainHistoryId)
|
||||
.build();
|
||||
PollMessage.Autorenew newAutorenewPollMessage =
|
||||
newAutorenewPollMessage(existingDomain)
|
||||
.setEventTime(toInstant(newExpirationTime))
|
||||
.setEventTime(newExpirationTime)
|
||||
.setDomainHistoryId(domainHistoryId)
|
||||
.build();
|
||||
// End the old autorenew billing event and poll message now. This may delete the poll message.
|
||||
@@ -239,9 +242,9 @@ public final class DomainRenewFlow implements MutatingFlow {
|
||||
Domain newDomain =
|
||||
existingDomain
|
||||
.asBuilder()
|
||||
.setLastEppUpdateTime(toInstant(now))
|
||||
.setLastEppUpdateTime(now)
|
||||
.setLastEppUpdateRegistrarId(registrarId)
|
||||
.setRegistrationExpirationTime(toInstant(newExpirationTime))
|
||||
.setRegistrationExpirationTime(newExpirationTime)
|
||||
.setAutorenewBillingEvent(newAutorenewEvent.createVKey())
|
||||
.setAutorenewPollMessage(newAutorenewPollMessage.createVKey())
|
||||
.addGracePeriod(
|
||||
@@ -278,7 +281,7 @@ public final class DomainRenewFlow implements MutatingFlow {
|
||||
flowCustomLogic.beforeResponse(
|
||||
BeforeResponseParameters.newBuilder()
|
||||
.setDomain(newDomain)
|
||||
.setResData(DomainRenewData.create(targetId, toInstant(newExpirationTime)))
|
||||
.setResData(DomainRenewData.create(targetId, newExpirationTime))
|
||||
.setResponseExtensions(createResponseExtensions(feesAndCredits, feeRenew))
|
||||
.build());
|
||||
persistEntityChanges(entityChanges);
|
||||
@@ -289,7 +292,7 @@ public final class DomainRenewFlow implements MutatingFlow {
|
||||
}
|
||||
|
||||
private DomainHistory buildDomainHistory(
|
||||
Domain newDomain, DateTime now, Period period, Duration renewGracePeriod) {
|
||||
Domain newDomain, Instant now, Period period, Duration renewGracePeriod) {
|
||||
Optional<MetadataExtension> metadataExtensionOpt =
|
||||
eppInput.getSingleExtension(MetadataExtension.class);
|
||||
if (metadataExtensionOpt.isPresent()) {
|
||||
@@ -307,7 +310,7 @@ public final class DomainRenewFlow implements MutatingFlow {
|
||||
ImmutableSet.of(
|
||||
DomainTransactionRecord.create(
|
||||
newDomain.getTld(),
|
||||
toInstant(now.plus(renewGracePeriod)),
|
||||
now.plusMillis(renewGracePeriod.getMillis()),
|
||||
TransactionReportField.netRenewsFieldFromYears(period.getValue()),
|
||||
1)))
|
||||
.build();
|
||||
@@ -343,20 +346,20 @@ public final class DomainRenewFlow implements MutatingFlow {
|
||||
int years,
|
||||
HistoryEntryId domainHistoryId,
|
||||
Optional<AllocationToken> allocationToken,
|
||||
DateTime now) {
|
||||
Instant now) {
|
||||
return new BillingEvent.Builder()
|
||||
.setReason(Reason.RENEW)
|
||||
.setTargetId(targetId)
|
||||
.setRegistrarId(registrarId)
|
||||
.setPeriodYears(years)
|
||||
.setCost(renewCost)
|
||||
.setEventTime(toInstant(now))
|
||||
.setEventTime(now)
|
||||
.setAllocationToken(
|
||||
allocationToken
|
||||
.filter(t -> AllocationToken.TokenBehavior.DEFAULT.equals(t.getTokenBehavior()))
|
||||
.map(AllocationToken::createVKey)
|
||||
.orElse(null))
|
||||
.setBillingTime(toInstant(now.plus(Tld.get(tld).getRenewGracePeriodLength())))
|
||||
.setBillingTime(now.plusMillis(Tld.get(tld).getRenewGracePeriodLength().getMillis()))
|
||||
.setDomainHistoryId(domainHistoryId)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -31,9 +31,6 @@ import static google.registry.flows.domain.DomainFlowUtils.verifyRegistrarIsActi
|
||||
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_RESTORE;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.util.DateTimeUtils.END_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.plusYears;
|
||||
import static google.registry.util.DateTimeUtils.toDateTime;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -72,9 +69,10 @@ import google.registry.model.reporting.HistoryEntry.HistoryEntryId;
|
||||
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
|
||||
import google.registry.model.tld.Tld;
|
||||
import jakarta.inject.Inject;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.Optional;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* An EPP flow that requests that a domain in the redemption grace period be restored.
|
||||
@@ -139,12 +137,11 @@ public final class DomainRestoreRequestFlow implements MutatingFlow {
|
||||
verifyRegistrarIsActive(registrarId);
|
||||
extensionManager.validate();
|
||||
Update command = (Update) resourceCommand;
|
||||
DateTime now = tm().getTransactionTime();
|
||||
Instant now = tm().getTxTime();
|
||||
Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now);
|
||||
boolean isExpired = existingDomain.getRegistrationExpirationTime().isBefore(toInstant(now));
|
||||
boolean isExpired = existingDomain.getRegistrationExpirationTime().isBefore(now);
|
||||
FeesAndCredits feesAndCredits =
|
||||
pricingLogic.getRestorePrice(
|
||||
Tld.get(existingDomain.getTld()), targetId, toInstant(now), isExpired);
|
||||
pricingLogic.getRestorePrice(Tld.get(existingDomain.getTld()), targetId, now, isExpired);
|
||||
Optional<FeeUpdateCommandExtension> feeUpdate =
|
||||
eppInput.getSingleExtension(FeeUpdateCommandExtension.class);
|
||||
verifyRestoreAllowed(command, existingDomain, feeUpdate, feesAndCredits, now);
|
||||
@@ -152,8 +149,12 @@ public final class DomainRestoreRequestFlow implements MutatingFlow {
|
||||
historyBuilder.setRevisionId(domainHistoryId.getRevisionId());
|
||||
ImmutableSet.Builder<ImmutableObject> entitiesToInsert = new ImmutableSet.Builder<>();
|
||||
|
||||
DateTime newExpirationTime =
|
||||
toDateTime(plusYears(existingDomain.getRegistrationExpirationTime(), isExpired ? 1 : 0));
|
||||
Instant newExpirationTime =
|
||||
existingDomain
|
||||
.getRegistrationExpirationTime()
|
||||
.atZone(ZoneOffset.UTC)
|
||||
.plusYears(isExpired ? 1 : 0)
|
||||
.toInstant();
|
||||
// Restore the expiration time on the deleted domain, except if that's already passed, then add
|
||||
// a year and bill for it immediately, with no grace period.
|
||||
if (isExpired) {
|
||||
@@ -166,14 +167,14 @@ public final class DomainRestoreRequestFlow implements MutatingFlow {
|
||||
|
||||
BillingRecurrence autorenewEvent =
|
||||
newAutorenewBillingEvent(existingDomain)
|
||||
.setEventTime(toInstant(newExpirationTime))
|
||||
.setEventTime(newExpirationTime)
|
||||
.setRecurrenceEndTime(END_INSTANT)
|
||||
.setDomainHistoryId(domainHistoryId)
|
||||
.build();
|
||||
entitiesToInsert.add(autorenewEvent);
|
||||
PollMessage.Autorenew autorenewPollMessage =
|
||||
newAutorenewPollMessage(existingDomain)
|
||||
.setEventTime(toInstant(newExpirationTime))
|
||||
.setEventTime(newExpirationTime)
|
||||
.setAutorenewEndTime(END_INSTANT)
|
||||
.setDomainHistoryId(domainHistoryId)
|
||||
.build();
|
||||
@@ -199,17 +200,14 @@ public final class DomainRestoreRequestFlow implements MutatingFlow {
|
||||
.build();
|
||||
}
|
||||
|
||||
private DomainHistory buildDomainHistory(Domain newDomain, DateTime now) {
|
||||
private DomainHistory buildDomainHistory(Domain newDomain, Instant now) {
|
||||
return historyBuilder
|
||||
.setType(DOMAIN_RESTORE)
|
||||
.setDomain(newDomain)
|
||||
.setDomainTransactionRecords(
|
||||
ImmutableSet.of(
|
||||
DomainTransactionRecord.create(
|
||||
newDomain.getTld(),
|
||||
toInstant(now),
|
||||
TransactionReportField.RESTORED_DOMAINS,
|
||||
1)))
|
||||
newDomain.getTld(), now, TransactionReportField.RESTORED_DOMAINS, 1)))
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -218,7 +216,7 @@ public final class DomainRestoreRequestFlow implements MutatingFlow {
|
||||
Domain existingDomain,
|
||||
Optional<FeeUpdateCommandExtension> feeUpdate,
|
||||
FeesAndCredits feesAndCredits,
|
||||
DateTime now)
|
||||
Instant now)
|
||||
throws EppException {
|
||||
verifyOptionalAuthInfo(authInfo, existingDomain);
|
||||
if (!isSuperuser) {
|
||||
@@ -241,14 +239,14 @@ public final class DomainRestoreRequestFlow implements MutatingFlow {
|
||||
|
||||
private static Domain performRestore(
|
||||
Domain existingDomain,
|
||||
DateTime newExpirationTime,
|
||||
Instant newExpirationTime,
|
||||
BillingRecurrence autorenewEvent,
|
||||
PollMessage.Autorenew autorenewPollMessage,
|
||||
DateTime now,
|
||||
Instant now,
|
||||
String registrarId) {
|
||||
return existingDomain
|
||||
.asBuilder()
|
||||
.setRegistrationExpirationTime(toInstant(newExpirationTime))
|
||||
.setRegistrationExpirationTime(newExpirationTime)
|
||||
.setDeletionTime(END_INSTANT)
|
||||
.setStatusValues(null)
|
||||
.setGracePeriods(null)
|
||||
@@ -258,28 +256,28 @@ public final class DomainRestoreRequestFlow implements MutatingFlow {
|
||||
// Clear the autorenew end time so if it had expired but is now explicitly being restored,
|
||||
// it won't immediately be deleted again.
|
||||
.setAutorenewEndTime(Optional.empty())
|
||||
.setLastEppUpdateTime(toInstant(now))
|
||||
.setLastEppUpdateTime(now)
|
||||
.setLastEppUpdateRegistrarId(registrarId)
|
||||
.build();
|
||||
}
|
||||
|
||||
private BillingEvent createRenewBillingEvent(
|
||||
HistoryEntryId domainHistoryId, Money renewCost, DateTime now) {
|
||||
HistoryEntryId domainHistoryId, Money renewCost, Instant now) {
|
||||
return prepareBillingEvent(domainHistoryId, renewCost, now).setReason(Reason.RENEW).build();
|
||||
}
|
||||
|
||||
private BillingEvent createRestoreBillingEvent(
|
||||
HistoryEntryId domainHistoryId, Money restoreCost, DateTime now) {
|
||||
HistoryEntryId domainHistoryId, Money restoreCost, Instant now) {
|
||||
return prepareBillingEvent(domainHistoryId, restoreCost, now).setReason(Reason.RESTORE).build();
|
||||
}
|
||||
|
||||
private BillingEvent.Builder prepareBillingEvent(
|
||||
HistoryEntryId domainHistoryId, Money cost, DateTime now) {
|
||||
HistoryEntryId domainHistoryId, Money cost, Instant now) {
|
||||
return new BillingEvent.Builder()
|
||||
.setTargetId(targetId)
|
||||
.setRegistrarId(registrarId)
|
||||
.setEventTime(toInstant(now))
|
||||
.setBillingTime(toInstant(now))
|
||||
.setEventTime(now)
|
||||
.setBillingTime(now)
|
||||
.setPeriodYears(1)
|
||||
.setCost(cost)
|
||||
.setDomainHistoryId(domainHistoryId);
|
||||
|
||||
@@ -33,8 +33,6 @@ import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_TRANSFER_
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.util.CollectionUtils.union;
|
||||
import static google.registry.util.DateTimeUtils.END_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.toDateTime;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -70,9 +68,9 @@ import google.registry.model.tld.Tld;
|
||||
import google.registry.model.transfer.DomainTransferData;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import jakarta.inject.Inject;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* An EPP flow that approves a pending transfer on a domain.
|
||||
@@ -127,7 +125,7 @@ public final class DomainTransferApproveFlow implements MutatingFlow {
|
||||
extensionManager.register(MetadataExtension.class, AllocationTokenExtension.class);
|
||||
validateRegistrarIsLoggedIn(registrarId);
|
||||
extensionManager.validate();
|
||||
DateTime now = tm().getTransactionTime();
|
||||
Instant now = tm().getTxTime();
|
||||
Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now);
|
||||
AllocationTokenFlowUtils.loadAllocationTokenFromExtension(
|
||||
registrarId, targetId, now, eppInput.getSingleExtension(AllocationTokenExtension.class));
|
||||
@@ -169,9 +167,9 @@ public final class DomainTransferApproveFlow implements MutatingFlow {
|
||||
// billing event should not be passed in.
|
||||
hasBulkToken ? null : existingBillingRecurrence)
|
||||
.getRenewCost())
|
||||
.setEventTime(toInstant(now))
|
||||
.setEventTime(now)
|
||||
.setBillingTime(
|
||||
toInstant(now.plus(Tld.get(tldStr).getTransferGracePeriodLength())))
|
||||
now.plusMillis(Tld.get(tldStr).getTransferGracePeriodLength().getMillis()))
|
||||
.setDomainHistoryId(domainHistoryId)
|
||||
.build());
|
||||
|
||||
@@ -188,18 +186,15 @@ public final class DomainTransferApproveFlow implements MutatingFlow {
|
||||
// still needs to be charged for the auto-renew.
|
||||
if (billingEvent.isPresent()) {
|
||||
entitiesToInsert.add(
|
||||
BillingCancellation.forGracePeriod(
|
||||
autorenewGrace, toInstant(now), domainHistoryId, targetId));
|
||||
BillingCancellation.forGracePeriod(autorenewGrace, now, domainHistoryId, targetId));
|
||||
}
|
||||
}
|
||||
// Close the old autorenew event and poll message at the transfer time (aka now). This may end
|
||||
// up deleting the poll message.
|
||||
updateAutorenewRecurrenceEndTime(
|
||||
existingDomain, existingBillingRecurrence, now, domainHistoryId);
|
||||
DateTime newExpirationTime =
|
||||
toDateTime(
|
||||
computeExDateForApprovalTime(
|
||||
existingDomain, toInstant(now), transferData.getTransferPeriod()));
|
||||
Instant newExpirationTime =
|
||||
computeExDateForApprovalTime(existingDomain, now, transferData.getTransferPeriod());
|
||||
// Create a new autorenew event starting at the expiration time.
|
||||
BillingRecurrence autorenewEvent =
|
||||
new BillingRecurrence.Builder()
|
||||
@@ -207,7 +202,7 @@ public final class DomainTransferApproveFlow implements MutatingFlow {
|
||||
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
|
||||
.setTargetId(targetId)
|
||||
.setRegistrarId(gainingRegistrarId)
|
||||
.setEventTime(toInstant(newExpirationTime))
|
||||
.setEventTime(newExpirationTime)
|
||||
.setRenewalPriceBehavior(
|
||||
hasBulkToken
|
||||
? RenewalPriceBehavior.DEFAULT
|
||||
@@ -221,7 +216,7 @@ public final class DomainTransferApproveFlow implements MutatingFlow {
|
||||
new PollMessage.Autorenew.Builder()
|
||||
.setTargetId(targetId)
|
||||
.setRegistrarId(gainingRegistrarId)
|
||||
.setEventTime(toInstant(newExpirationTime))
|
||||
.setEventTime(newExpirationTime)
|
||||
.setAutorenewEndTime(END_INSTANT)
|
||||
.setMsg("Domain was auto-renewed.")
|
||||
.setDomainHistoryId(domainHistoryId)
|
||||
@@ -238,9 +233,9 @@ public final class DomainTransferApproveFlow implements MutatingFlow {
|
||||
partiallyApprovedDomain
|
||||
.getTransferData()
|
||||
.asBuilder()
|
||||
.setTransferredRegistrationExpirationTime(toInstant(newExpirationTime))
|
||||
.setTransferredRegistrationExpirationTime(newExpirationTime)
|
||||
.build())
|
||||
.setRegistrationExpirationTime(toInstant(newExpirationTime))
|
||||
.setRegistrationExpirationTime(newExpirationTime)
|
||||
.setAutorenewBillingEvent(autorenewEvent.createVKey())
|
||||
.setAutorenewPollMessage(gainingClientAutorenewPollMessage.createVKey())
|
||||
// Remove all the old grace periods and add a new one for the transfer.
|
||||
@@ -252,7 +247,7 @@ public final class DomainTransferApproveFlow implements MutatingFlow {
|
||||
GracePeriod.forBillingEvent(
|
||||
GracePeriodStatus.TRANSFER, existingDomain.getRepoId(), event)))
|
||||
.orElseGet(ImmutableSet::of))
|
||||
.setLastEppUpdateTime(toInstant(now))
|
||||
.setLastEppUpdateTime(now)
|
||||
.setLastEppUpdateRegistrarId(registrarId)
|
||||
// Even if the existing domain had a bulk token, that bulk token should be removed
|
||||
// on transfer
|
||||
@@ -276,14 +271,12 @@ public final class DomainTransferApproveFlow implements MutatingFlow {
|
||||
return responseBuilder
|
||||
.setResData(
|
||||
createTransferResponse(
|
||||
targetId,
|
||||
newDomain.getTransferData(),
|
||||
toDateTime(newDomain.getRegistrationExpirationTime())))
|
||||
targetId, newDomain.getTransferData(), newDomain.getRegistrationExpirationTime()))
|
||||
.build();
|
||||
}
|
||||
|
||||
private DomainHistory buildDomainHistory(
|
||||
Domain newDomain, Tld tld, DateTime now, String gainingRegistrarId) {
|
||||
Domain newDomain, Tld tld, Instant now, String gainingRegistrarId) {
|
||||
ImmutableSet<DomainTransactionRecord> cancelingRecords =
|
||||
createCancelingRecords(
|
||||
newDomain,
|
||||
@@ -299,7 +292,7 @@ public final class DomainTransferApproveFlow implements MutatingFlow {
|
||||
cancelingRecords,
|
||||
DomainTransactionRecord.create(
|
||||
newDomain.getTld(),
|
||||
toInstant(now.plus(tld.getTransferGracePeriodLength())),
|
||||
now.plusMillis(tld.getTransferGracePeriodLength().getMillis()),
|
||||
TRANSFER_SUCCESSFUL,
|
||||
1)))
|
||||
.build();
|
||||
|
||||
@@ -29,7 +29,7 @@ import static google.registry.model.ResourceTransferUtils.denyPendingTransfer;
|
||||
import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.TRANSFER_SUCCESSFUL;
|
||||
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_TRANSFER_CANCEL;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.END_INSTANT;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.flows.EppException;
|
||||
@@ -51,8 +51,8 @@ import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
|
||||
import google.registry.model.tld.Tld;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import jakarta.inject.Inject;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* An EPP flow that cancels a pending transfer on a domain.
|
||||
@@ -92,7 +92,7 @@ public final class DomainTransferCancelFlow implements MutatingFlow {
|
||||
extensionManager.register(MetadataExtension.class);
|
||||
validateRegistrarIsLoggedIn(registrarId);
|
||||
extensionManager.validate();
|
||||
DateTime now = tm().getTransactionTime();
|
||||
Instant now = tm().getTxTime();
|
||||
Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now);
|
||||
verifyOptionalAuthInfo(authInfo, existingDomain);
|
||||
verifyHasPendingTransfer(existingDomain);
|
||||
@@ -120,7 +120,7 @@ public final class DomainTransferCancelFlow implements MutatingFlow {
|
||||
BillingRecurrence existingBillingRecurrence =
|
||||
tm().loadByKey(existingDomain.getAutorenewBillingEvent());
|
||||
updateAutorenewRecurrenceEndTime(
|
||||
existingDomain, existingBillingRecurrence, END_OF_TIME, domainHistory.getHistoryEntryId());
|
||||
existingDomain, existingBillingRecurrence, END_INSTANT, domainHistory.getHistoryEntryId());
|
||||
// Delete the billing event and poll messages that were written in case the transfer would have
|
||||
// been implicitly server approved.
|
||||
tm().delete(existingDomain.getTransferData().getServerApproveEntities());
|
||||
@@ -129,7 +129,7 @@ public final class DomainTransferCancelFlow implements MutatingFlow {
|
||||
.build();
|
||||
}
|
||||
|
||||
private DomainHistory buildDomainHistory(Domain newDomain, Tld tld, DateTime now) {
|
||||
private DomainHistory buildDomainHistory(Domain newDomain, Tld tld, Instant now) {
|
||||
ImmutableSet<DomainTransactionRecord> cancelingRecords =
|
||||
createCancelingRecords(
|
||||
newDomain,
|
||||
|
||||
@@ -19,8 +19,6 @@ import static google.registry.flows.ResourceFlowUtils.computeExDateForApprovalTi
|
||||
import static google.registry.flows.ResourceFlowUtils.loadAndVerifyExistence;
|
||||
import static google.registry.flows.ResourceFlowUtils.verifyOptionalAuthInfo;
|
||||
import static google.registry.flows.domain.DomainTransferUtils.createTransferResponse;
|
||||
import static google.registry.util.DateTimeUtils.toDateTime;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.ExtensionManager;
|
||||
@@ -38,8 +36,8 @@ import google.registry.model.transfer.DomainTransferData;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.util.Clock;
|
||||
import jakarta.inject.Inject;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* An EPP flow that queries a pending transfer on a domain.
|
||||
@@ -72,7 +70,7 @@ public final class DomainTransferQueryFlow implements TransactionalFlow {
|
||||
public EppResponse run() throws EppException {
|
||||
validateRegistrarIsLoggedIn(registrarId);
|
||||
extensionManager.validate(); // There are no legal extensions for this flow.
|
||||
DateTime now = clock.nowUtc();
|
||||
Instant now = clock.now();
|
||||
Domain domain = loadAndVerifyExistence(Domain.class, targetId, now);
|
||||
verifyOptionalAuthInfo(authInfo, domain);
|
||||
// Most of the fields on the transfer response are required, so there's no way to return valid
|
||||
@@ -88,14 +86,12 @@ public final class DomainTransferQueryFlow implements TransactionalFlow {
|
||||
&& !registrarId.equals(transferData.getLosingRegistrarId())) {
|
||||
throw new NotAuthorizedToViewTransferException();
|
||||
}
|
||||
DateTime newExpirationTime = null;
|
||||
Instant newExpirationTime = null;
|
||||
if (transferData.getTransferStatus().isApproved()) {
|
||||
newExpirationTime = toDateTime(transferData.getTransferredRegistrationExpirationTime());
|
||||
newExpirationTime = transferData.getTransferredRegistrationExpirationTime();
|
||||
} else if (transferData.getTransferStatus().equals(TransferStatus.PENDING)) {
|
||||
newExpirationTime =
|
||||
toDateTime(
|
||||
computeExDateForApprovalTime(
|
||||
domain, toInstant(now), domain.getTransferData().getTransferPeriod()));
|
||||
computeExDateForApprovalTime(domain, now, domain.getTransferData().getTransferPeriod());
|
||||
}
|
||||
return responseBuilder
|
||||
.setResData(createTransferResponse(targetId, transferData, newExpirationTime))
|
||||
|
||||
@@ -31,9 +31,8 @@ import static google.registry.model.reporting.DomainTransactionRecord.Transactio
|
||||
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_TRANSFER_REJECT;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.util.CollectionUtils.union;
|
||||
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 static google.registry.util.DateTimeUtils.toInstant;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.flows.EppException;
|
||||
@@ -57,7 +56,6 @@ import google.registry.model.transfer.TransferStatus;
|
||||
import jakarta.inject.Inject;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* An EPP flow that rejects a pending transfer on a domain.
|
||||
@@ -112,18 +110,18 @@ public final class DomainTransferRejectFlow implements MutatingFlow {
|
||||
Domain newDomain =
|
||||
denyPendingTransfer(
|
||||
existingDomain, TransferStatus.CLIENT_REJECTED, toDateTime(now), registrarId);
|
||||
DomainHistory domainHistory = buildDomainHistory(newDomain, tld, toDateTime(now));
|
||||
DomainHistory domainHistory = buildDomainHistory(newDomain, tld, now);
|
||||
tm().update(newDomain);
|
||||
tm().insertAll(
|
||||
domainHistory,
|
||||
createGainingTransferPollMessage(
|
||||
targetId, newDomain.getTransferData(), null, toDateTime(now), domainHistoryId));
|
||||
targetId, newDomain.getTransferData(), null, now, domainHistoryId));
|
||||
// Reopen the autorenew event and poll message that we closed for the implicit transfer. This
|
||||
// may end up recreating the poll message if it was deleted upon the transfer request.
|
||||
BillingRecurrence existingBillingRecurrence =
|
||||
tm().loadByKey(existingDomain.getAutorenewBillingEvent());
|
||||
updateAutorenewRecurrenceEndTime(
|
||||
existingDomain, existingBillingRecurrence, END_OF_TIME, domainHistory.getHistoryEntryId());
|
||||
existingDomain, existingBillingRecurrence, END_INSTANT, domainHistory.getHistoryEntryId());
|
||||
// Delete the billing event and poll messages that were written in case the transfer would have
|
||||
// been implicitly server approved.
|
||||
tm().delete(existingDomain.getTransferData().getServerApproveEntities());
|
||||
@@ -132,7 +130,7 @@ public final class DomainTransferRejectFlow implements MutatingFlow {
|
||||
.build();
|
||||
}
|
||||
|
||||
private DomainHistory buildDomainHistory(Domain newDomain, Tld tld, DateTime now) {
|
||||
private DomainHistory buildDomainHistory(Domain newDomain, Tld tld, Instant now) {
|
||||
ImmutableSet<DomainTransactionRecord> cancelingRecords =
|
||||
createCancelingRecords(
|
||||
newDomain,
|
||||
@@ -144,8 +142,7 @@ public final class DomainTransferRejectFlow implements MutatingFlow {
|
||||
.setDomainTransactionRecords(
|
||||
union(
|
||||
cancelingRecords,
|
||||
DomainTransactionRecord.create(
|
||||
newDomain.getTld(), toInstant(now), TRANSFER_NACKED, 1)))
|
||||
DomainTransactionRecord.create(newDomain.getTld(), now, TRANSFER_NACKED, 1)))
|
||||
.setDomain(newDomain)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ import static google.registry.model.eppoutput.Result.Code.SUCCESS_WITH_ACTION_PE
|
||||
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.util.DateTimeUtils.toDateTime;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -83,8 +82,8 @@ import google.registry.model.transfer.TransferResponse.DomainTransferResponse;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import jakarta.inject.Inject;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Optional;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* An EPP flow that requests a transfer on a domain.
|
||||
@@ -165,7 +164,7 @@ public final class DomainTransferRequestFlow implements MutatingFlow {
|
||||
validateRegistrarIsLoggedIn(gainingClientId);
|
||||
verifyRegistrarIsActive(gainingClientId);
|
||||
extensionManager.validate();
|
||||
DateTime now = tm().getTransactionTime();
|
||||
Instant now = tm().getTxTime();
|
||||
Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now);
|
||||
AllocationTokenFlowUtils.loadAllocationTokenFromExtension(
|
||||
gainingClientId,
|
||||
@@ -198,9 +197,7 @@ public final class DomainTransferRequestFlow implements MutatingFlow {
|
||||
feesAndCredits = Optional.empty();
|
||||
} else if (existingDomain.getCurrentBulkToken().isEmpty()) {
|
||||
feesAndCredits =
|
||||
Optional.of(
|
||||
pricingLogic.getTransferPrice(
|
||||
tld, targetId, toInstant(now), existingBillingRecurrence));
|
||||
Optional.of(pricingLogic.getTransferPrice(tld, targetId, now, existingBillingRecurrence));
|
||||
} else {
|
||||
// If existing domain is in a bulk pricing package, calculate the transfer price with default
|
||||
// renewal price
|
||||
@@ -208,7 +205,7 @@ public final class DomainTransferRequestFlow implements MutatingFlow {
|
||||
feesAndCredits =
|
||||
period.getValue() == 0
|
||||
? Optional.empty()
|
||||
: Optional.of(pricingLogic.getTransferPrice(tld, targetId, toInstant(now), null));
|
||||
: Optional.of(pricingLogic.getTransferPrice(tld, targetId, now, null));
|
||||
}
|
||||
|
||||
if (feesAndCredits.isPresent()) {
|
||||
@@ -218,13 +215,14 @@ public final class DomainTransferRequestFlow implements MutatingFlow {
|
||||
historyBuilder
|
||||
.setRevisionId(domainHistoryId.getRevisionId())
|
||||
.setOtherRegistrarId(existingDomain.getCurrentSponsorRegistrarId());
|
||||
DateTime automaticTransferTime =
|
||||
Instant automaticTransferTime =
|
||||
superuserExtension
|
||||
.map(
|
||||
domainTransferRequestSuperuserExtension ->
|
||||
now.plusDays(
|
||||
domainTransferRequestSuperuserExtension.getAutomaticTransferLength()))
|
||||
.orElseGet(() -> now.plus(tld.getAutomaticTransferLength()));
|
||||
now.plus(
|
||||
domainTransferRequestSuperuserExtension.getAutomaticTransferLength(),
|
||||
ChronoUnit.DAYS))
|
||||
.orElseGet(() -> now.plusMillis(tld.getAutomaticTransferLength().getMillis()));
|
||||
// If the domain will be in the auto-renew grace period at the moment of transfer, the transfer
|
||||
// will subsume the autorenew, so we don't add the normal extra year from the transfer.
|
||||
// The gaining registrar is still billed for the extra year; the losing registrar will get a
|
||||
@@ -232,13 +230,10 @@ public final class DomainTransferRequestFlow implements MutatingFlow {
|
||||
//
|
||||
// See b/19430703#comment17 and https://www.icann.org/news/advisory-2002-06-06-en for the
|
||||
// policy documentation for transfers subsuming autorenews within the autorenew grace period.
|
||||
Domain domainAtTransferTime =
|
||||
existingDomain.cloneProjectedAtTime(toInstant(automaticTransferTime));
|
||||
Domain domainAtTransferTime = existingDomain.cloneProjectedAtTime(automaticTransferTime);
|
||||
// The new expiration time if there is a server approval.
|
||||
DateTime serverApproveNewExpirationTime =
|
||||
toDateTime(
|
||||
computeExDateForApprovalTime(
|
||||
domainAtTransferTime, toInstant(automaticTransferTime), period));
|
||||
Instant serverApproveNewExpirationTime =
|
||||
computeExDateForApprovalTime(domainAtTransferTime, automaticTransferTime, period);
|
||||
// Create speculative entities in anticipation of an automatic server approval.
|
||||
ImmutableSet<TransferServerApproveEntity> serverApproveEntities =
|
||||
createTransferServerApproveEntities(
|
||||
@@ -258,12 +253,11 @@ public final class DomainTransferRequestFlow implements MutatingFlow {
|
||||
domainHistoryId.getRevisionId(),
|
||||
new DomainTransferData.Builder()
|
||||
.setTransferRequestTrid(trid)
|
||||
.setTransferRequestTime(toInstant(now))
|
||||
.setTransferRequestTime(now)
|
||||
.setGainingRegistrarId(gainingClientId)
|
||||
.setLosingRegistrarId(existingDomain.getCurrentSponsorRegistrarId())
|
||||
.setPendingTransferExpirationTime(toInstant(automaticTransferTime))
|
||||
.setTransferredRegistrationExpirationTime(
|
||||
toInstant(serverApproveNewExpirationTime)),
|
||||
.setPendingTransferExpirationTime(automaticTransferTime)
|
||||
.setTransferredRegistrationExpirationTime(serverApproveNewExpirationTime),
|
||||
serverApproveEntities,
|
||||
period);
|
||||
// Create a poll message to notify the losing registrar that a transfer was requested.
|
||||
@@ -271,7 +265,7 @@ public final class DomainTransferRequestFlow implements MutatingFlow {
|
||||
createLosingTransferPollMessage(
|
||||
targetId, pendingTransferData, serverApproveNewExpirationTime, domainHistoryId)
|
||||
.asBuilder()
|
||||
.setEventTime(toInstant(now))
|
||||
.setEventTime(now)
|
||||
.build();
|
||||
// End the old autorenew event and poll message at the implicit transfer time. This may delete
|
||||
// the poll message if it has no events left. Note that if the automatic transfer succeeds, then
|
||||
@@ -284,19 +278,21 @@ public final class DomainTransferRequestFlow implements MutatingFlow {
|
||||
.asBuilder()
|
||||
.setTransferData(pendingTransferData)
|
||||
.addStatusValue(StatusValue.PENDING_TRANSFER)
|
||||
.setLastEppUpdateTime(toInstant(now))
|
||||
.setLastEppUpdateTime(now)
|
||||
.setLastEppUpdateRegistrarId(gainingClientId)
|
||||
.build();
|
||||
DomainHistory domainHistory = buildDomainHistory(newDomain, tld, now, period);
|
||||
|
||||
asyncTaskEnqueuer.enqueueAsyncResave(
|
||||
newDomain.createVKey(), now, ImmutableSortedSet.of(automaticTransferTime));
|
||||
newDomain.createVKey(),
|
||||
toDateTime(now),
|
||||
ImmutableSortedSet.of(toDateTime(automaticTransferTime)));
|
||||
tm().put(newDomain);
|
||||
tm().putAll(serverApproveEntities);
|
||||
tm().insertAll(domainHistory, requestPollMessage);
|
||||
return responseBuilder
|
||||
.setResultFromCode(SUCCESS_WITH_ACTION_PENDING)
|
||||
.setResData(createResponse(period, existingDomain, newDomain, toInstant(now)))
|
||||
.setResData(createResponse(period, existingDomain, newDomain, now))
|
||||
.setExtensions(createResponseExtensions(feesAndCredits, feeTransfer))
|
||||
.build();
|
||||
}
|
||||
@@ -304,7 +300,7 @@ public final class DomainTransferRequestFlow implements MutatingFlow {
|
||||
private void verifyTransferAllowed(
|
||||
Domain existingDomain,
|
||||
Period period,
|
||||
DateTime now,
|
||||
Instant now,
|
||||
Optional<DomainTransferRequestSuperuserExtension> superuserExtension)
|
||||
throws EppException {
|
||||
verifyNoDisallowedStatuses(existingDomain, ImmutableSet.of(StatusValue.PENDING_DELETE));
|
||||
@@ -367,7 +363,7 @@ public final class DomainTransferRequestFlow implements MutatingFlow {
|
||||
}
|
||||
}
|
||||
|
||||
private DomainHistory buildDomainHistory(Domain newDomain, Tld tld, DateTime now, Period period) {
|
||||
private DomainHistory buildDomainHistory(Domain newDomain, Tld tld, Instant now, Period period) {
|
||||
return historyBuilder
|
||||
.setType(DOMAIN_TRANSFER_REQUEST)
|
||||
.setPeriod(period)
|
||||
@@ -376,9 +372,8 @@ public final class DomainTransferRequestFlow implements MutatingFlow {
|
||||
ImmutableSet.of(
|
||||
DomainTransactionRecord.create(
|
||||
tld.getTldStr(),
|
||||
toInstant(
|
||||
now.plus(tld.getAutomaticTransferLength())
|
||||
.plus(tld.getTransferGracePeriodLength())),
|
||||
now.plusMillis(tld.getAutomaticTransferLength().getMillis())
|
||||
.plusMillis(tld.getTransferGracePeriodLength().getMillis()),
|
||||
TransactionReportField.TRANSFER_SUCCESSFUL,
|
||||
1)))
|
||||
.build();
|
||||
@@ -392,7 +387,7 @@ public final class DomainTransferRequestFlow implements MutatingFlow {
|
||||
Instant approveNowExtendedRegistrationTime =
|
||||
computeExDateForApprovalTime(existingDomain, now, period);
|
||||
return createTransferResponse(
|
||||
targetId, newDomain.getTransferData(), toDateTime(approveNowExtendedRegistrationTime));
|
||||
targetId, newDomain.getTransferData(), approveNowExtendedRegistrationTime);
|
||||
}
|
||||
|
||||
private static ImmutableList<FeeTransformResponseExtension> createResponseExtensions(
|
||||
|
||||
@@ -17,7 +17,6 @@ package google.registry.flows.domain;
|
||||
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||
import static com.google.common.collect.MoreCollectors.onlyElement;
|
||||
import static google.registry.util.DateTimeUtils.END_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -41,10 +40,10 @@ import google.registry.model.transfer.DomainTransferData.TransferServerApproveEn
|
||||
import google.registry.model.transfer.TransferResponse.DomainTransferResponse;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.persistence.VKey;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* Utility logic for facilitating domain transfers.
|
||||
@@ -107,25 +106,25 @@ public final class DomainTransferUtils {
|
||||
* </ul>
|
||||
*/
|
||||
public static ImmutableSet<TransferServerApproveEntity> createTransferServerApproveEntities(
|
||||
DateTime automaticTransferTime,
|
||||
DateTime serverApproveNewExpirationTime,
|
||||
Instant automaticTransferTime,
|
||||
Instant serverApproveNewExpirationTime,
|
||||
HistoryEntryId domainHistoryId,
|
||||
Domain existingDomain,
|
||||
BillingRecurrence existingBillingRecurrence,
|
||||
Trid trid,
|
||||
String gainingRegistrarId,
|
||||
Optional<Money> transferCost,
|
||||
DateTime now) {
|
||||
Instant now) {
|
||||
String targetId = existingDomain.getDomainName();
|
||||
// Create a TransferData for the server-approve case to use for the speculative poll messages.
|
||||
DomainTransferData serverApproveTransferData =
|
||||
new DomainTransferData.Builder()
|
||||
.setTransferRequestTrid(trid)
|
||||
.setTransferRequestTime(toInstant(now))
|
||||
.setTransferRequestTime(now)
|
||||
.setGainingRegistrarId(gainingRegistrarId)
|
||||
.setLosingRegistrarId(existingDomain.getCurrentSponsorRegistrarId())
|
||||
.setPendingTransferExpirationTime(toInstant(automaticTransferTime))
|
||||
.setTransferredRegistrationExpirationTime(toInstant(serverApproveNewExpirationTime))
|
||||
.setPendingTransferExpirationTime(automaticTransferTime)
|
||||
.setTransferredRegistrationExpirationTime(serverApproveNewExpirationTime)
|
||||
.setTransferStatus(TransferStatus.SERVER_APPROVED)
|
||||
.build();
|
||||
Tld tld = Tld.get(existingDomain.getTld());
|
||||
@@ -180,8 +179,8 @@ public final class DomainTransferUtils {
|
||||
public static PollMessage createGainingTransferPollMessage(
|
||||
String targetId,
|
||||
DomainTransferData transferData,
|
||||
@Nullable DateTime extendedRegistrationExpirationTime,
|
||||
DateTime now,
|
||||
@Nullable Instant extendedRegistrationExpirationTime,
|
||||
Instant now,
|
||||
HistoryEntryId domainHistoryId) {
|
||||
return new PollMessage.OneTime.Builder()
|
||||
.setRegistrarId(transferData.getGainingRegistrarId())
|
||||
@@ -203,7 +202,7 @@ public final class DomainTransferUtils {
|
||||
public static PollMessage createLosingTransferPollMessage(
|
||||
String targetId,
|
||||
DomainTransferData transferData,
|
||||
@Nullable DateTime extendedRegistrationExpirationTime,
|
||||
@Nullable Instant extendedRegistrationExpirationTime,
|
||||
HistoryEntryId domainHistoryId) {
|
||||
return new PollMessage.OneTime.Builder()
|
||||
.setRegistrarId(transferData.getLosingRegistrarId())
|
||||
@@ -220,7 +219,7 @@ public final class DomainTransferUtils {
|
||||
static DomainTransferResponse createTransferResponse(
|
||||
String targetId,
|
||||
DomainTransferData transferData,
|
||||
@Nullable DateTime extendedRegistrationExpirationTime) {
|
||||
@Nullable Instant extendedRegistrationExpirationTime) {
|
||||
return new DomainTransferResponse.Builder()
|
||||
.setDomainName(targetId)
|
||||
.setGainingRegistrarId(transferData.getGainingRegistrarId())
|
||||
@@ -228,19 +227,19 @@ public final class DomainTransferUtils {
|
||||
.setPendingTransferExpirationTime(transferData.getPendingTransferExpirationTime())
|
||||
.setTransferRequestTime(transferData.getTransferRequestTime())
|
||||
.setTransferStatus(transferData.getTransferStatus())
|
||||
.setExtendedRegistrationExpirationTime(toInstant(extendedRegistrationExpirationTime))
|
||||
.setExtendedRegistrationExpirationTime(extendedRegistrationExpirationTime)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static PollMessage.Autorenew createGainingClientAutorenewPollMessage(
|
||||
DateTime serverApproveNewExpirationTime,
|
||||
Instant serverApproveNewExpirationTime,
|
||||
HistoryEntryId domainHistoryId,
|
||||
String targetId,
|
||||
String gainingRegistrarId) {
|
||||
return new PollMessage.Autorenew.Builder()
|
||||
.setTargetId(targetId)
|
||||
.setRegistrarId(gainingRegistrarId)
|
||||
.setEventTime(toInstant(serverApproveNewExpirationTime))
|
||||
.setEventTime(serverApproveNewExpirationTime)
|
||||
.setAutorenewEndTime(END_INSTANT)
|
||||
.setMsg("Domain was auto-renewed.")
|
||||
.setDomainHistoryId(domainHistoryId)
|
||||
@@ -249,7 +248,7 @@ public final class DomainTransferUtils {
|
||||
|
||||
private static BillingRecurrence createGainingClientAutorenewEvent(
|
||||
BillingRecurrence existingBillingRecurrence,
|
||||
DateTime serverApproveNewExpirationTime,
|
||||
Instant serverApproveNewExpirationTime,
|
||||
HistoryEntryId domainHistoryId,
|
||||
String targetId,
|
||||
String gainingRegistrarId) {
|
||||
@@ -258,7 +257,7 @@ public final class DomainTransferUtils {
|
||||
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
|
||||
.setTargetId(targetId)
|
||||
.setRegistrarId(gainingRegistrarId)
|
||||
.setEventTime(toInstant(serverApproveNewExpirationTime))
|
||||
.setEventTime(serverApproveNewExpirationTime)
|
||||
.setRecurrenceEndTime(END_INSTANT)
|
||||
.setRenewalPriceBehavior(existingBillingRecurrence.getRenewalPriceBehavior())
|
||||
.setRenewalPrice(existingBillingRecurrence.getRenewalPrice().orElse(null))
|
||||
@@ -283,30 +282,28 @@ public final class DomainTransferUtils {
|
||||
* href="https://www.icann.org/news/advisory-2002-06-06-en">this ICANN advisory</a>.
|
||||
*/
|
||||
private static Optional<BillingCancellation> createOptionalAutorenewCancellation(
|
||||
DateTime automaticTransferTime,
|
||||
DateTime now,
|
||||
Instant automaticTransferTime,
|
||||
Instant now,
|
||||
HistoryEntryId domainHistoryId,
|
||||
String targetId,
|
||||
Domain existingDomain,
|
||||
Optional<Money> transferCost) {
|
||||
Domain domainAtTransferTime =
|
||||
existingDomain.cloneProjectedAtTime(toInstant(automaticTransferTime));
|
||||
Domain domainAtTransferTime = existingDomain.cloneProjectedAtTime(automaticTransferTime);
|
||||
GracePeriod autorenewGracePeriod =
|
||||
getOnlyElement(
|
||||
domainAtTransferTime.getGracePeriodsOfType(GracePeriodStatus.AUTO_RENEW), null);
|
||||
if (autorenewGracePeriod != null && transferCost.isPresent()) {
|
||||
return Optional.of(
|
||||
BillingCancellation.forGracePeriod(
|
||||
autorenewGracePeriod, toInstant(now), domainHistoryId, targetId)
|
||||
BillingCancellation.forGracePeriod(autorenewGracePeriod, now, domainHistoryId, targetId)
|
||||
.asBuilder()
|
||||
.setEventTime(toInstant(automaticTransferTime))
|
||||
.setEventTime(automaticTransferTime)
|
||||
.build());
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
private static BillingEvent createTransferBillingEvent(
|
||||
DateTime automaticTransferTime,
|
||||
Instant automaticTransferTime,
|
||||
HistoryEntryId domainHistoryId,
|
||||
String targetId,
|
||||
String gainingRegistrarId,
|
||||
@@ -318,9 +315,9 @@ public final class DomainTransferUtils {
|
||||
.setRegistrarId(gainingRegistrarId)
|
||||
.setCost(transferCost)
|
||||
.setPeriodYears(1)
|
||||
.setEventTime(toInstant(automaticTransferTime))
|
||||
.setEventTime(automaticTransferTime)
|
||||
.setBillingTime(
|
||||
toInstant(automaticTransferTime.plus(registry.getTransferGracePeriodLength())))
|
||||
automaticTransferTime.plusMillis(registry.getTransferGracePeriodLength().getMillis()))
|
||||
.setDomainHistoryId(domainHistoryId)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ import static google.registry.flows.domain.DomainFlowUtils.verifyClientUpdateNot
|
||||
import static google.registry.flows.domain.DomainFlowUtils.verifyNotInPendingDelete;
|
||||
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_UPDATE;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -85,9 +84,9 @@ import google.registry.model.poll.PollMessage;
|
||||
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
|
||||
import google.registry.model.tld.Tld;
|
||||
import jakarta.inject.Inject;
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* An EPP flow that updates a domain.
|
||||
@@ -165,7 +164,7 @@ public final class DomainUpdateFlow implements MutatingFlow {
|
||||
flowCustomLogic.beforeValidation();
|
||||
validateRegistrarIsLoggedIn(registrarId);
|
||||
extensionManager.validate();
|
||||
DateTime now = tm().getTransactionTime();
|
||||
Instant now = tm().getTxTime();
|
||||
Update command = cloneAndLinkReferences((Update) resourceCommand, now);
|
||||
Domain existingDomain = loadAndVerifyExistence(Domain.class, targetId, now);
|
||||
verifyUpdateAllowed(command, existingDomain, now);
|
||||
@@ -212,7 +211,7 @@ public final class DomainUpdateFlow implements MutatingFlow {
|
||||
}
|
||||
|
||||
/** Fail if the object doesn't exist or was deleted. */
|
||||
private void verifyUpdateAllowed(Update command, Domain existingDomain, DateTime now)
|
||||
private void verifyUpdateAllowed(Update command, Domain existingDomain, Instant now)
|
||||
throws EppException {
|
||||
verifyOptionalAuthInfo(authInfo, existingDomain);
|
||||
AddRemove add = command.getInnerAdd();
|
||||
@@ -228,13 +227,13 @@ public final class DomainUpdateFlow implements MutatingFlow {
|
||||
Tld tld = Tld.get(tldStr);
|
||||
Optional<FeeUpdateCommandExtension> feeUpdate =
|
||||
eppInput.getSingleExtension(FeeUpdateCommandExtension.class);
|
||||
FeesAndCredits feesAndCredits = pricingLogic.getUpdatePrice(tld, targetId, toInstant(now));
|
||||
FeesAndCredits feesAndCredits = pricingLogic.getUpdatePrice(tld, targetId, now);
|
||||
validateFeesAckedIfPresent(feeUpdate, feesAndCredits, false);
|
||||
verifyNotInPendingDelete(add.getNameservers());
|
||||
validateNameserversAllowedOnTld(tldStr, add.getNameserverHostNames());
|
||||
}
|
||||
|
||||
private Domain performUpdate(Update command, Domain domain, DateTime now) throws EppException {
|
||||
private Domain performUpdate(Update command, Domain domain, Instant now) throws EppException {
|
||||
AddRemove add = command.getInnerAdd();
|
||||
AddRemove remove = command.getInnerRemove();
|
||||
Optional<SecDnsUpdateExtension> secDnsUpdate =
|
||||
@@ -263,7 +262,7 @@ public final class DomainUpdateFlow implements MutatingFlow {
|
||||
.collect(toImmutableSet()),
|
||||
secDnsUpdate.get())
|
||||
: domain.getDsData())
|
||||
.setLastEppUpdateTime(toInstant(now))
|
||||
.setLastEppUpdateTime(now)
|
||||
.setLastEppUpdateRegistrarId(registrarId)
|
||||
.addStatusValues(add.getStatusValues())
|
||||
.removeStatusValues(remove.getStatusValues())
|
||||
@@ -305,7 +304,7 @@ public final class DomainUpdateFlow implements MutatingFlow {
|
||||
|
||||
/** Some status updates cost money. Bill only once no matter how many of them are changed. */
|
||||
private Optional<BillingEvent> createBillingEventForStatusUpdates(
|
||||
Domain existingDomain, Domain newDomain, DomainHistory historyEntry, DateTime now) {
|
||||
Domain existingDomain, Domain newDomain, DomainHistory historyEntry, Instant now) {
|
||||
Optional<MetadataExtension> metadataExtension =
|
||||
eppInput.getSingleExtension(MetadataExtension.class);
|
||||
if (metadataExtension.isPresent() && metadataExtension.get().getRequestedByRegistrar()) {
|
||||
@@ -319,8 +318,8 @@ public final class DomainUpdateFlow implements MutatingFlow {
|
||||
.setTargetId(targetId)
|
||||
.setRegistrarId(registrarId)
|
||||
.setCost(Tld.get(existingDomain.getTld()).getServerStatusChangeBillingCost())
|
||||
.setEventTime(toInstant(now))
|
||||
.setBillingTime(toInstant(now))
|
||||
.setEventTime(now)
|
||||
.setBillingTime(now)
|
||||
.setDomainHistory(historyEntry)
|
||||
.build());
|
||||
}
|
||||
@@ -331,7 +330,7 @@ public final class DomainUpdateFlow implements MutatingFlow {
|
||||
|
||||
/** Enqueues a poll message iff a superuser is adding/removing server statuses. */
|
||||
private Optional<PollMessage.OneTime> createPollMessageForServerStatusUpdates(
|
||||
Domain existingDomain, Domain newDomain, DomainHistory historyEntry, DateTime now) {
|
||||
Domain existingDomain, Domain newDomain, DomainHistory historyEntry, Instant now) {
|
||||
if (registrarId.equals(existingDomain.getPersistedCurrentSponsorRegistrarId())) {
|
||||
// Don't send a poll message when a superuser registrar is updating its own domain.
|
||||
return Optional.empty();
|
||||
@@ -369,7 +368,7 @@ public final class DomainUpdateFlow implements MutatingFlow {
|
||||
return Optional.ofNullable(
|
||||
new PollMessage.OneTime.Builder()
|
||||
.setHistoryEntry(historyEntry)
|
||||
.setEventTime(toInstant(now))
|
||||
.setEventTime(now)
|
||||
.setRegistrarId(existingDomain.getCurrentSponsorRegistrarId())
|
||||
.setMsg(msg)
|
||||
.setResponseData(
|
||||
|
||||
+11
-14
@@ -19,7 +19,6 @@ import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.pricing.PricingEngineProxy.isDomainPremium;
|
||||
import static google.registry.util.CollectionUtils.isNullOrEmpty;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Strings;
|
||||
@@ -43,9 +42,9 @@ import google.registry.model.reporting.HistoryEntry.HistoryEntryId;
|
||||
import google.registry.model.tld.Tld;
|
||||
import google.registry.persistence.VKey;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/** Utility functions for dealing with {@link AllocationToken}s in domain flows. */
|
||||
public class AllocationTokenFlowUtils {
|
||||
@@ -72,7 +71,7 @@ public class AllocationTokenFlowUtils {
|
||||
public static Optional<AllocationToken> loadAllocationTokenFromExtension(
|
||||
String registrarId,
|
||||
String domainName,
|
||||
DateTime now,
|
||||
Instant now,
|
||||
Optional<AllocationTokenExtension> extension)
|
||||
throws NonexistentAllocationTokenException, AllocationTokenInvalidException {
|
||||
if (extension.isEmpty()) {
|
||||
@@ -91,7 +90,7 @@ public class AllocationTokenFlowUtils {
|
||||
*/
|
||||
public static Optional<AllocationToken> loadTokenFromExtensionOrGetDefault(
|
||||
String registrarId,
|
||||
DateTime now,
|
||||
Instant now,
|
||||
Optional<AllocationTokenExtension> extension,
|
||||
Tld tld,
|
||||
String domainName,
|
||||
@@ -166,9 +165,8 @@ public class AllocationTokenFlowUtils {
|
||||
*/
|
||||
@VisibleForTesting
|
||||
static boolean tokenIsValidAgainstDomain(
|
||||
InternetDomainName domainName, AllocationToken token, CommandName commandName, DateTime now) {
|
||||
if (discountTokenInvalidForPremiumName(
|
||||
token, isDomainPremium(domainName.toString(), toInstant(now)))) {
|
||||
InternetDomainName domainName, AllocationToken token, CommandName commandName, Instant now) {
|
||||
if (discountTokenInvalidForPremiumName(token, isDomainPremium(domainName.toString(), now))) {
|
||||
return false;
|
||||
}
|
||||
if (!token.getAllowedEppActions().isEmpty()
|
||||
@@ -194,7 +192,7 @@ public class AllocationTokenFlowUtils {
|
||||
String domainName,
|
||||
CommandName commandName,
|
||||
String registrarId,
|
||||
DateTime now,
|
||||
Instant now,
|
||||
Optional<Integer> years,
|
||||
DomainPricingLogic pricingLogic)
|
||||
throws EppException {
|
||||
@@ -234,7 +232,7 @@ public class AllocationTokenFlowUtils {
|
||||
String domainName,
|
||||
AllocationToken token,
|
||||
CommandName commandName,
|
||||
DateTime now,
|
||||
Instant now,
|
||||
Optional<Integer> years,
|
||||
DomainPricingLogic pricingLogic)
|
||||
throws EppException {
|
||||
@@ -244,13 +242,12 @@ public class AllocationTokenFlowUtils {
|
||||
case CREATE ->
|
||||
pricingLogic
|
||||
.getCreatePrice(
|
||||
tld, domainName, toInstant(now), yearsForAction, false, false, Optional.of(token))
|
||||
tld, domainName, now, yearsForAction, false, false, Optional.of(token))
|
||||
.getTotalCost()
|
||||
.getAmount();
|
||||
case RENEW ->
|
||||
pricingLogic
|
||||
.getRenewPrice(
|
||||
tld, domainName, toInstant(now), yearsForAction, null, Optional.of(token))
|
||||
.getRenewPrice(tld, domainName, now, yearsForAction, null, Optional.of(token))
|
||||
.getTotalCost()
|
||||
.getAmount();
|
||||
default -> BigDecimal.ZERO;
|
||||
@@ -259,7 +256,7 @@ public class AllocationTokenFlowUtils {
|
||||
|
||||
/** Loads a given token and validates it against the registrar, time, etc */
|
||||
private static AllocationToken loadAndValidateToken(
|
||||
String token, String registrarId, String domainName, DateTime now)
|
||||
String token, String registrarId, String domainName, Instant now)
|
||||
throws NonexistentAllocationTokenException, AllocationTokenInvalidException {
|
||||
if (Strings.isNullOrEmpty(token)) {
|
||||
// We load the token directly from the input XML. If it's null or empty we should throw
|
||||
@@ -283,7 +280,7 @@ public class AllocationTokenFlowUtils {
|
||||
}
|
||||
|
||||
private static void validateTokenEntity(
|
||||
AllocationToken token, String registrarId, String domainName, DateTime now)
|
||||
AllocationToken token, String registrarId, String domainName, Instant now)
|
||||
throws AllocationTokenInvalidException {
|
||||
if (token.isRedeemed()) {
|
||||
throw new AlreadyRedeemedAllocationTokenException();
|
||||
|
||||
@@ -62,7 +62,7 @@ public final class HostCheckFlow implements TransactionalFlow {
|
||||
ImmutableList<String> hostnames = ((Check) resourceCommand).getTargetIds();
|
||||
verifyTargetIdCount(hostnames, maxChecks);
|
||||
ImmutableSet<String> existingIds =
|
||||
ForeignKeyUtils.loadKeys(Host.class, hostnames, clock.nowUtc()).keySet();
|
||||
ForeignKeyUtils.loadKeys(Host.class, hostnames, clock.now()).keySet();
|
||||
ImmutableList.Builder<HostCheck> checks = new ImmutableList.Builder<>();
|
||||
for (String hostname : hostnames) {
|
||||
HostFlowUtils.validateHostName(hostname);
|
||||
|
||||
@@ -25,7 +25,6 @@ import static google.registry.model.EppResourceUtils.createRepoId;
|
||||
import static google.registry.model.reporting.HistoryEntry.Type.HOST_CREATE;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.util.CollectionUtils.isNullOrEmpty;
|
||||
import static google.registry.util.DateTimeUtils.toDateTime;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
@@ -101,7 +100,7 @@ public final class HostCreateFlow implements MutatingFlow {
|
||||
extensionManager.validate();
|
||||
Create command = (Create) resourceCommand;
|
||||
Instant now = tm().getTxTime();
|
||||
verifyResourceDoesNotExist(Host.class, targetId, toDateTime(now), registrarId);
|
||||
verifyResourceDoesNotExist(Host.class, targetId, now, registrarId);
|
||||
// The superordinate domain of the host object if creating an in-bailiwick host, or null if
|
||||
// creating an external host. This is looked up before we actually create the Host object, so
|
||||
// we can detect error conditions earlier.
|
||||
|
||||
@@ -24,7 +24,6 @@ import static google.registry.flows.ResourceFlowUtils.verifyResourceOwnership;
|
||||
import static google.registry.flows.host.HostFlowUtils.validateHostName;
|
||||
import static google.registry.model.eppoutput.Result.Code.SUCCESS;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.util.DateTimeUtils.toDateTime;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.flows.EppException;
|
||||
@@ -85,7 +84,7 @@ public final class HostDeleteFlow implements MutatingFlow {
|
||||
extensionManager.validate();
|
||||
Instant now = tm().getTxTime();
|
||||
validateHostName(targetId);
|
||||
checkLinkedDomains(targetId, toDateTime(now));
|
||||
checkLinkedDomains(targetId, now);
|
||||
Host existingHost = loadAndVerifyExistence(Host.class, targetId, now);
|
||||
verifyNoDisallowedStatuses(existingHost, ImmutableSet.of(StatusValue.PENDING_DELETE));
|
||||
if (!isSuperuser) {
|
||||
|
||||
@@ -16,12 +16,14 @@ package google.registry.model;
|
||||
import static com.google.common.collect.ImmutableSortedMap.toImmutableSortedMap;
|
||||
import static com.google.common.collect.ImmutableSortedSet.toImmutableSortedSet;
|
||||
import static com.google.common.collect.Ordering.natural;
|
||||
import static google.registry.util.DateTimeUtils.ISO_8601_FORMATTER;
|
||||
import static google.registry.util.DateTimeUtils.formatInstant;
|
||||
import static google.registry.util.DateTimeUtils.parseInstant;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.KeyDeserializer;
|
||||
import com.fasterxml.jackson.databind.MapperFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
@@ -64,6 +66,8 @@ public class EntityYamlUtils {
|
||||
module.addSerializer(CreateAutoTimestamp.class, new CreateAutoTimestampSerializer());
|
||||
module.addDeserializer(CreateAutoTimestamp.class, new CreateAutoTimestampDeserializer());
|
||||
module.addSerializer(Duration.class, new DurationSerializer());
|
||||
module.addKeySerializer(Instant.class, new InstantKeySerializer());
|
||||
module.addKeyDeserializer(Instant.class, new InstantKeyDeserializer());
|
||||
module.addSerializer(Instant.class, new InstantSerializer());
|
||||
module.addDeserializer(Instant.class, new InstantDeserializer());
|
||||
ObjectMapper mapper =
|
||||
@@ -416,7 +420,7 @@ public class EntityYamlUtils {
|
||||
if (value.getTimestamp() == null) {
|
||||
gen.writeNull();
|
||||
} else {
|
||||
gen.writeString(ISO_8601_FORMATTER.format(value.getTimestamp()));
|
||||
gen.writeString(formatInstant(value.getTimestamp()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -441,6 +445,24 @@ public class EntityYamlUtils {
|
||||
}
|
||||
|
||||
/** A custom JSON serializer for {@link Instant}. */
|
||||
|
||||
/** A custom JSON key serializer for {@link Instant}. */
|
||||
public static class InstantKeySerializer extends JsonSerializer<Instant> {
|
||||
@Override
|
||||
public void serialize(Instant value, JsonGenerator gen, SerializerProvider provider)
|
||||
throws IOException {
|
||||
gen.writeFieldName(formatInstant(value));
|
||||
}
|
||||
}
|
||||
|
||||
/** A custom JSON key deserializer for {@link Instant}. */
|
||||
public static class InstantKeyDeserializer extends KeyDeserializer {
|
||||
@Override
|
||||
public Object deserializeKey(String key, DeserializationContext ctxt) throws IOException {
|
||||
return parseInstant(key);
|
||||
}
|
||||
}
|
||||
|
||||
public static class InstantSerializer extends StdSerializer<Instant> {
|
||||
|
||||
public InstantSerializer() {
|
||||
@@ -450,7 +472,7 @@ public class EntityYamlUtils {
|
||||
@Override
|
||||
public void serialize(Instant value, JsonGenerator gen, SerializerProvider provider)
|
||||
throws IOException {
|
||||
gen.writeString(ISO_8601_FORMATTER.format(value));
|
||||
gen.writeString(formatInstant(value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -154,8 +154,7 @@ public final class EppResourceUtils {
|
||||
* @return the resource at {@code timestamp} or {@code null} if resource is deleted or not yet
|
||||
* created.
|
||||
*/
|
||||
public static <T extends EppResource> T loadAtPointInTime(
|
||||
final T resource, final Instant timestamp) {
|
||||
public static <T extends EppResource> T loadAtPointInTime(final T resource, Instant timestamp) {
|
||||
// If we're before the resource creation time, don't try to find a "most recent revision".
|
||||
if (timestamp.isBefore(resource.getCreationTime())) {
|
||||
return null;
|
||||
@@ -189,7 +188,7 @@ public final class EppResourceUtils {
|
||||
* falling back to using the resource as-is if there are no revisions.
|
||||
*/
|
||||
private static <T extends EppResource> T loadMostRecentRevisionAtTime(
|
||||
final T resource, final Instant timestamp) {
|
||||
final T resource, Instant timestamp) {
|
||||
@SuppressWarnings("unchecked")
|
||||
T resourceAtPointInTime =
|
||||
(T)
|
||||
|
||||
@@ -16,7 +16,7 @@ package google.registry.model;
|
||||
|
||||
import static com.google.common.collect.Iterables.transform;
|
||||
import static com.google.common.collect.Maps.transformValues;
|
||||
import static google.registry.util.DateTimeUtils.ISO_8601_FORMATTER;
|
||||
import static google.registry.util.DateTimeUtils.formatInstant;
|
||||
import static java.lang.annotation.ElementType.FIELD;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import static java.util.stream.Collectors.toCollection;
|
||||
@@ -143,7 +143,7 @@ public abstract class ImmutableObject implements Cloneable {
|
||||
for (Entry<Field, Object> entry : getSignificantFields().entrySet()) {
|
||||
Object value = entry.getValue();
|
||||
if (value instanceof Instant instant) {
|
||||
value = ISO_8601_FORMATTER.format(instant);
|
||||
value = formatInstant(instant);
|
||||
}
|
||||
sortedFields.put(entry.getKey().getName(), value);
|
||||
}
|
||||
@@ -161,7 +161,7 @@ public abstract class ImmutableObject implements Cloneable {
|
||||
? entry.getValue()
|
||||
: hydrate(entry.getValue());
|
||||
if (value instanceof Instant instant) {
|
||||
value = ISO_8601_FORMATTER.format(instant);
|
||||
value = formatInstant(instant);
|
||||
}
|
||||
sortedFields.put(field.getName(), value);
|
||||
}
|
||||
@@ -187,7 +187,7 @@ public abstract class ImmutableObject implements Cloneable {
|
||||
return immutableObject.toHydratedString();
|
||||
}
|
||||
if (value instanceof Instant instant) {
|
||||
return ISO_8601_FORMATTER.format(instant);
|
||||
return formatInstant(instant);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@@ -225,7 +225,7 @@ public abstract class ImmutableObject implements Cloneable {
|
||||
// original ImmutableObject might have been the result of a cloneEmptyToNull call).
|
||||
.collect(toList());
|
||||
} else if (o instanceof Instant instant) {
|
||||
return ISO_8601_FORMATTER.format(instant);
|
||||
return formatInstant(instant);
|
||||
} else if (o instanceof Number || o instanceof Boolean) {
|
||||
return o;
|
||||
} else {
|
||||
|
||||
@@ -21,7 +21,7 @@ import static com.google.common.collect.ImmutableMap.toImmutableMap;
|
||||
import static google.registry.model.tld.Tld.TldState.GENERAL_AVAILABILITY;
|
||||
import static google.registry.model.tld.Tld.TldState.START_DATE_SUNRISE;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -46,6 +46,7 @@ import google.registry.persistence.VKey;
|
||||
import google.registry.tools.IamClient;
|
||||
import google.registry.util.CidrAddressBlock;
|
||||
import google.registry.util.RegistryEnvironment;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -108,13 +109,13 @@ public final class OteAccountBuilder {
|
||||
.setZip("55555")
|
||||
.build();
|
||||
|
||||
private static final ImmutableSortedMap<DateTime, Money> EAP_FEE_SCHEDULE =
|
||||
private static final ImmutableSortedMap<Instant, Money> EAP_FEE_SCHEDULE =
|
||||
ImmutableSortedMap.of(
|
||||
new DateTime(0),
|
||||
Instant.EPOCH,
|
||||
Money.of(CurrencyUnit.USD, 0),
|
||||
DateTime.parse("2018-03-01T00:00:00Z"),
|
||||
Instant.parse("2018-03-01T00:00:00Z"),
|
||||
Money.of(CurrencyUnit.USD, 100),
|
||||
DateTime.parse("2030-03-01T00:00:00Z"),
|
||||
Instant.parse("2030-03-01T00:00:00Z"),
|
||||
Money.of(CurrencyUnit.USD, 0));
|
||||
|
||||
/**
|
||||
@@ -330,7 +331,7 @@ public final class OteAccountBuilder {
|
||||
new Tld.Builder()
|
||||
.setTldStr(tldName)
|
||||
.setPremiumPricingEngine(StaticPremiumListPricingEngine.NAME)
|
||||
.setTldStateTransitions(ImmutableSortedMap.of(START_OF_TIME, initialTldState))
|
||||
.setTldStateTransitions(ImmutableSortedMap.of(START_INSTANT, initialTldState))
|
||||
.setDnsWriters(ImmutableSet.of("VoidDnsWriter"))
|
||||
.setPremiumList(premiumList.get())
|
||||
.setTldType(TldType.TEST)
|
||||
|
||||
@@ -17,8 +17,8 @@ package google.registry.model.common;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.collect.ImmutableSortedMap.toImmutableSortedMap;
|
||||
import static google.registry.util.DateTimeUtils.ISO_8601_FORMATTER;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.formatInstant;
|
||||
import static google.registry.util.DateTimeUtils.latestOf;
|
||||
import static google.registry.util.DateTimeUtils.toDateTime;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
@@ -63,9 +63,7 @@ public class TimedTransitionProperty<V extends Serializable> implements UnsafeSe
|
||||
return backingMap.entrySet().stream()
|
||||
.collect(
|
||||
toImmutableSortedMap(
|
||||
Ordering.natural(),
|
||||
e -> ISO_8601_FORMATTER.format(e.getKey()),
|
||||
Map.Entry::getValue));
|
||||
Ordering.natural(), e -> formatInstant(e.getKey()), Map.Entry::getValue));
|
||||
}
|
||||
|
||||
private TimedTransitionProperty(ImmutableSortedMap<Instant, V> backingMap) {
|
||||
@@ -281,7 +279,7 @@ public class TimedTransitionProperty<V extends Serializable> implements UnsafeSe
|
||||
@Override
|
||||
public String toString() {
|
||||
return backingMap.entrySet().stream()
|
||||
.map(e -> ISO_8601_FORMATTER.format(e.getKey()) + "=" + e.getValue())
|
||||
.map(e -> formatInstant(e.getKey()) + "=" + e.getValue())
|
||||
.collect(Collectors.joining(", ", "{", "}"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,11 @@
|
||||
elementFormDefault = XmlNsForm.QUALIFIED)
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlJavaTypeAdapters({
|
||||
@XmlJavaTypeAdapter(UtcDateTimeAdapter.class),
|
||||
@XmlJavaTypeAdapter(UtcInstantAdapter.class),
|
||||
@XmlJavaTypeAdapter(UtcInstantAdapter.class)
|
||||
})
|
||||
package google.registry.model.contact;
|
||||
|
||||
import google.registry.xml.UtcDateTimeAdapter;
|
||||
import google.registry.xml.UtcInstantAdapter;
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
|
||||
@@ -533,9 +533,8 @@ public class DomainBase extends EppResource {
|
||||
GracePeriod.createForRecurrence(
|
||||
GracePeriodStatus.AUTO_RENEW,
|
||||
domain.getRepoId(),
|
||||
lastAutorenewTime.plus(
|
||||
Duration.ofMillis(
|
||||
Tld.get(domain.getTld()).getAutoRenewGracePeriodLength().getMillis())),
|
||||
lastAutorenewTime.plusMillis(
|
||||
Tld.get(domain.getTld()).getAutoRenewGracePeriodLength().getMillis()),
|
||||
domain.getCurrentSponsorRegistrarId(),
|
||||
domain.getAutorenewBillingEvent()));
|
||||
newLastEppUpdateTime = Optional.of(lastAutorenewTime);
|
||||
|
||||
@@ -16,6 +16,7 @@ package google.registry.model.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static google.registry.util.DateTimeUtils.isBeforeOrAt;
|
||||
import static google.registry.util.DateTimeUtils.minusHours;
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
@@ -36,10 +37,10 @@ import jakarta.persistence.Index;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
import org.joda.time.Duration;
|
||||
|
||||
/**
|
||||
* Represents a registry lock/unlock object, meaning that the domain is locked on the registry
|
||||
@@ -155,7 +156,7 @@ public final class RegistryLock extends UpdateAutoTimestampEntity implements Bui
|
||||
|
||||
/** The duration after which we will re-lock this domain after it is unlocked. */
|
||||
@Column(columnDefinition = "interval")
|
||||
private org.joda.time.Duration relockDuration;
|
||||
private Duration relockDuration;
|
||||
|
||||
public String getRepoId() {
|
||||
return repoId;
|
||||
@@ -221,7 +222,7 @@ public final class RegistryLock extends UpdateAutoTimestampEntity implements Bui
|
||||
}
|
||||
|
||||
/** The duration after which we will re-lock this domain after it is unlocked. */
|
||||
public Optional<org.joda.time.Duration> getRelockDuration() {
|
||||
public Optional<Duration> getRelockDuration() {
|
||||
return Optional.ofNullable(relockDuration);
|
||||
}
|
||||
|
||||
@@ -232,7 +233,7 @@ public final class RegistryLock extends UpdateAutoTimestampEntity implements Bui
|
||||
/** Returns true iff the lock was requested >= 1 hour ago and has not been verified. */
|
||||
public boolean isLockRequestExpired(Instant now) {
|
||||
return getLockCompletionTime().isEmpty()
|
||||
&& isBeforeOrAt(getLockRequestTime(), now.minus(Duration.ofHours(1)));
|
||||
&& isBeforeOrAt(getLockRequestTime(), minusHours(now, 1));
|
||||
}
|
||||
|
||||
/** Returns true iff the unlock was requested >= 1 hour ago and has not been verified. */
|
||||
@@ -240,7 +241,7 @@ public final class RegistryLock extends UpdateAutoTimestampEntity implements Bui
|
||||
Optional<Instant> unlockRequestTimestamp = getUnlockRequestTime();
|
||||
return unlockRequestTimestamp.isPresent()
|
||||
&& getUnlockCompletionTime().isEmpty()
|
||||
&& isBeforeOrAt(unlockRequestTimestamp.get(), now.minus(Duration.ofHours(1)));
|
||||
&& isBeforeOrAt(unlockRequestTimestamp.get(), minusHours(now, 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -318,7 +319,7 @@ public final class RegistryLock extends UpdateAutoTimestampEntity implements Bui
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setRelockDuration(@Nullable org.joda.time.Duration relockDuration) {
|
||||
public Builder setRelockDuration(@Nullable Duration relockDuration) {
|
||||
getInstance().relockDuration = relockDuration;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -18,12 +18,10 @@
|
||||
elementFormDefault = XmlNsForm.QUALIFIED)
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlJavaTypeAdapters({
|
||||
@XmlJavaTypeAdapter(UtcDateTimeAdapter.class),
|
||||
@XmlJavaTypeAdapter(UtcInstantAdapter.class)
|
||||
})
|
||||
package google.registry.model.domain.launch;
|
||||
|
||||
import google.registry.xml.UtcDateTimeAdapter;
|
||||
import google.registry.xml.UtcInstantAdapter;
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
|
||||
@@ -18,14 +18,13 @@
|
||||
elementFormDefault = XmlNsForm.QUALIFIED)
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlJavaTypeAdapters({
|
||||
@XmlJavaTypeAdapter(UtcDateTimeAdapter.class),
|
||||
@XmlJavaTypeAdapter(UtcInstantAdapter.class),
|
||||
@XmlJavaTypeAdapter(UtcInstantAdapter.class),
|
||||
@XmlJavaTypeAdapter(DateAdapter.class)
|
||||
})
|
||||
package google.registry.model.domain;
|
||||
|
||||
import google.registry.xml.DateAdapter;
|
||||
import google.registry.xml.UtcDateTimeAdapter;
|
||||
import google.registry.xml.UtcInstantAdapter;
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
|
||||
@@ -18,12 +18,11 @@
|
||||
elementFormDefault = XmlNsForm.QUALIFIED)
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlJavaTypeAdapters({
|
||||
@XmlJavaTypeAdapter(UtcDateTimeAdapter.class),
|
||||
@XmlJavaTypeAdapter(UtcInstantAdapter.class),
|
||||
@XmlJavaTypeAdapter(UtcInstantAdapter.class)
|
||||
})
|
||||
package google.registry.model.eppinput;
|
||||
|
||||
import google.registry.xml.UtcDateTimeAdapter;
|
||||
import google.registry.xml.UtcInstantAdapter;
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
|
||||
@@ -18,12 +18,11 @@
|
||||
elementFormDefault = XmlNsForm.QUALIFIED)
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlJavaTypeAdapters({
|
||||
@XmlJavaTypeAdapter(UtcDateTimeAdapter.class),
|
||||
@XmlJavaTypeAdapter(UtcInstantAdapter.class),
|
||||
@XmlJavaTypeAdapter(UtcInstantAdapter.class)
|
||||
})
|
||||
package google.registry.model.eppoutput;
|
||||
|
||||
import google.registry.xml.UtcDateTimeAdapter;
|
||||
import google.registry.xml.UtcInstantAdapter;
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
|
||||
@@ -18,13 +18,12 @@
|
||||
elementFormDefault = XmlNsForm.QUALIFIED)
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlJavaTypeAdapters({
|
||||
@XmlJavaTypeAdapter(UtcDateTimeAdapter.class),
|
||||
@XmlJavaTypeAdapter(UtcInstantAdapter.class),
|
||||
@XmlJavaTypeAdapter(UtcInstantAdapter.class),
|
||||
@XmlJavaTypeAdapter(InetAddressAdapter.class)
|
||||
})
|
||||
package google.registry.model.host;
|
||||
|
||||
import google.registry.xml.UtcDateTimeAdapter;
|
||||
import google.registry.xml.UtcInstantAdapter;
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
xmlns = @XmlNs(namespaceURI = "urn:ietf:params:xml:ns:epp-1.0", prefix = ""),
|
||||
elementFormDefault = XmlNsForm.QUALIFIED)
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlJavaTypeAdapter(UtcDateTimeAdapter.class)
|
||||
@XmlJavaTypeAdapter(UtcInstantAdapter.class)
|
||||
package google.registry.model;
|
||||
|
||||
import google.registry.xml.UtcDateTimeAdapter;
|
||||
import google.registry.xml.UtcInstantAdapter;
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
import jakarta.xml.bind.annotation.XmlNs;
|
||||
|
||||
@@ -18,12 +18,11 @@
|
||||
elementFormDefault = XmlNsForm.QUALIFIED)
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlJavaTypeAdapters({
|
||||
@XmlJavaTypeAdapter(UtcDateTimeAdapter.class),
|
||||
@XmlJavaTypeAdapter(UtcInstantAdapter.class),
|
||||
@XmlJavaTypeAdapter(UtcInstantAdapter.class)
|
||||
})
|
||||
package google.registry.model.poll;
|
||||
|
||||
import google.registry.xml.UtcDateTimeAdapter;
|
||||
import google.registry.xml.UtcInstantAdapter;
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
|
||||
@@ -616,15 +616,6 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl
|
||||
return invoicingEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the TLD state at the given time. Defaults to {@link TldState#PREDELEGATION}.
|
||||
*
|
||||
* <p>Note that {@link TldState#PDT} TLDs pretend to be in {@link TldState#GENERAL_AVAILABILITY}.
|
||||
*/
|
||||
public TldState getTldState(DateTime now) {
|
||||
return getTldState(toInstant(now));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the TLD state at the given time. Defaults to {@link TldState#PREDELEGATION}.
|
||||
*
|
||||
@@ -635,11 +626,6 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl
|
||||
return TldState.PDT.equals(state) ? TldState.GENERAL_AVAILABILITY : state;
|
||||
}
|
||||
|
||||
/** Retrieve whether this TLD is in predelegation testing. */
|
||||
public boolean isPdt(DateTime now) {
|
||||
return isPdt(toInstant(now));
|
||||
}
|
||||
|
||||
/** Retrieve whether this TLD is in predelegation testing. */
|
||||
public boolean isPdt(Instant now) {
|
||||
return TldState.PDT.equals(tldStateTransitions.getValueAtTime(now));
|
||||
@@ -702,14 +688,6 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl
|
||||
return currency;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use {@code PricingEngineProxy.getDomainCreateCost} instead of this to find the cost for a
|
||||
* domain create.
|
||||
*/
|
||||
public Money getCreateBillingCost(DateTime now) {
|
||||
return getCreateBillingCost(toInstant(now));
|
||||
}
|
||||
|
||||
/**
|
||||
* Use {@code PricingEngineProxy.getDomainCreateCost} instead of this to find the cost for a
|
||||
* domain create.
|
||||
@@ -718,12 +696,7 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl
|
||||
return createBillingCostTransitions.getValueAtTime(now);
|
||||
}
|
||||
|
||||
public ImmutableSortedMap<DateTime, Money> getCreateBillingCostTransitions() {
|
||||
return createBillingCostTransitions.toValueMap();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public ImmutableSortedMap<Instant, Money> getCreateBillingCostTransitionsInstant() {
|
||||
public ImmutableSortedMap<Instant, Money> getCreateBillingCostTransitions() {
|
||||
return createBillingCostTransitions.toValueMapInstant();
|
||||
}
|
||||
|
||||
@@ -735,15 +708,6 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl
|
||||
return restoreBillingCost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use {@code PricingEngineProxy.getDomainRenewCost} instead of this to find the cost for a domain
|
||||
* renewal, and all derived costs (i.e. autorenews, transfers, and the per-domain part of a
|
||||
* restore cost).
|
||||
*/
|
||||
public Money getStandardRenewCost(DateTime now) {
|
||||
return getStandardRenewCost(toInstant(now));
|
||||
}
|
||||
|
||||
/**
|
||||
* Use {@code PricingEngineProxy.getDomainRenewCost} instead of this to find the cost for a domain
|
||||
* renewal, and all derived costs (i.e. autorenews, transfers, and the per-domain part of a
|
||||
@@ -763,32 +727,17 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl
|
||||
return registryLockOrUnlockBillingCost;
|
||||
}
|
||||
|
||||
public ImmutableSortedMap<DateTime, TldState> getTldStateTransitions() {
|
||||
return tldStateTransitions.toValueMap();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public ImmutableSortedMap<Instant, TldState> getTldStateTransitionsInstant() {
|
||||
public ImmutableSortedMap<Instant, TldState> getTldStateTransitions() {
|
||||
return tldStateTransitions.toValueMapInstant();
|
||||
}
|
||||
|
||||
public ImmutableSortedMap<DateTime, Money> getRenewBillingCostTransitions() {
|
||||
return renewBillingCostTransitions.toValueMap();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public ImmutableSortedMap<Instant, Money> getRenewBillingCostTransitionsInstant() {
|
||||
public ImmutableSortedMap<Instant, Money> getRenewBillingCostTransitions() {
|
||||
return renewBillingCostTransitions.toValueMapInstant();
|
||||
}
|
||||
|
||||
/** Returns the EAP fee for the tld at the given time. */
|
||||
public Fee getEapFeeFor(DateTime now) {
|
||||
return getEapFeeFor(toInstant(now));
|
||||
}
|
||||
|
||||
/** Returns the EAP fee for the tld at the given time. */
|
||||
public Fee getEapFeeFor(Instant now) {
|
||||
ImmutableSortedMap<Instant, Money> valueMap = getEapFeeScheduleAsMapInstant();
|
||||
ImmutableSortedMap<Instant, Money> valueMap = getEapFeeScheduleAsMap();
|
||||
Instant periodStart = valueMap.floorKey(now);
|
||||
Instant periodEnd = valueMap.ceilingKey(now);
|
||||
// NOTE: assuming END_INSTANT would never be reached...
|
||||
@@ -808,13 +757,7 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl
|
||||
|
||||
@VisibleForTesting
|
||||
@JsonProperty("eapFeeSchedule")
|
||||
public ImmutableSortedMap<DateTime, Money> getEapFeeScheduleAsMap() {
|
||||
return eapFeeSchedule.toValueMap();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@VisibleForTesting
|
||||
public ImmutableSortedMap<Instant, Money> getEapFeeScheduleAsMapInstant() {
|
||||
public ImmutableSortedMap<Instant, Money> getEapFeeScheduleAsMap() {
|
||||
return eapFeeSchedule.toValueMapInstant();
|
||||
}
|
||||
|
||||
@@ -822,12 +765,7 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl
|
||||
return lordnUsername;
|
||||
}
|
||||
|
||||
public DateTime getClaimsPeriodEnd() {
|
||||
return toDateTime(claimsPeriodEnd);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Instant getClaimsPeriodEndInstant() {
|
||||
public Instant getClaimsPeriodEnd() {
|
||||
return claimsPeriodEnd;
|
||||
}
|
||||
|
||||
@@ -904,17 +842,7 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl
|
||||
}
|
||||
|
||||
/** Sets the TLD state to transition to the specified states at the specified times. */
|
||||
public Builder setTldStateTransitions(ImmutableSortedMap<DateTime, TldState> tldStatesMap) {
|
||||
return setTldStateTransitionsInstant(
|
||||
tldStatesMap.entrySet().stream()
|
||||
.collect(
|
||||
ImmutableSortedMap.toImmutableSortedMap(
|
||||
Ordering.natural(), e -> toInstant(e.getKey()), Map.Entry::getValue)));
|
||||
}
|
||||
|
||||
/** Sets the TLD state to transition to the specified states at the specified times. */
|
||||
public Builder setTldStateTransitionsInstant(
|
||||
ImmutableSortedMap<Instant, TldState> tldStatesMap) {
|
||||
public Builder setTldStateTransitions(ImmutableSortedMap<Instant, TldState> tldStatesMap) {
|
||||
checkNotNull(tldStatesMap, "TLD states map cannot be null");
|
||||
// Filter out any entries with QUIET_PERIOD as the value before checking for ordering, since
|
||||
// that phase is allowed to appear anywhere.
|
||||
@@ -1046,15 +974,6 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl
|
||||
}
|
||||
|
||||
public Builder setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap<DateTime, Money> createCostsMap) {
|
||||
return setCreateBillingCostTransitionsInstant(
|
||||
createCostsMap.entrySet().stream()
|
||||
.collect(
|
||||
ImmutableSortedMap.toImmutableSortedMap(
|
||||
Ordering.natural(), e -> toInstant(e.getKey()), Map.Entry::getValue)));
|
||||
}
|
||||
|
||||
public Builder setCreateBillingCostTransitionsInstant(
|
||||
ImmutableSortedMap<Instant, Money> createCostsMap) {
|
||||
checkArgumentNotNull(createCostsMap, "Create billing costs map cannot be null");
|
||||
checkArgument(
|
||||
@@ -1107,24 +1026,7 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the renew billing cost to transition to the specified values at the specified times.
|
||||
*
|
||||
* <p>Renew billing costs transitions should only be added at least 5 days (the length of an
|
||||
* automatic transfer) in advance, to avoid discrepancies between the cost stored with the
|
||||
* billing event (created when the transfer is requested) and the cost at the time when the
|
||||
* transfer actually occurs (5 days later).
|
||||
*/
|
||||
public Builder setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap<DateTime, Money> renewCostsMap) {
|
||||
return setRenewBillingCostTransitionsInstant(
|
||||
renewCostsMap.entrySet().stream()
|
||||
.collect(
|
||||
ImmutableSortedMap.toImmutableSortedMap(
|
||||
Ordering.natural(), e -> toInstant(e.getKey()), Map.Entry::getValue)));
|
||||
}
|
||||
|
||||
public Builder setRenewBillingCostTransitionsInstant(
|
||||
ImmutableSortedMap<Instant, Money> renewCostsMap) {
|
||||
checkArgumentNotNull(renewCostsMap, "Renew billing costs map cannot be null");
|
||||
checkArgument(
|
||||
@@ -1136,16 +1038,7 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl
|
||||
}
|
||||
|
||||
/** Sets the EAP fee schedule for the TLD. */
|
||||
public Builder setEapFeeSchedule(ImmutableSortedMap<DateTime, Money> eapFeeSchedule) {
|
||||
return setEapFeeScheduleInstant(
|
||||
eapFeeSchedule.entrySet().stream()
|
||||
.collect(
|
||||
ImmutableSortedMap.toImmutableSortedMap(
|
||||
Ordering.natural(), e -> toInstant(e.getKey()), Map.Entry::getValue)));
|
||||
}
|
||||
|
||||
/** Sets the EAP fee schedule for the TLD. */
|
||||
public Builder setEapFeeScheduleInstant(ImmutableSortedMap<Instant, Money> eapFeeSchedule) {
|
||||
public Builder setEapFeeSchedule(ImmutableSortedMap<Instant, Money> eapFeeSchedule) {
|
||||
checkArgumentNotNull(eapFeeSchedule, "EAP fee schedule cannot be null");
|
||||
checkArgument(
|
||||
eapFeeSchedule.values().stream().allMatch(Money::isPositiveOrZero),
|
||||
@@ -1184,11 +1077,7 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setClaimsPeriodEnd(DateTime claimsPeriodEnd) {
|
||||
return setClaimsPeriodEndInstant(toInstant(claimsPeriodEnd));
|
||||
}
|
||||
|
||||
public Builder setClaimsPeriodEndInstant(Instant claimsPeriodEnd) {
|
||||
public Builder setClaimsPeriodEnd(Instant claimsPeriodEnd) {
|
||||
getInstance().claimsPeriodEnd = checkArgumentNotNull(claimsPeriodEnd);
|
||||
return this;
|
||||
}
|
||||
@@ -1277,12 +1166,10 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl
|
||||
Predicate<Money> currencyCheck =
|
||||
(Money money) -> money.getCurrencyUnit().equals(instance.currency);
|
||||
checkArgument(
|
||||
instance.getRenewBillingCostTransitionsInstant().values().stream()
|
||||
.allMatch(currencyCheck),
|
||||
instance.getRenewBillingCostTransitions().values().stream().allMatch(currencyCheck),
|
||||
"Renew cost must be in the TLD's currency");
|
||||
checkArgument(
|
||||
instance.getCreateBillingCostTransitionsInstant().values().stream()
|
||||
.allMatch(currencyCheck),
|
||||
instance.getCreateBillingCostTransitions().values().stream().allMatch(currencyCheck),
|
||||
"Create cost must be in the TLD's currency");
|
||||
checkArgument(
|
||||
instance.eapFeeSchedule.toValueMapInstant().values().stream().allMatch(currencyCheck),
|
||||
|
||||
@@ -18,12 +18,11 @@
|
||||
elementFormDefault = XmlNsForm.QUALIFIED)
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlJavaTypeAdapters({
|
||||
@XmlJavaTypeAdapter(UtcDateTimeAdapter.class),
|
||||
@XmlJavaTypeAdapter(UtcInstantAdapter.class),
|
||||
@XmlJavaTypeAdapter(UtcInstantAdapter.class)
|
||||
})
|
||||
package google.registry.model.transfer;
|
||||
|
||||
import google.registry.xml.UtcDateTimeAdapter;
|
||||
import google.registry.xml.UtcInstantAdapter;
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
|
||||
+2
-4
@@ -16,7 +16,7 @@ package google.registry.persistence.converter;
|
||||
|
||||
import static com.google.common.collect.ImmutableMap.toImmutableMap;
|
||||
import static com.google.common.collect.ImmutableSortedMap.toImmutableSortedMap;
|
||||
import static google.registry.util.DateTimeUtils.ISO_8601_FORMATTER;
|
||||
import static google.registry.util.DateTimeUtils.formatInstant;
|
||||
import static google.registry.util.DateTimeUtils.parseInstant;
|
||||
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
@@ -47,9 +47,7 @@ public abstract class TimedTransitionBaseUserType<V extends Serializable>
|
||||
@Override
|
||||
Map<String, String> toStringMap(TimedTransitionProperty<V> map) {
|
||||
return map.toValueMapInstant().entrySet().stream()
|
||||
.collect(
|
||||
toImmutableMap(
|
||||
e -> ISO_8601_FORMATTER.format(e.getKey()), e -> valueToString(e.getValue())));
|
||||
.collect(toImmutableMap(e -> formatInstant(e.getKey()), e -> valueToString(e.getValue())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,7 +16,7 @@ package google.registry.rdap;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static google.registry.util.DateTimeUtils.ISO_8601_FORMATTER;
|
||||
import static google.registry.util.DateTimeUtils.formatInstant;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
@@ -343,8 +343,8 @@ abstract class AbstractJsonableObject implements Jsonable {
|
||||
if (object instanceof Instant instant) {
|
||||
// According to RFC 9083 section 3, the syntax of dates and times is defined in RFC3339.
|
||||
//
|
||||
// According to RFC3339, we should use ISO8601, so we use ISO_8601_FORMATTER.
|
||||
return new JsonPrimitive(ISO_8601_FORMATTER.format(instant));
|
||||
// According to RFC3339, we should use ISO8601, so we use formatInstant.
|
||||
return new JsonPrimitive(formatInstant(instant));
|
||||
}
|
||||
if (object == null) {
|
||||
return JsonNull.INSTANCE;
|
||||
|
||||
@@ -85,7 +85,7 @@ public class RdapDomainAction extends RdapActionBase {
|
||||
|
||||
private void handlePossibleBsaBlock(InternetDomainName domainName) {
|
||||
Tld tld = Tld.get(domainName.parent().toString());
|
||||
if (DomainFlowUtils.isBlockedByBsa(domainName.parts().getFirst(), tld, clock.nowUtc())) {
|
||||
if (DomainFlowUtils.isBlockedByBsa(domainName.parts().getFirst(), tld, clock.now())) {
|
||||
throw new DomainBlockedByBsaException(domainName + " blocked by BSA");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
package google.registry.tmch;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static google.registry.util.DateTimeUtils.ISO_8601_FORMATTER;
|
||||
import static google.registry.util.DateTimeUtils.formatInstant;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import google.registry.model.domain.Domain;
|
||||
@@ -45,7 +45,7 @@ public final class LordnTaskUtils {
|
||||
domain.getDomainName(),
|
||||
domain.getSmdId(),
|
||||
getIanaIdentifier(domain.getCreationRegistrarId()),
|
||||
ISO_8601_FORMATTER.format(domain.getCreationTime())); // Used as creation time.
|
||||
formatInstant(domain.getCreationTime())); // Used as creation time.
|
||||
}
|
||||
|
||||
/** Returns the corresponding CSV LORDN line for a claims domain. */
|
||||
@@ -56,8 +56,8 @@ public final class LordnTaskUtils {
|
||||
domain.getDomainName(),
|
||||
domain.getLaunchNotice().getNoticeId().getTcnId(),
|
||||
getIanaIdentifier(domain.getCreationRegistrarId()),
|
||||
ISO_8601_FORMATTER.format(domain.getCreationTime()), // Used as creation time.
|
||||
ISO_8601_FORMATTER.format(domain.getLaunchNotice().getAcceptedTime()));
|
||||
formatInstant(domain.getCreationTime()), // Used as creation time.
|
||||
formatInstant(domain.getLaunchNotice().getAcceptedTime()));
|
||||
}
|
||||
|
||||
/** Retrieves the IANA identifier for a registrar by its ID. */
|
||||
|
||||
@@ -24,7 +24,7 @@ import static google.registry.tmch.LordnTaskUtils.COLUMNS_CLAIMS;
|
||||
import static google.registry.tmch.LordnTaskUtils.COLUMNS_SUNRISE;
|
||||
import static google.registry.tmch.LordnTaskUtils.getCsvLineForClaimsDomain;
|
||||
import static google.registry.tmch.LordnTaskUtils.getCsvLineForSunriseDomain;
|
||||
import static google.registry.util.DateTimeUtils.ISO_8601_FORMATTER;
|
||||
import static google.registry.util.DateTimeUtils.formatInstant;
|
||||
import static jakarta.servlet.http.HttpServletResponse.SC_ACCEPTED;
|
||||
import static java.nio.charset.StandardCharsets.US_ASCII;
|
||||
|
||||
@@ -172,8 +172,7 @@ public final class NordnUploadAction implements Runnable {
|
||||
phase.equals(PARAM_LORDN_PHASE_SUNRISE) ? COLUMNS_SUNRISE : COLUMNS_CLAIMS;
|
||||
String header =
|
||||
String.format(
|
||||
"1,%s,%d\n%s\n",
|
||||
ISO_8601_FORMATTER.format(clock.now()), domains.size(), columns);
|
||||
"1,%s,%d\n%s\n", formatInstant(clock.now()), domains.size(), columns);
|
||||
try {
|
||||
URL url =
|
||||
uploadCsvToLordn(String.format("/LORDN/%s/%s", tld, phase), header + csv);
|
||||
|
||||
@@ -86,7 +86,7 @@ class EnqueuePollMessageCommand extends MutatingCommand {
|
||||
() -> {
|
||||
Domain domain =
|
||||
ResourceFlowUtils.loadAndVerifyExistence(
|
||||
Domain.class, domainName, tm().getTransactionTime());
|
||||
Domain.class, domainName, tm().getTxTime());
|
||||
ImmutableList<String> registrarIds;
|
||||
if (sendToAll) {
|
||||
registrarIds =
|
||||
@@ -116,7 +116,7 @@ class EnqueuePollMessageCommand extends MutatingCommand {
|
||||
new PollMessage.OneTime.Builder()
|
||||
.setRegistrarId(registrarId)
|
||||
.setHistoryEntry(historyEntry)
|
||||
.setEventTime(tm().getTransactionTime())
|
||||
.setEventTime(tm().getTxTime())
|
||||
.setMsg(message)
|
||||
.build());
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||
import static google.registry.util.CollectionUtils.findDuplicates;
|
||||
import static google.registry.util.DateTimeUtils.toDateTime;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||
|
||||
import com.beust.jcommander.Parameter;
|
||||
@@ -72,7 +73,8 @@ final class RenewDomainCommand extends MutatingEppToolCommand {
|
||||
checkArgument(period < 10, "Cannot renew domains for 10 or more years");
|
||||
DateTime now = clock.nowUtc();
|
||||
for (String domainName : mainParameters) {
|
||||
Domain domain = ResourceFlowUtils.loadAndVerifyExistence(Domain.class, domainName, now);
|
||||
Domain domain =
|
||||
ResourceFlowUtils.loadAndVerifyExistence(Domain.class, domainName, toInstant(now));
|
||||
setSoyTemplate(DomainRenewSoyInfo.getInstance(), DomainRenewSoyInfo.RENEWDOMAIN);
|
||||
SoyMapData soyMapData =
|
||||
new SoyMapData(
|
||||
|
||||
@@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
import static com.google.common.collect.Sets.difference;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
|
||||
import com.beust.jcommander.Parameter;
|
||||
import com.beust.jcommander.Parameters;
|
||||
@@ -126,7 +127,8 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand {
|
||||
throws ResourceFlowUtils.ResourceDoesNotExistException {
|
||||
superuser = true;
|
||||
DateTime now = clock.nowUtc();
|
||||
Domain domain = ResourceFlowUtils.loadAndVerifyExistence(Domain.class, domainName, now);
|
||||
Domain domain =
|
||||
ResourceFlowUtils.loadAndVerifyExistence(Domain.class, domainName, toInstant(now));
|
||||
Set<String> missingHosts =
|
||||
difference(newHosts, ForeignKeyUtils.loadKeys(Host.class, newHosts, now).keySet());
|
||||
checkArgument(missingHosts.isEmpty(), "Hosts do not exist: %s", missingHosts);
|
||||
|
||||
@@ -20,8 +20,8 @@ import static google.registry.flows.domain.DomainFlowUtils.newAutorenewBillingEv
|
||||
import static google.registry.flows.domain.DomainFlowUtils.newAutorenewPollMessage;
|
||||
import static google.registry.flows.domain.DomainFlowUtils.updateAutorenewRecurrenceEndTime;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.util.DateTimeUtils.ISO_8601_FORMATTER;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.formatInstant;
|
||||
import static google.registry.util.DateTimeUtils.isBeforeOrAt;
|
||||
import static google.registry.util.DateTimeUtils.minusYears;
|
||||
import static google.registry.util.DateTimeUtils.toDateTime;
|
||||
@@ -206,7 +206,7 @@ class UnrenewDomainCommand extends ConfirmingCommand {
|
||||
.setMsg(
|
||||
String.format(
|
||||
"Domain %s was unrenewed by %d years; now expires at %s.",
|
||||
domainName, period, ISO_8601_FORMATTER.format(newExpirationTime)))
|
||||
domainName, period, formatInstant(newExpirationTime)))
|
||||
.setHistoryEntry(domainHistory)
|
||||
.setEventTime(now)
|
||||
.build();
|
||||
@@ -224,7 +224,7 @@ class UnrenewDomainCommand extends ConfirmingCommand {
|
||||
// End the old autorenew billing event and poll message now.
|
||||
BillingRecurrence existingBillingRecurrence = tm().loadByKey(domain.getAutorenewBillingEvent());
|
||||
updateAutorenewRecurrenceEndTime(
|
||||
domain, existingBillingRecurrence, now, domainHistory.getHistoryEntryId());
|
||||
domain, existingBillingRecurrence, toInstant(now), domainHistory.getHistoryEntryId());
|
||||
Domain newDomain =
|
||||
domain
|
||||
.asBuilder()
|
||||
|
||||
@@ -28,7 +28,7 @@ import google.registry.request.Action;
|
||||
import google.registry.request.auth.Auth;
|
||||
import google.registry.util.Clock;
|
||||
import jakarta.inject.Inject;
|
||||
import org.joda.time.DateTime;
|
||||
import java.time.Instant;
|
||||
|
||||
/** An action that lists hosts, for use by the {@code nomulus list_hosts} command. */
|
||||
@Action(
|
||||
@@ -50,7 +50,7 @@ public final class ListHostsAction extends ListObjectsAction<Host> {
|
||||
|
||||
@Override
|
||||
public ImmutableSet<Host> loadObjects() {
|
||||
final DateTime now = clock.nowUtc();
|
||||
Instant now = clock.now();
|
||||
return loadAllOf(Host.class)
|
||||
.flatMap(ImmutableList::stream)
|
||||
.filter(host -> EppResourceUtils.isActive(host, now))
|
||||
|
||||
@@ -27,7 +27,7 @@ import google.registry.request.Action;
|
||||
import google.registry.request.auth.Auth;
|
||||
import google.registry.util.Clock;
|
||||
import jakarta.inject.Inject;
|
||||
import org.joda.time.DateTime;
|
||||
import java.time.Instant;
|
||||
|
||||
/** An action that lists top-level domains, for use by the {@code nomulus list_tlds} command. */
|
||||
@Action(
|
||||
@@ -62,7 +62,7 @@ public final class ListTldsAction extends ListObjectsAction<Tld> {
|
||||
|
||||
@Override
|
||||
public ImmutableMap<String, String> getFieldOverrides(Tld tld) {
|
||||
final DateTime now = clock.nowUtc();
|
||||
Instant now = clock.now();
|
||||
return new ImmutableMap.Builder<String, String>()
|
||||
.put("dnsPaused", tld.getDnsPaused() ? "paused" : "-")
|
||||
.put("escrowEnabled", tld.getEscrowEnabled() ? "enabled" : "-")
|
||||
|
||||
+2
-4
@@ -18,7 +18,6 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.request.Action.Method.POST;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentPresent;
|
||||
import static org.apache.http.HttpStatus.SC_OK;
|
||||
|
||||
@@ -40,7 +39,6 @@ import jakarta.inject.Inject;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
@Action(
|
||||
service = Service.CONSOLE,
|
||||
@@ -93,14 +91,14 @@ public class ConsoleUpdateRegistrarAction extends ConsoleApiAction {
|
||||
}
|
||||
}
|
||||
|
||||
DateTime now = tm().getTransactionTime();
|
||||
Instant now = tm().getTxTime();
|
||||
Instant newLastPocVerificationDate =
|
||||
registrarParam.getLastPocVerificationDate() == null
|
||||
? START_INSTANT
|
||||
: registrarParam.getLastPocVerificationDate();
|
||||
|
||||
checkArgument(
|
||||
newLastPocVerificationDate.isBefore(toInstant(now)),
|
||||
newLastPocVerificationDate.isBefore(now),
|
||||
"Invalid value of LastPocVerificationDate - value is in the future");
|
||||
|
||||
var updatedRegistrarBuilder =
|
||||
|
||||
@@ -19,6 +19,7 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.
|
||||
import static google.registry.request.Action.Method.GET;
|
||||
import static google.registry.request.Action.Method.POST;
|
||||
import static google.registry.ui.server.console.PasswordResetRequestAction.checkUserExistsWithRegistryLockEmail;
|
||||
import static google.registry.util.DateTimeUtils.plusHours;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
@@ -33,7 +34,6 @@ import google.registry.request.Parameter;
|
||||
import google.registry.request.auth.Auth;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.time.Duration;
|
||||
import java.util.Optional;
|
||||
|
||||
@Action(
|
||||
@@ -122,7 +122,7 @@ public class PasswordResetVerifyAction extends ConsoleApiAction {
|
||||
case REGISTRY_LOCK -> ConsolePermission.REGISTRY_LOCK;
|
||||
};
|
||||
checkPermission(user, request.getRegistrarId(), requiredVerifyPermission);
|
||||
if (request.getRequestTime().plus(Duration.ofHours(1)).isBefore(tm().getTxTime())) {
|
||||
if (plusHours(request.getRequestTime(), 1).isBefore(tm().getTxTime())) {
|
||||
throw createVerificationCodeException();
|
||||
}
|
||||
return request;
|
||||
|
||||
@@ -49,7 +49,6 @@ import google.registry.testing.DatabaseHelper;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.SystemPropertyExtension;
|
||||
import google.registry.util.RegistryEnvironment;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@@ -239,7 +238,7 @@ class DeleteProberDataActionTest {
|
||||
persistResource(
|
||||
DatabaseHelper.newDomain("blah.ib-any.test")
|
||||
.asBuilder()
|
||||
.setCreationTimeForTest(clock.now().minus(Duration.ofSeconds(1)))
|
||||
.setCreationTimeForTest(clock.now().minusSeconds(1))
|
||||
.build());
|
||||
action.run();
|
||||
Optional<Domain> domain =
|
||||
|
||||
+9
-14
@@ -30,6 +30,7 @@ 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_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.minusHours;
|
||||
import static google.registry.util.DateTimeUtils.minusYears;
|
||||
import static google.registry.util.DateTimeUtils.plusDays;
|
||||
import static google.registry.util.DateTimeUtils.plusYears;
|
||||
@@ -57,7 +58,6 @@ 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;
|
||||
@@ -69,6 +69,7 @@ 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.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
@@ -163,15 +164,10 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
|
||||
@Test
|
||||
void testSuccess_expandSingleEvent_deletedDuringGracePeriod() {
|
||||
domain =
|
||||
persistResource(
|
||||
domain.asBuilder().setDeletionTime(endTime.minus(Duration.ofHours(2))).build());
|
||||
domain = persistResource(domain.asBuilder().setDeletionTime(minusHours(endTime, 2)).build());
|
||||
billingRecurrence =
|
||||
persistResource(
|
||||
billingRecurrence
|
||||
.asBuilder()
|
||||
.setRecurrenceEndTime(endTime.minus(Duration.ofHours(2)))
|
||||
.build());
|
||||
billingRecurrence.asBuilder().setRecurrenceEndTime(minusHours(endTime, 2)).build());
|
||||
runPipeline();
|
||||
|
||||
// Assert about DomainHistory, no transaction record should have been written.
|
||||
@@ -371,7 +367,7 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
|
||||
@Test
|
||||
void testSuccess_expandMultipleEvents_multipleEventTime() {
|
||||
clock.advanceBy(org.joda.time.Duration.standardDays(365));
|
||||
clock.advanceBy(Duration.standardDays(365));
|
||||
endTime = plusYears(endTime, 1);
|
||||
options.setEndTime(endTime.toString());
|
||||
|
||||
@@ -387,8 +383,7 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
domain.getTld(),
|
||||
// We report this when the autorenew grace period ends.
|
||||
plusYears(domain.getCreationTime(), 2)
|
||||
.plus(
|
||||
Duration.ofMillis(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD.getMillis())),
|
||||
.plusMillis(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD.getMillis()),
|
||||
TransactionReportField.netRenewsFieldFromYears(1),
|
||||
1)))
|
||||
.build());
|
||||
@@ -413,7 +408,7 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
.setEventTime(plusYears(domain.getCreationTime(), 2))
|
||||
.setBillingTime(
|
||||
plusYears(domain.getCreationTime(), 2)
|
||||
.plus(Duration.ofMillis(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD.getMillis())))
|
||||
.plusMillis(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD.getMillis()))
|
||||
.build(),
|
||||
billingRecurrence
|
||||
.asBuilder()
|
||||
@@ -472,7 +467,7 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
domain.getTld(),
|
||||
// We report this when the autorenew grace period ends.
|
||||
plusYears(domain.getCreationTime(), 1)
|
||||
.plus(Duration.ofMillis(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD.getMillis())),
|
||||
.plusMillis(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD.getMillis()),
|
||||
TransactionReportField.netRenewsFieldFromYears(1),
|
||||
1)))
|
||||
.build();
|
||||
@@ -487,7 +482,7 @@ public class ExpandBillingRecurrencesPipelineTest {
|
||||
return new BillingEvent.Builder()
|
||||
.setBillingTime(
|
||||
plusYears(domain.getCreationTime(), 1)
|
||||
.plus(Duration.ofMillis(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD.getMillis())))
|
||||
.plusMillis(Tld.DEFAULT_AUTO_RENEW_GRACE_PERIOD.getMillis()))
|
||||
.setRegistrarId("TheRegistrar")
|
||||
.setCost(Money.of(USD, cost))
|
||||
.setEventTime(plusYears(domain.getCreationTime(), 1))
|
||||
|
||||
@@ -24,7 +24,7 @@ import static google.registry.testing.DatabaseHelper.persistNewRegistrar;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.LogsSubject.assertAboutLogs;
|
||||
import static google.registry.util.DateTimeUtils.END_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static java.util.logging.Level.SEVERE;
|
||||
import static org.joda.money.CurrencyUnit.CAD;
|
||||
import static org.joda.money.CurrencyUnit.JPY;
|
||||
@@ -335,7 +335,7 @@ class InvoicingPipelineTest {
|
||||
.build();
|
||||
persistResource(registrar);
|
||||
Tld test =
|
||||
newTld("test", "TEST", ImmutableSortedMap.of(START_OF_TIME, GENERAL_AVAILABILITY))
|
||||
newTld("test", "TEST", ImmutableSortedMap.of(START_INSTANT, GENERAL_AVAILABILITY))
|
||||
.asBuilder()
|
||||
.setInvoicingEnabled(true)
|
||||
.build();
|
||||
@@ -449,13 +449,13 @@ AND cr.id IS NULL
|
||||
persistResource(registrar3);
|
||||
|
||||
Tld test =
|
||||
newTld("test", "TEST", ImmutableSortedMap.of(START_OF_TIME, GENERAL_AVAILABILITY))
|
||||
newTld("test", "TEST", ImmutableSortedMap.of(START_INSTANT, GENERAL_AVAILABILITY))
|
||||
.asBuilder()
|
||||
.setInvoicingEnabled(true)
|
||||
.build();
|
||||
persistResource(test);
|
||||
Tld hello =
|
||||
newTld("hello", "HELLO", ImmutableSortedMap.of(START_OF_TIME, GENERAL_AVAILABILITY))
|
||||
newTld("hello", "HELLO", ImmutableSortedMap.of(START_INSTANT, GENERAL_AVAILABILITY))
|
||||
.asBuilder()
|
||||
.setInvoicingEnabled(true)
|
||||
.build();
|
||||
|
||||
@@ -36,6 +36,8 @@ import static google.registry.testing.DatabaseHelper.persistEppResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistNewRegistrar;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static google.registry.util.DateTimeUtils.plusDays;
|
||||
import static google.registry.util.DateTimeUtils.toDateTime;
|
||||
import static google.registry.util.ResourceUtils.readResourceUtf8;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
@@ -81,6 +83,7 @@ import google.registry.testing.CloudTasksHelper.TaskMatcher;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.FakeKeyringModule;
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -113,13 +116,16 @@ public class RdePipelineTest {
|
||||
private final FakeClock clock = new FakeClock(DateTime.parse("1999-12-31TZ"));
|
||||
|
||||
// This is teh default as-of time the RDE/BRDA job.
|
||||
private final DateTime now = DateTime.parse("2000-01-01TZ");
|
||||
private final Instant now = Instant.parse("2000-01-01T00:00:00.000Z");
|
||||
|
||||
private final ImmutableSet<PendingDeposit> pendings =
|
||||
ImmutableSet.of(
|
||||
PendingDeposit.create("soy", now, FULL, RDE_STAGING, Duration.standardDays(1)),
|
||||
PendingDeposit.create("soy", now, THIN, RDE_STAGING, Duration.standardDays(1)),
|
||||
PendingDeposit.create("fun", now, FULL, RDE_STAGING, Duration.standardDays(1)));
|
||||
PendingDeposit.create(
|
||||
"soy", toDateTime(now), FULL, RDE_STAGING, Duration.standardDays(1)),
|
||||
PendingDeposit.create(
|
||||
"soy", toDateTime(now), THIN, RDE_STAGING, Duration.standardDays(1)),
|
||||
PendingDeposit.create(
|
||||
"fun", toDateTime(now), FULL, RDE_STAGING, Duration.standardDays(1)));
|
||||
|
||||
private final ImmutableList<DepositFragment> brdaFragments =
|
||||
ImmutableList.of(
|
||||
@@ -223,10 +229,10 @@ public class RdePipelineTest {
|
||||
|
||||
tm().transact(
|
||||
() -> {
|
||||
tm().put(Cursor.createScoped(CursorType.BRDA, now, Tld.get("soy")));
|
||||
tm().put(Cursor.createScoped(RDE_STAGING, now, Tld.get("soy")));
|
||||
RdeRevision.saveRevision("soy", now, THIN, 0);
|
||||
RdeRevision.saveRevision("soy", now, FULL, 0);
|
||||
tm().put(Cursor.createScoped(CursorType.BRDA, toDateTime(now), Tld.get("soy")));
|
||||
tm().put(Cursor.createScoped(RDE_STAGING, toDateTime(now), Tld.get("soy")));
|
||||
RdeRevision.saveRevision("soy", toDateTime(now), THIN, 0);
|
||||
RdeRevision.saveRevision("soy", toDateTime(now), FULL, 0);
|
||||
});
|
||||
|
||||
// This host is never referenced.
|
||||
@@ -307,9 +313,14 @@ public class RdePipelineTest {
|
||||
options.setPendings(
|
||||
encodePendingDeposits(
|
||||
ImmutableSet.of(
|
||||
PendingDeposit.create("soy", now, FULL, RDE_STAGING, Duration.standardDays(1)),
|
||||
PendingDeposit.create(
|
||||
"soy", now.plusSeconds(1), THIN, RDE_STAGING, Duration.standardDays(1)))));
|
||||
"soy", toDateTime(now), FULL, RDE_STAGING, Duration.standardDays(1)),
|
||||
PendingDeposit.create(
|
||||
"soy",
|
||||
toDateTime(now.plusSeconds(1)),
|
||||
THIN,
|
||||
RDE_STAGING,
|
||||
Duration.standardDays(1)))));
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> new RdePipeline(options, gcsUtils, cloudTasksHelper.getTestCloudTasksUtils()));
|
||||
@@ -427,9 +438,10 @@ public class RdePipelineTest {
|
||||
@RetryingTest(4)
|
||||
void testSuccess_persistData() throws Exception {
|
||||
PendingDeposit brdaKey =
|
||||
PendingDeposit.create("soy", now, THIN, CursorType.BRDA, Duration.standardDays(1));
|
||||
PendingDeposit.create(
|
||||
"soy", toDateTime(now), THIN, CursorType.BRDA, Duration.standardDays(1));
|
||||
PendingDeposit rdeKey =
|
||||
PendingDeposit.create("soy", now, FULL, RDE_STAGING, Duration.standardDays(1));
|
||||
PendingDeposit.create("soy", toDateTime(now), FULL, RDE_STAGING, Duration.standardDays(1));
|
||||
|
||||
verifyFiles(ImmutableMap.of(brdaKey, brdaFragments, rdeKey, rdeFragments), false);
|
||||
|
||||
@@ -441,20 +453,18 @@ public class RdePipelineTest {
|
||||
"soy_2000-01-01_full_S1_R1.xml.ghostryde",
|
||||
"soy_2000-01-01_full_S1_R1-report.xml.ghostryde");
|
||||
|
||||
assertThat(loadCursorTime(CursorType.BRDA))
|
||||
.isEquivalentAccordingToCompareTo(now.plus(Duration.standardDays(1)));
|
||||
assertThat(loadRevision(now, THIN)).isEqualTo(1);
|
||||
assertThat(loadCursorTime(CursorType.BRDA)).isEquivalentAccordingToCompareTo(plusDays(now, 1));
|
||||
assertThat(loadRevision(toDateTime(now), THIN)).isEqualTo(1);
|
||||
|
||||
assertThat(loadCursorTime(RDE_STAGING))
|
||||
.isEquivalentAccordingToCompareTo(now.plus(Duration.standardDays(1)));
|
||||
assertThat(loadRevision(now, FULL)).isEqualTo(1);
|
||||
assertThat(loadCursorTime(RDE_STAGING)).isEquivalentAccordingToCompareTo(plusDays(now, 1));
|
||||
assertThat(loadRevision(toDateTime(now), FULL)).isEqualTo(1);
|
||||
cloudTasksHelper.assertTasksEnqueued(
|
||||
"brda",
|
||||
new TaskMatcher()
|
||||
.path("/_dr/task/brdaCopy")
|
||||
.service("backend")
|
||||
.param("tld", "soy")
|
||||
.param("watermark", now.toString())
|
||||
.param("watermark", toDateTime(now).toString())
|
||||
.param("prefix", "rde-job/"));
|
||||
cloudTasksHelper.assertTasksEnqueued(
|
||||
"rde-upload",
|
||||
@@ -468,8 +478,10 @@ public class RdePipelineTest {
|
||||
// The GCS folder listing can be a bit flaky, so retry if necessary
|
||||
@RetryingTest(4)
|
||||
void testSuccess_persistData_manual() throws Exception {
|
||||
PendingDeposit brdaKey = PendingDeposit.createInManualOperation("soy", now, THIN, "test/", 0);
|
||||
PendingDeposit rdeKey = PendingDeposit.createInManualOperation("soy", now, FULL, "test/", 0);
|
||||
PendingDeposit brdaKey =
|
||||
PendingDeposit.createInManualOperation("soy", toDateTime(now), THIN, "test/", 0);
|
||||
PendingDeposit rdeKey =
|
||||
PendingDeposit.createInManualOperation("soy", toDateTime(now), FULL, "test/", 0);
|
||||
|
||||
verifyFiles(ImmutableMap.of(brdaKey, brdaFragments, rdeKey, rdeFragments), true);
|
||||
|
||||
@@ -482,10 +494,10 @@ public class RdePipelineTest {
|
||||
"soy_2000-01-01_full_S1_R0-report.xml.ghostryde");
|
||||
|
||||
assertThat(loadCursorTime(CursorType.BRDA)).isEquivalentAccordingToCompareTo(now);
|
||||
assertThat(loadRevision(now, THIN)).isEqualTo(0);
|
||||
assertThat(loadRevision(toDateTime(now), THIN)).isEqualTo(0);
|
||||
|
||||
assertThat(loadCursorTime(RDE_STAGING)).isEquivalentAccordingToCompareTo(now);
|
||||
assertThat(loadRevision(now, FULL)).isEqualTo(0);
|
||||
assertThat(loadRevision(toDateTime(now), FULL)).isEqualTo(0);
|
||||
cloudTasksHelper.assertNoTasksEnqueued("brda", "rde-upload");
|
||||
}
|
||||
|
||||
@@ -547,9 +559,11 @@ public class RdePipelineTest {
|
||||
.getRevision());
|
||||
}
|
||||
|
||||
private static DateTime loadCursorTime(CursorType type) {
|
||||
private static Instant loadCursorTime(CursorType type) {
|
||||
return tm().transact(
|
||||
() -> tm().loadByKey(Cursor.createScopedVKey(type, Tld.get("soy"))).getCursorTime());
|
||||
() ->
|
||||
tm().loadByKey(Cursor.createScopedVKey(type, Tld.get("soy")))
|
||||
.getCursorTimeInstant());
|
||||
}
|
||||
|
||||
private static Function<DepositFragment, String> getXmlElement(String pattern) {
|
||||
|
||||
@@ -26,6 +26,7 @@ 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 org.joda.time.Duration.millis;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.startsWith;
|
||||
@@ -107,7 +108,7 @@ public class BsaValidateActionTest {
|
||||
idnChecker,
|
||||
new BsaEmailSender(gmailClient, emailRecipient),
|
||||
/* transactionBatchSize= */ 500,
|
||||
org.joda.time.Duration.millis(MAX_STALENESS.toMillis()),
|
||||
millis(MAX_STALENESS.toMillis()),
|
||||
fakeClock,
|
||||
response);
|
||||
createTld("app");
|
||||
@@ -238,8 +239,7 @@ public class BsaValidateActionTest {
|
||||
void isStalenessAllowed_newDomain_allowed() {
|
||||
persistBsaLabel("label");
|
||||
Domain domain = persistActiveDomain("label.app", fakeClock.nowUtc());
|
||||
fakeClock.advanceBy(
|
||||
org.joda.time.Duration.millis(MAX_STALENESS.minus(Duration.ofSeconds(1)).toMillis()));
|
||||
fakeClock.advanceBy(millis(MAX_STALENESS.minusSeconds(1).toMillis()));
|
||||
assertThat(action.isStalenessAllowed(domain)).isTrue();
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ public class BsaValidateActionTest {
|
||||
void isStalenessAllowed_newDomain_notAllowed() {
|
||||
persistBsaLabel("label");
|
||||
Domain domain = persistActiveDomain("label.app", fakeClock.nowUtc());
|
||||
fakeClock.advanceBy(org.joda.time.Duration.millis(MAX_STALENESS.toMillis()));
|
||||
fakeClock.advanceBy(millis(MAX_STALENESS.toMillis()));
|
||||
assertThat(action.isStalenessAllowed(domain)).isFalse();
|
||||
}
|
||||
|
||||
|
||||
@@ -70,8 +70,8 @@ class ReservedDomainsUtilsTest {
|
||||
.asBuilder()
|
||||
.setTldStateTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
fakeClock.nowUtc(), START_DATE_SUNRISE,
|
||||
fakeClock.nowUtc().plusMillis(1), GENERAL_AVAILABILITY))
|
||||
fakeClock.now(), START_DATE_SUNRISE,
|
||||
fakeClock.now().plusMillis(1), GENERAL_AVAILABILITY))
|
||||
.build());
|
||||
addReservedListsToTld("tld", ImmutableList.of("testlist"));
|
||||
|
||||
@@ -81,20 +81,20 @@ class ReservedDomainsUtilsTest {
|
||||
|
||||
@Test
|
||||
void enumerateReservedDomain_in_sunrise() {
|
||||
assertThat(getAllReservedDomainsInTld(Tld.get("tld"), fakeClock.nowUtc()))
|
||||
assertThat(getAllReservedDomainsInTld(Tld.get("tld"), fakeClock.now()))
|
||||
.containsExactly("specific.tld", "anchor.tld", "fully.tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
void enumerateReservedDomain_after_sunrise() {
|
||||
fakeClock.advanceOneMilli();
|
||||
assertThat(getAllReservedDomainsInTld(Tld.get("tld"), fakeClock.nowUtc()))
|
||||
assertThat(getAllReservedDomainsInTld(Tld.get("tld"), fakeClock.now()))
|
||||
.containsExactly("sunrise.tld", "name.tld", "specific.tld", "anchor.tld", "fully.tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
void enumerateReservedDomain_multiple_lists() {
|
||||
assertThat(getAllReservedDomainsInTld(Tld.get("tld2"), fakeClock.nowUtc()))
|
||||
assertThat(getAllReservedDomainsInTld(Tld.get("tld2"), fakeClock.now()))
|
||||
.containsExactly(
|
||||
"somethingelse.tld2",
|
||||
"sunrise.tld2",
|
||||
|
||||
@@ -34,6 +34,7 @@ import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatabaseHelper.persistDomainAsDeleted;
|
||||
import static google.registry.testing.DatabaseHelper.persistNewRegistrar;
|
||||
import static google.registry.util.DateTimeUtils.END_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.plusHours;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -43,7 +44,6 @@ import google.registry.bsa.persistence.Queries.DomainLifeSpan;
|
||||
import google.registry.persistence.transaction.JpaTestExtensions;
|
||||
import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationWithCoverageExtension;
|
||||
import google.registry.testing.FakeClock;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -294,7 +294,7 @@ class QueriesTest {
|
||||
bsaQuery(() -> queryMissedRegisteredUnblockables("tld2", fakeClock.now())))
|
||||
.containsExactly(
|
||||
new DomainLifeSpan("label2.tld2", time1, END_INSTANT),
|
||||
new DomainLifeSpan("label3.tld2", time2, time2.plus(Duration.ofHours(1))));
|
||||
new DomainLifeSpan("label3.tld2", time2, plusHours(time2, 1)));
|
||||
|
||||
BsaTestingUtils.persistUnblockableDomain(
|
||||
UnblockableDomain.of("label2", "tld2", UnblockableDomain.Reason.REGISTERED));
|
||||
@@ -303,7 +303,7 @@ class QueriesTest {
|
||||
assertThat(
|
||||
(ImmutableList<DomainLifeSpan>)
|
||||
bsaQuery(() -> queryMissedRegisteredUnblockables("tld2", fakeClock.now())))
|
||||
.containsExactly(new DomainLifeSpan("label3.tld2", time2, time2.plus(Duration.ofHours(1))));
|
||||
.containsExactly(new DomainLifeSpan("label3.tld2", time2, plusHours(time2, 1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -24,6 +24,8 @@ import static google.registry.testing.DatabaseHelper.loadByKey;
|
||||
import static google.registry.testing.DatabaseHelper.persistNewRegistrar;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static google.registry.util.DateTimeUtils.minusHours;
|
||||
import static google.registry.util.DateTimeUtils.plusHours;
|
||||
import static org.joda.money.CurrencyUnit.JPY;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
@@ -42,7 +44,6 @@ 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;
|
||||
@@ -90,11 +91,9 @@ public class SyncRegistrarsSheetTest {
|
||||
@Test
|
||||
void test_wereRegistrarsModified_atDifferentCursorTimes() {
|
||||
persistNewRegistrar("SomeRegistrar", "Some Registrar Inc.", Registrar.Type.REAL, 8L);
|
||||
persistResource(
|
||||
Cursor.createGlobal(SYNC_REGISTRAR_SHEET, clock.now().minus(Duration.ofHours(1))));
|
||||
persistResource(Cursor.createGlobal(SYNC_REGISTRAR_SHEET, minusHours(clock.now(), 1)));
|
||||
assertThat(newSyncRegistrarsSheet().wereRegistrarsModified()).isTrue();
|
||||
persistResource(
|
||||
Cursor.createGlobal(SYNC_REGISTRAR_SHEET, clock.now().plus(Duration.ofHours(1))));
|
||||
persistResource(Cursor.createGlobal(SYNC_REGISTRAR_SHEET, plusHours(clock.now(), 1)));
|
||||
assertThat(newSyncRegistrarsSheet().wereRegistrarsModified()).isFalse();
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,13 @@ import static google.registry.testing.DatabaseHelper.loadByEntity;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DomainSubject.assertAboutDomains;
|
||||
import static google.registry.testing.EppMetricSubject.assertThat;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.minusDays;
|
||||
import static google.registry.util.DateTimeUtils.plusDays;
|
||||
import static google.registry.util.DateTimeUtils.plusHours;
|
||||
import static google.registry.util.DateTimeUtils.plusMinutes;
|
||||
import static google.registry.util.DateTimeUtils.plusMonths;
|
||||
import static google.registry.util.DateTimeUtils.plusYears;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
@@ -50,8 +55,8 @@ import google.registry.persistence.transaction.JpaTestExtensions;
|
||||
import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension;
|
||||
import google.registry.tmch.TmchData;
|
||||
import google.registry.tmch.TmchTestData;
|
||||
import java.time.Instant;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
@@ -294,7 +299,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
void testDomainDelete_duringAddAndRenewalGracePeriod_deletesImmediately() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
|
||||
DateTime createTime = DateTime.parse("2000-06-01T00:02:00Z");
|
||||
Instant createTime = Instant.parse("2000-06-01T00:02:00Z");
|
||||
// Create domain example.tld
|
||||
assertThatCommand(
|
||||
"domain_create_no_hosts_or_dsdata.xml", ImmutableMap.of("DOMAIN", "example.tld"))
|
||||
@@ -315,7 +320,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
"CRDATE", "2000-06-01T00:02:00Z",
|
||||
"EXDATE", "2002-06-01T00:02:00Z"));
|
||||
|
||||
DateTime renewTime = DateTime.parse("2000-06-03T00:00:00Z");
|
||||
Instant renewTime = Instant.parse("2000-06-03T00:00:00Z");
|
||||
assertThatCommand(
|
||||
"domain_renew.xml",
|
||||
ImmutableMap.of("DOMAIN", "example.tld", "EXPDATE", "2002-06-01", "YEARS", "3"))
|
||||
@@ -337,9 +342,9 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
"UPDATE", "2000-06-03T00:00:00Z"));
|
||||
|
||||
Domain domain =
|
||||
loadResource(Domain.class, "example.tld", DateTime.parse("2000-06-03T04:00:00Z")).get();
|
||||
loadResource(Domain.class, "example.tld", Instant.parse("2000-06-03T04:00:00Z")).get();
|
||||
|
||||
DateTime deleteTime = DateTime.parse("2000-06-04T00:00:00Z");
|
||||
Instant deleteTime = Instant.parse("2000-06-04T00:00:00Z");
|
||||
// Delete domain example.tld during both grace periods.
|
||||
assertThatCommand("domain_delete.xml", ImmutableMap.of("DOMAIN", "example.tld"))
|
||||
.atTime("2000-06-04T00:00:00Z")
|
||||
@@ -365,8 +370,8 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
renewBillingEvent,
|
||||
// There should be two ended recurring billing events, one each from the create and renew.
|
||||
// (The former was ended by the renew and the latter was ended by the delete.)
|
||||
makeCreateRecurrence(domain, createTime.plusYears(2), renewTime),
|
||||
makeRenewRecurrence(domain, createTime.plusYears(5), deleteTime),
|
||||
makeCreateRecurrence(domain, plusYears(createTime, 2), renewTime),
|
||||
makeRenewRecurrence(domain, plusYears(createTime, 5), deleteTime),
|
||||
// There should be Cancellations offsetting both of the one-times.
|
||||
makeCancellationBillingEventForCreate(domain, createBillingEvent, createTime, deleteTime),
|
||||
makeCancellationBillingEventForRenew(domain, renewBillingEvent, renewTime, deleteTime));
|
||||
@@ -386,7 +391,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
|
||||
// Create domain example.tld
|
||||
DateTime createTime = DateTime.parse("2000-06-01T00:02:00Z");
|
||||
Instant createTime = Instant.parse("2000-06-01T00:02:00Z");
|
||||
assertThatCommand(
|
||||
"domain_create_no_hosts_or_dsdata.xml", ImmutableMap.of("DOMAIN", "example.tld"))
|
||||
.atTime(createTime)
|
||||
@@ -397,10 +402,10 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
"CRDATE", "2000-06-01T00:02:00.0Z",
|
||||
"EXDATE", "2002-06-01T00:02:00.0Z"));
|
||||
|
||||
Domain domain = loadResource(Domain.class, "example.tld", createTime.plusHours(1)).get();
|
||||
Domain domain = loadResource(Domain.class, "example.tld", plusHours(createTime, 1)).get();
|
||||
|
||||
// Delete domain example.tld within the add grace period.
|
||||
DateTime deleteTime = createTime.plusDays(1);
|
||||
Instant deleteTime = plusDays(createTime, 1);
|
||||
assertThatCommand("domain_delete.xml", ImmutableMap.of("DOMAIN", "example.tld"))
|
||||
.atTime(deleteTime)
|
||||
.hasResponse("generic_success_response.xml");
|
||||
@@ -420,7 +425,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
domain,
|
||||
// Check the existence of the expected create one-time billing event.
|
||||
createBillingEvent,
|
||||
makeCreateRecurrence(domain, createTime.plusYears(2), deleteTime),
|
||||
makeCreateRecurrence(domain, plusYears(createTime, 2), deleteTime),
|
||||
// Check for the existence of a cancellation for the given one-time billing event.
|
||||
makeCancellationBillingEventForCreate(domain, createBillingEvent, createTime, deleteTime));
|
||||
|
||||
@@ -438,7 +443,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
void testDomainDeletion_outsideAddGracePeriod_showsRedemptionPeriod() throws Exception {
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
|
||||
DateTime createTime = DateTime.parse("2000-06-01T00:02:00Z");
|
||||
Instant createTime = Instant.parse("2000-06-01T00:02:00Z");
|
||||
// Create domain example.tld
|
||||
assertThatCommand(
|
||||
"domain_create_no_hosts_or_dsdata.xml", ImmutableMap.of("DOMAIN", "example.tld"))
|
||||
@@ -450,7 +455,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
"CRDATE", "2000-06-01T00:02:00.0Z",
|
||||
"EXDATE", "2002-06-01T00:02:00.0Z"));
|
||||
|
||||
DateTime deleteTime = DateTime.parse("2000-07-07T00:02:00Z"); // 1 month and 6 days after
|
||||
Instant deleteTime = Instant.parse("2000-07-07T00:02:00Z"); // 1 month and 6 days after
|
||||
// Delete domain example.tld after its add grace period has expired.
|
||||
assertThatCommand("domain_delete.xml", ImmutableMap.of("DOMAIN", "example.tld"))
|
||||
.atTime(deleteTime)
|
||||
@@ -478,19 +483,18 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
"CODE", "2303", "MSG", "The domain with given ID (example.tld) doesn't exist."));
|
||||
|
||||
Domain domain =
|
||||
loadResource(Domain.class, "example.tld", DateTime.parse("2000-08-01T00:02:00Z")).get();
|
||||
loadResource(Domain.class, "example.tld", Instant.parse("2000-08-01T00:02:00Z")).get();
|
||||
// Verify that the autorenew was ended and that the one-time billing event is not canceled.
|
||||
assertBillingEventsForResource(
|
||||
domain,
|
||||
makeOneTimeCreateBillingEvent(domain, createTime),
|
||||
makeCreateRecurrence(domain, createTime.plusYears(2), deleteTime));
|
||||
makeCreateRecurrence(domain, plusYears(createTime, 2), deleteTime));
|
||||
|
||||
assertThatLogoutSucceeds();
|
||||
|
||||
// Make sure that in the future, the domain expiration is unchanged after deletion
|
||||
Domain clonedDomain = domain.cloneProjectedAtTime(toInstant(deleteTime.plusYears(5)));
|
||||
assertThat(clonedDomain.getRegistrationExpirationTime())
|
||||
.isEqualTo(toInstant(createTime.plusYears(2)));
|
||||
Domain clonedDomain = domain.cloneProjectedAtTime(plusYears(deleteTime, 5));
|
||||
assertThat(clonedDomain.getRegistrationExpirationTime()).isEqualTo(plusYears(createTime, 2));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -503,25 +507,25 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
.asBuilder()
|
||||
.setEapFeeSchedule(
|
||||
ImmutableSortedMap.of(
|
||||
START_OF_TIME,
|
||||
START_INSTANT,
|
||||
Money.of(USD, 0),
|
||||
DateTime.parse("2000-06-01T00:00:00Z"),
|
||||
Instant.parse("2000-06-01T00:00:00Z"),
|
||||
Money.of(USD, 100),
|
||||
DateTime.parse("2000-06-02T00:00:00Z"),
|
||||
Instant.parse("2000-06-02T00:00:00Z"),
|
||||
Money.of(USD, 0)))
|
||||
.build());
|
||||
|
||||
// Create domain example.tld, which should have an EAP fee of USD 100.
|
||||
DateTime createTime = DateTime.parse("2000-06-01T00:02:00Z");
|
||||
Instant createTime = Instant.parse("2000-06-01T00:02:00Z");
|
||||
assertThatCommand("domain_create_eap_fee.xml")
|
||||
.atTime(createTime)
|
||||
.hasResponse("domain_create_response_eap_fee.xml");
|
||||
|
||||
Domain domain =
|
||||
loadResource(Domain.class, "example.tld", DateTime.parse("2000-06-01T00:03:00Z")).get();
|
||||
loadResource(Domain.class, "example.tld", Instant.parse("2000-06-01T00:03:00Z")).get();
|
||||
|
||||
// Delete domain example.tld within the add grade period.
|
||||
DateTime deleteTime = createTime.plusDays(1);
|
||||
Instant deleteTime = plusDays(createTime, 1);
|
||||
assertThatCommand("domain_delete.xml", ImmutableMap.of("DOMAIN", "example.tld"))
|
||||
.atTime(deleteTime)
|
||||
.hasResponse("domain_delete_response_fee.xml");
|
||||
@@ -535,8 +539,9 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
.setRegistrarId("NewRegistrar")
|
||||
.setPeriodYears(1)
|
||||
.setCost(Money.parse("USD 100.00"))
|
||||
.setEventTime(toInstant(createTime))
|
||||
.setBillingTime(toInstant(createTime.plus(Tld.get("tld").getRenewGracePeriodLength())))
|
||||
.setEventTime(createTime)
|
||||
.setBillingTime(
|
||||
createTime.plusMillis(Tld.get("tld").getRenewGracePeriodLength().getMillis()))
|
||||
.setDomainHistory(
|
||||
getOnlyHistoryEntryOfType(domain, Type.DOMAIN_CREATE, DomainHistory.class))
|
||||
.build();
|
||||
@@ -549,7 +554,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
expectedCreateBillingEvent,
|
||||
// ... and the expected one-time EAP fee billing event ...
|
||||
expectedCreateEapBillingEvent,
|
||||
makeCreateRecurrence(domain, createTime.plusYears(2), deleteTime),
|
||||
makeCreateRecurrence(domain, plusYears(createTime, 2), deleteTime),
|
||||
// ... and verify that the create one-time billing event was canceled ...
|
||||
makeCancellationBillingEventForCreate(
|
||||
domain, expectedCreateBillingEvent, createTime, deleteTime));
|
||||
@@ -672,13 +677,13 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
|
||||
@Test
|
||||
void testDomainCreation_failsBeforeSunrise() throws Exception {
|
||||
DateTime sunriseDate = DateTime.parse("2000-05-30T00:00:00Z");
|
||||
Instant sunriseDate = Instant.parse("2000-05-30T00:00:00Z");
|
||||
createTld(
|
||||
"example",
|
||||
new ImmutableSortedMap.Builder<DateTime, TldState>(Ordering.natural())
|
||||
.put(START_OF_TIME, PREDELEGATION)
|
||||
new ImmutableSortedMap.Builder<Instant, TldState>(Ordering.natural())
|
||||
.put(START_INSTANT, TldState.PREDELEGATION)
|
||||
.put(sunriseDate, START_DATE_SUNRISE)
|
||||
.put(sunriseDate.plusMonths(2), GENERAL_AVAILABILITY)
|
||||
.put(plusMonths(sunriseDate, 2), GENERAL_AVAILABILITY)
|
||||
.build());
|
||||
|
||||
assertThatLoginSucceeds("NewRegistrar", "foo-BAR2");
|
||||
@@ -686,7 +691,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
createHosts();
|
||||
|
||||
assertThatCommand("domain_create_sunrise_encoded_mark.xml")
|
||||
.atTime(sunriseDate.minusDays(1))
|
||||
.atTime(minusDays(sunriseDate, 1))
|
||||
.hasResponse(
|
||||
"response_error.xml",
|
||||
ImmutableMap.of(
|
||||
@@ -694,7 +699,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
"MSG", "The current registry phase does not allow for general registrations"));
|
||||
|
||||
assertThatCommand("domain_info_testvalidate.xml")
|
||||
.atTime(sunriseDate.plusDays(1))
|
||||
.atTime(plusDays(sunriseDate, 1))
|
||||
.hasResponse(
|
||||
"response_error.xml",
|
||||
ImmutableMap.of(
|
||||
@@ -706,17 +711,15 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
|
||||
@Test
|
||||
void testDomainCheckFee_succeeds() throws Exception {
|
||||
DateTime gaDate = DateTime.parse("2000-05-30T00:00:00Z");
|
||||
Instant gaDate = Instant.parse("2000-05-30T00:00:00Z");
|
||||
createTld(
|
||||
"example",
|
||||
ImmutableSortedMap.of(
|
||||
START_OF_TIME, PREDELEGATION,
|
||||
gaDate, GENERAL_AVAILABILITY));
|
||||
ImmutableSortedMap.of(START_INSTANT, PREDELEGATION, gaDate, GENERAL_AVAILABILITY));
|
||||
|
||||
assertThatCommand("login_valid_fee_extension.xml").hasSuccessfulLogin();
|
||||
|
||||
assertThatCommand("domain_check_fee_premium.xml")
|
||||
.atTime(gaDate.plusDays(1))
|
||||
.atTime(plusDays(gaDate, 1))
|
||||
.hasResponse("domain_check_fee_premium_response.xml");
|
||||
assertThat(getRecordedEppMetric())
|
||||
.hasClientId("NewRegistrar")
|
||||
@@ -1178,24 +1181,27 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
@Test
|
||||
void testDomainCreation_startDateSunriseFull() throws Exception {
|
||||
// The signed mark is valid between 2022-11-22 and 2027-10-18.
|
||||
DateTime sunriseDate = DateTime.parse("2025-09-08T09:09:09Z");
|
||||
DateTime gaDate = sunriseDate.plusDays(30);
|
||||
Instant sunriseDate = Instant.parse("2025-09-08T09:09:09Z");
|
||||
Instant gaDate = plusDays(sunriseDate, 30);
|
||||
createTld(
|
||||
"example",
|
||||
ImmutableSortedMap.of(
|
||||
START_OF_TIME, PREDELEGATION,
|
||||
sunriseDate, START_DATE_SUNRISE,
|
||||
gaDate, GENERAL_AVAILABILITY));
|
||||
START_INSTANT,
|
||||
PREDELEGATION,
|
||||
sunriseDate,
|
||||
START_DATE_SUNRISE,
|
||||
gaDate,
|
||||
GENERAL_AVAILABILITY));
|
||||
|
||||
assertThatLogin("NewRegistrar", "foo-BAR2")
|
||||
.atTime(sunriseDate.minusDays(3))
|
||||
.atTime(minusDays(sunriseDate, 3))
|
||||
.hasSuccessfulLogin();
|
||||
|
||||
createHosts();
|
||||
|
||||
// During pre-delegation, any create should fail both with and without mark
|
||||
assertThatCommand("domain_create_sunrise_encoded_mark.xml", ImmutableMap.of("SMD", ENCODED_SMD))
|
||||
.atTime(sunriseDate.minusDays(2))
|
||||
.atTime(minusDays(sunriseDate, 2))
|
||||
.hasResponse(
|
||||
"response_error.xml",
|
||||
ImmutableMap.of(
|
||||
@@ -1204,7 +1210,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
|
||||
assertThatCommand(
|
||||
"domain_create_no_hosts_or_dsdata.xml", ImmutableMap.of("DOMAIN", "general.example"))
|
||||
.atTime(sunriseDate.minusDays(1))
|
||||
.atTime(minusDays(sunriseDate, 1))
|
||||
.hasResponse(
|
||||
"response_error.xml",
|
||||
ImmutableMap.of(
|
||||
@@ -1227,7 +1233,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
// During sunrise, create with mark will succeed but without will fail.
|
||||
// We also test we can delete without a mark.
|
||||
assertThatCommand("domain_create_sunrise_encoded_mark.xml", ImmutableMap.of("SMD", ENCODED_SMD))
|
||||
.atTime(sunriseDate.plusDays(1))
|
||||
.atTime(plusDays(sunriseDate, 1))
|
||||
.hasResponse(
|
||||
"domain_create_response.xml",
|
||||
ImmutableMap.of(
|
||||
@@ -1236,12 +1242,12 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
"EXDATE", "2026-09-09T09:09:09Z"));
|
||||
|
||||
assertThatCommand("domain_delete.xml", ImmutableMap.of("DOMAIN", "test-validate.example"))
|
||||
.atTime(sunriseDate.plusDays(1).plusMinutes(1))
|
||||
.atTime(plusMinutes(plusDays(sunriseDate, 1), 1))
|
||||
.hasResponse("generic_success_response.xml");
|
||||
|
||||
assertThatCommand(
|
||||
"domain_create_no_hosts_or_dsdata.xml", ImmutableMap.of("DOMAIN", "general.example"))
|
||||
.atTime(sunriseDate.plusDays(2))
|
||||
.atTime(plusDays(sunriseDate, 2))
|
||||
.hasResponse(
|
||||
"response_error.xml",
|
||||
ImmutableMap.of(
|
||||
@@ -1250,7 +1256,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
|
||||
// During general availability, sunrise creates will fail but regular creates succeed
|
||||
assertThatCommand("domain_create_sunrise_encoded_mark.xml")
|
||||
.atTime(gaDate.plusDays(1))
|
||||
.atTime(plusDays(gaDate, 1))
|
||||
.hasResponse(
|
||||
"response_error.xml",
|
||||
ImmutableMap.of(
|
||||
@@ -1261,7 +1267,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
|
||||
assertThatCommand(
|
||||
"domain_create_no_hosts_or_dsdata.xml", ImmutableMap.of("DOMAIN", "general.example"))
|
||||
.atTime(gaDate.plusDays(2))
|
||||
.atTime(plusDays(gaDate, 2))
|
||||
.hasResponse(
|
||||
"domain_create_response.xml",
|
||||
ImmutableMap.of(
|
||||
@@ -1276,17 +1282,20 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
@Test
|
||||
void testDomainCreation_startDateSunrise_noType() throws Exception {
|
||||
// The signed mark is valid between 2022-11-22 and 2027-10-18.
|
||||
DateTime sunriseDate = DateTime.parse("2025-09-08T09:09:09Z");
|
||||
DateTime gaDate = sunriseDate.plusDays(30);
|
||||
Instant sunriseDate = Instant.parse("2025-09-08T09:09:09Z");
|
||||
Instant gaDate = plusDays(sunriseDate, 30);
|
||||
createTld(
|
||||
"example",
|
||||
ImmutableSortedMap.of(
|
||||
START_OF_TIME, PREDELEGATION,
|
||||
sunriseDate, START_DATE_SUNRISE,
|
||||
gaDate, GENERAL_AVAILABILITY));
|
||||
START_INSTANT,
|
||||
PREDELEGATION,
|
||||
sunriseDate,
|
||||
START_DATE_SUNRISE,
|
||||
gaDate,
|
||||
GENERAL_AVAILABILITY));
|
||||
|
||||
assertThatLogin("NewRegistrar", "foo-BAR2")
|
||||
.atTime(sunriseDate.minusDays(3))
|
||||
.atTime(minusDays(sunriseDate, 3))
|
||||
.hasSuccessfulLogin();
|
||||
|
||||
createHosts();
|
||||
@@ -1294,7 +1303,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
// During start-date sunrise, create with mark will succeed but without will fail.
|
||||
// We also test we can delete without a mark.
|
||||
assertThatCommand("domain_info.xml", ImmutableMap.of("DOMAIN", "test-validate.example"))
|
||||
.atTime(sunriseDate.plusDays(1))
|
||||
.atTime(plusDays(sunriseDate, 1))
|
||||
.hasResponse(
|
||||
"response_error.xml",
|
||||
ImmutableMap.of(
|
||||
@@ -1304,7 +1313,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
assertThatCommand(
|
||||
"domain_create_start_date_sunrise_encoded_mark_no_type.xml",
|
||||
ImmutableMap.of("SMD", ENCODED_SMD))
|
||||
.atTime(sunriseDate.plusDays(1).plusMinutes(1))
|
||||
.atTime(plusMinutes(plusDays(sunriseDate, 1), 1))
|
||||
.hasResponse(
|
||||
"domain_create_response.xml",
|
||||
ImmutableMap.of(
|
||||
@@ -1313,7 +1322,7 @@ class EppLifecycleDomainTest extends EppTestCase {
|
||||
"EXDATE", "2026-09-09T09:10:09Z"));
|
||||
|
||||
assertThatCommand("domain_info.xml", ImmutableMap.of("DOMAIN", "test-validate.example"))
|
||||
.atTime(sunriseDate.plusDays(1).plusMinutes(2))
|
||||
.atTime(plusMinutes(plusDays(sunriseDate, 1), 2))
|
||||
.hasResponse(
|
||||
"domain_info_response_ok_wildcard.xml",
|
||||
ImmutableMap.of(
|
||||
|
||||
@@ -19,7 +19,7 @@ import static google.registry.testing.DatabaseHelper.getOnlyHistoryEntryOfType;
|
||||
import static google.registry.testing.DatabaseHelper.loadAllOf;
|
||||
import static google.registry.testing.DatabaseHelper.stripBillingEventId;
|
||||
import static google.registry.testing.TestDataHelper.loadFile;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
import static google.registry.util.DateTimeUtils.toDateTime;
|
||||
import static google.registry.xml.XmlTestUtils.assertXmlEqualsWithMessage;
|
||||
import static jakarta.servlet.http.HttpServletResponse.SC_OK;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
@@ -43,6 +43,7 @@ import google.registry.persistence.VKey;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.FakeHttpSession;
|
||||
import google.registry.testing.FakeResponse;
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
@@ -94,6 +95,11 @@ public class EppTestCase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandAsserter atTime(Instant now) {
|
||||
this.now = toDateTime(now);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandAsserter atTime(String now) {
|
||||
return atTime(DateTime.parse(now));
|
||||
}
|
||||
@@ -280,39 +286,38 @@ public class EppTestCase {
|
||||
}
|
||||
|
||||
/** Makes a one-time billing event corresponding to the given domain's creation. */
|
||||
protected static BillingEvent makeOneTimeCreateBillingEvent(Domain domain, DateTime createTime) {
|
||||
protected static BillingEvent makeOneTimeCreateBillingEvent(Domain domain, Instant createTime) {
|
||||
return new BillingEvent.Builder()
|
||||
.setReason(Reason.CREATE)
|
||||
.setTargetId(domain.getDomainName())
|
||||
.setRegistrarId(domain.getCurrentSponsorRegistrarId())
|
||||
.setCost(Money.parse("USD 24.00"))
|
||||
.setPeriodYears(2)
|
||||
.setEventTime(toInstant(createTime))
|
||||
.setEventTime(createTime)
|
||||
.setBillingTime(
|
||||
toInstant(createTime.plus(Tld.get(domain.getTld()).getAddGracePeriodLength())))
|
||||
createTime.plusMillis(Tld.get(domain.getTld()).getAddGracePeriodLength().getMillis()))
|
||||
.setDomainHistory(
|
||||
getOnlyHistoryEntryOfType(domain, Type.DOMAIN_CREATE, DomainHistory.class))
|
||||
.build();
|
||||
}
|
||||
|
||||
/** Makes a one-time billing event corresponding to the given domain's renewal. */
|
||||
static BillingEvent makeOneTimeRenewBillingEvent(Domain domain, DateTime renewTime) {
|
||||
static BillingEvent makeOneTimeRenewBillingEvent(Domain domain, Instant renewTime) {
|
||||
return new BillingEvent.Builder()
|
||||
.setReason(Reason.RENEW)
|
||||
.setTargetId(domain.getDomainName())
|
||||
.setRegistrarId(domain.getCurrentSponsorRegistrarId())
|
||||
.setCost(Money.parse("USD 33.00"))
|
||||
.setPeriodYears(3)
|
||||
.setEventTime(toInstant(renewTime))
|
||||
.setEventTime(renewTime)
|
||||
.setBillingTime(
|
||||
toInstant(renewTime.plus(Tld.get(domain.getTld()).getRenewGracePeriodLength())))
|
||||
renewTime.plusMillis(Tld.get(domain.getTld()).getRenewGracePeriodLength().getMillis()))
|
||||
.setDomainHistory(getOnlyHistoryEntryOfType(domain, Type.DOMAIN_RENEW, DomainHistory.class))
|
||||
.build();
|
||||
}
|
||||
|
||||
/** Makes a recurrence billing event corresponding to the given domain's creation. */
|
||||
static BillingRecurrence makeCreateRecurrence(
|
||||
Domain domain, DateTime eventTime, DateTime endTime) {
|
||||
static BillingRecurrence makeCreateRecurrence(Domain domain, Instant eventTime, Instant endTime) {
|
||||
return makeRecurrence(
|
||||
domain,
|
||||
getOnlyHistoryEntryOfType(domain, Type.DOMAIN_CREATE, DomainHistory.class),
|
||||
@@ -321,8 +326,7 @@ public class EppTestCase {
|
||||
}
|
||||
|
||||
/** Makes a recurrence billing event corresponding to the given domain's renewal. */
|
||||
static BillingRecurrence makeRenewRecurrence(
|
||||
Domain domain, DateTime eventTime, DateTime endTime) {
|
||||
static BillingRecurrence makeRenewRecurrence(Domain domain, Instant eventTime, Instant endTime) {
|
||||
return makeRecurrence(
|
||||
domain,
|
||||
getOnlyHistoryEntryOfType(domain, Type.DOMAIN_RENEW, DomainHistory.class),
|
||||
@@ -332,28 +336,28 @@ public class EppTestCase {
|
||||
|
||||
/** Makes a recurrence corresponding to the given history entry. */
|
||||
protected static BillingRecurrence makeRecurrence(
|
||||
Domain domain, DomainHistory historyEntry, DateTime eventTime, DateTime endTime) {
|
||||
Domain domain, DomainHistory historyEntry, Instant eventTime, Instant endTime) {
|
||||
return new BillingRecurrence.Builder()
|
||||
.setReason(Reason.RENEW)
|
||||
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
|
||||
.setTargetId(domain.getDomainName())
|
||||
.setRegistrarId(domain.getCurrentSponsorRegistrarId())
|
||||
.setEventTime(toInstant(eventTime))
|
||||
.setRecurrenceEndTime(toInstant(endTime))
|
||||
.setEventTime(eventTime)
|
||||
.setRecurrenceEndTime(endTime)
|
||||
.setDomainHistory(historyEntry)
|
||||
.build();
|
||||
}
|
||||
|
||||
/** Makes a cancellation billing event cancelling out the given domain create billing event. */
|
||||
static BillingCancellation makeCancellationBillingEventForCreate(
|
||||
Domain domain, BillingEvent billingEventToCancel, DateTime createTime, DateTime deleteTime) {
|
||||
Domain domain, BillingEvent billingEventToCancel, Instant createTime, Instant deleteTime) {
|
||||
return new BillingCancellation.Builder()
|
||||
.setTargetId(domain.getDomainName())
|
||||
.setRegistrarId(domain.getCurrentSponsorRegistrarId())
|
||||
.setEventTime(toInstant(deleteTime))
|
||||
.setEventTime(deleteTime)
|
||||
.setBillingEvent(findKeyToActualOneTimeBillingEvent(billingEventToCancel))
|
||||
.setBillingTime(
|
||||
toInstant(createTime.plus(Tld.get(domain.getTld()).getAddGracePeriodLength())))
|
||||
createTime.plusMillis(Tld.get(domain.getTld()).getAddGracePeriodLength().getMillis()))
|
||||
.setReason(Reason.CREATE)
|
||||
.setDomainHistory(
|
||||
getOnlyHistoryEntryOfType(domain, Type.DOMAIN_DELETE, DomainHistory.class))
|
||||
@@ -362,14 +366,14 @@ public class EppTestCase {
|
||||
|
||||
/** Makes a cancellation billing event cancelling out the given domain renew billing event. */
|
||||
static BillingCancellation makeCancellationBillingEventForRenew(
|
||||
Domain domain, BillingEvent billingEventToCancel, DateTime renewTime, DateTime deleteTime) {
|
||||
Domain domain, BillingEvent billingEventToCancel, Instant renewTime, Instant deleteTime) {
|
||||
return new BillingCancellation.Builder()
|
||||
.setTargetId(domain.getDomainName())
|
||||
.setRegistrarId(domain.getCurrentSponsorRegistrarId())
|
||||
.setEventTime(toInstant(deleteTime))
|
||||
.setEventTime(deleteTime)
|
||||
.setBillingEvent(findKeyToActualOneTimeBillingEvent(billingEventToCancel))
|
||||
.setBillingTime(
|
||||
toInstant(renewTime.plus(Tld.get(domain.getTld()).getRenewGracePeriodLength())))
|
||||
renewTime.plusMillis(Tld.get(domain.getTld()).getRenewGracePeriodLength().getMillis()))
|
||||
.setReason(Reason.RENEW)
|
||||
.setDomainHistory(
|
||||
getOnlyHistoryEntryOfType(domain, Type.DOMAIN_DELETE, DomainHistory.class))
|
||||
|
||||
@@ -801,10 +801,10 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCurrency(JPY)
|
||||
.setCreateBillingCostTransitionsInstant(
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setEapFeeScheduleInstant(ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setRenewBillingCostTransitionsInstant(
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setServerStatusChangeBillingCost(Money.ofMajor(JPY, 800))
|
||||
@@ -1047,7 +1047,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCreateBillingCostTransitionsInstant(
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 11.1)))
|
||||
.build());
|
||||
setEppInput("domain_check_fee_fractional_stdv1.xml");
|
||||
@@ -1150,10 +1150,10 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
createTld("example")
|
||||
.asBuilder()
|
||||
.setCurrency(JPY)
|
||||
.setCreateBillingCostTransitionsInstant(
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setEapFeeScheduleInstant(ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setRenewBillingCostTransitionsInstant(
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setServerStatusChangeBillingCost(Money.ofMajor(JPY, 800))
|
||||
@@ -1327,7 +1327,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
persistResource(
|
||||
Tld.get("example")
|
||||
.asBuilder()
|
||||
.setEapFeeScheduleInstant(
|
||||
.setEapFeeSchedule(
|
||||
new ImmutableSortedMap.Builder<Instant, Money>(Ordering.natural())
|
||||
.put(START_INSTANT, Money.of(USD, 0))
|
||||
.put(minusDays(clock.now(), 1), Money.of(USD, 100))
|
||||
@@ -1356,7 +1356,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
persistResource(
|
||||
Tld.get("example")
|
||||
.asBuilder()
|
||||
.setEapFeeScheduleInstant(
|
||||
.setEapFeeSchedule(
|
||||
new ImmutableSortedMap.Builder<Instant, Money>(Ordering.natural())
|
||||
.put(START_INSTANT, Money.of(USD, 0))
|
||||
.put(minusDays(startTime, 1), Money.of(USD, 100))
|
||||
@@ -2073,10 +2073,10 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
createTld("example")
|
||||
.asBuilder()
|
||||
.setCurrency(JPY)
|
||||
.setCreateBillingCostTransitionsInstant(
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setEapFeeScheduleInstant(ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setRenewBillingCostTransitionsInstant(
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setServerStatusChangeBillingCost(Money.ofMajor(JPY, 800))
|
||||
@@ -2137,7 +2137,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCreateBillingCostTransitionsInstant(
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 11.1)))
|
||||
.build());
|
||||
setEppInput("domain_check_fee_fractional_v06.xml");
|
||||
@@ -2453,7 +2453,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setEapFeeScheduleInstant(
|
||||
.setEapFeeSchedule(
|
||||
new ImmutableSortedMap.Builder<Instant, Money>(Ordering.natural())
|
||||
.put(START_INSTANT, Money.of(USD, 0))
|
||||
.put(minusDays(clock.now(), 1), Money.of(USD, 100))
|
||||
|
||||
@@ -21,7 +21,7 @@ import static google.registry.testing.DatabaseHelper.createTlds;
|
||||
import static google.registry.testing.DatabaseHelper.loadRegistrar;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static org.joda.money.CurrencyUnit.JPY;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
@@ -135,10 +135,10 @@ public class DomainClaimsCheckFlowTest extends ResourceFlowTestCase<DomainClaims
|
||||
.asBuilder()
|
||||
.setCurrency(JPY)
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setServerStatusChangeBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setRestoreBillingCost(Money.ofMajor(JPY, 800))
|
||||
@@ -181,7 +181,7 @@ public class DomainClaimsCheckFlowTest extends ResourceFlowTestCase<DomainClaims
|
||||
void testFailure_multipleTlds_oneHasEndedClaims() {
|
||||
createTlds("tld1", "tld2");
|
||||
persistResource(
|
||||
Tld.get("tld2").asBuilder().setClaimsPeriodEndInstant(clock.now().minusMillis(1)).build());
|
||||
Tld.get("tld2").asBuilder().setClaimsPeriodEnd(clock.now().minusMillis(1)).build());
|
||||
setEppInput("domain_check_claims_multiple_tlds.xml");
|
||||
EppException thrown = assertThrows(ClaimsPeriodEndedException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
|
||||
@@ -733,7 +733,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("example")
|
||||
.asBuilder()
|
||||
.setEapFeeScheduleInstant(
|
||||
.setEapFeeSchedule(
|
||||
ImmutableSortedMap.of(
|
||||
START_INSTANT,
|
||||
Money.of(USD, 0),
|
||||
@@ -871,7 +871,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setTldStateTransitionsInstant(
|
||||
.setTldStateTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
START_INSTANT,
|
||||
PREDELEGATION,
|
||||
@@ -893,7 +893,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
void testSuccess_noClaimsNotice_forClaimsListName_afterClaimsPeriodEnd() throws Exception {
|
||||
persistClaimsList(ImmutableMap.of("example", CLAIMS_KEY));
|
||||
persistHosts();
|
||||
persistResource(Tld.get("tld").asBuilder().setClaimsPeriodEndInstant(clock.now()).build());
|
||||
persistResource(Tld.get("tld").asBuilder().setClaimsPeriodEnd(clock.now()).build());
|
||||
runFlowAssertResponse(
|
||||
loadFile("domain_create_response.xml", ImmutableMap.of("DOMAIN", "example.tld")));
|
||||
assertSuccessfulCreate("tld", ImmutableSet.of());
|
||||
@@ -922,7 +922,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
setEppInput("domain_create_claim_notice.xml");
|
||||
persistClaimsList(ImmutableMap.of("example-one", CLAIMS_KEY));
|
||||
persistHosts();
|
||||
persistResource(Tld.get("tld").asBuilder().setClaimsPeriodEndInstant(clock.now()).build());
|
||||
persistResource(Tld.get("tld").asBuilder().setClaimsPeriodEnd(clock.now()).build());
|
||||
EppException thrown = assertThrows(ClaimsPeriodEndedException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
@@ -981,7 +981,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCreateBillingCostTransitionsInstant(
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 20)))
|
||||
.build());
|
||||
persistHosts();
|
||||
@@ -995,8 +995,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCreateBillingCostTransitionsInstant(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 8)))
|
||||
.setCreateBillingCostTransitions(ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 8)))
|
||||
.build());
|
||||
// Expects fee of $24
|
||||
setEppInput("domain_create_fee.xml", FEE_STD_1_0_MAP);
|
||||
@@ -1011,7 +1010,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCreateBillingCostTransitionsInstant(
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 100)))
|
||||
.build());
|
||||
// Expects fee of $24
|
||||
@@ -1215,7 +1214,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
.asBuilder()
|
||||
.setReservedLists(
|
||||
persistReservedList("anchor_tenants", "test-validate,RESERVED_FOR_ANCHOR_TENANT"))
|
||||
.setTldStateTransitionsInstant(ImmutableSortedMap.of(START_INSTANT, START_DATE_SUNRISE))
|
||||
.setTldStateTransitions(ImmutableSortedMap.of(START_INSTANT, START_DATE_SUNRISE))
|
||||
.build());
|
||||
setEppInput("domain_create_anchor_tenant_signed_mark.xml", ImmutableMap.of("SMD", ENCODED_SMD));
|
||||
clock.setTo(SMD_VALID_TIME);
|
||||
@@ -1241,7 +1240,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setTldStateTransitionsInstant(
|
||||
.setTldStateTransitions(
|
||||
new ImmutableSortedMap.Builder<Instant, TldState>(Ordering.natural())
|
||||
.put(START_INSTANT, PREDELEGATION)
|
||||
.put(Instant.parse("1999-01-01T00:00:00Z"), QUIET_PERIOD)
|
||||
@@ -1284,7 +1283,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setTldStateTransitionsInstant(ImmutableSortedMap.of(START_INSTANT, QUIET_PERIOD))
|
||||
.setTldStateTransitions(ImmutableSortedMap.of(START_INSTANT, QUIET_PERIOD))
|
||||
.build());
|
||||
allocationToken =
|
||||
persistResource(
|
||||
@@ -1680,7 +1679,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setTldStateTransitionsInstant(ImmutableSortedMap.of(START_INSTANT, START_DATE_SUNRISE))
|
||||
.setTldStateTransitions(ImmutableSortedMap.of(START_INSTANT, START_DATE_SUNRISE))
|
||||
.build());
|
||||
clock.setTo(SMD_VALID_TIME);
|
||||
setEppInput(
|
||||
@@ -2119,7 +2118,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setTldStateTransitionsInstant(ImmutableSortedMap.of(START_INSTANT, QUIET_PERIOD))
|
||||
.setTldStateTransitions(ImmutableSortedMap.of(START_INSTANT, QUIET_PERIOD))
|
||||
.build());
|
||||
runFlow();
|
||||
assertSuccessfulCreate("tld", ImmutableSet.of(), token);
|
||||
@@ -2445,10 +2444,10 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCurrency(JPY)
|
||||
.setCreateBillingCostTransitionsInstant(
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setEapFeeScheduleInstant(ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setRenewBillingCostTransitionsInstant(
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setServerStatusChangeBillingCost(Money.ofMajor(JPY, 800))
|
||||
@@ -2636,7 +2635,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get(tld)
|
||||
.asBuilder()
|
||||
.setEapFeeScheduleInstant(
|
||||
.setEapFeeSchedule(
|
||||
ImmutableSortedMap.of(
|
||||
START_INSTANT,
|
||||
Money.of(USD, 0),
|
||||
@@ -2653,7 +2652,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setEapFeeScheduleInstant(
|
||||
.setEapFeeSchedule(
|
||||
ImmutableSortedMap.of(
|
||||
START_INSTANT,
|
||||
Money.of(USD, 0),
|
||||
@@ -2671,7 +2670,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setEapFeeScheduleInstant(
|
||||
.setEapFeeSchedule(
|
||||
ImmutableSortedMap.of(
|
||||
START_INSTANT,
|
||||
Money.of(USD, 0),
|
||||
@@ -2812,7 +2811,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setTldStateTransitionsInstant(ImmutableSortedMap.of(START_INSTANT, QUIET_PERIOD))
|
||||
.setTldStateTransitions(ImmutableSortedMap.of(START_INSTANT, QUIET_PERIOD))
|
||||
.build());
|
||||
runFlow();
|
||||
assertSuccessfulCreate("tld", ImmutableSet.of(), token);
|
||||
@@ -2834,7 +2833,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setTldStateTransitionsInstant(ImmutableSortedMap.of(START_INSTANT, QUIET_PERIOD))
|
||||
.setTldStateTransitions(ImmutableSortedMap.of(START_INSTANT, QUIET_PERIOD))
|
||||
.build());
|
||||
runFlow();
|
||||
assertSuccessfulCreate("tld", ImmutableSet.of(), token);
|
||||
@@ -2868,7 +2867,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setTldStateTransitionsInstant(ImmutableSortedMap.of(START_INSTANT, QUIET_PERIOD))
|
||||
.setTldStateTransitions(ImmutableSortedMap.of(START_INSTANT, QUIET_PERIOD))
|
||||
.build());
|
||||
assertThrows(NoGeneralRegistrationsInCurrentPhaseException.class, this::runFlow);
|
||||
}
|
||||
@@ -2887,7 +2886,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setTldStateTransitionsInstant(
|
||||
.setTldStateTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
START_INSTANT, QUIET_PERIOD, plusYears(clock.now(), 1), START_DATE_SUNRISE))
|
||||
.build());
|
||||
@@ -2910,7 +2909,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setTldStateTransitionsInstant(
|
||||
.setTldStateTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
START_INSTANT,
|
||||
QUIET_PERIOD,
|
||||
@@ -3058,7 +3057,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setTldStateTransitionsInstant(
|
||||
.setTldStateTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
START_INSTANT,
|
||||
QUIET_PERIOD,
|
||||
@@ -3089,7 +3088,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setTldStateTransitionsInstant(
|
||||
.setTldStateTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
START_INSTANT,
|
||||
QUIET_PERIOD,
|
||||
@@ -3115,7 +3114,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setTldStateTransitionsInstant(
|
||||
.setTldStateTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
START_INSTANT,
|
||||
QUIET_PERIOD,
|
||||
@@ -3313,7 +3312,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCreateBillingCostTransitionsInstant(
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 20)))
|
||||
.build());
|
||||
persistHosts();
|
||||
@@ -3327,7 +3326,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCreateBillingCostTransitionsInstant(
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 20)))
|
||||
.build());
|
||||
persistHosts();
|
||||
@@ -3341,7 +3340,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCreateBillingCostTransitionsInstant(
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 20)))
|
||||
.build());
|
||||
persistHosts();
|
||||
@@ -3355,8 +3354,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCreateBillingCostTransitionsInstant(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 8)))
|
||||
.setCreateBillingCostTransitions(ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 8)))
|
||||
.build());
|
||||
// Expects fee of $24
|
||||
setEppInput("domain_create_fee.xml", FEE_06_MAP);
|
||||
@@ -3371,8 +3369,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCreateBillingCostTransitionsInstant(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 8)))
|
||||
.setCreateBillingCostTransitions(ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 8)))
|
||||
.build());
|
||||
// Expects fee of $24
|
||||
setEppInput("domain_create_fee.xml", FEE_11_MAP);
|
||||
@@ -3387,8 +3384,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCreateBillingCostTransitionsInstant(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 8)))
|
||||
.setCreateBillingCostTransitions(ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 8)))
|
||||
.build());
|
||||
// Expects fee of $24
|
||||
setEppInput("domain_create_fee.xml", FEE_12_MAP);
|
||||
@@ -3529,7 +3525,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCreateBillingCostTransitionsInstant(
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 100)))
|
||||
.build());
|
||||
// Expects fee of $24
|
||||
@@ -3545,7 +3541,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCreateBillingCostTransitionsInstant(
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 100)))
|
||||
.build());
|
||||
// Expects fee of $24
|
||||
@@ -3561,7 +3557,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCreateBillingCostTransitionsInstant(
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 100)))
|
||||
.build());
|
||||
// Expects fee of $24
|
||||
@@ -3948,7 +3944,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("example")
|
||||
.asBuilder()
|
||||
.setEapFeeScheduleInstant(
|
||||
.setEapFeeSchedule(
|
||||
ImmutableSortedMap.of(
|
||||
START_INSTANT,
|
||||
Money.of(USD, 0),
|
||||
|
||||
@@ -543,7 +543,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitionsInstant(
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
START_INSTANT,
|
||||
Money.of(USD, 11),
|
||||
@@ -1325,7 +1325,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitionsInstant(
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
START_INSTANT,
|
||||
Money.of(USD, 11),
|
||||
@@ -1344,7 +1344,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitionsInstant(
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
START_INSTANT,
|
||||
Money.of(USD, 11),
|
||||
@@ -1362,7 +1362,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitionsInstant(
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
START_INSTANT,
|
||||
Money.of(USD, 11),
|
||||
|
||||
@@ -20,7 +20,7 @@ import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.newTld;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static org.joda.money.CurrencyUnit.CHF;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
@@ -187,10 +187,10 @@ class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
|
||||
.setTldType(tldType)
|
||||
.setCurrency(CHF)
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(CHF, 800)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(CHF, 800)))
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(CHF, 800)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(CHF, 800)))
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(CHF, 800)))
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(CHF, 800)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.ofMajor(CHF, 800))
|
||||
.setServerStatusChangeBillingCost(Money.ofMajor(CHF, 800))
|
||||
.setRestoreBillingCost(Money.ofMajor(CHF, 800))
|
||||
|
||||
@@ -30,7 +30,7 @@ import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
|
||||
import static google.registry.testing.TestDataHelper.updateSubstitutions;
|
||||
import static google.registry.util.DateTimeUtils.END_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.minusDays;
|
||||
import static google.registry.util.DateTimeUtils.plusDays;
|
||||
import static google.registry.xml.XmlTestUtils.assertXmlEquals;
|
||||
@@ -301,7 +301,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setTldStateTransitions(ImmutableSortedMap.of(START_OF_TIME, QUIET_PERIOD))
|
||||
.setTldStateTransitions(ImmutableSortedMap.of(START_INSTANT, QUIET_PERIOD))
|
||||
.build());
|
||||
doSuccessfulTest("domain_info_response.xml");
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ import static google.registry.testing.DatabaseHelper.persistPremiumList;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.util.DateTimeUtils.END_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.minusHours;
|
||||
import static google.registry.util.DateTimeUtils.plusHours;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
@@ -56,7 +58,6 @@ import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.FakeHttpSession;
|
||||
import google.registry.util.Clock;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import org.joda.money.Money;
|
||||
@@ -89,7 +90,7 @@ public class DomainPricingLogicTest {
|
||||
persistResource(
|
||||
Tld.get("example")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitionsInstant(
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
START_INSTANT, Money.of(USD, 1), clock.now(), Money.of(USD, 10)))
|
||||
.setPremiumList(persistPremiumList("tld2", USD, "premium,USD 100"))
|
||||
@@ -137,13 +138,12 @@ public class DomainPricingLogicTest {
|
||||
ImmutableSortedMap<Instant, TldState> transitions =
|
||||
ImmutableSortedMap.<Instant, TldState>naturalOrder()
|
||||
.put(START_INSTANT, TldState.PREDELEGATION)
|
||||
.put(clock.now().minus(Duration.ofHours(1)), TldState.START_DATE_SUNRISE)
|
||||
.put(clock.now().plus(Duration.ofHours(1)), TldState.GENERAL_AVAILABILITY)
|
||||
.put(minusHours(clock.now(), 1), TldState.START_DATE_SUNRISE)
|
||||
.put(plusHours(clock.now(), 1), TldState.GENERAL_AVAILABILITY)
|
||||
.build();
|
||||
createTld("sunrise");
|
||||
Tld sunriseTld =
|
||||
persistResource(
|
||||
Tld.get("sunrise").asBuilder().setTldStateTransitionsInstant(transitions).build());
|
||||
persistResource(Tld.get("sunrise").asBuilder().setTldStateTransitions(transitions).build());
|
||||
assertThat(
|
||||
domainPricingLogic.getCreatePrice(
|
||||
sunriseTld, "domain.sunrise", clock.now(), 2, false, true, Optional.empty()))
|
||||
|
||||
@@ -40,9 +40,7 @@ import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptio
|
||||
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
|
||||
import static google.registry.testing.TestDataHelper.updateSubstitutions;
|
||||
import static google.registry.util.DateTimeUtils.END_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.minusDays;
|
||||
import static google.registry.util.DateTimeUtils.minusYears;
|
||||
import static google.registry.util.DateTimeUtils.plusDays;
|
||||
@@ -184,7 +182,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
.setTargetId(getUniqueIdFromCommand())
|
||||
.setRegistrarId("TheRegistrar")
|
||||
.setEventTime(expirationTime)
|
||||
.setAutorenewEndTime(END_OF_TIME)
|
||||
.setAutorenewEndTime(END_INSTANT)
|
||||
.setMsg("Domain was auto-renewed.")
|
||||
.setHistoryEntry(historyEntryDomainCreate)
|
||||
.build();
|
||||
@@ -322,7 +320,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
.setTargetId(getUniqueIdFromCommand())
|
||||
.setRegistrarId("TheRegistrar")
|
||||
.setEventTime(domain.getRegistrationExpirationTime())
|
||||
.setAutorenewEndTime(END_OF_TIME)
|
||||
.setAutorenewEndTime(END_INSTANT)
|
||||
.setMsg("Domain was auto-renewed.")
|
||||
.setHistoryEntry(historyEntryDomainRenew)
|
||||
.build());
|
||||
@@ -826,7 +824,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
.setTargetId(getUniqueIdFromCommand())
|
||||
.setRegistrarId("TheRegistrar")
|
||||
.setEventTime(reloadResourceByForeignKey().getRegistrationExpirationTime())
|
||||
.setAutorenewEndTime(END_OF_TIME)
|
||||
.setAutorenewEndTime(END_INSTANT)
|
||||
.setMsg("Domain was auto-renewed.")
|
||||
.setHistoryEntry(historyEntryDomainRenew)
|
||||
.build());
|
||||
@@ -932,7 +930,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 20)))
|
||||
.build());
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||
@@ -947,10 +945,10 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
.asBuilder()
|
||||
.setCurrency(EUR)
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 13)))
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(EUR, 13)))
|
||||
.setRestoreBillingCost(Money.of(EUR, 11))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 7)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_INSTANT, Money.of(EUR, 7)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_INSTANT, Money.zero(EUR)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.of(EUR, 20))
|
||||
.setServerStatusChangeBillingCost(Money.of(EUR, 19))
|
||||
.build());
|
||||
@@ -975,10 +973,10 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
.asBuilder()
|
||||
.setCurrency(JPY)
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setServerStatusChangeBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setRestoreBillingCost(Money.ofMajor(JPY, 800))
|
||||
@@ -1569,7 +1567,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setDefaultPromoTokens(ImmutableList.of(defaultToken1.createVKey()))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 20)))
|
||||
.build());
|
||||
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
@@ -1581,7 +1579,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 20)))
|
||||
.build());
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||
@@ -1594,7 +1592,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 20)))
|
||||
.build());
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||
@@ -1607,7 +1605,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 20)))
|
||||
.build());
|
||||
persistDomain();
|
||||
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||
@@ -1622,10 +1620,10 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
.asBuilder()
|
||||
.setCurrency(EUR)
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 13)))
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(EUR, 13)))
|
||||
.setRestoreBillingCost(Money.of(EUR, 11))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 7)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_INSTANT, Money.of(EUR, 7)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_INSTANT, Money.zero(EUR)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.of(EUR, 20))
|
||||
.setServerStatusChangeBillingCost(Money.of(EUR, 19))
|
||||
.build());
|
||||
@@ -1642,10 +1640,10 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
.asBuilder()
|
||||
.setCurrency(EUR)
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 13)))
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(EUR, 13)))
|
||||
.setRestoreBillingCost(Money.of(EUR, 11))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 7)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_INSTANT, Money.of(EUR, 7)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_INSTANT, Money.zero(EUR)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.of(EUR, 20))
|
||||
.setServerStatusChangeBillingCost(Money.of(EUR, 19))
|
||||
.build());
|
||||
@@ -1662,10 +1660,10 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
.asBuilder()
|
||||
.setCurrency(EUR)
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 13)))
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(EUR, 13)))
|
||||
.setRestoreBillingCost(Money.of(EUR, 11))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 7)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_INSTANT, Money.of(EUR, 7)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_INSTANT, Money.zero(EUR)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.of(EUR, 20))
|
||||
.setServerStatusChangeBillingCost(Money.of(EUR, 19))
|
||||
.build());
|
||||
@@ -1819,7 +1817,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setDefaultPromoTokens(ImmutableList.of(defaultToken1.createVKey()))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 20)))
|
||||
.build());
|
||||
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
@@ -1880,7 +1878,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setDefaultPromoTokens(ImmutableList.of(defaultToken1.createVKey()))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 20)))
|
||||
.build());
|
||||
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
@@ -1941,7 +1939,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setDefaultPromoTokens(ImmutableList.of(defaultToken1.createVKey()))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 20)))
|
||||
.build());
|
||||
EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
|
||||
@@ -82,7 +82,6 @@ import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.tld.Tld;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.testing.DatabaseHelper;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -172,7 +171,7 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
|
||||
@Test
|
||||
void testSuccess_expiryStillInFuture_notExtended() throws Exception {
|
||||
setEppInput("domain_update_restore_request.xml", ImmutableMap.of("DOMAIN", "example.tld"));
|
||||
Instant expirationTime = plusYears(clock.now(), 5).plus(Duration.ofDays(45));
|
||||
Instant expirationTime = plusDays(plusYears(clock.now(), 5), 45);
|
||||
persistPendingDeleteDomain(expirationTime);
|
||||
assertMutatingFlow(true);
|
||||
// Double check that we see a poll message in the future for when the delete happens.
|
||||
@@ -482,12 +481,11 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCurrency(EUR)
|
||||
.setCreateBillingCostTransitionsInstant(
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(EUR, 13)))
|
||||
.setRestoreBillingCost(Money.of(EUR, 11))
|
||||
.setRenewBillingCostTransitionsInstant(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(EUR, 7)))
|
||||
.setEapFeeScheduleInstant(ImmutableSortedMap.of(START_INSTANT, Money.zero(EUR)))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_INSTANT, Money.of(EUR, 7)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_INSTANT, Money.zero(EUR)))
|
||||
.setServerStatusChangeBillingCost(Money.of(EUR, 19))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.of(EUR, 0))
|
||||
.build());
|
||||
@@ -601,10 +599,10 @@ class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreReq
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCurrency(JPY)
|
||||
.setCreateBillingCostTransitionsInstant(
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setEapFeeScheduleInstant(ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setRenewBillingCostTransitionsInstant(
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setServerStatusChangeBillingCost(Money.ofMajor(JPY, 800))
|
||||
|
||||
@@ -120,7 +120,7 @@ class DomainTransferApproveFlowTest
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitionsInstant(
|
||||
.setRenewBillingCostTransitions(
|
||||
new ImmutableSortedMap.Builder<Instant, Money>(Ordering.natural())
|
||||
.put(START_INSTANT, Money.of(USD, 1))
|
||||
.put(minusDays(clock.now(), 1).plusMillis(1), Money.of(USD, 22))
|
||||
|
||||
@@ -47,7 +47,6 @@ import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntr
|
||||
import static google.registry.testing.HostSubject.assertAboutHosts;
|
||||
import static google.registry.testing.TestDataHelper.updateSubstitutions;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.minusDays;
|
||||
import static google.registry.util.DateTimeUtils.minusYears;
|
||||
import static google.registry.util.DateTimeUtils.plusDays;
|
||||
@@ -798,7 +797,7 @@ class DomainTransferRequestFlowTest
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setTldStateTransitions(ImmutableSortedMap.of(START_OF_TIME, QUIET_PERIOD))
|
||||
.setTldStateTransitions(ImmutableSortedMap.of(START_INSTANT, QUIET_PERIOD))
|
||||
.build());
|
||||
doSuccessfulTest("domain_transfer_request.xml", "domain_transfer_request_response.xml");
|
||||
}
|
||||
@@ -1022,10 +1021,10 @@ class DomainTransferRequestFlowTest
|
||||
.asBuilder()
|
||||
.setCurrency(JPY)
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 800)))
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.ofMajor(JPY, 800)))
|
||||
.setRegistryLockOrUnlockBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setServerStatusChangeBillingCost(Money.ofMajor(JPY, 800))
|
||||
.setRestoreBillingCost(Money.ofMajor(JPY, 800))
|
||||
@@ -1486,7 +1485,7 @@ class DomainTransferRequestFlowTest
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 20)))
|
||||
.build());
|
||||
EppException thrown =
|
||||
assertThrows(
|
||||
|
||||
@@ -50,7 +50,7 @@ import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DomainSubject.assertAboutDomains;
|
||||
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
|
||||
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.plusDays;
|
||||
import static google.registry.util.DateTimeUtils.plusYears;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
@@ -264,7 +264,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
|
||||
persistResource(
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setTldStateTransitions(ImmutableSortedMap.of(START_OF_TIME, QUIET_PERIOD))
|
||||
.setTldStateTransitions(ImmutableSortedMap.of(START_INSTANT, QUIET_PERIOD))
|
||||
.build());
|
||||
persistReferencedEntities();
|
||||
persistDomain();
|
||||
|
||||
+17
-23
@@ -27,6 +27,7 @@ import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.minusDays;
|
||||
import static google.registry.util.DateTimeUtils.minusHours;
|
||||
import static google.registry.util.DateTimeUtils.minusMonths;
|
||||
import static google.registry.util.DateTimeUtils.plusDays;
|
||||
import static google.registry.util.DateTimeUtils.plusMonths;
|
||||
@@ -53,7 +54,6 @@ import google.registry.model.tld.Tld;
|
||||
import google.registry.persistence.transaction.JpaTestExtensions;
|
||||
import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension;
|
||||
import google.registry.testing.FakeClock;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -125,10 +125,7 @@ class AllocationTokenFlowUtilsTest {
|
||||
when(allocationTokenExtension.getAllocationToken()).thenReturn("tokeN");
|
||||
assertThat(
|
||||
AllocationTokenFlowUtils.loadAllocationTokenFromExtension(
|
||||
"TheRegistrar",
|
||||
"example.tld",
|
||||
clock.nowUtc(),
|
||||
Optional.of(allocationTokenExtension)))
|
||||
"TheRegistrar", "example.tld", clock.now(), Optional.of(allocationTokenExtension)))
|
||||
.hasValue(token);
|
||||
}
|
||||
|
||||
@@ -146,7 +143,7 @@ class AllocationTokenFlowUtilsTest {
|
||||
assertThat(
|
||||
AllocationTokenFlowUtils.loadTokenFromExtensionOrGetDefault(
|
||||
"TheRegistrar",
|
||||
clock.nowUtc(),
|
||||
clock.now(),
|
||||
Optional.of(allocationTokenExtension),
|
||||
tld,
|
||||
"example.tld",
|
||||
@@ -162,7 +159,7 @@ class AllocationTokenFlowUtilsTest {
|
||||
assertThat(
|
||||
AllocationTokenFlowUtils.loadTokenFromExtensionOrGetDefault(
|
||||
"TheRegistrar",
|
||||
clock.nowUtc(),
|
||||
clock.now(),
|
||||
Optional.empty(),
|
||||
tld,
|
||||
"example.tld",
|
||||
@@ -186,7 +183,7 @@ class AllocationTokenFlowUtilsTest {
|
||||
assertThat(
|
||||
AllocationTokenFlowUtils.loadTokenFromExtensionOrGetDefault(
|
||||
"TheRegistrar",
|
||||
clock.nowUtc(),
|
||||
clock.now(),
|
||||
Optional.of(allocationTokenExtension),
|
||||
tld,
|
||||
"example.tld",
|
||||
@@ -201,7 +198,7 @@ class AllocationTokenFlowUtilsTest {
|
||||
AllocationToken token = singleUseTokenBuilder().setDiscountPremiums(true).build();
|
||||
assertThat(
|
||||
AllocationTokenFlowUtils.tokenIsValidAgainstDomain(
|
||||
InternetDomainName.from("rich.tld"), token, CommandName.CREATE, clock.nowUtc()))
|
||||
InternetDomainName.from("rich.tld"), token, CommandName.CREATE, clock.now()))
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@@ -210,7 +207,7 @@ class AllocationTokenFlowUtilsTest {
|
||||
AllocationToken token = singleUseTokenBuilder().build();
|
||||
assertThat(
|
||||
AllocationTokenFlowUtils.tokenIsValidAgainstDomain(
|
||||
InternetDomainName.from("rich.tld"), token, CommandName.CREATE, clock.nowUtc()))
|
||||
InternetDomainName.from("rich.tld"), token, CommandName.CREATE, clock.now()))
|
||||
.isFalse();
|
||||
}
|
||||
|
||||
@@ -220,7 +217,7 @@ class AllocationTokenFlowUtilsTest {
|
||||
singleUseTokenBuilder().setAllowedEppActions(ImmutableSet.of(CommandName.RESTORE)).build();
|
||||
assertThat(
|
||||
AllocationTokenFlowUtils.tokenIsValidAgainstDomain(
|
||||
InternetDomainName.from("domain.tld"), token, CommandName.CREATE, clock.nowUtc()))
|
||||
InternetDomainName.from("domain.tld"), token, CommandName.CREATE, clock.now()))
|
||||
.isFalse();
|
||||
}
|
||||
|
||||
@@ -230,10 +227,7 @@ class AllocationTokenFlowUtilsTest {
|
||||
AllocationToken token = singleUseTokenBuilder().build();
|
||||
assertThat(
|
||||
AllocationTokenFlowUtils.tokenIsValidAgainstDomain(
|
||||
InternetDomainName.from("domain.othertld"),
|
||||
token,
|
||||
CommandName.CREATE,
|
||||
clock.nowUtc()))
|
||||
InternetDomainName.from("domain.othertld"), token, CommandName.CREATE, clock.now()))
|
||||
.isFalse();
|
||||
}
|
||||
|
||||
@@ -242,7 +236,7 @@ class AllocationTokenFlowUtilsTest {
|
||||
AllocationToken token = singleUseTokenBuilder().setDomainName("anchor.tld").build();
|
||||
assertThat(
|
||||
AllocationTokenFlowUtils.tokenIsValidAgainstDomain(
|
||||
InternetDomainName.from("domain.tld"), token, CommandName.CREATE, clock.nowUtc()))
|
||||
InternetDomainName.from("domain.tld"), token, CommandName.CREATE, clock.now()))
|
||||
.isFalse();
|
||||
}
|
||||
|
||||
@@ -297,7 +291,7 @@ class AllocationTokenFlowUtilsTest {
|
||||
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
|
||||
.put(START_INSTANT, NOT_STARTED)
|
||||
.put(minusMonths(clock.now(), 1), VALID)
|
||||
.put(clock.now().minus(Duration.ofHours(12)), CANCELLED)
|
||||
.put(minusHours(clock.now(), 12), CANCELLED)
|
||||
.build())
|
||||
.build());
|
||||
assertLoadTokenFromExtensionThrowsException(AllocationTokenNotInPromotionException.class);
|
||||
@@ -311,7 +305,7 @@ class AllocationTokenFlowUtilsTest {
|
||||
() ->
|
||||
AllocationTokenFlowUtils.loadTokenFromExtensionOrGetDefault(
|
||||
"TheRegistrar",
|
||||
clock.nowUtc(),
|
||||
clock.now(),
|
||||
Optional.of(allocationTokenExtension),
|
||||
tld,
|
||||
"example.tld",
|
||||
@@ -325,7 +319,7 @@ class AllocationTokenFlowUtilsTest {
|
||||
assertThat(
|
||||
AllocationTokenFlowUtils.loadTokenFromExtensionOrGetDefault(
|
||||
"TheRegistrar",
|
||||
clock.nowUtc(),
|
||||
clock.now(),
|
||||
Optional.empty(),
|
||||
tld,
|
||||
"example.tld",
|
||||
@@ -345,7 +339,7 @@ class AllocationTokenFlowUtilsTest {
|
||||
() ->
|
||||
AllocationTokenFlowUtils.loadTokenFromExtensionOrGetDefault(
|
||||
"TheRegistrar",
|
||||
clock.nowUtc(),
|
||||
clock.now(),
|
||||
Optional.of(allocationTokenExtension),
|
||||
tld,
|
||||
"example.tld",
|
||||
@@ -385,7 +379,7 @@ class AllocationTokenFlowUtilsTest {
|
||||
assertThat(
|
||||
AllocationTokenFlowUtils.loadTokenFromExtensionOrGetDefault(
|
||||
"TheRegistrar",
|
||||
clock.nowUtc(),
|
||||
clock.now(),
|
||||
Optional.empty(),
|
||||
tld,
|
||||
"example.tld",
|
||||
@@ -428,7 +422,7 @@ class AllocationTokenFlowUtilsTest {
|
||||
assertThat(
|
||||
AllocationTokenFlowUtils.loadTokenFromExtensionOrGetDefault(
|
||||
"TheRegistrar",
|
||||
clock.nowUtc(),
|
||||
clock.now(),
|
||||
Optional.empty(),
|
||||
tld,
|
||||
"example.tld",
|
||||
@@ -465,7 +459,7 @@ class AllocationTokenFlowUtilsTest {
|
||||
AllocationTokenFlowUtils.loadAllocationTokenFromExtension(
|
||||
"TheRegistrar",
|
||||
"example.tld",
|
||||
clock.nowUtc(),
|
||||
clock.now(),
|
||||
Optional.of(allocationTokenExtension))))
|
||||
.marshalsToXml();
|
||||
}
|
||||
|
||||
@@ -1437,3 +1437,4 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
|
||||
assertIcannReportingActivityFieldLogged("srs-host-update");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,6 @@ import google.registry.model.registrar.Registrar;
|
||||
import google.registry.testing.CertificateSamples;
|
||||
import google.registry.util.CidrAddressBlock;
|
||||
import java.net.InetAddress;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Optional;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -64,7 +62,7 @@ public class LoginFlowViaTlsTest extends LoginFlowTestCase {
|
||||
@Override
|
||||
protected Registrar.Builder getRegistrarBuilder() {
|
||||
return super.getRegistrarBuilder()
|
||||
.setClientCertificate(GOOD_CERT.get(), Instant.now().truncatedTo(ChronoUnit.MILLIS))
|
||||
.setClientCertificate(GOOD_CERT.get(), clock.now())
|
||||
.setIpAddressAllowList(ImmutableList.of(CidrAddressBlock.create(GOOD_IP.get(), 32)));
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import google.registry.persistence.transaction.JpaTestExtensions;
|
||||
import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension;
|
||||
import google.registry.testing.FakeClock;
|
||||
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;
|
||||
@@ -53,7 +52,7 @@ class EppResourceUtilsTest {
|
||||
Host host =
|
||||
persistResource(
|
||||
newHost("ns1.cat.tld").asBuilder().setCreationTimeForTest(clock.now()).build());
|
||||
assertThat(loadAtPointInTime(host, clock.nowUtc().minus(Duration.millis(1)))).isNull();
|
||||
assertThat(loadAtPointInTime(host, clock.nowUtc().minusMillis(1))).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -25,7 +25,7 @@ import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.loadByKeyIfPresent;
|
||||
import static google.registry.testing.DatabaseHelper.persistPremiumList;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -48,11 +48,10 @@ import google.registry.testing.CloudTasksHelper.TaskMatcher;
|
||||
import google.registry.tools.IamClient;
|
||||
import google.registry.util.CidrAddressBlock;
|
||||
import google.registry.util.SystemClock;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -86,7 +85,7 @@ public final class OteAccountBuilderTest {
|
||||
Tld registry = Tld.get(tld);
|
||||
assertThat(registry).isNotNull();
|
||||
assertThat(registry.getPremiumListName()).hasValue("default_sandbox_list");
|
||||
assertThat(registry.getTldStateTransitions()).containsExactly(START_OF_TIME, tldState);
|
||||
assertThat(registry.getTldStateTransitions()).containsExactly(START_INSTANT, tldState);
|
||||
assertThat(registry.getDnsWriters()).containsExactly("VoidDnsWriter");
|
||||
assertThat(registry.getAddGracePeriodLength()).isEqualTo(Duration.standardHours(1));
|
||||
assertThat(registry.getPendingDeleteLength()).isEqualTo(Duration.standardMinutes(5));
|
||||
@@ -94,8 +93,7 @@ public final class OteAccountBuilderTest {
|
||||
assertThat(registry.getCurrency()).isEqualTo(eapFee.getCurrencyUnit());
|
||||
// This uses "now" on purpose - so the test will break at 2022 when the current EapFee in OTE
|
||||
// goes back to 0
|
||||
assertThat(registry.getEapFeeFor(DateTime.now(DateTimeZone.UTC)).getCost())
|
||||
.isEqualTo(eapFee.getAmount());
|
||||
assertThat(registry.getEapFeeFor(Instant.now()).getCost()).isEqualTo(eapFee.getAmount());
|
||||
}
|
||||
|
||||
private static void assertRegistrarExists(String registrarId, String tld) {
|
||||
|
||||
@@ -44,9 +44,7 @@ import google.registry.model.domain.token.AllocationToken.TokenStatus;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.persistence.VKey;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import org.joda.money.Money;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -102,10 +100,8 @@ public class BillingBaseTest extends EntityTestCase {
|
||||
.setTokenStatusTransitions(
|
||||
ImmutableSortedMap.<Instant, TokenStatus>naturalOrder()
|
||||
.put(START_INSTANT, TokenStatus.NOT_STARTED)
|
||||
.put(Instant.now().truncatedTo(ChronoUnit.MILLIS), TokenStatus.VALID)
|
||||
.put(
|
||||
Instant.now().truncatedTo(ChronoUnit.MILLIS).plus(Duration.ofDays(56)),
|
||||
TokenStatus.ENDED)
|
||||
.put(fakeClock.now(), TokenStatus.VALID)
|
||||
.put(plusDays(fakeClock.now(), 56), TokenStatus.ENDED)
|
||||
.build())
|
||||
.build());
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import static google.registry.util.DateTimeUtils.plusYears;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Range;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -45,9 +44,7 @@ class TimeOfYearTest {
|
||||
// This should be lossless because atOrAfter includes an exact match.
|
||||
assertThat(TimeOfYear.fromInstant(march1).getNextInstanceAtOrAfter(march1)).isEqualTo(march1);
|
||||
// This should be a year later because we stepped forward a millisecond
|
||||
assertThat(
|
||||
TimeOfYear.fromInstant(march1)
|
||||
.getNextInstanceAtOrAfter(march1.plus(Duration.ofMillis(1))))
|
||||
assertThat(TimeOfYear.fromInstant(march1).getNextInstanceAtOrAfter(march1.plusMillis(1)))
|
||||
.isEqualTo(plusYears(march1, 1));
|
||||
}
|
||||
|
||||
@@ -56,9 +53,7 @@ class TimeOfYearTest {
|
||||
// This should be lossless because beforeOrAt includes an exact match.
|
||||
assertThat(TimeOfYear.fromInstant(march1).getLastInstanceBeforeOrAt(march1)).isEqualTo(march1);
|
||||
// This should be a year earlier because we stepped backward a millisecond
|
||||
assertThat(
|
||||
TimeOfYear.fromInstant(march1)
|
||||
.getLastInstanceBeforeOrAt(march1.minus(Duration.ofMillis(1))))
|
||||
assertThat(TimeOfYear.fromInstant(march1).getLastInstanceBeforeOrAt(march1.minusMillis(1)))
|
||||
.isEqualTo(minusYears(march1, 1));
|
||||
}
|
||||
|
||||
|
||||
@@ -31,11 +31,9 @@ import static google.registry.testing.DomainSubject.assertAboutDomains;
|
||||
import static google.registry.testing.SqlHelper.saveRegistrar;
|
||||
import static google.registry.util.DateTimeUtils.END_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.minusDays;
|
||||
import static google.registry.util.DateTimeUtils.plusDays;
|
||||
import static google.registry.util.DateTimeUtils.plusYears;
|
||||
import static google.registry.util.DateTimeUtils.toDateTime;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
@@ -688,18 +686,14 @@ public class DomainTest {
|
||||
Tld.get("com")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitions(
|
||||
new ImmutableSortedMap.Builder<DateTime, Money>(Ordering.natural())
|
||||
.put(START_OF_TIME, Money.of(USD, 1))
|
||||
.put(toDateTime(oldExpirationTime.plusMillis(1)), Money.of(USD, 2))
|
||||
.put(
|
||||
toDateTime(plusYears(oldExpirationTime, 1).plusMillis(1)), Money.of(USD, 3))
|
||||
new ImmutableSortedMap.Builder<Instant, Money>(Ordering.natural())
|
||||
.put(START_INSTANT, Money.of(USD, 1))
|
||||
.put(oldExpirationTime.plusMillis(1), Money.of(USD, 2))
|
||||
.put(plusYears(oldExpirationTime, 1).plusMillis(1), Money.of(USD, 3))
|
||||
// Surround the third autorenew with price changes right before and after just
|
||||
// to be 100% sure that we lookup the cost at the expiration time.
|
||||
.put(
|
||||
toDateTime(plusYears(oldExpirationTime, 2).minusMillis(1)),
|
||||
Money.of(USD, 4))
|
||||
.put(
|
||||
toDateTime(plusYears(oldExpirationTime, 2).plusMillis(1)), Money.of(USD, 5))
|
||||
.put(plusYears(oldExpirationTime, 2).minusMillis(1), Money.of(USD, 4))
|
||||
.put(plusYears(oldExpirationTime, 2).plusMillis(1), Money.of(USD, 5))
|
||||
.build())
|
||||
.build());
|
||||
Domain renewedThreeTimes = domain.cloneProjectedAtTime(plusYears(oldExpirationTime, 2));
|
||||
|
||||
@@ -28,7 +28,6 @@ import static google.registry.testing.DatabaseHelper.newTld;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.DatabaseHelper.persistResources;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static org.joda.money.CurrencyUnit.JPY;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
@@ -69,13 +68,13 @@ class RegistrarTest extends EntityTestCase {
|
||||
.asBuilder()
|
||||
.setCurrency(JPY)
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.of(JPY, new BigDecimal(1300))))
|
||||
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)))
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(JPY, new BigDecimal(1100))))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_INSTANT, Money.zero(JPY)))
|
||||
.setPremiumList(null)
|
||||
.build());
|
||||
// Set up a new persisted registrar entity.
|
||||
|
||||
@@ -17,11 +17,11 @@ package google.registry.model.smd;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.util.DateTimeUtils.minusHours;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.model.EntityTestCase;
|
||||
import jakarta.persistence.OptimisticLockException;
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class SignedMarkRevocationListDaoTest extends EntityTestCase {
|
||||
void testSave_success() {
|
||||
SignedMarkRevocationList list =
|
||||
SignedMarkRevocationList.create(
|
||||
fakeClock.now(), ImmutableMap.of("mark", fakeClock.now().minus(Duration.ofHours(1))));
|
||||
fakeClock.now(), ImmutableMap.of("mark", minusHours(fakeClock.now(), 1)));
|
||||
list = SignedMarkRevocationListDao.save(list);
|
||||
SignedMarkRevocationList fromDb = SignedMarkRevocationListDao.load();
|
||||
assertAboutImmutableObjects().that(fromDb).isEqualExceptFields(list);
|
||||
@@ -45,7 +45,7 @@ public class SignedMarkRevocationListDaoTest extends EntityTestCase {
|
||||
void testSave_retrySuccess() {
|
||||
SignedMarkRevocationList list =
|
||||
SignedMarkRevocationList.create(
|
||||
fakeClock.now(), ImmutableMap.of("mark", fakeClock.now().minus(Duration.ofHours(1))));
|
||||
fakeClock.now(), ImmutableMap.of("mark", minusHours(fakeClock.now(), 1)));
|
||||
AtomicBoolean isFirstAttempt = new AtomicBoolean(true);
|
||||
tm().transact(
|
||||
() -> {
|
||||
@@ -72,7 +72,7 @@ public class SignedMarkRevocationListDaoTest extends EntityTestCase {
|
||||
void testSave_multipleVersions() {
|
||||
SignedMarkRevocationList list =
|
||||
SignedMarkRevocationList.create(
|
||||
fakeClock.now(), ImmutableMap.of("mark", fakeClock.now().minus(Duration.ofHours(1))));
|
||||
fakeClock.now(), ImmutableMap.of("mark", minusHours(fakeClock.now(), 1)));
|
||||
SignedMarkRevocationListDao.save(list);
|
||||
assertThat(SignedMarkRevocationListDao.load().isSmdRevoked("mark", fakeClock.now())).isTrue();
|
||||
|
||||
|
||||
@@ -31,8 +31,12 @@ import static google.registry.testing.DatabaseHelper.persistPremiumList;
|
||||
import static google.registry.testing.DatabaseHelper.persistReservedList;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.testing.TestDataHelper.loadFile;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.END_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.minusDays;
|
||||
import static google.registry.util.DateTimeUtils.plusDays;
|
||||
import static google.registry.util.DateTimeUtils.plusMonths;
|
||||
import static google.registry.util.ResourceUtils.readResourceBytes;
|
||||
import static java.math.RoundingMode.UNNECESSARY;
|
||||
import static org.joda.money.CurrencyUnit.EUR;
|
||||
@@ -55,9 +59,9 @@ import google.registry.persistence.VKey;
|
||||
import google.registry.tldconfig.idn.IdnTableEnum;
|
||||
import google.registry.util.SerializeUtils;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.util.Optional;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -117,11 +121,11 @@ public final class TldTest extends EntityTestCase {
|
||||
.setDnsWriters(ImmutableSet.of("baz", "bang"))
|
||||
.setEapFeeSchedule(
|
||||
ImmutableSortedMap.of(
|
||||
START_OF_TIME,
|
||||
START_INSTANT,
|
||||
Money.of(USD, 0),
|
||||
DateTime.parse("2000-06-01T00:00:00Z"),
|
||||
Instant.parse("2000-06-01T00:00:00Z"),
|
||||
Money.of(USD, 100),
|
||||
DateTime.parse("2000-06-02T00:00:00Z"),
|
||||
Instant.parse("2000-06-02T00:00:00Z"),
|
||||
Money.of(USD, 0)))
|
||||
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("foo"))
|
||||
.setDefaultPromoTokens(ImmutableList.of(defaultToken.createVKey()))
|
||||
@@ -151,11 +155,11 @@ public final class TldTest extends EntityTestCase {
|
||||
// set create billing cost back to the default (database helper sets it to $13)
|
||||
.setEapFeeSchedule(
|
||||
ImmutableSortedMap.of(
|
||||
START_OF_TIME,
|
||||
START_INSTANT,
|
||||
Money.of(USD, 0),
|
||||
DateTime.parse("2000-06-01T00:00:00Z"),
|
||||
Instant.parse("2000-06-01T00:00:00Z"),
|
||||
Money.of(USD, 100),
|
||||
DateTime.parse("2000-06-02T00:00:00Z"),
|
||||
Instant.parse("2000-06-02T00:00:00Z"),
|
||||
Money.of(USD, 0)))
|
||||
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("foo"))
|
||||
.setDefaultPromoTokens(ImmutableList.of(defaultToken.createVKey()))
|
||||
@@ -215,36 +219,36 @@ public final class TldTest extends EntityTestCase {
|
||||
|
||||
@Test
|
||||
void testSetCreateBillingCostTransitions() {
|
||||
ImmutableSortedMap<DateTime, Money> createCostTransitions =
|
||||
ImmutableSortedMap<Instant, Money> createCostTransitions =
|
||||
ImmutableSortedMap.of(
|
||||
START_OF_TIME,
|
||||
START_INSTANT,
|
||||
Money.of(USD, 8),
|
||||
fakeClock.nowUtc(),
|
||||
fakeClock.now(),
|
||||
Money.of(USD, 1),
|
||||
fakeClock.nowUtc().plusMonths(1),
|
||||
plusMonths(fakeClock.now(), 1),
|
||||
Money.of(USD, 2),
|
||||
fakeClock.nowUtc().plusMonths(2),
|
||||
plusMonths(fakeClock.now(), 2),
|
||||
Money.of(USD, 3));
|
||||
Tld registry =
|
||||
Tld.get("tld").asBuilder().setCreateBillingCostTransitions(createCostTransitions).build();
|
||||
assertThat(registry.getCreateBillingCostTransitions()).isEqualTo(createCostTransitions);
|
||||
assertThat(registry.getCreateBillingCost(fakeClock.nowUtc().minus(Duration.standardDays(5))))
|
||||
assertThat(registry.getCreateBillingCost(minusDays(fakeClock.now(), 5)))
|
||||
.isEqualTo(Money.of(USD, 8));
|
||||
assertThat(registry.getCreateBillingCost(fakeClock.nowUtc().plusMonths(8)))
|
||||
assertThat(registry.getCreateBillingCost(plusMonths(fakeClock.now(), 8)))
|
||||
.isEqualTo(Money.of(USD, 3));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSetCreateBillingCostTransitionsNegativeCost() throws Exception {
|
||||
ImmutableSortedMap<DateTime, Money> createCostTransitions =
|
||||
ImmutableSortedMap<Instant, Money> createCostTransitions =
|
||||
ImmutableSortedMap.of(
|
||||
START_OF_TIME,
|
||||
START_INSTANT,
|
||||
Money.of(USD, 8),
|
||||
fakeClock.nowUtc(),
|
||||
fakeClock.now(),
|
||||
Money.of(USD, 1),
|
||||
fakeClock.nowUtc().plusMonths(1),
|
||||
plusMonths(fakeClock.now(), 1),
|
||||
Money.of(USD, -2),
|
||||
fakeClock.nowUtc().plusMonths(2),
|
||||
plusMonths(fakeClock.now(), 2),
|
||||
Money.of(USD, 3));
|
||||
IllegalArgumentException thrown =
|
||||
assertThrows(
|
||||
@@ -261,7 +265,7 @@ public final class TldTest extends EntityTestCase {
|
||||
void testSettingRestoreBillingCost() {
|
||||
Tld registry = Tld.get("tld").asBuilder().setRestoreBillingCost(Money.of(USD, 42)).build();
|
||||
// The default value of 13 is set in createTld().
|
||||
assertThat(registry.getCreateBillingCost(fakeClock.nowUtc())).isEqualTo(Money.of(USD, 13));
|
||||
assertThat(registry.getCreateBillingCost(fakeClock.now())).isEqualTo(Money.of(USD, 13));
|
||||
assertThat(registry.getRestoreBillingCost()).isEqualTo(Money.of(USD, 42));
|
||||
}
|
||||
|
||||
@@ -418,9 +422,9 @@ public final class TldTest extends EntityTestCase {
|
||||
Tld registry =
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setTldStateTransitions(ImmutableSortedMap.of(START_OF_TIME, TldState.PDT))
|
||||
.setTldStateTransitions(ImmutableSortedMap.of(START_INSTANT, TldState.PDT))
|
||||
.build();
|
||||
assertThat(registry.getTldState(START_OF_TIME)).isEqualTo(GENERAL_AVAILABILITY);
|
||||
assertThat(registry.getTldState(START_INSTANT)).isEqualTo(GENERAL_AVAILABILITY);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -429,33 +433,32 @@ public final class TldTest extends EntityTestCase {
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setTldStateTransitions(
|
||||
ImmutableSortedMap.<DateTime, TldState>naturalOrder()
|
||||
.put(START_OF_TIME, PREDELEGATION)
|
||||
.put(fakeClock.nowUtc().plusMonths(1), START_DATE_SUNRISE)
|
||||
.put(fakeClock.nowUtc().plusMonths(2), QUIET_PERIOD)
|
||||
.put(fakeClock.nowUtc().plusMonths(3), GENERAL_AVAILABILITY)
|
||||
ImmutableSortedMap.<Instant, TldState>naturalOrder()
|
||||
.put(START_INSTANT, PREDELEGATION)
|
||||
.put(plusMonths(fakeClock.now(), 1), START_DATE_SUNRISE)
|
||||
.put(plusMonths(fakeClock.now(), 2), QUIET_PERIOD)
|
||||
.put(plusMonths(fakeClock.now(), 3), GENERAL_AVAILABILITY)
|
||||
.build())
|
||||
.build();
|
||||
assertThat(registry.getTldState(fakeClock.nowUtc())).isEqualTo(PREDELEGATION);
|
||||
assertThat(registry.getTldState(fakeClock.nowUtc().plusMillis(1))).isEqualTo(PREDELEGATION);
|
||||
assertThat(registry.getTldState(fakeClock.nowUtc().plusMonths(1).minusMillis(1)))
|
||||
assertThat(registry.getTldState(fakeClock.now())).isEqualTo(PREDELEGATION);
|
||||
assertThat(registry.getTldState(fakeClock.now().plusMillis(1))).isEqualTo(PREDELEGATION);
|
||||
assertThat(registry.getTldState(plusMonths(fakeClock.now(), 1).minusMillis(1)))
|
||||
.isEqualTo(PREDELEGATION);
|
||||
assertThat(registry.getTldState(fakeClock.nowUtc().plusMonths(1)))
|
||||
assertThat(registry.getTldState(plusMonths(fakeClock.now(), 1))).isEqualTo(START_DATE_SUNRISE);
|
||||
assertThat(registry.getTldState(plusMonths(fakeClock.now(), 1).plusMillis(1)))
|
||||
.isEqualTo(START_DATE_SUNRISE);
|
||||
assertThat(registry.getTldState(fakeClock.nowUtc().plusMonths(1).plusMillis(1)))
|
||||
assertThat(registry.getTldState(plusMonths(fakeClock.now(), 2).minusMillis(1)))
|
||||
.isEqualTo(START_DATE_SUNRISE);
|
||||
assertThat(registry.getTldState(fakeClock.nowUtc().plusMonths(2).minusMillis(1)))
|
||||
.isEqualTo(START_DATE_SUNRISE);
|
||||
assertThat(registry.getTldState(fakeClock.nowUtc().plusMonths(2))).isEqualTo(QUIET_PERIOD);
|
||||
assertThat(registry.getTldState(fakeClock.nowUtc().plusMonths(2).plusMillis(1)))
|
||||
assertThat(registry.getTldState(plusMonths(fakeClock.now(), 2))).isEqualTo(QUIET_PERIOD);
|
||||
assertThat(registry.getTldState(plusMonths(fakeClock.now(), 2).plusMillis(1)))
|
||||
.isEqualTo(QUIET_PERIOD);
|
||||
assertThat(registry.getTldState(fakeClock.nowUtc().plusMonths(3).minusMillis(1)))
|
||||
assertThat(registry.getTldState(plusMonths(fakeClock.now(), 3).minusMillis(1)))
|
||||
.isEqualTo(QUIET_PERIOD);
|
||||
assertThat(registry.getTldState(fakeClock.nowUtc().plusMonths(3)))
|
||||
assertThat(registry.getTldState(plusMonths(fakeClock.now(), 3)))
|
||||
.isEqualTo(GENERAL_AVAILABILITY);
|
||||
assertThat(registry.getTldState(fakeClock.nowUtc().plusMonths(3).plusMillis(1)))
|
||||
assertThat(registry.getTldState(plusMonths(fakeClock.now(), 3).plusMillis(1)))
|
||||
.isEqualTo(GENERAL_AVAILABILITY);
|
||||
assertThat(registry.getTldState(END_OF_TIME)).isEqualTo(GENERAL_AVAILABILITY);
|
||||
assertThat(registry.getTldState(END_INSTANT)).isEqualTo(GENERAL_AVAILABILITY);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -463,12 +466,12 @@ public final class TldTest extends EntityTestCase {
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setTldStateTransitions(
|
||||
ImmutableSortedMap.<DateTime, TldState>naturalOrder()
|
||||
.put(START_OF_TIME, PREDELEGATION)
|
||||
.put(fakeClock.nowUtc().plusMonths(1), QUIET_PERIOD)
|
||||
.put(fakeClock.nowUtc().plusMonths(2), START_DATE_SUNRISE)
|
||||
.put(fakeClock.nowUtc().plusMonths(3), QUIET_PERIOD)
|
||||
.put(fakeClock.nowUtc().plusMonths(6), GENERAL_AVAILABILITY)
|
||||
ImmutableSortedMap.<Instant, TldState>naturalOrder()
|
||||
.put(START_INSTANT, PREDELEGATION)
|
||||
.put(plusMonths(fakeClock.now(), 1), QUIET_PERIOD)
|
||||
.put(plusMonths(fakeClock.now(), 2), START_DATE_SUNRISE)
|
||||
.put(plusMonths(fakeClock.now(), 3), QUIET_PERIOD)
|
||||
.put(plusMonths(fakeClock.now(), 6), GENERAL_AVAILABILITY)
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
@@ -480,49 +483,49 @@ public final class TldTest extends EntityTestCase {
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
START_OF_TIME,
|
||||
START_INSTANT,
|
||||
Money.of(USD, 8),
|
||||
fakeClock.nowUtc(),
|
||||
fakeClock.now(),
|
||||
Money.of(USD, 1),
|
||||
fakeClock.nowUtc().plusMonths(1),
|
||||
plusMonths(fakeClock.now(), 1),
|
||||
Money.of(USD, 2),
|
||||
fakeClock.nowUtc().plusMonths(2),
|
||||
plusMonths(fakeClock.now(), 2),
|
||||
Money.of(USD, 3)))
|
||||
.build();
|
||||
assertThat(registry.getStandardRenewCost(START_OF_TIME)).isEqualTo(Money.of(USD, 8));
|
||||
assertThat(registry.getStandardRenewCost(fakeClock.nowUtc().minusMillis(1)))
|
||||
assertThat(registry.getStandardRenewCost(START_INSTANT)).isEqualTo(Money.of(USD, 8));
|
||||
assertThat(registry.getStandardRenewCost(fakeClock.now().minusMillis(1)))
|
||||
.isEqualTo(Money.of(USD, 8));
|
||||
assertThat(registry.getStandardRenewCost(fakeClock.nowUtc())).isEqualTo(Money.of(USD, 1));
|
||||
assertThat(registry.getStandardRenewCost(fakeClock.nowUtc().plusMillis(1)))
|
||||
assertThat(registry.getStandardRenewCost(fakeClock.now())).isEqualTo(Money.of(USD, 1));
|
||||
assertThat(registry.getStandardRenewCost(fakeClock.now().plusMillis(1)))
|
||||
.isEqualTo(Money.of(USD, 1));
|
||||
assertThat(registry.getStandardRenewCost(fakeClock.nowUtc().plusMonths(1).minusMillis(1)))
|
||||
assertThat(registry.getStandardRenewCost(plusMonths(fakeClock.now(), 1).minusMillis(1)))
|
||||
.isEqualTo(Money.of(USD, 1));
|
||||
assertThat(registry.getStandardRenewCost(fakeClock.nowUtc().plusMonths(1)))
|
||||
assertThat(registry.getStandardRenewCost(plusMonths(fakeClock.now(), 1)))
|
||||
.isEqualTo(Money.of(USD, 2));
|
||||
assertThat(registry.getStandardRenewCost(fakeClock.nowUtc().plusMonths(1).plusMillis(1)))
|
||||
assertThat(registry.getStandardRenewCost(plusMonths(fakeClock.now(), 1).plusMillis(1)))
|
||||
.isEqualTo(Money.of(USD, 2));
|
||||
assertThat(registry.getStandardRenewCost(fakeClock.nowUtc().plusMonths(2).minusMillis(1)))
|
||||
assertThat(registry.getStandardRenewCost(plusMonths(fakeClock.now(), 2).minusMillis(1)))
|
||||
.isEqualTo(Money.of(USD, 2));
|
||||
assertThat(registry.getStandardRenewCost(fakeClock.nowUtc().plusMonths(2)))
|
||||
assertThat(registry.getStandardRenewCost(plusMonths(fakeClock.now(), 2)))
|
||||
.isEqualTo(Money.of(USD, 3));
|
||||
assertThat(registry.getStandardRenewCost(fakeClock.nowUtc().plusMonths(2).plusMillis(1)))
|
||||
assertThat(registry.getStandardRenewCost(plusMonths(fakeClock.now(), 2).plusMillis(1)))
|
||||
.isEqualTo(Money.of(USD, 3));
|
||||
assertThat(registry.getStandardRenewCost(fakeClock.nowUtc().plusMonths(3).minusMillis(1)))
|
||||
assertThat(registry.getStandardRenewCost(plusMonths(fakeClock.now(), 3).minusMillis(1)))
|
||||
.isEqualTo(Money.of(USD, 3));
|
||||
assertThat(registry.getStandardRenewCost(END_OF_TIME)).isEqualTo(Money.of(USD, 3));
|
||||
assertThat(registry.getStandardRenewCost(END_INSTANT)).isEqualTo(Money.of(USD, 3));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRenewBillingCostNoTransitions() {
|
||||
Tld registry = Tld.get("tld");
|
||||
// The default value of 11 is set in createTld().
|
||||
assertThat(registry.getStandardRenewCost(START_OF_TIME)).isEqualTo(Money.of(USD, 11));
|
||||
assertThat(registry.getStandardRenewCost(fakeClock.nowUtc().minusMillis(1)))
|
||||
assertThat(registry.getStandardRenewCost(START_INSTANT)).isEqualTo(Money.of(USD, 11));
|
||||
assertThat(registry.getStandardRenewCost(fakeClock.now().minusMillis(1)))
|
||||
.isEqualTo(Money.of(USD, 11));
|
||||
assertThat(registry.getStandardRenewCost(fakeClock.nowUtc())).isEqualTo(Money.of(USD, 11));
|
||||
assertThat(registry.getStandardRenewCost(fakeClock.nowUtc().plusMillis(1)))
|
||||
assertThat(registry.getStandardRenewCost(fakeClock.now())).isEqualTo(Money.of(USD, 11));
|
||||
assertThat(registry.getStandardRenewCost(fakeClock.now().plusMillis(1)))
|
||||
.isEqualTo(Money.of(USD, 11));
|
||||
assertThat(registry.getStandardRenewCost(END_OF_TIME)).isEqualTo(Money.of(USD, 11));
|
||||
assertThat(registry.getStandardRenewCost(END_INSTANT)).isEqualTo(Money.of(USD, 11));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -568,8 +571,8 @@ public final class TldTest extends EntityTestCase {
|
||||
.asBuilder()
|
||||
.setTldStateTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
fakeClock.nowUtc(), GENERAL_AVAILABILITY,
|
||||
fakeClock.nowUtc().plusMonths(1), START_DATE_SUNRISE))
|
||||
fakeClock.now(), GENERAL_AVAILABILITY,
|
||||
plusMonths(fakeClock.now(), 1), START_DATE_SUNRISE))
|
||||
.build());
|
||||
}
|
||||
|
||||
@@ -582,8 +585,8 @@ public final class TldTest extends EntityTestCase {
|
||||
.asBuilder()
|
||||
.setTldStateTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
fakeClock.nowUtc(), START_DATE_SUNRISE,
|
||||
fakeClock.nowUtc().plusMonths(1), START_DATE_SUNRISE))
|
||||
fakeClock.now(), START_DATE_SUNRISE,
|
||||
plusMonths(fakeClock.now(), 1), START_DATE_SUNRISE))
|
||||
.build());
|
||||
}
|
||||
|
||||
@@ -595,7 +598,7 @@ public final class TldTest extends EntityTestCase {
|
||||
() ->
|
||||
new Tld.Builder()
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 13)))
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 13)))
|
||||
.setTldStr("invalid")
|
||||
.build());
|
||||
assertThat(thrown)
|
||||
@@ -612,7 +615,7 @@ public final class TldTest extends EntityTestCase {
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, -42))));
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, -42))));
|
||||
assertThat(thrown).hasMessageThat().contains("billing cost cannot be negative");
|
||||
}
|
||||
|
||||
@@ -663,7 +666,7 @@ public final class TldTest extends EntityTestCase {
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 42)))
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(EUR, 42)))
|
||||
.build());
|
||||
assertThat(thrown).hasMessageThat().contains("cost must be in the TLD's currency");
|
||||
}
|
||||
@@ -677,7 +680,7 @@ public final class TldTest extends EntityTestCase {
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 42)))
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(EUR, 42)))
|
||||
.build());
|
||||
assertThat(thrown).hasMessageThat().contains("cost must be in the TLD's currency");
|
||||
}
|
||||
@@ -706,29 +709,27 @@ public final class TldTest extends EntityTestCase {
|
||||
|
||||
@Test
|
||||
void testEapFee_undefined() {
|
||||
assertThat(Tld.get("tld").getEapFeeFor(fakeClock.nowUtc()).getCost())
|
||||
assertThat(Tld.get("tld").getEapFeeFor(fakeClock.now()).getCost())
|
||||
.isEqualTo(BigDecimal.ZERO.setScale(2, UNNECESSARY));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEapFee_specified() {
|
||||
DateTime a = fakeClock.nowUtc().minusDays(1);
|
||||
DateTime b = fakeClock.nowUtc().plusDays(1);
|
||||
Instant a = minusDays(fakeClock.now(), 1);
|
||||
Instant b = plusDays(fakeClock.now(), 1);
|
||||
Tld registry =
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setEapFeeSchedule(
|
||||
ImmutableSortedMap.of(
|
||||
START_OF_TIME, Money.of(USD, 0),
|
||||
a, Money.of(USD, 100),
|
||||
b, Money.of(USD, 50)))
|
||||
START_INSTANT, Money.of(USD, 0), a, Money.of(USD, 100), b, Money.of(USD, 50)))
|
||||
.build();
|
||||
|
||||
assertThat(registry.getEapFeeFor(fakeClock.nowUtc()).getCost())
|
||||
assertThat(registry.getEapFeeFor(fakeClock.now()).getCost())
|
||||
.isEqualTo(new BigDecimal("100.00"));
|
||||
assertThat(registry.getEapFeeFor(fakeClock.nowUtc().minusDays(2)).getCost())
|
||||
assertThat(registry.getEapFeeFor(minusDays(fakeClock.now(), 2)).getCost())
|
||||
.isEqualTo(BigDecimal.ZERO.setScale(2, UNNECESSARY));
|
||||
assertThat(registry.getEapFeeFor(fakeClock.nowUtc().plusDays(2)).getCost())
|
||||
assertThat(registry.getEapFeeFor(plusDays(fakeClock.now(), 2)).getCost())
|
||||
.isEqualTo(new BigDecimal("50.00"));
|
||||
}
|
||||
|
||||
@@ -740,7 +741,7 @@ public final class TldTest extends EntityTestCase {
|
||||
() ->
|
||||
Tld.get("tld")
|
||||
.asBuilder()
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_INSTANT, Money.zero(EUR)))
|
||||
.build());
|
||||
assertThat(thrown).hasMessageThat().contains("All EAP fees must be in the TLD's currency");
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class PricingEngineProxyTest {
|
||||
persistResource(
|
||||
Tld.get("example")
|
||||
.asBuilder()
|
||||
.setRenewBillingCostTransitionsInstant(
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(
|
||||
START_INSTANT, Money.of(USD, 8), clock.now(), Money.of(USD, 10)))
|
||||
.build());
|
||||
|
||||
@@ -39,7 +39,6 @@ import static google.registry.util.CollectionUtils.union;
|
||||
import static google.registry.util.DateTimeUtils.END_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.toDateTime;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
import static google.registry.util.DomainNameUtils.ACE_PREFIX_REGEX;
|
||||
@@ -185,18 +184,18 @@ public final class DatabaseHelper {
|
||||
}
|
||||
|
||||
public static Tld newTld(String tld, String roidSuffix) {
|
||||
return newTld(tld, roidSuffix, ImmutableSortedMap.of(START_OF_TIME, GENERAL_AVAILABILITY));
|
||||
return newTld(tld, roidSuffix, ImmutableSortedMap.of(START_INSTANT, GENERAL_AVAILABILITY));
|
||||
}
|
||||
|
||||
public static Tld newTld(
|
||||
String tld, String roidSuffix, ImmutableSortedMap<DateTime, TldState> tldStates) {
|
||||
String tld, String roidSuffix, ImmutableSortedMap<Instant, TldState> tldStates) {
|
||||
return setupTld(new Tld.Builder(), tld, roidSuffix, tldStates);
|
||||
}
|
||||
|
||||
public static Tld newTld(
|
||||
String tld,
|
||||
String roidSuffix,
|
||||
ImmutableSortedMap<DateTime, TldState> tldStates,
|
||||
ImmutableSortedMap<Instant, TldState> tldStates,
|
||||
TldType tldType) {
|
||||
return setupTld(new Tld.Builder().setTldType(tldType), tld, roidSuffix, tldStates);
|
||||
}
|
||||
@@ -205,15 +204,15 @@ public final class DatabaseHelper {
|
||||
Tld.Builder tldBuilder,
|
||||
String tld,
|
||||
String roidSuffix,
|
||||
ImmutableSortedMap<DateTime, TldState> tldStates) {
|
||||
ImmutableSortedMap<Instant, TldState> tldStates) {
|
||||
return tldBuilder
|
||||
.setTldStr(tld)
|
||||
.setRoidSuffix(roidSuffix)
|
||||
.setTldStateTransitions(tldStates)
|
||||
// Set billing costs to distinct small primes to avoid masking bugs in tests.
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 11)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(USD)))
|
||||
.setCreateBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 13)))
|
||||
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 11)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_INSTANT, Money.zero(USD)))
|
||||
.setCreateBillingCostTransitions(ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 13)))
|
||||
.setRestoreBillingCost(Money.of(USD, 17))
|
||||
.setServerStatusChangeBillingCost(Money.of(USD, 19))
|
||||
// Always set a default premium list. Tests that don't want it can delete it.
|
||||
@@ -366,7 +365,7 @@ public final class DatabaseHelper {
|
||||
}
|
||||
|
||||
public static Tld createTld(String tld, String roidSuffix) {
|
||||
return createTld(tld, roidSuffix, ImmutableSortedMap.of(START_OF_TIME, GENERAL_AVAILABILITY));
|
||||
return createTld(tld, roidSuffix, ImmutableSortedMap.of(START_INSTANT, GENERAL_AVAILABILITY));
|
||||
}
|
||||
|
||||
/** Creates and persists the given TLDs. */
|
||||
@@ -377,10 +376,10 @@ public final class DatabaseHelper {
|
||||
}
|
||||
|
||||
public static Tld createTld(String tld, TldState tldState) {
|
||||
return createTld(tld, ImmutableSortedMap.of(START_OF_TIME, tldState));
|
||||
return createTld(tld, ImmutableSortedMap.of(START_INSTANT, tldState));
|
||||
}
|
||||
|
||||
public static Tld createTld(String tld, ImmutableSortedMap<DateTime, TldState> tldStates) {
|
||||
public static Tld createTld(String tld, ImmutableSortedMap<Instant, TldState> tldStates) {
|
||||
// Coerce the TLD string into a valid ROID suffix.
|
||||
String roidSuffix =
|
||||
Ascii.toUpperCase(tld.replaceFirst(ACE_PREFIX_REGEX, "").replace(".", "")).replace("-", "");
|
||||
@@ -389,7 +388,7 @@ public final class DatabaseHelper {
|
||||
}
|
||||
|
||||
public static Tld createTld(
|
||||
String tld, String roidSuffix, ImmutableSortedMap<DateTime, TldState> tldStates) {
|
||||
String tld, String roidSuffix, ImmutableSortedMap<Instant, TldState> tldStates) {
|
||||
Tld registry = persistResource(newTld(tld, roidSuffix, tldStates));
|
||||
allowRegistrarAccess("TheRegistrar", tld);
|
||||
allowRegistrarAccess("NewRegistrar", tld);
|
||||
|
||||
@@ -24,12 +24,11 @@ import static google.registry.testing.TestDataHelper.loadFile;
|
||||
import static google.registry.tldconfig.idn.IdnTableEnum.EXTENDED_LATIN;
|
||||
import static google.registry.tldconfig.idn.IdnTableEnum.JA;
|
||||
import static google.registry.tldconfig.idn.IdnTableEnum.UNCONFUSABLE_LATIN;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static org.joda.money.CurrencyUnit.JPY;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
@@ -89,7 +88,7 @@ public class ConfigureTldCommandTest extends CommandTestCase<ConfigureTldCommand
|
||||
Tld tld = Tld.get("tld");
|
||||
assertThat(tld).isNotNull();
|
||||
assertThat(tld.getDriveFolderId()).isEqualTo("driveFolder");
|
||||
assertThat(tld.getCreateBillingCost(fakeClock.nowUtc())).isEqualTo(Money.of(USD, 25));
|
||||
assertThat(tld.getCreateBillingCost(fakeClock.now())).isEqualTo(Money.of(USD, 25));
|
||||
testTldConfiguredSuccessfully(tld, "tld.yaml");
|
||||
assertThat(tld.getBreakglassMode()).isFalse();
|
||||
}
|
||||
@@ -101,21 +100,21 @@ public class ConfigureTldCommandTest extends CommandTestCase<ConfigureTldCommand
|
||||
runCommandForced("--input=" + tldFile);
|
||||
Tld tld = Tld.get("jpy");
|
||||
assertThat(tld).isNotNull();
|
||||
assertThat(tld.getCreateBillingCost(fakeClock.nowUtc()))
|
||||
assertThat(tld.getCreateBillingCost(fakeClock.now()))
|
||||
.isEqualTo(Money.of(JPY, new BigDecimal("250")));
|
||||
assertThat(tld.getEapFeeFor(DateTime.now(UTC)).getCost()).isEqualTo(new BigDecimal(0));
|
||||
assertThat(tld.getEapFeeFor(fakeClock.now()).getCost()).isEqualTo(new BigDecimal(0));
|
||||
testTldConfiguredSuccessfully(tld, "jpy.yaml");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_updateTld() throws Exception {
|
||||
Tld tld = createTld("tld");
|
||||
assertThat(tld.getCreateBillingCost(fakeClock.nowUtc())).isEqualTo(Money.of(USD, 13));
|
||||
assertThat(tld.getCreateBillingCost(fakeClock.now())).isEqualTo(Money.of(USD, 13));
|
||||
File tldFile = tmpDir.resolve("tld.yaml").toFile();
|
||||
Files.asCharSink(tldFile, UTF_8).write(loadFile(getClass(), "tld.yaml"));
|
||||
runCommandForced("--input=" + tldFile);
|
||||
Tld updatedTld = Tld.get("tld");
|
||||
assertThat(updatedTld.getCreateBillingCost(fakeClock.nowUtc())).isEqualTo(Money.of(USD, 25));
|
||||
assertThat(updatedTld.getCreateBillingCost(fakeClock.now())).isEqualTo(Money.of(USD, 25));
|
||||
testTldConfiguredSuccessfully(updatedTld, "tld.yaml");
|
||||
assertThat(updatedTld.getBreakglassMode()).isFalse();
|
||||
assertThat(tld.getBsaEnrollStartTime()).isEmpty();
|
||||
@@ -124,7 +123,7 @@ public class ConfigureTldCommandTest extends CommandTestCase<ConfigureTldCommand
|
||||
@Test
|
||||
void testSuccess_updateTld_existingBsaTimeCarriedOver() throws Exception {
|
||||
Tld tld = createTld("tld");
|
||||
DateTime bsaStartTime = DateTime.now(UTC);
|
||||
DateTime bsaStartTime = fakeClock.nowUtc();
|
||||
persistResource(tld.asBuilder().setBsaEnrollStartTime(Optional.of(bsaStartTime)).build());
|
||||
File tldFile = tmpDir.resolve("tld.yaml").toFile();
|
||||
Files.asCharSink(tldFile, UTF_8).write(loadFile(getClass(), "tld.yaml"));
|
||||
@@ -159,21 +158,21 @@ public class ConfigureTldCommandTest extends CommandTestCase<ConfigureTldCommand
|
||||
// TLD's YAML will contain the fields in the correct order
|
||||
assertThat(tld).isNotNull();
|
||||
assertThat(tld.getDriveFolderId()).isEqualTo("driveFolder");
|
||||
assertThat(tld.getCreateBillingCost(fakeClock.nowUtc())).isEqualTo(Money.of(USD, 25));
|
||||
assertThat(tld.getCreateBillingCost(fakeClock.now())).isEqualTo(Money.of(USD, 25));
|
||||
assertThat(tld.getPremiumListName().get()).isEqualTo("test");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_outOfOrderFieldsOnUpdate() throws Exception {
|
||||
Tld tld = createTld("outoforderfields");
|
||||
assertThat(tld.getCreateBillingCost(fakeClock.nowUtc())).isEqualTo(Money.of(USD, 13));
|
||||
assertThat(tld.getCreateBillingCost(fakeClock.now())).isEqualTo(Money.of(USD, 13));
|
||||
File tldFile = tmpDir.resolve("outoforderfields.yaml").toFile();
|
||||
Files.asCharSink(tldFile, UTF_8).write(loadFile(getClass(), "outoforderfields.yaml"));
|
||||
runCommandForced("--input=" + tldFile);
|
||||
Tld updatedTld = Tld.get("outoforderfields");
|
||||
// Cannot test that created TLD converted to YAML is equal to original YAML since the created
|
||||
// TLD's YAML will contain the fields in the correct order
|
||||
assertThat(updatedTld.getCreateBillingCost(fakeClock.nowUtc())).isEqualTo(Money.of(USD, 25));
|
||||
assertThat(updatedTld.getCreateBillingCost(fakeClock.now())).isEqualTo(Money.of(USD, 25));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -214,7 +213,7 @@ public class ConfigureTldCommandTest extends CommandTestCase<ConfigureTldCommand
|
||||
Tld tld = Tld.get("nullablefieldsallnull");
|
||||
assertThat(tld).isNotNull();
|
||||
assertThat(tld.getDriveFolderId()).isEqualTo(null);
|
||||
assertThat(tld.getCreateBillingCost(fakeClock.nowUtc())).isEqualTo(Money.of(USD, 25));
|
||||
assertThat(tld.getCreateBillingCost(fakeClock.now())).isEqualTo(Money.of(USD, 25));
|
||||
// cannot test that created TLD converted to YAML is equal to original YAML since the created
|
||||
// TLD's YAML will contain empty sets for some of the null fields
|
||||
assertThat(tld.getIdnTables()).isEmpty();
|
||||
@@ -232,7 +231,7 @@ public class ConfigureTldCommandTest extends CommandTestCase<ConfigureTldCommand
|
||||
Tld updatedTld = Tld.get("nullablefieldsallnull");
|
||||
assertThat(updatedTld).isNotNull();
|
||||
assertThat(updatedTld.getDriveFolderId()).isEqualTo(null);
|
||||
assertThat(updatedTld.getCreateBillingCost(fakeClock.nowUtc())).isEqualTo(Money.of(USD, 25));
|
||||
assertThat(updatedTld.getCreateBillingCost(fakeClock.now())).isEqualTo(Money.of(USD, 25));
|
||||
// cannot test that created TLD converted to YAML is equal to original YAML since the created
|
||||
// TLD's YAML will contain empty sets for some of the null fields
|
||||
assertThat(updatedTld.getIdnTables()).isEmpty();
|
||||
@@ -305,7 +304,7 @@ public class ConfigureTldCommandTest extends CommandTestCase<ConfigureTldCommand
|
||||
Tld tld = Tld.get(name);
|
||||
assertThat(tld).isNotNull();
|
||||
assertThat(tld.getDriveFolderId()).isEqualTo("driveFolder");
|
||||
assertThat(tld.getCreateBillingCost(fakeClock.nowUtc())).isEqualTo(Money.of(USD, 25));
|
||||
assertThat(tld.getCreateBillingCost(fakeClock.now())).isEqualTo(Money.of(USD, 25));
|
||||
String yaml = objectMapper.writeValueAsString(tld);
|
||||
assertThat(yaml).isEqualTo(fileContents);
|
||||
}
|
||||
@@ -516,7 +515,7 @@ public class ConfigureTldCommandTest extends CommandTestCase<ConfigureTldCommand
|
||||
.setIdnTables(ImmutableSet.of(JA, UNCONFUSABLE_LATIN, EXTENDED_LATIN))
|
||||
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("zeta", "alpha", "gamma", "beta"))
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 13)))
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 13)))
|
||||
.build());
|
||||
File tldFile = tmpDir.resolve("idns.yaml").toFile();
|
||||
Files.asCharSink(tldFile, UTF_8).write(loadFile(getClass(), "idns.yaml"));
|
||||
@@ -532,12 +531,12 @@ public class ConfigureTldCommandTest extends CommandTestCase<ConfigureTldCommand
|
||||
@Test
|
||||
void testSuccess_breakGlassFlag_startsBreakGlassMode() throws Exception {
|
||||
Tld tld = createTld("tld");
|
||||
assertThat(tld.getCreateBillingCost(fakeClock.nowUtc())).isEqualTo(Money.of(USD, 13));
|
||||
assertThat(tld.getCreateBillingCost(fakeClock.now())).isEqualTo(Money.of(USD, 13));
|
||||
File tldFile = tmpDir.resolve("tld.yaml").toFile();
|
||||
Files.asCharSink(tldFile, UTF_8).write(loadFile(getClass(), "tld.yaml"));
|
||||
runCommandForced("--input=" + tldFile, "--break_glass=true");
|
||||
Tld updatedTld = Tld.get("tld");
|
||||
assertThat(updatedTld.getCreateBillingCost(fakeClock.nowUtc())).isEqualTo(Money.of(USD, 25));
|
||||
assertThat(updatedTld.getCreateBillingCost(fakeClock.now())).isEqualTo(Money.of(USD, 25));
|
||||
testTldConfiguredSuccessfully(updatedTld, "tld.yaml");
|
||||
assertThat(updatedTld.getBreakglassMode()).isTrue();
|
||||
}
|
||||
@@ -545,13 +544,13 @@ public class ConfigureTldCommandTest extends CommandTestCase<ConfigureTldCommand
|
||||
@Test
|
||||
void testSuccess_breakGlassFlag_continuesBreakGlassMode() throws Exception {
|
||||
Tld tld = createTld("tld");
|
||||
assertThat(tld.getCreateBillingCost(fakeClock.nowUtc())).isEqualTo(Money.of(USD, 13));
|
||||
assertThat(tld.getCreateBillingCost(fakeClock.now())).isEqualTo(Money.of(USD, 13));
|
||||
persistResource(tld.asBuilder().setBreakglassMode(true).build());
|
||||
File tldFile = tmpDir.resolve("tld.yaml").toFile();
|
||||
Files.asCharSink(tldFile, UTF_8).write(loadFile(getClass(), "tld.yaml"));
|
||||
runCommandForced("--input=" + tldFile, "--break_glass=true");
|
||||
Tld updatedTld = Tld.get("tld");
|
||||
assertThat(updatedTld.getCreateBillingCost(fakeClock.nowUtc())).isEqualTo(Money.of(USD, 25));
|
||||
assertThat(updatedTld.getCreateBillingCost(fakeClock.now())).isEqualTo(Money.of(USD, 25));
|
||||
testTldConfiguredSuccessfully(updatedTld, "tld.yaml");
|
||||
assertThat(updatedTld.getBreakglassMode()).isTrue();
|
||||
}
|
||||
@@ -564,7 +563,7 @@ public class ConfigureTldCommandTest extends CommandTestCase<ConfigureTldCommand
|
||||
.setIdnTables(ImmutableSet.of(JA, UNCONFUSABLE_LATIN, EXTENDED_LATIN))
|
||||
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("zeta", "alpha", "gamma", "beta"))
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 13)))
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 13)))
|
||||
.setBreakglassMode(true)
|
||||
.build());
|
||||
File tldFile = tmpDir.resolve("idns.yaml").toFile();
|
||||
@@ -585,7 +584,7 @@ public class ConfigureTldCommandTest extends CommandTestCase<ConfigureTldCommand
|
||||
.setIdnTables(ImmutableSet.of(JA, UNCONFUSABLE_LATIN, EXTENDED_LATIN))
|
||||
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("zeta", "alpha", "gamma", "beta"))
|
||||
.setCreateBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 13)))
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(USD, 13)))
|
||||
.setBreakglassMode(true)
|
||||
.build());
|
||||
File tldFile = tmpDir.resolve("idns.yaml").toFile();
|
||||
@@ -630,13 +629,13 @@ public class ConfigureTldCommandTest extends CommandTestCase<ConfigureTldCommand
|
||||
@Test
|
||||
void testSuccess_breakGlassFlagFalse_endsBreakGlassMode() throws Exception {
|
||||
Tld tld = createTld("tld");
|
||||
assertThat(tld.getCreateBillingCost(fakeClock.nowUtc())).isEqualTo(Money.of(USD, 13));
|
||||
assertThat(tld.getCreateBillingCost(fakeClock.now())).isEqualTo(Money.of(USD, 13));
|
||||
persistResource(tld.asBuilder().setBreakglassMode(true).build());
|
||||
File tldFile = tmpDir.resolve("tld.yaml").toFile();
|
||||
Files.asCharSink(tldFile, UTF_8).write(loadFile(getClass(), "tld.yaml"));
|
||||
runCommandForced("--break_glass=false", "--input=" + tldFile);
|
||||
Tld updatedTld = Tld.get("tld");
|
||||
assertThat(updatedTld.getCreateBillingCost(fakeClock.nowUtc())).isEqualTo(Money.of(USD, 25));
|
||||
assertThat(updatedTld.getCreateBillingCost(fakeClock.now())).isEqualTo(Money.of(USD, 25));
|
||||
testTldConfiguredSuccessfully(updatedTld, "tld.yaml");
|
||||
assertThat(updatedTld.getBreakglassMode()).isFalse();
|
||||
}
|
||||
@@ -673,12 +672,12 @@ public class ConfigureTldCommandTest extends CommandTestCase<ConfigureTldCommand
|
||||
@Test
|
||||
void testSuccess_dryRunOnUpdate_noChanges() throws Exception {
|
||||
Tld tld = createTld("tld");
|
||||
assertThat(tld.getCreateBillingCost(fakeClock.nowUtc())).isEqualTo(Money.of(USD, 13));
|
||||
assertThat(tld.getCreateBillingCost(fakeClock.now())).isEqualTo(Money.of(USD, 13));
|
||||
File tldFile = tmpDir.resolve("tld.yaml").toFile();
|
||||
Files.asCharSink(tldFile, UTF_8).write(loadFile(getClass(), "tld.yaml"));
|
||||
runCommandForced("--input=" + tldFile, "-d");
|
||||
Tld notUpdatedTld = Tld.get("tld");
|
||||
assertThat(notUpdatedTld.getCreateBillingCost(fakeClock.nowUtc())).isEqualTo(Money.of(USD, 13));
|
||||
assertThat(notUpdatedTld.getCreateBillingCost(fakeClock.now())).isEqualTo(Money.of(USD, 13));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -705,7 +704,7 @@ public class ConfigureTldCommandTest extends CommandTestCase<ConfigureTldCommand
|
||||
runCommandInEnvironment(
|
||||
RegistryToolEnvironment.PRODUCTION, "--input=" + tldFile, "--break_glass=true", "-f");
|
||||
Tld updatedTld = Tld.get("tld");
|
||||
assertThat(updatedTld.getCreateBillingCost(fakeClock.nowUtc())).isEqualTo(Money.of(USD, 25));
|
||||
assertThat(updatedTld.getCreateBillingCost(fakeClock.now())).isEqualTo(Money.of(USD, 25));
|
||||
testTldConfiguredSuccessfully(updatedTld, "tld.yaml");
|
||||
assertThat(updatedTld.getBreakglassMode()).isTrue();
|
||||
}
|
||||
@@ -718,7 +717,7 @@ public class ConfigureTldCommandTest extends CommandTestCase<ConfigureTldCommand
|
||||
runCommandInEnvironment(
|
||||
RegistryToolEnvironment.PRODUCTION, "--input=" + tldFile, "--build_environment", "-f");
|
||||
Tld updatedTld = Tld.get("tld");
|
||||
assertThat(updatedTld.getCreateBillingCost(fakeClock.nowUtc())).isEqualTo(Money.of(USD, 25));
|
||||
assertThat(updatedTld.getCreateBillingCost(fakeClock.now())).isEqualTo(Money.of(USD, 25));
|
||||
testTldConfiguredSuccessfully(updatedTld, "tld.yaml");
|
||||
assertThat(updatedTld.getBreakglassMode()).isFalse();
|
||||
}
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.
|
||||
import static google.registry.testing.DatabaseHelper.newTld;
|
||||
import static google.registry.testing.DatabaseHelper.persistPremiumList;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.common.base.Ascii;
|
||||
@@ -60,7 +60,7 @@ abstract class CreateOrUpdatePremiumListCommandTestCase<T extends CreateOrUpdate
|
||||
newTld(
|
||||
tldStr,
|
||||
Ascii.toUpperCase(tldStr),
|
||||
ImmutableSortedMap.of(START_OF_TIME, GENERAL_AVAILABILITY),
|
||||
ImmutableSortedMap.of(START_INSTANT, GENERAL_AVAILABILITY),
|
||||
TldType.TEST);
|
||||
persistPremiumList(tldStr, currency, premiumListInput);
|
||||
persistResource(registry);
|
||||
|
||||
@@ -596,14 +596,14 @@ class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarCommand>
|
||||
newTld("foo", "FOO")
|
||||
.asBuilder()
|
||||
.setCurrency(JPY)
|
||||
.setCreateBillingCostTransitionsInstant(
|
||||
.setCreateBillingCostTransitions(
|
||||
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)))
|
||||
.setRenewBillingCostTransitionsInstant(
|
||||
.setRenewBillingCostTransitions(
|
||||
ImmutableSortedMap.of(START_INSTANT, Money.of(JPY, new BigDecimal(1100))))
|
||||
.setEapFeeScheduleInstant(ImmutableSortedMap.of(START_INSTANT, Money.zero(JPY)))
|
||||
.setEapFeeSchedule(ImmutableSortedMap.of(START_INSTANT, Money.zero(JPY)))
|
||||
.setPremiumList(null)
|
||||
.build());
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import static google.registry.testing.DatabaseHelper.allowRegistrarAccess;
|
||||
import static google.registry.testing.DatabaseHelper.newTld;
|
||||
import static google.registry.testing.DatabaseHelper.persistDeletedDomain;
|
||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_INSTANT;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.google.common.base.Ascii;
|
||||
@@ -43,13 +43,13 @@ class DeleteTldCommandTest extends CommandTestCase<DeleteTldCommand> {
|
||||
newTld(
|
||||
TLD_REAL,
|
||||
Ascii.toUpperCase(TLD_REAL),
|
||||
ImmutableSortedMap.of(START_OF_TIME, GENERAL_AVAILABILITY),
|
||||
ImmutableSortedMap.of(START_INSTANT, GENERAL_AVAILABILITY),
|
||||
TldType.REAL));
|
||||
persistResource(
|
||||
newTld(
|
||||
TLD_TEST,
|
||||
Ascii.toUpperCase(TLD_TEST),
|
||||
ImmutableSortedMap.of(START_OF_TIME, GENERAL_AVAILABILITY),
|
||||
ImmutableSortedMap.of(START_INSTANT, GENERAL_AVAILABILITY),
|
||||
TldType.TEST));
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user