diff --git a/core/src/main/java/google/registry/model/poll/PollMessage.java b/core/src/main/java/google/registry/model/poll/PollMessage.java index d8232f756..ffa08cdb0 100644 --- a/core/src/main/java/google/registry/model/poll/PollMessage.java +++ b/core/src/main/java/google/registry/model/poll/PollMessage.java @@ -354,6 +354,10 @@ public abstract class PollMessage extends ImmutableObject @Column(name = "transfer_response_contact_id") String contactId; + @Ignore + @Column(name = "transfer_response_host_id") + String hostId; + @Override public VKey createVKey() { return VKey.create(OneTime.class, getId(), Key.create(this)); @@ -393,6 +397,9 @@ public abstract class PollMessage extends ImmutableObject if (!isNullOrEmpty(contactPendingActionNotificationResponses)) { pendingActionNotificationResponse = contactPendingActionNotificationResponses.get(0); } + if (!isNullOrEmpty(hostPendingActionNotificationResponses)) { + pendingActionNotificationResponse = hostPendingActionNotificationResponses.get(0); + } if (!isNullOrEmpty(contactTransferResponses)) { contactId = contactTransferResponses.get(0).getContactId(); transferResponse = contactTransferResponses.get(0); @@ -433,6 +440,16 @@ public abstract class PollMessage extends ImmutableObject pendingActionNotificationResponse.processedDate); pendingActionNotificationResponse = domainPendingResponse; domainPendingActionNotificationResponses = ImmutableList.of(domainPendingResponse); + } else if (hostId != null) { + HostPendingActionNotificationResponse hostPendingActionNotificationResponse = + HostPendingActionNotificationResponse.create( + pendingActionNotificationResponse.nameOrId.value, + pendingActionNotificationResponse.getActionResult(), + pendingActionNotificationResponse.getTrid(), + pendingActionNotificationResponse.processedDate); + pendingActionNotificationResponse = hostPendingActionNotificationResponse; + hostPendingActionNotificationResponses = + ImmutableList.of(hostPendingActionNotificationResponse); } } if (transferResponse != null) { @@ -527,6 +544,7 @@ public abstract class PollMessage extends ImmutableObject } else if (instance.hostPendingActionNotificationResponses != null) { instance.pendingActionNotificationResponse = instance.hostPendingActionNotificationResponses.get(0); + instance.hostId = instance.hostPendingActionNotificationResponses.get(0).nameOrId.value; } // Set the generic transfer response field as appropriate if (instance.contactTransferResponses != null) { diff --git a/core/src/test/java/google/registry/model/poll/PollMessageTest.java b/core/src/test/java/google/registry/model/poll/PollMessageTest.java index db44ea26e..04f7cd00f 100644 --- a/core/src/test/java/google/registry/model/poll/PollMessageTest.java +++ b/core/src/test/java/google/registry/model/poll/PollMessageTest.java @@ -24,12 +24,14 @@ import static google.registry.testing.DatabaseHelper.persistActiveContact; import static google.registry.testing.DatabaseHelper.persistResource; import static java.nio.charset.StandardCharsets.UTF_8; +import com.google.common.collect.ImmutableList; import google.registry.model.EntityTestCase; import google.registry.model.contact.ContactResource; import google.registry.model.domain.DomainBase; import google.registry.model.domain.DomainHistory; import google.registry.model.domain.Period; import google.registry.model.eppcommon.Trid; +import google.registry.model.poll.PendingActionNotificationResponse.HostPendingActionNotificationResponse; import google.registry.model.reporting.HistoryEntry; import google.registry.persistence.VKey; import google.registry.testing.DualDatabaseTest; @@ -119,6 +121,32 @@ public class PollMessageTest extends EntityTestCase { assertThat(tm().transact(() -> tm().loadByEntity(pollMessage))).isEqualTo(pollMessage); } + @TestOfyAndSql + void testPersistenceOneTime_hostPendingActionNotification() { + HostPendingActionNotificationResponse hostPendingActionNotificationResponse = + HostPendingActionNotificationResponse.create( + "test.example", + true, + Trid.create("ABC-123", "server-trid"), + fakeClock.nowUtc().minusDays(5)); + + PollMessage.OneTime pollMessage = + new PollMessage.OneTime.Builder() + .setRegistrarId("TheRegistrar") + .setEventTime(fakeClock.nowUtc()) + .setMsg("Test poll message") + .setParent(historyEntry) + .setResponseData(ImmutableList.of(hostPendingActionNotificationResponse)) + .build(); + persistResource(pollMessage); + assertThat(tm().transact(() -> tm().loadByEntity(pollMessage).getMsg())) + .isEqualTo(pollMessage.msg); + assertThat( + tm().transact(() -> tm().loadByEntity(pollMessage)) + .hostPendingActionNotificationResponses) + .contains(hostPendingActionNotificationResponse); + } + @TestSqlOnly void testSerializableOneTime() { PollMessage.OneTime pollMessage = diff --git a/db/src/main/resources/sql/er_diagram/brief_er_diagram.html b/db/src/main/resources/sql/er_diagram/brief_er_diagram.html index 898429879..a6eeff2f0 100644 --- a/db/src/main/resources/sql/er_diagram/brief_er_diagram.html +++ b/db/src/main/resources/sql/er_diagram/brief_er_diagram.html @@ -261,11 +261,19 @@ td.section { generated on +<<<<<<< HEAD 2021-11-23 20:43:41.968049 last flyway file V104__add_transfer_response_host_id_to_poll_message.sql +======= + 2021-11-17 21:23:12.62481 + + + last flyway file + V103__add_transfer_response_host_id_to_poll_message.sql +>>>>>>> 19aa29939 (Fix missing hostPendingActionNotificationResponses in PollMessage.OneTime) @@ -274,19 +282,24 @@ td.section { SchemaCrawler_Diagram - + generated by - + SchemaCrawler 16.10.1 - + generated on +<<<<<<< HEAD 2021-11-23 20:43:41.968049 +======= + + 2021-11-17 21:23:12.62481 +>>>>>>> 19aa29939 (Fix missing hostPendingActionNotificationResponses in PollMessage.OneTime) - + allocationtoken_a08ccbef diff --git a/db/src/main/resources/sql/er_diagram/full_er_diagram.html b/db/src/main/resources/sql/er_diagram/full_er_diagram.html index 681afebca..f12faddb3 100644 --- a/db/src/main/resources/sql/er_diagram/full_er_diagram.html +++ b/db/src/main/resources/sql/er_diagram/full_er_diagram.html @@ -261,11 +261,19 @@ td.section {
generated on +<<<<<<< HEAD 2021-11-23 20:43:39.672931
last flyway file V104__add_transfer_response_host_id_to_poll_message.sql +======= + 2021-11-17 21:23:10.198048 +
+
+ last flyway file + V103__add_transfer_response_host_id_to_poll_message.sql +>>>>>>> 19aa29939 (Fix missing hostPendingActionNotificationResponses in PollMessage.OneTime)
@@ -284,7 +292,11 @@ td.section { generated on
+<<<<<<< HEAD 2021-11-23 20:43:39.672931 +======= + 2021-11-17 21:23:10.198048 +>>>>>>> 19aa29939 (Fix missing hostPendingActionNotificationResponses in PollMessage.OneTime) diff --git a/db/src/main/resources/sql/schema/db-schema.sql.generated b/db/src/main/resources/sql/schema/db-schema.sql.generated index 8d22e2874..719851f22 100644 --- a/db/src/main/resources/sql/schema/db-schema.sql.generated +++ b/db/src/main/resources/sql/schema/db-schema.sql.generated @@ -523,6 +523,7 @@ transfer_response_contact_id text, transfer_response_domain_expiration_time timestamptz, transfer_response_domain_name text, + transfer_response_host_id text, pending_action_response_action_result boolean, pending_action_response_name_or_id text, pending_action_response_processed_date timestamptz,