mirror of
https://github.com/google/nomulus
synced 2026-04-29 20:37:13 +00:00
Move thrown.expect() right before the throwing statement
aka regexing for fun and profit.
This also makes sure that there are no statements after the
throwing statement, since these would be dead code. There
were a surprising number of places with assertions after
the throw, and none of these are actually triggered in tests
ever. When I found these, I replaced them with try/catch/rethrow
which makes the assertions actually happen:
before:
// This is the ExceptionRule that checks EppException marshaling
thrown.expect(FooException.class);
doThrowingThing();
assertSomething(); // Dead code!
after:
try {
doThrowingThing();
assertWithMessage("...").fail();
} catch (FooException e) {
assertSomething();
// For EppExceptions:
assertAboutEppExceptins().that(e).marshalsToXml();
}
To make this work, I added EppExceptionSubject.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=135793407
This commit is contained in:
@@ -113,10 +113,10 @@ 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\"))");
|
||||
persistActiveContact("sh8013");
|
||||
runCommand(
|
||||
"agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjItUk9JRAw",
|
||||
"agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjMtUk9JRAw");
|
||||
@@ -159,10 +159,10 @@ 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\"))");
|
||||
persistActiveHost("ns1.example.tld");
|
||||
runCommand(
|
||||
"agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw",
|
||||
"agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjMtUk9JRAw");
|
||||
|
||||
Reference in New Issue
Block a user