Replace loadByUniqueId() with methods that don't overload unique id

It is replaced by loadByForeignKey(), which does the same thing that
loadByUniqueId() did for contacts, hosts, and domains, and also
loadDomainApplication(), which loads domain application by ROID. This eliminates
the ugly mode-switching of attemping to load by other foreign key or ROID.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=133980156
This commit is contained in:
mcilwain 2016-09-22 11:45:58 -07:00 committed by Ben McIlwain
parent 025a4ae012
commit 21a98b899c
57 changed files with 367 additions and 340 deletions

View file

@ -16,7 +16,7 @@ package google.registry.flows.domain;
import static com.google.common.io.BaseEncoding.base16;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.EppResourceUtils.loadByUniqueId;
import static google.registry.model.EppResourceUtils.loadDomainApplication;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
import static google.registry.testing.DatastoreHelper.createTld;
@ -132,7 +132,7 @@ public class DomainAllocateFlowTest
UserPrivileges.SUPERUSER,
readFile("domain_allocate_response.xml"));
// Check that the domain was created and persisted with a history entry.
DomainResource domain = reloadResourceByUniqueId();
DomainResource domain = reloadResourceByForeignKey();
assertAboutDomains().that(domain)
.hasOnlyOneHistoryEntryWhich()
.hasType(HistoryEntry.Type.DOMAIN_ALLOCATE);
@ -142,8 +142,7 @@ public class DomainAllocateFlowTest
boolean sunrushAddGracePeriod = (nameservers == 0);
// The application should be marked as allocated, with a new history entry.
DomainApplication application =
loadByUniqueId(DomainApplication.class, applicationId, clock.nowUtc());
DomainApplication application = loadDomainApplication(applicationId, clock.nowUtc());
assertAboutApplications().that(application)
.hasApplicationStatus(ApplicationStatus.ALLOCATED).and()
.hasHistoryEntryAtIndex(1)
@ -284,7 +283,7 @@ public class DomainAllocateFlowTest
setupDomainApplication("tld", TldState.QUIET_PERIOD);
setEppInput("domain_allocate_dsdata.xml");
doSuccessfulTest(2);
assertAboutDomains().that(reloadResourceByUniqueId())
assertAboutDomains().that(reloadResourceByForeignKey())
.hasExactlyDsData(DelegationSignerData.create(
12345, 3, 1, base16().decode("49FD46E6C4B45C55D4AC")));
}
@ -295,7 +294,7 @@ public class DomainAllocateFlowTest
setEppInput("domain_allocate_dsdata_8_records.xml");
doSuccessfulTest(2);
assertThat(getOnlyGlobalResource(DomainResource.class)).isNotNull();
assertThat(reloadResourceByUniqueId().getDsData()).hasSize(8);
assertThat(reloadResourceByForeignKey().getDsData()).hasSize(8);
}
@Test
@ -326,7 +325,7 @@ public class DomainAllocateFlowTest
String expectedCsv = String.format(
"%s,example-one.tld,370d0b7c9223372036854775807,1,"
+ "2010-09-16T10:00:00.000Z,2010-07-16T09:00:00.000Z,2010-08-16T10:00:00.000Z",
reloadResourceByUniqueId().getRepoId());
reloadResourceByForeignKey().getRepoId());
assertTasksEnqueued(
"lordn-claims", new TaskMatcher().payload(expectedCsv).tag("tld"));
}
@ -339,7 +338,7 @@ public class DomainAllocateFlowTest
String expectedCsv = String.format(
"%s,example-one.tld,370d0b7c9223372036854775807,1,"
+ "2011-08-17T09:00:00.000Z,2010-07-16T09:00:00.000Z,2010-08-16T10:00:00.000Z",
reloadResourceByUniqueId().getRepoId());
reloadResourceByForeignKey().getRepoId());
assertTasksEnqueued("lordn-claims", new TaskMatcher().payload(expectedCsv).tag("tld"));
}

View file

@ -15,7 +15,7 @@
package google.registry.flows.domain;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.EppResourceUtils.loadByUniqueId;
import static google.registry.model.EppResourceUtils.loadByForeignKey;
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.newDomainApplication;
@ -65,7 +65,7 @@ public class DomainApplicationDeleteFlowTest
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_delete_response.xml"));
// Check that the domain is fully deleted.
assertThat(reloadResourceByUniqueId()).isNull();
assertThat(reloadDomainApplication()).isNull();
assertNoBillingEvents();
}
@ -86,15 +86,15 @@ public class DomainApplicationDeleteFlowTest
.setRepoId("1-TLD")
.setRegistrant(
Key.create(
loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc())))
.setNameservers(ImmutableSet.of(
Key.create(
loadByUniqueId(HostResource.class, "ns1.example.net", clock.nowUtc()))))
loadByForeignKey(HostResource.class, "ns1.example.net", clock.nowUtc()))))
.build());
doSuccessfulTest();
for (EppResource resource : new EppResource[]{
loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc()),
loadByUniqueId(HostResource.class, "ns1.example.net", clock.nowUtc()) }) {
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc()),
loadByForeignKey(HostResource.class, "ns1.example.net", clock.nowUtc()) }) {
assertAboutEppResources().that(resource).doesNotHaveStatusValue(StatusValue.LINKED);
}
}

View file

