mirror of
https://github.com/google/nomulus.git
synced 2025-07-07 11:43:24 +02:00
Restore symmetric VKey referenced by BillingEvent.Cancellation (#928)
This commit is contained in:
parent
9b711ec8e1
commit
b764c25a63
9 changed files with 181 additions and 108 deletions
|
@ -46,6 +46,8 @@ import google.registry.model.domain.rgp.GracePeriodStatus;
|
|||
import google.registry.model.domain.token.AllocationToken;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.transfer.TransferData.TransferServerApproveEntity;
|
||||
import google.registry.persistence.BillingVKey.BillingEventVKey;
|
||||
import google.registry.persistence.BillingVKey.BillingRecurrenceVKey;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.persistence.WithLongVKey;
|
||||
import google.registry.schema.replay.DatastoreAndSqlEntity;
|
||||
|
@ -572,8 +574,7 @@ public abstract class BillingEvent extends ImmutableObject
|
|||
* <p>Although the type is {@link Key} the name "ref" is preserved for historical reasons.
|
||||
*/
|
||||
@IgnoreSave(IfNull.class)
|
||||
@Column(name = "billing_event_id")
|
||||
VKey<BillingEvent.OneTime> refOneTime = null;
|
||||
BillingEventVKey refOneTime = null;
|
||||
|
||||
/**
|
||||
* The recurring billing event to cancel, or null for non-autorenew cancellations.
|
||||
|
@ -581,15 +582,14 @@ public abstract class BillingEvent extends ImmutableObject
|
|||
* <p>Although the type is {@link Key} the name "ref" is preserved for historical reasons.
|
||||
*/
|
||||
@IgnoreSave(IfNull.class)
|
||||
@Column(name = "billing_recurrence_id")
|
||||
VKey<BillingEvent.Recurring> refRecurring = null;
|
||||
BillingRecurrenceVKey refRecurring = null;
|
||||
|
||||
public DateTime getBillingTime() {
|
||||
return billingTime;
|
||||
}
|
||||
|
||||
public VKey<? extends BillingEvent> getEventKey() {
|
||||
return firstNonNull(refOneTime, refRecurring);
|
||||
return firstNonNull(refOneTime, refRecurring).createVKey();
|
||||
}
|
||||
|
||||
/** The mapping from billable grace period types to originating billing event reasons. */
|
||||
|
@ -656,12 +656,12 @@ public abstract class BillingEvent extends ImmutableObject
|
|||
}
|
||||
|
||||
public Builder setOneTimeEventKey(VKey<BillingEvent.OneTime> eventKey) {
|
||||
getInstance().refOneTime = eventKey;
|
||||
getInstance().refOneTime = BillingEventVKey.create(eventKey);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setRecurringEventKey(VKey<BillingEvent.Recurring> eventKey) {
|
||||
getInstance().refRecurring = eventKey;
|
||||
getInstance().refRecurring = BillingRecurrenceVKey.create(eventKey);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -318,13 +318,8 @@ public class BillingEventTest extends EntityTestCase {
|
|||
historyEntry2,
|
||||
"foo.tld");
|
||||
// Set ID to be the same to ignore for the purposes of comparison.
|
||||
newCancellation = newCancellation.asBuilder().setId(cancellationOneTime.getId()).build();
|
||||
|
||||
// TODO(b/168537779): Remove setRecurringEventKey after symmetric VKey can be reconstructed
|
||||
// correctly.
|
||||
assertThat(newCancellation)
|
||||
.isEqualTo(
|
||||
cancellationOneTime.asBuilder().setOneTimeEventKey(oneTime.createVKey()).build());
|
||||
assertThat(newCancellation.asBuilder().setId(cancellationOneTime.getId()).build())
|
||||
.isEqualTo(cancellationOneTime);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
|
@ -340,13 +335,8 @@ public class BillingEventTest extends EntityTestCase {
|
|||
historyEntry2,
|
||||
"foo.tld");
|
||||
// Set ID to be the same to ignore for the purposes of comparison.
|
||||
newCancellation = newCancellation.asBuilder().setId(cancellationRecurring.getId()).build();
|
||||
|
||||
// TODO(b/168537779): Remove setRecurringEventKey after symmetric VKey can be reconstructed
|
||||
// correctly.
|
||||
assertThat(newCancellation)
|
||||
.isEqualTo(
|
||||
cancellationRecurring.asBuilder().setRecurringEventKey(recurring.createVKey()).build());
|
||||
assertThat(newCancellation.asBuilder().setId(cancellationRecurring.getId()).build())
|
||||
.isEqualTo(cancellationRecurring);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
|
|
|
@ -8,8 +8,8 @@ class google.registry.model.billing.BillingEvent$Cancellation {
|
|||
@Id java.lang.Long id;
|
||||
@Parent com.googlecode.objectify.Key<google.registry.model.reporting.HistoryEntry> parent;
|
||||
google.registry.model.billing.BillingEvent$Reason reason;
|
||||
google.registry.persistence.VKey<google.registry.model.billing.BillingEvent$OneTime> refOneTime;
|
||||
google.registry.persistence.VKey<google.registry.model.billing.BillingEvent$Recurring> refRecurring;
|
||||
google.registry.persistence.BillingVKey$BillingEventVKey refOneTime;
|
||||
google.registry.persistence.BillingVKey$BillingRecurrenceVKey refRecurring;
|
||||
java.lang.String clientId;
|
||||
java.lang.String targetId;
|
||||
java.util.Set<google.registry.model.billing.BillingEvent$Flag> flags;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue