Populate the host in HostHistory objects in Host flows (#1129)

* Populate the host in HostHistory objects in Host flows
This commit is contained in:
gbrodman 2021-05-12 19:11:30 -04:00 committed by GitHub
parent 6e5d42b38d
commit 1a664fe95b
40 changed files with 68 additions and 58 deletions

View file

@ -95,7 +95,7 @@ public final class ContactCreateFlow implements TransactionalFlow {
.setType(HistoryEntry.Type.CONTACT_CREATE) .setType(HistoryEntry.Type.CONTACT_CREATE)
.setModificationTime(now) .setModificationTime(now)
.setXmlBytes(null) // We don't want to store contact details in the history entry. .setXmlBytes(null) // We don't want to store contact details in the history entry.
.setContactBase(newContact); .setContact(newContact);
tm().insertAll( tm().insertAll(
ImmutableSet.of( ImmutableSet.of(
newContact, newContact,

View file

@ -125,7 +125,7 @@ public final class ContactDeleteFlow implements TransactionalFlow {
historyBuilder historyBuilder
.setType(historyEntryType) .setType(historyEntryType)
.setModificationTime(now) .setModificationTime(now)
.setContactBase(newContact) .setContact(newContact)
.build(); .build();
if (!tm().isOfy()) { if (!tm().isOfy()) {
handlePendingTransferOnDelete(existingContact, newContact, now, contactHistory); handlePendingTransferOnDelete(existingContact, newContact, now, contactHistory);

View file

@ -91,7 +91,7 @@ public final class ContactTransferApproveFlow implements TransactionalFlow {
historyBuilder historyBuilder
.setType(HistoryEntry.Type.CONTACT_TRANSFER_APPROVE) .setType(HistoryEntry.Type.CONTACT_TRANSFER_APPROVE)
.setModificationTime(now) .setModificationTime(now)
.setContactBase(newContact) .setContact(newContact)
.build(); .build();
// Create a poll message for the gaining client. // Create a poll message for the gaining client.
PollMessage gainingPollMessage = PollMessage gainingPollMessage =

View file

@ -87,7 +87,7 @@ public final class ContactTransferCancelFlow implements TransactionalFlow {
historyBuilder historyBuilder
.setType(HistoryEntry.Type.CONTACT_TRANSFER_CANCEL) .setType(HistoryEntry.Type.CONTACT_TRANSFER_CANCEL)
.setModificationTime(now) .setModificationTime(now)
.setContactBase(newContact) .setContact(newContact)
.build(); .build();
// Create a poll message for the losing client. // Create a poll message for the losing client.
PollMessage losingPollMessage = PollMessage losingPollMessage =

View file

@ -85,7 +85,7 @@ public final class ContactTransferRejectFlow implements TransactionalFlow {
historyBuilder historyBuilder
.setType(HistoryEntry.Type.CONTACT_TRANSFER_REJECT) .setType(HistoryEntry.Type.CONTACT_TRANSFER_REJECT)
.setModificationTime(now) .setModificationTime(now)
.setContactBase(newContact) .setContact(newContact)
.build(); .build();
PollMessage gainingPollMessage = PollMessage gainingPollMessage =
createGainingTransferPollMessage( createGainingTransferPollMessage(

View file

@ -153,7 +153,7 @@ public final class ContactTransferRequestFlow implements TransactionalFlow {
tm().update(newContact); tm().update(newContact);
tm().insertAll( tm().insertAll(
ImmutableSet.of( ImmutableSet.of(
historyBuilder.setContactBase(newContact).build(), historyBuilder.setContact(newContact).build(),
requestPollMessage, requestPollMessage,
serverApproveGainingPollMessage, serverApproveGainingPollMessage,
serverApproveLosingPollMessage)); serverApproveLosingPollMessage));

View file

@ -149,7 +149,7 @@ public final class ContactUpdateFlow implements TransactionalFlow {
.setType(HistoryEntry.Type.CONTACT_UPDATE) .setType(HistoryEntry.Type.CONTACT_UPDATE)
.setModificationTime(now) .setModificationTime(now)
.setXmlBytes(null) // We don't want to store contact details in the history entry. .setXmlBytes(null) // We don't want to store contact details in the history entry.
.setContactBase(newContact); .setContact(newContact);
tm().insert(historyBuilder.build()); tm().insert(historyBuilder.build());
tm().update(newContact); tm().update(newContact);
return responseBuilder.build(); return responseBuilder.build();

View file

@ -502,7 +502,7 @@ public class DomainCreateFlow implements TransactionalFlow {
.setType(HistoryEntry.Type.DOMAIN_CREATE) .setType(HistoryEntry.Type.DOMAIN_CREATE)
.setPeriod(period) .setPeriod(period)
.setModificationTime(now) .setModificationTime(now)
.setDomainContent(domain) .setDomain(domain)
.build(); .build();
} }

View file

@ -331,7 +331,7 @@ public final class DomainDeleteFlow implements TransactionalFlow {
return historyBuilder return historyBuilder
.setType(HistoryEntry.Type.DOMAIN_DELETE) .setType(HistoryEntry.Type.DOMAIN_DELETE)
.setModificationTime(now) .setModificationTime(now)
.setDomainContent(domain) .setDomain(domain)
.build(); .build();
} }

View file

@ -233,7 +233,7 @@ public final class DomainRenewFlow implements TransactionalFlow {
.setType(HistoryEntry.Type.DOMAIN_RENEW) .setType(HistoryEntry.Type.DOMAIN_RENEW)
.setPeriod(period) .setPeriod(period)
.setModificationTime(now) .setModificationTime(now)
.setDomainContent(newDomain) .setDomain(newDomain)
.setDomainTransactionRecords( .setDomainTransactionRecords(
ImmutableSet.of( ImmutableSet.of(
DomainTransactionRecord.create( DomainTransactionRecord.create(

View file

@ -190,7 +190,7 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow {
return historyBuilder return historyBuilder
.setType(HistoryEntry.Type.DOMAIN_RESTORE) .setType(HistoryEntry.Type.DOMAIN_RESTORE)
.setModificationTime(now) .setModificationTime(now)
.setDomainContent(newDomain) .setDomain(newDomain)
.setDomainTransactionRecords( .setDomainTransactionRecords(
ImmutableSet.of( ImmutableSet.of(
DomainTransactionRecord.create( DomainTransactionRecord.create(

View file

@ -243,7 +243,7 @@ public final class DomainTransferApproveFlow implements TransactionalFlow {
.setType(HistoryEntry.Type.DOMAIN_TRANSFER_APPROVE) .setType(HistoryEntry.Type.DOMAIN_TRANSFER_APPROVE)
.setModificationTime(now) .setModificationTime(now)
.setOtherClientId(gainingClientId) .setOtherClientId(gainingClientId)
.setDomainContent(newDomain) .setDomain(newDomain)
.setDomainTransactionRecords( .setDomainTransactionRecords(
union( union(
cancelingRecords, cancelingRecords,

View file

@ -132,7 +132,7 @@ public final class DomainTransferCancelFlow implements TransactionalFlow {
return historyBuilder return historyBuilder
.setType(HistoryEntry.Type.DOMAIN_TRANSFER_CANCEL) .setType(HistoryEntry.Type.DOMAIN_TRANSFER_CANCEL)
.setModificationTime(now) .setModificationTime(now)
.setDomainContent(newDomain) .setDomain(newDomain)
.setDomainTransactionRecords(cancelingRecords) .setDomainTransactionRecords(cancelingRecords)
.build(); .build();
} }

View file

@ -137,7 +137,7 @@ public final class DomainTransferRejectFlow implements TransactionalFlow {
union( union(
cancelingRecords, cancelingRecords,
DomainTransactionRecord.create(newDomain.getTld(), now, TRANSFER_NACKED, 1))) DomainTransactionRecord.create(newDomain.getTld(), now, TRANSFER_NACKED, 1)))
.setDomainContent(newDomain) .setDomain(newDomain)
.build(); .build();
} }
} }

View file

@ -318,7 +318,7 @@ public final class DomainTransferRequestFlow implements TransactionalFlow {
.setType(HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST) .setType(HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST)
.setPeriod(period) .setPeriod(period)
.setModificationTime(now) .setModificationTime(now)
.setDomainContent(newDomain) .setDomain(newDomain)
.setDomainTransactionRecords( .setDomainTransactionRecords(
ImmutableSet.of( ImmutableSet.of(
DomainTransactionRecord.create( DomainTransactionRecord.create(

View file

@ -221,7 +221,7 @@ public final class DomainUpdateFlow implements TransactionalFlow {
return historyBuilder return historyBuilder
.setType(HistoryEntry.Type.DOMAIN_UPDATE) .setType(HistoryEntry.Type.DOMAIN_UPDATE)
.setModificationTime(now) .setModificationTime(now)
.setDomainContent(newDomain) .setDomain(newDomain)
.build(); .build();
} }

View file

@ -45,6 +45,7 @@ import google.registry.model.eppinput.ResourceCommand;
import google.registry.model.eppoutput.CreateData.HostCreateData; import google.registry.model.eppoutput.CreateData.HostCreateData;
import google.registry.model.eppoutput.EppResponse; import google.registry.model.eppoutput.EppResponse;
import google.registry.model.host.HostCommand.Create; import google.registry.model.host.HostCommand.Create;
import google.registry.model.host.HostHistory;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
import google.registry.model.index.EppResourceIndex; import google.registry.model.index.EppResourceIndex;
import google.registry.model.index.ForeignKeyIndex; import google.registry.model.index.ForeignKeyIndex;
@ -85,7 +86,7 @@ public final class HostCreateFlow implements TransactionalFlow {
@Inject ExtensionManager extensionManager; @Inject ExtensionManager extensionManager;
@Inject @ClientId String clientId; @Inject @ClientId String clientId;
@Inject @TargetId String targetId; @Inject @TargetId String targetId;
@Inject HistoryEntry.Builder historyBuilder; @Inject HostHistory.Builder historyBuilder;
@Inject DnsQueue dnsQueue; @Inject DnsQueue dnsQueue;
@Inject EppResponse.Builder responseBuilder; @Inject EppResponse.Builder responseBuilder;
@ -128,14 +129,11 @@ public final class HostCreateFlow implements TransactionalFlow {
.setRepoId(createRepoId(ObjectifyService.allocateId(), roidSuffix)) .setRepoId(createRepoId(ObjectifyService.allocateId(), roidSuffix))
.setSuperordinateDomain(superordinateDomain.map(DomainBase::createVKey).orElse(null)) .setSuperordinateDomain(superordinateDomain.map(DomainBase::createVKey).orElse(null))
.build(); .build();
historyBuilder historyBuilder.setType(HistoryEntry.Type.HOST_CREATE).setModificationTime(now).setHost(newHost);
.setType(HistoryEntry.Type.HOST_CREATE)
.setModificationTime(now)
.setParent(Key.create(newHost));
ImmutableSet<ImmutableObject> entitiesToSave = ImmutableSet<ImmutableObject> entitiesToSave =
ImmutableSet.of( ImmutableSet.of(
newHost, newHost,
historyBuilder.build().toChildHistoryEntity(), historyBuilder.build(),
ForeignKeyIndex.create(newHost, newHost.getDeletionTime()), ForeignKeyIndex.create(newHost, newHost.getDeletionTime()),
EppResourceIndex.create(Key.create(newHost))); EppResourceIndex.create(Key.create(newHost)));
if (superordinateDomain.isPresent()) { if (superordinateDomain.isPresent()) {

View file

@ -130,7 +130,7 @@ public final class HostDeleteFlow implements TransactionalFlow {
historyEntryType = Type.HOST_DELETE; historyEntryType = Type.HOST_DELETE;
resultCode = SUCCESS; resultCode = SUCCESS;
} }
historyBuilder.setType(historyEntryType).setModificationTime(now).setHostBase(newHost); historyBuilder.setType(historyEntryType).setModificationTime(now).setHost(newHost);
tm().insert(historyBuilder.build()); tm().insert(historyBuilder.build());
tm().update(newHost); tm().update(newHost);
return responseBuilder.setResultFromCode(resultCode).build(); return responseBuilder.setResultFromCode(resultCode).build();

View file

@ -31,7 +31,6 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.
import static google.registry.util.CollectionUtils.isNullOrEmpty; import static google.registry.util.CollectionUtils.isNullOrEmpty;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.googlecode.objectify.Key;
import google.registry.batch.AsyncTaskEnqueuer; import google.registry.batch.AsyncTaskEnqueuer;
import google.registry.dns.DnsQueue; import google.registry.dns.DnsQueue;
import google.registry.flows.EppException; import google.registry.flows.EppException;
@ -55,6 +54,7 @@ import google.registry.model.eppoutput.EppResponse;
import google.registry.model.host.HostCommand.Update; import google.registry.model.host.HostCommand.Update;
import google.registry.model.host.HostCommand.Update.AddRemove; import google.registry.model.host.HostCommand.Update.AddRemove;
import google.registry.model.host.HostCommand.Update.Change; import google.registry.model.host.HostCommand.Update.Change;
import google.registry.model.host.HostHistory;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
import google.registry.model.index.ForeignKeyIndex; import google.registry.model.index.ForeignKeyIndex;
import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry;
@ -116,7 +116,7 @@ public final class HostUpdateFlow implements TransactionalFlow {
@Inject @ClientId String clientId; @Inject @ClientId String clientId;
@Inject @TargetId String targetId; @Inject @TargetId String targetId;
@Inject @Superuser boolean isSuperuser; @Inject @Superuser boolean isSuperuser;
@Inject HistoryEntry.Builder historyBuilder; @Inject HostHistory.Builder historyBuilder;
@Inject AsyncTaskEnqueuer asyncTaskEnqueuer; @Inject AsyncTaskEnqueuer asyncTaskEnqueuer;
@Inject DnsQueue dnsQueue; @Inject DnsQueue dnsQueue;
@Inject EppResponse.Builder responseBuilder; @Inject EppResponse.Builder responseBuilder;
@ -205,9 +205,8 @@ public final class HostUpdateFlow implements TransactionalFlow {
historyBuilder historyBuilder
.setType(HistoryEntry.Type.HOST_UPDATE) .setType(HistoryEntry.Type.HOST_UPDATE)
.setModificationTime(now) .setModificationTime(now)
.setParent(Key.create(existingHost)) .setHost(newHost)
.build() .build());
.toChildHistoryEntity());
tm().updateAll(entitiesToUpdate.build()); tm().updateAll(entitiesToUpdate.build());
tm().insertAll(entitiesToInsert.build()); tm().insertAll(entitiesToInsert.build());
return responseBuilder.build(); return responseBuilder.build();

View file

@ -197,7 +197,7 @@ public class ContactHistory extends HistoryEntry implements SqlEntity {
super(instance); super(instance);
} }
public Builder setContactBase(@Nullable ContactBase contactBase) { public Builder setContact(@Nullable ContactBase contactBase) {
// Nullable for the sake of pre-Registry-3.0 history objects // Nullable for the sake of pre-Registry-3.0 history objects
if (contactBase == null) { if (contactBase == null) {
return this; return this;

View file

@ -345,7 +345,7 @@ public class DomainHistory extends HistoryEntry implements SqlEntity {
super(instance); super(instance);
} }
public Builder setDomainContent(@Nullable DomainContent domainContent) { public Builder setDomain(@Nullable DomainContent domainContent) {
// Nullable for the sake of pre-Registry-3.0 history objects // Nullable for the sake of pre-Registry-3.0 history objects
if (domainContent == null) { if (domainContent == null) {
return this; return this;

View file

@ -110,6 +110,9 @@ public class HostHistory extends HistoryEntry implements SqlEntity {
if (hostBase != null && hostBase.getHostName() == null) { if (hostBase != null && hostBase.getHostName() == null) {
hostBase = null; hostBase = null;
} }
if (hostBase != null && hostBase.getRepoId() == null) {
hostBase = hostBase.asBuilder().setRepoId(parent.getName()).build();
}
} }
// In Datastore, save as a HistoryEntry object regardless of this object's type // In Datastore, save as a HistoryEntry object regardless of this object's type
@ -195,7 +198,7 @@ public class HostHistory extends HistoryEntry implements SqlEntity {
super(instance); super(instance);
} }
public Builder setHostBase(@Nullable HostBase hostBase) { public Builder setHost(@Nullable HostBase hostBase) {
// Nullable for the sake of pre-Registry-3.0 history objects // Nullable for the sake of pre-Registry-3.0 history objects
if (hostBase == null) { if (hostBase == null) {
return this; return this;

View file

@ -196,7 +196,7 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
// Don't use direct equals comparison since one might be a subclass of the other // Don't use direct equals comparison since one might be a subclass of the other
assertAboutImmutableObjects() assertAboutImmutableObjects()
.that(contactHistory.getContactBase().get()) .that(contactHistory.getContactBase().get())
.isEqualExceptFields(resource); .hasFieldsEqualTo(resource);
} else if (resource instanceof DomainContent) { } else if (resource instanceof DomainContent) {
DomainHistory domainHistory = (DomainHistory) historyEntry; DomainHistory domainHistory = (DomainHistory) historyEntry;
assertAboutImmutableObjects() assertAboutImmutableObjects()
@ -204,7 +204,10 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
.isEqualExceptFields(resource, "gracePeriods", "dsData", "nsHosts"); .isEqualExceptFields(resource, "gracePeriods", "dsData", "nsHosts");
} else if (resource instanceof HostBase) { } else if (resource instanceof HostBase) {
HostHistory hostHistory = (HostHistory) historyEntry; HostHistory hostHistory = (HostHistory) historyEntry;
assertThat(hostHistory.getHostBase().get()).isEqualTo(resource); // Don't use direct equals comparison since one might be a subclass of the other
assertAboutImmutableObjects()
.that(hostHistory.getHostBase().get())
.hasFieldsEqualTo(resource);
} }
} }
} }

View file

@ -404,7 +404,7 @@ class DomainTransferCancelFlowTest
persistResource( persistResource(
new DomainHistory.Builder() new DomainHistory.Builder()
.setType(DOMAIN_TRANSFER_REQUEST) .setType(DOMAIN_TRANSFER_REQUEST)
.setDomainContent(domain) .setDomain(domain)
.setModificationTime(clock.nowUtc().minusDays(4)) .setModificationTime(clock.nowUtc().minusDays(4))
.setDomainTransactionRecords( .setDomainTransactionRecords(
ImmutableSet.of(previousSuccessRecord, notCancellableRecord)) ImmutableSet.of(previousSuccessRecord, notCancellableRecord))

View file

@ -92,17 +92,19 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
clock.advanceOneMilli(); clock.advanceOneMilli();
assertTransactionalFlow(true); assertTransactionalFlow(true);
runFlowAssertResponse(loadFile("host_create_response.xml")); runFlowAssertResponse(loadFile("host_create_response.xml"));
HostResource host = reloadResourceByForeignKey();
// Check that the host was created and persisted with a history entry. // Check that the host was created and persisted with a history entry.
assertAboutHosts() assertAboutHosts()
.that(reloadResourceByForeignKey()) .that(host)
.hasLastSuperordinateChange(null) .hasLastSuperordinateChange(null)
.and() .and()
.hasOnlyOneHistoryEntryWhich() .hasOnlyOneHistoryEntryWhich()
.hasType(HistoryEntry.Type.HOST_CREATE); .hasType(HistoryEntry.Type.HOST_CREATE);
assertNoBillingEvents(); assertNoBillingEvents();
if (tm().isOfy()) { if (tm().isOfy()) {
assertEppResourceIndexEntityFor(reloadResourceByForeignKey()); assertEppResourceIndexEntityFor(host);
} }
assertLastHistoryContainsResource(host);
} }
private void doSuccessfulInternalTest(String tld) throws Exception { private void doSuccessfulInternalTest(String tld) throws Exception {

View file

@ -375,6 +375,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
} else { } else {
assertNoDnsTasksEnqueued(); assertNoDnsTasksEnqueued();
} }
assertLastHistoryContainsResource(deletedHost);
assertNoTasksEnqueued(QUEUE_ASYNC_DELETE); assertNoTasksEnqueued(QUEUE_ASYNC_DELETE);
} }

View file

@ -176,6 +176,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.hasOnlyOneHistoryEntryWhich() .hasOnlyOneHistoryEntryWhich()
.hasType(HistoryEntry.Type.HOST_UPDATE); .hasType(HistoryEntry.Type.HOST_UPDATE);
assertNoBillingEvents(); assertNoBillingEvents();
assertLastHistoryContainsResource(renamedHost);
return renamedHost; return renamedHost;
} }

View file

@ -80,10 +80,10 @@ class ChildEntityInputTest {
domainA = persistEppResourceInFirstBucket(newDomainBase("a.tld", contact)); domainA = persistEppResourceInFirstBucket(newDomainBase("a.tld", contact));
domainHistoryEntryA = domainHistoryEntryA =
persistResource( persistResource(
new DomainHistory.Builder().setDomainContent(domainA).setModificationTime(now).build()); new DomainHistory.Builder().setDomain(domainA).setModificationTime(now).build());
contactHistoryEntry = contactHistoryEntry =
persistResource( persistResource(
new ContactHistory.Builder().setContactBase(contact).setModificationTime(now).build()); new ContactHistory.Builder().setContact(contact).setModificationTime(now).build());
oneTimeA = oneTimeA =
persistResource( persistResource(
new BillingEvent.OneTime.Builder() new BillingEvent.OneTime.Builder()
@ -113,7 +113,7 @@ class ChildEntityInputTest {
domainB = persistEppResourceInFirstBucket(newDomainBase("b.tld")); domainB = persistEppResourceInFirstBucket(newDomainBase("b.tld"));
domainHistoryEntryB = domainHistoryEntryB =
persistResource( persistResource(
new DomainHistory.Builder().setDomainContent(domainB).setModificationTime(now).build()); new DomainHistory.Builder().setDomain(domainB).setModificationTime(now).build());
oneTimeB = oneTimeB =
persistResource( persistResource(
new BillingEvent.OneTime.Builder() new BillingEvent.OneTime.Builder()
@ -294,7 +294,7 @@ class ChildEntityInputTest {
historyEntries.add( historyEntries.add(
persistResource( persistResource(
new DomainHistory.Builder() new DomainHistory.Builder()
.setDomainContent(domain) .setDomain(domain)
.setModificationTime(now) .setModificationTime(now)
.setClientId(i + ".tld") .setClientId(i + ".tld")
.build()) .build())

View file

@ -51,6 +51,10 @@ public final class ImmutableObjectSubject extends Subject {
this.actual = actual; this.actual = actual;
} }
public void hasFieldsEqualTo(@Nullable ImmutableObject expected) {
isEqualExceptFields(expected);
}
public void isEqualExceptFields( public void isEqualExceptFields(
@Nullable ImmutableObject expected, Iterable<String> ignoredFields) { @Nullable ImmutableObject expected, Iterable<String> ignoredFields) {
isEqualExceptFields(expected, Iterables.toArray(ignoredFields, String.class)); isEqualExceptFields(expected, Iterables.toArray(ignoredFields, String.class));

View file

@ -77,7 +77,7 @@ public class BillingEventTest extends EntityTestCase {
domainHistory = domainHistory =
persistResource( persistResource(
new DomainHistory.Builder() new DomainHistory.Builder()
.setDomainContent(domain) .setDomain(domain)
.setModificationTime(now) .setModificationTime(now)
.setRequestedByRegistrar(false) .setRequestedByRegistrar(false)
.setType(HistoryEntry.Type.DOMAIN_CREATE) .setType(HistoryEntry.Type.DOMAIN_CREATE)
@ -86,7 +86,7 @@ public class BillingEventTest extends EntityTestCase {
domainHistory2 = domainHistory2 =
persistResource( persistResource(
new DomainHistory.Builder() new DomainHistory.Builder()
.setDomainContent(domain) .setDomain(domain)
.setModificationTime(now.plusDays(1)) .setModificationTime(now.plusDays(1))
.setRequestedByRegistrar(false) .setRequestedByRegistrar(false)
.setType(HistoryEntry.Type.DOMAIN_CREATE) .setType(HistoryEntry.Type.DOMAIN_CREATE)

View file

@ -522,7 +522,7 @@ public class DomainBaseSqlTest {
.setTransferData(transferData) .setTransferData(transferData)
.setGracePeriods(gracePeriods) .setGracePeriods(gracePeriods)
.build(); .build();
historyEntry = historyEntry.asBuilder().setDomainContent(domain).build(); historyEntry = historyEntry.asBuilder().setDomain(domain).build();
jpaTm().insert(historyEntry); jpaTm().insert(historyEntry);
jpaTm().insert(autorenewPollMessage); jpaTm().insert(autorenewPollMessage);
jpaTm().insert(billEvent); jpaTm().insert(billEvent);
@ -661,7 +661,7 @@ public class DomainBaseSqlTest {
.setTransferData(transferData) .setTransferData(transferData)
.setGracePeriods(gracePeriods) .setGracePeriods(gracePeriods)
.build(); .build();
historyEntry = historyEntry.asBuilder().setDomainContent(domain).build(); historyEntry = historyEntry.asBuilder().setDomain(domain).build();
jpaTm().insert(historyEntry); jpaTm().insert(historyEntry);
jpaTm().insert(autorenewPollMessage); jpaTm().insert(autorenewPollMessage);
jpaTm().insert(billEvent); jpaTm().insert(billEvent);

View file

@ -69,7 +69,7 @@ public class ContactHistoryTest extends EntityTestCase {
ContactHistory contactHistory = ContactHistory contactHistory =
createContactHistory(contactFromDb, contact.getRepoId()) createContactHistory(contactFromDb, contact.getRepoId())
.asBuilder() .asBuilder()
.setContactBase(null) .setContact(null)
.build(); .build();
jpaTm().transact(() -> jpaTm().insert(contactHistory)); jpaTm().transact(() -> jpaTm().insert(contactHistory));
@ -116,7 +116,7 @@ public class ContactHistoryTest extends EntityTestCase {
.setBySuperuser(false) .setBySuperuser(false)
.setReason("reason") .setReason("reason")
.setRequestedByRegistrar(true) .setRequestedByRegistrar(true)
.setContactBase(contact) .setContact(contact)
.setContactRepoId(contactRepoId) .setContactRepoId(contactRepoId)
.build(); .build();
} }

View file

@ -86,8 +86,7 @@ public class DomainHistoryTest extends EntityTestCase {
@TestSqlOnly @TestSqlOnly
void testLegacyPersistence_nullResource() { void testLegacyPersistence_nullResource() {
DomainBase domain = addGracePeriodForSql(createDomainWithContactsAndHosts()); DomainBase domain = addGracePeriodForSql(createDomainWithContactsAndHosts());
DomainHistory domainHistory = DomainHistory domainHistory = createDomainHistory(domain).asBuilder().setDomain(null).build();
createDomainHistory(domain).asBuilder().setDomainContent(null).build();
jpaTm().transact(() -> jpaTm().insert(domainHistory)); jpaTm().transact(() -> jpaTm().insert(domainHistory));
jpaTm() jpaTm()
@ -255,7 +254,7 @@ public class DomainHistoryTest extends EntityTestCase {
.setBySuperuser(false) .setBySuperuser(false)
.setReason("reason") .setReason("reason")
.setRequestedByRegistrar(true) .setRequestedByRegistrar(true)
.setDomainContent(domain) .setDomain(domain)
.setDomainRepoId(domain.getRepoId()) .setDomainRepoId(domain.getRepoId())
.setDomainTransactionRecords(ImmutableSet.of(transactionRecord)) .setDomainTransactionRecords(ImmutableSet.of(transactionRecord))
.setOtherClientId("otherClient") .setOtherClientId("otherClient")

View file

@ -67,7 +67,7 @@ public class HostHistoryTest extends EntityTestCase {
HostResource hostFromDb = jpaTm().transact(() -> jpaTm().loadByKey(host.createVKey())); HostResource hostFromDb = jpaTm().transact(() -> jpaTm().loadByKey(host.createVKey()));
HostHistory hostHistory = HostHistory hostHistory =
createHostHistory(hostFromDb, host.getRepoId()).asBuilder().setHostBase(null).build(); createHostHistory(hostFromDb, host.getRepoId()).asBuilder().setHost(null).build();
jpaTm().transact(() -> jpaTm().insert(hostHistory)); jpaTm().transact(() -> jpaTm().insert(hostHistory));
jpaTm() jpaTm()
@ -121,7 +121,7 @@ public class HostHistoryTest extends EntityTestCase {
.setBySuperuser(false) .setBySuperuser(false)
.setReason("reason") .setReason("reason")
.setRequestedByRegistrar(true) .setRequestedByRegistrar(true)
.setHostBase(hostBase) .setHost(hostBase)
.setHostRepoId(hostRepoId) .setHostRepoId(hostRepoId)
.build(); .build();
} }

View file

@ -62,7 +62,7 @@ public class PollMessageExternalKeyConverterTest {
historyEntry = historyEntry =
persistResource( persistResource(
new DomainHistory.Builder() new DomainHistory.Builder()
.setDomainContent(persistActiveDomain("foo.foobar")) .setDomain(persistActiveDomain("foo.foobar"))
.setType(HistoryEntry.Type.DOMAIN_CREATE) .setType(HistoryEntry.Type.DOMAIN_CREATE)
.setPeriod(Period.create(1, Period.Unit.YEARS)) .setPeriod(Period.create(1, Period.Unit.YEARS))
.setXmlBytes("<xml></xml>".getBytes(UTF_8)) .setXmlBytes("<xml></xml>".getBytes(UTF_8))

View file

@ -58,7 +58,7 @@ class HistoryEntryDaoTest extends EntityTestCase {
// Set up a new persisted DomainHistory entity. // Set up a new persisted DomainHistory entity.
domainHistory = domainHistory =
new DomainHistory.Builder() new DomainHistory.Builder()
.setDomainContent(domain) .setDomain(domain)
.setType(HistoryEntry.Type.DOMAIN_CREATE) .setType(HistoryEntry.Type.DOMAIN_CREATE)
.setPeriod(Period.create(1, Period.Unit.YEARS)) .setPeriod(Period.create(1, Period.Unit.YEARS))
.setXmlBytes("<xml></xml>".getBytes(UTF_8)) .setXmlBytes("<xml></xml>".getBytes(UTF_8))

View file

@ -55,7 +55,7 @@ class HistoryEntryTest extends EntityTestCase {
// Set up a new persisted HistoryEntry entity. // Set up a new persisted HistoryEntry entity.
domainHistory = domainHistory =
new DomainHistory.Builder() new DomainHistory.Builder()
.setDomainContent(domain) .setDomain(domain)
.setType(HistoryEntry.Type.DOMAIN_CREATE) .setType(HistoryEntry.Type.DOMAIN_CREATE)
.setPeriod(Period.create(1, Period.Unit.YEARS)) .setPeriod(Period.create(1, Period.Unit.YEARS))
.setXmlBytes("<xml></xml>".getBytes(UTF_8)) .setXmlBytes("<xml></xml>".getBytes(UTF_8))

View file

@ -224,7 +224,7 @@ public class DomainBaseToXjcConverterTest {
new DomainHistory.Builder() new DomainHistory.Builder()
.setModificationTime(clock.nowUtc()) .setModificationTime(clock.nowUtc())
.setType(HistoryEntry.Type.DOMAIN_CREATE) .setType(HistoryEntry.Type.DOMAIN_CREATE)
.setDomainContent(domain) .setDomain(domain)
.build()); .build());
BillingEvent.OneTime billingEvent = BillingEvent.OneTime billingEvent =
persistResource( persistResource(

View file

@ -636,7 +636,7 @@ public class DatabaseHelper {
new DomainHistory.Builder() new DomainHistory.Builder()
.setType(HistoryEntry.Type.DOMAIN_CREATE) .setType(HistoryEntry.Type.DOMAIN_CREATE)
.setModificationTime(now) .setModificationTime(now)
.setDomainContent(domain) .setDomain(domain)
.build()); .build());
BillingEvent.Recurring autorenewEvent = BillingEvent.Recurring autorenewEvent =
persistResource( persistResource(
@ -677,7 +677,7 @@ public class DatabaseHelper {
new DomainHistory.Builder() new DomainHistory.Builder()
.setType(HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST) .setType(HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST)
.setModificationTime(tm().transact(() -> tm().getTransactionTime())) .setModificationTime(tm().transact(() -> tm().getTransactionTime()))
.setDomainContent(domain) .setDomain(domain)
.build()); .build());
BillingEvent.OneTime transferBillingEvent = BillingEvent.OneTime transferBillingEvent =
persistResource( persistResource(

View file

@ -298,7 +298,7 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
new DomainHistory.Builder() new DomainHistory.Builder()
.setModificationTime(fakeClock.nowUtc()) .setModificationTime(fakeClock.nowUtc())
.setType(DOMAIN_CREATE) .setType(DOMAIN_CREATE)
.setDomainContent(domain) .setDomain(domain)
.build()); .build());
BillingEvent.Recurring autorenewBillingEvent = BillingEvent.Recurring autorenewBillingEvent =
persistResource( persistResource(