mirror of
https://github.com/google/nomulus.git
synced 2025-07-08 12:13:19 +02:00
Use ReplaySpecializer to fix DomainBase replays (#991)
* Use ReplaySpecializer to fix DomainBase replays DomainBase currently has a number of ancillary objects that require a cascading delete that doesn't get propagated. Implement beforeSqlDelete() in DomainContent to delete these child entities. * Remove unnecessary Query variable * Fix rebase error
This commit is contained in:
parent
79b4cb0d82
commit
7b673c90db
8 changed files with 85 additions and 19 deletions
|
@ -25,6 +25,7 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.
|
|||
import static google.registry.testing.DatabaseHelper.assertBillingEventsForResource;
|
||||
import static google.registry.testing.DatabaseHelper.createTld;
|
||||
import static google.registry.testing.DatabaseHelper.deleteResource;
|
||||
import static google.registry.testing.DatabaseHelper.getBillingEvents;
|
||||
import static google.registry.testing.DatabaseHelper.getOnlyHistoryEntryOfType;
|
||||
import static google.registry.testing.DatabaseHelper.getOnlyPollMessage;
|
||||
import static google.registry.testing.DatabaseHelper.getPollMessages;
|
||||
|
@ -71,18 +72,25 @@ import google.registry.model.transfer.DomainTransferData;
|
|||
import google.registry.model.transfer.TransferResponse.DomainTransferResponse;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.testing.ReplayExtension;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Stream;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link DomainTransferApproveFlow}. */
|
||||
class DomainTransferApproveFlowTest
|
||||
extends DomainTransferFlowTestCase<DomainTransferApproveFlow, DomainBase> {
|
||||
|
||||
@Order(value = Order.DEFAULT - 2)
|
||||
@RegisterExtension
|
||||
final ReplayExtension replayExtension = ReplayExtension.createWithCompare(clock);
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
setEppInput("domain_transfer_approve.xml");
|
||||
|
@ -521,7 +529,24 @@ class DomainTransferApproveFlowTest
|
|||
|
||||
@Test
|
||||
void testFailure_nonexistentDomain() throws Exception {
|
||||
deleteResource(domain);
|
||||
Iterable<BillingEvent> billingEvents = getBillingEvents();
|
||||
Iterable<HistoryEntry> historyEntries = tm().loadAllOf(HistoryEntry.class);
|
||||
Iterable<PollMessage> pollMessages = tm().loadAllOf(PollMessage.class);
|
||||
tm().transact(
|
||||
() -> {
|
||||
deleteResource(domain);
|
||||
for (BillingEvent event : billingEvents) {
|
||||
deleteResource(event);
|
||||
}
|
||||
for (PollMessage pollMessage : pollMessages) {
|
||||
deleteResource(pollMessage);
|
||||
}
|
||||
deleteResource(subordinateHost);
|
||||
for (HistoryEntry hist : historyEntries) {
|
||||
deleteResource(hist);
|
||||
}
|
||||
});
|
||||
|
||||
ResourceDoesNotExistException thrown =
|
||||
assertThrows(
|
||||
ResourceDoesNotExistException.class,
|
||||
|
|
|
@ -766,7 +766,7 @@ public class DatabaseHelper {
|
|||
return newRegistrars.build();
|
||||
}
|
||||
|
||||
private static Iterable<BillingEvent> getBillingEvents() {
|
||||
public static Iterable<BillingEvent> getBillingEvents() {
|
||||
return transactIfJpaTm(
|
||||
() ->
|
||||
Iterables.concat(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue