Remove obsolete TransferData.extendedRegistrationYears

Now that transfers are always restricted to 1 year, it's unnecessary to store
extendedRegistrationYears on TransferData - it will always be equal to 1.  This
simplifies logic in a few other places, e.g. RdeDomainImportAction.

I verified in BigQuery that no DomainBases exist with extendedRegistrationYears
values that aren't either null or equal to 1.  At some point we should remove
the persisted fields from datastore via e.g. resaving all those domains, but
it's low priority and can wait until we have some more pressing migration.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=150373897
This commit is contained in:
nickfelt 2017-03-16 15:03:18 -07:00 committed by Ben McIlwain
parent 70fbdccea2
commit 09f619cce2
29 changed files with 54 additions and 215 deletions

View file

@ -298,18 +298,15 @@ public class DomainTransferApproveFlowTest
DateTime oldExpirationTime = clock.nowUtc().minusDays(1);
persistResource(domain.asBuilder()
.setRegistrationExpirationTime(oldExpirationTime)
.setTransferData(domain.getTransferData().asBuilder()
.setExtendedRegistrationYears(2)
.build())
.build());
// The autorenew should be subsumed into the transfer resulting in 2 years of renewal in total.
// The autorenew should be subsumed into the transfer resulting in 1 year of renewal in total.
clock.advanceOneMilli();
doSuccessfulTest(
"tld",
"domain_transfer_approve_domain_authinfo.xml",
"domain_transfer_approve_response_autorenew.xml",
oldExpirationTime.plusYears(2),
2,
oldExpirationTime.plusYears(1),
1,
// Expect the grace period for autorenew to be cancelled.
new BillingEvent.Cancellation.Builder()
.setReason(Reason.RENEW)

View file

@ -101,7 +101,6 @@ public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
TRANSFER_REQUEST_TIME,
TRANSFER_EXPIRATION_TIME,
EXTENDED_REGISTRATION_EXPIRATION_TIME,
EXTENDED_REGISTRATION_YEARS,
TRANSFER_REQUEST_TIME);
}
@ -176,8 +175,7 @@ public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
domain,
historyEntry,
TRANSFER_REQUEST_TIME,
TRANSFER_EXPIRATION_TIME,
EXTENDED_REGISTRATION_YEARS);
TRANSFER_EXPIRATION_TIME);
}
/** Get the autorenew event that the losing client will have after a SERVER_APPROVED transfer. */

View file

@ -148,10 +148,10 @@ public class DomainTransferQueryFlowTest
@Test
public void testSuccess_tenYears() throws Exception {
// Extend registration by 9 years here; with the extra 1 year from the transfer, we should
// hit the 10-year capping.
domain = persistResource(domain.asBuilder()
.setTransferData(domain.getTransferData().asBuilder()
.setExtendedRegistrationYears(10)
.build())
.setRegistrationExpirationTime(domain.getRegistrationExpirationTime().plusYears(9))
.build());
doSuccessfulTest(
"domain_transfer_query.xml",

View file

@ -164,7 +164,6 @@ public class DomainTransferRequestFlowTest
domain = reloadResourceByForeignKey();
final HistoryEntry historyEntryTransferRequest =
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST);
int registrationYears = domain.getTransferData().getExtendedRegistrationYears();
subordinateHost = reloadResourceAndCloneAtTime(subordinateHost, clock.nowUtc());
assertTransferRequested(domain);
assertAboutDomains().that(domain)
@ -174,7 +173,7 @@ public class DomainTransferRequestFlowTest
HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST);
assertAboutHistoryEntries()
.that(historyEntryTransferRequest)
.hasPeriodYears(registrationYears)
.hasPeriodYears(1)
.and()
.hasOtherClientId("TheRegistrar");
assertAboutHosts().that(subordinateHost).hasNoHistoryEntries();
@ -190,8 +189,8 @@ public class DomainTransferRequestFlowTest
.setEventTime(implicitTransferTime)
.setBillingTime(implicitTransferTime.plus(registry.getTransferGracePeriodLength()))
.setClientId("NewRegistrar")
.setCost(transferCost.or(Money.of(USD, 11).multipliedBy(registrationYears)))
.setPeriodYears(registrationYears)
.setCost(transferCost.or(Money.of(USD, 11)))
.setPeriodYears(1)
.setParent(historyEntryTransferRequest)
.build();
assertBillingEvents(FluentIterable.from(extraExpectedBillingEvents)

View file

@ -12,7 +12,7 @@
<domain:reDate>2000-06-06T22:00:00.0Z</domain:reDate>
<domain:acID>TheRegistrar</domain:acID>
<domain:acDate>2000-06-09T22:00:00.0Z</domain:acDate>
<domain:exDate>2002-06-08T22:00:00.0Z</domain:exDate>
<domain:exDate>2001-06-08T22:00:00.0Z</domain:exDate>
</domain:trnData>
</resData>
<trID>

View file

@ -193,7 +193,6 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
.setTransferRequestTime(requestTime)
.setLosingClientId("TheRegistrar")
.setPendingTransferExpirationTime(transferExpirationTime)
.setExtendedRegistrationYears(1)
.build())
.build());
persistResource(
@ -222,7 +221,6 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
.setTransferRequestTime(requestTime)
.setLosingClientId("NewRegistrar")
.setPendingTransferExpirationTime(transferExpirationTime)
.setExtendedRegistrationYears(1)
.build())
.build());
persistResource(

View file

@ -113,7 +113,6 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
.setTransferRequestTime(requestTime)
.setLosingClientId("TheRegistrar")
.setPendingTransferExpirationTime(transferExpirationTime)
.setExtendedRegistrationYears(1)
.build())
.build();
}

