mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 00:47:11 +02:00
Create *InfoData objects instead of reusing *Resource objects
This is probably best from a code-cleanliness perspective anyways, but the rationale is that tightly coupling the resources to the info responses was a straightjacket that required all status values and fields to be directly available on the resource. With this change, I already was able to get rid of the preMarshal() hackery, and I will be able to get rid of cloneWithLinkedStatus() and most of the contents of cloneProjectedAtTime() for non-domains. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=144252924
This commit is contained in:
parent
96a71ded91
commit
b0bcc1bb3d
22 changed files with 586 additions and 230 deletions
|
@ -14,14 +14,24 @@
|
|||
|
||||
package google.registry.flows.domain;
|
||||
|
||||
import static com.google.appengine.tools.development.testing.LocalMemcacheServiceTestConfig.getLocalMemcacheService;
|
||||
import static com.google.common.base.Predicates.equalTo;
|
||||
import static com.google.common.io.BaseEncoding.base16;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.TestDataHelper.loadFileWithSubstitutions;
|
||||
import static google.registry.util.DatastoreServiceUtils.KEY_TO_KIND_FUNCTION;
|
||||
|
||||
import com.google.appengine.api.memcache.MemcacheServicePb.MemcacheFlushRequest;
|
||||
import com.google.appengine.tools.development.LocalRpcService;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -44,10 +54,12 @@ import google.registry.model.domain.secdns.DelegationSignerData;
|
|||
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.ofy.RequestCapturingAsyncDatastoreService;
|
||||
import google.registry.model.registry.Registry.TldState;
|
||||
import google.registry.model.smd.EncodedSignedMark;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.testing.EppLoader;
|
||||
import java.util.List;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -317,4 +329,32 @@ public class DomainApplicationInfoFlowTest
|
|||
thrown.expect(ApplicationLaunchPhaseMismatchException.class);
|
||||
runFlow();
|
||||
}
|
||||
|
||||
/** Test that we load contacts and hosts as a batch rather than individually. */
|
||||
@Test
|
||||
public void testBatchLoadingOfReferences() throws Exception {
|
||||
persistTestEntities(HostsState.HOSTS_EXIST, MarksState.NO_MARKS_EXIST);
|
||||
// Clear out memcache and session cache so that we count actual datastore calls.
|
||||
ofy().clearSessionCache();
|
||||
getLocalMemcacheService().flushAll(
|
||||
new LocalRpcService.Status(), MemcacheFlushRequest.newBuilder().build());
|
||||
int numPreviousReads = RequestCapturingAsyncDatastoreService.getReads().size();
|
||||
doSuccessfulTest("domain_info_sunrise_response.xml", HostsState.HOSTS_EXIST);
|
||||
// Get all of the keys loaded in the flow, with each distinct load() call as a list of keys.
|
||||
int numReadsWithContactsOrHosts = FluentIterable
|
||||
.from(RequestCapturingAsyncDatastoreService.getReads())
|
||||
.skip(numPreviousReads)
|
||||
.filter(
|
||||
new Predicate<List<com.google.appengine.api.datastore.Key>>() {
|
||||
@Override
|
||||
public boolean apply(List<com.google.appengine.api.datastore.Key> keys) {
|
||||
return FluentIterable.from(keys)
|
||||
.transform(KEY_TO_KIND_FUNCTION)
|
||||
.anyMatch(Predicates.or(
|
||||
equalTo(Key.getKind(ContactResource.class)),
|
||||
equalTo(Key.getKind(HostResource.class))));
|
||||
}})
|
||||
.size();
|
||||
assertThat(numReadsWithContactsOrHosts).isEqualTo(1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue