Populate the contact in ContactHistory objects created in Contact flows (#1111)

* Populate the contact in ContactHistory objects created in Contact flows

Minimal interesting changes here
- a bit of reconstruction in ContactHistory to get the repo ID from the
key
- making the History revision ID Long instead of long so that it can be
null in non-built intermediate entities
- adding a copyFrom(HistoryEntry.Builder) method in HistoryEntry.Builder
so that we don't need to allocate quite as many unnecessary IDs, i.e.
removing the .build() lines in provideContactHistory and
provideDomainHistory
This commit is contained in:
gbrodman
2021-05-06 14:38:55 -04:00
committed by GitHub
parent 5120397607
commit 51a7ba249e
19 changed files with 115 additions and 72 deletions
@@ -193,7 +193,10 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
HistoryEntry historyEntry = Iterables.getLast(DatabaseHelper.getHistoryEntries(resource));
if (resource instanceof ContactBase) {
ContactHistory contactHistory = (ContactHistory) historyEntry;
assertThat(contactHistory.getContactBase().get()).isEqualTo(resource);
// Don't use direct equals comparison since one might be a subclass of the other
assertAboutImmutableObjects()
.that(contactHistory.getContactBase().get())
.isEqualExceptFields(resource);
} else if (resource instanceof DomainContent) {
DomainHistory domainHistory = (DomainHistory) historyEntry;
assertAboutImmutableObjects()
@@ -56,14 +56,13 @@ class ContactCreateFlowTest extends ResourceFlowTestCase<ContactCreateFlow, Cont
assertTransactionalFlow(true);
runFlowAssertResponse(loadFile("contact_create_response.xml"));
// Check that the contact was created and persisted with a history entry.
assertAboutContacts()
.that(reloadResourceByForeignKey())
.hasOnlyOneHistoryEntryWhich()
.hasNoXml();
ContactResource contact = reloadResourceByForeignKey();
assertAboutContacts().that(contact).hasOnlyOneHistoryEntryWhich().hasNoXml();
assertNoBillingEvents();
if (tm().isOfy()) {
assertEppResourceIndexEntityFor(reloadResourceByForeignKey());
assertEppResourceIndexEntityFor(contact);
}
assertLastHistoryContainsResource(contact);
}
@TestOfyAndSql
@@ -78,6 +78,7 @@ class ContactDeleteFlowTest extends ResourceFlowTestCase<ContactDeleteFlow, Cont
.hasOnlyOneHistoryEntryWhich()
.hasType(HistoryEntry.Type.CONTACT_PENDING_DELETE);
assertNoBillingEvents();
assertLastHistoryContainsResource(deletedContact);
}
@TestOfyAndSql
@@ -120,6 +120,7 @@ class ContactTransferApproveFlowTest
assertThat(panData.getTrid())
.isEqualTo(Trid.create("transferClient-trid", "transferServer-trid"));
assertThat(panData.getActionResult()).isTrue();
assertLastHistoryContainsResource(contact);
}
private void doFailingTest(String commandFilename) throws Exception {
@@ -104,6 +104,7 @@ class ContactTransferCancelFlowTest
.collect(onlyElement())
.getTransferStatus())
.isEqualTo(TransferStatus.CLIENT_CANCELLED);
assertLastHistoryContainsResource(contact);
}
private void doFailingTest(String commandFilename) throws Exception {
@@ -119,6 +119,7 @@ class ContactTransferRejectFlowTest
.isEqualTo(Trid.create("transferClient-trid", "transferServer-trid"));
assertThat(panData.getActionResult()).isFalse();
assertNoBillingEvents();
assertLastHistoryContainsResource(contact);
}
private void doFailingTest(String commandFilename) throws Exception {
@@ -137,6 +137,7 @@ class ContactTransferRequestFlowTest
Iterables.filter(
loadByKeys(contact.getTransferData().getServerApproveEntities()), PollMessage.class),
ImmutableList.of(gainingApproveMessage, losingApproveMessage));
assertLastHistoryContainsResource(contact);
}
private void doFailingTest(String commandFilename) throws Exception {
@@ -64,12 +64,16 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
clock.advanceOneMilli();
assertTransactionalFlow(true);
runFlowAssertResponse(loadFile("generic_success_response.xml"));
ContactResource contact = reloadResourceByForeignKey();
// Check that the contact was updated. This value came from the xml.
assertAboutContacts().that(reloadResourceByForeignKey())
.hasAuthInfoPwd("2fooBAR").and()
assertAboutContacts()
.that(contact)
.hasAuthInfoPwd("2fooBAR")
.and()
.hasOnlyOneHistoryEntryWhich()
.hasNoXml();
assertNoBillingEvents();
assertLastHistoryContainsResource(contact);
}
@TestOfyAndSql