diff --git a/javatests/google/registry/flows/host/HostCheckFlowTest.java b/javatests/google/registry/flows/host/HostCheckFlowTest.java index df00b6132..b62824aca 100644 --- a/javatests/google/registry/flows/host/HostCheckFlowTest.java +++ b/javatests/google/registry/flows/host/HostCheckFlowTest.java @@ -17,8 +17,10 @@ package google.registry.flows.host; import static google.registry.model.eppoutput.CheckData.HostCheck.create; import static google.registry.testing.DatastoreHelper.persistActiveHost; import static google.registry.testing.DatastoreHelper.persistDeletedHost; -import static google.registry.testing.JUnitBackports.assertThrows; +import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; +import static google.registry.testing.JUnitBackports.expectThrows; +import google.registry.flows.EppException; import google.registry.flows.ResourceCheckFlowTestCase; import google.registry.flows.exceptions.TooManyResourceChecksException; import google.registry.model.host.HostResource; @@ -76,7 +78,8 @@ public class HostCheckFlowTest extends ResourceCheckFlowTestCase192.0.2.2\n" + "192.0.2.29\n" + "1080:0:0:0:8:800:200C:417A"); - assertThrows(IpAddressVersionMismatchException.class, this::runFlow); + EppException thrown = expectThrows(IpAddressVersionMismatchException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } - private void doFailingHostNameTest(String hostName, Class exception) + private void doFailingHostNameTest(String hostName, Class exception) throws Exception { setEppHostCreateInputWithIps(hostName); - assertThrows(exception, this::runFlow); + EppException thrown = expectThrows(exception, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test @@ -279,7 +289,8 @@ public class HostCreateFlowTest extends ResourceFlowTestCase oldFkiBeforeRename = - ForeignKeyIndex.load( - HostResource.class, oldHostName(), clock.nowUtc().minusMillis(1)); + ForeignKeyIndex.load(HostResource.class, oldHostName(), clock.nowUtc().minusMillis(1)); assertThat(oldFkiBeforeRename.getResourceKey()).isEqualTo(Key.create(renamedHost)); assertThat(oldFkiBeforeRename.getDeletionTime()).isEqualTo(clock.nowUtc()); ForeignKeyIndex oldFkiAfterRename = @@ -185,7 +192,8 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase1080:0:0:0:8:800:200C:417A"); createTld("tld"); DomainResource example = persistActiveDomain("example.tld"); - DomainResource foo = persistResource(newDomainResource("foo.tld").asBuilder() - .setSubordinateHosts(ImmutableSet.of(oldHostName())) - .build()); + DomainResource foo = + persistResource( + newDomainResource("foo.tld") + .asBuilder() + .setSubordinateHosts(ImmutableSet.of(oldHostName())) + .build()); persistActiveSubordinateHost(oldHostName(), foo); assertThat(foo.getSubordinateHosts()).containsExactly("ns2.foo.tld"); assertThat(example.getSubordinateHosts()).isEmpty(); HostResource renamedHost = doSuccessfulTest(); DateTime now = clock.nowUtc(); - assertAboutHosts().that(renamedHost) - .hasSuperordinateDomain(Key.create(example)).and() - .hasLastSuperordinateChange(now).and() - .hasPersistedCurrentSponsorClientId("TheRegistrar").and() + assertAboutHosts() + .that(renamedHost) + .hasSuperordinateDomain(Key.create(example)) + .and() + .hasLastSuperordinateChange(now) + .and() + .hasPersistedCurrentSponsorClientId("TheRegistrar") + .and() .hasLastTransferTime(null); assertThat(ofy().load().entity(foo).now().cloneProjectedAtTime(now).getSubordinateHosts()) .isEmpty(); @@ -306,19 +336,26 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase1080:0:0:0:8:800:200C:417A"); createTld("foo"); createTld("tld"); - DomainResource fooDomain = persistResource(newDomainResource("example.foo").asBuilder() - .setSubordinateHosts(ImmutableSet.of(oldHostName())) - .build()); + DomainResource fooDomain = + persistResource( + newDomainResource("example.foo") + .asBuilder() + .setSubordinateHosts(ImmutableSet.of(oldHostName())) + .build()); DomainResource tldDomain = persistActiveDomain("example.tld"); persistActiveSubordinateHost(oldHostName(), fooDomain); assertThat(fooDomain.getSubordinateHosts()).containsExactly("ns1.example.foo"); assertThat(tldDomain.getSubordinateHosts()).isEmpty(); HostResource renamedHost = doSuccessfulTest(); DateTime now = clock.nowUtc(); - assertAboutHosts().that(renamedHost) - .hasSuperordinateDomain(Key.create(tldDomain)).and() - .hasLastSuperordinateChange(now).and() - .hasPersistedCurrentSponsorClientId("TheRegistrar").and() + assertAboutHosts() + .that(renamedHost) + .hasSuperordinateDomain(Key.create(tldDomain)) + .and() + .hasLastSuperordinateChange(now) + .and() + .hasPersistedCurrentSponsorClientId("TheRegistrar") + .and() .hasLastTransferTime(null); DomainResource reloadedFooDomain = ofy().load().entity(fooDomain).now().cloneProjectedAtTime(now); @@ -337,23 +374,32 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase1080:0:0:0:8:800:200C:417A"); createTld("foo"); - DomainResource domain = persistResource(newDomainResource("example.foo").asBuilder() - .setSubordinateHosts(ImmutableSet.of(oldHostName())) - .build()); + DomainResource domain = + persistResource( + newDomainResource("example.foo") + .asBuilder() + .setSubordinateHosts(ImmutableSet.of(oldHostName())) + .build()); assertThat(domain.getCurrentSponsorClientId()).isEqualTo("TheRegistrar"); DateTime oneDayAgo = clock.nowUtc().minusDays(1); - HostResource oldHost = persistResource( - persistActiveSubordinateHost(oldHostName(), domain).asBuilder() - .setPersistedCurrentSponsorClientId("ClientThatShouldBeSupersededByDomainClient") - .setLastTransferTime(oneDayAgo) - .build()); + HostResource oldHost = + persistResource( + persistActiveSubordinateHost(oldHostName(), domain) + .asBuilder() + .setPersistedCurrentSponsorClientId("ClientThatShouldBeSupersededByDomainClient") + .setLastTransferTime(oneDayAgo) + .build()); assertThat(oldHost.isSubordinate()).isTrue(); assertThat(domain.getSubordinateHosts()).containsExactly("ns1.example.foo"); HostResource renamedHost = doSuccessfulTest(); - assertAboutHosts().that(renamedHost) - .hasSuperordinateDomain(null).and() - .hasPersistedCurrentSponsorClientId("TheRegistrar").and() - .hasLastTransferTime(oneDayAgo).and() + assertAboutHosts() + .that(renamedHost) + .hasSuperordinateDomain(null) + .and() + .hasPersistedCurrentSponsorClientId("TheRegistrar") + .and() + .hasLastTransferTime(oneDayAgo) + .and() .hasLastSuperordinateChange(clock.nowUtc()); assertThat(renamedHost.getLastTransferTime()).isEqualTo(oneDayAgo); DomainResource reloadedDomain = @@ -365,10 +411,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase192.0.2.22", - null); + "ns1.example.foo", "ns2.example.tld", "192.0.2.22", null); createTld("tld"); DomainResource domain = persistActiveDomain("example.tld"); persistActiveHost(oldHostName()); @@ -380,20 +423,21 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase192.0.2.22", - null); + "ns1.example.foo", "ns2.example.tld", "192.0.2.22", null); createTld("tld"); DomainResource domain = persistActiveDomain("example.tld"); persistActiveHost(oldHostName()); assertThat(domain.getSubordinateHosts()).isEmpty(); HostResource renamedHost = doSuccessfulTestAsSuperuser(); DateTime now = clock.nowUtc(); - assertAboutHosts().that(renamedHost) - .hasSuperordinateDomain(Key.create(domain)).and() - .hasLastSuperordinateChange(now).and() - .hasPersistedCurrentSponsorClientId("TheRegistrar").and() + assertAboutHosts() + .that(renamedHost) + .hasSuperordinateDomain(Key.create(domain)) + .and() + .hasLastSuperordinateChange(now) + .and() + .hasPersistedCurrentSponsorClientId("TheRegistrar") + .and() .hasLastTransferTime(null); assertThat(ofy().load().entity(domain).now().cloneProjectedAtTime(now).getSubordinateHosts()) .containsExactly("ns2.example.tld"); @@ -402,28 +446,25 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase1080:0:0:0:8:800:200C:417A"); createTld("tld"); DateTime lastTransferTime = clock.nowUtc().minusDays(5); - DomainResource foo = newDomainResource("foo.tld").asBuilder() - .setLastTransferTime(lastTransferTime) - .build(); + DomainResource foo = + newDomainResource("foo.tld").asBuilder().setLastTransferTime(lastTransferTime).build(); // Set the new domain to have a last transfer time that is different than the last transfer // time on the host in question. persistResource( - newDomainResource("example.tld").asBuilder() + newDomainResource("example.tld") + .asBuilder() .setLastTransferTime(clock.nowUtc().minusDays(10)) .build()); persistResource( - newHostResource(oldHostName()).asBuilder() + newHostResource(oldHostName()) + .asBuilder() .setSuperordinateDomain(Key.create(foo)) .setLastTransferTime(null) .build()); - persistResource( - foo.asBuilder() - .setSubordinateHosts(ImmutableSet.of(oldHostName())) - .build()); + persistResource(foo.asBuilder().setSubordinateHosts(ImmutableSet.of(oldHostName())).build()); clock.advanceOneMilli(); HostResource renamedHost = doSuccessfulTest(); - assertAboutHosts().that(renamedHost) - .hasPersistedCurrentSponsorClientId("TheRegistrar").and() + assertAboutHosts() + .that(renamedHost) + .hasPersistedCurrentSponsorClientId("TheRegistrar") + .and() .hasLastTransferTime(lastTransferTime); } @Test - public void testSuccess_subordToSubord_lastTransferTimeOnExistingHostWinsOut() - throws Exception { + public void testSuccess_subordToSubord_lastTransferTimeOnExistingHostWinsOut() throws Exception { setEppHostUpdateInput( "ns2.foo.tld", "ns2.example.tld", "192.0.2.22", "1080:0:0:0:8:800:200C:417A"); createTld("tld"); - DomainResource domain = newDomainResource("foo.tld").asBuilder() - .setLastTransferTime(clock.nowUtc().minusDays(5)) - .build(); + DomainResource domain = + newDomainResource("foo.tld") + .asBuilder() + .setLastTransferTime(clock.nowUtc().minusDays(5)) + .build(); // Set the new domain to have a last transfer time that is different than the last transfer // time on the host in question. persistResource( - newDomainResource("example.tld").asBuilder() + newDomainResource("example.tld") + .asBuilder() .setLastTransferTime(clock.nowUtc().minusDays(10)) .build()); - HostResource host = persistResource( - newHostResource(oldHostName()).asBuilder() - .setSuperordinateDomain(Key.create(domain)) - .setLastTransferTime(clock.nowUtc().minusDays(20)) - .setLastSuperordinateChange(clock.nowUtc().minusDays(3)) - .build()); + HostResource host = + persistResource( + newHostResource(oldHostName()) + .asBuilder() + .setSuperordinateDomain(Key.create(domain)) + .setLastTransferTime(clock.nowUtc().minusDays(20)) + .setLastSuperordinateChange(clock.nowUtc().minusDays(3)) + .build()); DateTime lastTransferTime = host.getLastTransferTime(); - persistResource( - domain.asBuilder().setSubordinateHosts(ImmutableSet.of(oldHostName())).build()); + persistResource(domain.asBuilder().setSubordinateHosts(ImmutableSet.of(oldHostName())).build()); HostResource renamedHost = doSuccessfulTest(); - assertAboutHosts().that(renamedHost) - .hasPersistedCurrentSponsorClientId("TheRegistrar").and() + assertAboutHosts() + .that(renamedHost) + .hasPersistedCurrentSponsorClientId("TheRegistrar") + .and() .hasLastTransferTime(lastTransferTime); } @@ -525,28 +574,29 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase192.0.2.22", "1080:0:0:0:8:800:200C:417A"); createTld("tld"); - DomainResource foo = newDomainResource("foo.tld").asBuilder() - .setLastTransferTime(clock.nowUtc().minusDays(5)) - .build(); + DomainResource foo = + newDomainResource("foo.tld") + .asBuilder() + .setLastTransferTime(clock.nowUtc().minusDays(5)) + .build(); // Set the new domain to have a null last transfer time. - persistResource( - newDomainResource("example.tld").asBuilder().setLastTransferTime(null).build()); + persistResource(newDomainResource("example.tld").asBuilder().setLastTransferTime(null).build()); DateTime lastTransferTime = clock.nowUtc().minusDays(20); persistResource( - newHostResource(oldHostName()).asBuilder() + newHostResource(oldHostName()) + .asBuilder() .setSuperordinateDomain(Key.create(foo)) .setLastTransferTime(lastTransferTime) .setLastSuperordinateChange(clock.nowUtc().minusDays(3)) .build()); - persistResource( - foo.asBuilder() - .setSubordinateHosts(ImmutableSet.of(oldHostName())) - .build()); + persistResource(foo.asBuilder().setSubordinateHosts(ImmutableSet.of(oldHostName())).build()); clock.advanceOneMilli(); HostResource renamedHost = doSuccessfulTest(); - assertAboutHosts().that(renamedHost) - .hasPersistedCurrentSponsorClientId("TheRegistrar").and() + assertAboutHosts() + .that(renamedHost) + .hasPersistedCurrentSponsorClientId("TheRegistrar") + .and() .hasLastTransferTime(lastTransferTime); } @@ -559,61 +609,56 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase192.0.2.22", "1080:0:0:0:8:800:200C:417A"); createTld("tld"); - DomainResource foo = newDomainResource("foo.tld").asBuilder() - .setLastTransferTime(null) - .build(); + DomainResource foo = newDomainResource("foo.tld").asBuilder().setLastTransferTime(null).build(); // Set the new domain to have a null last transfer time. - persistResource( - newDomainResource("example.tld").asBuilder() - .setLastTransferTime(null) - .build()); + persistResource(newDomainResource("example.tld").asBuilder().setLastTransferTime(null).build()); DateTime lastTransferTime = clock.nowUtc().minusDays(20); persistResource( - newHostResource(oldHostName()).asBuilder() + newHostResource(oldHostName()) + .asBuilder() .setSuperordinateDomain(Key.create(foo)) .setLastTransferTime(lastTransferTime) .setLastSuperordinateChange(clock.nowUtc().minusDays(10)) .build()); - persistResource( - foo.asBuilder() - .setSubordinateHosts(ImmutableSet.of(oldHostName())) - .build()); + persistResource(foo.asBuilder().setSubordinateHosts(ImmutableSet.of(oldHostName())).build()); clock.advanceOneMilli(); HostResource renamedHost = doSuccessfulTest(); - assertAboutHosts().that(renamedHost) - .hasPersistedCurrentSponsorClientId("TheRegistrar").and() + assertAboutHosts() + .that(renamedHost) + .hasPersistedCurrentSponsorClientId("TheRegistrar") + .and() .hasLastTransferTime(lastTransferTime); } @Test - public void testSuccess_subordToSubord_lastTransferTimeIsNull_whenNullOnBoth() - throws Exception { + public void testSuccess_subordToSubord_lastTransferTimeIsNull_whenNullOnBoth() throws Exception { setEppHostUpdateInput( "ns2.foo.tld", "ns2.example.tld", "192.0.2.22", "1080:0:0:0:8:800:200C:417A"); createTld("tld"); - DomainResource foo = newDomainResource("foo.tld").asBuilder() - .setLastTransferTime(clock.nowUtc().minusDays(5)) - .build(); + DomainResource foo = + newDomainResource("foo.tld") + .asBuilder() + .setLastTransferTime(clock.nowUtc().minusDays(5)) + .build(); // Set the new domain to have a null last transfer time. + persistResource(newDomainResource("example.tld").asBuilder().setLastTransferTime(null).build()); persistResource( - newDomainResource("example.tld").asBuilder() - .setLastTransferTime(null) - .build()); - persistResource( - newHostResource(oldHostName()).asBuilder() + newHostResource(oldHostName()) + .asBuilder() .setSuperordinateDomain(Key.create(foo)) .setLastTransferTime(null) .setLastSuperordinateChange(clock.nowUtc().minusDays(3)) .build()); - persistResource( - foo.asBuilder().setSubordinateHosts(ImmutableSet.of(oldHostName())).build()); + persistResource(foo.asBuilder().setSubordinateHosts(ImmutableSet.of(oldHostName())).build()); HostResource renamedHost = doSuccessfulTest(); - assertAboutHosts().that(renamedHost) - .hasPersistedCurrentSponsorClientId("TheRegistrar").and() + assertAboutHosts() + .that(renamedHost) + .hasPersistedCurrentSponsorClientId("TheRegistrar") + .and() .hasLastTransferTime(null); } @@ -628,26 +673,28 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase192.0.2.22", - null); + "ns1.example.foo", "ns2.example.tld", "192.0.2.22", null); createTld("tld"); persistResource( - newDomainResource("example.tld").asBuilder() + newDomainResource("example.tld") + .asBuilder() .setLastTransferTime(domainTransferTime) .build()); persistResource( - newHostResource(oldHostName()).asBuilder() - .setLastTransferTime(hostTransferTime) - .build()); + newHostResource(oldHostName()).asBuilder().setLastTransferTime(hostTransferTime).build()); HostResource renamedHost = doSuccessfulTestAsSuperuser(); - assertAboutHosts().that(renamedHost) - .hasPersistedCurrentSponsorClientId("TheRegistrar").and() + assertAboutHosts() + .that(renamedHost) + .hasPersistedCurrentSponsorClientId("TheRegistrar") + .and() .hasLastTransferTime(hostTransferTime); } @@ -772,12 +826,14 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase192.0.2.22", "1080:0:0:0:8:800:200C:417A"); createTld("tld"); - DomainResource domain = persistResource(newDomainResource("example.tld") - .asBuilder() - .setSubordinateHosts(ImmutableSet.of(oldHostName())) - .setDeletionTime(clock.nowUtc().plusDays(35)) - .setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE)) - .build()); + DomainResource domain = + persistResource( + newDomainResource("example.tld") + .asBuilder() + .setSubordinateHosts(ImmutableSet.of(oldHostName())) + .setDeletionTime(clock.nowUtc().plusDays(35)) + .setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE)) + .build()); persistActiveSubordinateHost(oldHostName(), domain); clock.advanceOneMilli(); SuperordinateDomainInPendingDeleteException thrown = @@ -834,14 +890,16 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase1080:0:0:0:8:800:200C:417A"); createTld("tld"); persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld")); - assertThrows(CannotRemoveSubordinateHostLastIpException.class, this::runFlow); + EppException thrown = + expectThrows(CannotRemoveSubordinateHostLastIpException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_subordinateToExternal_mustRemoveAllIps() throws Exception { - setEppHostUpdateInput( - "ns1.example.tld", - "ns2.example.com", - null, - null); + setEppHostUpdateInput("ns1.example.tld", "ns2.example.com", null, null); createTld("tld"); persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld")); - assertThrows(RenameHostToExternalRemoveIpException.class, this::runFlow); + EppException thrown = expectThrows(RenameHostToExternalRemoveIpException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_subordinateToExternal_cantAddAnIp() throws Exception { setEppHostUpdateInput( - "ns1.example.tld", - "ns2.example.com", - "192.0.2.22", - null); + "ns1.example.tld", "ns2.example.com", "192.0.2.22", null); createTld("tld"); persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld")); - assertThrows(CannotAddIpToExternalHostException.class, this::runFlow); + EppException thrown = expectThrows(CannotAddIpToExternalHostException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test @@ -921,7 +978,8 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase", ""); persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld")); - assertThrows(AddRemoveSameValueException.class, this::runFlow); + EppException thrown = expectThrows(AddRemoveSameValueException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test @@ -933,19 +991,22 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase192.0.2.22", "192.0.2.22"); - assertThrows(AddRemoveSameValueException.class, this::runFlow); + EppException thrown = expectThrows(AddRemoveSameValueException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testSuccess_clientUpdateProhibited_removed() throws Exception { setEppInput("host_update_remove_client_update_prohibited.xml"); persistResource( - newHostResource(oldHostName()).asBuilder() + newHostResource(oldHostName()) + .asBuilder() .setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED)) .build()); clock.advanceOneMilli(); runFlow(); - assertAboutEppResources().that(reloadResourceByForeignKey()) + assertAboutEppResources() + .that(reloadResourceByForeignKey()) .doesNotHaveStatusValue(StatusValue.CLIENT_UPDATE_PROHIBITED); } @@ -953,18 +1014,22 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase192.0.2.22", - null); + "ns1.example.foo", "ns2.example.tld", "192.0.2.22", null); sessionMetadata.setClientId("TheRegistrar"); createTld("foo"); createTld("tld"); - persistResource(newDomainResource("example.tld").asBuilder() - .setPersistedCurrentSponsorClientId("NewRegistar") - .build()); + persistResource( + newDomainResource("example.tld") + .asBuilder() + .setPersistedCurrentSponsorClientId("NewRegistar") + .build()); HostResource host = persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.foo")); assertAboutHosts().that(host).hasPersistedCurrentSponsorClientId("TheRegistrar"); - assertThrows(HostDomainNotOwnedException.class, this::runFlow); + EppException thrown = expectThrows(HostDomainNotOwnedException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_newSuperordinateWasTransferredToDifferentRegistrar() throws Exception { setEppHostUpdateInput( - "ns1.example.foo", - "ns2.example.tld", - "192.0.2.22", - null); + "ns1.example.foo", "ns2.example.tld", "192.0.2.22", null); sessionMetadata.setClientId("TheRegistrar"); createTld("foo"); createTld("tld"); @@ -1132,44 +1205,47 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase192.0.2.22", - null); + "ns1.example.foo", "ns2.example.tld", "192.0.2.22", null); sessionMetadata.setClientId("NewRegistrar"); createTld("foo"); createTld("tld"); // The domain will belong to NewRegistrar after cloneProjectedAtTime is called. DomainResource domain = persistResource(createDomainWithServerApprovedTransfer("example.tld")); - DomainResource superordinate = persistResource(newDomainResource("example.foo").asBuilder() - .setPersistedCurrentSponsorClientId("NewRegistrar") - .build()); + DomainResource superordinate = + persistResource( + newDomainResource("example.foo") + .asBuilder() + .setPersistedCurrentSponsorClientId("NewRegistrar") + .build()); assertAboutDomains().that(domain).hasPersistedCurrentSponsorClientId("TheRegistrar"); - persistResource(newHostResource("ns1.example.foo").asBuilder() - .setSuperordinateDomain(Key.create(superordinate)) - .setPersistedCurrentSponsorClientId("NewRegistrar") - .build()); + persistResource( + newHostResource("ns1.example.foo") + .asBuilder() + .setSuperordinateDomain(Key.create(superordinate)) + .setPersistedCurrentSponsorClientId("NewRegistrar") + .build()); clock.advanceOneMilli(); runFlowAssertResponse(loadFile("host_update_response.xml")); } - private void doFailingHostNameTest( - String hostName, - Class exception) throws Exception { + private void doFailingHostNameTest(String hostName, Class exception) + throws Exception { persistActiveHost(oldHostName()); setEppHostUpdateInput( "ns1.example.tld", hostName, "192.0.2.22", "1080:0:0:0:8:800:200C:417A"); - assertThrows(exception, this::runFlow); + EppException thrown = expectThrows(exception, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test @@ -1230,9 +1306,10 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase