Change nested transact calls to retransact (#2563)

This commit is contained in:
Weimin Yu
2024-09-20 15:16:52 +00:00
committed by GitHub
parent e167b4b753
commit 4ba0f4a2cd
9 changed files with 31 additions and 29 deletions
@@ -19,6 +19,7 @@ import static google.registry.model.registrar.RegistrarPocBase.Type.ABUSE;
import static google.registry.model.registrar.RegistrarPocBase.Type.ADMIN;
import static google.registry.model.registrar.RegistrarPocBase.Type.TECH;
import static google.registry.model.registrar.RegistrarPocBase.Type.WHOIS;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import static google.registry.testing.DatabaseHelper.loadRegistrar;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DatabaseHelper.persistSimpleResource;
@@ -49,16 +50,18 @@ class RegistrarPocCommandTest extends CommandTestCase<RegistrarPocCommand> {
@Test
void testList() throws Exception {
Registrar registrar = loadRegistrar("NewRegistrar");
RegistrarPoc.updateContacts(
registrar,
ImmutableSet.of(
new RegistrarPoc.Builder()
.setRegistrar(registrar)
.setName("John Doe")
.setEmailAddress("john.doe@example.com")
.setTypes(ImmutableSet.of(ADMIN))
.setVisibleInWhoisAsAdmin(true)
.build()));
tm().transact(
() ->
RegistrarPoc.updateContacts(
registrar,
ImmutableSet.of(
new RegistrarPoc.Builder()
.setRegistrar(registrar)
.setName("John Doe")
.setEmailAddress("john.doe@example.com")
.setTypes(ImmutableSet.of(ADMIN))
.setVisibleInWhoisAsAdmin(true)
.build())));
runCommandForced("--mode=LIST", "--output=" + output, "NewRegistrar");
assertThat(Files.readAllLines(Paths.get(output), UTF_8))
.containsExactly(