mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 16:37:13 +02: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:
parent
cb8320ff40
commit
f3a0b78145
62 changed files with 519 additions and 450 deletions
|
@ -481,8 +481,6 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
|
||||
@Test
|
||||
public void testFailure_setCurrentTldState_outOfOrder() throws Exception {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class, "The TLD states are chronologically out of order");
|
||||
persistResource(
|
||||
Registry.get("xn--q9jyb4c").asBuilder()
|
||||
.setTldStateTransitions(
|
||||
|
@ -490,14 +488,13 @@ 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");
|
||||
runCommandForced("--set_current_tld_state=SUNRISE", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_setCurrentTldState_laterTransitionScheduled() throws Exception {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
" when there is a later transition already scheduled");
|
||||
persistResource(
|
||||
Registry.get("xn--q9jyb4c").asBuilder()
|
||||
.setTldStateTransitions(
|
||||
|
@ -505,14 +502,14 @@ 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");
|
||||
runCommandForced("--set_current_tld_state=SUNRISE", "xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_setCurrentTldState_inProduction() throws Exception {
|
||||
thrown.expect(
|
||||
IllegalArgumentException.class,
|
||||
"--set_current_tld_state is not safe to use in production.");
|
||||
persistResource(
|
||||
Registry.get("xn--q9jyb4c").asBuilder()
|
||||
.setTldStateTransitions(
|
||||
|
@ -520,6 +517,9 @@ 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.");
|
||||
runCommandInEnvironment(
|
||||
RegistryToolEnvironment.PRODUCTION,
|
||||
"--set_current_tld_state=SUNRISE",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue