From d4d02f89773c1335c83610d538cf571535ad6ef0 Mon Sep 17 00:00:00 2001 From: cgoldfeder Date: Thu, 27 Apr 2017 14:30:09 -0700 Subject: [PATCH] Add a test for Registrar.loadByClientId not being enrolled in a transaction ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=154470388 --- .../model/registrar/RegistrarTest.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/javatests/google/registry/model/registrar/RegistrarTest.java b/javatests/google/registry/model/registrar/RegistrarTest.java index 9e2ca33b1..ed6122753 100644 --- a/javatests/google/registry/model/registrar/RegistrarTest.java +++ b/javatests/google/registry/model/registrar/RegistrarTest.java @@ -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)); + } }