@ -17,7 +17,7 @@ package google.registry.flows.domain;
import static com.google.common.collect.Sets.union;
import static com.google.common.io.BaseEncoding.base16;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.EppResourceUtils.loadByUniqueId;
import static google.registry.model.EppResourceUtils.loadByForeignKey;
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.generateNewDomainRoid;
@ -107,7 +107,7 @@ public class DomainApplicationUpdateFlowTest
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact)),
DesignatedContact.create(Type.ADMIN, Key.create(unusedContact))))
.setNameservers(ImmutableSet.of(Key.create(
loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
.build());
}
@ -124,7 +124,7 @@ public class DomainApplicationUpdateFlowTest
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_update_response.xml"));
// Check that the application was updated. These values came from the xml.
DomainApplication application = reloadResourceByUniqueId();
DomainApplication application = reloadDomainApplication();
assertAboutApplications().that(application)
.hasStatusValue(StatusValue.CLIENT_HOLD).and()
.hasOnlyOneHistoryEntryWhich()
@ -168,7 +168,7 @@ public class DomainApplicationUpdateFlowTest
public void testSuccess_registrantMovedToTechContact() throws Exception {
setEppInput("domain_update_sunrise_registrant_to_tech.xml");
persistReferencedEntities();
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
ContactResource sh8013 = loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc());
persistResource(
newApplicationBuilder().setRegistrant(Key.create(sh8013)).build());
clock.advanceOneMilli();
@ -179,7 +179,7 @@ public class DomainApplicationUpdateFlowTest
public void testSuccess_multipleReferencesToSameContactRemoved() throws Exception {
setEppInput("domain_update_sunrise_remove_multiple_contacts.xml");
persistReferencedEntities();
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
ContactResource sh8013 = loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc());
Key<ContactResource> sh8013Key = Key.create(sh8013);
persistResource(newApplicationBuilder()
.setRegistrant(sh8013Key)
@ -199,7 +199,7 @@ public class DomainApplicationUpdateFlowTest
ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED)).build());
clock.advanceOneMilli();
runFlow();
assertAboutApplications().that(reloadResourceByUniqueId())
assertAboutApplications().that(reloadDomainApplication())
.doesNotHaveStatusValue(StatusValue.CLIENT_UPDATE_PROHIBITED);
}
@ -213,7 +213,7 @@ public class DomainApplicationUpdateFlowTest
assertTransactionalFlow(true);
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_update_response.xml"));
assertAboutApplications().that(reloadResourceByUniqueId())
assertAboutApplications().that(reloadDomainApplication())
.hasExactlyDsData(expectedDsData).and()
.hasOnlyOneHistoryEntryWhich()
.hasType(HistoryEntry.Type.DOMAIN_APPLICATION_UPDATE);
@ -372,11 +372,11 @@ public class DomainApplicationUpdateFlowTest
ImmutableSet.Builder<Key<HostResource>> nameservers = new ImmutableSet.Builder<>();
for (int i = 1; i < 15; i++) {
if (i != 2) { // Skip 2 since that's the one that the tests will add.
nameservers.add(Key.create(loadByUniqueId(
nameservers.add(Key.create(loadByForeignKey(
HostResource.class, String.format("ns%d.example.tld", i), clock.nowUtc())));
}
}
persistResource(reloadResourceByUniqueId().asBuilder()
persistResource(reloadDomainApplication().asBuilder()
.setNameservers(nameservers.build())
.build());
}
@ -491,9 +491,9 @@ public class DomainApplicationUpdateFlowTest
persistNewApplication();
// Add a tech contact to the persisted entity, which should cause the flow to fail when it tries
// to add "mak21" as a second tech contact.
persistResource(reloadResourceByUniqueId().asBuilder().setContacts(ImmutableSet.of(
persistResource(reloadDomainApplication().asBuilder().setContacts(ImmutableSet.of(
DesignatedContact.create(Type.TECH, Key.create(
loadByUniqueId(ContactResource.class, "foo", clock.nowUtc()))))).build());
loadByForeignKey(ContactResource.class, "foo", clock.nowUtc()))))).build());
runFlow();
}
@ -577,7 +577,7 @@ public class DomainApplicationUpdateFlowTest
persistReferencedEntities();
persistResource(newApplicationBuilder()
.setNameservers(ImmutableSet.of(Key.create(
loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
.build());
runFlow();
}
@ -591,7 +591,7 @@ public class DomainApplicationUpdateFlowTest
.setContacts(ImmutableSet.of(DesignatedContact.create(
Type.TECH,
Key.create(
loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))))
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc())))))
.build());
runFlow();
}

View file

