mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 16:37:13 +02:00
Get rid of custom ExceptionRule methods
The only remaining methods on ExceptionRule after this are methods that also exist on ExpectedException, which will allow us to, in the next CL, swap out the one for the other and then run the automated refactoring to turn it all into assertThrows/expectThrows. Note that there were some assertions about root causes that couldn't easily be turned into ExpectedException invocations, so I simply converted them directly to usages of assertThrows/expectThrows. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=178623431
This commit is contained in:
parent
68a26f5b6e
commit
b825a2b5a8
144 changed files with 1176 additions and 894 deletions
|
@ -464,42 +464,45 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_invalidAddGracePeriod() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "Invalid format: \"5m\"");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Invalid format: \"5m\"");
|
||||
runCommandForced("--add_grace_period=5m", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidRedemptionGracePeriod() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "Invalid format: \"5m\"");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Invalid format: \"5m\"");
|
||||
runCommandForced("--redemption_grace_period=5m", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidPendingDeleteLength() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "Invalid format: \"5m\"");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Invalid format: \"5m\"");
|
||||
runCommandForced("--pending_delete_length=5m", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidTldState() throws Exception {
|
||||
thrown.expect(
|
||||
ParameterException.class,
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage(
|
||||
"INVALID_STATE not formatted correctly or has transition times out of order");
|
||||
runCommandForced("--tld_state_transitions=" + START_OF_TIME + "=INVALID_STATE", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_invalidTldStateTransitionTime() throws Exception {
|
||||
thrown.expect(
|
||||
ParameterException.class,
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage(
|
||||
"INVALID_STATE not formatted correctly or has transition times out of order");
|
||||
runCommandForced("--tld_state_transitions=tomorrow=INVALID_STATE", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_tldStatesOutOfOrder() throws Exception {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class, "The TLD states are chronologically out of order");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("The TLD states are chronologically out of order");
|
||||
runCommandForced(
|
||||
String.format(
|
||||
"--tld_state_transitions=%s=SUNRISE,%s=PREDELEGATION", now, now.plusMonths(1)),
|
||||
|
@ -508,9 +511,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_duplicateTldStateTransitions() throws Exception {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
"The TLD states are chronologically out of order");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("The TLD states are chronologically out of order");
|
||||
runCommandForced(
|
||||
String.format("--tld_state_transitions=%s=SUNRISE,%s=SUNRISE", now, now.plusMonths(1)),
|
||||
"xn--q9jyb4c");
|
||||
|
@ -518,8 +520,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_duplicateTldStateTransitionTimes() throws Exception {
|
||||
thrown.expect(
|
||||
ParameterException.class, "not formatted correctly or has transition times out of order");
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("not formatted correctly or has transition times out of order");
|
||||
runCommandForced(
|
||||
String.format("--tld_state_transitions=%s=PREDELEGATION,%s=SUNRISE", now, now),
|
||||
"xn--q9jyb4c");
|
||||
|
@ -527,8 +529,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_outOfOrderTldStateTransitionTimes() throws Exception {
|
||||
thrown.expect(
|
||||
ParameterException.class, "not formatted correctly or has transition times out of order");
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("not formatted correctly or has transition times out of order");
|
||||
runCommandForced(
|
||||
String.format(
|
||||
"--tld_state_transitions=%s=PREDELEGATION,%s=SUNRISE",
|
||||
|
@ -538,9 +540,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_bothTldStateFlags() throws Exception {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
"Don't pass both --set_current_tld_state and --tld_state_transitions");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Don't pass both --set_current_tld_state and --tld_state_transitions");
|
||||
runCommandForced(
|
||||
String.format("--tld_state_transitions=%s=PREDELEGATION,%s=SUNRISE", now, now.plusDays(1)),
|
||||
"--set_current_tld_state=GENERAL_AVAILABILITY",
|
||||
|
@ -556,8 +557,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
START_OF_TIME, TldState.PREDELEGATION,
|
||||
now.minusMonths(1), TldState.GENERAL_AVAILABILITY))
|
||||
.build());
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class, "The TLD states are chronologically out of order");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("The TLD states are chronologically out of order");
|
||||
runCommandForced("--set_current_tld_state=SUNRISE", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
|
@ -570,9 +571,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
START_OF_TIME, TldState.PREDELEGATION,
|
||||
now.plusMonths(1), TldState.GENERAL_AVAILABILITY))
|
||||
.build());
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
" when there is a later transition already scheduled");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage(" when there is a later transition already scheduled");
|
||||
runCommandForced("--set_current_tld_state=SUNRISE", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
|
@ -585,9 +585,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
START_OF_TIME, TldState.PREDELEGATION,
|
||||
now.minusMonths(1), TldState.GENERAL_AVAILABILITY))
|
||||
.build());
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
"--set_current_tld_state is not safe to use in production.");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("--set_current_tld_state is not safe to use in production.");
|
||||
runCommandInEnvironment(
|
||||
RegistryToolEnvironment.PRODUCTION,
|
||||
"--set_current_tld_state=SUNRISE",
|
||||
|
@ -597,15 +596,16 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_invalidRenewBillingCost() throws Exception {
|
||||
thrown.expect(
|
||||
ParameterException.class, "not formatted correctly or has transition times out of order");
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("not formatted correctly or has transition times out of order");
|
||||
runCommandForced(
|
||||
String.format("--renew_billing_cost_transitions=%s=US42", START_OF_TIME), "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_negativeRenewBillingCost() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "Renew billing cost cannot be negative");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Renew billing cost cannot be negative");
|
||||
runCommandForced(
|
||||
String.format("--renew_billing_cost_transitions=%s=USD-42", START_OF_TIME),
|
||||
"xn--q9jyb4c");
|
||||
|
@ -613,15 +613,15 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_invalidRenewCostTransitionTime() throws Exception {
|
||||
thrown.expect(
|
||||
ParameterException.class, "not formatted correctly or has transition times out of order");
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("not formatted correctly or has transition times out of order");
|
||||
runCommandForced("--renew_billing_cost_transitions=tomorrow=USD 1", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_duplicateRenewCostTransitionTimes() throws Exception {
|
||||
thrown.expect(
|
||||
ParameterException.class, "not formatted correctly or has transition times out of order");
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("not formatted correctly or has transition times out of order");
|
||||
runCommandForced(
|
||||
String.format("--renew_billing_cost_transitions=\"%s=USD 1,%s=USD 2\"", now, now),
|
||||
"xn--q9jyb4c");
|
||||
|
@ -629,8 +629,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_outOfOrderRenewCostTransitionTimes() throws Exception {
|
||||
thrown.expect(
|
||||
ParameterException.class, "not formatted correctly or has transition times out of order");
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("not formatted correctly or has transition times out of order");
|
||||
runCommandForced(
|
||||
String.format(
|
||||
"--renew_billing_cost_transitions=\"%s=USD 1,%s=USD 2\"",
|
||||
|
@ -640,40 +640,43 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_noTldName() throws Exception {
|
||||
thrown.expect(ParameterException.class, "Main parameters are required (\"Names of the TLDs\")");
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("Main parameters are required (\"Names of the TLDs\")");
|
||||
runCommandForced();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_oneTldDoesNotExist() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "TLD foo does not exist");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("TLD foo does not exist");
|
||||
runCommandForced("foo", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_duplicateArguments() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "Duplicate arguments found: 'xn--q9jyb4c'");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Duplicate arguments found: 'xn--q9jyb4c'");
|
||||
runCommandForced("xn--q9jyb4c", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_tldDoesNotExist() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "TLD foobarbaz does not exist");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("TLD foobarbaz does not exist");
|
||||
runCommandForced("foobarbaz");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_specifiedDnsWriter_doesntExist() throws Exception {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class, "Invalid DNS writer name(s) specified: [InvalidDnsWriter]");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Invalid DNS writer name(s) specified: [InvalidDnsWriter]");
|
||||
runCommandForced("xn--q9jyb4c", "--dns_writers=InvalidDnsWriter");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_setNonExistentReservedLists() throws Exception {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
"Could not find reserved list xn--q9jyb4c_ZZZ to add to the tld");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Could not find reserved list xn--q9jyb4c_ZZZ to add to the tld");
|
||||
runCommandForced("--reserved_lists", "xn--q9jyb4c_ZZZ", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
|
@ -682,7 +685,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
persistResource(Registry.get("xn--q9jyb4c").asBuilder()
|
||||
.setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2"))
|
||||
.build());
|
||||
thrown.expect(IllegalArgumentException.class, "xn--q9jyb4c_r1");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("xn--q9jyb4c_r1");
|
||||
runCommandForced("--add_reserved_lists=xn--q9jyb4c_r1", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
|
@ -691,13 +695,15 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
persistResource(Registry.get("xn--q9jyb4c").asBuilder()
|
||||
.setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2"))
|
||||
.build());
|
||||
thrown.expect(IllegalArgumentException.class, "xn--q9jyb4c_Z");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("xn--q9jyb4c_Z");
|
||||
runCommandForced("--remove_reserved_lists=xn--q9jyb4c_Z", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_cantAddAndRemoveSameReservedListSimultaneously() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "xn--q9jyb4c_r1");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("xn--q9jyb4c_r1");
|
||||
runCommandForced(
|
||||
"--add_reserved_lists=xn--q9jyb4c_r1",
|
||||
"--remove_reserved_lists=xn--q9jyb4c_r1",
|
||||
|
@ -710,7 +716,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
Registry.get("xn--q9jyb4c").asBuilder()
|
||||
.setAllowedRegistrantContactIds(ImmutableSet.of("alice", "bob"))
|
||||
.build());
|
||||
thrown.expect(IllegalArgumentException.class, "alice");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("alice");
|
||||
runCommandForced("--add_allowed_registrants=alice", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
|
@ -720,13 +727,15 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
Registry.get("xn--q9jyb4c").asBuilder()
|
||||
.setAllowedRegistrantContactIds(ImmutableSet.of("alice"))
|
||||
.build());
|
||||
thrown.expect(IllegalArgumentException.class, "bob");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("bob");
|
||||
runCommandForced("--remove_allowed_registrants=bob", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_cantAddAndRemoveSameAllowedRegistrantsSimultaneously() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "alice");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("alice");
|
||||
runCommandForced(
|
||||
"--add_allowed_registrants=alice",
|
||||
"--remove_allowed_registrants=alice",
|
||||
|
@ -740,7 +749,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
.setAllowedFullyQualifiedHostNames(
|
||||
ImmutableSet.of("ns1.example.com", "ns2.example.com"))
|
||||
.build());
|
||||
thrown.expect(IllegalArgumentException.class, "ns1.example.com");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("ns1.example.com");
|
||||
runCommandForced("--add_allowed_nameservers=ns1.example.com", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
|
@ -751,13 +761,15 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
.setAllowedFullyQualifiedHostNames(
|
||||
ImmutableSet.of("ns1.example.com"))
|
||||
.build());
|
||||
thrown.expect(IllegalArgumentException.class, "ns2.example.com");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("ns2.example.com");
|
||||
runCommandForced("--remove_allowed_nameservers=ns2.example.com", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_cantAddAndRemoveSameAllowedNameserversSimultaneously() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "ns1.example.com");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("ns1.example.com");
|
||||
runCommandForced(
|
||||
"--add_allowed_nameservers=ns1.example.com",
|
||||
"--remove_allowed_nameservers=ns1.example.com",
|
||||
|
@ -882,7 +894,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_setPremiumListThatDoesntExist() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class, "The premium list 'phonies' doesn't exist");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("The premium list 'phonies' doesn't exist");
|
||||
runCommandForced("--premium_list=phonies", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
|
@ -896,15 +909,16 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_updateLrpPeriod_backwardsInterval() throws Exception {
|
||||
thrown.expect(
|
||||
ParameterException.class,
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage(
|
||||
"--lrp_period=2005-06-09T12:30:00Z/2004-07-10T13:30:00Z not an ISO-8601 interval");
|
||||
runCommandForced("--lrp_period=2005-06-09T12:30:00Z/2004-07-10T13:30:00Z", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_updateLrpPeriod_badInterval() throws Exception {
|
||||
thrown.expect(ParameterException.class, "--lrp_period=foobar not an ISO-8601 interval");
|
||||
thrown.expect(ParameterException.class);
|
||||
thrown.expectMessage("--lrp_period=foobar not an ISO-8601 interval");
|
||||
runCommandForced("--lrp_period=foobar", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
|
@ -923,7 +937,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
String reservedLists,
|
||||
Class<? extends Exception> errorClass,
|
||||
String errorMsg) throws Exception {
|
||||
thrown.expect(errorClass, errorMsg);
|
||||
thrown.expect(errorClass);
|
||||
thrown.expectMessage(errorMsg);
|
||||
runCommandForced("--reserved_lists", reservedLists, "xn--q9jyb4c");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue