Rename ContactResource -> Contact (#1763)

* Rename ContactResource -> Contact

This is a follow-up to PR #1725 and #1733. Now all EPP resource entity class
names have been rationalized to match with their SQL table names.
This commit is contained in:
Ben McIlwain 2022-08-29 14:48:32 -04:00 committed by GitHub
parent b394341886
commit aacd834e16
116 changed files with 1118 additions and 1108 deletions

View file

@ -29,7 +29,7 @@ import google.registry.config.RegistryEnvironment;
import google.registry.flows.poll.PollFlowUtils; import google.registry.flows.poll.PollFlowUtils;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.EppResourceUtils; import google.registry.model.EppResourceUtils;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.host.Host; import google.registry.model.host.Host;
import google.registry.model.poll.PollMessage; import google.registry.model.poll.PollMessage;
@ -43,8 +43,8 @@ import google.registry.util.Clock;
import javax.inject.Inject; import javax.inject.Inject;
/** /**
* Hard deletes load-test ContactResources, Hosts, their subordinate history entries, and the * Hard deletes load-test Contacts, Hosts, their subordinate history entries, and the associated
* associated ForeignKey and EppResourceIndex entities. * ForeignKey and EppResourceIndex entities.
* *
* <p>This only deletes contacts and hosts, NOT domains. To delete domains, use {@link * <p>This only deletes contacts and hosts, NOT domains. To delete domains, use {@link
* DeleteProberDataAction} and pass it the TLD(s) that the load test domains were created on. Note * DeleteProberDataAction} and pass it the TLD(s) that the load test domains were created on. Note
@ -92,7 +92,7 @@ public class DeleteLoadTestDataAction implements Runnable {
tm().transact( tm().transact(
() -> { () -> {
LOAD_TEST_REGISTRARS.forEach(this::deletePollMessages); LOAD_TEST_REGISTRARS.forEach(this::deletePollMessages);
tm().loadAllOfStream(ContactResource.class).forEach(this::deleteContact); tm().loadAllOfStream(Contact.class).forEach(this::deleteContact);
tm().loadAllOfStream(Host.class).forEach(this::deleteHost); tm().loadAllOfStream(Host.class).forEach(this::deleteHost);
}); });
} }
@ -108,7 +108,7 @@ public class DeleteLoadTestDataAction implements Runnable {
} }
} }
private void deleteContact(ContactResource contact) { private void deleteContact(Contact contact) {
if (!LOAD_TEST_REGISTRARS.contains(contact.getPersistedCurrentSponsorRegistrarId())) { if (!LOAD_TEST_REGISTRARS.contains(contact.getPersistedCurrentSponsorRegistrarId())) {
return; return;
} }

View file

@ -17,7 +17,7 @@ package google.registry.beam.common;
import static com.google.common.base.Verify.verify; import static com.google.common.base.Verify.verify;
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm; import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.persistence.transaction.CriteriaQueryBuilder; import google.registry.persistence.transaction.CriteriaQueryBuilder;
import google.registry.persistence.transaction.JpaTransactionManager; import google.registry.persistence.transaction.JpaTransactionManager;
import java.io.Serializable; import java.io.Serializable;
@ -46,8 +46,7 @@ public class JpaDemoPipeline implements Serializable {
.apply( .apply(
"Read contacts", "Read contacts",
RegistryJpaIO.read( RegistryJpaIO.read(
() -> CriteriaQueryBuilder.create(ContactResource.class).build(), () -> CriteriaQueryBuilder.create(Contact.class).build(), Contact::getRepoId))
ContactResource::getRepoId))
.apply( .apply(
"Count Contacts", "Count Contacts",
ParDo.of( ParDo.of(

View file

@ -45,8 +45,8 @@ import google.registry.config.CredentialModule;
import google.registry.config.RegistryConfig.ConfigModule; import google.registry.config.RegistryConfig.ConfigModule;
import google.registry.gcs.GcsUtils; import google.registry.gcs.GcsUtils;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.host.Host; import google.registry.model.host.Host;
@ -140,7 +140,7 @@ import org.joda.time.DateTime;
* pairs of (contact/host repo ID: pending deposit) for all RDE pending deposits for further * pairs of (contact/host repo ID: pending deposit) for all RDE pending deposits for further
* processing. * processing.
* *
* <h3>{@link ContactResource}</h3> * <h3>{@link Contact}</h3>
* *
* We first join most recent contact histories, represented by (contact repo ID: contact history * We first join most recent contact histories, represented by (contact repo ID: contact history
* revision ID) pairs, with referenced contacts, represented by (contact repo ID: pending deposit) * revision ID) pairs, with referenced contacts, represented by (contact repo ID: pending deposit)
@ -150,13 +150,13 @@ import org.joda.time.DateTime;
* *
* <h3>{@link Host}</h3> * <h3>{@link Host}</h3>
* *
* Similar to {@link ContactResource}, we join the most recent host history with referenced hosts to * Similar to {@link Contact}, we join the most recent host history with referenced hosts to find
* find most recent referenced hosts. For external hosts we do the same treatment as we did on * most recent referenced hosts. For external hosts we do the same treatment as we did on contacts
* contacts and obtain the (pending deposit: deposit fragment) pairs. For subordinate hosts, we need * and obtain the (pending deposit: deposit fragment) pairs. For subordinate hosts, we need to find
* to find the superordinate domain in order to properly handle pending transfer in the deposit as * the superordinate domain in order to properly handle pending transfer in the deposit as well. So
* well. So we first find the superordinate domain repo ID from the host and join the (superordinate * we first find the superordinate domain repo ID from the host and join the (superordinate domain
* domain repo ID: (subordinate host repo ID: (pending deposit: revision ID))) pair with the (domain * repo ID: (subordinate host repo ID: (pending deposit: revision ID))) pair with the (domain repo
* repo ID: revision ID) pair obtained from the domain history query in order to map the host at * ID: revision ID) pair obtained from the domain history query in order to map the host at
* watermark to the domain at watermark. We then proceed to create the (pending deposit: deposit * watermark to the domain at watermark. We then proceed to create the (pending deposit: deposit
* fragment) pair for subordinate hosts using the added domain information. * fragment) pair for subordinate hosts using the added domain information.
* *
@ -466,10 +466,10 @@ public class RdePipeline implements Serializable {
private PCollectionTuple processDomainHistories(PCollection<KV<String, Long>> domainHistories) { private PCollectionTuple processDomainHistories(PCollection<KV<String, Long>> domainHistories) {
Counter activeDomainCounter = Metrics.counter("RDE", "ActiveDomainBase"); Counter activeDomainCounter = Metrics.counter("RDE", "ActiveDomainBase");
Counter domainFragmentCounter = Metrics.counter("RDE", "DomainFragment"); Counter domainFragmentCounter = Metrics.counter("RDE", "DomainFragment");
Counter referencedContactCounter = Metrics.counter("RDE", "ReferencedContactResource"); Counter referencedContactCounter = Metrics.counter("RDE", "ReferencedContact");
Counter referencedHostCounter = Metrics.counter("RDE", "ReferencedHost"); Counter referencedHostCounter = Metrics.counter("RDE", "ReferencedHost");
return domainHistories.apply( return domainHistories.apply(
"Map DomainHistory to DepositFragment " + "and emit referenced ContactResource and Host", "Map DomainHistory to DepositFragment " + "and emit referenced Contact and Host",
ParDo.of( ParDo.of(
new DoFn<KV<String, Long>, KV<PendingDeposit, DepositFragment>>() { new DoFn<KV<String, Long>, KV<PendingDeposit, DepositFragment>>() {
@ProcessElement @ProcessElement
@ -533,17 +533,17 @@ public class RdePipeline implements Serializable {
PCollection<KV<String, PendingDeposit>> referencedContacts, PCollection<KV<String, PendingDeposit>> referencedContacts,
PCollection<KV<String, Long>> contactHistories) { PCollection<KV<String, Long>> contactHistories) {
Counter contactFragmentCounter = Metrics.counter("RDE", "ContactFragment"); Counter contactFragmentCounter = Metrics.counter("RDE", "ContactFragment");
return removeUnreferencedResource(referencedContacts, contactHistories, ContactResource.class) return removeUnreferencedResource(referencedContacts, contactHistories, Contact.class)
.apply( .apply(
"Map ContactResource to DepositFragment", "Map Contact to DepositFragment",
FlatMapElements.into( FlatMapElements.into(
kvs( kvs(
TypeDescriptor.of(PendingDeposit.class), TypeDescriptor.of(PendingDeposit.class),
TypeDescriptor.of(DepositFragment.class))) TypeDescriptor.of(DepositFragment.class)))
.via( .via(
(KV<String, CoGbkResult> kv) -> { (KV<String, CoGbkResult> kv) -> {
ContactResource contact = Contact contact =
(ContactResource) (Contact)
loadResourceByHistoryEntryId( loadResourceByHistoryEntryId(
ContactHistory.class, ContactHistory.class,
kv.getKey(), kv.getKey(),

View file

@ -22,7 +22,7 @@ import com.google.common.collect.ImmutableSet;
import google.registry.beam.common.RegistryJpaIO; import google.registry.beam.common.RegistryJpaIO;
import google.registry.beam.common.RegistryJpaIO.Read; import google.registry.beam.common.RegistryJpaIO.Read;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.DomainBase;
import google.registry.model.host.Host; import google.registry.model.host.Host;
@ -53,7 +53,7 @@ import org.joda.time.DateTime;
public class ResaveAllEppResourcesPipeline implements Serializable { public class ResaveAllEppResourcesPipeline implements Serializable {
private static final ImmutableSet<Class<? extends EppResource>> EPP_RESOURCE_CLASSES = private static final ImmutableSet<Class<? extends EppResource>> EPP_RESOURCE_CLASSES =
ImmutableSet.of(ContactResource.class, Domain.class, Host.class); ImmutableSet.of(Contact.class, Domain.class, Host.class);
/** /**
* There exist three possible situations where we know we'll want to project domains to the * There exist three possible situations where we know we'll want to project domains to the
@ -99,13 +99,13 @@ public class ResaveAllEppResourcesPipeline implements Serializable {
/** Projects to the current time and saves any contacts with expired transfers. */ /** Projects to the current time and saves any contacts with expired transfers. */
private void fastResaveContacts(Pipeline pipeline) { private void fastResaveContacts(Pipeline pipeline) {
Read<ContactResource, ContactResource> read = Read<Contact, Contact> read =
RegistryJpaIO.read( RegistryJpaIO.read(
"FROM Contact WHERE transferData.transferStatus = 'PENDING' AND" "FROM Contact WHERE transferData.transferStatus = 'PENDING' AND"
+ " transferData.pendingTransferExpirationTime < current_timestamp()", + " transferData.pendingTransferExpirationTime < current_timestamp()",
ContactResource.class, Contact.class,
c -> c); c -> c);
projectAndResaveResources(pipeline, ContactResource.class, read); projectAndResaveResources(pipeline, Contact.class, read);
} }
/** /**

View file

@ -1,6 +1,6 @@
<datastore-indexes autoGenerate="false"> <datastore-indexes autoGenerate="false">
<!-- For finding contact resources by registrar. --> <!-- For finding contact resources by registrar. -->
<datastore-index kind="ContactResource" ancestor="false" source="manual"> <datastore-index kind="Contact" ancestor="false" source="manual">
<property name="currentSponsorClientId" direction="asc"/> <property name="currentSponsorClientId" direction="asc"/>
<property name="deletionTime" direction="asc"/> <property name="deletionTime" direction="asc"/>
<property name="searchName" direction="asc"/> <property name="searchName" direction="asc"/>
@ -91,7 +91,7 @@
<property name="deletionTime" direction="asc"/> <property name="deletionTime" direction="asc"/>
<property name="fullyQualifiedHostName" direction="asc"/> <property name="fullyQualifiedHostName" direction="asc"/>
</datastore-index> </datastore-index>
<datastore-index kind="ContactResource" ancestor="false" source="manual"> <datastore-index kind="Contact" ancestor="false" source="manual">
<property name="deletionTime" direction="asc"/> <property name="deletionTime" direction="asc"/>
<property name="searchName" direction="asc"/> <property name="searchName" direction="asc"/>
</datastore-index> </datastore-index>

View file

@ -38,7 +38,7 @@ import google.registry.flows.exceptions.TooManyResourceChecksException;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.EppResource.ForeignKeyedEppResource; import google.registry.model.EppResource.ForeignKeyedEppResource;
import google.registry.model.EppResource.ResourceWithTransferData; import google.registry.model.EppResource.ResourceWithTransferData;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Period; import google.registry.model.domain.Period;
@ -139,7 +139,7 @@ public final class ResourceFlowUtils {
} }
/** Check that the given AuthInfo is either missing or else is valid for the given resource. */ /** Check that the given AuthInfo is either missing or else is valid for the given resource. */
public static void verifyOptionalAuthInfo(Optional<AuthInfo> authInfo, ContactResource contact) public static void verifyOptionalAuthInfo(Optional<AuthInfo> authInfo, Contact contact)
throws EppException { throws EppException {
if (authInfo.isPresent()) { if (authInfo.isPresent()) {
verifyAuthInfo(authInfo.get(), contact); verifyAuthInfo(authInfo.get(), contact);
@ -167,7 +167,7 @@ public final class ResourceFlowUtils {
return; return;
} }
// The roid should match one of the contacts. // The roid should match one of the contacts.
Optional<VKey<ContactResource>> foundContact = Optional<VKey<Contact>> foundContact =
domain.getReferencedContacts().stream() domain.getReferencedContacts().stream()
.filter(key -> key.getSqlKey().equals(authRepoId)) .filter(key -> key.getSqlKey().equals(authRepoId))
.findFirst(); .findFirst();
@ -179,8 +179,7 @@ public final class ResourceFlowUtils {
} }
/** Check that the given {@link AuthInfo} is valid for the given contact. */ /** Check that the given {@link AuthInfo} is valid for the given contact. */
public static void verifyAuthInfo(AuthInfo authInfo, ContactResource contact) public static void verifyAuthInfo(AuthInfo authInfo, Contact contact) throws EppException {
throws EppException {
String authRepoId = authInfo.getPw().getRepoId(); String authRepoId = authInfo.getPw().getRepoId();
String authPassword = authInfo.getPw().getValue(); String authPassword = authInfo.getPw().getValue();
String contactPassword = contact.getAuthInfo().getPw().getValue(); String contactPassword = contact.getAuthInfo().getPw().getValue();

View file

@ -26,8 +26,8 @@ import google.registry.flows.ExtensionManager;
import google.registry.flows.Flow; import google.registry.flows.Flow;
import google.registry.flows.FlowModule.RegistrarId; import google.registry.flows.FlowModule.RegistrarId;
import google.registry.flows.annotations.ReportingSpec; import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactCommand.Check; import google.registry.model.contact.ContactCommand.Check;
import google.registry.model.contact.ContactResource;
import google.registry.model.eppinput.ResourceCommand; import google.registry.model.eppinput.ResourceCommand;
import google.registry.model.eppoutput.CheckData.ContactCheck; import google.registry.model.eppoutput.CheckData.ContactCheck;
import google.registry.model.eppoutput.CheckData.ContactCheckData; import google.registry.model.eppoutput.CheckData.ContactCheckData;
@ -62,7 +62,7 @@ public final class ContactCheckFlow implements Flow {
ImmutableList<String> targetIds = ((Check) resourceCommand).getTargetIds(); ImmutableList<String> targetIds = ((Check) resourceCommand).getTargetIds();
verifyTargetIdCount(targetIds, maxChecks); verifyTargetIdCount(targetIds, maxChecks);
ImmutableSet<String> existingIds = ImmutableSet<String> existingIds =
checkResourcesExist(ContactResource.class, targetIds, clock.nowUtc()); checkResourcesExist(Contact.class, targetIds, clock.nowUtc());
ImmutableList.Builder<ContactCheck> checks = new ImmutableList.Builder<>(); ImmutableList.Builder<ContactCheck> checks = new ImmutableList.Builder<>();
for (String id : targetIds) { for (String id : targetIds) {
boolean unused = !existingIds.contains(id); boolean unused = !existingIds.contains(id);

View file

@ -33,9 +33,9 @@ import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec; import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.exceptions.ResourceAlreadyExistsForThisClientException; import google.registry.flows.exceptions.ResourceAlreadyExistsForThisClientException;
import google.registry.flows.exceptions.ResourceCreateContentionException; import google.registry.flows.exceptions.ResourceCreateContentionException;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactCommand.Create; import google.registry.model.contact.ContactCommand.Create;
import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.metadata.MetadataExtension; import google.registry.model.domain.metadata.MetadataExtension;
import google.registry.model.eppinput.ResourceCommand; import google.registry.model.eppinput.ResourceCommand;
import google.registry.model.eppoutput.CreateData.ContactCreateData; import google.registry.model.eppoutput.CreateData.ContactCreateData;
@ -75,9 +75,9 @@ public final class ContactCreateFlow implements TransactionalFlow {
extensionManager.validate(); extensionManager.validate();
Create command = (Create) resourceCommand; Create command = (Create) resourceCommand;
DateTime now = tm().getTransactionTime(); DateTime now = tm().getTransactionTime();
verifyResourceDoesNotExist(ContactResource.class, targetId, now, registrarId); verifyResourceDoesNotExist(Contact.class, targetId, now, registrarId);
ContactResource newContact = Contact newContact =
new ContactResource.Builder() new Contact.Builder()
.setContactId(targetId) .setContactId(targetId)
.setAuthInfo(command.getAuthInfo()) .setAuthInfo(command.getAuthInfo())
.setCreationRegistrarId(registrarId) .setCreationRegistrarId(registrarId)

View file

@ -35,8 +35,8 @@ import google.registry.flows.FlowModule.Superuser;
import google.registry.flows.FlowModule.TargetId; import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow; import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec; import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.metadata.MetadataExtension; import google.registry.model.domain.metadata.MetadataExtension;
import google.registry.model.eppcommon.AuthInfo; import google.registry.model.eppcommon.AuthInfo;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
@ -91,15 +91,15 @@ public final class ContactDeleteFlow implements TransactionalFlow {
validateRegistrarIsLoggedIn(registrarId); validateRegistrarIsLoggedIn(registrarId);
extensionManager.validate(); extensionManager.validate();
DateTime now = tm().getTransactionTime(); DateTime now = tm().getTransactionTime();
checkLinkedDomains(targetId, now, ContactResource.class); checkLinkedDomains(targetId, now, Contact.class);
ContactResource existingContact = loadAndVerifyExistence(ContactResource.class, targetId, now); Contact existingContact = loadAndVerifyExistence(Contact.class, targetId, now);
verifyNoDisallowedStatuses(existingContact, DISALLOWED_STATUSES); verifyNoDisallowedStatuses(existingContact, DISALLOWED_STATUSES);
verifyOptionalAuthInfo(authInfo, existingContact); verifyOptionalAuthInfo(authInfo, existingContact);
if (!isSuperuser) { if (!isSuperuser) {
verifyResourceOwnership(registrarId, existingContact); verifyResourceOwnership(registrarId, existingContact);
} }
// Handle pending transfers on contact deletion. // Handle pending transfers on contact deletion.
ContactResource newContact = Contact newContact =
existingContact.getStatusValues().contains(StatusValue.PENDING_TRANSFER) existingContact.getStatusValues().contains(StatusValue.PENDING_TRANSFER)
? denyPendingTransfer(existingContact, SERVER_CANCELLED, now, registrarId) ? denyPendingTransfer(existingContact, SERVER_CANCELLED, now, registrarId)
: existingContact; : existingContact;

View file

@ -24,10 +24,10 @@ import com.googlecode.objectify.Key;
import google.registry.flows.EppException; import google.registry.flows.EppException;
import google.registry.flows.EppException.ParameterValuePolicyErrorException; import google.registry.flows.EppException.ParameterValuePolicyErrorException;
import google.registry.flows.EppException.ParameterValueSyntaxErrorException; import google.registry.flows.EppException.ParameterValueSyntaxErrorException;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactAddress; import google.registry.model.contact.ContactAddress;
import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactHistory.ContactHistoryId; import google.registry.model.contact.ContactHistory.ContactHistoryId;
import google.registry.model.contact.ContactResource;
import google.registry.model.contact.PostalInfo; import google.registry.model.contact.PostalInfo;
import google.registry.model.poll.PendingActionNotificationResponse.ContactPendingActionNotificationResponse; import google.registry.model.poll.PendingActionNotificationResponse.ContactPendingActionNotificationResponse;
import google.registry.model.poll.PollMessage; import google.registry.model.poll.PollMessage;
@ -61,7 +61,7 @@ public class ContactFlowUtils {
} }
/** Check contact's state against server policy. */ /** Check contact's state against server policy. */
static void validateContactAgainstPolicy(ContactResource contact) throws EppException { static void validateContactAgainstPolicy(Contact contact) throws EppException {
if (contact.getDisclose() != null && !contact.getDisclose().getFlag()) { if (contact.getDisclose() != null && !contact.getDisclose().getFlag()) {
throw new DeclineContactDisclosureFieldDisallowedPolicyException(); throw new DeclineContactDisclosureFieldDisallowedPolicyException();
} }

View file

@ -27,8 +27,8 @@ import google.registry.flows.FlowModule.RegistrarId;
import google.registry.flows.FlowModule.Superuser; import google.registry.flows.FlowModule.Superuser;
import google.registry.flows.FlowModule.TargetId; import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.annotations.ReportingSpec; import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactInfoData; import google.registry.model.contact.ContactInfoData;
import google.registry.model.contact.ContactResource;
import google.registry.model.eppcommon.AuthInfo; import google.registry.model.eppcommon.AuthInfo;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppoutput.EppResponse; import google.registry.model.eppoutput.EppResponse;
@ -69,7 +69,7 @@ public final class ContactInfoFlow implements Flow {
DateTime now = clock.nowUtc(); DateTime now = clock.nowUtc();
validateRegistrarIsLoggedIn(registrarId); validateRegistrarIsLoggedIn(registrarId);
extensionManager.validate(); // There are no legal extensions for this flow. extensionManager.validate(); // There are no legal extensions for this flow.
ContactResource contact = loadAndVerifyExistence(ContactResource.class, targetId, now); Contact contact = loadAndVerifyExistence(Contact.class, targetId, now);
if (!isSuperuser) { if (!isSuperuser) {
verifyResourceOwnership(registrarId, contact); verifyResourceOwnership(registrarId, contact);
} }

View file

@ -33,8 +33,8 @@ import google.registry.flows.FlowModule.RegistrarId;
import google.registry.flows.FlowModule.TargetId; import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow; import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec; import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.metadata.MetadataExtension; import google.registry.model.domain.metadata.MetadataExtension;
import google.registry.model.eppcommon.AuthInfo; import google.registry.model.eppcommon.AuthInfo;
import google.registry.model.eppinput.ResourceCommand; import google.registry.model.eppinput.ResourceCommand;
@ -74,7 +74,7 @@ public final class ContactTransferApproveFlow implements TransactionalFlow {
/** /**
* The logic in this flow, which handles client approvals, very closely parallels the logic in * The logic in this flow, which handles client approvals, very closely parallels the logic in
* {@link ContactResource#cloneProjectedAtTime} which handles implicit server approvals. * {@link Contact#cloneProjectedAtTime} which handles implicit server approvals.
*/ */
@Override @Override
public EppResponse run() throws EppException { public EppResponse run() throws EppException {
@ -82,11 +82,11 @@ public final class ContactTransferApproveFlow implements TransactionalFlow {
validateRegistrarIsLoggedIn(registrarId); validateRegistrarIsLoggedIn(registrarId);
extensionManager.validate(); extensionManager.validate();
DateTime now = tm().getTransactionTime(); DateTime now = tm().getTransactionTime();
ContactResource existingContact = loadAndVerifyExistence(ContactResource.class, targetId, now); Contact existingContact = loadAndVerifyExistence(Contact.class, targetId, now);
verifyOptionalAuthInfo(authInfo, existingContact); verifyOptionalAuthInfo(authInfo, existingContact);
verifyHasPendingTransfer(existingContact); verifyHasPendingTransfer(existingContact);
verifyResourceOwnership(registrarId, existingContact); verifyResourceOwnership(registrarId, existingContact);
ContactResource newContact = Contact newContact =
approvePendingTransfer(existingContact, TransferStatus.CLIENT_APPROVED, now); approvePendingTransfer(existingContact, TransferStatus.CLIENT_APPROVED, now);
ContactHistory contactHistory = ContactHistory contactHistory =
historyBuilder.setType(CONTACT_TRANSFER_APPROVE).setContact(newContact).build(); historyBuilder.setType(CONTACT_TRANSFER_APPROVE).setContact(newContact).build();

View file

@ -33,8 +33,8 @@ import google.registry.flows.FlowModule.RegistrarId;
import google.registry.flows.FlowModule.TargetId; import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow; import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec; import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.metadata.MetadataExtension; import google.registry.model.domain.metadata.MetadataExtension;
import google.registry.model.eppcommon.AuthInfo; import google.registry.model.eppcommon.AuthInfo;
import google.registry.model.eppinput.ResourceCommand; import google.registry.model.eppinput.ResourceCommand;
@ -78,11 +78,11 @@ public final class ContactTransferCancelFlow implements TransactionalFlow {
validateRegistrarIsLoggedIn(registrarId); validateRegistrarIsLoggedIn(registrarId);
extensionManager.validate(); extensionManager.validate();
DateTime now = tm().getTransactionTime(); DateTime now = tm().getTransactionTime();
ContactResource existingContact = loadAndVerifyExistence(ContactResource.class, targetId, now); Contact existingContact = loadAndVerifyExistence(Contact.class, targetId, now);
verifyOptionalAuthInfo(authInfo, existingContact); verifyOptionalAuthInfo(authInfo, existingContact);
verifyHasPendingTransfer(existingContact); verifyHasPendingTransfer(existingContact);
verifyTransferInitiator(registrarId, existingContact); verifyTransferInitiator(registrarId, existingContact);
ContactResource newContact = Contact newContact =
denyPendingTransfer(existingContact, TransferStatus.CLIENT_CANCELLED, now, registrarId); denyPendingTransfer(existingContact, TransferStatus.CLIENT_CANCELLED, now, registrarId);
ContactHistory contactHistory = ContactHistory contactHistory =
historyBuilder.setType(CONTACT_TRANSFER_CANCEL).setContact(newContact).build(); historyBuilder.setType(CONTACT_TRANSFER_CANCEL).setContact(newContact).build();

View file

@ -27,7 +27,7 @@ import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.annotations.ReportingSpec; import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.exceptions.NoTransferHistoryToQueryException; import google.registry.flows.exceptions.NoTransferHistoryToQueryException;
import google.registry.flows.exceptions.NotAuthorizedToViewTransferException; import google.registry.flows.exceptions.NotAuthorizedToViewTransferException;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.eppcommon.AuthInfo; import google.registry.model.eppcommon.AuthInfo;
import google.registry.model.eppoutput.EppResponse; import google.registry.model.eppoutput.EppResponse;
import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField;
@ -66,8 +66,7 @@ public final class ContactTransferQueryFlow implements Flow {
public EppResponse run() throws EppException { public EppResponse run() throws EppException {
validateRegistrarIsLoggedIn(registrarId); validateRegistrarIsLoggedIn(registrarId);
extensionManager.validate(); // There are no legal extensions for this flow. extensionManager.validate(); // There are no legal extensions for this flow.
ContactResource contact = Contact contact = loadAndVerifyExistence(Contact.class, targetId, clock.nowUtc());
loadAndVerifyExistence(ContactResource.class, targetId, clock.nowUtc());
verifyOptionalAuthInfo(authInfo, contact); verifyOptionalAuthInfo(authInfo, contact);
// Most of the fields on the transfer response are required, so there's no way to return valid // Most of the fields on the transfer response are required, so there's no way to return valid
// XML if the object has never been transferred (and hence the fields aren't populated). // XML if the object has never been transferred (and hence the fields aren't populated).

View file

@ -33,8 +33,8 @@ import google.registry.flows.FlowModule.RegistrarId;
import google.registry.flows.FlowModule.TargetId; import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow; import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec; import google.registry.flows.annotations.ReportingSpec;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.metadata.MetadataExtension; import google.registry.model.domain.metadata.MetadataExtension;
import google.registry.model.eppcommon.AuthInfo; import google.registry.model.eppcommon.AuthInfo;
import google.registry.model.eppoutput.EppResponse; import google.registry.model.eppoutput.EppResponse;
@ -76,11 +76,11 @@ public final class ContactTransferRejectFlow implements TransactionalFlow {
validateRegistrarIsLoggedIn(registrarId); validateRegistrarIsLoggedIn(registrarId);
extensionManager.validate(); extensionManager.validate();
DateTime now = tm().getTransactionTime(); DateTime now = tm().getTransactionTime();
ContactResource existingContact = loadAndVerifyExistence(ContactResource.class, targetId, now); Contact existingContact = loadAndVerifyExistence(Contact.class, targetId, now);
verifyOptionalAuthInfo(authInfo, existingContact); verifyOptionalAuthInfo(authInfo, existingContact);
verifyHasPendingTransfer(existingContact); verifyHasPendingTransfer(existingContact);
verifyResourceOwnership(registrarId, existingContact); verifyResourceOwnership(registrarId, existingContact);
ContactResource newContact = Contact newContact =
denyPendingTransfer(existingContact, TransferStatus.CLIENT_REJECTED, now, registrarId); denyPendingTransfer(existingContact, TransferStatus.CLIENT_REJECTED, now, registrarId);
ContactHistory contactHistory = ContactHistory contactHistory =
historyBuilder.setType(CONTACT_TRANSFER_REJECT).setContact(newContact).build(); historyBuilder.setType(CONTACT_TRANSFER_REJECT).setContact(newContact).build();

View file

@ -38,8 +38,8 @@ import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec; import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.exceptions.AlreadyPendingTransferException; import google.registry.flows.exceptions.AlreadyPendingTransferException;
import google.registry.flows.exceptions.ObjectAlreadySponsoredException; import google.registry.flows.exceptions.ObjectAlreadySponsoredException;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.metadata.MetadataExtension; import google.registry.model.domain.metadata.MetadataExtension;
import google.registry.model.eppcommon.AuthInfo; import google.registry.model.eppcommon.AuthInfo;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
@ -96,7 +96,7 @@ public final class ContactTransferRequestFlow implements TransactionalFlow {
validateRegistrarIsLoggedIn(gainingClientId); validateRegistrarIsLoggedIn(gainingClientId);
extensionManager.validate(); extensionManager.validate();
DateTime now = tm().getTransactionTime(); DateTime now = tm().getTransactionTime();
ContactResource existingContact = loadAndVerifyExistence(ContactResource.class, targetId, now); Contact existingContact = loadAndVerifyExistence(Contact.class, targetId, now);
verifyAuthInfoPresentForResourceTransfer(authInfo); verifyAuthInfoPresentForResourceTransfer(authInfo);
verifyAuthInfo(authInfo.get(), existingContact); verifyAuthInfo(authInfo.get(), existingContact);
// Verify that the resource does not already have a pending transfer. // Verify that the resource does not already have a pending transfer.
@ -146,7 +146,9 @@ public final class ContactTransferRequestFlow implements TransactionalFlow {
.asBuilder() .asBuilder()
.setEventTime(now) // Unlike the serverApprove messages, this applies immediately. .setEventTime(now) // Unlike the serverApprove messages, this applies immediately.
.build(); .build();
ContactResource newContact = existingContact.asBuilder() Contact newContact =
existingContact
.asBuilder()
.setTransferData(pendingTransferData) .setTransferData(pendingTransferData)
.addStatusValue(StatusValue.PENDING_TRANSFER) .addStatusValue(StatusValue.PENDING_TRANSFER)
.build(); .build();

View file

@ -36,10 +36,10 @@ import google.registry.flows.FlowModule.TargetId;
import google.registry.flows.TransactionalFlow; import google.registry.flows.TransactionalFlow;
import google.registry.flows.annotations.ReportingSpec; import google.registry.flows.annotations.ReportingSpec;
import google.registry.flows.exceptions.ResourceHasClientUpdateProhibitedException; import google.registry.flows.exceptions.ResourceHasClientUpdateProhibitedException;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactCommand.Update; import google.registry.model.contact.ContactCommand.Update;
import google.registry.model.contact.ContactCommand.Update.Change; import google.registry.model.contact.ContactCommand.Update.Change;
import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactResource;
import google.registry.model.contact.PostalInfo; import google.registry.model.contact.PostalInfo;
import google.registry.model.domain.metadata.MetadataExtension; import google.registry.model.domain.metadata.MetadataExtension;
import google.registry.model.eppcommon.AuthInfo; import google.registry.model.eppcommon.AuthInfo;
@ -94,7 +94,7 @@ public final class ContactUpdateFlow implements TransactionalFlow {
extensionManager.validate(); extensionManager.validate();
Update command = (Update) resourceCommand; Update command = (Update) resourceCommand;
DateTime now = tm().getTransactionTime(); DateTime now = tm().getTransactionTime();
ContactResource existingContact = loadAndVerifyExistence(ContactResource.class, targetId, now); Contact existingContact = loadAndVerifyExistence(Contact.class, targetId, now);
verifyOptionalAuthInfo(authInfo, existingContact); verifyOptionalAuthInfo(authInfo, existingContact);
ImmutableSet<StatusValue> statusToRemove = command.getInnerRemove().getStatusValues(); ImmutableSet<StatusValue> statusToRemove = command.getInnerRemove().getStatusValues();
ImmutableSet<StatusValue> statusesToAdd = command.getInnerAdd().getStatusValues(); ImmutableSet<StatusValue> statusesToAdd = command.getInnerAdd().getStatusValues();
@ -104,7 +104,7 @@ public final class ContactUpdateFlow implements TransactionalFlow {
} }
verifyNoDisallowedStatuses(existingContact, DISALLOWED_STATUSES); verifyNoDisallowedStatuses(existingContact, DISALLOWED_STATUSES);
checkSameValuesNotAddedAndRemoved(statusesToAdd, statusToRemove); checkSameValuesNotAddedAndRemoved(statusesToAdd, statusToRemove);
ContactResource.Builder builder = existingContact.asBuilder(); Contact.Builder builder = existingContact.asBuilder();
Change change = command.getInnerChange(); Change change = command.getInnerChange();
// The spec requires the following behaviors: // The spec requires the following behaviors:
// * If you update part of a postal info, the fields that you didn't update are unchanged. // * If you update part of a postal info, the fields that you didn't update are unchanged.
@ -126,7 +126,7 @@ public final class ContactUpdateFlow implements TransactionalFlow {
builder.setInternationalizedPostalInfo(null); builder.setInternationalizedPostalInfo(null);
} }
} }
ContactResource newContact = Contact newContact =
builder builder
.setLastEppUpdateTime(now) .setLastEppUpdateTime(now)
.setLastEppUpdateRegistrarId(registrarId) .setLastEppUpdateRegistrarId(registrarId)

View file

@ -79,7 +79,7 @@ import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.billing.BillingEvent.Recurring; import google.registry.model.billing.BillingEvent.Recurring;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DesignatedContact;
import google.registry.model.domain.DesignatedContact.Type; import google.registry.model.domain.DesignatedContact.Type;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
@ -380,9 +380,7 @@ public class DomainFlowUtils {
/** Verify that no linked resources have disallowed statuses. */ /** Verify that no linked resources have disallowed statuses. */
static void verifyNotInPendingDelete( static void verifyNotInPendingDelete(
Set<DesignatedContact> contacts, Set<DesignatedContact> contacts, VKey<Contact> registrant, Set<VKey<Host>> nameservers)
VKey<ContactResource> registrant,
Set<VKey<Host>> nameservers)
throws EppException { throws EppException {
ImmutableList.Builder<VKey<? extends EppResource>> keysToLoad = new ImmutableList.Builder<>(); ImmutableList.Builder<VKey<? extends EppResource>> keysToLoad = new ImmutableList.Builder<>();
contacts.stream().map(DesignatedContact::getContactKey).forEach(keysToLoad::add); contacts.stream().map(DesignatedContact::getContactKey).forEach(keysToLoad::add);
@ -427,7 +425,7 @@ public class DomainFlowUtils {
static void validateNoDuplicateContacts(Set<DesignatedContact> contacts) static void validateNoDuplicateContacts(Set<DesignatedContact> contacts)
throws ParameterValuePolicyErrorException { throws ParameterValuePolicyErrorException {
ImmutableMultimap<Type, VKey<ContactResource>> contactsByType = ImmutableMultimap<Type, VKey<Contact>> contactsByType =
contacts.stream() contacts.stream()
.collect( .collect(
toImmutableSetMultimap( toImmutableSetMultimap(
@ -436,15 +434,13 @@ public class DomainFlowUtils {
// If any contact type has multiple contacts: // If any contact type has multiple contacts:
if (contactsByType.asMap().values().stream().anyMatch(v -> v.size() > 1)) { if (contactsByType.asMap().values().stream().anyMatch(v -> v.size() > 1)) {
// Find the duplicates. // Find the duplicates.
Map<Type, Collection<VKey<ContactResource>>> dupeKeysMap = Map<Type, Collection<VKey<Contact>>> dupeKeysMap =
Maps.filterEntries(contactsByType.asMap(), e -> e.getValue().size() > 1); Maps.filterEntries(contactsByType.asMap(), e -> e.getValue().size() > 1);
ImmutableList<VKey<ContactResource>> dupeKeys = ImmutableList<VKey<Contact>> dupeKeys =
dupeKeysMap.values().stream().flatMap(Collection::stream).collect(toImmutableList()); dupeKeysMap.values().stream().flatMap(Collection::stream).collect(toImmutableList());
// Load the duplicates in one batch. // Load the duplicates in one batch.
Map<VKey<? extends ContactResource>, ContactResource> dupeContacts = Map<VKey<? extends Contact>, Contact> dupeContacts = tm().loadByKeys(dupeKeys);
tm().loadByKeys(dupeKeys); ImmutableMultimap.Builder<Type, VKey<Contact>> typesMap = new ImmutableMultimap.Builder<>();
ImmutableMultimap.Builder<Type, VKey<ContactResource>> typesMap =
new ImmutableMultimap.Builder<>();
dupeKeysMap.forEach(typesMap::putAll); dupeKeysMap.forEach(typesMap::putAll);
// Create an error message showing the type and contact IDs of the duplicates. // Create an error message showing the type and contact IDs of the duplicates.
throw new DuplicateContactForRoleException( throw new DuplicateContactForRoleException(
@ -453,7 +449,7 @@ public class DomainFlowUtils {
} }
static void validateRequiredContactsPresent( static void validateRequiredContactsPresent(
@Nullable VKey<ContactResource> registrant, Set<DesignatedContact> contacts) @Nullable VKey<Contact> registrant, Set<DesignatedContact> contacts)
throws RequiredParameterMissingException { throws RequiredParameterMissingException {
if (registrant == null) { if (registrant == null) {
throw new MissingRegistrantException(); throw new MissingRegistrantException();

View file

@ -18,8 +18,8 @@ import com.google.common.collect.ImmutableSet;
import google.registry.model.annotations.DeleteAfterMigration; import google.registry.model.annotations.DeleteAfterMigration;
import google.registry.model.common.EntityGroupRoot; import google.registry.model.common.EntityGroupRoot;
import google.registry.model.common.GaeUserIdConverter; import google.registry.model.common.GaeUserIdConverter;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.token.AllocationToken; import google.registry.model.domain.token.AllocationToken;
@ -42,8 +42,8 @@ public final class EntityClasses {
public static final ImmutableSet<Class<? extends ImmutableObject>> ALL_CLASSES = public static final ImmutableSet<Class<? extends ImmutableObject>> ALL_CLASSES =
ImmutableSet.of( ImmutableSet.of(
AllocationToken.class, AllocationToken.class,
Contact.class,
ContactHistory.class, ContactHistory.class,
ContactResource.class,
Domain.class, Domain.class,
DomainHistory.class, DomainHistory.class,
EntityGroupRoot.class, EntityGroupRoot.class,

View file

@ -32,7 +32,7 @@ import google.registry.config.RegistryConfig;
import google.registry.model.EppResource.BuilderWithTransferData; import google.registry.model.EppResource.BuilderWithTransferData;
import google.registry.model.EppResource.ForeignKeyedEppResource; import google.registry.model.EppResource.ForeignKeyedEppResource;
import google.registry.model.EppResource.ResourceWithTransferData; import google.registry.model.EppResource.ResourceWithTransferData;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.Host; import google.registry.model.host.Host;
@ -345,10 +345,10 @@ public final class EppResourceUtils {
public static ImmutableSet<VKey<Domain>> getLinkedDomainKeys( public static ImmutableSet<VKey<Domain>> getLinkedDomainKeys(
VKey<? extends EppResource> key, DateTime now, @Nullable Integer limit) { VKey<? extends EppResource> key, DateTime now, @Nullable Integer limit) {
checkArgument( checkArgument(
key.getKind().equals(ContactResource.class) || key.getKind().equals(Host.class), key.getKind().equals(Contact.class) || key.getKind().equals(Host.class),
"key must be either VKey<ContactResource> or VKey<Host>, but it is %s", "key must be either VKey<Contact> or VKey<Host>, but it is %s",
key); key);
boolean isContactKey = key.getKind().equals(ContactResource.class); boolean isContactKey = key.getKind().equals(Contact.class);
if (tm().isOfy()) { if (tm().isOfy()) {
com.googlecode.objectify.cmd.Query<Domain> query = com.googlecode.objectify.cmd.Query<Domain> query =
auditedOfy() auditedOfy()

View file

@ -25,7 +25,7 @@ import com.google.common.collect.Sets;
import google.registry.model.EppResource.BuilderWithTransferData; import google.registry.model.EppResource.BuilderWithTransferData;
import google.registry.model.EppResource.ForeignKeyedEppResource; import google.registry.model.EppResource.ForeignKeyedEppResource;
import google.registry.model.EppResource.ResourceWithTransferData; import google.registry.model.EppResource.ResourceWithTransferData;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppcommon.Trid; import google.registry.model.eppcommon.Trid;
@ -60,7 +60,7 @@ public final class ResourceTransferUtils {
EppResource eppResource, TransferData transferData) { EppResource eppResource, TransferData transferData) {
assertIsContactOrDomain(eppResource); assertIsContactOrDomain(eppResource);
TransferResponse.Builder<? extends TransferResponse, ?> builder; TransferResponse.Builder<? extends TransferResponse, ?> builder;
if (eppResource instanceof ContactResource) { if (eppResource instanceof Contact) {
builder = new ContactTransferResponse.Builder().setContactId(eppResource.getForeignKey()); builder = new ContactTransferResponse.Builder().setContactId(eppResource.getForeignKey());
} else { } else {
DomainTransferData domainTransferData = (DomainTransferData) transferData; DomainTransferData domainTransferData = (DomainTransferData) transferData;
@ -93,7 +93,7 @@ public final class ResourceTransferUtils {
boolean actionResult, boolean actionResult,
DateTime processedDate) { DateTime processedDate) {
assertIsContactOrDomain(eppResource); assertIsContactOrDomain(eppResource);
return eppResource instanceof ContactResource return eppResource instanceof Contact
? ContactPendingActionNotificationResponse.create( ? ContactPendingActionNotificationResponse.create(
eppResource.getForeignKey(), actionResult, transferRequestTrid, processedDate) eppResource.getForeignKey(), actionResult, transferRequestTrid, processedDate)
: DomainPendingActionNotificationResponse.create( : DomainPendingActionNotificationResponse.create(
@ -101,7 +101,7 @@ public final class ResourceTransferUtils {
} }
private static void assertIsContactOrDomain(EppResource eppResource) { private static void assertIsContactOrDomain(EppResource eppResource) {
checkState(eppResource instanceof ContactResource || eppResource instanceof Domain); checkState(eppResource instanceof Contact || eppResource instanceof Domain);
} }
/** Update the relevant {@link ForeignKeyIndex} to cache the new deletion time. */ /** Update the relevant {@link ForeignKeyIndex} to cache the new deletion time. */

View file

@ -15,7 +15,6 @@
package google.registry.model.contact; package google.registry.model.contact;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Entity;
import google.registry.model.EppResource.ForeignKeyedEppResource; import google.registry.model.EppResource.ForeignKeyedEppResource;
import google.registry.model.annotations.ExternalMessagingName; import google.registry.model.annotations.ExternalMessagingName;
import google.registry.model.annotations.ReportedOn; import google.registry.model.annotations.ReportedOn;
@ -23,6 +22,10 @@ import google.registry.persistence.VKey;
import google.registry.persistence.WithStringVKey; import google.registry.persistence.WithStringVKey;
import javax.persistence.Access; import javax.persistence.Access;
import javax.persistence.AccessType; import javax.persistence.AccessType;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;
import org.joda.time.DateTime; import org.joda.time.DateTime;
/** /**
@ -32,35 +35,35 @@ import org.joda.time.DateTime;
*/ */
@ReportedOn @ReportedOn
@Entity @Entity
@javax.persistence.Entity(name = "Contact") @com.googlecode.objectify.annotation.Entity
@javax.persistence.Table( @Table(
name = "Contact", name = "Contact",
indexes = { indexes = {
@javax.persistence.Index(columnList = "creationTime"), @Index(columnList = "creationTime"),
@javax.persistence.Index(columnList = "currentSponsorRegistrarId"), @Index(columnList = "currentSponsorRegistrarId"),
@javax.persistence.Index(columnList = "deletionTime"), @Index(columnList = "deletionTime"),
@javax.persistence.Index(columnList = "contactId"), @Index(columnList = "contactId"),
@javax.persistence.Index(columnList = "searchName") @Index(columnList = "searchName")
}) })
@ExternalMessagingName("contact") @ExternalMessagingName("contact")
@WithStringVKey @WithStringVKey
@Access(AccessType.FIELD) @Access(AccessType.FIELD)
public class ContactResource extends ContactBase implements ForeignKeyedEppResource { public class Contact extends ContactBase implements ForeignKeyedEppResource {
@Override @Override
public VKey<ContactResource> createVKey() { public VKey<Contact> createVKey() {
return VKey.create(ContactResource.class, getRepoId(), Key.create(this)); return VKey.create(Contact.class, getRepoId(), Key.create(this));
} }
@Override @Override
@javax.persistence.Id @Id
@Access(AccessType.PROPERTY) @Access(AccessType.PROPERTY)
public String getRepoId() { public String getRepoId() {
return super.getRepoId(); return super.getRepoId();
} }
@Override @Override
public ContactResource cloneProjectedAtTime(DateTime now) { public Contact cloneProjectedAtTime(DateTime now) {
return ContactBase.cloneContactProjectedAtTime(this, now); return ContactBase.cloneContactProjectedAtTime(this, now);
} }
@ -69,12 +72,12 @@ public class ContactResource extends ContactBase implements ForeignKeyedEppResou
return new Builder(clone(this)); return new Builder(clone(this));
} }
/** A builder for constructing {@link ContactResource}, since it is immutable. */ /** A builder for constructing {@link Contact}, since it is immutable. */
public static class Builder extends ContactBase.Builder<ContactResource, Builder> { public static class Builder extends ContactBase.Builder<Contact, Builder> {
public Builder() {} public Builder() {}
private Builder(ContactResource instance) { private Builder(Contact instance) {
super(instance); super(instance);
} }

View file

@ -67,7 +67,7 @@ public class ContactBase extends EppResource implements ResourceWithTransferData
/** /**
* Localized postal info for the contact. All contained values must be representable in the 7-bit * Localized postal info for the contact. All contained values must be representable in the 7-bit
* US-ASCII character set. Personal info; cleared by {@link ContactResource.Builder#wipeOut}. * US-ASCII character set. Personal info; cleared by {@link Contact.Builder#wipeOut}.
*/ */
@Ignore @Ignore
@Embedded @Embedded
@ -95,7 +95,7 @@ public class ContactBase extends EppResource implements ResourceWithTransferData
/** /**
* Internationalized postal info for the contact. Personal info; cleared by {@link * Internationalized postal info for the contact. Personal info; cleared by {@link
* ContactResource.Builder#wipeOut}. * Contact.Builder#wipeOut}.
*/ */
@Ignore @Ignore
@Embedded @Embedded
@ -124,11 +124,11 @@ public class ContactBase extends EppResource implements ResourceWithTransferData
/** /**
* Contact name used for name searches. This is set automatically to be the internationalized * Contact name used for name searches. This is set automatically to be the internationalized
* postal name, or if null, the localized postal name, or if that is null as well, null. Personal * postal name, or if null, the localized postal name, or if that is null as well, null. Personal
* info; cleared by {@link ContactResource.Builder#wipeOut}. * info; cleared by {@link Contact.Builder#wipeOut}.
*/ */
@Index String searchName; @Index String searchName;
/** Contacts voice number. Personal info; cleared by {@link ContactResource.Builder#wipeOut}. */ /** Contacts voice number. Personal info; cleared by {@link Contact.Builder#wipeOut}. */
@IgnoreSave(IfNull.class) @IgnoreSave(IfNull.class)
@Embedded @Embedded
@AttributeOverrides({ @AttributeOverrides({
@ -137,7 +137,7 @@ public class ContactBase extends EppResource implements ResourceWithTransferData
}) })
ContactPhoneNumber voice; ContactPhoneNumber voice;
/** Contacts fax number. Personal info; cleared by {@link ContactResource.Builder#wipeOut}. */ /** Contacts fax number. Personal info; cleared by {@link Contact.Builder#wipeOut}. */
@IgnoreSave(IfNull.class) @IgnoreSave(IfNull.class)
@Embedded @Embedded
@AttributeOverrides({ @AttributeOverrides({
@ -146,7 +146,7 @@ public class ContactBase extends EppResource implements ResourceWithTransferData
}) })
ContactPhoneNumber fax; ContactPhoneNumber fax;
/** Contacts email address. Personal info; cleared by {@link ContactResource.Builder#wipeOut}. */ /** Contacts email address. Personal info; cleared by {@link Contact.Builder#wipeOut}. */
@IgnoreSave(IfNull.class) @IgnoreSave(IfNull.class)
String email; String email;
@ -188,7 +188,7 @@ public class ContactBase extends EppResource implements ResourceWithTransferData
public VKey<? extends ContactBase> createVKey() { public VKey<? extends ContactBase> createVKey() {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"ContactBase is not an actual persisted entity you can create a key to;" "ContactBase is not an actual persisted entity you can create a key to;"
+ " use ContactResource instead"); + " use Contact instead");
} }
@OnLoad @OnLoad
@ -292,7 +292,7 @@ public class ContactBase extends EppResource implements ResourceWithTransferData
return new Builder<>(clone(this)); return new Builder<>(clone(this));
} }
/** A builder for constructing {@link ContactResource}, since it is immutable. */ /** A builder for constructing {@link Contact}, since it is immutable. */
public static class Builder<T extends ContactBase, B extends Builder<T, B>> public static class Builder<T extends ContactBase, B extends Builder<T, B>>
extends EppResource.Builder<T, B> implements BuilderWithTransferData<ContactTransferData, B> { extends EppResource.Builder<T, B> implements BuilderWithTransferData<ContactTransferData, B> {

View file

@ -34,13 +34,13 @@ import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
/** A collection of {@link ContactResource} commands. */ /** A collection of {@link Contact} commands. */
public class ContactCommand { public class ContactCommand {
/** The fields on "chgType" from <a href="http://tools.ietf.org/html/rfc5733">RFC5733</a>. */ /** The fields on "chgType" from <a href="http://tools.ietf.org/html/rfc5733">RFC5733</a>. */
@XmlTransient @XmlTransient
public static class ContactCreateOrChange extends ImmutableObject public static class ContactCreateOrChange extends ImmutableObject
implements ResourceCreateOrChange<ContactResource.Builder> { implements ResourceCreateOrChange<Contact.Builder> {
/** Postal info for the contact. */ /** Postal info for the contact. */
List<PostalInfo> postalInfo; List<PostalInfo> postalInfo;
@ -111,13 +111,13 @@ public class ContactCommand {
} }
/** /**
* A create command for a {@link ContactResource}, mapping "createType" from <a * A create command for a {@link Contact}, mapping "createType" from <a
* href="http://tools.ietf.org/html/rfc5733">RFC5733</a>}. * href="http://tools.ietf.org/html/rfc5733">RFC5733</a>}.
*/ */
@XmlType(propOrder = {"contactId", "postalInfo", "voice", "fax", "email", "authInfo", "disclose"}) @XmlType(propOrder = {"contactId", "postalInfo", "voice", "fax", "email", "authInfo", "disclose"})
@XmlRootElement @XmlRootElement
public static class Create extends ContactCreateOrChange public static class Create extends ContactCreateOrChange
implements SingleResourceCommand, ResourceCreateOrChange<ContactResource.Builder> { implements SingleResourceCommand, ResourceCreateOrChange<Contact.Builder> {
/** /**
* Unique identifier for this contact. * Unique identifier for this contact.
* *
@ -139,29 +139,29 @@ public class ContactCommand {
} }
} }
/** A delete command for a {@link ContactResource}. */ /** A delete command for a {@link Contact}. */
@XmlRootElement @XmlRootElement
public static class Delete extends AbstractSingleResourceCommand {} public static class Delete extends AbstractSingleResourceCommand {}
/** An info request for a {@link ContactResource}. */ /** An info request for a {@link Contact}. */
@XmlRootElement @XmlRootElement
@XmlType(propOrder = {"targetId", "authInfo"}) @XmlType(propOrder = {"targetId", "authInfo"})
public static class Info extends AbstractContactAuthCommand {} public static class Info extends AbstractContactAuthCommand {}
/** A check request for {@link ContactResource}. */ /** A check request for {@link Contact}. */
@XmlRootElement @XmlRootElement
public static class Check extends ResourceCheck {} public static class Check extends ResourceCheck {}
/** A transfer operation for a {@link ContactResource}. */ /** A transfer operation for a {@link Contact}. */
@XmlRootElement @XmlRootElement
@XmlType(propOrder = {"targetId", "authInfo"}) @XmlType(propOrder = {"targetId", "authInfo"})
public static class Transfer extends AbstractContactAuthCommand {} public static class Transfer extends AbstractContactAuthCommand {}
/** An update to a {@link ContactResource}. */ /** An update to a {@link Contact}. */
@XmlRootElement @XmlRootElement
@XmlType(propOrder = {"targetId", "innerAdd", "innerRemove", "innerChange"}) @XmlType(propOrder = {"targetId", "innerAdd", "innerRemove", "innerChange"})
public static class Update public static class Update
extends ResourceUpdate<Update.AddRemove, ContactResource.Builder, Update.Change> { extends ResourceUpdate<Update.AddRemove, Contact.Builder, Update.Change> {
@XmlElement(name = "chg") @XmlElement(name = "chg")
protected Change innerChange; protected Change innerChange;

View file

@ -58,7 +58,7 @@ import javax.persistence.PostLoad;
@IdClass(ContactHistoryId.class) @IdClass(ContactHistoryId.class)
public class ContactHistory extends HistoryEntry implements UnsafeSerializable { public class ContactHistory extends HistoryEntry implements UnsafeSerializable {
// Store ContactBase instead of ContactResource so we don't pick up its @Id // Store ContactBase instead of Contact so we don't pick up its @Id
// Nullable for the sake of pre-Registry-3.0 history objects // Nullable for the sake of pre-Registry-3.0 history objects
@DoNotCompare @Nullable ContactBase contactBase; @DoNotCompare @Nullable ContactBase contactBase;
@ -73,7 +73,7 @@ public class ContactHistory extends HistoryEntry implements UnsafeSerializable {
/** This method is private because it is only used by Hibernate. */ /** This method is private because it is only used by Hibernate. */
@SuppressWarnings("unused") @SuppressWarnings("unused")
private void setContactRepoId(String contactRepoId) { private void setContactRepoId(String contactRepoId) {
parent = Key.create(ContactResource.class, contactRepoId); parent = Key.create(Contact.class, contactRepoId);
} }
@Id @Id
@ -98,9 +98,9 @@ public class ContactHistory extends HistoryEntry implements UnsafeSerializable {
return Optional.ofNullable(contactBase); return Optional.ofNullable(contactBase);
} }
/** The key to the {@link ContactResource} this is based off of. */ /** The key to the {@link Contact} this is based off of. */
public VKey<ContactResource> getParentVKey() { public VKey<Contact> getParentVKey() {
return VKey.create(ContactResource.class, getContactRepoId()); return VKey.create(Contact.class, getContactRepoId());
} }
/** Creates a {@link VKey} instance for this entity. */ /** Creates a {@link VKey} instance for this entity. */
@ -112,8 +112,7 @@ public class ContactHistory extends HistoryEntry implements UnsafeSerializable {
@Override @Override
public Optional<? extends EppResource> getResourceAtPointInTime() { public Optional<? extends EppResource> getResourceAtPointInTime() {
return getContactBase() return getContactBase().map(contactBase -> new Contact.Builder().copyFrom(contactBase).build());
.map(contactBase -> new ContactResource.Builder().copyFrom(contactBase).build());
} }
@PostLoad @PostLoad
@ -210,7 +209,7 @@ public class ContactHistory extends HistoryEntry implements UnsafeSerializable {
} }
public Builder setContactRepoId(String contactRepoId) { public Builder setContactRepoId(String contactRepoId) {
getInstance().parent = Key.create(ContactResource.class, contactRepoId); getInstance().parent = Key.create(Contact.class, contactRepoId);
return this; return this;
} }

View file

@ -21,11 +21,11 @@ import javax.persistence.Embeddable;
/** /**
* EPP Contact Phone Number * EPP Contact Phone Number
* *
* <p>This class is embedded inside a {@link ContactResource} hold the phone number of an EPP * <p>This class is embedded inside a {@link Contact} hold the phone number of an EPP contact. The
* contact. The fields are all defined in the parent class {@link PhoneNumber}, but the subclass is * fields are all defined in the parent class {@link PhoneNumber}, but the subclass is still
* still necessary to pick up the contact namespace. * necessary to pick up the contact namespace.
* *
* @see ContactResource * @see Contact
*/ */
@Embed @Embed
@Embeddable @Embeddable

View file

@ -22,7 +22,7 @@ import com.googlecode.objectify.annotation.Ignore;
import com.googlecode.objectify.annotation.Index; import com.googlecode.objectify.annotation.Index;
import google.registry.model.ImmutableObject; import google.registry.model.ImmutableObject;
import google.registry.model.UnsafeSerializable; import google.registry.model.UnsafeSerializable;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.persistence.VKey; import google.registry.persistence.VKey;
import javax.persistence.Embeddable; import javax.persistence.Embeddable;
import javax.xml.bind.annotation.XmlEnumValue; import javax.xml.bind.annotation.XmlEnumValue;
@ -64,7 +64,7 @@ public class DesignatedContact extends ImmutableObject implements UnsafeSerializ
REGISTRANT REGISTRANT
} }
public static DesignatedContact create(Type type, VKey<ContactResource> contact) { public static DesignatedContact create(Type type, VKey<Contact> contact) {
DesignatedContact instance = new DesignatedContact(); DesignatedContact instance = new DesignatedContact();
instance.type = type; instance.type = type;
instance.contactVKey = checkArgumentNotNull(contact, "Must specify contact key"); instance.contactVKey = checkArgumentNotNull(contact, "Must specify contact key");
@ -74,14 +74,14 @@ public class DesignatedContact extends ImmutableObject implements UnsafeSerializ
Type type; Type type;
@Index Key<ContactResource> contact; @Index Key<Contact> contact;
@Ignore VKey<ContactResource> contactVKey; @Ignore VKey<Contact> contactVKey;
public Type getType() { public Type getType() {
return type; return type;
} }
public VKey<ContactResource> getContactKey() { public VKey<Contact> getContactKey() {
return contactVKey; return contactVKey;
} }

View file

@ -52,7 +52,7 @@ import google.registry.model.EppResource;
import google.registry.model.EppResource.ResourceWithTransferData; import google.registry.model.EppResource.ResourceWithTransferData;
import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent;
import google.registry.model.common.EntityGroupRoot; import google.registry.model.common.EntityGroupRoot;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.launch.LaunchNotice; import google.registry.model.domain.launch.LaunchNotice;
import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.domain.rgp.GracePeriodStatus;
import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.domain.secdns.DelegationSignerData;
@ -132,11 +132,11 @@ public class DomainBase extends EppResource
@EmptySetToNull @Index @Transient Set<VKey<Host>> nsHosts; @EmptySetToNull @Index @Transient Set<VKey<Host>> nsHosts;
/** Contacts. */ /** Contacts. */
VKey<ContactResource> adminContact; VKey<Contact> adminContact;
VKey<ContactResource> billingContact; VKey<Contact> billingContact;
VKey<ContactResource> techContact; VKey<Contact> techContact;
VKey<ContactResource> registrantContact; VKey<Contact> registrantContact;
/** Authorization info (aka transfer secret) of the domain. */ /** Authorization info (aka transfer secret) of the domain. */
@Embedded @Embedded
@ -602,19 +602,19 @@ public class DomainBase extends EppResource
} }
/** A key to the registrant who registered this domain. */ /** A key to the registrant who registered this domain. */
public VKey<ContactResource> getRegistrant() { public VKey<Contact> getRegistrant() {
return registrantContact; return registrantContact;
} }
public VKey<ContactResource> getAdminContact() { public VKey<Contact> getAdminContact() {
return adminContact; return adminContact;
} }
public VKey<ContactResource> getBillingContact() { public VKey<Contact> getBillingContact() {
return billingContact; return billingContact;
} }
public VKey<ContactResource> getTechContact() { public VKey<Contact> getTechContact() {
return techContact; return techContact;
} }
@ -628,7 +628,7 @@ public class DomainBase extends EppResource
} }
/** Returns all referenced contacts from this domain. */ /** Returns all referenced contacts from this domain. */
public ImmutableSet<VKey<ContactResource>> getReferencedContacts() { public ImmutableSet<VKey<Contact>> getReferencedContacts() {
return nullToEmptyImmutableCopy(getAllContacts(true)).stream() return nullToEmptyImmutableCopy(getAllContacts(true)).stream()
.map(DesignatedContact::getContactKey) .map(DesignatedContact::getContactKey)
.filter(Objects::nonNull) .filter(Objects::nonNull)
@ -771,7 +771,7 @@ public class DomainBase extends EppResource
return thisCastToDerived(); return thisCastToDerived();
} }
public B setRegistrant(VKey<ContactResource> registrant) { public B setRegistrant(VKey<Contact> registrant) {
// Set the registrant field specifically. // Set the registrant field specifically.
getInstance().registrantContact = registrant; getInstance().registrantContact = registrant;
return thisCastToDerived(); return thisCastToDerived();

View file

@ -32,7 +32,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.ImmutableObject; import google.registry.model.ImmutableObject;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.eppinput.ResourceCommand.AbstractSingleResourceCommand; import google.registry.model.eppinput.ResourceCommand.AbstractSingleResourceCommand;
import google.registry.model.eppinput.ResourceCommand.ResourceCheck; import google.registry.model.eppinput.ResourceCommand.ResourceCheck;
import google.registry.model.eppinput.ResourceCommand.ResourceCreateOrChange; import google.registry.model.eppinput.ResourceCommand.ResourceCreateOrChange;
@ -80,7 +80,7 @@ public class DomainCommand {
String registrantContactId; String registrantContactId;
/** A resolved key to the registrant who registered this domain. */ /** A resolved key to the registrant who registered this domain. */
@XmlTransient VKey<ContactResource> registrant; @XmlTransient VKey<Contact> registrant;
/** Authorization info (aka transfer secret) of the domain. */ /** Authorization info (aka transfer secret) of the domain. */
DomainAuthInfo authInfo; DomainAuthInfo authInfo;
@ -90,7 +90,7 @@ public class DomainCommand {
} }
@Nullable @Nullable
public VKey<ContactResource> getRegistrant() { public VKey<Contact> getRegistrant() {
return registrant; return registrant;
} }
@ -391,7 +391,7 @@ public class DomainCommand {
? null ? null
: getOnlyElement( : getOnlyElement(
loadByForeignKeysCached( loadByForeignKeysCached(
ImmutableSet.of(clone.registrantContactId), ContactResource.class, now) ImmutableSet.of(clone.registrantContactId), Contact.class, now)
.values()); .values());
return clone; return clone;
} }
@ -431,8 +431,8 @@ public class DomainCommand {
for (ForeignKeyedDesignatedContact contact : contacts) { for (ForeignKeyedDesignatedContact contact : contacts) {
foreignKeys.add(contact.contactId); foreignKeys.add(contact.contactId);
} }
ImmutableMap<String, VKey<ContactResource>> loadedContacts = ImmutableMap<String, VKey<Contact>> loadedContacts =
loadByForeignKeysCached(foreignKeys.build(), ContactResource.class, now); loadByForeignKeysCached(foreignKeys.build(), Contact.class, now);
ImmutableSet.Builder<DesignatedContact> linkedContacts = new ImmutableSet.Builder<>(); ImmutableSet.Builder<DesignatedContact> linkedContacts = new ImmutableSet.Builder<>();
for (ForeignKeyedDesignatedContact contact : contacts) { for (ForeignKeyedDesignatedContact contact : contacts) {
linkedContacts.add( linkedContacts.add(

View file

@ -20,8 +20,8 @@ import static com.google.common.base.Strings.nullToEmpty;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactBase; import google.registry.model.contact.ContactBase;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.DomainBase;
import google.registry.model.host.Host; import google.registry.model.host.Host;
@ -130,12 +130,12 @@ public enum StatusValue implements EppEnum {
/** Enum to help clearly list which resource types a status value is allowed to be present on. */ /** Enum to help clearly list which resource types a status value is allowed to be present on. */
private enum AllowedOn { private enum AllowedOn {
ALL( ALL(
Contact.class,
ContactBase.class, ContactBase.class,
ContactResource.class,
DomainBase.class,
Domain.class, Domain.class,
HostBase.class, DomainBase.class,
Host.class), Host.class,
HostBase.class),
NONE, NONE,
DOMAINS(DomainBase.class, Domain.class); DOMAINS(DomainBase.class, Domain.class);

View file

@ -47,7 +47,7 @@ import google.registry.model.CacheUtils.AppEngineEnvironmentCacheLoader;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.annotations.DeleteAfterMigration; import google.registry.model.annotations.DeleteAfterMigration;
import google.registry.model.annotations.ReportedOn; import google.registry.model.annotations.ReportedOn;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.host.Host; import google.registry.model.host.Host;
import google.registry.persistence.VKey; import google.registry.persistence.VKey;
@ -70,10 +70,10 @@ import org.joda.time.DateTime;
@DeleteAfterMigration @DeleteAfterMigration
public abstract class ForeignKeyIndex<E extends EppResource> extends BackupGroupRoot { public abstract class ForeignKeyIndex<E extends EppResource> extends BackupGroupRoot {
/** The {@link ForeignKeyIndex} type for {@link ContactResource} entities. */ /** The {@link ForeignKeyIndex} type for {@link Contact} entities. */
@ReportedOn @ReportedOn
@Entity @Entity
public static class ForeignKeyContactIndex extends ForeignKeyIndex<ContactResource> {} public static class ForeignKeyContactIndex extends ForeignKeyIndex<Contact> {}
/** The {@link ForeignKeyIndex} type for {@link Domain} entities. */ /** The {@link ForeignKeyIndex} type for {@link Domain} entities. */
@ReportedOn @ReportedOn
@ -89,14 +89,14 @@ public abstract class ForeignKeyIndex<E extends EppResource> extends BackupGroup
Class<? extends EppResource>, Class<? extends ForeignKeyIndex<?>>> Class<? extends EppResource>, Class<? extends ForeignKeyIndex<?>>>
RESOURCE_CLASS_TO_FKI_CLASS = RESOURCE_CLASS_TO_FKI_CLASS =
ImmutableBiMap.of( ImmutableBiMap.of(
ContactResource.class, ForeignKeyContactIndex.class, Contact.class, ForeignKeyContactIndex.class,
Domain.class, ForeignKeyDomainIndex.class, Domain.class, ForeignKeyDomainIndex.class,
Host.class, ForeignKeyHostIndex.class); Host.class, ForeignKeyHostIndex.class);
private static final ImmutableMap<Class<? extends EppResource>, String> private static final ImmutableMap<Class<? extends EppResource>, String>
RESOURCE_CLASS_TO_FKI_PROPERTY = RESOURCE_CLASS_TO_FKI_PROPERTY =
ImmutableMap.of( ImmutableMap.of(
ContactResource.class, "contactId", Contact.class, "contactId",
Domain.class, "fullyQualifiedDomainName", Domain.class, "fullyQualifiedDomainName",
Host.class, "fullyQualifiedHostName"); Host.class, "fullyQualifiedHostName");

View file

@ -34,7 +34,7 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
* *
* <p>All first class entities are represented as a resource class - {@link * <p>All first class entities are represented as a resource class - {@link
* google.registry.model.domain.Domain}, {@link google.registry.model.host.Host}, {@link * google.registry.model.domain.Domain}, {@link google.registry.model.host.Host}, {@link
* google.registry.model.contact.ContactResource}, and {@link * google.registry.model.contact.Contact}, and {@link
* google.registry.model.registrar.Registrar}. Resource objects are written in a single shared * google.registry.model.registrar.Registrar}. Resource objects are written in a single shared
* entity group per TLD. All commands that operate on those entities are grouped in a "Command" * entity group per TLD. All commands that operate on those entities are grouped in a "Command"
* class- {@link google.registry.model.domain.DomainCommand}, {@link * class- {@link google.registry.model.domain.DomainCommand}, {@link

View file

@ -26,9 +26,9 @@ import google.registry.model.ImmutableObject;
import google.registry.model.UnsafeSerializable; import google.registry.model.UnsafeSerializable;
import google.registry.model.annotations.ExternalMessagingName; import google.registry.model.annotations.ExternalMessagingName;
import google.registry.model.annotations.OfyIdAllocation; import google.registry.model.annotations.OfyIdAllocation;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactHistory.ContactHistoryId; import google.registry.model.contact.ContactHistory.ContactHistoryId;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.DomainHistory.DomainHistoryId; import google.registry.model.domain.DomainHistory.DomainHistoryId;
@ -95,7 +95,7 @@ public abstract class PollMessage extends ImmutableObject
/** Indicates the type of entity the poll message is for. */ /** Indicates the type of entity the poll message is for. */
public enum Type { public enum Type {
DOMAIN(1L, Domain.class), DOMAIN(1L, Domain.class),
CONTACT(2L, ContactResource.class), CONTACT(2L, Contact.class),
HOST(3L, Host.class); HOST(3L, Host.class);
private final long id; private final long id;
@ -179,7 +179,7 @@ public abstract class PollMessage extends ImmutableObject
/** /**
* Returns the contact repo id. * Returns the contact repo id.
* *
* <p>This may only be used on a ContactResource poll event. * <p>This may only be used on a {@link Contact} poll event.
*/ */
public String getContactRepoId() { public String getContactRepoId() {
checkArgument(getType() == Type.CONTACT); checkArgument(getType() == Type.CONTACT);

View file

@ -34,10 +34,10 @@ import google.registry.model.EppResource;
import google.registry.model.ImmutableObject; import google.registry.model.ImmutableObject;
import google.registry.model.UnsafeSerializable; import google.registry.model.UnsafeSerializable;
import google.registry.model.annotations.ReportedOn; import google.registry.model.annotations.ReportedOn;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactBase; import google.registry.model.contact.ContactBase;
import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactHistory.ContactHistoryId; import google.registry.model.contact.ContactHistory.ContactHistoryId;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
@ -392,7 +392,7 @@ public class HistoryEntry extends ImmutableObject implements Buildable, UnsafeSe
} else if (parentKind.equals(getKind(Host.class))) { } else if (parentKind.equals(getKind(Host.class))) {
resultEntity = resultEntity =
new HostHistory.Builder().copyFrom(this).setHostRepoId(parent.getName()).build(); new HostHistory.Builder().copyFrom(this).setHostRepoId(parent.getName()).build();
} else if (parentKind.equals(getKind(ContactResource.class))) { } else if (parentKind.equals(getKind(Contact.class))) {
resultEntity = resultEntity =
new ContactHistory.Builder().copyFrom(this).setContactRepoId(parent.getName()).build(); new ContactHistory.Builder().copyFrom(this).setContactRepoId(parent.getName()).build();
} else { } else {
@ -418,7 +418,7 @@ public class HistoryEntry extends ImmutableObject implements Buildable, UnsafeSe
HostHistory.class, HostHistory.class,
new HostHistoryId(repoId, id), new HostHistoryId(repoId, id),
Key.create(parent, HostHistory.class, id)); Key.create(parent, HostHistory.class, id));
} else if (parentKind.equals(getKind(ContactResource.class))) { } else if (parentKind.equals(getKind(Contact.class))) {
return VKey.create( return VKey.create(
ContactHistory.class, ContactHistory.class,
new ContactHistoryId(repoId, id), new ContactHistoryId(repoId, id),

View file

@ -25,8 +25,8 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Streams; import com.google.common.collect.Streams;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.host.Host; import google.registry.model.host.Host;
@ -51,7 +51,7 @@ public class HistoryEntryDao {
public static ImmutableMap<Class<? extends EppResource>, Class<? extends HistoryEntry>> public static ImmutableMap<Class<? extends EppResource>, Class<? extends HistoryEntry>>
RESOURCE_TYPES_TO_HISTORY_TYPES = RESOURCE_TYPES_TO_HISTORY_TYPES =
ImmutableMap.of( ImmutableMap.of(
ContactResource.class, Contact.class,
ContactHistory.class, ContactHistory.class,
Domain.class, Domain.class,
DomainHistory.class, DomainHistory.class,

View file

@ -40,7 +40,7 @@ public class EppHistoryVKeyTranslatorFactory
// one dedicated VKey class, e.g. DomainHistoryVKey, for each such kind of entity, and we need // one dedicated VKey class, e.g. DomainHistoryVKey, for each such kind of entity, and we need
// a way to map the raw Datastore key to its VKey class. So, we use the kind path as the key of // a way to map the raw Datastore key to its VKey class. So, we use the kind path as the key of
// the map, and the kind path is created by concatenating all the kind strings in a raw Datastore // the map, and the kind path is created by concatenating all the kind strings in a raw Datastore
// key, e.g. the map key for ContactPollMessageVKey is "ContactResource/HistoryEntry/PollMessage". // key, e.g. the map key for ContactPollMessageVKey is "Contact/HistoryEntry/PollMessage".
@VisibleForTesting @VisibleForTesting
static final ImmutableMap<String, Class<? extends EppHistoryVKey>> kindPathToVKeyClass = static final ImmutableMap<String, Class<? extends EppHistoryVKey>> kindPathToVKeyClass =
ImmutableSet.of(DomainHistoryVKey.class).stream() ImmutableSet.of(DomainHistoryVKey.class).stream()

View file

@ -23,7 +23,7 @@ import static google.registry.request.Action.Method.HEAD;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.primitives.Longs; import com.google.common.primitives.Longs;
import com.google.re2j.Pattern; import com.google.re2j.Pattern;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
import google.registry.persistence.VKey; import google.registry.persistence.VKey;
import google.registry.rdap.RdapJsonFormatter.OutputDataType; import google.registry.rdap.RdapJsonFormatter.OutputDataType;
@ -69,14 +69,14 @@ public class RdapEntityAction extends RdapActionBase {
// RDAP Technical Implementation Guide 2.3.1 - MUST support contact entity lookup using the // RDAP Technical Implementation Guide 2.3.1 - MUST support contact entity lookup using the
// handle // handle
if (ROID_PATTERN.matcher(pathSearchString).matches()) { if (ROID_PATTERN.matcher(pathSearchString).matches()) {
VKey<ContactResource> contactVKey = VKey.create(ContactResource.class, pathSearchString); VKey<Contact> contactVKey = VKey.create(Contact.class, pathSearchString);
Optional<ContactResource> contactResource = Optional<Contact> contact =
replicaJpaTm().transact(() -> replicaJpaTm().loadByKeyIfPresent(contactVKey)); replicaJpaTm().transact(() -> replicaJpaTm().loadByKeyIfPresent(contactVKey));
// As per Andy Newton on the regext mailing list, contacts by themselves have no role, since // As per Andy Newton on the regext mailing list, contacts by themselves have no role, since
// they are global, and might have different roles for different domains. // they are global, and might have different roles for different domains.
if (contactResource.isPresent() && isAuthorized(contactResource.get())) { if (contact.isPresent() && isAuthorized(contact.get())) {
return rdapJsonFormatter.createRdapContactEntity( return rdapJsonFormatter.createRdapContactEntity(
contactResource.get(), ImmutableSet.of(), OutputDataType.FULL); contact.get(), ImmutableSet.of(), OutputDataType.FULL);
} }
} }

View file

@ -28,7 +28,7 @@ import com.google.common.collect.Streams;
import com.google.common.primitives.Booleans; import com.google.common.primitives.Booleans;
import com.google.common.primitives.Longs; import com.google.common.primitives.Longs;
import com.googlecode.objectify.cmd.Query; import com.googlecode.objectify.cmd.Query;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
import google.registry.persistence.VKey; import google.registry.persistence.VKey;
import google.registry.persistence.transaction.CriteriaQueryBuilder; import google.registry.persistence.transaction.CriteriaQueryBuilder;
@ -253,7 +253,7 @@ public class RdapEntitySearchAction extends RdapSearchActionBase {
// see any names anyway. Also, if a registrar cursor is present, we have already moved past the // see any names anyway. Also, if a registrar cursor is present, we have already moved past the
// contacts, and don't need to fetch them this time. We can skip contacts if subtype is // contacts, and don't need to fetch them this time. We can skip contacts if subtype is
// REGISTRARS. // REGISTRARS.
RdapResultSet<ContactResource> resultSet; RdapResultSet<Contact> resultSet;
if (subtype == Subtype.REGISTRARS) { if (subtype == Subtype.REGISTRARS) {
resultSet = RdapResultSet.create(ImmutableList.of()); resultSet = RdapResultSet.create(ImmutableList.of());
} else { } else {
@ -262,9 +262,9 @@ public class RdapEntitySearchAction extends RdapSearchActionBase {
resultSet = RdapResultSet.create(ImmutableList.of()); resultSet = RdapResultSet.create(ImmutableList.of());
} else { } else {
if (tm().isOfy()) { if (tm().isOfy()) {
Query<ContactResource> query = Query<Contact> query =
queryItems( queryItems(
ContactResource.class, Contact.class,
"searchName", "searchName",
partialStringQuery, partialStringQuery,
cursorQueryString, // if we get here and there's a cursor, it must be a contact cursorQueryString, // if we get here and there's a cursor, it must be a contact
@ -279,9 +279,9 @@ public class RdapEntitySearchAction extends RdapSearchActionBase {
replicaJpaTm() replicaJpaTm()
.transact( .transact(
() -> { () -> {
CriteriaQueryBuilder<ContactResource> builder = CriteriaQueryBuilder<Contact> builder =
queryItemsSql( queryItemsSql(
ContactResource.class, Contact.class,
"searchName", "searchName",
partialStringQuery, partialStringQuery,
cursorQueryString, cursorQueryString,
@ -319,21 +319,20 @@ public class RdapEntitySearchAction extends RdapSearchActionBase {
} }
// Handle queries without a wildcard (and not including deleted) -- load by ID. // Handle queries without a wildcard (and not including deleted) -- load by ID.
if (!partialStringQuery.getHasWildcard() && !shouldIncludeDeleted()) { if (!partialStringQuery.getHasWildcard() && !shouldIncludeDeleted()) {
ImmutableList<ContactResource> contactResourceList; ImmutableList<Contact> contactList;
if (subtype == Subtype.REGISTRARS) { if (subtype == Subtype.REGISTRARS) {
contactResourceList = ImmutableList.of(); contactList = ImmutableList.of();
} else { } else {
Optional<ContactResource> contactResource = Optional<Contact> contact =
replicaJpaTm() replicaJpaTm()
.transact( .transact(
() -> () ->
replicaJpaTm() replicaJpaTm()
.loadByKeyIfPresent( .loadByKeyIfPresent(
VKey.create( VKey.create(Contact.class, partialStringQuery.getInitialString())));
ContactResource.class, partialStringQuery.getInitialString()))); contactList =
contactResourceList = (contact.isPresent() && shouldBeVisible(contact.get()))
(contactResource.isPresent() && shouldBeVisible(contactResource.get())) ? ImmutableList.of(contact.get())
? ImmutableList.of(contactResource.get())
: ImmutableList.of(); : ImmutableList.of();
} }
ImmutableList<Registrar> registrarList; ImmutableList<Registrar> registrarList;
@ -343,9 +342,9 @@ public class RdapEntitySearchAction extends RdapSearchActionBase {
registrarList = getMatchingRegistrars(partialStringQuery.getInitialString()); registrarList = getMatchingRegistrars(partialStringQuery.getInitialString());
} }
return makeSearchResults( return makeSearchResults(
contactResourceList, contactList,
IncompletenessWarningType.COMPLETE, IncompletenessWarningType.COMPLETE,
contactResourceList.size(), contactList.size(),
registrarList, registrarList,
QueryType.HANDLE); QueryType.HANDLE);
// Handle queries with a wildcard (or including deleted), but no suffix. Because the handle // Handle queries with a wildcard (or including deleted), but no suffix. Because the handle
@ -383,7 +382,7 @@ public class RdapEntitySearchAction extends RdapSearchActionBase {
// get excluded due to permissioning. Any cursor present must be a contact cursor, because we // get excluded due to permissioning. Any cursor present must be a contact cursor, because we
// would never return a registrar for this search. // would never return a registrar for this search.
int querySizeLimit = getStandardQuerySizeLimit(); int querySizeLimit = getStandardQuerySizeLimit();
RdapResultSet<ContactResource> contactResultSet; RdapResultSet<Contact> contactResultSet;
if (subtype == Subtype.REGISTRARS) { if (subtype == Subtype.REGISTRARS) {
contactResultSet = RdapResultSet.create(ImmutableList.of()); contactResultSet = RdapResultSet.create(ImmutableList.of());
} else { } else {
@ -391,7 +390,7 @@ public class RdapEntitySearchAction extends RdapSearchActionBase {
contactResultSet = contactResultSet =
getMatchingResources( getMatchingResources(
queryItemsByKey( queryItemsByKey(
ContactResource.class, Contact.class,
partialStringQuery, partialStringQuery,
cursorQueryString, cursorQueryString,
getDeletedItemHandling(), getDeletedItemHandling(),
@ -405,7 +404,7 @@ public class RdapEntitySearchAction extends RdapSearchActionBase {
() -> () ->
getMatchingResourcesSql( getMatchingResourcesSql(
queryItemsByKeySql( queryItemsByKeySql(
ContactResource.class, Contact.class,
partialStringQuery, partialStringQuery,
cursorQueryString, cursorQueryString,
getDeletedItemHandling()), getDeletedItemHandling()),
@ -436,7 +435,7 @@ public class RdapEntitySearchAction extends RdapSearchActionBase {
* properties of the {@link RdapResultSet} structure and passes them as separate arguments. * properties of the {@link RdapResultSet} structure and passes them as separate arguments.
*/ */
private EntitySearchResponse makeSearchResults( private EntitySearchResponse makeSearchResults(
RdapResultSet<ContactResource> resultSet, List<Registrar> registrars, QueryType queryType) { RdapResultSet<Contact> resultSet, List<Registrar> registrars, QueryType queryType) {
return makeSearchResults( return makeSearchResults(
resultSet.resources(), resultSet.resources(),
resultSet.incompletenessWarningType(), resultSet.incompletenessWarningType(),
@ -461,7 +460,7 @@ public class RdapEntitySearchAction extends RdapSearchActionBase {
* @return an {@link RdapSearchResults} object * @return an {@link RdapSearchResults} object
*/ */
private EntitySearchResponse makeSearchResults( private EntitySearchResponse makeSearchResults(
List<ContactResource> contacts, List<Contact> contacts,
IncompletenessWarningType incompletenessWarningType, IncompletenessWarningType incompletenessWarningType,
int numContactsRetrieved, int numContactsRetrieved,
List<Registrar> registrars, List<Registrar> registrars,
@ -485,7 +484,7 @@ public class RdapEntitySearchAction extends RdapSearchActionBase {
EntitySearchResponse.builder() EntitySearchResponse.builder()
.setIncompletenessWarningType(incompletenessWarningType); .setIncompletenessWarningType(incompletenessWarningType);
Optional<String> newCursor = Optional.empty(); Optional<String> newCursor = Optional.empty();
for (ContactResource contact : Iterables.limit(contacts, rdapResultSetMaxSize)) { for (Contact contact : Iterables.limit(contacts, rdapResultSetMaxSize)) {
// As per Andy Newton on the regext mailing list, contacts by themselves have no role, since // As per Andy Newton on the regext mailing list, contacts by themselves have no role, since
// they are global, and might have different roles for different domains. // they are global, and might have different roles for different domains.
builder builder

View file

@ -39,9 +39,9 @@ import com.google.common.net.InetAddresses;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import google.registry.config.RegistryConfig.Config; import google.registry.config.RegistryConfig.Config;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactAddress; import google.registry.model.contact.ContactAddress;
import google.registry.model.contact.ContactPhoneNumber; import google.registry.model.contact.ContactPhoneNumber;
import google.registry.model.contact.ContactResource;
import google.registry.model.contact.PostalInfo; import google.registry.model.contact.PostalInfo;
import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DesignatedContact;
import google.registry.model.domain.DesignatedContact.Type; import google.registry.model.domain.DesignatedContact.Type;
@ -363,7 +363,7 @@ public class RdapJsonFormatter {
ImmutableSet.copyOf( ImmutableSet.copyOf(
replicaJpaTm().loadByKeys(domain.getNameservers()).values())); replicaJpaTm().loadByKeys(domain.getNameservers()).values()));
// Load the registrant and other contacts and add them to the data. // Load the registrant and other contacts and add them to the data.
ImmutableMap<VKey<? extends ContactResource>, ContactResource> loadedContacts = ImmutableMap<VKey<? extends Contact>, Contact> loadedContacts =
replicaJpaTm() replicaJpaTm()
.transact(() -> replicaJpaTm().loadByKeysIfPresent(domain.getReferencedContacts())); .transact(() -> replicaJpaTm().loadByKeysIfPresent(domain.getReferencedContacts()));
// RDAP Response Profile 2.7.3, A domain MUST have the REGISTRANT, ADMIN, TECH roles and MAY // RDAP Response Profile 2.7.3, A domain MUST have the REGISTRANT, ADMIN, TECH roles and MAY
@ -373,7 +373,7 @@ public class RdapJsonFormatter {
// fields we don't want to show (as opposed to not having contacts at all) because of GDPR etc. // fields we don't want to show (as opposed to not having contacts at all) because of GDPR etc.
// //
// the GDPR redaction is handled in createRdapContactEntity // the GDPR redaction is handled in createRdapContactEntity
ImmutableSetMultimap<VKey<ContactResource>, Type> contactsToRoles = ImmutableSetMultimap<VKey<Contact>, Type> contactsToRoles =
Streams.concat( Streams.concat(
domain.getContacts().stream(), domain.getContacts().stream(),
Stream.of(DesignatedContact.create(Type.REGISTRANT, domain.getRegistrant()))) Stream.of(DesignatedContact.create(Type.REGISTRANT, domain.getRegistrant())))
@ -382,7 +382,7 @@ public class RdapJsonFormatter {
toImmutableSetMultimap( toImmutableSetMultimap(
DesignatedContact::getContactKey, DesignatedContact::getType)); DesignatedContact::getContactKey, DesignatedContact::getType));
for (VKey<ContactResource> contactKey : contactsToRoles.keySet()) { for (VKey<Contact> contactKey : contactsToRoles.keySet()) {
Set<RdapEntity.Role> roles = Set<RdapEntity.Role> roles =
contactsToRoles.get(contactKey).stream() contactsToRoles.get(contactKey).stream()
.map(RdapJsonFormatter::convertContactTypeToRdapRole) .map(RdapJsonFormatter::convertContactTypeToRdapRole)
@ -495,16 +495,14 @@ public class RdapJsonFormatter {
} }
/** /**
* Creates a JSON object for a {@link ContactResource} and associated contact type. * Creates a JSON object for a {@link Contact} and associated contact type.
* *
* @param contactResource the contact resource object from which the JSON object should be created * @param contact the contact resource object from which the JSON object should be created
* @param roles the roles of this contact * @param roles the roles of this contact
* @param outputDataType whether to generate full or summary data * @param outputDataType whether to generate full or summary data
*/ */
RdapContactEntity createRdapContactEntity( RdapContactEntity createRdapContactEntity(
ContactResource contactResource, Contact contact, Iterable<RdapEntity.Role> roles, OutputDataType outputDataType) {
Iterable<RdapEntity.Role> roles,
OutputDataType outputDataType) {
RdapContactEntity.Builder contactBuilder = RdapContactEntity.builder(); RdapContactEntity.Builder contactBuilder = RdapContactEntity.builder();
// RDAP Response Profile 2.7.1, 2.7.3 - we MUST have the contacts. 2.7.4 discusses censoring of // RDAP Response Profile 2.7.1, 2.7.3 - we MUST have the contacts. 2.7.4 discusses censoring of
@ -512,12 +510,12 @@ public class RdapJsonFormatter {
// //
// 2.8 allows for unredacted output for authorized people. // 2.8 allows for unredacted output for authorized people.
boolean isAuthorized = boolean isAuthorized =
rdapAuthorization.isAuthorizedForRegistrar(contactResource.getCurrentSponsorRegistrarId()); rdapAuthorization.isAuthorizedForRegistrar(contact.getCurrentSponsorRegistrarId());
// ROID needs to be redacted if we aren't authorized, so we can't have a self-link for // ROID needs to be redacted if we aren't authorized, so we can't have a self-link for
// unauthorized users // unauthorized users
if (isAuthorized) { if (isAuthorized) {
contactBuilder.linksBuilder().add(makeSelfLink("entity", contactResource.getRepoId())); contactBuilder.linksBuilder().add(makeSelfLink("entity", contact.getRepoId()));
} }
// Only show the "summary data remark" if the user is authorized to see this data - because // Only show the "summary data remark" if the user is authorized to see this data - because
@ -544,10 +542,10 @@ public class RdapJsonFormatter {
.remarksBuilder() .remarksBuilder()
.add(RdapIcannStandardInformation.CONTACT_PERSONAL_DATA_HIDDEN_DATA_REMARK); .add(RdapIcannStandardInformation.CONTACT_PERSONAL_DATA_HIDDEN_DATA_REMARK);
// to make sure we don't accidentally display data we shouldn't - we replace the // to make sure we don't accidentally display data we shouldn't - we replace the
// contactResource with a safe resource. Then we can add any information we need (e.g. the // contact with a safe resource. Then we can add any information we need (e.g. the
// Organization / state / country of the registrant), although we currently don't do that. // Organization / state / country of the registrant), although we currently don't do that.
contactResource = contact =
new ContactResource.Builder() new Contact.Builder()
.setRepoId(CONTACT_REDACTED_VALUE) .setRepoId(CONTACT_REDACTED_VALUE)
.setVoiceNumber( .setVoiceNumber(
new ContactPhoneNumber.Builder().setPhoneNumber(CONTACT_REDACTED_VALUE).build()) new ContactPhoneNumber.Builder().setPhoneNumber(CONTACT_REDACTED_VALUE).build())
@ -572,7 +570,7 @@ public class RdapJsonFormatter {
// RDAP Response Profile 2.7.3 - we MUST provide a handle set with the ROID, subject to the // RDAP Response Profile 2.7.3 - we MUST provide a handle set with the ROID, subject to the
// redaction above. // redaction above.
contactBuilder.setHandle(contactResource.getRepoId()); contactBuilder.setHandle(contact.getRepoId());
// RDAP Response Profile doesn't mention status for contacts, so we only show it if we're both // RDAP Response Profile doesn't mention status for contacts, so we only show it if we're both
// FULL and Authorized. // FULL and Authorized.
@ -581,11 +579,11 @@ public class RdapJsonFormatter {
.statusBuilder() .statusBuilder()
.addAll( .addAll(
makeStatusValueList( makeStatusValueList(
isLinked(contactResource.createVKey(), getRequestTime()) isLinked(contact.createVKey(), getRequestTime())
? union(contactResource.getStatusValues(), StatusValue.LINKED) ? union(contact.getStatusValues(), StatusValue.LINKED)
: contactResource.getStatusValues(), : contact.getStatusValues(),
false, false,
contactResource.getDeletionTime().isBefore(getRequestTime()))); contact.getDeletionTime().isBefore(getRequestTime())));
} }
contactBuilder.rolesBuilder().addAll(roles); contactBuilder.rolesBuilder().addAll(roles);
@ -596,9 +594,9 @@ public class RdapJsonFormatter {
// RDAP Response Profile 2.7.3 - we MUST have FN, ADR, TEL, EMAIL. // RDAP Response Profile 2.7.3 - we MUST have FN, ADR, TEL, EMAIL.
// //
// Note that 2.7.5 also says the EMAIL must be omitted, so we'll omit it // Note that 2.7.5 also says the EMAIL must be omitted, so we'll omit it
PostalInfo postalInfo = contactResource.getInternationalizedPostalInfo(); PostalInfo postalInfo = contact.getInternationalizedPostalInfo();
if (postalInfo == null) { if (postalInfo == null) {
postalInfo = contactResource.getLocalizedPostalInfo(); postalInfo = contact.getLocalizedPostalInfo();
} }
if (postalInfo != null) { if (postalInfo != null) {
if (postalInfo.getName() != null) { if (postalInfo.getName() != null) {
@ -609,11 +607,11 @@ public class RdapJsonFormatter {
} }
addVCardAddressEntry(vcardBuilder, postalInfo.getAddress()); addVCardAddressEntry(vcardBuilder, postalInfo.getAddress());
} }
ContactPhoneNumber voicePhoneNumber = contactResource.getVoiceNumber(); ContactPhoneNumber voicePhoneNumber = contact.getVoiceNumber();
if (voicePhoneNumber != null) { if (voicePhoneNumber != null) {
vcardBuilder.add(makePhoneEntry(PHONE_TYPE_VOICE, makePhoneString(voicePhoneNumber))); vcardBuilder.add(makePhoneEntry(PHONE_TYPE_VOICE, makePhoneString(voicePhoneNumber)));
} }
ContactPhoneNumber faxPhoneNumber = contactResource.getFaxNumber(); ContactPhoneNumber faxPhoneNumber = contact.getFaxNumber();
if (faxPhoneNumber != null) { if (faxPhoneNumber != null) {
vcardBuilder.add(makePhoneEntry(PHONE_TYPE_FAX, makePhoneString(faxPhoneNumber))); vcardBuilder.add(makePhoneEntry(PHONE_TYPE_FAX, makePhoneString(faxPhoneNumber)));
} }
@ -641,7 +639,7 @@ public class RdapJsonFormatter {
// We also only add it for authorized users because millisecond times can fingerprint a user // We also only add it for authorized users because millisecond times can fingerprint a user
// just as much as the handle can. // just as much as the handle can.
if (outputDataType == OutputDataType.FULL && isAuthorized) { if (outputDataType == OutputDataType.FULL && isAuthorized) {
contactBuilder.eventsBuilder().addAll(makeOptionalEvents(contactResource)); contactBuilder.eventsBuilder().addAll(makeOptionalEvents(contact));
} }
return contactBuilder.build(); return contactBuilder.build();
} }

View file

@ -16,9 +16,9 @@ package google.registry.rde;
import static google.registry.util.XmlEnumUtils.enumToXml; import static google.registry.util.XmlEnumUtils.enumToXml;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactAddress; import google.registry.model.contact.ContactAddress;
import google.registry.model.contact.ContactPhoneNumber; import google.registry.model.contact.ContactPhoneNumber;
import google.registry.model.contact.ContactResource;
import google.registry.model.contact.Disclose; import google.registry.model.contact.Disclose;
import google.registry.model.contact.Disclose.PostalInfoChoice; import google.registry.model.contact.Disclose.PostalInfoChoice;
import google.registry.model.contact.PostalInfo; import google.registry.model.contact.PostalInfo;
@ -39,16 +39,16 @@ import google.registry.xjc.rdecontact.XjcRdeContactTransferDataType;
import javax.annotation.CheckForNull; import javax.annotation.CheckForNull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
/** Utility class that turns {@link ContactResource} as {@link XjcRdeContactElement}. */ /** Utility class that turns {@link Contact} as {@link XjcRdeContactElement}. */
final class ContactResourceToXjcConverter { final class ContactToXjcConverter {
/** Converts {@link ContactResource} to {@link XjcRdeContactElement}. */ /** Converts {@link Contact} to {@link XjcRdeContactElement}. */
static XjcRdeContactElement convert(ContactResource host) { static XjcRdeContactElement convert(Contact host) {
return new XjcRdeContactElement(convertContact(host)); return new XjcRdeContactElement(convertContact(host));
} }
/** Converts {@link ContactResource} to {@link XjcRdeContact}. */ /** Converts {@link Contact} to {@link XjcRdeContact}. */
static XjcRdeContact convertContact(ContactResource model) { static XjcRdeContact convertContact(Contact model) {
XjcRdeContact bean = new XjcRdeContact(); XjcRdeContact bean = new XjcRdeContact();
bean.setRoid(model.getRepoId()); bean.setRoid(model.getRepoId());
for (StatusValue status : model.getStatusValues()) { for (StatusValue status : model.getStatusValues()) {
@ -188,5 +188,5 @@ final class ContactResourceToXjcConverter {
return bean; return bean;
} }
private ContactResourceToXjcConverter() {} private ContactToXjcConverter() {}
} }

View file

@ -21,7 +21,7 @@ import com.google.common.base.Ascii;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DesignatedContact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.domain.rgp.GracePeriodStatus;
@ -168,11 +168,11 @@ final class DomainToXjcConverter {
// o An OPTIONAL <registrant> element that contain the identifier for // o An OPTIONAL <registrant> element that contain the identifier for
// the human or organizational social information object associated // the human or organizational social information object associated
// as the holder of the domain name object. // as the holder of the domain name object.
VKey<ContactResource> registrant = model.getRegistrant(); VKey<Contact> registrant = model.getRegistrant();
if (registrant == null) { if (registrant == null) {
logger.atWarning().log("Domain %s has no registrant contact.", domainName); logger.atWarning().log("Domain %s has no registrant contact.", domainName);
} else { } else {
ContactResource registrantContact = tm().transact(() -> tm().loadByKey(registrant)); Contact registrantContact = tm().transact(() -> tm().loadByKey(registrant));
checkState( checkState(
registrantContact != null, registrantContact != null,
"Registrant contact %s on domain %s does not exist", "Registrant contact %s on domain %s does not exist",
@ -304,7 +304,7 @@ final class DomainToXjcConverter {
"Contact key for type %s is null on domain %s", "Contact key for type %s is null on domain %s",
model.getType(), model.getType(),
domainName); domainName);
ContactResource contact = tm().transact(() -> tm().loadByKey(model.getContactKey())); Contact contact = tm().transact(() -> tm().loadByKey(model.getContactKey()));
checkState( checkState(
contact != null, contact != null,
"Contact %s on domain %s does not exist", "Contact %s on domain %s does not exist",

View file

@ -20,7 +20,7 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.
import com.google.auto.value.AutoValue; import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.host.Host; import google.registry.model.host.Host;
import google.registry.model.rde.RdeMode; import google.registry.model.rde.RdeMode;
@ -66,8 +66,8 @@ public class RdeFragmenter {
result = Optional.of(marshaller.marshalDomain((Domain) resource, mode)); result = Optional.of(marshaller.marshalDomain((Domain) resource, mode));
cache.put(WatermarkModePair.create(watermark, mode), result); cache.put(WatermarkModePair.create(watermark, mode), result);
return result; return result;
} else if (resource instanceof ContactResource) { } else if (resource instanceof Contact) {
result = Optional.of(marshaller.marshalContact((ContactResource) resource)); result = Optional.of(marshaller.marshalContact((Contact) resource));
cache.put(WatermarkModePair.create(watermark, RdeMode.FULL), result); cache.put(WatermarkModePair.create(watermark, RdeMode.FULL), result);
cache.put(WatermarkModePair.create(watermark, RdeMode.THIN), result); cache.put(WatermarkModePair.create(watermark, RdeMode.THIN), result);
return result; return result;

View file

@ -20,7 +20,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.model.ImmutableObject; import google.registry.model.ImmutableObject;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.host.Host; import google.registry.model.host.Host;
import google.registry.model.rde.RdeMode; import google.registry.model.rde.RdeMode;
@ -117,10 +117,10 @@ public final class RdeMarshaller implements Serializable {
} }
} }
/** Turns {@link ContactResource} object into an XML fragment. */ /** Turns {@link Contact} object into an XML fragment. */
public DepositFragment marshalContact(ContactResource contact) { public DepositFragment marshalContact(Contact contact) {
return marshalResource(RdeResourceType.CONTACT, contact, return marshalResource(
ContactResourceToXjcConverter.convert(contact)); RdeResourceType.CONTACT, contact, ContactToXjcConverter.convert(contact));
} }
/** Turns {@link Domain} object into an XML fragment. */ /** Turns {@link Domain} object into an XML fragment. */

View file

@ -45,7 +45,7 @@ import google.registry.gcs.GcsUtils;
import google.registry.keyring.api.KeyModule.Key; import google.registry.keyring.api.KeyModule.Key;
import google.registry.model.common.Cursor; import google.registry.model.common.Cursor;
import google.registry.model.common.Cursor.CursorType; import google.registry.model.common.Cursor.CursorType;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.host.Host; import google.registry.model.host.Host;
import google.registry.model.index.EppResourceIndex; import google.registry.model.index.EppResourceIndex;
@ -82,8 +82,8 @@ import org.joda.time.Duration;
* type and loads the embedded resource from it, which is then projected to watermark time to * type and loads the embedded resource from it, which is then projected to watermark time to
* account for things like pending transfer. * account for things like pending transfer.
* *
* <p>Only {@link ContactResource}s and {@link Host}s that are referenced by an included {@link * <p>Only {@link Contact}s and {@link Host}s that are referenced by an included {@link Domain} will
* Domain} will be included in the corresponding pending deposit. * be included in the corresponding pending deposit.
* *
* <p>{@link Registrar} entities, both active and inactive, are included in all deposits. They are * <p>{@link Registrar} entities, both active and inactive, are included in all deposits. They are
* not rewinded point-in-time. * not rewinded point-in-time.

View file

@ -19,7 +19,7 @@ import static com.google.common.base.Preconditions.checkState;
import com.google.common.base.Ascii; import com.google.common.base.Ascii;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.host.Host; import google.registry.model.host.Host;
import google.registry.model.index.ForeignKeyIndex; import google.registry.model.index.ForeignKeyIndex;
@ -31,7 +31,7 @@ class CommandUtilities {
/** A useful parameter enum for commands that operate on {@link EppResource} objects. */ /** A useful parameter enum for commands that operate on {@link EppResource} objects. */
public enum ResourceType { public enum ResourceType {
CONTACT(ContactResource.class), CONTACT(Contact.class),
HOST(Host.class), HOST(Host.class),
DOMAIN(Domain.class); DOMAIN(Domain.class);

View file

@ -18,7 +18,7 @@ import static google.registry.model.EppResourceUtils.loadByForeignKey;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import java.util.List; import java.util.List;
/** Command to show one or more contacts. */ /** Command to show one or more contacts. */
@ -34,7 +34,7 @@ final class GetContactCommand extends GetEppResourceCommand {
public void runAndPrint() { public void runAndPrint() {
for (String contactId : mainParameters) { for (String contactId : mainParameters) {
printResource( printResource(
"Contact", contactId, loadByForeignKey(ContactResource.class, contactId, readTimestamp)); "Contact", contactId, loadByForeignKey(Contact.class, contactId, readTimestamp));
} }
} }
} }

View file

@ -15,13 +15,13 @@
package google.registry.tools.params; package google.registry.tools.params;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.host.Host; import google.registry.model.host.Host;
/** Enum to make it easy for a command to accept a flag that specifies an EppResource subclass. */ /** Enum to make it easy for a command to accept a flag that specifies an EppResource subclass. */
public enum EppResourceTypeParameter { public enum EppResourceTypeParameter {
CONTACT(ContactResource.class), CONTACT(Contact.class),
DOMAIN(Domain.class), DOMAIN(Domain.class),
HOST(Host.class); HOST(Host.class);

View file

@ -23,8 +23,8 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactPhoneNumber; import google.registry.model.contact.ContactPhoneNumber;
import google.registry.model.contact.ContactResource;
import google.registry.model.contact.PostalInfo; import google.registry.model.contact.PostalInfo;
import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DesignatedContact;
import google.registry.model.domain.DesignatedContact.Type; import google.registry.model.domain.DesignatedContact.Type;
@ -124,7 +124,7 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
} }
/** Returns the contact of the given type. */ /** Returns the contact of the given type. */
private Optional<VKey<ContactResource>> getContactReference(Type type) { private Optional<VKey<Contact>> getContactReference(Type type) {
Optional<DesignatedContact> contactOfType = Optional<DesignatedContact> contactOfType =
domain.getContacts().stream().filter(d -> d.getType() == type).findFirst(); domain.getContacts().stream().filter(d -> d.getType() == type).findFirst();
return contactOfType.map(DesignatedContact::getContactKey); return contactOfType.map(DesignatedContact::getContactKey);
@ -145,15 +145,15 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
/** Emit the contact entry of the given type. */ /** Emit the contact entry of the given type. */
DomainEmitter emitContact( DomainEmitter emitContact(
String contactType, Optional<VKey<ContactResource>> contact, boolean preferUnicode) { String contactType, Optional<VKey<Contact>> contact, boolean preferUnicode) {
if (!contact.isPresent()) { if (!contact.isPresent()) {
return this; return this;
} }
// If we refer to a contact that doesn't exist, that's a bug. It means referential integrity // If we refer to a contact that doesn't exist, that's a bug. It means referential integrity
// has somehow been broken. We skip the rest of this contact, but log it to hopefully bring it // has somehow been broken. We skip the rest of this contact, but log it to hopefully bring it
// someone's attention. // someone's attention.
ContactResource contactResource = EppResource.loadCached(contact.get()); Contact contact1 = EppResource.loadCached(contact.get());
if (contactResource == null) { if (contact1 == null) {
logger.atSevere().log( logger.atSevere().log(
"(BUG) Broken reference found from domain %s to contact %s.", "(BUG) Broken reference found from domain %s to contact %s.",
domain.getDomainName(), contact); domain.getDomainName(), contact);
@ -162,11 +162,10 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
PostalInfo postalInfo = PostalInfo postalInfo =
chooseByUnicodePreference( chooseByUnicodePreference(
preferUnicode, preferUnicode,
contactResource.getLocalizedPostalInfo(), contact1.getLocalizedPostalInfo(),
contactResource.getInternationalizedPostalInfo()); contact1.getInternationalizedPostalInfo());
// ICANN Consistent Labeling & Display policy requires that this be the ROID. // ICANN Consistent Labeling & Display policy requires that this be the ROID.
emitField( emitField(ImmutableList.of("Registry", contactType, "ID"), contact1.getRepoId(), fullOutput);
ImmutableList.of("Registry", contactType, "ID"), contactResource.getRepoId(), fullOutput);
if (postalInfo != null) { if (postalInfo != null) {
emitFieldIfDefined(ImmutableList.of(contactType, "Name"), postalInfo.getName(), fullOutput); emitFieldIfDefined(ImmutableList.of(contactType, "Name"), postalInfo.getName(), fullOutput);
emitFieldIfDefined( emitFieldIfDefined(
@ -175,10 +174,9 @@ final class DomainWhoisResponse extends WhoisResponseImpl {
fullOutput || contactType.equals("Registrant")); fullOutput || contactType.equals("Registrant"));
emitAddress(contactType, postalInfo.getAddress(), fullOutput); emitAddress(contactType, postalInfo.getAddress(), fullOutput);
} }
emitPhone(contactType, "Phone", contactResource.getVoiceNumber()); emitPhone(contactType, "Phone", contact1.getVoiceNumber());
emitPhone(contactType, "Fax", contactResource.getFaxNumber()); emitPhone(contactType, "Fax", contact1.getFaxNumber());
String emailFieldContent = String emailFieldContent = fullOutput ? contact1.getEmailAddress() : whoisRedactedEmailText;
fullOutput ? contactResource.getEmailAddress() : whoisRedactedEmailText;
emitField(ImmutableList.of(contactType, "Email"), emailFieldContent); emitField(ImmutableList.of(contactType, "Email"), emailFieldContent);
return this; return this;
} }

View file

@ -45,7 +45,7 @@
<class>google.registry.model.common.DatabaseMigrationStateSchedule</class> <class>google.registry.model.common.DatabaseMigrationStateSchedule</class>
<class>google.registry.model.console.User</class> <class>google.registry.model.console.User</class>
<class>google.registry.model.contact.ContactHistory</class> <class>google.registry.model.contact.ContactHistory</class>
<class>google.registry.model.contact.ContactResource</class> <class>google.registry.model.contact.Contact</class>
<class>google.registry.model.domain.Domain</class> <class>google.registry.model.domain.Domain</class>
<class>google.registry.model.domain.DomainHistory</class> <class>google.registry.model.domain.DomainHistory</class>
<class>google.registry.model.domain.GracePeriod</class> <class>google.registry.model.domain.GracePeriod</class>
@ -104,7 +104,7 @@
<class>google.registry.model.billing.VKeyConverter_Cancellation</class> <class>google.registry.model.billing.VKeyConverter_Cancellation</class>
<class>google.registry.model.billing.VKeyConverter_OneTime</class> <class>google.registry.model.billing.VKeyConverter_OneTime</class>
<class>google.registry.model.billing.VKeyConverter_Recurring</class> <class>google.registry.model.billing.VKeyConverter_Recurring</class>
<class>google.registry.model.contact.VKeyConverter_ContactResource</class> <class>google.registry.model.contact.VKeyConverter_Contact</class>
<class>google.registry.model.domain.VKeyConverter_Domain</class> <class>google.registry.model.domain.VKeyConverter_Domain</class>
<class>google.registry.model.domain.token.VKeyConverter_AllocationToken</class> <class>google.registry.model.domain.token.VKeyConverter_AllocationToken</class>
<class>google.registry.model.host.VKeyConverter_Host</class> <class>google.registry.model.host.VKeyConverter_Host</class>

View file

@ -27,7 +27,7 @@ import static org.joda.time.Duration.standardSeconds;
import com.google.cloud.tasks.v2.HttpMethod; import com.google.cloud.tasks.v2.HttpMethod;
import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.ImmutableSortedSet;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.testing.AppEngineExtension; import google.registry.testing.AppEngineExtension;
import google.registry.testing.CloudTasksHelper; import google.registry.testing.CloudTasksHelper;
import google.registry.testing.CloudTasksHelper.TaskMatcher; import google.registry.testing.CloudTasksHelper.TaskMatcher;
@ -80,7 +80,7 @@ public class AsyncTaskEnqueuerTest {
@Test @Test
void test_enqueueAsyncResave_success() { void test_enqueueAsyncResave_success() {
ContactResource contact = persistActiveContact("jd23456"); Contact contact = persistActiveContact("jd23456");
asyncTaskEnqueuer.enqueueAsyncResave( asyncTaskEnqueuer.enqueueAsyncResave(
contact.createVKey(), clock.nowUtc(), clock.nowUtc().plusDays(5)); contact.createVKey(), clock.nowUtc(), clock.nowUtc().plusDays(5));
cloudTasksHelper.assertTasksEnqueued( cloudTasksHelper.assertTasksEnqueued(
@ -97,7 +97,7 @@ public class AsyncTaskEnqueuerTest {
@Test @Test
void test_enqueueAsyncResave_multipleResaves() { void test_enqueueAsyncResave_multipleResaves() {
ContactResource contact = persistActiveContact("jd23456"); Contact contact = persistActiveContact("jd23456");
DateTime now = clock.nowUtc(); DateTime now = clock.nowUtc();
asyncTaskEnqueuer.enqueueAsyncResave( asyncTaskEnqueuer.enqueueAsyncResave(
contact.createVKey(), contact.createVKey(),
@ -119,7 +119,7 @@ public class AsyncTaskEnqueuerTest {
@MockitoSettings(strictness = Strictness.LENIENT) @MockitoSettings(strictness = Strictness.LENIENT)
@Test @Test
void test_enqueueAsyncResave_ignoresTasksTooFarIntoFuture() { void test_enqueueAsyncResave_ignoresTasksTooFarIntoFuture() {
ContactResource contact = persistActiveContact("jd23456"); Contact contact = persistActiveContact("jd23456");
asyncTaskEnqueuer.enqueueAsyncResave( asyncTaskEnqueuer.enqueueAsyncResave(
contact.createVKey(), clock.nowUtc(), clock.nowUtc().plusDays(31)); contact.createVKey(), clock.nowUtc(), clock.nowUtc().plusDays(31));
cloudTasksHelper.assertNoTasksEnqueued(QUEUE_ASYNC_ACTIONS); cloudTasksHelper.assertNoTasksEnqueued(QUEUE_ASYNC_ACTIONS);

View file

@ -23,12 +23,12 @@ import static org.apache.http.HttpStatus.SC_OK;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactAddress; import google.registry.model.contact.ContactAddress;
import google.registry.model.contact.ContactAuthInfo; import google.registry.model.contact.ContactAuthInfo;
import google.registry.model.contact.ContactBase; import google.registry.model.contact.ContactBase;
import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactPhoneNumber; import google.registry.model.contact.ContactPhoneNumber;
import google.registry.model.contact.ContactResource;
import google.registry.model.contact.Disclose; import google.registry.model.contact.Disclose;
import google.registry.model.contact.PostalInfo; import google.registry.model.contact.PostalInfo;
import google.registry.model.eppcommon.AuthInfo.PasswordAuth; import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
@ -48,8 +48,8 @@ class WipeOutContactHistoryPiiActionTest {
private static final int TEST_BATCH_SIZE = 20; private static final int TEST_BATCH_SIZE = 20;
private static final int MIN_MONTHS_BEFORE_WIPE_OUT = 18; private static final int MIN_MONTHS_BEFORE_WIPE_OUT = 18;
private static final ContactResource defaultContactResource = private static final Contact DEFAULT_CONTACT =
new ContactResource.Builder() new Contact.Builder()
.setContactId("sh8013") .setContactId("sh8013")
.setRepoId("2FF-ROID") .setRepoId("2FF-ROID")
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_DELETE_PROHIBITED)) .setStatusValues(ImmutableSet.of(StatusValue.CLIENT_DELETE_PROHIBITED))
@ -117,8 +117,7 @@ class WipeOutContactHistoryPiiActionTest {
@Test @Test
void getAllHistoryEntitiesOlderThan_returnsAllPersistedEntities() { void getAllHistoryEntitiesOlderThan_returnsAllPersistedEntities() {
ImmutableList<ContactHistory> expectedToBeWipedOut = ImmutableList<ContactHistory> expectedToBeWipedOut =
persistLotsOfContactHistoryEntities( persistLotsOfContactHistoryEntities(20, MIN_MONTHS_BEFORE_WIPE_OUT + 1, 0, DEFAULT_CONTACT);
20, MIN_MONTHS_BEFORE_WIPE_OUT + 1, 0, defaultContactResource);
jpaTm() jpaTm()
.transact( .transact(
() -> () ->
@ -131,12 +130,10 @@ class WipeOutContactHistoryPiiActionTest {
@Test @Test
void getAllHistoryEntitiesOlderThan_returnsOnlyOldEnoughPersistedEntities() { void getAllHistoryEntitiesOlderThan_returnsOnlyOldEnoughPersistedEntities() {
ImmutableList<ContactHistory> expectedToBeWipedOut = ImmutableList<ContactHistory> expectedToBeWipedOut =
persistLotsOfContactHistoryEntities( persistLotsOfContactHistoryEntities(19, MIN_MONTHS_BEFORE_WIPE_OUT + 2, 0, DEFAULT_CONTACT);
19, MIN_MONTHS_BEFORE_WIPE_OUT + 2, 0, defaultContactResource);
// persisted entities that should not be part of the actual result // persisted entities that should not be part of the actual result
persistLotsOfContactHistoryEntities( persistLotsOfContactHistoryEntities(15, 17, MIN_MONTHS_BEFORE_WIPE_OUT - 1, DEFAULT_CONTACT);
15, 17, MIN_MONTHS_BEFORE_WIPE_OUT - 1, defaultContactResource);
jpaTm() jpaTm()
.transact( .transact(
@ -179,7 +176,7 @@ class WipeOutContactHistoryPiiActionTest {
void run_withOneBatchOfEntities_success() { void run_withOneBatchOfEntities_success() {
int numOfMonthsFromNow = MIN_MONTHS_BEFORE_WIPE_OUT + 2; int numOfMonthsFromNow = MIN_MONTHS_BEFORE_WIPE_OUT + 2;
ImmutableList<ContactHistory> expectedToBeWipedOut = ImmutableList<ContactHistory> expectedToBeWipedOut =
persistLotsOfContactHistoryEntities(20, numOfMonthsFromNow, 0, defaultContactResource); persistLotsOfContactHistoryEntities(20, numOfMonthsFromNow, 0, DEFAULT_CONTACT);
// The query should return a stream of all persisted entities. // The query should return a stream of all persisted entities.
assertThat( assertThat(
@ -216,7 +213,7 @@ class WipeOutContactHistoryPiiActionTest {
void run_withMultipleBatches_numOfEntitiesAsNonMultipleOfBatchSize_success() { void run_withMultipleBatches_numOfEntitiesAsNonMultipleOfBatchSize_success() {
int numOfMonthsFromNow = MIN_MONTHS_BEFORE_WIPE_OUT + 2; int numOfMonthsFromNow = MIN_MONTHS_BEFORE_WIPE_OUT + 2;
ImmutableList<ContactHistory> expectedToBeWipedOut = ImmutableList<ContactHistory> expectedToBeWipedOut =
persistLotsOfContactHistoryEntities(56, numOfMonthsFromNow, 0, defaultContactResource); persistLotsOfContactHistoryEntities(56, numOfMonthsFromNow, 0, DEFAULT_CONTACT);
// The query should return a subset of all persisted data. // The query should return a subset of all persisted data.
assertThat( assertThat(
@ -253,7 +250,7 @@ class WipeOutContactHistoryPiiActionTest {
int numOfMonthsFromNow = MIN_MONTHS_BEFORE_WIPE_OUT + 2; int numOfMonthsFromNow = MIN_MONTHS_BEFORE_WIPE_OUT + 2;
ImmutableList<ContactHistory> expectedToBeWipedOut = ImmutableList<ContactHistory> expectedToBeWipedOut =
persistLotsOfContactHistoryEntities( persistLotsOfContactHistoryEntities(
TEST_BATCH_SIZE * 2, numOfMonthsFromNow, 0, defaultContactResource); TEST_BATCH_SIZE * 2, numOfMonthsFromNow, 0, DEFAULT_CONTACT);
// The query should return a subset of all persisted data. // The query should return a subset of all persisted data.
assertThat( assertThat(
@ -302,7 +299,7 @@ class WipeOutContactHistoryPiiActionTest {
void wipeOutContactHistoryData_wipesOutMultipleEntities() { void wipeOutContactHistoryData_wipesOutMultipleEntities() {
int numOfMonthsFromNow = MIN_MONTHS_BEFORE_WIPE_OUT + 3; int numOfMonthsFromNow = MIN_MONTHS_BEFORE_WIPE_OUT + 3;
ImmutableList<ContactHistory> expectedToBeWipedOut = ImmutableList<ContactHistory> expectedToBeWipedOut =
persistLotsOfContactHistoryEntities(20, numOfMonthsFromNow, 0, defaultContactResource); persistLotsOfContactHistoryEntities(20, numOfMonthsFromNow, 0, DEFAULT_CONTACT);
assertAllEntitiesContainPii(DatabaseHelper.loadByEntitiesIfPresent(expectedToBeWipedOut)); assertAllEntitiesContainPii(DatabaseHelper.loadByEntitiesIfPresent(expectedToBeWipedOut));
@ -319,7 +316,7 @@ class WipeOutContactHistoryPiiActionTest {
/** persists a number of ContactHistory entities for load and query testing. */ /** persists a number of ContactHistory entities for load and query testing. */
ImmutableList<ContactHistory> persistLotsOfContactHistoryEntities( ImmutableList<ContactHistory> persistLotsOfContactHistoryEntities(
int numOfEntities, int minusMonths, int minusDays, ContactResource contact) { int numOfEntities, int minusMonths, int minusDays, Contact contact) {
ImmutableList.Builder<ContactHistory> expectedEntitesBuilder = new ImmutableList.Builder<>(); ImmutableList.Builder<ContactHistory> expectedEntitesBuilder = new ImmutableList.Builder<>();
for (int i = 0; i < numOfEntities; i++) { for (int i = 0; i < numOfEntities; i++) {
expectedEntitesBuilder.add( expectedEntitesBuilder.add(

View file

@ -16,6 +16,7 @@ package google.registry.beam.common;
import static google.registry.testing.AppEngineExtension.makeRegistrar1; import static google.registry.testing.AppEngineExtension.makeRegistrar1;
import static google.registry.testing.DatabaseHelper.insertInDb; import static google.registry.testing.DatabaseHelper.insertInDb;
import static google.registry.testing.DatabaseHelper.newContact;
import static google.registry.testing.DatabaseHelper.newRegistry; import static google.registry.testing.DatabaseHelper.newRegistry;
import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_OF_TIME; import static google.registry.util.DateTimeUtils.START_OF_TIME;
@ -25,8 +26,8 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import google.registry.beam.TestPipelineExtension; import google.registry.beam.TestPipelineExtension;
import google.registry.beam.common.RegistryJpaIO.Read; import google.registry.beam.common.RegistryJpaIO.Read;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactBase; import google.registry.model.contact.ContactBase;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainAuthInfo; import google.registry.model.domain.DomainAuthInfo;
import google.registry.model.domain.GracePeriod; import google.registry.model.domain.GracePeriod;
@ -42,7 +43,6 @@ import google.registry.persistence.transaction.CriteriaQueryBuilder;
import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions;
import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension;
import google.registry.testing.AppEngineExtension; import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.DatastoreEntityExtension; import google.registry.testing.DatastoreEntityExtension;
import google.registry.testing.FakeClock; import google.registry.testing.FakeClock;
import org.apache.beam.sdk.testing.PAssert; import org.apache.beam.sdk.testing.PAssert;
@ -76,17 +76,17 @@ public class RegistryJpaReadTest {
final transient TestPipelineExtension testPipeline = final transient TestPipelineExtension testPipeline =
TestPipelineExtension.create().enableAbandonedNodeEnforcement(true); TestPipelineExtension.create().enableAbandonedNodeEnforcement(true);
private transient ImmutableList<ContactResource> contacts; private transient ImmutableList<Contact> contacts;
@BeforeEach @BeforeEach
void beforeEach() { void beforeEach() {
Registrar ofyRegistrar = AppEngineExtension.makeRegistrar2(); Registrar ofyRegistrar = AppEngineExtension.makeRegistrar2();
insertInDb(ofyRegistrar); insertInDb(ofyRegistrar);
ImmutableList.Builder<ContactResource> builder = new ImmutableList.Builder<>(); ImmutableList.Builder<Contact> builder = new ImmutableList.Builder<>();
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
ContactResource contact = DatabaseHelper.newContactResource("contact_" + i); Contact contact = newContact("contact_" + i);
builder.add(contact); builder.add(contact);
} }
contacts = builder.build(); contacts = builder.build();
@ -95,10 +95,9 @@ public class RegistryJpaReadTest {
@Test @Test
void readWithCriteriaQuery() { void readWithCriteriaQuery() {
Read<ContactResource, String> read = Read<Contact, String> read =
RegistryJpaIO.read( RegistryJpaIO.read(
() -> CriteriaQueryBuilder.create(ContactResource.class).build(), () -> CriteriaQueryBuilder.create(Contact.class).build(), ContactBase::getContactId);
ContactBase::getContactId);
PCollection<String> repoIds = testPipeline.apply(read); PCollection<String> repoIds = testPipeline.apply(read);
PAssert.that(repoIds).containsInAnyOrder("contact_0", "contact_1", "contact_2"); PAssert.that(repoIds).containsInAnyOrder("contact_0", "contact_1", "contact_2");
@ -172,8 +171,8 @@ public class RegistryJpaReadTest {
.setRegistrarId("registrar1") .setRegistrarId("registrar1")
.setEmailAddress("me@google.com") .setEmailAddress("me@google.com")
.build(); .build();
ContactResource contact = Contact contact =
new ContactResource.Builder() new Contact.Builder()
.setRepoId("contactid_1") .setRepoId("contactid_1")
.setCreationRegistrarId(registrar.getRegistrarId()) .setCreationRegistrarId(registrar.getRegistrarId())
.setTransferData(new ContactTransferData.Builder().build()) .setTransferData(new ContactTransferData.Builder().build())

View file

@ -17,11 +17,11 @@ package google.registry.beam.common;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.ImmutableObjectSubject.immutableObjectCorrespondence; import static google.registry.model.ImmutableObjectSubject.immutableObjectCorrespondence;
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm; import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
import static google.registry.testing.DatabaseHelper.newContactResource; import static google.registry.testing.DatabaseHelper.newContact;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import google.registry.beam.TestPipelineExtension; import google.registry.beam.TestPipelineExtension;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.persistence.transaction.JpaTestExtensions; import google.registry.persistence.transaction.JpaTestExtensions;
import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension; import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationTestExtension;
import google.registry.testing.AppEngineExtension; import google.registry.testing.AppEngineExtension;
@ -55,21 +55,17 @@ class RegistryJpaWriteTest implements Serializable {
@Test @Test
void writeToSql_twoWriters() { void writeToSql_twoWriters() {
jpaTm().transact(() -> jpaTm().put(AppEngineExtension.makeRegistrar2())); jpaTm().transact(() -> jpaTm().put(AppEngineExtension.makeRegistrar2()));
ImmutableList.Builder<ContactResource> contactsBuilder = new ImmutableList.Builder<>(); ImmutableList.Builder<Contact> contactsBuilder = new ImmutableList.Builder<>();
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
contactsBuilder.add(newContactResource("contact_" + i)); contactsBuilder.add(newContact("contact_" + i));
} }
ImmutableList<ContactResource> contacts = contactsBuilder.build(); ImmutableList<Contact> contacts = contactsBuilder.build();
testPipeline testPipeline
.apply(Create.of(contacts)) .apply(Create.of(contacts))
.apply( .apply(RegistryJpaIO.<Contact>write().withName("Contact").withBatchSize(4).withShards(2));
RegistryJpaIO.<ContactResource>write()
.withName("ContactResource")
.withBatchSize(4)
.withShards(2));
testPipeline.run().waitUntilFinish(); testPipeline.run().waitUntilFinish();
assertThat(jpaTm().transact(() -> jpaTm().loadAllOf(ContactResource.class))) assertThat(jpaTm().transact(() -> jpaTm().loadAllOf(Contact.class)))
.comparingElementsUsing(immutableObjectCorrespondence("revisions", "updateTimestamp")) .comparingElementsUsing(immutableObjectCorrespondence("revisions", "updateTimestamp"))
.containsExactlyElementsIn(contacts); .containsExactlyElementsIn(contacts);
} }

View file

@ -53,9 +53,9 @@ import google.registry.gcs.GcsUtils;
import google.registry.keyring.api.PgpHelper; import google.registry.keyring.api.PgpHelper;
import google.registry.model.common.Cursor; import google.registry.model.common.Cursor;
import google.registry.model.common.Cursor.CursorType; import google.registry.model.common.Cursor.CursorType;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactBase; import google.registry.model.contact.ContactBase;
import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DesignatedContact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.DomainBase;
@ -265,9 +265,9 @@ public class RdePipelineTest {
// This contact is never referenced. // This contact is never referenced.
persistContactHistory(persistActiveContact("contactX")); persistContactHistory(persistActiveContact("contactX"));
ContactResource contact1 = persistActiveContact("contact1234"); Contact contact1 = persistActiveContact("contact1234");
persistContactHistory(contact1); persistContactHistory(contact1);
ContactResource contact2 = persistActiveContact("contact456"); Contact contact2 = persistActiveContact("contact456");
persistContactHistory(contact2); persistContactHistory(contact2);
// This host is never referenced. // This host is never referenced.
@ -302,7 +302,7 @@ public class RdePipelineTest {
persistDomainHistory(deletedDomain.asBuilder().setDeletionTime(clock.nowUtc()).build()); persistDomainHistory(deletedDomain.asBuilder().setDeletionTime(clock.nowUtc()).build());
kittyDomain = kittyDomain.asBuilder().setDomainName("cat.fun").build(); kittyDomain = kittyDomain.asBuilder().setDomainName("cat.fun").build();
persistDomainHistory(kittyDomain); persistDomainHistory(kittyDomain);
ContactResource contact3 = persistActiveContact("contact789"); Contact contact3 = persistActiveContact("contact789");
persistContactHistory(contact3); persistContactHistory(contact3);
// This is a subordinate domain in TLD .cat, which is not included in any pending deposit. But // This is a subordinate domain in TLD .cat, which is not included in any pending deposit. But
// it should still be included as a subordinate host in the pendign deposit for .soy. // it should still be included as a subordinate host in the pendign deposit for .soy.
@ -329,7 +329,7 @@ public class RdePipelineTest {
// resulting deposit fragments. // resulting deposit fragments.
clock.advanceBy(Duration.standardDays(2)); clock.advanceBy(Duration.standardDays(2));
persistDomainHistory(kittyDomain.asBuilder().setDeletionTime(clock.nowUtc()).build()); persistDomainHistory(kittyDomain.asBuilder().setDeletionTime(clock.nowUtc()).build());
ContactResource futureContact = persistActiveContact("future-contact"); Contact futureContact = persistActiveContact("future-contact");
persistContactHistory(futureContact); persistContactHistory(futureContact);
Host futureHost = persistActiveHost("ns1.future.tld"); Host futureHost = persistActiveHost("ns1.future.tld");
persistHostHistory(futureHost); persistHostHistory(futureHost);

View file

@ -32,7 +32,7 @@ import static org.mockito.Mockito.verify;
import google.registry.beam.TestPipelineExtension; import google.registry.beam.TestPipelineExtension;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.GracePeriod; import google.registry.model.domain.GracePeriod;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
@ -81,7 +81,7 @@ public class ResaveAllEppResourcesPipelineTest {
@Test @Test
void testPipeline_unchangedEntity() { void testPipeline_unchangedEntity() {
ContactResource contact = persistActiveContact("test123"); Contact contact = persistActiveContact("test123");
DateTime creationTime = contact.getUpdateTimestamp().getTimestamp(); DateTime creationTime = contact.getUpdateTimestamp().getTimestamp();
fakeClock.advanceOneMilli(); fakeClock.advanceOneMilli();
assertThat(loadByEntity(contact).getUpdateTimestamp().getTimestamp()).isEqualTo(creationTime); assertThat(loadByEntity(contact).getUpdateTimestamp().getTimestamp()).isEqualTo(creationTime);
@ -92,7 +92,7 @@ public class ResaveAllEppResourcesPipelineTest {
@Test @Test
void testPipeline_fulfilledContactTransfer() { void testPipeline_fulfilledContactTransfer() {
ContactResource contact = persistActiveContact("test123"); Contact contact = persistActiveContact("test123");
DateTime now = fakeClock.nowUtc(); DateTime now = fakeClock.nowUtc();
contact = persistContactWithPendingTransfer(contact, now, now.plusDays(5), now); contact = persistContactWithPendingTransfer(contact, now, now.plusDays(5), now);
fakeClock.advanceBy(Duration.standardDays(10)); fakeClock.advanceBy(Duration.standardDays(10));
@ -154,7 +154,7 @@ public class ResaveAllEppResourcesPipelineTest {
@Test @Test
void testPipeline_fastOnlySavesChanged() { void testPipeline_fastOnlySavesChanged() {
DateTime now = fakeClock.nowUtc(); DateTime now = fakeClock.nowUtc();
ContactResource contact = persistActiveContact("jd1234"); Contact contact = persistActiveContact("jd1234");
persistDomainWithDependentResources("renewed", "tld", contact, now, now, now.plusYears(1)); persistDomainWithDependentResources("renewed", "tld", contact, now, now, now.plusYears(1));
persistActiveDomain("nonrenewed.tld", now, now.plusYears(20)); persistActiveDomain("nonrenewed.tld", now, now.plusYears(20));
// Spy the transaction manager so we can be sure we're only saving the renewed domain // Spy the transaction manager so we can be sure we're only saving the renewed domain
@ -171,7 +171,7 @@ public class ResaveAllEppResourcesPipelineTest {
void testPipeline_notFastResavesAll() { void testPipeline_notFastResavesAll() {
options.setFast(false); options.setFast(false);
DateTime now = fakeClock.nowUtc(); DateTime now = fakeClock.nowUtc();
ContactResource contact = persistActiveContact("jd1234"); Contact contact = persistActiveContact("jd1234");
Domain renewed = Domain renewed =
persistDomainWithDependentResources("renewed", "tld", contact, now, now, now.plusYears(1)); persistDomainWithDependentResources("renewed", "tld", contact, now, now, now.plusYears(1));
Domain nonRenewed = Domain nonRenewed =

View file

@ -37,7 +37,7 @@ import com.google.common.truth.Correspondence.BinaryPredicate;
import google.registry.beam.TestPipelineExtension; import google.registry.beam.TestPipelineExtension;
import google.registry.beam.spec11.SafeBrowsingTransforms.EvaluateSafeBrowsingFn; import google.registry.beam.spec11.SafeBrowsingTransforms.EvaluateSafeBrowsingFn;
import google.registry.beam.spec11.SafeBrowsingTransformsTest.HttpResponder; import google.registry.beam.spec11.SafeBrowsingTransformsTest.HttpResponder;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainAuthInfo; import google.registry.model.domain.DomainAuthInfo;
import google.registry.model.eppcommon.AuthInfo.PasswordAuth; import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
@ -258,9 +258,9 @@ class Spec11PipelineTest {
createTld("bank"); createTld("bank");
createTld("dev"); createTld("dev");
ContactResource contact1 = persistActiveContact(registrar1.getRegistrarId()); Contact contact1 = persistActiveContact(registrar1.getRegistrarId());
ContactResource contact2 = persistActiveContact(registrar2.getRegistrarId()); Contact contact2 = persistActiveContact(registrar2.getRegistrarId());
ContactResource contact3 = persistActiveContact(registrar3.getRegistrarId()); Contact contact3 = persistActiveContact(registrar3.getRegistrarId());
persistResource(createDomain("111.com", "123456789-COM", registrar1, contact1)); persistResource(createDomain("111.com", "123456789-COM", registrar1, contact1));
persistResource(createDomain("party-night.net", "2244AABBC-NET", registrar2, contact2)); persistResource(createDomain("party-night.net", "2244AABBC-NET", registrar2, contact2));
@ -297,7 +297,7 @@ class Spec11PipelineTest {
} }
private Domain createDomain( private Domain createDomain(
String domainName, String repoId, Registrar registrar, ContactResource contact) { String domainName, String repoId, Registrar registrar, Contact contact) {
return new Domain.Builder() return new Domain.Builder()
.setDomainName(domainName) .setDomainName(domainName)
.setRepoId(repoId) .setRepoId(repoId)

View file

@ -24,11 +24,11 @@ import google.registry.flows.EppException;
import google.registry.flows.FlowUtils.NotLoggedInException; import google.registry.flows.FlowUtils.NotLoggedInException;
import google.registry.flows.ResourceCheckFlowTestCase; import google.registry.flows.ResourceCheckFlowTestCase;
import google.registry.flows.exceptions.TooManyResourceChecksException; import google.registry.flows.exceptions.TooManyResourceChecksException;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link ContactCheckFlow}. */ /** Unit tests for {@link ContactCheckFlow}. */
class ContactCheckFlowTest extends ResourceCheckFlowTestCase<ContactCheckFlow, ContactResource> { class ContactCheckFlowTest extends ResourceCheckFlowTestCase<ContactCheckFlow, Contact> {
ContactCheckFlowTest() { ContactCheckFlowTest() {
setEppInput("contact_check.xml"); setEppInput("contact_check.xml");

View file

@ -15,9 +15,9 @@
package google.registry.flows.contact; package google.registry.flows.contact;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.ContactResourceSubject.assertAboutContacts; import static google.registry.testing.ContactSubject.assertAboutContacts;
import static google.registry.testing.DatabaseHelper.assertNoBillingEvents; import static google.registry.testing.DatabaseHelper.assertNoBillingEvents;
import static google.registry.testing.DatabaseHelper.newContactResource; import static google.registry.testing.DatabaseHelper.newContact;
import static google.registry.testing.DatabaseHelper.persistActiveContact; import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistDeletedContact; import static google.registry.testing.DatabaseHelper.persistDeletedContact;
import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistResource;
@ -31,12 +31,12 @@ import google.registry.flows.contact.ContactFlowUtils.BadInternationalizedPostal
import google.registry.flows.contact.ContactFlowUtils.DeclineContactDisclosureFieldDisallowedPolicyException; import google.registry.flows.contact.ContactFlowUtils.DeclineContactDisclosureFieldDisallowedPolicyException;
import google.registry.flows.exceptions.ResourceAlreadyExistsForThisClientException; import google.registry.flows.exceptions.ResourceAlreadyExistsForThisClientException;
import google.registry.flows.exceptions.ResourceCreateContentionException; import google.registry.flows.exceptions.ResourceCreateContentionException;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link ContactCreateFlow}. */ /** Unit tests for {@link ContactCreateFlow}. */
class ContactCreateFlowTest extends ResourceFlowTestCase<ContactCreateFlow, ContactResource> { class ContactCreateFlowTest extends ResourceFlowTestCase<ContactCreateFlow, Contact> {
ContactCreateFlowTest() { ContactCreateFlowTest() {
setEppInput("contact_create.xml"); setEppInput("contact_create.xml");
@ -47,7 +47,7 @@ class ContactCreateFlowTest extends ResourceFlowTestCase<ContactCreateFlow, Cont
assertTransactionalFlow(true); assertTransactionalFlow(true);
runFlowAssertResponse(loadFile("contact_create_response.xml")); runFlowAssertResponse(loadFile("contact_create_response.xml"));
// Check that the contact was created and persisted with a history entry. // Check that the contact was created and persisted with a history entry.
ContactResource contact = reloadResourceByForeignKey(); Contact contact = reloadResourceByForeignKey();
assertAboutContacts().that(contact).hasOnlyOneHistoryEntryWhich().hasNoXml(); assertAboutContacts().that(contact).hasOnlyOneHistoryEntryWhich().hasNoXml();
assertNoBillingEvents(); assertNoBillingEvents();
assertLastHistoryContainsResource(contact); assertLastHistoryContainsResource(contact);
@ -93,7 +93,7 @@ class ContactCreateFlowTest extends ResourceFlowTestCase<ContactCreateFlow, Cont
void testFailure_resourceContention() throws Exception { void testFailure_resourceContention() throws Exception {
String targetId = getUniqueIdFromCommand(); String targetId = getUniqueIdFromCommand();
persistResource( persistResource(
newContactResource(targetId) newContact(targetId)
.asBuilder() .asBuilder()
.setPersistedCurrentSponsorRegistrarId("NewRegistrar") .setPersistedCurrentSponsorRegistrarId("NewRegistrar")
.build()); .build());

View file

@ -17,11 +17,11 @@ package google.registry.flows.contact;
import static com.google.common.collect.MoreCollectors.onlyElement; import static com.google.common.collect.MoreCollectors.onlyElement;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static google.registry.batch.AsyncTaskEnqueuer.QUEUE_ASYNC_DELETE; import static google.registry.batch.AsyncTaskEnqueuer.QUEUE_ASYNC_DELETE;
import static google.registry.testing.ContactResourceSubject.assertAboutContacts; import static google.registry.testing.ContactSubject.assertAboutContacts;
import static google.registry.testing.DatabaseHelper.assertNoBillingEvents; import static google.registry.testing.DatabaseHelper.assertNoBillingEvents;
import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.getPollMessages; import static google.registry.testing.DatabaseHelper.getPollMessages;
import static google.registry.testing.DatabaseHelper.newContactResource; import static google.registry.testing.DatabaseHelper.newContact;
import static google.registry.testing.DatabaseHelper.persistActiveContact; import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistContactWithPendingTransfer; import static google.registry.testing.DatabaseHelper.persistContactWithPendingTransfer;
import static google.registry.testing.DatabaseHelper.persistDeletedContact; import static google.registry.testing.DatabaseHelper.persistDeletedContact;
@ -39,7 +39,7 @@ import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException; import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
import google.registry.flows.exceptions.ResourceStatusProhibitsOperationException; import google.registry.flows.exceptions.ResourceStatusProhibitsOperationException;
import google.registry.flows.exceptions.ResourceToDeleteIsReferencedException; import google.registry.flows.exceptions.ResourceToDeleteIsReferencedException;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppcommon.Trid; import google.registry.model.eppcommon.Trid;
import google.registry.model.poll.PendingActionNotificationResponse; import google.registry.model.poll.PendingActionNotificationResponse;
@ -56,7 +56,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link ContactDeleteFlow}. */ /** Unit tests for {@link ContactDeleteFlow}. */
class ContactDeleteFlowTest extends ResourceFlowTestCase<ContactDeleteFlow, ContactResource> { class ContactDeleteFlowTest extends ResourceFlowTestCase<ContactDeleteFlow, Contact> {
@BeforeEach @BeforeEach
void initFlowTest() { void initFlowTest() {
@ -99,7 +99,7 @@ class ContactDeleteFlowTest extends ResourceFlowTestCase<ContactDeleteFlow, Cont
assertTransactionalFlow(true); assertTransactionalFlow(true);
runFlowAssertResponse(loadFile("contact_delete_response.xml")); runFlowAssertResponse(loadFile("contact_delete_response.xml"));
assertSqlDeleteSuccess(Type.CONTACT_DELETE, Type.CONTACT_TRANSFER_REQUEST); assertSqlDeleteSuccess(Type.CONTACT_DELETE, Type.CONTACT_TRANSFER_REQUEST);
ContactResource softDeletedContact = reloadResourceByForeignKey(clock.nowUtc().minusMillis(1)); Contact softDeletedContact = reloadResourceByForeignKey(clock.nowUtc().minusMillis(1));
assertThat(softDeletedContact.getTransferData()) assertThat(softDeletedContact.getTransferData())
.isEqualTo( .isEqualTo(
oldTransferData oldTransferData
@ -175,7 +175,7 @@ class ContactDeleteFlowTest extends ResourceFlowTestCase<ContactDeleteFlow, Cont
private void doFailingStatusTest(StatusValue statusValue, Class<? extends EppException> exception) private void doFailingStatusTest(StatusValue statusValue, Class<? extends EppException> exception)
throws Exception { throws Exception {
persistResource( persistResource(
newContactResource(getUniqueIdFromCommand()) newContact(getUniqueIdFromCommand())
.asBuilder() .asBuilder()
.setStatusValues(ImmutableSet.of(statusValue)) .setStatusValues(ImmutableSet.of(statusValue))
.build()); .build());

View file

@ -29,10 +29,10 @@ import google.registry.flows.FlowUtils.NotLoggedInException;
import google.registry.flows.ResourceFlowTestCase; import google.registry.flows.ResourceFlowTestCase;
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException; import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException; import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactAddress; import google.registry.model.contact.ContactAddress;
import google.registry.model.contact.ContactAuthInfo; import google.registry.model.contact.ContactAuthInfo;
import google.registry.model.contact.ContactPhoneNumber; import google.registry.model.contact.ContactPhoneNumber;
import google.registry.model.contact.ContactResource;
import google.registry.model.contact.Disclose; import google.registry.model.contact.Disclose;
import google.registry.model.contact.PostalInfo; import google.registry.model.contact.PostalInfo;
import google.registry.model.contact.PostalInfo.Type; import google.registry.model.contact.PostalInfo.Type;
@ -44,16 +44,16 @@ import org.joda.time.DateTime;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link ContactInfoFlow}. */ /** Unit tests for {@link ContactInfoFlow}. */
class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, ContactResource> { class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, Contact> {
ContactInfoFlowTest() { ContactInfoFlowTest() {
setEppInput("contact_info.xml"); setEppInput("contact_info.xml");
} }
private ContactResource persistContactResource(boolean active) { private Contact persistContact(boolean active) {
ContactResource contact = Contact contact =
persistResource( persistResource(
new ContactResource.Builder() new Contact.Builder()
.setContactId("sh8013") .setContactId("sh8013")
.setRepoId("2FF-ROID") .setRepoId("2FF-ROID")
.setDeletionTime(active ? null : clock.nowUtc().minusDays(1)) .setDeletionTime(active ? null : clock.nowUtc().minusDays(1))
@ -107,7 +107,7 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, ContactR
@Test @Test
void testSuccess() throws Exception { void testSuccess() throws Exception {
persistContactResource(true); persistContact(true);
// Check that the persisted contact info was returned. // Check that the persisted contact info was returned.
assertTransactionalFlow(false); assertTransactionalFlow(false);
runFlowAssertResponse( runFlowAssertResponse(
@ -121,7 +121,7 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, ContactR
@Test @Test
void testSuccess_linked() throws Exception { void testSuccess_linked() throws Exception {
createTld("foobar"); createTld("foobar");
persistResource(DatabaseHelper.newDomain("example.foobar", persistContactResource(true))); persistResource(DatabaseHelper.newDomain("example.foobar", persistContact(true)));
// Check that the persisted contact info was returned. // Check that the persisted contact info was returned.
assertTransactionalFlow(false); assertTransactionalFlow(false);
runFlowAssertResponse( runFlowAssertResponse(
@ -135,7 +135,7 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, ContactR
@Test @Test
void testSuccess_owningRegistrarWithoutAuthInfo_seesAuthInfo() throws Exception { void testSuccess_owningRegistrarWithoutAuthInfo_seesAuthInfo() throws Exception {
setEppInput("contact_info_no_authinfo.xml"); setEppInput("contact_info_no_authinfo.xml");
persistContactResource(true); persistContact(true);
// Check that the persisted contact info was returned. // Check that the persisted contact info was returned.
assertTransactionalFlow(false); assertTransactionalFlow(false);
runFlowAssertResponse( runFlowAssertResponse(
@ -149,7 +149,7 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, ContactR
@Test @Test
void testFailure_otherRegistrar_notAuthorized() throws Exception { void testFailure_otherRegistrar_notAuthorized() throws Exception {
setRegistrarIdForFlow("NewRegistrar"); setRegistrarIdForFlow("NewRegistrar");
persistContactResource(true); persistContact(true);
// Check that the persisted contact info was returned. // Check that the persisted contact info was returned.
assertTransactionalFlow(false); assertTransactionalFlow(false);
ResourceNotOwnedException thrown = assertThrows(ResourceNotOwnedException.class, this::runFlow); ResourceNotOwnedException thrown = assertThrows(ResourceNotOwnedException.class, this::runFlow);
@ -160,7 +160,7 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, ContactR
void testSuccess_otherRegistrarWithoutAuthInfoAsSuperuser_doesNotSeeAuthInfo() throws Exception { void testSuccess_otherRegistrarWithoutAuthInfoAsSuperuser_doesNotSeeAuthInfo() throws Exception {
setRegistrarIdForFlow("NewRegistrar"); setRegistrarIdForFlow("NewRegistrar");
setEppInput("contact_info_no_authinfo.xml"); setEppInput("contact_info_no_authinfo.xml");
persistContactResource(true); persistContact(true);
// Check that the persisted contact info was returned. // Check that the persisted contact info was returned.
assertTransactionalFlow(false); assertTransactionalFlow(false);
runFlowAssertResponse( runFlowAssertResponse(
@ -176,7 +176,7 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, ContactR
@Test @Test
void testSuccess_otherRegistrarWithAuthInfoAsSuperuser_seesAuthInfo() throws Exception { void testSuccess_otherRegistrarWithAuthInfoAsSuperuser_seesAuthInfo() throws Exception {
setRegistrarIdForFlow("NewRegistrar"); setRegistrarIdForFlow("NewRegistrar");
persistContactResource(true); persistContact(true);
// Check that the persisted contact info was returned. // Check that the persisted contact info was returned.
assertTransactionalFlow(false); assertTransactionalFlow(false);
runFlowAssertResponse( runFlowAssertResponse(
@ -199,7 +199,7 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, ContactR
@Test @Test
void testFailure_existedButWasDeleted() throws Exception { void testFailure_existedButWasDeleted() throws Exception {
persistContactResource(false); persistContact(false);
ResourceDoesNotExistException thrown = ResourceDoesNotExistException thrown =
assertThrows(ResourceDoesNotExistException.class, this::runFlow); assertThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand())); assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
@ -208,7 +208,7 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, ContactR
@Test @Test
void testIcannActivityReportField_getsLogged() throws Exception { void testIcannActivityReportField_getsLogged() throws Exception {
persistContactResource(true); persistContact(true);
runFlow(); runFlow();
assertIcannReportingActivityFieldLogged("srs-cont-info"); assertIcannReportingActivityFieldLogged("srs-cont-info");
} }

View file

@ -16,7 +16,7 @@ package google.registry.flows.contact;
import static com.google.common.collect.MoreCollectors.onlyElement; import static com.google.common.collect.MoreCollectors.onlyElement;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.ContactResourceSubject.assertAboutContacts; import static google.registry.testing.ContactSubject.assertAboutContacts;
import static google.registry.testing.DatabaseHelper.assertNoBillingEvents; import static google.registry.testing.DatabaseHelper.assertNoBillingEvents;
import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.getOnlyPollMessage; import static google.registry.testing.DatabaseHelper.getOnlyPollMessage;
@ -31,8 +31,8 @@ import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException; import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException; import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
import google.registry.flows.exceptions.NotPendingTransferException; import google.registry.flows.exceptions.NotPendingTransferException;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactAuthInfo; import google.registry.model.contact.ContactAuthInfo;
import google.registry.model.contact.ContactResource;
import google.registry.model.eppcommon.AuthInfo.PasswordAuth; import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
import google.registry.model.eppcommon.Trid; import google.registry.model.eppcommon.Trid;
import google.registry.model.poll.PendingActionNotificationResponse; import google.registry.model.poll.PendingActionNotificationResponse;
@ -46,7 +46,7 @@ import org.junit.jupiter.api.Test;
/** Unit tests for {@link ContactTransferApproveFlow}. */ /** Unit tests for {@link ContactTransferApproveFlow}. */
class ContactTransferApproveFlowTest class ContactTransferApproveFlowTest
extends ContactTransferFlowTestCase<ContactTransferApproveFlow, ContactResource> { extends ContactTransferFlowTestCase<ContactTransferApproveFlow, Contact> {
@BeforeEach @BeforeEach
void setUp() { void setUp() {

View file

@ -16,7 +16,7 @@ package google.registry.flows.contact;
import static com.google.common.collect.MoreCollectors.onlyElement; import static com.google.common.collect.MoreCollectors.onlyElement;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.ContactResourceSubject.assertAboutContacts; import static google.registry.testing.ContactSubject.assertAboutContacts;
import static google.registry.testing.DatabaseHelper.assertNoBillingEvents; import static google.registry.testing.DatabaseHelper.assertNoBillingEvents;
import static google.registry.testing.DatabaseHelper.getOnlyPollMessage; import static google.registry.testing.DatabaseHelper.getOnlyPollMessage;
import static google.registry.testing.DatabaseHelper.getPollMessages; import static google.registry.testing.DatabaseHelper.getPollMessages;
@ -30,8 +30,8 @@ import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException; import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
import google.registry.flows.exceptions.NotPendingTransferException; import google.registry.flows.exceptions.NotPendingTransferException;
import google.registry.flows.exceptions.NotTransferInitiatorException; import google.registry.flows.exceptions.NotTransferInitiatorException;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactAuthInfo; import google.registry.model.contact.ContactAuthInfo;
import google.registry.model.contact.ContactResource;
import google.registry.model.eppcommon.AuthInfo.PasswordAuth; import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
import google.registry.model.poll.PollMessage; import google.registry.model.poll.PollMessage;
import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry;
@ -43,7 +43,7 @@ import org.junit.jupiter.api.Test;
/** Unit tests for {@link ContactTransferCancelFlow}. */ /** Unit tests for {@link ContactTransferCancelFlow}. */
class ContactTransferCancelFlowTest class ContactTransferCancelFlowTest
extends ContactTransferFlowTestCase<ContactTransferCancelFlow, ContactResource> { extends ContactTransferFlowTestCase<ContactTransferCancelFlow, Contact> {
@BeforeEach @BeforeEach
void setUp() { void setUp() {

View file

@ -15,14 +15,14 @@
package google.registry.flows.contact; package google.registry.flows.contact;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import static google.registry.testing.DatabaseHelper.newContactResource; import static google.registry.testing.DatabaseHelper.newContact;
import static google.registry.testing.DatabaseHelper.persistContactWithPendingTransfer; import static google.registry.testing.DatabaseHelper.persistContactWithPendingTransfer;
import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistResource;
import google.registry.flows.Flow; import google.registry.flows.Flow;
import google.registry.flows.ResourceFlowTestCase; import google.registry.flows.ResourceFlowTestCase;
import google.registry.model.EppResource; import google.registry.model.EppResource;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.tld.Registry; import google.registry.model.tld.Registry;
import google.registry.model.transfer.TransferStatus; import google.registry.model.transfer.TransferStatus;
import google.registry.testing.AppEngineExtension; import google.registry.testing.AppEngineExtension;
@ -47,7 +47,7 @@ abstract class ContactTransferFlowTestCase<F extends Flow, R extends EppResource
TRANSFER_REQUEST_TIME.plus(Registry.DEFAULT_TRANSFER_GRACE_PERIOD); TRANSFER_REQUEST_TIME.plus(Registry.DEFAULT_TRANSFER_GRACE_PERIOD);
private static final Duration TIME_SINCE_REQUEST = Duration.standardDays(3); private static final Duration TIME_SINCE_REQUEST = Duration.standardDays(3);
protected ContactResource contact; protected Contact contact;
ContactTransferFlowTestCase() { ContactTransferFlowTestCase() {
checkState(!Registry.DEFAULT_TRANSFER_GRACE_PERIOD.isShorterThan(TIME_SINCE_REQUEST)); checkState(!Registry.DEFAULT_TRANSFER_GRACE_PERIOD.isShorterThan(TIME_SINCE_REQUEST));
@ -64,8 +64,9 @@ abstract class ContactTransferFlowTestCase<F extends Flow, R extends EppResource
/** Adds a contact that has a pending transfer on it from TheRegistrar to NewRegistrar. */ /** Adds a contact that has a pending transfer on it from TheRegistrar to NewRegistrar. */
void setupContactWithPendingTransfer() { void setupContactWithPendingTransfer() {
contact = persistContactWithPendingTransfer( contact =
newContactResource("sh8013"), persistContactWithPendingTransfer(
newContact("sh8013"),
TRANSFER_REQUEST_TIME, TRANSFER_REQUEST_TIME,
TRANSFER_EXPIRATION_TIME, TRANSFER_EXPIRATION_TIME,
TRANSFER_REQUEST_TIME); TRANSFER_REQUEST_TIME);

View file

@ -15,7 +15,7 @@
package google.registry.flows.contact; package google.registry.flows.contact;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.ContactResourceSubject.assertAboutContacts; import static google.registry.testing.ContactSubject.assertAboutContacts;
import static google.registry.testing.DatabaseHelper.assertNoBillingEvents; import static google.registry.testing.DatabaseHelper.assertNoBillingEvents;
import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
@ -27,8 +27,8 @@ import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException; import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
import google.registry.flows.exceptions.NoTransferHistoryToQueryException; import google.registry.flows.exceptions.NoTransferHistoryToQueryException;
import google.registry.flows.exceptions.NotAuthorizedToViewTransferException; import google.registry.flows.exceptions.NotAuthorizedToViewTransferException;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactAuthInfo; import google.registry.model.contact.ContactAuthInfo;
import google.registry.model.contact.ContactResource;
import google.registry.model.eppcommon.AuthInfo.PasswordAuth; import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry;
import google.registry.model.transfer.TransferStatus; import google.registry.model.transfer.TransferStatus;
@ -38,7 +38,7 @@ import org.junit.jupiter.api.Test;
/** Unit tests for {@link ContactTransferQueryFlow}. */ /** Unit tests for {@link ContactTransferQueryFlow}. */
class ContactTransferQueryFlowTest class ContactTransferQueryFlowTest
extends ContactTransferFlowTestCase<ContactTransferQueryFlow, ContactResource> { extends ContactTransferFlowTestCase<ContactTransferQueryFlow, Contact> {
@BeforeEach @BeforeEach
void setUp() { void setUp() {

View file

@ -16,7 +16,7 @@ package google.registry.flows.contact;
import static com.google.common.collect.MoreCollectors.onlyElement; import static com.google.common.collect.MoreCollectors.onlyElement;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.ContactResourceSubject.assertAboutContacts; import static google.registry.testing.ContactSubject.assertAboutContacts;
import static google.registry.testing.DatabaseHelper.assertNoBillingEvents; import static google.registry.testing.DatabaseHelper.assertNoBillingEvents;
import static google.registry.testing.DatabaseHelper.getOnlyPollMessage; import static google.registry.testing.DatabaseHelper.getOnlyPollMessage;
import static google.registry.testing.DatabaseHelper.getPollMessages; import static google.registry.testing.DatabaseHelper.getPollMessages;
@ -30,8 +30,8 @@ import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException; import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException; import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
import google.registry.flows.exceptions.NotPendingTransferException; import google.registry.flows.exceptions.NotPendingTransferException;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactAuthInfo; import google.registry.model.contact.ContactAuthInfo;
import google.registry.model.contact.ContactResource;
import google.registry.model.eppcommon.AuthInfo.PasswordAuth; import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
import google.registry.model.eppcommon.Trid; import google.registry.model.eppcommon.Trid;
import google.registry.model.poll.PendingActionNotificationResponse; import google.registry.model.poll.PendingActionNotificationResponse;
@ -45,7 +45,7 @@ import org.junit.jupiter.api.Test;
/** Unit tests for {@link ContactTransferRejectFlow}. */ /** Unit tests for {@link ContactTransferRejectFlow}. */
class ContactTransferRejectFlowTest class ContactTransferRejectFlowTest
extends ContactTransferFlowTestCase<ContactTransferRejectFlow, ContactResource> { extends ContactTransferFlowTestCase<ContactTransferRejectFlow, Contact> {
@BeforeEach @BeforeEach
void setUp() { void setUp() {

View file

@ -20,7 +20,7 @@ import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.collect.MoreCollectors.onlyElement; import static com.google.common.collect.MoreCollectors.onlyElement;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static google.registry.config.RegistryConfig.getContactAutomaticTransferLength; import static google.registry.config.RegistryConfig.getContactAutomaticTransferLength;
import static google.registry.testing.ContactResourceSubject.assertAboutContacts; import static google.registry.testing.ContactSubject.assertAboutContacts;
import static google.registry.testing.DatabaseHelper.assertNoBillingEvents; import static google.registry.testing.DatabaseHelper.assertNoBillingEvents;
import static google.registry.testing.DatabaseHelper.assertPollMessagesEqual; import static google.registry.testing.DatabaseHelper.assertPollMessagesEqual;
import static google.registry.testing.DatabaseHelper.deleteResource; import static google.registry.testing.DatabaseHelper.deleteResource;
@ -42,8 +42,8 @@ import google.registry.flows.exceptions.AlreadyPendingTransferException;
import google.registry.flows.exceptions.MissingTransferRequestAuthInfoException; import google.registry.flows.exceptions.MissingTransferRequestAuthInfoException;
import google.registry.flows.exceptions.ObjectAlreadySponsoredException; import google.registry.flows.exceptions.ObjectAlreadySponsoredException;
import google.registry.flows.exceptions.ResourceStatusProhibitsOperationException; import google.registry.flows.exceptions.ResourceStatusProhibitsOperationException;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactAuthInfo; import google.registry.model.contact.ContactAuthInfo;
import google.registry.model.contact.ContactResource;
import google.registry.model.eppcommon.AuthInfo.PasswordAuth; import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppcommon.Trid; import google.registry.model.eppcommon.Trid;
@ -57,7 +57,7 @@ import org.junit.jupiter.api.Test;
/** Unit tests for {@link ContactTransferRequestFlow}. */ /** Unit tests for {@link ContactTransferRequestFlow}. */
class ContactTransferRequestFlowTest class ContactTransferRequestFlowTest
extends ContactTransferFlowTestCase<ContactTransferRequestFlow, ContactResource> { extends ContactTransferFlowTestCase<ContactTransferRequestFlow, Contact> {
ContactTransferRequestFlowTest() { ContactTransferRequestFlowTest() {
// We need the transfer to happen at exactly this time in order for the response to match up. // We need the transfer to happen at exactly this time in order for the response to match up.

View file

@ -15,9 +15,9 @@
package google.registry.flows.contact; package google.registry.flows.contact;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.ContactResourceSubject.assertAboutContacts; import static google.registry.testing.ContactSubject.assertAboutContacts;
import static google.registry.testing.DatabaseHelper.assertNoBillingEvents; import static google.registry.testing.DatabaseHelper.assertNoBillingEvents;
import static google.registry.testing.DatabaseHelper.newContactResource; import static google.registry.testing.DatabaseHelper.newContact;
import static google.registry.testing.DatabaseHelper.persistActiveContact; import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistDeletedContact; import static google.registry.testing.DatabaseHelper.persistDeletedContact;
import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistResource;
@ -37,15 +37,15 @@ import google.registry.flows.contact.ContactFlowUtils.BadInternationalizedPostal
import google.registry.flows.contact.ContactFlowUtils.DeclineContactDisclosureFieldDisallowedPolicyException; import google.registry.flows.contact.ContactFlowUtils.DeclineContactDisclosureFieldDisallowedPolicyException;
import google.registry.flows.exceptions.ResourceHasClientUpdateProhibitedException; import google.registry.flows.exceptions.ResourceHasClientUpdateProhibitedException;
import google.registry.flows.exceptions.ResourceStatusProhibitsOperationException; import google.registry.flows.exceptions.ResourceStatusProhibitsOperationException;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactAddress; import google.registry.model.contact.ContactAddress;
import google.registry.model.contact.ContactResource;
import google.registry.model.contact.PostalInfo; import google.registry.model.contact.PostalInfo;
import google.registry.model.contact.PostalInfo.Type; import google.registry.model.contact.PostalInfo.Type;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link ContactUpdateFlow}. */ /** Unit tests for {@link ContactUpdateFlow}. */
class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, ContactResource> { class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Contact> {
ContactUpdateFlowTest() { ContactUpdateFlowTest() {
setEppInput("contact_update.xml"); setEppInput("contact_update.xml");
@ -56,7 +56,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
clock.advanceOneMilli(); clock.advanceOneMilli();
assertTransactionalFlow(true); assertTransactionalFlow(true);
runFlowAssertResponse(loadFile("generic_success_response.xml")); runFlowAssertResponse(loadFile("generic_success_response.xml"));
ContactResource contact = reloadResourceByForeignKey(); Contact contact = reloadResourceByForeignKey();
// Check that the contact was updated. This value came from the xml. // Check that the contact was updated. This value came from the xml.
assertAboutContacts() assertAboutContacts()
.that(contact) .that(contact)
@ -88,12 +88,15 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
@Test @Test
void testSuccess_updatingInternationalizedPostalInfoDeletesLocalized() throws Exception { void testSuccess_updatingInternationalizedPostalInfoDeletesLocalized() throws Exception {
ContactResource contact = Contact contact =
persistResource( persistResource(
newContactResource(getUniqueIdFromCommand()).asBuilder() newContact(getUniqueIdFromCommand())
.setLocalizedPostalInfo(new PostalInfo.Builder() .asBuilder()
.setLocalizedPostalInfo(
new PostalInfo.Builder()
.setType(Type.LOCALIZED) .setType(Type.LOCALIZED)
.setAddress(new ContactAddress.Builder() .setAddress(
new ContactAddress.Builder()
.setStreet(ImmutableList.of("111 8th Ave", "4th Floor")) .setStreet(ImmutableList.of("111 8th Ave", "4th Floor"))
.setCity("New York") .setCity("New York")
.setState("NY") .setState("NY")
@ -127,12 +130,15 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
@Test @Test
void testSuccess_updatingLocalizedPostalInfoDeletesInternationalized() throws Exception { void testSuccess_updatingLocalizedPostalInfoDeletesInternationalized() throws Exception {
setEppInput("contact_update_localized.xml"); setEppInput("contact_update_localized.xml");
ContactResource contact = Contact contact =
persistResource( persistResource(
newContactResource(getUniqueIdFromCommand()).asBuilder() newContact(getUniqueIdFromCommand())
.setInternationalizedPostalInfo(new PostalInfo.Builder() .asBuilder()
.setInternationalizedPostalInfo(
new PostalInfo.Builder()
.setType(Type.INTERNATIONALIZED) .setType(Type.INTERNATIONALIZED)
.setAddress(new ContactAddress.Builder() .setAddress(
new ContactAddress.Builder()
.setStreet(ImmutableList.of("111 8th Ave", "4th Floor")) .setStreet(ImmutableList.of("111 8th Ave", "4th Floor"))
.setCity("New York") .setCity("New York")
.setState("NY") .setState("NY")
@ -167,12 +173,15 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
void testSuccess_partialPostalInfoUpdate() throws Exception { void testSuccess_partialPostalInfoUpdate() throws Exception {
setEppInput("contact_update_partial_postalinfo.xml"); setEppInput("contact_update_partial_postalinfo.xml");
persistResource( persistResource(
newContactResource(getUniqueIdFromCommand()).asBuilder() newContact(getUniqueIdFromCommand())
.setLocalizedPostalInfo(new PostalInfo.Builder() .asBuilder()
.setLocalizedPostalInfo(
new PostalInfo.Builder()
.setType(Type.LOCALIZED) .setType(Type.LOCALIZED)
.setName("A. Person") .setName("A. Person")
.setOrg("Company Inc.") .setOrg("Company Inc.")
.setAddress(new ContactAddress.Builder() .setAddress(
new ContactAddress.Builder()
.setStreet(ImmutableList.of("123 4th st", "5th Floor")) .setStreet(ImmutableList.of("123 4th st", "5th Floor"))
.setCity("City") .setCity("City")
.setState("AB") .setState("AB")
@ -203,12 +212,15 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
void testSuccess_updateOnePostalInfo_touchOtherPostalInfoPreservesIt() throws Exception { void testSuccess_updateOnePostalInfo_touchOtherPostalInfoPreservesIt() throws Exception {
setEppInput("contact_update_partial_postalinfo_preserve_int.xml"); setEppInput("contact_update_partial_postalinfo_preserve_int.xml");
persistResource( persistResource(
newContactResource(getUniqueIdFromCommand()).asBuilder() newContact(getUniqueIdFromCommand())
.setLocalizedPostalInfo(new PostalInfo.Builder() .asBuilder()
.setLocalizedPostalInfo(
new PostalInfo.Builder()
.setType(Type.LOCALIZED) .setType(Type.LOCALIZED)
.setName("A. Person") .setName("A. Person")
.setOrg("Company Inc.") .setOrg("Company Inc.")
.setAddress(new ContactAddress.Builder() .setAddress(
new ContactAddress.Builder()
.setStreet(ImmutableList.of("123 4th st", "5th Floor")) .setStreet(ImmutableList.of("123 4th st", "5th Floor"))
.setCity("City") .setCity("City")
.setState("AB") .setState("AB")
@ -216,11 +228,13 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
.setCountryCode("US") .setCountryCode("US")
.build()) .build())
.build()) .build())
.setInternationalizedPostalInfo(new PostalInfo.Builder() .setInternationalizedPostalInfo(
new PostalInfo.Builder()
.setType(Type.INTERNATIONALIZED) .setType(Type.INTERNATIONALIZED)
.setName("B. Person") .setName("B. Person")
.setOrg("Company Co.") .setOrg("Company Co.")
.setAddress(new ContactAddress.Builder() .setAddress(
new ContactAddress.Builder()
.setStreet(ImmutableList.of("100 200th Dr.", "6th Floor")) .setStreet(ImmutableList.of("100 200th Dr.", "6th Floor"))
.setCity("Town") .setCity("Town")
.setState("CD") .setState("CD")
@ -320,7 +334,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
void testSuccess_clientUpdateProhibited_removed() throws Exception { void testSuccess_clientUpdateProhibited_removed() throws Exception {
setEppInput("contact_update_remove_client_update_prohibited.xml"); setEppInput("contact_update_remove_client_update_prohibited.xml");
persistResource( persistResource(
newContactResource(getUniqueIdFromCommand()) newContact(getUniqueIdFromCommand())
.asBuilder() .asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED)) .setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
.build()); .build());
@ -334,7 +348,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
void testSuccess_superuserClientUpdateProhibited_notRemoved() throws Exception { void testSuccess_superuserClientUpdateProhibited_notRemoved() throws Exception {
setEppInput("contact_update_prohibited_status.xml"); setEppInput("contact_update_prohibited_status.xml");
persistResource( persistResource(
newContactResource(getUniqueIdFromCommand()) newContact(getUniqueIdFromCommand())
.asBuilder() .asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED)) .setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
.build()); .build());
@ -351,7 +365,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
@Test @Test
void testFailure_clientUpdateProhibited_notRemoved() throws Exception { void testFailure_clientUpdateProhibited_notRemoved() throws Exception {
persistResource( persistResource(
newContactResource(getUniqueIdFromCommand()) newContact(getUniqueIdFromCommand())
.asBuilder() .asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED)) .setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
.build()); .build());
@ -363,7 +377,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
@Test @Test
void testFailure_serverUpdateProhibited() throws Exception { void testFailure_serverUpdateProhibited() throws Exception {
persistResource( persistResource(
newContactResource(getUniqueIdFromCommand()) newContact(getUniqueIdFromCommand())
.asBuilder() .asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.SERVER_UPDATE_PROHIBITED)) .setStatusValues(ImmutableSet.of(StatusValue.SERVER_UPDATE_PROHIBITED))
.build()); .build());
@ -376,7 +390,7 @@ class ContactUpdateFlowTest extends ResourceFlowTestCase<ContactUpdateFlow, Cont
@Test @Test
void testFailure_pendingDeleteProhibited() throws Exception { void testFailure_pendingDeleteProhibited() throws Exception {
persistResource( persistResource(
newContactResource(getUniqueIdFromCommand()) newContact(getUniqueIdFromCommand())
.asBuilder() .asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE)) .setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
.build()); .build());

View file

@ -43,7 +43,7 @@ import static google.registry.testing.DatabaseHelper.createTlds;
import static google.registry.testing.DatabaseHelper.deleteTld; import static google.registry.testing.DatabaseHelper.deleteTld;
import static google.registry.testing.DatabaseHelper.getHistoryEntries; import static google.registry.testing.DatabaseHelper.getHistoryEntries;
import static google.registry.testing.DatabaseHelper.loadRegistrar; import static google.registry.testing.DatabaseHelper.loadRegistrar;
import static google.registry.testing.DatabaseHelper.newContactResource; import static google.registry.testing.DatabaseHelper.newContact;
import static google.registry.testing.DatabaseHelper.newHost; import static google.registry.testing.DatabaseHelper.newHost;
import static google.registry.testing.DatabaseHelper.persistActiveContact; import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistActiveDomain; import static google.registry.testing.DatabaseHelper.persistActiveDomain;
@ -1723,8 +1723,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistActiveHost("ns1.example.net"); persistActiveHost("ns1.example.net");
persistActiveHost("ns2.example.net"); persistActiveHost("ns2.example.net");
persistActiveContact("sh8013"); persistActiveContact("sh8013");
persistResource( persistResource(newContact("jd1234").asBuilder().addStatusValue(PENDING_DELETE).build());
newContactResource("jd1234").asBuilder().addStatusValue(PENDING_DELETE).build());
clock.advanceOneMilli(); clock.advanceOneMilli();
LinkedResourceInPendingDeleteProhibitsOperationException thrown = LinkedResourceInPendingDeleteProhibitsOperationException thrown =
assertThrows(LinkedResourceInPendingDeleteProhibitsOperationException.class, this::runFlow); assertThrows(LinkedResourceInPendingDeleteProhibitsOperationException.class, this::runFlow);

View file

@ -80,7 +80,7 @@ import google.registry.flows.exceptions.ResourceStatusProhibitsOperationExceptio
import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.GracePeriod; import google.registry.model.domain.GracePeriod;
@ -155,7 +155,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
private void createReferencedEntities(DateTime expirationTime) throws Exception { private void createReferencedEntities(DateTime expirationTime) throws Exception {
// Persist a linked contact. // Persist a linked contact.
ContactResource contact = persistActiveContact("sh8013"); Contact contact = persistActiveContact("sh8013");
domain = domain =
persistResource( persistResource(
DatabaseHelper.newDomain(getUniqueIdFromCommand()) DatabaseHelper.newDomain(getUniqueIdFromCommand())
@ -742,9 +742,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
DatabaseHelper.newDomain("example1.tld") DatabaseHelper.newDomain("example1.tld")
.asBuilder() .asBuilder()
.setRegistrant( .setRegistrant(
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc()) loadByForeignKey(Contact.class, "sh8013", clock.nowUtc()).get().createVKey())
.get()
.createVKey())
.setNameservers(ImmutableSet.of(host.createVKey())) .setNameservers(ImmutableSet.of(host.createVKey()))
.setDeletionTime(START_OF_TIME) .setDeletionTime(START_OF_TIME)
.build()); .build());

View file

@ -52,8 +52,8 @@ import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.billing.BillingEvent.Recurring; import google.registry.model.billing.BillingEvent.Recurring;
import google.registry.model.billing.BillingEvent.RenewalPriceBehavior; import google.registry.model.billing.BillingEvent.RenewalPriceBehavior;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactAuthInfo; import google.registry.model.contact.ContactAuthInfo;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DesignatedContact;
import google.registry.model.domain.DesignatedContact.Type; import google.registry.model.domain.DesignatedContact.Type;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
@ -94,8 +94,8 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
private static final Pattern OK_PATTERN = Pattern.compile("\"ok\""); private static final Pattern OK_PATTERN = Pattern.compile("\"ok\"");
private ContactResource registrant; private Contact registrant;
private ContactResource contact; private Contact contact;
private Host host1; private Host host1;
private Host host2; private Host host2;
private Host host3; private Host host3;
@ -661,7 +661,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
@Test @Test
void testFailure_differentRegistrarUnrelatedContactAuthInfo() { void testFailure_differentRegistrarUnrelatedContactAuthInfo() {
persistTestEntities(false); persistTestEntities(false);
ContactResource unrelatedContact = persistActiveContact("foo1234"); Contact unrelatedContact = persistActiveContact("foo1234");
sessionMetadata.setRegistrarId("ClientZ"); sessionMetadata.setRegistrarId("ClientZ");
setEppInput("domain_info_with_contact_auth.xml"); setEppInput("domain_info_with_contact_auth.xml");
// Replace the ROID in the xml file with the one for our unrelated contact. // Replace the ROID in the xml file with the one for our unrelated contact.
@ -673,7 +673,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
@Test @Test
void testFailure_unrelatedContactAuthInfo() { void testFailure_unrelatedContactAuthInfo() {
persistTestEntities(false); persistTestEntities(false);
ContactResource unrelatedContact = persistActiveContact("foo1234"); Contact unrelatedContact = persistActiveContact("foo1234");
setEppInput("domain_info_with_contact_auth.xml"); setEppInput("domain_info_with_contact_auth.xml");
// Replace the ROID in the xml file with the one for our unrelated contact. // Replace the ROID in the xml file with the one for our unrelated contact.
eppLoader.replaceAll("JD1234-REP", unrelatedContact.getRepoId()); eppLoader.replaceAll("JD1234-REP", unrelatedContact.getRepoId());

View file

@ -35,7 +35,7 @@ import google.registry.model.EppResource;
import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
@ -71,7 +71,7 @@ abstract class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
static final DateTime EXTENDED_REGISTRATION_EXPIRATION_TIME = static final DateTime EXTENDED_REGISTRATION_EXPIRATION_TIME =
REGISTRATION_EXPIRATION_TIME.plusYears(EXTENDED_REGISTRATION_YEARS); REGISTRATION_EXPIRATION_TIME.plusYears(EXTENDED_REGISTRATION_YEARS);
protected ContactResource contact; protected Contact contact;
protected Domain domain; protected Domain domain;
Host subordinateHost; Host subordinateHost;
private DomainHistory historyEntryDomainCreate; private DomainHistory historyEntryDomainCreate;

View file

@ -91,7 +91,7 @@ import google.registry.flows.exceptions.ResourceHasClientUpdateProhibitedExcepti
import google.registry.flows.exceptions.ResourceStatusProhibitsOperationException; import google.registry.flows.exceptions.ResourceStatusProhibitsOperationException;
import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DesignatedContact;
import google.registry.model.domain.DesignatedContact.Type; import google.registry.model.domain.DesignatedContact.Type;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
@ -127,9 +127,9 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
"DIGEST_TYPE", "1", "DIGEST_TYPE", "1",
"DIGEST", "A94A8FE5CCB19BA61C4C0873D391E987982FBBD3"); "DIGEST", "A94A8FE5CCB19BA61C4C0873D391E987982FBBD3");
private ContactResource sh8013Contact; private Contact sh8013Contact;
private ContactResource mak21Contact; private Contact mak21Contact;
private ContactResource unusedContact; private Contact unusedContact;
@BeforeEach @BeforeEach
void beforeEach() { void beforeEach() {
@ -419,8 +419,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
void testSuccess_registrantMovedToTechContact() throws Exception { void testSuccess_registrantMovedToTechContact() throws Exception {
setEppInput("domain_update_registrant_to_tech.xml"); setEppInput("domain_update_registrant_to_tech.xml");
persistReferencedEntities(); persistReferencedEntities();
ContactResource sh8013 = Contact sh8013 = loadByForeignKey(Contact.class, "sh8013", clock.nowUtc()).get();
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc()).get();
persistResource( persistResource(
DatabaseHelper.newDomain(getUniqueIdFromCommand()) DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder() .asBuilder()
@ -434,9 +433,8 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
void testSuccess_multipleReferencesToSameContactRemoved() throws Exception { void testSuccess_multipleReferencesToSameContactRemoved() throws Exception {
setEppInput("domain_update_remove_multiple_contacts.xml"); setEppInput("domain_update_remove_multiple_contacts.xml");
persistReferencedEntities(); persistReferencedEntities();
ContactResource sh8013 = Contact sh8013 = loadByForeignKey(Contact.class, "sh8013", clock.nowUtc()).get();
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc()).get(); VKey<Contact> sh8013Key = sh8013.createVKey();
VKey<ContactResource> sh8013Key = sh8013.createVKey();
persistResource( persistResource(
DatabaseHelper.newDomain(getUniqueIdFromCommand()) DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder() .asBuilder()
@ -1111,9 +1109,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
.setContacts( .setContacts(
DesignatedContact.create( DesignatedContact.create(
Type.TECH, Type.TECH,
loadByForeignKey(ContactResource.class, "foo", clock.nowUtc()) loadByForeignKey(Contact.class, "foo", clock.nowUtc()).get().createVKey()))
.get()
.createVKey()))
.build()); .build());
EppException thrown = assertThrows(DuplicateContactForRoleException.class, this::runFlow); EppException thrown = assertThrows(DuplicateContactForRoleException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
@ -1436,9 +1432,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
.setContacts( .setContacts(
DesignatedContact.create( DesignatedContact.create(
Type.TECH, Type.TECH,
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc()) loadByForeignKey(Contact.class, "sh8013", clock.nowUtc()).get().createVKey()))
.get()
.createVKey()))
.build()); .build());
EppException thrown = assertThrows(AddRemoveSameValueException.class, this::runFlow); EppException thrown = assertThrows(AddRemoveSameValueException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
@ -1484,7 +1478,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
persistActiveHost("ns2.example.foo"); persistActiveHost("ns2.example.foo");
persistActiveContact("sh8013"); persistActiveContact("sh8013");
persistResource( persistResource(
loadByForeignKey(ContactResource.class, "mak21", clock.nowUtc()) loadByForeignKey(Contact.class, "mak21", clock.nowUtc())
.get() .get()
.asBuilder() .asBuilder()
.addStatusValue(StatusValue.PENDING_DELETE) .addStatusValue(StatusValue.PENDING_DELETE)

View file

@ -28,7 +28,7 @@ import google.registry.flows.poll.PollAckFlow.InvalidMessageIdException;
import google.registry.flows.poll.PollAckFlow.MessageDoesNotExistException; import google.registry.flows.poll.PollAckFlow.MessageDoesNotExistException;
import google.registry.flows.poll.PollAckFlow.MissingMessageIdException; import google.registry.flows.poll.PollAckFlow.MissingMessageIdException;
import google.registry.flows.poll.PollAckFlow.NotAuthorizedToAckMessageException; import google.registry.flows.poll.PollAckFlow.NotAuthorizedToAckMessageException;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.poll.PollMessage; import google.registry.model.poll.PollMessage;
import google.registry.testing.DatabaseHelper; import google.registry.testing.DatabaseHelper;
@ -43,7 +43,7 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
private static final long MESSAGE_ID = 3; private static final long MESSAGE_ID = 3;
private Domain domain; private Domain domain;
private ContactResource contact; private Contact contact;
@BeforeEach @BeforeEach
void setUp() { void setUp() {
@ -116,7 +116,7 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
} }
@Test @Test
void testSuccess_messageOnContactResource() throws Exception { void testSuccess_messageOnContact() throws Exception {
persistOneTimePollMessage(MESSAGE_ID); persistOneTimePollMessage(MESSAGE_ID);
assertTransactionalFlow(true); assertTransactionalFlow(true);
runFlowAssertResponse(loadFile("poll_ack_response_empty.xml")); runFlowAssertResponse(loadFile("poll_ack_response_empty.xml"));

View file

@ -27,8 +27,8 @@ import com.google.common.collect.ImmutableList;
import google.registry.flows.EppException; import google.registry.flows.EppException;
import google.registry.flows.FlowTestCase; import google.registry.flows.FlowTestCase;
import google.registry.flows.poll.PollRequestFlow.UnexpectedMessageIdException; import google.registry.flows.poll.PollRequestFlow.UnexpectedMessageIdException;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.Trid; import google.registry.model.eppcommon.Trid;
import google.registry.model.host.Host; import google.registry.model.host.Host;
@ -48,7 +48,7 @@ import org.junit.jupiter.api.Test;
class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> { class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
private Domain domain; private Domain domain;
private ContactResource contact; private Contact contact;
private Host host; private Host host;
@BeforeEach @BeforeEach

View file

@ -22,7 +22,7 @@ import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistResource;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.host.Host; import google.registry.model.host.Host;
import google.registry.testing.TestCacheExtension; import google.registry.testing.TestCacheExtension;
import java.time.Duration; import java.time.Duration;
@ -38,14 +38,14 @@ public class EppResourceTest extends EntityTestCase {
@Test @Test
void test_loadCached_ignoresContactChange() { void test_loadCached_ignoresContactChange() {
ContactResource originalContact = persistActiveContact("contact123"); Contact originalContact = persistActiveContact("contact123");
assertThat(EppResource.loadCached(ImmutableList.of(originalContact.createVKey()))) assertThat(EppResource.loadCached(ImmutableList.of(originalContact.createVKey())))
.containsExactly(originalContact.createVKey(), originalContact); .containsExactly(originalContact.createVKey(), originalContact);
ContactResource modifiedContact = Contact modifiedContact =
persistResource(originalContact.asBuilder().setEmailAddress("different@fake.lol").build()); persistResource(originalContact.asBuilder().setEmailAddress("different@fake.lol").build());
assertThat(EppResource.loadCached(ImmutableList.of(originalContact.createVKey()))) assertThat(EppResource.loadCached(ImmutableList.of(originalContact.createVKey())))
.containsExactly(originalContact.createVKey(), originalContact); .containsExactly(originalContact.createVKey(), originalContact);
assertThat(loadByForeignKey(ContactResource.class, "contact123", fakeClock.nowUtc())) assertThat(loadByForeignKey(Contact.class, "contact123", fakeClock.nowUtc()))
.hasValue(modifiedContact); .hasValue(modifiedContact);
} }

View file

@ -22,7 +22,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.base.Ascii; import com.google.common.base.Ascii;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DesignatedContact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainAuthInfo; import google.registry.model.domain.DomainAuthInfo;
@ -72,7 +72,7 @@ public final class TestSetupHelper {
public Registry registry; public Registry registry;
public Registrar registrar; public Registrar registrar;
public ContactResource contact; public Contact contact;
public Domain domain; public Domain domain;
public DomainHistory domainHistory; public DomainHistory domainHistory;
public Host host; public Host host;
@ -118,8 +118,8 @@ public final class TestSetupHelper {
} }
} }
static ContactResource createContact(String repoId, String registrarId) { static Contact createContact(String repoId, String registrarId) {
return new ContactResource.Builder() return new Contact.Builder()
.setRepoId(repoId) .setRepoId(repoId)
.setCreationRegistrarId(registrarId) .setCreationRegistrarId(registrarId)
.setTransferData(new ContactTransferData.Builder().build()) .setTransferData(new ContactTransferData.Builder().build())
@ -127,7 +127,7 @@ public final class TestSetupHelper {
.build(); .build();
} }
static Domain createSimpleDomain(ContactResource contact) { static Domain createSimpleDomain(Contact contact) {
return DatabaseHelper.newDomain(DOMAIN_NAME, DOMAIN_REPO_ID, contact) return DatabaseHelper.newDomain(DOMAIN_NAME, DOMAIN_REPO_ID, contact)
.asBuilder() .asBuilder()
.setCreationRegistrarId(REGISTRAR_ID) .setCreationRegistrarId(REGISTRAR_ID)
@ -135,7 +135,7 @@ public final class TestSetupHelper {
.build(); .build();
} }
static Domain createFullDomain(ContactResource contact, Host host, FakeClock fakeClock) { static Domain createFullDomain(Contact contact, Host host, FakeClock fakeClock) {
return createSimpleDomain(contact) return createSimpleDomain(contact)
.asBuilder() .asBuilder()
.setDomainName(DOMAIN_NAME) .setDomainName(DOMAIN_NAME)

View file

@ -17,7 +17,7 @@ package google.registry.model.common;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.token.AllocationToken; import google.registry.model.domain.token.AllocationToken;
@ -54,7 +54,7 @@ public class ClassPathManagerTest {
assertThat(ClassPathManager.getClass("RdeRevision")).isEqualTo(RdeRevision.class); assertThat(ClassPathManager.getClass("RdeRevision")).isEqualTo(RdeRevision.class);
assertThat(ClassPathManager.getClass("Host")).isEqualTo(Host.class); assertThat(ClassPathManager.getClass("Host")).isEqualTo(Host.class);
assertThat(ClassPathManager.getClass("Registrar")).isEqualTo(Registrar.class); assertThat(ClassPathManager.getClass("Registrar")).isEqualTo(Registrar.class);
assertThat(ClassPathManager.getClass("ContactResource")).isEqualTo(ContactResource.class); assertThat(ClassPathManager.getClass("Contact")).isEqualTo(Contact.class);
assertThat(ClassPathManager.getClass("GaeUserIdConverter")).isEqualTo(GaeUserIdConverter.class); assertThat(ClassPathManager.getClass("GaeUserIdConverter")).isEqualTo(GaeUserIdConverter.class);
assertThat(ClassPathManager.getClass("EppResourceIndexBucket")) assertThat(ClassPathManager.getClass("EppResourceIndexBucket"))
.isEqualTo(EppResourceIndexBucket.class); .isEqualTo(EppResourceIndexBucket.class);
@ -106,7 +106,7 @@ public class ClassPathManagerTest {
assertThat(ClassPathManager.getClassName(RdeRevision.class)).isEqualTo("RdeRevision"); assertThat(ClassPathManager.getClassName(RdeRevision.class)).isEqualTo("RdeRevision");
assertThat(ClassPathManager.getClassName(Host.class)).isEqualTo("Host"); assertThat(ClassPathManager.getClassName(Host.class)).isEqualTo("Host");
assertThat(ClassPathManager.getClassName(Registrar.class)).isEqualTo("Registrar"); assertThat(ClassPathManager.getClassName(Registrar.class)).isEqualTo("Registrar");
assertThat(ClassPathManager.getClassName(ContactResource.class)).isEqualTo("ContactResource"); assertThat(ClassPathManager.getClassName(Contact.class)).isEqualTo("Contact");
assertThat(ClassPathManager.getClassName(GaeUserIdConverter.class)) assertThat(ClassPathManager.getClassName(GaeUserIdConverter.class))
.isEqualTo("GaeUserIdConverter"); .isEqualTo("GaeUserIdConverter");
assertThat(ClassPathManager.getClassName(EppResourceIndexBucket.class)) assertThat(ClassPathManager.getClassName(EppResourceIndexBucket.class))

View file

@ -18,7 +18,7 @@ import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat; import static com.google.common.truth.Truth8.assertThat;
import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.model.EppResourceUtils.loadByForeignKey;
import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects; import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects;
import static google.registry.testing.ContactResourceSubject.assertAboutContacts; import static google.registry.testing.ContactSubject.assertAboutContacts;
import static google.registry.testing.DatabaseHelper.cloneAndSetAutoTimestamps; import static google.registry.testing.DatabaseHelper.cloneAndSetAutoTimestamps;
import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.insertInDb; import static google.registry.testing.DatabaseHelper.insertInDb;
@ -43,13 +43,13 @@ import google.registry.util.SerializeUtils;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** Unit tests for {@link ContactResource}. */ /** Unit tests for {@link Contact}. */
public class ContactResourceTest extends EntityTestCase { public class ContactTest extends EntityTestCase {
private ContactResource originalContact; private Contact originalContact;
private ContactResource contactResource; private Contact contact;
ContactResourceTest() { ContactTest() {
super(JpaEntityCoverageCheck.ENABLED); super(JpaEntityCoverageCheck.ENABLED);
} }
@ -57,7 +57,7 @@ public class ContactResourceTest extends EntityTestCase {
void setUp() { void setUp() {
createTld("foobar"); createTld("foobar");
originalContact = originalContact =
new ContactResource.Builder() new Contact.Builder()
.setContactId("contact_id") .setContactId("contact_id")
.setRepoId("1-FOOBAR") .setRepoId("1-FOOBAR")
.setCreationRegistrarId("TheRegistrar") .setCreationRegistrarId("TheRegistrar")
@ -118,15 +118,15 @@ public class ContactResourceTest extends EntityTestCase {
.setTransferRequestTrid(Trid.create("client-trid", "server-trid")) .setTransferRequestTrid(Trid.create("client-trid", "server-trid"))
.build()) .build())
.build(); .build();
// Set up a new persisted ContactResource entity. // Set up a new persisted Contact entity.
contactResource = persistResource(cloneAndSetAutoTimestamps(originalContact)); contact = persistResource(cloneAndSetAutoTimestamps(originalContact));
} }
@Test @Test
void testContactBaseToContactResource() { void testContactBaseToContact() {
assertAboutImmutableObjects() assertAboutImmutableObjects()
.that(new ContactResource.Builder().copyFrom(contactResource).build()) .that(new Contact.Builder().copyFrom(contact).build())
.isEqualExceptFields(contactResource, "updateTimestamp", "revisions"); .isEqualExceptFields(contact, "updateTimestamp", "revisions");
} }
@Test @Test
@ -143,8 +143,8 @@ public class ContactResourceTest extends EntityTestCase {
@Test @Test
void testCloudSqlPersistence_succeed() { void testCloudSqlPersistence_succeed() {
ContactResource persisted = loadByEntity(originalContact); Contact persisted = loadByEntity(originalContact);
ContactResource fixed = Contact fixed =
originalContact originalContact
.asBuilder() .asBuilder()
.setCreationTime(persisted.getCreationTime()) .setCreationTime(persisted.getCreationTime())
@ -160,28 +160,25 @@ public class ContactResourceTest extends EntityTestCase {
@Test @Test
void testPersistence() { void testPersistence() {
assertThat( assertThat(loadByForeignKey(Contact.class, contact.getForeignKey(), fakeClock.nowUtc()))
loadByForeignKey( .hasValue(contact);
ContactResource.class, contactResource.getForeignKey(), fakeClock.nowUtc()))
.hasValue(contactResource);
} }
@Test @Test
void testSerializable() { void testSerializable() {
ContactResource persisted = Contact persisted =
loadByForeignKey(ContactResource.class, contactResource.getForeignKey(), fakeClock.nowUtc()) loadByForeignKey(Contact.class, contact.getForeignKey(), fakeClock.nowUtc()).get();
.get();
assertThat(SerializeUtils.serializeDeserialize(persisted)).isEqualTo(persisted); assertThat(SerializeUtils.serializeDeserialize(persisted)).isEqualTo(persisted);
} }
@Test @Test
void testEmptyStringsBecomeNull() { void testEmptyStringsBecomeNull() {
assertThat(new ContactResource.Builder().setContactId(null).build().getContactId()).isNull(); assertThat(new Contact.Builder().setContactId(null).build().getContactId()).isNull();
assertThat(new ContactResource.Builder().setContactId("").build().getContactId()).isNull(); assertThat(new Contact.Builder().setContactId("").build().getContactId()).isNull();
assertThat(new ContactResource.Builder().setContactId(" ").build().getContactId()).isNotNull(); assertThat(new Contact.Builder().setContactId(" ").build().getContactId()).isNotNull();
// Nested ImmutableObjects should also be fixed // Nested ImmutableObjects should also be fixed
assertThat( assertThat(
new ContactResource.Builder() new Contact.Builder()
.setInternationalizedPostalInfo( .setInternationalizedPostalInfo(
new PostalInfo.Builder().setType(Type.INTERNATIONALIZED).setName(null).build()) new PostalInfo.Builder().setType(Type.INTERNATIONALIZED).setName(null).build())
.build() .build()
@ -189,7 +186,7 @@ public class ContactResourceTest extends EntityTestCase {
.getName()) .getName())
.isNull(); .isNull();
assertThat( assertThat(
new ContactResource.Builder() new Contact.Builder()
.setInternationalizedPostalInfo( .setInternationalizedPostalInfo(
new PostalInfo.Builder().setType(Type.INTERNATIONALIZED).setName("").build()) new PostalInfo.Builder().setType(Type.INTERNATIONALIZED).setName("").build())
.build() .build()
@ -197,7 +194,7 @@ public class ContactResourceTest extends EntityTestCase {
.getName()) .getName())
.isNull(); .isNull();
assertThat( assertThat(
new ContactResource.Builder() new Contact.Builder()
.setInternationalizedPostalInfo( .setInternationalizedPostalInfo(
new PostalInfo.Builder().setType(Type.INTERNATIONALIZED).setName(" ").build()) new PostalInfo.Builder().setType(Type.INTERNATIONALIZED).setName(" ").build())
.build() .build()
@ -208,9 +205,8 @@ public class ContactResourceTest extends EntityTestCase {
@Test @Test
void testEmptyTransferDataBecomesNull() { void testEmptyTransferDataBecomesNull() {
ContactResource withNull = new ContactResource.Builder().setTransferData(null).build(); Contact withNull = new Contact.Builder().setTransferData(null).build();
ContactResource withEmpty = Contact withEmpty = withNull.asBuilder().setTransferData(ContactTransferData.EMPTY).build();
withNull.asBuilder().setTransferData(ContactTransferData.EMPTY).build();
assertThat(withNull).isEqualTo(withEmpty); assertThat(withNull).isEqualTo(withEmpty);
assertThat(withEmpty.transferData).isNull(); assertThat(withEmpty.transferData).isNull();
} }
@ -219,19 +215,17 @@ public class ContactResourceTest extends EntityTestCase {
void testImplicitStatusValues() { void testImplicitStatusValues() {
// OK is implicit if there's no other statuses. // OK is implicit if there's no other statuses.
assertAboutContacts() assertAboutContacts()
.that(new ContactResource.Builder().build()) .that(new Contact.Builder().build())
.hasExactlyStatusValues(StatusValue.OK); .hasExactlyStatusValues(StatusValue.OK);
// If there are other status values, OK should be suppressed. // If there are other status values, OK should be suppressed.
assertAboutContacts() assertAboutContacts()
.that( .that(
new ContactResource.Builder() new Contact.Builder().setStatusValues(ImmutableSet.of(StatusValue.CLIENT_HOLD)).build())
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_HOLD))
.build())
.hasExactlyStatusValues(StatusValue.CLIENT_HOLD); .hasExactlyStatusValues(StatusValue.CLIENT_HOLD);
// When OK is suppressed, it should be removed even if it was originally there. // When OK is suppressed, it should be removed even if it was originally there.
assertAboutContacts() assertAboutContacts()
.that( .that(
new ContactResource.Builder() new Contact.Builder()
.setStatusValues(ImmutableSet.of(StatusValue.OK, StatusValue.CLIENT_HOLD)) .setStatusValues(ImmutableSet.of(StatusValue.OK, StatusValue.CLIENT_HOLD))
.build()) .build())
.hasExactlyStatusValues(StatusValue.CLIENT_HOLD); .hasExactlyStatusValues(StatusValue.CLIENT_HOLD);
@ -239,11 +233,11 @@ public class ContactResourceTest extends EntityTestCase {
@Test @Test
void testExpiredTransfer() { void testExpiredTransfer() {
ContactResource afterTransfer = Contact afterTransfer =
contactResource contact
.asBuilder() .asBuilder()
.setTransferData( .setTransferData(
contactResource contact
.getTransferData() .getTransferData()
.asBuilder() .asBuilder()
.setTransferStatus(TransferStatus.PENDING) .setTransferStatus(TransferStatus.PENDING)
@ -262,14 +256,13 @@ public class ContactResourceTest extends EntityTestCase {
void testSetCreationTime_cantBeCalledTwice() { void testSetCreationTime_cantBeCalledTwice() {
IllegalStateException thrown = IllegalStateException thrown =
assertThrows( assertThrows(
IllegalStateException.class, IllegalStateException.class, () -> contact.asBuilder().setCreationTime(END_OF_TIME));
() -> contactResource.asBuilder().setCreationTime(END_OF_TIME));
assertThat(thrown).hasMessageThat().contains("creationTime can only be set once"); assertThat(thrown).hasMessageThat().contains("creationTime can only be set once");
} }
@Test @Test
void testToHydratedString_notCircular() { void testToHydratedString_notCircular() {
// If there are circular references, this will overflow the stack. // If there are circular references, this will overflow the stack.
contactResource.toHydratedString(); contact.toHydratedString();
} }
} }

View file

@ -39,7 +39,7 @@ import com.googlecode.objectify.Key;
import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.DesignatedContact.Type; import google.registry.model.domain.DesignatedContact.Type;
import google.registry.model.domain.launch.LaunchNotice; import google.registry.model.domain.launch.LaunchNotice;
import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.domain.rgp.GracePeriodStatus;
@ -80,12 +80,12 @@ public class DomainSqlTest {
private Domain domain; private Domain domain;
private DomainHistory historyEntry; private DomainHistory historyEntry;
private VKey<ContactResource> contactKey; private VKey<Contact> contactKey;
private VKey<ContactResource> contact2Key; private VKey<Contact> contact2Key;
private VKey<Host> host1VKey; private VKey<Host> host1VKey;
private Host host; private Host host;
private ContactResource contact; private Contact contact;
private ContactResource contact2; private Contact contact2;
private ImmutableSet<GracePeriod> gracePeriods; private ImmutableSet<GracePeriod> gracePeriods;
private AllocationToken allocationToken; private AllocationToken allocationToken;
@ -94,8 +94,8 @@ public class DomainSqlTest {
saveRegistrar("registrar1"); saveRegistrar("registrar1");
saveRegistrar("registrar2"); saveRegistrar("registrar2");
saveRegistrar("registrar3"); saveRegistrar("registrar3");
contactKey = createKey(ContactResource.class, "contact_id1"); contactKey = createKey(Contact.class, "contact_id1");
contact2Key = createKey(ContactResource.class, "contact_id2"); contact2Key = createKey(Contact.class, "contact_id2");
host1VKey = createKey(Host.class, "host1"); host1VKey = createKey(Host.class, "host1");
@ -406,8 +406,8 @@ public class DomainSqlTest {
.isEqualExceptFields(domain, "updateTimestamp", "creationTime"); .isEqualExceptFields(domain, "updateTimestamp", "creationTime");
} }
static ContactResource makeContact(String repoId) { static Contact makeContact(String repoId) {
return new ContactResource.Builder() return new Contact.Builder()
.setRepoId(repoId) .setRepoId(repoId)
.setCreationRegistrarId("registrar1") .setCreationRegistrarId("registrar1")
.setTransferData(new ContactTransferData.Builder().build()) .setTransferData(new ContactTransferData.Builder().build())

View file

@ -46,7 +46,7 @@ import google.registry.model.ImmutableObjectSubject;
import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.DesignatedContact.Type; import google.registry.model.domain.DesignatedContact.Type;
import google.registry.model.domain.launch.LaunchNotice; import google.registry.model.domain.launch.LaunchNotice;
import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.domain.rgp.GracePeriodStatus;
@ -89,7 +89,7 @@ public class DomainTest {
private VKey<BillingEvent.OneTime> oneTimeBillKey; private VKey<BillingEvent.OneTime> oneTimeBillKey;
private VKey<BillingEvent.Recurring> recurringBillKey; private VKey<BillingEvent.Recurring> recurringBillKey;
private DomainHistory domainHistory; private DomainHistory domainHistory;
private VKey<ContactResource> contact1Key, contact2Key; private VKey<Contact> contact1Key, contact2Key;
@BeforeEach @BeforeEach
void setUp() { void setUp() {
@ -938,8 +938,8 @@ public class DomainTest {
@Test @Test
void testContactFields() { void testContactFields() {
VKey<ContactResource> contact3Key = persistActiveContact("contact_id3").createVKey(); VKey<Contact> contact3Key = persistActiveContact("contact_id3").createVKey();
VKey<ContactResource> contact4Key = persistActiveContact("contact_id4").createVKey(); VKey<Contact> contact4Key = persistActiveContact("contact_id4").createVKey();
// Set all of the contacts. // Set all of the contacts.
domain.setContactFields( domain.setContactFields(

View file

@ -20,7 +20,7 @@ import static google.registry.model.eppcommon.EppXmlTransformer.unmarshal;
import static google.registry.testing.TestDataHelper.loadBytes; import static google.registry.testing.TestDataHelper.loadBytes;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;
import google.registry.model.contact.ContactResourceTest; import google.registry.model.contact.ContactTest;
import google.registry.model.domain.DomainTest; import google.registry.model.domain.DomainTest;
import google.registry.model.eppinput.EppInput.InnerCommand; import google.registry.model.eppinput.EppInput.InnerCommand;
import google.registry.model.eppinput.EppInput.Login; import google.registry.model.eppinput.EppInput.Login;
@ -33,7 +33,7 @@ class EppInputTest {
@Test @Test
void testUnmarshalling_contactInfo() throws Exception { void testUnmarshalling_contactInfo() throws Exception {
EppInput input = EppInput input =
unmarshal(EppInput.class, loadBytes(ContactResourceTest.class, "contact_info.xml").read()); unmarshal(EppInput.class, loadBytes(ContactTest.class, "contact_info.xml").read());
assertThat(input.getCommandWrapper().getClTrid()).hasValue("ABC-12345"); assertThat(input.getCommandWrapper().getClTrid()).hasValue("ABC-12345");
assertThat(input.getCommandType()).isEqualTo("info"); assertThat(input.getCommandType()).isEqualTo("info");
assertThat(input.getResourceType()).hasValue("contact"); assertThat(input.getResourceType()).hasValue("contact");

View file

@ -19,16 +19,16 @@ import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableO
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm; import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
import static google.registry.testing.DatabaseHelper.insertInDb; import static google.registry.testing.DatabaseHelper.insertInDb;
import static google.registry.testing.DatabaseHelper.loadByEntity; import static google.registry.testing.DatabaseHelper.loadByEntity;
import static google.registry.testing.DatabaseHelper.newContactResourceWithRoid; import static google.registry.testing.DatabaseHelper.newContactWithRoid;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import google.registry.model.EntityTestCase; import google.registry.model.EntityTestCase;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactAddress; import google.registry.model.contact.ContactAddress;
import google.registry.model.contact.ContactBase; import google.registry.model.contact.ContactBase;
import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactPhoneNumber; import google.registry.model.contact.ContactPhoneNumber;
import google.registry.model.contact.ContactResource;
import google.registry.model.contact.PostalInfo; import google.registry.model.contact.PostalInfo;
import google.registry.model.eppcommon.Trid; import google.registry.model.eppcommon.Trid;
import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry;
@ -44,9 +44,9 @@ public class ContactHistoryTest extends EntityTestCase {
@Test @Test
void testPersistence() { void testPersistence() {
ContactResource contact = newContactResourceWithRoid("contactId", "contact1"); Contact contact = newContactWithRoid("contactId", "contact1");
insertInDb(contact); insertInDb(contact);
ContactResource contactFromDb = loadByEntity(contact); Contact contactFromDb = loadByEntity(contact);
ContactHistory contactHistory = createContactHistory(contactFromDb); ContactHistory contactHistory = createContactHistory(contactFromDb);
insertInDb(contactHistory); insertInDb(contactHistory);
jpaTm() jpaTm()
@ -60,9 +60,9 @@ public class ContactHistoryTest extends EntityTestCase {
@Test @Test
void testSerializable() { void testSerializable() {
ContactResource contact = newContactResourceWithRoid("contactId", "contact1"); Contact contact = newContactWithRoid("contactId", "contact1");
insertInDb(contact); insertInDb(contact);
ContactResource contactFromDb = loadByEntity(contact); Contact contactFromDb = loadByEntity(contact);
ContactHistory contactHistory = createContactHistory(contactFromDb); ContactHistory contactHistory = createContactHistory(contactFromDb);
insertInDb(contactHistory); insertInDb(contactHistory);
ContactHistory fromDatabase = ContactHistory fromDatabase =
@ -72,9 +72,9 @@ public class ContactHistoryTest extends EntityTestCase {
@Test @Test
void testLegacyPersistence_nullContactBase() { void testLegacyPersistence_nullContactBase() {
ContactResource contact = newContactResourceWithRoid("contactId", "contact1"); Contact contact = newContactWithRoid("contactId", "contact1");
insertInDb(contact); insertInDb(contact);
ContactResource contactFromDb = loadByEntity(contact); Contact contactFromDb = loadByEntity(contact);
ContactHistory contactHistory = ContactHistory contactHistory =
createContactHistory(contactFromDb).asBuilder().setContact(null).build(); createContactHistory(contactFromDb).asBuilder().setContact(null).build();
insertInDb(contactHistory); insertInDb(contactHistory);
@ -92,7 +92,7 @@ public class ContactHistoryTest extends EntityTestCase {
void testWipeOutPii_assertsAllPiiFieldsAreNull() { void testWipeOutPii_assertsAllPiiFieldsAreNull() {
ContactHistory originalEntity = ContactHistory originalEntity =
createContactHistory( createContactHistory(
new ContactResource.Builder() new Contact.Builder()
.setRepoId("1-FOOBAR") .setRepoId("1-FOOBAR")
.setLocalizedPostalInfo( .setLocalizedPostalInfo(
new PostalInfo.Builder() new PostalInfo.Builder()

View file

@ -19,7 +19,7 @@ import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableO
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm; import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.insertInDb; import static google.registry.testing.DatabaseHelper.insertInDb;
import static google.registry.testing.DatabaseHelper.newContactResourceWithRoid; import static google.registry.testing.DatabaseHelper.newContactWithRoid;
import static google.registry.testing.DatabaseHelper.newDomain; import static google.registry.testing.DatabaseHelper.newDomain;
import static google.registry.testing.DatabaseHelper.newHostWithRoid; import static google.registry.testing.DatabaseHelper.newHostWithRoid;
import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.DateTimeUtils.END_OF_TIME;
@ -27,7 +27,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import google.registry.model.EntityTestCase; import google.registry.model.EntityTestCase;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
@ -103,7 +103,7 @@ public class DomainHistoryTest extends EntityTestCase {
static Domain createDomainWithContactsAndHosts() { static Domain createDomainWithContactsAndHosts() {
createTld("tld"); createTld("tld");
Host host = newHostWithRoid("ns1.example.com", "host1"); Host host = newHostWithRoid("ns1.example.com", "host1");
ContactResource contact = newContactResourceWithRoid("contactId", "contact1"); Contact contact = newContactWithRoid("contactId", "contact1");
jpaTm() jpaTm()
.transact( .transact(

View file

@ -16,7 +16,7 @@ package google.registry.model.ofy;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.ofy.ObjectifyService.initOfy; import static google.registry.model.ofy.ObjectifyService.initOfy;
import static google.registry.testing.DatabaseHelper.newContactResource; import static google.registry.testing.DatabaseHelper.newContact;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig; import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
@ -27,7 +27,7 @@ import com.googlecode.objectify.ObjectifyFilter;
import com.googlecode.objectify.ObjectifyService; import com.googlecode.objectify.ObjectifyService;
import com.googlecode.objectify.annotation.Entity; import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id; import com.googlecode.objectify.annotation.Id;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -81,7 +81,7 @@ class OfyFilterTest {
@Test @Test
void testKeyCreateAfterFilter() { void testKeyCreateAfterFilter() {
new OfyFilter().init(null); new OfyFilter().init(null);
ContactResource contact = newContactResource("contact1234"); Contact contact = newContact("contact1234");
Key.create(contact); Key.create(contact);
} }

View file

@ -22,7 +22,7 @@ import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
import static google.registry.model.ofy.ObjectifyService.auditedOfy; import static google.registry.model.ofy.ObjectifyService.auditedOfy;
import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.ofy.Ofy.getBaseEntityClassFromEntityOrKey; import static google.registry.model.ofy.Ofy.getBaseEntityClassFromEntityOrKey;
import static google.registry.testing.DatabaseHelper.newContactResource; import static google.registry.testing.DatabaseHelper.newContact;
import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_OF_TIME; import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
@ -39,8 +39,8 @@ import com.googlecode.objectify.annotation.OnLoad;
import com.googlecode.objectify.annotation.OnSave; import com.googlecode.objectify.annotation.OnSave;
import com.googlecode.objectify.annotation.Parent; import com.googlecode.objectify.annotation.Parent;
import google.registry.model.ImmutableObject; import google.registry.model.ImmutableObject;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactResource;
import google.registry.model.eppcommon.Trid; import google.registry.model.eppcommon.Trid;
import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry;
import google.registry.testing.AppEngineExtension; import google.registry.testing.AppEngineExtension;
@ -74,7 +74,7 @@ public class OfyTest {
.setRegistrarId("clientid") .setRegistrarId("clientid")
.setModificationTime(START_OF_TIME) .setModificationTime(START_OF_TIME)
.setType(HistoryEntry.Type.CONTACT_CREATE) .setType(HistoryEntry.Type.CONTACT_CREATE)
.setContact(newContactResource("parentContact")) .setContact(newContact("parentContact"))
.setTrid(Trid.create("client", "server")) .setTrid(Trid.create("client", "server"))
.setXmlBytes("<xml></xml>".getBytes(UTF_8)) .setXmlBytes("<xml></xml>".getBytes(UTF_8))
.build(); .build();
@ -294,10 +294,9 @@ public class OfyTest {
@Test @Test
void test_getBaseEntityClassFromEntityOrKey_regularEntity() { void test_getBaseEntityClassFromEntityOrKey_regularEntity() {
ContactResource contact = newContactResource("testcontact"); Contact contact = newContact("testcontact");
assertThat(getBaseEntityClassFromEntityOrKey(contact)).isEqualTo(ContactResource.class); assertThat(getBaseEntityClassFromEntityOrKey(contact)).isEqualTo(Contact.class);
assertThat(getBaseEntityClassFromEntityOrKey(Key.create(contact))) assertThat(getBaseEntityClassFromEntityOrKey(Key.create(contact))).isEqualTo(Contact.class);
.isEqualTo(ContactResource.class);
} }
@Test @Test

View file

@ -25,7 +25,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import google.registry.model.EntityTestCase; import google.registry.model.EntityTestCase;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.Period; import google.registry.model.domain.Period;
@ -53,7 +53,7 @@ public class PollMessageTest extends EntityTestCase {
@BeforeEach @BeforeEach
void setUp() { void setUp() {
createTld("foobar"); createTld("foobar");
ContactResource contact = persistActiveContact("contact1234"); Contact contact = persistActiveContact("contact1234");
domain = persistResource(DatabaseHelper.newDomain("foo.foobar", contact)); domain = persistResource(DatabaseHelper.newDomain("foo.foobar", contact));
historyEntry = historyEntry =
persistResource( persistResource(

View file

@ -24,7 +24,7 @@ import static google.registry.testing.DatabaseHelper.persistResource;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import google.registry.model.EntityTestCase; import google.registry.model.EntityTestCase;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.reporting.Spec11ThreatMatch.ThreatType; import google.registry.model.reporting.Spec11ThreatMatch.ThreatType;
import google.registry.testing.DatabaseHelper; import google.registry.testing.DatabaseHelper;
@ -46,7 +46,7 @@ class Spec11ThreatMatchDaoTest extends EntityTestCase {
@BeforeEach @BeforeEach
void setUp() { void setUp() {
createTlds("com", "org"); createTlds("com", "org");
ContactResource contact = persistActiveContact("jd1234"); Contact contact = persistActiveContact("jd1234");
todayComDomain = persistResource(DatabaseHelper.newDomain("today.com", contact)); todayComDomain = persistResource(DatabaseHelper.newDomain("today.com", contact));
todayOrgDomain = persistResource(DatabaseHelper.newDomain("today.org", contact)); todayOrgDomain = persistResource(DatabaseHelper.newDomain("today.org", contact));
yesterdayComDomain = persistResource(DatabaseHelper.newDomain("yesterday.com", contact)); yesterdayComDomain = persistResource(DatabaseHelper.newDomain("yesterday.com", contact));

View file

@ -26,7 +26,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import google.registry.model.EntityTestCase; import google.registry.model.EntityTestCase;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.host.Host; import google.registry.model.host.Host;
import google.registry.model.transfer.ContactTransferData; import google.registry.model.transfer.ContactTransferData;
@ -46,7 +46,7 @@ public final class Spec11ThreatMatchTest extends EntityTestCase {
private Spec11ThreatMatch threat; private Spec11ThreatMatch threat;
private Domain domain; private Domain domain;
private Host host; private Host host;
private ContactResource registrantContact; private Contact registrantContact;
Spec11ThreatMatchTest() { Spec11ThreatMatchTest() {
super(JpaEntityCoverageCheck.ENABLED); super(JpaEntityCoverageCheck.ENABLED);
@ -55,8 +55,7 @@ public final class Spec11ThreatMatchTest extends EntityTestCase {
@BeforeEach @BeforeEach
void setUp() { void setUp() {
VKey<Host> hostVKey = VKey.createSql(Host.class, "host"); VKey<Host> hostVKey = VKey.createSql(Host.class, "host");
VKey<ContactResource> registrantContactVKey = VKey<Contact> registrantContactVKey = VKey.createSql(Contact.class, "contact_id");
VKey.createSql(ContactResource.class, "contact_id");
String domainRepoId = "4-TLD"; String domainRepoId = "4-TLD";
createTld("tld"); createTld("tld");
@ -75,7 +74,7 @@ public final class Spec11ThreatMatchTest extends EntityTestCase {
// Create a contact for the purpose of testing a foreign key reference in the Domain table. // Create a contact for the purpose of testing a foreign key reference in the Domain table.
registrantContact = registrantContact =
new ContactResource.Builder() new Contact.Builder()
.setRepoId("contact_id") .setRepoId("contact_id")
.setCreationRegistrarId(REGISTRAR_ID) .setCreationRegistrarId(REGISTRAR_ID)
.setTransferData(new ContactTransferData.Builder().build()) .setTransferData(new ContactTransferData.Builder().build())

View file

@ -19,16 +19,15 @@ import static google.registry.rdap.RdapTestHelper.assertThat;
import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DatabaseHelper.persistSimpleResources; import static google.registry.testing.DatabaseHelper.persistSimpleResources;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistContactResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHost; import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHost;
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain; import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry; import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarPocs;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.Period; import google.registry.model.domain.Period;
import google.registry.model.host.Host; import google.registry.model.host.Host;
@ -40,6 +39,7 @@ import google.registry.rdap.RdapMetrics.SearchType;
import google.registry.rdap.RdapMetrics.WildcardType; import google.registry.rdap.RdapMetrics.WildcardType;
import google.registry.rdap.RdapSearchResults.IncompletenessWarningType; import google.registry.rdap.RdapSearchResults.IncompletenessWarningType;
import google.registry.request.Action; import google.registry.request.Action;
import google.registry.testing.FullFieldsTestEntityHelper;
import java.util.Optional; import java.util.Optional;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
@ -63,28 +63,24 @@ class RdapDomainActionTest extends RdapActionBaseTestCase<RdapDomainAction> {
createTld("lol"); createTld("lol");
Registrar registrarLol = persistResource(makeRegistrar( Registrar registrarLol = persistResource(makeRegistrar(
"evilregistrar", "Yes Virginia <script>", Registrar.State.ACTIVE)); "evilregistrar", "Yes Virginia <script>", Registrar.State.ACTIVE));
persistSimpleResources(makeRegistrarContacts(registrarLol)); persistSimpleResources(makeRegistrarPocs(registrarLol));
ContactResource registrantLol = Contact registrantLol =
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"5372808-ERL", "5372808-ERL",
"Goblin Market", "Goblin Market",
"lol@cat.lol", "lol@cat.lol",
clock.nowUtc().minusYears(1), clock.nowUtc().minusYears(1),
registrarLol); registrarLol);
ContactResource adminContactLol = Contact adminContactLol =
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"5372808-IRL", "5372808-IRL",
"Santa Claus", "Santa Claus",
"BOFH@cat.lol", "BOFH@cat.lol",
clock.nowUtc().minusYears(2), clock.nowUtc().minusYears(2),
registrarLol); registrarLol);
ContactResource techContactLol = Contact techContactLol =
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"5372808-TRL", "5372808-TRL", "The Raven", "bog@cat.lol", clock.nowUtc().minusYears(3), registrarLol);
"The Raven",
"bog@cat.lol",
clock.nowUtc().minusYears(3),
registrarLol);
Host host1 = makeAndPersistHost("ns1.cat.lol", "1.2.3.4", null, clock.nowUtc().minusYears(1)); Host host1 = makeAndPersistHost("ns1.cat.lol", "1.2.3.4", null, clock.nowUtc().minusYears(1));
Host host2 = Host host2 =
makeAndPersistHost( makeAndPersistHost(
@ -111,19 +107,19 @@ class RdapDomainActionTest extends RdapActionBaseTestCase<RdapDomainAction> {
persistResource( persistResource(
makeDomain( makeDomain(
"dodo.lol", "dodo.lol",
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"5372808-ERL", "5372808-ERL",
"Goblin Market", "Goblin Market",
"lol@cat.lol", "lol@cat.lol",
clock.nowUtc().minusYears(1), clock.nowUtc().minusYears(1),
registrarLol), registrarLol),
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"5372808-IRL", "5372808-IRL",
"Santa Claus", "Santa Claus",
"BOFH@cat.lol", "BOFH@cat.lol",
clock.nowUtc().minusYears(2), clock.nowUtc().minusYears(2),
registrarLol), registrarLol),
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"5372808-TRL", "5372808-TRL",
"The Raven", "The Raven",
"bog@cat.lol", "bog@cat.lol",
@ -141,28 +137,24 @@ class RdapDomainActionTest extends RdapActionBaseTestCase<RdapDomainAction> {
createTld("xn--q9jyb4c"); createTld("xn--q9jyb4c");
Registrar registrarIdn = Registrar registrarIdn =
persistResource(makeRegistrar("idnregistrar", "IDN Registrar", Registrar.State.ACTIVE)); persistResource(makeRegistrar("idnregistrar", "IDN Registrar", Registrar.State.ACTIVE));
persistSimpleResources(makeRegistrarContacts(registrarIdn)); persistSimpleResources(makeRegistrarPocs(registrarIdn));
ContactResource registrantIdn = Contact registrantIdn =
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"5372808-ERL", "5372808-ERL",
"Goblin Market", "Goblin Market",
"lol@cat.lol", "lol@cat.lol",
clock.nowUtc().minusYears(1), clock.nowUtc().minusYears(1),
registrarIdn); registrarIdn);
ContactResource adminContactIdn = Contact adminContactIdn =
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"5372808-IRL", "5372808-IRL",
"Santa Claus", "Santa Claus",
"BOFH@cat.lol", "BOFH@cat.lol",
clock.nowUtc().minusYears(2), clock.nowUtc().minusYears(2),
registrarIdn); registrarIdn);
ContactResource techContactIdn = Contact techContactIdn =
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"5372808-TRL", "5372808-TRL", "The Raven", "bog@cat.lol", clock.nowUtc().minusYears(3), registrarIdn);
"The Raven",
"bog@cat.lol",
clock.nowUtc().minusYears(3),
registrarIdn);
persistResource( persistResource(
makeDomain( makeDomain(
"cat.みんな", "cat.みんな",
@ -181,28 +173,24 @@ class RdapDomainActionTest extends RdapActionBaseTestCase<RdapDomainAction> {
createTld("1.tld"); createTld("1.tld");
Registrar registrar1Tld = persistResource( Registrar registrar1Tld = persistResource(
makeRegistrar("1tldregistrar", "Multilevel Registrar", Registrar.State.ACTIVE)); makeRegistrar("1tldregistrar", "Multilevel Registrar", Registrar.State.ACTIVE));
persistSimpleResources(makeRegistrarContacts(registrar1Tld)); persistSimpleResources(makeRegistrarPocs(registrar1Tld));
ContactResource registrant1Tld = Contact registrant1Tld =
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"5372808-ERL", "5372808-ERL",
"Goblin Market", "Goblin Market",
"lol@cat.lol", "lol@cat.lol",
clock.nowUtc().minusYears(1), clock.nowUtc().minusYears(1),
registrar1Tld); registrar1Tld);
ContactResource adminContact1Tld = Contact adminContact1Tld =
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"5372808-IRL", "5372808-IRL",
"Santa Claus", "Santa Claus",
"BOFH@cat.lol", "BOFH@cat.lol",
clock.nowUtc().minusYears(2), clock.nowUtc().minusYears(2),
registrar1Tld); registrar1Tld);
ContactResource techContact1Tld = Contact techContact1Tld =
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"5372808-TRL", "5372808-TRL", "The Raven", "bog@cat.lol", clock.nowUtc().minusYears(3), registrar1Tld);
"The Raven",
"bog@cat.lol",
clock.nowUtc().minusYears(3),
registrar1Tld);
persistResource( persistResource(
makeDomain( makeDomain(
"cat.1.tld", "cat.1.tld",

View file

@ -23,11 +23,10 @@ import static google.registry.testing.DatabaseHelper.persistDomainAsDeleted;
import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DatabaseHelper.persistResources; import static google.registry.testing.DatabaseHelper.persistResources;
import static google.registry.testing.DatabaseHelper.persistSimpleResources; import static google.registry.testing.DatabaseHelper.persistSimpleResources;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistContactResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain; import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry; import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarPocs;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
@ -36,7 +35,7 @@ import com.google.common.collect.Range;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.domain.Period; import google.registry.model.domain.Period;
import google.registry.model.host.Host; import google.registry.model.host.Host;
@ -70,9 +69,9 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
private Domain domainCatExample; private Domain domainCatExample;
private Domain domainIdn; private Domain domainIdn;
private Domain domainMultipart; private Domain domainMultipart;
private ContactResource contact1; private Contact contact1;
private ContactResource contact2; private Contact contact2;
private ContactResource contact3; private Contact contact3;
private Host hostNs1CatLol; private Host hostNs1CatLol;
private Host hostNs2CatLol; private Host hostNs2CatLol;
private HashMap<String, Host> hostNameToHostMap = new HashMap<>(); private HashMap<String, Host> hostNameToHostMap = new HashMap<>();
@ -134,15 +133,15 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
registrar = registrar =
persistResource( persistResource(
makeRegistrar("evilregistrar", "Yes Virginia <script>", Registrar.State.ACTIVE)); makeRegistrar("evilregistrar", "Yes Virginia <script>", Registrar.State.ACTIVE));
persistSimpleResources(makeRegistrarContacts(registrar)); persistSimpleResources(makeRegistrarPocs(registrar));
contact1 = contact1 =
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"5372808-ERL", "Goblin Market", "lol@cat.lol", clock.nowUtc().minusYears(1), registrar); "5372808-ERL", "Goblin Market", "lol@cat.lol", clock.nowUtc().minusYears(1), registrar);
contact2 = contact2 =
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"5372808-IRL", "Santa Claus", "BOFH@cat.lol", clock.nowUtc().minusYears(2), registrar); "5372808-IRL", "Santa Claus", "BOFH@cat.lol", clock.nowUtc().minusYears(2), registrar);
contact3 = contact3 =
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"5372808-TRL", "The Raven", "bog@cat.lol", clock.nowUtc().minusYears(3), registrar); "5372808-TRL", "The Raven", "bog@cat.lol", clock.nowUtc().minusYears(3), registrar);
hostNs1CatLol = hostNs1CatLol =
addHostToMap( addHostToMap(
@ -176,19 +175,19 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
persistResource( persistResource(
makeDomain( makeDomain(
"cat2.lol", "cat2.lol",
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"6372808-ERL", "6372808-ERL",
"Siegmund", "Siegmund",
"siegmund@cat2.lol", "siegmund@cat2.lol",
clock.nowUtc().minusYears(1), clock.nowUtc().minusYears(1),
registrar), registrar),
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"6372808-IRL", "6372808-IRL",
"Sieglinde", "Sieglinde",
"sieglinde@cat2.lol", "sieglinde@cat2.lol",
clock.nowUtc().minusYears(2), clock.nowUtc().minusYears(2),
registrar), registrar),
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"6372808-TRL", "6372808-TRL",
"Siegfried", "Siegfried",
"siegfried@cat2.lol", "siegfried@cat2.lol",
@ -212,24 +211,24 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
registrar = registrar =
persistResource( persistResource(
makeRegistrar("goodregistrar", "St. John Chrysostom", Registrar.State.ACTIVE)); makeRegistrar("goodregistrar", "St. John Chrysostom", Registrar.State.ACTIVE));
persistSimpleResources(makeRegistrarContacts(registrar)); persistSimpleResources(makeRegistrarPocs(registrar));
domainCatExample = domainCatExample =
persistResource( persistResource(
makeDomain( makeDomain(
"cat.example", "cat.example",
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"7372808-ERL", "7372808-ERL",
"Matthew", "Matthew",
"lol@cat.lol", "lol@cat.lol",
clock.nowUtc().minusYears(1), clock.nowUtc().minusYears(1),
registrar), registrar),
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"7372808-IRL", "7372808-IRL",
"Mark", "Mark",
"BOFH@cat.lol", "BOFH@cat.lol",
clock.nowUtc().minusYears(2), clock.nowUtc().minusYears(2),
registrar), registrar),
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"7372808-TRL", "7372808-TRL",
"Luke", "Luke",
"bog@cat.lol", "bog@cat.lol",
@ -249,24 +248,24 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
// cat.みんな // cat.みんな
createTld("xn--q9jyb4c"); createTld("xn--q9jyb4c");
registrar = persistResource(makeRegistrar("unicoderegistrar", "みんな", Registrar.State.ACTIVE)); registrar = persistResource(makeRegistrar("unicoderegistrar", "みんな", Registrar.State.ACTIVE));
persistSimpleResources(makeRegistrarContacts(registrar)); persistSimpleResources(makeRegistrarPocs(registrar));
domainIdn = domainIdn =
persistResource( persistResource(
makeDomain( makeDomain(
"cat.みんな", "cat.みんな",
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"8372808-ERL", "8372808-ERL",
"(◕‿◕)", "(◕‿◕)",
"lol@cat.みんな", "lol@cat.みんな",
clock.nowUtc().minusYears(1), clock.nowUtc().minusYears(1),
registrar), registrar),
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"8372808-IRL", "8372808-IRL",
"Santa Claus", "Santa Claus",
"BOFH@cat.みんな", "BOFH@cat.みんな",
clock.nowUtc().minusYears(2), clock.nowUtc().minusYears(2),
registrar), registrar),
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"8372808-TRL", "8372808-TRL",
"The Raven", "The Raven",
"bog@cat.みんな", "bog@cat.みんな",
@ -288,24 +287,24 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
// cat.1.test // cat.1.test
createTld("1.test"); createTld("1.test");
registrar = persistResource(makeRegistrar("multiregistrar", "1.test", Registrar.State.ACTIVE)); registrar = persistResource(makeRegistrar("multiregistrar", "1.test", Registrar.State.ACTIVE));
persistSimpleResources(makeRegistrarContacts(registrar)); persistSimpleResources(makeRegistrarPocs(registrar));
domainMultipart = domainMultipart =
persistResource( persistResource(
makeDomain( makeDomain(
"cat.1.test", "cat.1.test",
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"9372808-ERL", "9372808-ERL",
"(◕‿◕)", "(◕‿◕)",
"lol@cat.みんな", "lol@cat.みんな",
clock.nowUtc().minusYears(1), clock.nowUtc().minusYears(1),
registrar), registrar),
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"9372808-IRL", "9372808-IRL",
"Santa Claus", "Santa Claus",
"BOFH@cat.みんな", "BOFH@cat.みんな",
clock.nowUtc().minusYears(2), clock.nowUtc().minusYears(2),
registrar), registrar),
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"9372808-TRL", "9372808-TRL",
"The Raven", "The Raven",
"bog@cat.みんな", "bog@cat.みんな",

View file

@ -20,17 +20,16 @@ import static google.registry.rdap.RdapTestHelper.loadJsonFile;
import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DatabaseHelper.persistSimpleResources; import static google.registry.testing.DatabaseHelper.persistSimpleResources;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistContactResource; import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistDeletedContact;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistDeletedContactResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain; import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
import static google.registry.testing.FullFieldsTestEntityHelper.makeHost; import static google.registry.testing.FullFieldsTestEntityHelper.makeHost;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarPocs;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.host.Host; import google.registry.model.host.Host;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
import google.registry.rdap.RdapMetrics.EndpointType; import google.registry.rdap.RdapMetrics.EndpointType;
@ -38,6 +37,7 @@ import google.registry.rdap.RdapMetrics.SearchType;
import google.registry.rdap.RdapMetrics.WildcardType; import google.registry.rdap.RdapMetrics.WildcardType;
import google.registry.rdap.RdapSearchResults.IncompletenessWarningType; import google.registry.rdap.RdapSearchResults.IncompletenessWarningType;
import google.registry.request.Action; import google.registry.request.Action;
import google.registry.testing.FullFieldsTestEntityHelper;
import java.util.Optional; import java.util.Optional;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
@ -51,11 +51,11 @@ class RdapEntityActionTest extends RdapActionBaseTestCase<RdapEntityAction> {
} }
private Registrar registrarLol; private Registrar registrarLol;
private ContactResource registrant; private Contact registrant;
private ContactResource adminContact; private Contact adminContact;
private ContactResource techContact; private Contact techContact;
private ContactResource disconnectedContact; private Contact disconnectedContact;
private ContactResource deletedContact; private Contact deletedContact;
@BeforeEach @BeforeEach
void beforeEach() { void beforeEach() {
@ -63,22 +63,25 @@ class RdapEntityActionTest extends RdapActionBaseTestCase<RdapEntityAction> {
createTld("lol"); createTld("lol");
registrarLol = persistResource(makeRegistrar( registrarLol = persistResource(makeRegistrar(
"evilregistrar", "Yes Virginia <script>", Registrar.State.ACTIVE, 101L)); "evilregistrar", "Yes Virginia <script>", Registrar.State.ACTIVE, 101L));
persistSimpleResources(makeRegistrarContacts(registrarLol)); persistSimpleResources(makeRegistrarPocs(registrarLol));
registrant = makeAndPersistContactResource( registrant =
FullFieldsTestEntityHelper.makeAndPersistContact(
"8372808-REG", "8372808-REG",
"(◕‿◕)", "(◕‿◕)",
"lol@cat.みんな", "lol@cat.みんな",
ImmutableList.of("1 Smiley Row", "Suite みんな"), ImmutableList.of("1 Smiley Row", "Suite みんな"),
clock.nowUtc(), clock.nowUtc(),
registrarLol); registrarLol);
adminContact = makeAndPersistContactResource( adminContact =
FullFieldsTestEntityHelper.makeAndPersistContact(
"8372808-ADM", "8372808-ADM",
"(◕‿◕)", "(◕‿◕)",
"lol@cat.みんな", "lol@cat.みんな",
ImmutableList.of("1 Smiley Row", "Suite みんな"), ImmutableList.of("1 Smiley Row", "Suite みんな"),
clock.nowUtc(), clock.nowUtc(),
registrarLol); registrarLol);
techContact = makeAndPersistContactResource( techContact =
FullFieldsTestEntityHelper.makeAndPersistContact(
"8372808-TEC", "8372808-TEC",
"(◕‿◕)", "(◕‿◕)",
"lol@cat.みんな", "lol@cat.みんな",
@ -93,19 +96,19 @@ class RdapEntityActionTest extends RdapActionBaseTestCase<RdapEntityAction> {
createTld("xn--q9jyb4c"); createTld("xn--q9jyb4c");
Registrar registrarIdn = persistResource( Registrar registrarIdn = persistResource(
makeRegistrar("idnregistrar", "IDN Registrar", Registrar.State.ACTIVE, 102L)); makeRegistrar("idnregistrar", "IDN Registrar", Registrar.State.ACTIVE, 102L));
persistSimpleResources(makeRegistrarContacts(registrarIdn)); persistSimpleResources(makeRegistrarPocs(registrarIdn));
// 1.tld // 1.tld
createTld("1.tld"); createTld("1.tld");
Registrar registrar1tld = persistResource( Registrar registrar1tld = persistResource(
makeRegistrar("1tldregistrar", "Multilevel Registrar", Registrar.State.ACTIVE, 103L)); makeRegistrar("1tldregistrar", "Multilevel Registrar", Registrar.State.ACTIVE, 103L));
persistSimpleResources(makeRegistrarContacts(registrar1tld)); persistSimpleResources(makeRegistrarPocs(registrar1tld));
// deleted registrar // deleted registrar
Registrar registrarDeleted = persistResource( Registrar registrarDeleted = persistResource(
makeRegistrar("deletedregistrar", "Yes Virginia <script>", Registrar.State.PENDING, 104L)); makeRegistrar("deletedregistrar", "Yes Virginia <script>", Registrar.State.PENDING, 104L));
persistSimpleResources(makeRegistrarContacts(registrarDeleted)); persistSimpleResources(makeRegistrarPocs(registrarDeleted));
// other contacts // other contacts
disconnectedContact = disconnectedContact =
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"8372808-DIS", "8372808-DIS",
"(◕‿◕)", "(◕‿◕)",
"lol@cat.みんな", "lol@cat.みんな",
@ -113,7 +116,7 @@ class RdapEntityActionTest extends RdapActionBaseTestCase<RdapEntityAction> {
clock.nowUtc(), clock.nowUtc(),
registrarLol); registrarLol);
deletedContact = deletedContact =
makeAndPersistDeletedContactResource( makeAndPersistDeletedContact(
"8372808-DEL", "8372808-DEL",
clock.nowUtc().minusYears(1), clock.nowUtc().minusYears(1),
registrarLol, registrarLol,

View file

@ -23,12 +23,10 @@ import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DatabaseHelper.persistResources; import static google.registry.testing.DatabaseHelper.persistResources;
import static google.registry.testing.DatabaseHelper.persistSimpleResources; import static google.registry.testing.DatabaseHelper.persistSimpleResources;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistContactResource; import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistDeletedContact;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistDeletedContactResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeContactResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry; import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarPocs;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
@ -37,13 +35,14 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import google.registry.model.ImmutableObject; import google.registry.model.ImmutableObject;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry;
import google.registry.rdap.RdapMetrics.EndpointType; import google.registry.rdap.RdapMetrics.EndpointType;
import google.registry.rdap.RdapMetrics.SearchType; import google.registry.rdap.RdapMetrics.SearchType;
import google.registry.rdap.RdapSearchResults.IncompletenessWarningType; import google.registry.rdap.RdapSearchResults.IncompletenessWarningType;
import google.registry.testing.FakeResponse; import google.registry.testing.FakeResponse;
import google.registry.testing.FullFieldsTestEntityHelper;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.util.Optional; import java.util.Optional;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -110,12 +109,12 @@ class RdapEntitySearchActionTest extends RdapSearchActionTestCase<RdapEntitySear
registrarDeleted = registrarDeleted =
persistResource( persistResource(
makeRegistrar("2-Registrar", "Yes Virginia <script>", Registrar.State.ACTIVE, 20L)); makeRegistrar("2-Registrar", "Yes Virginia <script>", Registrar.State.ACTIVE, 20L));
persistSimpleResources(makeRegistrarContacts(registrarDeleted)); persistSimpleResources(makeRegistrarPocs(registrarDeleted));
// inactive // inactive
registrarInactive = registrarInactive =
persistResource(makeRegistrar("2-RegistrarInact", "No Way", Registrar.State.PENDING, 21L)); persistResource(makeRegistrar("2-RegistrarInact", "No Way", Registrar.State.PENDING, 21L));
persistSimpleResources(makeRegistrarContacts(registrarInactive)); persistSimpleResources(makeRegistrarPocs(registrarInactive));
// test // test
registrarTest = registrarTest =
@ -125,9 +124,9 @@ class RdapEntitySearchActionTest extends RdapSearchActionTestCase<RdapEntitySear
.setType(Registrar.Type.TEST) .setType(Registrar.Type.TEST)
.setIanaIdentifier(null) .setIanaIdentifier(null)
.build()); .build());
persistSimpleResources(makeRegistrarContacts(registrarTest)); persistSimpleResources(makeRegistrarPocs(registrarTest));
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"blinky", "blinky",
"Blinky (赤ベイ)", "Blinky (赤ベイ)",
"blinky@b.tld", "blinky@b.tld",
@ -135,7 +134,7 @@ class RdapEntitySearchActionTest extends RdapSearchActionTestCase<RdapEntitySear
clock.nowUtc(), clock.nowUtc(),
registrarTest); registrarTest);
makeAndPersistContactResource( FullFieldsTestEntityHelper.makeAndPersistContact(
"blindly", "blindly",
"Blindly", "Blindly",
"blindly@b.tld", "blindly@b.tld",
@ -143,11 +142,8 @@ class RdapEntitySearchActionTest extends RdapSearchActionTestCase<RdapEntitySear
clock.nowUtc(), clock.nowUtc(),
registrarTest); registrarTest);
makeAndPersistDeletedContactResource( makeAndPersistDeletedContact(
"clyde", "clyde", clock.nowUtc().minusYears(1), registrarDeleted, clock.nowUtc().minusMonths(6));
clock.nowUtc().minusYears(1),
registrarDeleted,
clock.nowUtc().minusMonths(6));
action.fnParam = Optional.empty(); action.fnParam = Optional.empty();
action.handleParam = Optional.empty(); action.handleParam = Optional.empty();
@ -200,8 +196,8 @@ class RdapEntitySearchActionTest extends RdapSearchActionTestCase<RdapEntitySear
ImmutableList.Builder<ImmutableObject> resourcesBuilder = new ImmutableList.Builder<>(); ImmutableList.Builder<ImmutableObject> resourcesBuilder = new ImmutableList.Builder<>();
for (int i = 1; i <= numContacts; i++) { for (int i = 1; i <= numContacts; i++) {
// Set the ROIDs to a known value for later use. // Set the ROIDs to a known value for later use.
ContactResource contact = Contact contact =
makeContactResource( FullFieldsTestEntityHelper.makeContact(
String.format("contact%d", i), String.format("contact%d", i),
String.format("Entity %d", i), String.format("Entity %d", i),
String.format("contact%d@gmail.com", i), String.format("contact%d@gmail.com", i),
@ -222,7 +218,7 @@ class RdapEntitySearchActionTest extends RdapSearchActionTestCase<RdapEntitySear
Registrar.State.ACTIVE, Registrar.State.ACTIVE,
300L + i); 300L + i);
resourcesBuilder.add(registrar); resourcesBuilder.add(registrar);
resourcesBuilder.addAll(makeRegistrarContacts(registrar)); resourcesBuilder.addAll(makeRegistrarPocs(registrar));
} }
persistResources(resourcesBuilder.build()); persistResources(resourcesBuilder.build());
} }

View file

@ -20,7 +20,6 @@ import static google.registry.rdap.RdapTestHelper.assertThat;
import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DatabaseHelper.persistSimpleResources; import static google.registry.testing.DatabaseHelper.persistSimpleResources;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistContactResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHost; import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHost;
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain; import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry; import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry;
@ -34,7 +33,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import google.registry.model.contact.ContactResource; import google.registry.model.contact.Contact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.Host; import google.registry.model.host.Host;
@ -50,6 +49,7 @@ import google.registry.rdap.RdapObjectClasses.ReplyPayloadBase;
import google.registry.rdap.RdapObjectClasses.TopLevelReplyObject; import google.registry.rdap.RdapObjectClasses.TopLevelReplyObject;
import google.registry.testing.AppEngineExtension; import google.registry.testing.AppEngineExtension;
import google.registry.testing.FakeClock; import google.registry.testing.FakeClock;
import google.registry.testing.FullFieldsTestEntityHelper;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -74,10 +74,10 @@ class RdapJsonFormatterTest {
private Host hostNoAddresses; private Host hostNoAddresses;
private Host hostNotLinked; private Host hostNotLinked;
private Host hostSuperordinatePendingTransfer; private Host hostSuperordinatePendingTransfer;
private ContactResource contactResourceRegistrant; private Contact contactRegistrant;
private ContactResource contactResourceAdmin; private Contact contactAdmin;
private ContactResource contactResourceTech; private Contact contactTech;
private ContactResource contactResourceNotLinked; private Contact contactNotLinked;
@BeforeEach @BeforeEach
void beforeEach() { void beforeEach() {
@ -94,28 +94,27 @@ class RdapJsonFormatterTest {
persistSimpleResources(makeMoreRegistrarContacts(registrar)); persistSimpleResources(makeMoreRegistrarContacts(registrar));
contactResourceRegistrant = makeAndPersistContactResource( contactRegistrant =
"8372808-ERL", FullFieldsTestEntityHelper.makeAndPersistContact(
"(◕‿◕)", "8372808-ERL", "(◕‿◕)", "lol@cat.みんな", null, clock.nowUtc().minusYears(1), registrar);
"lol@cat.みんな", contactAdmin =
null, FullFieldsTestEntityHelper.makeAndPersistContact(
clock.nowUtc().minusYears(1),
registrar);
contactResourceAdmin = makeAndPersistContactResource(
"8372808-IRL", "8372808-IRL",
"Santa Claus", "Santa Claus",
null, null,
ImmutableList.of("Santa Claus Tower", "41st floor", "Suite みんな"), ImmutableList.of("Santa Claus Tower", "41st floor", "Suite みんな"),
clock.nowUtc().minusYears(2), clock.nowUtc().minusYears(2),
registrar); registrar);
contactResourceTech = makeAndPersistContactResource( contactTech =
FullFieldsTestEntityHelper.makeAndPersistContact(
"8372808-TRL", "8372808-TRL",
"The Raven", "The Raven",
"bog@cat.みんな", "bog@cat.みんな",
ImmutableList.of("Chamber Door", "upper level"), ImmutableList.of("Chamber Door", "upper level"),
clock.nowUtc().minusYears(3), clock.nowUtc().minusYears(3),
registrar); registrar);
contactResourceNotLinked = makeAndPersistContactResource( contactNotLinked =
FullFieldsTestEntityHelper.makeAndPersistContact(
"8372808-QRL", "8372808-QRL",
"The Wizard", "The Wizard",
"dog@cat.みんな", "dog@cat.みんな",
@ -154,9 +153,9 @@ class RdapJsonFormatterTest {
persistResource( persistResource(
makeDomain( makeDomain(
"dog.みんな", "dog.みんな",
contactResourceRegistrant, contactRegistrant,
contactResourceAdmin, contactAdmin,
contactResourceTech, contactTech,
null, null,
null, null,
registrar) registrar)
@ -180,9 +179,9 @@ class RdapJsonFormatterTest {
persistResource( persistResource(
makeDomain( makeDomain(
"cat.みんな", "cat.みんな",
contactResourceRegistrant, contactRegistrant,
contactResourceAdmin, contactAdmin,
contactResourceTech, contactTech,
hostIpv4, hostIpv4,
hostIpv6, hostIpv6,
registrar) registrar)
@ -194,9 +193,9 @@ class RdapJsonFormatterTest {
persistResource( persistResource(
makeDomain( makeDomain(
"fish.みんな", "fish.みんな",
contactResourceRegistrant, contactRegistrant,
contactResourceRegistrant, contactRegistrant,
contactResourceRegistrant, contactRegistrant,
null, null,
null, null,
registrar) registrar)
@ -209,9 +208,9 @@ class RdapJsonFormatterTest {
persistResource( persistResource(
makeDomain( makeDomain(
"dog.みんな", "dog.みんな",
contactResourceRegistrant, contactRegistrant,
contactResourceAdmin, contactAdmin,
contactResourceTech, contactTech,
hostBoth, hostBoth,
hostNoAddresses, hostNoAddresses,
registrar)); registrar));
@ -360,7 +359,7 @@ class RdapJsonFormatterTest {
assertThat( assertThat(
rdapJsonFormatter rdapJsonFormatter
.createRdapContactEntity( .createRdapContactEntity(
contactResourceRegistrant, contactRegistrant,
ImmutableSet.of(RdapEntity.Role.REGISTRANT), ImmutableSet.of(RdapEntity.Role.REGISTRANT),
OutputDataType.FULL) OutputDataType.FULL)
.toJson()) .toJson())
@ -372,7 +371,7 @@ class RdapJsonFormatterTest {
assertThat( assertThat(
rdapJsonFormatter rdapJsonFormatter
.createRdapContactEntity( .createRdapContactEntity(
contactResourceRegistrant, contactRegistrant,
ImmutableSet.of(RdapEntity.Role.REGISTRANT), ImmutableSet.of(RdapEntity.Role.REGISTRANT),
OutputDataType.SUMMARY) OutputDataType.SUMMARY)
.toJson()) .toJson())
@ -385,7 +384,7 @@ class RdapJsonFormatterTest {
assertThat( assertThat(
rdapJsonFormatter rdapJsonFormatter
.createRdapContactEntity( .createRdapContactEntity(
contactResourceRegistrant, contactRegistrant,
ImmutableSet.of(RdapEntity.Role.REGISTRANT), ImmutableSet.of(RdapEntity.Role.REGISTRANT),
OutputDataType.FULL) OutputDataType.FULL)
.toJson()) .toJson())
@ -404,7 +403,7 @@ class RdapJsonFormatterTest {
assertThat( assertThat(
rdapJsonFormatter rdapJsonFormatter
.createRdapContactEntity( .createRdapContactEntity(
contactResourceRegistrant, contactRegistrant,
ImmutableSet.of(RdapEntity.Role.REGISTRANT), ImmutableSet.of(RdapEntity.Role.REGISTRANT),
OutputDataType.FULL) OutputDataType.FULL)
.toJson()) .toJson())
@ -416,9 +415,7 @@ class RdapJsonFormatterTest {
assertThat( assertThat(
rdapJsonFormatter rdapJsonFormatter
.createRdapContactEntity( .createRdapContactEntity(
contactResourceAdmin, contactAdmin, ImmutableSet.of(RdapEntity.Role.ADMIN), OutputDataType.FULL)
ImmutableSet.of(RdapEntity.Role.ADMIN),
OutputDataType.FULL)
.toJson()) .toJson())
.isEqualTo(loadJson("rdapjson_admincontact.json")); .isEqualTo(loadJson("rdapjson_admincontact.json"));
} }
@ -428,7 +425,7 @@ class RdapJsonFormatterTest {
assertThat( assertThat(
rdapJsonFormatter rdapJsonFormatter
.createRdapContactEntity( .createRdapContactEntity(
contactResourceTech, ImmutableSet.of(RdapEntity.Role.TECH), OutputDataType.FULL) contactTech, ImmutableSet.of(RdapEntity.Role.TECH), OutputDataType.FULL)
.toJson()) .toJson())
.isEqualTo(loadJson("rdapjson_techcontact.json")); .isEqualTo(loadJson("rdapjson_techcontact.json"));
} }
@ -437,8 +434,7 @@ class RdapJsonFormatterTest {
void testRolelessContact() { void testRolelessContact() {
assertThat( assertThat(
rdapJsonFormatter rdapJsonFormatter
.createRdapContactEntity( .createRdapContactEntity(contactTech, ImmutableSet.of(), OutputDataType.FULL)
contactResourceTech, ImmutableSet.of(), OutputDataType.FULL)
.toJson()) .toJson())
.isEqualTo(loadJson("rdapjson_rolelesscontact.json")); .isEqualTo(loadJson("rdapjson_rolelesscontact.json"));
} }
@ -447,8 +443,7 @@ class RdapJsonFormatterTest {
void testUnlinkedContact() { void testUnlinkedContact() {
assertThat( assertThat(
rdapJsonFormatter rdapJsonFormatter
.createRdapContactEntity( .createRdapContactEntity(contactNotLinked, ImmutableSet.of(), OutputDataType.FULL)
contactResourceNotLinked, ImmutableSet.of(), OutputDataType.FULL)
.toJson()) .toJson())
.isEqualTo(loadJson("rdapjson_unlinkedcontact.json")); .isEqualTo(loadJson("rdapjson_unlinkedcontact.json"));
} }

View file

@ -23,10 +23,9 @@ import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DatabaseHelper.persistResources; import static google.registry.testing.DatabaseHelper.persistResources;
import static google.registry.testing.DatabaseHelper.persistSimpleResources; import static google.registry.testing.DatabaseHelper.persistSimpleResources;
import static google.registry.testing.FullFieldsTestEntityHelper.makeContactResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain; import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarPocs;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.ImmutableListMultimap;
@ -104,7 +103,7 @@ class RdapNameserverSearchActionTest extends RdapSearchActionTestCase<RdapNamese
Registrar registrar = Registrar registrar =
persistResource( persistResource(
makeRegistrar("evilregistrar", "Yes Virginia <script>", Registrar.State.ACTIVE)); makeRegistrar("evilregistrar", "Yes Virginia <script>", Registrar.State.ACTIVE));
persistSimpleResources(makeRegistrarContacts(registrar)); persistSimpleResources(makeRegistrarPocs(registrar));
hostNs1CatLol = hostNs1CatLol =
FullFieldsTestEntityHelper.makeAndPersistHost( FullFieldsTestEntityHelper.makeAndPersistHost(
"ns1.cat.lol", "1.2.3.4", clock.nowUtc().minusYears(1)); "ns1.cat.lol", "1.2.3.4", clock.nowUtc().minusYears(1));
@ -119,14 +118,14 @@ class RdapNameserverSearchActionTest extends RdapSearchActionTestCase<RdapNamese
// cat.みんな // cat.みんな
createTld("xn--q9jyb4c"); createTld("xn--q9jyb4c");
registrar = persistResource(makeRegistrar("unicoderegistrar", "みんな", Registrar.State.ACTIVE)); registrar = persistResource(makeRegistrar("unicoderegistrar", "みんな", Registrar.State.ACTIVE));
persistSimpleResources(makeRegistrarContacts(registrar)); persistSimpleResources(makeRegistrarPocs(registrar));
FullFieldsTestEntityHelper.makeAndPersistHost( FullFieldsTestEntityHelper.makeAndPersistHost(
"ns1.cat.みんな", "1.2.3.5", clock.nowUtc().minusYears(1)); "ns1.cat.みんな", "1.2.3.5", clock.nowUtc().minusYears(1));
// cat.1.test // cat.1.test
createTld("1.test"); createTld("1.test");
registrar = persistResource(makeRegistrar("multiregistrar", "1.test", Registrar.State.ACTIVE)); registrar = persistResource(makeRegistrar("multiregistrar", "1.test", Registrar.State.ACTIVE));
persistSimpleResources(makeRegistrarContacts(registrar)); persistSimpleResources(makeRegistrarPocs(registrar));
FullFieldsTestEntityHelper.makeAndPersistHost( FullFieldsTestEntityHelper.makeAndPersistHost(
"ns1.cat.1.test", "1.2.3.6", clock.nowUtc().minusYears(1)); "ns1.cat.1.test", "1.2.3.6", clock.nowUtc().minusYears(1));
@ -136,13 +135,14 @@ class RdapNameserverSearchActionTest extends RdapSearchActionTestCase<RdapNamese
makeDomain( makeDomain(
"cat.lol", "cat.lol",
persistResource( persistResource(
makeContactResource( FullFieldsTestEntityHelper.makeContact(
"5372808-ERL", "Goblin Market", "lol@cat.lol", registrar)), "5372808-ERL", "Goblin Market", "lol@cat.lol", registrar)),
persistResource( persistResource(
makeContactResource( FullFieldsTestEntityHelper.makeContact(
"5372808-IRL", "Santa Claus", "BOFH@cat.lol", registrar)), "5372808-IRL", "Santa Claus", "BOFH@cat.lol", registrar)),
persistResource( persistResource(
makeContactResource("5372808-TRL", "The Raven", "bog@cat.lol", registrar)), FullFieldsTestEntityHelper.makeContact(
"5372808-TRL", "The Raven", "bog@cat.lol", registrar)),
hostNs1CatLol, hostNs1CatLol,
hostNs2CatLol, hostNs2CatLol,
registrar) registrar)

View file

@ -21,10 +21,10 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactAddress; import google.registry.model.contact.ContactAddress;
import google.registry.model.contact.ContactAuthInfo; import google.registry.model.contact.ContactAuthInfo;
import google.registry.model.contact.ContactPhoneNumber; import google.registry.model.contact.ContactPhoneNumber;
import google.registry.model.contact.ContactResource;
import google.registry.model.contact.Disclose; import google.registry.model.contact.Disclose;
import google.registry.model.contact.PostalInfo; import google.registry.model.contact.PostalInfo;
import google.registry.model.eppcommon.AuthInfo.PasswordAuth; import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
@ -52,12 +52,12 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.api.extension.RegisterExtension;
/** /**
* Unit tests for {@link ContactResourceToXjcConverter}. * Unit tests for {@link ContactToXjcConverter}.
* *
* <p>This tests the mapping between {@link ContactResource} and {@link XjcRdeContact} as well as * <p>This tests the mapping between {@link Contact} and {@link XjcRdeContact} as well as some
* some exceptional conditions. * exceptional conditions.
*/ */
public class ContactResourceToXjcConverterTest { public class ContactToXjcConverterTest {
@RegisterExtension @RegisterExtension
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build(); public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
@ -69,8 +69,8 @@ public class ContactResourceToXjcConverterTest {
@Test @Test
void testConvertContact() { void testConvertContact() {
ContactResource contact = makeContactResource(); Contact contact = makeContact();
XjcRdeContact bean = ContactResourceToXjcConverter.convertContact(contact); XjcRdeContact bean = ContactToXjcConverter.convertContact(contact);
// o A <id> element that contains the server-unique identifier of the // o A <id> element that contains the server-unique identifier of the
// contact object // contact object
@ -230,38 +230,32 @@ public class ContactResourceToXjcConverterTest {
@Test @Test
void testConvertContact_absentVoiceAndFaxNumbers() { void testConvertContact_absentVoiceAndFaxNumbers() {
XjcRdeContact bean = ContactResourceToXjcConverter.convertContact( XjcRdeContact bean =
makeContactResource().asBuilder() ContactToXjcConverter.convertContact(
.setVoiceNumber(null) makeContact().asBuilder().setVoiceNumber(null).setFaxNumber(null).build());
.setFaxNumber(null)
.build());
assertThat(bean.getVoice()).isNull(); assertThat(bean.getVoice()).isNull();
assertThat(bean.getFax()).isNull(); assertThat(bean.getFax()).isNull();
} }
@Test @Test
void testConvertContact_absentDisclose() { void testConvertContact_absentDisclose() {
XjcRdeContact bean = ContactResourceToXjcConverter.convertContact( XjcRdeContact bean =
makeContactResource().asBuilder() ContactToXjcConverter.convertContact(makeContact().asBuilder().setDisclose(null).build());
.setDisclose(null)
.build());
assertThat(bean.getDisclose()).isNull(); assertThat(bean.getDisclose()).isNull();
} }
@Test @Test
void testConvertContact_absentTransferData() { void testConvertContact_absentTransferData() {
XjcRdeContact bean = ContactResourceToXjcConverter.convertContact( XjcRdeContact bean =
makeContactResource().asBuilder() ContactToXjcConverter.convertContact(
.setLastTransferTime(null) makeContact().asBuilder().setLastTransferTime(null).setTransferData(null).build());
.setTransferData(null)
.build());
assertThat(bean.getTrDate()).isNull(); assertThat(bean.getTrDate()).isNull();
assertThat(bean.getTrnData()).isNull(); assertThat(bean.getTrnData()).isNull();
} }
@Test @Test
void testMarshal() throws Exception { void testMarshal() throws Exception {
XjcRdeContact bean = ContactResourceToXjcConverter.convertContact(makeContactResource()); XjcRdeContact bean = ContactToXjcConverter.convertContact(makeContact());
wrapDeposit(bean).marshal(new ByteArrayOutputStream(), UTF_8); wrapDeposit(bean).marshal(new ByteArrayOutputStream(), UTF_8);
} }
@ -282,8 +276,8 @@ public class ContactResourceToXjcConverterTest {
return deposit; return deposit;
} }
private static ContactResource makeContactResource() { private static Contact makeContact() {
return new ContactResource.Builder() return new Contact.Builder()
.setContactId("love-id") .setContactId("love-id")
.setRepoId("2-ROID") .setRepoId("2-ROID")
.setCreationRegistrarId("NewRegistrar") .setCreationRegistrarId("NewRegistrar")

View file

@ -33,9 +33,9 @@ import com.google.common.net.InetAddresses;
import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactAddress; import google.registry.model.contact.ContactAddress;
import google.registry.model.contact.ContactPhoneNumber; import google.registry.model.contact.ContactPhoneNumber;
import google.registry.model.contact.ContactResource;
import google.registry.model.contact.PostalInfo; import google.registry.model.contact.PostalInfo;
import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DesignatedContact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
@ -247,7 +247,7 @@ public class DomainToXjcConverterTest {
ImmutableSet.of( ImmutableSet.of(
DesignatedContact.create( DesignatedContact.create(
DesignatedContact.Type.ADMIN, DesignatedContact.Type.ADMIN,
makeContactResource( makeContact(
clock, clock,
"10-Q9JYB4C", "10-Q9JYB4C",
"5372808-IRL", "5372808-IRL",
@ -256,7 +256,7 @@ public class DomainToXjcConverterTest {
.createVKey()), .createVKey()),
DesignatedContact.create( DesignatedContact.create(
DesignatedContact.Type.TECH, DesignatedContact.Type.TECH,
makeContactResource( makeContact(
clock, clock,
"11-Q9JYB4C", "11-Q9JYB4C",
"5372808-TRL", "5372808-TRL",
@ -279,7 +279,7 @@ public class DomainToXjcConverterTest {
makeHost(clock, "4-Q9JYB4C", "ns2.cat.みんな", "bad:f00d:cafe::15:beef") makeHost(clock, "4-Q9JYB4C", "ns2.cat.みんな", "bad:f00d:cafe::15:beef")
.createVKey())) .createVKey()))
.setRegistrant( .setRegistrant(
makeContactResource( makeContact(
clock, "12-Q9JYB4C", "5372808-ERL", "(◕‿◕) nevermore", "prophet@evil.みんな") clock, "12-Q9JYB4C", "5372808-ERL", "(◕‿◕) nevermore", "prophet@evil.みんな")
.createVKey()) .createVKey())
.setRegistrationExpirationTime(DateTime.parse("1930-01-01T00:00:00Z")) .setRegistrationExpirationTime(DateTime.parse("1930-01-01T00:00:00Z"))
@ -379,11 +379,11 @@ public class DomainToXjcConverterTest {
return persistResource(domain); return persistResource(domain);
} }
private static ContactResource makeContactResource( private static Contact makeContact(
FakeClock clock, String repoId, String id, String name, String email) { FakeClock clock, String repoId, String id, String name, String email) {
clock.advanceOneMilli(); clock.advanceOneMilli();
return persistEppResource( return persistEppResource(
new ContactResource.Builder() new Contact.Builder()
.setContactId(id) .setContactId(id)
.setEmailAddress(email) .setEmailAddress(email)
.setPersistedCurrentSponsorRegistrarId("TheRegistrar") .setPersistedCurrentSponsorRegistrarId("TheRegistrar")

View file

@ -28,9 +28,9 @@ import com.google.common.net.InetAddresses;
import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactAddress; import google.registry.model.contact.ContactAddress;
import google.registry.model.contact.ContactPhoneNumber; import google.registry.model.contact.ContactPhoneNumber;
import google.registry.model.contact.ContactResource;
import google.registry.model.contact.PostalInfo; import google.registry.model.contact.PostalInfo;
import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DesignatedContact;
import google.registry.model.domain.Domain; import google.registry.model.domain.Domain;
@ -62,7 +62,7 @@ final class RdeFixtures {
.setDomainName("example." + tld) .setDomainName("example." + tld)
.setRepoId(generateNewDomainRoid(tld)) .setRepoId(generateNewDomainRoid(tld))
.setRegistrant( .setRegistrant(
makeContactResource(clock, "5372808-ERL", "(◕‿◕) nevermore", "prophet@evil.みんな") makeContact(clock, "5372808-ERL", "(◕‿◕) nevermore", "prophet@evil.みんな")
.createVKey()) .createVKey())
.build(); .build();
DomainHistory historyEntry = DomainHistory historyEntry =
@ -94,7 +94,7 @@ final class RdeFixtures {
ImmutableSet.of( ImmutableSet.of(
DesignatedContact.create( DesignatedContact.create(
DesignatedContact.Type.ADMIN, DesignatedContact.Type.ADMIN,
makeContactResource( makeContact(
clock, clock,
"5372808-IRL", "5372808-IRL",
"be that word our sign in parting", "be that word our sign in parting",
@ -102,7 +102,7 @@ final class RdeFixtures {
.createVKey()), .createVKey()),
DesignatedContact.create( DesignatedContact.create(
DesignatedContact.Type.TECH, DesignatedContact.Type.TECH,
makeContactResource( makeContact(
clock, clock,
"5372808-TRL", "5372808-TRL",
"bird or fiend!? i shrieked upstarting", "bird or fiend!? i shrieked upstarting",
@ -220,11 +220,10 @@ final class RdeFixtures {
return persistResource(domain); return persistResource(domain);
} }
static ContactResource makeContactResource( static Contact makeContact(FakeClock clock, String id, String name, String email) {
FakeClock clock, String id, String name, String email) {
clock.advanceOneMilli(); clock.advanceOneMilli();
return persistResource( return persistResource(
new ContactResource.Builder() new Contact.Builder()
.setContactId(id) .setContactId(id)
.setRepoId(generateNewContactHostRoid()) .setRepoId(generateNewContactHostRoid())
.setEmailAddress(email) .setEmailAddress(email)

View file

@ -19,7 +19,7 @@ import static com.google.common.truth.Truth.assert_;
import google.registry.model.billing.BillingEventTest; import google.registry.model.billing.BillingEventTest;
import google.registry.model.common.CursorTest; import google.registry.model.common.CursorTest;
import google.registry.model.console.UserTest; import google.registry.model.console.UserTest;
import google.registry.model.contact.ContactResourceTest; import google.registry.model.contact.ContactTest;
import google.registry.model.domain.DomainSqlTest; import google.registry.model.domain.DomainSqlTest;
import google.registry.model.domain.token.AllocationTokenTest; import google.registry.model.domain.token.AllocationTokenTest;
import google.registry.model.domain.token.PackagePromotionTest; import google.registry.model.domain.token.PackagePromotionTest;
@ -84,7 +84,7 @@ import org.junit.runner.RunWith;
BillingEventTest.class, BillingEventTest.class,
ClaimsListDaoTest.class, ClaimsListDaoTest.class,
ContactHistoryTest.class, ContactHistoryTest.class,
ContactResourceTest.class, ContactTest.class,
CursorTest.class, CursorTest.class,
DomainSqlTest.class, DomainSqlTest.class,
DomainHistoryTest.class, DomainHistoryTest.class,

View file

@ -19,7 +19,7 @@ import static google.registry.model.domain.DesignatedContact.Type.BILLING;
import static google.registry.model.domain.DesignatedContact.Type.TECH; import static google.registry.model.domain.DesignatedContact.Type.TECH;
import static google.registry.testing.DatabaseHelper.createTlds; import static google.registry.testing.DatabaseHelper.createTlds;
import static google.registry.testing.DatabaseHelper.loadRegistrar; import static google.registry.testing.DatabaseHelper.loadRegistrar;
import static google.registry.testing.DatabaseHelper.newContactResource; import static google.registry.testing.DatabaseHelper.newContact;
import static google.registry.testing.DatabaseHelper.persistActiveHost; import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistPremiumList; import static google.registry.testing.DatabaseHelper.persistPremiumList;
import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistResource;
@ -28,8 +28,8 @@ import static org.joda.money.CurrencyUnit.USD;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import google.registry.model.OteStatsTestHelper; import google.registry.model.OteStatsTestHelper;
import google.registry.model.contact.Contact;
import google.registry.model.contact.ContactAddress; import google.registry.model.contact.ContactAddress;
import google.registry.model.contact.ContactResource;
import google.registry.model.contact.PostalInfo; import google.registry.model.contact.PostalInfo;
import google.registry.model.domain.DesignatedContact; import google.registry.model.domain.DesignatedContact;
import google.registry.testing.DatabaseHelper; import google.registry.testing.DatabaseHelper;
@ -59,13 +59,17 @@ public enum Fixture {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
ContactResource google = persistResource(newContactResource("google") Contact google =
persistResource(
newContact("google")
.asBuilder() .asBuilder()
.setLocalizedPostalInfo(new PostalInfo.Builder() .setLocalizedPostalInfo(
new PostalInfo.Builder()
.setType(PostalInfo.Type.LOCALIZED) .setType(PostalInfo.Type.LOCALIZED)
.setName("Mr. Google") .setName("Mr. Google")
.setOrg("Google Inc.") .setOrg("Google Inc.")
.setAddress(new ContactAddress.Builder() .setAddress(
new ContactAddress.Builder()
.setStreet(ImmutableList.of("111 8th Ave", "4th Floor")) .setStreet(ImmutableList.of("111 8th Ave", "4th Floor"))
.setCity("New York") .setCity("New York")
.setState("NY") .setState("NY")
@ -75,13 +79,17 @@ public enum Fixture {
.build()) .build())
.build()); .build());
ContactResource justine = persistResource(newContactResource("justine") Contact justine =
persistResource(
newContact("justine")
.asBuilder() .asBuilder()
.setLocalizedPostalInfo(new PostalInfo.Builder() .setLocalizedPostalInfo(
new PostalInfo.Builder()
.setType(PostalInfo.Type.LOCALIZED) .setType(PostalInfo.Type.LOCALIZED)
.setName("Justine Bean") .setName("Justine Bean")
.setOrg("(✿◕ ‿◕ ) Incorporated") .setOrg("(✿◕ ‿◕ ) Incorporated")
.setAddress(new ContactAddress.Builder() .setAddress(
new ContactAddress.Builder()
.setStreet(ImmutableList.of("123 Fake St.")) .setStreet(ImmutableList.of("123 Fake St."))
.setCity("Stratford") .setCity("Stratford")
.setState("CT") .setState("CT")
@ -91,14 +99,19 @@ public enum Fixture {
.build()) .build())
.build()); .build());
ContactResource robert = persistResource(newContactResource("robert") Contact robert =
persistResource(
newContact("robert")
.asBuilder() .asBuilder()
.setLocalizedPostalInfo(new PostalInfo.Builder() .setLocalizedPostalInfo(
new PostalInfo.Builder()
.setType(PostalInfo.Type.LOCALIZED) .setType(PostalInfo.Type.LOCALIZED)
.setName("Captain Robert") .setName("Captain Robert")
.setOrg("Ancient World") .setOrg("Ancient World")
.setAddress(new ContactAddress.Builder() .setAddress(
.setStreet(ImmutableList.of( new ContactAddress.Builder()
.setStreet(
ImmutableList.of(
"A skeleton crew is what came back", "A skeleton crew is what came back",
"And once in port he filled his sack", "And once in port he filled his sack",
"With bribes and cash and fame and coin")) "With bribes and cash and fame and coin"))

View file

@ -53,7 +53,7 @@ class AppEngineExtensionTest {
Joiner.on('\n') Joiner.on('\n')
.join( .join(
"<datastore-indexes autoGenerate=\"false\">", "<datastore-indexes autoGenerate=\"false\">",
" <datastore-index kind=\"ContactResource\" ancestor=\"false\" source=\"manual\">", " <datastore-index kind=\"Contact\" ancestor=\"false\" source=\"manual\">",
" <property name=\"currentSponsorClientId\" direction=\"asc\"/>", " <property name=\"currentSponsorClientId\" direction=\"asc\"/>",
" <property name=\"deletionTime\" direction=\"asc\"/>", " <property name=\"deletionTime\" direction=\"asc\"/>",
" <property name=\"searchName\" direction=\"asc\"/>", " <property name=\"searchName\" direction=\"asc\"/>",
@ -61,7 +61,7 @@ class AppEngineExtensionTest {
"</datastore-indexes>"); "</datastore-indexes>");
private static final String UNDECLARED_INDEX = private static final String UNDECLARED_INDEX =
DECLARED_INDEX.replace("ContactResource", "NoSuchResource"); DECLARED_INDEX.replace("Contact", "NoSuchResource");
/** /**
* Sets up test AppEngine instance. * Sets up test AppEngine instance.

Some files were not shown because too many files have changed in this diff Show more