mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +02:00
Automatically refactor more exception testing to use new JUnit rules
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=179072309
This commit is contained in:
parent
d5d29959b4
commit
9157930983
100 changed files with 3900 additions and 3192 deletions
|
@ -408,8 +408,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
null,
|
||||
null);
|
||||
persistActiveHost(oldHostName());
|
||||
thrown.expect(CannotRenameExternalHostException.class);
|
||||
runFlow();
|
||||
assertThrows(CannotRenameExternalHostException.class, () -> runFlow());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -760,9 +759,9 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
public void testFailure_superordinateMissing() throws Exception {
|
||||
createTld("tld");
|
||||
persistActiveHost(oldHostName());
|
||||
thrown.expect(SuperordinateDomainDoesNotExistException.class);
|
||||
thrown.expectMessage("(example.tld)");
|
||||
runFlow();
|
||||
SuperordinateDomainDoesNotExistException thrown =
|
||||
expectThrows(SuperordinateDomainDoesNotExistException.class, () -> runFlow());
|
||||
assertThat(thrown).hasMessageThat().contains("(example.tld)");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -781,32 +780,34 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
.build());
|
||||
persistActiveSubordinateHost(oldHostName(), domain);
|
||||
clock.advanceOneMilli();
|
||||
thrown.expect(SuperordinateDomainInPendingDeleteException.class);
|
||||
thrown.expectMessage("Superordinate domain for this hostname is in pending delete");
|
||||
runFlow();
|
||||
SuperordinateDomainInPendingDeleteException thrown =
|
||||
expectThrows(SuperordinateDomainInPendingDeleteException.class, () -> runFlow());
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Superordinate domain for this hostname is in pending delete");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_neverExisted() throws Exception {
|
||||
thrown.expect(ResourceDoesNotExistException.class);
|
||||
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
runFlow();
|
||||
ResourceDoesNotExistException thrown =
|
||||
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_neverExisted_updateWithoutNameChange() throws Exception {
|
||||
setEppInput("host_update_name_unchanged.xml");
|
||||
thrown.expect(ResourceDoesNotExistException.class);
|
||||
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
runFlow();
|
||||
ResourceDoesNotExistException thrown =
|
||||
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_existedButWasDeleted() throws Exception {
|
||||
persistDeletedHost(oldHostName(), clock.nowUtc().minusDays(1));
|
||||
thrown.expect(ResourceDoesNotExistException.class);
|
||||
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
runFlow();
|
||||
ResourceDoesNotExistException thrown =
|
||||
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -815,9 +816,9 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
|
||||
clock.advanceOneMilli();
|
||||
setEppHostUpdateInput("ns1.example.tld", "ns1.example.tld", null, null);
|
||||
thrown.expect(HostAlreadyExistsException.class);
|
||||
thrown.expectMessage("ns1.example.tld");
|
||||
runFlow();
|
||||
HostAlreadyExistsException thrown =
|
||||
expectThrows(HostAlreadyExistsException.class, () -> runFlow());
|
||||
assertThat(thrown).hasMessageThat().contains("ns1.example.tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -825,57 +826,53 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
createTld("tld");
|
||||
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
|
||||
persistActiveHost("ns2.example.tld");
|
||||
thrown.expect(HostAlreadyExistsException.class);
|
||||
thrown.expectMessage("ns2.example.tld");
|
||||
runFlow();
|
||||
HostAlreadyExistsException thrown =
|
||||
expectThrows(HostAlreadyExistsException.class, () -> runFlow());
|
||||
assertThat(thrown).hasMessageThat().contains("ns2.example.tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_referToNonLowerCaseHostname() throws Exception {
|
||||
setEppHostUpdateInput("ns1.EXAMPLE.tld", "ns2.example.tld", null, null);
|
||||
thrown.expect(HostNameNotLowerCaseException.class);
|
||||
runFlow();
|
||||
assertThrows(HostNameNotLowerCaseException.class, () -> runFlow());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_renameToNonLowerCaseHostname() throws Exception {
|
||||
persistActiveHost("ns1.example.tld");
|
||||
setEppHostUpdateInput("ns1.example.tld", "ns2.EXAMPLE.tld", null, null);
|
||||
thrown.expect(HostNameNotLowerCaseException.class);
|
||||
runFlow();
|
||||
assertThrows(HostNameNotLowerCaseException.class, () -> runFlow());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_referToNonPunyCodedHostname() throws Exception {
|
||||
setEppHostUpdateInput("ns1.çauçalito.tld", "ns1.sausalito.tld", null, null);
|
||||
thrown.expect(HostNameNotPunyCodedException.class);
|
||||
thrown.expectMessage("expected ns1.xn--aualito-txac.tld");
|
||||
runFlow();
|
||||
HostNameNotPunyCodedException thrown =
|
||||
expectThrows(HostNameNotPunyCodedException.class, () -> runFlow());
|
||||
assertThat(thrown).hasMessageThat().contains("expected ns1.xn--aualito-txac.tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_renameToNonPunyCodedHostname() throws Exception {
|
||||
persistActiveHost("ns1.sausalito.tld");
|
||||
setEppHostUpdateInput("ns1.sausalito.tld", "ns1.çauçalito.tld", null, null);
|
||||
thrown.expect(HostNameNotPunyCodedException.class);
|
||||
thrown.expectMessage("expected ns1.xn--aualito-txac.tld");
|
||||
runFlow();
|
||||
HostNameNotPunyCodedException thrown =
|
||||
expectThrows(HostNameNotPunyCodedException.class, () -> runFlow());
|
||||
assertThat(thrown).hasMessageThat().contains("expected ns1.xn--aualito-txac.tld");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_referToNonCanonicalHostname() throws Exception {
|
||||
persistActiveHost("ns1.example.tld.");
|
||||
setEppHostUpdateInput("ns1.example.tld.", "ns2.example.tld", null, null);
|
||||
thrown.expect(HostNameNotNormalizedException.class);
|
||||
runFlow();
|
||||
assertThrows(HostNameNotNormalizedException.class, () -> runFlow());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_renameToNonCanonicalHostname() throws Exception {
|
||||
persistActiveHost("ns1.example.tld");
|
||||
setEppHostUpdateInput("ns1.example.tld", "ns2.example.tld.", null, null);
|
||||
thrown.expect(HostNameNotNormalizedException.class);
|
||||
runFlow();
|
||||
assertThrows(HostNameNotNormalizedException.class, () -> runFlow());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -887,8 +884,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
"<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
|
||||
createTld("tld");
|
||||
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
|
||||
thrown.expect(CannotRemoveSubordinateHostLastIpException.class);
|
||||
runFlow();
|
||||
assertThrows(CannotRemoveSubordinateHostLastIpException.class, () -> runFlow());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -900,8 +896,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
null);
|
||||
createTld("tld");
|
||||
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
|
||||
thrown.expect(RenameHostToExternalRemoveIpException.class);
|
||||
runFlow();
|
||||
assertThrows(RenameHostToExternalRemoveIpException.class, () -> runFlow());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -913,8 +908,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
null);
|
||||
createTld("tld");
|
||||
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
|
||||
thrown.expect(CannotAddIpToExternalHostException.class);
|
||||
runFlow();
|
||||
assertThrows(CannotAddIpToExternalHostException.class, () -> runFlow());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -927,8 +921,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
"<host:status s=\"clientUpdateProhibited\"/>",
|
||||
"<host:status s=\"clientUpdateProhibited\"/>");
|
||||
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
|
||||
thrown.expect(AddRemoveSameValueException.class);
|
||||
runFlow();
|
||||
assertThrows(AddRemoveSameValueException.class, () -> runFlow());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -940,8 +933,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
"ns2.example.tld",
|
||||
"<host:addr ip=\"v4\">192.0.2.22</host:addr>",
|
||||
"<host:addr ip=\"v4\">192.0.2.22</host:addr>");
|
||||
thrown.expect(AddRemoveSameValueException.class);
|
||||
runFlow();
|
||||
assertThrows(AddRemoveSameValueException.class, () -> runFlow());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -965,8 +957,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
|
||||
.setSuperordinateDomain(Key.create(persistActiveDomain("example.tld")))
|
||||
.build());
|
||||
thrown.expect(ResourceHasClientUpdateProhibitedException.class);
|
||||
runFlow();
|
||||
assertThrows(ResourceHasClientUpdateProhibitedException.class, () -> runFlow());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -977,9 +968,9 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
.setStatusValues(ImmutableSet.of(StatusValue.SERVER_UPDATE_PROHIBITED))
|
||||
.setSuperordinateDomain(Key.create(persistActiveDomain("example.tld")))
|
||||
.build());
|
||||
thrown.expect(ResourceStatusProhibitsOperationException.class);
|
||||
thrown.expectMessage("serverUpdateProhibited");
|
||||
runFlow();
|
||||
ResourceStatusProhibitsOperationException thrown =
|
||||
expectThrows(ResourceStatusProhibitsOperationException.class, () -> runFlow());
|
||||
assertThat(thrown).hasMessageThat().contains("serverUpdateProhibited");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -990,9 +981,9 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
|
||||
.setSuperordinateDomain(Key.create(persistActiveDomain("example.tld")))
|
||||
.build());
|
||||
thrown.expect(ResourceStatusProhibitsOperationException.class);
|
||||
thrown.expectMessage("pendingDelete");
|
||||
runFlow();
|
||||
ResourceStatusProhibitsOperationException thrown =
|
||||
expectThrows(ResourceStatusProhibitsOperationException.class, () -> runFlow());
|
||||
assertThat(thrown).hasMessageThat().contains("pendingDelete");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1000,8 +991,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
createTld("tld");
|
||||
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
|
||||
setEppInput("host_update_prohibited_status.xml");
|
||||
thrown.expect(StatusNotClientSettableException.class);
|
||||
runFlow();
|
||||
assertThrows(StatusNotClientSettableException.class, () -> runFlow());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1022,8 +1012,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
public void testFailure_unauthorizedClient() throws Exception {
|
||||
sessionMetadata.setClientId("NewRegistrar");
|
||||
persistActiveHost("ns1.example.tld");
|
||||
thrown.expect(ResourceNotOwnedException.class);
|
||||
runFlow();
|
||||
assertThrows(ResourceNotOwnedException.class, () -> runFlow());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1070,8 +1059,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
.setInetAddresses(ImmutableSet.of(InetAddresses.forString("127.0.0.1")))
|
||||
.build());
|
||||
|
||||
thrown.expect(ResourceNotOwnedException.class);
|
||||
runFlow();
|
||||
assertThrows(ResourceNotOwnedException.class, () -> runFlow());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1104,8 +1092,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
.setInetAddresses(ImmutableSet.of(InetAddresses.forString("127.0.0.1")))
|
||||
.build());
|
||||
|
||||
thrown.expect(ResourceNotOwnedException.class);
|
||||
runFlow();
|
||||
assertThrows(ResourceNotOwnedException.class, () -> runFlow());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1125,8 +1112,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.foo"));
|
||||
assertAboutHosts().that(host).hasPersistedCurrentSponsorClientId("TheRegistrar");
|
||||
|
||||
thrown.expect(HostDomainNotOwnedException.class);
|
||||
runFlow();
|
||||
assertThrows(HostDomainNotOwnedException.class, () -> runFlow());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1146,8 +1132,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
assertAboutDomains().that(domain).hasPersistedCurrentSponsorClientId("TheRegistrar");
|
||||
assertAboutHosts().that(host).hasPersistedCurrentSponsorClientId("TheRegistrar");
|
||||
|
||||
thrown.expect(HostDomainNotOwnedException.class);
|
||||
runFlow();
|
||||
assertThrows(HostDomainNotOwnedException.class, () -> runFlow());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue