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

@ -76,11 +76,11 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
assertTransactionalFlow(true);
runFlowAssertResponse(readFile("host_create_response.xml"));
// Check that the host was created and persisted with a history entry.
assertAboutHosts().that(reloadResourceByUniqueId())
assertAboutHosts().that(reloadResourceByForeignKey())
.hasOnlyOneHistoryEntryWhich()
.hasType(HistoryEntry.Type.HOST_CREATE);
assertNoBillingEvents();
assertEppResourceIndexEntityFor(reloadResourceByUniqueId());
assertEppResourceIndexEntityFor(reloadResourceByForeignKey());
}
private void doSuccessfulInternalTest(String tld) throws Exception {
@ -104,10 +104,10 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
@Test
public void testSuccess_internalNeverExisted() throws Exception {
doSuccessfulInternalTest("tld");
assertThat(ofy().load().key(reloadResourceByUniqueId().getSuperordinateDomain())
assertThat(ofy().load().key(reloadResourceByForeignKey().getSuperordinateDomain())
.now().getFullyQualifiedDomainName())
.isEqualTo("example.tld");
assertThat(ofy().load().key(reloadResourceByUniqueId().getSuperordinateDomain())
assertThat(ofy().load().key(reloadResourceByForeignKey().getSuperordinateDomain())
.now().getSubordinateHosts()).containsExactly("ns1.example.tld");
assertDnsTasksEnqueued("ns1.example.tld");
}
@ -123,10 +123,10 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
public void testSuccess_internalExistedButWasDeleted() throws Exception {
persistDeletedHost(getUniqueIdFromCommand(), clock.nowUtc());
doSuccessfulInternalTest("tld");
assertThat(ofy().load().key(reloadResourceByUniqueId().getSuperordinateDomain())
assertThat(ofy().load().key(reloadResourceByForeignKey().getSuperordinateDomain())
.now().getFullyQualifiedDomainName())
.isEqualTo("example.tld");
assertThat(ofy().load().key(reloadResourceByUniqueId().getSuperordinateDomain())
assertThat(ofy().load().key(reloadResourceByForeignKey().getSuperordinateDomain())
.now().getSubordinateHosts()).containsExactly("ns1.example.tld");
assertDnsTasksEnqueued("ns1.example.tld");
}