mirror of
https://github.com/google/nomulus
synced 2026-06-01 20:46:35 +00:00
Migrate TMCH, SMD, and Fee models to java.time (#3019)
Continues the project-wide migration from Joda-Time's DateTime to java.time.Instant, focusing on Trademark Clearinghouse (TMCH), Signed Mark Data (SMD), and Fee extension models. Key updates: - TMCH & SMD: Updated SmdRevocationList and domain check/create flows to use Instant for sunrise validations and revocation checks. - Fee Extension Ecosystem: Refactored FeeCheckRequest, FeeCreateCommandExtension, and BaseFee to use Instant for effective dates and period calculations. - EPP Objects: Updated DomainInfoData, TransferResponse, and PollMessage objects to use Instant for event timestamps. - Pricing Logic: DomainPricingLogic methods now accept Instant for cost calculations. Additionally, DateTimeUtils was enhanced with Instant compatibility methods for plusMonths and minusMonths to safely handle leap years. Redundant conversions between DateTime and Instant were eliminated throughout the flows and tests. DomainFlowUtils leverages Instant natively to avoid inline casting, and test assertions now utilize Truth's Instant subjects for cleaner validation.
This commit is contained in:
@@ -23,7 +23,9 @@ import static google.registry.util.DateTimeUtils.earliestOf;
|
||||
import static google.registry.util.DateTimeUtils.isAtOrAfter;
|
||||
import static google.registry.util.DateTimeUtils.isBeforeOrAt;
|
||||
import static google.registry.util.DateTimeUtils.latestOf;
|
||||
import static google.registry.util.DateTimeUtils.minusMonths;
|
||||
import static google.registry.util.DateTimeUtils.minusYears;
|
||||
import static google.registry.util.DateTimeUtils.plusMonths;
|
||||
import static google.registry.util.DateTimeUtils.plusYears;
|
||||
import static google.registry.util.DateTimeUtils.toDateTime;
|
||||
import static google.registry.util.DateTimeUtils.toInstant;
|
||||
@@ -108,6 +110,24 @@ class DateTimeUtilsTest {
|
||||
assertThat(minusYears(startDate, 4)).isEqualTo(Instant.parse("2008-02-28T00:00:00Z"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void test_plusMonths_worksWithInstants() {
|
||||
Instant startDate = Instant.parse("2012-02-29T00:00:00Z");
|
||||
assertThat(plusMonths(startDate, 4)).isEqualTo(Instant.parse("2012-06-29T00:00:00Z"));
|
||||
|
||||
Instant startLeapYear = Instant.parse("2012-01-31T00:00:00Z");
|
||||
assertThat(plusMonths(startLeapYear, 1)).isEqualTo(Instant.parse("2012-02-29T00:00:00Z"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void test_minusMonths_worksWithInstants() {
|
||||
Instant startDate = Instant.parse("2012-06-29T00:00:00Z");
|
||||
assertThat(minusMonths(startDate, 4)).isEqualTo(Instant.parse("2012-02-29T00:00:00Z"));
|
||||
|
||||
Instant startLeapYear = Instant.parse("2012-03-31T00:00:00Z");
|
||||
assertThat(minusMonths(startLeapYear, 1)).isEqualTo(Instant.parse("2012-02-29T00:00:00Z"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_minusYears_zeroYears() {
|
||||
DateTime leapDay = DateTime.parse("2012-02-29T00:00:00Z");
|
||||
|
||||
Reference in New Issue
Block a user