Scope down TransferData to only ContactResource and DomainResource

HostResource and DomainApplication are not transferable, (or at
least, not directly in the case of hosts) and have no need for
the TransferData field. In a flat-flow world, we can push it down
to where it's actually used.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=139201423
This commit is contained in:
cgoldfeder 2016-11-15 08:03:25 -08:00 committed by Ben McIlwain
parent 0234795240
commit 84009eaccb
24 changed files with 309 additions and 240 deletions

View file

@ -167,7 +167,7 @@ public class ContactResourceTest extends EntityTestCase {
ContactResource withNull = new ContactResource.Builder().setTransferData(null).build();
ContactResource withEmpty = withNull.asBuilder().setTransferData(TransferData.EMPTY).build();
assertThat(withNull).isEqualTo(withEmpty);
assertThat(withEmpty.hasTransferData()).isFalse();
assertThat(withEmpty.transferData).isNull();
}
@Test

View file

@ -36,7 +36,6 @@ import com.google.common.collect.ImmutableSet;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.VoidWork;
import google.registry.model.EntityTestCase;
import google.registry.model.billing.BillingEvent;
import google.registry.model.domain.launch.ApplicationStatus;
import google.registry.model.domain.launch.LaunchNotice;
import google.registry.model.domain.launch.LaunchPhase;
@ -47,9 +46,6 @@ import google.registry.model.eppcommon.Trid;
import google.registry.model.host.HostResource;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.smd.EncodedSignedMark;
import google.registry.model.transfer.TransferData;
import google.registry.model.transfer.TransferData.TransferServerApproveEntity;
import google.registry.model.transfer.TransferStatus;
import google.registry.testing.ExceptionRule;
import org.joda.money.Money;
import org.joda.time.DateTime;
@ -95,19 +91,6 @@ public class DomainApplicationTest extends EntityTestCase {
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2})))
.setLaunchNotice(
LaunchNotice.create("tcnid", "validatorId", START_OF_TIME, START_OF_TIME))
.setTransferData(
new TransferData.Builder()
.setExtendedRegistrationYears(0)
.setGainingClientId("gaining")
.setLosingClientId("losing")
.setPendingTransferExpirationTime(clock.nowUtc())
.setServerApproveEntities(
ImmutableSet.<Key<? extends TransferServerApproveEntity>>of(
Key.create(BillingEvent.OneTime.class, 1)))
.setTransferRequestTime(clock.nowUtc())
.setTransferStatus(TransferStatus.SERVER_APPROVED)
.setTransferRequestTrid(Trid.create("client trid"))
.build())
.setCreationTrid(Trid.create("client creation trid"))
.setPhase(LaunchPhase.LANDRUSH)
// TODO(b/32447342): set period
@ -183,14 +166,6 @@ public class DomainApplicationTest extends EntityTestCase {
.isNotNull();
}
@Test
public void testEmptyTransferDataBecomesNull() throws Exception {
DomainApplication withNull = emptyBuilder().setTransferData(null).build();
DomainApplication withEmpty = withNull.asBuilder().setTransferData(TransferData.EMPTY).build();
assertThat(withNull).isEqualTo(withEmpty);
assertThat(withEmpty.hasTransferData()).isFalse();
}
@Test
public void testToHydratedString_notCircular() {
// If there are circular references, this will overflow the stack.

View file

@ -231,7 +231,7 @@ public class DomainResourceTest extends EntityTestCase {
newDomainResource("example.com").asBuilder().setTransferData(null).build();
DomainResource withEmpty = withNull.asBuilder().setTransferData(TransferData.EMPTY).build();
assertThat(withNull).isEqualTo(withEmpty);
assertThat(withEmpty.hasTransferData()).isFalse();
assertThat(withEmpty.transferData).isNull();
}
@Test

View file

@ -149,14 +149,6 @@ public class HostResourceTest extends EntityTestCase {
.isNotNull();
}
@Test
public void testEmptyTransferDataBecomesNull() throws Exception {
HostResource withNull = new HostResource.Builder().setTransferData(null).build();
HostResource withEmpty = withNull.asBuilder().setTransferData(TransferData.EMPTY).build();
assertThat(withNull).isEqualTo(withEmpty);
assertThat(withEmpty.hasTransferData()).isFalse();
}
@Test
public void testImplicitStatusValues() {
// OK is implicit if there's no other statuses.
@ -205,7 +197,6 @@ public class HostResourceTest extends EntityTestCase {
hostResource.asBuilder()
.setLastSuperordinateChange(superordinateChangeTime)
.setLastTransferTime(hostTransferTime)
.setTransferData(null)
.build());
return hostResource.cloneProjectedAtTime(clock.nowUtc()).getLastTransferTime();
}
@ -279,8 +270,6 @@ public class HostResourceTest extends EntityTestCase {
.build())
.build());
HostResource afterTransfer = hostResource.cloneProjectedAtTime(clock.nowUtc().plusDays(1));
assertThat(afterTransfer.getTransferData().getTransferStatus())
.isEqualTo(TransferStatus.SERVER_APPROVED);
assertThat(afterTransfer.getCurrentSponsorClientId()).isEqualTo("winner");
assertThat(afterTransfer.getLastTransferTime()).isEqualTo(clock.nowUtc().plusDays(1));
}

View file

@ -206,7 +206,6 @@ class google.registry.model.domain.DomainApplication {
google.registry.model.domain.launch.LaunchNotice launchNotice;
google.registry.model.domain.launch.LaunchPhase phase;
google.registry.model.eppcommon.Trid creationTrid;
google.registry.model.transfer.TransferData transferData;
java.lang.String creationClientId;
java.lang.String currentSponsorClientId;
java.lang.String fullyQualifiedDomainName;
@ -233,7 +232,6 @@ class google.registry.model.domain.DomainBase {
google.registry.model.UpdateAutoTimestamp updateTimestamp;
google.registry.model.domain.DomainAuthInfo authInfo;
google.registry.model.domain.launch.LaunchNotice launchNotice;
google.registry.model.transfer.TransferData transferData;
java.lang.String creationClientId;
java.lang.String currentSponsorClientId;
java.lang.String fullyQualifiedDomainName;
@ -387,7 +385,6 @@ class google.registry.model.host.HostResource {
com.googlecode.objectify.Key<google.registry.model.domain.DomainResource> superordinateDomain;
google.registry.model.CreateAutoTimestamp creationTime;
google.registry.model.UpdateAutoTimestamp updateTimestamp;
google.registry.model.transfer.TransferData transferData;
java.lang.String creationClientId;
java.lang.String currentSponsorClientId;
java.lang.String fullyQualifiedHostName;