mirror of
https://github.com/google/nomulus.git
synced 2025-06-11 15:04:46 +02:00
Add remaining columns to Domain's SQL schema (#702)
This commit is contained in:
parent
8d78c37ede
commit
33c20a6017
29 changed files with 239 additions and 199 deletions
|
@ -22,6 +22,7 @@ import static com.google.common.truth.Truth.assertThat;
|
|||
import static com.google.common.truth.Truth.assertWithMessage;
|
||||
import static google.registry.model.eppcommon.EppXmlTransformer.marshal;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatastoreHelper.POLL_MESSAGE_ID_STRIPPER;
|
||||
import static google.registry.testing.DatastoreHelper.getPollMessages;
|
||||
import static google.registry.testing.DatastoreHelper.stripBillingEventId;
|
||||
|
@ -196,12 +197,9 @@ public abstract class FlowTestCase<F extends Flow> {
|
|||
assertWithMessage("Billing event is present for grace period: " + gracePeriod)
|
||||
.that(gracePeriod.hasBillingEvent())
|
||||
.isTrue();
|
||||
return ofy()
|
||||
.load()
|
||||
.key(
|
||||
return tm().load(
|
||||
firstNonNull(
|
||||
gracePeriod.getOneTimeBillingEvent(), gracePeriod.getRecurringBillingEvent()))
|
||||
.now();
|
||||
gracePeriod.getOneTimeBillingEvent(), gracePeriod.getRecurringBillingEvent()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -31,6 +31,7 @@ import static google.registry.model.registry.Registry.TldState.GENERAL_AVAILABIL
|
|||
import static google.registry.model.registry.Registry.TldState.PREDELEGATION;
|
||||
import static google.registry.model.registry.Registry.TldState.QUIET_PERIOD;
|
||||
import static google.registry.model.registry.Registry.TldState.START_DATE_SUNRISE;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.pricing.PricingEngineProxy.isDomainPremium;
|
||||
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
||||
import static google.registry.testing.DatastoreHelper.assertPollMessagesForResource;
|
||||
|
@ -257,8 +258,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
|
|||
HistoryEntry historyEntry = getHistoryEntries(domain).get(0);
|
||||
assertAboutDomains()
|
||||
.that(domain)
|
||||
.hasRegistrationExpirationTime(
|
||||
ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime())
|
||||
.hasRegistrationExpirationTime(tm().load(domain.getAutorenewBillingEvent()).getEventTime())
|
||||
.and()
|
||||
.hasOnlyOneHistoryEntryWhich()
|
||||
.hasType(HistoryEntry.Type.DOMAIN_CREATE)
|
||||
|
|
|
@ -34,6 +34,7 @@ import static google.registry.model.reporting.DomainTransactionRecord.Transactio
|
|||
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_CREATE;
|
||||
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_DELETE;
|
||||
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
|
||||
|
@ -139,8 +140,8 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
|||
persistResource(
|
||||
domain
|
||||
.asBuilder()
|
||||
.setAutorenewBillingEvent(Key.create(autorenewBillingEvent))
|
||||
.setAutorenewPollMessage(Key.create(autorenewPollMessage))
|
||||
.setAutorenewBillingEvent(autorenewBillingEvent.createVKey())
|
||||
.setAutorenewPollMessage(autorenewPollMessage.createVKey())
|
||||
.build());
|
||||
assertTransactionalFlow(true);
|
||||
}
|
||||
|
@ -196,9 +197,9 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
|||
GracePeriodStatus.AUTO_RENEW,
|
||||
A_MONTH_AGO.plusDays(45),
|
||||
"TheRegistrar",
|
||||
Key.create(autorenewBillingEvent))))
|
||||
.setAutorenewBillingEvent(Key.create(autorenewBillingEvent))
|
||||
.setAutorenewPollMessage(Key.create(autorenewPollMessage))
|
||||
autorenewBillingEvent.createVKey())))
|
||||
.setAutorenewBillingEvent(autorenewBillingEvent.createVKey())
|
||||
.setAutorenewPollMessage(autorenewPollMessage.createVKey())
|
||||
.build());
|
||||
assertTransactionalFlow(true);
|
||||
}
|
||||
|
@ -436,9 +437,9 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
|||
DateTime deletionTime = domain.getDeletionTime();
|
||||
assertThat(getPollMessages("TheRegistrar", deletionTime.minusMinutes(1))).isEmpty();
|
||||
assertThat(getPollMessages("TheRegistrar", deletionTime)).hasSize(1);
|
||||
assertThat(domain.getDeletePollMessage())
|
||||
.isEqualTo(Key.create(getOnlyPollMessage("TheRegistrar")));
|
||||
PollMessage.OneTime deletePollMessage = ofy().load().key(domain.getDeletePollMessage()).now();
|
||||
assertThat(domain.getDeletePollMessage().getOfyKey())
|
||||
.isEqualTo(getOnlyPollMessage("TheRegistrar").createVKey().getOfyKey());
|
||||
PollMessage.OneTime deletePollMessage = tm().load(domain.getDeletePollMessage());
|
||||
assertThat(deletePollMessage.getMsg()).isEqualTo(expectedMessage);
|
||||
}
|
||||
|
||||
|
@ -472,10 +473,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
|
|||
// Modify the autorenew poll message so that it has unacked messages in the past. This should
|
||||
// prevent it from being deleted when the domain is deleted.
|
||||
persistResource(
|
||||
ofy()
|
||||
.load()
|
||||
.key(reloadResourceByForeignKey().getAutorenewPollMessage())
|
||||
.now()
|
||||
tm().load(reloadResourceByForeignKey().getAutorenewPollMessage())
|
||||
.asBuilder()
|
||||
.setEventTime(A_MONTH_FROM_NOW.minusYears(3))
|
||||
.build());
|
||||
|
|
|
@ -44,6 +44,7 @@ import google.registry.flows.domain.DomainFlowUtils.CurrencyUnitMismatchExceptio
|
|||
import google.registry.flows.domain.DomainFlowUtils.FeeChecksDontSupportPhasesException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.RestoresAreAlwaysForOneYearException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.TransfersAreAlwaysForOneYearException;
|
||||
import google.registry.model.billing.BillingEvent;
|
||||
import google.registry.model.billing.BillingEvent.Recurring;
|
||||
import google.registry.model.contact.ContactAuthInfo;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
|
@ -59,6 +60,8 @@ import google.registry.model.eppcommon.StatusValue;
|
|||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.ofy.RequestCapturingAsyncDatastoreService;
|
||||
import google.registry.model.registry.Registry;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
@ -324,16 +327,17 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
|
|||
@Test
|
||||
void testSuccess_autoRenewGracePeriod() throws Exception {
|
||||
persistTestEntities(false);
|
||||
Key<HistoryEntry> historyEntry =
|
||||
Key.create(domain.createVKey().getOfyKey(), HistoryEntry.class, 67890);
|
||||
VKey<BillingEvent.Recurring> recurringVKey =
|
||||
VKey.from(Key.create(historyEntry, Recurring.class, 12345));
|
||||
// Add an AUTO_RENEW grace period to the saved resource.
|
||||
persistResource(
|
||||
domain
|
||||
.asBuilder()
|
||||
.addGracePeriod(
|
||||
GracePeriod.createForRecurring(
|
||||
GracePeriodStatus.AUTO_RENEW,
|
||||
clock.nowUtc().plusDays(1),
|
||||
"foo",
|
||||
Key.create(Recurring.class, 12345)))
|
||||
GracePeriodStatus.AUTO_RENEW, clock.nowUtc().plusDays(1), "foo", recurringVKey))
|
||||
.build());
|
||||
doSuccessfulTest("domain_info_response_autorenewperiod.xml", false);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ package google.registry.flows.domain;
|
|||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.flows.domain.DomainTransferFlowTestCase.persistWithPendingTransfer;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
|
||||
|
@ -38,7 +38,6 @@ import static org.junit.Assert.assertThrows;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.FlowUtils.UnknownCurrencyEppException;
|
||||
import google.registry.flows.ResourceFlowTestCase;
|
||||
|
@ -137,8 +136,8 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
|||
.asBuilder()
|
||||
.setRegistrationExpirationTime(expirationTime)
|
||||
.setStatusValues(ImmutableSet.copyOf(statusValues))
|
||||
.setAutorenewBillingEvent(Key.create(autorenewEvent))
|
||||
.setAutorenewPollMessage(Key.create(autorenewPollMessage))
|
||||
.setAutorenewBillingEvent(autorenewEvent.createVKey())
|
||||
.setAutorenewPollMessage(autorenewPollMessage.createVKey())
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
}
|
||||
|
@ -175,7 +174,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
|||
DomainBase domain = reloadResourceByForeignKey();
|
||||
HistoryEntry historyEntryDomainRenew =
|
||||
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RENEW);
|
||||
assertThat(ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime())
|
||||
assertThat(tm().load(domain.getAutorenewBillingEvent()).getEventTime())
|
||||
.isEqualTo(newExpiration);
|
||||
assertAboutDomains()
|
||||
.that(domain)
|
||||
|
@ -470,10 +469,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
|
|||
persistDomain();
|
||||
// Modify the autorenew poll message so that it has an undelivered message in the past.
|
||||
persistResource(
|
||||
ofy()
|
||||
.load()
|
||||
.key(reloadResourceByForeignKey().getAutorenewPollMessage())
|
||||
.now()
|
||||
tm().load(reloadResourceByForeignKey().getAutorenewPollMessage())
|
||||
.asBuilder()
|
||||
.setEventTime(expirationTime.minusYears(1))
|
||||
.build());
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
package google.registry.flows.domain;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
|
||||
|
@ -38,7 +38,6 @@ import static org.junit.Assert.assertThrows;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.EppException.UnimplementedExtensionException;
|
||||
import google.registry.flows.FlowUtils.UnknownCurrencyEppException;
|
||||
|
@ -116,13 +115,13 @@ class DomainRestoreRequestFlowTest
|
|||
GracePeriodStatus.REDEMPTION, clock.nowUtc().plusDays(1), "foo", null))
|
||||
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
|
||||
.setDeletePollMessage(
|
||||
Key.create(
|
||||
persistResource(
|
||||
persistResource(
|
||||
new PollMessage.OneTime.Builder()
|
||||
.setClientId("TheRegistrar")
|
||||
.setEventTime(clock.nowUtc().plusDays(5))
|
||||
.setParent(historyEntry)
|
||||
.build())))
|
||||
.build())
|
||||
.createVKey())
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
}
|
||||
|
@ -146,7 +145,7 @@ class DomainRestoreRequestFlowTest
|
|||
DomainBase domain = reloadResourceByForeignKey();
|
||||
HistoryEntry historyEntryDomainRestore =
|
||||
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RESTORE);
|
||||
assertThat(ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime())
|
||||
assertThat(tm().load(domain.getAutorenewBillingEvent()).getEventTime())
|
||||
.isEqualTo(expirationTime);
|
||||
assertAboutDomains()
|
||||
.that(domain)
|
||||
|
@ -214,7 +213,7 @@ class DomainRestoreRequestFlowTest
|
|||
DomainBase domain = reloadResourceByForeignKey();
|
||||
HistoryEntry historyEntryDomainRestore =
|
||||
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RESTORE);
|
||||
assertThat(ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime())
|
||||
assertThat(tm().load(domain.getAutorenewBillingEvent()).getEventTime())
|
||||
.isEqualTo(newExpirationTime);
|
||||
assertAboutDomains()
|
||||
.that(domain)
|
||||
|
|
|
@ -16,12 +16,12 @@ package google.registry.flows.domain;
|
|||
|
||||
import static com.google.common.collect.MoreCollectors.onlyElement;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.NET_ADDS_4_YR;
|
||||
import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.TRANSFER_SUCCESSFUL;
|
||||
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_CREATE;
|
||||
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_TRANSFER_APPROVE;
|
||||
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatastoreHelper.assertBillingEventsForResource;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.deleteResource;
|
||||
|
@ -42,7 +42,6 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.flows.EppException;
|
||||
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
|
||||
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
||||
|
@ -192,7 +191,7 @@ class DomainTransferApproveFlowTest
|
|||
assertAboutHistoryEntries().that(historyEntryTransferApproved).hasOtherClientId("NewRegistrar");
|
||||
assertTransferApproved(domain, originalTransferData);
|
||||
assertAboutDomains().that(domain).hasRegistrationExpirationTime(expectedExpirationTime);
|
||||
assertThat(ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime())
|
||||
assertThat(tm().load(domain.getAutorenewBillingEvent()).getEventTime())
|
||||
.isEqualTo(expectedExpirationTime);
|
||||
// The poll message (in the future) to the losing registrar for implicit ack should be gone.
|
||||
assertThat(getPollMessages(domain, "TheRegistrar", clock.nowUtc().plusMonths(1))).isEmpty();
|
||||
|
@ -403,7 +402,7 @@ class DomainTransferApproveFlowTest
|
|||
.setEventTime(clock.nowUtc()) // The cancellation happens at the moment of transfer.
|
||||
.setBillingTime(
|
||||
oldExpirationTime.plus(Registry.get("tld").getAutoRenewGracePeriodLength()))
|
||||
.setRecurringEventKey(VKey.from(domain.getAutorenewBillingEvent())));
|
||||
.setRecurringEventKey(domain.getAutorenewBillingEvent()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -634,7 +633,7 @@ class DomainTransferApproveFlowTest
|
|||
@Test
|
||||
void testSuccess_superuserExtension_transferPeriodZero_autorenewGraceActive() throws Exception {
|
||||
DomainBase domain = reloadResourceByForeignKey();
|
||||
Key<Recurring> existingAutorenewEvent = domain.getAutorenewBillingEvent();
|
||||
VKey<Recurring> existingAutorenewEvent = domain.getAutorenewBillingEvent();
|
||||
// Set domain to have auto-renewed just before the transfer request, so that it will have an
|
||||
// active autorenew grace period spanning the entire transfer window.
|
||||
DateTime autorenewTime = clock.nowUtc().minusDays(1);
|
||||
|
|
|
@ -318,8 +318,7 @@ class DomainTransferRequestFlowTest
|
|||
BillingEvent.class),
|
||||
Sets.union(expectedServeApproveBillingEvents, extraBillingEvents));
|
||||
// The domain's autorenew billing event should still point to the losing client's event.
|
||||
BillingEvent.Recurring domainAutorenewEvent =
|
||||
ofy().load().key(domain.getAutorenewBillingEvent()).now();
|
||||
BillingEvent.Recurring domainAutorenewEvent = tm().load(domain.getAutorenewBillingEvent());
|
||||
assertThat(domainAutorenewEvent.getClientId()).isEqualTo("TheRegistrar");
|
||||
assertThat(domainAutorenewEvent.getRecurrenceEndTime()).isEqualTo(implicitTransferTime);
|
||||
// The original grace periods should remain untouched.
|
||||
|
@ -446,12 +445,7 @@ class DomainTransferRequestFlowTest
|
|||
.hasLastEppUpdateTime(implicitTransferTime)
|
||||
.and()
|
||||
.hasLastEppUpdateClientId("NewRegistrar");
|
||||
assertThat(
|
||||
ofy()
|
||||
.load()
|
||||
.key(domainAfterAutomaticTransfer.getAutorenewBillingEvent())
|
||||
.now()
|
||||
.getEventTime())
|
||||
assertThat(tm().load(domainAfterAutomaticTransfer.getAutorenewBillingEvent()).getEventTime())
|
||||
.isEqualTo(expectedExpirationTime);
|
||||
// And after the expected grace time, the grace period should be gone.
|
||||
DomainBase afterGracePeriod =
|
||||
|
@ -955,7 +949,7 @@ class DomainTransferRequestFlowTest
|
|||
void testSuccess_superuserExtension_zeroPeriod_autorenewGraceActive() throws Exception {
|
||||
eppRequestSource = EppRequestSource.TOOL;
|
||||
setupDomain("example", "tld");
|
||||
Key<BillingEvent.Recurring> existingAutorenewEvent = domain.getAutorenewBillingEvent();
|
||||
VKey<BillingEvent.Recurring> existingAutorenewEvent = domain.getAutorenewBillingEvent();
|
||||
// Set domain to have auto-renewed just before the transfer request, so that it will have an
|
||||
// active autorenew grace period spanning the entire transfer window.
|
||||
DateTime autorenewTime = clock.nowUtc().minusDays(1);
|
||||
|
@ -1110,7 +1104,7 @@ class DomainTransferRequestFlowTest
|
|||
@Test
|
||||
void testSuccess_autorenewGraceActive_throughoutTransferWindow() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
Key<BillingEvent.Recurring> existingAutorenewEvent = domain.getAutorenewBillingEvent();
|
||||
VKey<BillingEvent.Recurring> existingAutorenewEvent = domain.getAutorenewBillingEvent();
|
||||
// Set domain to have auto-renewed just before the transfer request, so that it will have an
|
||||
// active autorenew grace period spanning the entire transfer window.
|
||||
DateTime autorenewTime = clock.nowUtc().minusDays(1);
|
||||
|
@ -1142,13 +1136,13 @@ class DomainTransferRequestFlowTest
|
|||
.setEventTime(clock.nowUtc().plus(Registry.get("tld").getAutomaticTransferLength()))
|
||||
.setBillingTime(autorenewTime.plus(Registry.get("tld").getAutoRenewGracePeriodLength()))
|
||||
// The cancellation should refer to the old autorenew billing event.
|
||||
.setRecurringEventKey(VKey.from(existingAutorenewEvent)));
|
||||
.setRecurringEventKey(existingAutorenewEvent));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_autorenewGraceActive_onlyAtAutomaticTransferTime() throws Exception {
|
||||
setupDomain("example", "tld");
|
||||
Key<BillingEvent.Recurring> existingAutorenewEvent = domain.getAutorenewBillingEvent();
|
||||
VKey<BillingEvent.Recurring> existingAutorenewEvent = domain.getAutorenewBillingEvent();
|
||||
// Set domain to expire in 1 day, so that it will be in the autorenew grace period by the
|
||||
// automatic transfer time, even though it isn't yet.
|
||||
DateTime expirationTime = clock.nowUtc().plusDays(1);
|
||||
|
@ -1170,7 +1164,7 @@ class DomainTransferRequestFlowTest
|
|||
.setBillingTime(
|
||||
expirationTime.plus(Registry.get("tld").getAutoRenewGracePeriodLength()))
|
||||
// The cancellation should refer to the old autorenew billing event.
|
||||
.setRecurringEventKey(VKey.from(existingAutorenewEvent)));
|
||||
.setRecurringEventKey(existingAutorenewEvent));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -396,14 +396,15 @@ public class BillingEventTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
void testSuccess_cancellation_forGracePeriod_withRecurring() {
|
||||
BillingEvent.Cancellation newCancellation = BillingEvent.Cancellation.forGracePeriod(
|
||||
GracePeriod.createForRecurring(
|
||||
GracePeriodStatus.AUTO_RENEW,
|
||||
now.plusYears(1).plusDays(45),
|
||||
"a registrar",
|
||||
Key.create(recurring)),
|
||||
historyEntry2,
|
||||
"foo.tld");
|
||||
BillingEvent.Cancellation newCancellation =
|
||||
BillingEvent.Cancellation.forGracePeriod(
|
||||
GracePeriod.createForRecurring(
|
||||
GracePeriodStatus.AUTO_RENEW,
|
||||
now.plusYears(1).plusDays(45),
|
||||
"a registrar",
|
||||
recurring.createVKey()),
|
||||
historyEntry2,
|
||||
"foo.tld");
|
||||
// Set ID to be the same to ignore for the purposes of comparison.
|
||||
newCancellation = newCancellation.asBuilder().setId(cancellationRecurring.getId()).build();
|
||||
assertThat(newCancellation).isEqualTo(cancellationRecurring);
|
||||
|
|
|
@ -64,19 +64,19 @@ import org.junit.jupiter.api.Test;
|
|||
public class DomainBaseTest extends EntityTestCase {
|
||||
|
||||
private DomainBase domain;
|
||||
private Key<BillingEvent.OneTime> oneTimeBillKey;
|
||||
private Key<BillingEvent.Recurring> recurringBillKey;
|
||||
private Key<DomainBase> domainKey;
|
||||
private VKey<BillingEvent.OneTime> oneTimeBillKey;
|
||||
private VKey<BillingEvent.Recurring> recurringBillKey;
|
||||
private VKey<DomainBase> domainKey;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
createTld("com");
|
||||
domainKey = Key.create(null, DomainBase.class, "4-COM");
|
||||
domainKey = VKey.from(Key.create(null, DomainBase.class, "4-COM"));
|
||||
VKey<HostResource> hostKey =
|
||||
persistResource(
|
||||
new HostResource.Builder()
|
||||
.setHostName("ns1.example.com")
|
||||
.setSuperordinateDomain(VKey.from(domainKey))
|
||||
.setSuperordinateDomain(domainKey)
|
||||
.setRepoId("1-COM")
|
||||
.build())
|
||||
.createVKey();
|
||||
|
@ -95,13 +95,14 @@ public class DomainBaseTest extends EntityTestCase {
|
|||
.build())
|
||||
.createVKey();
|
||||
Key<HistoryEntry> historyEntryKey =
|
||||
Key.create(persistResource(new HistoryEntry.Builder().setParent(domainKey).build()));
|
||||
oneTimeBillKey = Key.create(historyEntryKey, BillingEvent.OneTime.class, 1);
|
||||
recurringBillKey = Key.create(historyEntryKey, BillingEvent.Recurring.class, 2);
|
||||
Key<PollMessage.Autorenew> autorenewPollKey =
|
||||
Key.create(historyEntryKey, PollMessage.Autorenew.class, 3);
|
||||
Key<PollMessage.OneTime> onetimePollKey =
|
||||
Key.create(historyEntryKey, PollMessage.OneTime.class, 1);
|
||||
Key.create(
|
||||
persistResource(new HistoryEntry.Builder().setParent(domainKey.getOfyKey()).build()));
|
||||
oneTimeBillKey = VKey.from(Key.create(historyEntryKey, BillingEvent.OneTime.class, 1));
|
||||
recurringBillKey = VKey.from(Key.create(historyEntryKey, BillingEvent.Recurring.class, 2));
|
||||
VKey<PollMessage.Autorenew> autorenewPollKey =
|
||||
VKey.from(Key.create(historyEntryKey, PollMessage.Autorenew.class, 3));
|
||||
VKey<PollMessage.OneTime> onetimePollKey =
|
||||
VKey.from(Key.create(historyEntryKey, PollMessage.OneTime.class, 1));
|
||||
// Set up a new persisted domain entity.
|
||||
domain =
|
||||
persistResource(
|
||||
|
@ -138,13 +139,10 @@ public class DomainBaseTest extends EntityTestCase {
|
|||
.setLosingClientId("losing")
|
||||
.setPendingTransferExpirationTime(fakeClock.nowUtc())
|
||||
.setServerApproveEntities(
|
||||
ImmutableSet.of(
|
||||
VKey.from(oneTimeBillKey),
|
||||
VKey.from(recurringBillKey),
|
||||
VKey.from(autorenewPollKey)))
|
||||
.setServerApproveBillingEvent(VKey.from(oneTimeBillKey))
|
||||
.setServerApproveAutorenewEvent(VKey.from(recurringBillKey))
|
||||
.setServerApproveAutorenewPollMessage(VKey.from(autorenewPollKey))
|
||||
ImmutableSet.of(oneTimeBillKey, recurringBillKey, autorenewPollKey))
|
||||
.setServerApproveBillingEvent(oneTimeBillKey)
|
||||
.setServerApproveAutorenewEvent(recurringBillKey)
|
||||
.setServerApproveAutorenewPollMessage(autorenewPollKey)
|
||||
.setTransferRequestTime(fakeClock.nowUtc().plusDays(1))
|
||||
.setTransferStatus(TransferStatus.SERVER_APPROVED)
|
||||
.setTransferRequestTrid(Trid.create("client-trid", "server-trid"))
|
||||
|
@ -327,7 +325,7 @@ public class DomainBaseTest extends EntityTestCase {
|
|||
private void assertTransferred(
|
||||
DomainBase domain,
|
||||
DateTime newExpirationTime,
|
||||
Key<BillingEvent.Recurring> newAutorenewEvent) {
|
||||
VKey<BillingEvent.Recurring> newAutorenewEvent) {
|
||||
assertThat(domain.getTransferData().getTransferStatus())
|
||||
.isEqualTo(TransferStatus.SERVER_APPROVED);
|
||||
assertThat(domain.getCurrentSponsorClientId()).isEqualTo("winner");
|
||||
|
@ -377,8 +375,8 @@ public class DomainBaseTest extends EntityTestCase {
|
|||
.build();
|
||||
DomainBase afterTransfer = domain.cloneProjectedAtTime(fakeClock.nowUtc().plusDays(1));
|
||||
DateTime newExpirationTime = oldExpirationTime.plusYears(1);
|
||||
Key<BillingEvent.Recurring> serverApproveAutorenewEvent =
|
||||
domain.getTransferData().getServerApproveAutorenewEvent().getOfyKey();
|
||||
VKey<BillingEvent.Recurring> serverApproveAutorenewEvent =
|
||||
domain.getTransferData().getServerApproveAutorenewEvent();
|
||||
assertTransferred(afterTransfer, newExpirationTime, serverApproveAutorenewEvent);
|
||||
assertThat(afterTransfer.getGracePeriods())
|
||||
.containsExactly(
|
||||
|
@ -389,7 +387,7 @@ public class DomainBaseTest extends EntityTestCase {
|
|||
.plusDays(1)
|
||||
.plus(Registry.get("com").getTransferGracePeriodLength()),
|
||||
"winner",
|
||||
Key.create(transferBillingEvent)));
|
||||
transferBillingEvent.createVKey()));
|
||||
// If we project after the grace period expires all should be the same except the grace period.
|
||||
DomainBase afterGracePeriod =
|
||||
domain.cloneProjectedAtTime(
|
||||
|
@ -747,8 +745,8 @@ public class DomainBaseTest extends EntityTestCase {
|
|||
.setPendingTransferExpirationTime(transferExpirationTime)
|
||||
.setTransferStatus(TransferStatus.PENDING)
|
||||
.setGainingClientId("TheRegistrar")
|
||||
.setServerApproveAutorenewEvent(VKey.from(recurringBillKey))
|
||||
.setServerApproveBillingEvent(VKey.from(oneTimeBillKey))
|
||||
.setServerApproveAutorenewEvent(recurringBillKey)
|
||||
.setServerApproveBillingEvent(oneTimeBillKey)
|
||||
.build();
|
||||
domain =
|
||||
persistResource(
|
||||
|
|
|
@ -24,6 +24,7 @@ import google.registry.model.billing.BillingEvent.Reason;
|
|||
import google.registry.model.billing.BillingEvent.Recurring;
|
||||
import google.registry.model.domain.rgp.GracePeriodStatus;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.money.Money;
|
||||
|
@ -46,23 +47,25 @@ public class GracePeriodTest {
|
|||
|
||||
@BeforeEach
|
||||
void before() {
|
||||
onetime = new BillingEvent.OneTime.Builder()
|
||||
.setEventTime(now)
|
||||
.setBillingTime(now.plusDays(1))
|
||||
.setClientId("TheRegistrar")
|
||||
.setCost(Money.of(CurrencyUnit.USD, 42))
|
||||
.setParent(Key.create(HistoryEntry.class, 12345))
|
||||
.setReason(Reason.CREATE)
|
||||
.setPeriodYears(1)
|
||||
.setTargetId("foo.google")
|
||||
.build();
|
||||
onetime =
|
||||
new BillingEvent.OneTime.Builder()
|
||||
.setEventTime(now)
|
||||
.setBillingTime(now.plusDays(1))
|
||||
.setClientId("TheRegistrar")
|
||||
.setCost(Money.of(CurrencyUnit.USD, 42))
|
||||
.setParent(
|
||||
Key.create(Key.create(DomainBase.class, "domain"), HistoryEntry.class, 12345))
|
||||
.setReason(Reason.CREATE)
|
||||
.setPeriodYears(1)
|
||||
.setTargetId("foo.google")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_forBillingEvent() {
|
||||
GracePeriod gracePeriod = GracePeriod.forBillingEvent(GracePeriodStatus.ADD, onetime);
|
||||
assertThat(gracePeriod.getType()).isEqualTo(GracePeriodStatus.ADD);
|
||||
assertThat(gracePeriod.getOneTimeBillingEvent()).isEqualTo(Key.create(onetime));
|
||||
assertThat(gracePeriod.getOneTimeBillingEvent()).isEqualTo(onetime.createVKey());
|
||||
assertThat(gracePeriod.getRecurringBillingEvent()).isNull();
|
||||
assertThat(gracePeriod.getClientId()).isEqualTo("TheRegistrar");
|
||||
assertThat(gracePeriod.getExpirationTime()).isEqualTo(now.plusDays(1));
|
||||
|
@ -100,7 +103,7 @@ public class GracePeriodTest {
|
|||
GracePeriodStatus.RENEW,
|
||||
now.plusDays(1),
|
||||
"TheRegistrar",
|
||||
Key.create(Recurring.class, 12345)));
|
||||
VKey.create(Recurring.class, 12345)));
|
||||
assertThat(thrown).hasMessageThat().contains("autorenew");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ import static org.joda.money.CurrencyUnit.USD;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.net.InetAddresses;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.billing.BillingEvent;
|
||||
import google.registry.model.billing.BillingEvent.Flag;
|
||||
import google.registry.model.billing.BillingEvent.Reason;
|
||||
|
@ -302,8 +301,7 @@ public class DomainBaseToXjcConverterTest {
|
|||
StatusValue.CLIENT_TRANSFER_PROHIBITED,
|
||||
StatusValue.SERVER_UPDATE_PROHIBITED))
|
||||
.setAutorenewBillingEvent(
|
||||
Key.create(
|
||||
persistResource(
|
||||
persistResource(
|
||||
new BillingEvent.Recurring.Builder()
|
||||
.setReason(Reason.RENEW)
|
||||
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
|
||||
|
@ -312,10 +310,10 @@ public class DomainBaseToXjcConverterTest {
|
|||
.setEventTime(END_OF_TIME)
|
||||
.setRecurrenceEndTime(END_OF_TIME)
|
||||
.setParent(historyEntry)
|
||||
.build())))
|
||||
.build())
|
||||
.createVKey())
|
||||
.setAutorenewPollMessage(
|
||||
Key.create(
|
||||
persistResource(
|
||||
persistResource(
|
||||
new PollMessage.Autorenew.Builder()
|
||||
.setTargetId("lol")
|
||||
.setClientId("TheRegistrar")
|
||||
|
@ -323,7 +321,8 @@ public class DomainBaseToXjcConverterTest {
|
|||
.setAutorenewEndTime(END_OF_TIME)
|
||||
.setMsg("Domain was auto-renewed.")
|
||||
.setParent(historyEntry)
|
||||
.build())))
|
||||
.build())
|
||||
.createVKey())
|
||||
.setTransferData(
|
||||
new DomainTransferData.Builder()
|
||||
.setGainingClientId("gaining")
|
||||
|
|
|
@ -26,7 +26,6 @@ import static org.joda.money.CurrencyUnit.USD;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.net.InetAddresses;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.billing.BillingEvent;
|
||||
import google.registry.model.billing.BillingEvent.Flag;
|
||||
import google.registry.model.billing.BillingEvent.Reason;
|
||||
|
@ -147,8 +146,7 @@ final class RdeFixtures {
|
|||
StatusValue.CLIENT_TRANSFER_PROHIBITED,
|
||||
StatusValue.SERVER_UPDATE_PROHIBITED))
|
||||
.setAutorenewBillingEvent(
|
||||
Key.create(
|
||||
persistResource(
|
||||
persistResource(
|
||||
new BillingEvent.Recurring.Builder()
|
||||
.setReason(Reason.RENEW)
|
||||
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
|
||||
|
@ -157,10 +155,10 @@ final class RdeFixtures {
|
|||
.setEventTime(END_OF_TIME)
|
||||
.setRecurrenceEndTime(END_OF_TIME)
|
||||
.setParent(historyEntry)
|
||||
.build())))
|
||||
.build())
|
||||
.createVKey())
|
||||
.setAutorenewPollMessage(
|
||||
Key.create(
|
||||
persistSimpleResource(
|
||||
persistSimpleResource(
|
||||
new PollMessage.Autorenew.Builder()
|
||||
.setTargetId(tld)
|
||||
.setClientId("TheRegistrar")
|
||||
|
@ -168,7 +166,8 @@ final class RdeFixtures {
|
|||
.setAutorenewEndTime(END_OF_TIME)
|
||||
.setMsg("Domain was auto-renewed.")
|
||||
.setParent(historyEntry)
|
||||
.build())))
|
||||
.build())
|
||||
.createVKey())
|
||||
.setTransferData(
|
||||
new DomainTransferData.Builder()
|
||||
.setGainingClientId("gaining")
|
||||
|
|
|
@ -545,8 +545,8 @@ public class DatastoreHelper {
|
|||
return persistResource(
|
||||
domain
|
||||
.asBuilder()
|
||||
.setAutorenewBillingEvent(Key.create(autorenewEvent))
|
||||
.setAutorenewPollMessage(Key.create(autorenewPollMessage))
|
||||
.setAutorenewBillingEvent(autorenewEvent.createVKey())
|
||||
.setAutorenewPollMessage(autorenewPollMessage.createVKey())
|
||||
.build());
|
||||
}
|
||||
|
||||
|
@ -588,13 +588,13 @@ public class DatastoreHelper {
|
|||
.build());
|
||||
// Modify the existing autorenew event to reflect the pending transfer.
|
||||
persistResource(
|
||||
ofy().load().key(domain.getAutorenewBillingEvent()).now().asBuilder()
|
||||
tm().load(domain.getAutorenewBillingEvent())
|
||||
.asBuilder()
|
||||
.setRecurrenceEndTime(expirationTime)
|
||||
.build());
|
||||
// Update the end time of the existing autorenew poll message. We must delete it if it has no
|
||||
// events left in it.
|
||||
PollMessage.Autorenew autorenewPollMessage =
|
||||
ofy().load().key(domain.getAutorenewPollMessage()).now();
|
||||
PollMessage.Autorenew autorenewPollMessage = tm().load(domain.getAutorenewPollMessage());
|
||||
if (autorenewPollMessage.getEventTime().isBefore(expirationTime)) {
|
||||
persistResource(
|
||||
autorenewPollMessage.asBuilder()
|
||||
|
|
|
@ -20,6 +20,7 @@ import static google.registry.model.eppcommon.StatusValue.PENDING_DELETE;
|
|||
import static google.registry.model.eppcommon.StatusValue.PENDING_TRANSFER;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.model.reporting.HistoryEntry.Type.SYNTHETIC;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
|
||||
import static google.registry.testing.DatastoreHelper.assertBillingEventsEqual;
|
||||
import static google.registry.testing.DatastoreHelper.assertPollMessagesEqual;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
|
@ -119,7 +120,7 @@ public class UnrenewDomainCommandTest extends CommandTestCase<UnrenewDomainComma
|
|||
HistoryEntry synthetic = getOnlyHistoryEntryOfType(domain, SYNTHETIC);
|
||||
|
||||
assertBillingEventsEqual(
|
||||
ofy().load().key(domain.getAutorenewBillingEvent()).now(),
|
||||
tm().load(domain.getAutorenewBillingEvent()),
|
||||
new BillingEvent.Recurring.Builder()
|
||||
.setParent(synthetic)
|
||||
.setReason(Reason.RENEW)
|
||||
|
@ -148,7 +149,8 @@ public class UnrenewDomainCommandTest extends CommandTestCase<UnrenewDomainComma
|
|||
.build()));
|
||||
|
||||
// Check that fields on domain were updated correctly.
|
||||
assertThat(domain.getAutorenewPollMessage().getParent()).isEqualTo(Key.create(synthetic));
|
||||
assertThat(domain.getAutorenewPollMessage().getOfyKey().getParent())
|
||||
.isEqualTo(Key.create(synthetic));
|
||||
assertThat(domain.getRegistrationExpirationTime()).isEqualTo(newExpirationTime);
|
||||
assertThat(domain.getLastEppUpdateTime()).isEqualTo(unrenewTime);
|
||||
assertThat(domain.getLastEppUpdateClientId()).isEqualTo("TheRegistrar");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue