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

@ -15,7 +15,7 @@
package google.registry.flows;
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.model.tmch.ClaimsListShardTest.createTestClaimsListShard;
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
@ -27,6 +27,8 @@ import com.google.common.collect.ImmutableMap;
import com.googlecode.objectify.Key;
import google.registry.flows.EppException.CommandUseErrorException;
import google.registry.model.EppResource;
import google.registry.model.EppResourceUtils;
import google.registry.model.domain.DomainApplication;
import google.registry.model.domain.launch.ApplicationIdTargetExtension;
import google.registry.model.eppinput.EppInput.ResourceCommandWrapper;
import google.registry.model.eppinput.ResourceCommand;
@ -54,19 +56,20 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
@Rule
public final ExceptionRule thrown = new ExceptionRule();
private R reloadResourceByUniqueId(DateTime now) throws Exception {
protected R reloadResourceByForeignKey(DateTime now) throws Exception {
// Force the session to be cleared so that when we read it back, we read from the datastore and
// not from the transaction cache or memcache.
ofy().clearSessionCache();
return loadByUniqueId(getResourceClass(), getUniqueIdFromCommand(), now);
return loadByForeignKey(getResourceClass(), getUniqueIdFromCommand(), now);
}
protected R reloadResourceByUniqueId() throws Exception {
return reloadResourceByUniqueId(clock.nowUtc());
protected R reloadResourceByForeignKey() throws Exception {
return reloadResourceByForeignKey(clock.nowUtc());
}
protected R reloadResourceByUniqueIdYesterday() throws Exception {
return reloadResourceByUniqueId(clock.nowUtc().minusDays(1));
protected DomainApplication reloadDomainApplication() throws Exception {
ofy().clearSessionCache();
return EppResourceUtils.loadDomainApplication(getUniqueIdFromCommand(), clock.nowUtc());
}
protected <T extends EppResource> T reloadResourceAndCloneAtTime(T resource, DateTime now) {