mirror of
https://github.com/google/nomulus.git
synced 2025-07-19 17:26:09 +02:00
Fix missing hostPendingActionNotificationResponses in PollMessage.OneTime (#1426)
This commit is contained in:
parent
18d051ef87
commit
cff8f9a1cd
5 changed files with 76 additions and 4 deletions
|
@ -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<OneTime> 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) {
|
||||
|
|
|
@ -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 =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue