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:
mcilwain 2017-12-11 08:47:27 -08:00 committed by jianglai
parent 68a26f5b6e
commit b825a2b5a8
144 changed files with 1176 additions and 894 deletions

View file

@ -68,9 +68,8 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
@Test
public void testFailure_domain_oneDoesNotExist() throws Exception {
persistActiveDomain("example.tld");
thrown.expect(
NullPointerException.class,
"Could not load resource for key: Key<?>(DomainBase(\"4-TLD\"))");
thrown.expect(NullPointerException.class);
thrown.expectMessage("Could not load resource for key: Key<?>(DomainBase(\"4-TLD\"))");
runCommand(
"agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw", "agR0ZXN0chULEgpEb21haW5CYXNlIgU0LVRMRAw");
}
@ -112,9 +111,8 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
@Test
public void testFailure_contact_oneDoesNotExist() throws Exception {
persistActiveContact("sh8013");
thrown.expect(
NullPointerException.class,
"Could not load resource for key: Key<?>(ContactResource(\"3-ROID\"))");
thrown.expect(NullPointerException.class);
thrown.expectMessage("Could not load resource for key: Key<?>(ContactResource(\"3-ROID\"))");
runCommand(
"agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjItUk9JRAw",
"agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjMtUk9JRAw");
@ -157,9 +155,8 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
@Test
public void testFailure_host_oneDoesNotExist() throws Exception {
persistActiveHost("ns1.example.tld");
thrown.expect(
NullPointerException.class,
"Could not load resource for key: Key<?>(HostResource(\"3-ROID\"))");
thrown.expect(NullPointerException.class);
thrown.expectMessage("Could not load resource for key: Key<?>(HostResource(\"3-ROID\"))");
runCommand(
"agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw",
"agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjMtUk9JRAw");
@ -189,15 +186,15 @@ public class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKe
@Test
public void testFailure_keyDoesNotExist() throws Exception {
thrown.expect(
NullPointerException.class,
"Could not load resource for key: Key<?>(DomainBase(\"2-TLD\"))");
thrown.expect(NullPointerException.class);
thrown.expectMessage("Could not load resource for key: Key<?>(DomainBase(\"2-TLD\"))");
runCommand("agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw");
}
@Test
public void testFailure_nonsenseKey() throws Exception {
thrown.expect(IllegalArgumentException.class, "Could not parse Reference");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("Could not parse Reference");
runCommand("agR0ZXN0chULEgpEb21haW5CYXN");
}