From 748dd34385aa8efbc91d89839bf51c101d0ad329 Mon Sep 17 00:00:00 2001 From: mountford Date: Wed, 26 Oct 2016 14:11:30 -0700 Subject: [PATCH] Save number of years in DomainApplication Right now, DomainApplicationCreateFlow checks to make sure that the registration period is in years, but doesn't store it in the DomainApplication explicitly. Instead, when DomainAllocateFlow runs later, it goes back to the XML in the HistoryEntry to get the number of years. Corey suggests that it would be cleaner to store the number of years in the DomainApplication. This is stage one of a data migration; we store the value, but don't actually read it anywhere except in tests. If we have any outstanding domain applications, we will then need to write a scrap tool to populate the years field, after which we can start relying on the field. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=137317739 --- .../flows/domain/DomainApplicationCreateFlow.java | 1 + .../registry/model/domain/DomainApplication.java | 13 +++++++++++++ .../domain/DomainApplicationCreateFlowTest.java | 1 + javatests/google/registry/model/schema.txt | 1 + .../registry/testing/DomainApplicationSubject.java | 5 +++++ 5 files changed, 21 insertions(+) diff --git a/java/google/registry/flows/domain/DomainApplicationCreateFlow.java b/java/google/registry/flows/domain/DomainApplicationCreateFlow.java index 783f9af99..b683e8c88 100644 --- a/java/google/registry/flows/domain/DomainApplicationCreateFlow.java +++ b/java/google/registry/flows/domain/DomainApplicationCreateFlow.java @@ -218,6 +218,7 @@ public final class DomainApplicationCreateFlow extends LoggedInFlow implements T .setLaunchNotice(launchCreate == null ? null : launchCreate.getNotice()) .setIdnTableName(idnTableName) .setPhase(launchCreate.getPhase()) + .setYears(command.getPeriod().getValue()) .setApplicationStatus(ApplicationStatus.VALIDATED) .addStatusValue(StatusValue.PENDING_CREATE) .setDsData(secDnsCreate == null ? null : secDnsCreate.getDsData()) diff --git a/java/google/registry/model/domain/DomainApplication.java b/java/google/registry/model/domain/DomainApplication.java index c5ad80760..1ffb7041d 100644 --- a/java/google/registry/model/domain/DomainApplication.java +++ b/java/google/registry/model/domain/DomainApplication.java @@ -69,6 +69,10 @@ public class DomainApplication extends DomainBase { @XmlTransient LaunchPhase phase; + /** The requested number of years of registration. */ + @XmlTransient + int years; + /** The current status of this application. */ @XmlTransient ApplicationStatus applicationStatus; @@ -94,6 +98,10 @@ public class DomainApplication extends DomainBase { return phase; } + public int getYears() { + return years; + } + public ApplicationStatus getApplicationStatus() { return applicationStatus; } @@ -150,6 +158,11 @@ public class DomainApplication extends DomainBase { getInstance().phase = phase; return this; } + + public Builder setYears(int years) { + getInstance().years = years; + return this; + } public Builder setApplicationStatus(ApplicationStatus applicationStatus) { getInstance().applicationStatus = applicationStatus; diff --git a/javatests/google/registry/flows/domain/DomainApplicationCreateFlowTest.java b/javatests/google/registry/flows/domain/DomainApplicationCreateFlowTest.java index b47b831e7..118e055a7 100644 --- a/javatests/google/registry/flows/domain/DomainApplicationCreateFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainApplicationCreateFlowTest.java @@ -214,6 +214,7 @@ public class DomainApplicationCreateFlowTest assertAboutApplications().that(getLast(applications)) .hasFullyQualifiedDomainName(getUniqueIdFromCommand()).and() .hasNumEncodedSignedMarks(sunriseApplication ? 1 : 0).and() + .hasYears(years).and() .hasOnlyOneHistoryEntryWhich() .hasType(HistoryEntry.Type.DOMAIN_APPLICATION_CREATE).and() .hasPeriodYears(years); diff --git a/javatests/google/registry/model/schema.txt b/javatests/google/registry/model/schema.txt index d76800b6c..60446e0be 100644 --- a/javatests/google/registry/model/schema.txt +++ b/javatests/google/registry/model/schema.txt @@ -208,6 +208,7 @@ class google.registry.model.domain.DomainApplication { google.registry.model.domain.launch.LaunchPhase phase; google.registry.model.eppcommon.Trid creationTrid; google.registry.model.transfer.TransferData transferData; + int years; java.lang.String creationClientId; java.lang.String currentSponsorClientId; java.lang.String fullyQualifiedDomainName; diff --git a/javatests/google/registry/testing/DomainApplicationSubject.java b/javatests/google/registry/testing/DomainApplicationSubject.java index 2664595f0..d5c2ca259 100644 --- a/javatests/google/registry/testing/DomainApplicationSubject.java +++ b/javatests/google/registry/testing/DomainApplicationSubject.java @@ -31,6 +31,11 @@ import java.util.Objects; public final class DomainApplicationSubject extends AbstractDomainBaseSubject { + public And hasYears(int years) { + assertThat(actual().getYears()).isEqualTo(years); + return andChainer(); + } + public And hasApplicationStatus( ApplicationStatus applicationStatus) { if (!Objects.equals(actual().getApplicationStatus(), applicationStatus)) {