1
0
mirror of https://github.com/google/nomulus synced 2026-06-09 16:33:02 +00:00

Convert more flow tests to replay/compare (#1009)

* Convert more flow tests to replay/compare

Add the replay extension to another batch of flow tests.  In the course of
this:

- Refactor out domain deletion code into DatabaseHelper so that it can be used
  from multiple tests.
- Make null handling uniform for contact phone numbers.

* Convert postLoad method to onLoad.

* Remove "Test" import missed during rebase

* Deal with persistence of billing cancellations

Deal with the persistence of billing cancellations, which were added in the
master branch since before this PR was initially sent for review.

* Adding forgotten flyway file

* Removed debug variable
This commit is contained in:
Michael Muller
2021-03-18 14:31:58 -04:00
committed by GitHub
parent deb84cf74d
commit 6bc943bb7d
17 changed files with 2281 additions and 2135 deletions

View File

@@ -21,6 +21,7 @@ import static google.registry.model.EppResourceUtils.projectResourceOntoBuilderA
import com.google.common.collect.ImmutableList;
import com.googlecode.objectify.annotation.IgnoreSave;
import com.googlecode.objectify.annotation.Index;
import com.googlecode.objectify.annotation.OnLoad;
import com.googlecode.objectify.condition.IfNull;
import google.registry.model.EppResource;
import google.registry.model.EppResource.ResourceWithTransferData;
@@ -189,6 +190,17 @@ public class ContactBase extends EppResource implements ResourceWithTransferData
+ " use ContactResource instead");
}
@OnLoad
void onLoad() {
if (voice != null && voice.hasNullFields()) {
voice = null;
}
if (fax != null && fax.hasNullFields()) {
fax = null;
}
}
public String getContactId() {
return contactId;
}
@@ -325,11 +337,17 @@ public class ContactBase extends EppResource implements ResourceWithTransferData
}
public B setVoiceNumber(ContactPhoneNumber voiceNumber) {
if (voiceNumber != null && voiceNumber.hasNullFields()) {
voiceNumber = null;
}
getInstance().voice = voiceNumber;
return thisCastToDerived();
}
public B setFaxNumber(ContactPhoneNumber faxNumber) {
if (faxNumber != null && faxNumber.hasNullFields()) {
faxNumber = null;
}
getInstance().fax = faxNumber;
return thisCastToDerived();
}

View File

@@ -71,6 +71,11 @@ public class PhoneNumber extends ImmutableObject {
return phoneNumber + (extension != null ? " x" + extension : "");
}
/** Returns true if both fields of the phone number are null. */
public boolean hasNullFields() {
return phoneNumber == null && extension == null;
}
/** A builder for constructing {@link PhoneNumber}. */
public static class Builder<T extends PhoneNumber> extends Buildable.Builder<T> {
@Override

View File

@@ -83,7 +83,11 @@ public class DomainTransferData extends TransferData<DomainTransferData.Builder>
@Ignore
@Column(name = "transfer_billing_cancellation_id")
VKey<BillingEvent.Cancellation> billingCancellationId;
public VKey<BillingEvent.Cancellation> billingCancellationId;
@Ignore
@Column(name = "transfer_billing_cancellation_history_id")
Long billingCancellationHistoryId;
/**
* The regular one-time billing event that will be charged for a server-approved transfer.
@@ -149,6 +153,17 @@ public class DomainTransferData extends TransferData<DomainTransferData.Builder>
serverApproveAutorenewPollMessage =
DomainBase.restoreOfyFrom(
rootKey, serverApproveAutorenewPollMessage, serverApproveAutorenewPollMessageHistoryId);
billingCancellationId =
DomainBase.restoreOfyFrom(rootKey, billingCancellationId, billingCancellationHistoryId);
// Reconstruct server approve entities. We currently have to call postLoad() a _second_ time
// if the billing cancellation id has been reconstituted, as it is part of that set.
// TODO(b/183010623): Normalize the approaches to VKey reconstitution for the TransferData
// hierarchy (the logic currently lives either in PostLoad or here, depending on the key).
if (billingCancellationId != null) {
serverApproveEntities = null;
postLoad();
}
}
/**
@@ -179,6 +194,12 @@ public class DomainTransferData extends TransferData<DomainTransferData.Builder>
serverApproveAutorenewPollMessageHistoryId = DomainBase.getHistoryId(val);
}
@SuppressWarnings("unused") // For Hibernate.
private void billingCancellationHistoryId(
@AlsoLoad("billingCancellationHistoryId") VKey<BillingEvent.Cancellation> val) {
billingCancellationHistoryId = DomainBase.getHistoryId(val);
}
public Period getTransferPeriod() {
return transferPeriod;
}
@@ -269,6 +290,7 @@ public class DomainTransferData extends TransferData<DomainTransferData.Builder>
DomainTransferData domainTransferData) {
if (isNullOrEmpty(serverApproveEntities)) {
domainTransferData.billingCancellationId = null;
domainTransferData.billingCancellationHistoryId = null;
} else {
domainTransferData.billingCancellationId =
(VKey<BillingEvent.Cancellation>)
@@ -276,6 +298,10 @@ public class DomainTransferData extends TransferData<DomainTransferData.Builder>
.filter(k -> k.getKind().equals(BillingEvent.Cancellation.class))
.findFirst()
.orElse(null);
domainTransferData.billingCancellationHistoryId =
domainTransferData.billingCancellationId != null
? DomainBase.getHistoryId(domainTransferData.billingCancellationId)
: null;
}
}