@ -165,7 +165,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
}
private void assertSuccessfulCreate(String domainTld, boolean isAnchorTenant) throws Exception {
DomainResource domain = reloadResourceByUniqueId();
DomainResource domain = reloadResourceByForeignKey();
// Calculate the total cost.
Money cost = getPricesForDomainName(getUniqueIdFromCommand(), clock.nowUtc()).isPremium()
@ -255,21 +255,21 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
private void assertNoLordn() throws Exception {
// TODO(b/26161326): Assert tasks NOT enqueued.
assertAboutDomains().that(reloadResourceByUniqueId())
assertAboutDomains().that(reloadResourceByForeignKey())
.hasSmdId(null).and()
.hasLaunchNotice(null);
}
private void assertSunriseLordn() throws Exception {
// TODO(b/26161326): Assert tasks enqueued.
assertAboutDomains().that(reloadResourceByUniqueId())
assertAboutDomains().that(reloadResourceByForeignKey())
.hasSmdId("0000001761376042759136-65535").and()
.hasLaunchNotice(null);
}
private void assertClaimsLordn() throws Exception {
// TODO(b/26161326): Assert tasks enqueued.
assertAboutDomains().that(reloadResourceByUniqueId())
assertAboutDomains().that(reloadResourceByForeignKey())
.hasSmdId(null).and()
.hasLaunchNotice(LaunchNotice.create(
"370d0b7c9223372036854775807",
@ -479,7 +479,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
setEppInput("domain_create_metadata.xml");
persistContactsAndHosts();
doSuccessfulTest();
assertAboutDomains().that(reloadResourceByUniqueId())
assertAboutDomains().that(reloadResourceByForeignKey())
.hasOnlyOneHistoryEntryWhich()
.hasType(HistoryEntry.Type.DOMAIN_CREATE).and()
.hasMetadataReason("domain-create-test").and()
@ -545,7 +545,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
setEppInput("domain_create_dsdata_no_maxsiglife.xml");
persistContactsAndHosts("tld"); // For some reason this sample uses "tld".
doSuccessfulTest("tld");
assertAboutDomains().that(reloadResourceByUniqueId()).hasExactlyDsData(
assertAboutDomains().that(reloadResourceByForeignKey()).hasExactlyDsData(
DelegationSignerData.create(12345, 3, 1, base16().decode("49FD46E6C4B45C55D4AC")));
}
@ -554,7 +554,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
setEppInput("domain_create_dsdata_8_records.xml");
persistContactsAndHosts("tld"); // For some reason this sample uses "tld".
doSuccessfulTest("tld");
assertAboutDomains().that(reloadResourceByUniqueId()).hasNumDsData(8);
assertAboutDomains().that(reloadResourceByForeignKey()).hasNumDsData(8);
}
@Test
@ -581,7 +581,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistContactsAndHosts();
runFlowAssertResponse(readFile("domain_create_response.xml"),
"epp.response.resData.creData.exDate"); // Ignore expiration date; we verify it below
assertAboutDomains().that(reloadResourceByUniqueId())
assertAboutDomains().that(reloadResourceByForeignKey())
.hasRegistrationExpirationTime(clock.nowUtc().plusYears(1));
assertDnsTasksEnqueued("example.tld");
}

View file

@ -16,7 +16,7 @@ package google.registry.flows.domain;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.flows.domain.DomainTransferFlowTestCase.persistWithPendingTransfer;
import static google.registry.model.EppResourceUtils.loadByUniqueId;
import static google.registry.model.EppResourceUtils.loadByForeignKey;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
import static google.registry.testing.DatastoreHelper.createTlds;
@ -255,7 +255,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
clock.advanceOneMilli();
runFlowAssertResponse(readFile(responseFilename, substitutions));
// Check that the domain is fully deleted.
assertThat(reloadResourceByUniqueId()).isNull();
assertThat(reloadResourceByForeignKey()).isNull();
// The add grace period is for a billable action, so it should trigger a cancellation.
assertAutorenewClosedAndCancellationCreatedFor(
graceBillingEvent,
@ -313,7 +313,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
assertPollMessages(createAutorenewPollMessage("TheRegistrar").build());
clock.advanceOneMilli();
runFlowAssertResponse(readFile(responseFilename, substitutions));
DomainResource resource = reloadResourceByUniqueId();
DomainResource resource = reloadResourceByForeignKey();
// Check that the domain is in the pending delete state.
assertAboutDomains().that(resource)
.hasStatusValue(StatusValue.PENDING_DELETE).and()
@ -375,14 +375,14 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
// Modify the autorenew poll message so that it has unacked messages in the past. This should
// prevent it from being deleted when the domain is deleted.
persistResource(
ofy().load().key(reloadResourceByUniqueId().getAutorenewPollMessage()).now().asBuilder()
ofy().load().key(reloadResourceByForeignKey().getAutorenewPollMessage()).now().asBuilder()
.setEventTime(A_MONTH_FROM_NOW.minusYears(3))
.build());
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_delete_response_pending.xml"));
// There should now be two poll messages; one for the delete of the domain (in the future), and
// another for the unacked autorenew messages.
DateTime deletionTime = reloadResourceByUniqueId().getDeletionTime();
DateTime deletionTime = reloadResourceByForeignKey().getDeletionTime();
assertThat(getPollMessages("TheRegistrar", deletionTime.minusMinutes(1)))
.hasSize(1);
assertThat(getPollMessages("TheRegistrar", deletionTime)).hasSize(2);
@ -482,10 +482,10 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
setupSuccessfulTest();
// Modify the domain we are testing to include a pending transfer.
TransferData oldTransferData =
persistWithPendingTransfer(reloadResourceByUniqueId()).getTransferData();
persistWithPendingTransfer(reloadResourceByForeignKey()).getTransferData();
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_delete_response_pending.xml"));
DomainResource domain = reloadResourceByUniqueId();
DomainResource domain = reloadResourceByForeignKey();
// Check that the domain is in the pending delete state.
// The PENDING_TRANSFER status should be gone.
assertAboutDomains().that(domain)
@ -554,17 +554,20 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
setupGracePeriods(GracePeriod.forBillingEvent(GracePeriodStatus.ADD, graceBillingEvent));
// Add a nameserver.
HostResource host = persistResource(newHostResource("ns1.example.tld"));
persistResource(loadByUniqueId(
persistResource(loadByForeignKey(
DomainResource.class, getUniqueIdFromCommand(), clock.nowUtc())
.asBuilder()
.setNameservers(ImmutableSet.of(Key.create(host)))
.build());
// Persist another domain that's already been deleted and references this contact and host.
persistResource(newDomainResource("example1.tld").asBuilder()
.setRegistrant(Key.create(loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))
.setNameservers(ImmutableSet.of(Key.create(host)))
.setDeletionTime(START_OF_TIME)
.build());
persistResource(
newDomainResource("example1.tld")
.asBuilder()
.setRegistrant(
Key.create(loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc())))
.setNameservers(ImmutableSet.of(Key.create(host)))
.setDeletionTime(START_OF_TIME)
.build());
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_delete_response.xml"));
assertDnsTasksEnqueued("example.tld");
@ -578,7 +581,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
setupSuccessfulTest();
persistResource(
newHostResource("ns1." + getUniqueIdFromCommand()).asBuilder()
.setSuperordinateDomain(Key.create(reloadResourceByUniqueId()))
.setSuperordinateDomain(Key.create(reloadResourceByForeignKey()))
.setDeletionTime(clock.nowUtc().minusDays(1))
.build());
clock.advanceOneMilli();
@ -610,7 +613,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
DomainResource domain = persistActiveDomain(getUniqueIdFromCommand());
HostResource subordinateHost = persistResource(
newHostResource("ns1." + getUniqueIdFromCommand()).asBuilder()
.setSuperordinateDomain(Key.create(reloadResourceByUniqueId()))
.setSuperordinateDomain(Key.create(reloadResourceByForeignKey()))
.build());
domain = persistResource(domain.asBuilder()
.addSubordinateHost(subordinateHost.getFullyQualifiedHostName())
@ -681,7 +684,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
setupSuccessfulTest();
clock.advanceOneMilli();
runFlow();
assertAboutDomains().that(reloadResourceByUniqueId())
assertAboutDomains().that(reloadResourceByForeignKey())
.hasOneHistoryEntryEachOfTypes(
HistoryEntry.Type.DOMAIN_CREATE,
HistoryEntry.Type.DOMAIN_DELETE);
@ -699,7 +702,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
persistResource(newDomainResource(getUniqueIdFromCommand()));
runFlow();
}
@Test
public void testSuccess_flags() throws Exception {
setEppInput("domain_delete_flags.xml");

View file

@ -135,10 +135,10 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
int renewalYears,
Map<String, String> substitutions) throws Exception {
assertTransactionalFlow(true);
DateTime currentExpiration = reloadResourceByUniqueId().getRegistrationExpirationTime();
DateTime currentExpiration = reloadResourceByForeignKey().getRegistrationExpirationTime();
DateTime newExpiration = currentExpiration.plusYears(renewalYears);
runFlowAssertResponse(readFile(responseFilename, substitutions));
DomainResource domain = reloadResourceByUniqueId();
DomainResource domain = reloadResourceByForeignKey();
HistoryEntry historyEntryDomainRenew =
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RENEW);
assertThat(ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime())
@ -351,12 +351,12 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
persistDomain();
// Modify the autorenew poll message so that it has an undelivered message in the past.
persistResource(
ofy().load().key(reloadResourceByUniqueId().getAutorenewPollMessage()).now().asBuilder()
ofy().load().key(reloadResourceByForeignKey().getAutorenewPollMessage()).now().asBuilder()
.setEventTime(expirationTime.minusYears(1))
.build());
runFlowAssertResponse(readFile("domain_renew_response.xml"));
HistoryEntry historyEntryDomainRenew =
getOnlyHistoryEntryOfType(reloadResourceByUniqueId(), HistoryEntry.Type.DOMAIN_RENEW);
getOnlyHistoryEntryOfType(reloadResourceByForeignKey(), HistoryEntry.Type.DOMAIN_RENEW);
assertPollMessages(
new PollMessage.Autorenew.Builder()
.setTargetId(getUniqueIdFromCommand())
@ -365,12 +365,12 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
.setAutorenewEndTime(clock.nowUtc())
.setMsg("Domain was auto-renewed.")
.setParent(getOnlyHistoryEntryOfType(
reloadResourceByUniqueId(), HistoryEntry.Type.DOMAIN_CREATE))
reloadResourceByForeignKey(), HistoryEntry.Type.DOMAIN_CREATE))
.build(),
new PollMessage.Autorenew.Builder()
.setTargetId(getUniqueIdFromCommand())
.setClientId("TheRegistrar")
.setEventTime(reloadResourceByUniqueId().getRegistrationExpirationTime())
.setEventTime(reloadResourceByForeignKey().getRegistrationExpirationTime())
.setAutorenewEndTime(END_OF_TIME)
.setMsg("Domain was auto-renewed.")
.setParent(historyEntryDomainRenew)
@ -529,7 +529,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
public void testFailure_pendingTransfer() throws Exception {
thrown.expect(DomainHasPendingTransferException.class);
persistDomain();
persistWithPendingTransfer(reloadResourceByUniqueId()
persistWithPendingTransfer(reloadResourceByForeignKey()
.asBuilder()
.setRegistrationExpirationTime(DateTime.parse("2001-09-08T22:00:00.0Z"))
.build());
@ -568,7 +568,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
thrown.expect(IncorrectCurrentExpirationDateException.class);
persistDomain();
// Note expiration time is off by one day.
persistResource(reloadResourceByUniqueId().asBuilder()
persistResource(reloadResourceByForeignKey().asBuilder()
.setRegistrationExpirationTime(DateTime.parse("2000-04-04T22:00:00.0Z"))
.build());
runFlow();

View file

@ -129,7 +129,7 @@ public class DomainRestoreRequestFlowTest extends
assertThat(getPollMessages("TheRegistrar", clock.nowUtc().plusMonths(1)))
.hasSize(1);
runFlowAssertResponse(readFile("domain_update_response.xml"));
DomainResource domain = reloadResourceByUniqueId();
DomainResource domain = reloadResourceByForeignKey();
HistoryEntry historyEntryDomainRestore =
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RESTORE);
assertThat(ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime())

View file

@ -16,7 +16,7 @@ package google.registry.flows.domain;
import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.EppResourceUtils.loadByUniqueId;
import static google.registry.model.EppResourceUtils.loadByForeignKey;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.testing.DatastoreHelper.assertBillingEventsForResource;
import static google.registry.testing.DatastoreHelper.createTld;
@ -141,7 +141,7 @@ public class DomainTransferApproveFlowTest
assertTransactionalFlow(true);
runFlowAssertResponse(readFile(expectedXmlFilename));
// Transfer should have succeeded. Verify correct fields were set.
domain = reloadResourceByUniqueId();
domain = reloadResourceByForeignKey();
assertAboutDomains().that(domain).hasOneHistoryEntryEachOfTypes(
HistoryEntry.Type.DOMAIN_CREATE,
HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST,
@ -280,7 +280,7 @@ public class DomainTransferApproveFlowTest
@Test
public void testSuccess_lastTransferTime_reflectedOnSubordinateHost() throws Exception {
domain = reloadResourceByUniqueId();
domain = reloadResourceByForeignKey();
// Set an older last transfer time on the subordinate host.
subordinateHost = persistResource(
subordinateHost.asBuilder()
@ -288,7 +288,7 @@ public class DomainTransferApproveFlowTest
.build());
doSuccessfulTest("tld", "domain_transfer_approve.xml", "domain_transfer_approve_response.xml");
subordinateHost = loadByUniqueId(
subordinateHost = loadByForeignKey(
HostResource.class, subordinateHost.getFullyQualifiedHostName(), clock.nowUtc());
// Verify that the host's last transfer time is now that of when the superordinate domain was
// transferred.
@ -297,7 +297,7 @@ public class DomainTransferApproveFlowTest
@Test
public void testSuccess_lastTransferTime_overridesExistingOnSubordinateHost() throws Exception {
domain = reloadResourceByUniqueId();
domain = reloadResourceByForeignKey();
// Set an older last transfer time on the subordinate host.
subordinateHost = persistResource(
subordinateHost.asBuilder()
@ -306,7 +306,7 @@ public class DomainTransferApproveFlowTest
.build());
doSuccessfulTest("tld", "domain_transfer_approve.xml", "domain_transfer_approve_response.xml");
subordinateHost = loadByUniqueId(
subordinateHost = loadByForeignKey(
HostResource.class, subordinateHost.getFullyQualifiedHostName(), clock.nowUtc());
// Verify that the host's last transfer time is now that of when the superordinate domain was
// transferred.
@ -316,7 +316,7 @@ public class DomainTransferApproveFlowTest
@Test
public void testSuccess_lastTransferTime_overridesExistingOnSubordinateHostWithNullTransferTime()
throws Exception {
domain = reloadResourceByUniqueId();
domain = reloadResourceByForeignKey();
// Set an older last transfer time on the subordinate host.
subordinateHost = persistResource(
subordinateHost.asBuilder()
@ -325,7 +325,7 @@ public class DomainTransferApproveFlowTest
.build());
doSuccessfulTest("tld", "domain_transfer_approve.xml", "domain_transfer_approve_response.xml");
subordinateHost = loadByUniqueId(
subordinateHost = loadByForeignKey(
HostResource.class, subordinateHost.getFullyQualifiedHostName(), clock.nowUtc());
// Verify that the host's last transfer time is now that of when the superordinate domain was
// transferred.
@ -350,7 +350,7 @@ public class DomainTransferApproveFlowTest
@Test
public void testSuccess_autorenewBeforeTransfer() throws Exception {
DomainResource domain = reloadResourceByUniqueId();
DomainResource domain = reloadResourceByForeignKey();
DateTime oldExpirationTime = clock.nowUtc().minusDays(1);
persistResource(domain.asBuilder()
.setRegistrationExpirationTime(oldExpirationTime)

View file

@ -107,7 +107,7 @@ public class DomainTransferCancelFlowTest
runFlowAssertResponse(readFile(expectedXmlFilename));
// Transfer should have been cancelled. Verify correct fields were set.
domain = reloadResourceByUniqueId();
domain = reloadResourceByForeignKey();
assertTransferFailed(domain, TransferStatus.CLIENT_CANCELLED);
assertAboutDomains().that(domain)
.hasRegistrationExpirationTime(originalExpirationTime).and()

View file

@ -16,7 +16,7 @@ package google.registry.flows.domain;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.EppResourceUtils.loadByUniqueId;
import static google.registry.model.EppResourceUtils.loadByForeignKey;
import static google.registry.testing.DatastoreHelper.createBillingEventForTransfer;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType;
@ -120,14 +120,15 @@ public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
.setCreationClientId("TheRegistrar")
.setCreationTimeForTest(DateTime.parse("1999-04-03T22:00:00.0Z"))
.setRegistrationExpirationTime(REGISTRATION_EXPIRATION_TIME)
.setRegistrant(Key.create(loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc())))
.setRegistrant(
Key.create(loadByForeignKey(ContactResource.class, "jd1234", clock.nowUtc())))
.setContacts(ImmutableSet.of(
DesignatedContact.create(
Type.ADMIN,
Key.create(loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc()))),
Key.create(loadByForeignKey(ContactResource.class, "jd1234", clock.nowUtc()))),
DesignatedContact.create(
Type.TECH,
Key.create(loadByUniqueId(ContactResource.class, "jd1234", clock.nowUtc())))))
Key.create(loadByForeignKey(ContactResource.class, "jd1234", clock.nowUtc())))))
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("fooBAR")))
.addGracePeriod(GracePeriod.create(
GracePeriodStatus.ADD, clock.nowUtc().plusDays(10), "foo", null))

View file

@ -80,7 +80,7 @@ public class DomainTransferRejectFlowTest
ImmutableSet<GracePeriod> originalGracePeriods = domain.getGracePeriods();
runFlowAssertResponse(readFile(expectedXmlFilename));
// Transfer should have been rejected. Verify correct fields were set.
domain = reloadResourceByUniqueId();
domain = reloadResourceByForeignKey();
assertTransferFailed(domain, TransferStatus.CLIENT_REJECTED);
assertTransferFailed(
reloadResourceAndCloneAtTime(subordinateHost, clock.nowUtc()),

View file

@ -147,7 +147,7 @@ public class DomainTransferRequestFlowTest
assertTransactionalFlow(true);
runFlowAssertResponse(readFile(expectedXmlFilename, substitutions));
// Transfer should have been requested. Verify correct fields were set.
domain = reloadResourceByUniqueId();
domain = reloadResourceByForeignKey();
final HistoryEntry historyEntryTransferRequest =
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_TRANSFER_REQUEST);
int registrationYears = domain.getTransferData().getExtendedRegistrationYears();
@ -503,7 +503,7 @@ public class DomainTransferRequestFlowTest
@Test
public void testSuccess_autorenewBeforeAutomaticTransfer() throws Exception {
DomainResource oldResource = persistResource(reloadResourceByUniqueId().asBuilder()
DomainResource oldResource = persistResource(reloadResourceByForeignKey().asBuilder()
.setRegistrationExpirationTime(clock.nowUtc().plusDays(1).plus(1))
.build());
clock.advanceOneMilli();

View file

@ -17,7 +17,7 @@ package google.registry.flows.domain;
import static com.google.common.collect.Sets.union;
import static com.google.common.io.BaseEncoding.base16;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.EppResourceUtils.loadByUniqueId;
import static google.registry.model.EppResourceUtils.loadByForeignKey;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.testing.DatastoreHelper.assertBillingEvents;
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
@ -121,7 +121,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
}
private DomainResource persistDomain() throws Exception {
HostResource host = loadByUniqueId(HostResource.class, "ns1.example.foo", clock.nowUtc());
HostResource host = loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc());
DomainResource domain = persistResource(
newDomainResource(getUniqueIdFromCommand()).asBuilder()
.setContacts(ImmutableSet.of(
@ -142,7 +142,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
assertTransactionalFlow(true);
runFlowAssertResponse(readFile("domain_update_response.xml"));
// Check that the domain was updated. These values came from the xml.
assertAboutDomains().that(reloadResourceByUniqueId())
assertAboutDomains().that(reloadResourceByForeignKey())
.hasStatusValue(StatusValue.CLIENT_HOLD).and()
.hasAuthInfoPwd("2BARfoo").and()
.hasOneHistoryEntryEachOfTypes(
@ -178,12 +178,12 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
CommitMode.LIVE, userPrivileges, readFile("domain_update_response.xml"));
// Verify that the domain now has the new nameserver and is in the add grace period.
DomainResource resource = reloadResourceByUniqueId();
DomainResource resource = reloadResourceByForeignKey();
HistoryEntry historyEntryDomainUpdate =
getOnlyHistoryEntryOfType(resource, HistoryEntry.Type.DOMAIN_UPDATE);
assertThat(resource.getNameservers()).containsExactly(
Key.create(
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc())));
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc())));
BillingEvent.OneTime regularAddBillingEvent = new BillingEvent.OneTime.Builder()
.setReason(Reason.CREATE)
.setTargetId("example.tld")
@ -236,7 +236,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
getSunrushAddBillingEvent(clock.nowUtc().plusDays(20)));
// Modify domain so it has no nameservers and is in the sunrush add grace period.
persistResource(
reloadResourceByUniqueId().asBuilder()
reloadResourceByForeignKey().asBuilder()
.setNameservers(null)
.addGracePeriod(GracePeriod.forBillingEvent(
GracePeriodStatus.SUNRUSH_ADD, sunrushAddBillingEvent))
@ -260,7 +260,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
// that grace period only has a couple days left so that the resultant add grace period will get
// truncated.
persistResource(
reloadResourceByUniqueId().asBuilder()
reloadResourceByForeignKey().asBuilder()
.setNameservers(null)
.addGracePeriod(GracePeriod.forBillingEvent(
GracePeriodStatus.SUNRUSH_ADD, sunrushAddBillingEvent))
@ -279,9 +279,9 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
// Modify domain so that it is in the sunrush add grace period, has nameservers, but has a
// serverHold on it.
persistResource(
reloadResourceByUniqueId().asBuilder()
reloadResourceByForeignKey().asBuilder()
.setNameservers(ImmutableSet.of(Key.create(
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
.addGracePeriod(GracePeriod.forBillingEvent(
GracePeriodStatus.SUNRUSH_ADD, sunrushAddBillingEvent))
.addStatusValue(StatusValue.SERVER_HOLD)
@ -303,9 +303,9 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
// Modify domain so that it is in the sunrush add grace period, has nameservers, but has a
// serverHold on it.
persistResource(
reloadResourceByUniqueId().asBuilder()
reloadResourceByForeignKey().asBuilder()
.setNameservers(ImmutableSet.of(Key.create(
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
.addGracePeriod(GracePeriod.forBillingEvent(
GracePeriodStatus.SUNRUSH_ADD, sunrushAddBillingEvent))
.addStatusValue(StatusValue.CLIENT_HOLD)
@ -328,7 +328,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
// Modify domain so it has no nameservers and is in the sunrush add grace period, but also has a
// server hold on it that will prevent the sunrush add grace period from being removed.
persistResource(
reloadResourceByUniqueId().asBuilder()
reloadResourceByForeignKey().asBuilder()
.setNameservers(null)
.addGracePeriod(GracePeriod.forBillingEvent(
GracePeriodStatus.SUNRUSH_ADD, sunrushAddBillingEvent))
@ -339,7 +339,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
CommitMode.LIVE, UserPrivileges.NORMAL, readFile("domain_update_response.xml"));
// Verify that the domain is still in the sunrush add grace period.
assertGracePeriods(
reloadResourceByUniqueId().getGracePeriods(),
reloadResourceByForeignKey().getGracePeriods(),
ImmutableMap.of(
GracePeriod.create(
GracePeriodStatus.SUNRUSH_ADD, endOfGracePeriod, "TheRegistrar", null),
@ -350,12 +350,12 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
ImmutableSet.Builder<Key<HostResource>> nameservers = new ImmutableSet.Builder<>();
for (int i = 1; i < 15; i++) {
if (i != 2) { // Skip 2 since that's the one that the tests will add.
nameservers.add(Key.create(loadByUniqueId(
nameservers.add(Key.create(loadByForeignKey(
HostResource.class, String.format("ns%d.example.foo", i), clock.nowUtc())));
}
}
persistResource(
reloadResourceByUniqueId().asBuilder()
reloadResourceByForeignKey().asBuilder()
.setNameservers(nameservers.build())
.build());
clock.advanceOneMilli();
@ -392,7 +392,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
}
ImmutableList<DesignatedContact> contacts = contactsBuilder.build();
persistResource(
reloadResourceByUniqueId().asBuilder()
reloadResourceByForeignKey().asBuilder()
.setNameservers(nameservers.build())
.setContacts(ImmutableSet.copyOf(contacts.subList(0, 3)))
.setRegistrant(contacts.get(3).getContactKey())
@ -400,7 +400,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
clock.advanceOneMilli();
assertTransactionalFlow(true);
runFlowAssertResponse(readFile("domain_update_response.xml"));
DomainResource domain = reloadResourceByUniqueId();
DomainResource domain = reloadResourceByForeignKey();
assertAboutDomains().that(domain)
.hasOneHistoryEntryEachOfTypes(
HistoryEntry.Type.DOMAIN_CREATE,
@ -421,7 +421,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistReferencedEntities();
persistDomain();
runFlow();
DomainResource domain = reloadResourceByUniqueId();
DomainResource domain = reloadResourceByForeignKey();
assertAboutDomains().that(domain)
.hasOneHistoryEntryEachOfTypes(
HistoryEntry.Type.DOMAIN_CREATE,
@ -462,16 +462,16 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.addSubordinateHost("ns1.example.tld")
.addSubordinateHost("ns2.example.tld")
.setNameservers(ImmutableSet.of(Key.create(
loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
.build());
clock.advanceOneMilli();
assertTransactionalFlow(true);
runFlowAssertResponse(readFile("domain_update_response.xml"));
domain = reloadResourceByUniqueId();
domain = reloadResourceByForeignKey();
assertThat(domain.getNameservers()).containsExactly(Key.create(addedHost));
assertThat(domain.getSubordinateHosts()).containsExactly("ns1.example.tld", "ns2.example.tld");
existingHost = loadByUniqueId(HostResource.class, "ns1.example.tld", clock.nowUtc());
addedHost = loadByUniqueId(HostResource.class, "ns2.example.tld", clock.nowUtc());
existingHost = loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc());
addedHost = loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc());
assertThat(existingHost.getSuperordinateDomain()).isEqualTo(Key.create(domain));
assertThat(addedHost.getSuperordinateDomain()).isEqualTo(Key.create(domain));
}
@ -480,7 +480,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
public void testSuccess_registrantMovedToTechContact() throws Exception {
setEppInput("domain_update_registrant_to_tech.xml");
persistReferencedEntities();
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
ContactResource sh8013 = loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc());
persistResource(
newDomainResource(getUniqueIdFromCommand()).asBuilder()
.setRegistrant(Key.create(sh8013))
@ -493,7 +493,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
public void testSuccess_multipleReferencesToSameContactRemoved() throws Exception {
setEppInput("domain_update_remove_multiple_contacts.xml");
persistReferencedEntities();
ContactResource sh8013 = loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc());
ContactResource sh8013 = loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc());
Key<ContactResource> sh8013Key = Key.create(sh8013);
persistResource(
newDomainResource(getUniqueIdFromCommand()).asBuilder()
@ -516,7 +516,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.build());
clock.advanceOneMilli();
runFlow();
assertAboutDomains().that(reloadResourceByUniqueId())
assertAboutDomains().that(reloadResourceByForeignKey())
.doesNotHaveStatusValue(StatusValue.CLIENT_UPDATE_PROHIBITED);
}
@ -533,7 +533,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
assertTransactionalFlow(true);
clock.advanceOneMilli();
runFlowAssertResponse(readFile("domain_update_response.xml"));
DomainResource resource = reloadResourceByUniqueId();
DomainResource resource = reloadResourceByForeignKey();
assertAboutDomains().that(resource)
.hasOnlyOneHistoryEntryWhich()
.hasType(HistoryEntry.Type.DOMAIN_UPDATE);
@ -660,7 +660,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.setEventTime(clock.nowUtc())
.setBillingTime(clock.nowUtc())
.setParent(getOnlyHistoryEntryOfType(
reloadResourceByUniqueId(), HistoryEntry.Type.DOMAIN_UPDATE))
reloadResourceByForeignKey(), HistoryEntry.Type.DOMAIN_UPDATE))
.build());
} else {
assertNoBillingEvents();
@ -742,7 +742,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
CommitMode.LIVE,
UserPrivileges.SUPERUSER,
readFile("domain_update_response.xml"));
assertAboutDomains().that(reloadResourceByUniqueId())
assertAboutDomains().that(reloadResourceByForeignKey())
.hasStatusValue(StatusValue.CLIENT_UPDATE_PROHIBITED).and()
.hasStatusValue(StatusValue.SERVER_HOLD);
}
@ -891,10 +891,10 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
// Add a tech contact to the persisted entity, which should cause the flow to fail when it tries
// to add "mak21" as a second tech contact.
persistResource(
reloadResourceByUniqueId().asBuilder()
reloadResourceByForeignKey().asBuilder()
.setContacts(ImmutableSet.of(
DesignatedContact.create(Type.TECH, Key.create(
loadByUniqueId(ContactResource.class, "foo", clock.nowUtc())))))
loadByForeignKey(ContactResource.class, "foo", clock.nowUtc())))))
.build());
runFlow();
}
@ -990,7 +990,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistResource(
newDomainResource(getUniqueIdFromCommand()).asBuilder()
.setNameservers(ImmutableSet.of(Key.create(
loadByUniqueId(HostResource.class, "ns1.example.foo", clock.nowUtc()))))
loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc()))))
.build());
runFlow();
}
@ -1005,7 +1005,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.setContacts(ImmutableSet.of(DesignatedContact.create(
Type.TECH,
Key.create(
loadByUniqueId(ContactResource.class, "sh8013", clock.nowUtc())))))
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc())))))
.build());
runFlow();
}
@ -1048,7 +1048,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistActiveHost("ns1.example.foo");
persistActiveHost("ns2.example.foo");
persistActiveContact("sh8013");
persistResource(loadByUniqueId(ContactResource.class, "mak21", clock.nowUtc()).asBuilder()
persistResource(loadByForeignKey(ContactResource.class, "mak21", clock.nowUtc()).asBuilder()
.addStatusValue(StatusValue.PENDING_DELETE)
.build());
clock.advanceOneMilli();
@ -1066,7 +1066,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistActiveContact("mak21");
persistActiveContact("sh8013");
persistResource(
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc()).asBuilder()
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc()).asBuilder()
.addStatusValue(StatusValue.PENDING_DELETE)
.build());
clock.advanceOneMilli();
@ -1111,11 +1111,11 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.setAllowedFullyQualifiedHostNames(
ImmutableSet.of("ns1.example.foo", "ns2.example.foo"))
.build());
assertThat(reloadResourceByUniqueId().getNameservers()).doesNotContain(
Key.create(loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc())));
assertThat(reloadResourceByForeignKey().getNameservers()).doesNotContain(
Key.create(loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc())));
runFlow();
assertThat(reloadResourceByUniqueId().getNameservers()).contains(
Key.create(loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc())));
assertThat(reloadResourceByForeignKey().getNameservers()).contains(
Key.create(loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc())));
}
@Test
@ -1130,7 +1130,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns1.example.foo"))
.build());
runFlow();
assertThat(ofy().load().key(reloadResourceByUniqueId().getRegistrant()).now().getContactId())
assertThat(ofy().load().key(reloadResourceByForeignKey().getRegistrant()).now().getContactId())
.isEqualTo("sh8013");
}
@ -1152,21 +1152,21 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistReferencedEntities();
persistDomain();
persistResource(
reloadResourceByUniqueId().asBuilder()
reloadResourceByForeignKey().asBuilder()
.addNameservers(ImmutableSet.of(Key.create(
loadByUniqueId(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
.build());
persistResource(
Registry.get("tld").asBuilder()
.setAllowedFullyQualifiedHostNames(
ImmutableSet.of("ns1.example.foo", "ns2.example.foo"))
.build());
assertThat(reloadResourceByUniqueId().getNameservers()).contains(
Key.create(loadByUniqueId(HostResource.class, "ns1.example.foo", clock.nowUtc())));
assertThat(reloadResourceByForeignKey().getNameservers()).contains(
Key.create(loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc())));
clock.advanceOneMilli();
runFlow();
assertThat(reloadResourceByUniqueId().getNameservers()).doesNotContain(
Key.create(loadByUniqueId(HostResource.class, "ns1.example.foo", clock.nowUtc())));
assertThat(reloadResourceByForeignKey().getNameservers()).doesNotContain(
Key.create(loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc())));
}
@Test