View file

@ -102,7 +102,6 @@ public class ContactResourceTest extends EntityTestCase {
.build())
.setStatusValues(ImmutableSet.of(StatusValue.OK))
.setTransferData(new TransferData.Builder()
.setExtendedRegistrationYears(0)
.setGainingClientId("gaining")
.setLosingClientId("losing")
.setPendingTransferExpirationTime(clock.nowUtc())

View file

@ -124,7 +124,6 @@ public class DomainResourceTest extends EntityTestCase {
LaunchNotice.create("tcnid", "validatorId", START_OF_TIME, START_OF_TIME))
.setTransferData(
new TransferData.Builder()
.setExtendedRegistrationYears(1)
.setGainingClientId("gaining")
.setLosingClientId("losing")
.setPendingTransferExpirationTime(clock.nowUtc())
@ -306,7 +305,6 @@ public class DomainResourceTest extends EntityTestCase {
.setServerApproveBillingEvent(Key.create(transferBillingEvent))
.setServerApproveEntities(ImmutableSet.<Key<? extends TransferServerApproveEntity>>of(
Key.create(transferBillingEvent)))
.setExtendedRegistrationYears(1)
.build())
.addGracePeriod(
// Okay for billing event to be null since the point of this grace period is just

View file

@ -61,7 +61,6 @@ public class HostResourceTest extends EntityTestCase {
newDomainResource("example.com").asBuilder()
.setRepoId("1-COM")
.setTransferData(new TransferData.Builder()
.setExtendedRegistrationYears(0)
.setGainingClientId("gaining")
.setLosingClientId("losing")
.setPendingTransferExpirationTime(clock.nowUtc())

View file

@ -876,7 +876,6 @@ class google.registry.model.transfer.TransferData {
com.googlecode.objectify.Key<google.registry.model.poll.PollMessage$Autorenew> serverApproveAutorenewPollMessage;
google.registry.model.eppcommon.Trid transferRequestTrid;
google.registry.model.transfer.TransferStatus transferStatus;
java.lang.Integer extendedRegistrationYears;
java.lang.String gainingClientId;
java.lang.String losingClientId;
java.util.Set<com.googlecode.objectify.Key<? extends google.registry.model.transfer.TransferData$TransferServerApproveEntity>> serverApproveEntities;

View file

@ -160,7 +160,6 @@ public class RdapJsonFormatterTest {
.setTransferRequestTime(clock.nowUtc().minusDays(1))
.setLosingClientId("TheRegistrar")
.setPendingTransferExpirationTime(clock.nowUtc().plusYears(100))
.setExtendedRegistrationYears(1)
.build())
.build())))
.build());

View file

@ -332,7 +332,6 @@ public class ContactResourceToXjcConverterTest {
.setPhoneNumber("+1.2126660001")
.build())
.setTransferData(new TransferData.Builder()
.setExtendedRegistrationYears(1)
.setGainingClientId("TheRegistrar")
.setLosingClientId("NewRegistrar")
.setTransferRequestTime(DateTime.parse("1925-04-19TZ"))

View file

@ -324,7 +324,6 @@ public class DomainResourceToXjcConverterTest {
.setParent(historyEntry)
.build())))
.setTransferData(new TransferData.Builder()
.setExtendedRegistrationYears(1)
.setGainingClientId("gaining")
.setLosingClientId("losing")
.setPendingTransferExpirationTime(DateTime.parse("1925-04-20T00:00:00Z"))

View file

@ -149,7 +149,6 @@ final class RdeFixtures {
.setParent(historyEntry)
.build())))
.setTransferData(new TransferData.Builder()
.setExtendedRegistrationYears(1)
.setGainingClientId("gaining")
.setLosingClientId("losing")
.setPendingTransferExpirationTime(DateTime.parse("1925-04-20T00:00:00Z"))

View file

@ -388,36 +388,6 @@ public class XjcToDomainResourceConverterTest {
.isEqualTo(DateTime.parse("2015-01-08T22:00:00.0Z"));
}
@Test
public void testConvertDomainResourcePendingTransferDefaultExtendedYears() throws Exception {
persistActiveContact("jd1234");
persistActiveContact("sh8013");
final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_pending_transfer.xml");
DomainResource domain = persistResource(convertDomainInTransaction(xjcDomain));
assertThat(domain.getTransferData()).isNotNull();
assertThat(domain.getTransferData().getExtendedRegistrationYears()).isEqualTo(1);
}
@Test
public void testConvertDomainResourcePendingTransferExtendOneYear() throws Exception {
persistActiveContact("jd1234");
persistActiveContact("sh8013");
final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_pending_transfer_1yr.xml");
DomainResource domain = persistResource(convertDomainInTransaction(xjcDomain));
assertThat(domain.getTransferData()).isNotNull();
assertThat(domain.getTransferData().getExtendedRegistrationYears()).isEqualTo(1);
}
@Test
public void testConvertDomainResourcePendingTransferExtendTwoYears() throws Exception {
persistActiveContact("jd1234");
persistActiveContact("sh8013");
final XjcRdeDomain xjcDomain = loadDomainFromRdeXml("domain_fragment_pending_transfer_2yr.xml");
DomainResource domain = persistResource(convertDomainInTransaction(xjcDomain));
assertThat(domain.getTransferData()).isNotNull();
assertThat(domain.getTransferData().getExtendedRegistrationYears()).isEqualTo(2);
}
private static DomainResource convertDomainInTransaction(final XjcRdeDomain xjcDomain) {
final HistoryEntry historyEntry = createHistoryEntryForDomainImport(xjcDomain);
final BillingEvent.Recurring autorenewBillingEvent =

View file

@ -1,24 +0,0 @@
<rdeDom:domain
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"
xmlns:rdeDom="urn:ietf:params:xml:ns:rdeDomain-1.0">
<rdeDom:name>example1.example</rdeDom:name>
<rdeDom:roid>Dexample1-TEST</rdeDom:roid>
<rdeDom:status s="pendingTransfer"/>
<rdeDom:registrant>jd1234</rdeDom:registrant>
<rdeDom:contact type="admin">sh8013</rdeDom:contact>
<rdeDom:contact type="tech">sh8013</rdeDom:contact>
<rdeDom:clID>RegistrarX</rdeDom:clID>
<rdeDom:crRr client="jdoe">RegistrarX</rdeDom:crRr>
<rdeDom:crDate>1999-04-03T22:00:00.0Z</rdeDom:crDate>
<rdeDom:exDate>2015-04-03T22:00:00.0Z</rdeDom:exDate>
<rdeDom:upRr>RegistrarY</rdeDom:upRr>
<rdeDom:upDate>2015-01-03T22:00:00.0Z</rdeDom:upDate>
<rdeDom:trnData>
<rdeDom:trStatus>pending</rdeDom:trStatus>
<rdeDom:reRr>RegistrarY</rdeDom:reRr>
<rdeDom:reDate>2015-01-03T22:00:00.0Z</rdeDom:reDate>
<rdeDom:acRr>RegistrarX</rdeDom:acRr>
<rdeDom:acDate>2015-01-08T22:00:00.0Z</rdeDom:acDate>
<rdeDom:exDate>2016-04-03T22:00:00.0Z</rdeDom:exDate>
</rdeDom:trnData>
</rdeDom:domain>

View file

@ -1,24 +0,0 @@
<rdeDom:domain
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"
xmlns:rdeDom="urn:ietf:params:xml:ns:rdeDomain-1.0">
<rdeDom:name>example1.example</rdeDom:name>
<rdeDom:roid>Dexample1-TEST</rdeDom:roid>
<rdeDom:status s="pendingTransfer"/>
<rdeDom:registrant>jd1234</rdeDom:registrant>
<rdeDom:contact type="admin">sh8013</rdeDom:contact>
<rdeDom:contact type="tech">sh8013</rdeDom:contact>
<rdeDom:clID>RegistrarX</rdeDom:clID>
<rdeDom:crRr client="jdoe">RegistrarX</rdeDom:crRr>
<rdeDom:crDate>1999-04-03T22:00:00.0Z</rdeDom:crDate>
<rdeDom:exDate>2015-04-03T22:00:00.0Z</rdeDom:exDate>
<rdeDom:upRr>RegistrarY</rdeDom:upRr>
<rdeDom:upDate>2015-01-03T22:00:00.0Z</rdeDom:upDate>
<rdeDom:trnData>
<rdeDom:trStatus>pending</rdeDom:trStatus>
<rdeDom:reRr>RegistrarY</rdeDom:reRr>
<rdeDom:reDate>2015-01-03T22:00:00.0Z</rdeDom:reDate>
<rdeDom:acRr>RegistrarX</rdeDom:acRr>
<rdeDom:acDate>2015-01-08T22:00:00.0Z</rdeDom:acDate>
<rdeDom:exDate>2017-04-03T22:00:00.0Z</rdeDom:exDate>
</rdeDom:trnData>
</rdeDom:domain>

View file

@ -431,12 +431,6 @@ public class DatastoreHelper {
.setPendingTransferExpirationTime(expirationTime);
}
private static Builder createTransferDataBuilder(
DateTime requestTime, DateTime expirationTime, Integer extendedRegistrationYears) {
return createTransferDataBuilder(requestTime, expirationTime)
.setExtendedRegistrationYears(extendedRegistrationYears);
}
public static PollMessage.OneTime createPollMessageForImplicitTransfer(
EppResource contact,
HistoryEntry historyEntry,
@ -460,8 +454,7 @@ public class DatastoreHelper {
DomainResource domain,
HistoryEntry historyEntry,
DateTime costLookupTime,
DateTime eventTime,
Integer extendedRegistrationYears) {
DateTime eventTime) {
return new BillingEvent.OneTime.Builder()
.setReason(Reason.TRANSFER)
.setTargetId(domain.getFullyQualifiedDomainName())
@ -469,10 +462,8 @@ public class DatastoreHelper {
.setBillingTime(
eventTime.plus(Registry.get(domain.getTld()).getTransferGracePeriodLength()))
.setClientId("NewRegistrar")
.setPeriodYears(extendedRegistrationYears)
.setCost(
getDomainRenewCost(
domain.getFullyQualifiedDomainName(), costLookupTime, extendedRegistrationYears))
.setPeriodYears(1)
.setCost(getDomainRenewCost(domain.getFullyQualifiedDomainName(), costLookupTime, 1))
.setParent(historyEntry)
.build();
}
@ -522,7 +513,6 @@ public class DatastoreHelper {
DateTime requestTime,
DateTime expirationTime,
DateTime extendedRegistrationExpirationTime,
int extendedRegistrationYears,
DateTime now) {
HistoryEntry historyEntryDomainTransfer = persistResource(
new HistoryEntry.Builder()
@ -533,8 +523,7 @@ public class DatastoreHelper {
domain,
historyEntryDomainTransfer,
requestTime,
expirationTime,
extendedRegistrationYears));
expirationTime));
BillingEvent.Recurring gainingClientAutorenewEvent = persistResource(
new BillingEvent.Recurring.Builder()
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
@ -571,8 +560,7 @@ public class DatastoreHelper {
} else {
deleteResource(autorenewPollMessage);
}
Builder transferDataBuilder = createTransferDataBuilder(
requestTime, expirationTime, extendedRegistrationYears);
Builder transferDataBuilder = createTransferDataBuilder(requestTime, expirationTime);
return persistResource(domain.asBuilder()
.setPersistedCurrentSponsorClientId("TheRegistrar")
.addStatusValue(StatusValue.PENDING_TRANSFER)
@ -602,7 +590,6 @@ public class DatastoreHelper {
expirationTime,
now)))))
.setTransferRequestTrid(Trid.create("transferClient-trid", "transferServer-trid"))
.setExtendedRegistrationYears(extendedRegistrationYears)
.build())
.build());
}