Add a test for Registrar.loadByClientId not being enrolled in a transaction

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=154470388
This commit is contained in:
cgoldfeder 2017-04-27 14:30:09 -07:00 committed by Ben McIlwain
parent 8025c7547b
commit d4d02f8977

View file

@ -30,6 +30,8 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.VoidWork;
import google.registry.model.EntityTestCase;
import google.registry.model.common.EntityGroupRoot;
import google.registry.model.registrar.Registrar.State;
@ -375,4 +377,21 @@ public class RegistrarTest extends EntityTestCase {
thrown.expect(IllegalArgumentException.class);
new Registrar.Builder().setPhonePasscode("code1");
}
@Test
public void testLoadByClientId_isTransactionless() {
ofy().transact(new VoidWork() {
@Override
public void vrun() {
assertThat(Registrar.loadByClientId("registrar")).isNotNull();
// Load something as a control to make sure we are seeing loaded keys in the session cache.
ofy().load().entity(abuseAdminContact).now();
assertThat(ofy().getSessionKeys()).contains(Key.create(abuseAdminContact));
assertThat(ofy().getSessionKeys()).doesNotContain(Key.create(registrar));
}});
ofy().clearSessionCache();
// Conversely, loads outside of a transaction should end up in the session cache.
assertThat(Registrar.loadByClientId("registrar")).isNotNull();
assertThat(ofy().getSessionKeys()).contains(Key.create(registrar));
}
}