mirror of
https://github.com/google/nomulus
synced 2026-01-08 15:21:46 +00:00
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:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user